require-backend.min.js 941 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493
  1. /*! jQuery v3.7.1 | (c) OpenJS Foundation and other contributors | jquery.org/license */
  2. !function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(ie,e){"use strict";var oe=[],r=Object.getPrototypeOf,ae=oe.slice,g=oe.flat?function(e){return oe.flat.call(e)}:function(e){return oe.concat.apply([],e)},s=oe.push,se=oe.indexOf,n={},i=n.toString,ue=n.hasOwnProperty,o=ue.toString,a=o.call(Object),le={},v=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},y=function(e){return null!=e&&e===e.window},C=ie.document,u={type:!0,src:!0,nonce:!0,noModule:!0};function m(e,t,n){var r,i,o=(n=n||C).createElement("script");if(o.text=e,t)for(r in u)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function x(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[i.call(e)]||"object":typeof e}var t="3.7.1",l=/HTML$/i,ce=function(e,t){return new ce.fn.init(e,t)};function c(e){var t=!!e&&"length"in e&&e.length,n=x(e);return!v(e)&&!y(e)&&("array"===n||0===t||"number"==typeof t&&0<t&&t-1 in e)}function fe(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}ce.fn=ce.prototype={jquery:t,constructor:ce,length:0,toArray:function(){return ae.call(this)},get:function(e){return null==e?ae.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=ce.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return ce.each(this,e)},map:function(n){return this.pushStack(ce.map(this,function(e,t){return n.call(e,t,e)}))},slice:function(){return this.pushStack(ae.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(ce.grep(this,function(e,t){return(t+1)%2}))},odd:function(){return this.pushStack(ce.grep(this,function(e,t){return t%2}))},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(0<=n&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:s,sort:oe.sort,splice:oe.splice},ce.extend=ce.fn.extend=function(){var e,t,n,r,i,o,a=arguments[0]||{},s=1,u=arguments.length,l=!1;for("boolean"==typeof a&&(l=a,a=arguments[s]||{},s++),"object"==typeof a||v(a)||(a={}),s===u&&(a=this,s--);s<u;s++)if(null!=(e=arguments[s]))for(t in e)r=e[t],"__proto__"!==t&&a!==r&&(l&&r&&(ce.isPlainObject(r)||(i=Array.isArray(r)))?(n=a[t],o=i&&!Array.isArray(n)?[]:i||ce.isPlainObject(n)?n:{},i=!1,a[t]=ce.extend(l,o,r)):void 0!==r&&(a[t]=r));return a},ce.extend({expando:"jQuery"+(t+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==i.call(e))&&(!(t=r(e))||"function"==typeof(n=ue.call(t,"constructor")&&t.constructor)&&o.call(n)===a)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},globalEval:function(e,t,n){m(e,{nonce:t&&t.nonce},n)},each:function(e,t){var n,r=0;if(c(e)){for(n=e.length;r<n;r++)if(!1===t.call(e[r],r,e[r]))break}else for(r in e)if(!1===t.call(e[r],r,e[r]))break;return e},text:function(e){var t,n="",r=0,i=e.nodeType;if(!i)while(t=e[r++])n+=ce.text(t);return 1===i||11===i?e.textContent:9===i?e.documentElement.textContent:3===i||4===i?e.nodeValue:n},makeArray:function(e,t){var n=t||[];return null!=e&&(c(Object(e))?ce.merge(n,"string"==typeof e?[e]:e):s.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:se.call(t,e,n)},isXMLDoc:function(e){var t=e&&e.namespaceURI,n=e&&(e.ownerDocument||e).documentElement;return!l.test(t||n&&n.nodeName||"HTML")},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;r<n;r++)e[i++]=t[r];return e.length=i,e},grep:function(e,t,n){for(var r=[],i=0,o=e.length,a=!n;i<o;i++)!t(e[i],i)!==a&&r.push(e[i]);return r},map:function(e,t,n){var r,i,o=0,a=[];if(c(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&a.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&a.push(i);return g(a)},guid:1,support:le}),"function"==typeof Symbol&&(ce.fn[Symbol.iterator]=oe[Symbol.iterator]),ce.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){n["[object "+t+"]"]=t.toLowerCase()});var pe=oe.pop,de=oe.sort,he=oe.splice,ge="[\\x20\\t\\r\\n\\f]",ve=new RegExp("^"+ge+"+|((?:^|[^\\\\])(?:\\\\.)*)"+ge+"+$","g");ce.contains=function(e,t){var n=t&&t.parentNode;return e===n||!(!n||1!==n.nodeType||!(e.contains?e.contains(n):e.compareDocumentPosition&&16&e.compareDocumentPosition(n)))};var f=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;function p(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e}ce.escapeSelector=function(e){return(e+"").replace(f,p)};var ye=C,me=s;!function(){var e,b,w,o,a,T,r,C,d,i,k=me,S=ce.expando,E=0,n=0,s=W(),c=W(),u=W(),h=W(),l=function(e,t){return e===t&&(a=!0),0},f="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",t="(?:\\\\[\\da-fA-F]{1,6}"+ge+"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",p="\\["+ge+"*("+t+")(?:"+ge+"*([*^$|!~]?=)"+ge+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+t+"))|)"+ge+"*\\]",g=":("+t+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+p+")*)|.*)\\)|)",v=new RegExp(ge+"+","g"),y=new RegExp("^"+ge+"*,"+ge+"*"),m=new RegExp("^"+ge+"*([>+~]|"+ge+")"+ge+"*"),x=new RegExp(ge+"|>"),j=new RegExp(g),A=new RegExp("^"+t+"$"),D={ID:new RegExp("^#("+t+")"),CLASS:new RegExp("^\\.("+t+")"),TAG:new RegExp("^("+t+"|[*])"),ATTR:new RegExp("^"+p),PSEUDO:new RegExp("^"+g),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+ge+"*(even|odd|(([+-]|)(\\d*)n|)"+ge+"*(?:([+-]|)"+ge+"*(\\d+)|))"+ge+"*\\)|)","i"),bool:new RegExp("^(?:"+f+")$","i"),needsContext:new RegExp("^"+ge+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+ge+"*((?:-\\d)?\\d*)"+ge+"*\\)|)(?=[^-]|$)","i")},N=/^(?:input|select|textarea|button)$/i,q=/^h\d$/i,L=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,H=/[+~]/,O=new RegExp("\\\\[\\da-fA-F]{1,6}"+ge+"?|\\\\([^\\r\\n\\f])","g"),P=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},M=function(){V()},R=J(function(e){return!0===e.disabled&&fe(e,"fieldset")},{dir:"parentNode",next:"legend"});try{k.apply(oe=ae.call(ye.childNodes),ye.childNodes),oe[ye.childNodes.length].nodeType}catch(e){k={apply:function(e,t){me.apply(e,ae.call(t))},call:function(e){me.apply(e,ae.call(arguments,1))}}}function I(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&(V(e),e=e||T,C)){if(11!==p&&(u=L.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return k.call(n,a),n}else if(f&&(a=f.getElementById(i))&&I.contains(e,a)&&a.id===i)return k.call(n,a),n}else{if(u[2])return k.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&e.getElementsByClassName)return k.apply(n,e.getElementsByClassName(i)),n}if(!(h[t+" "]||d&&d.test(t))){if(c=t,f=e,1===p&&(x.test(t)||m.test(t))){(f=H.test(t)&&U(e.parentNode)||e)==e&&le.scope||((s=e.getAttribute("id"))?s=ce.escapeSelector(s):e.setAttribute("id",s=S)),o=(l=Y(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+Q(l[o]);c=l.join(",")}try{return k.apply(n,f.querySelectorAll(c)),n}catch(e){h(t,!0)}finally{s===S&&e.removeAttribute("id")}}}return re(t.replace(ve,"$1"),e,n,r)}function W(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function F(e){return e[S]=!0,e}function $(e){var t=T.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function B(t){return function(e){return fe(e,"input")&&e.type===t}}function _(t){return function(e){return(fe(e,"input")||fe(e,"button"))&&e.type===t}}function z(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&R(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function X(a){return F(function(o){return o=+o,F(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function U(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}function V(e){var t,n=e?e.ownerDocument||e:ye;return n!=T&&9===n.nodeType&&n.documentElement&&(r=(T=n).documentElement,C=!ce.isXMLDoc(T),i=r.matches||r.webkitMatchesSelector||r.msMatchesSelector,r.msMatchesSelector&&ye!=T&&(t=T.defaultView)&&t.top!==t&&t.addEventListener("unload",M),le.getById=$(function(e){return r.appendChild(e).id=ce.expando,!T.getElementsByName||!T.getElementsByName(ce.expando).length}),le.disconnectedMatch=$(function(e){return i.call(e,"*")}),le.scope=$(function(){return T.querySelectorAll(":scope")}),le.cssHas=$(function(){try{return T.querySelector(":has(*,:jqfake)"),!1}catch(e){return!0}}),le.getById?(b.filter.ID=function(e){var t=e.replace(O,P);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&C){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(O,P);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&C){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):t.querySelectorAll(e)},b.find.CLASS=function(e,t){if("undefined"!=typeof t.getElementsByClassName&&C)return t.getElementsByClassName(e)},d=[],$(function(e){var t;r.appendChild(e).innerHTML="<a id='"+S+"' href='' disabled='disabled'></a><select id='"+S+"-\r\\' disabled='disabled'><option selected=''></option></select>",e.querySelectorAll("[selected]").length||d.push("\\["+ge+"*(?:value|"+f+")"),e.querySelectorAll("[id~="+S+"-]").length||d.push("~="),e.querySelectorAll("a#"+S+"+*").length||d.push(".#.+[+~]"),e.querySelectorAll(":checked").length||d.push(":checked"),(t=T.createElement("input")).setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),r.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&d.push(":enabled",":disabled"),(t=T.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||d.push("\\["+ge+"*name"+ge+"*="+ge+"*(?:''|\"\")")}),le.cssHas||d.push(":has"),d=d.length&&new RegExp(d.join("|")),l=function(e,t){if(e===t)return a=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!le.sortDetached&&t.compareDocumentPosition(e)===n?e===T||e.ownerDocument==ye&&I.contains(ye,e)?-1:t===T||t.ownerDocument==ye&&I.contains(ye,t)?1:o?se.call(o,e)-se.call(o,t):0:4&n?-1:1)}),T}for(e in I.matches=function(e,t){return I(e,null,null,t)},I.matchesSelector=function(e,t){if(V(e),C&&!h[t+" "]&&(!d||!d.test(t)))try{var n=i.call(e,t);if(n||le.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){h(t,!0)}return 0<I(t,T,null,[e]).length},I.contains=function(e,t){return(e.ownerDocument||e)!=T&&V(e),ce.contains(e,t)},I.attr=function(e,t){(e.ownerDocument||e)!=T&&V(e);var n=b.attrHandle[t.toLowerCase()],r=n&&ue.call(b.attrHandle,t.toLowerCase())?n(e,t,!C):void 0;return void 0!==r?r:e.getAttribute(t)},I.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},ce.uniqueSort=function(e){var t,n=[],r=0,i=0;if(a=!le.sortStable,o=!le.sortStable&&ae.call(e,0),de.call(e,l),a){while(t=e[i++])t===e[i]&&(r=n.push(i));while(r--)he.call(e,n[r],1)}return o=null,e},ce.fn.uniqueSort=function(){return this.pushStack(ce.uniqueSort(ae.apply(this)))},(b=ce.expr={cacheLength:50,createPseudo:F,match:D,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(O,P),e[3]=(e[3]||e[4]||e[5]||"").replace(O,P),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||I.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&I.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return D.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&j.test(n)&&(t=Y(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(O,P).toLowerCase();return"*"===e?function(){return!0}:function(e){return fe(e,t)}},CLASS:function(e){var t=s[e+" "];return t||(t=new RegExp("(^|"+ge+")"+e+"("+ge+"|$)"))&&s(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=I.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1<t.indexOf(i):"$="===r?i&&t.slice(-i.length)===i:"~="===r?-1<(" "+t.replace(v," ")+" ").indexOf(i):"|="===r&&(t===i||t.slice(0,i.length+1)===i+"-"))}},CHILD:function(d,e,t,h,g){var v="nth"!==d.slice(0,3),y="last"!==d.slice(-4),m="of-type"===e;return 1===h&&0===g?function(e){return!!e.parentNode}:function(e,t,n){var r,i,o,a,s,u=v!==y?"nextSibling":"previousSibling",l=e.parentNode,c=m&&e.nodeName.toLowerCase(),f=!n&&!m,p=!1;if(l){if(v){while(u){o=e;while(o=o[u])if(m?fe(o,c):1===o.nodeType)return!1;s=u="only"===d&&!s&&"nextSibling"}return!0}if(s=[y?l.firstChild:l.lastChild],y&&f){p=(a=(r=(i=l[S]||(l[S]={}))[d]||[])[0]===E&&r[1])&&r[2],o=a&&l.childNodes[a];while(o=++a&&o&&o[u]||(p=a=0)||s.pop())if(1===o.nodeType&&++p&&o===e){i[d]=[E,a,p];break}}else if(f&&(p=a=(r=(i=e[S]||(e[S]={}))[d]||[])[0]===E&&r[1]),!1===p)while(o=++a&&o&&o[u]||(p=a=0)||s.pop())if((m?fe(o,c):1===o.nodeType)&&++p&&(f&&((i=o[S]||(o[S]={}))[d]=[E,p]),o===e))break;return(p-=g)===h||p%h==0&&0<=p/h}}},PSEUDO:function(e,o){var t,a=b.pseudos[e]||b.setFilters[e.toLowerCase()]||I.error("unsupported pseudo: "+e);return a[S]?a(o):1<a.length?(t=[e,e,"",o],b.setFilters.hasOwnProperty(e.toLowerCase())?F(function(e,t){var n,r=a(e,o),i=r.length;while(i--)e[n=se.call(e,r[i])]=!(t[n]=r[i])}):function(e){return a(e,0,t)}):a}},pseudos:{not:F(function(e){var r=[],i=[],s=ne(e.replace(ve,"$1"));return s[S]?F(function(e,t,n,r){var i,o=s(e,null,r,[]),a=e.length;while(a--)(i=o[a])&&(e[a]=!(t[a]=i))}):function(e,t,n){return r[0]=e,s(r,null,n,i),r[0]=null,!i.pop()}}),has:F(function(t){return function(e){return 0<I(t,e).length}}),contains:F(function(t){return t=t.replace(O,P),function(e){return-1<(e.textContent||ce.text(e)).indexOf(t)}}),lang:F(function(n){return A.test(n||"")||I.error("unsupported lang: "+n),n=n.replace(O,P).toLowerCase(),function(e){var t;do{if(t=C?e.lang:e.getAttribute("xml:lang")||e.getAttribute("lang"))return(t=t.toLowerCase())===n||0===t.indexOf(n+"-")}while((e=e.parentNode)&&1===e.nodeType);return!1}}),target:function(e){var t=ie.location&&ie.location.hash;return t&&t.slice(1)===e.id},root:function(e){return e===r},focus:function(e){return e===function(){try{return T.activeElement}catch(e){}}()&&T.hasFocus()&&!!(e.type||e.href||~e.tabIndex)},enabled:z(!1),disabled:z(!0),checked:function(e){return fe(e,"input")&&!!e.checked||fe(e,"option")&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!b.pseudos.empty(e)},header:function(e){return q.test(e.nodeName)},input:function(e){return N.test(e.nodeName)},button:function(e){return fe(e,"input")&&"button"===e.type||fe(e,"button")},text:function(e){var t;return fe(e,"input")&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:X(function(){return[0]}),last:X(function(e,t){return[t-1]}),eq:X(function(e,t,n){return[n<0?n+t:n]}),even:X(function(e,t){for(var n=0;n<t;n+=2)e.push(n);return e}),odd:X(function(e,t){for(var n=1;n<t;n+=2)e.push(n);return e}),lt:X(function(e,t,n){var r;for(r=n<0?n+t:t<n?t:n;0<=--r;)e.push(r);return e}),gt:X(function(e,t,n){for(var r=n<0?n+t:n;++r<t;)e.push(r);return e})}}).pseudos.nth=b.pseudos.eq,{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})b.pseudos[e]=B(e);for(e in{submit:!0,reset:!0})b.pseudos[e]=_(e);function G(){}function Y(e,t){var n,r,i,o,a,s,u,l=c[e+" "];if(l)return t?0:l.slice(0);a=e,s=[],u=b.preFilter;while(a){for(o in n&&!(r=y.exec(a))||(r&&(a=a.slice(r[0].length)||a),s.push(i=[])),n=!1,(r=m.exec(a))&&(n=r.shift(),i.push({value:n,type:r[0].replace(ve," ")}),a=a.slice(n.length)),b.filter)!(r=D[o].exec(a))||u[o]&&!(r=u[o](r))||(n=r.shift(),i.push({value:n,type:o,matches:r}),a=a.slice(n.length));if(!n)break}return t?a.length:a?I.error(e):c(e,s).slice(0)}function Q(e){for(var t=0,n=e.length,r="";t<n;t++)r+=e[t].value;return r}function J(a,e,t){var s=e.dir,u=e.next,l=u||s,c=t&&"parentNode"===l,f=n++;return e.first?function(e,t,n){while(e=e[s])if(1===e.nodeType||c)return a(e,t,n);return!1}:function(e,t,n){var r,i,o=[E,f];if(n){while(e=e[s])if((1===e.nodeType||c)&&a(e,t,n))return!0}else while(e=e[s])if(1===e.nodeType||c)if(i=e[S]||(e[S]={}),u&&fe(e,u))e=e[s]||e;else{if((r=i[l])&&r[0]===E&&r[1]===f)return o[2]=r[2];if((i[l]=o)[2]=a(e,t,n))return!0}return!1}}function K(i){return 1<i.length?function(e,t,n){var r=i.length;while(r--)if(!i[r](e,t,n))return!1;return!0}:i[0]}function Z(e,t,n,r,i){for(var o,a=[],s=0,u=e.length,l=null!=t;s<u;s++)(o=e[s])&&(n&&!n(o,r,i)||(a.push(o),l&&t.push(s)));return a}function ee(d,h,g,v,y,e){return v&&!v[S]&&(v=ee(v)),y&&!y[S]&&(y=ee(y,e)),F(function(e,t,n,r){var i,o,a,s,u=[],l=[],c=t.length,f=e||function(e,t,n){for(var r=0,i=t.length;r<i;r++)I(e,t[r],n);return n}(h||"*",n.nodeType?[n]:n,[]),p=!d||!e&&h?f:Z(f,u,d,n,r);if(g?g(p,s=y||(e?d:c||v)?[]:t,n,r):s=p,v){i=Z(s,l),v(i,[],n,r),o=i.length;while(o--)(a=i[o])&&(s[l[o]]=!(p[l[o]]=a))}if(e){if(y||d){if(y){i=[],o=s.length;while(o--)(a=s[o])&&i.push(p[o]=a);y(null,s=[],i,r)}o=s.length;while(o--)(a=s[o])&&-1<(i=y?se.call(e,a):u[o])&&(e[i]=!(t[i]=a))}}else s=Z(s===t?s.splice(c,s.length):s),y?y(null,t,s,r):k.apply(t,s)})}function te(e){for(var i,t,n,r=e.length,o=b.relative[e[0].type],a=o||b.relative[" "],s=o?1:0,u=J(function(e){return e===i},a,!0),l=J(function(e){return-1<se.call(i,e)},a,!0),c=[function(e,t,n){var r=!o&&(n||t!=w)||((i=t).nodeType?u(e,t,n):l(e,t,n));return i=null,r}];s<r;s++)if(t=b.relative[e[s].type])c=[J(K(c),t)];else{if((t=b.filter[e[s].type].apply(null,e[s].matches))[S]){for(n=++s;n<r;n++)if(b.relative[e[n].type])break;return ee(1<s&&K(c),1<s&&Q(e.slice(0,s-1).concat({value:" "===e[s-2].type?"*":""})).replace(ve,"$1"),t,s<n&&te(e.slice(s,n)),n<r&&te(e=e.slice(n)),n<r&&Q(e))}c.push(t)}return K(c)}function ne(e,t){var n,v,y,m,x,r,i=[],o=[],a=u[e+" "];if(!a){t||(t=Y(e)),n=t.length;while(n--)(a=te(t[n]))[S]?i.push(a):o.push(a);(a=u(e,(v=o,m=0<(y=i).length,x=0<v.length,r=function(e,t,n,r,i){var o,a,s,u=0,l="0",c=e&&[],f=[],p=w,d=e||x&&b.find.TAG("*",i),h=E+=null==p?1:Math.random()||.1,g=d.length;for(i&&(w=t==T||t||i);l!==g&&null!=(o=d[l]);l++){if(x&&o){a=0,t||o.ownerDocument==T||(V(o),n=!C);while(s=v[a++])if(s(o,t||T,n)){k.call(r,o);break}i&&(E=h)}m&&((o=!s&&o)&&u--,e&&c.push(o))}if(u+=l,m&&l!==u){a=0;while(s=y[a++])s(c,f,t,n);if(e){if(0<u)while(l--)c[l]||f[l]||(f[l]=pe.call(r));f=Z(f)}k.apply(r,f),i&&!e&&0<f.length&&1<u+y.length&&ce.uniqueSort(r)}return i&&(E=h,w=p),c},m?F(r):r))).selector=e}return a}function re(e,t,n,r){var i,o,a,s,u,l="function"==typeof e&&e,c=!r&&Y(e=l.selector||e);if(n=n||[],1===c.length){if(2<(o=c[0]=c[0].slice(0)).length&&"ID"===(a=o[0]).type&&9===t.nodeType&&C&&b.relative[o[1].type]){if(!(t=(b.find.ID(a.matches[0].replace(O,P),t)||[])[0]))return n;l&&(t=t.parentNode),e=e.slice(o.shift().value.length)}i=D.needsContext.test(e)?0:o.length;while(i--){if(a=o[i],b.relative[s=a.type])break;if((u=b.find[s])&&(r=u(a.matches[0].replace(O,P),H.test(o[0].type)&&U(t.parentNode)||t))){if(o.splice(i,1),!(e=r.length&&Q(o)))return k.apply(n,r),n;break}}}return(l||ne(e,c))(r,t,!C,n,!t||H.test(e)&&U(t.parentNode)||t),n}G.prototype=b.filters=b.pseudos,b.setFilters=new G,le.sortStable=S.split("").sort(l).join("")===S,V(),le.sortDetached=$(function(e){return 1&e.compareDocumentPosition(T.createElement("fieldset"))}),ce.find=I,ce.expr[":"]=ce.expr.pseudos,ce.unique=ce.uniqueSort,I.compile=ne,I.select=re,I.setDocument=V,I.tokenize=Y,I.escape=ce.escapeSelector,I.getText=ce.text,I.isXML=ce.isXMLDoc,I.selectors=ce.expr,I.support=ce.support,I.uniqueSort=ce.uniqueSort}();var d=function(e,t,n){var r=[],i=void 0!==n;while((e=e[t])&&9!==e.nodeType)if(1===e.nodeType){if(i&&ce(e).is(n))break;r.push(e)}return r},h=function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n},b=ce.expr.match.needsContext,w=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function T(e,n,r){return v(n)?ce.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?ce.grep(e,function(e){return e===n!==r}):"string"!=typeof n?ce.grep(e,function(e){return-1<se.call(n,e)!==r}):ce.filter(n,e,r)}ce.filter=function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?ce.find.matchesSelector(r,e)?[r]:[]:ce.find.matches(e,ce.grep(t,function(e){return 1===e.nodeType}))},ce.fn.extend({find:function(e){var t,n,r=this.length,i=this;if("string"!=typeof e)return this.pushStack(ce(e).filter(function(){for(t=0;t<r;t++)if(ce.contains(i[t],this))return!0}));for(n=this.pushStack([]),t=0;t<r;t++)ce.find(e,i[t],n);return 1<r?ce.uniqueSort(n):n},filter:function(e){return this.pushStack(T(this,e||[],!1))},not:function(e){return this.pushStack(T(this,e||[],!0))},is:function(e){return!!T(this,"string"==typeof e&&b.test(e)?ce(e):e||[],!1).length}});var k,S=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(ce.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||k,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:S.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof ce?t[0]:t,ce.merge(this,ce.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:C,!0)),w.test(r[1])&&ce.isPlainObject(t))for(r in t)v(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=C.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):v(e)?void 0!==n.ready?n.ready(e):e(ce):ce.makeArray(e,this)}).prototype=ce.fn,k=ce(C);var E=/^(?:parents|prev(?:Until|All))/,j={children:!0,contents:!0,next:!0,prev:!0};function A(e,t){while((e=e[t])&&1!==e.nodeType);return e}ce.fn.extend({has:function(e){var t=ce(e,this),n=t.length;return this.filter(function(){for(var e=0;e<n;e++)if(ce.contains(this,t[e]))return!0})},closest:function(e,t){var n,r=0,i=this.length,o=[],a="string"!=typeof e&&ce(e);if(!b.test(e))for(;r<i;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(n.nodeType<11&&(a?-1<a.index(n):1===n.nodeType&&ce.find.matchesSelector(n,e))){o.push(n);break}return this.pushStack(1<o.length?ce.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?se.call(ce(e),this[0]):se.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(ce.uniqueSort(ce.merge(this.get(),ce(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),ce.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return d(e,"parentNode")},parentsUntil:function(e,t,n){return d(e,"parentNode",n)},next:function(e){return A(e,"nextSibling")},prev:function(e){return A(e,"previousSibling")},nextAll:function(e){return d(e,"nextSibling")},prevAll:function(e){return d(e,"previousSibling")},nextUntil:function(e,t,n){return d(e,"nextSibling",n)},prevUntil:function(e,t,n){return d(e,"previousSibling",n)},siblings:function(e){return h((e.parentNode||{}).firstChild,e)},children:function(e){return h(e.firstChild)},contents:function(e){return null!=e.contentDocument&&r(e.contentDocument)?e.contentDocument:(fe(e,"template")&&(e=e.content||e),ce.merge([],e.childNodes))}},function(r,i){ce.fn[r]=function(e,t){var n=ce.map(this,i,e);return"Until"!==r.slice(-5)&&(t=e),t&&"string"==typeof t&&(n=ce.filter(t,n)),1<this.length&&(j[r]||ce.uniqueSort(n),E.test(r)&&n.reverse()),this.pushStack(n)}});var D=/[^\x20\t\r\n\f]+/g;function N(e){return e}function q(e){throw e}function L(e,t,n,r){var i;try{e&&v(i=e.promise)?i.call(e).done(t).fail(n):e&&v(i=e.then)?i.call(e,t,n):t.apply(void 0,[e].slice(r))}catch(e){n.apply(void 0,[e])}}ce.Callbacks=function(r){var e,n;r="string"==typeof r?(e=r,n={},ce.each(e.match(D)||[],function(e,t){n[t]=!0}),n):ce.extend({},r);var i,t,o,a,s=[],u=[],l=-1,c=function(){for(a=a||r.once,o=i=!0;u.length;l=-1){t=u.shift();while(++l<s.length)!1===s[l].apply(t[0],t[1])&&r.stopOnFalse&&(l=s.length,t=!1)}r.memory||(t=!1),i=!1,a&&(s=t?[]:"")},f={add:function(){return s&&(t&&!i&&(l=s.length-1,u.push(t)),function n(e){ce.each(e,function(e,t){v(t)?r.unique&&f.has(t)||s.push(t):t&&t.length&&"string"!==x(t)&&n(t)})}(arguments),t&&!i&&c()),this},remove:function(){return ce.each(arguments,function(e,t){var n;while(-1<(n=ce.inArray(t,s,n)))s.splice(n,1),n<=l&&l--}),this},has:function(e){return e?-1<ce.inArray(e,s):0<s.length},empty:function(){return s&&(s=[]),this},disable:function(){return a=u=[],s=t="",this},disabled:function(){return!s},lock:function(){return a=u=[],t||i||(s=t=""),this},locked:function(){return!!a},fireWith:function(e,t){return a||(t=[e,(t=t||[]).slice?t.slice():t],u.push(t),i||c()),this},fire:function(){return f.fireWith(this,arguments),this},fired:function(){return!!o}};return f},ce.extend({Deferred:function(e){var o=[["notify","progress",ce.Callbacks("memory"),ce.Callbacks("memory"),2],["resolve","done",ce.Callbacks("once memory"),ce.Callbacks("once memory"),0,"resolved"],["reject","fail",ce.Callbacks("once memory"),ce.Callbacks("once memory"),1,"rejected"]],i="pending",a={state:function(){return i},always:function(){return s.done(arguments).fail(arguments),this},"catch":function(e){return a.then(null,e)},pipe:function(){var i=arguments;return ce.Deferred(function(r){ce.each(o,function(e,t){var n=v(i[t[4]])&&i[t[4]];s[t[1]](function(){var e=n&&n.apply(this,arguments);e&&v(e.promise)?e.promise().progress(r.notify).done(r.resolve).fail(r.reject):r[t[0]+"With"](this,n?[e]:arguments)})}),i=null}).promise()},then:function(t,n,r){var u=0;function l(i,o,a,s){return function(){var n=this,r=arguments,e=function(){var e,t;if(!(i<u)){if((e=a.apply(n,r))===o.promise())throw new TypeError("Thenable self-resolution");t=e&&("object"==typeof e||"function"==typeof e)&&e.then,v(t)?s?t.call(e,l(u,o,N,s),l(u,o,q,s)):(u++,t.call(e,l(u,o,N,s),l(u,o,q,s),l(u,o,N,o.notifyWith))):(a!==N&&(n=void 0,r=[e]),(s||o.resolveWith)(n,r))}},t=s?e:function(){try{e()}catch(e){ce.Deferred.exceptionHook&&ce.Deferred.exceptionHook(e,t.error),u<=i+1&&(a!==q&&(n=void 0,r=[e]),o.rejectWith(n,r))}};i?t():(ce.Deferred.getErrorHook?t.error=ce.Deferred.getErrorHook():ce.Deferred.getStackHook&&(t.error=ce.Deferred.getStackHook()),ie.setTimeout(t))}}return ce.Deferred(function(e){o[0][3].add(l(0,e,v(r)?r:N,e.notifyWith)),o[1][3].add(l(0,e,v(t)?t:N)),o[2][3].add(l(0,e,v(n)?n:q))}).promise()},promise:function(e){return null!=e?ce.extend(e,a):a}},s={};return ce.each(o,function(e,t){var n=t[2],r=t[5];a[t[1]]=n.add,r&&n.add(function(){i=r},o[3-e][2].disable,o[3-e][3].disable,o[0][2].lock,o[0][3].lock),n.add(t[3].fire),s[t[0]]=function(){return s[t[0]+"With"](this===s?void 0:this,arguments),this},s[t[0]+"With"]=n.fireWith}),a.promise(s),e&&e.call(s,s),s},when:function(e){var n=arguments.length,t=n,r=Array(t),i=ae.call(arguments),o=ce.Deferred(),a=function(t){return function(e){r[t]=this,i[t]=1<arguments.length?ae.call(arguments):e,--n||o.resolveWith(r,i)}};if(n<=1&&(L(e,o.done(a(t)).resolve,o.reject,!n),"pending"===o.state()||v(i[t]&&i[t].then)))return o.then();while(t--)L(i[t],a(t),o.reject);return o.promise()}});var H=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;ce.Deferred.exceptionHook=function(e,t){ie.console&&ie.console.warn&&e&&H.test(e.name)&&ie.console.warn("jQuery.Deferred exception: "+e.message,e.stack,t)},ce.readyException=function(e){ie.setTimeout(function(){throw e})};var O=ce.Deferred();function P(){C.removeEventListener("DOMContentLoaded",P),ie.removeEventListener("load",P),ce.ready()}ce.fn.ready=function(e){return O.then(e)["catch"](function(e){ce.readyException(e)}),this},ce.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--ce.readyWait:ce.isReady)||(ce.isReady=!0)!==e&&0<--ce.readyWait||O.resolveWith(C,[ce])}}),ce.ready.then=O.then,"complete"===C.readyState||"loading"!==C.readyState&&!C.documentElement.doScroll?ie.setTimeout(ce.ready):(C.addEventListener("DOMContentLoaded",P),ie.addEventListener("load",P));var M=function(e,t,n,r,i,o,a){var s=0,u=e.length,l=null==n;if("object"===x(n))for(s in i=!0,n)M(e,t,s,n[s],!0,o,a);else if(void 0!==r&&(i=!0,v(r)||(a=!0),l&&(a?(t.call(e,r),t=null):(l=t,t=function(e,t,n){return l.call(ce(e),n)})),t))for(;s<u;s++)t(e[s],n,a?r:r.call(e[s],s,t(e[s],n)));return i?e:l?t.call(e):u?t(e[0],n):o},R=/^-ms-/,I=/-([a-z])/g;function W(e,t){return t.toUpperCase()}function F(e){return e.replace(R,"ms-").replace(I,W)}var $=function(e){return 1===e.nodeType||9===e.nodeType||!+e.nodeType};function B(){this.expando=ce.expando+B.uid++}B.uid=1,B.prototype={cache:function(e){var t=e[this.expando];return t||(t={},$(e)&&(e.nodeType?e[this.expando]=t:Object.defineProperty(e,this.expando,{value:t,configurable:!0}))),t},set:function(e,t,n){var r,i=this.cache(e);if("string"==typeof t)i[F(t)]=n;else for(r in t)i[F(r)]=t[r];return i},get:function(e,t){return void 0===t?this.cache(e):e[this.expando]&&e[this.expando][F(t)]},access:function(e,t,n){return void 0===t||t&&"string"==typeof t&&void 0===n?this.get(e,t):(this.set(e,t,n),void 0!==n?n:t)},remove:function(e,t){var n,r=e[this.expando];if(void 0!==r){if(void 0!==t){n=(t=Array.isArray(t)?t.map(F):(t=F(t))in r?[t]:t.match(D)||[]).length;while(n--)delete r[t[n]]}(void 0===t||ce.isEmptyObject(r))&&(e.nodeType?e[this.expando]=void 0:delete e[this.expando])}},hasData:function(e){var t=e[this.expando];return void 0!==t&&!ce.isEmptyObject(t)}};var _=new B,z=new B,X=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,U=/[A-Z]/g;function V(e,t,n){var r,i;if(void 0===n&&1===e.nodeType)if(r="data-"+t.replace(U,"-$&").toLowerCase(),"string"==typeof(n=e.getAttribute(r))){try{n="true"===(i=n)||"false"!==i&&("null"===i?null:i===+i+""?+i:X.test(i)?JSON.parse(i):i)}catch(e){}z.set(e,t,n)}else n=void 0;return n}ce.extend({hasData:function(e){return z.hasData(e)||_.hasData(e)},data:function(e,t,n){return z.access(e,t,n)},removeData:function(e,t){z.remove(e,t)},_data:function(e,t,n){return _.access(e,t,n)},_removeData:function(e,t){_.remove(e,t)}}),ce.fn.extend({data:function(n,e){var t,r,i,o=this[0],a=o&&o.attributes;if(void 0===n){if(this.length&&(i=z.get(o),1===o.nodeType&&!_.get(o,"hasDataAttrs"))){t=a.length;while(t--)a[t]&&0===(r=a[t].name).indexOf("data-")&&(r=F(r.slice(5)),V(o,r,i[r]));_.set(o,"hasDataAttrs",!0)}return i}return"object"==typeof n?this.each(function(){z.set(this,n)}):M(this,function(e){var t;if(o&&void 0===e)return void 0!==(t=z.get(o,n))?t:void 0!==(t=V(o,n))?t:void 0;this.each(function(){z.set(this,n,e)})},null,e,1<arguments.length,null,!0)},removeData:function(e){return this.each(function(){z.remove(this,e)})}}),ce.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=_.get(e,t),n&&(!r||Array.isArray(n)?r=_.access(e,t,ce.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=ce.queue(e,t),r=n.length,i=n.shift(),o=ce._queueHooks(e,t);"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,function(){ce.dequeue(e,t)},o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return _.get(e,n)||_.access(e,n,{empty:ce.Callbacks("once memory").add(function(){_.remove(e,[t+"queue",n])})})}}),ce.fn.extend({queue:function(t,n){var e=2;return"string"!=typeof t&&(n=t,t="fx",e--),arguments.length<e?ce.queue(this[0],t):void 0===n?this:this.each(function(){var e=ce.queue(this,t,n);ce._queueHooks(this,t),"fx"===t&&"inprogress"!==e[0]&&ce.dequeue(this,t)})},dequeue:function(e){return this.each(function(){ce.dequeue(this,e)})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,t){var n,r=1,i=ce.Deferred(),o=this,a=this.length,s=function(){--r||i.resolveWith(o,[o])};"string"!=typeof e&&(t=e,e=void 0),e=e||"fx";while(a--)(n=_.get(o[a],e+"queueHooks"))&&n.empty&&(r++,n.empty.add(s));return s(),i.promise(t)}});var G=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,Y=new RegExp("^(?:([+-])=|)("+G+")([a-z%]*)$","i"),Q=["Top","Right","Bottom","Left"],J=C.documentElement,K=function(e){return ce.contains(e.ownerDocument,e)},Z={composed:!0};J.getRootNode&&(K=function(e){return ce.contains(e.ownerDocument,e)||e.getRootNode(Z)===e.ownerDocument});var ee=function(e,t){return"none"===(e=t||e).style.display||""===e.style.display&&K(e)&&"none"===ce.css(e,"display")};function te(e,t,n,r){var i,o,a=20,s=r?function(){return r.cur()}:function(){return ce.css(e,t,"")},u=s(),l=n&&n[3]||(ce.cssNumber[t]?"":"px"),c=e.nodeType&&(ce.cssNumber[t]||"px"!==l&&+u)&&Y.exec(ce.css(e,t));if(c&&c[3]!==l){u/=2,l=l||c[3],c=+u||1;while(a--)ce.style(e,t,c+l),(1-o)*(1-(o=s()/u||.5))<=0&&(a=0),c/=o;c*=2,ce.style(e,t,c+l),n=n||[]}return n&&(c=+c||+u||0,i=n[1]?c+(n[1]+1)*n[2]:+n[2],r&&(r.unit=l,r.start=c,r.end=i)),i}var ne={};function re(e,t){for(var n,r,i,o,a,s,u,l=[],c=0,f=e.length;c<f;c++)(r=e[c]).style&&(n=r.style.display,t?("none"===n&&(l[c]=_.get(r,"display")||null,l[c]||(r.style.display="")),""===r.style.display&&ee(r)&&(l[c]=(u=a=o=void 0,a=(i=r).ownerDocument,s=i.nodeName,(u=ne[s])||(o=a.body.appendChild(a.createElement(s)),u=ce.css(o,"display"),o.parentNode.removeChild(o),"none"===u&&(u="block"),ne[s]=u)))):"none"!==n&&(l[c]="none",_.set(r,"display",n)));for(c=0;c<f;c++)null!=l[c]&&(e[c].style.display=l[c]);return e}ce.fn.extend({show:function(){return re(this,!0)},hide:function(){return re(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){ee(this)?ce(this).show():ce(this).hide()})}});var xe,be,we=/^(?:checkbox|radio)$/i,Te=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i,Ce=/^$|^module$|\/(?:java|ecma)script/i;xe=C.createDocumentFragment().appendChild(C.createElement("div")),(be=C.createElement("input")).setAttribute("type","radio"),be.setAttribute("checked","checked"),be.setAttribute("name","t"),xe.appendChild(be),le.checkClone=xe.cloneNode(!0).cloneNode(!0).lastChild.checked,xe.innerHTML="<textarea>x</textarea>",le.noCloneChecked=!!xe.cloneNode(!0).lastChild.defaultValue,xe.innerHTML="<option></option>",le.option=!!xe.lastChild;var ke={thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};function Se(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&fe(e,t)?ce.merge([e],n):n}function Ee(e,t){for(var n=0,r=e.length;n<r;n++)_.set(e[n],"globalEval",!t||_.get(t[n],"globalEval"))}ke.tbody=ke.tfoot=ke.colgroup=ke.caption=ke.thead,ke.th=ke.td,le.option||(ke.optgroup=ke.option=[1,"<select multiple='multiple'>","</select>"]);var je=/<|&#?\w+;/;function Ae(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d<h;d++)if((o=e[d])||0===o)if("object"===x(o))ce.merge(p,o.nodeType?[o]:o);else if(je.test(o)){a=a||f.appendChild(t.createElement("div")),s=(Te.exec(o)||["",""])[1].toLowerCase(),u=ke[s]||ke._default,a.innerHTML=u[1]+ce.htmlPrefilter(o)+u[2],c=u[0];while(c--)a=a.lastChild;ce.merge(p,a.childNodes),(a=f.firstChild).textContent=""}else p.push(t.createTextNode(o));f.textContent="",d=0;while(o=p[d++])if(r&&-1<ce.inArray(o,r))i&&i.push(o);else if(l=K(o),a=Se(f.appendChild(o),"script"),l&&Ee(a),n){c=0;while(o=a[c++])Ce.test(o.type||"")&&n.push(o)}return f}var De=/^([^.]*)(?:\.(.+)|)/;function Ne(){return!0}function qe(){return!1}function Le(e,t,n,r,i,o){var a,s;if("object"==typeof t){for(s in"string"!=typeof n&&(r=r||n,n=void 0),t)Le(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=qe;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return ce().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=ce.guid++)),e.each(function(){ce.event.add(this,t,i,r,n)})}function He(e,r,t){t?(_.set(e,r,!1),ce.event.add(e,r,{namespace:!1,handler:function(e){var t,n=_.get(this,r);if(1&e.isTrigger&&this[r]){if(n)(ce.event.special[r]||{}).delegateType&&e.stopPropagation();else if(n=ae.call(arguments),_.set(this,r,n),this[r](),t=_.get(this,r),_.set(this,r,!1),n!==t)return e.stopImmediatePropagation(),e.preventDefault(),t}else n&&(_.set(this,r,ce.event.trigger(n[0],n.slice(1),this)),e.stopPropagation(),e.isImmediatePropagationStopped=Ne)}})):void 0===_.get(e,r)&&ce.event.add(e,r,Ne)}ce.event={global:{},add:function(t,e,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,v=_.get(t);if($(t)){n.handler&&(n=(o=n).handler,i=o.selector),i&&ce.find.matchesSelector(J,i),n.guid||(n.guid=ce.guid++),(u=v.events)||(u=v.events=Object.create(null)),(a=v.handle)||(a=v.handle=function(e){return"undefined"!=typeof ce&&ce.event.triggered!==e.type?ce.event.dispatch.apply(t,arguments):void 0}),l=(e=(e||"").match(D)||[""]).length;while(l--)d=g=(s=De.exec(e[l])||[])[1],h=(s[2]||"").split(".").sort(),d&&(f=ce.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=ce.event.special[d]||{},c=ce.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&ce.expr.match.needsContext.test(i),namespace:h.join(".")},o),(p=u[d])||((p=u[d]=[]).delegateCount=0,f.setup&&!1!==f.setup.call(t,r,h,a)||t.addEventListener&&t.addEventListener(d,a)),f.add&&(f.add.call(t,c),c.handler.guid||(c.handler.guid=n.guid)),i?p.splice(p.delegateCount++,0,c):p.push(c),ce.event.global[d]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,v=_.hasData(e)&&_.get(e);if(v&&(u=v.events)){l=(t=(t||"").match(D)||[""]).length;while(l--)if(d=g=(s=De.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),d){f=ce.event.special[d]||{},p=u[d=(r?f.delegateType:f.bindType)||d]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&!1!==f.teardown.call(e,h,v.handle)||ce.removeEvent(e,d,v.handle),delete u[d])}else for(d in u)ce.event.remove(e,d+t[l],n,r,!0);ce.isEmptyObject(u)&&_.remove(e,"handle events")}},dispatch:function(e){var t,n,r,i,o,a,s=new Array(arguments.length),u=ce.event.fix(e),l=(_.get(this,"events")||Object.create(null))[u.type]||[],c=ce.event.special[u.type]||{};for(s[0]=u,t=1;t<arguments.length;t++)s[t]=arguments[t];if(u.delegateTarget=this,!c.preDispatch||!1!==c.preDispatch.call(this,u)){a=ce.event.handlers.call(this,u,l),t=0;while((i=a[t++])&&!u.isPropagationStopped()){u.currentTarget=i.elem,n=0;while((o=i.handlers[n++])&&!u.isImmediatePropagationStopped())u.rnamespace&&!1!==o.namespace&&!u.rnamespace.test(o.namespace)||(u.handleObj=o,u.data=o.data,void 0!==(r=((ce.event.special[o.origType]||{}).handle||o.handler).apply(i.elem,s))&&!1===(u.result=r)&&(u.preventDefault(),u.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,u),u.result}},handlers:function(e,t){var n,r,i,o,a,s=[],u=t.delegateCount,l=e.target;if(u&&l.nodeType&&!("click"===e.type&&1<=e.button))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&("click"!==e.type||!0!==l.disabled)){for(o=[],a={},n=0;n<u;n++)void 0===a[i=(r=t[n]).selector+" "]&&(a[i]=r.needsContext?-1<ce(i,this).index(l):ce.find(i,this,null,[l]).length),a[i]&&o.push(r);o.length&&s.push({elem:l,handlers:o})}return l=this,u<t.length&&s.push({elem:l,handlers:t.slice(u)}),s},addProp:function(t,e){Object.defineProperty(ce.Event.prototype,t,{enumerable:!0,configurable:!0,get:v(e)?function(){if(this.originalEvent)return e(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[t]},set:function(e){Object.defineProperty(this,t,{enumerable:!0,configurable:!0,writable:!0,value:e})}})},fix:function(e){return e[ce.expando]?e:new ce.Event(e)},special:{load:{noBubble:!0},click:{setup:function(e){var t=this||e;return we.test(t.type)&&t.click&&fe(t,"input")&&He(t,"click",!0),!1},trigger:function(e){var t=this||e;return we.test(t.type)&&t.click&&fe(t,"input")&&He(t,"click"),!0},_default:function(e){var t=e.target;return we.test(t.type)&&t.click&&fe(t,"input")&&_.get(t,"click")||fe(t,"a")}},beforeunload:{postDispatch:function(e){void 0!==e.result&&e.originalEvent&&(e.originalEvent.returnValue=e.result)}}}},ce.removeEvent=function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n)},ce.Event=function(e,t){if(!(this instanceof ce.Event))return new ce.Event(e,t);e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||void 0===e.defaultPrevented&&!1===e.returnValue?Ne:qe,this.target=e.target&&3===e.target.nodeType?e.target.parentNode:e.target,this.currentTarget=e.currentTarget,this.relatedTarget=e.relatedTarget):this.type=e,t&&ce.extend(this,t),this.timeStamp=e&&e.timeStamp||Date.now(),this[ce.expando]=!0},ce.Event.prototype={constructor:ce.Event,isDefaultPrevented:qe,isPropagationStopped:qe,isImmediatePropagationStopped:qe,isSimulated:!1,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=Ne,e&&!this.isSimulated&&e.preventDefault()},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=Ne,e&&!this.isSimulated&&e.stopPropagation()},stopImmediatePropagation:function(){var e=this.originalEvent;this.isImmediatePropagationStopped=Ne,e&&!this.isSimulated&&e.stopImmediatePropagation(),this.stopPropagation()}},ce.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,"char":!0,code:!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:!0},ce.event.addProp),ce.each({focus:"focusin",blur:"focusout"},function(r,i){function o(e){if(C.documentMode){var t=_.get(this,"handle"),n=ce.event.fix(e);n.type="focusin"===e.type?"focus":"blur",n.isSimulated=!0,t(e),n.target===n.currentTarget&&t(n)}else ce.event.simulate(i,e.target,ce.event.fix(e))}ce.event.special[r]={setup:function(){var e;if(He(this,r,!0),!C.documentMode)return!1;(e=_.get(this,i))||this.addEventListener(i,o),_.set(this,i,(e||0)+1)},trigger:function(){return He(this,r),!0},teardown:function(){var e;if(!C.documentMode)return!1;(e=_.get(this,i)-1)?_.set(this,i,e):(this.removeEventListener(i,o),_.remove(this,i))},_default:function(e){return _.get(e.target,r)},delegateType:i},ce.event.special[i]={setup:function(){var e=this.ownerDocument||this.document||this,t=C.documentMode?this:e,n=_.get(t,i);n||(C.documentMode?this.addEventListener(i,o):e.addEventListener(r,o,!0)),_.set(t,i,(n||0)+1)},teardown:function(){var e=this.ownerDocument||this.document||this,t=C.documentMode?this:e,n=_.get(t,i)-1;n?_.set(t,i,n):(C.documentMode?this.removeEventListener(i,o):e.removeEventListener(r,o,!0),_.remove(t,i))}}}),ce.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(e,i){ce.event.special[e]={delegateType:i,bindType:i,handle:function(e){var t,n=e.relatedTarget,r=e.handleObj;return n&&(n===this||ce.contains(this,n))||(e.type=r.origType,t=r.handler.apply(this,arguments),e.type=i),t}}}),ce.fn.extend({on:function(e,t,n,r){return Le(this,e,t,n,r)},one:function(e,t,n,r){return Le(this,e,t,n,r,1)},off:function(e,t,n){var r,i;if(e&&e.preventDefault&&e.handleObj)return r=e.handleObj,ce(e.delegateTarget).off(r.namespace?r.origType+"."+r.namespace:r.origType,r.selector,r.handler),this;if("object"==typeof e){for(i in e)this.off(i,t,e[i]);return this}return!1!==t&&"function"!=typeof t||(n=t,t=void 0),!1===n&&(n=qe),this.each(function(){ce.event.remove(this,e,n,t)})}});var Oe=/<script|<style|<link/i,Pe=/checked\s*(?:[^=]|=\s*.checked.)/i,Me=/^\s*<!\[CDATA\[|\]\]>\s*$/g;function Re(e,t){return fe(e,"table")&&fe(11!==t.nodeType?t:t.firstChild,"tr")&&ce(e).children("tbody")[0]||e}function Ie(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function We(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Fe(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(_.hasData(e)&&(s=_.get(e).events))for(i in _.remove(t,"handle events"),s)for(n=0,r=s[i].length;n<r;n++)ce.event.add(t,i,s[i][n]);z.hasData(e)&&(o=z.access(e),a=ce.extend({},o),z.set(t,a))}}function $e(n,r,i,o){r=g(r);var e,t,a,s,u,l,c=0,f=n.length,p=f-1,d=r[0],h=v(d);if(h||1<f&&"string"==typeof d&&!le.checkClone&&Pe.test(d))return n.each(function(e){var t=n.eq(e);h&&(r[0]=d.call(this,e,t.html())),$e(t,r,i,o)});if(f&&(t=(e=Ae(r,n[0].ownerDocument,!1,n,o)).firstChild,1===e.childNodes.length&&(e=t),t||o)){for(s=(a=ce.map(Se(e,"script"),Ie)).length;c<f;c++)u=e,c!==p&&(u=ce.clone(u,!0,!0),s&&ce.merge(a,Se(u,"script"))),i.call(n[c],u,c);if(s)for(l=a[a.length-1].ownerDocument,ce.map(a,We),c=0;c<s;c++)u=a[c],Ce.test(u.type||"")&&!_.access(u,"globalEval")&&ce.contains(l,u)&&(u.src&&"module"!==(u.type||"").toLowerCase()?ce._evalUrl&&!u.noModule&&ce._evalUrl(u.src,{nonce:u.nonce||u.getAttribute("nonce")},l):m(u.textContent.replace(Me,""),u,l))}return n}function Be(e,t,n){for(var r,i=t?ce.filter(t,e):e,o=0;null!=(r=i[o]);o++)n||1!==r.nodeType||ce.cleanData(Se(r)),r.parentNode&&(n&&K(r)&&Ee(Se(r,"script")),r.parentNode.removeChild(r));return e}ce.extend({htmlPrefilter:function(e){return e},clone:function(e,t,n){var r,i,o,a,s,u,l,c=e.cloneNode(!0),f=K(e);if(!(le.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||ce.isXMLDoc(e)))for(a=Se(c),r=0,i=(o=Se(e)).length;r<i;r++)s=o[r],u=a[r],void 0,"input"===(l=u.nodeName.toLowerCase())&&we.test(s.type)?u.checked=s.checked:"input"!==l&&"textarea"!==l||(u.defaultValue=s.defaultValue);if(t)if(n)for(o=o||Se(e),a=a||Se(c),r=0,i=o.length;r<i;r++)Fe(o[r],a[r]);else Fe(e,c);return 0<(a=Se(c,"script")).length&&Ee(a,!f&&Se(e,"script")),c},cleanData:function(e){for(var t,n,r,i=ce.event.special,o=0;void 0!==(n=e[o]);o++)if($(n)){if(t=n[_.expando]){if(t.events)for(r in t.events)i[r]?ce.event.remove(n,r):ce.removeEvent(n,r,t.handle);n[_.expando]=void 0}n[z.expando]&&(n[z.expando]=void 0)}}}),ce.fn.extend({detach:function(e){return Be(this,e,!0)},remove:function(e){return Be(this,e)},text:function(e){return M(this,function(e){return void 0===e?ce.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)})},null,e,arguments.length)},append:function(){return $e(this,arguments,function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||Re(this,e).appendChild(e)})},prepend:function(){return $e(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Re(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return $e(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return $e(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(ce.cleanData(Se(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return ce.clone(this,e,t)})},html:function(e){return M(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!Oe.test(e)&&!ke[(Te.exec(e)||["",""])[1].toLowerCase()]){e=ce.htmlPrefilter(e);try{for(;n<r;n++)1===(t=this[n]||{}).nodeType&&(ce.cleanData(Se(t,!1)),t.innerHTML=e);t=0}catch(e){}}t&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var n=[];return $e(this,arguments,function(e){var t=this.parentNode;ce.inArray(this,n)<0&&(ce.cleanData(Se(this)),t&&t.replaceChild(e,this))},n)}}),ce.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,a){ce.fn[e]=function(e){for(var t,n=[],r=ce(e),i=r.length-1,o=0;o<=i;o++)t=o===i?this:this.clone(!0),ce(r[o])[a](t),s.apply(n,t.get());return this.pushStack(n)}});var _e=new RegExp("^("+G+")(?!px)[a-z%]+$","i"),ze=/^--/,Xe=function(e){var t=e.ownerDocument.defaultView;return t&&t.opener||(t=ie),t.getComputedStyle(e)},Ue=function(e,t,n){var r,i,o={};for(i in t)o[i]=e.style[i],e.style[i]=t[i];for(i in r=n.call(e),t)e.style[i]=o[i];return r},Ve=new RegExp(Q.join("|"),"i");function Ge(e,t,n){var r,i,o,a,s=ze.test(t),u=e.style;return(n=n||Xe(e))&&(a=n.getPropertyValue(t)||n[t],s&&a&&(a=a.replace(ve,"$1")||void 0),""!==a||K(e)||(a=ce.style(e,t)),!le.pixelBoxStyles()&&_e.test(a)&&Ve.test(t)&&(r=u.width,i=u.minWidth,o=u.maxWidth,u.minWidth=u.maxWidth=u.width=a,a=n.width,u.width=r,u.minWidth=i,u.maxWidth=o)),void 0!==a?a+"":a}function Ye(e,t){return{get:function(){if(!e())return(this.get=t).apply(this,arguments);delete this.get}}}!function(){function e(){if(l){u.style.cssText="position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0",l.style.cssText="position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%",J.appendChild(u).appendChild(l);var e=ie.getComputedStyle(l);n="1%"!==e.top,s=12===t(e.marginLeft),l.style.right="60%",o=36===t(e.right),r=36===t(e.width),l.style.position="absolute",i=12===t(l.offsetWidth/3),J.removeChild(u),l=null}}function t(e){return Math.round(parseFloat(e))}var n,r,i,o,a,s,u=C.createElement("div"),l=C.createElement("div");l.style&&(l.style.backgroundClip="content-box",l.cloneNode(!0).style.backgroundClip="",le.clearCloneStyle="content-box"===l.style.backgroundClip,ce.extend(le,{boxSizingReliable:function(){return e(),r},pixelBoxStyles:function(){return e(),o},pixelPosition:function(){return e(),n},reliableMarginLeft:function(){return e(),s},scrollboxSize:function(){return e(),i},reliableTrDimensions:function(){var e,t,n,r;return null==a&&(e=C.createElement("table"),t=C.createElement("tr"),n=C.createElement("div"),e.style.cssText="position:absolute;left:-11111px;border-collapse:separate",t.style.cssText="box-sizing:content-box;border:1px solid",t.style.height="1px",n.style.height="9px",n.style.display="block",J.appendChild(e).appendChild(t).appendChild(n),r=ie.getComputedStyle(t),a=parseInt(r.height,10)+parseInt(r.borderTopWidth,10)+parseInt(r.borderBottomWidth,10)===t.offsetHeight,J.removeChild(e)),a}}))}();var Qe=["Webkit","Moz","ms"],Je=C.createElement("div").style,Ke={};function Ze(e){var t=ce.cssProps[e]||Ke[e];return t||(e in Je?e:Ke[e]=function(e){var t=e[0].toUpperCase()+e.slice(1),n=Qe.length;while(n--)if((e=Qe[n]+t)in Je)return e}(e)||e)}var et=/^(none|table(?!-c[ea]).+)/,tt={position:"absolute",visibility:"hidden",display:"block"},nt={letterSpacing:"0",fontWeight:"400"};function rt(e,t,n){var r=Y.exec(t);return r?Math.max(0,r[2]-(n||0))+(r[3]||"px"):t}function it(e,t,n,r,i,o){var a="width"===t?1:0,s=0,u=0,l=0;if(n===(r?"border":"content"))return 0;for(;a<4;a+=2)"margin"===n&&(l+=ce.css(e,n+Q[a],!0,i)),r?("content"===n&&(u-=ce.css(e,"padding"+Q[a],!0,i)),"margin"!==n&&(u-=ce.css(e,"border"+Q[a]+"Width",!0,i))):(u+=ce.css(e,"padding"+Q[a],!0,i),"padding"!==n?u+=ce.css(e,"border"+Q[a]+"Width",!0,i):s+=ce.css(e,"border"+Q[a]+"Width",!0,i));return!r&&0<=o&&(u+=Math.max(0,Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-o-u-s-.5))||0),u+l}function ot(e,t,n){var r=Xe(e),i=(!le.boxSizingReliable()||n)&&"border-box"===ce.css(e,"boxSizing",!1,r),o=i,a=Ge(e,t,r),s="offset"+t[0].toUpperCase()+t.slice(1);if(_e.test(a)){if(!n)return a;a="auto"}return(!le.boxSizingReliable()&&i||!le.reliableTrDimensions()&&fe(e,"tr")||"auto"===a||!parseFloat(a)&&"inline"===ce.css(e,"display",!1,r))&&e.getClientRects().length&&(i="border-box"===ce.css(e,"boxSizing",!1,r),(o=s in e)&&(a=e[s])),(a=parseFloat(a)||0)+it(e,t,n||(i?"border":"content"),o,r,a)+"px"}function at(e,t,n,r,i){return new at.prototype.init(e,t,n,r,i)}ce.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Ge(e,"opacity");return""===n?"1":n}}}},cssNumber:{animationIterationCount:!0,aspectRatio:!0,borderImageSlice:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,scale:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeMiterlimit:!0,strokeOpacity:!0},cssProps:{},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,a,s=F(t),u=ze.test(t),l=e.style;if(u||(t=Ze(s)),a=ce.cssHooks[t]||ce.cssHooks[s],void 0===n)return a&&"get"in a&&void 0!==(i=a.get(e,!1,r))?i:l[t];"string"===(o=typeof n)&&(i=Y.exec(n))&&i[1]&&(n=te(e,t,i),o="number"),null!=n&&n==n&&("number"!==o||u||(n+=i&&i[3]||(ce.cssNumber[s]?"":"px")),le.clearCloneStyle||""!==n||0!==t.indexOf("background")||(l[t]="inherit"),a&&"set"in a&&void 0===(n=a.set(e,n,r))||(u?l.setProperty(t,n):l[t]=n))}},css:function(e,t,n,r){var i,o,a,s=F(t);return ze.test(t)||(t=Ze(s)),(a=ce.cssHooks[t]||ce.cssHooks[s])&&"get"in a&&(i=a.get(e,!0,n)),void 0===i&&(i=Ge(e,t,r)),"normal"===i&&t in nt&&(i=nt[t]),""===n||n?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),ce.each(["height","width"],function(e,u){ce.cssHooks[u]={get:function(e,t,n){if(t)return!et.test(ce.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?ot(e,u,n):Ue(e,tt,function(){return ot(e,u,n)})},set:function(e,t,n){var r,i=Xe(e),o=!le.scrollboxSize()&&"absolute"===i.position,a=(o||n)&&"border-box"===ce.css(e,"boxSizing",!1,i),s=n?it(e,u,n,a,i):0;return a&&o&&(s-=Math.ceil(e["offset"+u[0].toUpperCase()+u.slice(1)]-parseFloat(i[u])-it(e,u,"border",!1,i)-.5)),s&&(r=Y.exec(t))&&"px"!==(r[3]||"px")&&(e.style[u]=t,t=ce.css(e,u)),rt(0,t,s)}}}),ce.cssHooks.marginLeft=Ye(le.reliableMarginLeft,function(e,t){if(t)return(parseFloat(Ge(e,"marginLeft"))||e.getBoundingClientRect().left-Ue(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),ce.each({margin:"",padding:"",border:"Width"},function(i,o){ce.cssHooks[i+o]={expand:function(e){for(var t=0,n={},r="string"==typeof e?e.split(" "):[e];t<4;t++)n[i+Q[t]+o]=r[t]||r[t-2]||r[0];return n}},"margin"!==i&&(ce.cssHooks[i+o].set=rt)}),ce.fn.extend({css:function(e,t){return M(this,function(e,t,n){var r,i,o={},a=0;if(Array.isArray(t)){for(r=Xe(e),i=t.length;a<i;a++)o[t[a]]=ce.css(e,t[a],!1,r);return o}return void 0!==n?ce.style(e,t,n):ce.css(e,t)},e,t,1<arguments.length)}}),((ce.Tween=at).prototype={constructor:at,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||ce.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(ce.cssNumber[n]?"":"px")},cur:function(){var e=at.propHooks[this.prop];return e&&e.get?e.get(this):at.propHooks._default.get(this)},run:function(e){var t,n=at.propHooks[this.prop];return this.options.duration?this.pos=t=ce.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):at.propHooks._default.set(this),this}}).init.prototype=at.prototype,(at.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=ce.css(e.elem,e.prop,""))&&"auto"!==t?t:0},set:function(e){ce.fx.step[e.prop]?ce.fx.step[e.prop](e):1!==e.elem.nodeType||!ce.cssHooks[e.prop]&&null==e.elem.style[Ze(e.prop)]?e.elem[e.prop]=e.now:ce.style(e.elem,e.prop,e.now+e.unit)}}}).scrollTop=at.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},ce.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},ce.fx=at.prototype.init,ce.fx.step={};var st,ut,lt,ct,ft=/^(?:toggle|show|hide)$/,pt=/queueHooks$/;function dt(){ut&&(!1===C.hidden&&ie.requestAnimationFrame?ie.requestAnimationFrame(dt):ie.setTimeout(dt,ce.fx.interval),ce.fx.tick())}function ht(){return ie.setTimeout(function(){st=void 0}),st=Date.now()}function gt(e,t){var n,r=0,i={height:e};for(t=t?1:0;r<4;r+=2-t)i["margin"+(n=Q[r])]=i["padding"+n]=e;return t&&(i.opacity=i.width=e),i}function vt(e,t,n){for(var r,i=(yt.tweeners[t]||[]).concat(yt.tweeners["*"]),o=0,a=i.length;o<a;o++)if(r=i[o].call(n,t,e))return r}function yt(o,e,t){var n,a,r=0,i=yt.prefilters.length,s=ce.Deferred().always(function(){delete u.elem}),u=function(){if(a)return!1;for(var e=st||ht(),t=Math.max(0,l.startTime+l.duration-e),n=1-(t/l.duration||0),r=0,i=l.tweens.length;r<i;r++)l.tweens[r].run(n);return s.notifyWith(o,[l,n,t]),n<1&&i?t:(i||s.notifyWith(o,[l,1,0]),s.resolveWith(o,[l]),!1)},l=s.promise({elem:o,props:ce.extend({},e),opts:ce.extend(!0,{specialEasing:{},easing:ce.easing._default},t),originalProperties:e,originalOptions:t,startTime:st||ht(),duration:t.duration,tweens:[],createTween:function(e,t){var n=ce.Tween(o,l.opts,e,t,l.opts.specialEasing[e]||l.opts.easing);return l.tweens.push(n),n},stop:function(e){var t=0,n=e?l.tweens.length:0;if(a)return this;for(a=!0;t<n;t++)l.tweens[t].run(1);return e?(s.notifyWith(o,[l,1,0]),s.resolveWith(o,[l,e])):s.rejectWith(o,[l,e]),this}}),c=l.props;for(!function(e,t){var n,r,i,o,a;for(n in e)if(i=t[r=F(n)],o=e[n],Array.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),(a=ce.cssHooks[r])&&"expand"in a)for(n in o=a.expand(o),delete e[r],o)n in e||(e[n]=o[n],t[n]=i);else t[r]=i}(c,l.opts.specialEasing);r<i;r++)if(n=yt.prefilters[r].call(l,o,c,l.opts))return v(n.stop)&&(ce._queueHooks(l.elem,l.opts.queue).stop=n.stop.bind(n)),n;return ce.map(c,vt,l),v(l.opts.start)&&l.opts.start.call(o,l),l.progress(l.opts.progress).done(l.opts.done,l.opts.complete).fail(l.opts.fail).always(l.opts.always),ce.fx.timer(ce.extend(u,{elem:o,anim:l,queue:l.opts.queue})),l}ce.Animation=ce.extend(yt,{tweeners:{"*":[function(e,t){var n=this.createTween(e,t);return te(n.elem,e,Y.exec(t),n),n}]},tweener:function(e,t){v(e)?(t=e,e=["*"]):e=e.match(D);for(var n,r=0,i=e.length;r<i;r++)n=e[r],yt.tweeners[n]=yt.tweeners[n]||[],yt.tweeners[n].unshift(t)},prefilters:[function(e,t,n){var r,i,o,a,s,u,l,c,f="width"in t||"height"in t,p=this,d={},h=e.style,g=e.nodeType&&ee(e),v=_.get(e,"fxshow");for(r in n.queue||(null==(a=ce._queueHooks(e,"fx")).unqueued&&(a.unqueued=0,s=a.empty.fire,a.empty.fire=function(){a.unqueued||s()}),a.unqueued++,p.always(function(){p.always(function(){a.unqueued--,ce.queue(e,"fx").length||a.empty.fire()})})),t)if(i=t[r],ft.test(i)){if(delete t[r],o=o||"toggle"===i,i===(g?"hide":"show")){if("show"!==i||!v||void 0===v[r])continue;g=!0}d[r]=v&&v[r]||ce.style(e,r)}if((u=!ce.isEmptyObject(t))||!ce.isEmptyObject(d))for(r in f&&1===e.nodeType&&(n.overflow=[h.overflow,h.overflowX,h.overflowY],null==(l=v&&v.display)&&(l=_.get(e,"display")),"none"===(c=ce.css(e,"display"))&&(l?c=l:(re([e],!0),l=e.style.display||l,c=ce.css(e,"display"),re([e]))),("inline"===c||"inline-block"===c&&null!=l)&&"none"===ce.css(e,"float")&&(u||(p.done(function(){h.display=l}),null==l&&(c=h.display,l="none"===c?"":c)),h.display="inline-block")),n.overflow&&(h.overflow="hidden",p.always(function(){h.overflow=n.overflow[0],h.overflowX=n.overflow[1],h.overflowY=n.overflow[2]})),u=!1,d)u||(v?"hidden"in v&&(g=v.hidden):v=_.access(e,"fxshow",{display:l}),o&&(v.hidden=!g),g&&re([e],!0),p.done(function(){for(r in g||re([e]),_.remove(e,"fxshow"),d)ce.style(e,r,d[r])})),u=vt(g?v[r]:0,r,p),r in v||(v[r]=u.start,g&&(u.end=u.start,u.start=0))}],prefilter:function(e,t){t?yt.prefilters.unshift(e):yt.prefilters.push(e)}}),ce.speed=function(e,t,n){var r=e&&"object"==typeof e?ce.extend({},e):{complete:n||!n&&t||v(e)&&e,duration:e,easing:n&&t||t&&!v(t)&&t};return ce.fx.off?r.duration=0:"number"!=typeof r.duration&&(r.duration in ce.fx.speeds?r.duration=ce.fx.speeds[r.duration]:r.duration=ce.fx.speeds._default),null!=r.queue&&!0!==r.queue||(r.queue="fx"),r.old=r.complete,r.complete=function(){v(r.old)&&r.old.call(this),r.queue&&ce.dequeue(this,r.queue)},r},ce.fn.extend({fadeTo:function(e,t,n,r){return this.filter(ee).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(t,e,n,r){var i=ce.isEmptyObject(t),o=ce.speed(e,n,r),a=function(){var e=yt(this,ce.extend({},t),o);(i||_.get(this,"finish"))&&e.stop(!0)};return a.finish=a,i||!1===o.queue?this.each(a):this.queue(o.queue,a)},stop:function(i,e,o){var a=function(e){var t=e.stop;delete e.stop,t(o)};return"string"!=typeof i&&(o=e,e=i,i=void 0),e&&this.queue(i||"fx",[]),this.each(function(){var e=!0,t=null!=i&&i+"queueHooks",n=ce.timers,r=_.get(this);if(t)r[t]&&r[t].stop&&a(r[t]);else for(t in r)r[t]&&r[t].stop&&pt.test(t)&&a(r[t]);for(t=n.length;t--;)n[t].elem!==this||null!=i&&n[t].queue!==i||(n[t].anim.stop(o),e=!1,n.splice(t,1));!e&&o||ce.dequeue(this,i)})},finish:function(a){return!1!==a&&(a=a||"fx"),this.each(function(){var e,t=_.get(this),n=t[a+"queue"],r=t[a+"queueHooks"],i=ce.timers,o=n?n.length:0;for(t.finish=!0,ce.queue(this,a,[]),r&&r.stop&&r.stop.call(this,!0),e=i.length;e--;)i[e].elem===this&&i[e].queue===a&&(i[e].anim.stop(!0),i.splice(e,1));for(e=0;e<o;e++)n[e]&&n[e].finish&&n[e].finish.call(this);delete t.finish})}}),ce.each(["toggle","show","hide"],function(e,r){var i=ce.fn[r];ce.fn[r]=function(e,t,n){return null==e||"boolean"==typeof e?i.apply(this,arguments):this.animate(gt(r,!0),e,t,n)}}),ce.each({slideDown:gt("show"),slideUp:gt("hide"),slideToggle:gt("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,r){ce.fn[e]=function(e,t,n){return this.animate(r,e,t,n)}}),ce.timers=[],ce.fx.tick=function(){var e,t=0,n=ce.timers;for(st=Date.now();t<n.length;t++)(e=n[t])()||n[t]!==e||n.splice(t--,1);n.length||ce.fx.stop(),st=void 0},ce.fx.timer=function(e){ce.timers.push(e),ce.fx.start()},ce.fx.interval=13,ce.fx.start=function(){ut||(ut=!0,dt())},ce.fx.stop=function(){ut=null},ce.fx.speeds={slow:600,fast:200,_default:400},ce.fn.delay=function(r,e){return r=ce.fx&&ce.fx.speeds[r]||r,e=e||"fx",this.queue(e,function(e,t){var n=ie.setTimeout(e,r);t.stop=function(){ie.clearTimeout(n)}})},lt=C.createElement("input"),ct=C.createElement("select").appendChild(C.createElement("option")),lt.type="checkbox",le.checkOn=""!==lt.value,le.optSelected=ct.selected,(lt=C.createElement("input")).value="t",lt.type="radio",le.radioValue="t"===lt.value;var mt,xt=ce.expr.attrHandle;ce.fn.extend({attr:function(e,t){return M(this,ce.attr,e,t,1<arguments.length)},removeAttr:function(e){return this.each(function(){ce.removeAttr(this,e)})}}),ce.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return"undefined"==typeof e.getAttribute?ce.prop(e,t,n):(1===o&&ce.isXMLDoc(e)||(i=ce.attrHooks[t.toLowerCase()]||(ce.expr.match.bool.test(t)?mt:void 0)),void 0!==n?null===n?void ce.removeAttr(e,t):i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n+""),n):i&&"get"in i&&null!==(r=i.get(e,t))?r:null==(r=ce.find.attr(e,t))?void 0:r)},attrHooks:{type:{set:function(e,t){if(!le.radioValue&&"radio"===t&&fe(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,r=0,i=t&&t.match(D);if(i&&1===e.nodeType)while(n=i[r++])e.removeAttribute(n)}}),mt={set:function(e,t,n){return!1===t?ce.removeAttr(e,n):e.setAttribute(n,n),n}},ce.each(ce.expr.match.bool.source.match(/\w+/g),function(e,t){var a=xt[t]||ce.find.attr;xt[t]=function(e,t,n){var r,i,o=t.toLowerCase();return n||(i=xt[o],xt[o]=r,r=null!=a(e,t,n)?o:null,xt[o]=i),r}});var bt=/^(?:input|select|textarea|button)$/i,wt=/^(?:a|area)$/i;function Tt(e){return(e.match(D)||[]).join(" ")}function Ct(e){return e.getAttribute&&e.getAttribute("class")||""}function kt(e){return Array.isArray(e)?e:"string"==typeof e&&e.match(D)||[]}ce.fn.extend({prop:function(e,t){return M(this,ce.prop,e,t,1<arguments.length)},removeProp:function(e){return this.each(function(){delete this[ce.propFix[e]||e]})}}),ce.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&ce.isXMLDoc(e)||(t=ce.propFix[t]||t,i=ce.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=ce.find.attr(e,"tabindex");return t?parseInt(t,10):bt.test(e.nodeName)||wt.test(e.nodeName)&&e.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),le.optSelected||(ce.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),ce.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){ce.propFix[this.toLowerCase()]=this}),ce.fn.extend({addClass:function(t){var e,n,r,i,o,a;return v(t)?this.each(function(e){ce(this).addClass(t.call(this,e,Ct(this)))}):(e=kt(t)).length?this.each(function(){if(r=Ct(this),n=1===this.nodeType&&" "+Tt(r)+" "){for(o=0;o<e.length;o++)i=e[o],n.indexOf(" "+i+" ")<0&&(n+=i+" ");a=Tt(n),r!==a&&this.setAttribute("class",a)}}):this},removeClass:function(t){var e,n,r,i,o,a;return v(t)?this.each(function(e){ce(this).removeClass(t.call(this,e,Ct(this)))}):arguments.length?(e=kt(t)).length?this.each(function(){if(r=Ct(this),n=1===this.nodeType&&" "+Tt(r)+" "){for(o=0;o<e.length;o++){i=e[o];while(-1<n.indexOf(" "+i+" "))n=n.replace(" "+i+" "," ")}a=Tt(n),r!==a&&this.setAttribute("class",a)}}):this:this.attr("class","")},toggleClass:function(t,n){var e,r,i,o,a=typeof t,s="string"===a||Array.isArray(t);return v(t)?this.each(function(e){ce(this).toggleClass(t.call(this,e,Ct(this),n),n)}):"boolean"==typeof n&&s?n?this.addClass(t):this.removeClass(t):(e=kt(t),this.each(function(){if(s)for(o=ce(this),i=0;i<e.length;i++)r=e[i],o.hasClass(r)?o.removeClass(r):o.addClass(r);else void 0!==t&&"boolean"!==a||((r=Ct(this))&&_.set(this,"__className__",r),this.setAttribute&&this.setAttribute("class",r||!1===t?"":_.get(this,"__className__")||""))}))},hasClass:function(e){var t,n,r=0;t=" "+e+" ";while(n=this[r++])if(1===n.nodeType&&-1<(" "+Tt(Ct(n))+" ").indexOf(t))return!0;return!1}});var St=/\r/g;ce.fn.extend({val:function(n){var r,e,i,t=this[0];return arguments.length?(i=v(n),this.each(function(e){var t;1===this.nodeType&&(null==(t=i?n.call(this,e,ce(this).val()):n)?t="":"number"==typeof t?t+="":Array.isArray(t)&&(t=ce.map(t,function(e){return null==e?"":e+""})),(r=ce.valHooks[this.type]||ce.valHooks[this.nodeName.toLowerCase()])&&"set"in r&&void 0!==r.set(this,t,"value")||(this.value=t))})):t?(r=ce.valHooks[t.type]||ce.valHooks[t.nodeName.toLowerCase()])&&"get"in r&&void 0!==(e=r.get(t,"value"))?e:"string"==typeof(e=t.value)?e.replace(St,""):null==e?"":e:void 0}}),ce.extend({valHooks:{option:{get:function(e){var t=ce.find.attr(e,"value");return null!=t?t:Tt(ce.text(e))}},select:{get:function(e){var t,n,r,i=e.options,o=e.selectedIndex,a="select-one"===e.type,s=a?null:[],u=a?o+1:i.length;for(r=o<0?u:a?o:0;r<u;r++)if(((n=i[r]).selected||r===o)&&!n.disabled&&(!n.parentNode.disabled||!fe(n.parentNode,"optgroup"))){if(t=ce(n).val(),a)return t;s.push(t)}return s},set:function(e,t){var n,r,i=e.options,o=ce.makeArray(t),a=i.length;while(a--)((r=i[a]).selected=-1<ce.inArray(ce.valHooks.option.get(r),o))&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),ce.each(["radio","checkbox"],function(){ce.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=-1<ce.inArray(ce(e).val(),t)}},le.checkOn||(ce.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})});var Et=ie.location,jt={guid:Date.now()},At=/\?/;ce.parseXML=function(e){var t,n;if(!e||"string"!=typeof e)return null;try{t=(new ie.DOMParser).parseFromString(e,"text/xml")}catch(e){}return n=t&&t.getElementsByTagName("parsererror")[0],t&&!n||ce.error("Invalid XML: "+(n?ce.map(n.childNodes,function(e){return e.textContent}).join("\n"):e)),t};var Dt=/^(?:focusinfocus|focusoutblur)$/,Nt=function(e){e.stopPropagation()};ce.extend(ce.event,{trigger:function(e,t,n,r){var i,o,a,s,u,l,c,f,p=[n||C],d=ue.call(e,"type")?e.type:e,h=ue.call(e,"namespace")?e.namespace.split("."):[];if(o=f=a=n=n||C,3!==n.nodeType&&8!==n.nodeType&&!Dt.test(d+ce.event.triggered)&&(-1<d.indexOf(".")&&(d=(h=d.split(".")).shift(),h.sort()),u=d.indexOf(":")<0&&"on"+d,(e=e[ce.expando]?e:new ce.Event(d,"object"==typeof e&&e)).isTrigger=r?2:3,e.namespace=h.join("."),e.rnamespace=e.namespace?new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,e.result=void 0,e.target||(e.target=n),t=null==t?[e]:ce.makeArray(t,[e]),c=ce.event.special[d]||{},r||!c.trigger||!1!==c.trigger.apply(n,t))){if(!r&&!c.noBubble&&!y(n)){for(s=c.delegateType||d,Dt.test(s+d)||(o=o.parentNode);o;o=o.parentNode)p.push(o),a=o;a===(n.ownerDocument||C)&&p.push(a.defaultView||a.parentWindow||ie)}i=0;while((o=p[i++])&&!e.isPropagationStopped())f=o,e.type=1<i?s:c.bindType||d,(l=(_.get(o,"events")||Object.create(null))[e.type]&&_.get(o,"handle"))&&l.apply(o,t),(l=u&&o[u])&&l.apply&&$(o)&&(e.result=l.apply(o,t),!1===e.result&&e.preventDefault());return e.type=d,r||e.isDefaultPrevented()||c._default&&!1!==c._default.apply(p.pop(),t)||!$(n)||u&&v(n[d])&&!y(n)&&((a=n[u])&&(n[u]=null),ce.event.triggered=d,e.isPropagationStopped()&&f.addEventListener(d,Nt),n[d](),e.isPropagationStopped()&&f.removeEventListener(d,Nt),ce.event.triggered=void 0,a&&(n[u]=a)),e.result}},simulate:function(e,t,n){var r=ce.extend(new ce.Event,n,{type:e,isSimulated:!0});ce.event.trigger(r,null,t)}}),ce.fn.extend({trigger:function(e,t){return this.each(function(){ce.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return ce.event.trigger(e,t,n,!0)}});var qt=/\[\]$/,Lt=/\r?\n/g,Ht=/^(?:submit|button|image|reset|file)$/i,Ot=/^(?:input|select|textarea|keygen)/i;function Pt(n,e,r,i){var t;if(Array.isArray(e))ce.each(e,function(e,t){r||qt.test(n)?i(n,t):Pt(n+"["+("object"==typeof t&&null!=t?e:"")+"]",t,r,i)});else if(r||"object"!==x(e))i(n,e);else for(t in e)Pt(n+"["+t+"]",e[t],r,i)}ce.param=function(e,t){var n,r=[],i=function(e,t){var n=v(t)?t():t;r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(null==e)return"";if(Array.isArray(e)||e.jquery&&!ce.isPlainObject(e))ce.each(e,function(){i(this.name,this.value)});else for(n in e)Pt(n,e[n],t,i);return r.join("&")},ce.fn.extend({serialize:function(){return ce.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=ce.prop(this,"elements");return e?ce.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!ce(this).is(":disabled")&&Ot.test(this.nodeName)&&!Ht.test(e)&&(this.checked||!we.test(e))}).map(function(e,t){var n=ce(this).val();return null==n?null:Array.isArray(n)?ce.map(n,function(e){return{name:t.name,value:e.replace(Lt,"\r\n")}}):{name:t.name,value:n.replace(Lt,"\r\n")}}).get()}});var Mt=/%20/g,Rt=/#.*$/,It=/([?&])_=[^&]*/,Wt=/^(.*?):[ \t]*([^\r\n]*)$/gm,Ft=/^(?:GET|HEAD)$/,$t=/^\/\//,Bt={},_t={},zt="*/".concat("*"),Xt=C.createElement("a");function Ut(o){return function(e,t){"string"!=typeof e&&(t=e,e="*");var n,r=0,i=e.toLowerCase().match(D)||[];if(v(t))while(n=i[r++])"+"===n[0]?(n=n.slice(1)||"*",(o[n]=o[n]||[]).unshift(t)):(o[n]=o[n]||[]).push(t)}}function Vt(t,i,o,a){var s={},u=t===_t;function l(e){var r;return s[e]=!0,ce.each(t[e]||[],function(e,t){var n=t(i,o,a);return"string"!=typeof n||u||s[n]?u?!(r=n):void 0:(i.dataTypes.unshift(n),l(n),!1)}),r}return l(i.dataTypes[0])||!s["*"]&&l("*")}function Gt(e,t){var n,r,i=ce.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&ce.extend(!0,e,r),e}Xt.href=Et.href,ce.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Et.href,type:"GET",isLocal:/^(?:about|app|app-storage|.+-extension|file|res|widget):$/.test(Et.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":zt,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":ce.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?Gt(Gt(e,ce.ajaxSettings),t):Gt(ce.ajaxSettings,e)},ajaxPrefilter:Ut(Bt),ajaxTransport:Ut(_t),ajax:function(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};var c,f,p,n,d,r,h,g,i,o,v=ce.ajaxSetup({},t),y=v.context||v,m=v.context&&(y.nodeType||y.jquery)?ce(y):ce.event,x=ce.Deferred(),b=ce.Callbacks("once memory"),w=v.statusCode||{},a={},s={},u="canceled",T={readyState:0,getResponseHeader:function(e){var t;if(h){if(!n){n={};while(t=Wt.exec(p))n[t[1].toLowerCase()+" "]=(n[t[1].toLowerCase()+" "]||[]).concat(t[2])}t=n[e.toLowerCase()+" "]}return null==t?null:t.join(", ")},getAllResponseHeaders:function(){return h?p:null},setRequestHeader:function(e,t){return null==h&&(e=s[e.toLowerCase()]=s[e.toLowerCase()]||e,a[e]=t),this},overrideMimeType:function(e){return null==h&&(v.mimeType=e),this},statusCode:function(e){var t;if(e)if(h)T.always(e[T.status]);else for(t in e)w[t]=[w[t],e[t]];return this},abort:function(e){var t=e||u;return c&&c.abort(t),l(0,t),this}};if(x.promise(T),v.url=((e||v.url||Et.href)+"").replace($t,Et.protocol+"//"),v.type=t.method||t.type||v.method||v.type,v.dataTypes=(v.dataType||"*").toLowerCase().match(D)||[""],null==v.crossDomain){r=C.createElement("a");try{r.href=v.url,r.href=r.href,v.crossDomain=Xt.protocol+"//"+Xt.host!=r.protocol+"//"+r.host}catch(e){v.crossDomain=!0}}if(v.data&&v.processData&&"string"!=typeof v.data&&(v.data=ce.param(v.data,v.traditional)),Vt(Bt,v,t,T),h)return T;for(i in(g=ce.event&&v.global)&&0==ce.active++&&ce.event.trigger("ajaxStart"),v.type=v.type.toUpperCase(),v.hasContent=!Ft.test(v.type),f=v.url.replace(Rt,""),v.hasContent?v.data&&v.processData&&0===(v.contentType||"").indexOf("application/x-www-form-urlencoded")&&(v.data=v.data.replace(Mt,"+")):(o=v.url.slice(f.length),v.data&&(v.processData||"string"==typeof v.data)&&(f+=(At.test(f)?"&":"?")+v.data,delete v.data),!1===v.cache&&(f=f.replace(It,"$1"),o=(At.test(f)?"&":"?")+"_="+jt.guid+++o),v.url=f+o),v.ifModified&&(ce.lastModified[f]&&T.setRequestHeader("If-Modified-Since",ce.lastModified[f]),ce.etag[f]&&T.setRequestHeader("If-None-Match",ce.etag[f])),(v.data&&v.hasContent&&!1!==v.contentType||t.contentType)&&T.setRequestHeader("Content-Type",v.contentType),T.setRequestHeader("Accept",v.dataTypes[0]&&v.accepts[v.dataTypes[0]]?v.accepts[v.dataTypes[0]]+("*"!==v.dataTypes[0]?", "+zt+"; q=0.01":""):v.accepts["*"]),v.headers)T.setRequestHeader(i,v.headers[i]);if(v.beforeSend&&(!1===v.beforeSend.call(y,T,v)||h))return T.abort();if(u="abort",b.add(v.complete),T.done(v.success),T.fail(v.error),c=Vt(_t,v,t,T)){if(T.readyState=1,g&&m.trigger("ajaxSend",[T,v]),h)return T;v.async&&0<v.timeout&&(d=ie.setTimeout(function(){T.abort("timeout")},v.timeout));try{h=!1,c.send(a,l)}catch(e){if(h)throw e;l(-1,e)}}else l(-1,"No Transport");function l(e,t,n,r){var i,o,a,s,u,l=t;h||(h=!0,d&&ie.clearTimeout(d),c=void 0,p=r||"",T.readyState=0<e?4:0,i=200<=e&&e<300||304===e,n&&(s=function(e,t,n){var r,i,o,a,s=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),void 0===r&&(r=e.mimeType||t.getResponseHeader("Content-Type"));if(r)for(i in s)if(s[i]&&s[i].test(r)){u.unshift(i);break}if(u[0]in n)o=u[0];else{for(i in n){if(!u[0]||e.converters[i+" "+u[0]]){o=i;break}a||(a=i)}o=o||a}if(o)return o!==u[0]&&u.unshift(o),n[o]}(v,T,n)),!i&&-1<ce.inArray("script",v.dataTypes)&&ce.inArray("json",v.dataTypes)<0&&(v.converters["text script"]=function(){}),s=function(e,t,n,r){var i,o,a,s,u,l={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)l[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift())if("*"===o)o=u;else if("*"!==u&&u!==o){if(!(a=l[u+" "+o]||l["* "+o]))for(i in l)if((s=i.split(" "))[1]===o&&(a=l[u+" "+s[0]]||l["* "+s[0]])){!0===a?a=l[i]:!0!==l[i]&&(o=s[0],c.unshift(s[1]));break}if(!0!==a)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(e){return{state:"parsererror",error:a?e:"No conversion from "+u+" to "+o}}}return{state:"success",data:t}}(v,s,T,i),i?(v.ifModified&&((u=T.getResponseHeader("Last-Modified"))&&(ce.lastModified[f]=u),(u=T.getResponseHeader("etag"))&&(ce.etag[f]=u)),204===e||"HEAD"===v.type?l="nocontent":304===e?l="notmodified":(l=s.state,o=s.data,i=!(a=s.error))):(a=l,!e&&l||(l="error",e<0&&(e=0))),T.status=e,T.statusText=(t||l)+"",i?x.resolveWith(y,[o,l,T]):x.rejectWith(y,[T,l,a]),T.statusCode(w),w=void 0,g&&m.trigger(i?"ajaxSuccess":"ajaxError",[T,v,i?o:a]),b.fireWith(y,[T,l]),g&&(m.trigger("ajaxComplete",[T,v]),--ce.active||ce.event.trigger("ajaxStop")))}return T},getJSON:function(e,t,n){return ce.get(e,t,n,"json")},getScript:function(e,t){return ce.get(e,void 0,t,"script")}}),ce.each(["get","post"],function(e,i){ce[i]=function(e,t,n,r){return v(t)&&(r=r||n,n=t,t=void 0),ce.ajax(ce.extend({url:e,type:i,dataType:r,data:t,success:n},ce.isPlainObject(e)&&e))}}),ce.ajaxPrefilter(function(e){var t;for(t in e.headers)"content-type"===t.toLowerCase()&&(e.contentType=e.headers[t]||"")}),ce._evalUrl=function(e,t,n){return ce.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,converters:{"text script":function(){}},dataFilter:function(e){ce.globalEval(e,t,n)}})},ce.fn.extend({wrapAll:function(e){var t;return this[0]&&(v(e)&&(e=e.call(this[0])),t=ce(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstElementChild)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(n){return v(n)?this.each(function(e){ce(this).wrapInner(n.call(this,e))}):this.each(function(){var e=ce(this),t=e.contents();t.length?t.wrapAll(n):e.append(n)})},wrap:function(t){var n=v(t);return this.each(function(e){ce(this).wrapAll(n?t.call(this,e):t)})},unwrap:function(e){return this.parent(e).not("body").each(function(){ce(this).replaceWith(this.childNodes)}),this}}),ce.expr.pseudos.hidden=function(e){return!ce.expr.pseudos.visible(e)},ce.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},ce.ajaxSettings.xhr=function(){try{return new ie.XMLHttpRequest}catch(e){}};var Yt={0:200,1223:204},Qt=ce.ajaxSettings.xhr();le.cors=!!Qt&&"withCredentials"in Qt,le.ajax=Qt=!!Qt,ce.ajaxTransport(function(i){var o,a;if(le.cors||Qt&&!i.crossDomain)return{send:function(e,t){var n,r=i.xhr();if(r.open(i.type,i.url,i.async,i.username,i.password),i.xhrFields)for(n in i.xhrFields)r[n]=i.xhrFields[n];for(n in i.mimeType&&r.overrideMimeType&&r.overrideMimeType(i.mimeType),i.crossDomain||e["X-Requested-With"]||(e["X-Requested-With"]="XMLHttpRequest"),e)r.setRequestHeader(n,e[n]);o=function(e){return function(){o&&(o=a=r.onload=r.onerror=r.onabort=r.ontimeout=r.onreadystatechange=null,"abort"===e?r.abort():"error"===e?"number"!=typeof r.status?t(0,"error"):t(r.status,r.statusText):t(Yt[r.status]||r.status,r.statusText,"text"!==(r.responseType||"text")||"string"!=typeof r.responseText?{binary:r.response}:{text:r.responseText},r.getAllResponseHeaders()))}},r.onload=o(),a=r.onerror=r.ontimeout=o("error"),void 0!==r.onabort?r.onabort=a:r.onreadystatechange=function(){4===r.readyState&&ie.setTimeout(function(){o&&a()})},o=o("abort");try{r.send(i.hasContent&&i.data||null)}catch(e){if(o)throw e}},abort:function(){o&&o()}}}),ce.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),ce.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return ce.globalEval(e),e}}}),ce.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),ce.ajaxTransport("script",function(n){var r,i;if(n.crossDomain||n.scriptAttrs)return{send:function(e,t){r=ce("<script>").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),C.head.appendChild(r[0])},abort:function(){i&&i()}}});var Jt,Kt=[],Zt=/(=)\?(?=&|$)|\?\?/;ce.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Kt.pop()||ce.expando+"_"+jt.guid++;return this[e]=!0,e}}),ce.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Zt.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Zt.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=v(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Zt,"$1"+r):!1!==e.jsonp&&(e.url+=(At.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||ce.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=ie[r],ie[r]=function(){o=arguments},n.always(function(){void 0===i?ce(ie).removeProp(r):ie[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,Kt.push(r)),o&&v(i)&&i(o[0]),o=i=void 0}),"script"}),le.createHTMLDocument=((Jt=C.implementation.createHTMLDocument("").body).innerHTML="<form></form><form></form>",2===Jt.childNodes.length),ce.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(le.createHTMLDocument?((r=(t=C.implementation.createHTMLDocument("")).createElement("base")).href=C.location.href,t.head.appendChild(r)):t=C),o=!n&&[],(i=w.exec(e))?[t.createElement(i[1])]:(i=Ae([e],t,o),o&&o.length&&ce(o).remove(),ce.merge([],i.childNodes)));var r,i,o},ce.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1<s&&(r=Tt(e.slice(s)),e=e.slice(0,s)),v(t)?(n=t,t=void 0):t&&"object"==typeof t&&(i="POST"),0<a.length&&ce.ajax({url:e,type:i||"GET",dataType:"html",data:t}).done(function(e){o=arguments,a.html(r?ce("<div>").append(ce.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},ce.expr.pseudos.animated=function(t){return ce.grep(ce.timers,function(e){return t===e.elem}).length},ce.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=ce.css(e,"position"),c=ce(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=ce.css(e,"top"),u=ce.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),v(t)&&(t=t.call(e,n,ce.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},ce.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){ce.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===ce.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===ce.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=ce(e).offset()).top+=ce.css(e,"borderTopWidth",!0),i.left+=ce.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-ce.css(r,"marginTop",!0),left:t.left-i.left-ce.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===ce.css(e,"position"))e=e.offsetParent;return e||J})}}),ce.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;ce.fn[t]=function(e){return M(this,function(e,t,n){var r;if(y(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),ce.each(["top","left"],function(e,n){ce.cssHooks[n]=Ye(le.pixelPosition,function(e,t){if(t)return t=Ge(e,n),_e.test(t)?ce(e).position()[n]+"px":t})}),ce.each({Height:"height",Width:"width"},function(a,s){ce.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){ce.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return M(this,function(e,t,n){var r;return y(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?ce.css(e,t,i):ce.style(e,t,n,i)},s,n?e:void 0,n)}})}),ce.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){ce.fn[t]=function(e){return this.on(t,e)}}),ce.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.on("mouseenter",e).on("mouseleave",t||e)}}),ce.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){ce.fn[n]=function(e,t){return 0<arguments.length?this.on(n,null,e,t):this.trigger(n)}});var en=/^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;ce.proxy=function(e,t){var n,r,i;if("string"==typeof t&&(n=e[t],t=e,e=n),v(e))return r=ae.call(arguments,2),(i=function(){return e.apply(t||this,r.concat(ae.call(arguments)))}).guid=e.guid=e.guid||ce.guid++,i},ce.holdReady=function(e){e?ce.readyWait++:ce.ready(!0)},ce.isArray=Array.isArray,ce.parseJSON=JSON.parse,ce.nodeName=fe,ce.isFunction=v,ce.isWindow=y,ce.camelCase=F,ce.type=x,ce.now=Date.now,ce.isNumeric=function(e){var t=ce.type(e);return("number"===t||"string"===t)&&!isNaN(e-parseFloat(e))},ce.trim=function(e){return null==e?"":(e+"").replace(en,"$1")},"function"==typeof define&&define.amd&&define("jquery",[],function(){return ce});var tn=ie.jQuery,nn=ie.$;return ce.noConflict=function(e){return ie.$===ce&&(ie.$=nn),e&&ie.jQuery===ce&&(ie.jQuery=tn),ce},"undefined"==typeof e&&(ie.jQuery=ie.$=ce),ce});
  3. /*!
  4. * Bootstrap v3.4.1 (https://getbootstrap.com/)
  5. * Copyright 2011-2019 Twitter, Inc.
  6. * Licensed under the MIT license
  7. */
  8. if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");!function(t){"use strict";var e=jQuery.fn.jquery.split(" ")[0].split(".");if(e[0]<2&&e[1]<9||1==e[0]&&9==e[1]&&e[2]<1||3<e[0])throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4")}(),function(n){"use strict";n.fn.emulateTransitionEnd=function(t){var e=!1,i=this;n(this).one("bsTransitionEnd",function(){e=!0});return setTimeout(function(){e||n(i).trigger(n.support.transition.end)},t),this},n(function(){n.support.transition=function o(){var t=document.createElement("bootstrap"),e={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var i in e)if(t.style[i]!==undefined)return{end:e[i]};return!1}(),n.support.transition&&(n.event.special.bsTransitionEnd={bindType:n.support.transition.end,delegateType:n.support.transition.end,handle:function(t){if(n(t.target).is(this))return t.handleObj.handler.apply(this,arguments)}})})}(jQuery),function(s){"use strict";var e='[data-dismiss="alert"]',a=function(t){s(t).on("click",e,this.close)};a.VERSION="3.4.1",a.TRANSITION_DURATION=150,a.prototype.close=function(t){var e=s(this),i=e.attr("data-target");i||(i=(i=e.attr("href"))&&i.replace(/.*(?=#[^\s]*$)/,"")),i="#"===i?[]:i;var o=s(document).find(i);function n(){o.detach().trigger("closed.bs.alert").remove()}t&&t.preventDefault(),o.length||(o=e.closest(".alert")),o.trigger(t=s.Event("close.bs.alert")),t.isDefaultPrevented()||(o.removeClass("in"),s.support.transition&&o.hasClass("fade")?o.one("bsTransitionEnd",n).emulateTransitionEnd(a.TRANSITION_DURATION):n())};var t=s.fn.alert;s.fn.alert=function o(i){return this.each(function(){var t=s(this),e=t.data("bs.alert");e||t.data("bs.alert",e=new a(this)),"string"==typeof i&&e[i].call(t)})},s.fn.alert.Constructor=a,s.fn.alert.noConflict=function(){return s.fn.alert=t,this},s(document).on("click.bs.alert.data-api",e,a.prototype.close)}(jQuery),function(s){"use strict";var n=function(t,e){this.$element=s(t),this.options=s.extend({},n.DEFAULTS,e),this.isLoading=!1};function i(o){return this.each(function(){var t=s(this),e=t.data("bs.button"),i="object"==typeof o&&o;e||t.data("bs.button",e=new n(this,i)),"toggle"==o?e.toggle():o&&e.setState(o)})}n.VERSION="3.4.1",n.DEFAULTS={loadingText:"loading..."},n.prototype.setState=function(t){var e="disabled",i=this.$element,o=i.is("input")?"val":"html",n=i.data();t+="Text",null==n.resetText&&i.data("resetText",i[o]()),setTimeout(s.proxy(function(){i[o](null==n[t]?this.options[t]:n[t]),"loadingText"==t?(this.isLoading=!0,i.addClass(e).attr(e,e).prop(e,!0)):this.isLoading&&(this.isLoading=!1,i.removeClass(e).removeAttr(e).prop(e,!1))},this),0)},n.prototype.toggle=function(){var t=!0,e=this.$element.closest('[data-toggle="buttons"]');if(e.length){var i=this.$element.find("input");"radio"==i.prop("type")?(i.prop("checked")&&(t=!1),e.find(".active").removeClass("active"),this.$element.addClass("active")):"checkbox"==i.prop("type")&&(i.prop("checked")!==this.$element.hasClass("active")&&(t=!1),this.$element.toggleClass("active")),i.prop("checked",this.$element.hasClass("active")),t&&i.trigger("change")}else this.$element.attr("aria-pressed",!this.$element.hasClass("active")),this.$element.toggleClass("active")};var t=s.fn.button;s.fn.button=i,s.fn.button.Constructor=n,s.fn.button.noConflict=function(){return s.fn.button=t,this},s(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(t){var e=s(t.target).closest(".btn");i.call(e,"toggle"),s(t.target).is('input[type="radio"], input[type="checkbox"]')||(t.preventDefault(),e.is("input,button")?e.trigger("focus"):e.find("input:visible,button:visible").first().trigger("focus"))}).on("focus.bs.button.data-api blur.bs.button.data-api",'[data-toggle^="button"]',function(t){s(t.target).closest(".btn").toggleClass("focus",/^focus(in)?$/.test(t.type))})}(jQuery),function(p){"use strict";var c=function(t,e){this.$element=p(t),this.$indicators=this.$element.find(".carousel-indicators"),this.options=e,this.paused=null,this.sliding=null,this.interval=null,this.$active=null,this.$items=null,this.options.keyboard&&this.$element.on("keydown.bs.carousel",p.proxy(this.keydown,this)),"hover"==this.options.pause&&!("ontouchstart"in document.documentElement)&&this.$element.on("mouseenter.bs.carousel",p.proxy(this.pause,this)).on("mouseleave.bs.carousel",p.proxy(this.cycle,this))};function r(n){return this.each(function(){var t=p(this),e=t.data("bs.carousel"),i=p.extend({},c.DEFAULTS,t.data(),"object"==typeof n&&n),o="string"==typeof n?n:i.slide;e||t.data("bs.carousel",e=new c(this,i)),"number"==typeof n?e.to(n):o?e[o]():i.interval&&e.pause().cycle()})}c.VERSION="3.4.1",c.TRANSITION_DURATION=600,c.DEFAULTS={interval:5e3,pause:"hover",wrap:!0,keyboard:!0},c.prototype.keydown=function(t){if(!/input|textarea/i.test(t.target.tagName)){switch(t.which){case 37:this.prev();break;case 39:this.next();break;default:return}t.preventDefault()}},c.prototype.cycle=function(t){return t||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(p.proxy(this.next,this),this.options.interval)),this},c.prototype.getItemIndex=function(t){return this.$items=t.parent().children(".item"),this.$items.index(t||this.$active)},c.prototype.getItemForDirection=function(t,e){var i=this.getItemIndex(e);if(("prev"==t&&0===i||"next"==t&&i==this.$items.length-1)&&!this.options.wrap)return e;var o=(i+("prev"==t?-1:1))%this.$items.length;return this.$items.eq(o)},c.prototype.to=function(t){var e=this,i=this.getItemIndex(this.$active=this.$element.find(".item.active"));if(!(t>this.$items.length-1||t<0))return this.sliding?this.$element.one("slid.bs.carousel",function(){e.to(t)}):i==t?this.pause().cycle():this.slide(i<t?"next":"prev",this.$items.eq(t))},c.prototype.pause=function(t){return t||(this.paused=!0),this.$element.find(".next, .prev").length&&p.support.transition&&(this.$element.trigger(p.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},c.prototype.next=function(){if(!this.sliding)return this.slide("next")},c.prototype.prev=function(){if(!this.sliding)return this.slide("prev")},c.prototype.slide=function(t,e){var i=this.$element.find(".item.active"),o=e||this.getItemForDirection(t,i),n=this.interval,s="next"==t?"left":"right",a=this;if(o.hasClass("active"))return this.sliding=!1;var r=o[0],l=p.Event("slide.bs.carousel",{relatedTarget:r,direction:s});if(this.$element.trigger(l),!l.isDefaultPrevented()){if(this.sliding=!0,n&&this.pause(),this.$indicators.length){this.$indicators.find(".active").removeClass("active");var h=p(this.$indicators.children()[this.getItemIndex(o)]);h&&h.addClass("active")}var d=p.Event("slid.bs.carousel",{relatedTarget:r,direction:s});return p.support.transition&&this.$element.hasClass("slide")?(o.addClass(t),"object"==typeof o&&o.length&&o[0].offsetWidth,i.addClass(s),o.addClass(s),i.one("bsTransitionEnd",function(){o.removeClass([t,s].join(" ")).addClass("active"),i.removeClass(["active",s].join(" ")),a.sliding=!1,setTimeout(function(){a.$element.trigger(d)},0)}).emulateTransitionEnd(c.TRANSITION_DURATION)):(i.removeClass("active"),o.addClass("active"),this.sliding=!1,this.$element.trigger(d)),n&&this.cycle(),this}};var t=p.fn.carousel;p.fn.carousel=r,p.fn.carousel.Constructor=c,p.fn.carousel.noConflict=function(){return p.fn.carousel=t,this};var e=function(t){var e=p(this),i=e.attr("href");i&&(i=i.replace(/.*(?=#[^\s]+$)/,""));var o=e.attr("data-target")||i,n=p(document).find(o);if(n.hasClass("carousel")){var s=p.extend({},n.data(),e.data()),a=e.attr("data-slide-to");a&&(s.interval=!1),r.call(n,s),a&&n.data("bs.carousel").to(a),t.preventDefault()}};p(document).on("click.bs.carousel.data-api","[data-slide]",e).on("click.bs.carousel.data-api","[data-slide-to]",e),p(window).on("load",function(){p('[data-ride="carousel"]').each(function(){var t=p(this);r.call(t,t.data())})})}(jQuery),function(a){"use strict";var r=function(t,e){this.$element=a(t),this.options=a.extend({},r.DEFAULTS,e),this.$trigger=a('[data-toggle="collapse"][href="#'+t.id+'"],[data-toggle="collapse"][data-target="#'+t.id+'"]'),this.transitioning=null,this.options.parent?this.$parent=this.getParent():this.addAriaAndCollapsedClass(this.$element,this.$trigger),this.options.toggle&&this.toggle()};function n(t){var e,i=t.attr("data-target")||(e=t.attr("href"))&&e.replace(/.*(?=#[^\s]+$)/,"");return a(document).find(i)}function l(o){return this.each(function(){var t=a(this),e=t.data("bs.collapse"),i=a.extend({},r.DEFAULTS,t.data(),"object"==typeof o&&o);!e&&i.toggle&&/show|hide/.test(o)&&(i.toggle=!1),e||t.data("bs.collapse",e=new r(this,i)),"string"==typeof o&&e[o]()})}r.VERSION="3.4.1",r.TRANSITION_DURATION=350,r.DEFAULTS={toggle:!0},r.prototype.dimension=function(){return this.$element.hasClass("width")?"width":"height"},r.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var t,e=this.$parent&&this.$parent.children(".panel").children(".in, .collapsing");if(!(e&&e.length&&(t=e.data("bs.collapse"))&&t.transitioning)){var i=a.Event("show.bs.collapse");if(this.$element.trigger(i),!i.isDefaultPrevented()){e&&e.length&&(l.call(e,"hide"),t||e.data("bs.collapse",null));var o=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[o](0).attr("aria-expanded",!0),this.$trigger.removeClass("collapsed").attr("aria-expanded",!0),this.transitioning=1;var n=function(){this.$element.removeClass("collapsing").addClass("collapse in")[o](""),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!a.support.transition)return n.call(this);var s=a.camelCase(["scroll",o].join("-"));this.$element.one("bsTransitionEnd",a.proxy(n,this)).emulateTransitionEnd(r.TRANSITION_DURATION)[o](this.$element[0][s])}}}},r.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var t=a.Event("hide.bs.collapse");if(this.$element.trigger(t),!t.isDefaultPrevented()){var e=this.dimension();this.$element[e](this.$element[e]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse in").attr("aria-expanded",!1),this.$trigger.addClass("collapsed").attr("aria-expanded",!1),this.transitioning=1;var i=function(){this.transitioning=0,this.$element.removeClass("collapsing").addClass("collapse").trigger("hidden.bs.collapse")};if(!a.support.transition)return i.call(this);this.$element[e](0).one("bsTransitionEnd",a.proxy(i,this)).emulateTransitionEnd(r.TRANSITION_DURATION)}}},r.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()},r.prototype.getParent=function(){return a(document).find(this.options.parent).find('[data-toggle="collapse"][data-parent="'+this.options.parent+'"]').each(a.proxy(function(t,e){var i=a(e);this.addAriaAndCollapsedClass(n(i),i)},this)).end()},r.prototype.addAriaAndCollapsedClass=function(t,e){var i=t.hasClass("in");t.attr("aria-expanded",i),e.toggleClass("collapsed",!i).attr("aria-expanded",i)};var t=a.fn.collapse;a.fn.collapse=l,a.fn.collapse.Constructor=r,a.fn.collapse.noConflict=function(){return a.fn.collapse=t,this},a(document).on("click.bs.collapse.data-api",'[data-toggle="collapse"]',function(t){var e=a(this);e.attr("data-target")||t.preventDefault();var i=n(e),o=i.data("bs.collapse")?"toggle":e.data();l.call(i,o)})}(jQuery),function(a){"use strict";var r='[data-toggle="dropdown"]',o=function(t){a(t).on("click.bs.dropdown",this.toggle)};function l(t){var e=t.attr("data-target");e||(e=(e=t.attr("href"))&&/#[A-Za-z]/.test(e)&&e.replace(/.*(?=#[^\s]*$)/,""));var i="#"!==e?a(document).find(e):null;return i&&i.length?i:t.parent()}function s(o){o&&3===o.which||(a(".dropdown-backdrop").remove(),a(r).each(function(){var t=a(this),e=l(t),i={relatedTarget:this};e.hasClass("open")&&(o&&"click"==o.type&&/input|textarea/i.test(o.target.tagName)&&a.contains(e[0],o.target)||(e.trigger(o=a.Event("hide.bs.dropdown",i)),o.isDefaultPrevented()||(t.attr("aria-expanded","false"),e.removeClass("open").trigger(a.Event("hidden.bs.dropdown",i)))))}))}o.VERSION="3.4.1",o.prototype.toggle=function(t){var e=a(this);if(!e.is(".disabled, :disabled")){var i=l(e),o=i.hasClass("open");if(s(),!o){"ontouchstart"in document.documentElement&&!i.closest(".navbar-nav").length&&a(document.createElement("div")).addClass("dropdown-backdrop").insertAfter(a(this)).on("click",s);var n={relatedTarget:this};if(i.trigger(t=a.Event("show.bs.dropdown",n)),t.isDefaultPrevented())return;e.trigger("focus").attr("aria-expanded","true"),i.toggleClass("open").trigger(a.Event("shown.bs.dropdown",n))}return!1}},o.prototype.keydown=function(t){if(/(38|40|27|32)/.test(t.which)&&!/input|textarea/i.test(t.target.tagName)){var e=a(this);if(t.preventDefault(),t.stopPropagation(),!e.is(".disabled, :disabled")){var i=l(e),o=i.hasClass("open");if(!o&&27!=t.which||o&&27==t.which)return 27==t.which&&i.find(r).trigger("focus"),e.trigger("click");var n=i.find(".dropdown-menu li:not(.disabled):visible a");if(n.length){var s=n.index(t.target);38==t.which&&0<s&&s--,40==t.which&&s<n.length-1&&s++,~s||(s=0),n.eq(s).trigger("focus")}}}};var t=a.fn.dropdown;a.fn.dropdown=function e(i){return this.each(function(){var t=a(this),e=t.data("bs.dropdown");e||t.data("bs.dropdown",e=new o(this)),"string"==typeof i&&e[i].call(t)})},a.fn.dropdown.Constructor=o,a.fn.dropdown.noConflict=function(){return a.fn.dropdown=t,this},a(document).on("click.bs.dropdown.data-api",s).on("click.bs.dropdown.data-api",".dropdown form",function(t){t.stopPropagation()}).on("click.bs.dropdown.data-api",r,o.prototype.toggle).on("keydown.bs.dropdown.data-api",r,o.prototype.keydown).on("keydown.bs.dropdown.data-api",".dropdown-menu",o.prototype.keydown)}(jQuery),function(a){"use strict";var s=function(t,e){this.options=e,this.$body=a(document.body),this.$element=a(t),this.$dialog=this.$element.find(".modal-dialog"),this.$backdrop=null,this.isShown=null,this.originalBodyPad=null,this.scrollbarWidth=0,this.ignoreBackdropClick=!1,this.fixedContent=".navbar-fixed-top, .navbar-fixed-bottom",this.options.remote&&this.$element.find(".modal-content").load(this.options.remote,a.proxy(function(){this.$element.trigger("loaded.bs.modal")},this))};function r(o,n){return this.each(function(){var t=a(this),e=t.data("bs.modal"),i=a.extend({},s.DEFAULTS,t.data(),"object"==typeof o&&o);e||t.data("bs.modal",e=new s(this,i)),"string"==typeof o?e[o](n):i.show&&e.show(n)})}s.VERSION="3.4.1",s.TRANSITION_DURATION=300,s.BACKDROP_TRANSITION_DURATION=150,s.DEFAULTS={backdrop:!0,keyboard:!0,show:!0},s.prototype.toggle=function(t){return this.isShown?this.hide():this.show(t)},s.prototype.show=function(i){var o=this,t=a.Event("show.bs.modal",{relatedTarget:i});this.$element.trigger(t),this.isShown||t.isDefaultPrevented()||(this.isShown=!0,this.checkScrollbar(),this.setScrollbar(),this.$body.addClass("modal-open"),this.escape(),this.resize(),this.$element.on("click.dismiss.bs.modal",'[data-dismiss="modal"]',a.proxy(this.hide,this)),this.$dialog.on("mousedown.dismiss.bs.modal",function(){o.$element.one("mouseup.dismiss.bs.modal",function(t){a(t.target).is(o.$element)&&(o.ignoreBackdropClick=!0)})}),this.backdrop(function(){var t=a.support.transition&&o.$element.hasClass("fade");o.$element.parent().length||o.$element.appendTo(o.$body),o.$element.show().scrollTop(0),o.adjustDialog(),t&&o.$element[0].offsetWidth,o.$element.addClass("in"),o.enforceFocus();var e=a.Event("shown.bs.modal",{relatedTarget:i});t?o.$dialog.one("bsTransitionEnd",function(){o.$element.trigger("focus").trigger(e)}).emulateTransitionEnd(s.TRANSITION_DURATION):o.$element.trigger("focus").trigger(e)}))},s.prototype.hide=function(t){t&&t.preventDefault(),t=a.Event("hide.bs.modal"),this.$element.trigger(t),this.isShown&&!t.isDefaultPrevented()&&(this.isShown=!1,this.escape(),this.resize(),a(document).off("focusin.bs.modal"),this.$element.removeClass("in").off("click.dismiss.bs.modal").off("mouseup.dismiss.bs.modal"),this.$dialog.off("mousedown.dismiss.bs.modal"),a.support.transition&&this.$element.hasClass("fade")?this.$element.one("bsTransitionEnd",a.proxy(this.hideModal,this)).emulateTransitionEnd(s.TRANSITION_DURATION):this.hideModal())},s.prototype.enforceFocus=function(){a(document).off("focusin.bs.modal").on("focusin.bs.modal",a.proxy(function(t){document===t.target||this.$element[0]===t.target||this.$element.has(t.target).length||this.$element.trigger("focus")},this))},s.prototype.escape=function(){this.isShown&&this.options.keyboard?this.$element.on("keydown.dismiss.bs.modal",a.proxy(function(t){27==t.which&&this.hide()},this)):this.isShown||this.$element.off("keydown.dismiss.bs.modal")},s.prototype.resize=function(){this.isShown?a(window).on("resize.bs.modal",a.proxy(this.handleUpdate,this)):a(window).off("resize.bs.modal")},s.prototype.hideModal=function(){var t=this;this.$element.hide(),this.backdrop(function(){t.$body.removeClass("modal-open"),t.resetAdjustments(),t.resetScrollbar(),t.$element.trigger("hidden.bs.modal")})},s.prototype.removeBackdrop=function(){this.$backdrop&&this.$backdrop.remove(),this.$backdrop=null},s.prototype.backdrop=function(t){var e=this,i=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var o=a.support.transition&&i;if(this.$backdrop=a(document.createElement("div")).addClass("modal-backdrop "+i).appendTo(this.$body),this.$element.on("click.dismiss.bs.modal",a.proxy(function(t){this.ignoreBackdropClick?this.ignoreBackdropClick=!1:t.target===t.currentTarget&&("static"==this.options.backdrop?this.$element[0].focus():this.hide())},this)),o&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),!t)return;o?this.$backdrop.one("bsTransitionEnd",t).emulateTransitionEnd(s.BACKDROP_TRANSITION_DURATION):t()}else if(!this.isShown&&this.$backdrop){this.$backdrop.removeClass("in");var n=function(){e.removeBackdrop(),t&&t()};a.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one("bsTransitionEnd",n).emulateTransitionEnd(s.BACKDROP_TRANSITION_DURATION):n()}else t&&t()},s.prototype.handleUpdate=function(){this.adjustDialog()},s.prototype.adjustDialog=function(){var t=this.$element[0].scrollHeight>document.documentElement.clientHeight;this.$element.css({paddingLeft:!this.bodyIsOverflowing&&t?this.scrollbarWidth:"",paddingRight:this.bodyIsOverflowing&&!t?this.scrollbarWidth:""})},s.prototype.resetAdjustments=function(){this.$element.css({paddingLeft:"",paddingRight:""})},s.prototype.checkScrollbar=function(){var t=window.innerWidth;if(!t){var e=document.documentElement.getBoundingClientRect();t=e.right-Math.abs(e.left)}this.bodyIsOverflowing=document.body.clientWidth<t,this.scrollbarWidth=this.measureScrollbar()},s.prototype.setScrollbar=function(){var t=parseInt(this.$body.css("padding-right")||0,10);this.originalBodyPad=document.body.style.paddingRight||"";var n=this.scrollbarWidth;this.bodyIsOverflowing&&(this.$body.css("padding-right",t+n),a(this.fixedContent).each(function(t,e){var i=e.style.paddingRight,o=a(e).css("padding-right");a(e).data("padding-right",i).css("padding-right",parseFloat(o)+n+"px")}))},s.prototype.resetScrollbar=function(){this.$body.css("padding-right",this.originalBodyPad),a(this.fixedContent).each(function(t,e){var i=a(e).data("padding-right");a(e).removeData("padding-right"),e.style.paddingRight=i||""})},s.prototype.measureScrollbar=function(){var t=document.createElement("div");t.className="modal-scrollbar-measure",this.$body.append(t);var e=t.offsetWidth-t.clientWidth;return this.$body[0].removeChild(t),e};var t=a.fn.modal;a.fn.modal=r,a.fn.modal.Constructor=s,a.fn.modal.noConflict=function(){return a.fn.modal=t,this},a(document).on("click.bs.modal.data-api",'[data-toggle="modal"]',function(t){var e=a(this),i=e.attr("href"),o=e.attr("data-target")||i&&i.replace(/.*(?=#[^\s]+$)/,""),n=a(document).find(o),s=n.data("bs.modal")?"toggle":a.extend({remote:!/#/.test(i)&&i},n.data(),e.data());e.is("a")&&t.preventDefault(),n.one("show.bs.modal",function(t){t.isDefaultPrevented()||n.one("hidden.bs.modal",function(){e.is(":visible")&&e.trigger("focus")})}),r.call(n,s,this)})}(jQuery),function(g){"use strict";var o=["sanitize","whiteList","sanitizeFn"],a=["background","cite","href","itemtype","longdesc","poster","src","xlink:href"],t={"*":["class","dir","id","lang","role",/^aria-[\w-]*$/i],a:["target","href","title","rel"],area:[],b:[],br:[],col:[],code:[],div:[],em:[],hr:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],i:[],img:["src","alt","title","width","height"],li:[],ol:[],p:[],pre:[],s:[],small:[],span:[],sub:[],sup:[],strong:[],u:[],ul:[]},r=/^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi,l=/^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;function u(t,e){var i=t.nodeName.toLowerCase();if(-1!==g.inArray(i,e))return-1===g.inArray(i,a)||Boolean(t.nodeValue.match(r)||t.nodeValue.match(l));for(var o=g(e).filter(function(t,e){return e instanceof RegExp}),n=0,s=o.length;n<s;n++)if(i.match(o[n]))return!0;return!1}function n(t,e,i){if(0===t.length)return t;if(i&&"function"==typeof i)return i(t);if(!document.implementation||!document.implementation.createHTMLDocument)return t;var o=document.implementation.createHTMLDocument("sanitization");o.body.innerHTML=t;for(var n=g.map(e,function(t,e){return e}),s=g(o.body).find("*"),a=0,r=s.length;a<r;a++){var l=s[a],h=l.nodeName.toLowerCase();if(-1!==g.inArray(h,n))for(var d=g.map(l.attributes,function(t){return t}),p=[].concat(e["*"]||[],e[h]||[]),c=0,f=d.length;c<f;c++)u(d[c],p)||l.removeAttribute(d[c].nodeName);else l.parentNode.removeChild(l)}return o.body.innerHTML}var m=function(t,e){this.type=null,this.options=null,this.enabled=null,this.timeout=null,this.hoverState=null,this.$element=null,this.inState=null,this.init("tooltip",t,e)};m.VERSION="3.4.1",m.TRANSITION_DURATION=150,m.DEFAULTS={animation:!0,placement:"top",selector:!1,template:'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:"hover focus",title:"",delay:0,html:!1,container:!1,viewport:{selector:"body",padding:0},sanitize:!0,sanitizeFn:null,whiteList:t},m.prototype.init=function(t,e,i){if(this.enabled=!0,this.type=t,this.$element=g(e),this.options=this.getOptions(i),this.$viewport=this.options.viewport&&g(document).find(g.isFunction(this.options.viewport)?this.options.viewport.call(this,this.$element):this.options.viewport.selector||this.options.viewport),this.inState={click:!1,hover:!1,focus:!1},this.$element[0]instanceof document.constructor&&!this.options.selector)throw new Error("`selector` option must be specified when initializing "+this.type+" on the window.document object!");for(var o=this.options.trigger.split(" "),n=o.length;n--;){var s=o[n];if("click"==s)this.$element.on("click."+this.type,this.options.selector,g.proxy(this.toggle,this));else if("manual"!=s){var a="hover"==s?"mouseenter":"focusin",r="hover"==s?"mouseleave":"focusout";this.$element.on(a+"."+this.type,this.options.selector,g.proxy(this.enter,this)),this.$element.on(r+"."+this.type,this.options.selector,g.proxy(this.leave,this))}}this.options.selector?this._options=g.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},m.prototype.getDefaults=function(){return m.DEFAULTS},m.prototype.getOptions=function(t){var e=this.$element.data();for(var i in e)e.hasOwnProperty(i)&&-1!==g.inArray(i,o)&&delete e[i];return(t=g.extend({},this.getDefaults(),e,t)).delay&&"number"==typeof t.delay&&(t.delay={show:t.delay,hide:t.delay}),t.sanitize&&(t.template=n(t.template,t.whiteList,t.sanitizeFn)),t},m.prototype.getDelegateOptions=function(){var i={},o=this.getDefaults();return this._options&&g.each(this._options,function(t,e){o[t]!=e&&(i[t]=e)}),i},m.prototype.enter=function(t){var e=t instanceof this.constructor?t:g(t.currentTarget).data("bs."+this.type);if(e||(e=new this.constructor(t.currentTarget,this.getDelegateOptions()),g(t.currentTarget).data("bs."+this.type,e)),t instanceof g.Event&&(e.inState["focusin"==t.type?"focus":"hover"]=!0),e.tip().hasClass("in")||"in"==e.hoverState)e.hoverState="in";else{if(clearTimeout(e.timeout),e.hoverState="in",!e.options.delay||!e.options.delay.show)return e.show();e.timeout=setTimeout(function(){"in"==e.hoverState&&e.show()},e.options.delay.show)}},m.prototype.isInStateTrue=function(){for(var t in this.inState)if(this.inState[t])return!0;return!1},m.prototype.leave=function(t){var e=t instanceof this.constructor?t:g(t.currentTarget).data("bs."+this.type);if(e||(e=new this.constructor(t.currentTarget,this.getDelegateOptions()),g(t.currentTarget).data("bs."+this.type,e)),t instanceof g.Event&&(e.inState["focusout"==t.type?"focus":"hover"]=!1),!e.isInStateTrue()){if(clearTimeout(e.timeout),e.hoverState="out",!e.options.delay||!e.options.delay.hide)return e.hide();e.timeout=setTimeout(function(){"out"==e.hoverState&&e.hide()},e.options.delay.hide)}},m.prototype.show=function(){var t=g.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(t);var e=g.contains(this.$element[0].ownerDocument.documentElement,this.$element[0]);if(t.isDefaultPrevented()||!e)return;var i=this,o=this.tip(),n=this.getUID(this.type);this.setContent(),o.attr("id",n),this.$element.attr("aria-describedby",n),this.options.animation&&o.addClass("fade");var s="function"==typeof this.options.placement?this.options.placement.call(this,o[0],this.$element[0]):this.options.placement,a=/\s?auto?\s?/i,r=a.test(s);r&&(s=s.replace(a,"")||"top"),o.detach().css({top:0,left:0,display:"block"}).addClass(s).data("bs."+this.type,this),this.options.container?o.appendTo(g(document).find(this.options.container)):o.insertAfter(this.$element),this.$element.trigger("inserted.bs."+this.type);var l=this.getPosition(),h=o[0].offsetWidth,d=o[0].offsetHeight;if(r){var p=s,c=this.getPosition(this.$viewport);s="bottom"==s&&l.bottom+d>c.bottom?"top":"top"==s&&l.top-d<c.top?"bottom":"right"==s&&l.right+h>c.width?"left":"left"==s&&l.left-h<c.left?"right":s,o.removeClass(p).addClass(s)}var f=this.getCalculatedOffset(s,l,h,d);this.applyPlacement(f,s);var u=function(){var t=i.hoverState;i.$element.trigger("shown.bs."+i.type),i.hoverState=null,"out"==t&&i.leave(i)};g.support.transition&&this.$tip.hasClass("fade")?o.one("bsTransitionEnd",u).emulateTransitionEnd(m.TRANSITION_DURATION):u()}},m.prototype.applyPlacement=function(t,e){var i=this.tip(),o=i[0].offsetWidth,n=i[0].offsetHeight,s=parseInt(i.css("margin-top"),10),a=parseInt(i.css("margin-left"),10);isNaN(s)&&(s=0),isNaN(a)&&(a=0),t.top+=s,t.left+=a,g.offset.setOffset(i[0],g.extend({using:function(t){i.css({top:Math.round(t.top),left:Math.round(t.left)})}},t),0),i.addClass("in");var r=i[0].offsetWidth,l=i[0].offsetHeight;"top"==e&&l!=n&&(t.top=t.top+n-l);var h=this.getViewportAdjustedDelta(e,t,r,l);h.left?t.left+=h.left:t.top+=h.top;var d=/top|bottom/.test(e),p=d?2*h.left-o+r:2*h.top-n+l,c=d?"offsetWidth":"offsetHeight";i.offset(t),this.replaceArrow(p,i[0][c],d)},m.prototype.replaceArrow=function(t,e,i){this.arrow().css(i?"left":"top",50*(1-t/e)+"%").css(i?"top":"left","")},m.prototype.setContent=function(){var t=this.tip(),e=this.getTitle();this.options.html?(this.options.sanitize&&(e=n(e,this.options.whiteList,this.options.sanitizeFn)),t.find(".tooltip-inner").html(e)):t.find(".tooltip-inner").text(e),t.removeClass("fade in top bottom left right")},m.prototype.hide=function(t){var e=this,i=g(this.$tip),o=g.Event("hide.bs."+this.type);function n(){"in"!=e.hoverState&&i.detach(),e.$element&&e.$element.removeAttr("aria-describedby").trigger("hidden.bs."+e.type),t&&t()}if(this.$element.trigger(o),!o.isDefaultPrevented())return i.removeClass("in"),g.support.transition&&i.hasClass("fade")?i.one("bsTransitionEnd",n).emulateTransitionEnd(m.TRANSITION_DURATION):n(),this.hoverState=null,this},m.prototype.fixTitle=function(){var t=this.$element;(t.attr("title")||"string"!=typeof t.attr("data-original-title"))&&t.attr("data-original-title",t.attr("title")||"").attr("title","")},m.prototype.hasContent=function(){return this.getTitle()},m.prototype.getPosition=function(t){var e=(t=t||this.$element)[0],i="BODY"==e.tagName,o=e.getBoundingClientRect();null==o.width&&(o=g.extend({},o,{width:o.right-o.left,height:o.bottom-o.top}));var n=window.SVGElement&&e instanceof window.SVGElement,s=i?{top:0,left:0}:n?null:t.offset(),a={scroll:i?document.documentElement.scrollTop||document.body.scrollTop:t.scrollTop()},r=i?{width:g(window).width(),height:g(window).height()}:null;return g.extend({},o,a,r,s)},m.prototype.getCalculatedOffset=function(t,e,i,o){return"bottom"==t?{top:e.top+e.height,left:e.left+e.width/2-i/2}:"top"==t?{top:e.top-o,left:e.left+e.width/2-i/2}:"left"==t?{top:e.top+e.height/2-o/2,left:e.left-i}:{top:e.top+e.height/2-o/2,left:e.left+e.width}},m.prototype.getViewportAdjustedDelta=function(t,e,i,o){var n={top:0,left:0};if(!this.$viewport)return n;var s=this.options.viewport&&this.options.viewport.padding||0,a=this.getPosition(this.$viewport);if(/right|left/.test(t)){var r=e.top-s-a.scroll,l=e.top+s-a.scroll+o;r<a.top?n.top=a.top-r:l>a.top+a.height&&(n.top=a.top+a.height-l)}else{var h=e.left-s,d=e.left+s+i;h<a.left?n.left=a.left-h:d>a.right&&(n.left=a.left+a.width-d)}return n},m.prototype.getTitle=function(){var t=this.$element,e=this.options;return t.attr("data-original-title")||("function"==typeof e.title?e.title.call(t[0]):e.title)},m.prototype.getUID=function(t){for(;t+=~~(1e6*Math.random()),document.getElementById(t););return t},m.prototype.tip=function(){if(!this.$tip&&(this.$tip=g(this.options.template),1!=this.$tip.length))throw new Error(this.type+" `template` option must consist of exactly 1 top-level element!");return this.$tip},m.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},m.prototype.enable=function(){this.enabled=!0},m.prototype.disable=function(){this.enabled=!1},m.prototype.toggleEnabled=function(){this.enabled=!this.enabled},m.prototype.toggle=function(t){var e=this;t&&((e=g(t.currentTarget).data("bs."+this.type))||(e=new this.constructor(t.currentTarget,this.getDelegateOptions()),g(t.currentTarget).data("bs."+this.type,e))),t?(e.inState.click=!e.inState.click,e.isInStateTrue()?e.enter(e):e.leave(e)):e.tip().hasClass("in")?e.leave(e):e.enter(e)},m.prototype.destroy=function(){var t=this;clearTimeout(this.timeout),this.hide(function(){t.$element.off("."+t.type).removeData("bs."+t.type),t.$tip&&t.$tip.detach(),t.$tip=null,t.$arrow=null,t.$viewport=null,t.$element=null})},m.prototype.sanitizeHtml=function(t){return n(t,this.options.whiteList,this.options.sanitizeFn)};var e=g.fn.tooltip;g.fn.tooltip=function i(o){return this.each(function(){var t=g(this),e=t.data("bs.tooltip"),i="object"==typeof o&&o;!e&&/destroy|hide/.test(o)||(e||t.data("bs.tooltip",e=new m(this,i)),"string"==typeof o&&e[o]())})},g.fn.tooltip.Constructor=m,g.fn.tooltip.noConflict=function(){return g.fn.tooltip=e,this}}(jQuery),function(n){"use strict";var s=function(t,e){this.init("popover",t,e)};if(!n.fn.tooltip)throw new Error("Popover requires tooltip.js");s.VERSION="3.4.1",s.DEFAULTS=n.extend({},n.fn.tooltip.Constructor.DEFAULTS,{placement:"right",trigger:"click",content:"",template:'<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'}),((s.prototype=n.extend({},n.fn.tooltip.Constructor.prototype)).constructor=s).prototype.getDefaults=function(){return s.DEFAULTS},s.prototype.setContent=function(){var t=this.tip(),e=this.getTitle(),i=this.getContent();if(this.options.html){var o=typeof i;this.options.sanitize&&(e=this.sanitizeHtml(e),"string"===o&&(i=this.sanitizeHtml(i))),t.find(".popover-title").html(e),t.find(".popover-content").children().detach().end()["string"===o?"html":"append"](i)}else t.find(".popover-title").text(e),t.find(".popover-content").children().detach().end().text(i);t.removeClass("fade top bottom left right in"),t.find(".popover-title").html()||t.find(".popover-title").hide()},s.prototype.hasContent=function(){return this.getTitle()||this.getContent()},s.prototype.getContent=function(){var t=this.$element,e=this.options;return t.attr("data-content")||("function"==typeof e.content?e.content.call(t[0]):e.content)},s.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")};var t=n.fn.popover;n.fn.popover=function e(o){return this.each(function(){var t=n(this),e=t.data("bs.popover"),i="object"==typeof o&&o;!e&&/destroy|hide/.test(o)||(e||t.data("bs.popover",e=new s(this,i)),"string"==typeof o&&e[o]())})},n.fn.popover.Constructor=s,n.fn.popover.noConflict=function(){return n.fn.popover=t,this}}(jQuery),function(s){"use strict";function n(t,e){this.$body=s(document.body),this.$scrollElement=s(t).is(document.body)?s(window):s(t),this.options=s.extend({},n.DEFAULTS,e),this.selector=(this.options.target||"")+" .nav li > a",this.offsets=[],this.targets=[],this.activeTarget=null,this.scrollHeight=0,this.$scrollElement.on("scroll.bs.scrollspy",s.proxy(this.process,this)),this.refresh(),this.process()}function e(o){return this.each(function(){var t=s(this),e=t.data("bs.scrollspy"),i="object"==typeof o&&o;e||t.data("bs.scrollspy",e=new n(this,i)),"string"==typeof o&&e[o]()})}n.VERSION="3.4.1",n.DEFAULTS={offset:10},n.prototype.getScrollHeight=function(){return this.$scrollElement[0].scrollHeight||Math.max(this.$body[0].scrollHeight,document.documentElement.scrollHeight)},n.prototype.refresh=function(){var t=this,o="offset",n=0;this.offsets=[],this.targets=[],this.scrollHeight=this.getScrollHeight(),s.isWindow(this.$scrollElement[0])||(o="position",n=this.$scrollElement.scrollTop()),this.$body.find(this.selector).map(function(){var t=s(this),e=t.data("target")||t.attr("href"),i=/^#./.test(e)&&s(e);return i&&i.length&&i.is(":visible")&&[[i[o]().top+n,e]]||null}).sort(function(t,e){return t[0]-e[0]}).each(function(){t.offsets.push(this[0]),t.targets.push(this[1])})},n.prototype.process=function(){var t,e=this.$scrollElement.scrollTop()+this.options.offset,i=this.getScrollHeight(),o=this.options.offset+i-this.$scrollElement.height(),n=this.offsets,s=this.targets,a=this.activeTarget;if(this.scrollHeight!=i&&this.refresh(),o<=e)return a!=(t=s[s.length-1])&&this.activate(t);if(a&&e<n[0])return this.activeTarget=null,this.clear();for(t=n.length;t--;)a!=s[t]&&e>=n[t]&&(n[t+1]===undefined||e<n[t+1])&&this.activate(s[t])},n.prototype.activate=function(t){this.activeTarget=t,this.clear();var e=this.selector+'[data-target="'+t+'"],'+this.selector+'[href="'+t+'"]',i=s(e).parents("li").addClass("active");i.parent(".dropdown-menu").length&&(i=i.closest("li.dropdown").addClass("active")),i.trigger("activate.bs.scrollspy")},n.prototype.clear=function(){s(this.selector).parentsUntil(this.options.target,".active").removeClass("active")};var t=s.fn.scrollspy;s.fn.scrollspy=e,s.fn.scrollspy.Constructor=n,s.fn.scrollspy.noConflict=function(){return s.fn.scrollspy=t,this},s(window).on("load.bs.scrollspy.data-api",function(){s('[data-spy="scroll"]').each(function(){var t=s(this);e.call(t,t.data())})})}(jQuery),function(r){"use strict";var a=function(t){this.element=r(t)};function e(i){return this.each(function(){var t=r(this),e=t.data("bs.tab");e||t.data("bs.tab",e=new a(this)),"string"==typeof i&&e[i]()})}a.VERSION="3.4.1",a.TRANSITION_DURATION=150,a.prototype.show=function(){var t=this.element,e=t.closest("ul:not(.dropdown-menu)"),i=t.data("target");if(i||(i=(i=t.attr("href"))&&i.replace(/.*(?=#[^\s]*$)/,"")),!t.parent("li").hasClass("active")){var o=e.find(".active:last a"),n=r.Event("hide.bs.tab",{relatedTarget:t[0]}),s=r.Event("show.bs.tab",{relatedTarget:o[0]});if(o.trigger(n),t.trigger(s),!s.isDefaultPrevented()&&!n.isDefaultPrevented()){var a=r(document).find(i);this.activate(t.closest("li"),e),this.activate(a,a.parent(),function(){o.trigger({type:"hidden.bs.tab",relatedTarget:t[0]}),t.trigger({type:"shown.bs.tab",relatedTarget:o[0]})})}}},a.prototype.activate=function(t,e,i){var o=e.find("> .active"),n=i&&r.support.transition&&(o.length&&o.hasClass("fade")||!!e.find("> .fade").length);function s(){o.removeClass("active").find("> .dropdown-menu > .active").removeClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!1),t.addClass("active").find('[data-toggle="tab"]').attr("aria-expanded",!0),n?(t[0].offsetWidth,t.addClass("in")):t.removeClass("fade"),t.parent(".dropdown-menu").length&&t.closest("li.dropdown").addClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!0),i&&i()}o.length&&n?o.one("bsTransitionEnd",s).emulateTransitionEnd(a.TRANSITION_DURATION):s(),o.removeClass("in")};var t=r.fn.tab;r.fn.tab=e,r.fn.tab.Constructor=a,r.fn.tab.noConflict=function(){return r.fn.tab=t,this};var i=function(t){t.preventDefault(),e.call(r(this),"show")};r(document).on("click.bs.tab.data-api",'[data-toggle="tab"]',i).on("click.bs.tab.data-api",'[data-toggle="pill"]',i)}(jQuery),function(l){"use strict";var h=function(t,e){this.options=l.extend({},h.DEFAULTS,e);var i=this.options.target===h.DEFAULTS.target?l(this.options.target):l(document).find(this.options.target);this.$target=i.on("scroll.bs.affix.data-api",l.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",l.proxy(this.checkPositionWithEventLoop,this)),this.$element=l(t),this.affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};function i(o){return this.each(function(){var t=l(this),e=t.data("bs.affix"),i="object"==typeof o&&o;e||t.data("bs.affix",e=new h(this,i)),"string"==typeof o&&e[o]()})}h.VERSION="3.4.1",h.RESET="affix affix-top affix-bottom",h.DEFAULTS={offset:0,target:window},h.prototype.getState=function(t,e,i,o){var n=this.$target.scrollTop(),s=this.$element.offset(),a=this.$target.height();if(null!=i&&"top"==this.affixed)return n<i&&"top";if("bottom"==this.affixed)return null!=i?!(n+this.unpin<=s.top)&&"bottom":!(n+a<=t-o)&&"bottom";var r=null==this.affixed,l=r?n:s.top;return null!=i&&n<=i?"top":null!=o&&t-o<=l+(r?a:e)&&"bottom"},h.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(h.RESET).addClass("affix");var t=this.$target.scrollTop(),e=this.$element.offset();return this.pinnedOffset=e.top-t},h.prototype.checkPositionWithEventLoop=function(){setTimeout(l.proxy(this.checkPosition,this),1)},h.prototype.checkPosition=function(){if(this.$element.is(":visible")){var t=this.$element.height(),e=this.options.offset,i=e.top,o=e.bottom,n=Math.max(l(document).height(),l(document.body).height());"object"!=typeof e&&(o=i=e),"function"==typeof i&&(i=e.top(this.$element)),"function"==typeof o&&(o=e.bottom(this.$element));var s=this.getState(n,t,i,o);if(this.affixed!=s){null!=this.unpin&&this.$element.css("top","");var a="affix"+(s?"-"+s:""),r=l.Event(a+".bs.affix");if(this.$element.trigger(r),r.isDefaultPrevented())return;this.affixed=s,this.unpin="bottom"==s?this.getPinnedOffset():null,this.$element.removeClass(h.RESET).addClass(a).trigger(a.replace("affix","affixed")+".bs.affix")}"bottom"==s&&this.$element.offset({top:n-t-o})}};var t=l.fn.affix;l.fn.affix=i,l.fn.affix.Constructor=h,l.fn.affix.noConflict=function(){return l.fn.affix=t,this},l(window).on("load",function(){l('[data-spy="affix"]').each(function(){var t=l(this),e=t.data();e.offset=e.offset||{},null!=e.offsetBottom&&(e.offset.bottom=e.offsetBottom),null!=e.offsetTop&&(e.offset.top=e.offsetTop),i.call(t,e)})})}(jQuery);
  9. define("bootstrap", ["jquery"], function(){});
  10. require.config({
  11. urlArgs: "v=" + requirejs.s.contexts._.config.config.site.version,
  12. packages: [{
  13. name: 'moment',
  14. location: '../libs/moment',
  15. main: 'moment'
  16. }],
  17. //在打包压缩时将会把include中的模块合并到主文件中
  18. include: ['css', 'layer', 'toastr', 'fast', 'backend', 'backend-init', 'table', 'form', 'dragsort', 'addtabs', 'selectpage', 'bootstrap-daterangepicker'],
  19. paths: {
  20. 'lang': "empty:",
  21. 'form': 'require-form',
  22. 'table': 'require-table',
  23. 'upload': 'require-upload',
  24. 'dropzone': 'dropzone.min',
  25. 'echarts': 'echarts.min',
  26. 'echarts-theme': 'echarts-theme',
  27. 'adminlte': 'adminlte',
  28. 'bootstrap-table-commonsearch': 'bootstrap-table-commonsearch',
  29. 'bootstrap-table-template': 'bootstrap-table-template',
  30. // 以下的包从libs目录加载
  31. 'jquery': '../libs/jquery/dist/jquery.min',
  32. 'bootstrap': '../libs/bootstrap/dist/js/bootstrap.min',
  33. 'bootstrap-datetimepicker': '../libs/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min',
  34. 'bootstrap-daterangepicker': '../libs/bootstrap-daterangepicker/daterangepicker',
  35. 'bootstrap-select': '../libs/bootstrap-select/dist/js/bootstrap-select.min',
  36. 'bootstrap-select-lang': '../libs/bootstrap-select/dist/js/i18n/defaults-zh_CN',
  37. 'bootstrap-table': '../libs/bootstrap-table/dist/bootstrap-table.min',
  38. 'bootstrap-table-export': '../libs/bootstrap-table/dist/extensions/export/bootstrap-table-export',
  39. 'bootstrap-table-fixed-columns': '../libs/bootstrap-table/dist/extensions/fixed-columns/bootstrap-table-fixed-columns',
  40. 'bootstrap-table-mobile': '../libs/bootstrap-table/dist/extensions/mobile/bootstrap-table-mobile.min',
  41. 'bootstrap-table-lang': '../libs/bootstrap-table/dist/locale/bootstrap-table-zh-CN',
  42. 'bootstrap-table-jumpto': '../libs/bootstrap-table/dist/extensions/page-jumpto/bootstrap-table-jumpto',
  43. 'bootstrap-slider': '../libs/bootstrap-slider/dist/bootstrap-slider.min',
  44. 'tableexport': '../libs/tableexport.jquery.plugin/tableExport.min',
  45. 'dragsort': '../libs/fastadmin-dragsort/jquery.dragsort',
  46. 'sortable': '../libs/sortablejs/Sortable.min',
  47. 'addtabs': '../libs/fastadmin-addtabs/jquery.addtabs',
  48. 'slimscroll': '../libs/jquery-slimscroll/jquery.slimscroll',
  49. 'validator': '../libs/nice-validator/dist/jquery.validator',
  50. 'validator-lang': '../libs/nice-validator/dist/local/zh-CN',
  51. 'toastr': '../libs/toastr/toastr',
  52. 'jstree': '../libs/jstree/dist/jstree.min',
  53. 'layer': '../libs/fastadmin-layer/dist/layer',
  54. 'cookie': '../libs/jquery.cookie/jquery.cookie',
  55. 'cxselect': '../libs/fastadmin-cxselect/js/jquery.cxselect',
  56. 'template': '../libs/art-template/dist/template-native',
  57. 'selectpage': '../libs/fastadmin-selectpage/selectpage',
  58. 'citypicker': '../libs/fastadmin-citypicker/dist/js/city-picker.min',
  59. 'citypicker-data': '../libs/fastadmin-citypicker/dist/js/city-picker.data',
  60. },
  61. // shim依赖配置
  62. shim: {
  63. 'addons': ['backend'],
  64. 'bootstrap': ['jquery'],
  65. 'bootstrap-table': {
  66. deps: ['bootstrap'],
  67. exports: '$.fn.bootstrapTable'
  68. },
  69. 'bootstrap-table-lang': {
  70. deps: ['bootstrap-table'],
  71. exports: '$.fn.bootstrapTable.defaults'
  72. },
  73. 'bootstrap-table-export': {
  74. deps: ['bootstrap-table'],
  75. exports: '$.fn.bootstrapTable.defaults'
  76. },
  77. 'bootstrap-table-fixed-columns': {
  78. deps: ['bootstrap-table'],
  79. exports: '$.fn.bootstrapTable.defaults'
  80. },
  81. 'bootstrap-table-mobile': {
  82. deps: ['bootstrap-table'],
  83. exports: '$.fn.bootstrapTable.defaults'
  84. },
  85. 'bootstrap-table-advancedsearch': {
  86. deps: ['bootstrap-table'],
  87. exports: '$.fn.bootstrapTable.defaults'
  88. },
  89. 'bootstrap-table-commonsearch': {
  90. deps: ['bootstrap-table'],
  91. exports: '$.fn.bootstrapTable.defaults'
  92. },
  93. 'bootstrap-table-template': {
  94. deps: ['bootstrap-table', 'template'],
  95. exports: '$.fn.bootstrapTable.defaults'
  96. },
  97. 'bootstrap-table-jumpto': {
  98. deps: ['bootstrap-table'],
  99. exports: '$.fn.bootstrapTable.defaults'
  100. },
  101. 'tableexport': {
  102. deps: ['jquery'],
  103. exports: '$.fn.extend'
  104. },
  105. 'slimscroll': {
  106. deps: ['jquery'],
  107. exports: '$.fn.extend'
  108. },
  109. 'adminlte': {
  110. deps: ['bootstrap', 'slimscroll'],
  111. exports: '$.AdminLTE'
  112. },
  113. 'table': [
  114. 'moment', 'moment/locale/zh-cn',
  115. 'bootstrap-table',
  116. 'bootstrap-table-lang', 'bootstrap-table-export', 'bootstrap-table-commonsearch', 'bootstrap-table-template',
  117. 'bootstrap-table-jumpto', 'bootstrap-table-fixed-columns'
  118. ],
  119. 'bootstrap-daterangepicker': ['moment', 'moment/locale/zh-cn'],
  120. 'bootstrap-datetimepicker': ['moment', 'moment/locale/zh-cn'],
  121. 'bootstrap-select-lang': ['bootstrap-select'],
  122. 'selectpage': {
  123. deps: ['jquery'],
  124. exports: '$.fn.extend'
  125. },
  126. 'layer': {
  127. deps: ['jquery']
  128. },
  129. 'jstree': ['css!../libs/jstree/dist/themes/default/style.css'],
  130. 'validator-lang': ['validator'],
  131. 'citypicker': ['citypicker-data', 'css!../libs/fastadmin-citypicker/dist/css/city-picker.css']
  132. },
  133. baseUrl: requirejs.s.contexts._.config.config.site.cdnurl + '/assets/js/', //资源基础路径
  134. map: {
  135. '*': {
  136. 'css': '../libs/require-css/css.min'
  137. }
  138. },
  139. waitSeconds: 60,
  140. charset: 'utf-8' // 文件编码
  141. });
  142. require(['jquery', 'bootstrap'], function ($, undefined) {
  143. //初始配置
  144. var Config = requirejs.s.contexts._.config.config;
  145. //将Config渲染到全局
  146. window.Config = Config;
  147. // 配置语言包的路径
  148. var paths = {};
  149. paths['lang'] = Config.moduleurl + '/ajax/lang?callback=define&controllername=' + Config.controllername + '&lang=' + Config.language + '&v=' + Config.site.version;
  150. // 避免目录冲突
  151. paths['backend/'] = 'backend/';
  152. // 如果是英文,则移除默认的定义
  153. if (Config.language === 'en') {
  154. $.each(requirejs.s.contexts._.config.paths, function (key, value) {
  155. if (key.match(/\-lang$/)) {
  156. define('require-backend',key);
  157. }
  158. });
  159. define('moment/locale/zh-cn');
  160. }
  161. require.config({paths: paths});
  162. // 初始化
  163. $(function () {
  164. require(['fast'], function (Fast) {
  165. require(['backend', 'backend-init', 'addons'], function (Backend, undefined, Addons) {
  166. //加载相应模块
  167. if (Config.jsname) {
  168. require([Config.jsname], function (Controller) {
  169. if (Controller.hasOwnProperty(Config.actionname)) {
  170. Controller[Config.actionname]();
  171. } else {
  172. if (Controller.hasOwnProperty("_empty")) {
  173. Controller._empty();
  174. }
  175. }
  176. }, function (e) {
  177. console.error(e);
  178. // 这里可捕获模块加载的错误
  179. });
  180. }
  181. });
  182. });
  183. });
  184. });
  185. define('../libs/require-css/css.min',[],function(){if("undefined"==typeof window)return{load:function(a,b,c){c()}};var a=document.getElementsByTagName("head")[0],b=window.navigator.userAgent.match(/Trident\/([^ ;]*)|AppleWebKit\/([^ ;]*)|Opera\/([^ ;]*)|rv\:([^ ;]*)(.*?)Gecko\/([^ ;]*)|MSIE\s([^ ;]*)|AndroidWebKit\/([^ ;]*)/)||0,c=!1,d=!0;b[1]||b[7]?c=parseInt(b[1])<6||parseInt(b[7])<=9:b[2]||b[8]?d=!1:b[4]&&(c=parseInt(b[4])<18);var e={};e.pluginBuilder="./css-builder";var f,g,h,i=function(){f=document.createElement("style"),a.appendChild(f),g=f.styleSheet||f.sheet},j=0,k=[],l=function(a){g.addImport(a),f.onload=function(){m()},j++,31==j&&(i(),j=0)},m=function(){h();var a=k.shift();return a?(h=a[1],void l(a[0])):void(h=null)},n=function(a,b){if(g&&g.addImport||i(),g&&g.addImport)h?k.push([a,b]):(l(a),h=b);else{f.textContent='@import "'+a+'";';var c=setInterval(function(){try{f.sheet.cssRules,clearInterval(c),b()}catch(a){}},10)}},o=function(b,c){var e=document.createElement("link");if(e.type="text/css",e.rel="stylesheet",d)e.onload=function(){e.onload=function(){},setTimeout(c,7)};else var f=setInterval(function(){for(var a=0;a<document.styleSheets.length;a++){var b=document.styleSheets[a];if(b.href==e.href)return clearInterval(f),c()}},10);e.href=b,a.appendChild(e)};return e.normalize=function(a,b){return".css"==a.substr(a.length-4,4)&&(a=a.substr(0,a.length-4)),b(a)},e.load=function(a,b,d,e){(c?n:o)(b.toUrl(a+".css"),d)},e});
  186. /*! layer-v3.5.5 Web 通用弹出层组件 MIT License http://layer.layui.com/ By 贤心 */
  187. ;!function(e,t){"use strict";var i,n,a=e.layui&&layui.define,o={getPath:function(){var t=document.currentScript?document.currentScript.src:function(){for(var e,t=document.scripts,i=t.length-1,n=i;n>0;n--)if("interactive"===t[n].readyState){e=t[n].src;break}return e||t[i].src}(),i=e.LAYUI_GLOBAL||{};return i.layer_dir||t.substring(0,t.lastIndexOf("/")+1)}(),config:{},end:{},minIndex:0,minLeft:[],btn:["&#x786E;&#x5B9A;","&#x53D6;&#x6D88;"],type:["dialog","page","iframe","loading","tips"],getStyle:function(t,i){var n=t.currentStyle?t.currentStyle:e.getComputedStyle(t,null);return n[n.getPropertyValue?"getPropertyValue":"getAttribute"](i)},link:function(t,i,n){if(r.path){var a=document.getElementsByTagName("head")[0],s=document.createElement("link");"string"==typeof i&&(n=i);var l=(n||t).replace(/\.|\//g,""),f="layuicss-"+l,c="creating",u=0;s.rel="stylesheet",s.href=r.path+t,s.id=f,document.getElementById(f)||a.appendChild(s),"function"==typeof i&&!function d(t){var n=100,a=document.getElementById(f);return++u>1e4/n?e.console&&console.error(l+".css: Invalid"):void(1989===parseInt(o.getStyle(a,"width"))?(t===c&&a.removeAttribute("lay-status"),a.getAttribute("lay-status")===c?setTimeout(d,n):i()):(a.setAttribute("lay-status",c),setTimeout(function(){d(c)},n)))}()}}},r={v:"3.5.2",ie:function(){var t=navigator.userAgent.toLowerCase();return!!(e.ActiveXObject||"ActiveXObject"in e)&&((t.match(/msie\s(\d+)/)||[])[1]||"11")}(),index:e.layer&&e.layer.v?1e5:0,path:o.getPath,config:function(e,t){return e=e||{},f=r.cache=o.config=i.extend({},o.config,e),r.path=o.config.path||r.path,"string"==typeof e.extend&&(e.extend=[e.extend]),o.config.path&&r.ready(),e.extend?(a?layui.addcss("modules/layer/"+e.extend):o.link("theme/"+e.extend),this):this},ready:function(e){var t="layer",i="",n=(a?"modules/layer/":"theme/")+"default/layer.css?v="+r.v+i;return a?layui.addcss(n,e,t):o.link(n,e,t),this},alert:function(e,t,n){var a="function"==typeof t;return a&&(n=t),r.open(i.extend({content:e,yes:n},a?{}:t))},confirm:function(e,t,n,a){var s="function"==typeof t;return s&&(a=n,n=t),r.open(i.extend({content:e,btn:o.btn,yes:n,btn2:a},s?{}:t))},msg:function(e,n,a){var s="function"==typeof n,f=o.config.skin,c=(f?f+" "+f+"-msg":"")||"layui-layer-msg",u=l.anim.length-1;return s&&(a=n),r.open(i.extend({content:e,time:3e3,shade:!1,skin:c,title:!1,closeBtn:!1,btn:!1,resize:!1,end:a},s&&!o.config.skin?{skin:c+" layui-layer-hui",anim:u}:function(){return n=n||{},n.icon!==-1&&n.icon!==t||(n.skin=c+" "+(n.skin||"layui-layer-hui")),n}()))},load:function(e,t){return r.open(i.extend({type:3,icon:e||0,resize:!1,shade:.01},t))},tips:function(e,t,n){return r.open(i.extend({type:4,content:[e,t],closeBtn:!1,time:3e3,shade:!1,resize:!1,fixed:!1,maxWidth:260},n))}},s=function(e){var t=this,n=function(){t.creat()};t.index=++r.index,t.config=i.extend({},t.config,o.config,e),document.body?n():setTimeout(function(){n()},30)};s.pt=s.prototype;var l=["layui-layer",".layui-layer-title",".layui-layer-main",".layui-layer-dialog","layui-layer-iframe","layui-layer-content","layui-layer-btn","layui-layer-close"];l.anim=["layer-anim-00","layer-anim-01","layer-anim-02","layer-anim-03","layer-anim-04","layer-anim-05","layer-anim-06"],l.SHADE="layui-layer-shade",l.MOVE="layui-layer-move",s.pt.config={type:0,shade:.3,fixed:!0,move:l[1],title:"&#x4FE1;&#x606F;",offset:"auto",area:"auto",closeBtn:1,time:0,zIndex:19891014,maxWidth:360,anim:0,isOutAnim:!0,minStack:!0,focusBtn:0,icon:-1,moveType:1,resize:!0,scrollbar:!0,tips:2},s.pt.vessel=function(e,t){var n=this,a=n.index,r=n.config,s=r.zIndex+a,f="object"==typeof r.title,c=r.maxmin&&(1===r.type||2===r.type),u=r.title?'<div class="layui-layer-title" style="'+(f?r.title[1]:"")+'">'+(f?r.title[0]:r.title)+"</div>":"";return r.zIndex=s,t([r.shade?'<div class="'+l.SHADE+'" id="'+l.SHADE+a+'" times="'+a+'" style="'+("z-index:"+(s-1)+"; ")+'"></div>':"",'<div class="'+l[0]+(" layui-layer-"+o.type[r.type])+(0!=r.type&&2!=r.type||r.shade?"":" layui-layer-border")+" "+(r.skin||"")+'" id="'+l[0]+a+'" type="'+o.type[r.type]+'" times="'+a+'" showtime="'+r.time+'" conType="'+(e?"object":"string")+'" style="z-index: '+s+"; width:"+r.area[0]+";height:"+r.area[1]+";position:"+(r.fixed?"fixed;":"absolute;")+'">'+(e&&2!=r.type?"":u)+'<div id="'+(r.id||"")+'" class="layui-layer-content'+(0==r.type&&r.icon!==-1?" layui-layer-padding":"")+(3==r.type?" layui-layer-loading"+r.icon:"")+'">'+(0==r.type&&r.icon!==-1?'<i class="layui-layer-ico layui-layer-ico'+r.icon+'"></i>':"")+(1==r.type&&e?"":r.content||"")+'</div><span class="layui-layer-setwin">'+function(){var e=c?'<a class="layui-layer-min" href="javascript:;"><cite></cite></a><a class="layui-layer-ico layui-layer-max" href="javascript:;"></a>':"";return r.closeBtn&&(e+='<a class="layui-layer-ico '+l[7]+" "+l[7]+(r.title?r.closeBtn:4==r.type?"1":"2")+'" href="javascript:;"></a>'),e}()+"</span>"+(r.btn?function(){var e="";"string"==typeof r.btn&&(r.btn=[r.btn]);for(var t=0,i=r.btn.length;t<i;t++)e+='<a class="'+l[6]+t+'" href="javascript:">'+r.btn[t]+"</a>";return'<div class="'+l[6]+" layui-layer-btn-"+(r.btnAlign||"")+'">'+e+"</div>"}():"")+(r.resize?'<span class="layui-layer-resize"></span>':"")+"</div>"],u,i('<div class="'+l.MOVE+'" id="'+l.MOVE+'"></div>')),n},s.pt.creat=function(){var e=this,t=e.config,a=e.index,s=t.content,f="object"==typeof s,c=i("body");if(!t.id||!i("#"+t.id)[0]){switch("string"==typeof t.area&&(t.area="auto"===t.area?["",""]:[t.area,""]),t.shift&&(t.anim=t.shift),6==r.ie&&(t.fixed=!1),t.type){case 0:t.btn="btn"in t?t.btn:o.btn[0],r.closeAll("dialog");break;case 2:var s=t.content=f?t.content:[t.content||"","auto"];t.content='<iframe scrolling="'+(t.content[1]||"auto")+'" allowtransparency="true" id="'+l[4]+a+'" name="'+l[4]+a+'" onload="this.className=\'\';" class="layui-layer-load" frameborder="0" src="'+t.content[0]+'"></iframe>';break;case 3:delete t.title,delete t.closeBtn,t.icon===-1&&0===t.icon,r.closeAll("loading");break;case 4:f||(t.content=[t.content,"body"]),t.follow=t.content[1],t.content=t.content[0]+'<i class="layui-layer-TipsG"></i>',delete t.title,t.tips="object"==typeof t.tips?t.tips:[t.tips,!0],t.tipsMore||r.closeAll("tips")}if(e.vessel(f,function(n,r,u){c.append(n[0]),f?function(){2==t.type||4==t.type?function(){i("body").append(n[1])}():function(){s.parents("."+l[0])[0]||(s.data("display",s.css("display")).show().addClass("layui-layer-wrap").wrap(n[1]),i("#"+l[0]+a).find("."+l[5]).before(r))}()}():c.append(n[1]),i("#"+l.MOVE)[0]||c.append(o.moveElem=u),e.layero=i("#"+l[0]+a),e.shadeo=i("#"+l.SHADE+a),t.scrollbar||l.html.css("overflow","hidden").attr("layer-full",a)}).auto(a),e.shadeo.css({"background-color":t.shade[1]||"#000",opacity:t.shade[0]||t.shade}),2==t.type&&6==r.ie&&e.layero.find("iframe").attr("src",s[0]),4==t.type?e.tips():function(){e.offset(),parseInt(o.getStyle(document.getElementById(l.MOVE),"z-index"))||function(){e.layero.css("visibility","hidden"),r.ready(function(){e.offset(),e.layero.css("visibility","visible")})}()}(),t.fixed&&n.on("resize",function(){e.offset(),(/^\d+%$/.test(t.area[0])||/^\d+%$/.test(t.area[1]))&&e.auto(a),4==t.type&&e.tips()}),t.time<=0||setTimeout(function(){r.close(e.index)},t.time),e.move().callback(),l.anim[t.anim]){var u="layer-anim "+l.anim[t.anim];e.layero.addClass(u).one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend",function(){i(this).removeClass(u)})}t.isOutAnim&&e.layero.data("isOutAnim",!0)}},s.pt.auto=function(e){var t=this,a=t.config,o=i("#"+l[0]+e);""===a.area[0]&&a.maxWidth>0&&(r.ie&&r.ie<8&&a.btn&&o.width(o.innerWidth()),o.outerWidth()>a.maxWidth&&o.width(a.maxWidth));var s=[o.innerWidth(),o.innerHeight()],f=o.find(l[1]).outerHeight()||0,c=o.find("."+l[6]).outerHeight()||0,u=function(e){e=o.find(e),e.height(s[1]-f-c-2*(0|parseFloat(e.css("padding-top"))))};switch(a.type){case 2:u("iframe");break;default:""===a.area[1]?a.maxHeight>0&&o.outerHeight()>a.maxHeight?(s[1]=a.maxHeight,u("."+l[5])):a.fixed&&s[1]>=n.height()&&(s[1]=n.height(),u("."+l[5])):u("."+l[5])}return t},s.pt.offset=function(){var e=this,t=e.config,i=e.layero,a=[i.outerWidth(),i.outerHeight()],o="object"==typeof t.offset;e.offsetTop=(n.height()-a[1])/2,e.offsetLeft=(n.width()-a[0])/2,o?(e.offsetTop=t.offset[0],e.offsetLeft=t.offset[1]||e.offsetLeft):"auto"!==t.offset&&("t"===t.offset?e.offsetTop=0:"r"===t.offset?e.offsetLeft=n.width()-a[0]:"b"===t.offset?e.offsetTop=n.height()-a[1]:"l"===t.offset?e.offsetLeft=0:"lt"===t.offset?(e.offsetTop=0,e.offsetLeft=0):"lb"===t.offset?(e.offsetTop=n.height()-a[1],e.offsetLeft=0):"rt"===t.offset?(e.offsetTop=0,e.offsetLeft=n.width()-a[0]):"rb"===t.offset?(e.offsetTop=n.height()-a[1],e.offsetLeft=n.width()-a[0]):e.offsetTop=t.offset),t.fixed||(e.offsetTop=/%$/.test(e.offsetTop)?n.height()*parseFloat(e.offsetTop)/100:parseFloat(e.offsetTop),e.offsetLeft=/%$/.test(e.offsetLeft)?n.width()*parseFloat(e.offsetLeft)/100:parseFloat(e.offsetLeft),e.offsetTop+=n.scrollTop(),e.offsetLeft+=n.scrollLeft()),i.attr("minLeft")&&(e.offsetTop=n.height()-(i.find(l[1]).outerHeight()||0),e.offsetLeft=i.css("left")),i.css({top:e.offsetTop,left:e.offsetLeft})},s.pt.tips=function(){var e=this,t=e.config,a=e.layero,o=[a.outerWidth(),a.outerHeight()],r=i(t.follow);r[0]||(r=i("body"));var s={width:r.outerWidth(),height:r.outerHeight(),top:r.offset().top,left:r.offset().left},f=a.find(".layui-layer-TipsG"),c=t.tips[0];t.tips[1]||f.remove(),s.autoLeft=function(){s.left+o[0]-n.width()>0?(s.tipLeft=s.left+s.width-o[0],f.css({right:12,left:"auto"})):s.tipLeft=s.left},s.where=[function(){s.autoLeft(),s.tipTop=s.top-o[1]-10,f.removeClass("layui-layer-TipsB").addClass("layui-layer-TipsT").css("border-right-color",t.tips[1])},function(){s.tipLeft=s.left+s.width+10,s.tipTop=s.top,f.removeClass("layui-layer-TipsL").addClass("layui-layer-TipsR").css("border-bottom-color",t.tips[1])},function(){s.autoLeft(),s.tipTop=s.top+s.height+10,f.removeClass("layui-layer-TipsT").addClass("layui-layer-TipsB").css("border-right-color",t.tips[1])},function(){s.tipLeft=s.left-o[0]-10,s.tipTop=s.top,f.removeClass("layui-layer-TipsR").addClass("layui-layer-TipsL").css("border-bottom-color",t.tips[1])}],s.where[c-1](),1===c?s.top-(n.scrollTop()+o[1]+16)<0&&s.where[2]():2===c?n.width()-(s.left+s.width+o[0]+16)>0||s.where[3]():3===c?s.top-n.scrollTop()+s.height+o[1]+16-n.height()>0&&s.where[0]():4===c&&o[0]+16-s.left>0&&s.where[1](),a.find("."+l[5]).css({"background-color":t.tips[1],"padding-right":t.closeBtn?"30px":""}),a.css({left:s.tipLeft-(t.fixed?n.scrollLeft():0),top:s.tipTop-(t.fixed?n.scrollTop():0)})},s.pt.move=function(){var e=this,t=e.config,a=i(document),s=e.layero,l=s.find(t.move),f=s.find(".layui-layer-resize"),c={};return t.move&&l.css("cursor","move"),l.on("mousedown",function(e){e.preventDefault(),t.move&&(c.moveStart=!0,c.offset=[e.clientX-parseFloat(s.css("left")),e.clientY-parseFloat(s.css("top"))],o.moveElem.css("cursor","move").show())}),f.on("mousedown",function(e){e.preventDefault(),c.resizeStart=!0,c.offset=[e.clientX,e.clientY],c.area=[s.outerWidth(),s.outerHeight()],o.moveElem.css("cursor","se-resize").show()}),a.on("mousemove",function(i){if(c.moveStart){var a=i.clientX-c.offset[0],o=i.clientY-c.offset[1],l="fixed"===s.css("position");if(i.preventDefault(),c.stX=l?0:n.scrollLeft(),c.stY=l?0:n.scrollTop(),!t.moveOut){var f=n.width()-s.outerWidth()+c.stX,u=n.height()-s.outerHeight()+c.stY;a<c.stX&&(a=c.stX),a>f&&(a=f),o<c.stY&&(o=c.stY),o>u&&(o=u)}s.css({left:a,top:o})}if(t.resize&&c.resizeStart){var a=i.clientX-c.offset[0],o=i.clientY-c.offset[1];i.preventDefault(),r.style(e.index,{width:c.area[0]+a,height:c.area[1]+o}),c.isResize=!0,t.resizing&&t.resizing(s)}}).on("mouseup",function(e){c.moveStart&&(delete c.moveStart,o.moveElem.hide(),t.moveEnd&&t.moveEnd(s)),c.resizeStart&&(delete c.resizeStart,o.moveElem.hide())}),e},s.pt.callback=function(){function e(){var e=a.cancel&&a.cancel(t.index,n);e===!1||r.close(t.index)}var t=this,n=t.layero,a=t.config;if(t.openLayer(),a.success&&(2==a.type?n.find("iframe").on("load",function(){a.success(n,t.index)}):a.success(n,t.index)),6==r.ie&&t.IE6(n),n.find("."+l[6]).children("a").on("click",function(){var e=i(this).index();if(0===e)a.yes?a.yes(t.index,n):a.btn1?a.btn1(t.index,n):r.close(t.index);else{var o=a["btn"+(e+1)]&&a["btn"+(e+1)](t.index,n);o===!1||r.close(t.index)}}),"number"==typeof a.focusBtn){n.find("."+l[6]).children("a").each(function(){var e=i(this),t=i("<button type='button' />").addClass("layui-layer-confirm");e.css("position","relative").attr("tabindex",-1).append(t),t.click(function(){return e.trigger("click"),!1})});var s=n.find("."+l[6]).find("button.layui-layer-confirm").eq(a.focusBtn);s.length>0&&s.focus()}n.find("."+l[7]).on("click",e),a.shadeClose&&t.shadeo.on("click",function(){r.close(t.index)}),n.find(".layui-layer-min").on("click",function(){var e=a.min&&a.min(n,t.index);e===!1||r.min(t.index,a)}),n.find(".layui-layer-max").on("click",function(){i(this).hasClass("layui-layer-maxmin")?(r.restore(t.index),a.restore&&a.restore(n,t.index)):(r.full(t.index,a),setTimeout(function(){a.full&&a.full(n,t.index)},100))}),a.end&&(o.end[t.index]=a.end)},o.reselect=function(){i.each(i("select"),function(e,t){var n=i(this);n.parents("."+l[0])[0]||1==n.attr("layer")&&i("."+l[0]).length<1&&n.removeAttr("layer").show(),n=null})},s.pt.IE6=function(e){i("select").each(function(e,t){var n=i(this);n.parents("."+l[0])[0]||"none"===n.css("display")||n.attr({layer:"1"}).hide(),n=null})},s.pt.openLayer=function(){var e=this;r.zIndex=e.config.zIndex,r.setTop=function(e){var t=function(){r.zIndex++,e.css("z-index",r.zIndex+1)};return r.zIndex=parseInt(e[0].style.zIndex),e.on("mousedown",t),r.zIndex}},o.record=function(e){var t=[e.width(),e.height(),e.position().top,e.position().left+parseFloat(e.css("margin-left"))];e.find(".layui-layer-max").addClass("layui-layer-maxmin"),e.attr({area:t})},o.rescollbar=function(e){l.html.attr("layer-full")==e&&(l.html[0].style.removeProperty?l.html[0].style.removeProperty("overflow"):l.html[0].style.removeAttribute("overflow"),l.html.removeAttr("layer-full"))},e.layer=r,r.getChildFrame=function(e,t){return t=t||i("."+l[4]).attr("times"),i("#"+l[0]+t).find("iframe").contents().find(e)},r.getFrameIndex=function(e){return i("#"+e).parents("."+l[4]).attr("times")},r.iframeAuto=function(e){if(e){var t=r.getChildFrame("html",e).outerHeight(),n=i("#"+l[0]+e),a=n.find(l[1]).outerHeight()||0,o=n.find("."+l[6]).outerHeight()||0;n.css({height:t+a+o}),n.find("iframe").css({height:t})}},r.iframeSrc=function(e,t){i("#"+l[0]+e).find("iframe").attr("src",t)},r.style=function(e,t,n){var a=i("#"+l[0]+e),r=a.find(".layui-layer-content"),s=a.attr("type"),f=a.find(l[1]).outerHeight()||0,c=a.find("."+l[6]).outerHeight()||0;a.attr("minLeft");if(s!==o.type[3]&&s!==o.type[4])if(n||(parseFloat(t.width)<=260&&(t.width=260),parseFloat(t.height)-f-c<=64&&(t.height=64+f+c)),a.css(t),c=a.find("."+l[6]).outerHeight()||0,s===o.type[2])a.find("iframe").css({height:parseFloat(t.height)-f-c});else{var u="border-box"==r.css("box-sizing");r.css({height:parseFloat(t.height)-f-c-parseFloat(u?0:r.css("padding-top"))-parseFloat(u?0:r.css("padding-bottom"))})}},r.min=function(e,t){t=t||{};var a=i("#"+l[0]+e),s=i("#"+l.SHADE+e),f=a.find(l[1]).outerHeight()||0,c=a.attr("minLeft")||181*o.minIndex+"px",u=a.css("position"),d={width:180,height:f,position:"fixed",overflow:"hidden"};o.record(a),o.minLeft[0]&&(c=o.minLeft[0],o.minLeft.shift()),t.minStack&&(d.left=c,d.top=n.height()-f,a.attr("minLeft")||o.minIndex++,a.attr("minLeft",c)),a.attr("position",u),r.style(e,d,!0),a.find(".layui-layer-min").hide(),"page"===a.attr("type")&&a.find(l[4]).hide(),o.rescollbar(e),s.hide()},r.restore=function(e){var t=i("#"+l[0]+e),n=i("#"+l.SHADE+e),a=t.attr("area").split(",");t.attr("type");r.style(e,{width:parseFloat(a[0]),height:parseFloat(a[1]),top:parseFloat(a[2]),left:parseFloat(a[3]),position:t.attr("position"),overflow:"visible"},!0),t.find(".layui-layer-max").removeClass("layui-layer-maxmin"),t.find(".layui-layer-min").show(),"page"===t.attr("type")&&t.find(l[4]).show(),o.rescollbar(e),n.show()},r.full=function(e){var t,a=i("#"+l[0]+e);o.record(a),l.html.attr("layer-full")||l.html.css("overflow","hidden").attr("layer-full",e),clearTimeout(t),t=setTimeout(function(){var t="fixed"===a.css("position");r.style(e,{top:t?0:n.scrollTop(),left:t?0:n.scrollLeft(),width:n.width(),height:n.height()},!0),a.find(".layui-layer-min").hide()},100)},r.title=function(e,t){var n=i("#"+l[0]+(t||r.index)).find(l[1]);n.html(e)},r.close=function(e,t){var n=i("#"+l[0]+e),a=n.attr("type"),s="layer-anim-close";if(n[0]){var f="layui-layer-wrap",c=function(){if(a===o.type[1]&&"object"===n.attr("conType")){n.children(":not(."+l[5]+")").remove();for(var r=n.find("."+f),s=0;s<2;s++)r.unwrap();r.css("display",r.data("display")).removeClass(f)}else{if(a===o.type[2])try{var c=i("#"+l[4]+e)[0];c.contentWindow.document.write(""),c.contentWindow.close(),n.find("."+l[5])[0].removeChild(c)}catch(u){}n[0].innerHTML="",n.remove()}"function"==typeof o.end[e]&&o.end[e](),delete o.end[e],"function"==typeof t&&t()};n.data("isOutAnim")&&n.addClass("layer-anim "+s),i("#layui-layer-moves, #"+l.SHADE+e).remove(),6==r.ie&&o.reselect(),o.rescollbar(e),n.attr("minLeft")&&(o.minIndex--,o.minLeft.push(n.attr("minLeft"))),r.ie&&r.ie<10||!n.data("isOutAnim")?c():setTimeout(function(){c()},200)}},r.closeAll=function(e,t){"function"==typeof e&&(t=e,e=null);var n=i("."+l[0]);i.each(n,function(a){var o=i(this),s=e?o.attr("type")===e:1;s&&r.close(o.attr("times"),a===n.length-1?t:null),s=null}),0===n.length&&"function"==typeof t&&t()};var f=r.cache||{},c=function(e){return f.skin?" "+f.skin+" "+f.skin+"-"+e:""};r.prompt=function(e,t){var a="";if(e=e||{},"function"==typeof e&&(t=e),e.area){var o=e.area;a='style="width: '+o[0]+"; height: "+o[1]+';"',delete e.area}var s,l=2==e.formType?'<textarea class="layui-layer-input"'+a+"></textarea>":function(){return'<input type="'+(1==e.formType?"password":"text")+'" class="layui-layer-input">'}(),f=e.success;return delete e.success,r.open(i.extend({type:1,btn:["&#x786E;&#x5B9A;","&#x53D6;&#x6D88;"],content:l,skin:"layui-layer-prompt"+c("prompt"),maxWidth:n.width(),success:function(t){s=t.find(".layui-layer-input"),s.val(e.value||"").focus(),"function"==typeof f&&f(t)},resize:!1,yes:function(i){var n=s.val();""===n?s.focus():n.length>(e.maxlength||500)?r.tips("&#x6700;&#x591A;&#x8F93;&#x5165;"+(e.maxlength||500)+"&#x4E2A;&#x5B57;&#x6570;",s,{tips:1}):t&&t(n,i,s)}},e))},r.tab=function(e){e=e||{};var t=e.tab||{},n="layui-this",a=e.success;return delete e.success,r.open(i.extend({type:1,skin:"layui-layer-tab"+c("tab"),resize:!1,title:function(){var e=t.length,i=1,a="";if(e>0)for(a='<span class="'+n+'">'+t[0].title+"</span>";i<e;i++)a+="<span>"+t[i].title+"</span>";return a}(),content:'<ul class="layui-layer-tabmain">'+function(){var e=t.length,i=1,a="";if(e>0)for(a='<li class="layui-layer-tabli '+n+'">'+(t[0].content||"no content")+"</li>";i<e;i++)a+='<li class="layui-layer-tabli">'+(t[i].content||"no content")+"</li>";return a}()+"</ul>",success:function(t){var o=t.find(".layui-layer-title").children(),r=t.find(".layui-layer-tabmain").children();o.on("mousedown",function(t){t.stopPropagation?t.stopPropagation():t.cancelBubble=!0;var a=i(this),o=a.index();a.addClass(n).siblings().removeClass(n),r.eq(o).show().siblings().hide(),"function"==typeof e.change&&e.change(o)}),"function"==typeof a&&a(t)}},e))},r.photos=function(t,n,a){function o(e,t,i){var n=new Image;return n.src=e,n.complete?t(n):(n.onload=function(){n.onload=null,t(n)},void(n.onerror=function(e){n.onerror=null,i(e)}))}var s={};if(t=t||{},t.photos){t.zoom="undefined"==typeof t.zoom||!!t.zoom;var l=!("string"==typeof t.photos||t.photos instanceof i),f=l?t.photos:{},u=f.data||[],d=f.start||0;s.imgIndex=(0|d)+1,t.img=t.img||"img";var y=t.success;if(delete t.success,l){if(0===u.length)return r.msg("&#x6CA1;&#x6709;&#x56FE;&#x7247;")}else{var p=i(t.photos),h=function(){u=[],p.find(t.img).each(function(e){var t=i(this);t.attr("layer-index",e),u.push({alt:t.attr("alt"),pid:t.attr("layer-pid"),src:t.attr("layer-src")||t.attr("src"),thumb:t.attr("src")})})};if(h(),0===u.length)return;if(n||p.on("click",t.img,function(){h();var e=i(this),n=e.attr("layer-index");r.photos(i.extend(t,{photos:{start:n,data:u,tab:t.tab},full:t.full}),!0)}),!n)return}s.imgprev=function(e){s.imgIndex--,s.imgIndex<1&&(s.imgIndex=u.length),s.tabimg(e)},s.imgnext=function(e,t){s.imgIndex++,s.imgIndex>u.length&&(s.imgIndex=1,t)||s.tabimg(e)},s.keyup=function(e){if(!s.end){var t=e.keyCode;e.preventDefault(),37===t?s.imgprev(!0):39===t?s.imgnext(!0):27===t&&r.close(s.index)}},s.tabimg=function(e){if(!(u.length<=1))return f.start=s.imgIndex-1,r.close(s.index),r.photos(t,!0,e)},s.event=function(){s.bigimg.find(".layui-layer-imgprev").on("click",function(e){e.preventDefault(),s.imgprev(!0)}),s.bigimg.find(".layui-layer-imgnext").on("click",function(e){e.preventDefault(),s.imgnext(!0)}),i(document).on("keyup",s.keyup),t.zoom&&s.bigimg.on("wheel mousewheel",i(">img",s.bigimg),function(e){var t=i(this).offset(),n=e.originalEvent.wheelDelta>0,a=n?"+=":"-=",o=24,r=Math.floor(o/2);return!(!n&&(i(this).width()<50||i(this).height()<50))&&(i(this).width(a+o).height(a+o).offset({left:n?t.left-r:t.left+r,top:n?t.top-r:t.top+r}),!1)})},s.loadi=r.load(1,{shade:!("shade"in t)&&.9,scrollbar:!1}),o(u[d].src,function(n){r.close(s.loadi),a&&(t.anim=-1),s.index=r.open(i.extend({type:1,id:"layui-layer-photos",area:function(){var a=[n.width,n.height],o=[i(e).width()-100,i(e).height()-100];if(!t.full&&(a[0]>o[0]||a[1]>o[1])){var r=[a[0]/o[0],a[1]/o[1]];r[0]>r[1]?(a[0]=a[0]/r[0],a[1]=a[1]/r[0]):r[0]<r[1]&&(a[0]=a[0]/r[1],a[1]=a[1]/r[1])}return[a[0]+"px",a[1]+"px"]}(),title:!1,shade:.9,shadeClose:!0,closeBtn:!1,move:".layui-layer-phimg img",moveType:1,scrollbar:!1,moveOut:!0,anim:5,isOutAnim:!1,skin:"layui-layer-photos"+c("photos"),content:'<div class="layui-layer-phimg"><img src="'+u[d].src+'" alt="'+(u[d].alt||"")+'" layer-pid="'+u[d].pid+'">'+function(){return u.length>1?'<div class="layui-layer-imgsee"><span class="layui-layer-imguide"><a href="javascript:;" class="layui-layer-iconext layui-layer-imgprev"></a><a href="javascript:;" class="layui-layer-iconext layui-layer-imgnext"></a></span><div class="layui-layer-imgbar" style="display:'+(a?"block":"")+'"><span class="layui-layer-imgtit"><a href="javascript:;">'+(u[d].alt||"")+"</a><em>"+s.imgIndex+" / "+u.length+"</em></span></div></div>":""}()+"</div>",success:function(e,i){s.bigimg=e.find(".layui-layer-phimg"),s.imgsee=e.find(".layui-layer-imgbar"),s.event(e),t.tab&&t.tab(u[d],e),"function"==typeof y&&y(e)},end:function(){s.end=!0,i(document).off("keyup",s.keyup)}},t))},function(){r.close(s.loadi),r.msg("&#x5F53;&#x524D;&#x56FE;&#x7247;&#x5730;&#x5740;&#x5F02;&#x5E38;<br>&#x662F;&#x5426;&#x7EE7;&#x7EED;&#x67E5;&#x770B;&#x4E0B;&#x4E00;&#x5F20;&#xFF1F;",{time:3e4,btn:["&#x4E0B;&#x4E00;&#x5F20;","&#x4E0D;&#x770B;&#x4E86;"],yes:function(){u.length>1&&s.imgnext(!0,!0)}})})}},o.run=function(t){i=t,n=i(e),l.html=i("html"),r.open=function(e){var t=new s(e);return t.index}},e.layui&&layui.define?(r.ready(),layui.define("jquery",function(t){r.path=layui.cache.dir,o.run(layui.$),e.layer=r,t("layer",r)})):"function"==typeof define&&define.amd?define('layer',["jquery"],function(){return o.run(e.jQuery),r}):function(){r.ready(),o.run(e.jQuery)}()}(window);
  188. /*
  189. * Toastr
  190. * Copyright 2012-2015
  191. * Authors: John Papa, Hans Fjällemark, and Tim Ferrell.
  192. * All Rights Reserved.
  193. * Use, reproduction, distribution, and modification of this code is subject to the terms and
  194. * conditions of the MIT license, available at http://www.opensource.org/licenses/mit-license.php
  195. *
  196. * ARIA Support: Greta Krafsig
  197. *
  198. * Project: https://github.com/CodeSeven/toastr
  199. */
  200. /* global define */
  201. (function (define) {
  202. define('toastr',['jquery'], function ($) {
  203. return (function () {
  204. var $container;
  205. var listener;
  206. var toastId = 0;
  207. var toastType = {
  208. error: 'error',
  209. info: 'info',
  210. success: 'success',
  211. warning: 'warning'
  212. };
  213. var toastr = {
  214. clear: clear,
  215. remove: remove,
  216. error: error,
  217. getContainer: getContainer,
  218. info: info,
  219. options: {},
  220. subscribe: subscribe,
  221. success: success,
  222. version: '2.1.4',
  223. warning: warning
  224. };
  225. var previousToast;
  226. return toastr;
  227. ////////////////
  228. function error(message, title, optionsOverride) {
  229. return notify({
  230. type: toastType.error,
  231. iconClass: getOptions().iconClasses.error,
  232. message: message,
  233. optionsOverride: optionsOverride,
  234. title: title
  235. });
  236. }
  237. function getContainer(options, create) {
  238. if (!options) { options = getOptions(); }
  239. $container = $('#' + options.containerId);
  240. if ($container.length) {
  241. return $container;
  242. }
  243. if (create) {
  244. $container = createContainer(options);
  245. }
  246. return $container;
  247. }
  248. function info(message, title, optionsOverride) {
  249. return notify({
  250. type: toastType.info,
  251. iconClass: getOptions().iconClasses.info,
  252. message: message,
  253. optionsOverride: optionsOverride,
  254. title: title
  255. });
  256. }
  257. function subscribe(callback) {
  258. listener = callback;
  259. }
  260. function success(message, title, optionsOverride) {
  261. return notify({
  262. type: toastType.success,
  263. iconClass: getOptions().iconClasses.success,
  264. message: message,
  265. optionsOverride: optionsOverride,
  266. title: title
  267. });
  268. }
  269. function warning(message, title, optionsOverride) {
  270. return notify({
  271. type: toastType.warning,
  272. iconClass: getOptions().iconClasses.warning,
  273. message: message,
  274. optionsOverride: optionsOverride,
  275. title: title
  276. });
  277. }
  278. function clear($toastElement, clearOptions) {
  279. var options = getOptions();
  280. if (!$container) { getContainer(options); }
  281. if (!clearToast($toastElement, options, clearOptions)) {
  282. clearContainer(options);
  283. }
  284. }
  285. function remove($toastElement) {
  286. var options = getOptions();
  287. if (!$container) { getContainer(options); }
  288. if ($toastElement && $(':focus', $toastElement).length === 0) {
  289. removeToast($toastElement);
  290. return;
  291. }
  292. if ($container.children().length) {
  293. $container.remove();
  294. }
  295. }
  296. // internal functions
  297. function clearContainer (options) {
  298. var toastsToClear = $container.children();
  299. for (var i = toastsToClear.length - 1; i >= 0; i--) {
  300. clearToast($(toastsToClear[i]), options);
  301. }
  302. }
  303. function clearToast ($toastElement, options, clearOptions) {
  304. var force = clearOptions && clearOptions.force ? clearOptions.force : false;
  305. if ($toastElement && (force || $(':focus', $toastElement).length === 0)) {
  306. $toastElement[options.hideMethod]({
  307. duration: options.hideDuration,
  308. easing: options.hideEasing,
  309. complete: function () { removeToast($toastElement); }
  310. });
  311. return true;
  312. }
  313. return false;
  314. }
  315. function createContainer(options) {
  316. $container = $('<div/>')
  317. .attr('id', options.containerId)
  318. .addClass(options.positionClass);
  319. $container.appendTo($(options.target));
  320. return $container;
  321. }
  322. function getDefaults() {
  323. return {
  324. tapToDismiss: true,
  325. toastClass: 'toast',
  326. containerId: 'toast-container',
  327. debug: false,
  328. showMethod: 'fadeIn', //fadeIn, slideDown, and show are built into jQuery
  329. showDuration: 300,
  330. showEasing: 'swing', //swing and linear are built into jQuery
  331. onShown: undefined,
  332. hideMethod: 'fadeOut',
  333. hideDuration: 1000,
  334. hideEasing: 'swing',
  335. onHidden: undefined,
  336. closeMethod: false,
  337. closeDuration: false,
  338. closeEasing: false,
  339. closeOnHover: true,
  340. extendedTimeOut: 1000,
  341. iconClasses: {
  342. error: 'toast-error',
  343. info: 'toast-info',
  344. success: 'toast-success',
  345. warning: 'toast-warning'
  346. },
  347. iconClass: 'toast-info',
  348. positionClass: 'toast-top-right',
  349. timeOut: 5000, // Set timeOut and extendedTimeOut to 0 to make it sticky
  350. titleClass: 'toast-title',
  351. messageClass: 'toast-message',
  352. escapeHtml: false,
  353. target: 'body',
  354. closeHtml: '<button type="button">&times;</button>',
  355. closeClass: 'toast-close-button',
  356. newestOnTop: true,
  357. preventDuplicates: false,
  358. progressBar: false,
  359. progressClass: 'toast-progress',
  360. rtl: false
  361. };
  362. }
  363. function publish(args) {
  364. if (!listener) { return; }
  365. listener(args);
  366. }
  367. function notify(map) {
  368. var options = getOptions();
  369. var iconClass = map.iconClass || options.iconClass;
  370. if (typeof (map.optionsOverride) !== 'undefined') {
  371. options = $.extend(options, map.optionsOverride);
  372. iconClass = map.optionsOverride.iconClass || iconClass;
  373. }
  374. if (shouldExit(options, map)) { return; }
  375. toastId++;
  376. $container = getContainer(options, true);
  377. var intervalId = null;
  378. var $toastElement = $('<div/>');
  379. var $titleElement = $('<div/>');
  380. var $messageElement = $('<div/>');
  381. var $progressElement = $('<div/>');
  382. var $closeElement = $(options.closeHtml);
  383. var progressBar = {
  384. intervalId: null,
  385. hideEta: null,
  386. maxHideTime: null
  387. };
  388. var response = {
  389. toastId: toastId,
  390. state: 'visible',
  391. startTime: new Date(),
  392. options: options,
  393. map: map
  394. };
  395. personalizeToast();
  396. displayToast();
  397. handleEvents();
  398. publish(response);
  399. if (options.debug && console) {
  400. console.log(response);
  401. }
  402. return $toastElement;
  403. function escapeHtml(source) {
  404. if (source == null) {
  405. source = '';
  406. }
  407. return source
  408. .replace(/&/g, '&amp;')
  409. .replace(/"/g, '&quot;')
  410. .replace(/'/g, '&#39;')
  411. .replace(/</g, '&lt;')
  412. .replace(/>/g, '&gt;');
  413. }
  414. function personalizeToast() {
  415. setIcon();
  416. setTitle();
  417. setMessage();
  418. setCloseButton();
  419. setProgressBar();
  420. setRTL();
  421. setSequence();
  422. setAria();
  423. }
  424. function setAria() {
  425. var ariaValue = '';
  426. switch (map.iconClass) {
  427. case 'toast-success':
  428. case 'toast-info':
  429. ariaValue = 'polite';
  430. break;
  431. default:
  432. ariaValue = 'assertive';
  433. }
  434. $toastElement.attr('aria-live', ariaValue);
  435. }
  436. function handleEvents() {
  437. if (options.closeOnHover) {
  438. $toastElement.hover(stickAround, delayedHideToast);
  439. }
  440. if (!options.onclick && options.tapToDismiss) {
  441. $toastElement.click(hideToast);
  442. }
  443. if (options.closeButton && $closeElement) {
  444. $closeElement.click(function (event) {
  445. if (event.stopPropagation) {
  446. event.stopPropagation();
  447. } else if (event.cancelBubble !== undefined && event.cancelBubble !== true) {
  448. event.cancelBubble = true;
  449. }
  450. if (options.onCloseClick) {
  451. options.onCloseClick(event);
  452. }
  453. hideToast(true);
  454. });
  455. }
  456. if (options.onclick) {
  457. $toastElement.click(function (event) {
  458. options.onclick(event);
  459. hideToast();
  460. });
  461. }
  462. }
  463. function displayToast() {
  464. $toastElement.hide();
  465. $toastElement[options.showMethod](
  466. {duration: options.showDuration, easing: options.showEasing, complete: options.onShown}
  467. );
  468. if (options.timeOut > 0) {
  469. intervalId = setTimeout(hideToast, options.timeOut);
  470. progressBar.maxHideTime = parseFloat(options.timeOut);
  471. progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime;
  472. if (options.progressBar) {
  473. progressBar.intervalId = setInterval(updateProgress, 10);
  474. }
  475. }
  476. }
  477. function setIcon() {
  478. if (map.iconClass) {
  479. $toastElement.addClass(options.toastClass).addClass(iconClass);
  480. }
  481. }
  482. function setSequence() {
  483. if (options.newestOnTop) {
  484. $container.prepend($toastElement);
  485. } else {
  486. $container.append($toastElement);
  487. }
  488. }
  489. function setTitle() {
  490. if (map.title) {
  491. var suffix = map.title;
  492. if (options.escapeHtml) {
  493. suffix = escapeHtml(map.title);
  494. }
  495. $titleElement.append(suffix).addClass(options.titleClass);
  496. $toastElement.append($titleElement);
  497. }
  498. }
  499. function setMessage() {
  500. if (map.message) {
  501. var suffix = map.message;
  502. if (options.escapeHtml) {
  503. suffix = escapeHtml(map.message);
  504. }
  505. $messageElement.append(suffix).addClass(options.messageClass);
  506. $toastElement.append($messageElement);
  507. }
  508. }
  509. function setCloseButton() {
  510. if (options.closeButton) {
  511. $closeElement.addClass(options.closeClass).attr('role', 'button');
  512. $toastElement.prepend($closeElement);
  513. }
  514. }
  515. function setProgressBar() {
  516. if (options.progressBar) {
  517. $progressElement.addClass(options.progressClass);
  518. $toastElement.prepend($progressElement);
  519. }
  520. }
  521. function setRTL() {
  522. if (options.rtl) {
  523. $toastElement.addClass('rtl');
  524. }
  525. }
  526. function shouldExit(options, map) {
  527. if (options.preventDuplicates) {
  528. if (map.message === previousToast) {
  529. return true;
  530. } else {
  531. previousToast = map.message;
  532. }
  533. }
  534. return false;
  535. }
  536. function hideToast(override) {
  537. var method = override && options.closeMethod !== false ? options.closeMethod : options.hideMethod;
  538. var duration = override && options.closeDuration !== false ?
  539. options.closeDuration : options.hideDuration;
  540. var easing = override && options.closeEasing !== false ? options.closeEasing : options.hideEasing;
  541. if ($(':focus', $toastElement).length && !override) {
  542. return;
  543. }
  544. clearTimeout(progressBar.intervalId);
  545. return $toastElement[method]({
  546. duration: duration,
  547. easing: easing,
  548. complete: function () {
  549. removeToast($toastElement);
  550. clearTimeout(intervalId);
  551. if (options.onHidden && response.state !== 'hidden') {
  552. options.onHidden();
  553. }
  554. response.state = 'hidden';
  555. response.endTime = new Date();
  556. publish(response);
  557. }
  558. });
  559. }
  560. function delayedHideToast() {
  561. if (options.timeOut > 0 || options.extendedTimeOut > 0) {
  562. intervalId = setTimeout(hideToast, options.extendedTimeOut);
  563. progressBar.maxHideTime = parseFloat(options.extendedTimeOut);
  564. progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime;
  565. }
  566. }
  567. function stickAround() {
  568. clearTimeout(intervalId);
  569. progressBar.hideEta = 0;
  570. $toastElement.stop(true, true)[options.showMethod](
  571. {duration: options.showDuration, easing: options.showEasing}
  572. );
  573. }
  574. function updateProgress() {
  575. var percentage = ((progressBar.hideEta - (new Date().getTime())) / progressBar.maxHideTime) * 100;
  576. $progressElement.width(percentage + '%');
  577. }
  578. }
  579. function getOptions() {
  580. return $.extend({}, getDefaults(), toastr.options);
  581. }
  582. function removeToast($toastElement) {
  583. if (!$container) { $container = getContainer(); }
  584. if ($toastElement.is(':visible')) {
  585. return;
  586. }
  587. $toastElement.remove();
  588. $toastElement = null;
  589. if ($container.children().length === 0) {
  590. $container.remove();
  591. previousToast = undefined;
  592. }
  593. }
  594. })();
  595. });
  596. }(typeof define === 'function' && define.amd ? define : function (deps, factory) {
  597. if (typeof module !== 'undefined' && module.exports) { //Node
  598. module.exports = factory(require('jquery'));
  599. } else {
  600. window.toastr = factory(window.jQuery);
  601. }
  602. }));
  603. define('fast',['jquery', 'bootstrap', 'toastr', 'layer', 'lang'], function ($, undefined, Toastr, Layer, Lang) {
  604. var Fast = {
  605. config: {
  606. //toastr默认配置
  607. toastr: {
  608. "closeButton": true,
  609. "debug": false,
  610. "newestOnTop": false,
  611. "progressBar": false,
  612. "positionClass": "toast-top-center",
  613. "preventDuplicates": false,
  614. "onclick": null,
  615. "showDuration": "300",
  616. "hideDuration": "1000",
  617. "timeOut": "5000",
  618. "extendedTimeOut": "1000",
  619. "showEasing": "swing",
  620. "hideEasing": "linear",
  621. "showMethod": "fadeIn",
  622. "hideMethod": "fadeOut"
  623. }
  624. },
  625. events: {
  626. //请求成功的回调
  627. onAjaxSuccess: function (ret, onAjaxSuccess) {
  628. var data = typeof ret.data !== 'undefined' ? ret.data : null;
  629. var msg = typeof ret.msg !== 'undefined' && ret.msg ? ret.msg : __('Operation completed');
  630. if (typeof onAjaxSuccess === 'function') {
  631. var result = onAjaxSuccess.call(this, data, ret);
  632. if (result === false)
  633. return;
  634. }
  635. Toastr.success(msg);
  636. },
  637. //请求错误的回调
  638. onAjaxError: function (ret, onAjaxError) {
  639. var data = typeof ret.data !== 'undefined' ? ret.data : null;
  640. if (typeof onAjaxError === 'function') {
  641. var result = onAjaxError.call(this, data, ret);
  642. if (result === false) {
  643. return;
  644. }
  645. }
  646. Toastr.error(ret.msg);
  647. },
  648. //服务器响应数据后
  649. onAjaxResponse: function (response) {
  650. try {
  651. var ret = typeof response === 'object' ? response : JSON.parse(response);
  652. if (!ret.hasOwnProperty('code')) {
  653. $.extend(ret, {code: -2, msg: response, data: null});
  654. }
  655. } catch (e) {
  656. var ret = {code: -1, msg: e.message, data: null};
  657. }
  658. return ret;
  659. }
  660. },
  661. api: {
  662. //发送Ajax请求
  663. ajax: function (options, success, error) {
  664. options = typeof options === 'string' ? {url: options} : options;
  665. var index;
  666. if (typeof options.loading === 'undefined' || options.loading) {
  667. index = Layer.load(options.loading || 0);
  668. }
  669. options = $.extend({
  670. type: "POST",
  671. dataType: "json",
  672. xhrFields: {
  673. withCredentials: true
  674. },
  675. success: function (ret) {
  676. index && Layer.close(index);
  677. ret = Fast.events.onAjaxResponse(ret);
  678. if (ret.code === 1) {
  679. Fast.events.onAjaxSuccess(ret, success);
  680. } else {
  681. Fast.events.onAjaxError(ret, error);
  682. }
  683. },
  684. error: function (xhr) {
  685. index && Layer.close(index);
  686. var ret = {code: xhr.status, msg: xhr.statusText, data: null};
  687. Fast.events.onAjaxError(ret, error);
  688. }
  689. }, options);
  690. return $.ajax(options);
  691. },
  692. //修复URL
  693. fixurl: function (url) {
  694. if (url.substr(0, 1) !== "/") {
  695. var r = new RegExp('^(?:[a-z]+:)?//', 'i');
  696. if (!r.test(url)) {
  697. url = Config.moduleurl + "/" + url;
  698. }
  699. } else if (url.substr(0, 8) === "/addons/") {
  700. url = Config.__PUBLIC__.replace(/(\/*$)/g, "") + url;
  701. }
  702. return url;
  703. },
  704. //获取修复后可访问的cdn链接
  705. cdnurl: function (url, domain) {
  706. var rule = new RegExp("^((?:[a-z]+:)?\\/\\/|data:image\\/)", "i");
  707. var cdnurl = Config.upload.cdnurl;
  708. if (typeof domain === 'undefined' || domain === true || cdnurl.indexOf("/") === 0) {
  709. url = rule.test(url) || (cdnurl && url.indexOf(cdnurl) === 0) ? url : cdnurl + url;
  710. }
  711. if (domain && !rule.test(url)) {
  712. domain = typeof domain === 'string' ? domain : location.origin;
  713. url = domain + url;
  714. }
  715. return url;
  716. },
  717. //查询Url参数
  718. query: function (name, url) {
  719. if (!url) {
  720. url = window.location.href;
  721. }
  722. if (!name)
  723. return '';
  724. name = name.replace(/[\[\]]/g, "\\$&");
  725. var regex = new RegExp("[?&/]" + name + "([=/]([^&#/?]*)|&|#|$)"),
  726. results = regex.exec(url);
  727. if (!results)
  728. return null;
  729. if (!results[2])
  730. return '';
  731. return decodeURIComponent(results[2].replace(/\+/g, " "));
  732. },
  733. //打开一个弹出窗口
  734. open: function (url, title, options) {
  735. title = options && options.title ? options.title : (title ? title : "");
  736. url = Fast.api.fixurl(url);
  737. url = url + (url.indexOf("?") > -1 ? "&" : "?") + "dialog=1";
  738. var area = Fast.config.openArea != undefined ? Fast.config.openArea : [$(window).width() > 800 ? '800px' : '95%', $(window).height() > 600 ? '600px' : '95%'];
  739. var success = options && typeof options.success === 'function' ? options.success : $.noop;
  740. if (options && typeof options.success === 'function') {
  741. delete options.success;
  742. }
  743. options = $.extend({
  744. type: 2,
  745. title: title,
  746. shadeClose: true,
  747. shade: false,
  748. maxmin: true,
  749. moveOut: true,
  750. area: area,
  751. content: url,
  752. zIndex: Layer.zIndex,
  753. success: function (layero, index) {
  754. var that = this;
  755. //存储callback事件
  756. $(layero).data("callback", that.callback);
  757. //$(layero).removeClass("layui-layer-border");
  758. Layer.setTop(layero);
  759. try {
  760. var frame = Layer.getChildFrame('html', index);
  761. var layerfooter = frame.find(".layer-footer");
  762. Fast.api.layerfooter(layero, index, that);
  763. //绑定事件
  764. if (layerfooter.length > 0) {
  765. // 监听窗口内的元素及属性变化
  766. // Firefox和Chrome早期版本中带有前缀
  767. var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
  768. if (MutationObserver) {
  769. // 选择目标节点
  770. var target = layerfooter[0];
  771. // 创建观察者对象
  772. var observer = new MutationObserver(function (mutations) {
  773. Fast.api.layerfooter(layero, index, that);
  774. mutations.forEach(function (mutation) {
  775. });
  776. });
  777. // 配置观察选项:
  778. var config = {attributes: true, childList: true, characterData: true, subtree: true}
  779. // 传入目标节点和观察选项
  780. observer.observe(target, config);
  781. // 随后,你还可以停止观察
  782. // observer.disconnect();
  783. }
  784. }
  785. } catch (e) {
  786. }
  787. if ($(layero).height() > $(window).height()) {
  788. //当弹出窗口大于浏览器可视高度时,重定位
  789. Layer.style(index, {
  790. top: 0,
  791. height: $(window).height()
  792. });
  793. }
  794. success.call(this, layero, index);
  795. }
  796. }, options ? options : {});
  797. if ($(window).width() < 480 || (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream && top.$(".tab-pane.active").length > 0)) {
  798. if (top.$(".tab-pane.active").length > 0) {
  799. options.area = [top.$(".tab-pane.active").width() + "px", top.$(".tab-pane.active").height() + "px"];
  800. options.offset = [top.$(".tab-pane.active").scrollTop() + "px", "0px"];
  801. } else {
  802. options.area = [$(window).width() + "px", $(window).height() + "px"];
  803. options.offset = ["0px", "0px"];
  804. }
  805. }
  806. return Layer.open(options);
  807. },
  808. //关闭窗口并回传数据
  809. close: function (data) {
  810. var index = parent.Layer.getFrameIndex(window.name);
  811. var callback = parent.$("#layui-layer" + index).data("callback");
  812. //再执行关闭
  813. parent.Layer.close(index);
  814. //再调用回传函数
  815. if (typeof callback === 'function') {
  816. callback.call(undefined, data);
  817. }
  818. },
  819. layerfooter: function (layero, index, that) {
  820. var frame = Layer.getChildFrame('html', index);
  821. var layerfooter = frame.find(".layer-footer");
  822. if (layerfooter.length > 0) {
  823. $(".layui-layer-footer", layero).remove();
  824. var footer = $("<div />").addClass('layui-layer-btn layui-layer-footer');
  825. footer.html(layerfooter.html());
  826. if ($(".row", footer).length === 0) {
  827. $(">", footer).wrapAll("<div class='row'></div>");
  828. }
  829. footer.insertAfter(layero.find('.layui-layer-content'));
  830. //绑定事件
  831. footer.on("click", ".btn", function () {
  832. if ($(this).hasClass("disabled") || $(this).parent().hasClass("disabled")) {
  833. return;
  834. }
  835. var index = footer.find('.btn').index(this);
  836. $(".btn:eq(" + index + ")", layerfooter).trigger("click");
  837. });
  838. var titHeight = layero.find('.layui-layer-title').outerHeight() || 0;
  839. var btnHeight = layero.find('.layui-layer-btn').outerHeight() || 0;
  840. //重设iframe高度
  841. $("iframe", layero).height(layero.height() - titHeight - btnHeight);
  842. }
  843. //修复iOS下弹出窗口的高度和iOS下iframe无法滚动的BUG
  844. if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
  845. var titHeight = layero.find('.layui-layer-title').outerHeight() || 0;
  846. var btnHeight = layero.find('.layui-layer-btn').outerHeight() || 0;
  847. $("iframe", layero).parent().css("height", layero.height() - titHeight - btnHeight);
  848. $("iframe", layero).css("height", "100%");
  849. }
  850. },
  851. success: function (options, callback) {
  852. var type = typeof options === 'function';
  853. if (type) {
  854. callback = options;
  855. }
  856. return Layer.msg(__('Operation completed'), $.extend({
  857. offset: 0, icon: 1
  858. }, type ? {} : options), callback);
  859. },
  860. error: function (options, callback) {
  861. var type = typeof options === 'function';
  862. if (type) {
  863. callback = options;
  864. }
  865. return Layer.msg(__('Operation failed'), $.extend({
  866. offset: 0, icon: 2
  867. }, type ? {} : options), callback);
  868. },
  869. msg: function (message, url) {
  870. var callback = typeof url === 'function' ? url : function () {
  871. if (typeof url !== 'undefined' && url) {
  872. location.href = url;
  873. }
  874. };
  875. Layer.msg(message, {
  876. time: 2000
  877. }, callback);
  878. },
  879. escape: function (text) {
  880. if (typeof text === 'string') {
  881. return text
  882. .replace(/&/g, '&amp;')
  883. .replace(/</g, '&lt;')
  884. .replace(/>/g, '&gt;')
  885. .replace(/"/g, '&quot;')
  886. .replace(/'/g, '&#039;')
  887. .replace(/`/g, '&#x60;');
  888. }
  889. return text;
  890. },
  891. toastr: Toastr,
  892. layer: Layer
  893. },
  894. lang: function () {
  895. var args = arguments,
  896. string = args[0],
  897. i = 1;
  898. string = string.toLowerCase();
  899. //string = typeof Lang[string] != 'undefined' ? Lang[string] : string;
  900. if (typeof Lang !== 'undefined' && typeof Lang[string] !== 'undefined') {
  901. if (typeof Lang[string] == 'object')
  902. return Lang[string];
  903. string = Lang[string];
  904. } else if (string.indexOf('.') !== -1 && false) {
  905. var arr = string.split('.');
  906. var current = Lang[arr[0]];
  907. for (var i = 1; i < arr.length; i++) {
  908. current = typeof current[arr[i]] != 'undefined' ? current[arr[i]] : '';
  909. if (typeof current != 'object')
  910. break;
  911. }
  912. if (typeof current == 'object')
  913. return current;
  914. string = current;
  915. } else {
  916. string = args[0];
  917. }
  918. return string.replace(/%((%)|s|d)/g, function (m) {
  919. // m is the matched format, e.g. %s, %d
  920. var val = null;
  921. if (m[2]) {
  922. val = m[2];
  923. } else {
  924. val = args[i];
  925. // A switch statement so that the formatter can be extended. Default is %s
  926. switch (m) {
  927. case '%d':
  928. val = parseFloat(val);
  929. if (isNaN(val)) {
  930. val = 0;
  931. }
  932. break;
  933. }
  934. i++;
  935. }
  936. return val;
  937. });
  938. },
  939. init: function () {
  940. // jQuery兼容处理
  941. $.fn.extend({
  942. size: function () {
  943. return $(this).length;
  944. }
  945. });
  946. // 对相对地址进行处理
  947. $.ajaxSetup({
  948. beforeSend: function (xhr, setting) {
  949. setting.url = Fast.api.fixurl(setting.url);
  950. }
  951. });
  952. Layer.config({
  953. skin: 'layui-layer-fast'
  954. });
  955. // 绑定ESC关闭窗口事件
  956. $(window).keyup(function (e) {
  957. if (e.keyCode == 27) {
  958. if ($(".layui-layer").length > 0) {
  959. var index = 0;
  960. $(".layui-layer").each(function () {
  961. index = Math.max(index, parseInt($(this).attr("times")));
  962. });
  963. if (index) {
  964. Layer.close(index);
  965. }
  966. }
  967. }
  968. });
  969. //公共代码
  970. //配置Toastr的参数
  971. Toastr.options = Fast.config.toastr;
  972. }
  973. };
  974. //将Layer暴露到全局中去
  975. window.Layer = Layer;
  976. //将Toastr暴露到全局中去
  977. window.Toastr = Toastr;
  978. //将语言方法暴露到全局中去
  979. window.__ = Fast.lang;
  980. //将Fast渲染至全局
  981. window.Fast = Fast;
  982. //默认初始化执行的代码
  983. Fast.init();
  984. return Fast;
  985. });
  986. /*!art-template - Template Engine | http://aui.github.com/artTemplate/*/
  987. !function(){function a(a){return a.replace(t,"").replace(u,",").replace(v,"").replace(w,"").replace(x,"").split(y)}function b(a){return"'"+a.replace(/('|\\)/g,"\\$1").replace(/\r/g,"\\r").replace(/\n/g,"\\n")+"'"}function c(c,d){function e(a){return m+=a.split(/\n/).length-1,k&&(a=a.replace(/\s+/g," ").replace(/<!--[\w\W]*?-->/g,"")),a&&(a=s[1]+b(a)+s[2]+"\n"),a}function f(b){var c=m;if(j?b=j(b,d):g&&(b=b.replace(/\n/g,function(){return m++,"$line="+m+";"})),0===b.indexOf("=")){var e=l&&!/^=[=#]/.test(b);if(b=b.replace(/^=[=#]?|[\s;]*$/g,""),e){var f=b.replace(/\s*\([^\)]+\)/,"");n[f]||/^(include|print)$/.test(f)||(b="$escape("+b+")")}else b="$string("+b+")";b=s[1]+b+s[2]}return g&&(b="$line="+c+";"+b),r(a(b),function(a){if(a&&!p[a]){var b;b="print"===a?u:"include"===a?v:n[a]?"$utils."+a:o[a]?"$helpers."+a:"$data."+a,w+=a+"="+b+",",p[a]=!0}}),b+"\n"}var g=d.debug,h=d.openTag,i=d.closeTag,j=d.parser,k=d.compress,l=d.escape,m=1,p={$data:1,$filename:1,$utils:1,$helpers:1,$out:1,$line:1},q="".trim,s=q?["$out='';","$out+=",";","$out"]:["$out=[];","$out.push(",");","$out.join('')"],t=q?"$out+=text;return $out;":"$out.push(text);",u="function(){var text=''.concat.apply('',arguments);"+t+"}",v="function(filename,data){data=data||$data;var text=$utils.$include(filename,data,$filename);"+t+"}",w="'use strict';var $utils=this,$helpers=$utils.$helpers,"+(g?"$line=0,":""),x=s[0],y="return new String("+s[3]+");";r(c.split(h),function(a){a=a.split(i);var b=a[0],c=a[1];1===a.length?x+=e(b):(x+=f(b),c&&(x+=e(c)))});var z=w+x+y;g&&(z="try{"+z+"}catch(e){throw {filename:$filename,name:'Render Error',message:e.message,line:$line,source:"+b(c)+".split(/\\n/)[$line-1].replace(/^\\s+/,'')};}");try{var A=new Function("$data","$filename",z);return A.prototype=n,A}catch(a){throw a.temp="function anonymous($data,$filename) {"+z+"}",a}}var d=function(a,b){return"string"==typeof b?q(b,{filename:a}):g(a,b)};d.version="3.0.0",d.config=function(a,b){e[a]=b};var e=d.defaults={openTag:"<%",closeTag:"%>",escape:!0,cache:!0,compress:!1,parser:null},f=d.cache={};d.render=function(a,b){return q(a)(b)};var g=d.renderFile=function(a,b){var c=d.get(a)||p({filename:a,name:"Render Error",message:"Template not found"});return b?c(b):c};d.get=function(a){var b;if(f[a])b=f[a];else if("object"==typeof document){var c=document.getElementById(a);if(c){var d=(c.value||c.innerHTML).replace(/^\s*|\s*$/g,"");b=q(d,{filename:a})}}return b};var h=function(a,b){return"string"!=typeof a&&(b=typeof a,"number"===b?a+="":a="function"===b?h(a.call(a)):""),a},i={"<":"&#60;",">":"&#62;",'"':"&#34;","'":"&#39;","&":"&#38;"},j=function(a){return i[a]},k=function(a){return h(a).replace(/&(?![\w#]+;)|[<>"']/g,j)},l=Array.isArray||function(a){return"[object Array]"==={}.toString.call(a)},m=function(a,b){var c,d;if(l(a))for(c=0,d=a.length;c<d;c++)b.call(a,a[c],c,a);else for(c in a)b.call(a,a[c],c)},n=d.utils={$helpers:{},$include:g,$string:h,$escape:k,$each:m};d.helper=function(a,b){o[a]=b};var o=d.helpers=n.$helpers;d.onerror=function(a){var b="Template Error\n\n";for(var c in a)b+="<"+c+">\n"+a[c]+"\n\n";"object"==typeof console&&console.error(b)};var p=function(a){return d.onerror(a),function(){return"{Template Error}"}},q=d.compile=function(a,b){function d(c){try{return new i(c,h)+""}catch(d){return b.debug?p(d)():(b.debug=!0,q(a,b)(c))}}b=b||{};for(var g in e)void 0===b[g]&&(b[g]=e[g]);var h=b.filename;try{var i=c(a,b)}catch(a){return a.filename=h||"anonymous",a.name="Syntax Error",p(a)}return d.prototype=i.prototype,d.toString=function(){return i.toString()},h&&b.cache&&(f[h]=d),d},r=n.$each,s="break,case,catch,continue,debugger,default,delete,do,else,false,finally,for,function,if,in,instanceof,new,null,return,switch,this,throw,true,try,typeof,var,void,while,with,abstract,boolean,byte,char,class,const,double,enum,export,extends,final,float,goto,implements,import,int,interface,long,native,package,private,protected,public,short,static,super,synchronized,throws,transient,volatile,arguments,let,yield,undefined",t=/\/\*[\w\W]*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|"(?:[^"\\]|\\[\w\W])*"|'(?:[^'\\]|\\[\w\W])*'|\s*\.\s*[$\w\.]+/g,u=/[^\w$]+/g,v=new RegExp(["\\b"+s.replace(/,/g,"\\b|\\b")+"\\b"].join("|"),"g"),w=/^\d[^,]*|,\d[^,]*/g,x=/^,+|,+$/g,y=/^$|,+/;"function"==typeof define?define('template',[],function(){return d}):"undefined"!=typeof exports?module.exports=d:this.template=d}();
  988. //! moment.js
  989. //! version : 2.30.1
  990. //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
  991. //! license : MIT
  992. //! momentjs.com
  993. ;(function (global, factory) {
  994. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  995. typeof define === 'function' && define.amd ? define('moment/moment',factory) :
  996. global.moment = factory()
  997. }(this, (function () { 'use strict';
  998. var hookCallback;
  999. function hooks() {
  1000. return hookCallback.apply(null, arguments);
  1001. }
  1002. // This is done to register the method called with moment()
  1003. // without creating circular dependencies.
  1004. function setHookCallback(callback) {
  1005. hookCallback = callback;
  1006. }
  1007. function isArray(input) {
  1008. return (
  1009. input instanceof Array ||
  1010. Object.prototype.toString.call(input) === '[object Array]'
  1011. );
  1012. }
  1013. function isObject(input) {
  1014. // IE8 will treat undefined and null as object if it wasn't for
  1015. // input != null
  1016. return (
  1017. input != null &&
  1018. Object.prototype.toString.call(input) === '[object Object]'
  1019. );
  1020. }
  1021. function hasOwnProp(a, b) {
  1022. return Object.prototype.hasOwnProperty.call(a, b);
  1023. }
  1024. function isObjectEmpty(obj) {
  1025. if (Object.getOwnPropertyNames) {
  1026. return Object.getOwnPropertyNames(obj).length === 0;
  1027. } else {
  1028. var k;
  1029. for (k in obj) {
  1030. if (hasOwnProp(obj, k)) {
  1031. return false;
  1032. }
  1033. }
  1034. return true;
  1035. }
  1036. }
  1037. function isUndefined(input) {
  1038. return input === void 0;
  1039. }
  1040. function isNumber(input) {
  1041. return (
  1042. typeof input === 'number' ||
  1043. Object.prototype.toString.call(input) === '[object Number]'
  1044. );
  1045. }
  1046. function isDate(input) {
  1047. return (
  1048. input instanceof Date ||
  1049. Object.prototype.toString.call(input) === '[object Date]'
  1050. );
  1051. }
  1052. function map(arr, fn) {
  1053. var res = [],
  1054. i,
  1055. arrLen = arr.length;
  1056. for (i = 0; i < arrLen; ++i) {
  1057. res.push(fn(arr[i], i));
  1058. }
  1059. return res;
  1060. }
  1061. function extend(a, b) {
  1062. for (var i in b) {
  1063. if (hasOwnProp(b, i)) {
  1064. a[i] = b[i];
  1065. }
  1066. }
  1067. if (hasOwnProp(b, 'toString')) {
  1068. a.toString = b.toString;
  1069. }
  1070. if (hasOwnProp(b, 'valueOf')) {
  1071. a.valueOf = b.valueOf;
  1072. }
  1073. return a;
  1074. }
  1075. function createUTC(input, format, locale, strict) {
  1076. return createLocalOrUTC(input, format, locale, strict, true).utc();
  1077. }
  1078. function defaultParsingFlags() {
  1079. // We need to deep clone this object.
  1080. return {
  1081. empty: false,
  1082. unusedTokens: [],
  1083. unusedInput: [],
  1084. overflow: -2,
  1085. charsLeftOver: 0,
  1086. nullInput: false,
  1087. invalidEra: null,
  1088. invalidMonth: null,
  1089. invalidFormat: false,
  1090. userInvalidated: false,
  1091. iso: false,
  1092. parsedDateParts: [],
  1093. era: null,
  1094. meridiem: null,
  1095. rfc2822: false,
  1096. weekdayMismatch: false,
  1097. };
  1098. }
  1099. function getParsingFlags(m) {
  1100. if (m._pf == null) {
  1101. m._pf = defaultParsingFlags();
  1102. }
  1103. return m._pf;
  1104. }
  1105. var some;
  1106. if (Array.prototype.some) {
  1107. some = Array.prototype.some;
  1108. } else {
  1109. some = function (fun) {
  1110. var t = Object(this),
  1111. len = t.length >>> 0,
  1112. i;
  1113. for (i = 0; i < len; i++) {
  1114. if (i in t && fun.call(this, t[i], i, t)) {
  1115. return true;
  1116. }
  1117. }
  1118. return false;
  1119. };
  1120. }
  1121. function isValid(m) {
  1122. var flags = null,
  1123. parsedParts = false,
  1124. isNowValid = m._d && !isNaN(m._d.getTime());
  1125. if (isNowValid) {
  1126. flags = getParsingFlags(m);
  1127. parsedParts = some.call(flags.parsedDateParts, function (i) {
  1128. return i != null;
  1129. });
  1130. isNowValid =
  1131. flags.overflow < 0 &&
  1132. !flags.empty &&
  1133. !flags.invalidEra &&
  1134. !flags.invalidMonth &&
  1135. !flags.invalidWeekday &&
  1136. !flags.weekdayMismatch &&
  1137. !flags.nullInput &&
  1138. !flags.invalidFormat &&
  1139. !flags.userInvalidated &&
  1140. (!flags.meridiem || (flags.meridiem && parsedParts));
  1141. if (m._strict) {
  1142. isNowValid =
  1143. isNowValid &&
  1144. flags.charsLeftOver === 0 &&
  1145. flags.unusedTokens.length === 0 &&
  1146. flags.bigHour === undefined;
  1147. }
  1148. }
  1149. if (Object.isFrozen == null || !Object.isFrozen(m)) {
  1150. m._isValid = isNowValid;
  1151. } else {
  1152. return isNowValid;
  1153. }
  1154. return m._isValid;
  1155. }
  1156. function createInvalid(flags) {
  1157. var m = createUTC(NaN);
  1158. if (flags != null) {
  1159. extend(getParsingFlags(m), flags);
  1160. } else {
  1161. getParsingFlags(m).userInvalidated = true;
  1162. }
  1163. return m;
  1164. }
  1165. // Plugins that add properties should also add the key here (null value),
  1166. // so we can properly clone ourselves.
  1167. var momentProperties = (hooks.momentProperties = []),
  1168. updateInProgress = false;
  1169. function copyConfig(to, from) {
  1170. var i,
  1171. prop,
  1172. val,
  1173. momentPropertiesLen = momentProperties.length;
  1174. if (!isUndefined(from._isAMomentObject)) {
  1175. to._isAMomentObject = from._isAMomentObject;
  1176. }
  1177. if (!isUndefined(from._i)) {
  1178. to._i = from._i;
  1179. }
  1180. if (!isUndefined(from._f)) {
  1181. to._f = from._f;
  1182. }
  1183. if (!isUndefined(from._l)) {
  1184. to._l = from._l;
  1185. }
  1186. if (!isUndefined(from._strict)) {
  1187. to._strict = from._strict;
  1188. }
  1189. if (!isUndefined(from._tzm)) {
  1190. to._tzm = from._tzm;
  1191. }
  1192. if (!isUndefined(from._isUTC)) {
  1193. to._isUTC = from._isUTC;
  1194. }
  1195. if (!isUndefined(from._offset)) {
  1196. to._offset = from._offset;
  1197. }
  1198. if (!isUndefined(from._pf)) {
  1199. to._pf = getParsingFlags(from);
  1200. }
  1201. if (!isUndefined(from._locale)) {
  1202. to._locale = from._locale;
  1203. }
  1204. if (momentPropertiesLen > 0) {
  1205. for (i = 0; i < momentPropertiesLen; i++) {
  1206. prop = momentProperties[i];
  1207. val = from[prop];
  1208. if (!isUndefined(val)) {
  1209. to[prop] = val;
  1210. }
  1211. }
  1212. }
  1213. return to;
  1214. }
  1215. // Moment prototype object
  1216. function Moment(config) {
  1217. copyConfig(this, config);
  1218. this._d = new Date(config._d != null ? config._d.getTime() : NaN);
  1219. if (!this.isValid()) {
  1220. this._d = new Date(NaN);
  1221. }
  1222. // Prevent infinite loop in case updateOffset creates new moment
  1223. // objects.
  1224. if (updateInProgress === false) {
  1225. updateInProgress = true;
  1226. hooks.updateOffset(this);
  1227. updateInProgress = false;
  1228. }
  1229. }
  1230. function isMoment(obj) {
  1231. return (
  1232. obj instanceof Moment || (obj != null && obj._isAMomentObject != null)
  1233. );
  1234. }
  1235. function warn(msg) {
  1236. if (
  1237. hooks.suppressDeprecationWarnings === false &&
  1238. typeof console !== 'undefined' &&
  1239. console.warn
  1240. ) {
  1241. console.warn('Deprecation warning: ' + msg);
  1242. }
  1243. }
  1244. function deprecate(msg, fn) {
  1245. var firstTime = true;
  1246. return extend(function () {
  1247. if (hooks.deprecationHandler != null) {
  1248. hooks.deprecationHandler(null, msg);
  1249. }
  1250. if (firstTime) {
  1251. var args = [],
  1252. arg,
  1253. i,
  1254. key,
  1255. argLen = arguments.length;
  1256. for (i = 0; i < argLen; i++) {
  1257. arg = '';
  1258. if (typeof arguments[i] === 'object') {
  1259. arg += '\n[' + i + '] ';
  1260. for (key in arguments[0]) {
  1261. if (hasOwnProp(arguments[0], key)) {
  1262. arg += key + ': ' + arguments[0][key] + ', ';
  1263. }
  1264. }
  1265. arg = arg.slice(0, -2); // Remove trailing comma and space
  1266. } else {
  1267. arg = arguments[i];
  1268. }
  1269. args.push(arg);
  1270. }
  1271. warn(
  1272. msg +
  1273. '\nArguments: ' +
  1274. Array.prototype.slice.call(args).join('') +
  1275. '\n' +
  1276. new Error().stack
  1277. );
  1278. firstTime = false;
  1279. }
  1280. return fn.apply(this, arguments);
  1281. }, fn);
  1282. }
  1283. var deprecations = {};
  1284. function deprecateSimple(name, msg) {
  1285. if (hooks.deprecationHandler != null) {
  1286. hooks.deprecationHandler(name, msg);
  1287. }
  1288. if (!deprecations[name]) {
  1289. warn(msg);
  1290. deprecations[name] = true;
  1291. }
  1292. }
  1293. hooks.suppressDeprecationWarnings = false;
  1294. hooks.deprecationHandler = null;
  1295. function isFunction(input) {
  1296. return (
  1297. (typeof Function !== 'undefined' && input instanceof Function) ||
  1298. Object.prototype.toString.call(input) === '[object Function]'
  1299. );
  1300. }
  1301. function set(config) {
  1302. var prop, i;
  1303. for (i in config) {
  1304. if (hasOwnProp(config, i)) {
  1305. prop = config[i];
  1306. if (isFunction(prop)) {
  1307. this[i] = prop;
  1308. } else {
  1309. this['_' + i] = prop;
  1310. }
  1311. }
  1312. }
  1313. this._config = config;
  1314. // Lenient ordinal parsing accepts just a number in addition to
  1315. // number + (possibly) stuff coming from _dayOfMonthOrdinalParse.
  1316. // TODO: Remove "ordinalParse" fallback in next major release.
  1317. this._dayOfMonthOrdinalParseLenient = new RegExp(
  1318. (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
  1319. '|' +
  1320. /\d{1,2}/.source
  1321. );
  1322. }
  1323. function mergeConfigs(parentConfig, childConfig) {
  1324. var res = extend({}, parentConfig),
  1325. prop;
  1326. for (prop in childConfig) {
  1327. if (hasOwnProp(childConfig, prop)) {
  1328. if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
  1329. res[prop] = {};
  1330. extend(res[prop], parentConfig[prop]);
  1331. extend(res[prop], childConfig[prop]);
  1332. } else if (childConfig[prop] != null) {
  1333. res[prop] = childConfig[prop];
  1334. } else {
  1335. delete res[prop];
  1336. }
  1337. }
  1338. }
  1339. for (prop in parentConfig) {
  1340. if (
  1341. hasOwnProp(parentConfig, prop) &&
  1342. !hasOwnProp(childConfig, prop) &&
  1343. isObject(parentConfig[prop])
  1344. ) {
  1345. // make sure changes to properties don't modify parent config
  1346. res[prop] = extend({}, res[prop]);
  1347. }
  1348. }
  1349. return res;
  1350. }
  1351. function Locale(config) {
  1352. if (config != null) {
  1353. this.set(config);
  1354. }
  1355. }
  1356. var keys;
  1357. if (Object.keys) {
  1358. keys = Object.keys;
  1359. } else {
  1360. keys = function (obj) {
  1361. var i,
  1362. res = [];
  1363. for (i in obj) {
  1364. if (hasOwnProp(obj, i)) {
  1365. res.push(i);
  1366. }
  1367. }
  1368. return res;
  1369. };
  1370. }
  1371. var defaultCalendar = {
  1372. sameDay: '[Today at] LT',
  1373. nextDay: '[Tomorrow at] LT',
  1374. nextWeek: 'dddd [at] LT',
  1375. lastDay: '[Yesterday at] LT',
  1376. lastWeek: '[Last] dddd [at] LT',
  1377. sameElse: 'L',
  1378. };
  1379. function calendar(key, mom, now) {
  1380. var output = this._calendar[key] || this._calendar['sameElse'];
  1381. return isFunction(output) ? output.call(mom, now) : output;
  1382. }
  1383. function zeroFill(number, targetLength, forceSign) {
  1384. var absNumber = '' + Math.abs(number),
  1385. zerosToFill = targetLength - absNumber.length,
  1386. sign = number >= 0;
  1387. return (
  1388. (sign ? (forceSign ? '+' : '') : '-') +
  1389. Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) +
  1390. absNumber
  1391. );
  1392. }
  1393. var formattingTokens =
  1394. /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,
  1395. localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,
  1396. formatFunctions = {},
  1397. formatTokenFunctions = {};
  1398. // token: 'M'
  1399. // padded: ['MM', 2]
  1400. // ordinal: 'Mo'
  1401. // callback: function () { this.month() + 1 }
  1402. function addFormatToken(token, padded, ordinal, callback) {
  1403. var func = callback;
  1404. if (typeof callback === 'string') {
  1405. func = function () {
  1406. return this[callback]();
  1407. };
  1408. }
  1409. if (token) {
  1410. formatTokenFunctions[token] = func;
  1411. }
  1412. if (padded) {
  1413. formatTokenFunctions[padded[0]] = function () {
  1414. return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
  1415. };
  1416. }
  1417. if (ordinal) {
  1418. formatTokenFunctions[ordinal] = function () {
  1419. return this.localeData().ordinal(
  1420. func.apply(this, arguments),
  1421. token
  1422. );
  1423. };
  1424. }
  1425. }
  1426. function removeFormattingTokens(input) {
  1427. if (input.match(/\[[\s\S]/)) {
  1428. return input.replace(/^\[|\]$/g, '');
  1429. }
  1430. return input.replace(/\\/g, '');
  1431. }
  1432. function makeFormatFunction(format) {
  1433. var array = format.match(formattingTokens),
  1434. i,
  1435. length;
  1436. for (i = 0, length = array.length; i < length; i++) {
  1437. if (formatTokenFunctions[array[i]]) {
  1438. array[i] = formatTokenFunctions[array[i]];
  1439. } else {
  1440. array[i] = removeFormattingTokens(array[i]);
  1441. }
  1442. }
  1443. return function (mom) {
  1444. var output = '',
  1445. i;
  1446. for (i = 0; i < length; i++) {
  1447. output += isFunction(array[i])
  1448. ? array[i].call(mom, format)
  1449. : array[i];
  1450. }
  1451. return output;
  1452. };
  1453. }
  1454. // format date using native date object
  1455. function formatMoment(m, format) {
  1456. if (!m.isValid()) {
  1457. return m.localeData().invalidDate();
  1458. }
  1459. format = expandFormat(format, m.localeData());
  1460. formatFunctions[format] =
  1461. formatFunctions[format] || makeFormatFunction(format);
  1462. return formatFunctions[format](m);
  1463. }
  1464. function expandFormat(format, locale) {
  1465. var i = 5;
  1466. function replaceLongDateFormatTokens(input) {
  1467. return locale.longDateFormat(input) || input;
  1468. }
  1469. localFormattingTokens.lastIndex = 0;
  1470. while (i >= 0 && localFormattingTokens.test(format)) {
  1471. format = format.replace(
  1472. localFormattingTokens,
  1473. replaceLongDateFormatTokens
  1474. );
  1475. localFormattingTokens.lastIndex = 0;
  1476. i -= 1;
  1477. }
  1478. return format;
  1479. }
  1480. var defaultLongDateFormat = {
  1481. LTS: 'h:mm:ss A',
  1482. LT: 'h:mm A',
  1483. L: 'MM/DD/YYYY',
  1484. LL: 'MMMM D, YYYY',
  1485. LLL: 'MMMM D, YYYY h:mm A',
  1486. LLLL: 'dddd, MMMM D, YYYY h:mm A',
  1487. };
  1488. function longDateFormat(key) {
  1489. var format = this._longDateFormat[key],
  1490. formatUpper = this._longDateFormat[key.toUpperCase()];
  1491. if (format || !formatUpper) {
  1492. return format;
  1493. }
  1494. this._longDateFormat[key] = formatUpper
  1495. .match(formattingTokens)
  1496. .map(function (tok) {
  1497. if (
  1498. tok === 'MMMM' ||
  1499. tok === 'MM' ||
  1500. tok === 'DD' ||
  1501. tok === 'dddd'
  1502. ) {
  1503. return tok.slice(1);
  1504. }
  1505. return tok;
  1506. })
  1507. .join('');
  1508. return this._longDateFormat[key];
  1509. }
  1510. var defaultInvalidDate = 'Invalid date';
  1511. function invalidDate() {
  1512. return this._invalidDate;
  1513. }
  1514. var defaultOrdinal = '%d',
  1515. defaultDayOfMonthOrdinalParse = /\d{1,2}/;
  1516. function ordinal(number) {
  1517. return this._ordinal.replace('%d', number);
  1518. }
  1519. var defaultRelativeTime = {
  1520. future: 'in %s',
  1521. past: '%s ago',
  1522. s: 'a few seconds',
  1523. ss: '%d seconds',
  1524. m: 'a minute',
  1525. mm: '%d minutes',
  1526. h: 'an hour',
  1527. hh: '%d hours',
  1528. d: 'a day',
  1529. dd: '%d days',
  1530. w: 'a week',
  1531. ww: '%d weeks',
  1532. M: 'a month',
  1533. MM: '%d months',
  1534. y: 'a year',
  1535. yy: '%d years',
  1536. };
  1537. function relativeTime(number, withoutSuffix, string, isFuture) {
  1538. var output = this._relativeTime[string];
  1539. return isFunction(output)
  1540. ? output(number, withoutSuffix, string, isFuture)
  1541. : output.replace(/%d/i, number);
  1542. }
  1543. function pastFuture(diff, output) {
  1544. var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
  1545. return isFunction(format) ? format(output) : format.replace(/%s/i, output);
  1546. }
  1547. var aliases = {
  1548. D: 'date',
  1549. dates: 'date',
  1550. date: 'date',
  1551. d: 'day',
  1552. days: 'day',
  1553. day: 'day',
  1554. e: 'weekday',
  1555. weekdays: 'weekday',
  1556. weekday: 'weekday',
  1557. E: 'isoWeekday',
  1558. isoweekdays: 'isoWeekday',
  1559. isoweekday: 'isoWeekday',
  1560. DDD: 'dayOfYear',
  1561. dayofyears: 'dayOfYear',
  1562. dayofyear: 'dayOfYear',
  1563. h: 'hour',
  1564. hours: 'hour',
  1565. hour: 'hour',
  1566. ms: 'millisecond',
  1567. milliseconds: 'millisecond',
  1568. millisecond: 'millisecond',
  1569. m: 'minute',
  1570. minutes: 'minute',
  1571. minute: 'minute',
  1572. M: 'month',
  1573. months: 'month',
  1574. month: 'month',
  1575. Q: 'quarter',
  1576. quarters: 'quarter',
  1577. quarter: 'quarter',
  1578. s: 'second',
  1579. seconds: 'second',
  1580. second: 'second',
  1581. gg: 'weekYear',
  1582. weekyears: 'weekYear',
  1583. weekyear: 'weekYear',
  1584. GG: 'isoWeekYear',
  1585. isoweekyears: 'isoWeekYear',
  1586. isoweekyear: 'isoWeekYear',
  1587. w: 'week',
  1588. weeks: 'week',
  1589. week: 'week',
  1590. W: 'isoWeek',
  1591. isoweeks: 'isoWeek',
  1592. isoweek: 'isoWeek',
  1593. y: 'year',
  1594. years: 'year',
  1595. year: 'year',
  1596. };
  1597. function normalizeUnits(units) {
  1598. return typeof units === 'string'
  1599. ? aliases[units] || aliases[units.toLowerCase()]
  1600. : undefined;
  1601. }
  1602. function normalizeObjectUnits(inputObject) {
  1603. var normalizedInput = {},
  1604. normalizedProp,
  1605. prop;
  1606. for (prop in inputObject) {
  1607. if (hasOwnProp(inputObject, prop)) {
  1608. normalizedProp = normalizeUnits(prop);
  1609. if (normalizedProp) {
  1610. normalizedInput[normalizedProp] = inputObject[prop];
  1611. }
  1612. }
  1613. }
  1614. return normalizedInput;
  1615. }
  1616. var priorities = {
  1617. date: 9,
  1618. day: 11,
  1619. weekday: 11,
  1620. isoWeekday: 11,
  1621. dayOfYear: 4,
  1622. hour: 13,
  1623. millisecond: 16,
  1624. minute: 14,
  1625. month: 8,
  1626. quarter: 7,
  1627. second: 15,
  1628. weekYear: 1,
  1629. isoWeekYear: 1,
  1630. week: 5,
  1631. isoWeek: 5,
  1632. year: 1,
  1633. };
  1634. function getPrioritizedUnits(unitsObj) {
  1635. var units = [],
  1636. u;
  1637. for (u in unitsObj) {
  1638. if (hasOwnProp(unitsObj, u)) {
  1639. units.push({ unit: u, priority: priorities[u] });
  1640. }
  1641. }
  1642. units.sort(function (a, b) {
  1643. return a.priority - b.priority;
  1644. });
  1645. return units;
  1646. }
  1647. var match1 = /\d/, // 0 - 9
  1648. match2 = /\d\d/, // 00 - 99
  1649. match3 = /\d{3}/, // 000 - 999
  1650. match4 = /\d{4}/, // 0000 - 9999
  1651. match6 = /[+-]?\d{6}/, // -999999 - 999999
  1652. match1to2 = /\d\d?/, // 0 - 99
  1653. match3to4 = /\d\d\d\d?/, // 999 - 9999
  1654. match5to6 = /\d\d\d\d\d\d?/, // 99999 - 999999
  1655. match1to3 = /\d{1,3}/, // 0 - 999
  1656. match1to4 = /\d{1,4}/, // 0 - 9999
  1657. match1to6 = /[+-]?\d{1,6}/, // -999999 - 999999
  1658. matchUnsigned = /\d+/, // 0 - inf
  1659. matchSigned = /[+-]?\d+/, // -inf - inf
  1660. matchOffset = /Z|[+-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z
  1661. matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi, // +00 -00 +00:00 -00:00 +0000 -0000 or Z
  1662. matchTimestamp = /[+-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123
  1663. // any word (or two) characters or numbers including two/three word month in arabic.
  1664. // includes scottish gaelic two word and hyphenated months
  1665. matchWord =
  1666. /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i,
  1667. match1to2NoLeadingZero = /^[1-9]\d?/, // 1-99
  1668. match1to2HasZero = /^([1-9]\d|\d)/, // 0-99
  1669. regexes;
  1670. regexes = {};
  1671. function addRegexToken(token, regex, strictRegex) {
  1672. regexes[token] = isFunction(regex)
  1673. ? regex
  1674. : function (isStrict, localeData) {
  1675. return isStrict && strictRegex ? strictRegex : regex;
  1676. };
  1677. }
  1678. function getParseRegexForToken(token, config) {
  1679. if (!hasOwnProp(regexes, token)) {
  1680. return new RegExp(unescapeFormat(token));
  1681. }
  1682. return regexes[token](config._strict, config._locale);
  1683. }
  1684. // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
  1685. function unescapeFormat(s) {
  1686. return regexEscape(
  1687. s
  1688. .replace('\\', '')
  1689. .replace(
  1690. /\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,
  1691. function (matched, p1, p2, p3, p4) {
  1692. return p1 || p2 || p3 || p4;
  1693. }
  1694. )
  1695. );
  1696. }
  1697. function regexEscape(s) {
  1698. return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
  1699. }
  1700. function absFloor(number) {
  1701. if (number < 0) {
  1702. // -0 -> 0
  1703. return Math.ceil(number) || 0;
  1704. } else {
  1705. return Math.floor(number);
  1706. }
  1707. }
  1708. function toInt(argumentForCoercion) {
  1709. var coercedNumber = +argumentForCoercion,
  1710. value = 0;
  1711. if (coercedNumber !== 0 && isFinite(coercedNumber)) {
  1712. value = absFloor(coercedNumber);
  1713. }
  1714. return value;
  1715. }
  1716. var tokens = {};
  1717. function addParseToken(token, callback) {
  1718. var i,
  1719. func = callback,
  1720. tokenLen;
  1721. if (typeof token === 'string') {
  1722. token = [token];
  1723. }
  1724. if (isNumber(callback)) {
  1725. func = function (input, array) {
  1726. array[callback] = toInt(input);
  1727. };
  1728. }
  1729. tokenLen = token.length;
  1730. for (i = 0; i < tokenLen; i++) {
  1731. tokens[token[i]] = func;
  1732. }
  1733. }
  1734. function addWeekParseToken(token, callback) {
  1735. addParseToken(token, function (input, array, config, token) {
  1736. config._w = config._w || {};
  1737. callback(input, config._w, config, token);
  1738. });
  1739. }
  1740. function addTimeToArrayFromToken(token, input, config) {
  1741. if (input != null && hasOwnProp(tokens, token)) {
  1742. tokens[token](input, config._a, config, token);
  1743. }
  1744. }
  1745. function isLeapYear(year) {
  1746. return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
  1747. }
  1748. var YEAR = 0,
  1749. MONTH = 1,
  1750. DATE = 2,
  1751. HOUR = 3,
  1752. MINUTE = 4,
  1753. SECOND = 5,
  1754. MILLISECOND = 6,
  1755. WEEK = 7,
  1756. WEEKDAY = 8;
  1757. // FORMATTING
  1758. addFormatToken('Y', 0, 0, function () {
  1759. var y = this.year();
  1760. return y <= 9999 ? zeroFill(y, 4) : '+' + y;
  1761. });
  1762. addFormatToken(0, ['YY', 2], 0, function () {
  1763. return this.year() % 100;
  1764. });
  1765. addFormatToken(0, ['YYYY', 4], 0, 'year');
  1766. addFormatToken(0, ['YYYYY', 5], 0, 'year');
  1767. addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
  1768. // PARSING
  1769. addRegexToken('Y', matchSigned);
  1770. addRegexToken('YY', match1to2, match2);
  1771. addRegexToken('YYYY', match1to4, match4);
  1772. addRegexToken('YYYYY', match1to6, match6);
  1773. addRegexToken('YYYYYY', match1to6, match6);
  1774. addParseToken(['YYYYY', 'YYYYYY'], YEAR);
  1775. addParseToken('YYYY', function (input, array) {
  1776. array[YEAR] =
  1777. input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
  1778. });
  1779. addParseToken('YY', function (input, array) {
  1780. array[YEAR] = hooks.parseTwoDigitYear(input);
  1781. });
  1782. addParseToken('Y', function (input, array) {
  1783. array[YEAR] = parseInt(input, 10);
  1784. });
  1785. // HELPERS
  1786. function daysInYear(year) {
  1787. return isLeapYear(year) ? 366 : 365;
  1788. }
  1789. // HOOKS
  1790. hooks.parseTwoDigitYear = function (input) {
  1791. return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
  1792. };
  1793. // MOMENTS
  1794. var getSetYear = makeGetSet('FullYear', true);
  1795. function getIsLeapYear() {
  1796. return isLeapYear(this.year());
  1797. }
  1798. function makeGetSet(unit, keepTime) {
  1799. return function (value) {
  1800. if (value != null) {
  1801. set$1(this, unit, value);
  1802. hooks.updateOffset(this, keepTime);
  1803. return this;
  1804. } else {
  1805. return get(this, unit);
  1806. }
  1807. };
  1808. }
  1809. function get(mom, unit) {
  1810. if (!mom.isValid()) {
  1811. return NaN;
  1812. }
  1813. var d = mom._d,
  1814. isUTC = mom._isUTC;
  1815. switch (unit) {
  1816. case 'Milliseconds':
  1817. return isUTC ? d.getUTCMilliseconds() : d.getMilliseconds();
  1818. case 'Seconds':
  1819. return isUTC ? d.getUTCSeconds() : d.getSeconds();
  1820. case 'Minutes':
  1821. return isUTC ? d.getUTCMinutes() : d.getMinutes();
  1822. case 'Hours':
  1823. return isUTC ? d.getUTCHours() : d.getHours();
  1824. case 'Date':
  1825. return isUTC ? d.getUTCDate() : d.getDate();
  1826. case 'Day':
  1827. return isUTC ? d.getUTCDay() : d.getDay();
  1828. case 'Month':
  1829. return isUTC ? d.getUTCMonth() : d.getMonth();
  1830. case 'FullYear':
  1831. return isUTC ? d.getUTCFullYear() : d.getFullYear();
  1832. default:
  1833. return NaN; // Just in case
  1834. }
  1835. }
  1836. function set$1(mom, unit, value) {
  1837. var d, isUTC, year, month, date;
  1838. if (!mom.isValid() || isNaN(value)) {
  1839. return;
  1840. }
  1841. d = mom._d;
  1842. isUTC = mom._isUTC;
  1843. switch (unit) {
  1844. case 'Milliseconds':
  1845. return void (isUTC
  1846. ? d.setUTCMilliseconds(value)
  1847. : d.setMilliseconds(value));
  1848. case 'Seconds':
  1849. return void (isUTC ? d.setUTCSeconds(value) : d.setSeconds(value));
  1850. case 'Minutes':
  1851. return void (isUTC ? d.setUTCMinutes(value) : d.setMinutes(value));
  1852. case 'Hours':
  1853. return void (isUTC ? d.setUTCHours(value) : d.setHours(value));
  1854. case 'Date':
  1855. return void (isUTC ? d.setUTCDate(value) : d.setDate(value));
  1856. // case 'Day': // Not real
  1857. // return void (isUTC ? d.setUTCDay(value) : d.setDay(value));
  1858. // case 'Month': // Not used because we need to pass two variables
  1859. // return void (isUTC ? d.setUTCMonth(value) : d.setMonth(value));
  1860. case 'FullYear':
  1861. break; // See below ...
  1862. default:
  1863. return; // Just in case
  1864. }
  1865. year = value;
  1866. month = mom.month();
  1867. date = mom.date();
  1868. date = date === 29 && month === 1 && !isLeapYear(year) ? 28 : date;
  1869. void (isUTC
  1870. ? d.setUTCFullYear(year, month, date)
  1871. : d.setFullYear(year, month, date));
  1872. }
  1873. // MOMENTS
  1874. function stringGet(units) {
  1875. units = normalizeUnits(units);
  1876. if (isFunction(this[units])) {
  1877. return this[units]();
  1878. }
  1879. return this;
  1880. }
  1881. function stringSet(units, value) {
  1882. if (typeof units === 'object') {
  1883. units = normalizeObjectUnits(units);
  1884. var prioritized = getPrioritizedUnits(units),
  1885. i,
  1886. prioritizedLen = prioritized.length;
  1887. for (i = 0; i < prioritizedLen; i++) {
  1888. this[prioritized[i].unit](units[prioritized[i].unit]);
  1889. }
  1890. } else {
  1891. units = normalizeUnits(units);
  1892. if (isFunction(this[units])) {
  1893. return this[units](value);
  1894. }
  1895. }
  1896. return this;
  1897. }
  1898. function mod(n, x) {
  1899. return ((n % x) + x) % x;
  1900. }
  1901. var indexOf;
  1902. if (Array.prototype.indexOf) {
  1903. indexOf = Array.prototype.indexOf;
  1904. } else {
  1905. indexOf = function (o) {
  1906. // I know
  1907. var i;
  1908. for (i = 0; i < this.length; ++i) {
  1909. if (this[i] === o) {
  1910. return i;
  1911. }
  1912. }
  1913. return -1;
  1914. };
  1915. }
  1916. function daysInMonth(year, month) {
  1917. if (isNaN(year) || isNaN(month)) {
  1918. return NaN;
  1919. }
  1920. var modMonth = mod(month, 12);
  1921. year += (month - modMonth) / 12;
  1922. return modMonth === 1
  1923. ? isLeapYear(year)
  1924. ? 29
  1925. : 28
  1926. : 31 - ((modMonth % 7) % 2);
  1927. }
  1928. // FORMATTING
  1929. addFormatToken('M', ['MM', 2], 'Mo', function () {
  1930. return this.month() + 1;
  1931. });
  1932. addFormatToken('MMM', 0, 0, function (format) {
  1933. return this.localeData().monthsShort(this, format);
  1934. });
  1935. addFormatToken('MMMM', 0, 0, function (format) {
  1936. return this.localeData().months(this, format);
  1937. });
  1938. // PARSING
  1939. addRegexToken('M', match1to2, match1to2NoLeadingZero);
  1940. addRegexToken('MM', match1to2, match2);
  1941. addRegexToken('MMM', function (isStrict, locale) {
  1942. return locale.monthsShortRegex(isStrict);
  1943. });
  1944. addRegexToken('MMMM', function (isStrict, locale) {
  1945. return locale.monthsRegex(isStrict);
  1946. });
  1947. addParseToken(['M', 'MM'], function (input, array) {
  1948. array[MONTH] = toInt(input) - 1;
  1949. });
  1950. addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
  1951. var month = config._locale.monthsParse(input, token, config._strict);
  1952. // if we didn't find a month name, mark the date as invalid.
  1953. if (month != null) {
  1954. array[MONTH] = month;
  1955. } else {
  1956. getParsingFlags(config).invalidMonth = input;
  1957. }
  1958. });
  1959. // LOCALES
  1960. var defaultLocaleMonths =
  1961. 'January_February_March_April_May_June_July_August_September_October_November_December'.split(
  1962. '_'
  1963. ),
  1964. defaultLocaleMonthsShort =
  1965. 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
  1966. MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,
  1967. defaultMonthsShortRegex = matchWord,
  1968. defaultMonthsRegex = matchWord;
  1969. function localeMonths(m, format) {
  1970. if (!m) {
  1971. return isArray(this._months)
  1972. ? this._months
  1973. : this._months['standalone'];
  1974. }
  1975. return isArray(this._months)
  1976. ? this._months[m.month()]
  1977. : this._months[
  1978. (this._months.isFormat || MONTHS_IN_FORMAT).test(format)
  1979. ? 'format'
  1980. : 'standalone'
  1981. ][m.month()];
  1982. }
  1983. function localeMonthsShort(m, format) {
  1984. if (!m) {
  1985. return isArray(this._monthsShort)
  1986. ? this._monthsShort
  1987. : this._monthsShort['standalone'];
  1988. }
  1989. return isArray(this._monthsShort)
  1990. ? this._monthsShort[m.month()]
  1991. : this._monthsShort[
  1992. MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'
  1993. ][m.month()];
  1994. }
  1995. function handleStrictParse(monthName, format, strict) {
  1996. var i,
  1997. ii,
  1998. mom,
  1999. llc = monthName.toLocaleLowerCase();
  2000. if (!this._monthsParse) {
  2001. // this is not used
  2002. this._monthsParse = [];
  2003. this._longMonthsParse = [];
  2004. this._shortMonthsParse = [];
  2005. for (i = 0; i < 12; ++i) {
  2006. mom = createUTC([2000, i]);
  2007. this._shortMonthsParse[i] = this.monthsShort(
  2008. mom,
  2009. ''
  2010. ).toLocaleLowerCase();
  2011. this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
  2012. }
  2013. }
  2014. if (strict) {
  2015. if (format === 'MMM') {
  2016. ii = indexOf.call(this._shortMonthsParse, llc);
  2017. return ii !== -1 ? ii : null;
  2018. } else {
  2019. ii = indexOf.call(this._longMonthsParse, llc);
  2020. return ii !== -1 ? ii : null;
  2021. }
  2022. } else {
  2023. if (format === 'MMM') {
  2024. ii = indexOf.call(this._shortMonthsParse, llc);
  2025. if (ii !== -1) {
  2026. return ii;
  2027. }
  2028. ii = indexOf.call(this._longMonthsParse, llc);
  2029. return ii !== -1 ? ii : null;
  2030. } else {
  2031. ii = indexOf.call(this._longMonthsParse, llc);
  2032. if (ii !== -1) {
  2033. return ii;
  2034. }
  2035. ii = indexOf.call(this._shortMonthsParse, llc);
  2036. return ii !== -1 ? ii : null;
  2037. }
  2038. }
  2039. }
  2040. function localeMonthsParse(monthName, format, strict) {
  2041. var i, mom, regex;
  2042. if (this._monthsParseExact) {
  2043. return handleStrictParse.call(this, monthName, format, strict);
  2044. }
  2045. if (!this._monthsParse) {
  2046. this._monthsParse = [];
  2047. this._longMonthsParse = [];
  2048. this._shortMonthsParse = [];
  2049. }
  2050. // TODO: add sorting
  2051. // Sorting makes sure if one month (or abbr) is a prefix of another
  2052. // see sorting in computeMonthsParse
  2053. for (i = 0; i < 12; i++) {
  2054. // make the regex if we don't have it already
  2055. mom = createUTC([2000, i]);
  2056. if (strict && !this._longMonthsParse[i]) {
  2057. this._longMonthsParse[i] = new RegExp(
  2058. '^' + this.months(mom, '').replace('.', '') + '$',
  2059. 'i'
  2060. );
  2061. this._shortMonthsParse[i] = new RegExp(
  2062. '^' + this.monthsShort(mom, '').replace('.', '') + '$',
  2063. 'i'
  2064. );
  2065. }
  2066. if (!strict && !this._monthsParse[i]) {
  2067. regex =
  2068. '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
  2069. this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
  2070. }
  2071. // test the regex
  2072. if (
  2073. strict &&
  2074. format === 'MMMM' &&
  2075. this._longMonthsParse[i].test(monthName)
  2076. ) {
  2077. return i;
  2078. } else if (
  2079. strict &&
  2080. format === 'MMM' &&
  2081. this._shortMonthsParse[i].test(monthName)
  2082. ) {
  2083. return i;
  2084. } else if (!strict && this._monthsParse[i].test(monthName)) {
  2085. return i;
  2086. }
  2087. }
  2088. }
  2089. // MOMENTS
  2090. function setMonth(mom, value) {
  2091. if (!mom.isValid()) {
  2092. // No op
  2093. return mom;
  2094. }
  2095. if (typeof value === 'string') {
  2096. if (/^\d+$/.test(value)) {
  2097. value = toInt(value);
  2098. } else {
  2099. value = mom.localeData().monthsParse(value);
  2100. // TODO: Another silent failure?
  2101. if (!isNumber(value)) {
  2102. return mom;
  2103. }
  2104. }
  2105. }
  2106. var month = value,
  2107. date = mom.date();
  2108. date = date < 29 ? date : Math.min(date, daysInMonth(mom.year(), month));
  2109. void (mom._isUTC
  2110. ? mom._d.setUTCMonth(month, date)
  2111. : mom._d.setMonth(month, date));
  2112. return mom;
  2113. }
  2114. function getSetMonth(value) {
  2115. if (value != null) {
  2116. setMonth(this, value);
  2117. hooks.updateOffset(this, true);
  2118. return this;
  2119. } else {
  2120. return get(this, 'Month');
  2121. }
  2122. }
  2123. function getDaysInMonth() {
  2124. return daysInMonth(this.year(), this.month());
  2125. }
  2126. function monthsShortRegex(isStrict) {
  2127. if (this._monthsParseExact) {
  2128. if (!hasOwnProp(this, '_monthsRegex')) {
  2129. computeMonthsParse.call(this);
  2130. }
  2131. if (isStrict) {
  2132. return this._monthsShortStrictRegex;
  2133. } else {
  2134. return this._monthsShortRegex;
  2135. }
  2136. } else {
  2137. if (!hasOwnProp(this, '_monthsShortRegex')) {
  2138. this._monthsShortRegex = defaultMonthsShortRegex;
  2139. }
  2140. return this._monthsShortStrictRegex && isStrict
  2141. ? this._monthsShortStrictRegex
  2142. : this._monthsShortRegex;
  2143. }
  2144. }
  2145. function monthsRegex(isStrict) {
  2146. if (this._monthsParseExact) {
  2147. if (!hasOwnProp(this, '_monthsRegex')) {
  2148. computeMonthsParse.call(this);
  2149. }
  2150. if (isStrict) {
  2151. return this._monthsStrictRegex;
  2152. } else {
  2153. return this._monthsRegex;
  2154. }
  2155. } else {
  2156. if (!hasOwnProp(this, '_monthsRegex')) {
  2157. this._monthsRegex = defaultMonthsRegex;
  2158. }
  2159. return this._monthsStrictRegex && isStrict
  2160. ? this._monthsStrictRegex
  2161. : this._monthsRegex;
  2162. }
  2163. }
  2164. function computeMonthsParse() {
  2165. function cmpLenRev(a, b) {
  2166. return b.length - a.length;
  2167. }
  2168. var shortPieces = [],
  2169. longPieces = [],
  2170. mixedPieces = [],
  2171. i,
  2172. mom,
  2173. shortP,
  2174. longP;
  2175. for (i = 0; i < 12; i++) {
  2176. // make the regex if we don't have it already
  2177. mom = createUTC([2000, i]);
  2178. shortP = regexEscape(this.monthsShort(mom, ''));
  2179. longP = regexEscape(this.months(mom, ''));
  2180. shortPieces.push(shortP);
  2181. longPieces.push(longP);
  2182. mixedPieces.push(longP);
  2183. mixedPieces.push(shortP);
  2184. }
  2185. // Sorting makes sure if one month (or abbr) is a prefix of another it
  2186. // will match the longer piece.
  2187. shortPieces.sort(cmpLenRev);
  2188. longPieces.sort(cmpLenRev);
  2189. mixedPieces.sort(cmpLenRev);
  2190. this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  2191. this._monthsShortRegex = this._monthsRegex;
  2192. this._monthsStrictRegex = new RegExp(
  2193. '^(' + longPieces.join('|') + ')',
  2194. 'i'
  2195. );
  2196. this._monthsShortStrictRegex = new RegExp(
  2197. '^(' + shortPieces.join('|') + ')',
  2198. 'i'
  2199. );
  2200. }
  2201. function createDate(y, m, d, h, M, s, ms) {
  2202. // can't just apply() to create a date:
  2203. // https://stackoverflow.com/q/181348
  2204. var date;
  2205. // the date constructor remaps years 0-99 to 1900-1999
  2206. if (y < 100 && y >= 0) {
  2207. // preserve leap years using a full 400 year cycle, then reset
  2208. date = new Date(y + 400, m, d, h, M, s, ms);
  2209. if (isFinite(date.getFullYear())) {
  2210. date.setFullYear(y);
  2211. }
  2212. } else {
  2213. date = new Date(y, m, d, h, M, s, ms);
  2214. }
  2215. return date;
  2216. }
  2217. function createUTCDate(y) {
  2218. var date, args;
  2219. // the Date.UTC function remaps years 0-99 to 1900-1999
  2220. if (y < 100 && y >= 0) {
  2221. args = Array.prototype.slice.call(arguments);
  2222. // preserve leap years using a full 400 year cycle, then reset
  2223. args[0] = y + 400;
  2224. date = new Date(Date.UTC.apply(null, args));
  2225. if (isFinite(date.getUTCFullYear())) {
  2226. date.setUTCFullYear(y);
  2227. }
  2228. } else {
  2229. date = new Date(Date.UTC.apply(null, arguments));
  2230. }
  2231. return date;
  2232. }
  2233. // start-of-first-week - start-of-year
  2234. function firstWeekOffset(year, dow, doy) {
  2235. var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
  2236. fwd = 7 + dow - doy,
  2237. // first-week day local weekday -- which local weekday is fwd
  2238. fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
  2239. return -fwdlw + fwd - 1;
  2240. }
  2241. // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
  2242. function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
  2243. var localWeekday = (7 + weekday - dow) % 7,
  2244. weekOffset = firstWeekOffset(year, dow, doy),
  2245. dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
  2246. resYear,
  2247. resDayOfYear;
  2248. if (dayOfYear <= 0) {
  2249. resYear = year - 1;
  2250. resDayOfYear = daysInYear(resYear) + dayOfYear;
  2251. } else if (dayOfYear > daysInYear(year)) {
  2252. resYear = year + 1;
  2253. resDayOfYear = dayOfYear - daysInYear(year);
  2254. } else {
  2255. resYear = year;
  2256. resDayOfYear = dayOfYear;
  2257. }
  2258. return {
  2259. year: resYear,
  2260. dayOfYear: resDayOfYear,
  2261. };
  2262. }
  2263. function weekOfYear(mom, dow, doy) {
  2264. var weekOffset = firstWeekOffset(mom.year(), dow, doy),
  2265. week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
  2266. resWeek,
  2267. resYear;
  2268. if (week < 1) {
  2269. resYear = mom.year() - 1;
  2270. resWeek = week + weeksInYear(resYear, dow, doy);
  2271. } else if (week > weeksInYear(mom.year(), dow, doy)) {
  2272. resWeek = week - weeksInYear(mom.year(), dow, doy);
  2273. resYear = mom.year() + 1;
  2274. } else {
  2275. resYear = mom.year();
  2276. resWeek = week;
  2277. }
  2278. return {
  2279. week: resWeek,
  2280. year: resYear,
  2281. };
  2282. }
  2283. function weeksInYear(year, dow, doy) {
  2284. var weekOffset = firstWeekOffset(year, dow, doy),
  2285. weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
  2286. return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
  2287. }
  2288. // FORMATTING
  2289. addFormatToken('w', ['ww', 2], 'wo', 'week');
  2290. addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
  2291. // PARSING
  2292. addRegexToken('w', match1to2, match1to2NoLeadingZero);
  2293. addRegexToken('ww', match1to2, match2);
  2294. addRegexToken('W', match1to2, match1to2NoLeadingZero);
  2295. addRegexToken('WW', match1to2, match2);
  2296. addWeekParseToken(
  2297. ['w', 'ww', 'W', 'WW'],
  2298. function (input, week, config, token) {
  2299. week[token.substr(0, 1)] = toInt(input);
  2300. }
  2301. );
  2302. // HELPERS
  2303. // LOCALES
  2304. function localeWeek(mom) {
  2305. return weekOfYear(mom, this._week.dow, this._week.doy).week;
  2306. }
  2307. var defaultLocaleWeek = {
  2308. dow: 0, // Sunday is the first day of the week.
  2309. doy: 6, // The week that contains Jan 6th is the first week of the year.
  2310. };
  2311. function localeFirstDayOfWeek() {
  2312. return this._week.dow;
  2313. }
  2314. function localeFirstDayOfYear() {
  2315. return this._week.doy;
  2316. }
  2317. // MOMENTS
  2318. function getSetWeek(input) {
  2319. var week = this.localeData().week(this);
  2320. return input == null ? week : this.add((input - week) * 7, 'd');
  2321. }
  2322. function getSetISOWeek(input) {
  2323. var week = weekOfYear(this, 1, 4).week;
  2324. return input == null ? week : this.add((input - week) * 7, 'd');
  2325. }
  2326. // FORMATTING
  2327. addFormatToken('d', 0, 'do', 'day');
  2328. addFormatToken('dd', 0, 0, function (format) {
  2329. return this.localeData().weekdaysMin(this, format);
  2330. });
  2331. addFormatToken('ddd', 0, 0, function (format) {
  2332. return this.localeData().weekdaysShort(this, format);
  2333. });
  2334. addFormatToken('dddd', 0, 0, function (format) {
  2335. return this.localeData().weekdays(this, format);
  2336. });
  2337. addFormatToken('e', 0, 0, 'weekday');
  2338. addFormatToken('E', 0, 0, 'isoWeekday');
  2339. // PARSING
  2340. addRegexToken('d', match1to2);
  2341. addRegexToken('e', match1to2);
  2342. addRegexToken('E', match1to2);
  2343. addRegexToken('dd', function (isStrict, locale) {
  2344. return locale.weekdaysMinRegex(isStrict);
  2345. });
  2346. addRegexToken('ddd', function (isStrict, locale) {
  2347. return locale.weekdaysShortRegex(isStrict);
  2348. });
  2349. addRegexToken('dddd', function (isStrict, locale) {
  2350. return locale.weekdaysRegex(isStrict);
  2351. });
  2352. addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
  2353. var weekday = config._locale.weekdaysParse(input, token, config._strict);
  2354. // if we didn't get a weekday name, mark the date as invalid
  2355. if (weekday != null) {
  2356. week.d = weekday;
  2357. } else {
  2358. getParsingFlags(config).invalidWeekday = input;
  2359. }
  2360. });
  2361. addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
  2362. week[token] = toInt(input);
  2363. });
  2364. // HELPERS
  2365. function parseWeekday(input, locale) {
  2366. if (typeof input !== 'string') {
  2367. return input;
  2368. }
  2369. if (!isNaN(input)) {
  2370. return parseInt(input, 10);
  2371. }
  2372. input = locale.weekdaysParse(input);
  2373. if (typeof input === 'number') {
  2374. return input;
  2375. }
  2376. return null;
  2377. }
  2378. function parseIsoWeekday(input, locale) {
  2379. if (typeof input === 'string') {
  2380. return locale.weekdaysParse(input) % 7 || 7;
  2381. }
  2382. return isNaN(input) ? null : input;
  2383. }
  2384. // LOCALES
  2385. function shiftWeekdays(ws, n) {
  2386. return ws.slice(n, 7).concat(ws.slice(0, n));
  2387. }
  2388. var defaultLocaleWeekdays =
  2389. 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
  2390. defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
  2391. defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
  2392. defaultWeekdaysRegex = matchWord,
  2393. defaultWeekdaysShortRegex = matchWord,
  2394. defaultWeekdaysMinRegex = matchWord;
  2395. function localeWeekdays(m, format) {
  2396. var weekdays = isArray(this._weekdays)
  2397. ? this._weekdays
  2398. : this._weekdays[
  2399. m && m !== true && this._weekdays.isFormat.test(format)
  2400. ? 'format'
  2401. : 'standalone'
  2402. ];
  2403. return m === true
  2404. ? shiftWeekdays(weekdays, this._week.dow)
  2405. : m
  2406. ? weekdays[m.day()]
  2407. : weekdays;
  2408. }
  2409. function localeWeekdaysShort(m) {
  2410. return m === true
  2411. ? shiftWeekdays(this._weekdaysShort, this._week.dow)
  2412. : m
  2413. ? this._weekdaysShort[m.day()]
  2414. : this._weekdaysShort;
  2415. }
  2416. function localeWeekdaysMin(m) {
  2417. return m === true
  2418. ? shiftWeekdays(this._weekdaysMin, this._week.dow)
  2419. : m
  2420. ? this._weekdaysMin[m.day()]
  2421. : this._weekdaysMin;
  2422. }
  2423. function handleStrictParse$1(weekdayName, format, strict) {
  2424. var i,
  2425. ii,
  2426. mom,
  2427. llc = weekdayName.toLocaleLowerCase();
  2428. if (!this._weekdaysParse) {
  2429. this._weekdaysParse = [];
  2430. this._shortWeekdaysParse = [];
  2431. this._minWeekdaysParse = [];
  2432. for (i = 0; i < 7; ++i) {
  2433. mom = createUTC([2000, 1]).day(i);
  2434. this._minWeekdaysParse[i] = this.weekdaysMin(
  2435. mom,
  2436. ''
  2437. ).toLocaleLowerCase();
  2438. this._shortWeekdaysParse[i] = this.weekdaysShort(
  2439. mom,
  2440. ''
  2441. ).toLocaleLowerCase();
  2442. this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
  2443. }
  2444. }
  2445. if (strict) {
  2446. if (format === 'dddd') {
  2447. ii = indexOf.call(this._weekdaysParse, llc);
  2448. return ii !== -1 ? ii : null;
  2449. } else if (format === 'ddd') {
  2450. ii = indexOf.call(this._shortWeekdaysParse, llc);
  2451. return ii !== -1 ? ii : null;
  2452. } else {
  2453. ii = indexOf.call(this._minWeekdaysParse, llc);
  2454. return ii !== -1 ? ii : null;
  2455. }
  2456. } else {
  2457. if (format === 'dddd') {
  2458. ii = indexOf.call(this._weekdaysParse, llc);
  2459. if (ii !== -1) {
  2460. return ii;
  2461. }
  2462. ii = indexOf.call(this._shortWeekdaysParse, llc);
  2463. if (ii !== -1) {
  2464. return ii;
  2465. }
  2466. ii = indexOf.call(this._minWeekdaysParse, llc);
  2467. return ii !== -1 ? ii : null;
  2468. } else if (format === 'ddd') {
  2469. ii = indexOf.call(this._shortWeekdaysParse, llc);
  2470. if (ii !== -1) {
  2471. return ii;
  2472. }
  2473. ii = indexOf.call(this._weekdaysParse, llc);
  2474. if (ii !== -1) {
  2475. return ii;
  2476. }
  2477. ii = indexOf.call(this._minWeekdaysParse, llc);
  2478. return ii !== -1 ? ii : null;
  2479. } else {
  2480. ii = indexOf.call(this._minWeekdaysParse, llc);
  2481. if (ii !== -1) {
  2482. return ii;
  2483. }
  2484. ii = indexOf.call(this._weekdaysParse, llc);
  2485. if (ii !== -1) {
  2486. return ii;
  2487. }
  2488. ii = indexOf.call(this._shortWeekdaysParse, llc);
  2489. return ii !== -1 ? ii : null;
  2490. }
  2491. }
  2492. }
  2493. function localeWeekdaysParse(weekdayName, format, strict) {
  2494. var i, mom, regex;
  2495. if (this._weekdaysParseExact) {
  2496. return handleStrictParse$1.call(this, weekdayName, format, strict);
  2497. }
  2498. if (!this._weekdaysParse) {
  2499. this._weekdaysParse = [];
  2500. this._minWeekdaysParse = [];
  2501. this._shortWeekdaysParse = [];
  2502. this._fullWeekdaysParse = [];
  2503. }
  2504. for (i = 0; i < 7; i++) {
  2505. // make the regex if we don't have it already
  2506. mom = createUTC([2000, 1]).day(i);
  2507. if (strict && !this._fullWeekdaysParse[i]) {
  2508. this._fullWeekdaysParse[i] = new RegExp(
  2509. '^' + this.weekdays(mom, '').replace('.', '\\.?') + '$',
  2510. 'i'
  2511. );
  2512. this._shortWeekdaysParse[i] = new RegExp(
  2513. '^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$',
  2514. 'i'
  2515. );
  2516. this._minWeekdaysParse[i] = new RegExp(
  2517. '^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$',
  2518. 'i'
  2519. );
  2520. }
  2521. if (!this._weekdaysParse[i]) {
  2522. regex =
  2523. '^' +
  2524. this.weekdays(mom, '') +
  2525. '|^' +
  2526. this.weekdaysShort(mom, '') +
  2527. '|^' +
  2528. this.weekdaysMin(mom, '');
  2529. this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
  2530. }
  2531. // test the regex
  2532. if (
  2533. strict &&
  2534. format === 'dddd' &&
  2535. this._fullWeekdaysParse[i].test(weekdayName)
  2536. ) {
  2537. return i;
  2538. } else if (
  2539. strict &&
  2540. format === 'ddd' &&
  2541. this._shortWeekdaysParse[i].test(weekdayName)
  2542. ) {
  2543. return i;
  2544. } else if (
  2545. strict &&
  2546. format === 'dd' &&
  2547. this._minWeekdaysParse[i].test(weekdayName)
  2548. ) {
  2549. return i;
  2550. } else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
  2551. return i;
  2552. }
  2553. }
  2554. }
  2555. // MOMENTS
  2556. function getSetDayOfWeek(input) {
  2557. if (!this.isValid()) {
  2558. return input != null ? this : NaN;
  2559. }
  2560. var day = get(this, 'Day');
  2561. if (input != null) {
  2562. input = parseWeekday(input, this.localeData());
  2563. return this.add(input - day, 'd');
  2564. } else {
  2565. return day;
  2566. }
  2567. }
  2568. function getSetLocaleDayOfWeek(input) {
  2569. if (!this.isValid()) {
  2570. return input != null ? this : NaN;
  2571. }
  2572. var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
  2573. return input == null ? weekday : this.add(input - weekday, 'd');
  2574. }
  2575. function getSetISODayOfWeek(input) {
  2576. if (!this.isValid()) {
  2577. return input != null ? this : NaN;
  2578. }
  2579. // behaves the same as moment#day except
  2580. // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
  2581. // as a setter, sunday should belong to the previous week.
  2582. if (input != null) {
  2583. var weekday = parseIsoWeekday(input, this.localeData());
  2584. return this.day(this.day() % 7 ? weekday : weekday - 7);
  2585. } else {
  2586. return this.day() || 7;
  2587. }
  2588. }
  2589. function weekdaysRegex(isStrict) {
  2590. if (this._weekdaysParseExact) {
  2591. if (!hasOwnProp(this, '_weekdaysRegex')) {
  2592. computeWeekdaysParse.call(this);
  2593. }
  2594. if (isStrict) {
  2595. return this._weekdaysStrictRegex;
  2596. } else {
  2597. return this._weekdaysRegex;
  2598. }
  2599. } else {
  2600. if (!hasOwnProp(this, '_weekdaysRegex')) {
  2601. this._weekdaysRegex = defaultWeekdaysRegex;
  2602. }
  2603. return this._weekdaysStrictRegex && isStrict
  2604. ? this._weekdaysStrictRegex
  2605. : this._weekdaysRegex;
  2606. }
  2607. }
  2608. function weekdaysShortRegex(isStrict) {
  2609. if (this._weekdaysParseExact) {
  2610. if (!hasOwnProp(this, '_weekdaysRegex')) {
  2611. computeWeekdaysParse.call(this);
  2612. }
  2613. if (isStrict) {
  2614. return this._weekdaysShortStrictRegex;
  2615. } else {
  2616. return this._weekdaysShortRegex;
  2617. }
  2618. } else {
  2619. if (!hasOwnProp(this, '_weekdaysShortRegex')) {
  2620. this._weekdaysShortRegex = defaultWeekdaysShortRegex;
  2621. }
  2622. return this._weekdaysShortStrictRegex && isStrict
  2623. ? this._weekdaysShortStrictRegex
  2624. : this._weekdaysShortRegex;
  2625. }
  2626. }
  2627. function weekdaysMinRegex(isStrict) {
  2628. if (this._weekdaysParseExact) {
  2629. if (!hasOwnProp(this, '_weekdaysRegex')) {
  2630. computeWeekdaysParse.call(this);
  2631. }
  2632. if (isStrict) {
  2633. return this._weekdaysMinStrictRegex;
  2634. } else {
  2635. return this._weekdaysMinRegex;
  2636. }
  2637. } else {
  2638. if (!hasOwnProp(this, '_weekdaysMinRegex')) {
  2639. this._weekdaysMinRegex = defaultWeekdaysMinRegex;
  2640. }
  2641. return this._weekdaysMinStrictRegex && isStrict
  2642. ? this._weekdaysMinStrictRegex
  2643. : this._weekdaysMinRegex;
  2644. }
  2645. }
  2646. function computeWeekdaysParse() {
  2647. function cmpLenRev(a, b) {
  2648. return b.length - a.length;
  2649. }
  2650. var minPieces = [],
  2651. shortPieces = [],
  2652. longPieces = [],
  2653. mixedPieces = [],
  2654. i,
  2655. mom,
  2656. minp,
  2657. shortp,
  2658. longp;
  2659. for (i = 0; i < 7; i++) {
  2660. // make the regex if we don't have it already
  2661. mom = createUTC([2000, 1]).day(i);
  2662. minp = regexEscape(this.weekdaysMin(mom, ''));
  2663. shortp = regexEscape(this.weekdaysShort(mom, ''));
  2664. longp = regexEscape(this.weekdays(mom, ''));
  2665. minPieces.push(minp);
  2666. shortPieces.push(shortp);
  2667. longPieces.push(longp);
  2668. mixedPieces.push(minp);
  2669. mixedPieces.push(shortp);
  2670. mixedPieces.push(longp);
  2671. }
  2672. // Sorting makes sure if one weekday (or abbr) is a prefix of another it
  2673. // will match the longer piece.
  2674. minPieces.sort(cmpLenRev);
  2675. shortPieces.sort(cmpLenRev);
  2676. longPieces.sort(cmpLenRev);
  2677. mixedPieces.sort(cmpLenRev);
  2678. this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  2679. this._weekdaysShortRegex = this._weekdaysRegex;
  2680. this._weekdaysMinRegex = this._weekdaysRegex;
  2681. this._weekdaysStrictRegex = new RegExp(
  2682. '^(' + longPieces.join('|') + ')',
  2683. 'i'
  2684. );
  2685. this._weekdaysShortStrictRegex = new RegExp(
  2686. '^(' + shortPieces.join('|') + ')',
  2687. 'i'
  2688. );
  2689. this._weekdaysMinStrictRegex = new RegExp(
  2690. '^(' + minPieces.join('|') + ')',
  2691. 'i'
  2692. );
  2693. }
  2694. // FORMATTING
  2695. function hFormat() {
  2696. return this.hours() % 12 || 12;
  2697. }
  2698. function kFormat() {
  2699. return this.hours() || 24;
  2700. }
  2701. addFormatToken('H', ['HH', 2], 0, 'hour');
  2702. addFormatToken('h', ['hh', 2], 0, hFormat);
  2703. addFormatToken('k', ['kk', 2], 0, kFormat);
  2704. addFormatToken('hmm', 0, 0, function () {
  2705. return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
  2706. });
  2707. addFormatToken('hmmss', 0, 0, function () {
  2708. return (
  2709. '' +
  2710. hFormat.apply(this) +
  2711. zeroFill(this.minutes(), 2) +
  2712. zeroFill(this.seconds(), 2)
  2713. );
  2714. });
  2715. addFormatToken('Hmm', 0, 0, function () {
  2716. return '' + this.hours() + zeroFill(this.minutes(), 2);
  2717. });
  2718. addFormatToken('Hmmss', 0, 0, function () {
  2719. return (
  2720. '' +
  2721. this.hours() +
  2722. zeroFill(this.minutes(), 2) +
  2723. zeroFill(this.seconds(), 2)
  2724. );
  2725. });
  2726. function meridiem(token, lowercase) {
  2727. addFormatToken(token, 0, 0, function () {
  2728. return this.localeData().meridiem(
  2729. this.hours(),
  2730. this.minutes(),
  2731. lowercase
  2732. );
  2733. });
  2734. }
  2735. meridiem('a', true);
  2736. meridiem('A', false);
  2737. // PARSING
  2738. function matchMeridiem(isStrict, locale) {
  2739. return locale._meridiemParse;
  2740. }
  2741. addRegexToken('a', matchMeridiem);
  2742. addRegexToken('A', matchMeridiem);
  2743. addRegexToken('H', match1to2, match1to2HasZero);
  2744. addRegexToken('h', match1to2, match1to2NoLeadingZero);
  2745. addRegexToken('k', match1to2, match1to2NoLeadingZero);
  2746. addRegexToken('HH', match1to2, match2);
  2747. addRegexToken('hh', match1to2, match2);
  2748. addRegexToken('kk', match1to2, match2);
  2749. addRegexToken('hmm', match3to4);
  2750. addRegexToken('hmmss', match5to6);
  2751. addRegexToken('Hmm', match3to4);
  2752. addRegexToken('Hmmss', match5to6);
  2753. addParseToken(['H', 'HH'], HOUR);
  2754. addParseToken(['k', 'kk'], function (input, array, config) {
  2755. var kInput = toInt(input);
  2756. array[HOUR] = kInput === 24 ? 0 : kInput;
  2757. });
  2758. addParseToken(['a', 'A'], function (input, array, config) {
  2759. config._isPm = config._locale.isPM(input);
  2760. config._meridiem = input;
  2761. });
  2762. addParseToken(['h', 'hh'], function (input, array, config) {
  2763. array[HOUR] = toInt(input);
  2764. getParsingFlags(config).bigHour = true;
  2765. });
  2766. addParseToken('hmm', function (input, array, config) {
  2767. var pos = input.length - 2;
  2768. array[HOUR] = toInt(input.substr(0, pos));
  2769. array[MINUTE] = toInt(input.substr(pos));
  2770. getParsingFlags(config).bigHour = true;
  2771. });
  2772. addParseToken('hmmss', function (input, array, config) {
  2773. var pos1 = input.length - 4,
  2774. pos2 = input.length - 2;
  2775. array[HOUR] = toInt(input.substr(0, pos1));
  2776. array[MINUTE] = toInt(input.substr(pos1, 2));
  2777. array[SECOND] = toInt(input.substr(pos2));
  2778. getParsingFlags(config).bigHour = true;
  2779. });
  2780. addParseToken('Hmm', function (input, array, config) {
  2781. var pos = input.length - 2;
  2782. array[HOUR] = toInt(input.substr(0, pos));
  2783. array[MINUTE] = toInt(input.substr(pos));
  2784. });
  2785. addParseToken('Hmmss', function (input, array, config) {
  2786. var pos1 = input.length - 4,
  2787. pos2 = input.length - 2;
  2788. array[HOUR] = toInt(input.substr(0, pos1));
  2789. array[MINUTE] = toInt(input.substr(pos1, 2));
  2790. array[SECOND] = toInt(input.substr(pos2));
  2791. });
  2792. // LOCALES
  2793. function localeIsPM(input) {
  2794. // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
  2795. // Using charAt should be more compatible.
  2796. return (input + '').toLowerCase().charAt(0) === 'p';
  2797. }
  2798. var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i,
  2799. // Setting the hour should keep the time, because the user explicitly
  2800. // specified which hour they want. So trying to maintain the same hour (in
  2801. // a new timezone) makes sense. Adding/subtracting hours does not follow
  2802. // this rule.
  2803. getSetHour = makeGetSet('Hours', true);
  2804. function localeMeridiem(hours, minutes, isLower) {
  2805. if (hours > 11) {
  2806. return isLower ? 'pm' : 'PM';
  2807. } else {
  2808. return isLower ? 'am' : 'AM';
  2809. }
  2810. }
  2811. var baseConfig = {
  2812. calendar: defaultCalendar,
  2813. longDateFormat: defaultLongDateFormat,
  2814. invalidDate: defaultInvalidDate,
  2815. ordinal: defaultOrdinal,
  2816. dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
  2817. relativeTime: defaultRelativeTime,
  2818. months: defaultLocaleMonths,
  2819. monthsShort: defaultLocaleMonthsShort,
  2820. week: defaultLocaleWeek,
  2821. weekdays: defaultLocaleWeekdays,
  2822. weekdaysMin: defaultLocaleWeekdaysMin,
  2823. weekdaysShort: defaultLocaleWeekdaysShort,
  2824. meridiemParse: defaultLocaleMeridiemParse,
  2825. };
  2826. // internal storage for locale config files
  2827. var locales = {},
  2828. localeFamilies = {},
  2829. globalLocale;
  2830. function commonPrefix(arr1, arr2) {
  2831. var i,
  2832. minl = Math.min(arr1.length, arr2.length);
  2833. for (i = 0; i < minl; i += 1) {
  2834. if (arr1[i] !== arr2[i]) {
  2835. return i;
  2836. }
  2837. }
  2838. return minl;
  2839. }
  2840. function normalizeLocale(key) {
  2841. return key ? key.toLowerCase().replace('_', '-') : key;
  2842. }
  2843. // pick the locale from the array
  2844. // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
  2845. // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
  2846. function chooseLocale(names) {
  2847. var i = 0,
  2848. j,
  2849. next,
  2850. locale,
  2851. split;
  2852. while (i < names.length) {
  2853. split = normalizeLocale(names[i]).split('-');
  2854. j = split.length;
  2855. next = normalizeLocale(names[i + 1]);
  2856. next = next ? next.split('-') : null;
  2857. while (j > 0) {
  2858. locale = loadLocale(split.slice(0, j).join('-'));
  2859. if (locale) {
  2860. return locale;
  2861. }
  2862. if (
  2863. next &&
  2864. next.length >= j &&
  2865. commonPrefix(split, next) >= j - 1
  2866. ) {
  2867. //the next array item is better than a shallower substring of this one
  2868. break;
  2869. }
  2870. j--;
  2871. }
  2872. i++;
  2873. }
  2874. return globalLocale;
  2875. }
  2876. function isLocaleNameSane(name) {
  2877. // Prevent names that look like filesystem paths, i.e contain '/' or '\'
  2878. // Ensure name is available and function returns boolean
  2879. return !!(name && name.match('^[^/\\\\]*$'));
  2880. }
  2881. function loadLocale(name) {
  2882. var oldLocale = null,
  2883. aliasedRequire;
  2884. // TODO: Find a better way to register and load all the locales in Node
  2885. if (
  2886. locales[name] === undefined &&
  2887. typeof module !== 'undefined' &&
  2888. module &&
  2889. module.exports &&
  2890. isLocaleNameSane(name)
  2891. ) {
  2892. try {
  2893. oldLocale = globalLocale._abbr;
  2894. aliasedRequire = require;
  2895. aliasedRequire('./locale/' + name);
  2896. getSetGlobalLocale(oldLocale);
  2897. } catch (e) {
  2898. // mark as not found to avoid repeating expensive file require call causing high CPU
  2899. // when trying to find en-US, en_US, en-us for every format call
  2900. locales[name] = null; // null means not found
  2901. }
  2902. }
  2903. return locales[name];
  2904. }
  2905. // This function will load locale and then set the global locale. If
  2906. // no arguments are passed in, it will simply return the current global
  2907. // locale key.
  2908. function getSetGlobalLocale(key, values) {
  2909. var data;
  2910. if (key) {
  2911. if (isUndefined(values)) {
  2912. data = getLocale(key);
  2913. } else {
  2914. data = defineLocale(key, values);
  2915. }
  2916. if (data) {
  2917. // moment.duration._locale = moment._locale = data;
  2918. globalLocale = data;
  2919. } else {
  2920. if (typeof console !== 'undefined' && console.warn) {
  2921. //warn user if arguments are passed but the locale could not be set
  2922. console.warn(
  2923. 'Locale ' + key + ' not found. Did you forget to load it?'
  2924. );
  2925. }
  2926. }
  2927. }
  2928. return globalLocale._abbr;
  2929. }
  2930. function defineLocale(name, config) {
  2931. if (config !== null) {
  2932. var locale,
  2933. parentConfig = baseConfig;
  2934. config.abbr = name;
  2935. if (locales[name] != null) {
  2936. deprecateSimple(
  2937. 'defineLocaleOverride',
  2938. 'use moment.updateLocale(localeName, config) to change ' +
  2939. 'an existing locale. moment.defineLocale(localeName, ' +
  2940. 'config) should only be used for creating a new locale ' +
  2941. 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.'
  2942. );
  2943. parentConfig = locales[name]._config;
  2944. } else if (config.parentLocale != null) {
  2945. if (locales[config.parentLocale] != null) {
  2946. parentConfig = locales[config.parentLocale]._config;
  2947. } else {
  2948. locale = loadLocale(config.parentLocale);
  2949. if (locale != null) {
  2950. parentConfig = locale._config;
  2951. } else {
  2952. if (!localeFamilies[config.parentLocale]) {
  2953. localeFamilies[config.parentLocale] = [];
  2954. }
  2955. localeFamilies[config.parentLocale].push({
  2956. name: name,
  2957. config: config,
  2958. });
  2959. return null;
  2960. }
  2961. }
  2962. }
  2963. locales[name] = new Locale(mergeConfigs(parentConfig, config));
  2964. if (localeFamilies[name]) {
  2965. localeFamilies[name].forEach(function (x) {
  2966. defineLocale(x.name, x.config);
  2967. });
  2968. }
  2969. // backwards compat for now: also set the locale
  2970. // make sure we set the locale AFTER all child locales have been
  2971. // created, so we won't end up with the child locale set.
  2972. getSetGlobalLocale(name);
  2973. return locales[name];
  2974. } else {
  2975. // useful for testing
  2976. delete locales[name];
  2977. return null;
  2978. }
  2979. }
  2980. function updateLocale(name, config) {
  2981. if (config != null) {
  2982. var locale,
  2983. tmpLocale,
  2984. parentConfig = baseConfig;
  2985. if (locales[name] != null && locales[name].parentLocale != null) {
  2986. // Update existing child locale in-place to avoid memory-leaks
  2987. locales[name].set(mergeConfigs(locales[name]._config, config));
  2988. } else {
  2989. // MERGE
  2990. tmpLocale = loadLocale(name);
  2991. if (tmpLocale != null) {
  2992. parentConfig = tmpLocale._config;
  2993. }
  2994. config = mergeConfigs(parentConfig, config);
  2995. if (tmpLocale == null) {
  2996. // updateLocale is called for creating a new locale
  2997. // Set abbr so it will have a name (getters return
  2998. // undefined otherwise).
  2999. config.abbr = name;
  3000. }
  3001. locale = new Locale(config);
  3002. locale.parentLocale = locales[name];
  3003. locales[name] = locale;
  3004. }
  3005. // backwards compat for now: also set the locale
  3006. getSetGlobalLocale(name);
  3007. } else {
  3008. // pass null for config to unupdate, useful for tests
  3009. if (locales[name] != null) {
  3010. if (locales[name].parentLocale != null) {
  3011. locales[name] = locales[name].parentLocale;
  3012. if (name === getSetGlobalLocale()) {
  3013. getSetGlobalLocale(name);
  3014. }
  3015. } else if (locales[name] != null) {
  3016. delete locales[name];
  3017. }
  3018. }
  3019. }
  3020. return locales[name];
  3021. }
  3022. // returns locale data
  3023. function getLocale(key) {
  3024. var locale;
  3025. if (key && key._locale && key._locale._abbr) {
  3026. key = key._locale._abbr;
  3027. }
  3028. if (!key) {
  3029. return globalLocale;
  3030. }
  3031. if (!isArray(key)) {
  3032. //short-circuit everything else
  3033. locale = loadLocale(key);
  3034. if (locale) {
  3035. return locale;
  3036. }
  3037. key = [key];
  3038. }
  3039. return chooseLocale(key);
  3040. }
  3041. function listLocales() {
  3042. return keys(locales);
  3043. }
  3044. function checkOverflow(m) {
  3045. var overflow,
  3046. a = m._a;
  3047. if (a && getParsingFlags(m).overflow === -2) {
  3048. overflow =
  3049. a[MONTH] < 0 || a[MONTH] > 11
  3050. ? MONTH
  3051. : a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH])
  3052. ? DATE
  3053. : a[HOUR] < 0 ||
  3054. a[HOUR] > 24 ||
  3055. (a[HOUR] === 24 &&
  3056. (a[MINUTE] !== 0 ||
  3057. a[SECOND] !== 0 ||
  3058. a[MILLISECOND] !== 0))
  3059. ? HOUR
  3060. : a[MINUTE] < 0 || a[MINUTE] > 59
  3061. ? MINUTE
  3062. : a[SECOND] < 0 || a[SECOND] > 59
  3063. ? SECOND
  3064. : a[MILLISECOND] < 0 || a[MILLISECOND] > 999
  3065. ? MILLISECOND
  3066. : -1;
  3067. if (
  3068. getParsingFlags(m)._overflowDayOfYear &&
  3069. (overflow < YEAR || overflow > DATE)
  3070. ) {
  3071. overflow = DATE;
  3072. }
  3073. if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
  3074. overflow = WEEK;
  3075. }
  3076. if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
  3077. overflow = WEEKDAY;
  3078. }
  3079. getParsingFlags(m).overflow = overflow;
  3080. }
  3081. return m;
  3082. }
  3083. // iso 8601 regex
  3084. // 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
  3085. var extendedIsoRegex =
  3086. /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,
  3087. basicIsoRegex =
  3088. /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,
  3089. tzRegex = /Z|[+-]\d\d(?::?\d\d)?/,
  3090. isoDates = [
  3091. ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/],
  3092. ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/],
  3093. ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/],
  3094. ['GGGG-[W]WW', /\d{4}-W\d\d/, false],
  3095. ['YYYY-DDD', /\d{4}-\d{3}/],
  3096. ['YYYY-MM', /\d{4}-\d\d/, false],
  3097. ['YYYYYYMMDD', /[+-]\d{10}/],
  3098. ['YYYYMMDD', /\d{8}/],
  3099. ['GGGG[W]WWE', /\d{4}W\d{3}/],
  3100. ['GGGG[W]WW', /\d{4}W\d{2}/, false],
  3101. ['YYYYDDD', /\d{7}/],
  3102. ['YYYYMM', /\d{6}/, false],
  3103. ['YYYY', /\d{4}/, false],
  3104. ],
  3105. // iso time formats and regexes
  3106. isoTimes = [
  3107. ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/],
  3108. ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/],
  3109. ['HH:mm:ss', /\d\d:\d\d:\d\d/],
  3110. ['HH:mm', /\d\d:\d\d/],
  3111. ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/],
  3112. ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/],
  3113. ['HHmmss', /\d\d\d\d\d\d/],
  3114. ['HHmm', /\d\d\d\d/],
  3115. ['HH', /\d\d/],
  3116. ],
  3117. aspNetJsonRegex = /^\/?Date\((-?\d+)/i,
  3118. // RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3
  3119. rfc2822 =
  3120. /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,
  3121. obsOffsets = {
  3122. UT: 0,
  3123. GMT: 0,
  3124. EDT: -4 * 60,
  3125. EST: -5 * 60,
  3126. CDT: -5 * 60,
  3127. CST: -6 * 60,
  3128. MDT: -6 * 60,
  3129. MST: -7 * 60,
  3130. PDT: -7 * 60,
  3131. PST: -8 * 60,
  3132. };
  3133. // date from iso format
  3134. function configFromISO(config) {
  3135. var i,
  3136. l,
  3137. string = config._i,
  3138. match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
  3139. allowTime,
  3140. dateFormat,
  3141. timeFormat,
  3142. tzFormat,
  3143. isoDatesLen = isoDates.length,
  3144. isoTimesLen = isoTimes.length;
  3145. if (match) {
  3146. getParsingFlags(config).iso = true;
  3147. for (i = 0, l = isoDatesLen; i < l; i++) {
  3148. if (isoDates[i][1].exec(match[1])) {
  3149. dateFormat = isoDates[i][0];
  3150. allowTime = isoDates[i][2] !== false;
  3151. break;
  3152. }
  3153. }
  3154. if (dateFormat == null) {
  3155. config._isValid = false;
  3156. return;
  3157. }
  3158. if (match[3]) {
  3159. for (i = 0, l = isoTimesLen; i < l; i++) {
  3160. if (isoTimes[i][1].exec(match[3])) {
  3161. // match[2] should be 'T' or space
  3162. timeFormat = (match[2] || ' ') + isoTimes[i][0];
  3163. break;
  3164. }
  3165. }
  3166. if (timeFormat == null) {
  3167. config._isValid = false;
  3168. return;
  3169. }
  3170. }
  3171. if (!allowTime && timeFormat != null) {
  3172. config._isValid = false;
  3173. return;
  3174. }
  3175. if (match[4]) {
  3176. if (tzRegex.exec(match[4])) {
  3177. tzFormat = 'Z';
  3178. } else {
  3179. config._isValid = false;
  3180. return;
  3181. }
  3182. }
  3183. config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
  3184. configFromStringAndFormat(config);
  3185. } else {
  3186. config._isValid = false;
  3187. }
  3188. }
  3189. function extractFromRFC2822Strings(
  3190. yearStr,
  3191. monthStr,
  3192. dayStr,
  3193. hourStr,
  3194. minuteStr,
  3195. secondStr
  3196. ) {
  3197. var result = [
  3198. untruncateYear(yearStr),
  3199. defaultLocaleMonthsShort.indexOf(monthStr),
  3200. parseInt(dayStr, 10),
  3201. parseInt(hourStr, 10),
  3202. parseInt(minuteStr, 10),
  3203. ];
  3204. if (secondStr) {
  3205. result.push(parseInt(secondStr, 10));
  3206. }
  3207. return result;
  3208. }
  3209. function untruncateYear(yearStr) {
  3210. var year = parseInt(yearStr, 10);
  3211. if (year <= 49) {
  3212. return 2000 + year;
  3213. } else if (year <= 999) {
  3214. return 1900 + year;
  3215. }
  3216. return year;
  3217. }
  3218. function preprocessRFC2822(s) {
  3219. // Remove comments and folding whitespace and replace multiple-spaces with a single space
  3220. return s
  3221. .replace(/\([^()]*\)|[\n\t]/g, ' ')
  3222. .replace(/(\s\s+)/g, ' ')
  3223. .replace(/^\s\s*/, '')
  3224. .replace(/\s\s*$/, '');
  3225. }
  3226. function checkWeekday(weekdayStr, parsedInput, config) {
  3227. if (weekdayStr) {
  3228. // TODO: Replace the vanilla JS Date object with an independent day-of-week check.
  3229. var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr),
  3230. weekdayActual = new Date(
  3231. parsedInput[0],
  3232. parsedInput[1],
  3233. parsedInput[2]
  3234. ).getDay();
  3235. if (weekdayProvided !== weekdayActual) {
  3236. getParsingFlags(config).weekdayMismatch = true;
  3237. config._isValid = false;
  3238. return false;
  3239. }
  3240. }
  3241. return true;
  3242. }
  3243. function calculateOffset(obsOffset, militaryOffset, numOffset) {
  3244. if (obsOffset) {
  3245. return obsOffsets[obsOffset];
  3246. } else if (militaryOffset) {
  3247. // the only allowed military tz is Z
  3248. return 0;
  3249. } else {
  3250. var hm = parseInt(numOffset, 10),
  3251. m = hm % 100,
  3252. h = (hm - m) / 100;
  3253. return h * 60 + m;
  3254. }
  3255. }
  3256. // date and time from ref 2822 format
  3257. function configFromRFC2822(config) {
  3258. var match = rfc2822.exec(preprocessRFC2822(config._i)),
  3259. parsedArray;
  3260. if (match) {
  3261. parsedArray = extractFromRFC2822Strings(
  3262. match[4],
  3263. match[3],
  3264. match[2],
  3265. match[5],
  3266. match[6],
  3267. match[7]
  3268. );
  3269. if (!checkWeekday(match[1], parsedArray, config)) {
  3270. return;
  3271. }
  3272. config._a = parsedArray;
  3273. config._tzm = calculateOffset(match[8], match[9], match[10]);
  3274. config._d = createUTCDate.apply(null, config._a);
  3275. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  3276. getParsingFlags(config).rfc2822 = true;
  3277. } else {
  3278. config._isValid = false;
  3279. }
  3280. }
  3281. // date from 1) ASP.NET, 2) ISO, 3) RFC 2822 formats, or 4) optional fallback if parsing isn't strict
  3282. function configFromString(config) {
  3283. var matched = aspNetJsonRegex.exec(config._i);
  3284. if (matched !== null) {
  3285. config._d = new Date(+matched[1]);
  3286. return;
  3287. }
  3288. configFromISO(config);
  3289. if (config._isValid === false) {
  3290. delete config._isValid;
  3291. } else {
  3292. return;
  3293. }
  3294. configFromRFC2822(config);
  3295. if (config._isValid === false) {
  3296. delete config._isValid;
  3297. } else {
  3298. return;
  3299. }
  3300. if (config._strict) {
  3301. config._isValid = false;
  3302. } else {
  3303. // Final attempt, use Input Fallback
  3304. hooks.createFromInputFallback(config);
  3305. }
  3306. }
  3307. hooks.createFromInputFallback = deprecate(
  3308. 'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' +
  3309. 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' +
  3310. 'discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.',
  3311. function (config) {
  3312. config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
  3313. }
  3314. );
  3315. // Pick the first defined of two or three arguments.
  3316. function defaults(a, b, c) {
  3317. if (a != null) {
  3318. return a;
  3319. }
  3320. if (b != null) {
  3321. return b;
  3322. }
  3323. return c;
  3324. }
  3325. function currentDateArray(config) {
  3326. // hooks is actually the exported moment object
  3327. var nowValue = new Date(hooks.now());
  3328. if (config._useUTC) {
  3329. return [
  3330. nowValue.getUTCFullYear(),
  3331. nowValue.getUTCMonth(),
  3332. nowValue.getUTCDate(),
  3333. ];
  3334. }
  3335. return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
  3336. }
  3337. // convert an array to a date.
  3338. // the array should mirror the parameters below
  3339. // note: all values past the year are optional and will default to the lowest possible value.
  3340. // [year, month, day , hour, minute, second, millisecond]
  3341. function configFromArray(config) {
  3342. var i,
  3343. date,
  3344. input = [],
  3345. currentDate,
  3346. expectedWeekday,
  3347. yearToUse;
  3348. if (config._d) {
  3349. return;
  3350. }
  3351. currentDate = currentDateArray(config);
  3352. //compute day of the year from weeks and weekdays
  3353. if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
  3354. dayOfYearFromWeekInfo(config);
  3355. }
  3356. //if the day of the year is set, figure out what it is
  3357. if (config._dayOfYear != null) {
  3358. yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
  3359. if (
  3360. config._dayOfYear > daysInYear(yearToUse) ||
  3361. config._dayOfYear === 0
  3362. ) {
  3363. getParsingFlags(config)._overflowDayOfYear = true;
  3364. }
  3365. date = createUTCDate(yearToUse, 0, config._dayOfYear);
  3366. config._a[MONTH] = date.getUTCMonth();
  3367. config._a[DATE] = date.getUTCDate();
  3368. }
  3369. // Default to current date.
  3370. // * if no year, month, day of month are given, default to today
  3371. // * if day of month is given, default month and year
  3372. // * if month is given, default only year
  3373. // * if year is given, don't default anything
  3374. for (i = 0; i < 3 && config._a[i] == null; ++i) {
  3375. config._a[i] = input[i] = currentDate[i];
  3376. }
  3377. // Zero out whatever was not defaulted, including time
  3378. for (; i < 7; i++) {
  3379. config._a[i] = input[i] =
  3380. config._a[i] == null ? (i === 2 ? 1 : 0) : config._a[i];
  3381. }
  3382. // Check for 24:00:00.000
  3383. if (
  3384. config._a[HOUR] === 24 &&
  3385. config._a[MINUTE] === 0 &&
  3386. config._a[SECOND] === 0 &&
  3387. config._a[MILLISECOND] === 0
  3388. ) {
  3389. config._nextDay = true;
  3390. config._a[HOUR] = 0;
  3391. }
  3392. config._d = (config._useUTC ? createUTCDate : createDate).apply(
  3393. null,
  3394. input
  3395. );
  3396. expectedWeekday = config._useUTC
  3397. ? config._d.getUTCDay()
  3398. : config._d.getDay();
  3399. // Apply timezone offset from input. The actual utcOffset can be changed
  3400. // with parseZone.
  3401. if (config._tzm != null) {
  3402. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  3403. }
  3404. if (config._nextDay) {
  3405. config._a[HOUR] = 24;
  3406. }
  3407. // check for mismatching day of week
  3408. if (
  3409. config._w &&
  3410. typeof config._w.d !== 'undefined' &&
  3411. config._w.d !== expectedWeekday
  3412. ) {
  3413. getParsingFlags(config).weekdayMismatch = true;
  3414. }
  3415. }
  3416. function dayOfYearFromWeekInfo(config) {
  3417. var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow, curWeek;
  3418. w = config._w;
  3419. if (w.GG != null || w.W != null || w.E != null) {
  3420. dow = 1;
  3421. doy = 4;
  3422. // TODO: We need to take the current isoWeekYear, but that depends on
  3423. // how we interpret now (local, utc, fixed offset). So create
  3424. // a now version of current config (take local/utc/offset flags, and
  3425. // create now).
  3426. weekYear = defaults(
  3427. w.GG,
  3428. config._a[YEAR],
  3429. weekOfYear(createLocal(), 1, 4).year
  3430. );
  3431. week = defaults(w.W, 1);
  3432. weekday = defaults(w.E, 1);
  3433. if (weekday < 1 || weekday > 7) {
  3434. weekdayOverflow = true;
  3435. }
  3436. } else {
  3437. dow = config._locale._week.dow;
  3438. doy = config._locale._week.doy;
  3439. curWeek = weekOfYear(createLocal(), dow, doy);
  3440. weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
  3441. // Default to current week.
  3442. week = defaults(w.w, curWeek.week);
  3443. if (w.d != null) {
  3444. // weekday -- low day numbers are considered next week
  3445. weekday = w.d;
  3446. if (weekday < 0 || weekday > 6) {
  3447. weekdayOverflow = true;
  3448. }
  3449. } else if (w.e != null) {
  3450. // local weekday -- counting starts from beginning of week
  3451. weekday = w.e + dow;
  3452. if (w.e < 0 || w.e > 6) {
  3453. weekdayOverflow = true;
  3454. }
  3455. } else {
  3456. // default to beginning of week
  3457. weekday = dow;
  3458. }
  3459. }
  3460. if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
  3461. getParsingFlags(config)._overflowWeeks = true;
  3462. } else if (weekdayOverflow != null) {
  3463. getParsingFlags(config)._overflowWeekday = true;
  3464. } else {
  3465. temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
  3466. config._a[YEAR] = temp.year;
  3467. config._dayOfYear = temp.dayOfYear;
  3468. }
  3469. }
  3470. // constant that refers to the ISO standard
  3471. hooks.ISO_8601 = function () {};
  3472. // constant that refers to the RFC 2822 form
  3473. hooks.RFC_2822 = function () {};
  3474. // date from string and format string
  3475. function configFromStringAndFormat(config) {
  3476. // TODO: Move this to another part of the creation flow to prevent circular deps
  3477. if (config._f === hooks.ISO_8601) {
  3478. configFromISO(config);
  3479. return;
  3480. }
  3481. if (config._f === hooks.RFC_2822) {
  3482. configFromRFC2822(config);
  3483. return;
  3484. }
  3485. config._a = [];
  3486. getParsingFlags(config).empty = true;
  3487. // This array is used to make a Date, either with `new Date` or `Date.UTC`
  3488. var string = '' + config._i,
  3489. i,
  3490. parsedInput,
  3491. tokens,
  3492. token,
  3493. skipped,
  3494. stringLength = string.length,
  3495. totalParsedInputLength = 0,
  3496. era,
  3497. tokenLen;
  3498. tokens =
  3499. expandFormat(config._f, config._locale).match(formattingTokens) || [];
  3500. tokenLen = tokens.length;
  3501. for (i = 0; i < tokenLen; i++) {
  3502. token = tokens[i];
  3503. parsedInput = (string.match(getParseRegexForToken(token, config)) ||
  3504. [])[0];
  3505. if (parsedInput) {
  3506. skipped = string.substr(0, string.indexOf(parsedInput));
  3507. if (skipped.length > 0) {
  3508. getParsingFlags(config).unusedInput.push(skipped);
  3509. }
  3510. string = string.slice(
  3511. string.indexOf(parsedInput) + parsedInput.length
  3512. );
  3513. totalParsedInputLength += parsedInput.length;
  3514. }
  3515. // don't parse if it's not a known token
  3516. if (formatTokenFunctions[token]) {
  3517. if (parsedInput) {
  3518. getParsingFlags(config).empty = false;
  3519. } else {
  3520. getParsingFlags(config).unusedTokens.push(token);
  3521. }
  3522. addTimeToArrayFromToken(token, parsedInput, config);
  3523. } else if (config._strict && !parsedInput) {
  3524. getParsingFlags(config).unusedTokens.push(token);
  3525. }
  3526. }
  3527. // add remaining unparsed input length to the string
  3528. getParsingFlags(config).charsLeftOver =
  3529. stringLength - totalParsedInputLength;
  3530. if (string.length > 0) {
  3531. getParsingFlags(config).unusedInput.push(string);
  3532. }
  3533. // clear _12h flag if hour is <= 12
  3534. if (
  3535. config._a[HOUR] <= 12 &&
  3536. getParsingFlags(config).bigHour === true &&
  3537. config._a[HOUR] > 0
  3538. ) {
  3539. getParsingFlags(config).bigHour = undefined;
  3540. }
  3541. getParsingFlags(config).parsedDateParts = config._a.slice(0);
  3542. getParsingFlags(config).meridiem = config._meridiem;
  3543. // handle meridiem
  3544. config._a[HOUR] = meridiemFixWrap(
  3545. config._locale,
  3546. config._a[HOUR],
  3547. config._meridiem
  3548. );
  3549. // handle era
  3550. era = getParsingFlags(config).era;
  3551. if (era !== null) {
  3552. config._a[YEAR] = config._locale.erasConvertYear(era, config._a[YEAR]);
  3553. }
  3554. configFromArray(config);
  3555. checkOverflow(config);
  3556. }
  3557. function meridiemFixWrap(locale, hour, meridiem) {
  3558. var isPm;
  3559. if (meridiem == null) {
  3560. // nothing to do
  3561. return hour;
  3562. }
  3563. if (locale.meridiemHour != null) {
  3564. return locale.meridiemHour(hour, meridiem);
  3565. } else if (locale.isPM != null) {
  3566. // Fallback
  3567. isPm = locale.isPM(meridiem);
  3568. if (isPm && hour < 12) {
  3569. hour += 12;
  3570. }
  3571. if (!isPm && hour === 12) {
  3572. hour = 0;
  3573. }
  3574. return hour;
  3575. } else {
  3576. // this is not supposed to happen
  3577. return hour;
  3578. }
  3579. }
  3580. // date from string and array of format strings
  3581. function configFromStringAndArray(config) {
  3582. var tempConfig,
  3583. bestMoment,
  3584. scoreToBeat,
  3585. i,
  3586. currentScore,
  3587. validFormatFound,
  3588. bestFormatIsValid = false,
  3589. configfLen = config._f.length;
  3590. if (configfLen === 0) {
  3591. getParsingFlags(config).invalidFormat = true;
  3592. config._d = new Date(NaN);
  3593. return;
  3594. }
  3595. for (i = 0; i < configfLen; i++) {
  3596. currentScore = 0;
  3597. validFormatFound = false;
  3598. tempConfig = copyConfig({}, config);
  3599. if (config._useUTC != null) {
  3600. tempConfig._useUTC = config._useUTC;
  3601. }
  3602. tempConfig._f = config._f[i];
  3603. configFromStringAndFormat(tempConfig);
  3604. if (isValid(tempConfig)) {
  3605. validFormatFound = true;
  3606. }
  3607. // if there is any input that was not parsed add a penalty for that format
  3608. currentScore += getParsingFlags(tempConfig).charsLeftOver;
  3609. //or tokens
  3610. currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
  3611. getParsingFlags(tempConfig).score = currentScore;
  3612. if (!bestFormatIsValid) {
  3613. if (
  3614. scoreToBeat == null ||
  3615. currentScore < scoreToBeat ||
  3616. validFormatFound
  3617. ) {
  3618. scoreToBeat = currentScore;
  3619. bestMoment = tempConfig;
  3620. if (validFormatFound) {
  3621. bestFormatIsValid = true;
  3622. }
  3623. }
  3624. } else {
  3625. if (currentScore < scoreToBeat) {
  3626. scoreToBeat = currentScore;
  3627. bestMoment = tempConfig;
  3628. }
  3629. }
  3630. }
  3631. extend(config, bestMoment || tempConfig);
  3632. }
  3633. function configFromObject(config) {
  3634. if (config._d) {
  3635. return;
  3636. }
  3637. var i = normalizeObjectUnits(config._i),
  3638. dayOrDate = i.day === undefined ? i.date : i.day;
  3639. config._a = map(
  3640. [i.year, i.month, dayOrDate, i.hour, i.minute, i.second, i.millisecond],
  3641. function (obj) {
  3642. return obj && parseInt(obj, 10);
  3643. }
  3644. );
  3645. configFromArray(config);
  3646. }
  3647. function createFromConfig(config) {
  3648. var res = new Moment(checkOverflow(prepareConfig(config)));
  3649. if (res._nextDay) {
  3650. // Adding is smart enough around DST
  3651. res.add(1, 'd');
  3652. res._nextDay = undefined;
  3653. }
  3654. return res;
  3655. }
  3656. function prepareConfig(config) {
  3657. var input = config._i,
  3658. format = config._f;
  3659. config._locale = config._locale || getLocale(config._l);
  3660. if (input === null || (format === undefined && input === '')) {
  3661. return createInvalid({ nullInput: true });
  3662. }
  3663. if (typeof input === 'string') {
  3664. config._i = input = config._locale.preparse(input);
  3665. }
  3666. if (isMoment(input)) {
  3667. return new Moment(checkOverflow(input));
  3668. } else if (isDate(input)) {
  3669. config._d = input;
  3670. } else if (isArray(format)) {
  3671. configFromStringAndArray(config);
  3672. } else if (format) {
  3673. configFromStringAndFormat(config);
  3674. } else {
  3675. configFromInput(config);
  3676. }
  3677. if (!isValid(config)) {
  3678. config._d = null;
  3679. }
  3680. return config;
  3681. }
  3682. function configFromInput(config) {
  3683. var input = config._i;
  3684. if (isUndefined(input)) {
  3685. config._d = new Date(hooks.now());
  3686. } else if (isDate(input)) {
  3687. config._d = new Date(input.valueOf());
  3688. } else if (typeof input === 'string') {
  3689. configFromString(config);
  3690. } else if (isArray(input)) {
  3691. config._a = map(input.slice(0), function (obj) {
  3692. return parseInt(obj, 10);
  3693. });
  3694. configFromArray(config);
  3695. } else if (isObject(input)) {
  3696. configFromObject(config);
  3697. } else if (isNumber(input)) {
  3698. // from milliseconds
  3699. config._d = new Date(input);
  3700. } else {
  3701. hooks.createFromInputFallback(config);
  3702. }
  3703. }
  3704. function createLocalOrUTC(input, format, locale, strict, isUTC) {
  3705. var c = {};
  3706. if (format === true || format === false) {
  3707. strict = format;
  3708. format = undefined;
  3709. }
  3710. if (locale === true || locale === false) {
  3711. strict = locale;
  3712. locale = undefined;
  3713. }
  3714. if (
  3715. (isObject(input) && isObjectEmpty(input)) ||
  3716. (isArray(input) && input.length === 0)
  3717. ) {
  3718. input = undefined;
  3719. }
  3720. // object construction must be done this way.
  3721. // https://github.com/moment/moment/issues/1423
  3722. c._isAMomentObject = true;
  3723. c._useUTC = c._isUTC = isUTC;
  3724. c._l = locale;
  3725. c._i = input;
  3726. c._f = format;
  3727. c._strict = strict;
  3728. return createFromConfig(c);
  3729. }
  3730. function createLocal(input, format, locale, strict) {
  3731. return createLocalOrUTC(input, format, locale, strict, false);
  3732. }
  3733. var prototypeMin = deprecate(
  3734. 'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',
  3735. function () {
  3736. var other = createLocal.apply(null, arguments);
  3737. if (this.isValid() && other.isValid()) {
  3738. return other < this ? this : other;
  3739. } else {
  3740. return createInvalid();
  3741. }
  3742. }
  3743. ),
  3744. prototypeMax = deprecate(
  3745. 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',
  3746. function () {
  3747. var other = createLocal.apply(null, arguments);
  3748. if (this.isValid() && other.isValid()) {
  3749. return other > this ? this : other;
  3750. } else {
  3751. return createInvalid();
  3752. }
  3753. }
  3754. );
  3755. // Pick a moment m from moments so that m[fn](other) is true for all
  3756. // other. This relies on the function fn to be transitive.
  3757. //
  3758. // moments should either be an array of moment objects or an array, whose
  3759. // first element is an array of moment objects.
  3760. function pickBy(fn, moments) {
  3761. var res, i;
  3762. if (moments.length === 1 && isArray(moments[0])) {
  3763. moments = moments[0];
  3764. }
  3765. if (!moments.length) {
  3766. return createLocal();
  3767. }
  3768. res = moments[0];
  3769. for (i = 1; i < moments.length; ++i) {
  3770. if (!moments[i].isValid() || moments[i][fn](res)) {
  3771. res = moments[i];
  3772. }
  3773. }
  3774. return res;
  3775. }
  3776. // TODO: Use [].sort instead?
  3777. function min() {
  3778. var args = [].slice.call(arguments, 0);
  3779. return pickBy('isBefore', args);
  3780. }
  3781. function max() {
  3782. var args = [].slice.call(arguments, 0);
  3783. return pickBy('isAfter', args);
  3784. }
  3785. var now = function () {
  3786. return Date.now ? Date.now() : +new Date();
  3787. };
  3788. var ordering = [
  3789. 'year',
  3790. 'quarter',
  3791. 'month',
  3792. 'week',
  3793. 'day',
  3794. 'hour',
  3795. 'minute',
  3796. 'second',
  3797. 'millisecond',
  3798. ];
  3799. function isDurationValid(m) {
  3800. var key,
  3801. unitHasDecimal = false,
  3802. i,
  3803. orderLen = ordering.length;
  3804. for (key in m) {
  3805. if (
  3806. hasOwnProp(m, key) &&
  3807. !(
  3808. indexOf.call(ordering, key) !== -1 &&
  3809. (m[key] == null || !isNaN(m[key]))
  3810. )
  3811. ) {
  3812. return false;
  3813. }
  3814. }
  3815. for (i = 0; i < orderLen; ++i) {
  3816. if (m[ordering[i]]) {
  3817. if (unitHasDecimal) {
  3818. return false; // only allow non-integers for smallest unit
  3819. }
  3820. if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
  3821. unitHasDecimal = true;
  3822. }
  3823. }
  3824. }
  3825. return true;
  3826. }
  3827. function isValid$1() {
  3828. return this._isValid;
  3829. }
  3830. function createInvalid$1() {
  3831. return createDuration(NaN);
  3832. }
  3833. function Duration(duration) {
  3834. var normalizedInput = normalizeObjectUnits(duration),
  3835. years = normalizedInput.year || 0,
  3836. quarters = normalizedInput.quarter || 0,
  3837. months = normalizedInput.month || 0,
  3838. weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
  3839. days = normalizedInput.day || 0,
  3840. hours = normalizedInput.hour || 0,
  3841. minutes = normalizedInput.minute || 0,
  3842. seconds = normalizedInput.second || 0,
  3843. milliseconds = normalizedInput.millisecond || 0;
  3844. this._isValid = isDurationValid(normalizedInput);
  3845. // representation for dateAddRemove
  3846. this._milliseconds =
  3847. +milliseconds +
  3848. seconds * 1e3 + // 1000
  3849. minutes * 6e4 + // 1000 * 60
  3850. hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
  3851. // Because of dateAddRemove treats 24 hours as different from a
  3852. // day when working around DST, we need to store them separately
  3853. this._days = +days + weeks * 7;
  3854. // It is impossible to translate months into days without knowing
  3855. // which months you are are talking about, so we have to store
  3856. // it separately.
  3857. this._months = +months + quarters * 3 + years * 12;
  3858. this._data = {};
  3859. this._locale = getLocale();
  3860. this._bubble();
  3861. }
  3862. function isDuration(obj) {
  3863. return obj instanceof Duration;
  3864. }
  3865. function absRound(number) {
  3866. if (number < 0) {
  3867. return Math.round(-1 * number) * -1;
  3868. } else {
  3869. return Math.round(number);
  3870. }
  3871. }
  3872. // compare two arrays, return the number of differences
  3873. function compareArrays(array1, array2, dontConvert) {
  3874. var len = Math.min(array1.length, array2.length),
  3875. lengthDiff = Math.abs(array1.length - array2.length),
  3876. diffs = 0,
  3877. i;
  3878. for (i = 0; i < len; i++) {
  3879. if (
  3880. (dontConvert && array1[i] !== array2[i]) ||
  3881. (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))
  3882. ) {
  3883. diffs++;
  3884. }
  3885. }
  3886. return diffs + lengthDiff;
  3887. }
  3888. // FORMATTING
  3889. function offset(token, separator) {
  3890. addFormatToken(token, 0, 0, function () {
  3891. var offset = this.utcOffset(),
  3892. sign = '+';
  3893. if (offset < 0) {
  3894. offset = -offset;
  3895. sign = '-';
  3896. }
  3897. return (
  3898. sign +
  3899. zeroFill(~~(offset / 60), 2) +
  3900. separator +
  3901. zeroFill(~~offset % 60, 2)
  3902. );
  3903. });
  3904. }
  3905. offset('Z', ':');
  3906. offset('ZZ', '');
  3907. // PARSING
  3908. addRegexToken('Z', matchShortOffset);
  3909. addRegexToken('ZZ', matchShortOffset);
  3910. addParseToken(['Z', 'ZZ'], function (input, array, config) {
  3911. config._useUTC = true;
  3912. config._tzm = offsetFromString(matchShortOffset, input);
  3913. });
  3914. // HELPERS
  3915. // timezone chunker
  3916. // '+10:00' > ['10', '00']
  3917. // '-1530' > ['-15', '30']
  3918. var chunkOffset = /([\+\-]|\d\d)/gi;
  3919. function offsetFromString(matcher, string) {
  3920. var matches = (string || '').match(matcher),
  3921. chunk,
  3922. parts,
  3923. minutes;
  3924. if (matches === null) {
  3925. return null;
  3926. }
  3927. chunk = matches[matches.length - 1] || [];
  3928. parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
  3929. minutes = +(parts[1] * 60) + toInt(parts[2]);
  3930. return minutes === 0 ? 0 : parts[0] === '+' ? minutes : -minutes;
  3931. }
  3932. // Return a moment from input, that is local/utc/zone equivalent to model.
  3933. function cloneWithOffset(input, model) {
  3934. var res, diff;
  3935. if (model._isUTC) {
  3936. res = model.clone();
  3937. diff =
  3938. (isMoment(input) || isDate(input)
  3939. ? input.valueOf()
  3940. : createLocal(input).valueOf()) - res.valueOf();
  3941. // Use low-level api, because this fn is low-level api.
  3942. res._d.setTime(res._d.valueOf() + diff);
  3943. hooks.updateOffset(res, false);
  3944. return res;
  3945. } else {
  3946. return createLocal(input).local();
  3947. }
  3948. }
  3949. function getDateOffset(m) {
  3950. // On Firefox.24 Date#getTimezoneOffset returns a floating point.
  3951. // https://github.com/moment/moment/pull/1871
  3952. return -Math.round(m._d.getTimezoneOffset());
  3953. }
  3954. // HOOKS
  3955. // This function will be called whenever a moment is mutated.
  3956. // It is intended to keep the offset in sync with the timezone.
  3957. hooks.updateOffset = function () {};
  3958. // MOMENTS
  3959. // keepLocalTime = true means only change the timezone, without
  3960. // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
  3961. // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
  3962. // +0200, so we adjust the time as needed, to be valid.
  3963. //
  3964. // Keeping the time actually adds/subtracts (one hour)
  3965. // from the actual represented time. That is why we call updateOffset
  3966. // a second time. In case it wants us to change the offset again
  3967. // _changeInProgress == true case, then we have to adjust, because
  3968. // there is no such time in the given timezone.
  3969. function getSetOffset(input, keepLocalTime, keepMinutes) {
  3970. var offset = this._offset || 0,
  3971. localAdjust;
  3972. if (!this.isValid()) {
  3973. return input != null ? this : NaN;
  3974. }
  3975. if (input != null) {
  3976. if (typeof input === 'string') {
  3977. input = offsetFromString(matchShortOffset, input);
  3978. if (input === null) {
  3979. return this;
  3980. }
  3981. } else if (Math.abs(input) < 16 && !keepMinutes) {
  3982. input = input * 60;
  3983. }
  3984. if (!this._isUTC && keepLocalTime) {
  3985. localAdjust = getDateOffset(this);
  3986. }
  3987. this._offset = input;
  3988. this._isUTC = true;
  3989. if (localAdjust != null) {
  3990. this.add(localAdjust, 'm');
  3991. }
  3992. if (offset !== input) {
  3993. if (!keepLocalTime || this._changeInProgress) {
  3994. addSubtract(
  3995. this,
  3996. createDuration(input - offset, 'm'),
  3997. 1,
  3998. false
  3999. );
  4000. } else if (!this._changeInProgress) {
  4001. this._changeInProgress = true;
  4002. hooks.updateOffset(this, true);
  4003. this._changeInProgress = null;
  4004. }
  4005. }
  4006. return this;
  4007. } else {
  4008. return this._isUTC ? offset : getDateOffset(this);
  4009. }
  4010. }
  4011. function getSetZone(input, keepLocalTime) {
  4012. if (input != null) {
  4013. if (typeof input !== 'string') {
  4014. input = -input;
  4015. }
  4016. this.utcOffset(input, keepLocalTime);
  4017. return this;
  4018. } else {
  4019. return -this.utcOffset();
  4020. }
  4021. }
  4022. function setOffsetToUTC(keepLocalTime) {
  4023. return this.utcOffset(0, keepLocalTime);
  4024. }
  4025. function setOffsetToLocal(keepLocalTime) {
  4026. if (this._isUTC) {
  4027. this.utcOffset(0, keepLocalTime);
  4028. this._isUTC = false;
  4029. if (keepLocalTime) {
  4030. this.subtract(getDateOffset(this), 'm');
  4031. }
  4032. }
  4033. return this;
  4034. }
  4035. function setOffsetToParsedOffset() {
  4036. if (this._tzm != null) {
  4037. this.utcOffset(this._tzm, false, true);
  4038. } else if (typeof this._i === 'string') {
  4039. var tZone = offsetFromString(matchOffset, this._i);
  4040. if (tZone != null) {
  4041. this.utcOffset(tZone);
  4042. } else {
  4043. this.utcOffset(0, true);
  4044. }
  4045. }
  4046. return this;
  4047. }
  4048. function hasAlignedHourOffset(input) {
  4049. if (!this.isValid()) {
  4050. return false;
  4051. }
  4052. input = input ? createLocal(input).utcOffset() : 0;
  4053. return (this.utcOffset() - input) % 60 === 0;
  4054. }
  4055. function isDaylightSavingTime() {
  4056. return (
  4057. this.utcOffset() > this.clone().month(0).utcOffset() ||
  4058. this.utcOffset() > this.clone().month(5).utcOffset()
  4059. );
  4060. }
  4061. function isDaylightSavingTimeShifted() {
  4062. if (!isUndefined(this._isDSTShifted)) {
  4063. return this._isDSTShifted;
  4064. }
  4065. var c = {},
  4066. other;
  4067. copyConfig(c, this);
  4068. c = prepareConfig(c);
  4069. if (c._a) {
  4070. other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
  4071. this._isDSTShifted =
  4072. this.isValid() && compareArrays(c._a, other.toArray()) > 0;
  4073. } else {
  4074. this._isDSTShifted = false;
  4075. }
  4076. return this._isDSTShifted;
  4077. }
  4078. function isLocal() {
  4079. return this.isValid() ? !this._isUTC : false;
  4080. }
  4081. function isUtcOffset() {
  4082. return this.isValid() ? this._isUTC : false;
  4083. }
  4084. function isUtc() {
  4085. return this.isValid() ? this._isUTC && this._offset === 0 : false;
  4086. }
  4087. // ASP.NET json date format regex
  4088. var aspNetRegex = /^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,
  4089. // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
  4090. // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
  4091. // and further modified to allow for strings containing both week and day
  4092. isoRegex =
  4093. /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
  4094. function createDuration(input, key) {
  4095. var duration = input,
  4096. // matching against regexp is expensive, do it on demand
  4097. match = null,
  4098. sign,
  4099. ret,
  4100. diffRes;
  4101. if (isDuration(input)) {
  4102. duration = {
  4103. ms: input._milliseconds,
  4104. d: input._days,
  4105. M: input._months,
  4106. };
  4107. } else if (isNumber(input) || !isNaN(+input)) {
  4108. duration = {};
  4109. if (key) {
  4110. duration[key] = +input;
  4111. } else {
  4112. duration.milliseconds = +input;
  4113. }
  4114. } else if ((match = aspNetRegex.exec(input))) {
  4115. sign = match[1] === '-' ? -1 : 1;
  4116. duration = {
  4117. y: 0,
  4118. d: toInt(match[DATE]) * sign,
  4119. h: toInt(match[HOUR]) * sign,
  4120. m: toInt(match[MINUTE]) * sign,
  4121. s: toInt(match[SECOND]) * sign,
  4122. ms: toInt(absRound(match[MILLISECOND] * 1000)) * sign, // the millisecond decimal point is included in the match
  4123. };
  4124. } else if ((match = isoRegex.exec(input))) {
  4125. sign = match[1] === '-' ? -1 : 1;
  4126. duration = {
  4127. y: parseIso(match[2], sign),
  4128. M: parseIso(match[3], sign),
  4129. w: parseIso(match[4], sign),
  4130. d: parseIso(match[5], sign),
  4131. h: parseIso(match[6], sign),
  4132. m: parseIso(match[7], sign),
  4133. s: parseIso(match[8], sign),
  4134. };
  4135. } else if (duration == null) {
  4136. // checks for null or undefined
  4137. duration = {};
  4138. } else if (
  4139. typeof duration === 'object' &&
  4140. ('from' in duration || 'to' in duration)
  4141. ) {
  4142. diffRes = momentsDifference(
  4143. createLocal(duration.from),
  4144. createLocal(duration.to)
  4145. );
  4146. duration = {};
  4147. duration.ms = diffRes.milliseconds;
  4148. duration.M = diffRes.months;
  4149. }
  4150. ret = new Duration(duration);
  4151. if (isDuration(input) && hasOwnProp(input, '_locale')) {
  4152. ret._locale = input._locale;
  4153. }
  4154. if (isDuration(input) && hasOwnProp(input, '_isValid')) {
  4155. ret._isValid = input._isValid;
  4156. }
  4157. return ret;
  4158. }
  4159. createDuration.fn = Duration.prototype;
  4160. createDuration.invalid = createInvalid$1;
  4161. function parseIso(inp, sign) {
  4162. // We'd normally use ~~inp for this, but unfortunately it also
  4163. // converts floats to ints.
  4164. // inp may be undefined, so careful calling replace on it.
  4165. var res = inp && parseFloat(inp.replace(',', '.'));
  4166. // apply sign while we're at it
  4167. return (isNaN(res) ? 0 : res) * sign;
  4168. }
  4169. function positiveMomentsDifference(base, other) {
  4170. var res = {};
  4171. res.months =
  4172. other.month() - base.month() + (other.year() - base.year()) * 12;
  4173. if (base.clone().add(res.months, 'M').isAfter(other)) {
  4174. --res.months;
  4175. }
  4176. res.milliseconds = +other - +base.clone().add(res.months, 'M');
  4177. return res;
  4178. }
  4179. function momentsDifference(base, other) {
  4180. var res;
  4181. if (!(base.isValid() && other.isValid())) {
  4182. return { milliseconds: 0, months: 0 };
  4183. }
  4184. other = cloneWithOffset(other, base);
  4185. if (base.isBefore(other)) {
  4186. res = positiveMomentsDifference(base, other);
  4187. } else {
  4188. res = positiveMomentsDifference(other, base);
  4189. res.milliseconds = -res.milliseconds;
  4190. res.months = -res.months;
  4191. }
  4192. return res;
  4193. }
  4194. // TODO: remove 'name' arg after deprecation is removed
  4195. function createAdder(direction, name) {
  4196. return function (val, period) {
  4197. var dur, tmp;
  4198. //invert the arguments, but complain about it
  4199. if (period !== null && !isNaN(+period)) {
  4200. deprecateSimple(
  4201. name,
  4202. 'moment().' +
  4203. name +
  4204. '(period, number) is deprecated. Please use moment().' +
  4205. name +
  4206. '(number, period). ' +
  4207. 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.'
  4208. );
  4209. tmp = val;
  4210. val = period;
  4211. period = tmp;
  4212. }
  4213. dur = createDuration(val, period);
  4214. addSubtract(this, dur, direction);
  4215. return this;
  4216. };
  4217. }
  4218. function addSubtract(mom, duration, isAdding, updateOffset) {
  4219. var milliseconds = duration._milliseconds,
  4220. days = absRound(duration._days),
  4221. months = absRound(duration._months);
  4222. if (!mom.isValid()) {
  4223. // No op
  4224. return;
  4225. }
  4226. updateOffset = updateOffset == null ? true : updateOffset;
  4227. if (months) {
  4228. setMonth(mom, get(mom, 'Month') + months * isAdding);
  4229. }
  4230. if (days) {
  4231. set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
  4232. }
  4233. if (milliseconds) {
  4234. mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
  4235. }
  4236. if (updateOffset) {
  4237. hooks.updateOffset(mom, days || months);
  4238. }
  4239. }
  4240. var add = createAdder(1, 'add'),
  4241. subtract = createAdder(-1, 'subtract');
  4242. function isString(input) {
  4243. return typeof input === 'string' || input instanceof String;
  4244. }
  4245. // type MomentInput = Moment | Date | string | number | (number | string)[] | MomentInputObject | void; // null | undefined
  4246. function isMomentInput(input) {
  4247. return (
  4248. isMoment(input) ||
  4249. isDate(input) ||
  4250. isString(input) ||
  4251. isNumber(input) ||
  4252. isNumberOrStringArray(input) ||
  4253. isMomentInputObject(input) ||
  4254. input === null ||
  4255. input === undefined
  4256. );
  4257. }
  4258. function isMomentInputObject(input) {
  4259. var objectTest = isObject(input) && !isObjectEmpty(input),
  4260. propertyTest = false,
  4261. properties = [
  4262. 'years',
  4263. 'year',
  4264. 'y',
  4265. 'months',
  4266. 'month',
  4267. 'M',
  4268. 'days',
  4269. 'day',
  4270. 'd',
  4271. 'dates',
  4272. 'date',
  4273. 'D',
  4274. 'hours',
  4275. 'hour',
  4276. 'h',
  4277. 'minutes',
  4278. 'minute',
  4279. 'm',
  4280. 'seconds',
  4281. 'second',
  4282. 's',
  4283. 'milliseconds',
  4284. 'millisecond',
  4285. 'ms',
  4286. ],
  4287. i,
  4288. property,
  4289. propertyLen = properties.length;
  4290. for (i = 0; i < propertyLen; i += 1) {
  4291. property = properties[i];
  4292. propertyTest = propertyTest || hasOwnProp(input, property);
  4293. }
  4294. return objectTest && propertyTest;
  4295. }
  4296. function isNumberOrStringArray(input) {
  4297. var arrayTest = isArray(input),
  4298. dataTypeTest = false;
  4299. if (arrayTest) {
  4300. dataTypeTest =
  4301. input.filter(function (item) {
  4302. return !isNumber(item) && isString(input);
  4303. }).length === 0;
  4304. }
  4305. return arrayTest && dataTypeTest;
  4306. }
  4307. function isCalendarSpec(input) {
  4308. var objectTest = isObject(input) && !isObjectEmpty(input),
  4309. propertyTest = false,
  4310. properties = [
  4311. 'sameDay',
  4312. 'nextDay',
  4313. 'lastDay',
  4314. 'nextWeek',
  4315. 'lastWeek',
  4316. 'sameElse',
  4317. ],
  4318. i,
  4319. property;
  4320. for (i = 0; i < properties.length; i += 1) {
  4321. property = properties[i];
  4322. propertyTest = propertyTest || hasOwnProp(input, property);
  4323. }
  4324. return objectTest && propertyTest;
  4325. }
  4326. function getCalendarFormat(myMoment, now) {
  4327. var diff = myMoment.diff(now, 'days', true);
  4328. return diff < -6
  4329. ? 'sameElse'
  4330. : diff < -1
  4331. ? 'lastWeek'
  4332. : diff < 0
  4333. ? 'lastDay'
  4334. : diff < 1
  4335. ? 'sameDay'
  4336. : diff < 2
  4337. ? 'nextDay'
  4338. : diff < 7
  4339. ? 'nextWeek'
  4340. : 'sameElse';
  4341. }
  4342. function calendar$1(time, formats) {
  4343. // Support for single parameter, formats only overload to the calendar function
  4344. if (arguments.length === 1) {
  4345. if (!arguments[0]) {
  4346. time = undefined;
  4347. formats = undefined;
  4348. } else if (isMomentInput(arguments[0])) {
  4349. time = arguments[0];
  4350. formats = undefined;
  4351. } else if (isCalendarSpec(arguments[0])) {
  4352. formats = arguments[0];
  4353. time = undefined;
  4354. }
  4355. }
  4356. // We want to compare the start of today, vs this.
  4357. // Getting start-of-today depends on whether we're local/utc/offset or not.
  4358. var now = time || createLocal(),
  4359. sod = cloneWithOffset(now, this).startOf('day'),
  4360. format = hooks.calendarFormat(this, sod) || 'sameElse',
  4361. output =
  4362. formats &&
  4363. (isFunction(formats[format])
  4364. ? formats[format].call(this, now)
  4365. : formats[format]);
  4366. return this.format(
  4367. output || this.localeData().calendar(format, this, createLocal(now))
  4368. );
  4369. }
  4370. function clone() {
  4371. return new Moment(this);
  4372. }
  4373. function isAfter(input, units) {
  4374. var localInput = isMoment(input) ? input : createLocal(input);
  4375. if (!(this.isValid() && localInput.isValid())) {
  4376. return false;
  4377. }
  4378. units = normalizeUnits(units) || 'millisecond';
  4379. if (units === 'millisecond') {
  4380. return this.valueOf() > localInput.valueOf();
  4381. } else {
  4382. return localInput.valueOf() < this.clone().startOf(units).valueOf();
  4383. }
  4384. }
  4385. function isBefore(input, units) {
  4386. var localInput = isMoment(input) ? input : createLocal(input);
  4387. if (!(this.isValid() && localInput.isValid())) {
  4388. return false;
  4389. }
  4390. units = normalizeUnits(units) || 'millisecond';
  4391. if (units === 'millisecond') {
  4392. return this.valueOf() < localInput.valueOf();
  4393. } else {
  4394. return this.clone().endOf(units).valueOf() < localInput.valueOf();
  4395. }
  4396. }
  4397. function isBetween(from, to, units, inclusivity) {
  4398. var localFrom = isMoment(from) ? from : createLocal(from),
  4399. localTo = isMoment(to) ? to : createLocal(to);
  4400. if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
  4401. return false;
  4402. }
  4403. inclusivity = inclusivity || '()';
  4404. return (
  4405. (inclusivity[0] === '('
  4406. ? this.isAfter(localFrom, units)
  4407. : !this.isBefore(localFrom, units)) &&
  4408. (inclusivity[1] === ')'
  4409. ? this.isBefore(localTo, units)
  4410. : !this.isAfter(localTo, units))
  4411. );
  4412. }
  4413. function isSame(input, units) {
  4414. var localInput = isMoment(input) ? input : createLocal(input),
  4415. inputMs;
  4416. if (!(this.isValid() && localInput.isValid())) {
  4417. return false;
  4418. }
  4419. units = normalizeUnits(units) || 'millisecond';
  4420. if (units === 'millisecond') {
  4421. return this.valueOf() === localInput.valueOf();
  4422. } else {
  4423. inputMs = localInput.valueOf();
  4424. return (
  4425. this.clone().startOf(units).valueOf() <= inputMs &&
  4426. inputMs <= this.clone().endOf(units).valueOf()
  4427. );
  4428. }
  4429. }
  4430. function isSameOrAfter(input, units) {
  4431. return this.isSame(input, units) || this.isAfter(input, units);
  4432. }
  4433. function isSameOrBefore(input, units) {
  4434. return this.isSame(input, units) || this.isBefore(input, units);
  4435. }
  4436. function diff(input, units, asFloat) {
  4437. var that, zoneDelta, output;
  4438. if (!this.isValid()) {
  4439. return NaN;
  4440. }
  4441. that = cloneWithOffset(input, this);
  4442. if (!that.isValid()) {
  4443. return NaN;
  4444. }
  4445. zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
  4446. units = normalizeUnits(units);
  4447. switch (units) {
  4448. case 'year':
  4449. output = monthDiff(this, that) / 12;
  4450. break;
  4451. case 'month':
  4452. output = monthDiff(this, that);
  4453. break;
  4454. case 'quarter':
  4455. output = monthDiff(this, that) / 3;
  4456. break;
  4457. case 'second':
  4458. output = (this - that) / 1e3;
  4459. break; // 1000
  4460. case 'minute':
  4461. output = (this - that) / 6e4;
  4462. break; // 1000 * 60
  4463. case 'hour':
  4464. output = (this - that) / 36e5;
  4465. break; // 1000 * 60 * 60
  4466. case 'day':
  4467. output = (this - that - zoneDelta) / 864e5;
  4468. break; // 1000 * 60 * 60 * 24, negate dst
  4469. case 'week':
  4470. output = (this - that - zoneDelta) / 6048e5;
  4471. break; // 1000 * 60 * 60 * 24 * 7, negate dst
  4472. default:
  4473. output = this - that;
  4474. }
  4475. return asFloat ? output : absFloor(output);
  4476. }
  4477. function monthDiff(a, b) {
  4478. if (a.date() < b.date()) {
  4479. // end-of-month calculations work correct when the start month has more
  4480. // days than the end month.
  4481. return -monthDiff(b, a);
  4482. }
  4483. // difference in months
  4484. var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month()),
  4485. // b is in (anchor - 1 month, anchor + 1 month)
  4486. anchor = a.clone().add(wholeMonthDiff, 'months'),
  4487. anchor2,
  4488. adjust;
  4489. if (b - anchor < 0) {
  4490. anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
  4491. // linear across the month
  4492. adjust = (b - anchor) / (anchor - anchor2);
  4493. } else {
  4494. anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
  4495. // linear across the month
  4496. adjust = (b - anchor) / (anchor2 - anchor);
  4497. }
  4498. //check for negative zero, return zero if negative zero
  4499. return -(wholeMonthDiff + adjust) || 0;
  4500. }
  4501. hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
  4502. hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
  4503. function toString() {
  4504. return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
  4505. }
  4506. function toISOString(keepOffset) {
  4507. if (!this.isValid()) {
  4508. return null;
  4509. }
  4510. var utc = keepOffset !== true,
  4511. m = utc ? this.clone().utc() : this;
  4512. if (m.year() < 0 || m.year() > 9999) {
  4513. return formatMoment(
  4514. m,
  4515. utc
  4516. ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]'
  4517. : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ'
  4518. );
  4519. }
  4520. if (isFunction(Date.prototype.toISOString)) {
  4521. // native implementation is ~50x faster, use it when we can
  4522. if (utc) {
  4523. return this.toDate().toISOString();
  4524. } else {
  4525. return new Date(this.valueOf() + this.utcOffset() * 60 * 1000)
  4526. .toISOString()
  4527. .replace('Z', formatMoment(m, 'Z'));
  4528. }
  4529. }
  4530. return formatMoment(
  4531. m,
  4532. utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ'
  4533. );
  4534. }
  4535. /**
  4536. * Return a human readable representation of a moment that can
  4537. * also be evaluated to get a new moment which is the same
  4538. *
  4539. * @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects
  4540. */
  4541. function inspect() {
  4542. if (!this.isValid()) {
  4543. return 'moment.invalid(/* ' + this._i + ' */)';
  4544. }
  4545. var func = 'moment',
  4546. zone = '',
  4547. prefix,
  4548. year,
  4549. datetime,
  4550. suffix;
  4551. if (!this.isLocal()) {
  4552. func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
  4553. zone = 'Z';
  4554. }
  4555. prefix = '[' + func + '("]';
  4556. year = 0 <= this.year() && this.year() <= 9999 ? 'YYYY' : 'YYYYYY';
  4557. datetime = '-MM-DD[T]HH:mm:ss.SSS';
  4558. suffix = zone + '[")]';
  4559. return this.format(prefix + year + datetime + suffix);
  4560. }
  4561. function format(inputString) {
  4562. if (!inputString) {
  4563. inputString = this.isUtc()
  4564. ? hooks.defaultFormatUtc
  4565. : hooks.defaultFormat;
  4566. }
  4567. var output = formatMoment(this, inputString);
  4568. return this.localeData().postformat(output);
  4569. }
  4570. function from(time, withoutSuffix) {
  4571. if (
  4572. this.isValid() &&
  4573. ((isMoment(time) && time.isValid()) || createLocal(time).isValid())
  4574. ) {
  4575. return createDuration({ to: this, from: time })
  4576. .locale(this.locale())
  4577. .humanize(!withoutSuffix);
  4578. } else {
  4579. return this.localeData().invalidDate();
  4580. }
  4581. }
  4582. function fromNow(withoutSuffix) {
  4583. return this.from(createLocal(), withoutSuffix);
  4584. }
  4585. function to(time, withoutSuffix) {
  4586. if (
  4587. this.isValid() &&
  4588. ((isMoment(time) && time.isValid()) || createLocal(time).isValid())
  4589. ) {
  4590. return createDuration({ from: this, to: time })
  4591. .locale(this.locale())
  4592. .humanize(!withoutSuffix);
  4593. } else {
  4594. return this.localeData().invalidDate();
  4595. }
  4596. }
  4597. function toNow(withoutSuffix) {
  4598. return this.to(createLocal(), withoutSuffix);
  4599. }
  4600. // If passed a locale key, it will set the locale for this
  4601. // instance. Otherwise, it will return the locale configuration
  4602. // variables for this instance.
  4603. function locale(key) {
  4604. var newLocaleData;
  4605. if (key === undefined) {
  4606. return this._locale._abbr;
  4607. } else {
  4608. newLocaleData = getLocale(key);
  4609. if (newLocaleData != null) {
  4610. this._locale = newLocaleData;
  4611. }
  4612. return this;
  4613. }
  4614. }
  4615. var lang = deprecate(
  4616. 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
  4617. function (key) {
  4618. if (key === undefined) {
  4619. return this.localeData();
  4620. } else {
  4621. return this.locale(key);
  4622. }
  4623. }
  4624. );
  4625. function localeData() {
  4626. return this._locale;
  4627. }
  4628. var MS_PER_SECOND = 1000,
  4629. MS_PER_MINUTE = 60 * MS_PER_SECOND,
  4630. MS_PER_HOUR = 60 * MS_PER_MINUTE,
  4631. MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
  4632. // actual modulo - handles negative numbers (for dates before 1970):
  4633. function mod$1(dividend, divisor) {
  4634. return ((dividend % divisor) + divisor) % divisor;
  4635. }
  4636. function localStartOfDate(y, m, d) {
  4637. // the date constructor remaps years 0-99 to 1900-1999
  4638. if (y < 100 && y >= 0) {
  4639. // preserve leap years using a full 400 year cycle, then reset
  4640. return new Date(y + 400, m, d) - MS_PER_400_YEARS;
  4641. } else {
  4642. return new Date(y, m, d).valueOf();
  4643. }
  4644. }
  4645. function utcStartOfDate(y, m, d) {
  4646. // Date.UTC remaps years 0-99 to 1900-1999
  4647. if (y < 100 && y >= 0) {
  4648. // preserve leap years using a full 400 year cycle, then reset
  4649. return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
  4650. } else {
  4651. return Date.UTC(y, m, d);
  4652. }
  4653. }
  4654. function startOf(units) {
  4655. var time, startOfDate;
  4656. units = normalizeUnits(units);
  4657. if (units === undefined || units === 'millisecond' || !this.isValid()) {
  4658. return this;
  4659. }
  4660. startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
  4661. switch (units) {
  4662. case 'year':
  4663. time = startOfDate(this.year(), 0, 1);
  4664. break;
  4665. case 'quarter':
  4666. time = startOfDate(
  4667. this.year(),
  4668. this.month() - (this.month() % 3),
  4669. 1
  4670. );
  4671. break;
  4672. case 'month':
  4673. time = startOfDate(this.year(), this.month(), 1);
  4674. break;
  4675. case 'week':
  4676. time = startOfDate(
  4677. this.year(),
  4678. this.month(),
  4679. this.date() - this.weekday()
  4680. );
  4681. break;
  4682. case 'isoWeek':
  4683. time = startOfDate(
  4684. this.year(),
  4685. this.month(),
  4686. this.date() - (this.isoWeekday() - 1)
  4687. );
  4688. break;
  4689. case 'day':
  4690. case 'date':
  4691. time = startOfDate(this.year(), this.month(), this.date());
  4692. break;
  4693. case 'hour':
  4694. time = this._d.valueOf();
  4695. time -= mod$1(
  4696. time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
  4697. MS_PER_HOUR
  4698. );
  4699. break;
  4700. case 'minute':
  4701. time = this._d.valueOf();
  4702. time -= mod$1(time, MS_PER_MINUTE);
  4703. break;
  4704. case 'second':
  4705. time = this._d.valueOf();
  4706. time -= mod$1(time, MS_PER_SECOND);
  4707. break;
  4708. }
  4709. this._d.setTime(time);
  4710. hooks.updateOffset(this, true);
  4711. return this;
  4712. }
  4713. function endOf(units) {
  4714. var time, startOfDate;
  4715. units = normalizeUnits(units);
  4716. if (units === undefined || units === 'millisecond' || !this.isValid()) {
  4717. return this;
  4718. }
  4719. startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
  4720. switch (units) {
  4721. case 'year':
  4722. time = startOfDate(this.year() + 1, 0, 1) - 1;
  4723. break;
  4724. case 'quarter':
  4725. time =
  4726. startOfDate(
  4727. this.year(),
  4728. this.month() - (this.month() % 3) + 3,
  4729. 1
  4730. ) - 1;
  4731. break;
  4732. case 'month':
  4733. time = startOfDate(this.year(), this.month() + 1, 1) - 1;
  4734. break;
  4735. case 'week':
  4736. time =
  4737. startOfDate(
  4738. this.year(),
  4739. this.month(),
  4740. this.date() - this.weekday() + 7
  4741. ) - 1;
  4742. break;
  4743. case 'isoWeek':
  4744. time =
  4745. startOfDate(
  4746. this.year(),
  4747. this.month(),
  4748. this.date() - (this.isoWeekday() - 1) + 7
  4749. ) - 1;
  4750. break;
  4751. case 'day':
  4752. case 'date':
  4753. time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
  4754. break;
  4755. case 'hour':
  4756. time = this._d.valueOf();
  4757. time +=
  4758. MS_PER_HOUR -
  4759. mod$1(
  4760. time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
  4761. MS_PER_HOUR
  4762. ) -
  4763. 1;
  4764. break;
  4765. case 'minute':
  4766. time = this._d.valueOf();
  4767. time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
  4768. break;
  4769. case 'second':
  4770. time = this._d.valueOf();
  4771. time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
  4772. break;
  4773. }
  4774. this._d.setTime(time);
  4775. hooks.updateOffset(this, true);
  4776. return this;
  4777. }
  4778. function valueOf() {
  4779. return this._d.valueOf() - (this._offset || 0) * 60000;
  4780. }
  4781. function unix() {
  4782. return Math.floor(this.valueOf() / 1000);
  4783. }
  4784. function toDate() {
  4785. return new Date(this.valueOf());
  4786. }
  4787. function toArray() {
  4788. var m = this;
  4789. return [
  4790. m.year(),
  4791. m.month(),
  4792. m.date(),
  4793. m.hour(),
  4794. m.minute(),
  4795. m.second(),
  4796. m.millisecond(),
  4797. ];
  4798. }
  4799. function toObject() {
  4800. var m = this;
  4801. return {
  4802. years: m.year(),
  4803. months: m.month(),
  4804. date: m.date(),
  4805. hours: m.hours(),
  4806. minutes: m.minutes(),
  4807. seconds: m.seconds(),
  4808. milliseconds: m.milliseconds(),
  4809. };
  4810. }
  4811. function toJSON() {
  4812. // new Date(NaN).toJSON() === null
  4813. return this.isValid() ? this.toISOString() : null;
  4814. }
  4815. function isValid$2() {
  4816. return isValid(this);
  4817. }
  4818. function parsingFlags() {
  4819. return extend({}, getParsingFlags(this));
  4820. }
  4821. function invalidAt() {
  4822. return getParsingFlags(this).overflow;
  4823. }
  4824. function creationData() {
  4825. return {
  4826. input: this._i,
  4827. format: this._f,
  4828. locale: this._locale,
  4829. isUTC: this._isUTC,
  4830. strict: this._strict,
  4831. };
  4832. }
  4833. addFormatToken('N', 0, 0, 'eraAbbr');
  4834. addFormatToken('NN', 0, 0, 'eraAbbr');
  4835. addFormatToken('NNN', 0, 0, 'eraAbbr');
  4836. addFormatToken('NNNN', 0, 0, 'eraName');
  4837. addFormatToken('NNNNN', 0, 0, 'eraNarrow');
  4838. addFormatToken('y', ['y', 1], 'yo', 'eraYear');
  4839. addFormatToken('y', ['yy', 2], 0, 'eraYear');
  4840. addFormatToken('y', ['yyy', 3], 0, 'eraYear');
  4841. addFormatToken('y', ['yyyy', 4], 0, 'eraYear');
  4842. addRegexToken('N', matchEraAbbr);
  4843. addRegexToken('NN', matchEraAbbr);
  4844. addRegexToken('NNN', matchEraAbbr);
  4845. addRegexToken('NNNN', matchEraName);
  4846. addRegexToken('NNNNN', matchEraNarrow);
  4847. addParseToken(
  4848. ['N', 'NN', 'NNN', 'NNNN', 'NNNNN'],
  4849. function (input, array, config, token) {
  4850. var era = config._locale.erasParse(input, token, config._strict);
  4851. if (era) {
  4852. getParsingFlags(config).era = era;
  4853. } else {
  4854. getParsingFlags(config).invalidEra = input;
  4855. }
  4856. }
  4857. );
  4858. addRegexToken('y', matchUnsigned);
  4859. addRegexToken('yy', matchUnsigned);
  4860. addRegexToken('yyy', matchUnsigned);
  4861. addRegexToken('yyyy', matchUnsigned);
  4862. addRegexToken('yo', matchEraYearOrdinal);
  4863. addParseToken(['y', 'yy', 'yyy', 'yyyy'], YEAR);
  4864. addParseToken(['yo'], function (input, array, config, token) {
  4865. var match;
  4866. if (config._locale._eraYearOrdinalRegex) {
  4867. match = input.match(config._locale._eraYearOrdinalRegex);
  4868. }
  4869. if (config._locale.eraYearOrdinalParse) {
  4870. array[YEAR] = config._locale.eraYearOrdinalParse(input, match);
  4871. } else {
  4872. array[YEAR] = parseInt(input, 10);
  4873. }
  4874. });
  4875. function localeEras(m, format) {
  4876. var i,
  4877. l,
  4878. date,
  4879. eras = this._eras || getLocale('en')._eras;
  4880. for (i = 0, l = eras.length; i < l; ++i) {
  4881. switch (typeof eras[i].since) {
  4882. case 'string':
  4883. // truncate time
  4884. date = hooks(eras[i].since).startOf('day');
  4885. eras[i].since = date.valueOf();
  4886. break;
  4887. }
  4888. switch (typeof eras[i].until) {
  4889. case 'undefined':
  4890. eras[i].until = +Infinity;
  4891. break;
  4892. case 'string':
  4893. // truncate time
  4894. date = hooks(eras[i].until).startOf('day').valueOf();
  4895. eras[i].until = date.valueOf();
  4896. break;
  4897. }
  4898. }
  4899. return eras;
  4900. }
  4901. function localeErasParse(eraName, format, strict) {
  4902. var i,
  4903. l,
  4904. eras = this.eras(),
  4905. name,
  4906. abbr,
  4907. narrow;
  4908. eraName = eraName.toUpperCase();
  4909. for (i = 0, l = eras.length; i < l; ++i) {
  4910. name = eras[i].name.toUpperCase();
  4911. abbr = eras[i].abbr.toUpperCase();
  4912. narrow = eras[i].narrow.toUpperCase();
  4913. if (strict) {
  4914. switch (format) {
  4915. case 'N':
  4916. case 'NN':
  4917. case 'NNN':
  4918. if (abbr === eraName) {
  4919. return eras[i];
  4920. }
  4921. break;
  4922. case 'NNNN':
  4923. if (name === eraName) {
  4924. return eras[i];
  4925. }
  4926. break;
  4927. case 'NNNNN':
  4928. if (narrow === eraName) {
  4929. return eras[i];
  4930. }
  4931. break;
  4932. }
  4933. } else if ([name, abbr, narrow].indexOf(eraName) >= 0) {
  4934. return eras[i];
  4935. }
  4936. }
  4937. }
  4938. function localeErasConvertYear(era, year) {
  4939. var dir = era.since <= era.until ? +1 : -1;
  4940. if (year === undefined) {
  4941. return hooks(era.since).year();
  4942. } else {
  4943. return hooks(era.since).year() + (year - era.offset) * dir;
  4944. }
  4945. }
  4946. function getEraName() {
  4947. var i,
  4948. l,
  4949. val,
  4950. eras = this.localeData().eras();
  4951. for (i = 0, l = eras.length; i < l; ++i) {
  4952. // truncate time
  4953. val = this.clone().startOf('day').valueOf();
  4954. if (eras[i].since <= val && val <= eras[i].until) {
  4955. return eras[i].name;
  4956. }
  4957. if (eras[i].until <= val && val <= eras[i].since) {
  4958. return eras[i].name;
  4959. }
  4960. }
  4961. return '';
  4962. }
  4963. function getEraNarrow() {
  4964. var i,
  4965. l,
  4966. val,
  4967. eras = this.localeData().eras();
  4968. for (i = 0, l = eras.length; i < l; ++i) {
  4969. // truncate time
  4970. val = this.clone().startOf('day').valueOf();
  4971. if (eras[i].since <= val && val <= eras[i].until) {
  4972. return eras[i].narrow;
  4973. }
  4974. if (eras[i].until <= val && val <= eras[i].since) {
  4975. return eras[i].narrow;
  4976. }
  4977. }
  4978. return '';
  4979. }
  4980. function getEraAbbr() {
  4981. var i,
  4982. l,
  4983. val,
  4984. eras = this.localeData().eras();
  4985. for (i = 0, l = eras.length; i < l; ++i) {
  4986. // truncate time
  4987. val = this.clone().startOf('day').valueOf();
  4988. if (eras[i].since <= val && val <= eras[i].until) {
  4989. return eras[i].abbr;
  4990. }
  4991. if (eras[i].until <= val && val <= eras[i].since) {
  4992. return eras[i].abbr;
  4993. }
  4994. }
  4995. return '';
  4996. }
  4997. function getEraYear() {
  4998. var i,
  4999. l,
  5000. dir,
  5001. val,
  5002. eras = this.localeData().eras();
  5003. for (i = 0, l = eras.length; i < l; ++i) {
  5004. dir = eras[i].since <= eras[i].until ? +1 : -1;
  5005. // truncate time
  5006. val = this.clone().startOf('day').valueOf();
  5007. if (
  5008. (eras[i].since <= val && val <= eras[i].until) ||
  5009. (eras[i].until <= val && val <= eras[i].since)
  5010. ) {
  5011. return (
  5012. (this.year() - hooks(eras[i].since).year()) * dir +
  5013. eras[i].offset
  5014. );
  5015. }
  5016. }
  5017. return this.year();
  5018. }
  5019. function erasNameRegex(isStrict) {
  5020. if (!hasOwnProp(this, '_erasNameRegex')) {
  5021. computeErasParse.call(this);
  5022. }
  5023. return isStrict ? this._erasNameRegex : this._erasRegex;
  5024. }
  5025. function erasAbbrRegex(isStrict) {
  5026. if (!hasOwnProp(this, '_erasAbbrRegex')) {
  5027. computeErasParse.call(this);
  5028. }
  5029. return isStrict ? this._erasAbbrRegex : this._erasRegex;
  5030. }
  5031. function erasNarrowRegex(isStrict) {
  5032. if (!hasOwnProp(this, '_erasNarrowRegex')) {
  5033. computeErasParse.call(this);
  5034. }
  5035. return isStrict ? this._erasNarrowRegex : this._erasRegex;
  5036. }
  5037. function matchEraAbbr(isStrict, locale) {
  5038. return locale.erasAbbrRegex(isStrict);
  5039. }
  5040. function matchEraName(isStrict, locale) {
  5041. return locale.erasNameRegex(isStrict);
  5042. }
  5043. function matchEraNarrow(isStrict, locale) {
  5044. return locale.erasNarrowRegex(isStrict);
  5045. }
  5046. function matchEraYearOrdinal(isStrict, locale) {
  5047. return locale._eraYearOrdinalRegex || matchUnsigned;
  5048. }
  5049. function computeErasParse() {
  5050. var abbrPieces = [],
  5051. namePieces = [],
  5052. narrowPieces = [],
  5053. mixedPieces = [],
  5054. i,
  5055. l,
  5056. erasName,
  5057. erasAbbr,
  5058. erasNarrow,
  5059. eras = this.eras();
  5060. for (i = 0, l = eras.length; i < l; ++i) {
  5061. erasName = regexEscape(eras[i].name);
  5062. erasAbbr = regexEscape(eras[i].abbr);
  5063. erasNarrow = regexEscape(eras[i].narrow);
  5064. namePieces.push(erasName);
  5065. abbrPieces.push(erasAbbr);
  5066. narrowPieces.push(erasNarrow);
  5067. mixedPieces.push(erasName);
  5068. mixedPieces.push(erasAbbr);
  5069. mixedPieces.push(erasNarrow);
  5070. }
  5071. this._erasRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  5072. this._erasNameRegex = new RegExp('^(' + namePieces.join('|') + ')', 'i');
  5073. this._erasAbbrRegex = new RegExp('^(' + abbrPieces.join('|') + ')', 'i');
  5074. this._erasNarrowRegex = new RegExp(
  5075. '^(' + narrowPieces.join('|') + ')',
  5076. 'i'
  5077. );
  5078. }
  5079. // FORMATTING
  5080. addFormatToken(0, ['gg', 2], 0, function () {
  5081. return this.weekYear() % 100;
  5082. });
  5083. addFormatToken(0, ['GG', 2], 0, function () {
  5084. return this.isoWeekYear() % 100;
  5085. });
  5086. function addWeekYearFormatToken(token, getter) {
  5087. addFormatToken(0, [token, token.length], 0, getter);
  5088. }
  5089. addWeekYearFormatToken('gggg', 'weekYear');
  5090. addWeekYearFormatToken('ggggg', 'weekYear');
  5091. addWeekYearFormatToken('GGGG', 'isoWeekYear');
  5092. addWeekYearFormatToken('GGGGG', 'isoWeekYear');
  5093. // ALIASES
  5094. // PARSING
  5095. addRegexToken('G', matchSigned);
  5096. addRegexToken('g', matchSigned);
  5097. addRegexToken('GG', match1to2, match2);
  5098. addRegexToken('gg', match1to2, match2);
  5099. addRegexToken('GGGG', match1to4, match4);
  5100. addRegexToken('gggg', match1to4, match4);
  5101. addRegexToken('GGGGG', match1to6, match6);
  5102. addRegexToken('ggggg', match1to6, match6);
  5103. addWeekParseToken(
  5104. ['gggg', 'ggggg', 'GGGG', 'GGGGG'],
  5105. function (input, week, config, token) {
  5106. week[token.substr(0, 2)] = toInt(input);
  5107. }
  5108. );
  5109. addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
  5110. week[token] = hooks.parseTwoDigitYear(input);
  5111. });
  5112. // MOMENTS
  5113. function getSetWeekYear(input) {
  5114. return getSetWeekYearHelper.call(
  5115. this,
  5116. input,
  5117. this.week(),
  5118. this.weekday() + this.localeData()._week.dow,
  5119. this.localeData()._week.dow,
  5120. this.localeData()._week.doy
  5121. );
  5122. }
  5123. function getSetISOWeekYear(input) {
  5124. return getSetWeekYearHelper.call(
  5125. this,
  5126. input,
  5127. this.isoWeek(),
  5128. this.isoWeekday(),
  5129. 1,
  5130. 4
  5131. );
  5132. }
  5133. function getISOWeeksInYear() {
  5134. return weeksInYear(this.year(), 1, 4);
  5135. }
  5136. function getISOWeeksInISOWeekYear() {
  5137. return weeksInYear(this.isoWeekYear(), 1, 4);
  5138. }
  5139. function getWeeksInYear() {
  5140. var weekInfo = this.localeData()._week;
  5141. return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
  5142. }
  5143. function getWeeksInWeekYear() {
  5144. var weekInfo = this.localeData()._week;
  5145. return weeksInYear(this.weekYear(), weekInfo.dow, weekInfo.doy);
  5146. }
  5147. function getSetWeekYearHelper(input, week, weekday, dow, doy) {
  5148. var weeksTarget;
  5149. if (input == null) {
  5150. return weekOfYear(this, dow, doy).year;
  5151. } else {
  5152. weeksTarget = weeksInYear(input, dow, doy);
  5153. if (week > weeksTarget) {
  5154. week = weeksTarget;
  5155. }
  5156. return setWeekAll.call(this, input, week, weekday, dow, doy);
  5157. }
  5158. }
  5159. function setWeekAll(weekYear, week, weekday, dow, doy) {
  5160. var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
  5161. date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
  5162. this.year(date.getUTCFullYear());
  5163. this.month(date.getUTCMonth());
  5164. this.date(date.getUTCDate());
  5165. return this;
  5166. }
  5167. // FORMATTING
  5168. addFormatToken('Q', 0, 'Qo', 'quarter');
  5169. // PARSING
  5170. addRegexToken('Q', match1);
  5171. addParseToken('Q', function (input, array) {
  5172. array[MONTH] = (toInt(input) - 1) * 3;
  5173. });
  5174. // MOMENTS
  5175. function getSetQuarter(input) {
  5176. return input == null
  5177. ? Math.ceil((this.month() + 1) / 3)
  5178. : this.month((input - 1) * 3 + (this.month() % 3));
  5179. }
  5180. // FORMATTING
  5181. addFormatToken('D', ['DD', 2], 'Do', 'date');
  5182. // PARSING
  5183. addRegexToken('D', match1to2, match1to2NoLeadingZero);
  5184. addRegexToken('DD', match1to2, match2);
  5185. addRegexToken('Do', function (isStrict, locale) {
  5186. // TODO: Remove "ordinalParse" fallback in next major release.
  5187. return isStrict
  5188. ? locale._dayOfMonthOrdinalParse || locale._ordinalParse
  5189. : locale._dayOfMonthOrdinalParseLenient;
  5190. });
  5191. addParseToken(['D', 'DD'], DATE);
  5192. addParseToken('Do', function (input, array) {
  5193. array[DATE] = toInt(input.match(match1to2)[0]);
  5194. });
  5195. // MOMENTS
  5196. var getSetDayOfMonth = makeGetSet('Date', true);
  5197. // FORMATTING
  5198. addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
  5199. // PARSING
  5200. addRegexToken('DDD', match1to3);
  5201. addRegexToken('DDDD', match3);
  5202. addParseToken(['DDD', 'DDDD'], function (input, array, config) {
  5203. config._dayOfYear = toInt(input);
  5204. });
  5205. // HELPERS
  5206. // MOMENTS
  5207. function getSetDayOfYear(input) {
  5208. var dayOfYear =
  5209. Math.round(
  5210. (this.clone().startOf('day') - this.clone().startOf('year')) / 864e5
  5211. ) + 1;
  5212. return input == null ? dayOfYear : this.add(input - dayOfYear, 'd');
  5213. }
  5214. // FORMATTING
  5215. addFormatToken('m', ['mm', 2], 0, 'minute');
  5216. // PARSING
  5217. addRegexToken('m', match1to2, match1to2HasZero);
  5218. addRegexToken('mm', match1to2, match2);
  5219. addParseToken(['m', 'mm'], MINUTE);
  5220. // MOMENTS
  5221. var getSetMinute = makeGetSet('Minutes', false);
  5222. // FORMATTING
  5223. addFormatToken('s', ['ss', 2], 0, 'second');
  5224. // PARSING
  5225. addRegexToken('s', match1to2, match1to2HasZero);
  5226. addRegexToken('ss', match1to2, match2);
  5227. addParseToken(['s', 'ss'], SECOND);
  5228. // MOMENTS
  5229. var getSetSecond = makeGetSet('Seconds', false);
  5230. // FORMATTING
  5231. addFormatToken('S', 0, 0, function () {
  5232. return ~~(this.millisecond() / 100);
  5233. });
  5234. addFormatToken(0, ['SS', 2], 0, function () {
  5235. return ~~(this.millisecond() / 10);
  5236. });
  5237. addFormatToken(0, ['SSS', 3], 0, 'millisecond');
  5238. addFormatToken(0, ['SSSS', 4], 0, function () {
  5239. return this.millisecond() * 10;
  5240. });
  5241. addFormatToken(0, ['SSSSS', 5], 0, function () {
  5242. return this.millisecond() * 100;
  5243. });
  5244. addFormatToken(0, ['SSSSSS', 6], 0, function () {
  5245. return this.millisecond() * 1000;
  5246. });
  5247. addFormatToken(0, ['SSSSSSS', 7], 0, function () {
  5248. return this.millisecond() * 10000;
  5249. });
  5250. addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
  5251. return this.millisecond() * 100000;
  5252. });
  5253. addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
  5254. return this.millisecond() * 1000000;
  5255. });
  5256. // PARSING
  5257. addRegexToken('S', match1to3, match1);
  5258. addRegexToken('SS', match1to3, match2);
  5259. addRegexToken('SSS', match1to3, match3);
  5260. var token, getSetMillisecond;
  5261. for (token = 'SSSS'; token.length <= 9; token += 'S') {
  5262. addRegexToken(token, matchUnsigned);
  5263. }
  5264. function parseMs(input, array) {
  5265. array[MILLISECOND] = toInt(('0.' + input) * 1000);
  5266. }
  5267. for (token = 'S'; token.length <= 9; token += 'S') {
  5268. addParseToken(token, parseMs);
  5269. }
  5270. getSetMillisecond = makeGetSet('Milliseconds', false);
  5271. // FORMATTING
  5272. addFormatToken('z', 0, 0, 'zoneAbbr');
  5273. addFormatToken('zz', 0, 0, 'zoneName');
  5274. // MOMENTS
  5275. function getZoneAbbr() {
  5276. return this._isUTC ? 'UTC' : '';
  5277. }
  5278. function getZoneName() {
  5279. return this._isUTC ? 'Coordinated Universal Time' : '';
  5280. }
  5281. var proto = Moment.prototype;
  5282. proto.add = add;
  5283. proto.calendar = calendar$1;
  5284. proto.clone = clone;
  5285. proto.diff = diff;
  5286. proto.endOf = endOf;
  5287. proto.format = format;
  5288. proto.from = from;
  5289. proto.fromNow = fromNow;
  5290. proto.to = to;
  5291. proto.toNow = toNow;
  5292. proto.get = stringGet;
  5293. proto.invalidAt = invalidAt;
  5294. proto.isAfter = isAfter;
  5295. proto.isBefore = isBefore;
  5296. proto.isBetween = isBetween;
  5297. proto.isSame = isSame;
  5298. proto.isSameOrAfter = isSameOrAfter;
  5299. proto.isSameOrBefore = isSameOrBefore;
  5300. proto.isValid = isValid$2;
  5301. proto.lang = lang;
  5302. proto.locale = locale;
  5303. proto.localeData = localeData;
  5304. proto.max = prototypeMax;
  5305. proto.min = prototypeMin;
  5306. proto.parsingFlags = parsingFlags;
  5307. proto.set = stringSet;
  5308. proto.startOf = startOf;
  5309. proto.subtract = subtract;
  5310. proto.toArray = toArray;
  5311. proto.toObject = toObject;
  5312. proto.toDate = toDate;
  5313. proto.toISOString = toISOString;
  5314. proto.inspect = inspect;
  5315. if (typeof Symbol !== 'undefined' && Symbol.for != null) {
  5316. proto[Symbol.for('nodejs.util.inspect.custom')] = function () {
  5317. return 'Moment<' + this.format() + '>';
  5318. };
  5319. }
  5320. proto.toJSON = toJSON;
  5321. proto.toString = toString;
  5322. proto.unix = unix;
  5323. proto.valueOf = valueOf;
  5324. proto.creationData = creationData;
  5325. proto.eraName = getEraName;
  5326. proto.eraNarrow = getEraNarrow;
  5327. proto.eraAbbr = getEraAbbr;
  5328. proto.eraYear = getEraYear;
  5329. proto.year = getSetYear;
  5330. proto.isLeapYear = getIsLeapYear;
  5331. proto.weekYear = getSetWeekYear;
  5332. proto.isoWeekYear = getSetISOWeekYear;
  5333. proto.quarter = proto.quarters = getSetQuarter;
  5334. proto.month = getSetMonth;
  5335. proto.daysInMonth = getDaysInMonth;
  5336. proto.week = proto.weeks = getSetWeek;
  5337. proto.isoWeek = proto.isoWeeks = getSetISOWeek;
  5338. proto.weeksInYear = getWeeksInYear;
  5339. proto.weeksInWeekYear = getWeeksInWeekYear;
  5340. proto.isoWeeksInYear = getISOWeeksInYear;
  5341. proto.isoWeeksInISOWeekYear = getISOWeeksInISOWeekYear;
  5342. proto.date = getSetDayOfMonth;
  5343. proto.day = proto.days = getSetDayOfWeek;
  5344. proto.weekday = getSetLocaleDayOfWeek;
  5345. proto.isoWeekday = getSetISODayOfWeek;
  5346. proto.dayOfYear = getSetDayOfYear;
  5347. proto.hour = proto.hours = getSetHour;
  5348. proto.minute = proto.minutes = getSetMinute;
  5349. proto.second = proto.seconds = getSetSecond;
  5350. proto.millisecond = proto.milliseconds = getSetMillisecond;
  5351. proto.utcOffset = getSetOffset;
  5352. proto.utc = setOffsetToUTC;
  5353. proto.local = setOffsetToLocal;
  5354. proto.parseZone = setOffsetToParsedOffset;
  5355. proto.hasAlignedHourOffset = hasAlignedHourOffset;
  5356. proto.isDST = isDaylightSavingTime;
  5357. proto.isLocal = isLocal;
  5358. proto.isUtcOffset = isUtcOffset;
  5359. proto.isUtc = isUtc;
  5360. proto.isUTC = isUtc;
  5361. proto.zoneAbbr = getZoneAbbr;
  5362. proto.zoneName = getZoneName;
  5363. proto.dates = deprecate(
  5364. 'dates accessor is deprecated. Use date instead.',
  5365. getSetDayOfMonth
  5366. );
  5367. proto.months = deprecate(
  5368. 'months accessor is deprecated. Use month instead',
  5369. getSetMonth
  5370. );
  5371. proto.years = deprecate(
  5372. 'years accessor is deprecated. Use year instead',
  5373. getSetYear
  5374. );
  5375. proto.zone = deprecate(
  5376. 'moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/',
  5377. getSetZone
  5378. );
  5379. proto.isDSTShifted = deprecate(
  5380. 'isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information',
  5381. isDaylightSavingTimeShifted
  5382. );
  5383. function createUnix(input) {
  5384. return createLocal(input * 1000);
  5385. }
  5386. function createInZone() {
  5387. return createLocal.apply(null, arguments).parseZone();
  5388. }
  5389. function preParsePostFormat(string) {
  5390. return string;
  5391. }
  5392. var proto$1 = Locale.prototype;
  5393. proto$1.calendar = calendar;
  5394. proto$1.longDateFormat = longDateFormat;
  5395. proto$1.invalidDate = invalidDate;
  5396. proto$1.ordinal = ordinal;
  5397. proto$1.preparse = preParsePostFormat;
  5398. proto$1.postformat = preParsePostFormat;
  5399. proto$1.relativeTime = relativeTime;
  5400. proto$1.pastFuture = pastFuture;
  5401. proto$1.set = set;
  5402. proto$1.eras = localeEras;
  5403. proto$1.erasParse = localeErasParse;
  5404. proto$1.erasConvertYear = localeErasConvertYear;
  5405. proto$1.erasAbbrRegex = erasAbbrRegex;
  5406. proto$1.erasNameRegex = erasNameRegex;
  5407. proto$1.erasNarrowRegex = erasNarrowRegex;
  5408. proto$1.months = localeMonths;
  5409. proto$1.monthsShort = localeMonthsShort;
  5410. proto$1.monthsParse = localeMonthsParse;
  5411. proto$1.monthsRegex = monthsRegex;
  5412. proto$1.monthsShortRegex = monthsShortRegex;
  5413. proto$1.week = localeWeek;
  5414. proto$1.firstDayOfYear = localeFirstDayOfYear;
  5415. proto$1.firstDayOfWeek = localeFirstDayOfWeek;
  5416. proto$1.weekdays = localeWeekdays;
  5417. proto$1.weekdaysMin = localeWeekdaysMin;
  5418. proto$1.weekdaysShort = localeWeekdaysShort;
  5419. proto$1.weekdaysParse = localeWeekdaysParse;
  5420. proto$1.weekdaysRegex = weekdaysRegex;
  5421. proto$1.weekdaysShortRegex = weekdaysShortRegex;
  5422. proto$1.weekdaysMinRegex = weekdaysMinRegex;
  5423. proto$1.isPM = localeIsPM;
  5424. proto$1.meridiem = localeMeridiem;
  5425. function get$1(format, index, field, setter) {
  5426. var locale = getLocale(),
  5427. utc = createUTC().set(setter, index);
  5428. return locale[field](utc, format);
  5429. }
  5430. function listMonthsImpl(format, index, field) {
  5431. if (isNumber(format)) {
  5432. index = format;
  5433. format = undefined;
  5434. }
  5435. format = format || '';
  5436. if (index != null) {
  5437. return get$1(format, index, field, 'month');
  5438. }
  5439. var i,
  5440. out = [];
  5441. for (i = 0; i < 12; i++) {
  5442. out[i] = get$1(format, i, field, 'month');
  5443. }
  5444. return out;
  5445. }
  5446. // ()
  5447. // (5)
  5448. // (fmt, 5)
  5449. // (fmt)
  5450. // (true)
  5451. // (true, 5)
  5452. // (true, fmt, 5)
  5453. // (true, fmt)
  5454. function listWeekdaysImpl(localeSorted, format, index, field) {
  5455. if (typeof localeSorted === 'boolean') {
  5456. if (isNumber(format)) {
  5457. index = format;
  5458. format = undefined;
  5459. }
  5460. format = format || '';
  5461. } else {
  5462. format = localeSorted;
  5463. index = format;
  5464. localeSorted = false;
  5465. if (isNumber(format)) {
  5466. index = format;
  5467. format = undefined;
  5468. }
  5469. format = format || '';
  5470. }
  5471. var locale = getLocale(),
  5472. shift = localeSorted ? locale._week.dow : 0,
  5473. i,
  5474. out = [];
  5475. if (index != null) {
  5476. return get$1(format, (index + shift) % 7, field, 'day');
  5477. }
  5478. for (i = 0; i < 7; i++) {
  5479. out[i] = get$1(format, (i + shift) % 7, field, 'day');
  5480. }
  5481. return out;
  5482. }
  5483. function listMonths(format, index) {
  5484. return listMonthsImpl(format, index, 'months');
  5485. }
  5486. function listMonthsShort(format, index) {
  5487. return listMonthsImpl(format, index, 'monthsShort');
  5488. }
  5489. function listWeekdays(localeSorted, format, index) {
  5490. return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
  5491. }
  5492. function listWeekdaysShort(localeSorted, format, index) {
  5493. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
  5494. }
  5495. function listWeekdaysMin(localeSorted, format, index) {
  5496. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
  5497. }
  5498. getSetGlobalLocale('en', {
  5499. eras: [
  5500. {
  5501. since: '0001-01-01',
  5502. until: +Infinity,
  5503. offset: 1,
  5504. name: 'Anno Domini',
  5505. narrow: 'AD',
  5506. abbr: 'AD',
  5507. },
  5508. {
  5509. since: '0000-12-31',
  5510. until: -Infinity,
  5511. offset: 1,
  5512. name: 'Before Christ',
  5513. narrow: 'BC',
  5514. abbr: 'BC',
  5515. },
  5516. ],
  5517. dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
  5518. ordinal: function (number) {
  5519. var b = number % 10,
  5520. output =
  5521. toInt((number % 100) / 10) === 1
  5522. ? 'th'
  5523. : b === 1
  5524. ? 'st'
  5525. : b === 2
  5526. ? 'nd'
  5527. : b === 3
  5528. ? 'rd'
  5529. : 'th';
  5530. return number + output;
  5531. },
  5532. });
  5533. // Side effect imports
  5534. hooks.lang = deprecate(
  5535. 'moment.lang is deprecated. Use moment.locale instead.',
  5536. getSetGlobalLocale
  5537. );
  5538. hooks.langData = deprecate(
  5539. 'moment.langData is deprecated. Use moment.localeData instead.',
  5540. getLocale
  5541. );
  5542. var mathAbs = Math.abs;
  5543. function abs() {
  5544. var data = this._data;
  5545. this._milliseconds = mathAbs(this._milliseconds);
  5546. this._days = mathAbs(this._days);
  5547. this._months = mathAbs(this._months);
  5548. data.milliseconds = mathAbs(data.milliseconds);
  5549. data.seconds = mathAbs(data.seconds);
  5550. data.minutes = mathAbs(data.minutes);
  5551. data.hours = mathAbs(data.hours);
  5552. data.months = mathAbs(data.months);
  5553. data.years = mathAbs(data.years);
  5554. return this;
  5555. }
  5556. function addSubtract$1(duration, input, value, direction) {
  5557. var other = createDuration(input, value);
  5558. duration._milliseconds += direction * other._milliseconds;
  5559. duration._days += direction * other._days;
  5560. duration._months += direction * other._months;
  5561. return duration._bubble();
  5562. }
  5563. // supports only 2.0-style add(1, 's') or add(duration)
  5564. function add$1(input, value) {
  5565. return addSubtract$1(this, input, value, 1);
  5566. }
  5567. // supports only 2.0-style subtract(1, 's') or subtract(duration)
  5568. function subtract$1(input, value) {
  5569. return addSubtract$1(this, input, value, -1);
  5570. }
  5571. function absCeil(number) {
  5572. if (number < 0) {
  5573. return Math.floor(number);
  5574. } else {
  5575. return Math.ceil(number);
  5576. }
  5577. }
  5578. function bubble() {
  5579. var milliseconds = this._milliseconds,
  5580. days = this._days,
  5581. months = this._months,
  5582. data = this._data,
  5583. seconds,
  5584. minutes,
  5585. hours,
  5586. years,
  5587. monthsFromDays;
  5588. // if we have a mix of positive and negative values, bubble down first
  5589. // check: https://github.com/moment/moment/issues/2166
  5590. if (
  5591. !(
  5592. (milliseconds >= 0 && days >= 0 && months >= 0) ||
  5593. (milliseconds <= 0 && days <= 0 && months <= 0)
  5594. )
  5595. ) {
  5596. milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
  5597. days = 0;
  5598. months = 0;
  5599. }
  5600. // The following code bubbles up values, see the tests for
  5601. // examples of what that means.
  5602. data.milliseconds = milliseconds % 1000;
  5603. seconds = absFloor(milliseconds / 1000);
  5604. data.seconds = seconds % 60;
  5605. minutes = absFloor(seconds / 60);
  5606. data.minutes = minutes % 60;
  5607. hours = absFloor(minutes / 60);
  5608. data.hours = hours % 24;
  5609. days += absFloor(hours / 24);
  5610. // convert days to months
  5611. monthsFromDays = absFloor(daysToMonths(days));
  5612. months += monthsFromDays;
  5613. days -= absCeil(monthsToDays(monthsFromDays));
  5614. // 12 months -> 1 year
  5615. years = absFloor(months / 12);
  5616. months %= 12;
  5617. data.days = days;
  5618. data.months = months;
  5619. data.years = years;
  5620. return this;
  5621. }
  5622. function daysToMonths(days) {
  5623. // 400 years have 146097 days (taking into account leap year rules)
  5624. // 400 years have 12 months === 4800
  5625. return (days * 4800) / 146097;
  5626. }
  5627. function monthsToDays(months) {
  5628. // the reverse of daysToMonths
  5629. return (months * 146097) / 4800;
  5630. }
  5631. function as(units) {
  5632. if (!this.isValid()) {
  5633. return NaN;
  5634. }
  5635. var days,
  5636. months,
  5637. milliseconds = this._milliseconds;
  5638. units = normalizeUnits(units);
  5639. if (units === 'month' || units === 'quarter' || units === 'year') {
  5640. days = this._days + milliseconds / 864e5;
  5641. months = this._months + daysToMonths(days);
  5642. switch (units) {
  5643. case 'month':
  5644. return months;
  5645. case 'quarter':
  5646. return months / 3;
  5647. case 'year':
  5648. return months / 12;
  5649. }
  5650. } else {
  5651. // handle milliseconds separately because of floating point math errors (issue #1867)
  5652. days = this._days + Math.round(monthsToDays(this._months));
  5653. switch (units) {
  5654. case 'week':
  5655. return days / 7 + milliseconds / 6048e5;
  5656. case 'day':
  5657. return days + milliseconds / 864e5;
  5658. case 'hour':
  5659. return days * 24 + milliseconds / 36e5;
  5660. case 'minute':
  5661. return days * 1440 + milliseconds / 6e4;
  5662. case 'second':
  5663. return days * 86400 + milliseconds / 1000;
  5664. // Math.floor prevents floating point math errors here
  5665. case 'millisecond':
  5666. return Math.floor(days * 864e5) + milliseconds;
  5667. default:
  5668. throw new Error('Unknown unit ' + units);
  5669. }
  5670. }
  5671. }
  5672. function makeAs(alias) {
  5673. return function () {
  5674. return this.as(alias);
  5675. };
  5676. }
  5677. var asMilliseconds = makeAs('ms'),
  5678. asSeconds = makeAs('s'),
  5679. asMinutes = makeAs('m'),
  5680. asHours = makeAs('h'),
  5681. asDays = makeAs('d'),
  5682. asWeeks = makeAs('w'),
  5683. asMonths = makeAs('M'),
  5684. asQuarters = makeAs('Q'),
  5685. asYears = makeAs('y'),
  5686. valueOf$1 = asMilliseconds;
  5687. function clone$1() {
  5688. return createDuration(this);
  5689. }
  5690. function get$2(units) {
  5691. units = normalizeUnits(units);
  5692. return this.isValid() ? this[units + 's']() : NaN;
  5693. }
  5694. function makeGetter(name) {
  5695. return function () {
  5696. return this.isValid() ? this._data[name] : NaN;
  5697. };
  5698. }
  5699. var milliseconds = makeGetter('milliseconds'),
  5700. seconds = makeGetter('seconds'),
  5701. minutes = makeGetter('minutes'),
  5702. hours = makeGetter('hours'),
  5703. days = makeGetter('days'),
  5704. months = makeGetter('months'),
  5705. years = makeGetter('years');
  5706. function weeks() {
  5707. return absFloor(this.days() / 7);
  5708. }
  5709. var round = Math.round,
  5710. thresholds = {
  5711. ss: 44, // a few seconds to seconds
  5712. s: 45, // seconds to minute
  5713. m: 45, // minutes to hour
  5714. h: 22, // hours to day
  5715. d: 26, // days to month/week
  5716. w: null, // weeks to month
  5717. M: 11, // months to year
  5718. };
  5719. // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
  5720. function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
  5721. return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
  5722. }
  5723. function relativeTime$1(posNegDuration, withoutSuffix, thresholds, locale) {
  5724. var duration = createDuration(posNegDuration).abs(),
  5725. seconds = round(duration.as('s')),
  5726. minutes = round(duration.as('m')),
  5727. hours = round(duration.as('h')),
  5728. days = round(duration.as('d')),
  5729. months = round(duration.as('M')),
  5730. weeks = round(duration.as('w')),
  5731. years = round(duration.as('y')),
  5732. a =
  5733. (seconds <= thresholds.ss && ['s', seconds]) ||
  5734. (seconds < thresholds.s && ['ss', seconds]) ||
  5735. (minutes <= 1 && ['m']) ||
  5736. (minutes < thresholds.m && ['mm', minutes]) ||
  5737. (hours <= 1 && ['h']) ||
  5738. (hours < thresholds.h && ['hh', hours]) ||
  5739. (days <= 1 && ['d']) ||
  5740. (days < thresholds.d && ['dd', days]);
  5741. if (thresholds.w != null) {
  5742. a =
  5743. a ||
  5744. (weeks <= 1 && ['w']) ||
  5745. (weeks < thresholds.w && ['ww', weeks]);
  5746. }
  5747. a = a ||
  5748. (months <= 1 && ['M']) ||
  5749. (months < thresholds.M && ['MM', months]) ||
  5750. (years <= 1 && ['y']) || ['yy', years];
  5751. a[2] = withoutSuffix;
  5752. a[3] = +posNegDuration > 0;
  5753. a[4] = locale;
  5754. return substituteTimeAgo.apply(null, a);
  5755. }
  5756. // This function allows you to set the rounding function for relative time strings
  5757. function getSetRelativeTimeRounding(roundingFunction) {
  5758. if (roundingFunction === undefined) {
  5759. return round;
  5760. }
  5761. if (typeof roundingFunction === 'function') {
  5762. round = roundingFunction;
  5763. return true;
  5764. }
  5765. return false;
  5766. }
  5767. // This function allows you to set a threshold for relative time strings
  5768. function getSetRelativeTimeThreshold(threshold, limit) {
  5769. if (thresholds[threshold] === undefined) {
  5770. return false;
  5771. }
  5772. if (limit === undefined) {
  5773. return thresholds[threshold];
  5774. }
  5775. thresholds[threshold] = limit;
  5776. if (threshold === 's') {
  5777. thresholds.ss = limit - 1;
  5778. }
  5779. return true;
  5780. }
  5781. function humanize(argWithSuffix, argThresholds) {
  5782. if (!this.isValid()) {
  5783. return this.localeData().invalidDate();
  5784. }
  5785. var withSuffix = false,
  5786. th = thresholds,
  5787. locale,
  5788. output;
  5789. if (typeof argWithSuffix === 'object') {
  5790. argThresholds = argWithSuffix;
  5791. argWithSuffix = false;
  5792. }
  5793. if (typeof argWithSuffix === 'boolean') {
  5794. withSuffix = argWithSuffix;
  5795. }
  5796. if (typeof argThresholds === 'object') {
  5797. th = Object.assign({}, thresholds, argThresholds);
  5798. if (argThresholds.s != null && argThresholds.ss == null) {
  5799. th.ss = argThresholds.s - 1;
  5800. }
  5801. }
  5802. locale = this.localeData();
  5803. output = relativeTime$1(this, !withSuffix, th, locale);
  5804. if (withSuffix) {
  5805. output = locale.pastFuture(+this, output);
  5806. }
  5807. return locale.postformat(output);
  5808. }
  5809. var abs$1 = Math.abs;
  5810. function sign(x) {
  5811. return (x > 0) - (x < 0) || +x;
  5812. }
  5813. function toISOString$1() {
  5814. // for ISO strings we do not use the normal bubbling rules:
  5815. // * milliseconds bubble up until they become hours
  5816. // * days do not bubble at all
  5817. // * months bubble up until they become years
  5818. // This is because there is no context-free conversion between hours and days
  5819. // (think of clock changes)
  5820. // and also not between days and months (28-31 days per month)
  5821. if (!this.isValid()) {
  5822. return this.localeData().invalidDate();
  5823. }
  5824. var seconds = abs$1(this._milliseconds) / 1000,
  5825. days = abs$1(this._days),
  5826. months = abs$1(this._months),
  5827. minutes,
  5828. hours,
  5829. years,
  5830. s,
  5831. total = this.asSeconds(),
  5832. totalSign,
  5833. ymSign,
  5834. daysSign,
  5835. hmsSign;
  5836. if (!total) {
  5837. // this is the same as C#'s (Noda) and python (isodate)...
  5838. // but not other JS (goog.date)
  5839. return 'P0D';
  5840. }
  5841. // 3600 seconds -> 60 minutes -> 1 hour
  5842. minutes = absFloor(seconds / 60);
  5843. hours = absFloor(minutes / 60);
  5844. seconds %= 60;
  5845. minutes %= 60;
  5846. // 12 months -> 1 year
  5847. years = absFloor(months / 12);
  5848. months %= 12;
  5849. // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
  5850. s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : '';
  5851. totalSign = total < 0 ? '-' : '';
  5852. ymSign = sign(this._months) !== sign(total) ? '-' : '';
  5853. daysSign = sign(this._days) !== sign(total) ? '-' : '';
  5854. hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : '';
  5855. return (
  5856. totalSign +
  5857. 'P' +
  5858. (years ? ymSign + years + 'Y' : '') +
  5859. (months ? ymSign + months + 'M' : '') +
  5860. (days ? daysSign + days + 'D' : '') +
  5861. (hours || minutes || seconds ? 'T' : '') +
  5862. (hours ? hmsSign + hours + 'H' : '') +
  5863. (minutes ? hmsSign + minutes + 'M' : '') +
  5864. (seconds ? hmsSign + s + 'S' : '')
  5865. );
  5866. }
  5867. var proto$2 = Duration.prototype;
  5868. proto$2.isValid = isValid$1;
  5869. proto$2.abs = abs;
  5870. proto$2.add = add$1;
  5871. proto$2.subtract = subtract$1;
  5872. proto$2.as = as;
  5873. proto$2.asMilliseconds = asMilliseconds;
  5874. proto$2.asSeconds = asSeconds;
  5875. proto$2.asMinutes = asMinutes;
  5876. proto$2.asHours = asHours;
  5877. proto$2.asDays = asDays;
  5878. proto$2.asWeeks = asWeeks;
  5879. proto$2.asMonths = asMonths;
  5880. proto$2.asQuarters = asQuarters;
  5881. proto$2.asYears = asYears;
  5882. proto$2.valueOf = valueOf$1;
  5883. proto$2._bubble = bubble;
  5884. proto$2.clone = clone$1;
  5885. proto$2.get = get$2;
  5886. proto$2.milliseconds = milliseconds;
  5887. proto$2.seconds = seconds;
  5888. proto$2.minutes = minutes;
  5889. proto$2.hours = hours;
  5890. proto$2.days = days;
  5891. proto$2.weeks = weeks;
  5892. proto$2.months = months;
  5893. proto$2.years = years;
  5894. proto$2.humanize = humanize;
  5895. proto$2.toISOString = toISOString$1;
  5896. proto$2.toString = toISOString$1;
  5897. proto$2.toJSON = toISOString$1;
  5898. proto$2.locale = locale;
  5899. proto$2.localeData = localeData;
  5900. proto$2.toIsoString = deprecate(
  5901. 'toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)',
  5902. toISOString$1
  5903. );
  5904. proto$2.lang = lang;
  5905. // FORMATTING
  5906. addFormatToken('X', 0, 0, 'unix');
  5907. addFormatToken('x', 0, 0, 'valueOf');
  5908. // PARSING
  5909. addRegexToken('x', matchSigned);
  5910. addRegexToken('X', matchTimestamp);
  5911. addParseToken('X', function (input, array, config) {
  5912. config._d = new Date(parseFloat(input) * 1000);
  5913. });
  5914. addParseToken('x', function (input, array, config) {
  5915. config._d = new Date(toInt(input));
  5916. });
  5917. //! moment.js
  5918. hooks.version = '2.30.1';
  5919. setHookCallback(createLocal);
  5920. hooks.fn = proto;
  5921. hooks.min = min;
  5922. hooks.max = max;
  5923. hooks.now = now;
  5924. hooks.utc = createUTC;
  5925. hooks.unix = createUnix;
  5926. hooks.months = listMonths;
  5927. hooks.isDate = isDate;
  5928. hooks.locale = getSetGlobalLocale;
  5929. hooks.invalid = createInvalid;
  5930. hooks.duration = createDuration;
  5931. hooks.isMoment = isMoment;
  5932. hooks.weekdays = listWeekdays;
  5933. hooks.parseZone = createInZone;
  5934. hooks.localeData = getLocale;
  5935. hooks.isDuration = isDuration;
  5936. hooks.monthsShort = listMonthsShort;
  5937. hooks.weekdaysMin = listWeekdaysMin;
  5938. hooks.defineLocale = defineLocale;
  5939. hooks.updateLocale = updateLocale;
  5940. hooks.locales = listLocales;
  5941. hooks.weekdaysShort = listWeekdaysShort;
  5942. hooks.normalizeUnits = normalizeUnits;
  5943. hooks.relativeTimeRounding = getSetRelativeTimeRounding;
  5944. hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
  5945. hooks.calendarFormat = getCalendarFormat;
  5946. hooks.prototype = proto;
  5947. // currently HTML5 input type only supports 24-hour formats
  5948. hooks.HTML5_FMT = {
  5949. DATETIME_LOCAL: 'YYYY-MM-DDTHH:mm', // <input type="datetime-local" />
  5950. DATETIME_LOCAL_SECONDS: 'YYYY-MM-DDTHH:mm:ss', // <input type="datetime-local" step="1" />
  5951. DATETIME_LOCAL_MS: 'YYYY-MM-DDTHH:mm:ss.SSS', // <input type="datetime-local" step="0.001" />
  5952. DATE: 'YYYY-MM-DD', // <input type="date" />
  5953. TIME: 'HH:mm', // <input type="time" />
  5954. TIME_SECONDS: 'HH:mm:ss', // <input type="time" step="1" />
  5955. TIME_MS: 'HH:mm:ss.SSS', // <input type="time" step="0.001" />
  5956. WEEK: 'GGGG-[W]WW', // <input type="week" />
  5957. MONTH: 'YYYY-MM', // <input type="month" />
  5958. };
  5959. return hooks;
  5960. })));
  5961. define('moment', ['moment/moment'], function (main) { return main; });
  5962. define('backend',['fast', 'template', 'moment'], function (Fast, Template, Moment) {
  5963. var Backend = {
  5964. api: {
  5965. sidebar: function (params) {
  5966. colorArr = ['red', 'green', 'yellow', 'blue', 'teal', 'orange', 'purple'];
  5967. $colorNums = colorArr.length;
  5968. badgeList = {};
  5969. $.each(params, function (k, v) {
  5970. $url = Fast.api.fixurl(k);
  5971. if ($.isArray(v)) {
  5972. $nums = typeof v[0] !== 'undefined' ? v[0] : 0;
  5973. $color = typeof v[1] !== 'undefined' ? v[1] : colorArr[(!isNaN($nums) ? $nums : $nums.length) % $colorNums];
  5974. $class = typeof v[2] !== 'undefined' ? v[2] : 'label';
  5975. } else {
  5976. $nums = v;
  5977. $color = colorArr[(!isNaN($nums) ? $nums : $nums.length) % $colorNums];
  5978. $class = 'label';
  5979. }
  5980. //必须nums大于0才显示
  5981. badgeList[$url] = $nums > 0 ? '<small class="' + $class + ' pull-right bg-' + $color + '">' + $nums + '</small>' : '';
  5982. });
  5983. $.each(badgeList, function (k, v) {
  5984. var anchor = top.window.$("li a[addtabs][url='" + k + "']");
  5985. if (anchor) {
  5986. top.window.$(".pull-right-container", anchor).html(v);
  5987. top.window.$(".nav-addtabs li a[node-id='" + anchor.attr("addtabs") + "'] .pull-right-container").html(v);
  5988. }
  5989. });
  5990. },
  5991. addtabs: function (url, title, icon) {
  5992. var dom = "a[url='{url}']"
  5993. var leftlink = top.window.$(dom.replace(/\{url\}/, url));
  5994. if (leftlink.length > 0) {
  5995. leftlink.trigger("click");
  5996. } else {
  5997. url = Fast.api.fixurl(url);
  5998. leftlink = top.window.$(dom.replace(/\{url\}/, url));
  5999. if (leftlink.length > 0) {
  6000. var event = leftlink.parent().hasClass("active") ? "dblclick" : "click";
  6001. leftlink.trigger(event);
  6002. } else {
  6003. var baseurl = url.substr(0, url.indexOf("?") > -1 ? url.indexOf("?") : url.length);
  6004. leftlink = top.window.$(dom.replace(/\{url\}/, baseurl));
  6005. //能找到相对地址
  6006. if (leftlink.length > 0) {
  6007. icon = typeof icon !== 'undefined' ? icon : leftlink.find("i").attr("class");
  6008. title = typeof title !== 'undefined' ? title : leftlink.find("span:first").text();
  6009. leftlink.trigger("fa.event.toggleitem");
  6010. }
  6011. var navnode = top.window.$(".nav-tabs ul li a[node-url='" + url + "']");
  6012. if (navnode.length > 0) {
  6013. navnode.trigger("click");
  6014. } else {
  6015. //追加新的tab
  6016. var id = Math.floor(new Date().valueOf() * Math.random());
  6017. icon = typeof icon !== 'undefined' ? icon : 'fa fa-circle-o';
  6018. title = typeof title !== 'undefined' ? title : '';
  6019. top.window.$("<a />").append('<i class="' + icon + '"></i> <span>' + title + '</span>').prop("href", url).attr({
  6020. url: url,
  6021. addtabs: id
  6022. }).addClass("hide").appendTo(top.window.document.body).trigger("click");
  6023. }
  6024. }
  6025. }
  6026. },
  6027. closetabs: function (url) {
  6028. if (typeof url === 'undefined') {
  6029. top.window.$("ul.nav-addtabs li.active .close-tab").trigger("click");
  6030. } else {
  6031. var dom = "a[url='{url}']"
  6032. var navlink = top.window.$(dom.replace(/\{url\}/, url));
  6033. if (navlink.length === 0) {
  6034. url = Fast.api.fixurl(url);
  6035. navlink = top.window.$(dom.replace(/\{url\}/, url));
  6036. if (navlink.length === 0) {
  6037. } else {
  6038. var baseurl = url.substr(0, url.indexOf("?") > -1 ? url.indexOf("?") : url.length);
  6039. navlink = top.window.$(dom.replace(/\{url\}/, baseurl));
  6040. //能找到相对地址
  6041. if (navlink.length === 0) {
  6042. navlink = top.window.$(".nav-tabs ul li a[node-url='" + url + "']");
  6043. }
  6044. }
  6045. }
  6046. if (navlink.length > 0 && navlink.attr('addtabs')) {
  6047. top.window.$("ul.nav-addtabs li#tab_" + navlink.attr('addtabs') + " .close-tab").trigger("click");
  6048. }
  6049. }
  6050. },
  6051. replaceids: function (elem, url) {
  6052. //如果有需要替换ids的
  6053. if (url.indexOf("{ids}") > -1) {
  6054. var ids = 0;
  6055. var tableId = $(elem).data("table-id");
  6056. if (tableId && $("#" + tableId).length > 0 && $("#" + tableId).data("bootstrap.table")) {
  6057. var Table = require("table");
  6058. ids = Table.api.selectedids($("#" + tableId)).join(",");
  6059. }
  6060. url = url.replace(/\{ids\}/g, ids);
  6061. }
  6062. return url;
  6063. },
  6064. refreshmenu: function () {
  6065. top.window.$(".sidebar-menu").trigger("refresh");
  6066. },
  6067. gettablecolumnbutton: function (options) {
  6068. if (typeof options.tableId !== 'undefined' && typeof options.fieldIndex !== 'undefined' && typeof options.buttonIndex !== 'undefined') {
  6069. var tableOptions = $("#" + options.tableId).bootstrapTable('getOptions');
  6070. if (tableOptions) {
  6071. var columnObj = null;
  6072. $.each(tableOptions.columns, function (i, columns) {
  6073. $.each(columns, function (j, column) {
  6074. if (typeof column.fieldIndex !== 'undefined' && column.fieldIndex === options.fieldIndex) {
  6075. columnObj = column;
  6076. return false;
  6077. }
  6078. });
  6079. if (columnObj) {
  6080. return false;
  6081. }
  6082. });
  6083. if (columnObj) {
  6084. return columnObj['buttons'][options.buttonIndex];
  6085. }
  6086. }
  6087. }
  6088. return null;
  6089. },
  6090. },
  6091. init: function () {
  6092. //公共代码
  6093. //添加ios-fix兼容iOS下的iframe
  6094. if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
  6095. $("html").addClass("ios-fix");
  6096. }
  6097. //配置Toastr的参数
  6098. Toastr.options.positionClass = Config.controllername === 'index' ? "toast-top-right-index" : "toast-top-right";
  6099. //点击包含.btn-dialog的元素时弹出dialog
  6100. $(document).on('click', '.btn-dialog,.dialogit', function (e) {
  6101. var that = this;
  6102. var options = $.extend({}, $(that).data() || {});
  6103. var url = Backend.api.replaceids(that, $(that).data("url") || $(that).attr('href'));
  6104. var title = $(that).attr("title") || $(that).data("title") || $(that).data('original-title');
  6105. var button = Backend.api.gettablecolumnbutton(options);
  6106. if (button && typeof button.callback === 'function') {
  6107. options.callback = button.callback;
  6108. }
  6109. if (typeof options.confirm !== 'undefined') {
  6110. Layer.confirm(options.confirm, function (index) {
  6111. Backend.api.open(url, title, options);
  6112. Layer.close(index);
  6113. });
  6114. } else {
  6115. window[$(that).data("window") || 'self'].Backend.api.open(url, title, options);
  6116. }
  6117. return false;
  6118. });
  6119. //点击包含.btn-addtabs的元素时新增选项卡
  6120. $(document).on('click', '.btn-addtabs,.addtabsit', function (e) {
  6121. var that = this;
  6122. var options = $.extend({}, $(that).data() || {});
  6123. var url = Backend.api.replaceids(that, $(that).data("url") || $(that).attr('href'));
  6124. var title = $(that).attr("title") || $(that).data("title") || $(that).data('original-title');
  6125. var icon = $(that).attr("icon") || $(that).data("icon");
  6126. if (typeof options.confirm !== 'undefined') {
  6127. Layer.confirm(options.confirm, function (index) {
  6128. Backend.api.addtabs(url, title, icon);
  6129. Layer.close(index);
  6130. });
  6131. } else {
  6132. Backend.api.addtabs(url, title, icon);
  6133. }
  6134. return false;
  6135. });
  6136. //点击包含.btn-ajax的元素时发送Ajax请求
  6137. $(document).on('click', '.btn-ajax,.ajaxit', function (e) {
  6138. var that = this;
  6139. var options = $.extend({}, $(that).data() || {});
  6140. if (typeof options.url === 'undefined' && $(that).attr("href")) {
  6141. options.url = $(that).attr("href");
  6142. }
  6143. options.url = Backend.api.replaceids(this, options.url);
  6144. var success = typeof options.success === 'function' ? options.success : null;
  6145. var error = typeof options.error === 'function' ? options.error : null;
  6146. delete options.success;
  6147. delete options.error;
  6148. var button = Backend.api.gettablecolumnbutton(options);
  6149. if (button) {
  6150. if (typeof button.success === 'function') {
  6151. success = button.success;
  6152. }
  6153. if (typeof button.error === 'function') {
  6154. error = button.error;
  6155. }
  6156. }
  6157. //如果未设备成功的回调,设定了自动刷新的情况下自动进行刷新
  6158. if (!success && typeof options.tableId !== 'undefined' && typeof options.refresh !== 'undefined' && options.refresh) {
  6159. success = function () {
  6160. $("#" + options.tableId).bootstrapTable('refresh');
  6161. }
  6162. }
  6163. if (typeof options.confirm !== 'undefined') {
  6164. Layer.confirm(options.confirm, function (index) {
  6165. Backend.api.ajax(options, success, error);
  6166. Layer.close(index);
  6167. });
  6168. } else {
  6169. Backend.api.ajax(options, success, error);
  6170. }
  6171. return false;
  6172. });
  6173. $(document).on('click', '.btn-click,.clickit', function (e) {
  6174. var that = this;
  6175. var options = $.extend({}, $(that).data() || {});
  6176. var row = {};
  6177. if (typeof options.tableId !== 'undefined') {
  6178. var index = parseInt(options.rowIndex);
  6179. var data = $("#" + options.tableId).bootstrapTable('getData');
  6180. row = typeof data[index] !== 'undefined' ? data[index] : {};
  6181. }
  6182. var button = Backend.api.gettablecolumnbutton(options);
  6183. var click = typeof button.click === 'function' ? button.click : $.noop;
  6184. if (typeof options.confirm !== 'undefined') {
  6185. Layer.confirm(options.confirm, function (index) {
  6186. click.apply(that, [options, row, button]);
  6187. Layer.close(index);
  6188. });
  6189. } else {
  6190. click.apply(that, [options, row, button]);
  6191. }
  6192. return false;
  6193. });
  6194. //修复含有fixed-footer类的body边距
  6195. if ($(".fixed-footer").length > 0) {
  6196. $(document.body).css("padding-bottom", $(".fixed-footer").outerHeight());
  6197. }
  6198. //修复不在iframe时layer-footer隐藏的问题
  6199. if ($(".layer-footer").length > 0 && self === top) {
  6200. $(".layer-footer").show();
  6201. }
  6202. //tooltip和popover
  6203. if (!('ontouchstart' in document.documentElement)) {
  6204. $('body').tooltip({selector: '[data-toggle="tooltip"]', trigger: 'hover'});
  6205. }
  6206. $('body').popover({selector: '[data-toggle="popover"]'});
  6207. }
  6208. };
  6209. Backend.api = $.extend(Fast.api, Backend.api);
  6210. //将Template渲染至全局,以便于在子框架中调用
  6211. window.Template = Template;
  6212. //将Moment渲染至全局,以便于在子框架中调用
  6213. window.Moment = Moment;
  6214. //将Backend渲染至全局,以便于在子框架中调用
  6215. window.Backend = Backend;
  6216. Backend.init();
  6217. return Backend;
  6218. });
  6219. define('backend-init',['backend'], function (Backend) {
  6220. });
  6221. //! moment.js locale configuration
  6222. //! locale : Chinese (China) [zh-cn]
  6223. //! author : suupic : https://github.com/suupic
  6224. //! author : Zeno Zeng : https://github.com/zenozeng
  6225. //! author : uu109 : https://github.com/uu109
  6226. ;(function (global, factory) {
  6227. typeof exports === 'object' && typeof module !== 'undefined'
  6228. && typeof require === 'function' ? factory(require('../moment')) :
  6229. typeof define === 'function' && define.amd ? define('moment/locale/zh-cn',['../moment'], factory) :
  6230. factory(global.moment)
  6231. }(this, (function (moment) { 'use strict';
  6232. //! moment.js locale configuration
  6233. var zhCn = moment.defineLocale('zh-cn', {
  6234. months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split(
  6235. '_'
  6236. ),
  6237. monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split(
  6238. '_'
  6239. ),
  6240. weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
  6241. weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'),
  6242. weekdaysMin: '日_一_二_三_四_五_六'.split('_'),
  6243. longDateFormat: {
  6244. LT: 'HH:mm',
  6245. LTS: 'HH:mm:ss',
  6246. L: 'YYYY/MM/DD',
  6247. LL: 'YYYY年M月D日',
  6248. LLL: 'YYYY年M月D日Ah点mm分',
  6249. LLLL: 'YYYY年M月D日ddddAh点mm分',
  6250. l: 'YYYY/M/D',
  6251. ll: 'YYYY年M月D日',
  6252. lll: 'YYYY年M月D日 HH:mm',
  6253. llll: 'YYYY年M月D日dddd HH:mm',
  6254. },
  6255. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  6256. meridiemHour: function (hour, meridiem) {
  6257. if (hour === 12) {
  6258. hour = 0;
  6259. }
  6260. if (meridiem === '凌晨' || meridiem === '早上' || meridiem === '上午') {
  6261. return hour;
  6262. } else if (meridiem === '下午' || meridiem === '晚上') {
  6263. return hour + 12;
  6264. } else {
  6265. // '中午'
  6266. return hour >= 11 ? hour : hour + 12;
  6267. }
  6268. },
  6269. meridiem: function (hour, minute, isLower) {
  6270. var hm = hour * 100 + minute;
  6271. if (hm < 600) {
  6272. return '凌晨';
  6273. } else if (hm < 900) {
  6274. return '早上';
  6275. } else if (hm < 1130) {
  6276. return '上午';
  6277. } else if (hm < 1230) {
  6278. return '中午';
  6279. } else if (hm < 1800) {
  6280. return '下午';
  6281. } else {
  6282. return '晚上';
  6283. }
  6284. },
  6285. calendar: {
  6286. sameDay: '[今天]LT',
  6287. nextDay: '[明天]LT',
  6288. nextWeek: function (now) {
  6289. if (now.week() !== this.week()) {
  6290. return '[下]dddLT';
  6291. } else {
  6292. return '[本]dddLT';
  6293. }
  6294. },
  6295. lastDay: '[昨天]LT',
  6296. lastWeek: function (now) {
  6297. if (this.week() !== now.week()) {
  6298. return '[上]dddLT';
  6299. } else {
  6300. return '[本]dddLT';
  6301. }
  6302. },
  6303. sameElse: 'L',
  6304. },
  6305. dayOfMonthOrdinalParse: /\d{1,2}(日|月|周)/,
  6306. ordinal: function (number, period) {
  6307. switch (period) {
  6308. case 'd':
  6309. case 'D':
  6310. case 'DDD':
  6311. return number + '日';
  6312. case 'M':
  6313. return number + '月';
  6314. case 'w':
  6315. case 'W':
  6316. return number + '周';
  6317. default:
  6318. return number;
  6319. }
  6320. },
  6321. relativeTime: {
  6322. future: '%s后',
  6323. past: '%s前',
  6324. s: '几秒',
  6325. ss: '%d 秒',
  6326. m: '1 分钟',
  6327. mm: '%d 分钟',
  6328. h: '1 小时',
  6329. hh: '%d 小时',
  6330. d: '1 天',
  6331. dd: '%d 天',
  6332. w: '1 周',
  6333. ww: '%d 周',
  6334. M: '1 个月',
  6335. MM: '%d 个月',
  6336. y: '1 年',
  6337. yy: '%d 年',
  6338. },
  6339. week: {
  6340. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  6341. dow: 1, // Monday is the first day of the week.
  6342. doy: 4, // The week that contains Jan 4th is the first week of the year.
  6343. },
  6344. });
  6345. return zhCn;
  6346. })));
  6347. /*
  6348. * bootstrap-table - v1.11.10 - 2023-06-14
  6349. https://github.com/wenzhixin/bootstrap-table
  6350. * Copyright (c) 2017 zhixin wen
  6351. * Licensed MIT License
  6352. */
  6353. !function(C){"use strict";function T(t){var i=arguments,e=!0,o=1;return t=t.replace(/%s/g,function(){var t=i[o++];return void 0===t?(e=!1,""):t}),e?t:""}function p(t,e){var o=-1;return C.each(t,function(t,i){return i.field!==e||(o=t,!1)}),o}function a(){var t,i,e;return null===o&&(e=C("<p/>").addClass("fixed-table-scroll-inner"),(t=C("<div/>").addClass("fixed-table-scroll-outer")).append(e),C("body").append(t),i=e[0].offsetWidth,t.css("overflow","scroll"),i===(e=e[0].offsetWidth)&&(e=t[0].clientWidth),t.remove(),o=i-e),o}function A(t,i,e,o){var s,n=i;return"string"==typeof i&&(1<(s=i.split(".")).length?(n=window,C.each(s,function(t,i){n=n[i]})):n=window[i]),"object"==typeof n?n:"function"==typeof n?n.apply(t,e||[]):!n&&"string"==typeof i&&T.apply(this,[i].concat(e))?T.apply(this,[i].concat(e)):o}function i(t,i,e){var o,s=Object.getOwnPropertyNames(t),n=Object.getOwnPropertyNames(i);if(e&&s.length!==n.length)return!1;for(var a=0;a<s.length;a++)if(o=s[a],-1<C.inArray(o,n)&&t[o]!==i[o])return!1;return!0}function R(t){return"string"==typeof t?t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/`/g,"&#x60;"):t}function f(t){for(var i in t){var e=i.split(/(?=[A-Z])/).join("-").toLowerCase();e!==i&&(t[e]=t[i],delete t[i])}return t}function _(t,i,e){var o=t;if("string"!=typeof i||t.hasOwnProperty(i))return e?R(t[i]):t[i];var s,n=i.split(".");for(s in n)n.hasOwnProperty(s)&&(o=o&&o[n[s]]);return e?R(o):o}function e(){return!!(0<navigator.userAgent.indexOf("MSIE ")||navigator.userAgent.match(/Trident.*rv\:11\./))}function g(t,i){this.options=i,this.$el=C(t),this.$el_=this.$el.clone(),this.timeoutId_=0,this.timeoutFooter_=0,this.init()}var o=null,r=(g.DEFAULTS={classes:"table table-hover",sortClass:void 0,locale:void 0,height:void 0,undefinedText:"-",sortName:void 0,sortOrder:"asc",sortStable:!1,striped:!1,columns:[[]],data:[],totalField:"total",dataField:"rows",method:"get",url:void 0,ajax:void 0,cache:!0,contentType:"application/json",dataType:"json",ajaxOptions:{},queryParams:function(t){return t},queryParamsType:"limit",responseHandler:function(t){return t},pagination:!1,onlyInfoPagination:!1,paginationLoop:!0,sidePagination:"client",totalRows:0,pageNumber:1,pageSize:10,pageList:[10,25,50,100],paginationHAlign:"right",paginationVAlign:"bottom",paginationDetailHAlign:"left",paginationPreText:"&lsaquo;",paginationNextText:"&rsaquo;",search:!1,searchOnEnterKey:!1,strictSearch:!1,searchAlign:"right",selectItemName:"btSelectItem",showHeader:!0,showFooter:!1,showColumns:!1,showPaginationSwitch:!1,showRefresh:!1,showToggle:!1,buttonsAlign:"right",smartDisplay:!0,escape:!1,minimumCountColumns:1,idField:void 0,uniqueId:void 0,cardView:!1,detailView:!1,detailFormatter:function(t,i){return""},trimOnSearch:!0,clickToSelect:!1,singleSelect:!1,toolbar:void 0,toolbarAlign:"left",checkboxHeader:!0,sortable:!0,silentSort:!0,maintainSelected:!1,searchTimeOut:500,searchText:"",iconSize:void 0,buttonsClass:"default",iconsPrefix:"glyphicon",icons:{paginationSwitchDown:"glyphicon-collapse-down icon-chevron-down",paginationSwitchUp:"glyphicon-collapse-up icon-chevron-up",refresh:"glyphicon-refresh icon-refresh",toggle:"glyphicon-list-alt icon-list-alt",columns:"glyphicon-th icon-th",detailOpen:"glyphicon-plus icon-plus",detailClose:"glyphicon-minus icon-minus"},customSearch:C.noop,customSort:C.noop,rowStyle:function(t,i){return{}},rowAttributes:function(t,i){return{}},footerStyle:function(t,i){return{}},onAll:function(t,i){return!1},onClickCell:function(t,i,e,o){return!1},onDblClickCell:function(t,i,e,o){return!1},onClickRow:function(t,i){return!1},onDblClickRow:function(t,i){return!1},onSort:function(t,i){return!1},onCheck:function(t){return!1},onUncheck:function(t){return!1},onCheckAll:function(t){return!1},onUncheckAll:function(t){return!1},onCheckSome:function(t){return!1},onUncheckSome:function(t){return!1},onLoadSuccess:function(t){return!1},onLoadError:function(t){return!1},onColumnSwitch:function(t,i){return!1},onPageChange:function(t,i){return!1},onSearch:function(t){return!1},onToggle:function(t){return!1},onPreBody:function(t){return!1},onPostBody:function(){return!1},onPostHeader:function(){return!1},onExpandRow:function(t,i,e){return!1},onCollapseRow:function(t,i){return!1},onRefreshOptions:function(t){return!1},onRefresh:function(t){return!1},onResetView:function(){return!1}},(g.LOCALES={})["en-US"]=g.LOCALES.en={formatLoadingMessage:function(){return"Loading, please wait..."},formatRecordsPerPage:function(t){return T("%s rows per page",t)},formatShowingRows:function(t,i,e){return T("Showing %s to %s of %s rows",t,i,e)},formatDetailPagination:function(t){return T("Showing %s rows",t)},formatSearch:function(){return"Search"},formatNoMatches:function(){return"No matching records found"},formatPaginationSwitch:function(){return"Hide/Show pagination"},formatRefresh:function(){return"Refresh"},formatToggle:function(){return"Toggle"},formatColumns:function(){return"Columns"},formatAllRows:function(){return"All"}},C.extend(g.DEFAULTS,g.LOCALES["en-US"]),g.COLUMN_DEFAULTS={radio:!1,checkbox:!1,checkboxEnabled:!0,field:void 0,title:void 0,titleTooltip:void 0,class:void 0,align:void 0,halign:void 0,falign:void 0,valign:void 0,width:void 0,sortable:!1,order:"asc",visible:!0,switchable:!0,clickToSelect:!0,formatter:void 0,footerFormatter:void 0,events:void 0,sorter:void 0,sortName:void 0,cellStyle:void 0,searchable:!0,searchFormatter:!0,cardVisible:!0,escape:!1},g.EVENTS={"all.bs.table":"onAll","click-cell.bs.table":"onClickCell","dbl-click-cell.bs.table":"onDblClickCell","click-row.bs.table":"onClickRow","dbl-click-row.bs.table":"onDblClickRow","sort.bs.table":"onSort","check.bs.table":"onCheck","uncheck.bs.table":"onUncheck","check-all.bs.table":"onCheckAll","uncheck-all.bs.table":"onUncheckAll","check-some.bs.table":"onCheckSome","uncheck-some.bs.table":"onUncheckSome","load-success.bs.table":"onLoadSuccess","load-error.bs.table":"onLoadError","column-switch.bs.table":"onColumnSwitch","page-change.bs.table":"onPageChange","search.bs.table":"onSearch","toggle.bs.table":"onToggle","pre-body.bs.table":"onPreBody","post-body.bs.table":"onPostBody","post-header.bs.table":"onPostHeader","expand-row.bs.table":"onExpandRow","collapse-row.bs.table":"onCollapseRow","refresh-options.bs.table":"onRefreshOptions","reset-view.bs.table":"onResetView","refresh.bs.table":"onRefresh"},g.prototype.init=function(){this.initLocale(),this.initContainer(),this.initTable(),this.initHeader(),this.initData(),this.initHiddenRows(),this.initFooter(),this.initToolbar(),this.initPagination(),this.initBody(),this.initSearchText(),this.initServer()},g.prototype.initLocale=function(){var t;this.options.locale&&((t=this.options.locale.split(/-|_/))[0].toLowerCase(),t[1]&&t[1].toUpperCase(),C.fn.bootstrapTable.locales[this.options.locale]?C.extend(this.options,C.fn.bootstrapTable.locales[this.options.locale]):C.fn.bootstrapTable.locales[t.join("-")]?C.extend(this.options,C.fn.bootstrapTable.locales[t.join("-")]):C.fn.bootstrapTable.locales[t[0]]&&C.extend(this.options,C.fn.bootstrapTable.locales[t[0]]))},g.prototype.initContainer=function(){this.$container=C(['<div class="bootstrap-table">','<div class="fixed-table-toolbar"></div>',"top"===this.options.paginationVAlign||"both"===this.options.paginationVAlign?'<div class="fixed-table-pagination" style="clear: both;"></div>':"",'<div class="fixed-table-container">','<div class="fixed-table-header"><table></table></div>','<div class="fixed-table-body">','<div class="fixed-table-loading">',this.options.formatLoadingMessage(),"</div>","</div>",'<div class="fixed-table-footer"><table><tr></tr></table></div>',"bottom"===this.options.paginationVAlign||"both"===this.options.paginationVAlign?'<div class="fixed-table-pagination"></div>':"","</div>","</div>"].join("")),this.$container.insertAfter(this.$el),this.$tableContainer=this.$container.find(".fixed-table-container"),this.$tableHeader=this.$container.find(".fixed-table-header"),this.$tableBody=this.$container.find(".fixed-table-body"),this.$tableLoading=this.$container.find(".fixed-table-loading"),this.$tableFooter=this.$container.find(".fixed-table-footer"),this.$toolbar=this.$container.find(".fixed-table-toolbar"),this.$pagination=this.$container.find(".fixed-table-pagination"),this.$tableBody.append(this.$el),this.$container.after('<div class="clearfix"></div>'),this.$el.addClass(this.options.classes),this.options.striped&&this.$el.addClass("table-striped"),-1!==C.inArray("table-no-bordered",this.options.classes.split(" "))&&this.$tableContainer.addClass("table-no-bordered")},g.prototype.initTable=function(){for(var h,t,i,l=this,e=[],o=[],s=(this.$header=this.$el.find(">thead"),this.$header.length||(this.$header=C("<thead></thead>").appendTo(this.$el)),this.$header.find("tr").each(function(){var t=[];C(this).find("th").each(function(){void 0!==C(this).data("field")&&C(this).data("field",C(this).data("field")+""),t.push(C.extend({},{title:C(this).html(),class:C(this).attr("class"),titleTooltip:C(this).attr("title"),rowspan:C(this).attr("rowspan")?+C(this).attr("rowspan"):void 0,colspan:C(this).attr("colspan")?+C(this).attr("colspan"):void 0},C(this).data()))}),e.push(t)}),C.isArray(this.options.columns[0])||(this.options.columns=[this.options.columns]),this.options.columns=C.extend(!0,[],e,this.options.columns),this.columns=[],this.options.columns),n=0,a=[],r=0;r<s[0].length;r++)n+=s[0][r].colspan||1;for(r=0;r<s.length;r++)for(a[r]=[],t=0;t<n;t++)a[r][t]=!1;for(r=0;r<s.length;r++)for(t=0;t<s[r].length;t++){var p=s[r][t],c=p.rowspan||1,d=p.colspan||1,u=C.inArray(!1,a[r]);for(1===d&&(p.fieldIndex=u,void 0===p.field)&&(p.field=u),i=0;i<c;i++)a[r+i][u]=!0;for(i=0;i<d;i++)a[r][u+i]=!0}C.each(this.options.columns,function(e,t){C.each(t,function(t,i){void 0!==(i=C.extend({},g.COLUMN_DEFAULTS,i)).fieldIndex&&(l.columns[i.fieldIndex]=i),l.options.columns[e][t]=i})}),this.options.data.length||(h=[],this.$el.find(">tbody>tr").each(function(a){var r={};r._id=C(this).attr("id"),r._class=C(this).attr("class"),r._data=f(C(this).data()),C(this).find(">td").each(function(t){for(var i,e,o=C(this),s=+o.attr("colspan")||1,n=+o.attr("rowspan")||1;h[a]&&h[a][t];t++);for(i=t;i<t+s;i++)for(e=a;e<a+n;e++)h[e]||(h[e]=[]),h[e][i]=!0;o=l.columns[t].field;r[o]=C(this).html(),r["_"+o+"_id"]=C(this).attr("id"),r["_"+o+"_class"]=C(this).attr("class"),r["_"+o+"_rowspan"]=C(this).attr("rowspan"),r["_"+o+"_colspan"]=C(this).attr("colspan"),r["_"+o+"_title"]=C(this).attr("title"),r["_"+o+"_data"]=f(C(this).data())}),o.push(r)}),(this.options.data=o).length&&(this.fromHtml=!0))},g.prototype.initHeader=function(){var l=this,p={},c=[];this.header={fields:[],styles:[],classes:[],formatters:[],events:[],sorters:[],sortNames:[],cellStyles:[],searchables:[]},C.each(this.options.columns,function(t,i){c.push("<tr>"),0===t&&!l.options.cardView&&l.options.detailView&&c.push(T('<th class="detail" rowspan="%s"><div class="fht-cell"></div></th>',l.options.columns.length)),C.each(i,function(t,i){var e,o,s,n="",a=T(' class="%s"',i.class),r=(l.options.sortOrder||i.order,"px"),h=i.width;if(void 0===i.width||l.options.cardView||"string"==typeof i.width&&-1!==i.width.indexOf("%")&&(r="%"),i.width&&"string"==typeof i.width&&(h=i.width.replace("%","").replace("px","")),e=T("text-align: %s; ",i.halign||i.align),o=T("text-align: %s; ",i.align),s=T("vertical-align: %s; ",i.valign),s+=T("width: %s; ",!i.checkbox&&!i.radio||h?h?h+r:void 0:"36px"),void 0!==i.fieldIndex){if(l.header.fields[i.fieldIndex]=i.field,l.header.styles[i.fieldIndex]=o+s,l.header.classes[i.fieldIndex]=a,l.header.formatters[i.fieldIndex]=i.formatter,l.header.events[i.fieldIndex]=i.events,l.header.sorters[i.fieldIndex]=i.sorter,l.header.sortNames[i.fieldIndex]=i.sortName,l.header.cellStyles[i.fieldIndex]=i.cellStyle,l.header.searchables[i.fieldIndex]=i.searchable,!i.visible)return;if(l.options.cardView&&!i.cardVisible)return;p[i.field]=i}c.push("<th"+T(' title="%s"',i.titleTooltip),i.checkbox||i.radio?T(' class="bs-checkbox %s"',i.class||""):a,T(' style="%s"',e+s),T(' rowspan="%s"',i.rowspan),T(' colspan="%s"',i.colspan),T(' data-field="%s"',i.field),">"),c.push(T('<div class="th-inner %s">',l.options.sortable&&i.sortable?"sortable both":"")),n=l.options.escape?R(i.title):i.title,i.checkbox&&(!l.options.singleSelect&&l.options.checkboxHeader&&(n='<input name="btSelectAll" type="checkbox" />'),l.header.stateField=i.field),i.radio&&(n="",l.header.stateField=i.field,l.options.singleSelect=!0),c.push(n),c.push("</div>"),c.push('<div class="fht-cell"></div>'),c.push("</div>"),c.push("</th>")}),c.push("</tr>")}),this.$header.html(c.join("")),this.$header.find("th[data-field]").each(function(t){C(this).data(p[C(this).data("field")])}),this.$container.off("click",".th-inner").on("click",".th-inner",function(t){var i=C(this);if(l.options.detailView&&i.closest(".bootstrap-table")[0]!==l.$container[0])return!1;l.options.sortable&&i.parent().data().sortable&&l.onSort(t)}),this.$header.children().children().off("keypress").on("keypress",function(t){l.options.sortable&&C(this).data().sortable&&13==(t.keyCode||t.which)&&l.onSort(t)}),C(window).off("resize.bootstrap-table"),!this.options.showHeader||this.options.cardView?(this.$header.hide(),this.$tableHeader.hide(),this.$tableLoading.css("top",0)):(this.$header.show(),this.$tableHeader.show(),this.$tableLoading.css("top",this.$header.outerHeight()+1),this.getCaret(),C(window).on("resize.bootstrap-table",C.proxy(this.resetWidth,this))),this.$selectAll=this.$header.find('[name="btSelectAll"]'),this.$selectAll.off("click").on("click",function(){var t=C(this).prop("checked");l[t?"checkAll":"uncheckAll"](),l.updateSelected()})},g.prototype.initFooter=function(){!this.options.showFooter||this.options.cardView?this.$tableFooter.hide():this.$tableFooter.show()},g.prototype.initData=function(t,i){this.data="append"===i?this.data.concat(t):"prepend"===i?[].concat(t).concat(this.data):t||this.options.data,this.options.data="append"===i?this.options.data.concat(t):"prepend"===i?[].concat(t).concat(this.options.data):this.data,"server"!==this.options.sidePagination&&this.initSort()},g.prototype.initSort=function(){var n=this,a=this.options.sortName,r="desc"===this.options.sortOrder?-1:1,h=C.inArray(this.options.sortName,this.header.fields);this.options.customSort!==C.noop?this.options.customSort.apply(this,[this.options.sortName,this.options.sortOrder]):-1!==h&&(this.options.sortStable&&C.each(this.data,function(t,i){i.hasOwnProperty("_position")||(i._position=t)}),this.data.sort(function(t,i){n.header.sortNames[h]&&(a=n.header.sortNames[h]);var e=_(t,a,n.options.escape),o=_(i,a,n.options.escape),s=A(n.header,n.header.sorters[h],[e,o]);return void 0!==s?r*s:(null==e&&(e=""),null==o&&(o=""),n.options.sortStable&&e===o&&(e=t._position,o=i._position),C.isNumeric(e)&&C.isNumeric(o)?(e=parseFloat(e))<(o=parseFloat(o))?-1*r:r:e===o?0:-1===(e="string"!=typeof e?e.toString():e).localeCompare(o)?-1*r:r)}),void 0!==this.options.sortClass)&&(clearTimeout(0),setTimeout(function(){n.$el.removeClass(n.options.sortClass);var t=n.$header.find(T('[data-field="%s"]',n.options.sortName).index()+1);n.$el.find(T("tr td:nth-child(%s)",t)).addClass(n.options.sortClass)},250))},g.prototype.onSort=function(t){var t="keypress"===t.type?C(t.currentTarget):C(t.currentTarget).parent(),i=this.$header.find("th").eq(t.index());this.$header.add(this.$header_).find("span.order").remove(),this.options.sortName===t.data("field")?this.options.sortOrder="asc"===this.options.sortOrder?"desc":"asc":(this.options.sortName=t.data("field"),this.options.sortOrder="asc"===t.data("order")?"desc":"asc"),this.trigger("sort",this.options.sortName,this.options.sortOrder),t.add(i).data("order",this.options.sortOrder),this.getCaret(),"server"===this.options.sidePagination?this.initServer(this.options.silentSort):(this.initSort(),this.initBody())},g.prototype.initToolbar=function(){var t,o=this,s=[],i=0,n=0;this.$toolbar.find(".bs-bars").children().length&&C("body").append(C(this.options.toolbar)),this.$toolbar.html(""),"string"!=typeof this.options.toolbar&&"object"!=typeof this.options.toolbar||C(T('<div class="bs-bars pull-%s"></div>',this.options.toolbarAlign)).appendTo(this.$toolbar).append(C(this.options.toolbar)),s=[T('<div class="columns columns-%s btn-group pull-%s">',this.options.buttonsAlign,this.options.buttonsAlign)],"string"==typeof this.options.icons&&(this.options.icons=A(null,this.options.icons)),this.options.showPaginationSwitch&&s.push(T('<button class="btn'+T(" btn-%s",this.options.buttonsClass)+T(" btn-%s",this.options.iconSize)+'" type="button" name="paginationSwitch" aria-label="pagination Switch" title="%s">',this.options.formatPaginationSwitch()),T('<i class="%s %s"></i>',this.options.iconsPrefix,this.options.icons.paginationSwitchDown),"</button>"),this.options.showRefresh&&s.push(T('<button class="btn'+T(" btn-%s",this.options.buttonsClass)+T(" btn-%s",this.options.iconSize)+'" type="button" name="refresh" aria-label="refresh" title="%s">',this.options.formatRefresh()),T('<i class="%s %s"></i>',this.options.iconsPrefix,this.options.icons.refresh),"</button>"),this.options.showToggle&&s.push(T('<button class="btn'+T(" btn-%s",this.options.buttonsClass)+T(" btn-%s",this.options.iconSize)+'" type="button" name="toggle" aria-label="toggle" title="%s">',this.options.formatToggle()),T('<i class="%s %s"></i>',this.options.iconsPrefix,this.options.icons.toggle),"</button>"),this.options.showColumns&&(s.push(T('<div class="keep-open btn-group" title="%s">',this.options.formatColumns()),'<button type="button" aria-label="columns" class="btn'+T(" btn-%s",this.options.buttonsClass)+T(" btn-%s",this.options.iconSize)+' dropdown-toggle" data-toggle="dropdown">',T('<i class="%s %s"></i>',this.options.iconsPrefix,this.options.icons.columns),' <span class="caret"></span>',"</button>",'<ul class="dropdown-menu" role="menu">'),C.each(this.columns,function(t,i){var e;i.radio||i.checkbox||o.options.cardView&&!i.cardVisible||(e=i.visible?' checked="checked"':"",i.switchable&&(s.push(T('<li role="menuitem"><label><input type="checkbox" data-field="%s" value="%s"%s> %s</label></li>',i.field,t,e,i.title)),n++))}),s.push("</ul>","</div>")),s.push("</div>"),(this.showToolbar||2<s.length)&&this.$toolbar.append(s.join("")),this.options.showPaginationSwitch&&this.$toolbar.find('button[name="paginationSwitch"]').off("click").on("click",C.proxy(this.togglePagination,this)),this.options.showRefresh&&this.$toolbar.find('button[name="refresh"]').off("click").on("click",C.proxy(this.refresh,this)),this.options.showToggle&&this.$toolbar.find('button[name="toggle"]').off("click").on("click",function(){o.toggleView()}),this.options.showColumns&&(t=this.$toolbar.find(".keep-open"),n<=this.options.minimumCountColumns&&t.find("input").prop("disabled",!0),t.find("li").off("click").on("click",function(t){t.stopImmediatePropagation()}),t.find("input").off("click").on("click",function(){var t=C(this);o.toggleColumn(C(this).val(),t.prop("checked"),!1),o.trigger("column-switch",C(this).data("field"),t.prop("checked"))})),this.options.search&&((s=[]).push('<div class="pull-'+this.options.searchAlign+' search">',T('<input class="form-control'+T(" input-%s",this.options.iconSize)+'" type="text" placeholder="%s">',this.options.formatSearch()),"</div>"),this.$toolbar.append(s.join("")),(t=this.$toolbar.find(".search input")).off("keyup drop blur").on("keyup drop blur",function(t){o.options.searchOnEnterKey&&13!==t.keyCode||-1<C.inArray(t.keyCode,[37,38,39,40])||(clearTimeout(i),i=setTimeout(function(){o.onSearch(t)},o.options.searchTimeOut))}),e())&&t.off("mouseup").on("mouseup",function(t){clearTimeout(i),i=setTimeout(function(){o.onSearch(t)},o.options.searchTimeOut)})},g.prototype.onSearch=function(t){var i=C.trim(C(t.currentTarget).val());this.options.trimOnSearch&&C(t.currentTarget).val()!==i&&C(t.currentTarget).val(i),i===this.searchText||""===i&&void 0===this.searchText||(this.searchText=i,this.options.searchText=i,this.options.pageNumber=1,this.initSearch(),this.updatePagination(),this.trigger("search",i))},g.prototype.initSearch=function(){var h,o,l=this;"server"!==this.options.sidePagination&&(this.options.customSearch!==C.noop?this.options.customSearch.apply(this,[this.searchText]):(h=this.searchText&&(this.options.escape?R(this.searchText):this.searchText).toLowerCase(),o=C.isEmptyObject(this.filterColumns)?null:this.filterColumns,this.data=o?C.grep(this.options.data,function(t,i){for(var e in o)if(C.isArray(o[e])&&-1===C.inArray(t[e],o[e])||!C.isArray(o[e])&&t[e]!==o[e])return!1;return!0}):this.options.data,this.data=h?C.grep(this.data,function(t,i){for(var e=0;e<l.header.fields.length;e++)if(l.header.searchables[e]){var o=C.isNumeric(l.header.fields[e])?parseInt(l.header.fields[e],10):l.header.fields[e],s=l.columns[p(l.columns,o)];if("string"==typeof o){for(var n=t,a=o.split("."),r=0;r<a.length;r++)n=n[a[r]];s&&s.searchFormatter&&(n=A(s,l.header.formatters[e],[n,t,i],n))}else n=t[o];if("string"==typeof n||"number"==typeof n)if(l.options.strictSearch){if((n+"").toLowerCase()===h)return!0}else if(-1!==(n+"").toLowerCase().indexOf(h))return!0}return!1}):this.data))},g.prototype.initPagination=function(){if(this.options.pagination){this.$pagination.show();var t,i,e,o,s,n,a,r=this,h=[],l=!1,p=this.getData(),c=this.options.pageList;if("server"!==this.options.sidePagination&&(this.options.totalRows=p.length),this.totalPages=0,this.options.totalRows&&(this.options.pageSize===this.options.formatAllRows()?(this.options.pageSize=this.options.totalRows,l=!0):this.options.pageSize===this.options.totalRows&&(p="string"==typeof this.options.pageList?this.options.pageList.replace("[","").replace("]","").replace(/ /g,"").toLowerCase().split(","):this.options.pageList,-1<C.inArray(this.options.formatAllRows().toLowerCase(),p))&&(l=!0),this.totalPages=1+~~((this.options.totalRows-1)/this.options.pageSize),this.options.totalPages=this.totalPages),0<this.totalPages&&this.options.pageNumber>this.totalPages&&(this.options.pageNumber=this.totalPages),this.pageFrom=(this.options.pageNumber-1)*this.options.pageSize+1,this.pageTo=this.options.pageNumber*this.options.pageSize,this.pageTo>this.options.totalRows&&(this.pageTo=this.options.totalRows),h.push('<div class="pull-'+this.options.paginationDetailHAlign+' pagination-detail">','<span class="pagination-info">',this.options.onlyInfoPagination?this.options.formatDetailPagination(this.options.totalRows):this.options.formatShowingRows(this.pageFrom,this.pageTo,this.options.totalRows),"</span>"),!this.options.onlyInfoPagination){h.push('<span class="page-list">');var d=[T('<span class="btn-group %s">',"top"===this.options.paginationVAlign||"both"===this.options.paginationVAlign?"dropdown":"dropup"),'<button type="button" class="btn'+T(" btn-%s",this.options.buttonsClass)+T(" btn-%s",this.options.iconSize)+' dropdown-toggle" data-toggle="dropdown">','<span class="page-size">',l?this.options.formatAllRows():this.options.pageSize,"</span>",' <span class="caret"></span>',"</button>",'<ul class="dropdown-menu" role="menu">'];for("string"==typeof this.options.pageList&&(p=this.options.pageList.replace("[","").replace("]","").replace(/ /g,"").split(","),c=[],C.each(p,function(t,i){c.push(i.toUpperCase()===r.options.formatAllRows().toUpperCase()?r.options.formatAllRows():+i)})),C.each(c,function(t,i){(!r.options.smartDisplay||0===t||c[t-1]<r.options.totalRows)&&(t=l?i===r.options.formatAllRows()?' class="active"':"":i===r.options.pageSize?' class="active"':"",d.push(T('<li role="menuitem"%s><a href="#">%s</a></li>',t,i)))}),d.push("</ul></span>"),h.push(this.options.formatRecordsPerPage(d.join(""))),h.push("</span>"),h.push("</div>",'<div class="pull-'+this.options.paginationHAlign+' pagination">','<ul class="pagination'+T(" pagination-%s",this.options.iconSize)+'">','<li class="page-pre"><a href="#">'+this.options.paginationPreText+"</a></li>"),this.totalPages<5?(e=1,i=this.totalPages):(i=(e=this.options.pageNumber-2)+4,e<1&&(e=1,i=5),i>this.totalPages&&(e=(i=this.totalPages)-4)),6<=this.totalPages&&(3<=this.options.pageNumber&&(h.push('<li class="page-first'+(1===this.options.pageNumber?" active":"")+'">','<a href="#">',1,"</a>","</li>"),e++),4<=this.options.pageNumber)&&(4==this.options.pageNumber||6==this.totalPages||7==this.totalPages?e--:h.push('<li class="page-first-separator disabled">','<a href="#">...</a>',"</li>"),i--),7<=this.totalPages&&this.options.pageNumber>=this.totalPages-2&&e--,6==this.totalPages?this.options.pageNumber>=this.totalPages-2&&i++:7<=this.totalPages&&(7==this.totalPages||this.options.pageNumber>=this.totalPages-3)&&i++,t=e;t<=i;t++)h.push('<li class="page-number'+(t===this.options.pageNumber?" active":"")+'">','<a href="#">',t,"</a>","</li>");8<=this.totalPages&&this.options.pageNumber<=this.totalPages-4&&h.push('<li class="page-last-separator disabled">','<a href="#">...</a>',"</li>"),6<=this.totalPages&&this.options.pageNumber<=this.totalPages-3&&h.push('<li class="page-last'+(this.totalPages===this.options.pageNumber?" active":"")+'">','<a href="#">',this.totalPages,"</a>","</li>"),h.push('<li class="page-next"><a href="#">'+this.options.paginationNextText+"</a></li>","</ul>","</div>")}this.$pagination.html(h.join("")),this.options.onlyInfoPagination||(p=this.$pagination.find(".page-list a"),e=this.$pagination.find(".page-first"),o=this.$pagination.find(".page-pre"),s=this.$pagination.find(".page-next"),n=this.$pagination.find(".page-last"),a=this.$pagination.find(".page-number"),this.options.smartDisplay&&(this.totalPages<=1&&this.$pagination.find("div.pagination").hide(),(c.length<2||this.options.totalRows<=c[0])&&this.$pagination.find("span.page-list").hide(),this.$pagination[this.getData().length?"show":"hide"]()),this.options.paginationLoop||(1===this.options.pageNumber&&o.addClass("disabled"),this.options.pageNumber===this.totalPages&&s.addClass("disabled")),l&&(this.options.pageSize=this.options.formatAllRows()),p.off("click").on("click",C.proxy(this.onPageListChange,this)),e.off("click").on("click",C.proxy(this.onPageFirst,this)),o.off("click").on("click",C.proxy(this.onPagePre,this)),s.off("click").on("click",C.proxy(this.onPageNext,this)),n.off("click").on("click",C.proxy(this.onPageLast,this)),a.off("click").on("click",C.proxy(this.onPageNumber,this)))}else this.$pagination.hide()},g.prototype.updatePagination=function(t){t&&C(t.currentTarget).hasClass("disabled")||(this.options.maintainSelected||this.resetRows(),this.initPagination(),"server"===this.options.sidePagination?this.initServer():this.initBody(),this.trigger("page-change",this.options.pageNumber,this.options.pageSize))},g.prototype.onPageListChange=function(t){var i=C(t.currentTarget);return i.parent().addClass("active").siblings().removeClass("active"),this.options.pageSize=i.text().toUpperCase()===this.options.formatAllRows().toUpperCase()?this.options.formatAllRows():+i.text(),this.$toolbar.find(".page-size").text(this.options.pageSize),this.updatePagination(t),!1},g.prototype.onPageFirst=function(t){return this.options.pageNumber=1,this.updatePagination(t),!1},g.prototype.onPagePre=function(t){return this.options.pageNumber-1==0?this.options.pageNumber=this.options.totalPages:this.options.pageNumber--,this.updatePagination(t),!1},g.prototype.onPageNext=function(t){return this.options.pageNumber+1>this.options.totalPages?this.options.pageNumber=1:this.options.pageNumber++,this.updatePagination(t),!1},g.prototype.onPageLast=function(t){return this.options.pageNumber=this.totalPages,this.updatePagination(t),!1},g.prototype.onPageNumber=function(t){if(this.options.pageNumber!==+C(t.currentTarget).text())return this.options.pageNumber=+C(t.currentTarget).text(),this.updatePagination(t),!1},g.prototype.initRow=function(v,x,t,i){var e,$=this,S=[],k={},P=[],o="",s={},n=[];if(!(-1<C.inArray(v,this.hiddenRows))){if((k=A(this.options,this.options.rowStyle,[v,x],k))&&k.css)for(e in k.css)P.push(e+": "+k.css[e]);if(s=A(this.options,this.options.rowAttributes,[v,x],s))for(e in s)n.push(T('%s="%s"',e,R(s[e])));return v._data&&!C.isEmptyObject(v._data)&&C.each(v._data,function(t,i){"index"!==t&&(o+=T(' data-%s="%s"',t,i))}),S.push("<tr",T(" %s",n.join(" ")),T(' id="%s"',C.isArray(v)?void 0:v._id),T(' class="%s"',k.classes||(C.isArray(v)?void 0:v._class)),T(' data-index="%s"',x),T(' data-uniqueid="%s"',v[this.options.uniqueId]),T("%s",o),">"),this.options.cardView&&S.push(T('<td colspan="%s"><div class="card-views">',this.header.fields.length)),!this.options.cardView&&this.options.detailView&&S.push("<td>",'<a class="detail-icon" href="#">',T('<i class="%s %s"></i>',this.options.iconsPrefix,this.options.icons.detailOpen),"</a>","</td>"),C.each(this.header.fields,function(t,i){var e="",o=_(v,i,$.options.escape),s="",n={},a="",r=$.header.classes[t],h="",l="",p="",c="",d=$.columns[t];if((!$.fromHtml||void 0!==o)&&d.visible&&(!$.options.cardView||d.cardVisible)){if(d.escape&&(o=R(o)),k=T('style="%s"',P.concat($.header.styles[t]).join("; ")),v["_"+i+"_id"]&&(a=T(' id="%s"',v["_"+i+"_id"])),v["_"+i+"_class"]&&(r=T(' class="%s"',v["_"+i+"_class"])),v["_"+i+"_rowspan"]&&(l=T(' rowspan="%s"',v["_"+i+"_rowspan"])),v["_"+i+"_colspan"]&&(p=T(' colspan="%s"',v["_"+i+"_colspan"])),v["_"+i+"_title"]&&(c=T(' title="%s"',v["_"+i+"_title"])),(n=A($.header,$.header.cellStyles[t],[o,v,x,i],n)).classes&&(r=T(' class="%s"',n.classes)),n.css){var u,f=[];for(u in n.css)f.push(u+": "+n.css[u]);k=T('style="%s"',f.concat($.header.styles[t]).join("; "))}var g,b,m,y,w,s=A(d,$.header.formatters[t],[o,v,x],o);v["_"+i+"_data"]&&!C.isEmptyObject(v["_"+i+"_data"])&&C.each(v["_"+i+"_data"],function(t,i){"index"!==t&&(h+=T(' data-%s="%s"',t,i))}),d.checkbox||d.radio?(g=d.checkbox?"checkbox":"",g=d.radio?"radio":g,e=[T($.options.cardView?'<div class="card-view %s">':'<td class="bs-checkbox %s">',d.class||""),"<input"+T(' data-index="%s"',x)+T(' name="%s"',$.options.selectItemName)+T(' type="%s"',g)+T(' value="%s"',v[$.options.idField])+T(' checked="%s"',!0===s||o||s&&s.checked?"checked":void 0)+T(' disabled="%s"',!d.checkboxEnabled||s&&s.disabled?"disabled":void 0)+" />",$.header.formatters[t]&&"string"==typeof s?s:"",$.options.cardView?"</div>":"</td>"].join(""),v[$.header.stateField]=!0===s||s&&s.checked):(s=null==s?$.options.undefinedText:s,e=($.options.cardView?['<div class="card-view">',$.options.showHeader?T('<span class="title" %s>%s</span>',k,(g=$.columns,b="field",m="title",y=i,w="",C.each(g,function(t,i){return i[b]!==y||(w=i[m],!1)}),w)):"",T('<span class="value">%s</span>',s),"</div>"]:[T("<td%s %s %s %s %s %s %s>",a,r,k,h,l,p,c),s,"</td>"]).join(""),$.options.cardView&&$.options.smartDisplay&&""===s&&(e='<div class="card-view"></div>')),S.push(e)}}),this.options.cardView&&S.push("</div></td>"),S.push("</tr>"),S.join(" ")}},g.prototype.initBody=function(t){for(var l=this,s=this.getData(),i=(this.trigger("pre-body",s),this.$body=this.$el.find(">tbody"),this.$body.length||(this.$body=C("<tbody></tbody>").appendTo(this.$el)),this.options.pagination&&"server"!==this.options.sidePagination||(this.pageFrom=1,this.pageTo=s.length),C(document.createDocumentFragment())),e=this.pageFrom-1;e<this.pageTo;e++){var o=s[e],o=this.initRow(o,e,s,i),n=n||!!o;o&&!0!==o&&i.append(o)}n||i.append('<tr class="no-records-found">'+T('<td colspan="%s">%s</td>',this.$header.find("th").length,this.options.formatNoMatches())+"</tr>"),this.$body.html(i),t||this.scrollTo(0),this.$body.find("> tr[data-index] > td").off("click dblclick").on("click dblclick",function(t){var i=C(this),e=i.parent(),o=l.data[e.data("index")],s=i[0].cellIndex,s=l.getVisibleFields()[l.options.detailView&&!l.options.cardView?s-1:s],n=l.columns[p(l.columns,s)],a=_(o,s,l.options.escape);i.find(".detail-icon").length||(l.trigger("click"===t.type?"click-cell":"dbl-click-cell",s,a,o,i),l.trigger("click"===t.type?"click-row":"dbl-click-row",o,e,s),"click"===t.type&&l.options.clickToSelect&&n.clickToSelect&&(a=e.find(T('[name="%s"]',l.options.selectItemName))).length&&a[0].click())}),this.$body.find("> tr[data-index] > td > .detail-icon").off("click").on("click",function(){var t=C(this),i=t.parent().parent(),e=i.data("index"),o=s[e];return i.next().is("tr.detail-view")?(t.find("i").attr("class",T("%s %s",l.options.iconsPrefix,l.options.icons.detailOpen)),l.trigger("collapse-row",e,o),i.next().remove()):(t.find("i").attr("class",T("%s %s",l.options.iconsPrefix,l.options.icons.detailClose)),i.after(T('<tr class="detail-view"><td colspan="%s"></td></tr>',i.find("td").length)),t=i.next().find("td"),i=A(l.options,l.options.detailFormatter,[e,o,t],""),1===t.length&&t.append(i),l.trigger("expand-row",e,o,t)),l.resetView(),!1}),this.$selectItem=this.$body.find(T('[name="%s"]',this.options.selectItemName)),this.$selectItem.off("click").on("click",function(t){t.stopImmediatePropagation();var t=C(this),i=t.prop("checked"),e=l.data[t.data("index")];l.options.maintainSelected&&C(this).is(":radio")&&C.each(l.options.data,function(t,i){i[l.header.stateField]=!1}),e[l.header.stateField]=i,l.options.singleSelect&&(l.$selectItem.not(this).each(function(){l.data[C(this).data("index")][l.header.stateField]=!1}),l.$selectItem.filter(":checked").not(this).prop("checked",!1)),l.updateSelected(),l.trigger(i?"check":"uncheck",e,t)}),C.each(this.header.events,function(t,o){if(o){"string"==typeof o&&(o=A(null,o));var s,h=l.header.fields[t],n=C.inArray(h,l.getVisibleFields());for(s in l.options.detailView&&!l.options.cardView&&(n+=1),o)l.$body.find(">tr:not(.no-records-found)").each(function(){var a=C(this),t=a.find(l.options.cardView?".card-view":">td").eq(n),i=s.indexOf(" "),e=s.substring(0,i),i=s.substring(i+1),r=o[s];t.find(i).off(e).on(e,function(t){var i=a.data("index"),e=l.data[i],o=e[h],s=h.split(".");if(1<s.length)for(var o=e,n=0;n<s.length;n++)o=o[s[n]];r.apply(this,[t,o,e,i])})})}}),this.updateSelected(),this.resetView(),this.trigger("post-body",s)},g.prototype.initServer=function(i,t,e){var o=this,s={},n={searchText:this.searchText,sortName:this.options.sortName,sortOrder:this.options.sortOrder};this.options.pagination&&(n.pageSize=this.options.pageSize===this.options.formatAllRows()?this.options.totalRows:this.options.pageSize,n.pageNumber=this.options.pageNumber),(e||this.options.url||this.options.ajax)&&("limit"===this.options.queryParamsType&&(n={search:n.searchText,sort:n.sortName,order:n.sortOrder},this.options.pagination)&&(n.offset=this.options.pageSize===this.options.formatAllRows()?0:this.options.pageSize*(this.options.pageNumber-1),n.limit=this.options.pageSize===this.options.formatAllRows()?this.options.totalRows:this.options.pageSize),C.isEmptyObject(this.filterColumnsPartial)||(n.filter=JSON.stringify(this.filterColumnsPartial,null)),s=A(this.options,this.options.queryParams,[n],s),C.extend(s,t||{}),!1!==s)&&(i||this.$tableLoading.show(),n=C.extend({},A(null,this.options.ajaxOptions),{type:this.options.method,url:e||this.options.url,data:"application/json"===this.options.contentType&&"post"===this.options.method?JSON.stringify(s):s,cache:this.options.cache,contentType:this.options.contentType,dataType:this.options.dataType,success:function(t){t=A(o.options,o.options.responseHandler,[t],t),o.load(t),o.trigger("load-success",t),i||o.$tableLoading.hide()},error:function(t){o.trigger("load-error",t.status,t),i||o.$tableLoading.hide()}}),this.options.ajax?A(this,this.options.ajax,[n],null):(this._xhr&&4!==this._xhr.readyState&&this._xhr.abort(),this._xhr=C.ajax(n)))},g.prototype.initSearchText=function(){var t;this.options.search&&""!==this.options.searchText&&((t=this.$toolbar.find(".search input")).val(this.options.searchText),this.onSearch({currentTarget:t}))},g.prototype.getCaret=function(){var e=this;C.each(this.$header.find("th"),function(t,i){C(i).find(".sortable").removeClass("desc asc").addClass(C(i).data("field")===e.options.sortName?e.options.sortOrder:"both")})},g.prototype.updateSelected=function(){var t=this.$selectItem.filter(":enabled").length&&this.$selectItem.filter(":enabled").length===this.$selectItem.filter(":enabled").filter(":checked").length;this.$selectAll.add(this.$selectAll_).prop("checked",t),this.$selectItem.each(function(){C(this).closest("tr")[C(this).prop("checked")?"addClass":"removeClass"]("selected")})},g.prototype.updateRows=function(){var t=this;this.$selectItem.each(function(){t.data[C(this).data("index")][t.header.stateField]=C(this).prop("checked")})},g.prototype.resetRows=function(){var e=this;C.each(this.data,function(t,i){e.$selectAll.prop("checked",!1),e.$selectItem.prop("checked",!1),e.header.stateField&&(i[e.header.stateField]=!1)}),this.initHiddenRows()},g.prototype.trigger=function(t){var i=Array.prototype.slice.call(arguments,1);this.options[g.EVENTS[t+=".bs.table"]].apply(this.options,i),this.$el.trigger(C.Event(t),i),this.options.onAll(t,i),this.$el.trigger(C.Event("all.bs.table"),[t,i])},g.prototype.resetHeader=function(){clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(C.proxy(this.fitHeader,this),this.$el.is(":hidden")?100:0)},g.prototype.fitHeader=function(){var t,i,o,s,n=this;n.$el.is(":hidden")?n.timeoutId_=setTimeout(C.proxy(n.fitHeader,n),100):(i=(i=this.$tableBody.get(0)).scrollWidth>i.clientWidth&&i.scrollHeight>i.clientHeight+this.$header.outerHeight()?a():0,this.$el.css("margin-top",-this.$header.outerHeight()),0<(t=C(":focus")).length&&0<(t=t.parents("th")).length&&void 0!==(t=t.attr("data-field"))&&0<(t=this.$header.find("[data-field='"+t+"']")).length&&t.find(":input").addClass("focus-temp"),this.$header_=this.$header.clone(!0,!0),this.$selectAll_=this.$header_.find('[name="btSelectAll"]'),this.$tableHeader.css({"margin-right":i}).find("table").css("width",this.$el.outerWidth()).html("").attr("class",this.$el.attr("class")).append(this.$header_),0<(t=C(".focus-temp:visible:eq(0)")).length&&(t.focus(),this.$header.find(".focus-temp").removeClass("focus-temp")),this.$header.find("th[data-field]").each(function(t){n.$header_.find(T('th[data-field="%s"]',C(this).data("field"))).data(C(this).data())}),o=this.getVisibleFields(),s=this.$header_.find("th"),this.$body.find(">tr:first-child:not(.no-records-found) > *").each(function(t){var i=C(this),e=t,t=(n.options.detailView&&!n.options.cardView&&(0===t&&n.$header_.find("th.detail").find(".fht-cell").width(i.innerWidth()),e=t-1),n.$header_.find(T('th[data-field="%s"]',o[e])));(t=1<t.length?C(s[i[0].cellIndex]):t).find(".fht-cell").width(i.innerWidth())}),this.$tableBody.off("scroll").on("scroll",function(){n.$tableHeader.scrollLeft(C(this).scrollLeft()),n.options.showFooter&&!n.options.cardView&&n.$tableFooter.scrollLeft(C(this).scrollLeft())}),n.trigger("post-header"))},g.prototype.resetFooter=function(){var h=this,l=h.getData(),p=[];this.options.showFooter&&!this.options.cardView&&(!this.options.cardView&&this.options.detailView&&p.push('<td><div class="th-inner">&nbsp;</div><div class="fht-cell"></div></td>'),C.each(this.columns,function(t,i){var e,o,s,n,a=[],r=T(' class="%s"',i.class);if(i.visible&&(!h.options.cardView||i.cardVisible)){if(o=T("text-align: %s; ",i.falign||i.align),s=T("vertical-align: %s; ",i.valign),(n=A(null,h.options.footerStyle))&&n.css)for(e in n.css)a.push(e+": "+n.css[e]);p.push("<td",r,T(' style="%s"',o+s+a.concat().join("; ")),">"),p.push('<div class="th-inner">'),p.push(A(i,i.footerFormatter,[l],"&nbsp;")||"&nbsp;"),p.push("</div>"),p.push('<div class="fht-cell"></div>'),p.push("</div>"),p.push("</td>")}}),this.$tableFooter.find("tr").html(p.join("")),this.$tableFooter.show(),clearTimeout(this.timeoutFooter_),this.timeoutFooter_=setTimeout(C.proxy(this.fitFooter,this),this.$el.is(":hidden")?100:0))},g.prototype.fitFooter=function(){var e,t,i;clearTimeout(this.timeoutFooter_),this.$el.is(":hidden")?this.timeoutFooter_=setTimeout(C.proxy(this.fitFooter,this),100):(i=(t=this.$el.css("width"))>this.$tableBody.width()?a():0,this.$tableFooter.css({"margin-right":i}).find("table").css("width",t).attr("class",this.$el.attr("class")),e=this.$tableFooter.find("td"),this.$body.find(">tr:first-child:not(.no-records-found) > *").each(function(t){var i=C(this);e.eq(t).find(".fht-cell").width(i.innerWidth())}))},g.prototype.toggleColumn=function(t,i,e){var o;-1!==t&&(this.columns[t].visible=i,this.initHeader(),this.initSearch(),this.initPagination(),this.initBody(),this.options.showColumns)&&(o=this.$toolbar.find(".keep-open input").prop("disabled",!1),e&&o.filter(T('[value="%s"]',t)).prop("checked",i),o.filter(":checked").length<=this.options.minimumCountColumns)&&o.filter(":checked").prop("disabled",!0)},g.prototype.getVisibleFields=function(){var e=this,o=[];return C.each(this.header.fields,function(t,i){e.columns[p(e.columns,i)].visible&&o.push(i)}),o},g.prototype.resetView=function(t){var i,e=0;t&&t.height&&(this.options.height=t.height),this.$selectAll.prop("checked",0<this.$selectItem.length&&this.$selectItem.length===this.$selectItem.filter(":checked").length),this.options.height&&(t=this.$toolbar.outerHeight(!0),i=this.$pagination.outerHeight(!0),t=this.options.height-t-i,this.$tableContainer.css("height",t+"px")),this.options.cardView?(this.$el.css("margin-top","0"),this.$tableContainer.css("padding-bottom","0"),this.$tableFooter.hide()):(this.options.showHeader&&this.options.height?(this.$tableHeader.show(),this.resetHeader(),e+=this.$header.outerHeight()):(this.$tableHeader.hide(),this.trigger("post-header")),this.options.showFooter&&(this.resetFooter(),this.options.height)&&(e+=this.$tableFooter.outerHeight()+1),this.getCaret(),this.$tableContainer.css("padding-bottom",e+"px"),this.trigger("reset-view"))},g.prototype.getData=function(t){return!this.searchText&&C.isEmptyObject(this.filterColumns)&&C.isEmptyObject(this.filterColumnsPartial)?t?this.options.data.slice(this.pageFrom-1,this.pageTo):this.options.data:t?this.data.slice(this.pageFrom-1,this.pageTo):this.data},g.prototype.load=function(t){var i=!1;"server"===this.options.sidePagination?(this.options.totalRows=t[this.options.totalField],i=t.fixedScroll,t=t[this.options.dataField]):C.isArray(t)||(i=t.fixedScroll,t=t.data),this.initData(t),this.initSearch(),this.initPagination(),this.initBody(i)},g.prototype.append=function(t){this.initData(t,"append"),this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0)},g.prototype.prepend=function(t){this.initData(t,"prepend"),this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0)},g.prototype.remove=function(t){var i,e,o=this.options.data.length;if(t.hasOwnProperty("field")&&t.hasOwnProperty("values")){for(i=o-1;0<=i;i--)(e=this.options.data[i]).hasOwnProperty(t.field)&&-1!==C.inArray(e[t.field],t.values)&&(this.options.data.splice(i,1),"server"===this.options.sidePagination)&&--this.options.totalRows;o!==this.options.data.length&&(this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0))}},g.prototype.removeAll=function(){0<this.options.data.length&&(this.options.data.splice(0,this.options.data.length),this.initSearch(),this.initPagination(),this.initBody(!0))},g.prototype.getRowByUniqueId=function(t){for(var i,e,o=this.options.uniqueId,s=null,n=this.options.data.length-1;0<=n;n--){if((i=this.options.data[n]).hasOwnProperty(o))e=i[o];else{if(!i._data.hasOwnProperty(o))continue;e=i._data[o]}if("string"==typeof e?t=t.toString():"number"==typeof e&&(Number(e)===e&&e%1==0?t=parseInt(t):e===Number(e)&&0!==e&&(t=parseFloat(t))),e===t){s=i;break}}return s},g.prototype.removeByUniqueId=function(t){var i=this.options.data.length,t=this.getRowByUniqueId(t);t&&this.options.data.splice(this.options.data.indexOf(t),1),i!==this.options.data.length&&(this.initSearch(),this.initPagination(),this.initBody(!0))},g.prototype.updateByUniqueId=function(t){var o=this,t=C.isArray(t)?t:[t];C.each(t,function(t,i){var e;i.hasOwnProperty("id")&&i.hasOwnProperty("row")&&-1!==(e=C.inArray(o.getRowByUniqueId(i.id),o.options.data))&&C.extend(o.options.data[e],i.row)}),this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0)},g.prototype.insertRow=function(t){t.hasOwnProperty("index")&&t.hasOwnProperty("row")&&(this.data.splice(t.index,0,t.row),this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0))},g.prototype.updateRow=function(t){var e=this,t=C.isArray(t)?t:[t];C.each(t,function(t,i){i.hasOwnProperty("index")&&i.hasOwnProperty("row")&&C.extend(e.options.data[i.index],i.row)}),this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0)},g.prototype.initHiddenRows=function(){this.hiddenRows=[]},g.prototype.showRow=function(t){this.toggleRow(t,!0)},g.prototype.hideRow=function(t){this.toggleRow(t,!1)},g.prototype.toggleRow=function(t,i){var e;t.hasOwnProperty("index")?e=this.getData()[t.index]:t.hasOwnProperty("uniqueId")&&(e=this.getRowByUniqueId(t.uniqueId)),e&&(t=C.inArray(e,this.hiddenRows),i||-1!==t?i&&-1<t&&this.hiddenRows.splice(t,1):this.hiddenRows.push(e),this.initBody(!0))},g.prototype.getHiddenRows=function(t){var e=this,i=this.getData(),o=[];return C.each(i,function(t,i){-1<C.inArray(i,e.hiddenRows)&&o.push(i)}),this.hiddenRows=o},g.prototype.mergeCells=function(t){var i,e,o=t.index,s=C.inArray(t.field,this.getVisibleFields()),n=t.rowspan||1,a=t.colspan||1,r=this.$body.find(">tr");if(this.options.detailView&&!this.options.cardView&&(s+=1),t=r.eq(o).find(">td").eq(s),!(o<0||s<0||o>=this.data.length)){for(i=o;i<o+n;i++)for(e=s;e<s+a;e++)r.eq(i).find(">td").eq(e).hide();t.attr("rowspan",n).attr("colspan",a).show()}},g.prototype.updateCell=function(t){t.hasOwnProperty("index")&&t.hasOwnProperty("field")&&t.hasOwnProperty("value")&&(this.data[t.index][t.field]=t.value,!1!==t.reinit)&&(this.initSort(),this.initBody(!0))},g.prototype.getOptions=function(){return this.options},g.prototype.getSelections=function(){var i=this;return C.grep(this.options.data,function(t){return!0===t[i.header.stateField]})},g.prototype.getAllSelections=function(){var i=this;return C.grep(this.options.data,function(t){return t[i.header.stateField]})},g.prototype.checkAll=function(){this.checkAll_(!0)},g.prototype.uncheckAll=function(){this.checkAll_(!1)},g.prototype.checkInvert=function(){var t=this,i=t.$selectItem.filter(":enabled"),e=i.filter(":checked");i.each(function(){C(this).prop("checked",!C(this).prop("checked"))}),t.updateRows(),t.updateSelected(),t.trigger("uncheck-some",e),e=t.getSelections(),t.trigger("check-some",e)},g.prototype.checkAll_=function(t){var i;t||(i=this.getSelections()),this.$selectAll.add(this.$selectAll_).prop("checked",t),this.$selectItem.filter(":enabled").prop("checked",t),this.updateRows(),t&&(i=this.getSelections()),this.trigger(t?"check-all":"uncheck-all",i)},g.prototype.check=function(t){this.check_(!0,t)},g.prototype.uncheck=function(t){this.check_(!1,t)},g.prototype.check_=function(t,i){var e=this.$selectItem.filter(T('[data-index="%s"]',i)).prop("checked",t);this.data[i][this.header.stateField]=t,this.updateSelected(),this.trigger(t?"check":"uncheck",this.data[i],e)},g.prototype.checkBy=function(t){this.checkBy_(!0,t)},g.prototype.uncheckBy=function(t){this.checkBy_(!1,t)},g.prototype.checkBy_=function(e,o){var s,n;o.hasOwnProperty("field")&&o.hasOwnProperty("values")&&(n=[],C.each((s=this).options.data,function(t,i){if(!i.hasOwnProperty(o.field))return!1;-1!==C.inArray(i[o.field],o.values)&&(t=s.$selectItem.filter(":enabled").filter(T('[data-index="%s"]',t)).prop("checked",e),i[s.header.stateField]=e,n.push(i),s.trigger(e?"check":"uncheck",i,t))}),this.updateSelected(),this.trigger(e?"check-some":"uncheck-some",n))},g.prototype.destroy=function(){this.$el.insertBefore(this.$container),C(this.options.toolbar).insertBefore(this.$el),this.$container.next().remove(),this.$container.remove(),this.$el.html(this.$el_.html()).css("margin-top","0").attr("class",this.$el_.attr("class")||"")},g.prototype.showLoading=function(){this.$tableLoading.show()},g.prototype.hideLoading=function(){this.$tableLoading.hide()},g.prototype.togglePagination=function(){this.options.pagination=!this.options.pagination;var t=this.$toolbar.find('button[name="paginationSwitch"] i');this.options.pagination?t.attr("class",this.options.iconsPrefix+" "+this.options.icons.paginationSwitchDown):t.attr("class",this.options.iconsPrefix+" "+this.options.icons.paginationSwitchUp),this.updatePagination()},g.prototype.refresh=function(t){t&&t.url&&(this.options.url=t.url),t&&t.pageNumber&&(this.options.pageNumber=t.pageNumber),t&&t.pageSize&&(this.options.pageSize=t.pageSize),this.initServer(t&&t.silent,t&&t.query,t&&t.url),this.trigger("refresh",t)},g.prototype.resetWidth=function(){this.options.showHeader&&this.options.height&&this.fitHeader(),this.options.showFooter&&this.fitFooter()},g.prototype.showColumn=function(t){this.toggleColumn(p(this.columns,t),!0,!0)},g.prototype.hideColumn=function(t){this.toggleColumn(p(this.columns,t),!1,!0)},g.prototype.getHiddenColumns=function(){return C.grep(this.columns,function(t){return!t.visible})},g.prototype.getVisibleColumns=function(){return C.grep(this.columns,function(t){return t.visible})},g.prototype.toggleAllColumns=function(e){var t;C.each(this.columns,function(t,i){this.columns[t].visible=e}),this.initHeader(),this.initSearch(),this.initPagination(),this.initBody(),this.options.showColumns&&(t=this.$toolbar.find(".keep-open input").prop("disabled",!1)).filter(":checked").length<=this.options.minimumCountColumns&&t.filter(":checked").prop("disabled",!0)},g.prototype.showAllColumns=function(){this.toggleAllColumns(!0)},g.prototype.hideAllColumns=function(){this.toggleAllColumns(!1)},g.prototype.filterBy=function(t){this.filterColumns=C.isEmptyObject(t)?{}:t,this.options.pageNumber=1,this.initSearch(),this.updatePagination()},g.prototype.scrollTo=function(t){if("number"==typeof(t="string"==typeof t?"bottom"===t?this.$tableBody[0].scrollHeight:0:t)&&this.$tableBody.scrollTop(t),void 0===t)return this.$tableBody.scrollTop()},g.prototype.getScrollPosition=function(){return this.scrollTo()},g.prototype.selectPage=function(t){0<t&&t<=this.options.totalPages&&(this.options.pageNumber=t,this.updatePagination())},g.prototype.prevPage=function(){1<this.options.pageNumber&&(this.options.pageNumber--,this.updatePagination())},g.prototype.nextPage=function(){this.options.pageNumber<this.options.totalPages&&(this.options.pageNumber++,this.updatePagination())},g.prototype.toggleView=function(){this.options.cardView=!this.options.cardView,this.initHeader(),this.initBody(),this.trigger("toggle",this.options.cardView)},g.prototype.refreshOptions=function(t){i(this.options,t,!0)||(this.options=C.extend(this.options,t),this.trigger("refresh-options",this.options),this.destroy(),this.init())},g.prototype.resetSearch=function(t){var i=this.$toolbar.find(".search input");i.val(t||""),this.onSearch({currentTarget:i})},g.prototype.expandRow_=function(t,i){i=this.$body.find(T('> tr[data-index="%s"]',i));i.next().is("tr.detail-view")===!t&&i.find("> td > .detail-icon").click()},g.prototype.expandRow=function(t){this.expandRow_(!0,t)},g.prototype.collapseRow=function(t){this.expandRow_(!1,t)},g.prototype.expandAllRows=function(t){if(t){var t=this.$body.find(T('> tr[data-index="%s"]',0)),i=this,e=null,o=!1,s=-1;if(t.next().is("tr.detail-view")?t.next().next().is("tr.detail-view")||(t.next().find(".detail-icon").click(),o=!0):(t.find("> td > .detail-icon").click(),o=!0),o)try{s=setInterval(function(){0<(e=i.$body.find("tr.detail-view").last().find(".detail-icon")).length?e.click():clearInterval(s)},1)}catch(t){clearInterval(s)}}else for(var n=this.$body.children(),a=0;a<n.length;a++)this.expandRow_(!0,C(n[a]).data("index"))},g.prototype.collapseAllRows=function(t){if(t)this.expandRow_(!1,0);else for(var i=this.$body.children(),e=0;e<i.length;e++)this.expandRow_(!1,C(i[e]).data("index"))},g.prototype.updateFormatText=function(t,i){this.options[T("format%s",t)]&&("string"==typeof i?this.options[T("format%s",t)]=function(){return i}:"function"==typeof i&&(this.options[T("format%s",t)]=i)),this.initToolbar(),this.initPagination(),this.initBody()},["getOptions","getSelections","getAllSelections","getData","load","append","prepend","remove","removeAll","insertRow","updateRow","updateCell","updateByUniqueId","removeByUniqueId","getRowByUniqueId","showRow","hideRow","getHiddenRows","mergeCells","checkAll","uncheckAll","checkInvert","check","uncheck","checkBy","uncheckBy","refresh","resetView","resetWidth","destroy","showLoading","hideLoading","showColumn","hideColumn","getHiddenColumns","getVisibleColumns","showAllColumns","hideAllColumns","filterBy","scrollTo","getScrollPosition","selectPage","prevPage","nextPage","togglePagination","toggleView","refreshOptions","resetSearch","expandRow","collapseRow","expandAllRows","collapseAllRows","updateFormatText"]);C.fn.bootstrapTable=function(o){var s,n=Array.prototype.slice.call(arguments,1);return this.each(function(){var t=C(this),i=t.data("bootstrap.table"),e=C.extend({},g.DEFAULTS,t.data(),"object"==typeof o&&o);if("string"==typeof o){if(C.inArray(o,r)<0)throw new Error("Unknown method: "+o);if(!i)return;s=i[o].apply(i,n),"destroy"===o&&t.removeData("bootstrap.table")}i||t.data("bootstrap.table",i=new g(this,e))}),void 0===s?this:s},C.fn.bootstrapTable.Constructor=g,C.fn.bootstrapTable.defaults=g.DEFAULTS,C.fn.bootstrapTable.columnDefaults=g.COLUMN_DEFAULTS,C.fn.bootstrapTable.locales=g.LOCALES,C.fn.bootstrapTable.methods=r,C.fn.bootstrapTable.utils={sprintf:T,getFieldIndex:p,compareObjects:i,calculateObjectValue:A,getItemField:_,objectKeys:function(){var s,n,a,r;Object.keys||(Object.keys=(s=Object.prototype.hasOwnProperty,n=!{toString:null}.propertyIsEnumerable("toString"),r=(a=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"]).length,function(t){if("object"!=typeof t&&("function"!=typeof t||null===t))throw new TypeError("Object.keys called on non-object");var i,e,o=[];for(i in t)s.call(t,i)&&o.push(i);if(n)for(e=0;e<r;e++)s.call(t,a[e])&&o.push(a[e]);return o}))},isIEBrowser:e},C(function(){C('[data-toggle="table"]').bootstrapTable()})}(jQuery);
  6354. define("bootstrap-table", ["bootstrap"], (function (global) {
  6355. return function () {
  6356. var ret, fn;
  6357. return ret || global.$.fn.bootstrapTable;
  6358. };
  6359. }(this)));
  6360. /**
  6361. * Bootstrap Table Chinese translation
  6362. * Author: Zhixin Wen<wenzhixin2010@gmail.com>
  6363. */
  6364. (function ($) {
  6365. 'use strict';
  6366. $.fn.bootstrapTable.locales['zh-CN'] = {
  6367. formatLoadingMessage: function () {
  6368. return '正在努力地加载数据中,请稍候……';
  6369. },
  6370. formatRecordsPerPage: function (pageNumber) {
  6371. return '每页显示 ' + pageNumber + ' 条记录';
  6372. },
  6373. formatShowingRows: function (pageFrom, pageTo, totalRows) {
  6374. return '显示第 ' + pageFrom + ' 到第 ' + pageTo + ' 条记录,总共 ' + totalRows + ' 条记录';
  6375. },
  6376. formatDetailPagination: function (totalRows) {
  6377. return '总共 ' + totalRows + ' 条记录';
  6378. },
  6379. formatSearch: function () {
  6380. return '搜索';
  6381. },
  6382. formatNoMatches: function () {
  6383. return '没有找到匹配的记录';
  6384. },
  6385. formatPaginationSwitch: function () {
  6386. return '隐藏/显示分页';
  6387. },
  6388. formatRefresh: function () {
  6389. return '刷新';
  6390. },
  6391. formatToggle: function () {
  6392. return '切换';
  6393. },
  6394. formatColumns: function () {
  6395. return '列';
  6396. },
  6397. formatExport: function () {
  6398. return '导出数据';
  6399. },
  6400. formatClearFilters: function () {
  6401. return '清空过滤';
  6402. }
  6403. };
  6404. $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['zh-CN']);
  6405. })(jQuery);
  6406. define("bootstrap-table-lang", ["bootstrap-table"], (function (global) {
  6407. return function () {
  6408. var ret, fn;
  6409. return ret || global.$.fn.bootstrapTable.defaults;
  6410. };
  6411. }(this)));
  6412. /**
  6413. * @author zhixin wen <wenzhixin2010@gmail.com>
  6414. * extensions: https://github.com/kayalshri/tableExport.jquery.plugin
  6415. */
  6416. (function ($) {
  6417. 'use strict';
  6418. var sprintf = $.fn.bootstrapTable.utils.sprintf;
  6419. var TYPE_NAME = {
  6420. json: 'JSON',
  6421. xml: 'XML',
  6422. png: 'PNG',
  6423. csv: 'CSV',
  6424. txt: 'TXT',
  6425. sql: 'SQL',
  6426. doc: 'MS-Word',
  6427. excel: 'MS-Excel',
  6428. xlsx: 'MS-Excel (OpenXML)',
  6429. powerpoint: 'MS-Powerpoint',
  6430. pdf: 'PDF'
  6431. };
  6432. $.extend($.fn.bootstrapTable.defaults, {
  6433. showExport: false,
  6434. exportDataType: 'basic', // basic, all, selected
  6435. // 'json', 'xml', 'png', 'csv', 'txt', 'sql', 'doc', 'excel', 'powerpoint', 'pdf'
  6436. exportTypes: ['json', 'xml', 'csv', 'txt', 'sql', 'excel'],
  6437. exportOptions: {}
  6438. });
  6439. $.extend($.fn.bootstrapTable.defaults.icons, {
  6440. export: 'glyphicon-export icon-share'
  6441. });
  6442. $.extend($.fn.bootstrapTable.locales, {
  6443. formatExport: function () {
  6444. return 'Export data';
  6445. }
  6446. });
  6447. $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);
  6448. var BootstrapTable = $.fn.bootstrapTable.Constructor,
  6449. _initToolbar = BootstrapTable.prototype.initToolbar;
  6450. BootstrapTable.prototype.initToolbar = function () {
  6451. this.showToolbar = this.options.showExport;
  6452. _initToolbar.apply(this, Array.prototype.slice.apply(arguments));
  6453. if (this.options.showExport) {
  6454. var that = this,
  6455. $btnGroup = this.$toolbar.find('>.btn-group'),
  6456. $export = $btnGroup.find('div.export');
  6457. if (!$export.length) {
  6458. $export = $([
  6459. '<div class="export btn-group">',
  6460. '<button class="btn' +
  6461. sprintf(' btn-%s', this.options.buttonsClass) +
  6462. sprintf(' btn-%s', this.options.iconSize) +
  6463. ' dropdown-toggle" aria-label="export type" ' +
  6464. 'title="' + this.options.formatExport() + '" ' +
  6465. 'data-toggle="dropdown" type="button">',
  6466. sprintf('<i class="%s %s"></i> ', this.options.iconsPrefix, this.options.icons.export),
  6467. '<span class="caret"></span>',
  6468. '</button>',
  6469. '<ul class="dropdown-menu" role="menu">',
  6470. '</ul>',
  6471. '</div>'].join('')).appendTo($btnGroup);
  6472. var $menu = $export.find('.dropdown-menu'),
  6473. exportTypes = this.options.exportTypes;
  6474. if (typeof this.options.exportTypes === 'string') {
  6475. var types = this.options.exportTypes.slice(1, -1).replace(/ /g, '').split(',');
  6476. exportTypes = [];
  6477. $.each(types, function (i, value) {
  6478. exportTypes.push(value.slice(1, -1));
  6479. });
  6480. }
  6481. $.each(exportTypes, function (i, type) {
  6482. if (TYPE_NAME.hasOwnProperty(type)) {
  6483. $menu.append(['<li role="menuitem" data-type="' + type + '">',
  6484. '<a href="javascript:void(0)">',
  6485. TYPE_NAME[type],
  6486. '</a>',
  6487. '</li>'].join(''));
  6488. }
  6489. });
  6490. $menu.find('li').click(function () {
  6491. var li = this;
  6492. if (typeof require !== 'function') {
  6493. throw new Error("RequireJS not found");
  6494. }
  6495. require(['tableexport'], function () {
  6496. var type = $(li).data('type'),
  6497. doExport = function () {
  6498. that.$el.tableExport($.extend({}, that.options.exportOptions, {
  6499. type: type,
  6500. escape: false
  6501. }));
  6502. };
  6503. if (that.options.exportDataType === 'all' && that.options.pagination) {
  6504. that.$el.one(that.options.sidePagination === 'server' ? 'post-body.bs.table' : 'page-change.bs.table', function () {
  6505. doExport();
  6506. that.togglePagination();
  6507. });
  6508. that.togglePagination();
  6509. } else if (that.options.exportDataType === 'selected') {
  6510. var data = that.getData(),
  6511. selectedData = that.getAllSelections();
  6512. // Quick fix #2220
  6513. if (that.options.sidePagination === 'server') {
  6514. data = {total: that.options.totalRows};
  6515. data[that.options.dataField] = that.getData();
  6516. var Table = typeof require === 'function' ? require('table') : null;
  6517. selectedData = {total: that.options.totalRows};
  6518. selectedData[that.options.dataField] = Table && that.options.maintainSelected ? Table.api.selecteddata(that.$el) : that.getAllSelections();
  6519. }
  6520. that.load(selectedData);
  6521. doExport();
  6522. that.load(data);
  6523. } else {
  6524. doExport();
  6525. }
  6526. });
  6527. });
  6528. }
  6529. }
  6530. };
  6531. })(jQuery);
  6532. define("bootstrap-table-export", ["bootstrap-table"], (function (global) {
  6533. return function () {
  6534. var ret, fn;
  6535. return ret || global.$.fn.bootstrapTable.defaults;
  6536. };
  6537. }(this)));
  6538. (function(factory){if(typeof define==="function"&&define.amd){define('dropzone',["jquery"],factory)}else{factory(jQuery)}})(function(jQuery){var module={exports:{}};"use strict";function _typeof(obj){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj}}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj}}return _typeof(obj)}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call}return _assertThisInitialized(self)}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)};return _getPrototypeOf(o)}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function")}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass)}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o};return _setPrototypeOf(o,p)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a 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)}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor}var Emitter=function(){function Emitter(){_classCallCheck(this,Emitter)}_createClass(Emitter,[{key:"on",value:function on(event,fn){this._callbacks=this._callbacks||{};if(!this._callbacks[event]){this._callbacks[event]=[]}this._callbacks[event].push(fn);return this}},{key:"emit",value:function emit(event){this._callbacks=this._callbacks||{};var callbacks=this._callbacks[event];if(callbacks){for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key]}var _iteratorNormalCompletion=true;var _didIteratorError=false;var _iteratorError=undefined;try{for(var _iterator=callbacks[Symbol.iterator](),_step;!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=true){var callback=_step.value;callback.apply(this,args)}}catch(err){_didIteratorError=true;_iteratorError=err}finally{try{if(!_iteratorNormalCompletion&&_iterator["return"]!=null){_iterator["return"]()}}finally{if(_didIteratorError){throw _iteratorError}}}}return this}},{key:"off",value:function off(event,fn){if(!this._callbacks||arguments.length===0){this._callbacks={};return this}var callbacks=this._callbacks[event];if(!callbacks){return this}if(arguments.length===1){delete this._callbacks[event];return this}for(var i=0;i<callbacks.length;i++){var callback=callbacks[i];if(callback===fn){callbacks.splice(i,1);break}}return this}}]);return Emitter}();var Dropzone=function(_Emitter){_inherits(Dropzone,_Emitter);_createClass(Dropzone,null,[{key:"initClass",value:function initClass(){this.prototype.Emitter=Emitter;this.prototype.events=["drop","dragstart","dragend","dragenter","dragover","dragleave","addedfile","addedfiles","removedfile","thumbnail","error","errormultiple","processing","processingmultiple","uploadprogress","totaluploadprogress","sending","sendingmultiple","success","successmultiple","canceled","canceledmultiple","complete","completemultiple","reset","maxfilesexceeded","maxfilesreached","queuecomplete"];this.prototype.defaultOptions={url:null,method:"post",withCredentials:false,timeout:3e4,parallelUploads:2,uploadMultiple:false,chunking:false,forceChunking:false,chunkSize:2e6,parallelChunkUploads:false,retryChunks:false,retryChunksLimit:3,maxFilesize:256,paramName:"file",createImageThumbnails:true,maxThumbnailFilesize:10,thumbnailWidth:120,thumbnailHeight:120,thumbnailMethod:"crop",resizeWidth:null,resizeHeight:null,resizeMimeType:null,resizeQuality:.8,resizeMethod:"contain",filesizeBase:1e3,maxFiles:null,headers:null,clickable:true,ignoreHiddenFiles:true,acceptedFiles:null,acceptedMimeTypes:null,autoProcessQueue:true,autoQueue:true,addRemoveLinks:false,previewsContainer:null,hiddenInputContainer:"body",capture:null,renameFilename:null,renameFile:null,forceFallback:false,dictDefaultMessage:"Drop files here to upload",dictFallbackMessage:"Your browser does not support drag'n'drop file uploads.",dictFallbackText:"Please use the fallback form below to upload your files like in the olden days.",dictFileTooBig:"File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB.",dictInvalidFileType:"You can't upload files of this type.",dictResponseError:"Server responded with {{statusCode}} code.",dictCancelUpload:"Cancel upload",dictUploadCanceled:"Upload canceled.",dictCancelUploadConfirmation:"Are you sure you want to cancel this upload?",dictRemoveFile:"Remove file",dictRemoveFileConfirmation:null,dictMaxFilesExceeded:"You can not upload any more files.",dictFileSizeUnits:{tb:"TB",gb:"GB",mb:"MB",kb:"KB",b:"b"},init:function init(){},params:function params(files,xhr,chunk){if(chunk){return{dzuuid:chunk.file.upload.uuid,dzchunkindex:chunk.index,dztotalfilesize:chunk.file.size,dzchunksize:this.options.chunkSize,dztotalchunkcount:chunk.file.upload.totalChunkCount,dzchunkbyteoffset:chunk.index*this.options.chunkSize}}},accept:function accept(file,done){return done()},chunkSuccess:function(chunk,file,response){},chunksUploaded:function chunksUploaded(file,done){done()},fallback:function fallback(){var messageElement;this.element.className="".concat(this.element.className," dz-browser-not-supported");var _iteratorNormalCompletion2=true;var _didIteratorError2=false;var _iteratorError2=undefined;try{for(var _iterator2=this.element.getElementsByTagName("div")[Symbol.iterator](),_step2;!(_iteratorNormalCompletion2=(_step2=_iterator2.next()).done);_iteratorNormalCompletion2=true){var child=_step2.value;if(/(^| )dz-message($| )/.test(child.className)){messageElement=child;child.className="dz-message";break}}}catch(err){_didIteratorError2=true;_iteratorError2=err}finally{try{if(!_iteratorNormalCompletion2&&_iterator2["return"]!=null){_iterator2["return"]()}}finally{if(_didIteratorError2){throw _iteratorError2}}}if(!messageElement){messageElement=Dropzone.createElement('<div class="dz-message"><span></span></div>');this.element.appendChild(messageElement)}var span=messageElement.getElementsByTagName("span")[0];if(span){if(span.textContent!=null){span.textContent=this.options.dictFallbackMessage}else if(span.innerText!=null){span.innerText=this.options.dictFallbackMessage}}return this.element.appendChild(this.getFallbackForm())},resize:function resize(file,width,height,resizeMethod){var info={srcX:0,srcY:0,srcWidth:file.width,srcHeight:file.height};var srcRatio=file.width/file.height;if(width==null&&height==null){width=info.srcWidth;height=info.srcHeight}else if(width==null){width=height*srcRatio}else if(height==null){height=width/srcRatio}width=Math.min(width,info.srcWidth);height=Math.min(height,info.srcHeight);var trgRatio=width/height;if(info.srcWidth>width||info.srcHeight>height){if(resizeMethod==="crop"){if(srcRatio>trgRatio){info.srcHeight=file.height;info.srcWidth=info.srcHeight*trgRatio}else{info.srcWidth=file.width;info.srcHeight=info.srcWidth/trgRatio}}else if(resizeMethod==="contain"){if(srcRatio>trgRatio){height=width/srcRatio}else{width=height*srcRatio}}else{throw new Error("Unknown resizeMethod '".concat(resizeMethod,"'"))}}info.srcX=(file.width-info.srcWidth)/2;info.srcY=(file.height-info.srcHeight)/2;info.trgWidth=width;info.trgHeight=height;return info},transformFile:function transformFile(file,done){if((this.options.resizeWidth||this.options.resizeHeight)&&file.type.match(/image.*/)){return this.resizeImage(file,this.options.resizeWidth,this.options.resizeHeight,this.options.resizeMethod,done)}else{return done(file)}},previewTemplate:'<div class="dz-preview dz-file-preview">\n <div class="dz-image"><img data-dz-thumbnail /></div>\n <div class="dz-details">\n <div class="dz-size"><span data-dz-size></span></div>\n <div class="dz-filename"><span data-dz-name></span></div>\n </div>\n <div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress></span></div>\n <div class="dz-error-message"><span data-dz-errormessage></span></div>\n <div class="dz-success-mark">\n <svg width="54px" height="54px" viewBox="0 0 54 54" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">\n <title>Check</title>\n <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">\n <path d="M23.5,31.8431458 L17.5852419,25.9283877 C16.0248253,24.3679711 13.4910294,24.366835 11.9289322,25.9289322 C10.3700136,27.4878508 10.3665912,30.0234455 11.9283877,31.5852419 L20.4147581,40.0716123 C20.5133999,40.1702541 20.6159315,40.2626649 20.7218615,40.3488435 C22.2835669,41.8725651 24.794234,41.8626202 26.3461564,40.3106978 L43.3106978,23.3461564 C44.8771021,21.7797521 44.8758057,19.2483887 43.3137085,17.6862915 C41.7547899,16.1273729 39.2176035,16.1255422 37.6538436,17.6893022 L23.5,31.8431458 Z M27,53 C41.3594035,53 53,41.3594035 53,27 C53,12.6405965 41.3594035,1 27,1 C12.6405965,1 1,12.6405965 1,27 C1,41.3594035 12.6405965,53 27,53 Z" stroke-opacity="0.198794158" stroke="#747474" fill-opacity="0.816519475" fill="#FFFFFF"></path>\n </g>\n </svg>\n </div>\n <div class="dz-error-mark">\n <svg width="54px" height="54px" viewBox="0 0 54 54" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">\n <title>Error</title>\n <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">\n <g stroke="#747474" stroke-opacity="0.198794158" fill="#FFFFFF" fill-opacity="0.816519475">\n <path d="M32.6568542,29 L38.3106978,23.3461564 C39.8771021,21.7797521 39.8758057,19.2483887 38.3137085,17.6862915 C36.7547899,16.1273729 34.2176035,16.1255422 32.6538436,17.6893022 L27,23.3431458 L21.3461564,17.6893022 C19.7823965,16.1255422 17.2452101,16.1273729 15.6862915,17.6862915 C14.1241943,19.2483887 14.1228979,21.7797521 15.6893022,23.3461564 L21.3431458,29 L15.6893022,34.6538436 C14.1228979,36.2202479 14.1241943,38.7516113 15.6862915,40.3137085 C17.2452101,41.8726271 19.7823965,41.8744578 21.3461564,40.3106978 L27,34.6568542 L32.6538436,40.3106978 C34.2176035,41.8744578 36.7547899,41.8726271 38.3137085,40.3137085 C39.8758057,38.7516113 39.8771021,36.2202479 38.3106978,34.6538436 L32.6568542,29 Z M27,53 C41.3594035,53 53,41.3594035 53,27 C53,12.6405965 41.3594035,1 27,1 C12.6405965,1 1,12.6405965 1,27 C1,41.3594035 12.6405965,53 27,53 Z"></path>\n </g>\n </g>\n </svg>\n </div>\n</div>',drop:function drop(e){return this.element.classList.remove("dz-drag-hover")},dragstart:function dragstart(e){},dragend:function dragend(e){return this.element.classList.remove("dz-drag-hover")},dragenter:function dragenter(e){return this.element.classList.add("dz-drag-hover")},dragover:function dragover(e){return this.element.classList.add("dz-drag-hover")},dragleave:function dragleave(e){return this.element.classList.remove("dz-drag-hover")},paste:function paste(e){},reset:function reset(){return this.element.classList.remove("dz-started")},addedfile:function addedfile(file){var _this2=this;if(this.element===this.previewsContainer){this.element.classList.add("dz-started")}if(this.previewsContainer){file.previewElement=Dropzone.createElement(this.options.previewTemplate.trim());file.previewTemplate=file.previewElement;this.previewsContainer.appendChild(file.previewElement);var _iteratorNormalCompletion3=true;var _didIteratorError3=false;var _iteratorError3=undefined;try{for(var _iterator3=file.previewElement.querySelectorAll("[data-dz-name]")[Symbol.iterator](),_step3;!(_iteratorNormalCompletion3=(_step3=_iterator3.next()).done);_iteratorNormalCompletion3=true){var node=_step3.value;node.textContent=file.name}}catch(err){_didIteratorError3=true;_iteratorError3=err}finally{try{if(!_iteratorNormalCompletion3&&_iterator3["return"]!=null){_iterator3["return"]()}}finally{if(_didIteratorError3){throw _iteratorError3}}}var _iteratorNormalCompletion4=true;var _didIteratorError4=false;var _iteratorError4=undefined;try{for(var _iterator4=file.previewElement.querySelectorAll("[data-dz-size]")[Symbol.iterator](),_step4;!(_iteratorNormalCompletion4=(_step4=_iterator4.next()).done);_iteratorNormalCompletion4=true){node=_step4.value;node.innerHTML=this.filesize(file.size)}}catch(err){_didIteratorError4=true;_iteratorError4=err}finally{try{if(!_iteratorNormalCompletion4&&_iterator4["return"]!=null){_iterator4["return"]()}}finally{if(_didIteratorError4){throw _iteratorError4}}}if(this.options.addRemoveLinks){file._removeLink=Dropzone.createElement('<a class="dz-remove" href="javascript:undefined;" data-dz-remove>'.concat(this.options.dictRemoveFile,"</a>"));file.previewElement.appendChild(file._removeLink)}var removeFileEvent=function removeFileEvent(e){e.preventDefault();e.stopPropagation();if(file.status===Dropzone.UPLOADING){return Dropzone.confirm(_this2.options.dictCancelUploadConfirmation,function(){return _this2.removeFile(file)})}else{if(_this2.options.dictRemoveFileConfirmation){return Dropzone.confirm(_this2.options.dictRemoveFileConfirmation,function(){return _this2.removeFile(file)})}else{return _this2.removeFile(file)}}};var _iteratorNormalCompletion5=true;var _didIteratorError5=false;var _iteratorError5=undefined;try{for(var _iterator5=file.previewElement.querySelectorAll("[data-dz-remove]")[Symbol.iterator](),_step5;!(_iteratorNormalCompletion5=(_step5=_iterator5.next()).done);_iteratorNormalCompletion5=true){var removeLink=_step5.value;removeLink.addEventListener("click",removeFileEvent)}}catch(err){_didIteratorError5=true;_iteratorError5=err}finally{try{if(!_iteratorNormalCompletion5&&_iterator5["return"]!=null){_iterator5["return"]()}}finally{if(_didIteratorError5){throw _iteratorError5}}}}},removedfile:function removedfile(file){if(file.previewElement!=null&&file.previewElement.parentNode!=null){file.previewElement.parentNode.removeChild(file.previewElement)}return this._updateMaxFilesReachedClass()},thumbnail:function thumbnail(file,dataUrl){if(file.previewElement){file.previewElement.classList.remove("dz-file-preview");var _iteratorNormalCompletion6=true;var _didIteratorError6=false;var _iteratorError6=undefined;try{for(var _iterator6=file.previewElement.querySelectorAll("[data-dz-thumbnail]")[Symbol.iterator](),_step6;!(_iteratorNormalCompletion6=(_step6=_iterator6.next()).done);_iteratorNormalCompletion6=true){var thumbnailElement=_step6.value;thumbnailElement.alt=file.name;thumbnailElement.src=dataUrl}}catch(err){_didIteratorError6=true;_iteratorError6=err}finally{try{if(!_iteratorNormalCompletion6&&_iterator6["return"]!=null){_iterator6["return"]()}}finally{if(_didIteratorError6){throw _iteratorError6}}}return setTimeout(function(){return file.previewElement.classList.add("dz-image-preview")},1)}},error:function error(file,message){if(file.previewElement){file.previewElement.classList.add("dz-error");if(typeof message!=="String"&&message.error){message=message.error}var _iteratorNormalCompletion7=true;var _didIteratorError7=false;var _iteratorError7=undefined;try{for(var _iterator7=file.previewElement.querySelectorAll("[data-dz-errormessage]")[Symbol.iterator](),_step7;!(_iteratorNormalCompletion7=(_step7=_iterator7.next()).done);_iteratorNormalCompletion7=true){var node=_step7.value;node.textContent=message}}catch(err){_didIteratorError7=true;_iteratorError7=err}finally{try{if(!_iteratorNormalCompletion7&&_iterator7["return"]!=null){_iterator7["return"]()}}finally{if(_didIteratorError7){throw _iteratorError7}}}}},errormultiple:function errormultiple(){},processing:function processing(file){if(file.previewElement){file.previewElement.classList.add("dz-processing");if(file._removeLink){return file._removeLink.innerHTML=this.options.dictCancelUpload}}},processingmultiple:function processingmultiple(){},uploadprogress:function uploadprogress(file,progress,bytesSent){if(file.previewElement){var _iteratorNormalCompletion8=true;var _didIteratorError8=false;var _iteratorError8=undefined;try{for(var _iterator8=file.previewElement.querySelectorAll("[data-dz-uploadprogress]")[Symbol.iterator](),_step8;!(_iteratorNormalCompletion8=(_step8=_iterator8.next()).done);_iteratorNormalCompletion8=true){var node=_step8.value;node.nodeName==="PROGRESS"?node.value=progress:node.style.width="".concat(progress,"%")}}catch(err){_didIteratorError8=true;_iteratorError8=err}finally{try{if(!_iteratorNormalCompletion8&&_iterator8["return"]!=null){_iterator8["return"]()}}finally{if(_didIteratorError8){throw _iteratorError8}}}}},totaluploadprogress:function totaluploadprogress(){},sending:function sending(){},sendingmultiple:function sendingmultiple(){},success:function success(file){if(file.previewElement){return file.previewElement.classList.add("dz-success")}},successmultiple:function successmultiple(){},canceled:function canceled(file){return this.emit("error",file,this.options.dictUploadCanceled)},canceledmultiple:function canceledmultiple(){},complete:function complete(file){if(file._removeLink){file._removeLink.innerHTML=this.options.dictRemoveFile}if(file.previewElement){return file.previewElement.classList.add("dz-complete")}},completemultiple:function completemultiple(){},maxfilesexceeded:function maxfilesexceeded(){},maxfilesreached:function maxfilesreached(){},queuecomplete:function queuecomplete(){},addedfiles:function addedfiles(){}};this.prototype._thumbnailQueue=[];this.prototype._processingThumbnail=false}},{key:"extend",value:function extend(target){for(var _len2=arguments.length,objects=new Array(_len2>1?_len2-1:0),_key2=1;_key2<_len2;_key2++){objects[_key2-1]=arguments[_key2]}for(var _i=0,_objects=objects;_i<_objects.length;_i++){var object=_objects[_i];for(var key in object){var val=object[key];target[key]=val}}return target}}]);function Dropzone(el,options){var _this;_classCallCheck(this,Dropzone);_this=_possibleConstructorReturn(this,_getPrototypeOf(Dropzone).call(this));var fallback,left;_this.element=el;_this.version=Dropzone.version;_this.defaultOptions.previewTemplate=_this.defaultOptions.previewTemplate.replace(/\n*/g,"");_this.clickableElements=[];_this.listeners=[];_this.files=[];if(typeof _this.element==="string"){_this.element=document.querySelector(_this.element)}if(!_this.element||_this.element.nodeType==null){throw new Error("Invalid dropzone element.")}if(_this.element.dropzone){throw new Error("Dropzone already attached.")}Dropzone.instances.push(_assertThisInitialized(_this));_this.element.dropzone=_assertThisInitialized(_this);var elementOptions=(left=Dropzone.optionsForElement(_this.element))!=null?left:{};_this.options=Dropzone.extend({},_this.defaultOptions,elementOptions,options!=null?options:{});if(_this.options.forceFallback||!Dropzone.isBrowserSupported()){return _possibleConstructorReturn(_this,_this.options.fallback.call(_assertThisInitialized(_this)))}if(_this.options.url==null){_this.options.url=_this.element.getAttribute("action")}if(!_this.options.url){throw new Error("No URL provided.")}if(_this.options.acceptedFiles&&_this.options.acceptedMimeTypes){throw new Error("You can't provide both 'acceptedFiles' and 'acceptedMimeTypes'. 'acceptedMimeTypes' is deprecated.")}if(_this.options.uploadMultiple&&_this.options.chunking){throw new Error("You cannot set both: uploadMultiple and chunking.")}if(_this.options.acceptedMimeTypes){_this.options.acceptedFiles=_this.options.acceptedMimeTypes;delete _this.options.acceptedMimeTypes}if(_this.options.renameFilename!=null){_this.options.renameFile=function(file){return _this.options.renameFilename.call(_assertThisInitialized(_this),file.name,file)}}_this.options.method=typeof _this.options.method!=="function"?_this.options.method.toUpperCase():_this.options.method;if((fallback=_this.getExistingFallback())&&fallback.parentNode){fallback.parentNode.removeChild(fallback)}if(_this.options.previewsContainer!==false){if(_this.options.previewsContainer){_this.previewsContainer=Dropzone.getElement(_this.options.previewsContainer,"previewsContainer")}else{_this.previewsContainer=_this.element}}if(_this.options.clickable){if(_this.options.clickable===true){_this.clickableElements=[_this.element]}else{_this.clickableElements=Dropzone.getElements(_this.options.clickable,"clickable")}}_this.init();return _this}_createClass(Dropzone,[{key:"getAcceptedFiles",value:function getAcceptedFiles(){return this.files.filter(function(file){return file.accepted}).map(function(file){return file})}},{key:"getRejectedFiles",value:function getRejectedFiles(){return this.files.filter(function(file){return!file.accepted}).map(function(file){return file})}},{key:"getFilesWithStatus",value:function getFilesWithStatus(status){return this.files.filter(function(file){return file.status===status}).map(function(file){return file})}},{key:"getQueuedFiles",value:function getQueuedFiles(){return this.getFilesWithStatus(Dropzone.QUEUED)}},{key:"getUploadingFiles",value:function getUploadingFiles(){return this.getFilesWithStatus(Dropzone.UPLOADING)}},{key:"getAddedFiles",value:function getAddedFiles(){return this.getFilesWithStatus(Dropzone.ADDED)}},{key:"getActiveFiles",value:function getActiveFiles(){return this.files.filter(function(file){return file.status===Dropzone.UPLOADING||file.status===Dropzone.QUEUED}).map(function(file){return file})}},{key:"init",value:function init(){var _this3=this;if(this.element.tagName==="form"){this.element.setAttribute("enctype","multipart/form-data")}if(this.element.classList.contains("dropzone")&&!this.element.querySelector(".dz-message")){this.element.appendChild(Dropzone.createElement('<div class="dz-default dz-message"><button class="dz-button" type="button">'.concat(this.options.dictDefaultMessage,"</button></div>")))}if(this.clickableElements.length){var setupHiddenFileInput=function setupHiddenFileInput(){if(_this3.hiddenFileInput){_this3.hiddenFileInput.parentNode.removeChild(_this3.hiddenFileInput)}_this3.hiddenFileInput=document.createElement("input");_this3.hiddenFileInput.setAttribute("type","file");if(_this3.options.maxFiles===null||_this3.options.maxFiles>1){_this3.hiddenFileInput.setAttribute("multiple","multiple")}_this3.hiddenFileInput.className="dz-hidden-input";if(_this3.options.acceptedFiles!==null){_this3.hiddenFileInput.setAttribute("accept",_this3.options.acceptedFiles)}if(_this3.options.capture!==null){_this3.hiddenFileInput.setAttribute("capture",_this3.options.capture)}_this3.hiddenFileInput.style.visibility="hidden";_this3.hiddenFileInput.style.position="absolute";_this3.hiddenFileInput.style.top="0";_this3.hiddenFileInput.style.left="0";_this3.hiddenFileInput.style.height="0";_this3.hiddenFileInput.style.width="0";Dropzone.getElement(_this3.options.hiddenInputContainer,"hiddenInputContainer").appendChild(_this3.hiddenFileInput);return _this3.hiddenFileInput.addEventListener("change",function(){var files=_this3.hiddenFileInput.files;if(files.length){var _iteratorNormalCompletion9=true;var _didIteratorError9=false;var _iteratorError9=undefined;try{for(var _iterator9=files[Symbol.iterator](),_step9;!(_iteratorNormalCompletion9=(_step9=_iterator9.next()).done);_iteratorNormalCompletion9=true){var file=_step9.value;_this3.addFile(file)}}catch(err){_didIteratorError9=true;_iteratorError9=err}finally{try{if(!_iteratorNormalCompletion9&&_iterator9["return"]!=null){_iterator9["return"]()}}finally{if(_didIteratorError9){throw _iteratorError9}}}}_this3.emit("addedfiles",files);return setupHiddenFileInput()})};setupHiddenFileInput()}this.URL=window.URL!==null?window.URL:window.webkitURL;var _iteratorNormalCompletion10=true;var _didIteratorError10=false;var _iteratorError10=undefined;try{for(var _iterator10=this.events[Symbol.iterator](),_step10;!(_iteratorNormalCompletion10=(_step10=_iterator10.next()).done);_iteratorNormalCompletion10=true){var eventName=_step10.value;this.on(eventName,this.options[eventName])}}catch(err){_didIteratorError10=true;_iteratorError10=err}finally{try{if(!_iteratorNormalCompletion10&&_iterator10["return"]!=null){_iterator10["return"]()}}finally{if(_didIteratorError10){throw _iteratorError10}}}this.on("uploadprogress",function(){return _this3.updateTotalUploadProgress()});this.on("removedfile",function(){return _this3.updateTotalUploadProgress()});this.on("canceled",function(file){return _this3.emit("complete",file)});this.on("complete",function(file){if(_this3.getAddedFiles().length===0&&_this3.getUploadingFiles().length===0&&_this3.getQueuedFiles().length===0){return setTimeout(function(){return _this3.emit("queuecomplete")},0)}});var containsFiles=function containsFiles(e){return e.dataTransfer.types&&e.dataTransfer.types.some(function(type){return type=="Files"})};var noPropagation=function noPropagation(e){if(!containsFiles(e))return;e.stopPropagation();if(e.preventDefault){return e.preventDefault()}else{return e.returnValue=false}};this.listeners=[{element:this.element,events:{dragstart:function dragstart(e){return _this3.emit("dragstart",e)},dragenter:function dragenter(e){noPropagation(e);return _this3.emit("dragenter",e)},dragover:function dragover(e){var efct;try{efct=e.dataTransfer.effectAllowed}catch(error){}e.dataTransfer.dropEffect="move"===efct||"linkMove"===efct?"move":"copy";noPropagation(e);return _this3.emit("dragover",e)},dragleave:function dragleave(e){return _this3.emit("dragleave",e)},drop:function drop(e){noPropagation(e);return _this3.drop(e)},dragend:function dragend(e){return _this3.emit("dragend",e)}}}];this.clickableElements.forEach(function(clickableElement){return _this3.listeners.push({element:clickableElement,events:{click:function click(evt){if(clickableElement!==_this3.element||evt.target===_this3.element||Dropzone.elementInside(evt.target,_this3.element.querySelector(".dz-message"))){_this3.hiddenFileInput.click()}return true}}})});this.enable();return this.options.init.call(this)}},{key:"destroy",value:function destroy(){this.disable();this.removeAllFiles(true);if(this.hiddenFileInput!=null?this.hiddenFileInput.parentNode:undefined){this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput);this.hiddenFileInput=null}delete this.element.dropzone;return Dropzone.instances.splice(Dropzone.instances.indexOf(this),1)}},{key:"updateTotalUploadProgress",value:function updateTotalUploadProgress(){var totalUploadProgress;var totalBytesSent=0;var totalBytes=0;var activeFiles=this.getActiveFiles();if(activeFiles.length){var _iteratorNormalCompletion11=true;var _didIteratorError11=false;var _iteratorError11=undefined;try{for(var _iterator11=this.getActiveFiles()[Symbol.iterator](),_step11;!(_iteratorNormalCompletion11=(_step11=_iterator11.next()).done);_iteratorNormalCompletion11=true){var file=_step11.value;totalBytesSent+=file.upload.bytesSent;totalBytes+=file.upload.total}}catch(err){_didIteratorError11=true;_iteratorError11=err}finally{try{if(!_iteratorNormalCompletion11&&_iterator11["return"]!=null){_iterator11["return"]()}}finally{if(_didIteratorError11){throw _iteratorError11}}}totalUploadProgress=100*totalBytesSent/totalBytes}else{totalUploadProgress=100}return this.emit("totaluploadprogress",totalUploadProgress,totalBytes,totalBytesSent)}},{key:"_getParamName",value:function _getParamName(n){if(typeof this.options.paramName==="function"){return this.options.paramName(n)}else{return"".concat(this.options.paramName).concat(this.options.uploadMultiple?"[".concat(n,"]"):"")}}},{key:"_renameFile",value:function _renameFile(file){if(typeof this.options.renameFile!=="function"){return file.name}return this.options.renameFile(file)}},{key:"getFallbackForm",value:function getFallbackForm(){var existingFallback,form;if(existingFallback=this.getExistingFallback()){return existingFallback}var fieldsString='<div class="dz-fallback">';if(this.options.dictFallbackText){fieldsString+="<p>".concat(this.options.dictFallbackText,"</p>")}fieldsString+='<input type="file" name="'.concat(this._getParamName(0),'" ').concat(this.options.uploadMultiple?'multiple="multiple"':undefined,' /><input type="submit" value="Upload!"></div>');var fields=Dropzone.createElement(fieldsString);if(this.element.tagName!=="FORM"){form=Dropzone.createElement('<form action="'.concat(this.options.url,'" enctype="multipart/form-data" method="').concat(this.options.method,'"></form>'));form.appendChild(fields)}else{this.element.setAttribute("enctype","multipart/form-data");this.element.setAttribute("method",this.options.method)}return form!=null?form:fields}},{key:"getExistingFallback",value:function getExistingFallback(){var getFallback=function getFallback(elements){var _iteratorNormalCompletion12=true;var _didIteratorError12=false;var _iteratorError12=undefined;try{for(var _iterator12=elements[Symbol.iterator](),_step12;!(_iteratorNormalCompletion12=(_step12=_iterator12.next()).done);_iteratorNormalCompletion12=true){var el=_step12.value;if(/(^| )fallback($| )/.test(el.className)){return el}}}catch(err){_didIteratorError12=true;_iteratorError12=err}finally{try{if(!_iteratorNormalCompletion12&&_iterator12["return"]!=null){_iterator12["return"]()}}finally{if(_didIteratorError12){throw _iteratorError12}}}};for(var _i2=0,_arr=["div","form"];_i2<_arr.length;_i2++){var tagName=_arr[_i2];var fallback;if(fallback=getFallback(this.element.getElementsByTagName(tagName))){return fallback}}}},{key:"setupEventListeners",value:function setupEventListeners(){return this.listeners.map(function(elementListeners){return function(){var result=[];for(var event in elementListeners.events){var listener=elementListeners.events[event];result.push(elementListeners.element.addEventListener(event,listener,false))}return result}()})}},{key:"removeEventListeners",value:function removeEventListeners(){return this.listeners.map(function(elementListeners){return function(){var result=[];for(var event in elementListeners.events){var listener=elementListeners.events[event];result.push(elementListeners.element.removeEventListener(event,listener,false))}return result}()})}},{key:"disable",value:function disable(){var _this4=this;this.clickableElements.forEach(function(element){return element.classList.remove("dz-clickable")});this.removeEventListeners();this.disabled=true;return this.files.map(function(file){return _this4.cancelUpload(file)})}},{key:"enable",value:function enable(){delete this.disabled;this.clickableElements.forEach(function(element){return element.classList.add("dz-clickable")});return this.setupEventListeners()}},{key:"filesize",value:function filesize(size){var selectedSize=0;var selectedUnit="b";if(size>0){var units=["tb","gb","mb","kb","b"];for(var i=0;i<units.length;i++){var unit=units[i];var cutoff=Math.pow(this.options.filesizeBase,4-i)/10;if(size>=cutoff){selectedSize=size/Math.pow(this.options.filesizeBase,4-i);selectedUnit=unit;break}}selectedSize=Math.round(10*selectedSize)/10}return"<strong>".concat(selectedSize,"</strong> ").concat(this.options.dictFileSizeUnits[selectedUnit])}},{key:"_updateMaxFilesReachedClass",value:function _updateMaxFilesReachedClass(){if(this.options.maxFiles!=null&&this.getAcceptedFiles().length>=this.options.maxFiles){if(this.getAcceptedFiles().length===this.options.maxFiles){this.emit("maxfilesreached",this.files)}return this.element.classList.add("dz-max-files-reached")}else{return this.element.classList.remove("dz-max-files-reached")}}},{key:"drop",value:function drop(e){if(!e.dataTransfer){return}this.emit("drop",e);var files=[];for(var i=0;i<e.dataTransfer.files.length;i++){files[i]=e.dataTransfer.files[i]}if(files.length){var items=e.dataTransfer.items;if(items&&items.length&&items[0].webkitGetAsEntry!=null){this._addFilesFromItems(items)}else{this.handleFiles(files)}}this.emit("addedfiles",files)}},{key:"paste",value:function paste(e){if(__guard__(e!=null?e.clipboardData:undefined,function(x){return x.items})==null){return}this.emit("paste",e);var items=e.clipboardData.items;if(items.length){return this._addFilesFromItems(items)}}},{key:"handleFiles",value:function handleFiles(files){var _iteratorNormalCompletion13=true;var _didIteratorError13=false;var _iteratorError13=undefined;try{for(var _iterator13=files[Symbol.iterator](),_step13;!(_iteratorNormalCompletion13=(_step13=_iterator13.next()).done);_iteratorNormalCompletion13=true){var file=_step13.value;this.addFile(file)}}catch(err){_didIteratorError13=true;_iteratorError13=err}finally{try{if(!_iteratorNormalCompletion13&&_iterator13["return"]!=null){_iterator13["return"]()}}finally{if(_didIteratorError13){throw _iteratorError13}}}}},{key:"_addFilesFromItems",value:function _addFilesFromItems(items){var _this5=this;return function(){var result=[];var _iteratorNormalCompletion14=true;var _didIteratorError14=false;var _iteratorError14=undefined;try{for(var _iterator14=items[Symbol.iterator](),_step14;!(_iteratorNormalCompletion14=(_step14=_iterator14.next()).done);_iteratorNormalCompletion14=true){var item=_step14.value;var entry;if(item.webkitGetAsEntry!=null&&(entry=item.webkitGetAsEntry())){if(entry.isFile){result.push(_this5.addFile(item.getAsFile()))}else if(entry.isDirectory){result.push(_this5._addFilesFromDirectory(entry,entry.name))}else{result.push(undefined)}}else if(item.getAsFile!=null){if(item.kind==null||item.kind==="file"){result.push(_this5.addFile(item.getAsFile()))}else{result.push(undefined)}}else{result.push(undefined)}}}catch(err){_didIteratorError14=true;_iteratorError14=err}finally{try{if(!_iteratorNormalCompletion14&&_iterator14["return"]!=null){_iterator14["return"]()}}finally{if(_didIteratorError14){throw _iteratorError14}}}return result}()}},{key:"_addFilesFromDirectory",value:function _addFilesFromDirectory(directory,path){var _this6=this;var dirReader=directory.createReader();var errorHandler=function errorHandler(error){return __guardMethod__(console,"log",function(o){return o.log(error)})};var readEntries=function readEntries(){return dirReader.readEntries(function(entries){if(entries.length>0){var _iteratorNormalCompletion15=true;var _didIteratorError15=false;var _iteratorError15=undefined;try{for(var _iterator15=entries[Symbol.iterator](),_step15;!(_iteratorNormalCompletion15=(_step15=_iterator15.next()).done);_iteratorNormalCompletion15=true){var entry=_step15.value;if(entry.isFile){entry.file(function(file){if(_this6.options.ignoreHiddenFiles&&file.name.substring(0,1)==="."){return}file.fullPath="".concat(path,"/").concat(file.name);return _this6.addFile(file)})}else if(entry.isDirectory){_this6._addFilesFromDirectory(entry,"".concat(path,"/").concat(entry.name))}}}catch(err){_didIteratorError15=true;_iteratorError15=err}finally{try{if(!_iteratorNormalCompletion15&&_iterator15["return"]!=null){_iterator15["return"]()}}finally{if(_didIteratorError15){throw _iteratorError15}}}readEntries()}return null},errorHandler)};return readEntries()}},{key:"accept",value:function accept(file,done){if(this.options.maxFilesize&&file.size>this.options.maxFilesize*1024*1024){done(this.options.dictFileTooBig.replace("{{filesize}}",Math.round(file.size/1024/10.24)/100).replace("{{maxFilesize}}",this.options.maxFilesize))}else if(!Dropzone.isValidFile(file,this.options.acceptedFiles)){done(this.options.dictInvalidFileType)}else if(this.options.maxFiles!=null&&this.getAcceptedFiles().length>=this.options.maxFiles){done(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}",this.options.maxFiles));this.emit("maxfilesexceeded",file)}else{this.options.accept.call(this,file,done)}}},{key:"addFile",value:function addFile(file){var _this7=this;file.upload={uuid:Dropzone.uuidv4(),progress:0,total:file.size,bytesSent:0,filename:this._renameFile(file)};this.files.push(file);file.status=Dropzone.ADDED;this.emit("addedfile",file);this._enqueueThumbnail(file);this.accept(file,function(error){if(error){file.accepted=false;_this7._errorProcessing([file],error)}else{file.accepted=true;if(_this7.options.autoQueue){_this7.enqueueFile(file)}}_this7._updateMaxFilesReachedClass()})}},{key:"enqueueFiles",value:function enqueueFiles(files){var _iteratorNormalCompletion16=true;var _didIteratorError16=false;var _iteratorError16=undefined;try{for(var _iterator16=files[Symbol.iterator](),_step16;!(_iteratorNormalCompletion16=(_step16=_iterator16.next()).done);_iteratorNormalCompletion16=true){var file=_step16.value;this.enqueueFile(file)}}catch(err){_didIteratorError16=true;_iteratorError16=err}finally{try{if(!_iteratorNormalCompletion16&&_iterator16["return"]!=null){_iterator16["return"]()}}finally{if(_didIteratorError16){throw _iteratorError16}}}return null}},{key:"enqueueFile",value:function enqueueFile(file){var _this8=this;if(file.status===Dropzone.ADDED&&file.accepted===true){file.status=Dropzone.QUEUED;if(this.options.autoProcessQueue){return setTimeout(function(){return _this8.processQueue()},0)}}else{throw new Error("This file can't be queued because it has already been processed or was rejected.")}}},{key:"_enqueueThumbnail",value:function _enqueueThumbnail(file){var _this9=this;if(this.options.createImageThumbnails&&file.type.match(/image.*/)&&file.size<=this.options.maxThumbnailFilesize*1024*1024){this._thumbnailQueue.push(file);return setTimeout(function(){return _this9._processThumbnailQueue()},0)}}},{key:"_processThumbnailQueue",value:function _processThumbnailQueue(){var _this10=this;if(this._processingThumbnail||this._thumbnailQueue.length===0){return}this._processingThumbnail=true;var file=this._thumbnailQueue.shift();return this.createThumbnail(file,this.options.thumbnailWidth,this.options.thumbnailHeight,this.options.thumbnailMethod,true,function(dataUrl){_this10.emit("thumbnail",file,dataUrl);_this10._processingThumbnail=false;return _this10._processThumbnailQueue()})}},{key:"removeFile",value:function removeFile(file){if(file.status===Dropzone.UPLOADING){this.cancelUpload(file)}this.files=without(this.files,file);this.emit("removedfile",file);if(this.files.length===0){return this.emit("reset")}}},{key:"removeAllFiles",value:function removeAllFiles(cancelIfNecessary){if(cancelIfNecessary==null){cancelIfNecessary=false}var _iteratorNormalCompletion17=true;var _didIteratorError17=false;var _iteratorError17=undefined;try{for(var _iterator17=this.files.slice()[Symbol.iterator](),_step17;!(_iteratorNormalCompletion17=(_step17=_iterator17.next()).done);_iteratorNormalCompletion17=true){var file=_step17.value;if(file.status!==Dropzone.UPLOADING||cancelIfNecessary){this.removeFile(file)}}}catch(err){_didIteratorError17=true;_iteratorError17=err}finally{try{if(!_iteratorNormalCompletion17&&_iterator17["return"]!=null){_iterator17["return"]()}}finally{if(_didIteratorError17){throw _iteratorError17}}}return null}},{key:"resizeImage",value:function resizeImage(file,width,height,resizeMethod,callback){var _this11=this;return this.createThumbnail(file,width,height,resizeMethod,true,function(dataUrl,canvas){if(canvas==null){return callback(file)}else{var resizeMimeType=_this11.options.resizeMimeType;if(resizeMimeType==null){resizeMimeType=file.type}var resizedDataURL=canvas.toDataURL(resizeMimeType,_this11.options.resizeQuality);if(resizeMimeType==="image/jpeg"||resizeMimeType==="image/jpg"){resizedDataURL=ExifRestore.restore(file.dataURL,resizedDataURL)}return callback(Dropzone.dataURItoBlob(resizedDataURL))}})}},{key:"createThumbnail",value:function createThumbnail(file,width,height,resizeMethod,fixOrientation,callback){var _this12=this;var fileReader=new FileReader;fileReader.onload=function(){file.dataURL=fileReader.result;if(file.type==="image/svg+xml"){if(callback!=null){callback(fileReader.result)}return}_this12.createThumbnailFromUrl(file,width,height,resizeMethod,fixOrientation,callback)};fileReader.readAsDataURL(file)}},{key:"displayExistingFile",value:function displayExistingFile(mockFile,imageUrl,callback,crossOrigin){var _this13=this;var resizeThumbnail=arguments.length>4&&arguments[4]!==undefined?arguments[4]:true;this.emit("addedfile",mockFile);this.emit("complete",mockFile);if(!resizeThumbnail){this.emit("thumbnail",mockFile,imageUrl);if(callback)callback()}else{var onDone=function onDone(thumbnail){_this13.emit("thumbnail",mockFile,thumbnail);if(callback)callback()};mockFile.dataURL=imageUrl;this.createThumbnailFromUrl(mockFile,this.options.thumbnailWidth,this.options.thumbnailHeight,this.options.resizeMethod,this.options.fixOrientation,onDone,crossOrigin)}}},{key:"createThumbnailFromUrl",value:function createThumbnailFromUrl(file,width,height,resizeMethod,fixOrientation,callback,crossOrigin){var _this14=this;var img=document.createElement("img");if(crossOrigin){img.crossOrigin=crossOrigin}img.onload=function(){var loadExif=function loadExif(callback){return callback(1)};if(typeof EXIF!=="undefined"&&EXIF!==null&&fixOrientation){loadExif=function loadExif(callback){return EXIF.getData(img,function(){return callback(EXIF.getTag(this,"Orientation"))})}}return loadExif(function(orientation){file.width=img.width;file.height=img.height;var resizeInfo=_this14.options.resize.call(_this14,file,width,height,resizeMethod);var canvas=document.createElement("canvas");var ctx=canvas.getContext("2d");canvas.width=resizeInfo.trgWidth;canvas.height=resizeInfo.trgHeight;if(orientation>4){canvas.width=resizeInfo.trgHeight;canvas.height=resizeInfo.trgWidth}switch(orientation){case 2:ctx.translate(canvas.width,0);ctx.scale(-1,1);break;case 3:ctx.translate(canvas.width,canvas.height);ctx.rotate(Math.PI);break;case 4:ctx.translate(0,canvas.height);ctx.scale(1,-1);break;case 5:ctx.rotate(.5*Math.PI);ctx.scale(1,-1);break;case 6:ctx.rotate(.5*Math.PI);ctx.translate(0,-canvas.width);break;case 7:ctx.rotate(.5*Math.PI);ctx.translate(canvas.height,-canvas.width);ctx.scale(-1,1);break;case 8:ctx.rotate(-.5*Math.PI);ctx.translate(-canvas.height,0);break}drawImageIOSFix(ctx,img,resizeInfo.srcX!=null?resizeInfo.srcX:0,resizeInfo.srcY!=null?resizeInfo.srcY:0,resizeInfo.srcWidth,resizeInfo.srcHeight,resizeInfo.trgX!=null?resizeInfo.trgX:0,resizeInfo.trgY!=null?resizeInfo.trgY:0,resizeInfo.trgWidth,resizeInfo.trgHeight);var thumbnail=canvas.toDataURL("image/png");if(callback!=null){return callback(thumbnail,canvas)}})};if(callback!=null){img.onerror=callback}return img.src=file.dataURL}},{key:"processQueue",value:function processQueue(){var parallelUploads=this.options.parallelUploads;var processingLength=this.getUploadingFiles().length;var i=processingLength;if(processingLength>=parallelUploads){return}var queuedFiles=this.getQueuedFiles();if(!(queuedFiles.length>0)){return}if(this.options.uploadMultiple){return this.processFiles(queuedFiles.slice(0,parallelUploads-processingLength))}else{while(i<parallelUploads){if(!queuedFiles.length){return}this.processFile(queuedFiles.shift());i++}}}},{key:"processFile",value:function processFile(file){return this.processFiles([file])}},{key:"processFiles",value:function processFiles(files){var _iteratorNormalCompletion18=true;var _didIteratorError18=false;var _iteratorError18=undefined;try{for(var _iterator18=files[Symbol.iterator](),_step18;!(_iteratorNormalCompletion18=(_step18=_iterator18.next()).done);_iteratorNormalCompletion18=true){var file=_step18.value;file.processing=true;file.status=Dropzone.UPLOADING;this.emit("processing",file)}}catch(err){_didIteratorError18=true;_iteratorError18=err}finally{try{if(!_iteratorNormalCompletion18&&_iterator18["return"]!=null){_iterator18["return"]()}}finally{if(_didIteratorError18){throw _iteratorError18}}}if(this.options.uploadMultiple){this.emit("processingmultiple",files)}return this.uploadFiles(files)}},{key:"_getFilesWithXhr",value:function _getFilesWithXhr(xhr){var files;return files=this.files.filter(function(file){return file.xhr===xhr}).map(function(file){return file})}},{key:"cancelUpload",value:function cancelUpload(file){if(file.status===Dropzone.UPLOADING){var groupedFiles=this._getFilesWithXhr(file.xhr);var _iteratorNormalCompletion19=true;var _didIteratorError19=false;var _iteratorError19=undefined;try{for(var _iterator19=groupedFiles[Symbol.iterator](),_step19;!(_iteratorNormalCompletion19=(_step19=_iterator19.next()).done);_iteratorNormalCompletion19=true){var groupedFile=_step19.value;groupedFile.status=Dropzone.CANCELED}}catch(err){_didIteratorError19=true;_iteratorError19=err}finally{try{if(!_iteratorNormalCompletion19&&_iterator19["return"]!=null){_iterator19["return"]()}}finally{if(_didIteratorError19){throw _iteratorError19}}}if(typeof file.xhr!=="undefined"){file.xhr.abort()}var _iteratorNormalCompletion20=true;var _didIteratorError20=false;var _iteratorError20=undefined;try{for(var _iterator20=groupedFiles[Symbol.iterator](),_step20;!(_iteratorNormalCompletion20=(_step20=_iterator20.next()).done);_iteratorNormalCompletion20=true){var _groupedFile=_step20.value;this.emit("canceled",_groupedFile)}}catch(err){_didIteratorError20=true;_iteratorError20=err}finally{try{if(!_iteratorNormalCompletion20&&_iterator20["return"]!=null){_iterator20["return"]()}}finally{if(_didIteratorError20){throw _iteratorError20}}}if(this.options.uploadMultiple){this.emit("canceledmultiple",groupedFiles)}}else if(file.status===Dropzone.ADDED||file.status===Dropzone.QUEUED){file.status=Dropzone.CANCELED;this.emit("canceled",file);if(this.options.uploadMultiple){this.emit("canceledmultiple",[file])}}if(this.options.autoProcessQueue){return this.processQueue()}}},{key:"resolveOption",value:function resolveOption(option){if(typeof option==="function"){for(var _len3=arguments.length,args=new Array(_len3>1?_len3-1:0),_key3=1;_key3<_len3;_key3++){args[_key3-1]=arguments[_key3]}return option.apply(this,args)}return option}},{key:"uploadFile",value:function uploadFile(file){return this.uploadFiles([file])}},{key:"uploadFiles",value:function uploadFiles(files){var _this15=this;this._transformFiles(files,function(transformedFiles){if(_this15.options.chunking){var transformedFile=transformedFiles[0];files[0].upload.chunked=_this15.options.chunking&&(_this15.options.forceChunking||transformedFile.size>_this15.options.chunkSize);files[0].upload.totalChunkCount=Math.ceil(transformedFile.size/_this15.options.chunkSize)}if(files[0].upload.chunked){var file=files[0];var _transformedFile=transformedFiles[0];var startedChunkCount=0;file.upload.chunks=[];var handleNextChunk=function handleNextChunk(){var chunkIndex=0;while(file.upload.chunks[chunkIndex]!==undefined){chunkIndex++}if(chunkIndex>=file.upload.totalChunkCount)return;startedChunkCount++;var start=chunkIndex*_this15.options.chunkSize;var end=Math.min(start+_this15.options.chunkSize,file.size);var dataBlock={name:_this15._getParamName(0),data:_transformedFile.webkitSlice?_transformedFile.webkitSlice(start,end):_transformedFile.slice(start,end),filename:file.upload.filename,chunkIndex:chunkIndex};file.upload.chunks[chunkIndex]={file:file,index:chunkIndex,dataBlock:dataBlock,status:Dropzone.UPLOADING,progress:0,retries:0};_this15._uploadData(files,[dataBlock])};file.upload.finishedChunkUpload=function(chunk,response){var allFinished=true;chunk.status=Dropzone.SUCCESS;_this15.options.chunkSuccess.call(_this15,chunk,file,response);chunk.dataBlock=null;chunk.xhr=null;for(var i=0;i<file.upload.totalChunkCount;i++){if(file.upload.chunks[i]===undefined){return handleNextChunk()}if(file.upload.chunks[i].status!==Dropzone.SUCCESS){allFinished=false}}if(allFinished){_this15.options.chunksUploaded.call(_this15,file,function(response){_this15._finished(files,response||"",null)})}};if(_this15.options.parallelChunkUploads){for(var i=0;i<file.upload.totalChunkCount;i++){handleNextChunk()}}else{handleNextChunk()}}else{var dataBlocks=[];for(var _i3=0;_i3<files.length;_i3++){dataBlocks[_i3]={name:_this15._getParamName(_i3),data:transformedFiles[_i3],filename:files[_i3].upload.filename}}_this15._uploadData(files,dataBlocks)}})}},{key:"_getChunk",value:function _getChunk(file,xhr){for(var i=0;i<file.upload.totalChunkCount;i++){if(file.upload.chunks[i]!==undefined&&file.upload.chunks[i].xhr===xhr){return file.upload.chunks[i]}}}},{key:"_uploadData",value:function _uploadData(files,dataBlocks){var _this16=this;var xhr=new XMLHttpRequest;var _iteratorNormalCompletion21=true;var _didIteratorError21=false;var _iteratorError21=undefined;try{for(var _iterator21=files[Symbol.iterator](),_step21;!(_iteratorNormalCompletion21=(_step21=_iterator21.next()).done);_iteratorNormalCompletion21=true){var file=_step21.value;file.xhr=xhr}}catch(err){_didIteratorError21=true;_iteratorError21=err}finally{try{if(!_iteratorNormalCompletion21&&_iterator21["return"]!=null){_iterator21["return"]()}}finally{if(_didIteratorError21){throw _iteratorError21}}}if(files[0].upload.chunked){files[0].upload.chunks[dataBlocks[0].chunkIndex].xhr=xhr}var method=this.resolveOption(this.options.method,files);var url=this.resolveOption(this.options.url,files);xhr.open(method,url,true);xhr.timeout=this.resolveOption(this.options.timeout,files);xhr.withCredentials=!!this.options.withCredentials;xhr.onload=function(e){_this16._finishedUploading(files,xhr,e)};xhr.ontimeout=function(){_this16._handleUploadError(files,xhr,"Request timedout after ".concat(_this16.options.timeout," seconds"))};xhr.onerror=function(){_this16._handleUploadError(files,xhr)};var progressObj=xhr.upload!=null?xhr.upload:xhr;progressObj.onprogress=function(e){return _this16._updateFilesUploadProgress(files,xhr,e)};var headers={Accept:"application/json","Cache-Control":"no-cache","X-Requested-With":"XMLHttpRequest"};if(this.options.headers){Dropzone.extend(headers,this.options.headers)}for(var headerName in headers){var headerValue=headers[headerName];if(headerValue){xhr.setRequestHeader(headerName,headerValue)}}var formData=new FormData;if(this.options.params){var additionalParams=this.options.params;if(typeof additionalParams==="function"){additionalParams=additionalParams.call(this,files,xhr,files[0].upload.chunked?this._getChunk(files[0],xhr):null)}for(var key in additionalParams){var value=additionalParams[key];formData.append(key,value)}}var _iteratorNormalCompletion22=true;var _didIteratorError22=false;var _iteratorError22=undefined;try{for(var _iterator22=files[Symbol.iterator](),_step22;!(_iteratorNormalCompletion22=(_step22=_iterator22.next()).done);_iteratorNormalCompletion22=true){var _file=_step22.value;this.emit("sending",_file,xhr,formData)}}catch(err){_didIteratorError22=true;_iteratorError22=err}finally{try{if(!_iteratorNormalCompletion22&&_iterator22["return"]!=null){_iterator22["return"]()}}finally{if(_didIteratorError22){throw _iteratorError22}}}if(this.options.uploadMultiple){this.emit("sendingmultiple",files,xhr,formData)}this._addFormElementData(formData);for(var i=0;i<dataBlocks.length;i++){var dataBlock=dataBlocks[i];formData.append(dataBlock.name,dataBlock.data,dataBlock.filename)}this.submitRequest(xhr,formData,files)}},{key:"_transformFiles",value:function _transformFiles(files,done){var _this17=this;var transformedFiles=[];var doneCounter=0;var _loop=function _loop(i){_this17.options.transformFile.call(_this17,files[i],function(transformedFile){transformedFiles[i]=transformedFile;if(++doneCounter===files.length){done(transformedFiles)}})};for(var i=0;i<files.length;i++){_loop(i)}}},{key:"_addFormElementData",value:function _addFormElementData(formData){if(this.element.tagName==="FORM"){var _iteratorNormalCompletion23=true;var _didIteratorError23=false;var _iteratorError23=undefined;try{for(var _iterator23=this.element.querySelectorAll("input, textarea, select, button")[Symbol.iterator](),_step23;!(_iteratorNormalCompletion23=(_step23=_iterator23.next()).done);_iteratorNormalCompletion23=true){var input=_step23.value;var inputName=input.getAttribute("name");var inputType=input.getAttribute("type");if(inputType)inputType=inputType.toLowerCase();if(typeof inputName==="undefined"||inputName===null)continue;if(input.tagName==="SELECT"&&input.hasAttribute("multiple")){var _iteratorNormalCompletion24=true;var _didIteratorError24=false;var _iteratorError24=undefined;try{for(var _iterator24=input.options[Symbol.iterator](),_step24;!(_iteratorNormalCompletion24=(_step24=_iterator24.next()).done);_iteratorNormalCompletion24=true){var option=_step24.value;if(option.selected){formData.append(inputName,option.value)}}}catch(err){_didIteratorError24=true;_iteratorError24=err}finally{try{if(!_iteratorNormalCompletion24&&_iterator24["return"]!=null){_iterator24["return"]()}}finally{if(_didIteratorError24){throw _iteratorError24}}}}else if(!inputType||inputType!=="checkbox"&&inputType!=="radio"||input.checked){formData.append(inputName,input.value)}}}catch(err){_didIteratorError23=true;_iteratorError23=err}finally{try{if(!_iteratorNormalCompletion23&&_iterator23["return"]!=null){_iterator23["return"]()}}finally{if(_didIteratorError23){throw _iteratorError23}}}}}},{key:"_updateFilesUploadProgress",value:function _updateFilesUploadProgress(files,xhr,e){var progress;if(typeof e!=="undefined"){progress=100*e.loaded/e.total;if(files[0].upload.chunked){var file=files[0];var chunk=this._getChunk(file,xhr);chunk.progress=progress;chunk.total=e.total;chunk.bytesSent=e.loaded;var fileProgress=0,fileTotal,fileBytesSent;file.upload.progress=0;file.upload.total=0;file.upload.bytesSent=0;for(var i=0;i<file.upload.totalChunkCount;i++){if(file.upload.chunks[i]!==undefined&&file.upload.chunks[i].progress!==undefined){file.upload.progress+=file.upload.chunks[i].progress;file.upload.total+=file.upload.chunks[i].total;file.upload.bytesSent+=file.upload.chunks[i].bytesSent}}file.upload.progress=file.upload.progress/file.upload.totalChunkCount}else{var _iteratorNormalCompletion25=true;var _didIteratorError25=false;var _iteratorError25=undefined;try{for(var _iterator25=files[Symbol.iterator](),_step25;!(_iteratorNormalCompletion25=(_step25=_iterator25.next()).done);_iteratorNormalCompletion25=true){var _file2=_step25.value;_file2.upload.progress=progress;_file2.upload.total=e.total;_file2.upload.bytesSent=e.loaded}}catch(err){_didIteratorError25=true;_iteratorError25=err}finally{try{if(!_iteratorNormalCompletion25&&_iterator25["return"]!=null){_iterator25["return"]()}}finally{if(_didIteratorError25){throw _iteratorError25}}}}var _iteratorNormalCompletion26=true;var _didIteratorError26=false;var _iteratorError26=undefined;try{for(var _iterator26=files[Symbol.iterator](),_step26;!(_iteratorNormalCompletion26=(_step26=_iterator26.next()).done);_iteratorNormalCompletion26=true){var _file3=_step26.value;this.emit("uploadprogress",_file3,_file3.upload.progress,_file3.upload.bytesSent)}}catch(err){_didIteratorError26=true;_iteratorError26=err}finally{try{if(!_iteratorNormalCompletion26&&_iterator26["return"]!=null){_iterator26["return"]()}}finally{if(_didIteratorError26){throw _iteratorError26}}}}else{var allFilesFinished=true;progress=100;var _iteratorNormalCompletion27=true;var _didIteratorError27=false;var _iteratorError27=undefined;try{for(var _iterator27=files[Symbol.iterator](),_step27;!(_iteratorNormalCompletion27=(_step27=_iterator27.next()).done);_iteratorNormalCompletion27=true){var _file4=_step27.value;if(_file4.upload.progress!==100||_file4.upload.bytesSent!==_file4.upload.total){allFilesFinished=false}_file4.upload.progress=progress;_file4.upload.bytesSent=_file4.upload.total}}catch(err){_didIteratorError27=true;_iteratorError27=err}finally{try{if(!_iteratorNormalCompletion27&&_iterator27["return"]!=null){_iterator27["return"]()}}finally{if(_didIteratorError27){throw _iteratorError27}}}if(allFilesFinished){return}var _iteratorNormalCompletion28=true;var _didIteratorError28=false;var _iteratorError28=undefined;try{for(var _iterator28=files[Symbol.iterator](),_step28;!(_iteratorNormalCompletion28=(_step28=_iterator28.next()).done);_iteratorNormalCompletion28=true){var _file5=_step28.value;this.emit("uploadprogress",_file5,progress,_file5.upload.bytesSent)}}catch(err){_didIteratorError28=true;_iteratorError28=err}finally{try{if(!_iteratorNormalCompletion28&&_iterator28["return"]!=null){_iterator28["return"]()}}finally{if(_didIteratorError28){throw _iteratorError28}}}}}},{key:"_finishedUploading",value:function _finishedUploading(files,xhr,e){var response;if(files[0].status===Dropzone.CANCELED){return}if(xhr.readyState!==4){return}if(xhr.responseType!=="arraybuffer"&&xhr.responseType!=="blob"){response=xhr.responseText;if(xhr.getResponseHeader("content-type")&&~xhr.getResponseHeader("content-type").indexOf("application/json")){try{response=JSON.parse(response)}catch(error){e=error;response="Invalid JSON response from server."}}}this._updateFilesUploadProgress(files);if(!(200<=xhr.status&&xhr.status<300)){this._handleUploadError(files,xhr,response)}else{if(files[0].upload.chunked){files[0].upload.finishedChunkUpload(this._getChunk(files[0],xhr),response)}else{this._finished(files,response,e)}}}},{key:"_handleUploadError",value:function _handleUploadError(files,xhr,response){if(files[0].status===Dropzone.CANCELED){return}if(files[0].upload.chunked&&this.options.retryChunks){var chunk=this._getChunk(files[0],xhr);if(chunk.retries++<this.options.retryChunksLimit){this._uploadData(files,[chunk.dataBlock]);return}else{console.warn("Retried this chunk too often. Giving up.")}}this._errorProcessing(files,response||this.options.dictResponseError.replace("{{statusCode}}",xhr.status),xhr)}},{key:"submitRequest",value:function submitRequest(xhr,formData,files){xhr.send(formData)}},{key:"_finished",value:function _finished(files,responseText,e){var _iteratorNormalCompletion29=true;var _didIteratorError29=false;var _iteratorError29=undefined;try{for(var _iterator29=files[Symbol.iterator](),_step29;!(_iteratorNormalCompletion29=(_step29=_iterator29.next()).done);_iteratorNormalCompletion29=true){var file=_step29.value;file.status=Dropzone.SUCCESS;this.emit("success",file,responseText,e);this.emit("complete",file)}}catch(err){_didIteratorError29=true;_iteratorError29=err}finally{try{if(!_iteratorNormalCompletion29&&_iterator29["return"]!=null){_iterator29["return"]()}}finally{if(_didIteratorError29){throw _iteratorError29}}}if(this.options.uploadMultiple){this.emit("successmultiple",files,responseText,e);this.emit("completemultiple",files)}if(this.options.autoProcessQueue){return this.processQueue()}}},{key:"_errorProcessing",value:function _errorProcessing(files,message,xhr){var _iteratorNormalCompletion30=true;var _didIteratorError30=false;var _iteratorError30=undefined;try{for(var _iterator30=files[Symbol.iterator](),_step30;!(_iteratorNormalCompletion30=(_step30=_iterator30.next()).done);_iteratorNormalCompletion30=true){var file=_step30.value;file.status=Dropzone.ERROR;this.emit("error",file,message,xhr);this.emit("complete",file)}}catch(err){_didIteratorError30=true;_iteratorError30=err}finally{try{if(!_iteratorNormalCompletion30&&_iterator30["return"]!=null){_iterator30["return"]()}}finally{if(_didIteratorError30){throw _iteratorError30}}}if(this.options.uploadMultiple){this.emit("errormultiple",files,message,xhr);this.emit("completemultiple",files)}if(this.options.autoProcessQueue){return this.processQueue()}}}],[{key:"uuidv4",value:function uuidv4(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(c){var r=Math.random()*16|0,v=c==="x"?r:r&3|8;return v.toString(16)})}}]);return Dropzone}(Emitter);Dropzone.initClass();Dropzone.version="5.7.0";Dropzone.options={};Dropzone.optionsForElement=function(element){if(element.getAttribute("id")){return Dropzone.options[camelize(element.getAttribute("id"))]}else{return undefined}};Dropzone.instances=[];Dropzone.forElement=function(element){if(typeof element==="string"){element=document.querySelector(element)}if((element!=null?element.dropzone:undefined)==null){throw new Error("No Dropzone found for given element. This is probably because you're trying to access it before Dropzone had the time to initialize. Use the `init` option to setup any additional observers on your Dropzone.")}return element.dropzone};Dropzone.autoDiscover=true;Dropzone.discover=function(){var dropzones;if(document.querySelectorAll){dropzones=document.querySelectorAll(".dropzone")}else{dropzones=[];var checkElements=function checkElements(elements){return function(){var result=[];var _iteratorNormalCompletion31=true;var _didIteratorError31=false;var _iteratorError31=undefined;try{for(var _iterator31=elements[Symbol.iterator](),_step31;!(_iteratorNormalCompletion31=(_step31=_iterator31.next()).done);_iteratorNormalCompletion31=true){var el=_step31.value;if(/(^| )dropzone($| )/.test(el.className)){result.push(dropzones.push(el))}else{result.push(undefined)}}}catch(err){_didIteratorError31=true;_iteratorError31=err}finally{try{if(!_iteratorNormalCompletion31&&_iterator31["return"]!=null){_iterator31["return"]()}}finally{if(_didIteratorError31){throw _iteratorError31}}}return result}()};checkElements(document.getElementsByTagName("div"));checkElements(document.getElementsByTagName("form"))}return function(){var result=[];var _iteratorNormalCompletion32=true;var _didIteratorError32=false;var _iteratorError32=undefined;try{for(var _iterator32=dropzones[Symbol.iterator](),_step32;!(_iteratorNormalCompletion32=(_step32=_iterator32.next()).done);_iteratorNormalCompletion32=true){var dropzone=_step32.value;if(Dropzone.optionsForElement(dropzone)!==false){result.push(new Dropzone(dropzone))}else{result.push(undefined)}}}catch(err){_didIteratorError32=true;_iteratorError32=err}finally{try{if(!_iteratorNormalCompletion32&&_iterator32["return"]!=null){_iterator32["return"]()}}finally{if(_didIteratorError32){throw _iteratorError32}}}return result}()};Dropzone.blacklistedBrowsers=[/opera.*(Macintosh|Windows Phone).*version\/12/i];Dropzone.isBrowserSupported=function(){var capableBrowser=true;if(window.File&&window.FileReader&&window.FileList&&window.Blob&&window.FormData&&document.querySelector){if(!("classList"in document.createElement("a"))){capableBrowser=false}else{var _iteratorNormalCompletion33=true;var _didIteratorError33=false;var _iteratorError33=undefined;try{for(var _iterator33=Dropzone.blacklistedBrowsers[Symbol.iterator](),_step33;!(_iteratorNormalCompletion33=(_step33=_iterator33.next()).done);_iteratorNormalCompletion33=true){var regex=_step33.value;if(regex.test(navigator.userAgent)){capableBrowser=false;continue}}}catch(err){_didIteratorError33=true;_iteratorError33=err}finally{try{if(!_iteratorNormalCompletion33&&_iterator33["return"]!=null){_iterator33["return"]()}}finally{if(_didIteratorError33){throw _iteratorError33}}}}}else{capableBrowser=false}return capableBrowser};Dropzone.dataURItoBlob=function(dataURI){var byteString=atob(dataURI.split(",")[1]);var mimeString=dataURI.split(",")[0].split(":")[1].split(";")[0];var ab=new ArrayBuffer(byteString.length);var ia=new Uint8Array(ab);for(var i=0,end=byteString.length,asc=0<=end;asc?i<=end:i>=end;asc?i++:i--){ia[i]=byteString.charCodeAt(i)}return new Blob([ab],{type:mimeString})};var without=function without(list,rejectedItem){return list.filter(function(item){return item!==rejectedItem}).map(function(item){return item})};var camelize=function camelize(str){return str.replace(/[\-_](\w)/g,function(match){return match.charAt(1).toUpperCase()})};Dropzone.createElement=function(string){var div=document.createElement("div");div.innerHTML=string;return div.childNodes[0]};Dropzone.elementInside=function(element,container){if(element===container){return true}while(element=element.parentNode){if(element===container){return true}}return false};Dropzone.getElement=function(el,name){var element;if(typeof el==="string"){element=document.querySelector(el)}else if(el.nodeType!=null){element=el}if(element==null){throw new Error("Invalid `".concat(name,"` option provided. Please provide a CSS selector or a plain HTML element."))}return element};Dropzone.getElements=function(els,name){var el,elements;if(els instanceof Array){elements=[];try{var _iteratorNormalCompletion34=true;var _didIteratorError34=false;var _iteratorError34=undefined;try{for(var _iterator34=els[Symbol.iterator](),_step34;!(_iteratorNormalCompletion34=(_step34=_iterator34.next()).done);_iteratorNormalCompletion34=true){el=_step34.value;elements.push(this.getElement(el,name))}}catch(err){_didIteratorError34=true;_iteratorError34=err}finally{try{if(!_iteratorNormalCompletion34&&_iterator34["return"]!=null){_iterator34["return"]()}}finally{if(_didIteratorError34){throw _iteratorError34}}}}catch(e){elements=null}}else if(typeof els==="string"){elements=[];var _iteratorNormalCompletion35=true;var _didIteratorError35=false;var _iteratorError35=undefined;try{for(var _iterator35=document.querySelectorAll(els)[Symbol.iterator](),_step35;!(_iteratorNormalCompletion35=(_step35=_iterator35.next()).done);_iteratorNormalCompletion35=true){el=_step35.value;elements.push(el)}}catch(err){_didIteratorError35=true;_iteratorError35=err}finally{try{if(!_iteratorNormalCompletion35&&_iterator35["return"]!=null){_iterator35["return"]()}}finally{if(_didIteratorError35){throw _iteratorError35}}}}else if(els.nodeType!=null){elements=[els]}if(elements==null||!elements.length){throw new Error("Invalid `".concat(name,"` option provided. Please provide a CSS selector, a plain HTML element or a list of those."))}return elements};Dropzone.confirm=function(question,accepted,rejected){if(window.confirm(question)){return accepted()}else if(rejected!=null){return rejected()}};Dropzone.isValidFile=function(file,acceptedFiles){if(!acceptedFiles){return true}acceptedFiles=acceptedFiles.split(",");var mimeType=file.type;var baseMimeType=mimeType.replace(/\/.*$/,"");var _iteratorNormalCompletion36=true;var _didIteratorError36=false;var _iteratorError36=undefined;try{for(var _iterator36=acceptedFiles[Symbol.iterator](),_step36;!(_iteratorNormalCompletion36=(_step36=_iterator36.next()).done);_iteratorNormalCompletion36=true){var validType=_step36.value;validType=validType.trim();if(validType.charAt(0)==="."){if(file.name.toLowerCase().indexOf(validType.toLowerCase(),file.name.length-validType.length)!==-1){return true}}else if(/\/\*$/.test(validType)){if(baseMimeType===validType.replace(/\/.*$/,"")){return true}}else{if(mimeType===validType){return true}}}}catch(err){_didIteratorError36=true;_iteratorError36=err}finally{try{if(!_iteratorNormalCompletion36&&_iterator36["return"]!=null){_iterator36["return"]()}}finally{if(_didIteratorError36){throw _iteratorError36}}}return false};if(typeof jQuery!=="undefined"&&jQuery!==null){jQuery.fn.dropzone=function(options){return this.each(function(){return new Dropzone(this,options)})}}if(typeof module!=="undefined"&&module!==null){module.exports=Dropzone}else{window.Dropzone=Dropzone}Dropzone.ADDED="added";Dropzone.QUEUED="queued";Dropzone.ACCEPTED=Dropzone.QUEUED;Dropzone.UPLOADING="uploading";Dropzone.PROCESSING=Dropzone.UPLOADING;Dropzone.CANCELED="canceled";Dropzone.ERROR="error";Dropzone.SUCCESS="success";var detectVerticalSquash=function detectVerticalSquash(img){var iw=img.naturalWidth;var ih=img.naturalHeight;var canvas=document.createElement("canvas");canvas.width=1;canvas.height=ih;var ctx=canvas.getContext("2d");ctx.drawImage(img,0,0);var _ctx$getImageData=ctx.getImageData(1,0,1,ih),data=_ctx$getImageData.data;var sy=0;var ey=ih;var py=ih;while(py>sy){var alpha=data[(py-1)*4+3];if(alpha===0){ey=py}else{sy=py}py=ey+sy>>1}var ratio=py/ih;if(ratio===0){return 1}else{return ratio}};var drawImageIOSFix=function drawImageIOSFix(ctx,img,sx,sy,sw,sh,dx,dy,dw,dh){var vertSquashRatio=detectVerticalSquash(img);return ctx.drawImage(img,sx,sy,sw,sh,dx,dy,dw,dh/vertSquashRatio)};var ExifRestore=function(){function ExifRestore(){_classCallCheck(this,ExifRestore)}_createClass(ExifRestore,null,[{key:"initClass",value:function initClass(){this.KEY_STR="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}},{key:"encode64",value:function encode64(input){var output="";var chr1=undefined;var chr2=undefined;var chr3="";var enc1=undefined;var enc2=undefined;var enc3=undefined;var enc4="";var i=0;while(true){chr1=input[i++];chr2=input[i++];chr3=input[i++];enc1=chr1>>2;enc2=(chr1&3)<<4|chr2>>4;enc3=(chr2&15)<<2|chr3>>6;enc4=chr3&63;if(isNaN(chr2)){enc3=enc4=64}else if(isNaN(chr3)){enc4=64}output=output+this.KEY_STR.charAt(enc1)+this.KEY_STR.charAt(enc2)+this.KEY_STR.charAt(enc3)+this.KEY_STR.charAt(enc4);chr1=chr2=chr3="";enc1=enc2=enc3=enc4="";if(!(i<input.length)){break}}return output}},{key:"restore",value:function restore(origFileBase64,resizedFileBase64){if(!origFileBase64.match("data:image/jpeg;base64,")){return resizedFileBase64}var rawImage=this.decode64(origFileBase64.replace("data:image/jpeg;base64,",""));var segments=this.slice2Segments(rawImage);var image=this.exifManipulation(resizedFileBase64,segments);return"data:image/jpeg;base64,".concat(this.encode64(image))}},{key:"exifManipulation",value:function exifManipulation(resizedFileBase64,segments){var exifArray=this.getExifArray(segments);var newImageArray=this.insertExif(resizedFileBase64,exifArray);var aBuffer=new Uint8Array(newImageArray);return aBuffer}},{key:"getExifArray",value:function getExifArray(segments){var seg=undefined;var x=0;while(x<segments.length){seg=segments[x];if(seg[0]===255&seg[1]===225){return seg}x++}return[]}},{key:"insertExif",value:function insertExif(resizedFileBase64,exifArray){var imageData=resizedFileBase64.replace("data:image/jpeg;base64,","");var buf=this.decode64(imageData);var separatePoint=buf.indexOf(255,3);var mae=buf.slice(0,separatePoint);var ato=buf.slice(separatePoint);var array=mae;array=array.concat(exifArray);array=array.concat(ato);return array}},{key:"slice2Segments",value:function slice2Segments(rawImageArray){var head=0;var segments=[];while(true){var length;if(rawImageArray[head]===255&rawImageArray[head+1]===218){break}if(rawImageArray[head]===255&rawImageArray[head+1]===216){head+=2}else{length=rawImageArray[head+2]*256+rawImageArray[head+3];var endPoint=head+length+2;var seg=rawImageArray.slice(head,endPoint);segments.push(seg);head=endPoint}if(head>rawImageArray.length){break}}return segments}},{key:"decode64",value:function decode64(input){var output="";var chr1=undefined;var chr2=undefined;var chr3="";var enc1=undefined;var enc2=undefined;var enc3=undefined;var enc4="";var i=0;var buf=[];var base64test=/[^A-Za-z0-9\+\/\=]/g;if(base64test.exec(input)){console.warn("There were invalid base64 characters in the input text.\nValid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='\nExpect errors in decoding.")}input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(true){enc1=this.KEY_STR.indexOf(input.charAt(i++));enc2=this.KEY_STR.indexOf(input.charAt(i++));enc3=this.KEY_STR.indexOf(input.charAt(i++));enc4=this.KEY_STR.indexOf(input.charAt(i++));chr1=enc1<<2|enc2>>4;chr2=(enc2&15)<<4|enc3>>2;chr3=(enc3&3)<<6|enc4;buf.push(chr1);if(enc3!==64){buf.push(chr2)}if(enc4!==64){buf.push(chr3)}chr1=chr2=chr3="";enc1=enc2=enc3=enc4="";if(!(i<input.length)){break}}return buf}}]);return ExifRestore}();ExifRestore.initClass();var contentLoaded=function contentLoaded(win,fn){var done=false;var top=true;var doc=win.document;var root=doc.documentElement;var add=doc.addEventListener?"addEventListener":"attachEvent";var rem=doc.addEventListener?"removeEventListener":"detachEvent";var pre=doc.addEventListener?"":"on";var init=function init(e){if(e.type==="readystatechange"&&doc.readyState!=="complete"){return}(e.type==="load"?win:doc)[rem](pre+e.type,init,false);if(!done&&(done=true)){return fn.call(win,e.type||e)}};var poll=function poll(){try{root.doScroll("left")}catch(e){setTimeout(poll,50);return}return init("poll")};if(doc.readyState!=="complete"){if(doc.createEventObject&&root.doScroll){try{top=!win.frameElement}catch(error){}if(top){poll()}}doc[add](pre+"DOMContentLoaded",init,false);doc[add](pre+"readystatechange",init,false);return win[add](pre+"load",init,false)}};Dropzone._autoDiscoverFunction=function(){if(Dropzone.autoDiscover){return Dropzone.discover()}};contentLoaded(window,Dropzone._autoDiscoverFunction);function __guard__(value,transform){return typeof value!=="undefined"&&value!==null?transform(value):undefined}function __guardMethod__(obj,methodName,transform){if(typeof obj!=="undefined"&&obj!==null&&typeof obj[methodName]==="function"){return transform(obj,methodName)}else{return undefined}}return module.exports});
  6539. define('upload',['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined, Dropzone, Template) {
  6540. var Upload = {
  6541. list: {},
  6542. options: {},
  6543. config: {
  6544. container: document.body,
  6545. classname: '.plupload:not([initialized]),.faupload:not([initialized])',
  6546. previewtpl: '<li class="col-xs-3"><a href="<%=fullurl%>" data-url="<%=url%>" target="_blank" class="thumbnail"><img src="<%=fullurl%>" onerror="this.src=\'' + Fast.api.fixurl("ajax/icon") + '?suffix=<%=suffix%>\';this.onerror=null;" class="img-responsive"></a><a href="javascript:;" class="btn btn-danger btn-xs btn-trash"><i class="fa fa-trash"></i></a></li>',
  6547. },
  6548. events: {
  6549. //初始化
  6550. onInit: function () {
  6551. },
  6552. //上传成功的回调
  6553. onUploadSuccess: function (up, ret, file) {
  6554. var button = up.element;
  6555. var onUploadSuccess = up.options.onUploadSuccess;
  6556. var data = typeof ret.data !== 'undefined' ? ret.data : null;
  6557. //上传成功后回调
  6558. if (button) {
  6559. //如果有文本框则填充
  6560. var input_id = $(button).data("input-id") ? $(button).data("input-id") : "";
  6561. if (input_id) {
  6562. var urlArr = [];
  6563. var inputObj = $("#" + input_id);
  6564. if ($(button).data("multiple") && inputObj.val() !== "") {
  6565. urlArr.push(inputObj.val());
  6566. }
  6567. var url = Config.upload.fullmode ? (data.fullurl ? data.fullurl : Fast.api.cdnurl(data.url)) : data.url;
  6568. urlArr.push(url);
  6569. inputObj.val(urlArr.join(",")).trigger("change").trigger("validate");
  6570. }
  6571. //如果有回调函数
  6572. var onDomUploadSuccess = $(button).data("upload-success");
  6573. if (onDomUploadSuccess) {
  6574. if (typeof onDomUploadSuccess !== 'function' && typeof Upload.api.custom[onDomUploadSuccess] === 'function') {
  6575. onDomUploadSuccess = Upload.api.custom[onDomUploadSuccess];
  6576. }
  6577. if (typeof onDomUploadSuccess === 'function') {
  6578. var result = onDomUploadSuccess.call(button, data, ret, up, file);
  6579. if (result === false)
  6580. return;
  6581. }
  6582. }
  6583. }
  6584. if (typeof onUploadSuccess === 'function') {
  6585. var result = onUploadSuccess.call(button, data, ret, up, file);
  6586. if (result === false)
  6587. return;
  6588. }
  6589. },
  6590. //上传错误的回调
  6591. onUploadError: function (up, ret, file) {
  6592. var button = up.element;
  6593. var onUploadError = up.options.onUploadError;
  6594. var data = typeof ret.data !== 'undefined' ? ret.data : null;
  6595. if (button) {
  6596. var onDomUploadError = $(button).data("upload-error");
  6597. if (onDomUploadError) {
  6598. if (typeof onDomUploadError !== 'function' && typeof Upload.api.custom[onDomUploadError] === 'function') {
  6599. onDomUploadError = Upload.api.custom[onDomUploadError];
  6600. }
  6601. if (typeof onDomUploadError === 'function') {
  6602. var result = onDomUploadError.call(button, data, ret, up, file);
  6603. if (result === false)
  6604. return;
  6605. }
  6606. }
  6607. }
  6608. if (typeof onUploadError === 'function') {
  6609. var result = onUploadError.call(button, data, ret, up, file);
  6610. if (result === false) {
  6611. return;
  6612. }
  6613. }
  6614. Toastr.error(ret.msg.toString().replace(/(<([^>]+)>)/gi, "") + "(code:" + ret.code + ")");
  6615. },
  6616. //服务器响应数据后
  6617. onUploadResponse: function (response, up, file) {
  6618. try {
  6619. var ret = typeof response === 'object' ? response : JSON.parse(response);
  6620. if (!ret.hasOwnProperty('code')) {
  6621. $.extend(ret, {code: -2, msg: response, data: null});
  6622. }
  6623. } catch (e) {
  6624. var ret = {code: -1, msg: e.message, data: null};
  6625. }
  6626. return ret;
  6627. },
  6628. //上传全部结束后
  6629. onUploadComplete: function (up, files) {
  6630. var button = up.element;
  6631. var onUploadComplete = up.options.onUploadComplete;
  6632. if (button) {
  6633. var onDomUploadComplete = $(button).data("upload-complete");
  6634. if (onDomUploadComplete) {
  6635. if (typeof onDomUploadComplete !== 'function' && typeof Upload.api.custom[onDomUploadComplete] === 'function') {
  6636. onDomUploadComplete = Upload.api.custom[onDomUploadComplete];
  6637. }
  6638. if (typeof onDomUploadComplete === 'function') {
  6639. var result = onDomUploadComplete.call(button, files);
  6640. if (result === false)
  6641. return;
  6642. }
  6643. }
  6644. }
  6645. if (typeof onUploadComplete === 'function') {
  6646. var result = onUploadComplete.call(button, files);
  6647. if (result === false) {
  6648. return;
  6649. }
  6650. }
  6651. }
  6652. },
  6653. api: {
  6654. //上传接口
  6655. upload: function (element, onUploadSuccess, onUploadError, onUploadComplete) {
  6656. element = typeof element === 'undefined' ? Upload.config.classname : element;
  6657. $(element, Upload.config.container).each(function () {
  6658. if ($(this).attr("initialized")) {
  6659. return true;
  6660. }
  6661. $(this).attr("initialized", true);
  6662. var that = this;
  6663. var id = $(this).prop("id") || $(this).prop("name") || Dropzone.uuidv4();
  6664. var url = $(this).data("url");
  6665. var maxsize = $(this).data("maxsize");
  6666. var maxcount = $(this).data("maxcount");
  6667. var mimetype = $(this).data("mimetype");
  6668. var multipart = $(this).data("multipart");
  6669. var multiple = $(this).data("multiple");
  6670. //填充ID
  6671. var input_id = $(that).data("input-id") ? $(that).data("input-id") : "";
  6672. //预览ID
  6673. var preview_id = $(that).data("preview-id") ? $(that).data("preview-id") : "";
  6674. //上传URL
  6675. url = url ? url : Config.upload.uploadurl;
  6676. url = Fast.api.fixurl(url);
  6677. var chunking = false, chunkSize = Config.upload.chunksize || 2097152, timeout = Config.upload.timeout || 600000;
  6678. //最大可上传文件大小
  6679. maxsize = typeof maxsize !== "undefined" ? maxsize : Config.upload.maxsize;
  6680. //文件类型
  6681. mimetype = typeof mimetype !== "undefined" ? mimetype : Config.upload.mimetype;
  6682. //请求的表单参数
  6683. multipart = typeof multipart !== "undefined" ? multipart : Config.upload.multipart;
  6684. //是否支持批量上传
  6685. multiple = typeof multiple !== "undefined" ? multiple : Config.upload.multiple;
  6686. //后缀特殊处理
  6687. mimetype = mimetype.split(",").map(function (k) {
  6688. return k.indexOf("/") > -1 ? k : (!k || k === "*" || k.charAt(0) === "." ? k : "." + k);
  6689. }).join(",");
  6690. mimetype = mimetype === '*' ? null : mimetype;
  6691. //最大文件限制转换成mb
  6692. var maxFilesize = (function (maxsize) {
  6693. var matches = maxsize.toString().match(/^([0-9\.]+)(\w+)$/);
  6694. var size = matches ? parseFloat(matches[1]) : parseFloat(maxsize),
  6695. unit = matches ? matches[2].toLowerCase() : 'b';
  6696. var unitDict = {'b': 0, 'k': 1, 'kb': 1, 'm': 2, 'mb': 2, 'gb': 3, 'g': 3, 'tb': 4, 't': 4};
  6697. var y = typeof unitDict[unit] !== 'undefined' ? unitDict[unit] : 0;
  6698. var bytes = size * Math.pow(1024, y);
  6699. return bytes / Math.pow(1024, 2);
  6700. }(maxsize));
  6701. var options = $(this).data() || {};
  6702. options = $.extend(true, {}, options, $(this).data("upload-options") || {});
  6703. delete options.success;
  6704. delete options.url;
  6705. // delete options.params;
  6706. multipart = $.isArray(multipart) ? {} : multipart;
  6707. Upload.list[id] = new Dropzone(this, $.extend({
  6708. url: url,
  6709. params: function (files, xhr, chunk) {
  6710. var params = multipart;
  6711. if (chunk) {
  6712. return $.extend({}, params, {
  6713. filesize: chunk.file.size,
  6714. filename: chunk.file.name,
  6715. chunkid: chunk.file.upload.uuid,
  6716. chunkindex: chunk.index,
  6717. chunkcount: chunk.file.upload.totalChunkCount,
  6718. chunksize: this.options.chunkSize,
  6719. chunkfilesize: chunk.dataBlock.data.size,
  6720. width: chunk.file.width || 0,
  6721. height: chunk.file.height || 0,
  6722. type: chunk.file.type,
  6723. });
  6724. }
  6725. return params;
  6726. },
  6727. chunking: chunking,
  6728. chunkSize: chunkSize,
  6729. maxFilesize: maxFilesize,
  6730. acceptedFiles: mimetype,
  6731. maxFiles: (maxcount && parseInt(maxcount) > 1 ? maxcount : (multiple ? null : 1)),
  6732. timeout: timeout,
  6733. parallelUploads: 1,
  6734. previewsContainer: false,
  6735. dictDefaultMessage: __("Drop files here to upload"),
  6736. dictFallbackMessage: __("Your browser does not support drag'n'drop file uploads"),
  6737. dictFallbackText: __("Please use the fallback form below to upload your files like in the olden days"),
  6738. dictFileTooBig: __("File is too big (%sMiB), Max filesize: %sMiB", "{{filesize}}", "{{maxFilesize}}"),
  6739. dictInvalidFileType: __("You can't upload files of this type"),
  6740. dictResponseError: __("Server responded with %s code.", "{{statusCode}}"),
  6741. dictCancelUpload: __("Cancel upload"),
  6742. dictUploadCanceled: __("Upload canceled"),
  6743. dictCancelUploadConfirmation: __("Are you sure you want to cancel this upload?"),
  6744. dictRemoveFile: __("Remove file"),
  6745. dictMaxFilesExceeded: __("You can only upload a maximum of %s files", "{{maxFiles}}"),
  6746. init: function () {
  6747. Upload.events.onInit.call(this);
  6748. //必须添加dz-message,否则点击icon无法唤起上传窗口
  6749. $(">i", this.element).addClass("dz-message");
  6750. this.options.elementHtml = $(this.element).html();
  6751. },
  6752. sending: function (file, xhr, formData) {
  6753. if (typeof file.category !== 'undefined') {
  6754. formData.append('category', file.category);
  6755. }
  6756. },
  6757. addedfile: function (file) {
  6758. var params = $(this.element).data("params") || {};
  6759. params = typeof params === 'function' ? params.call(this, file) : params;
  6760. var category = typeof params.category !== 'undefined' ? params.category : ($(this.element).data("category") || '');
  6761. file.category = typeof category === 'function' ? category.call(this, file) : category;
  6762. },
  6763. addedfiles: function (files) {
  6764. if (this.options.maxFiles && (!this.options.maxFiles || this.options.maxFiles > 1) && this.options.inputId) {
  6765. var inputObj = $("#" + this.options.inputId);
  6766. if (inputObj.length > 0) {
  6767. var value = $.trim(inputObj.val());
  6768. var nums = value === '' ? 0 : value.split(/\,/).length;
  6769. var remain = this.options.maxFiles - nums;
  6770. if (remain === 0 || files.length > remain) {
  6771. files = Array.prototype.slice.call(files, remain);
  6772. for (var i = 0; i < files.length; i++) {
  6773. this.removeFile(files[i]);
  6774. }
  6775. Toastr.error(__("You can only upload a maximum of %s files", this.options.maxFiles));
  6776. }
  6777. }
  6778. }
  6779. },
  6780. success: function (file, response) {
  6781. var ret = Upload.events.onUploadResponse(response, this, file);
  6782. file.ret = ret;
  6783. if (ret.code === 1) {
  6784. Upload.events.onUploadSuccess(this, ret, file);
  6785. } else {
  6786. Upload.events.onUploadError(this, ret, file);
  6787. }
  6788. },
  6789. error: function (file, response, xhr) {
  6790. var responseObj = $("<div>" + (xhr && typeof xhr.responseText !== 'undefined' ? xhr.responseText : response) + "</div>");
  6791. responseObj.find("style, title, script").remove();
  6792. var msg = responseObj.text() || __('Network error');
  6793. var ret = {code: 0, data: null, msg: msg};
  6794. Upload.events.onUploadError(this, ret, file);
  6795. },
  6796. uploadprogress: function (file, progress, bytesSent) {
  6797. if (file.upload.chunked) {
  6798. $(this.element).prop("disabled", true).html("<i class='fa fa-upload'></i> " + __('Upload') + Math.floor((file.upload.bytesSent / file.size) * 100) + "%");
  6799. }
  6800. },
  6801. totaluploadprogress: function (progress, bytesSent) {
  6802. if (this.getActiveFiles().length > 0 && !this.options.chunking) {
  6803. $(this.element).prop("disabled", true).html("<i class='fa fa-upload'></i> " + __('Upload') + Math.floor(progress) + "%");
  6804. }
  6805. },
  6806. queuecomplete: function () {
  6807. Upload.events.onUploadComplete(this, this.files);
  6808. this.removeAllFiles(true);
  6809. $(this.element).prop("disabled", false).html(this.options.elementHtml);
  6810. },
  6811. chunkSuccess: function (chunk, file, response) {
  6812. },
  6813. chunksUploaded: function (file, done) {
  6814. var that = this;
  6815. Fast.api.ajax({
  6816. url: this.options.url,
  6817. data: $.extend({}, multipart, {
  6818. action: 'merge',
  6819. filesize: file.size,
  6820. filename: file.name,
  6821. chunkid: file.upload.uuid,
  6822. chunkcount: file.upload.totalChunkCount,
  6823. })
  6824. }, function (data, ret) {
  6825. done(JSON.stringify(ret));
  6826. return false;
  6827. }, function (data, ret) {
  6828. file.accepted = false;
  6829. that._errorProcessing([file], ret.msg);
  6830. });
  6831. },
  6832. onUploadSuccess: onUploadSuccess,
  6833. onUploadError: onUploadError,
  6834. onUploadComplete: onUploadComplete,
  6835. }, Upload.options, options));
  6836. //拖动排序
  6837. if (preview_id && multiple) {
  6838. require(['dragsort'], function () {
  6839. $("#" + preview_id).dragsort({
  6840. dragSelector: "li a:not(.btn-trash)",
  6841. dragEnd: function () {
  6842. $("#" + preview_id).trigger("fa.preview.change");
  6843. },
  6844. placeHolderTemplate: '<li class="col-xs-3"></li>'
  6845. });
  6846. });
  6847. }
  6848. //刷新隐藏textarea的值
  6849. var refresh = function (name) {
  6850. var data = {};
  6851. var textarea = $("textarea[name='" + name + "']");
  6852. var container = textarea.prev("ul");
  6853. $.each($("input,select,textarea", container).serializeArray(), function (i, j) {
  6854. var reg = /\[?(\w+)\]?\[(\w+)\]$/g;
  6855. var match = reg.exec(j.name);
  6856. if (!match)
  6857. return true;
  6858. if (!isNaN(match[2])) {
  6859. data[i] = j.value;
  6860. } else {
  6861. match[1] = "x" + parseInt(match[1]);
  6862. if (typeof data[match[1]] === 'undefined') {
  6863. data[match[1]] = {};
  6864. }
  6865. data[match[1]][match[2]] = j.value;
  6866. }
  6867. });
  6868. var result = [];
  6869. $.each(data, function (i, j) {
  6870. result.push(j);
  6871. });
  6872. textarea.val(JSON.stringify(result));
  6873. };
  6874. if (preview_id && input_id) {
  6875. $(document.body).on("keyup change", "#" + input_id, function (e) {
  6876. var inputStr = $("#" + input_id).val();
  6877. var inputArr = inputStr.split(/\,/);
  6878. var previewObj = $("#" + preview_id);
  6879. previewObj.empty();
  6880. var tpl = previewObj.data("template") ? previewObj.data("template") : "";
  6881. var extend = previewObj.next().is("textarea") ? previewObj.next("textarea").val() : "{}";
  6882. var json = {};
  6883. try {
  6884. json = JSON.parse(extend);
  6885. } catch (e) {
  6886. }
  6887. $.each(inputArr, function (i, j) {
  6888. if (!j) {
  6889. return true;
  6890. }
  6891. var suffix = /[\.]?([a-zA-Z0-9]+)$/.exec(j);
  6892. suffix = suffix ? suffix[1] : 'file';
  6893. var btnData = $(that).data();
  6894. var fullurl = typeof btnData.cdnurl!=='undefined' ? Fast.api.cdnurl(j, btnData.cdnurl) : Fast.api.cdnurl(j);
  6895. j = Config.upload.fullmode ? fullurl : j;
  6896. var value = (json && typeof json[i] !== 'undefined' ? json[i] : null);
  6897. var data = {url: j, fullurl: fullurl, data: btnData, key: i, index: i, value: value, row: value, suffix: suffix};
  6898. var html = tpl ? Template(tpl, data) : Template.render(Upload.config.previewtpl, data);
  6899. previewObj.append(html);
  6900. });
  6901. refresh(previewObj.data("name"));
  6902. });
  6903. $("#" + input_id).trigger("change");
  6904. }
  6905. if (preview_id) {
  6906. //监听文本框改变事件
  6907. $("#" + preview_id).on('change keyup', "input,textarea,select", function () {
  6908. refresh($(this).closest("ul").data("name"));
  6909. });
  6910. // 监听事件
  6911. $(document.body).on("fa.preview.change", "#" + preview_id, function () {
  6912. var urlArr = [];
  6913. $("#" + preview_id + " [data-url]").each(function (i, j) {
  6914. urlArr.push($(this).data("url"));
  6915. });
  6916. if (input_id) {
  6917. $("#" + input_id).val(urlArr.join(","));
  6918. }
  6919. refresh($("#" + preview_id).data("name"));
  6920. });
  6921. // 移除按钮事件
  6922. $(document.body).on("click", "#" + preview_id + " .btn-trash", function () {
  6923. $(this).closest("li").remove();
  6924. $("#" + preview_id).trigger("fa.preview.change");
  6925. });
  6926. }
  6927. if (input_id) {
  6928. $("#" + input_id).closest("form").on("reset", function () {
  6929. setTimeout($.proxy(function () {
  6930. $("#" + input_id, this).trigger("change");
  6931. }, this), 0);
  6932. });
  6933. //粘贴上传、拖拽上传
  6934. $("body").on('paste drop', "#" + input_id, function (event) {
  6935. var originEvent = event.originalEvent;
  6936. var button = $(".plupload[data-input-id='" + $(this).attr("id") + "'],.faupload[data-input-id='" + $(this).attr("id") + "']");
  6937. if (event.type === 'paste' && originEvent.clipboardData && originEvent.clipboardData.items) {
  6938. var items = originEvent.clipboardData.items;
  6939. if ((items.length === 1 && items[0].type.indexOf("text") > -1) || (items.length === 2 && items[1].type.indexOf("text") > -1)) {
  6940. } else {
  6941. Upload.list[button.attr("id")].paste(originEvent);
  6942. return false;
  6943. }
  6944. }
  6945. if (event.type === 'drop' && originEvent.dataTransfer && originEvent.dataTransfer.files) {
  6946. Upload.list[button.attr("id")].drop(originEvent);
  6947. return false;
  6948. }
  6949. });
  6950. }
  6951. });
  6952. },
  6953. /**
  6954. * @deprecated Use upload instead.
  6955. */
  6956. plupload: function (element, onUploadSuccess, onUploadError, onUploadComplete) {
  6957. return Upload.api.upload(element, onUploadSuccess, onUploadError, onUploadComplete);
  6958. },
  6959. /**
  6960. * @deprecated Use upload instead.
  6961. */
  6962. faupload: function (element, onUploadSuccess, onUploadError, onUploadComplete) {
  6963. return Upload.api.upload(element, onUploadSuccess, onUploadError, onUploadComplete);
  6964. },
  6965. // AJAX异步上传
  6966. send: function (file, onUploadSuccess, onUploadError, onUploadComplete) {
  6967. var index = Layer.msg(__('Uploading'), {offset: 't', time: 0});
  6968. var id = "dropzone-" + Dropzone.uuidv4();
  6969. $('<button type="button" id="' + id + '" class="btn btn-danger hidden faupload" />').appendTo("body");
  6970. $("#" + id).data("upload-complete", function (files) {
  6971. Layer.close(index);
  6972. Upload.list[id].removeAllFiles(true);
  6973. });
  6974. Upload.api.upload("#" + id, onUploadSuccess, onUploadError, onUploadComplete);
  6975. setTimeout(function () {
  6976. Upload.list[id].addFile(file);
  6977. }, 1);
  6978. },
  6979. custom: {
  6980. //自定义上传完成回调
  6981. afteruploadcallback: function (response) {
  6982. console.log(this, response);
  6983. alert("Custom Callback,Response URL:" + response.url);
  6984. },
  6985. }
  6986. }
  6987. }
  6988. ;
  6989. return Upload;
  6990. });
  6991. ;(function(factory) {
  6992. typeof module === 'object' && module.exports ? module.exports = factory( require( 'jquery' ) ) :
  6993. typeof define === 'function' && define.amd ? define('validator',['jquery'], factory) :
  6994. factory(jQuery);
  6995. }(function($, undefined) {
  6996. 'use strict';
  6997. var NS = 'validator',
  6998. CLS_NS = '.' + NS,
  6999. CLS_NS_RULE = '.rule',
  7000. CLS_NS_FIELD = '.field',
  7001. CLS_NS_FORM = '.form',
  7002. CLS_WRAPPER = 'nice-' + NS,
  7003. CLS_MSG_BOX = 'msg-box',
  7004. ARIA_INVALID = 'aria-invalid',
  7005. DATA_RULE = 'data-rule',
  7006. DATA_MSG = 'data-msg',
  7007. DATA_TIP = 'data-tip',
  7008. DATA_OK = 'data-ok',
  7009. DATA_TIMELY = 'data-timely',
  7010. DATA_TARGET = 'data-target',
  7011. DATA_DISPLAY = 'data-display',
  7012. DATA_MUST = 'data-must',
  7013. NOVALIDATE = 'novalidate',
  7014. INPUT_SELECTOR = ':verifiable',
  7015. rRules = /(&)?(!)?\b(\w+)(?:\[\s*(.*?\]?)\s*\]|\(\s*(.*?\)?)\s*\))?\s*(;|\|)?/g,
  7016. rRule = /(\w+)(?:\[\s*(.*?\]?)\s*\]|\(\s*(.*?\)?)\s*\))?/,
  7017. rDisplay = /(?:([^:;\(\[]*):)?(.*)/,
  7018. rDoubleBytes = /[^\x00-\xff]/g,
  7019. rPos = /top|right|bottom|left/,
  7020. rAjaxType = /(?:(cors|jsonp):)?(?:(post|get):)?(.+)/i,
  7021. rUnsafe = /[<>'"`\\]|&#x?\d+[A-F]?;?|%3[A-F]/gmi,
  7022. noop = $.noop,
  7023. proxy = $.proxy,
  7024. trim = $.trim,
  7025. isFunction = $.isFunction,
  7026. isString = function(s) {
  7027. return typeof s === 'string';
  7028. },
  7029. isObject = function(o) {
  7030. return o && Object.prototype.toString.call(o) === '[object Object]';
  7031. },
  7032. isIE = document.documentMode || +(navigator.userAgent.match(/MSIE (\d+)/) && RegExp.$1),
  7033. attr = function(el, key, value) {
  7034. if (!el || !el.tagName) return null;
  7035. if (value !== undefined) {
  7036. if (value === null) el.removeAttribute(key);
  7037. else el.setAttribute(key, '' + value);
  7038. } else {
  7039. return el.getAttribute(key);
  7040. }
  7041. },
  7042. novalidateonce,
  7043. preinitialized = {},
  7044. defaults = {
  7045. debug: 0,
  7046. theme: 'default',
  7047. ignore: '',
  7048. focusInvalid: true,
  7049. focusCleanup: false,
  7050. stopOnError: false,
  7051. beforeSubmit: null,
  7052. valid: null,
  7053. invalid: null,
  7054. validation: null,
  7055. formClass: 'n-default',
  7056. validClass: 'n-valid',
  7057. invalidClass: 'n-invalid',
  7058. bindClassTo: null,
  7059. remoteDataType: 'cors'
  7060. },
  7061. fieldDefaults = {
  7062. timely: 1,
  7063. display: null,
  7064. target: null,
  7065. ignoreBlank: false,
  7066. showOk: true,
  7067. // Translate ajax response to validation result
  7068. dataFilter: function (data) {
  7069. if ( isString(data) || ( isObject(data) && ('error' in data || 'ok' in data) ) ) {
  7070. return data;
  7071. }
  7072. },
  7073. msgMaker: function(opt) {
  7074. var html;
  7075. html = '<span role="alert" class="msg-wrap n-'+ opt.type + '">' + opt.arrow;
  7076. if (opt.result) {
  7077. $.each(opt.result, function(i, obj){
  7078. html += '<span class="n-'+ obj.type +'">' + opt.icon + '<span class="n-msg">' + obj.msg + '</span></span>';
  7079. });
  7080. } else {
  7081. html += opt.icon + '<span class="n-msg">' + opt.msg + '</span>';
  7082. }
  7083. html += '</span>';
  7084. return html;
  7085. },
  7086. msgWrapper: 'span',
  7087. msgArrow: '',
  7088. msgIcon: '<span class="n-icon"></span>',
  7089. msgClass: 'n-right',
  7090. msgStyle: '',
  7091. msgShow: null,
  7092. msgHide: null
  7093. },
  7094. themes = {};
  7095. /** jQuery Plugin
  7096. * @param {Object} options
  7097. debug {Boolean} 0 Whether to enable debug mode
  7098. timely {Number} 1 Whether to enable timely validation
  7099. theme {String} 'default' Theme name
  7100. stopOnError {Boolean} false Whether to stop validate when found an error input
  7101. focusCleanup {Boolean} false Whether to clean up the field message when focus the field
  7102. focusInvalid {Boolean} true Whether to focus the field that is invalid
  7103. ignoreBlank {Boolean} false When the field has no value, whether to ignore validation
  7104. ignore {jqSelector} '' Ignored fields (Using jQuery selector)
  7105. beforeSubmit {Function} Do something before submit form
  7106. dataFilter {Function} Convert ajax results
  7107. valid {Function} Triggered when the form is valid
  7108. invalid {Function} Triggered when the form is invalid
  7109. validClass {String} 'n-valid' Add this class name to a valid field
  7110. invalidClass {String} 'n-invalid' Add this class name to a invalid field
  7111. bindClassTo {jqSelector} ':verifiable' Which element should the className binding to
  7112. display {Function} Callback function to get dynamic display
  7113. target {Function} Callback function to get dynamic target
  7114. msgShow {Function} Trigger this callback when show message
  7115. msgHide {Function} Trigger this callback when hide message
  7116. msgWrapper {String} 'span' Message wrapper tag name
  7117. msgMaker {Function} Callback function to make message HTML
  7118. msgArrow {String} Message arrow template
  7119. msgIcon {String} Message icon template
  7120. msgStyle {String} Custom message css style
  7121. msgClass {String} Additional added to the message class names
  7122. formClass {String} Additional added to the form class names
  7123. messages {Object} Custom messages for the current instance
  7124. rules {Object} Custom rules for the current instance
  7125. fields {Object} Field validation configuration
  7126. {String} key name|#id
  7127. {String|Object} value Rule string or an object which can pass more arguments
  7128. fields[key][rule] {String} Rule string
  7129. fields[key][display] {String|Function}
  7130. fields[key][tip] {String} Custom tip message
  7131. fields[key][ok] {String} Custom success message
  7132. fields[key][msg] {Object} Custom error message
  7133. fields[key][msgStyle] {String} Custom message style
  7134. fields[key][msgClass] {String} A className which added to message placeholder element
  7135. fields[key][msgWrapper] {String} Tag name of the message placeholder element
  7136. fields[key][msgMaker] {Function} A function to custom message HTML
  7137. fields[key][dataFilter] {Function} A function to convert ajax results
  7138. fields[key][valid] {Function} A function triggered when field is valid
  7139. fields[key][invalid] {Function} A function triggered when field is invalid
  7140. fields[key][must] {Boolean} If set true, we always check the field even has remote checking
  7141. fields[key][timely] {Boolean} Whether to enable timely validation
  7142. fields[key][target] {jqSelector} Define placement of a message
  7143. */
  7144. $.fn.validator = function(options) {
  7145. var that = this,
  7146. args = arguments;
  7147. if (that.is(INPUT_SELECTOR)) return that;
  7148. if (!that.is('form')) that = this.find('form');
  7149. if (!that.length) that = this;
  7150. that.each(function() {
  7151. var instance = $(this).data(NS);
  7152. if (instance) {
  7153. if ( isString(options) ) {
  7154. if ( options.charAt(0) === '_' ) return;
  7155. instance[options].apply(instance, [].slice.call(args, 1));
  7156. }
  7157. else if (options) {
  7158. instance._reset(true);
  7159. instance._init(this, options);
  7160. }
  7161. } else {
  7162. new Validator(this, options);
  7163. }
  7164. });
  7165. return this;
  7166. };
  7167. // Validate a field, or an area
  7168. $.fn.isValid = function(callback, hideMsg) {
  7169. var me = _getInstance(this[0]),
  7170. hasCallback = isFunction(callback),
  7171. ret, opt;
  7172. if (!me) return true;
  7173. if (!hasCallback && hideMsg === undefined) hideMsg = callback;
  7174. me.checkOnly = !!hideMsg;
  7175. opt = me.options;
  7176. ret = me._multiValidate(
  7177. this.is(INPUT_SELECTOR) ? this : this.find(INPUT_SELECTOR),
  7178. function(isValid){
  7179. if (!isValid && opt.focusInvalid && !me.checkOnly) {
  7180. // navigate to the error element
  7181. me.$el.find('[' + ARIA_INVALID + ']:first').focus();
  7182. }
  7183. if (hasCallback) {
  7184. if (callback.length) {
  7185. callback(isValid);
  7186. } else if (isValid) {
  7187. callback();
  7188. }
  7189. }
  7190. me.checkOnly = false;
  7191. }
  7192. );
  7193. // If you pass a callback, we maintain the jQuery object chain
  7194. return hasCallback ? this : ret;
  7195. };
  7196. $.extend($.expr.pseudos || $.expr[':'], {
  7197. // A faster selector than ":input:not(:submit,:button,:reset,:image,:disabled,[contenteditable])"
  7198. verifiable: function(elem) {
  7199. var name = elem.nodeName.toLowerCase();
  7200. return ( name === 'input' && !({submit: 1, button: 1, reset: 1, image: 1})[elem.type] ||
  7201. name === 'select' ||
  7202. name === 'textarea' ||
  7203. elem.contentEditable === 'true'
  7204. ) && !elem.disabled;
  7205. },
  7206. // any value, but not only whitespace
  7207. filled: function(elem) {
  7208. return !!trim($(elem).val());
  7209. }
  7210. });
  7211. /**
  7212. * Creates a new Validator
  7213. *
  7214. * @class
  7215. * @param {Element} element - form element
  7216. * @param {Object} options - options for validator
  7217. */
  7218. function Validator(element, options) {
  7219. var me = this;
  7220. if ( !(me instanceof Validator) ) {
  7221. return new Validator(element, options);
  7222. }
  7223. if (Validator.pending) {
  7224. $(window).on('validatorready', init);
  7225. } else {
  7226. init();
  7227. }
  7228. function init() {
  7229. me.$el = $(element);
  7230. if (me.$el.length) {
  7231. me._init(me.$el[0], options);
  7232. }
  7233. else if (isString(element)) {
  7234. preinitialized[element] = options;
  7235. }
  7236. }
  7237. }
  7238. Validator.prototype = {
  7239. _init: function(element, options) {
  7240. var me = this,
  7241. opt, themeOpt, dataOpt;
  7242. // Initialization options
  7243. if ( isFunction(options) ) {
  7244. options = {
  7245. valid: options
  7246. };
  7247. }
  7248. options = me._opt = options || {};
  7249. dataOpt = attr(element, 'data-'+ NS +'-option');
  7250. dataOpt = me._dataOpt = dataOpt && dataOpt.charAt(0) === '{' ? (new Function('return ' + dataOpt))() : {};
  7251. themeOpt = me._themeOpt = themes[ options.theme || dataOpt.theme || defaults.theme ];
  7252. opt = me.options = $.extend({}, defaults, fieldDefaults, themeOpt, me.options, options, dataOpt);
  7253. me.rules = new Rules(opt.rules, true);
  7254. me.messages = new Messages(opt.messages, true);
  7255. me.Field = _createFieldFactory(me);
  7256. me.elements = me.elements || {};
  7257. me.deferred = {};
  7258. me.errors = {};
  7259. me.fields = {};
  7260. // Initialization fields
  7261. me._initFields(opt.fields);
  7262. // Initialization events and make a cache
  7263. if ( !me.$el.data(NS) ) {
  7264. me.$el.data(NS, me).addClass(CLS_WRAPPER +' '+ opt.formClass)
  7265. .on('form-submit-validate', function(e, a, $form, opts, veto) {
  7266. me.vetoed = veto.veto = !me.isValid;
  7267. me.ajaxFormOptions = opts;
  7268. })
  7269. .on('submit'+ CLS_NS +' validate'+ CLS_NS, proxy(me, '_submit'))
  7270. .on('reset'+ CLS_NS, proxy(me, '_reset'))
  7271. .on('showmsg'+ CLS_NS, proxy(me, '_showmsg'))
  7272. .on('hidemsg'+ CLS_NS, proxy(me, '_hidemsg'))
  7273. .on('focusin'+ CLS_NS + ' click'+ CLS_NS, INPUT_SELECTOR, proxy(me, '_focusin'))
  7274. .on('focusout'+ CLS_NS +' validate'+ CLS_NS, INPUT_SELECTOR, proxy(me, '_focusout'))
  7275. .on('keyup'+ CLS_NS +' input'+ CLS_NS + ' compositionstart compositionend', INPUT_SELECTOR, proxy(me, '_focusout'))
  7276. .on('click'+ CLS_NS, ':radio,:checkbox', 'click', proxy(me, '_focusout'))
  7277. .on('change'+ CLS_NS, 'select,input[type="file"]', 'change', proxy(me, '_focusout'));
  7278. // cache the novalidate attribute value
  7279. me._NOVALIDATE = attr(element, NOVALIDATE);
  7280. // Initialization is complete, stop off default HTML5 form validation
  7281. // If use "jQuery.attr('novalidate')" in IE7 will complain: "SCRIPT3: Member not found."
  7282. attr(element, NOVALIDATE, NOVALIDATE);
  7283. }
  7284. // Display all messages in target container
  7285. if ( isString(opt.target) ) {
  7286. me.$el.find(opt.target).addClass('msg-container');
  7287. }
  7288. },
  7289. // Guess whether the form use ajax submit
  7290. _guessAjax: function(form) {
  7291. var me = this;
  7292. if ( !(me.isAjaxSubmit = !!me.options.valid) ) {
  7293. // if there is a "valid.form" event
  7294. var events = ($._data || $.data)(form, 'events');
  7295. me.isAjaxSubmit = issetEvent(events, 'valid', 'form') || issetEvent(events, 'submit', 'form-plugin');
  7296. }
  7297. function issetEvent(events, name, namespace) {
  7298. return !!(
  7299. events && events[name]
  7300. && $.map(events[name], function(e){
  7301. return ~e.namespace.indexOf(namespace) ? 1 : null;
  7302. }).length )
  7303. }
  7304. },
  7305. _initFields: function(fields) {
  7306. var me = this, k, arr, i,
  7307. clear = fields === null;
  7308. // Processing field information
  7309. if (clear) fields = me.fields;
  7310. if ( isObject(fields) ) {
  7311. for (k in fields) {
  7312. if (~k.indexOf(',')) {
  7313. arr = k.split(',');
  7314. i = arr.length;
  7315. while (i--) {
  7316. initField(trim(arr[i]), fields[k]);
  7317. }
  7318. } else {
  7319. initField(k, fields[k]);
  7320. }
  7321. }
  7322. }
  7323. // Parsing DOM rules
  7324. me.$el.find(INPUT_SELECTOR).each(function() {
  7325. me._parse(this);
  7326. });
  7327. function initField(k, v) {
  7328. // delete a field from settings
  7329. if ( v === null || clear ) {
  7330. var el = me.elements[k];
  7331. if (el) me._resetElement(el, true);
  7332. delete me.fields[k];
  7333. } else {
  7334. me.fields[k] = new me.Field(k, isString(v) ? {rule: v} : v, me.fields[k]);
  7335. }
  7336. }
  7337. },
  7338. // Parsing a field
  7339. _parse: function(el) {
  7340. var me = this,
  7341. field,
  7342. key = el.name,
  7343. display,
  7344. timely,
  7345. dataRule = attr(el, DATA_RULE);
  7346. dataRule && attr(el, DATA_RULE, null);
  7347. // If the field has passed the key as id mode, or it doesn't has a name
  7348. if ( el.id && (
  7349. ('#' + el.id in me.fields) ||
  7350. !key ||
  7351. // If dataRule and element are diffrent from old's, we use ID mode.
  7352. (dataRule !== null && (field = me.fields[key]) && dataRule !== field.rule && el.id !== field.key)
  7353. )
  7354. ) {
  7355. key = '#' + el.id;
  7356. }
  7357. // Generate id
  7358. if (!key) {
  7359. key = '#' + (el.id = 'N' + String(Math.random()).slice(-12));
  7360. }
  7361. field = me.getField(key, true);
  7362. // The priority of passing parameter by DOM is higher than by JS.
  7363. field.rule = dataRule || field.rule;
  7364. if (display = attr(el, DATA_DISPLAY)) {
  7365. field.display = display;
  7366. }
  7367. if (field.rule) {
  7368. if ( attr(el, DATA_MUST) !== null || /\b(?:match|checked)\b/.test(field.rule) ) {
  7369. field.must = true;
  7370. }
  7371. if ( /\brequired\b/.test(field.rule) ) {
  7372. field.required = true;
  7373. }
  7374. if (timely = attr(el, DATA_TIMELY)) {
  7375. field.timely = +timely;
  7376. } else if (field.timely > 3) {
  7377. attr(el, DATA_TIMELY, field.timely);
  7378. }
  7379. me._parseRule(field);
  7380. field.old = {};
  7381. }
  7382. if ( isString(field.target) ) {
  7383. attr(el, DATA_TARGET, field.target);
  7384. }
  7385. if ( isString(field.tip) ) {
  7386. attr(el, DATA_TIP, field.tip);
  7387. }
  7388. return me.fields[key] = field;
  7389. },
  7390. // Parsing field rules
  7391. _parseRule: function(field) {
  7392. var arr = rDisplay.exec(field.rule);
  7393. if (!arr) return;
  7394. // current rule index
  7395. field._i = 0;
  7396. if (arr[1]) {
  7397. field.display = arr[1];
  7398. }
  7399. if (arr[2]) {
  7400. field._rules = [];
  7401. arr[2].replace(rRules, function(){
  7402. var args = arguments;
  7403. args[4] = args[4] || args[5];
  7404. field._rules.push({
  7405. and: args[1] === '&',
  7406. not: args[2] === '!',
  7407. or: args[6] === '|',
  7408. method: args[3],
  7409. params: args[4] ? $.map( args[4].split(', '), trim ) : undefined
  7410. });
  7411. });
  7412. }
  7413. },
  7414. // Verify a zone
  7415. _multiValidate: function($inputs, doneCallback){
  7416. var me = this,
  7417. opt = me.options;
  7418. me.hasError = false;
  7419. if (opt.ignore) {
  7420. $inputs = $inputs.not(opt.ignore);
  7421. }
  7422. $inputs.each(function() {
  7423. me._validate(this);
  7424. if (me.hasError && opt.stopOnError) {
  7425. // stop the validation
  7426. return false;
  7427. }
  7428. });
  7429. // Need to wait for all fields validation complete, especially asynchronous validation
  7430. if (doneCallback) {
  7431. me.validating = true;
  7432. $.when.apply(
  7433. null,
  7434. $.map(me.deferred, function(v){return v;})
  7435. ).done(function(){
  7436. doneCallback.call(me, !me.hasError);
  7437. me.validating = false;
  7438. });
  7439. }
  7440. // If the form does not contain asynchronous validation, the return value is correct.
  7441. // Otherwise, you should detect form validation result through "doneCallback".
  7442. return !$.isEmptyObject(me.deferred) ? undefined : !me.hasError;
  7443. },
  7444. // Validate the whole form
  7445. _submit: function(e) {
  7446. var me = this,
  7447. opt = me.options,
  7448. form = e.target,
  7449. canSubmit = e.type === 'submit' && form.tagName === 'FORM' && !e.isDefaultPrevented();
  7450. e.preventDefault();
  7451. if (
  7452. novalidateonce && ~(novalidateonce = false) ||
  7453. // Prevent duplicate submission
  7454. me.submiting ||
  7455. // Receive the "validate" event only from the form.
  7456. e.type === 'validate' && me.$el[0] !== form ||
  7457. // trigger the beforeSubmit callback.
  7458. isFunction(opt.beforeSubmit) && opt.beforeSubmit.call(me, form) === false
  7459. ) {
  7460. return;
  7461. }
  7462. if (me.isAjaxSubmit === undefined) {
  7463. me._guessAjax(form);
  7464. }
  7465. me._debug('log', '\n<<< event: ' + e.type);
  7466. me._reset();
  7467. me.submiting = true;
  7468. me._multiValidate(
  7469. me.$el.find(INPUT_SELECTOR),
  7470. function(isValid){
  7471. var ret = (isValid || opt.debug === 2) ? 'valid' : 'invalid',
  7472. errors;
  7473. if (!isValid) {
  7474. if (opt.focusInvalid) {
  7475. // navigate to the error element
  7476. me.$el.find('[' + ARIA_INVALID + ']:first').focus();
  7477. }
  7478. errors = $.map(me.errors, function(err){return err;});
  7479. }
  7480. // releasing submit
  7481. me.submiting = false;
  7482. me.isValid = isValid;
  7483. // trigger callback and event
  7484. isFunction(opt[ret]) && opt[ret].call(me, form, errors);
  7485. me.$el.trigger(ret + CLS_NS_FORM, [form, errors]);
  7486. me._debug('log', '>>> ' + ret);
  7487. if (!isValid) return;
  7488. // For jquery.form plugin
  7489. if (me.vetoed) {
  7490. $(form).ajaxSubmit(me.ajaxFormOptions);
  7491. }
  7492. else if (canSubmit && !me.isAjaxSubmit) {
  7493. document.createElement('form').submit.call(form);
  7494. }
  7495. }
  7496. );
  7497. },
  7498. _reset: function(e) {
  7499. var me = this;
  7500. me.errors = {};
  7501. if (e) {
  7502. me.reseting = true;
  7503. me.$el.find(INPUT_SELECTOR).each( function(){
  7504. me._resetElement(this);
  7505. });
  7506. delete me.reseting;
  7507. }
  7508. },
  7509. _resetElement: function(el, all) {
  7510. this._setClass(el, null);
  7511. this.hideMsg(el);
  7512. },
  7513. // Handle events: "focusin/click"
  7514. _focusin: function(e) {
  7515. var me = this,
  7516. opt = me.options,
  7517. el = e.target,
  7518. timely,
  7519. msg;
  7520. if ( me.validating || ( e.type==='click' && document.activeElement === el ) ) {
  7521. return;
  7522. }
  7523. if (opt.focusCleanup) {
  7524. if ( attr(el, ARIA_INVALID) === 'true' ) {
  7525. me._setClass(el, null);
  7526. me.hideMsg(el);
  7527. }
  7528. }
  7529. msg = attr(el, DATA_TIP);
  7530. if (msg) {
  7531. me.showMsg(el, {
  7532. type: 'tip',
  7533. msg: msg
  7534. });
  7535. } else {
  7536. if (attr(el, DATA_RULE)) {
  7537. me._parse(el);
  7538. }
  7539. if (timely = attr(el, DATA_TIMELY)) {
  7540. if ( timely === 8 || timely === 9 ) {
  7541. me._focusout(e);
  7542. }
  7543. }
  7544. }
  7545. },
  7546. // Handle events: "focusout/validate/keyup/click/change/input/compositionstart/compositionend"
  7547. _focusout: function(e) {
  7548. var me = this,
  7549. opt = me.options,
  7550. el = e.target,
  7551. etype = e.type,
  7552. etype0,
  7553. focusin = etype === 'focusin',
  7554. special = etype === 'validate',
  7555. elem,
  7556. field,
  7557. old,
  7558. value,
  7559. timestamp,
  7560. key, specialKey,
  7561. timely,
  7562. timer = 0;
  7563. if (etype === 'compositionstart') {
  7564. me.pauseValidate = true;
  7565. }
  7566. if (etype === 'compositionend') {
  7567. me.pauseValidate = false;
  7568. }
  7569. if (me.pauseValidate) {
  7570. return;
  7571. }
  7572. // For checkbox and radio
  7573. elem = el.name && _checkable(el) ? me.$el.find('input[name="'+ el.name +'"]').get(0) : el;
  7574. // Get field
  7575. if (!(field = me.getField(elem)) || !field.rule) {
  7576. return;
  7577. }
  7578. // Cache event type
  7579. etype0 = field._e;
  7580. field._e = etype;
  7581. timely = field.timely;
  7582. if (!special) {
  7583. if (!timely || (_checkable(el) && etype !== 'click')) {
  7584. return;
  7585. }
  7586. value = field.getValue();
  7587. // not validate field unless fill a value
  7588. if ( field.ignoreBlank && !value && !focusin ) {
  7589. me.hideMsg(el);
  7590. return;
  7591. }
  7592. if ( etype === 'focusout' ) {
  7593. if (etype0 === 'change') {
  7594. return;
  7595. }
  7596. if ( timely === 2 || timely === 8 ) {
  7597. old = field.old;
  7598. if (value && old) {
  7599. if (field.isValid && !old.showOk) {
  7600. me.hideMsg(el);
  7601. } else {
  7602. me._makeMsg(el, field, old);
  7603. }
  7604. } else {
  7605. return;
  7606. }
  7607. }
  7608. }
  7609. else {
  7610. if ( timely < 2 && !e.data ) {
  7611. return;
  7612. }
  7613. // mark timestamp to reduce the frequency of the received event
  7614. timestamp = +new Date();
  7615. if ( timestamp - (el._ts || 0) < 100 ) {
  7616. return;
  7617. }
  7618. el._ts = timestamp;
  7619. // handle keyup
  7620. if ( etype === 'keyup' ) {
  7621. if (etype0 === 'input') {
  7622. return;
  7623. }
  7624. key = e.keyCode;
  7625. specialKey = {
  7626. 8: 1, // Backspace
  7627. 9: 1, // Tab
  7628. 16: 1, // Shift
  7629. 32: 1, // Space
  7630. 46: 1 // Delete
  7631. };
  7632. // only gets focus, no validation
  7633. if ( key === 9 && !value ) {
  7634. return;
  7635. }
  7636. // do not validate, if triggered by these keys
  7637. if ( key < 48 && !specialKey[key] ) {
  7638. return;
  7639. }
  7640. }
  7641. if ( !focusin ) {
  7642. // keyboard events, reducing the frequency of validation
  7643. timer = timely <100 ? (etype === 'click' || el.tagName === 'SELECT') ? 0 : 400 : timely;
  7644. }
  7645. }
  7646. }
  7647. // if the current field is ignored
  7648. if ( opt.ignore && $(el).is(opt.ignore) ) {
  7649. return;
  7650. }
  7651. clearTimeout(field._t);
  7652. if (timer) {
  7653. field._t = setTimeout(function() {
  7654. me._validate(el, field);
  7655. }, timer);
  7656. } else {
  7657. if (special) field.old = {};
  7658. me._validate(el, field);
  7659. }
  7660. },
  7661. _setClass: function(el, isValid) {
  7662. var $el = $(el), opt = this.options;
  7663. if (opt.bindClassTo) {
  7664. $el = $el.closest(opt.bindClassTo);
  7665. }
  7666. $el.removeClass( opt.invalidClass + ' ' + opt.validClass );
  7667. if (isValid !== null) {
  7668. $el.addClass( isValid ? opt.validClass : opt.invalidClass );
  7669. }
  7670. },
  7671. _showmsg: function(e, type, msg) {
  7672. var me = this,
  7673. el = e.target;
  7674. if ( me.$el.is(el) ) {
  7675. if (isObject(type)) {
  7676. me.showMsg(type)
  7677. }
  7678. else if ( type === 'tip' ) {
  7679. me.$el.find(INPUT_SELECTOR +'['+ DATA_TIP +']', el).each(function(){
  7680. me.showMsg(this, {type: type, msg: msg});
  7681. });
  7682. }
  7683. }
  7684. else {
  7685. me.showMsg(el, {type: type, msg: msg});
  7686. }
  7687. },
  7688. _hidemsg: function(e) {
  7689. var $el = $(e.target);
  7690. if ( $el.is(INPUT_SELECTOR) ) {
  7691. this.hideMsg($el);
  7692. }
  7693. },
  7694. // Validated a field
  7695. _validatedField: function(el, field, ret) {
  7696. var me = this,
  7697. opt = me.options,
  7698. isValid = field.isValid = ret.isValid = !!ret.isValid,
  7699. callback = isValid ? 'valid' : 'invalid';
  7700. ret.key = field.key;
  7701. ret.ruleName = field._r;
  7702. ret.id = el.id;
  7703. ret.value = field.value;
  7704. me.elements[field.key] = ret.element = el;
  7705. me.isValid = me.$el[0].isValid = isValid ? me.isFormValid() : isValid;
  7706. if (isValid) {
  7707. ret.type = 'ok';
  7708. } else {
  7709. if (me.submiting) {
  7710. me.errors[field.key] = ret.msg;
  7711. }
  7712. me.hasError = true;
  7713. }
  7714. // cache result
  7715. field.old = ret;
  7716. // trigger callback
  7717. isFunction(field[callback]) && field[callback].call(me, el, ret);
  7718. isFunction(opt.validation) && opt.validation.call(me, el, ret);
  7719. // trigger event
  7720. $(el).attr( ARIA_INVALID, isValid ? null : true )
  7721. .trigger( callback + CLS_NS_FIELD, [ret, me] );
  7722. me.$el.triggerHandler('validation', [ret, me]);
  7723. if (me.checkOnly) return;
  7724. // set className
  7725. me._setClass(el, ret.skip || ret.type === 'tip' ? null : isValid);
  7726. me._makeMsg.apply(me, arguments);
  7727. },
  7728. _makeMsg: function(el, field, ret) {
  7729. // show or hide the message
  7730. if (field.msgMaker) {
  7731. ret = $.extend({}, ret);
  7732. if (field._e === 'focusin') {
  7733. ret.type = 'tip';
  7734. }
  7735. this[ ret.showOk || ret.msg || ret.type === 'tip' ? 'showMsg' : 'hideMsg' ](el, ret, field);
  7736. }
  7737. },
  7738. // Validated a rule
  7739. _validatedRule: function(el, field, ret, msgOpt) {
  7740. field = field || me.getField(el);
  7741. msgOpt = msgOpt || {};
  7742. var me = this,
  7743. msg,
  7744. rule,
  7745. method = field._r,
  7746. timely = field.timely,
  7747. special = timely === 9 || timely === 8,
  7748. transfer,
  7749. temp,
  7750. isValid = false;
  7751. // use null to break validation from a field
  7752. if (ret === null) {
  7753. me._validatedField(el, field, {isValid: true, skip: true});
  7754. field._i = 0;
  7755. return;
  7756. }
  7757. else if (ret === undefined) {
  7758. transfer = true;
  7759. }
  7760. else if (ret === true || ret === '') {
  7761. isValid = true;
  7762. }
  7763. else if (isString(ret)) {
  7764. msg = ret;
  7765. }
  7766. else if (isObject(ret)) {
  7767. if (ret.error) {
  7768. msg = ret.error;
  7769. } else {
  7770. msg = ret.ok;
  7771. isValid = true;
  7772. }
  7773. }
  7774. else {
  7775. isValid = !!ret
  7776. }
  7777. rule = field._rules[field._i];
  7778. if (rule.not) {
  7779. msg = undefined;
  7780. isValid = method === 'required' || !isValid;
  7781. }
  7782. if (rule.or) {
  7783. if (isValid) {
  7784. while ( field._i < field._rules.length && field._rules[field._i].or ) {
  7785. field._i++;
  7786. }
  7787. } else {
  7788. transfer = true;
  7789. }
  7790. }
  7791. else if (rule.and) {
  7792. if (!field.isValid) transfer = true;
  7793. }
  7794. if (transfer) {
  7795. isValid = true;
  7796. }
  7797. // message analysis, and throw rule level event
  7798. else {
  7799. if (isValid) {
  7800. if (field.showOk !== false) {
  7801. temp = attr(el, DATA_OK);
  7802. msg = temp === null ? isString(field.ok) ? field.ok : msg : temp;
  7803. if (!isString(msg) && isString(field.showOk)) {
  7804. msg = field.showOk;
  7805. }
  7806. if (isString(msg)) {
  7807. msgOpt.showOk = isValid;
  7808. }
  7809. }
  7810. }
  7811. if (!isValid || special) {
  7812. /* rule message priority:
  7813. 1. custom DOM message
  7814. 2. custom field message;
  7815. 3. global defined message;
  7816. 4. rule returned message;
  7817. 5. default message;
  7818. */
  7819. msg = (_getDataMsg(el, field, msg || rule.msg || me.messages[method]) || me.messages.fallback).replace(/\{0\|?([^\}]*)\}/, function(m, defaultDisplay){
  7820. return me._getDisplay(el, field.display) || defaultDisplay || me.messages[0];
  7821. });
  7822. }
  7823. if (!isValid) field.isValid = isValid;
  7824. msgOpt.msg = msg;
  7825. $(el).trigger( (isValid ? 'valid' : 'invalid') + CLS_NS_RULE, [method, msg]);
  7826. }
  7827. if (special && (!transfer || rule.and)) {
  7828. if (!isValid && !field._m) field._m = msg;
  7829. field._v = field._v || [];
  7830. field._v.push({
  7831. type: isValid ? !transfer ? 'ok' : 'tip' : 'error',
  7832. msg: msg || rule.msg
  7833. });
  7834. }
  7835. me._debug('log', ' ' + field._i + ': ' + method + ' => ' + (isValid || msg));
  7836. // the current rule has passed, continue to validate
  7837. if ( (isValid || special) && field._i < field._rules.length - 1) {
  7838. field._i++;
  7839. me._checkRule(el, field);
  7840. }
  7841. // field was invalid, or all fields was valid
  7842. else {
  7843. field._i = 0;
  7844. if (special) {
  7845. msgOpt.isValid = field.isValid;
  7846. msgOpt.result = field._v;
  7847. msgOpt.msg = field._m || '';
  7848. if (!field.value && (field._e === 'focusin')) {
  7849. msgOpt.type = 'tip';
  7850. }
  7851. } else {
  7852. msgOpt.isValid = isValid;
  7853. }
  7854. me._validatedField(el, field, msgOpt);
  7855. delete field._m;
  7856. delete field._v;
  7857. }
  7858. },
  7859. // Verify a rule form a field
  7860. _checkRule: function(el, field) {
  7861. var me = this,
  7862. ret,
  7863. fn,
  7864. old,
  7865. key = field.key,
  7866. rule = field._rules[field._i],
  7867. method = rule.method,
  7868. params = rule.params;
  7869. // request has been sent, wait it
  7870. if (me.submiting && me.deferred[key]) {
  7871. return;
  7872. }
  7873. old = field.old;
  7874. field._r = method;
  7875. if (old && !field.must && !rule.must && rule.result !== undefined &&
  7876. old.ruleName === method && old.id === el.id &&
  7877. field.value && old.value === field.value )
  7878. {
  7879. // get result from cache
  7880. ret = rule.result;
  7881. }
  7882. else {
  7883. // get result from current rule
  7884. fn = _getDataRule(el, method) || me.rules[method] || noop;
  7885. ret = fn.call(field, el, params, field);
  7886. if (fn.msg) rule.msg = fn.msg;
  7887. }
  7888. // asynchronous validation
  7889. if (isObject(ret) && isFunction(ret.then)) {
  7890. me.deferred[key] = ret;
  7891. // whether the field valid is unknown
  7892. field.isValid = undefined;
  7893. // show loading message
  7894. !me.checkOnly && me.showMsg(el, {
  7895. type: 'loading',
  7896. msg: me.messages.loading
  7897. }, field);
  7898. // waiting to parse the response data
  7899. ret.then(
  7900. function(d, textStatus, jqXHR) {
  7901. var data = trim(jqXHR.responseText),
  7902. result,
  7903. dataFilter = field.dataFilter;
  7904. // detect if data is json or jsonp format
  7905. if (/jsonp?/.test(this.dataType)) {
  7906. data = d;
  7907. } else if (data.charAt(0) === '{') {
  7908. data = $.parseJSON(data);
  7909. }
  7910. // filter data
  7911. result = dataFilter.call(this, data, field);
  7912. if (result === undefined) result = dataFilter.call(this, data.data, field);
  7913. rule.data = this.data;
  7914. rule.result = field.old ? result : undefined;
  7915. me._validatedRule(el, field, result);
  7916. },
  7917. function(jqXHR, textStatus){
  7918. me._validatedRule(el, field, me.messages[textStatus] || textStatus);
  7919. }
  7920. ).always(function(){
  7921. delete me.deferred[key];
  7922. });
  7923. }
  7924. // other result
  7925. else {
  7926. me._validatedRule(el, field, ret);
  7927. }
  7928. },
  7929. // Processing the validation
  7930. _validate: function(el, field) {
  7931. var me = this;
  7932. // doesn't validate the element that has "disabled" or "novalidate" attribute
  7933. if ( el.disabled || attr(el, NOVALIDATE) !== null ) {
  7934. return;
  7935. }
  7936. field = field || me.getField(el);
  7937. if (!field) return;
  7938. if (!field._rules) me._parse(el);
  7939. if (!field._rules) return;
  7940. me._debug('info', field.key);
  7941. field.isValid = true;
  7942. field.element = el;
  7943. // Cache the value
  7944. field.value = field.getValue();
  7945. // if the field is not required, and that has a blank value
  7946. if (!field.required && !field.must && !field.value) {
  7947. if (!_checkable(el)) {
  7948. me._validatedField(el, field, {isValid: true});
  7949. return true;
  7950. }
  7951. }
  7952. me._checkRule(el, field);
  7953. return field.isValid;
  7954. },
  7955. _debug: function(type, messages) {
  7956. if (window.console && this.options.debug) {
  7957. console[type](messages);
  7958. }
  7959. },
  7960. /**
  7961. * Detecting whether the value of an element that matches a rule
  7962. *
  7963. * @method test
  7964. * @param {Element} el - input element
  7965. * @param {String} rule - rule name
  7966. */
  7967. test: function(el, rule) {
  7968. var me = this,
  7969. ret,
  7970. parts = rRule.exec(rule),
  7971. field,
  7972. method,
  7973. params;
  7974. if (parts) {
  7975. method = parts[1];
  7976. if (method in me.rules) {
  7977. params = parts[2] || parts[3];
  7978. params = params ? params.split(', ') : undefined;
  7979. field = me.getField(el, true);
  7980. field._r = method;
  7981. field.value = field.getValue();
  7982. ret = me.rules[method].call(field, el, params);
  7983. }
  7984. }
  7985. return ret === true || ret === undefined || ret === null;
  7986. },
  7987. _getDisplay: function(el, str) {
  7988. return !isString(str) ? isFunction(str) ? str.call(this, el) : '' : str;
  7989. },
  7990. _getMsgOpt: function(obj, field) {
  7991. var opt = field ? field : this.options;
  7992. return $.extend({
  7993. type: 'error',
  7994. pos: _getPos(opt.msgClass),
  7995. target: opt.target,
  7996. wrapper: opt.msgWrapper,
  7997. style: opt.msgStyle,
  7998. cls: opt.msgClass,
  7999. arrow: opt.msgArrow,
  8000. icon: opt.msgIcon
  8001. }, isString(obj) ? {msg: obj} : obj);
  8002. },
  8003. _getMsgDOM: function(el, msgOpt) {
  8004. var $el = $(el), $msgbox, datafor, tgt, container;
  8005. if ( $el.is(INPUT_SELECTOR) ) {
  8006. tgt = msgOpt.target || attr(el, DATA_TARGET);
  8007. if (tgt) {
  8008. tgt = !isFunction(tgt) ? tgt.charAt(0) === '#' ? $(tgt) : this.$el.find(tgt) : tgt.call(this, el);
  8009. if (tgt.length) {
  8010. if ( tgt.is(INPUT_SELECTOR) ) {
  8011. $el = tgt
  8012. el = tgt.get(0);
  8013. } else if ( tgt.hasClass(CLS_MSG_BOX) ) {
  8014. $msgbox = tgt;
  8015. } else {
  8016. container = tgt;
  8017. }
  8018. }
  8019. }
  8020. if (!$msgbox) {
  8021. datafor = (!_checkable(el) || !el.name) && el.id ? el.id : el.name;
  8022. $msgbox = (container || this.$el).find(msgOpt.wrapper + '.' + CLS_MSG_BOX + '[for="' + datafor + '"]');
  8023. }
  8024. } else {
  8025. $msgbox = $el;
  8026. }
  8027. // Create new message box
  8028. if (!msgOpt.hide && !$msgbox.length) {
  8029. $msgbox = $('<'+ msgOpt.wrapper + '>').attr({
  8030. 'class': CLS_MSG_BOX + (msgOpt.cls ? ' ' + msgOpt.cls : ''),
  8031. 'style': msgOpt.style || undefined,
  8032. 'for': datafor
  8033. });
  8034. if (container) {
  8035. $msgbox.appendTo(container);
  8036. } else {
  8037. if ( _checkable(el) ) {
  8038. var $parent = $el.parent();
  8039. $msgbox.appendTo( $parent.is('label') ? $parent.parent() : $parent );
  8040. } else {
  8041. $msgbox[!msgOpt.pos || msgOpt.pos === 'right' ? 'insertAfter' : 'insertBefore']($el);
  8042. }
  8043. }
  8044. }
  8045. return $msgbox;
  8046. },
  8047. /**
  8048. * Show validation message
  8049. *
  8050. * @method showMsg
  8051. * @param {Element} el - input element
  8052. * @param {Object} msgOpt
  8053. */
  8054. showMsg: function(el, msgOpt, /*INTERNAL*/ field) {
  8055. if (!el) return;
  8056. var me = this,
  8057. opt = me.options,
  8058. msgShow,
  8059. msgMaker,
  8060. temp,
  8061. $msgbox;
  8062. if (isObject(el) && !el.jquery && !msgOpt) {
  8063. $.each(el, function(key, msg) {
  8064. var el = me.elements[key] || me.$el.find(_key2selector(key))[0];
  8065. me.showMsg(el, msg);
  8066. });
  8067. return;
  8068. }
  8069. if ($(el).is(INPUT_SELECTOR)) {
  8070. field = field || me.getField(el);
  8071. }
  8072. if (!(msgMaker = (field || opt).msgMaker)) {
  8073. return;
  8074. }
  8075. msgOpt = me._getMsgOpt(msgOpt, field);
  8076. el = (el.name && _checkable(el) ? me.$el.find('input[name="'+ el.name +'"]') : $(el)).get(0);
  8077. // ok or tip
  8078. if (!msgOpt.msg && msgOpt.type !== 'error') {
  8079. temp = attr(el, 'data-' + msgOpt.type);
  8080. if (temp !== null) msgOpt.msg = temp;
  8081. }
  8082. if ( !isString(msgOpt.msg) ) {
  8083. return;
  8084. }
  8085. $msgbox = me._getMsgDOM(el, msgOpt);
  8086. !rPos.test($msgbox[0].className) && $msgbox.addClass(msgOpt.cls);
  8087. if ( isIE === 6 && msgOpt.pos === 'bottom' ) {
  8088. $msgbox[0].style.marginTop = $(el).outerHeight() + 'px';
  8089. }
  8090. $msgbox.html( msgMaker.call(me, msgOpt) )[0].style.display = '';
  8091. if (isFunction(msgShow = field && field.msgShow || opt.msgShow)) {
  8092. msgShow.call(me, $msgbox, msgOpt.type);
  8093. }
  8094. },
  8095. /**
  8096. * Hide validation message
  8097. *
  8098. * @method hideMsg
  8099. * @param {Element} el - input element
  8100. * @param {Object} msgOpt optional
  8101. */
  8102. hideMsg: function(el, msgOpt, /*INTERNAL*/ field) {
  8103. var me = this,
  8104. opt = me.options,
  8105. msgHide,
  8106. $msgbox;
  8107. el = $(el).get(0);
  8108. if ($(el).is(INPUT_SELECTOR)) {
  8109. field = field || me.getField(el);
  8110. if (field) {
  8111. if (field.isValid || me.reseting) attr(el, ARIA_INVALID, null);
  8112. }
  8113. }
  8114. msgOpt = me._getMsgOpt(msgOpt, field);
  8115. msgOpt.hide = true;
  8116. $msgbox = me._getMsgDOM(el, msgOpt);
  8117. if (!$msgbox.length) return;
  8118. if ( isFunction(msgHide = field && field.msgHide || opt.msgHide) ) {
  8119. msgHide.call(me, $msgbox, msgOpt.type);
  8120. } else {
  8121. $msgbox[0].style.display = 'none';
  8122. $msgbox[0].innerHTML = '';
  8123. }
  8124. },
  8125. /**
  8126. * Get field information
  8127. *
  8128. * @method getField
  8129. * @param {Element} - input element
  8130. * @return {Object} field
  8131. */
  8132. getField: function(el, must) {
  8133. var me = this,
  8134. key,
  8135. field;
  8136. if (isString(el)) {
  8137. key = el;
  8138. el = undefined;
  8139. } else {
  8140. if (attr(el, DATA_RULE)) {
  8141. return me._parse(el);
  8142. }
  8143. if (el.id && '#' + el.id in me.fields || !el.name) {
  8144. key = '#' + el.id;
  8145. } else {
  8146. key = el.name;
  8147. }
  8148. }
  8149. if ( (field = me.fields[key]) || must && (field = new me.Field(key)) ) {
  8150. field.element = el;
  8151. }
  8152. return field;
  8153. },
  8154. /**
  8155. * Config a field
  8156. *
  8157. * @method: setField
  8158. * @param {String} key
  8159. * @param {Object} obj
  8160. */
  8161. setField: function(key, obj) {
  8162. var fields = {};
  8163. if (!key) return;
  8164. // update this field
  8165. if (isString(key)) {
  8166. fields[key] = obj;
  8167. }
  8168. // update fields
  8169. else {
  8170. fields = key;
  8171. }
  8172. this._initFields(fields);
  8173. },
  8174. /**
  8175. * Detecting whether the form is valid
  8176. *
  8177. * @method isFormValid
  8178. * @return {Boolean}
  8179. */
  8180. isFormValid: function() {
  8181. var fields = this.fields, k, field;
  8182. for (k in fields) {
  8183. field = fields[k];
  8184. if (!field._rules || !field.required && !field.must && !field.value) continue;
  8185. if (!field.isValid) return false;
  8186. }
  8187. return true;
  8188. },
  8189. /**
  8190. * Prevent submission form
  8191. *
  8192. * @method holdSubmit
  8193. * @param {Boolean} hold - If set to false, will release the hold
  8194. */
  8195. holdSubmit: function(hold) {
  8196. this.submiting = hold === undefined || hold;
  8197. },
  8198. /**
  8199. * Clean validation messages
  8200. *
  8201. * @method cleanUp
  8202. */
  8203. cleanUp: function() {
  8204. this._reset(1);
  8205. },
  8206. /**
  8207. * Destroy the validation
  8208. *
  8209. * @method destroy
  8210. */
  8211. destroy: function() {
  8212. this._reset(1);
  8213. this.$el.off(CLS_NS).removeData(NS);
  8214. attr(this.$el[0], NOVALIDATE, this._NOVALIDATE);
  8215. }
  8216. };
  8217. /**
  8218. * Create Field Factory
  8219. *
  8220. * @class
  8221. * @param {Object} context
  8222. * @return {Function} Factory
  8223. */
  8224. function _createFieldFactory(context) {
  8225. function FieldFactory() {
  8226. var options = this.options;
  8227. for (var i in options) {
  8228. if (i in fieldDefaults) this[i] = options[i];
  8229. }
  8230. $.extend(this, {
  8231. _valHook: function() {
  8232. return this.element.contentEditable === 'true' ? 'text' : 'val';
  8233. },
  8234. getValue: function() {
  8235. var elem = this.element;
  8236. if (elem.type === 'number' && elem.validity && elem.validity.badInput) {
  8237. return 'NaN';
  8238. }
  8239. return $(elem)[this._valHook()]();
  8240. },
  8241. setValue: function(value) {
  8242. $(this.element)[this._valHook()](this.value = value);
  8243. },
  8244. // Get a range of validation messages
  8245. getRangeMsg: function(value, params, suffix) {
  8246. if (!params) return;
  8247. var me = this,
  8248. msg = me.messages[me._r] || '',
  8249. result,
  8250. p = params[0].split('~'),
  8251. e = params[1] === 'false',
  8252. a = p[0],
  8253. b = p[1],
  8254. c = 'rg',
  8255. args = [''],
  8256. isNumber = trim(value) && +value === +value;
  8257. function compare(large, small) {
  8258. return !e ? large >= small : large > small;
  8259. }
  8260. if (p.length === 2) {
  8261. if (a && b) {
  8262. if (isNumber && compare(value, +a) && compare(+b, value)) {
  8263. result = true;
  8264. }
  8265. args = args.concat(p);
  8266. c = e ? 'gtlt' : 'rg';
  8267. }
  8268. else if (a && !b) {
  8269. if (isNumber && compare(value, +a)) {
  8270. result = true;
  8271. }
  8272. args.push(a);
  8273. c = e ? 'gt' : 'gte';
  8274. }
  8275. else if (!a && b) {
  8276. if (isNumber && compare(+b, value)) {
  8277. result = true;
  8278. }
  8279. args.push(b);
  8280. c = e ? 'lt' : 'lte';
  8281. }
  8282. }
  8283. else {
  8284. if (value === +a) {
  8285. result = true;
  8286. }
  8287. args.push(a);
  8288. c = 'eq';
  8289. }
  8290. if (msg) {
  8291. if (suffix && msg[c + suffix]) {
  8292. c += suffix;
  8293. }
  8294. args[0] = msg[c];
  8295. }
  8296. return result || me._rules && ( me._rules[me._i].msg = me.renderMsg.apply(null, args) );
  8297. },
  8298. // Render message template
  8299. renderMsg: function() {
  8300. var args = arguments,
  8301. tpl = args[0],
  8302. i = args.length;
  8303. if (!tpl) return;
  8304. while (--i) {
  8305. tpl = tpl.replace('{' + i + '}', args[i]);
  8306. }
  8307. return tpl;
  8308. }
  8309. });
  8310. }
  8311. function Field(key, obj, oldField) {
  8312. this.key = key;
  8313. this.validator = context;
  8314. $.extend(this, oldField, obj);
  8315. }
  8316. FieldFactory.prototype = context;
  8317. Field.prototype = new FieldFactory();
  8318. return Field;
  8319. }
  8320. /**
  8321. * Create Rules
  8322. *
  8323. * @class
  8324. * @param {Object} obj rules
  8325. * @param {Object} context context
  8326. */
  8327. function Rules(obj, context) {
  8328. if (!isObject(obj)) return;
  8329. var k, that = context ? context === true ? this : context : Rules.prototype;
  8330. for (k in obj) {
  8331. if (_checkRuleName(k)) {
  8332. that[k] = _getRule(obj[k]);
  8333. }
  8334. }
  8335. }
  8336. /**
  8337. * Create Messages
  8338. *
  8339. * @class
  8340. * @param {Object} obj rules
  8341. * @param {Object} context context
  8342. */
  8343. function Messages(obj, context) {
  8344. if (!isObject(obj)) return;
  8345. var k, that = context ? context === true ? this : context : Messages.prototype;
  8346. for (k in obj) {
  8347. that[k] = obj[k];
  8348. }
  8349. }
  8350. // Rule converted factory
  8351. function _getRule(fn) {
  8352. switch ($.type(fn)) {
  8353. case 'function':
  8354. return fn;
  8355. case 'array':
  8356. var f = function() {
  8357. return fn[0].test(this.value) || fn[1] || false;
  8358. };
  8359. f.msg = fn[1];
  8360. return f;
  8361. case 'regexp':
  8362. return function() {
  8363. return fn.test(this.value);
  8364. };
  8365. }
  8366. }
  8367. // Get instance by an element
  8368. function _getInstance(el) {
  8369. var wrap, k, options;
  8370. if (!el || !el.tagName) return;
  8371. switch (el.tagName) {
  8372. case 'INPUT':
  8373. case 'SELECT':
  8374. case 'TEXTAREA':
  8375. case 'BUTTON':
  8376. case 'FIELDSET':
  8377. wrap = el.form || $(el).closest('.' + CLS_WRAPPER);
  8378. break;
  8379. case 'FORM':
  8380. wrap = el;
  8381. break;
  8382. default:
  8383. wrap = $(el).closest('.' + CLS_WRAPPER);
  8384. }
  8385. for (k in preinitialized) {
  8386. if ($(wrap).is(k)) {
  8387. options = preinitialized[k];
  8388. break;
  8389. }
  8390. }
  8391. return $(wrap).data(NS) || $(wrap)[NS](options).data(NS);
  8392. }
  8393. // Get custom rules on the node
  8394. function _getDataRule(el, method) {
  8395. var fn = trim(attr(el, DATA_RULE + '-' + method));
  8396. if ( fn && (fn = new Function('return ' + fn)()) ) {
  8397. return _getRule(fn);
  8398. }
  8399. }
  8400. // Get custom messages on the node
  8401. function _getDataMsg(el, field, m) {
  8402. var msg = field.msg,
  8403. item = field._r;
  8404. if ( isObject(msg) ) msg = msg[item];
  8405. if ( !isString(msg) ) {
  8406. msg = attr(el, DATA_MSG + '-' + item) || attr(el, DATA_MSG) || ( m ? isString(m) ? m : m[item] : '');
  8407. }
  8408. return msg;
  8409. }
  8410. // Get message position
  8411. function _getPos(str) {
  8412. var pos;
  8413. if (str) pos = rPos.exec(str);
  8414. return pos && pos[0];
  8415. }
  8416. // Check whether the element is checkbox or radio
  8417. function _checkable(el) {
  8418. return el.tagName === 'INPUT' && el.type === 'checkbox' || el.type === 'radio';
  8419. }
  8420. // Parse date string to timestamp
  8421. function _parseDate(str) {
  8422. return Date.parse(str.replace(/\.|\-/g, '/'));
  8423. }
  8424. // Rule name only allows alphanumeric characters and underscores
  8425. function _checkRuleName(name) {
  8426. return /^\w+$/.test(name);
  8427. }
  8428. // Translate field key to jQuery selector.
  8429. function _key2selector(key) {
  8430. var isID = key.charAt(0) === '#';
  8431. key = key.replace(/([:.{(|)}/\[\]])/g, '\\$1');
  8432. return isID ? key : '[name="'+ key +'"]:first';
  8433. }
  8434. // Fixed a issue cause by refresh page in IE.
  8435. $(window).on('beforeunload', function(){
  8436. this.focus();
  8437. });
  8438. $(document)
  8439. .on('click', ':submit', function(){
  8440. var input = this, attrNode;
  8441. if (!input.form) return;
  8442. // Shim for "formnovalidate"
  8443. attrNode = input.getAttributeNode('formnovalidate');
  8444. if (attrNode && attrNode.nodeValue !== null || attr(input, NOVALIDATE)!== null) {
  8445. novalidateonce = true;
  8446. }
  8447. })
  8448. // Automatic initializing form validation
  8449. .on('focusin submit validate', 'form,.'+CLS_WRAPPER, function(e) {
  8450. if ( attr(this, NOVALIDATE) !== null ) return;
  8451. var $form = $(this), me;
  8452. if ( !$form.data(NS) && (me = _getInstance(this)) ) {
  8453. if ( !$.isEmptyObject(me.fields) ) {
  8454. // Execute event handler
  8455. if (e.type === 'focusin') {
  8456. me._focusin(e);
  8457. } else {
  8458. me._submit(e);
  8459. }
  8460. } else {
  8461. attr(this, NOVALIDATE, NOVALIDATE);
  8462. $form.off(CLS_NS).removeData(NS);
  8463. }
  8464. }
  8465. });
  8466. new Messages({
  8467. fallback: 'This field is not valid.',
  8468. loading: 'Validating...'
  8469. });
  8470. // Built-in rules (global)
  8471. new Rules({
  8472. /**
  8473. * required
  8474. *
  8475. * @example:
  8476. required
  8477. required(jqSelector)
  8478. required(anotherRule)
  8479. required(not, -1)
  8480. required(from, .contact)
  8481. */
  8482. required: function(element, params) {
  8483. var me = this,
  8484. val = trim(me.value),
  8485. isValid = true;
  8486. if (params) {
  8487. if ( params.length === 1 ) {
  8488. if ( !_checkRuleName(params[0]) ) {
  8489. if (!val && !$(params[0], me.$el).length ) {
  8490. return null;
  8491. }
  8492. }
  8493. else if ( me.rules[params[0]] ) {
  8494. if ( !val && !me.test(element, params[0]) ) {
  8495. return null;
  8496. }
  8497. me._r = 'required'
  8498. }
  8499. }
  8500. else if ( params[0] === 'not' ) {
  8501. $.each(params.slice(1), function() {
  8502. return (isValid = val !== trim(this));
  8503. });
  8504. }
  8505. else if ( params[0] === 'from' ) {
  8506. var $elements = me.$el.find(params[1]),
  8507. VALIDATED = '_validated_',
  8508. ret;
  8509. isValid = $elements.filter(function(){
  8510. var field = me.getField(this);
  8511. return field && !!trim(field.getValue());
  8512. }).length >= (params[2] || 1);
  8513. if (isValid) {
  8514. if (!val) ret = null;
  8515. } else {
  8516. ret = _getDataMsg($elements[0], me) || false;
  8517. }
  8518. if ( !$(element).data(VALIDATED) ) {
  8519. $elements.data(VALIDATED, 1).each(function(){
  8520. if (element !== this) {
  8521. me._validate(this);
  8522. }
  8523. }).removeData(VALIDATED);
  8524. }
  8525. return ret;
  8526. }
  8527. }
  8528. return isValid && !!val;
  8529. },
  8530. /**
  8531. * integer
  8532. *
  8533. * @example:
  8534. integer
  8535. integer[+]
  8536. integer[+0]
  8537. integer[-]
  8538. integer[-0]
  8539. */
  8540. integer: function(element, params) {
  8541. var re, z = '0|',
  8542. p = '[1-9]\\d*',
  8543. key = params ? params[0] : '*';
  8544. switch (key) {
  8545. case '+':
  8546. re = p;
  8547. break;
  8548. case '-':
  8549. re = '-' + p;
  8550. break;
  8551. case '+0':
  8552. re = z + p;
  8553. break;
  8554. case '-0':
  8555. re = z + '-' + p;
  8556. break;
  8557. default:
  8558. re = z + '-?' + p;
  8559. }
  8560. re = '^(?:' + re + ')$';
  8561. return new RegExp(re).test(this.value) || (this.messages.integer && this.messages.integer[key]);
  8562. },
  8563. /**
  8564. * match another field
  8565. *
  8566. * @example:
  8567. match[password] Match the password field (two values ​​must be the same)
  8568. match[eq, password] Ditto
  8569. match[neq, count] The value must be not equal to the value of the count field
  8570. match[lt, count] The value must be less than the value of the count field
  8571. match[lte, count] The value must be less than or equal to the value of the count field
  8572. match[gt, count] The value must be greater than the value of the count field
  8573. match[gte, count] The value must be greater than or equal to the value of the count field
  8574. match[gte, startDate, date]
  8575. match[gte, startTime, time]
  8576. **/
  8577. match: function(element, params) {
  8578. if (!params) return;
  8579. var me = this,
  8580. isValid = true,
  8581. a, b,
  8582. key, msg, type = 'eq', parser,
  8583. selector2, elem2, field2;
  8584. if (params.length === 1) {
  8585. key = params[0];
  8586. } else {
  8587. type = params[0];
  8588. key = params[1];
  8589. }
  8590. selector2 = _key2selector(key);
  8591. elem2 = me.$el.find(selector2)[0];
  8592. // If the compared field is not exist
  8593. if (!elem2) return;
  8594. field2 = me.getField(elem2);
  8595. a = me.value;
  8596. b = field2.getValue();
  8597. if (!me._match) {
  8598. me.$el.on('valid'+CLS_NS_FIELD+CLS_NS, selector2, function(){
  8599. $(element).trigger('validate');
  8600. });
  8601. me._match = field2._match = 1;
  8602. }
  8603. // If both fields are blank
  8604. if (!me.required && a === '' && b === '') {
  8605. return null;
  8606. }
  8607. parser = params[2];
  8608. if (parser) {
  8609. if (/^date(time)?$/i.test(parser)) {
  8610. a = _parseDate(a);
  8611. b = _parseDate(b);
  8612. } else if (parser === 'time') {
  8613. a = +a.replace(/:/g, '');
  8614. b = +b.replace(/:/g, '');
  8615. }
  8616. }
  8617. // If the compared field is incorrect, we only ensure that this field is correct.
  8618. if (type !== 'eq' && !isNaN(+a) && isNaN(+b)) {
  8619. return true;
  8620. }
  8621. switch (type) {
  8622. case 'lt':
  8623. isValid = +a < +b; break;
  8624. case 'lte':
  8625. isValid = +a <= +b; break;
  8626. case 'gte':
  8627. isValid = +a >= +b; break;
  8628. case 'gt':
  8629. isValid = +a > +b; break;
  8630. case 'neq':
  8631. isValid = a !== b; break;
  8632. default:
  8633. isValid = a === b;
  8634. }
  8635. return isValid || (
  8636. isObject(me.messages.match)
  8637. && me.messages.match[type].replace( '{1}', me._getDisplay( elem2, field2.display || key ) )
  8638. );
  8639. },
  8640. /**
  8641. * range numbers
  8642. *
  8643. * @example:
  8644. range[0~99] Number 0-99
  8645. range[0~] Number greater than or equal to 0
  8646. range[~100] Number less than or equal to 100
  8647. **/
  8648. range: function(element, params) {
  8649. return this.getRangeMsg(this.value, params);
  8650. },
  8651. /**
  8652. * how many checkbox or radio inputs that checked
  8653. *
  8654. * @example:
  8655. checked; no empty, same to required
  8656. checked[1~3] 1-3 items
  8657. checked[1~] greater than 1 item
  8658. checked[~3] less than 3 items
  8659. checked[3] 3 items
  8660. **/
  8661. checked: function(element, params) {
  8662. if ( !_checkable(element) ) return;
  8663. var me = this,
  8664. elem, count;
  8665. if (element.name) {
  8666. count = me.$el.find('input[name="' + element.name + '"]').filter(function() {
  8667. var el = this;
  8668. if (!elem && _checkable(el)) elem = el;
  8669. return !el.disabled && el.checked;
  8670. }).length;
  8671. } else {
  8672. elem = element;
  8673. count = elem.checked;
  8674. }
  8675. if (params) {
  8676. return me.getRangeMsg(count, params);
  8677. } else {
  8678. return !!count || _getDataMsg(elem, me, '') || me.messages.required || false;
  8679. }
  8680. },
  8681. /**
  8682. * length of a characters (You can pass the second parameter "true", will calculate the length in bytes)
  8683. *
  8684. * @example:
  8685. length[6~16] 6-16 characters
  8686. length[6~] Greater than 6 characters
  8687. length[~16] Less than 16 characters
  8688. length[~16, true] Less than 16 characters, non-ASCII characters calculating two-character
  8689. **/
  8690. length: function(element, params) {
  8691. var value = this.value,
  8692. len = (params[1] === 'true' ? value.replace(rDoubleBytes, 'xx') : value).length;
  8693. return this.getRangeMsg(len, params, (params[1] ? '_2' : ''));
  8694. },
  8695. /**
  8696. * remote validation
  8697. *
  8698. * @description
  8699. * remote([get:]url [, name1, [name2 ...]]);
  8700. * Adaptation three kinds of results (Front for the successful, followed by a failure):
  8701. 1. text:
  8702. '' 'Error Message'
  8703. 2. json:
  8704. {"ok": ""} {"error": "Error Message"}
  8705. 3. json wrapper:
  8706. {"status": 1, "data": {"ok": ""}} {"status": 1, "data": {"error": "Error Message"}}
  8707. * @example
  8708. The simplest: remote(path/to/server);
  8709. With parameters: remote(path/to/server, name1, name2, ...);
  8710. By GET: remote(get:path/to/server, name1, name2, ...);
  8711. Name proxy: remote(path/to/server, name1, proxyname2:name2, proxyname3:#id3, ...)
  8712. Query String remote(path/to/server, foo=1&bar=2, name1, name2, ...)
  8713. CORS remote(cors:path/to/server)
  8714. JSONP remote(jsonp:path/to/server)
  8715. */
  8716. remote: function(element, params) {
  8717. if (!params) return;
  8718. var me = this,
  8719. arr = rAjaxType.exec(params[0]),
  8720. rule = me._rules[me._i],
  8721. data = {},
  8722. queryString = '',
  8723. url = arr[3],
  8724. type = arr[2] || 'POST', // GET / POST
  8725. rType = (arr[1] || this.validator.options.remoteDataType || '').toLowerCase(), // CORS / JSONP
  8726. dataType;
  8727. rule.must = true;
  8728. data[element.name] = me.value;
  8729. // There are extra fields
  8730. if (params[1]) {
  8731. $.map(params.slice(1), function(name) {
  8732. var arr, key;
  8733. if (~name.indexOf('=')) {
  8734. queryString += '&' + name;
  8735. } else {
  8736. arr = name.split(':');
  8737. name = trim(arr[0]);
  8738. key = trim(arr[1]) || name;
  8739. data[ name ] = me.$el.find( _key2selector(key) ).val();
  8740. }
  8741. });
  8742. }
  8743. data = $.param(data) + queryString;
  8744. if (!me.must && rule.data && rule.data === data) {
  8745. return rule.result;
  8746. }
  8747. // Cross-domain request, force jsonp dataType
  8748. if (rType !== 'cors' && /^https?:/.test(url) && !~url.indexOf(location.host)) {
  8749. dataType = 'jsonp';
  8750. }
  8751. // Asynchronous validation need return jqXHR objects
  8752. return $.ajax({
  8753. url: url,
  8754. type: type,
  8755. data: data,
  8756. dataType: dataType
  8757. });
  8758. },
  8759. /**
  8760. * filter characters, direct filtration without prompting error (support custom regular expressions)
  8761. *
  8762. * @example
  8763. * filter filtering unsafe characters
  8764. * filter(regexp) filtering the "regexp" matched characters
  8765. */
  8766. filter: function(element, params) {
  8767. var value = this.value,
  8768. temp = value.replace( params ? (new RegExp('[' + params[0] + ']', 'gm')) : rUnsafe, '' );
  8769. if (temp !== value) this.setValue(temp);
  8770. }
  8771. });
  8772. /**
  8773. * Config global options
  8774. *
  8775. * @static config
  8776. * @param {Object} options
  8777. */
  8778. Validator.config = function(key, value) {
  8779. if (isObject(key)) {
  8780. $.each(key, _config);
  8781. }
  8782. else if (isString(key)) {
  8783. _config(key, value);
  8784. }
  8785. function _config(k, o) {
  8786. if (k === 'rules') {
  8787. new Rules(o);
  8788. }
  8789. else if (k === 'messages') {
  8790. new Messages(o);
  8791. }
  8792. else if (k in fieldDefaults) {
  8793. fieldDefaults[k] = o;
  8794. }
  8795. else {
  8796. defaults[k] = o;
  8797. }
  8798. }
  8799. };
  8800. /**
  8801. * Config themes
  8802. *
  8803. * @static setTheme
  8804. * @param {String|Object} name
  8805. * @param {Object} obj
  8806. * @example
  8807. .setTheme( themeName, themeOptions )
  8808. .setTheme( multiThemes )
  8809. */
  8810. Validator.setTheme = function(name, obj) {
  8811. if ( isObject(name) ) {
  8812. $.extend(true, themes, name);
  8813. }
  8814. else if ( isString(name) && isObject(obj) ) {
  8815. themes[name] = $.extend(themes[name], obj);
  8816. }
  8817. };
  8818. /**
  8819. * Resource loader
  8820. *
  8821. * @static load
  8822. * @param {String} str
  8823. * @example
  8824. .load('local=zh-CN') // load: local/zh-CN.js and jquery.validator.css
  8825. .load('local=zh-CN&css=') // load: local/zh-CN.js
  8826. .load('local&css') // load: local/en.js (set <html lang="en">) and jquery.validator.css
  8827. .load('local') // dito
  8828. */
  8829. Validator.load = function(str) {
  8830. if (!str) return;
  8831. var doc = document,
  8832. params = {},
  8833. node = doc.scripts[0],
  8834. dir, el, ONLOAD;
  8835. str.replace(/([^?=&]+)=([^&#]*)/g, function(m, key, value){
  8836. params[key] = value;
  8837. });
  8838. dir = params.dir || Validator.dir;
  8839. if (!Validator.css && params.css !== '') {
  8840. el = doc.createElement('link');
  8841. el.rel = 'stylesheet';
  8842. el.href = Validator.css = dir + 'jquery.validator.css';
  8843. node.parentNode.insertBefore(el, node);
  8844. }
  8845. if (!Validator.local && ~str.indexOf('local') && params.local !== '') {
  8846. Validator.local = (params.local || doc.documentElement.lang || 'en').replace('_','-');
  8847. Validator.pending = 1;
  8848. el = doc.createElement('script');
  8849. el.src = dir + 'local/' + Validator.local + '.js';
  8850. ONLOAD = 'onload' in el ? 'onload' : 'onreadystatechange';
  8851. el[ONLOAD] = function() {
  8852. if (!el.readyState || /loaded|complete/.test(el.readyState)) {
  8853. el = el[ONLOAD] = null;
  8854. delete Validator.pending;
  8855. $(window).triggerHandler('validatorready');
  8856. }
  8857. };
  8858. node.parentNode.insertBefore(el, node);
  8859. }
  8860. };
  8861. // Auto loading resources
  8862. (function(){
  8863. var scripts = document.scripts,
  8864. i = scripts.length, node, arr,
  8865. re = /(.*validator(?:\.min)?.js)(\?.*(?:local|css|dir)(?:=[\w\-]*)?)?/;
  8866. while (i-- && !arr) {
  8867. node = scripts[i];
  8868. arr = (node.hasAttribute ? node.src : node.getAttribute('src',4)||'').match(re);
  8869. }
  8870. if (!arr) return;
  8871. Validator.dir = arr[1].split('/').slice(0, -1).join('/')+'/';
  8872. Validator.load(arr[2]);
  8873. })();
  8874. return $[NS] = Validator;
  8875. }));
  8876. /*********************************
  8877. * Themes, rules, and i18n support
  8878. * Locale: Chinese; 中文
  8879. *********************************/
  8880. (function(factory) {
  8881. typeof module === "object" && module.exports ? module.exports = factory( require( "jquery" ) ) :
  8882. typeof define === 'function' && define.amd ? define('validator-lang',['jquery'], factory) :
  8883. factory(jQuery);
  8884. }(function($) {
  8885. /* Global configuration
  8886. */
  8887. $.validator.config({
  8888. //stopOnError: true,
  8889. //focusCleanup: true,
  8890. //theme: 'yellow_right',
  8891. //timely: 2,
  8892. // Custom rules
  8893. rules: {
  8894. digits: [/^\d+$/, "请填写数字"]
  8895. ,letters: [/^[a-z]+$/i, "请填写字母"]
  8896. ,date: [/^\d{4}-\d{2}-\d{2}$/, "请填写有效的日期,格式:yyyy-mm-dd"]
  8897. ,time: [/^([01]\d|2[0-3])(:[0-5]\d){1,2}$/, "请填写有效的时间,00:00到23:59之间"]
  8898. ,email: [/^[\w\+\-]+(\.[\w\+\-]+)*@[a-z\d\-]+(\.[a-z\d\-]+)*\.([a-z]{2,4})$/i, "请填写有效的邮箱"]
  8899. ,url: [/^(https?|s?ftp):\/\/\S+$/i, "请填写有效的网址"]
  8900. ,qq: [/^[1-9]\d{4,}$/, "请填写有效的QQ号"]
  8901. ,IDcard: [/^\d{6}(19|2\d)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)?$/, "请填写正确的身份证号码"]
  8902. ,tel: [/^(?:(?:0\d{2,3}[\- ]?[1-9]\d{6,7})|(?:[48]00[\- ]?[1-9]\d{6}))$/, "请填写有效的电话号码"]
  8903. ,mobile: [/^1[3-9]\d{9}$/, "请填写有效的手机号"]
  8904. ,zipcode: [/^\d{6}$/, "请检查邮政编码格式"]
  8905. ,chinese: [/^[\u0391-\uFFE5]+$/, "请填写中文字符"]
  8906. ,username: [/^\w{3,12}$/, "请填写3-12位数字、字母、下划线"]
  8907. ,password: [/^[\S]{6,16}$/, "请填写6-16位字符,不能包含空格"]
  8908. ,accept: function (element, params){
  8909. if (!params) return true;
  8910. var ext = params[0],
  8911. value = $(element).val();
  8912. return (ext === '*') ||
  8913. (new RegExp(".(?:" + ext + ")$", "i")).test(value) ||
  8914. this.renderMsg("只接受{1}后缀的文件", ext.replace(/\|/g, ','));
  8915. }
  8916. },
  8917. // Default error messages
  8918. messages: {
  8919. 0: "此处",
  8920. fallback: "{0}格式不正确",
  8921. loading: "正在验证...",
  8922. error: "网络异常",
  8923. timeout: "请求超时",
  8924. required: "{0}不能为空",
  8925. remote: "{0}已被使用",
  8926. integer: {
  8927. '*': "请填写整数",
  8928. '+': "请填写正整数",
  8929. '+0': "请填写正整数或0",
  8930. '-': "请填写负整数",
  8931. '-0': "请填写负整数或0"
  8932. },
  8933. match: {
  8934. eq: "{0}与{1}不一致",
  8935. neq: "{0}与{1}不能相同",
  8936. lt: "{0}必须小于{1}",
  8937. gt: "{0}必须大于{1}",
  8938. lte: "{0}不能大于{1}",
  8939. gte: "{0}不能小于{1}"
  8940. },
  8941. range: {
  8942. rg: "请填写{1}到{2}的数",
  8943. gte: "请填写不小于{1}的数",
  8944. lte: "请填写最大{1}的数",
  8945. gtlt: "请填写{1}到{2}之间的数",
  8946. gt: "请填写大于{1}的数",
  8947. lt: "请填写小于{1}的数"
  8948. },
  8949. checked: {
  8950. eq: "请选择{1}项",
  8951. rg: "请选择{1}到{2}项",
  8952. gte: "请至少选择{1}项",
  8953. lte: "请最多选择{1}项"
  8954. },
  8955. length: {
  8956. eq: "请填写{1}个字符",
  8957. rg: "请填写{1}到{2}个字符",
  8958. gte: "请至少填写{1}个字符",
  8959. lte: "请最多填写{1}个字符",
  8960. eq_2: "",
  8961. rg_2: "",
  8962. gte_2: "",
  8963. lte_2: ""
  8964. }
  8965. }
  8966. });
  8967. /* Themes
  8968. */
  8969. var TPL_ARROW = '<span class="n-arrow"><b>◆</b><i>◆</i></span>';
  8970. $.validator.setTheme({
  8971. 'simple_right': {
  8972. formClass: 'n-simple',
  8973. msgClass: 'n-right'
  8974. },
  8975. 'simple_bottom': {
  8976. formClass: 'n-simple',
  8977. msgClass: 'n-bottom'
  8978. },
  8979. 'yellow_top': {
  8980. formClass: 'n-yellow',
  8981. msgClass: 'n-top',
  8982. msgArrow: TPL_ARROW
  8983. },
  8984. 'yellow_right': {
  8985. formClass: 'n-yellow',
  8986. msgClass: 'n-right',
  8987. msgArrow: TPL_ARROW
  8988. },
  8989. 'yellow_right_effect': {
  8990. formClass: 'n-yellow',
  8991. msgClass: 'n-right',
  8992. msgArrow: TPL_ARROW,
  8993. msgShow: function($msgbox, type){
  8994. var $el = $msgbox.children();
  8995. if ($el.is(':animated')) return;
  8996. if (type === 'error') {
  8997. $el.css({left: '20px', opacity: 0})
  8998. .delay(100).show().stop()
  8999. .animate({left: '-4px', opacity: 1}, 150)
  9000. .animate({left: '3px'}, 80)
  9001. .animate({left: 0}, 80);
  9002. } else {
  9003. $el.css({left: 0, opacity: 1}).fadeIn(200);
  9004. }
  9005. },
  9006. msgHide: function($msgbox, type){
  9007. var $el = $msgbox.children();
  9008. $el.stop().delay(100).show()
  9009. .animate({left: '20px', opacity: 0}, 300, function(){
  9010. $msgbox.hide();
  9011. });
  9012. }
  9013. }
  9014. });
  9015. }));
  9016. define('form',['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], function ($, undefined, Upload, Validator, undefined) {
  9017. var Form = {
  9018. config: {
  9019. fieldlisttpl: '<dd class="form-inline"><input type="text" name="<%=name%>[<%=index%>][key]" class="form-control" value="<%=key%>" placeholder="<%=options.keyPlaceholder||\'\'%>" size="10" /> <input type="text" name="<%=name%>[<%=index%>][value]" class="form-control" value="<%=value%>" placeholder="<%=options.valuePlaceholder||\'\'%>" /> <span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span> <span class="btn btn-sm btn-primary btn-dragsort"><i class="fa fa-arrows"></i></span></dd>'
  9020. },
  9021. events: {
  9022. validator: function (form, success, error, submit) {
  9023. if (!form.is("form"))
  9024. return;
  9025. //绑定表单事件
  9026. form.validator($.extend({
  9027. rules: {
  9028. username: [/^\w{3,30}$/, __('Username must be 3 to 30 characters')],
  9029. password: [/^[\S]{6,30}$/, __('Password must be 6 to 30 characters')]
  9030. },
  9031. validClass: 'has-success',
  9032. invalidClass: 'has-error',
  9033. bindClassTo: '.form-group',
  9034. formClass: 'n-default n-bootstrap',
  9035. msgClass: 'n-right',
  9036. stopOnError: true,
  9037. display: function (elem) {
  9038. return $(elem).closest('.form-group').find(".control-label").text().replace(/\:/, '');
  9039. },
  9040. dataFilter: function (data) {
  9041. if (data.code === 1) {
  9042. return data.msg ? {"ok": data.msg} : '';
  9043. } else {
  9044. return data.msg;
  9045. }
  9046. },
  9047. target: function (input) {
  9048. var target = $(input).data("target");
  9049. if (target && $(target).length > 0) {
  9050. return $(target);
  9051. }
  9052. var $formitem = $(input).closest('.form-group'),
  9053. $msgbox = $formitem.find('span.msg-box');
  9054. if (!$msgbox.length) {
  9055. return [];
  9056. }
  9057. return $msgbox;
  9058. },
  9059. valid: function (ret) {
  9060. var that = this, submitBtn = $(".layer-footer [type=submit]", form);
  9061. that.holdSubmit(true);
  9062. submitBtn.addClass("disabled");
  9063. //验证通过提交表单
  9064. var submitResult = Form.api.submit($(ret), function (data, ret) {
  9065. that.holdSubmit(false);
  9066. submitBtn.removeClass("disabled");
  9067. if (false === $(this).triggerHandler("success.form", [data, ret])) {
  9068. return false;
  9069. }
  9070. if (typeof success === 'function') {
  9071. if (false === success.call($(this), data, ret)) {
  9072. return false;
  9073. }
  9074. }
  9075. //提示及关闭当前窗口
  9076. var msg = ret.hasOwnProperty("msg") && ret.msg !== "" ? ret.msg : __('Operation completed');
  9077. parent.Toastr.success(msg);
  9078. parent.$(".btn-refresh").trigger("click");
  9079. if (window.name) {
  9080. var index = parent.Layer.getFrameIndex(window.name);
  9081. parent.Layer.close(index);
  9082. }
  9083. return false;
  9084. }, function (data, ret) {
  9085. that.holdSubmit(false);
  9086. if (false === $(this).triggerHandler("error.form", [data, ret])) {
  9087. return false;
  9088. }
  9089. submitBtn.removeClass("disabled");
  9090. if (typeof error === 'function') {
  9091. if (false === error.call($(this), data, ret)) {
  9092. return false;
  9093. }
  9094. }
  9095. }, submit);
  9096. //如果提交失败则释放锁定
  9097. if (!submitResult) {
  9098. that.holdSubmit(false);
  9099. submitBtn.removeClass("disabled");
  9100. }
  9101. return false;
  9102. }
  9103. }, form.data("validator-options") || {}));
  9104. //移除提交按钮的disabled类
  9105. $(".layer-footer [type=submit],.fixed-footer [type=submit],.normal-footer [type=submit]", form).removeClass("disabled");
  9106. //自定义关闭按钮事件
  9107. form.on("click", ".layer-close", function () {
  9108. if (window.name) {
  9109. var index = parent.Layer.getFrameIndex(window.name);
  9110. parent.Layer.close(index);
  9111. }
  9112. return false;
  9113. });
  9114. },
  9115. selectpicker: function (form) {
  9116. //绑定select元素事件
  9117. if ($(".selectpicker", form).length > 0) {
  9118. require(['bootstrap-select', 'bootstrap-select-lang'], function () {
  9119. $.fn.selectpicker.Constructor.BootstrapVersion = '3';
  9120. $('.selectpicker', form).selectpicker();
  9121. $(form).on("reset", function () {
  9122. setTimeout(function () {
  9123. $('.selectpicker').selectpicker('refresh').trigger("change");
  9124. }, 1);
  9125. });
  9126. });
  9127. }
  9128. },
  9129. selectpage: function (form) {
  9130. //绑定selectpage元素事件
  9131. if ($(".selectpage", form).length > 0) {
  9132. require(['selectpage'], function () {
  9133. $('.selectpage', form).selectPage({
  9134. eAjaxSuccess: function (data) {
  9135. data.list = typeof data.rows !== 'undefined' ? data.rows : (typeof data.list !== 'undefined' ? data.list : []);
  9136. data.totalRow = typeof data.total !== 'undefined' ? data.total : (typeof data.totalRow !== 'undefined' ? data.totalRow : data.list.length);
  9137. return data;
  9138. }
  9139. });
  9140. });
  9141. //给隐藏的元素添加上validate验证触发事件
  9142. $(document).on("change", ".sp_hidden", function () {
  9143. $(this).trigger("validate");
  9144. });
  9145. $(document).on("change", ".sp_input", function () {
  9146. $(this).closest(".sp_container").find(".sp_hidden").trigger("change");
  9147. });
  9148. $(form).on("reset", function () {
  9149. setTimeout(function () {
  9150. $(".selectpage", form).each(function () {
  9151. var selectpage = $(this).data("selectPageObject");
  9152. selectpage.elem.hidden.val($(this).val());
  9153. $(this).selectPageRefresh();
  9154. });
  9155. }, 1);
  9156. });
  9157. }
  9158. },
  9159. cxselect: function (form) {
  9160. //绑定cxselect元素事件
  9161. if ($("[data-toggle='cxselect']", form).length > 0) {
  9162. require(['cxselect'], function () {
  9163. $.cxSelect.defaults.jsonName = 'name';
  9164. $.cxSelect.defaults.jsonValue = 'value';
  9165. $.cxSelect.defaults.jsonSpace = 'data';
  9166. $("[data-toggle='cxselect']", form).cxSelect();
  9167. });
  9168. }
  9169. },
  9170. citypicker: function (form) {
  9171. //绑定城市远程插件
  9172. if ($("[data-toggle='city-picker']", form).length > 0) {
  9173. require(['citypicker'], function () {
  9174. $(form).on("reset", function () {
  9175. setTimeout(function () {
  9176. $("[data-toggle='city-picker']").citypicker('refresh');
  9177. }, 1);
  9178. });
  9179. });
  9180. }
  9181. },
  9182. datetimepicker: function (form) {
  9183. //绑定日期时间元素事件
  9184. if ($(".datetimepicker", form).length > 0) {
  9185. require(['bootstrap-datetimepicker'], function () {
  9186. var options = {
  9187. format: 'YYYY-MM-DD HH:mm:ss',
  9188. icons: {
  9189. time: 'fa fa-clock-o',
  9190. date: 'fa fa-calendar',
  9191. up: 'fa fa-chevron-up',
  9192. down: 'fa fa-chevron-down',
  9193. previous: 'fa fa-chevron-left',
  9194. next: 'fa fa-chevron-right',
  9195. today: 'fa fa-history',
  9196. clear: 'fa fa-trash',
  9197. close: 'fa fa-remove'
  9198. },
  9199. showTodayButton: true,
  9200. showClose: true
  9201. };
  9202. $('.datetimepicker', form).parent().css('position', 'relative');
  9203. $('.datetimepicker', form).datetimepicker(options).on('dp.change', function (e) {
  9204. $(this, document).trigger("changed");
  9205. });
  9206. });
  9207. }
  9208. },
  9209. daterangepicker: function (form) {
  9210. //绑定日期时间元素事件
  9211. if ($(".datetimerange", form).length > 0) {
  9212. require(['bootstrap-daterangepicker'], function () {
  9213. var ranges = {};
  9214. ranges[__('Today')] = [Moment().startOf('day'), Moment().endOf('day')];
  9215. ranges[__('Yesterday')] = [Moment().subtract(1, 'days').startOf('day'), Moment().subtract(1, 'days').endOf('day')];
  9216. ranges[__('Last 7 Days')] = [Moment().subtract(6, 'days').startOf('day'), Moment().endOf('day')];
  9217. ranges[__('Last 30 Days')] = [Moment().subtract(29, 'days').startOf('day'), Moment().endOf('day')];
  9218. ranges[__('This Month')] = [Moment().startOf('month'), Moment().endOf('month')];
  9219. ranges[__('Last Month')] = [Moment().subtract(1, 'month').startOf('month'), Moment().subtract(1, 'month').endOf('month')];
  9220. var options = {
  9221. timePicker: false,
  9222. autoUpdateInput: false,
  9223. timePickerSeconds: true,
  9224. timePicker24Hour: true,
  9225. autoApply: true,
  9226. locale: {
  9227. format: 'YYYY-MM-DD HH:mm:ss',
  9228. customRangeLabel: __("Custom Range"),
  9229. applyLabel: __("Apply"),
  9230. cancelLabel: __("Clear"),
  9231. },
  9232. ranges: ranges,
  9233. };
  9234. var origincallback = function (start, end) {
  9235. $(this.element).val(start.format(this.locale.format) + " - " + end.format(this.locale.format));
  9236. $(this.element).trigger('change');
  9237. };
  9238. $(".datetimerange", form).each(function () {
  9239. var callback = typeof $(this).data('callback') == 'function' ? $(this).data('callback') : origincallback;
  9240. $(this).on('apply.daterangepicker', function (ev, picker) {
  9241. callback.call(picker, picker.startDate, picker.endDate);
  9242. });
  9243. $(this).on('cancel.daterangepicker', function (ev, picker) {
  9244. $(this).val('').trigger('change');
  9245. });
  9246. $(this).daterangepicker($.extend(true, {}, options, $(this).data() || {}, $(this).data("daterangepicker-options") || {}));
  9247. });
  9248. });
  9249. }
  9250. },
  9251. /**
  9252. * 绑定上传事件
  9253. * @param form
  9254. * @deprecated Use faupload instead.
  9255. */
  9256. plupload: function (form) {
  9257. Form.events.faupload(form);
  9258. },
  9259. /**
  9260. * 绑定上传事件
  9261. * @param form
  9262. */
  9263. faupload: function (form) {
  9264. //绑定上传元素事件
  9265. if ($(".plupload,.faupload", form).length > 0) {
  9266. Upload.api.upload($(".plupload,.faupload", form));
  9267. }
  9268. },
  9269. faselect: function (form) {
  9270. //绑定fachoose选择附件事件
  9271. if ($(".faselect,.fachoose", form).length > 0) {
  9272. $(".faselect,.fachoose", form).off('click').on('click', function () {
  9273. var that = this;
  9274. var multiple = $(this).data("multiple") ? $(this).data("multiple") : false;
  9275. var mimetype = $(this).data("mimetype") ? $(this).data("mimetype") : '';
  9276. var admin_id = $(this).data("admin-id") ? $(this).data("admin-id") : '';
  9277. var user_id = $(this).data("user-id") ? $(this).data("user-id") : '';
  9278. mimetype = mimetype.replace(/\/\*/ig, '/');
  9279. var url = $(this).data("url") ? $(this).data("url") : (typeof Backend !== 'undefined' ? "general/attachment/select" : "user/attachment");
  9280. parent.Fast.api.open(url + "?element_id=" + $(this).attr("id") + "&multiple=" + multiple + "&mimetype=" + mimetype + "&admin_id=" + admin_id + "&user_id=" + user_id, __('Choose'), {
  9281. callback: function (data) {
  9282. var button = $("#" + $(that).attr("id"));
  9283. var maxcount = $(button).data("maxcount");
  9284. var input_id = $(button).data("input-id") ? $(button).data("input-id") : "";
  9285. maxcount = typeof maxcount !== "undefined" ? maxcount : 0;
  9286. if (input_id && data.multiple) {
  9287. var urlArr = [];
  9288. var inputObj = $("#" + input_id);
  9289. var value = $.trim(inputObj.val());
  9290. if (value !== "") {
  9291. urlArr.push(inputObj.val());
  9292. }
  9293. var nums = value === '' ? 0 : value.split(/\,/).length;
  9294. var files = data.url !== "" ? data.url.split(/\,/) : [];
  9295. $.each(files, function (i, j) {
  9296. var url = Config.upload.fullmode ? Fast.api.cdnurl(j) : j;
  9297. urlArr.push(url);
  9298. });
  9299. if (maxcount > 0) {
  9300. var remains = maxcount - nums;
  9301. if (files.length > remains) {
  9302. Toastr.error(__('You can choose up to %d file%s', remains));
  9303. return false;
  9304. }
  9305. }
  9306. var result = urlArr.join(",");
  9307. inputObj.val(result).trigger("change").trigger("validate");
  9308. } else if (input_id) {
  9309. var url = Config.upload.fullmode ? Fast.api.cdnurl(data.url) : data.url;
  9310. $("#" + input_id).val(url).trigger("change").trigger("validate");
  9311. }
  9312. }
  9313. });
  9314. return false;
  9315. });
  9316. }
  9317. },
  9318. fieldlist: function (form) {
  9319. //绑定fieldlist
  9320. if ($(".fieldlist", form).length > 0) {
  9321. require(['dragsort', 'template'], function (undefined, Template) {
  9322. //刷新隐藏textarea的值
  9323. var refresh = function (container) {
  9324. var data = {};
  9325. var name = container.data("name");
  9326. var textarea = $("textarea[name='" + name + "']", form);
  9327. var template = container.data("template");
  9328. $.each($("input,select,textarea", container).serializeArray(), function (i, j) {
  9329. var reg = /\[(\w+)\]\[(\w+)\]$/g;
  9330. var match = reg.exec(j.name);
  9331. if (!match)
  9332. return true;
  9333. match[1] = "x" + parseInt(match[1]);
  9334. if (typeof data[match[1]] == 'undefined') {
  9335. data[match[1]] = {};
  9336. }
  9337. data[match[1]][match[2]] = j.value;
  9338. });
  9339. var result = template ? [] : {};
  9340. $.each(data, function (i, j) {
  9341. if (j) {
  9342. var keys = Object.keys(j);
  9343. if (keys.indexOf("value") > -1 && (keys.length === 1 || (keys.length === 2 && keys.indexOf("key") > -1))) {
  9344. if (keys.length === 2) {
  9345. if (j.key != '') {
  9346. result['__PLACEHOLDKEY__' + j.key] = j.value;
  9347. }
  9348. } else {
  9349. result.push(j.value);
  9350. }
  9351. } else {
  9352. result.push(j);
  9353. }
  9354. }
  9355. });
  9356. textarea.val(JSON.stringify(result).replace(/__PLACEHOLDKEY__/g, ''));
  9357. };
  9358. //追加一行数据
  9359. var append = function (container, row, initial) {
  9360. var tagName = container.data("tag") || (container.is("table") ? "tr" : "dd");
  9361. var index = container.data("index");
  9362. var name = container.data("name");
  9363. var template = container.data("template");
  9364. var data = container.data();
  9365. index = index ? parseInt(index) : 0;
  9366. container.data("index", index + 1);
  9367. row = row ? row : {};
  9368. row = typeof row.key === 'undefined' || typeof row.value === 'undefined' ? {key: '', value: row} : row;
  9369. var options = container.data("fieldlist-options") || {};
  9370. var vars = {index: index, name: name, data: data, options: options, key: row.key, value: row.value, row: row.value};
  9371. var html = template ? Template(template, vars) : Template.render(Form.config.fieldlisttpl, vars);
  9372. var obj = $(html);
  9373. if ((options.deleteBtn === false || options.removeBtn === false) && initial)
  9374. obj.find(".btn-remove").remove();
  9375. if (options.dragsortBtn === false && initial)
  9376. obj.find(".btn-dragsort").remove();
  9377. if ((options.readonlyKey === true || options.disableKey === true) && initial) {
  9378. obj.find("input[name$='[key]']").prop("readonly", true);
  9379. }
  9380. obj.attr("fieldlist-item", true);
  9381. obj.insertAfter($(tagName + "[fieldlist-item]", container).length > 0 ? $(tagName + "[fieldlist-item]:last", container) : $(tagName + ":first", container));
  9382. if ($(".btn-append,.append", container).length > 0) {
  9383. //兼容旧版本事件
  9384. $(".btn-append,.append", container).trigger("fa.event.appendfieldlist", obj);
  9385. } else {
  9386. //新版本事件
  9387. container.trigger("fa.event.appendfieldlist", obj);
  9388. }
  9389. return obj;
  9390. };
  9391. var fieldlist = $(".fieldlist", form);
  9392. //表单重置
  9393. form.on("reset", function () {
  9394. setTimeout(function () {
  9395. fieldlist.trigger("fa.event.refreshfieldlist");
  9396. });
  9397. });
  9398. //监听文本框改变事件
  9399. $(document).on('change keyup changed', ".fieldlist input,.fieldlist textarea,.fieldlist select", function () {
  9400. var container = $(this).closest(".fieldlist");
  9401. refresh(container);
  9402. });
  9403. //追加控制(点击按钮)
  9404. fieldlist.on("click", ".btn-append,.append", function (e, row) {
  9405. var container = $(this).closest(".fieldlist");
  9406. append(container, row);
  9407. refresh(container);
  9408. });
  9409. //移除控制(点击按钮)
  9410. fieldlist.on("click", ".btn-remove", function () {
  9411. var container = $(this).closest(".fieldlist");
  9412. var tagName = container.data("tag") || (container.is("table") ? "tr" : "dd");
  9413. $(this).closest(tagName).remove();
  9414. refresh(container);
  9415. });
  9416. //追加控制(通过事件)
  9417. fieldlist.on("fa.event.appendtofieldlist", function (e, row) {
  9418. var container = $(this);
  9419. append(container, row);
  9420. refresh(container);
  9421. });
  9422. //根据textarea内容重新渲染
  9423. fieldlist.on("fa.event.refreshfieldlist", function () {
  9424. var container = $(this);
  9425. var textarea = $("textarea[name='" + container.data("name") + "']", form);
  9426. //先清空已有的数据
  9427. $("[fieldlist-item]", container).remove();
  9428. var json = {};
  9429. try {
  9430. var val = textarea.val().replace(/"(\d+)"\:/g, "\"__PLACEHOLDERKEY__$1\":");
  9431. json = JSON.parse(val);
  9432. } catch (e) {
  9433. }
  9434. $.each(json, function (i, j) {
  9435. append(container, {key: i.toString().replace("__PLACEHOLDERKEY__", ""), value: j}, true);
  9436. });
  9437. });
  9438. //拖拽排序
  9439. fieldlist.each(function () {
  9440. var container = $(this);
  9441. var tagName = container.data("tag") || (container.is("table") ? "tr" : "dd");
  9442. container.dragsort({
  9443. itemSelector: tagName,
  9444. dragSelector: ".btn-dragsort",
  9445. dragEnd: function () {
  9446. refresh(container);
  9447. },
  9448. placeHolderTemplate: $("<" + tagName + "/>")
  9449. });
  9450. if (typeof container.data("options") === 'object' && container.data("options").appendBtn === false) {
  9451. $(".btn-append,.append", container).hide();
  9452. }
  9453. $("textarea[name='" + container.data("name") + "']", form).on("fa.event.refreshfieldlist", function () {
  9454. //兼容旧版本事件
  9455. $(this).closest(".fieldlist").trigger("fa.event.refreshfieldlist");
  9456. });
  9457. });
  9458. fieldlist.trigger("fa.event.refreshfieldlist");
  9459. });
  9460. }
  9461. },
  9462. switcher: function (form) {
  9463. form.on("click", "[data-toggle='switcher']", function () {
  9464. if ($(this).hasClass("disabled")) {
  9465. return false;
  9466. }
  9467. var switcher = $.proxy(function () {
  9468. var input = $(this).prev("input");
  9469. input = $(this).data("input-id") ? $("#" + $(this).data("input-id")) : input;
  9470. if (input.length > 0) {
  9471. var yes = $(this).data("yes");
  9472. var no = $(this).data("no");
  9473. if (input.val() == yes) {
  9474. input.val(no);
  9475. $("i", this).addClass("fa-flip-horizontal text-gray");
  9476. } else {
  9477. input.val(yes);
  9478. $("i", this).removeClass("fa-flip-horizontal text-gray");
  9479. }
  9480. input.trigger('change');
  9481. }
  9482. }, this);
  9483. if (typeof $(this).data("confirm") !== 'undefined') {
  9484. Layer.confirm($(this).data("confirm"), function (index) {
  9485. switcher();
  9486. Layer.close(index);
  9487. });
  9488. } else {
  9489. switcher();
  9490. }
  9491. return false;
  9492. });
  9493. },
  9494. bindevent: function (form) {
  9495. },
  9496. slider: function (form) {
  9497. if ($("[data-role='slider'],input.slider", form).length > 0) {
  9498. require(['bootstrap-slider'], function () {
  9499. $("[data-role='slider'],input.slider").removeClass('hidden').css('width', function (index, value) {
  9500. return $(this).parents('.form-control').width();
  9501. }).slider().on('slide', function (ev) {
  9502. var data = $(this).data();
  9503. if (typeof data.unit !== 'undefined') {
  9504. $(this).parents('.form-control').siblings('.value').text(ev.value + data.unit);
  9505. }
  9506. });
  9507. });
  9508. }
  9509. },
  9510. tagsinput: function (form) {
  9511. if ($("[data-role='tagsinput']", form).length > 0) {
  9512. require(['tagsinput', 'autocomplete'], function () {
  9513. $("[data-role='tagsinput']").tagsinput();
  9514. form.on("reset", function () {
  9515. setTimeout(function () {
  9516. $("[data-role='tagsinput']").tagsinput('reset');
  9517. }, 0);
  9518. });
  9519. });
  9520. }
  9521. },
  9522. autocomplete: function (form) {
  9523. if ($("[data-role='autocomplete']", form).length > 0) {
  9524. require(['autocomplete'], function () {
  9525. $("[data-role='autocomplete']").autocomplete();
  9526. });
  9527. }
  9528. },
  9529. favisible: function (form) {
  9530. if ($("[data-favisible]", form).length == 0) {
  9531. return;
  9532. }
  9533. var checkCondition = function (condition) {
  9534. var conditionArr = condition.split(/&&/);
  9535. var success = 0;
  9536. var baseregex = /^([a-z0-9\_]+)([>|<|=|\!]=?)(.*)$/i, strregex = /^('|")(.*)('|")$/, regregex = /^regex:(.*)$/;
  9537. // @formatter:off
  9538. var operator_result = {
  9539. '>': function (a, b) {
  9540. return a > b;
  9541. },
  9542. '>=': function (a, b) {
  9543. return a >= b;
  9544. },
  9545. '<': function (a, b) {
  9546. return a < b;
  9547. },
  9548. '<=': function (a, b) {
  9549. return a <= b;
  9550. },
  9551. '==': function (a, b) {
  9552. return a == b;
  9553. },
  9554. '!=': function (a, b) {
  9555. return a != b;
  9556. },
  9557. 'in': function (a, b) {
  9558. return b.split(/\,/).indexOf(a) > -1;
  9559. },
  9560. 'regex': function (a, b) {
  9561. var regParts = b.match(/^\/(.*?)\/([gim]*)$/);
  9562. var regexp = regParts ? new RegExp(regParts[1], regParts[2]) : new RegExp(b);
  9563. return regexp.test(a);
  9564. }
  9565. };
  9566. // @formatter:on
  9567. var dataArr = form.serializeArray(), dataObj = {}, fieldName, fieldValue;
  9568. $(dataArr).each(function (i, field) {
  9569. fieldName = field.name;
  9570. fieldValue = field.value;
  9571. fieldName = fieldName.substr(-2) === '[]' ? fieldName.substr(0, fieldName.length - 2) : fieldName;
  9572. dataObj[fieldName] = typeof dataObj[fieldName] !== 'undefined' ? [dataObj[fieldName], fieldValue].join(',') : fieldValue;
  9573. });
  9574. $.each(conditionArr, function (i, item) {
  9575. var basematches = baseregex.exec(item);
  9576. if (basematches) {
  9577. var name = basematches[1], operator = basematches[2], value = basematches[3].toString();
  9578. if (operator === '=') {
  9579. var strmatches = strregex.exec(value);
  9580. operator = strmatches ? '==' : 'in';
  9581. value = strmatches ? strmatches[2] : value;
  9582. }
  9583. var regmatches = regregex.exec(value);
  9584. if (regmatches) {
  9585. operator = 'regex';
  9586. value = regmatches[1];
  9587. }
  9588. var chkname = "row[" + name + "]";
  9589. if (typeof dataObj[chkname] === 'undefined') {
  9590. return false;
  9591. }
  9592. var objvalue = dataObj[chkname];
  9593. if ($.isArray(objvalue)) {
  9594. objvalue = dataObj[chkname].join(",");
  9595. }
  9596. if (['>', '>=', '<', '<='].indexOf(operator) > -1) {
  9597. objvalue = parseFloat(objvalue);
  9598. value = parseFloat(value);
  9599. }
  9600. var result = operator_result[operator](objvalue, value);
  9601. success += (result ? 1 : 0);
  9602. }
  9603. });
  9604. return success === conditionArr.length;
  9605. };
  9606. form.on("keyup change click configchange", "input,textarea,select", function () {
  9607. $("[data-favisible][data-favisible!='']", form).each(function () {
  9608. var visible = $(this).data("favisible");
  9609. var groupArr = visible ? visible.toString().split(/\|\|/) : [];
  9610. var success = 0;
  9611. $.each(groupArr, function (i, j) {
  9612. if (checkCondition(j)) {
  9613. success++;
  9614. }
  9615. });
  9616. if (success > 0) {
  9617. $(this).removeClass("hidden");
  9618. } else {
  9619. $(this).addClass("hidden");
  9620. }
  9621. });
  9622. });
  9623. //追加上忽略元素
  9624. setTimeout(function () {
  9625. var validator = form.data('validator');
  9626. if (validator) {
  9627. validator.options.ignore += ((validator.options.ignore ? ',' : '') + '.hidden[data-favisible] :hidden,.hidden[data-favisible]:hidden');
  9628. }
  9629. }, 0);
  9630. $("input,textarea,select", form).trigger("configchange");
  9631. }
  9632. },
  9633. api: {
  9634. submit: function (form, success, error, submit) {
  9635. if (form.length === 0) {
  9636. Toastr.error("表单未初始化完成,无法提交");
  9637. return false;
  9638. }
  9639. if (typeof submit === 'function') {
  9640. if (false === submit.call(form, success, error)) {
  9641. return false;
  9642. }
  9643. }
  9644. var type = form.attr("method") ? form.attr("method").toUpperCase() : 'GET';
  9645. type = type && (type === 'GET' || type === 'POST') ? type : 'GET';
  9646. url = form.attr("action");
  9647. url = url ? url : location.href;
  9648. //修复当存在多选项元素时提交的BUG
  9649. var params = {};
  9650. var multipleList = $("[name$='[]']", form);
  9651. if (multipleList.length > 0) {
  9652. var postFields = form.serializeArray().map(function (obj) {
  9653. return $(obj).prop("name");
  9654. });
  9655. $.each(multipleList, function (i, j) {
  9656. if (postFields.indexOf($(this).prop("name")) < 0) {
  9657. params[$(this).prop("name")] = '';
  9658. }
  9659. });
  9660. }
  9661. //调用Ajax请求方法
  9662. Fast.api.ajax({
  9663. type: type,
  9664. url: url,
  9665. data: form.serialize() + (Object.keys(params).length > 0 ? '&' + $.param(params) : ''),
  9666. dataType: 'json',
  9667. complete: function (xhr) {
  9668. var token = xhr.getResponseHeader('__token__');
  9669. if (token) {
  9670. $("input[name='__token__']").val(token);
  9671. }
  9672. }
  9673. }, function (data, ret) {
  9674. $('.form-group', form).removeClass('has-feedback has-success has-error');
  9675. if (data && typeof data === 'object') {
  9676. //刷新客户端token
  9677. if (typeof data.token !== 'undefined') {
  9678. $("input[name='__token__']").val(data.token);
  9679. }
  9680. //调用客户端事件
  9681. if (typeof data.callback !== 'undefined' && typeof data.callback === 'function') {
  9682. data.callback.call(form, data);
  9683. }
  9684. }
  9685. if (typeof success === 'function') {
  9686. if (false === success.call(form, data, ret)) {
  9687. return false;
  9688. }
  9689. }
  9690. }, function (data, ret) {
  9691. if (data && typeof data === 'object' && typeof data.token !== 'undefined') {
  9692. $("input[name='__token__']").val(data.token);
  9693. }
  9694. if (typeof error === 'function') {
  9695. if (false === error.call(form, data, ret)) {
  9696. return false;
  9697. }
  9698. }
  9699. });
  9700. return true;
  9701. },
  9702. bindevent: function (form, success, error, submit) {
  9703. form = typeof form === 'object' ? form : $(form);
  9704. var events = Form.events;
  9705. events.bindevent(form);
  9706. events.validator(form, success, error, submit);
  9707. events.selectpicker(form);
  9708. events.daterangepicker(form);
  9709. events.selectpage(form);
  9710. events.cxselect(form);
  9711. events.citypicker(form);
  9712. events.datetimepicker(form);
  9713. events.faupload(form);
  9714. events.faselect(form);
  9715. events.fieldlist(form);
  9716. events.slider(form);
  9717. events.switcher(form);
  9718. events.tagsinput(form);
  9719. events.autocomplete(form);
  9720. events.favisible(form);
  9721. },
  9722. custom: {}
  9723. },
  9724. };
  9725. return Form;
  9726. });
  9727. /**
  9728. * FastAdmin通用搜索
  9729. *
  9730. * @author: pppscn <35696959@qq.com>
  9731. * @update 2017-05-07 <https://gitee.com/pp/fastadmin>
  9732. *
  9733. * @author: Karson <karson@fastadmin.net>
  9734. * @update 2018-04-05 <https://gitee.com/karson/fastadmin>
  9735. */
  9736. !function ($) {
  9737. 'use strict';
  9738. var ColumnsForSearch = [];
  9739. var sprintf = $.fn.bootstrapTable.utils.sprintf;
  9740. var initCommonSearch = function (pColumns, that) {
  9741. var vFormCommon = createFormCommon(pColumns, that);
  9742. var vModal = sprintf("<div class=\"commonsearch-table %s\">", that.options.searchFormVisible ? "" : "hidden");
  9743. vModal += vFormCommon;
  9744. vModal += "</div>";
  9745. that.$container.prepend($(vModal));
  9746. that.$commonsearch = $(".commonsearch-table", that.$container);
  9747. var form = $("form.form-commonsearch", that.$commonsearch);
  9748. require(['form'], function (Form) {
  9749. Form.api.bindevent(form);
  9750. form.validator("destroy");
  9751. });
  9752. // 表单提交
  9753. form.on("submit", function (event) {
  9754. event.preventDefault();
  9755. that.onCommonSearch();
  9756. return false;
  9757. });
  9758. // 重置搜索
  9759. form.on("click", "button[type=reset]", function (event) {
  9760. form[0].reset();
  9761. setTimeout(function () {
  9762. that.onCommonSearch();
  9763. }, 1);
  9764. });
  9765. };
  9766. var createFormCommon = function (pColumns, that) {
  9767. // 如果有使用模板则直接返回模板的内容
  9768. if (that.options.searchFormTemplate) {
  9769. return Template(that.options.searchFormTemplate, {columns: pColumns, table: that});
  9770. }
  9771. var htmlForm = [];
  9772. htmlForm.push(sprintf('<form class="form-horizontal form-commonsearch" novalidate method="post" action="%s" >', that.options.actionForm));
  9773. htmlForm.push('<fieldset>');
  9774. if (that.options.titleForm.length > 0)
  9775. htmlForm.push(sprintf("<legend>%s</legend>", that.options.titleForm));
  9776. htmlForm.push('<div class="row">');
  9777. for (var i in pColumns) {
  9778. var vObjCol = pColumns[i];
  9779. if (!vObjCol.checkbox && !vObjCol.radio && vObjCol.field && vObjCol.field !== 'operate' && vObjCol.searchable && vObjCol.operate !== false) {
  9780. var query = Fast.api.query(vObjCol.field);
  9781. var operate = Fast.api.query(vObjCol.field + "-operate");
  9782. var renderDefault = that.options.renderDefault && (typeof vObjCol.renderDefault == 'undefined' || vObjCol.renderDefault);
  9783. vObjCol.defaultValue = renderDefault && query ? query : (typeof vObjCol.defaultValue === 'undefined' ? '' : vObjCol.defaultValue);
  9784. vObjCol.operate = renderDefault && operate ? operate : (typeof vObjCol.operate === 'undefined' ? '=' : vObjCol.operate);
  9785. ColumnsForSearch.push(vObjCol);
  9786. htmlForm.push('<div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">');
  9787. htmlForm.push(sprintf('<label for="%s" class="control-label col-xs-4">%s</label>', vObjCol.field, vObjCol.title));
  9788. htmlForm.push('<div class="col-xs-8">');
  9789. vObjCol.operate = vObjCol.operate ? vObjCol.operate.toUpperCase() : '=';
  9790. htmlForm.push(sprintf('<input type="hidden" class="form-control operate" name="%s-operate" data-name="%s" value="%s" readonly>', vObjCol.field, vObjCol.field, vObjCol.operate));
  9791. var addClass = typeof vObjCol.addClass === 'undefined' ? (typeof vObjCol.addclass === 'undefined' ? 'form-control' : 'form-control ' + vObjCol.addclass) : 'form-control ' + vObjCol.addClass;
  9792. var extend = typeof vObjCol.extend === 'undefined' ? '' : vObjCol.extend;
  9793. var style = typeof vObjCol.style === 'undefined' ? '' : sprintf('style="%s"', vObjCol.style);
  9794. extend = typeof vObjCol.data !== 'undefined' && extend == '' ? vObjCol.data : extend;
  9795. extend = typeof vObjCol.autocomplete !== 'undefined' ? extend + ' autocomplete="' + (vObjCol.autocomplete === false || vObjCol.autocomplete === 'off' ? 'off' : 'on') + '"' : extend;
  9796. if (vObjCol.searchList) {
  9797. if (typeof vObjCol.searchList === 'function') {
  9798. htmlForm.push(vObjCol.searchList.call(this, vObjCol));
  9799. } else {
  9800. var optionList = [sprintf('<option value="">%s</option>', that.options.formatCommonChoose())];
  9801. if (typeof vObjCol.searchList === 'object' && typeof vObjCol.searchList.then === 'function') {
  9802. (function (vObjCol, that) {
  9803. $.when(vObjCol.searchList).done(function (ret) {
  9804. var searchList = [];
  9805. if (ret.data && ret.data.searchlist && $.isArray(ret.data.searchlist)) {
  9806. searchList = ret.data.searchlist;
  9807. } else if (ret.constructor === Array || ret.constructor === Object) {
  9808. searchList = ret;
  9809. }
  9810. var optionList = createOptionList(searchList, vObjCol, that);
  9811. $("form.form-commonsearch select[name='" + vObjCol.field + "']", that.$container).html(optionList.join('')).trigger("change");
  9812. });
  9813. })(vObjCol, that);
  9814. } else {
  9815. optionList = createOptionList(vObjCol.searchList, vObjCol, that);
  9816. }
  9817. htmlForm.push(sprintf('<select class="%s" name="%s" %s %s>%s</select>', addClass, vObjCol.field, style, extend, optionList.join('')));
  9818. }
  9819. } else {
  9820. var placeholder = typeof vObjCol.placeholder === 'undefined' ? vObjCol.title : vObjCol.placeholder;
  9821. var type = typeof vObjCol.type === 'undefined' ? 'text' : vObjCol.type;
  9822. var defaultValue = typeof vObjCol.defaultValue === 'undefined' ? '' : vObjCol.defaultValue;
  9823. if (/BETWEEN$/.test(vObjCol.operate)) {
  9824. var defaultValueArr = defaultValue.toString().match(/\|/) ? defaultValue.split('|') : ['', ''];
  9825. var placeholderArr = placeholder.toString().match(/\|/) ? placeholder.split('|') : [placeholder, placeholder];
  9826. htmlForm.push('<div class="row row-between">');
  9827. htmlForm.push(sprintf('<div class="col-xs-6"><input type="%s" class="%s" name="%s" value="%s" placeholder="%s" id="%s-min" data-index="%s" %s %s></div>', type, addClass, vObjCol.field, defaultValueArr[0], placeholderArr[0], vObjCol.field, i, style, extend));
  9828. htmlForm.push(sprintf('<div class="col-xs-6"><input type="%s" class="%s" name="%s" value="%s" placeholder="%s" id="%s-max" data-index="%s" %s %s></div>', type, addClass, vObjCol.field, defaultValueArr[1], placeholderArr[1], vObjCol.field, i, style, extend));
  9829. htmlForm.push('</div>');
  9830. } else {
  9831. htmlForm.push(sprintf('<input type="%s" class="%s" name="%s" value="%s" placeholder="%s" id="%s" data-index="%s" %s %s>', type, addClass, vObjCol.field, defaultValue, placeholder, vObjCol.field, i, style, extend));
  9832. }
  9833. }
  9834. htmlForm.push('</div>');
  9835. htmlForm.push('</div>');
  9836. }
  9837. }
  9838. htmlForm.push('<div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">');
  9839. htmlForm.push(createFormBtn(that).join(''));
  9840. htmlForm.push('</div>');
  9841. htmlForm.push('</div>');
  9842. htmlForm.push('</fieldset>');
  9843. htmlForm.push('</form>');
  9844. return htmlForm.join('');
  9845. };
  9846. var createFormBtn = function (that) {
  9847. var htmlBtn = [];
  9848. var searchSubmit = that.options.formatCommonSubmitButton();
  9849. var searchReset = that.options.formatCommonResetButton();
  9850. htmlBtn.push('<div class="col-sm-8 col-xs-offset-4">');
  9851. htmlBtn.push(sprintf('<button type="submit" class="btn btn-success" formnovalidate>%s</button> ', searchSubmit));
  9852. htmlBtn.push(sprintf('<button type="reset" class="btn btn-default" >%s</button> ', searchReset));
  9853. htmlBtn.push('</div>');
  9854. return htmlBtn;
  9855. };
  9856. var createOptionList = function (searchList, vObjCol, that) {
  9857. var isArray = searchList.constructor === Array;
  9858. var optionList = [];
  9859. optionList.push(sprintf('<option value="">%s</option>', that.options.formatCommonChoose()));
  9860. $.each(searchList, function (key, value) {
  9861. if (value.constructor === Object) {
  9862. key = value.id;
  9863. value = value.name;
  9864. } else {
  9865. key = isArray ? value : key;
  9866. }
  9867. optionList.push(sprintf("<option value='" + key + "' %s>" + value + "</option>", key == vObjCol.defaultValue ? 'selected' : ''));
  9868. });
  9869. return optionList;
  9870. };
  9871. var isSearchAvailble = function (that) {
  9872. //只支持服务端搜索
  9873. if (!that.options.commonSearch || that.options.sidePagination != 'server' || !that.options.url) {
  9874. return false;
  9875. }
  9876. return true;
  9877. };
  9878. var getSearchQuery = function (that, removeempty) {
  9879. var op = {};
  9880. var filter = {};
  9881. var value = '';
  9882. $("form.form-commonsearch .operate", that.$commonsearch).each(function (i) {
  9883. var name = $(this).data("name");
  9884. var sym = $(this).is("select") ? $("option:selected", this).val() : $(this).val().toUpperCase();
  9885. var obj = $("[name='" + name + "']", that.$commonsearch);
  9886. if (obj.length == 0)
  9887. return true;
  9888. var vObjCol = ColumnsForSearch[i];
  9889. var process = !that.options.searchFormTemplate && vObjCol && typeof vObjCol.process == 'function' ? vObjCol.process : null;
  9890. if (obj.length > 1) {
  9891. if (/BETWEEN$/.test(sym)) {
  9892. var value_begin = $.trim($("[name='" + name + "']:first", that.$commonsearch).val()),
  9893. value_end = $.trim($("[name='" + name + "']:last", that.$commonsearch).val());
  9894. if (value_begin.length || value_end.length) {
  9895. if (process) {
  9896. value_begin = process(value_begin, 'begin');
  9897. value_end = process(value_end, 'end');
  9898. }
  9899. value = value_begin + ',' + value_end;
  9900. } else {
  9901. value = '';
  9902. }
  9903. //如果是时间筛选,将operate置为RANGE
  9904. if ($("[name='" + name + "']:first", that.$commonsearch).hasClass("datetimepicker")) {
  9905. sym = 'RANGE';
  9906. }
  9907. } else {
  9908. value = $("[name='" + name + "']:checked", that.$commonsearch).val();
  9909. value = process ? process(value) : value;
  9910. }
  9911. } else {
  9912. value = process ? process(obj.val()) : obj.val();
  9913. }
  9914. if (removeempty && (value === '' || value == null || ($.isArray(value) && value.length === 0)) && !sym.match(/null/i)) {
  9915. return true;
  9916. }
  9917. op[name] = sym;
  9918. filter[name] = value;
  9919. });
  9920. if (that.options.searchCountTips) {
  9921. var count = 0;
  9922. $.each(filter, function (key, value) {
  9923. if ((value === '' || value == null || ($.isArray(value) && value.length === 0))) {
  9924. return true;
  9925. }
  9926. count++;
  9927. });
  9928. that.$toolbar.find(".btn-commonsearch > span").text(count).toggleClass("hidden", count === 0);
  9929. }
  9930. return {op: op, filter: filter};
  9931. };
  9932. var getQueryParams = function (params, searchQuery, removeempty) {
  9933. params.filter = typeof params.filter === 'Object' ? params.filter : (params.filter ? JSON.parse(params.filter) : {});
  9934. params.op = typeof params.op === 'Object' ? params.op : (params.op ? JSON.parse(params.op) : {});
  9935. params.filter = $.extend({}, params.filter, searchQuery.filter);
  9936. params.op = $.extend({}, params.op, searchQuery.op);
  9937. //移除empty的值
  9938. if (removeempty) {
  9939. $.each(params.filter, function (i, j) {
  9940. if ((j == '' || j == null || ($.isArray(j) && j.length == 0)) && !params.op[i].match(/null/i)) {
  9941. delete params.filter[i];
  9942. delete params.op[i];
  9943. }
  9944. });
  9945. }
  9946. params.filter = JSON.stringify(params.filter);
  9947. params.op = JSON.stringify(params.op);
  9948. return params;
  9949. };
  9950. $.extend($.fn.bootstrapTable.defaults, {
  9951. commonSearch: false,
  9952. titleForm: "Common search",
  9953. actionForm: "",
  9954. searchFormTemplate: "",
  9955. searchFormVisible: true,
  9956. searchCountTips: true,
  9957. searchClass: 'searchit',
  9958. showSearch: true,
  9959. renderDefault: true,
  9960. onCommonSearch: function (field, text) {
  9961. return false;
  9962. },
  9963. onPostCommonSearch: function (table) {
  9964. return false;
  9965. }
  9966. });
  9967. $.extend($.fn.bootstrapTable.defaults.icons, {
  9968. commonSearchIcon: 'glyphicon-search'
  9969. });
  9970. $.extend($.fn.bootstrapTable.Constructor.EVENTS, {
  9971. 'common-search.bs.table': 'onCommonSearch',
  9972. 'post-common-search.bs.table': 'onPostCommonSearch'
  9973. });
  9974. $.extend($.fn.bootstrapTable.locales[$.fn.bootstrapTable.defaults.locale], {
  9975. formatCommonSearch: function () {
  9976. return "Common search";
  9977. },
  9978. formatCommonSubmitButton: function () {
  9979. return "Search";
  9980. },
  9981. formatCommonResetButton: function () {
  9982. return "Reset";
  9983. },
  9984. formatCommonCloseButton: function () {
  9985. return "Close";
  9986. },
  9987. formatCommonChoose: function () {
  9988. return "Choose";
  9989. }
  9990. });
  9991. $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);
  9992. var BootstrapTable = $.fn.bootstrapTable.Constructor,
  9993. _initHeader = BootstrapTable.prototype.initHeader,
  9994. _initToolbar = BootstrapTable.prototype.initToolbar,
  9995. _load = BootstrapTable.prototype.load,
  9996. _initSearch = BootstrapTable.prototype.initSearch;
  9997. BootstrapTable.prototype.initHeader = function () {
  9998. _initHeader.apply(this, Array.prototype.slice.apply(arguments));
  9999. this.$header.find('th[data-field]').each(function (i) {
  10000. var column = $(this).data();
  10001. if (typeof column['width'] !== 'undefined' && column['width'].toString().indexOf("%") === -1) {
  10002. $(".th-inner", this).outerWidth(column['width']);
  10003. $(this).css("max-width", column['width']);
  10004. }
  10005. });
  10006. this.options.stateField = this.header.stateField;
  10007. };
  10008. BootstrapTable.prototype.initToolbar = function () {
  10009. _initToolbar.apply(this, Array.prototype.slice.apply(arguments));
  10010. if (!isSearchAvailble(this)) {
  10011. return;
  10012. }
  10013. var that = this,
  10014. html = [];
  10015. if (that.options.showSearch) {
  10016. html.push(sprintf('<div class="columns-%s pull-%s" style="margin-top:10px;margin-bottom:10px;">', this.options.buttonsAlign, this.options.buttonsAlign));
  10017. html.push(sprintf('<button class="btn btn-default btn-commonsearch %s' + '" type="button" name="commonSearch" title="%s">', that.options.iconSize === undefined ? '' : ' btn-' + that.options.iconSize, that.options.formatCommonSearch()));
  10018. if (that.options.searchCountTips) {
  10019. html.push(sprintf('<span class="label label-danger hidden">0</span>'));
  10020. }
  10021. html.push(sprintf('<i class="%s %s"></i>', that.options.iconsPrefix, that.options.icons.commonSearchIcon));
  10022. html.push('</button></div>');
  10023. }
  10024. if (that.$toolbar.find(".pull-right").length > 0) {
  10025. $(html.join('')).insertBefore(that.$toolbar.find(".pull-right:first"));
  10026. } else {
  10027. that.$toolbar.append(html.join(''));
  10028. }
  10029. initCommonSearch(that.columns, that);
  10030. that.$toolbar.find('button[name="commonSearch"]')
  10031. .off('click').on('click', function () {
  10032. that.$commonsearch.toggleClass("hidden");
  10033. return;
  10034. });
  10035. that.$container.on("click", "." + that.options.searchClass, function () {
  10036. var value = $(this).data("value");
  10037. var field = $(this).data("field");
  10038. var ul = that.$container.closest(".panel-intro").find("ul[data-field='" + field + "']");
  10039. if (ul.length > 0) {
  10040. $('li a[data-value="' + value + '"][data-toggle="tab"]', ul).trigger('click');
  10041. return;
  10042. }
  10043. var obj = $("form [name='" + field + "']", that.$commonsearch);
  10044. if (obj.length > 0) {
  10045. if (obj.is("select")) {
  10046. $("option[value='" + value + "']", obj).prop("selected", true);
  10047. } else if (obj.length > 1) {
  10048. $("form [name='" + field + "'][value='" + value + "']", that.$commonsearch).prop("checked", true);
  10049. } else {
  10050. obj.val(value + "");
  10051. }
  10052. obj.trigger("change");
  10053. $("form", that.$commonsearch).trigger("submit");
  10054. }
  10055. });
  10056. var queryParams = that.options.queryParams;
  10057. //匹配默认搜索值
  10058. this.options.queryParams = function (params) {
  10059. return queryParams(getQueryParams(params, getSearchQuery(that, true)));
  10060. };
  10061. this.trigger('post-common-search', that);
  10062. };
  10063. BootstrapTable.prototype.onCommonSearch = function () {
  10064. var searchQuery = getSearchQuery(this);
  10065. this.trigger('common-search', this, searchQuery);
  10066. this.options.pageNumber = 1;
  10067. //this.options.pageSize = $.fn.bootstrapTable.defaults.pageSize;
  10068. this.refresh({});
  10069. };
  10070. BootstrapTable.prototype.load = function (data) {
  10071. _load.apply(this, Array.prototype.slice.apply(arguments));
  10072. if (!isSearchAvailble(this)) {
  10073. return;
  10074. }
  10075. };
  10076. BootstrapTable.prototype.initSearch = function () {
  10077. _initSearch.apply(this, Array.prototype.slice.apply(arguments));
  10078. if (!isSearchAvailble(this)) {
  10079. return;
  10080. }
  10081. var that = this;
  10082. var fp = $.isEmptyObject(this.filterColumnsPartial) ? null : this.filterColumnsPartial;
  10083. this.data = fp ? $.grep(this.data, function (item, i) {
  10084. for (var key in fp) {
  10085. var fval = fp[key].toLowerCase();
  10086. var value = item[key];
  10087. value = $.fn.bootstrapTable.utils.calculateObjectValue(that.header,
  10088. that.header.formatters[$.inArray(key, that.header.fields)],
  10089. [value, item, i], value);
  10090. if (!($.inArray(key, that.header.fields) !== -1 &&
  10091. (typeof value === 'string' || typeof value === 'number') &&
  10092. (value + '').toLowerCase().indexOf(fval) !== -1)) {
  10093. return false;
  10094. }
  10095. }
  10096. return true;
  10097. }) : this.data;
  10098. };
  10099. }(jQuery);
  10100. define("bootstrap-table-commonsearch", ["bootstrap-table"], (function (global) {
  10101. return function () {
  10102. var ret, fn;
  10103. return ret || global.$.fn.bootstrapTable.defaults;
  10104. };
  10105. }(this)));
  10106. /**
  10107. * 将BootstrapTable的行使用自定义的模板来渲染
  10108. *
  10109. * @author: karson
  10110. * @version: v0.0.1
  10111. *
  10112. * @update 2017-06-24 <http://github.com/karsonzhang/fastadmin>
  10113. */
  10114. !function ($) {
  10115. 'use strict';
  10116. $.extend($.fn.bootstrapTable.defaults, {
  10117. //是否启用模板渲染
  10118. templateView: false,
  10119. //数据格式化的模板ID或格式函数
  10120. templateFormatter: "itemtpl",
  10121. //添加的父类的class
  10122. templateParentClass: "row row-flex",
  10123. //向table添加的class
  10124. templateTableClass: "table-template",
  10125. });
  10126. var BootstrapTable = $.fn.bootstrapTable.Constructor,
  10127. _initContainer = BootstrapTable.prototype.initContainer,
  10128. _initBody = BootstrapTable.prototype.initBody,
  10129. _initRow = BootstrapTable.prototype.initRow;
  10130. BootstrapTable.prototype.initContainer = function () {
  10131. _initContainer.apply(this, Array.prototype.slice.apply(arguments));
  10132. var that = this;
  10133. if (!that.options.templateView) {
  10134. return;
  10135. }
  10136. that.options.cardView = true;
  10137. };
  10138. BootstrapTable.prototype.initBody = function () {
  10139. var that = this;
  10140. $.extend(that.options, {
  10141. showHeader: !that.options.templateView ? $.fn.bootstrapTable.defaults.showHeader : false,
  10142. showFooter: !that.options.templateView ? $.fn.bootstrapTable.defaults.showFooter : false,
  10143. });
  10144. $(that.$el).toggleClass(that.options.templateTableClass, that.options.templateView);
  10145. _initBody.apply(this, Array.prototype.slice.apply(arguments));
  10146. if (!that.options.templateView) {
  10147. return;
  10148. } else {
  10149. //由于Bootstrap是基于Table的,添加一个父类容器
  10150. $("> *:not(.no-records-found)", that.$body).wrapAll($("<div />").addClass(that.options.templateParentClass));
  10151. }
  10152. };
  10153. BootstrapTable.prototype.initRow = function (item, i, data, parentDom) {
  10154. var that = this;
  10155. //如果未启用则使用原生的initRow方法
  10156. if (!that.options.templateView) {
  10157. return _initRow.apply(that, Array.prototype.slice.apply(arguments));
  10158. }
  10159. var $content = '';
  10160. if (typeof that.options.templateFormatter === 'function') {
  10161. $content = that.options.templateFormatter.call(that, item, i, data);
  10162. } else {
  10163. var Template = require('template');
  10164. $content = Template(that.options.templateFormatter, {item: item, i: i, data: data});
  10165. }
  10166. return $content;
  10167. };
  10168. }(jQuery);
  10169. define("bootstrap-table-template", ["bootstrap-table","template"], (function (global) {
  10170. return function () {
  10171. var ret, fn;
  10172. return ret || global.$.fn.bootstrapTable.defaults;
  10173. };
  10174. }(this)));
  10175. /**
  10176. * @author Jay <jwang@dizsoft.com>
  10177. */
  10178. (function ($) {
  10179. 'use strict';
  10180. var sprintf = $.fn.bootstrapTable.utils.sprintf;
  10181. $.extend($.fn.bootstrapTable.defaults, {
  10182. showJumpto: false,
  10183. exportOptions: {}
  10184. });
  10185. $.extend($.fn.bootstrapTable.locales, {
  10186. formatJumpto: function () {
  10187. return 'GO';
  10188. }
  10189. });
  10190. $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);
  10191. var BootstrapTable = $.fn.bootstrapTable.Constructor,
  10192. _initPagination = BootstrapTable.prototype.initPagination;
  10193. BootstrapTable.prototype.initPagination = function () {
  10194. this.showToolbar = this.options.showExport;
  10195. _initPagination.apply(this, Array.prototype.slice.apply(arguments));
  10196. if (this.options.showJumpto) {
  10197. var that = this,
  10198. $pageGroup = this.$pagination.find('ul.pagination'),
  10199. $jumpto = $pageGroup.find('li.jumpto');
  10200. if (!$jumpto.length) {
  10201. $jumpto = $([
  10202. '<li class="jumpto">',
  10203. '<input type="text" class="form-control">',
  10204. '<button class="btn' +
  10205. sprintf(' btn-%s', this.options.buttonsClass) +
  10206. sprintf(' btn-%s', this.options.iconSize) +
  10207. '" title="' + this.options.formatJumpto() + '" ' +
  10208. ' type="button">'+this.options.formatJumpto(),
  10209. '</button>',
  10210. '</li>'].join('')).appendTo($pageGroup);
  10211. $jumpto.find('button').click(function () {
  10212. that.selectPage(parseInt($jumpto.find('input').val()));
  10213. });
  10214. }
  10215. }
  10216. };
  10217. })(jQuery);
  10218. define("bootstrap-table-jumpto", ["bootstrap-table"], (function (global) {
  10219. return function () {
  10220. var ret, fn;
  10221. return ret || global.$.fn.bootstrapTable.defaults;
  10222. };
  10223. }(this)));
  10224. (function ($) {
  10225. 'use strict';
  10226. // Reasonable defaults
  10227. var PIXEL_STEP = 10;
  10228. var LINE_HEIGHT = 40;
  10229. var PAGE_HEIGHT = 800;
  10230. function normalizeWheel(event) {
  10231. var sX = 0; // spinX
  10232. var sY = 0; // spinY
  10233. var pX = 0; // pixelX
  10234. var pY = 0; // pixelY
  10235. // Legacy
  10236. if ('detail' in event) {
  10237. sY = event.detail;
  10238. }
  10239. if ('wheelDelta' in event) {
  10240. sY = -event.wheelDelta / 120;
  10241. }
  10242. if ('wheelDeltaY' in event) {
  10243. sY = -event.wheelDeltaY / 120;
  10244. }
  10245. if ('wheelDeltaX' in event) {
  10246. sX = -event.wheelDeltaX / 120;
  10247. }
  10248. // side scrolling on FF with DOMMouseScroll
  10249. if ('axis' in event && event.axis === event.HORIZONTAL_AXIS) {
  10250. sX = sY;
  10251. sY = 0;
  10252. }
  10253. pX = sX * PIXEL_STEP;
  10254. pY = sY * PIXEL_STEP;
  10255. if ('deltaY' in event) {
  10256. pY = event.deltaY;
  10257. }
  10258. if ('deltaX' in event) {
  10259. pX = event.deltaX;
  10260. }
  10261. if ((pX || pY) && event.deltaMode) {
  10262. if (event.deltaMode === 1) {
  10263. // delta in LINE units
  10264. pX *= LINE_HEIGHT;
  10265. pY *= LINE_HEIGHT;
  10266. } else {
  10267. // delta in PAGE units
  10268. pX *= PAGE_HEIGHT;
  10269. pY *= PAGE_HEIGHT;
  10270. }
  10271. }
  10272. // Fall-back if spin cannot be determined
  10273. if (pX && !sX) {
  10274. sX = pX < 1 ? -1 : 1;
  10275. }
  10276. if (pY && !sY) {
  10277. sY = pY < 1 ? -1 : 1;
  10278. }
  10279. return {
  10280. spinX: sX,
  10281. spinY: sY,
  10282. pixelX: pX,
  10283. pixelY: pY
  10284. };
  10285. }
  10286. var cachedWidth = null;
  10287. var getScrollBarWidth = function getScrollBarWidth() {
  10288. if (cachedWidth === null) {
  10289. var inner = $('<p/>').addClass('fixed-table-scroll-inner'),
  10290. outer = $('<div/>').addClass('fixed-table-scroll-outer'),
  10291. w1 = void 0,
  10292. w2 = void 0;
  10293. outer.append(inner);
  10294. $('body').append(outer);
  10295. w1 = inner[0].offsetWidth;
  10296. outer.css('overflow', 'scroll');
  10297. w2 = inner[0].offsetWidth;
  10298. if (w1 === w2) {
  10299. w2 = outer[0].clientWidth;
  10300. }
  10301. outer.remove();
  10302. cachedWidth = w1 - w2;
  10303. }
  10304. return cachedWidth;
  10305. };
  10306. //获取原本表格体的滑块宽度
  10307. var getTableBodyScrollBarWidth = function getTableBodyScrollBarWidth(tableBody) {
  10308. return tableBody[0].scrollHeight > tableBody[0].clientHeight ? 15 : 0;
  10309. };
  10310. $.extend($.fn.bootstrapTable.defaults, {
  10311. fixedColumns: false,
  10312. fixedNumber: 0,
  10313. fixedRightNumber: 0
  10314. });
  10315. var BootstrapTable = $.fn.bootstrapTable.Constructor,
  10316. _initBody = BootstrapTable.prototype.initBody,
  10317. _initContainer = BootstrapTable.prototype.initContainer,
  10318. _trigger = BootstrapTable.prototype.trigger,
  10319. _hideLoading = BootstrapTable.prototype.hideLoading,
  10320. _updateSelected = BootstrapTable.prototype.updateSelected;
  10321. BootstrapTable.prototype.fixedColumnsSupported = function () {
  10322. var that = this;
  10323. return that.options.fixedColumns && !that.options.detailView && !that.options.cardView;
  10324. };
  10325. BootstrapTable.prototype.initFixedContainer = function () {
  10326. if (this.options.fixedNumber) {
  10327. this.$tableContainer.find('.fixed-columns').length == 0 && this.$tableContainer.append('<div class="fixed-columns"></div>');
  10328. this.$fixedColumns = this.$tableContainer.find('.fixed-columns');
  10329. }
  10330. if (this.options.fixedRightNumber) {
  10331. this.$tableContainer.find('.fixed-columns-right').length == 0 && this.$tableContainer.append('<div class="fixed-columns-right"></div>');
  10332. this.$fixedColumnsRight = this.$tableContainer.find('.fixed-columns-right');
  10333. }
  10334. };
  10335. BootstrapTable.prototype.initContainer = function () {
  10336. _initContainer.apply(this, Array.prototype.slice.apply(arguments));
  10337. this.initFixedContainer();
  10338. };
  10339. BootstrapTable.prototype.initBody = function () {
  10340. _initBody.apply(this, Array.prototype.slice.apply(arguments));
  10341. if (!this.fixedColumnsSupported()) {
  10342. return;
  10343. }
  10344. if (this.options.showHeader && this.options.height) {
  10345. return;
  10346. }
  10347. this.initFixedColumnsBody();
  10348. this.initFixedColumnsEvents();
  10349. };
  10350. BootstrapTable.prototype.trigger = function () {
  10351. var that = this;
  10352. _trigger.apply(this, Array.prototype.slice.apply(arguments));
  10353. if (arguments[0] === 'pre-body') {
  10354. //如果上来就是cardView 设置表格高度为auto
  10355. if (this.options.cardView) {
  10356. this.$tableBody.css("height", "auto");
  10357. }
  10358. }
  10359. //监听cardView 显示/隐藏fixed部分
  10360. if (arguments[0] === 'toggle') {
  10361. if (arguments[1]) {
  10362. this.$tableBody.css("height", "auto");
  10363. this.$fixedColumns && this.$fixedColumns.hide();
  10364. this.$fixedColumnsRight && this.$fixedColumnsRight.hide();
  10365. } else {
  10366. this.$tableBody.css("height", "100%");
  10367. this.$fixedColumns && this.$fixedColumns.show();
  10368. this.$fixedColumnsRight && this.$fixedColumnsRight.show();
  10369. this.$fixedHeaderRight && this.$fixedHeaderRight.scrollLeft(this.$tableBody.find('table').width());
  10370. this.$fixedBodyRight && this.$fixedBodyRight.scrollLeft(this.$tableBody.find('table').width());
  10371. }
  10372. }
  10373. if (!that.fixedColumnsSupported()) {
  10374. return;
  10375. }
  10376. if (arguments[0] === 'post-header') {
  10377. this.initFixedColumnsHeader();
  10378. } else if (arguments[0] === 'scroll-body') {
  10379. if (this.needFixedColumns && this.options.fixedNumber) {
  10380. this.$fixedBody && this.$fixedBody.scrollTop(this.$tableBody.scrollTop());
  10381. }
  10382. if (this.needFixedColumns && this.options.fixedRightNumber) {
  10383. this.$fixedBodyRight && this.$fixedBodyRight.scrollTop(this.$tableBody.scrollTop());
  10384. }
  10385. } else if (arguments[0] === 'load-success') {
  10386. this.hideLoading();
  10387. }
  10388. };
  10389. BootstrapTable.prototype.updateSelected = function () {
  10390. var that = this;
  10391. _updateSelected.apply(this, Array.prototype.slice.apply(arguments));
  10392. if (!this.fixedColumnsSupported()) {
  10393. return;
  10394. }
  10395. this.$tableBody.find('tr').each(function (i, el) {
  10396. var $el = $(el);
  10397. var index = $el.data('index');
  10398. var classes = $el.attr('class');
  10399. var inputSelector = '[name="' + that.options.selectItemName + '"]';
  10400. var $input = $el.find(inputSelector);
  10401. if (typeof index === 'undefined') {
  10402. return;
  10403. }
  10404. var updateFixedBody = function updateFixedBody($fixedHeader, $fixedBody) {
  10405. var $tr = $fixedBody.find('tr[data-index="' + index + '"]');
  10406. $tr.attr('class', classes);
  10407. if ($input.length) {
  10408. $tr.find(inputSelector).prop('checked', $input.prop('checked'));
  10409. }
  10410. if (that.$selectAll.length) {
  10411. $fixedHeader.add($fixedBody).find('[name="btSelectAll"]').prop('checked', that.$selectAll.prop('checked'));
  10412. }
  10413. };
  10414. if (that.$fixedBody && that.options.fixedNumber) {
  10415. updateFixedBody(that.$fixedHeader, that.$fixedBody);
  10416. }
  10417. if (that.$fixedBodyRight && that.options.fixedRightNumber) {
  10418. updateFixedBody(that.$fixedHeaderRight, that.$fixedBodyRight);
  10419. }
  10420. });
  10421. };
  10422. BootstrapTable.prototype.hideLoading = function () {
  10423. _hideLoading.apply(this, Array.prototype.slice.apply(arguments));
  10424. if (this.needFixedColumns && this.options.fixedNumber) {
  10425. this.$fixedColumns.find('.fixed-table-loading').hide();
  10426. }
  10427. if (this.needFixedColumns && this.options.fixedRightNumber) {
  10428. this.$fixedColumnsRight.find('.fixed-table-loading').hide();
  10429. }
  10430. };
  10431. BootstrapTable.prototype.initFixedColumnsHeader = function () {
  10432. var that = this;
  10433. if (this.options.height) {
  10434. this.needFixedColumns = this.$tableHeader.outerWidth(true) < this.$tableHeader.find('table').outerWidth(true);
  10435. } else {
  10436. this.needFixedColumns = this.$tableBody.outerWidth(true) < this.$tableBody.find('table').outerWidth(true);
  10437. }
  10438. var initFixedHeader = function initFixedHeader($fixedColumns, isRight) {
  10439. $fixedColumns.find('.fixed-table-header').remove();
  10440. $fixedColumns.append(that.$tableHeader.clone(true));
  10441. $fixedColumns.find('.fixed-table-header').css('margin-right', "");
  10442. $fixedColumns.css({
  10443. width: that.getFixedColumnsWidth(isRight)
  10444. });
  10445. return $fixedColumns.find('.fixed-table-header');
  10446. };
  10447. if (this.needFixedColumns && this.options.fixedNumber) {
  10448. this.$fixedHeader = initFixedHeader(this.$fixedColumns);
  10449. this.$fixedHeader.css('margin-right', '');
  10450. } else if (this.$fixedColumns) {
  10451. this.$fixedColumns.html('').css('width', '');
  10452. }
  10453. if (this.needFixedColumns && this.options.fixedRightNumber) {
  10454. this.$fixedHeaderRight = initFixedHeader(this.$fixedColumnsRight, true);
  10455. this.$fixedHeaderRight.scrollLeft(this.$fixedHeaderRight.find('table').width());
  10456. } else if (this.$fixedColumnsRight) {
  10457. this.$fixedColumnsRight.html('').css('width', '');
  10458. }
  10459. this.initFixedColumnsBody();
  10460. this.initFixedColumnsEvents();
  10461. };
  10462. BootstrapTable.prototype.initFixedColumnsBody = function () {
  10463. var that = this;
  10464. var initFixedBody = function initFixedBody($fixedColumns, $fixedHeader) {
  10465. $fixedColumns.find('.fixed-table-body').remove();
  10466. $fixedColumns.append(that.$tableBody.clone(true));
  10467. var $fixedBody = $fixedColumns.find('.fixed-table-body');
  10468. var tableBody = that.$tableBody.get(0);
  10469. var resizeHeight = function (){
  10470. var scrollHeight = tableBody.scrollWidth > tableBody.clientWidth ? getScrollBarWidth() : 0;
  10471. var paginationHeight = $(".fixed-table-pagination", that.$tableContainer).height();
  10472. if (typeof that.options.height !== 'undefined') paginationHeight = 0;
  10473. $fixedColumns.css({
  10474. "height": "calc(100% - " + (paginationHeight + scrollHeight) + "px)"
  10475. });
  10476. $fixedBody.css({
  10477. "height": "calc(100% - " + $fixedHeader.height() + "px)",
  10478. overflow: "hidden"
  10479. });
  10480. };
  10481. $(window).on("resize", resizeHeight);
  10482. resizeHeight();
  10483. return $fixedBody;
  10484. };
  10485. if (this.needFixedColumns && this.options.fixedNumber) {
  10486. this.$fixedBody = initFixedBody(this.$fixedColumns, this.$fixedHeader);
  10487. }
  10488. if (this.needFixedColumns && this.options.fixedRightNumber) {
  10489. this.$fixedBodyRight = initFixedBody(this.$fixedColumnsRight, this.$fixedHeaderRight);
  10490. this.$fixedBodyRight.scrollLeft(this.$fixedBodyRight.find('table').width());
  10491. this.$fixedBodyRight.css('overflow-y', 'hidden');
  10492. }
  10493. };
  10494. BootstrapTable.prototype.getFixedColumnsWidth = function (isRight) {
  10495. var visibleFields = this.getVisibleFields();
  10496. var width = 0;
  10497. var fixedNumber = this.options.fixedNumber;
  10498. var marginRight = 0;
  10499. if (isRight) {
  10500. visibleFields = visibleFields.reverse();
  10501. fixedNumber = this.options.fixedRightNumber;
  10502. //右侧固定列距离
  10503. this.$fixedColumnsRight.css('right', getTableBodyScrollBarWidth(this.$tableBody));
  10504. }
  10505. for (var i = 0; i < fixedNumber; i++) {
  10506. width += this.$header.find('th[data-field="' + visibleFields[i] + '"]').outerWidth();
  10507. }
  10508. return width + 1;
  10509. };
  10510. BootstrapTable.prototype.initFixedColumnsEvents = function () {
  10511. var that = this;
  10512. var toggleHover = function toggleHover(e, toggle) {
  10513. var tr = 'tr[data-index="' + $(e.currentTarget).data('index') + '"]';
  10514. var $trs = that.$tableBody.find(tr);
  10515. if (that.$fixedBody) {
  10516. $trs = $trs.add(that.$fixedBody.find(tr));
  10517. }
  10518. if (that.$fixedBodyRight) {
  10519. $trs = $trs.add(that.$fixedBodyRight.find(tr));
  10520. }
  10521. $trs.css('background-color', toggle ? $(e.currentTarget).css('background-color') : '');
  10522. };
  10523. this.$tableBody.find('tr').hover(function (e) {
  10524. toggleHover(e, true);
  10525. }, function (e) {
  10526. toggleHover(e, false);
  10527. });
  10528. var isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
  10529. var mousewheel = isFirefox ? 'DOMMouseScroll' : 'mousewheel';
  10530. var updateScroll = function updateScroll(e, fixedBody) {
  10531. var normalized = normalizeWheel(e);
  10532. var deltaY = Math.ceil(normalized.pixelY);
  10533. var top = that.$tableBody.scrollTop() + deltaY;
  10534. if (deltaY < 0 && top > 0 || deltaY > 0 && top < fixedBody.scrollHeight - fixedBody.clientHeight) {
  10535. e.preventDefault();
  10536. }
  10537. that.$tableBody.scrollTop(top);
  10538. if (that.$fixedBody) {
  10539. that.$fixedBody.scrollTop(top);
  10540. }
  10541. if (that.$fixedBodyRight) {
  10542. that.$fixedBodyRight.scrollTop(top);
  10543. }
  10544. };
  10545. if (this.needFixedColumns && this.options.fixedNumber) {
  10546. this.$fixedBody.find('tr').hover(function (e) {
  10547. toggleHover(e, true);
  10548. }, function (e) {
  10549. toggleHover(e, false);
  10550. });
  10551. this.$fixedBody[0].addEventListener(mousewheel, function (e) {
  10552. //给鼠标滑轮绑定事件
  10553. updateScroll(e, that.$fixedBody[0]);
  10554. });
  10555. //给固定表格的checkbox绑定事件
  10556. this.$fixedBody.find('input[name="' + this.options.selectItemName + '"]').off("click").on('click', function (e) {
  10557. e.stopImmediatePropagation();
  10558. var index = $(e.target).data("index");
  10559. $(that.$selectItem[index]).trigger("click");
  10560. });
  10561. //绑定TD点击事件
  10562. this.$fixedBody.find('> table > tbody > tr[data-index] > td').off('click dblclick').on('click dblclick', function (e) {
  10563. var index = $(this).closest("tr[data-index]").data("index");
  10564. $(that.$selectItem[index]).closest("tr[data-index]").find(">td:eq(" + $(this).index() + ")").trigger("click");
  10565. });
  10566. }
  10567. //给原本表格绑定scroll事件
  10568. $('div.fixed-table-body').off('scroll'); //给所有的body解绑 scroll
  10569. this.$tableBody.off('scroll').on('scroll', function (e) {
  10570. that.$tableHeader.scrollLeft(0);
  10571. if (that.$tableBody.scrollLeft() > 0) {
  10572. that.$tableHeader.scrollLeft(that.$tableBody.scrollLeft());
  10573. if (that.options.showFooter && !that.options.cardView) {
  10574. that.$tableFooter.scrollLeft(that.$tableBody.scrollLeft());
  10575. }
  10576. }
  10577. var top = that.$tableBody.scrollTop();
  10578. if (that.$fixedBody) {
  10579. that.$fixedBody.scrollTop(top);
  10580. }
  10581. if (that.$fixedBodyRight) {
  10582. that.$fixedBodyRight.scrollTop(top);
  10583. }
  10584. });
  10585. if (this.needFixedColumns && this.options.fixedRightNumber) {
  10586. this.$fixedBodyRight.find('tr').hover(function (e) {
  10587. toggleHover(e, true);
  10588. }, function (e) {
  10589. toggleHover(e, false);
  10590. });
  10591. this.$fixedBodyRight[0].addEventListener(mousewheel, function (e) {
  10592. //给鼠标滑轮绑定事件
  10593. updateScroll(e, that.$fixedBodyRight[0]);
  10594. });
  10595. //给固定表格的checkbox绑定事件
  10596. this.$fixedBodyRight.find('input[name="' + this.options.selectItemName + '"]').off("click").on('click', function (e) {
  10597. e.stopImmediatePropagation();
  10598. var index = $(e.target).data("index");
  10599. $(that.$selectItem[index]).trigger("click");
  10600. });
  10601. //绑定TD点击事件
  10602. this.$fixedBodyRight.find('> table > tbody > tr[data-index] > td').off('click dblclick').on('click dblclick', function (e) {
  10603. var index = $(this).closest("tr[data-index]").data("index");
  10604. $(that.$selectItem[index]).closest("tr[data-index]").find(">td:eq(" + $(this).index() + ")").trigger("click");
  10605. });
  10606. }
  10607. if (this.options.filterControl) {
  10608. $(this.$fixedColumns).off('keyup change').on('keyup change', function (e) {
  10609. var $target = $(e.target);
  10610. var value = $target.val();
  10611. var field = $target.parents('th').data('field');
  10612. var $coreTh = that.$header.find('th[data-field="' + field + '"]');
  10613. if ($target.is('input')) {
  10614. $coreTh.find('input').val(value);
  10615. } else if ($target.is('select')) {
  10616. var $select = $coreTh.find('select');
  10617. $select.find('option[selected]').removeAttr('selected');
  10618. $select.find('option[value="' + value + '"]').attr('selected', true);
  10619. }
  10620. that.triggerSearch();
  10621. });
  10622. }
  10623. };
  10624. })(jQuery);
  10625. define("bootstrap-table-fixed-columns", ["bootstrap-table"], (function (global) {
  10626. return function () {
  10627. var ret, fn;
  10628. return ret || global.$.fn.bootstrapTable.defaults;
  10629. };
  10630. }(this)));
  10631. define('table',['jquery', 'bootstrap'], function ($, undefined) {
  10632. var Table = {
  10633. list: {},
  10634. // Bootstrap-table 基础配置
  10635. defaults: {
  10636. url: '',
  10637. sidePagination: 'server',
  10638. method: 'get', //请求方法
  10639. toolbar: ".toolbar", //工具栏
  10640. search: true, //是否启用快速搜索
  10641. cache: false,
  10642. commonSearch: true, //是否启用通用搜索
  10643. searchFormVisible: false, //是否始终显示搜索表单
  10644. titleForm: '', //为空则不显示标题,不定义默认显示:普通搜索
  10645. idTable: 'commonTable',
  10646. showExport: true,
  10647. exportDataType: "auto", //支持auto,selected,all 当设定为auto时自动时有选中则导出选中,没有选中则导出全部
  10648. exportTypes: ['json', 'xml', 'csv', 'txt', 'doc', 'excel'],
  10649. exportOptions: {
  10650. fileName: 'export_' + Moment().format("YYYY-MM-DD"),
  10651. preventInjection: false,
  10652. mso: {
  10653. onMsoNumberFormat: function (cell, row, col) {
  10654. return !isNaN($(cell).text()) ? '\\@' : '';
  10655. },
  10656. },
  10657. ignoreColumn: [0, 'operate'] //默认不导出第一列(checkbox)与操作(operate)列
  10658. },
  10659. pageSize: Config.pagesize || localStorage.getItem("pagesize") || 10,
  10660. pageList: [10, 15, 20, 25, 50, 'All'],
  10661. pagination: true,
  10662. clickToSelect: true, //是否启用点击选中
  10663. dblClickToEdit: true, //是否启用双击编辑
  10664. singleSelect: false, //是否启用单选
  10665. showRefresh: false,
  10666. showJumpto: true,
  10667. locale: Config.language === 'en' ? 'en-US' : Config.language.replace(/\-(\w+)$/, function (value) {
  10668. return value.toUpperCase();
  10669. }),
  10670. showToggle: true,
  10671. showColumns: true,
  10672. pk: 'id',
  10673. sortName: 'id',
  10674. sortOrder: 'desc',
  10675. paginationFirstText: __("First"),
  10676. paginationPreText: __("Previous"),
  10677. paginationNextText: __("Next"),
  10678. paginationLastText: __("Last"),
  10679. cardView: false, //卡片视图
  10680. iosCardView: true, //ios卡片视图
  10681. checkOnInit: true, //是否在初始化时判断
  10682. escape: true, //是否对内容进行转义
  10683. fixDropdownPosition: true, //是否修复下拉的定位
  10684. dragCheckboxMultiselect: true, //拖拽时复选框是否多选模式
  10685. selectedIds: [],
  10686. selectedData: [],
  10687. extend: {
  10688. index_url: '',
  10689. add_url: '',
  10690. edit_url: '',
  10691. del_url: '',
  10692. import_url: '',
  10693. multi_url: '',
  10694. dragsort_url: 'ajax/weigh',
  10695. }
  10696. },
  10697. // Bootstrap-table 列配置
  10698. columnDefaults: {
  10699. align: 'center',
  10700. valign: 'middle',
  10701. },
  10702. config: {
  10703. checkboxtd: 'tbody>tr>td.bs-checkbox',
  10704. toolbar: '.toolbar',
  10705. refreshbtn: '.btn-refresh',
  10706. addbtn: '.btn-add',
  10707. editbtn: '.btn-edit',
  10708. delbtn: '.btn-del',
  10709. importbtn: '.btn-import',
  10710. multibtn: '.btn-multi',
  10711. disabledbtn: '.btn-disabled',
  10712. editonebtn: '.btn-editone',
  10713. restoreonebtn: '.btn-restoreone',
  10714. destroyonebtn: '.btn-destroyone',
  10715. restoreallbtn: '.btn-restoreall',
  10716. destroyallbtn: '.btn-destroyall',
  10717. dragsortfield: 'weigh',
  10718. },
  10719. button: {
  10720. edit: {
  10721. name: 'edit',
  10722. icon: 'fa fa-pencil',
  10723. title: __('Edit'),
  10724. extend: 'data-toggle="tooltip" data-container="body"',
  10725. classname: 'btn btn-xs btn-success btn-editone'
  10726. },
  10727. del: {
  10728. name: 'del',
  10729. icon: 'fa fa-trash',
  10730. title: __('Del'),
  10731. extend: 'data-toggle="tooltip" data-container="body"',
  10732. classname: 'btn btn-xs btn-danger btn-delone'
  10733. },
  10734. dragsort: {
  10735. name: 'dragsort',
  10736. icon: 'fa fa-arrows',
  10737. title: __('Drag to sort'),
  10738. extend: 'data-toggle="tooltip"',
  10739. classname: 'btn btn-xs btn-primary btn-dragsort'
  10740. }
  10741. },
  10742. api: {
  10743. init: function (defaults, columnDefaults, locales) {
  10744. defaults = defaults ? defaults : {};
  10745. columnDefaults = columnDefaults ? columnDefaults : {};
  10746. locales = locales ? locales : {};
  10747. $.fn.bootstrapTable.Constructor.prototype.getSelectItem = function () {
  10748. return this.$selectItem;
  10749. };
  10750. var _onPageListChange = $.fn.bootstrapTable.Constructor.prototype.onPageListChange;
  10751. $.fn.bootstrapTable.Constructor.prototype.onPageListChange = function () {
  10752. _onPageListChange.apply(this, Array.prototype.slice.apply(arguments));
  10753. localStorage.setItem('pagesize', this.options.pageSize);
  10754. return false;
  10755. };
  10756. // 写入bootstrap-table默认配置
  10757. $.extend(true, $.fn.bootstrapTable.defaults, Table.defaults, defaults);
  10758. // 写入bootstrap-table column配置
  10759. $.extend($.fn.bootstrapTable.columnDefaults, Table.columnDefaults, columnDefaults);
  10760. // 写入bootstrap-table locale配置
  10761. $.extend($.fn.bootstrapTable.locales[Table.defaults.locale], {
  10762. formatCommonSearch: function () {
  10763. return __('Common search');
  10764. },
  10765. formatCommonSubmitButton: function () {
  10766. return __('Search');
  10767. },
  10768. formatCommonResetButton: function () {
  10769. return __('Reset');
  10770. },
  10771. formatCommonCloseButton: function () {
  10772. return __('Close');
  10773. },
  10774. formatCommonChoose: function () {
  10775. return __('Choose');
  10776. },
  10777. formatJumpto: function () {
  10778. return __('Go');
  10779. }
  10780. }, locales);
  10781. // 如果是iOS设备则判断是否启用卡片视图
  10782. if ($.fn.bootstrapTable.defaults.iosCardView && navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
  10783. Table.defaults.cardView = true;
  10784. $.fn.bootstrapTable.defaults.cardView = true;
  10785. }
  10786. if (typeof defaults.exportTypes != 'undefined') {
  10787. $.fn.bootstrapTable.defaults.exportTypes = defaults.exportTypes;
  10788. }
  10789. },
  10790. // 绑定事件
  10791. bindevent: function (table) {
  10792. //Bootstrap-table的父元素,包含table,toolbar,pagnation
  10793. var parenttable = table.closest('.bootstrap-table');
  10794. //Bootstrap-table配置
  10795. var options = table.bootstrapTable('getOptions');
  10796. //Bootstrap操作区
  10797. var toolbar = $(options.toolbar, parenttable);
  10798. //跨页提示按钮
  10799. var tipsBtn = $(".btn-selected-tips", parenttable);
  10800. if (tipsBtn.length === 0) {
  10801. tipsBtn = $('<a href="javascript:" class="btn btn-warning-light btn-selected-tips hide" data-animation="false" data-toggle="tooltip" data-title="' + __("Click to uncheck all") + '"><i class="fa fa-info-circle"></i> ' + __("Multiple selection mode: %s checked", "<b>0</b>") + '</a>').appendTo(toolbar);
  10802. }
  10803. //点击提示按钮
  10804. tipsBtn.off("click").on("click", function (e) {
  10805. table.trigger("uncheckbox");
  10806. table.bootstrapTable("refresh");
  10807. });
  10808. //当刷新表格时
  10809. table.on('uncheckbox', function (status, res, e) {
  10810. options.selectedIds = [];
  10811. options.selectedData = [];
  10812. tipsBtn.tooltip('hide');
  10813. tipsBtn.addClass('hide');
  10814. });
  10815. //表格加载出错时
  10816. table.on('load-error.bs.table', function (status, res, e) {
  10817. if (e.status === 0) {
  10818. return;
  10819. }
  10820. Toastr.error(__('Unknown data format'));
  10821. });
  10822. //当加载数据成功时
  10823. table.on('load-success.bs.table', function (e, data) {
  10824. if (typeof data.rows === 'undefined' && typeof data.code != 'undefined') {
  10825. Toastr.error(data.msg);
  10826. }
  10827. });
  10828. //当刷新表格时
  10829. table.on('refresh.bs.table', function (e, settings, data) {
  10830. $(Table.config.refreshbtn, toolbar).find(".fa").addClass("fa-spin");
  10831. //移除指定浮动弹窗
  10832. $(".layui-layer-autocontent").remove();
  10833. });
  10834. //当执行搜索时
  10835. table.on('search.bs.table common-search.bs.table', function (e, settings, data) {
  10836. table.trigger("uncheckbox");
  10837. });
  10838. if (options.dblClickToEdit) {
  10839. //当双击单元格时
  10840. table.on('dbl-click-row.bs.table', function (e, row, element, field) {
  10841. $(Table.config.editonebtn, element).trigger("click");
  10842. });
  10843. }
  10844. //渲染内容前
  10845. table.on('pre-body.bs.table', function (e, data) {
  10846. if (options.maintainSelected) {
  10847. $.each(data, function (i, row) {
  10848. row[options.stateField] = $.inArray(row[options.pk], options.selectedIds) > -1;
  10849. });
  10850. }
  10851. });
  10852. //当内容渲染完成后
  10853. table.on('post-body.bs.table', function (e, data) {
  10854. $(Table.config.refreshbtn, toolbar).find(".fa").removeClass("fa-spin");
  10855. if ($(Table.config.checkboxtd + ":first", table).find("input[type='checkbox'][data-index]").length > 0) {
  10856. //拖拽选择复选框
  10857. var posx, posy, dragdiv, drag = false, prepare = false;
  10858. var mousemove = function (e) {
  10859. if (drag) {
  10860. var left = Math.min(e.pageX, posx);
  10861. var top = Math.min(e.pageY, posy);
  10862. var width = Math.abs(posx - e.pageX);
  10863. var height = Math.abs(posy - e.pageY);
  10864. dragdiv.css({left: left + "px", top: top + "px", width: width + "px", height: height + "px"});
  10865. var dragrect = {x: left, y: top, width: width, height: height};
  10866. $(Table.config.checkboxtd, table).each(function () {
  10867. var checkbox = $("input:checkbox", this);
  10868. var tdrect = this.getBoundingClientRect();
  10869. tdrect.x += document.documentElement.scrollLeft;
  10870. tdrect.y += document.documentElement.scrollTop;
  10871. var td_min_x = tdrect.x;
  10872. var td_min_y = tdrect.y;
  10873. var td_max_x = tdrect.x + tdrect.width;
  10874. var td_max_y = tdrect.y + tdrect.height;
  10875. var drag_min_x = dragrect.x;
  10876. var drag_min_y = dragrect.y;
  10877. var drag_max_x = dragrect.x + dragrect.width;
  10878. var drag_max_y = dragrect.y + dragrect.height;
  10879. var overlapped = td_min_x <= drag_max_x && td_max_x >= drag_min_x && td_min_y <= drag_max_y && td_max_y >= drag_min_y;
  10880. if (overlapped) {
  10881. if (!$(this).hasClass("overlaped")) {
  10882. $(this).addClass("overlaped");
  10883. checkbox.trigger("click");
  10884. }
  10885. } else {
  10886. if ($(this).hasClass("overlaped")) {
  10887. $(this).removeClass("overlaped");
  10888. checkbox.trigger("click");
  10889. }
  10890. }
  10891. });
  10892. }
  10893. };
  10894. var selectstart = function () {
  10895. return false;
  10896. };
  10897. var mouseup = function () {
  10898. if (drag) {
  10899. $(document).off("mousemove", mousemove);
  10900. $(document).off("selectstart", selectstart);
  10901. dragdiv.remove();
  10902. }
  10903. drag = false;
  10904. prepare = false;
  10905. $(document.body).css({'MozUserSelect': '', 'webkitUserSelect': ''}).attr('unselectable', 'off');
  10906. };
  10907. $(Table.config.checkboxtd, table).on("mousedown", function (e) {
  10908. //禁止鼠标右键事件和文本框
  10909. if (e.button === 2 || $(e.target).is("input")) {
  10910. return false;
  10911. }
  10912. posx = e.pageX;
  10913. posy = e.pageY;
  10914. prepare = true;
  10915. }).on("mousemove", function (e) {
  10916. if (prepare && !drag) {
  10917. drag = true;
  10918. dragdiv = $("<div />");
  10919. dragdiv.css({position: 'absolute', width: 0, height: 0, border: "1px dashed blue", background: "#0029ff", left: e.pageX + "px", top: e.pageY + "px", opacity: .1});
  10920. dragdiv.appendTo(document.body);
  10921. $(document.body).css({'MozUserSelect': 'none', 'webkitUserSelect': 'none'}).attr('unselectable', 'on');
  10922. $(document).on("mousemove", mousemove).on("mouseup", mouseup).on("selectstart", selectstart);
  10923. if (options.dragCheckboxMultiselect) {
  10924. $(Table.config.checkboxtd, table).removeClass("overlaped");
  10925. }
  10926. }
  10927. });
  10928. }
  10929. });
  10930. var exportDataType = options.exportDataType;
  10931. // 处理选中筛选框后按钮的状态统一变更
  10932. table.on('check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table post-body.bs.table', function (e) {
  10933. var allIds = [];
  10934. $.each(table.bootstrapTable("getData"), function (i, item) {
  10935. allIds.push(typeof item[options.pk] != 'undefined' ? item[options.pk] : '');
  10936. });
  10937. var selectedIds = Table.api.selectedids(table, true),
  10938. selectedData = Table.api.selecteddata(table, true);
  10939. //开启分页checkbox分页记忆
  10940. if (options.maintainSelected) {
  10941. options.selectedIds = options.selectedIds.filter(function (element, index, self) {
  10942. return $.inArray(element, allIds) === -1;
  10943. }).concat(selectedIds);
  10944. options.selectedData = options.selectedData.filter(function (element, index, self) {
  10945. return $.inArray(element[options.pk], allIds) === -1;
  10946. }).concat(selectedData);
  10947. if (options.selectedIds.length > selectedIds.length) {
  10948. $("b", tipsBtn).text(options.selectedIds.length);
  10949. tipsBtn.removeClass('hide');
  10950. } else {
  10951. tipsBtn.addClass('hide');
  10952. }
  10953. } else {
  10954. options.selectedIds = selectedIds;
  10955. options.selectedData = selectedData;
  10956. }
  10957. //如果导出类型为auto时则自动判断
  10958. if (exportDataType === 'auto') {
  10959. options.exportDataType = selectedIds.length > 0 ? 'selected' : 'all';
  10960. if ($(".export .exporttips").length === 0) {
  10961. $(".export .dropdown-menu").prepend("<li class='exporttips alert alert-warning-light mb-0 no-border p-2'></li>")
  10962. }
  10963. $(".export .exporttips").html("导出记录:" + (selectedIds.length > 0 ? "选中" : "全部"));
  10964. }
  10965. $(Table.config.disabledbtn, toolbar).toggleClass('disabled', !options.selectedIds.length);
  10966. });
  10967. // 提交通用搜索时判断是否和Tabs筛选一致
  10968. table.on('common-search.bs.table', function (e, setting, query) {
  10969. var tabs = $('.panel-heading [data-field]', table.closest(".panel-intro"));
  10970. var field = tabs.data("field");
  10971. var value = $("li.active > a", tabs).data("value");
  10972. if (query.filter && typeof query.filter[field] !== 'undefined' && query.filter[field] != value) {
  10973. $("li", tabs).removeClass("active");
  10974. $("li > a[data-value='" + query.filter[field] + "']", tabs).parent().addClass("active");
  10975. }
  10976. });
  10977. // 绑定TAB事件
  10978. $('.panel-heading [data-field] a[data-toggle="tab"]', table.closest(".panel-intro")).on('shown.bs.tab', function (e) {
  10979. var field = $(this).closest("[data-field]").data("field");
  10980. var value = $(this).data("value");
  10981. var object = $("[name='" + field + "']", table.closest(".bootstrap-table").find(".commonsearch-table"));
  10982. if (object.prop('tagName') === "SELECT") {
  10983. $("option[value='" + value + "']", object).prop("selected", true);
  10984. } else {
  10985. object.val(value);
  10986. }
  10987. table.trigger("uncheckbox");
  10988. table.bootstrapTable('getOptions').totalRows = 0;
  10989. table.bootstrapTable('refresh', {pageNumber: 1});
  10990. return false;
  10991. });
  10992. // 修复重置事件
  10993. $("form", table.closest(".bootstrap-table").find(".commonsearch-table")).on('reset', function () {
  10994. setTimeout(function () {
  10995. // $('.panel-heading [data-field] li.active a[data-toggle="tab"]').trigger('shown.bs.tab');
  10996. }, 0);
  10997. $('.panel-heading [data-field] li', table.closest(".panel-intro")).removeClass('active');
  10998. $('.panel-heading [data-field] li:first', table.closest(".panel-intro")).addClass('active');
  10999. });
  11000. // 刷新按钮事件
  11001. toolbar.on('click', Table.config.refreshbtn, function () {
  11002. table.bootstrapTable('refresh');
  11003. });
  11004. // 添加按钮事件
  11005. toolbar.on('click', Table.config.addbtn, function () {
  11006. var ids = Table.api.selectedids(table);
  11007. var url = options.extend.add_url;
  11008. if (url.indexOf("{ids}") !== -1) {
  11009. url = Table.api.replaceurl(url, {ids: ids.length > 0 ? ids.join(",") : 0}, table);
  11010. }
  11011. Fast.api.open(url, $(this).data("original-title") || $(this).attr("title") || __('Add'), $(this).data() || {});
  11012. });
  11013. // 导入按钮事件
  11014. if ($(Table.config.importbtn, toolbar).length > 0) {
  11015. require(['upload'], function (Upload) {
  11016. Upload.api.upload($(Table.config.importbtn, toolbar), function (data, ret) {
  11017. Fast.api.ajax({
  11018. url: options.extend.import_url,
  11019. data: {file: data.url},
  11020. }, function (data, ret) {
  11021. table.trigger("uncheckbox");
  11022. table.bootstrapTable('refresh');
  11023. });
  11024. });
  11025. });
  11026. }
  11027. // 批量编辑按钮事件
  11028. toolbar.on('click', Table.config.editbtn, function () {
  11029. var that = this;
  11030. var ids = Table.api.selectedids(table);
  11031. if (ids.length > 10) {
  11032. return;
  11033. }
  11034. var title = $(that).data('title') || $(that).attr("title") || __('Edit');
  11035. var data = $(that).data() || {};
  11036. delete data.title;
  11037. //循环弹出多个编辑框
  11038. $.each(Table.api.selecteddata(table), function (index, row) {
  11039. var url = options.extend.edit_url;
  11040. row = $.extend({}, row ? row : {}, {ids: row[options.pk]});
  11041. url = Table.api.replaceurl(url, row, table);
  11042. Fast.api.open(url, typeof title === 'function' ? title.call(table, row) : title, data);
  11043. });
  11044. });
  11045. //清空回收站
  11046. $(document).on('click', Table.config.destroyallbtn, function () {
  11047. var that = this;
  11048. Layer.confirm(__('Are you sure you want to truncate?'), function () {
  11049. var url = $(that).data("url") ? $(that).data("url") : $(that).attr("href");
  11050. Fast.api.ajax(url, function () {
  11051. Layer.closeAll();
  11052. table.trigger("uncheckbox");
  11053. table.bootstrapTable('refresh');
  11054. }, function () {
  11055. Layer.closeAll();
  11056. });
  11057. });
  11058. return false;
  11059. });
  11060. //全部还原
  11061. $(document).on('click', Table.config.restoreallbtn, function () {
  11062. var that = this;
  11063. var url = $(that).data("url") ? $(that).data("url") : $(that).attr("href");
  11064. Fast.api.ajax(url, function () {
  11065. Layer.closeAll();
  11066. table.trigger("uncheckbox");
  11067. table.bootstrapTable('refresh');
  11068. }, function () {
  11069. Layer.closeAll();
  11070. });
  11071. return false;
  11072. });
  11073. //销毁或删除
  11074. $(document).on('click', Table.config.restoreonebtn + ',' + Table.config.destroyonebtn, function () {
  11075. var that = this;
  11076. var url = $(that).data("url") ? $(that).data("url") : $(that).attr("href");
  11077. var row = Table.api.getrowbyindex(table, $(that).data("row-index"));
  11078. Fast.api.ajax({
  11079. url: url,
  11080. data: {ids: row[options.pk]}
  11081. }, function () {
  11082. table.trigger("uncheckbox");
  11083. table.bootstrapTable('refresh');
  11084. });
  11085. return false;
  11086. });
  11087. // 批量操作按钮事件
  11088. toolbar.on('click', Table.config.multibtn, function () {
  11089. var ids = Table.api.selectedids(table);
  11090. Table.api.multi($(this).data("action"), ids, table, this);
  11091. });
  11092. // 批量删除按钮事件
  11093. toolbar.on('click', Table.config.delbtn, function () {
  11094. var that = this;
  11095. var ids = Table.api.selectedids(table);
  11096. Layer.confirm(
  11097. __('Are you sure you want to delete the %s selected item?', ids.length),
  11098. {icon: 3, title: __('Warning'), offset: 0, shadeClose: true, btn: [__('OK'), __('Cancel')]},
  11099. function (index) {
  11100. Table.api.multi("del", ids, table, that);
  11101. Layer.close(index);
  11102. }
  11103. );
  11104. });
  11105. // 拖拽排序
  11106. require(['dragsort'], function () {
  11107. //绑定拖动排序
  11108. $("tbody", table).dragsort({
  11109. itemSelector: 'tr:visible',
  11110. dragSelector: "a.btn-dragsort",
  11111. dragEnd: function (a, b) {
  11112. var element = $("a.btn-dragsort", this);
  11113. var data = table.bootstrapTable('getData');
  11114. var current = data[parseInt($(this).data("index"))];
  11115. var options = table.bootstrapTable('getOptions');
  11116. //改变的值和改变的ID集合
  11117. var ids = $.map($("tbody tr:visible", table), function (tr) {
  11118. return data[parseInt($(tr).data("index"))][options.pk];
  11119. });
  11120. var changeid = current[options.pk];
  11121. var pid = typeof current.pid != 'undefined' ? current.pid : '';
  11122. var params = {
  11123. url: table.bootstrapTable('getOptions').extend.dragsort_url,
  11124. data: {
  11125. ids: ids.join(','),
  11126. changeid: changeid,
  11127. pid: pid,
  11128. field: Table.config.dragsortfield,
  11129. orderway: options.sortOrder,
  11130. table: options.extend.table,
  11131. pk: options.pk
  11132. }
  11133. };
  11134. Fast.api.ajax(params, function (data, ret) {
  11135. var success = $(element).data("success") || $.noop;
  11136. if (typeof success === 'function') {
  11137. if (false === success.call(element, data, ret)) {
  11138. return false;
  11139. }
  11140. }
  11141. table.bootstrapTable('refresh');
  11142. }, function (data, ret) {
  11143. var error = $(element).data("error") || $.noop;
  11144. if (typeof error === 'function') {
  11145. if (false === error.call(element, data, ret)) {
  11146. return false;
  11147. }
  11148. }
  11149. table.bootstrapTable('refresh');
  11150. });
  11151. },
  11152. placeHolderTemplate: ""
  11153. });
  11154. });
  11155. table.on("click", "input[data-id][name='checkbox']", function (e) {
  11156. var ids = $(this).data("id");
  11157. table.bootstrapTable($(this).prop("checked") ? 'checkBy' : 'uncheckBy', {field: options.pk, values: [ids]});
  11158. });
  11159. table.on("click", "[data-id].btn-change", function (e) {
  11160. e.preventDefault();
  11161. var changer = $.proxy(function () {
  11162. Table.api.multi($(this).data("action") ? $(this).data("action") : '', [$(this).data("id")], table, this);
  11163. }, this);
  11164. if (typeof $(this).data("confirm") !== 'undefined') {
  11165. Layer.confirm($(this).data("confirm"), function (index) {
  11166. changer();
  11167. Layer.close(index);
  11168. });
  11169. } else {
  11170. changer();
  11171. }
  11172. });
  11173. table.on("click", "[data-id].btn-edit", function (e) {
  11174. e.preventDefault();
  11175. var ids = $(this).data("id");
  11176. var row = Table.api.getrowbyid(table, ids);
  11177. row.ids = ids;
  11178. var url = Table.api.replaceurl(options.extend.edit_url, row, table);
  11179. Fast.api.open(url, $(this).data("original-title") || $(this).attr("title") || __('Edit'), $(this).data() || {});
  11180. });
  11181. table.on("click", "[data-id].btn-del", function (e) {
  11182. e.preventDefault();
  11183. var id = $(this).data("id");
  11184. var that = this;
  11185. Layer.confirm(
  11186. __('Are you sure you want to delete this item?'),
  11187. {icon: 3, title: __('Warning'), shadeClose: true, btn: [__('OK'), __('Cancel')]},
  11188. function (index) {
  11189. Table.api.multi("del", id, table, that);
  11190. Layer.close(index);
  11191. }
  11192. );
  11193. });
  11194. table.on("mouseenter mouseleave", ".autocontent", function (e) {
  11195. var target = $(".autocontent-item", this).get(0);
  11196. if (!target) return;
  11197. if (e.type === 'mouseenter') {
  11198. if (target.scrollWidth > target.offsetWidth && $(".autocontent-caret", this).length === 0) {
  11199. $(this).append("<div class='autocontent-caret'><i class='fa fa-chevron-down'></div>");
  11200. }
  11201. } else {
  11202. $(".autocontent-caret", this).remove();
  11203. }
  11204. });
  11205. table.on("click mouseenter", ".autocontent-caret", function (e) {
  11206. var hover = $(this).prev().hasClass("autocontent-hover");
  11207. if (!hover && e.type === 'mouseenter') {
  11208. return;
  11209. }
  11210. var text = $(this).prev().text();
  11211. var tdrect = $(this).parent().get(0).getBoundingClientRect();
  11212. var index = Layer.open({id: 'autocontent', skin: 'layui-layer-fast layui-layer-autocontent', title: false, content: text, btn: false, anim: false, shade: 0, isOutAnim: false, area: 'auto', maxWidth: 450, maxHeight: 350, offset: [tdrect.y, tdrect.x]});
  11213. if (hover) {
  11214. $(document).one("mouseleave", "#layui-layer" + index, function () {
  11215. Layer.close(index);
  11216. });
  11217. }
  11218. var mousedown = function (e) {
  11219. if ($(e.target).closest(".layui-layer").length === 0) {
  11220. Layer.close(index);
  11221. $(document).off("mousedown", mousedown);
  11222. }
  11223. };
  11224. $(document).off("mousedown", mousedown).on("mousedown", mousedown);
  11225. });
  11226. //修复dropdown定位溢出的情况
  11227. if (options.fixDropdownPosition) {
  11228. var tableBody = table.closest(".fixed-table-body");
  11229. table.on('show.bs.dropdown fa.event.refreshdropdown', ".btn-group", function (e) {
  11230. var dropdownMenu = $(".dropdown-menu", this);
  11231. var btnGroup = $(this);
  11232. var isPullRight = dropdownMenu.hasClass("pull-right") || dropdownMenu.hasClass("dropdown-menu-right");
  11233. var left, top, position;
  11234. if (true || dropdownMenu.outerHeight() + btnGroup.outerHeight() > tableBody.outerHeight() - 41) {
  11235. position = 'fixed';
  11236. top = btnGroup.offset().top - $(window).scrollTop() + btnGroup.outerHeight();
  11237. if ((top + dropdownMenu.outerHeight()) > $(window).height()) {
  11238. top = btnGroup.offset().top - dropdownMenu.outerHeight() - 5;
  11239. }
  11240. left = isPullRight ? btnGroup.offset().left + btnGroup.outerWidth() - dropdownMenu.outerWidth() : btnGroup.offset().left;
  11241. }
  11242. if (left || top) {
  11243. dropdownMenu.css({
  11244. position: position, left: left, top: top, right: 'inherit'
  11245. });
  11246. }
  11247. });
  11248. var checkdropdown = function () {
  11249. if ($(".btn-group.open", table).length > 0 && $(".btn-group.open .dropdown-menu", table).css("position") == 'fixed') {
  11250. $(".btn-group.open", table).trigger("fa.event.refreshdropdown");
  11251. }
  11252. };
  11253. $(window).on("scroll", function () {
  11254. checkdropdown();
  11255. });
  11256. tableBody.on("scroll", function () {
  11257. checkdropdown();
  11258. });
  11259. }
  11260. var id = table.attr("id");
  11261. Table.list[id] = table;
  11262. return table;
  11263. },
  11264. // 批量操作请求
  11265. multi: function (action, ids, table, element) {
  11266. var options = table.bootstrapTable('getOptions');
  11267. var data = element ? $(element).data() : {};
  11268. ids = ($.isArray(ids) ? ids.join(",") : ids);
  11269. var url = typeof data.url !== "undefined" ? data.url : (action == "del" ? options.extend.del_url : options.extend.multi_url);
  11270. var params = typeof data.params !== "undefined" ? (typeof data.params == 'object' ? $.param(data.params) : data.params) : '';
  11271. options = {url: url, data: {action: action, ids: ids, params: params}};
  11272. Fast.api.ajax(options, function (data, ret) {
  11273. table.trigger("uncheckbox");
  11274. var success = $(element).data("success") || $.noop;
  11275. if (typeof success === 'function') {
  11276. if (false === success.call(element, data, ret)) {
  11277. return false;
  11278. }
  11279. }
  11280. table.bootstrapTable('refresh');
  11281. }, function (data, ret) {
  11282. var error = $(element).data("error") || $.noop;
  11283. if (typeof error === 'function') {
  11284. if (false === error.call(element, data, ret)) {
  11285. return false;
  11286. }
  11287. }
  11288. });
  11289. },
  11290. // 单元格元素事件
  11291. events: {
  11292. operate: {
  11293. 'click .btn-editone': function (e, value, row, index) {
  11294. e.stopPropagation();
  11295. e.preventDefault();
  11296. var table = $(this).closest('table');
  11297. var options = table.bootstrapTable('getOptions');
  11298. var ids = row[options.pk];
  11299. row = $.extend({}, row ? row : {}, {ids: ids});
  11300. var url = options.extend.edit_url;
  11301. Fast.api.open(Table.api.replaceurl(url, row, table), $(this).data("original-title") || $(this).attr("title") || __('Edit'), $(this).data() || {});
  11302. },
  11303. 'click .btn-delone': function (e, value, row, index) {
  11304. e.stopPropagation();
  11305. e.preventDefault();
  11306. var that = this;
  11307. var top = $(that).offset().top - $(window).scrollTop();
  11308. var left = $(that).offset().left - $(window).scrollLeft() - 260;
  11309. if (top + 154 > $(window).height()) {
  11310. top = top - 154;
  11311. }
  11312. if ($(window).width() < 480) {
  11313. top = left = undefined;
  11314. }
  11315. Layer.confirm(
  11316. __('Are you sure you want to delete this item?'),
  11317. {icon: 3, title: __('Warning'), offset: [top, left], shadeClose: true, btn: [__('OK'), __('Cancel')]},
  11318. function (index) {
  11319. var table = $(that).closest('table');
  11320. var options = table.bootstrapTable('getOptions');
  11321. Table.api.multi("del", row[options.pk], table, that);
  11322. Layer.close(index);
  11323. }
  11324. );
  11325. }
  11326. },//单元格图片预览
  11327. image: {
  11328. 'click .img-center': function (e, value, row, index) {
  11329. var data = [];
  11330. value = value === null ? '' : value.toString();
  11331. var arr = value != '' ? value.split(",") : [];
  11332. var url;
  11333. $.each(arr, function (index, value) {
  11334. url = Fast.api.cdnurl(value);
  11335. data.push({
  11336. src: url,
  11337. thumb: url.match(/^(\/|data:image\\)/) ? url : url + Config.upload.thumbstyle
  11338. });
  11339. });
  11340. Layer.photos({
  11341. photos: {
  11342. "start": $(this).parent().index(),
  11343. "data": data
  11344. },
  11345. anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)
  11346. });
  11347. },
  11348. }
  11349. },
  11350. // 单元格数据格式化
  11351. formatter: {
  11352. icon: function (value, row, index) {
  11353. value = value === null ? '' : value.toString();
  11354. value = value.indexOf(" ") > -1 ? value : "fa fa-" + value;
  11355. //渲染fontawesome图标
  11356. return '<i class="' + value + '"></i> ' + value;
  11357. },
  11358. image: function (value, row, index) {
  11359. return Table.api.formatter.images.call(this, value, row, index);
  11360. },
  11361. images: function (value, row, index) {
  11362. value = value == null || value.length === 0 ? '' : value.toString();
  11363. var classname = typeof this.classname !== 'undefined' ? this.classname : 'img-sm img-center';
  11364. var arr = value !== '' ? (value.indexOf('data:image/') === -1 ? value.split(',') : [value]) : [];
  11365. var html = [];
  11366. var url;
  11367. $.each(arr, function (i, value) {
  11368. value = value ? value : '/assets/img/blank.gif';
  11369. url = Fast.api.cdnurl(value, true);
  11370. //匹配本地、data:image、或已包含标识符首字符
  11371. url = !Config.upload.thumbstyle || url.match(/^(\/|data:image\/)/) || url.indexOf(Config.upload.thumbstyle.substring(0, 1)) > -1 ? url : url + Config.upload.thumbstyle;
  11372. html.push('<a href="javascript:"><img class="' + classname + '" src="' + url + '" /></a>');
  11373. });
  11374. return html.join(' ');
  11375. },
  11376. file: function (value, row, index) {
  11377. Table.api.formatter.files.call(this, value, row, index);
  11378. },
  11379. files: function (value, row, index) {
  11380. value = value == null || value.length === 0 ? '' : value.toString();
  11381. var classname = typeof this.classname !== 'undefined' ? this.classname : 'img-sm img-center';
  11382. var arr = value !== '' ? (value.indexOf('data:image/') === -1 ? value.split(',') : [value]) : [];
  11383. var html = [];
  11384. var suffix, url;
  11385. $.each(arr, function (i, value) {
  11386. value = Fast.api.cdnurl(value, true);
  11387. suffix = /[\.]?([a-zA-Z0-9]+)$/.exec(value);
  11388. suffix = suffix ? suffix[1] : 'file';
  11389. url = Fast.api.fixurl("ajax/icon?suffix=" + suffix);
  11390. html.push('<a href="' + value + '" target="_blank"><img src="' + url + '" class="' + classname + '" width="30" height="30"></a>');
  11391. });
  11392. return html.join(' ');
  11393. },
  11394. content: function (value, row, index) {
  11395. var width = this.width != undefined ? (this.width.toString().match(/^\d+$/) ? this.width + "px" : this.width) : "250px";
  11396. var hover = this.hover != undefined && this.hover ? "autocontent-hover" : "";
  11397. return "<div class='autocontent-item " + hover + "' style='white-space: nowrap; text-overflow:ellipsis; overflow: hidden; max-width:" + width + ";'>" + value + "</div>";
  11398. },
  11399. status: function (value, row, index) {
  11400. var custom = {normal: 'success', hidden: 'gray', deleted: 'danger', locked: 'info'};
  11401. if (typeof this.custom !== 'undefined') {
  11402. custom = $.extend(custom, this.custom);
  11403. }
  11404. this.custom = custom;
  11405. this.icon = 'fa fa-circle';
  11406. return Table.api.formatter.normal.call(this, value, row, index);
  11407. },
  11408. normal: function (value, row, index) {
  11409. var colorArr = ["primary", "success", "danger", "warning", "info", "gray", "red", "yellow", "aqua", "blue", "navy", "teal", "olive", "lime", "fuchsia", "purple", "maroon"];
  11410. var custom = {};
  11411. if (typeof this.custom !== 'undefined') {
  11412. custom = $.extend(custom, this.custom);
  11413. }
  11414. value = value == null || value.length === 0 ? '' : value.toString();
  11415. var keys = typeof this.searchList === 'object' ? Object.keys(this.searchList) : [];
  11416. var index = keys.indexOf(value);
  11417. var color = value && typeof custom[value] !== 'undefined' ? custom[value] : null;
  11418. var display = index > -1 ? this.searchList[value] : null;
  11419. var icon = typeof this.icon !== 'undefined' ? this.icon : null;
  11420. if (!color) {
  11421. color = index > -1 && typeof colorArr[index] !== 'undefined' ? colorArr[index] : 'primary';
  11422. }
  11423. if (!display) {
  11424. display = __(value.charAt(0).toUpperCase() + value.slice(1));
  11425. }
  11426. var html = '<span class="text-' + color + '">' + (icon ? '<i class="' + icon + '"></i> ' : '') + display + '</span>';
  11427. if (this.operate != false) {
  11428. html = '<a href="javascript:;" class="searchit" data-toggle="tooltip" title="' + __('Click to search %s', display) + '" data-field="' + this.field + '" data-value="' + value + '">' + html + '</a>';
  11429. }
  11430. return html;
  11431. },
  11432. toggle: function (value, row, index) {
  11433. var table = this.table;
  11434. var options = table ? table.bootstrapTable('getOptions') : {};
  11435. var pk = options.pk || "id";
  11436. var color = typeof this.color !== 'undefined' ? this.color : 'success';
  11437. var yes = typeof this.yes !== 'undefined' ? this.yes : 1;
  11438. var no = typeof this.no !== 'undefined' ? this.no : 0;
  11439. var url = typeof this.url !== 'undefined' ? this.url : '';
  11440. var confirm = '';
  11441. var disable = false;
  11442. if (typeof this.confirm !== "undefined") {
  11443. confirm = typeof this.confirm === "function" ? this.confirm.call(this, value, row, index) : this.confirm;
  11444. }
  11445. if (typeof this.disable !== "undefined") {
  11446. disable = typeof this.disable === "function" ? this.disable.call(this, value, row, index) : this.disable;
  11447. }
  11448. return "<a href='javascript:;' data-toggle='tooltip' title='" + __('Click to toggle') + "' class='btn-change " + (disable ? 'btn disabled no-padding' : '') + "' data-index='" + index + "' data-id='"
  11449. + row[pk] + "' " + (url ? "data-url='" + url + "'" : "") + (confirm ? "data-confirm='" + confirm + "'" : "") + " data-params='" + this.field + "=" + (value == yes ? no : yes) + "'><i class='fa fa-toggle-on text-success text-" + color + " " + (value == yes ? '' : 'fa-flip-horizontal text-gray') + " fa-2x'></i></a>";
  11450. },
  11451. url: function (value, row, index) {
  11452. value = value == null || value.length === 0 ? '' : value.toString();
  11453. return '<div class="input-group input-group-sm" style="width:250px;margin:0 auto;"><input type="text" class="form-control input-sm" value="' + value + '"><span class="input-group-btn input-group-sm"><a href="' + value + '" target="_blank" class="btn btn-default btn-sm"><i class="fa fa-link"></i></a></span></div>';
  11454. },
  11455. search: function (value, row, index) {
  11456. var field = this.field;
  11457. if (typeof this.customField !== 'undefined' && typeof row[this.customField] !== 'undefined') {
  11458. value = row[this.customField];
  11459. field = this.customField;
  11460. }
  11461. return '<a href="javascript:;" class="searchit" data-toggle="tooltip" title="' + __('Click to search %s', value) + '" data-field="' + field + '" data-value="' + value + '">' + value + '</a>';
  11462. },
  11463. addtabs: function (value, row, index) {
  11464. var url = Table.api.replaceurl(this.url || '', row, this.table);
  11465. var title = this.atitle ? this.atitle : __("Search %s", value);
  11466. return '<a href="' + Fast.api.fixurl(url) + '" class="addtabsit" data-value="' + value + '" title="' + title + '">' + value + '</a>';
  11467. },
  11468. dialog: function (value, row, index) {
  11469. var url = Table.api.replaceurl(this.url || '', row, this.table);
  11470. var title = this.atitle ? this.atitle : __("View %s", value);
  11471. return '<a href="' + Fast.api.fixurl(url) + '" class="dialogit" data-value="' + value + '" title="' + title + '">' + value + '</a>';
  11472. },
  11473. flag: function (value, row, index) {
  11474. var that = this;
  11475. value = value == null || value.length === 0 ? '' : value.toString();
  11476. var colorArr = {index: 'success', hot: 'warning', recommend: 'danger', 'new': 'info'};
  11477. //如果字段列有定义custom
  11478. if (typeof this.custom !== 'undefined') {
  11479. colorArr = $.extend(colorArr, this.custom);
  11480. }
  11481. var field = this.field;
  11482. if (typeof this.customField !== 'undefined' && typeof row[this.customField] !== 'undefined') {
  11483. value = row[this.customField];
  11484. field = this.customField;
  11485. }
  11486. if (typeof that.searchList === 'object' && typeof that.custom === 'undefined') {
  11487. var i = 0;
  11488. var searchValues = Object.keys(colorArr).map(function (e) {
  11489. return colorArr[e];
  11490. });
  11491. $.each(that.searchList, function (key, val) {
  11492. if (typeof colorArr[key] == 'undefined') {
  11493. colorArr[key] = searchValues[i];
  11494. i = typeof searchValues[i + 1] === 'undefined' ? 0 : i + 1;
  11495. }
  11496. });
  11497. }
  11498. //渲染Flag
  11499. var html = [];
  11500. var arr = value !== '' ? value.split(',') : [];
  11501. var color, display, label;
  11502. $.each(arr, function (i, value) {
  11503. value = value == null || value.length === 0 ? '' : value.toString();
  11504. if (value === '')
  11505. return true;
  11506. color = value && typeof colorArr[value] !== 'undefined' ? colorArr[value] : 'primary';
  11507. display = typeof that.searchList !== 'undefined' && typeof that.searchList[value] !== 'undefined' ? that.searchList[value] : __(value.charAt(0).toUpperCase() + value.slice(1));
  11508. label = '<span class="label label-' + color + '">' + display + '</span>';
  11509. if (that.operate) {
  11510. html.push('<a href="javascript:;" class="searchit" data-toggle="tooltip" title="' + __('Click to search %s', display) + '" data-field="' + field + '" data-value="' + value + '">' + label + '</a>');
  11511. } else {
  11512. html.push(label);
  11513. }
  11514. });
  11515. return html.join(' ');
  11516. },
  11517. label: function (value, row, index) {
  11518. return Table.api.formatter.flag.call(this, value, row, index);
  11519. },
  11520. datetime: function (value, row, index) {
  11521. var datetimeFormat = typeof this.datetimeFormat === 'undefined' ? 'YYYY-MM-DD HH:mm:ss' : this.datetimeFormat;
  11522. if (isNaN(value)) {
  11523. return value ? Moment(value).format(datetimeFormat) : __('None');
  11524. } else {
  11525. return value ? Moment(parseInt(value) * 1000).format(datetimeFormat) : __('None');
  11526. }
  11527. },
  11528. operate: function (value, row, index) {
  11529. var table = this.table;
  11530. // 操作配置
  11531. var options = table ? table.bootstrapTable('getOptions') : {};
  11532. // 默认按钮组
  11533. var buttons = $.extend([], this.buttons || []);
  11534. // 所有按钮名称
  11535. var names = [];
  11536. buttons.forEach(function (item) {
  11537. names.push(item.name);
  11538. });
  11539. if (options.extend.dragsort_url !== '' && names.indexOf('dragsort') === -1) {
  11540. buttons.push(Table.button.dragsort);
  11541. }
  11542. if (options.extend.edit_url !== '' && names.indexOf('edit') === -1) {
  11543. Table.button.edit.url = options.extend.edit_url;
  11544. buttons.push(Table.button.edit);
  11545. }
  11546. if (options.extend.del_url !== '' && names.indexOf('del') === -1) {
  11547. buttons.push(Table.button.del);
  11548. }
  11549. return Table.api.buttonlink(this, buttons, value, row, index, 'operate');
  11550. }
  11551. ,
  11552. buttons: function (value, row, index) {
  11553. // 默认按钮组
  11554. var buttons = $.extend([], this.buttons || []);
  11555. return Table.api.buttonlink(this, buttons, value, row, index, 'buttons');
  11556. }
  11557. },
  11558. buttonlink: function (column, buttons, value, row, index, type) {
  11559. var table = column.table;
  11560. column.clickToSelect = false;
  11561. type = typeof type === 'undefined' ? 'buttons' : type;
  11562. var options = table ? table.bootstrapTable('getOptions') : {};
  11563. var html = [];
  11564. var hidden, visible, disable, url, classname, icon, text, title, refresh, confirm, extend,
  11565. dropdown, link;
  11566. var fieldIndex = column.fieldIndex;
  11567. var dropdowns = {};
  11568. $.each(buttons, function (i, j) {
  11569. if (type === 'operate') {
  11570. if (j.name === 'dragsort' && typeof row[Table.config.dragsortfield] === 'undefined') {
  11571. return true;
  11572. }
  11573. if (['add', 'edit', 'del', 'multi', 'dragsort'].indexOf(j.name) > -1 && !options.extend[j.name + "_url"]) {
  11574. return true;
  11575. }
  11576. }
  11577. var attr = table.data(type + "-" + j.name);
  11578. if (typeof attr === 'undefined' || attr) {
  11579. hidden = typeof j.hidden === 'function' ? j.hidden.call(table, row, j) : (typeof j.hidden !== 'undefined' ? j.hidden : false);
  11580. if (hidden) {
  11581. return true;
  11582. }
  11583. visible = typeof j.visible === 'function' ? j.visible.call(table, row, j) : (typeof j.visible !== 'undefined' ? j.visible : true);
  11584. if (!visible) {
  11585. return true;
  11586. }
  11587. dropdown = j.dropdown ? j.dropdown : '';
  11588. url = j.url ? j.url : '';
  11589. url = typeof url === 'function' ? url.call(table, row, j) : (url ? Fast.api.fixurl(Table.api.replaceurl(url, row, table)) : 'javascript:;');
  11590. classname = j.classname ? j.classname : (dropdown ? 'btn-' + name + 'one' : 'btn-primary btn-' + name + 'one');
  11591. icon = j.icon ? j.icon : '';
  11592. text = typeof j.text === 'function' ? j.text.call(table, row, j) : j.text ? j.text : '';
  11593. title = typeof j.title === 'function' ? j.title.call(table, row, j) : j.title ? j.title : text;
  11594. refresh = j.refresh ? 'data-refresh="' + j.refresh + '"' : '';
  11595. confirm = typeof j.confirm === 'function' ? j.confirm.call(table, row, j) : (typeof j.confirm !== 'undefined' ? j.confirm : false);
  11596. confirm = confirm ? 'data-confirm="' + confirm + '"' : '';
  11597. extend = typeof j.extend === 'function' ? j.extend.call(table, row, j) : (typeof j.extend !== 'undefined' ? j.extend : '');
  11598. disable = typeof j.disable === 'function' ? j.disable.call(table, row, j) : (typeof j.disable !== 'undefined' ? j.disable : false);
  11599. if (disable) {
  11600. classname = classname + ' disabled';
  11601. }
  11602. link = '<a href="' + url + '" class="' + classname + '" ' + (confirm ? confirm + ' ' : '') + (refresh ? refresh + ' ' : '') + extend + ' title="' + title + '" data-table-id="' + (table ? table.attr("id") : '') + '" data-field-index="' + fieldIndex + '" data-row-index="' + index + '" data-button-index="' + i + '"><i class="' + icon + '"></i>' + (text ? ' ' + text : '') + '</a>';
  11603. if (dropdown) {
  11604. if (typeof dropdowns[dropdown] == 'undefined') {
  11605. dropdowns[dropdown] = [];
  11606. }
  11607. dropdowns[dropdown].push(link);
  11608. } else {
  11609. html.push(link);
  11610. }
  11611. }
  11612. });
  11613. if (!$.isEmptyObject(dropdowns)) {
  11614. var dropdownHtml = [];
  11615. $.each(dropdowns, function (i, j) {
  11616. dropdownHtml.push('<div class="btn-group"><button type="button" class="btn btn-primary dropdown-toggle btn-xs" data-toggle="dropdown">' + i + '</button><button type="button" class="btn btn-primary dropdown-toggle btn-xs" data-toggle="dropdown"><span class="caret"></span></button><ul class="dropdown-menu dropdown-menu-right"><li>' + j.join('</li><li>') + '</li></ul></div>');
  11617. });
  11618. html.unshift(dropdownHtml.join(' '));
  11619. }
  11620. return html.join(' ');
  11621. },
  11622. //替换URL中的数据
  11623. replaceurl: function (url, row, table) {
  11624. var options = table ? table.bootstrapTable('getOptions') : null;
  11625. var ids = options ? row[options.pk] : 0;
  11626. row.ids = ids ? ids : (typeof row.ids !== 'undefined' ? row.ids : 0);
  11627. url = url == null || url.length === 0 ? '' : url.toString();
  11628. //自动添加ids参数
  11629. url = !url.match(/(?=([?&]ids=)|(\/ids\/)|(\{ids}))/i) ?
  11630. url + (url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + '{ids}' : url;
  11631. url = url.replace(/\{(.*?)\}/gi, function (matched) {
  11632. matched = matched.substring(1, matched.length - 1);
  11633. if (matched.indexOf(".") !== -1) {
  11634. var temp = row;
  11635. var arr = matched.split(/\./);
  11636. for (var i = 0; i < arr.length; i++) {
  11637. if (typeof temp[arr[i]] !== 'undefined') {
  11638. temp = temp[arr[i]];
  11639. }
  11640. }
  11641. return typeof temp === 'object' ? '' : temp;
  11642. }
  11643. return row[matched];
  11644. });
  11645. return url;
  11646. },
  11647. // 获取选中的条目ID集合
  11648. selectedids: function (table, current) {
  11649. var options = table.bootstrapTable('getOptions');
  11650. //如果有设置翻页记忆模式
  11651. if (!current && options.maintainSelected) {
  11652. return options.selectedIds;
  11653. }
  11654. return $.map(table.bootstrapTable('getSelections'), function (row) {
  11655. return row[options.pk];
  11656. });
  11657. },
  11658. //获取选中的数据
  11659. selecteddata: function (table, current) {
  11660. var options = table.bootstrapTable('getOptions');
  11661. //如果有设置翻页记忆模式
  11662. if (!current && options.maintainSelected) {
  11663. return options.selectedData;
  11664. }
  11665. return table.bootstrapTable('getSelections');
  11666. },
  11667. // 切换复选框状态
  11668. toggleattr: function (table) {
  11669. $("input[type='checkbox']", table).trigger('click');
  11670. },
  11671. // 根据行索引获取行数据
  11672. getrowdata: function (table, index) {
  11673. index = parseInt(index);
  11674. var data = table.bootstrapTable('getData');
  11675. return typeof data[index] !== 'undefined' ? data[index] : null;
  11676. },
  11677. // 根据行索引获取行数据
  11678. getrowbyindex: function (table, index) {
  11679. return Table.api.getrowdata(table, index);
  11680. },
  11681. // 根据主键ID获取行数据
  11682. getrowbyid: function (table, id) {
  11683. var row = {};
  11684. var options = table.bootstrapTable("getOptions");
  11685. $.each(Table.api.selecteddata(table), function (i, j) {
  11686. if (j[options.pk] == id) {
  11687. row = j;
  11688. return false;
  11689. }
  11690. });
  11691. return row;
  11692. }
  11693. },
  11694. };
  11695. return Table;
  11696. });
  11697. // jQuery List DragSort v0.5.2
  11698. // Website: http://dragsort.codeplex.com/
  11699. // License: http://dragsort.codeplex.com/license
  11700. (function($) {
  11701. $.fn.dragsort = function(options) {
  11702. if (options == "destroy") {
  11703. $(this.selector).trigger("dragsort-uninit");
  11704. return;
  11705. }
  11706. var opts = $.extend({}, $.fn.dragsort.defaults, options);
  11707. var lists = [];
  11708. var list = null, lastPos = null;
  11709. this.each(function(i, cont) {
  11710. //if list container is table, the browser automatically wraps rows in tbody if not specified so change list container to tbody so that children returns rows as user expected
  11711. if ($(cont).is("table") && $(cont).children().length == 1 && $(cont).children().is("tbody"))
  11712. cont = $(cont).children().get(0);
  11713. var newList = {
  11714. draggedItem: null,
  11715. placeHolderItem: null,
  11716. pos: null,
  11717. offset: null,
  11718. offsetLimit: null,
  11719. scroll: null,
  11720. container: cont,
  11721. init: function() {
  11722. //set options to default values if not set
  11723. opts.tagName = opts.tagName == "" ? ($(this.container).children().length == 0 ? "li" : $(this.container).children().get(0).tagName.toLowerCase()) : opts.tagName;
  11724. if (opts.itemSelector == "")
  11725. opts.itemSelector = opts.tagName;
  11726. if (opts.dragSelector == "")
  11727. opts.dragSelector = opts.tagName;
  11728. if (opts.placeHolderTemplate == "")
  11729. opts.placeHolderTemplate = "<" + opts.tagName + ">&nbsp;</" + opts.tagName + ">";
  11730. //listidx allows reference back to correct list variable instance
  11731. $(this.container).attr("data-listidx", i).mousedown(this.grabItem).bind("dragsort-uninit", this.uninit);
  11732. this.styleDragHandlers(true);
  11733. },
  11734. uninit: function() {
  11735. var list = lists[$(this).attr("data-listidx")];
  11736. $(list.container).unbind("mousedown", list.grabItem).unbind("dragsort-uninit");
  11737. list.styleDragHandlers(false);
  11738. },
  11739. getItems: function() {
  11740. return $(this.container).children(opts.itemSelector);
  11741. },
  11742. styleDragHandlers: function(cursor) {
  11743. this.getItems().map(function() { return $(this).is(opts.dragSelector) ? this : $(this).find(opts.dragSelector).get(); }).css("cursor", cursor ? "pointer" : "");
  11744. },
  11745. grabItem: function(e) {
  11746. var list = lists[$(this).attr("data-listidx")];
  11747. var item = $(e.target).closest("[data-listidx] > " + opts.tagName).get(0);
  11748. var insideMoveableItem = list.getItems().filter(function() { return this == item; }).length > 0;
  11749. //if not left click or if clicked on excluded element (e.g. text box) or not a moveable list item return
  11750. if (e.which != 1 || $(e.target).is(opts.dragSelectorExclude) || $(e.target).closest(opts.dragSelectorExclude).length > 0 || !insideMoveableItem)
  11751. return;
  11752. //prevents selection, stops issue on Fx where dragging hyperlink doesn't work and on IE where it triggers mousemove even though mouse hasn't moved,
  11753. //does also stop being able to click text boxes hence dragging on text boxes by default is disabled in dragSelectorExclude
  11754. //e.preventDefault();
  11755. //change cursor to move while dragging
  11756. var dragHandle = e.target;
  11757. while (!$(dragHandle).is(opts.dragSelector)) {
  11758. if (dragHandle == this) return;
  11759. dragHandle = dragHandle.parentNode;
  11760. }
  11761. $(dragHandle).attr("data-cursor", $(dragHandle).css("cursor"));
  11762. $(dragHandle).css("cursor", "move");
  11763. //on mousedown wait for movement of mouse before triggering dragsort script (dragStart) to allow clicking of hyperlinks to work
  11764. var listElem = this;
  11765. var trigger = function() {
  11766. list.dragStart.call(listElem, e);
  11767. $(list.container).unbind("mousemove", trigger);
  11768. };
  11769. $(list.container).mousemove(trigger).mouseup(function() { $(list.container).unbind("mousemove", trigger); $(dragHandle).css("cursor", $(dragHandle).attr("data-cursor")); });
  11770. },
  11771. dragStart: function(e) {
  11772. if (list != null && list.draggedItem != null)
  11773. list.dropItem();
  11774. list = lists[$(this).attr("data-listidx")];
  11775. list.draggedItem = $(e.target).closest("[data-listidx] > " + opts.tagName)
  11776. //record current position so on dragend we know if the dragged item changed position or not, not using getItems to allow dragsort to restore dragged item to original location in relation to fixed items
  11777. list.draggedItem.attr("data-origpos", $(this).attr("data-listidx") + "-" + $(list.container).children().index(list.draggedItem));
  11778. //calculate mouse offset relative to draggedItem
  11779. var mt = parseInt(list.draggedItem.css("marginTop"));
  11780. var ml = parseInt(list.draggedItem.css("marginLeft"));
  11781. list.offset = list.draggedItem.offset();
  11782. list.offset.top = e.pageY - list.offset.top + (isNaN(mt) ? 0 : mt) - 1;
  11783. list.offset.left = e.pageX - list.offset.left + (isNaN(ml) ? 0 : ml) - 1;
  11784. //calculate box the dragged item can't be dragged outside of
  11785. if (!opts.dragBetween) {
  11786. var containerHeight = $(list.container).outerHeight() == 0 ? Math.max(1, Math.round(0.5 + list.getItems().length * list.draggedItem.outerWidth() / $(list.container).outerWidth())) * list.draggedItem.outerHeight() : $(list.container).outerHeight();
  11787. list.offsetLimit = $(list.container).offset();
  11788. list.offsetLimit.right = list.offsetLimit.left + $(list.container).outerWidth() - list.draggedItem.outerWidth();
  11789. list.offsetLimit.bottom = list.offsetLimit.top + containerHeight - list.draggedItem.outerHeight();
  11790. }
  11791. //create placeholder item
  11792. var h = list.draggedItem.height();
  11793. var w = list.draggedItem.width();
  11794. if (opts.tagName == "tr") {
  11795. list.draggedItem.children().each(function() { $(this).width($(this).width()); });
  11796. list.placeHolderItem = list.draggedItem.clone().attr("data-placeholder", true);
  11797. list.draggedItem.after(list.placeHolderItem);
  11798. //list.placeHolderItem.children().each(function() { $(this).css({ borderWidth:0, width: $(this).width() + 1, height: $(this).height() + 1 }).html("&nbsp;"); });
  11799. list.placeHolderItem.children().each(function() { $(this).html("&nbsp;"); });
  11800. } else {
  11801. list.draggedItem.after(opts.placeHolderTemplate);
  11802. list.placeHolderItem = list.draggedItem.next().css({ height: h, width: w }).attr("data-placeholder", true);
  11803. }
  11804. if (opts.tagName == "td") {
  11805. var listTable = list.draggedItem.closest("table").get(0);
  11806. $("<table id='" + listTable.id + "' style='border-width: 0px;' class='dragSortItem " + listTable.className + "'><tr></tr></table>").appendTo("body").children().append(list.draggedItem);
  11807. }
  11808. //style draggedItem while dragging
  11809. var orig = list.draggedItem.attr("style");
  11810. list.draggedItem.attr("data-origstyle", orig ? orig : "");
  11811. list.draggedItem.css({ position: "absolute", opacity: 0.8, "z-index": 999, height: h, width: w });
  11812. //auto-scroll setup
  11813. list.scroll = { moveX: 0, moveY: 0, maxX: $(document).width() - $(window).width(), maxY: $(document).height() - $(window).height() };
  11814. list.scroll.scrollY = window.setInterval(function() {
  11815. if (opts.scrollContainer != window) {
  11816. $(opts.scrollContainer).scrollTop($(opts.scrollContainer).scrollTop() + list.scroll.moveY);
  11817. return;
  11818. }
  11819. var t = $(opts.scrollContainer).scrollTop();
  11820. if (list.scroll.moveY > 0 && t < list.scroll.maxY || list.scroll.moveY < 0 && t > 0) {
  11821. $(opts.scrollContainer).scrollTop(t + list.scroll.moveY);
  11822. list.draggedItem.css("top", list.draggedItem.offset().top + list.scroll.moveY + 1);
  11823. }
  11824. }, 10);
  11825. list.scroll.scrollX = window.setInterval(function() {
  11826. if (opts.scrollContainer != window) {
  11827. $(opts.scrollContainer).scrollLeft($(opts.scrollContainer).scrollLeft() + list.scroll.moveX);
  11828. return;
  11829. }
  11830. var l = $(opts.scrollContainer).scrollLeft();
  11831. if (list.scroll.moveX > 0 && l < list.scroll.maxX || list.scroll.moveX < 0 && l > 0) {
  11832. $(opts.scrollContainer).scrollLeft(l + list.scroll.moveX);
  11833. list.draggedItem.css("left", list.draggedItem.offset().left + list.scroll.moveX + 1);
  11834. }
  11835. }, 10);
  11836. //misc
  11837. $(lists).each(function(i, l) { l.createDropTargets(); l.buildPositionTable(); });
  11838. list.setPos(e.pageX, e.pageY);
  11839. $(document).bind("mousemove", list.swapItems);
  11840. $(document).bind("mouseup", list.dropItem);
  11841. if (opts.scrollContainer != window)
  11842. $(window).bind("wheel", list.wheel);
  11843. },
  11844. //set position of draggedItem
  11845. setPos: function(x, y) {
  11846. //remove mouse offset so mouse cursor remains in same place on draggedItem instead of top left corner
  11847. var top = y - this.offset.top;
  11848. var left = x - this.offset.left;
  11849. //limit top, left to within box draggedItem can't be dragged outside of
  11850. if (!opts.dragBetween) {
  11851. top = Math.min(this.offsetLimit.bottom, Math.max(top, this.offsetLimit.top));
  11852. left = Math.min(this.offsetLimit.right, Math.max(left, this.offsetLimit.left));
  11853. }
  11854. //adjust top & left calculations to parent offset
  11855. var parent = this.draggedItem.offsetParent().not("body").offset(); //offsetParent returns body even when it's static, if not static offset is only factoring margin
  11856. if (parent != null) {
  11857. top -= parent.top;
  11858. left -= parent.left;
  11859. }
  11860. //set x or y auto-scroll amount
  11861. if (opts.scrollContainer == window) {
  11862. y -= $(window).scrollTop();
  11863. x -= $(window).scrollLeft();
  11864. y = Math.max(0, y - $(window).height() + 5) + Math.min(0, y - 5);
  11865. x = Math.max(0, x - $(window).width() + 5) + Math.min(0, x - 5);
  11866. } else {
  11867. var cont = $(opts.scrollContainer);
  11868. var offset = cont.offset();
  11869. y = Math.max(0, y - cont.height() - offset.top) + Math.min(0, y - offset.top);
  11870. x = Math.max(0, x - cont.width() - offset.left) + Math.min(0, x - offset.left);
  11871. }
  11872. list.scroll.moveX = x == 0 ? 0 : x * opts.scrollSpeed / Math.abs(x);
  11873. list.scroll.moveY = y == 0 ? 0 : y * opts.scrollSpeed / Math.abs(y);
  11874. //move draggedItem to new mouse cursor location
  11875. this.draggedItem.css({ top: top, left: left });
  11876. },
  11877. //if scroll container is a div allow mouse wheel to scroll div instead of window when mouse is hovering over
  11878. wheel: function(e) {
  11879. if (list && opts.scrollContainer != window) {
  11880. var cont = $(opts.scrollContainer);
  11881. var offset = cont.offset();
  11882. e = e.originalEvent;
  11883. if (e.clientX > offset.left && e.clientX < offset.left + cont.width() && e.clientY > offset.top && e.clientY < offset.top + cont.height()) {
  11884. var deltaY = (e.deltaMode == 0 ? 1 : 10) * e.deltaY;
  11885. cont.scrollTop(cont.scrollTop() + deltaY);
  11886. e.preventDefault();
  11887. }
  11888. }
  11889. },
  11890. //build a table recording all the positions of the moveable list items
  11891. buildPositionTable: function() {
  11892. var pos = [];
  11893. this.getItems().not([list.draggedItem[0], list.placeHolderItem[0]]).each(function(i) {
  11894. var loc = $(this).offset();
  11895. loc.right = loc.left + $(this).outerWidth();
  11896. loc.bottom = loc.top + $(this).outerHeight();
  11897. loc.elm = this;
  11898. pos[i] = loc;
  11899. });
  11900. this.pos = pos;
  11901. },
  11902. dropItem: function() {
  11903. if (list.draggedItem == null)
  11904. return;
  11905. //list.draggedItem.attr("style", "") doesn't work on IE8 and jQuery 1.5 or lower
  11906. //list.draggedItem.removeAttr("style") doesn't work on chrome and jQuery 1.6 (works jQuery 1.5 or lower)
  11907. var orig = list.draggedItem.attr("data-origstyle");
  11908. list.draggedItem.attr("style", orig);
  11909. if (orig == "")
  11910. list.draggedItem.removeAttr("style");
  11911. list.draggedItem.removeAttr("data-origstyle");
  11912. list.styleDragHandlers(true);
  11913. list.placeHolderItem.before(list.draggedItem);
  11914. list.placeHolderItem.remove();
  11915. $("[data-droptarget], .dragSortItem").remove();
  11916. window.clearInterval(list.scroll.scrollY);
  11917. window.clearInterval(list.scroll.scrollX);
  11918. //if position changed call dragEnd
  11919. if (list.draggedItem.attr("data-origpos") != $(lists).index(list) + "-" + $(list.container).children().index(list.draggedItem))
  11920. if (opts.dragEnd.apply(list.draggedItem) == false) { //if dragEnd returns false revert order
  11921. var pos = list.draggedItem.attr("data-origpos").split('-');
  11922. var nextItem = $(lists[pos[0]].container).children().not(list.draggedItem).eq(pos[1]);
  11923. if (nextItem.length > 0)
  11924. nextItem.before(list.draggedItem);
  11925. else if (pos[1] == 0) //was the only item in list
  11926. $(lists[pos[0]].container).prepend(list.draggedItem);
  11927. else //was the last item in list
  11928. $(lists[pos[0]].container).append(list.draggedItem);
  11929. }
  11930. list.draggedItem.removeAttr("data-origpos");
  11931. list.draggedItem = null;
  11932. $(document).unbind("mousemove", list.swapItems);
  11933. $(document).unbind("mouseup", list.dropItem);
  11934. if (opts.scrollContainer != window)
  11935. $(window).unbind("wheel", list.wheel);
  11936. return false;
  11937. },
  11938. //swap the draggedItem (represented visually by placeholder) with the list item the it has been dragged on top of
  11939. swapItems: function(e) {
  11940. if (list.draggedItem == null)
  11941. return false;
  11942. //move draggedItem to mouse location
  11943. list.setPos(e.pageX, e.pageY);
  11944. //retrieve list and item position mouse cursor is over
  11945. var ei = list.findPos(e.pageX, e.pageY);
  11946. var nlist = list;
  11947. for (var i = 0; ei == -1 && opts.dragBetween && i < lists.length; i++) {
  11948. ei = lists[i].findPos(e.pageX, e.pageY);
  11949. nlist = lists[i];
  11950. }
  11951. //if not over another moveable list item return
  11952. if (ei == -1)
  11953. return false;
  11954. //save fixed items locations
  11955. var children = function() { return $(nlist.container).children().not(nlist.draggedItem); };
  11956. var fixed = children().not(opts.itemSelector).each(function(i) { this.idx = children().index(this); });
  11957. //if moving draggedItem up or left place placeHolder before list item the dragged item is hovering over otherwise place it after
  11958. if (lastPos == null || lastPos.top > list.draggedItem.offset().top || lastPos.left > list.draggedItem.offset().left)
  11959. $(nlist.pos[ei].elm).before(list.placeHolderItem);
  11960. else
  11961. $(nlist.pos[ei].elm).after(list.placeHolderItem);
  11962. //restore fixed items location
  11963. fixed.each(function() {
  11964. var elm = children().eq(this.idx).get(0);
  11965. if (this != elm && children().index(this) < this.idx)
  11966. $(this).insertAfter(elm);
  11967. else if (this != elm)
  11968. $(this).insertBefore(elm);
  11969. });
  11970. //misc
  11971. $(lists).each(function(i, l) { l.createDropTargets(); l.buildPositionTable(); });
  11972. lastPos = list.draggedItem.offset();
  11973. return false;
  11974. },
  11975. //returns the index of the list item the mouse is over
  11976. findPos: function(x, y) {
  11977. for (var i = 0; i < this.pos.length; i++) {
  11978. if (this.pos[i].left < x && this.pos[i].right > x && this.pos[i].top < y && this.pos[i].bottom > y)
  11979. return i;
  11980. }
  11981. return -1;
  11982. },
  11983. //create drop targets which are placeholders at the end of other lists to allow dragging straight to the last position
  11984. createDropTargets: function() {
  11985. if (!opts.dragBetween)
  11986. return;
  11987. $(lists).each(function() {
  11988. var ph = $(this.container).find("[data-placeholder]");
  11989. var dt = $(this.container).find("[data-droptarget]");
  11990. if (ph.length > 0 && dt.length > 0)
  11991. dt.remove();
  11992. else if (ph.length == 0 && dt.length == 0) {
  11993. if (opts.tagName == "td")
  11994. $(opts.placeHolderTemplate).attr("data-droptarget", true).appendTo(this.container);
  11995. else
  11996. //list.placeHolderItem.clone().removeAttr("data-placeholder") crashes in IE7 and jquery 1.5.1 (doesn't in jquery 1.4.2 or IE8)
  11997. $(this.container).append(list.placeHolderItem.removeAttr("data-placeholder").clone().attr("data-droptarget", true));
  11998. list.placeHolderItem.attr("data-placeholder", true);
  11999. }
  12000. });
  12001. }
  12002. };
  12003. newList.init();
  12004. lists.push(newList);
  12005. });
  12006. return this;
  12007. };
  12008. $.fn.dragsort.defaults = {
  12009. tagName:"",
  12010. itemSelector: "",
  12011. dragSelector: "",
  12012. dragSelectorExclude: "input, textarea",
  12013. dragEnd: function() { },
  12014. dragBetween: false,
  12015. placeHolderTemplate: "",
  12016. scrollContainer: window,
  12017. scrollSpeed: 5
  12018. };
  12019. })(jQuery);
  12020. define("dragsort", function(){});
  12021. /**
  12022. * http://git.oschina.net/hbbcs/bootStrap-addTabs
  12023. * Created by joe on 2015-12-19.
  12024. * Modified by FastAdmin
  12025. */
  12026. (function ($) {
  12027. $.fn.addtabs = function (options) {
  12028. var obj = $(this);
  12029. options = $.extend({
  12030. content: '', //直接指定所有页面TABS内容
  12031. close: true, //是否可以关闭
  12032. monitor: 'body', //监视的区域
  12033. nav: '.nav-addtabs',
  12034. tab: '.tab-addtabs',
  12035. iframeUse: true, //使用iframe还是ajax
  12036. simple: false, //是否启用简洁模式,简洁模式下将不启用nav和tab
  12037. iframeHeight: $(window).height() - 50, //固定TAB中IFRAME高度,根据需要自己修改
  12038. iframeForceRefresh: false, //点击后强制加载对应的iframe
  12039. iframeForceRefreshTable: false, //点击后强制刷新对应的iframe中的table
  12040. callback: function () {
  12041. //关闭后回调函数
  12042. }
  12043. }, options || {});
  12044. var navobj = $(options.nav);
  12045. var tabobj = $(options.tab);
  12046. if (history.pushState) {
  12047. //浏览器前进后退事件
  12048. $(window).on("popstate", function (e) {
  12049. var state = e.originalEvent.state;
  12050. if (state) {
  12051. $("a[addtabs=" + state.id + "]", options.monitor).data("pushstate", true).trigger("click");
  12052. }
  12053. });
  12054. }
  12055. $(options.monitor).on('click', '[addtabs]', function (e) {
  12056. if ($(this).attr('url').indexOf("javascript:") !== 0) {
  12057. if ($(this).is("a")) {
  12058. e.preventDefault();
  12059. }
  12060. var id = $(this).attr('addtabs');
  12061. var title = $(this).attr('title') ? $(this).attr('title') : $.trim($(this).text());
  12062. var url = $(this).attr('url');
  12063. var content = options.content ? options.content : $(this).attr('content');
  12064. var ajax = $(this).attr('ajax') === '1' || $(this).attr('ajax') === 'true';
  12065. var state = ({
  12066. url: url, title: title, id: id, content: content, ajax: ajax
  12067. });
  12068. document.title = title;
  12069. if (history.pushState && !$(this).data("pushstate")) {
  12070. var pushurl = url.indexOf("ref=addtabs") === -1 ? (url + (url.indexOf("?") > -1 ? "&" : "?") + "ref=addtabs") : url;
  12071. try {
  12072. window.history.pushState(state, title, pushurl);
  12073. } catch (e) {
  12074. }
  12075. }
  12076. $(this).data("pushstate", null);
  12077. _add.call(this, {
  12078. id: id,
  12079. title: $(this).attr('title') ? $(this).attr('title') : $(this).html(),
  12080. content: content,
  12081. url: url,
  12082. ajax: ajax
  12083. });
  12084. }
  12085. });
  12086. navobj.on('click', '.close-tab', function () {
  12087. var id = $(this).prev("a").attr("aria-controls");
  12088. _close(id);
  12089. return false;
  12090. });
  12091. navobj.on('dblclick', 'li[role=presentation]', function () {
  12092. $(this).find(".close-tab").trigger("click");
  12093. });
  12094. navobj.on('click', 'li[role=presentation]', function () {
  12095. $("a[addtabs=" + $("a", this).attr("node-id") + "]").trigger("click");
  12096. });
  12097. $(window).resize(function () {
  12098. if (typeof options.nav === 'object') {
  12099. var siblingsWidth = 0;
  12100. navobj.siblings().each(function () {
  12101. siblingsWidth += $(this).outerWidth();
  12102. });
  12103. navobj.width(navobj.parent().width() - siblingsWidth);
  12104. } else {
  12105. $("#nav").width($("#header").find("> .navbar").width() - $(".sidebar-toggle").outerWidth() - $(".navbar-custom-menu").outerWidth() - 20);
  12106. }
  12107. _drop();
  12108. });
  12109. var _add = function (opts) {
  12110. var id, tabid, conid, url;
  12111. id = opts.id;
  12112. tabid = 'tab_' + opts.id;
  12113. conid = 'con_' + opts.id;
  12114. url = opts.url;
  12115. url += (opts.url.indexOf("?") > -1 ? "&addtabs=1" : "?addtabs=1");
  12116. if (options.simple) {
  12117. navobj.find("[role='presentation']").remove();
  12118. tabobj.find("[role='tabpanel']").remove();
  12119. }
  12120. var tabitem = $('#' + tabid, navobj);
  12121. var conitem = $('#' + conid, tabobj);
  12122. navobj.find("[role='presentation']").removeClass('active');
  12123. tabobj.find("[role='tabpanel']").removeClass('active');
  12124. //如果TAB不存在,创建一个新的TAB
  12125. if (tabitem.length === 0) {
  12126. //创建新TAB的title
  12127. tabitem = $('<li role="presentation" id="' + tabid + '"><a href="#' + conid + '" node-id="' + opts.id + '" aria-controls="' + id + '" role="tab" data-toggle="tab">' + opts.title + '</a></li>');
  12128. //是否允许关闭
  12129. if (options.close && $("li", navobj).length > 0) {
  12130. tabitem.append(' <i class="close-tab fa fa-remove"></i>');
  12131. }
  12132. if (conitem.length === 0) {
  12133. //创建新TAB的内容
  12134. conitem = $('<div role="tabpanel" class="tab-pane" id="' + conid + '"></div>');
  12135. //是否指定TAB内容
  12136. if (opts.content) {
  12137. conitem.append(opts.content);
  12138. } else if (options.iframeUse && !opts.ajax) {//没有内容,使用IFRAME打开链接
  12139. var height = options.iframeHeight;
  12140. conitem.append('<iframe src="' + url + '" width="100%" height="' + height + '" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling-x="no" scrolling-y="auto" allowtransparency="yes"></iframe></div>');
  12141. } else {
  12142. $.get(url, function (data) {
  12143. conitem.append(data);
  12144. });
  12145. }
  12146. tabobj.append(conitem);
  12147. }
  12148. if (!options.simple) {
  12149. //加入TABS
  12150. if ($('.tabdrop li', navobj).length > 0) {
  12151. $('.tabdrop ul', navobj).append(tabitem);
  12152. } else {
  12153. navobj.append(tabitem);
  12154. }
  12155. }
  12156. } else {
  12157. //强制刷新iframe
  12158. if (options.iframeForceRefresh) {
  12159. $("#" + conid + " iframe").attr('src', function (i, val) {
  12160. return val;
  12161. });
  12162. } else if (options.iframeForceRefreshTable) {
  12163. try {
  12164. //检测iframe中是否存在刷新按钮
  12165. if ($("#" + conid + " iframe").contents().find(".btn-refresh:not([data-force-refresh=false])").length > 0) {
  12166. $("#" + conid + " iframe")[0].contentWindow.$(".btn-refresh:not([data-force-refresh=false])").trigger("click");
  12167. }
  12168. } catch (e) {
  12169. }
  12170. }
  12171. }
  12172. sessionStorage.setItem("addtabs", $(this).prop('outerHTML'));
  12173. //激活TAB
  12174. tabitem.addClass('active');
  12175. conitem.addClass("active");
  12176. _drop();
  12177. };
  12178. var _close = function (id) {
  12179. var tabid = 'tab_' + id;
  12180. var conid = 'con_' + id;
  12181. var tabitem = $('#' + tabid, navobj);
  12182. var conitem = $('#' + conid, tabobj);
  12183. //如果关闭的是当前激活的TAB,激活他的前一个TAB
  12184. if (obj.find("li.active").not('.tabdrop').attr('id') === tabid) {
  12185. var prev = tabitem.prev().not(".tabdrop");
  12186. var next = tabitem.next().not(".tabdrop");
  12187. if (prev.length > 0) {
  12188. prev.find('a').trigger("click");
  12189. } else if (next.length > 0) {
  12190. next.find('a').trigger("click");
  12191. } else {
  12192. $(">li:not(.tabdrop):last > a", navobj).trigger('click');
  12193. }
  12194. }
  12195. //关闭TAB
  12196. tabitem.remove();
  12197. conitem.remove();
  12198. _drop();
  12199. options.callback();
  12200. };
  12201. var _drop = function () {
  12202. navobj.refreshAddtabs();
  12203. };
  12204. };
  12205. //刷新Addtabs
  12206. $.fn.refreshAddtabs = function () {
  12207. var navobj = $(this);
  12208. var dropdown = $(".tabdrop", navobj);
  12209. if (dropdown.length === 0) {
  12210. dropdown = $('<li class="dropdown pull-right hide tabdrop"><a class="dropdown-toggle" data-toggle="dropdown" href="javascript:;">' +
  12211. '<i class="glyphicon glyphicon-align-justify"></i>' +
  12212. ' <b class="caret"></b></a><ul class="dropdown-menu"></ul></li>');
  12213. dropdown.prependTo(navobj);
  12214. }
  12215. //检测是否有下拉样式
  12216. if (navobj.parent().is('.tabs-below')) {
  12217. dropdown.addClass('dropup');
  12218. }
  12219. var collection = 0;
  12220. var maxwidth = navobj.width() - 65;
  12221. var liwidth = 0;
  12222. //检查超过一行的标签页
  12223. var litabs = navobj.append(dropdown.find('li')).find('>li').not('.tabdrop');
  12224. var totalwidth = 0;
  12225. litabs.each(function () {
  12226. totalwidth += $(this).outerWidth(true);
  12227. });
  12228. if (navobj.width() < totalwidth) {
  12229. litabs.each(function () {
  12230. liwidth += $(this).outerWidth(true);
  12231. if (liwidth > maxwidth) {
  12232. dropdown.find('ul').append($(this));
  12233. collection++;
  12234. }
  12235. });
  12236. if (collection > 0) {
  12237. dropdown.removeClass('hide');
  12238. if (dropdown.find('.active').length === 1) {
  12239. dropdown.addClass('active');
  12240. } else {
  12241. dropdown.removeClass('active');
  12242. }
  12243. }
  12244. } else {
  12245. dropdown.addClass('hide');
  12246. }
  12247. };
  12248. })(jQuery);
  12249. define("addtabs", function(){});
  12250. /**
  12251. * @summary SelectPage
  12252. * @desc Simple and powerful selection plugin
  12253. * @file selectpage.js
  12254. * @version 2.20
  12255. * @author TerryZeng
  12256. * @contact https://terryz.github.io/
  12257. * @license MIT License
  12258. *
  12259. */
  12260. ;(function ($) {
  12261. "use strict";
  12262. /**
  12263. * Default options
  12264. */
  12265. var defaults = {
  12266. /**
  12267. * Data source
  12268. * @type {string|Object}
  12269. *
  12270. * string:server side request url address
  12271. * Object:JSON array,format:[{a:1,b:2,c:3},{...}]
  12272. */
  12273. data: undefined,
  12274. /**
  12275. * Language ('cn', 'en')
  12276. * @type string
  12277. * @default 'cn'
  12278. */
  12279. lang: 'cn',
  12280. /**
  12281. * Multiple select mode(tags)
  12282. * @type boolean
  12283. * @default false
  12284. */
  12285. multiple: false,
  12286. /**
  12287. * pagination or not
  12288. * @type boolean
  12289. * @default true
  12290. */
  12291. pagination: true,
  12292. /**
  12293. * Show up menu button
  12294. * @type boolean
  12295. * @default true
  12296. */
  12297. dropButton: true,
  12298. /**
  12299. * Result list visible size in pagination bar close
  12300. * @type number
  12301. * @default 10
  12302. */
  12303. listSize: 10,
  12304. /**
  12305. * Show control bar in multiple select mode
  12306. * @type boolean
  12307. * @default true
  12308. */
  12309. multipleControlbar: true,
  12310. /**
  12311. * Max selected item limited in multiple select mode
  12312. * @type number
  12313. * @default 0(unlimited)
  12314. */
  12315. maxSelectLimit: 0,
  12316. /**
  12317. * Select result item to close list, work on multiple select mode
  12318. * @type boolean
  12319. * @default false
  12320. */
  12321. selectToCloseList: false,
  12322. /**
  12323. * Init selected item key, the result will match to option.keyField option
  12324. * @type string
  12325. */
  12326. initRecord: undefined,
  12327. /**
  12328. * The table parameter in server side mode
  12329. * @type string
  12330. */
  12331. dbTable: 'tbl',
  12332. /**
  12333. * The value field, the value will fill to hidden element
  12334. * @type string
  12335. * @default 'id'
  12336. */
  12337. keyField: 'id',
  12338. /**
  12339. * The show text field, the text will show to input element or tags(multiple mode)
  12340. * @type string
  12341. * @default 'name'
  12342. */
  12343. showField: 'name',
  12344. /**
  12345. * Actually used to search field
  12346. * @type string
  12347. */
  12348. searchField: undefined,
  12349. /**
  12350. * Search type ('AND' or 'OR')
  12351. * @type string
  12352. * @default 'AND'
  12353. */
  12354. andOr: 'OR',
  12355. /**
  12356. * Used to separate search content
  12357. * @see SelectPage.prototype.suggest()
  12358. */
  12359. separator: ',',
  12360. /**
  12361. * Result sort type
  12362. * @type array|boolean - if not set, will default used showField field
  12363. * @example
  12364. * orderBy : ['id desc']
  12365. */
  12366. orderBy: undefined,
  12367. /**
  12368. * Page size
  12369. * @type number
  12370. * @default 10
  12371. */
  12372. pageSize: 10,
  12373. /**
  12374. * Server side request parameters
  12375. * @type function
  12376. * @return object
  12377. * @example params : function(){return {'name':'aa','sex':1};}
  12378. */
  12379. params: undefined,
  12380. /**
  12381. * Custom result list item show text
  12382. * @type function
  12383. * @param data {object} row data
  12384. * @return string
  12385. */
  12386. formatItem: undefined,
  12387. /**
  12388. * Have some highlight item and lost focus, auto select the highlight item
  12389. * @type boolean
  12390. * @default false
  12391. */
  12392. autoFillResult: false,
  12393. /**
  12394. * Auto select first item in show up result list or search result
  12395. * depend on `autoFillResult` option set to true
  12396. * @type boolean
  12397. * @default false
  12398. */
  12399. autoSelectFirst: false,
  12400. /**
  12401. * Whether clear input element text when enter some keywords to search and no result return
  12402. * @type boolean
  12403. * @default true
  12404. */
  12405. noResultClean: true,
  12406. /**
  12407. * Select only mode
  12408. * @type boolean
  12409. */
  12410. selectOnly: false,
  12411. /**
  12412. * Input to search delay time, work on ajax data source
  12413. * @type number
  12414. * @default 0.5
  12415. */
  12416. inputDelay: 0.5,
  12417. /**
  12418. * -----------------------------------------Callback--------------------------------------------
  12419. */
  12420. /**
  12421. * Result list item selected callback
  12422. * @type function
  12423. * @param object - selected item json data
  12424. * @param self - plugin object
  12425. */
  12426. eSelect: undefined,
  12427. /**
  12428. * Before result list show up callback, you can do anything prepared
  12429. * @param self - plugin object
  12430. */
  12431. eOpen: undefined,
  12432. /**
  12433. * Server side return data convert callback
  12434. * @type function
  12435. * @param data {object} server side return data
  12436. * @param self {object} plugin object
  12437. * @return {object} return data format:
  12438. * @example
  12439. * {
  12440. * list : [{name:'aa',sex:1},{name:'bb',sex:1}...],
  12441. * totalRow : 100
  12442. * }
  12443. */
  12444. eAjaxSuccess: undefined,
  12445. /**
  12446. * Close selected item tag callback (multiple mode)
  12447. * @type function
  12448. * @param removeCount {number} remove item count
  12449. * @param self {object} plugin object
  12450. */
  12451. eTagRemove: undefined,
  12452. /**
  12453. * Clear selected item callback(single select mode)
  12454. * @type function
  12455. * @param self {object} plugin object
  12456. */
  12457. eClear: undefined
  12458. };
  12459. /**
  12460. * SelectPage class definition
  12461. * @constructor
  12462. * @param {Object} input - input element
  12463. * @param {Object} option
  12464. */
  12465. var SelectPage = function (input, option) {
  12466. //特殊字段处理
  12467. $.each({data: 'source', keyField: 'primaryKey', showField: 'field', pageSize: 'perPage'}, function (i, j) {
  12468. if (typeof option[j] !== 'undefined') {
  12469. option[i] = option[j];
  12470. delete option[j];
  12471. }
  12472. });
  12473. this.setOption(option);
  12474. this.setLanguage();
  12475. this.setCssClass();
  12476. this.setProp();
  12477. this.setElem(input);
  12478. this.setButtonAttrDefault();
  12479. this.setInitRecord();
  12480. this.eDropdownButton();
  12481. this.eInput();
  12482. this.eWhole();
  12483. };
  12484. /**
  12485. * Plugin version number
  12486. */
  12487. SelectPage.version = '2.19';
  12488. /**
  12489. * Plugin object cache key
  12490. */
  12491. SelectPage.dataKey = 'selectPageObject';
  12492. /**
  12493. * Options set
  12494. * @param {Object} option
  12495. */
  12496. SelectPage.prototype.setOption = function (option) {
  12497. //use showField to default
  12498. option.searchField = option.searchField || option.showField;
  12499. option.andOr = option.andOr.toUpperCase();
  12500. if (option.andOr !== 'AND' && option.andOr !== 'OR') option.andOr = 'AND';
  12501. //support multiple field set
  12502. var arr = ['searchField'];
  12503. for (var i = 0; i < arr.length; i++) {
  12504. option[arr[i]] = this.strToArray(option[arr[i]]);
  12505. }
  12506. //set default order field
  12507. option.orderBy = option.orderBy || option.showField;
  12508. //set multiple order field
  12509. //example: [ ['id', 'ASC'], ['name', 'DESC'] ]
  12510. if (option.orderBy !== false) option.orderBy = this.setOrderbyOption(option.orderBy, option.showField);
  12511. //close auto fill result and auto select first in multiple mode and select item not close list
  12512. if (option.multiple && !option.selectToCloseList) {
  12513. option.autoFillResult = false;
  12514. option.autoSelectFirst = false;
  12515. }
  12516. //show all item when pagination bar close, limited 200
  12517. if (!option.pagination) option.pageSize = 200;
  12518. if ($.type(option.listSize) !== 'number' || option.listSize < 0) option.listSize = 10;
  12519. if (typeof option.formatItem === 'string') {
  12520. var _formatItem = option.formatItem;
  12521. option.formatItem = function (row) {
  12522. if (typeof Template === 'function' && _formatItem.match(/\#([a-zA-Z0-9_\-]+)$/)) {
  12523. return Template(_formatItem.substring(1), row);
  12524. } else {
  12525. return _formatItem.replace(/\{(.*?)\}/gi, function (matched) {
  12526. matched = matched.substring(1, matched.length - 1);
  12527. return typeof row[matched] !== 'undefined' ? row[matched] : '';
  12528. });
  12529. }
  12530. };
  12531. }
  12532. this.option = option;
  12533. };
  12534. /**
  12535. * String convert to array
  12536. * @param str {string}
  12537. * @return {Array}
  12538. */
  12539. SelectPage.prototype.strToArray = function (str) {
  12540. return str ? str.replace(/[\s ]+/g, '').split(',') : '';
  12541. };
  12542. /**
  12543. * Set order field
  12544. * @param {Array} arg_order
  12545. * @param {string} arg_field - default sort field
  12546. * @return {Array}
  12547. */
  12548. SelectPage.prototype.setOrderbyOption = function (arg_order, arg_field) {
  12549. var arr = [], orders = [];
  12550. if (typeof arg_order === 'object') {
  12551. for (var i = 0; i < arg_order.length; i++) {
  12552. orders = $.trim(arg_order[i]).split(' ');
  12553. if (orders.length)
  12554. arr.push((orders.length === 2) ? orders.concat() : [orders[0], 'ASC']);
  12555. }
  12556. } else {
  12557. orders = $.trim(arg_order).split(' ');
  12558. arr[0] = (orders.length === 2) ? orders.concat() : (orders[0].toUpperCase().match(/^(ASC|DESC)$/i)) ? [arg_field, orders[0].toUpperCase()] : [orders[0], 'ASC'];
  12559. }
  12560. return arr;
  12561. };
  12562. /**
  12563. * i18n
  12564. */
  12565. SelectPage.prototype.setLanguage = function () {
  12566. var message, p = this.option;
  12567. switch (p.lang) {
  12568. // English
  12569. case 'en':
  12570. message = {
  12571. add_btn: 'Add button',
  12572. add_title: 'add a box',
  12573. del_btn: 'Del button',
  12574. del_title: 'delete a box',
  12575. next: 'Next',
  12576. next_title: 'Next' + p.pageSize + ' (Right key)',
  12577. prev: 'Prev',
  12578. prev_title: 'Prev' + p.pageSize + ' (Left key)',
  12579. first_title: 'First (Shift + Left key)',
  12580. last_title: 'Last (Shift + Right key)',
  12581. get_all_btn: 'Get All (Down key)',
  12582. get_all_alt: '(button)',
  12583. close_btn: 'Close (Tab key)',
  12584. close_alt: '(button)',
  12585. loading: 'loading...',
  12586. loading_alt: '(loading)',
  12587. page_info: 'page_num of page_count',
  12588. select_ng: 'Attention : Please choose from among the list.',
  12589. select_ok: 'OK : Correctly selected.',
  12590. not_found: 'not found',
  12591. ajax_error: 'An error occurred while loading data.',
  12592. clear: 'Clear content',
  12593. select_all: 'Select current page',
  12594. unselect_all: 'Clear current page',
  12595. clear_all: 'Clear all selected',
  12596. max_selected: 'You can only select up to max_selected_limit items'
  12597. };
  12598. break;
  12599. // 中文
  12600. case 'cn':
  12601. default:
  12602. message = {
  12603. add_btn: '添加按钮',
  12604. add_title: '添加区域',
  12605. del_btn: '删除按钮',
  12606. del_title: '删除区域',
  12607. next: '下一页',
  12608. next_title: '下' + p.pageSize + ' (→)',
  12609. prev: '上一页',
  12610. prev_title: '上' + p.pageSize + ' (←)',
  12611. first_title: '首页 (Shift + ←)',
  12612. last_title: '尾页 (Shift + →)',
  12613. get_all_btn: '获得全部 (↓)',
  12614. get_all_alt: '(按钮)',
  12615. close_btn: '关闭 (Tab键)',
  12616. close_alt: '(按钮)',
  12617. loading: '读取中...',
  12618. loading_alt: '(读取中)',
  12619. page_info: '第 page_num 页(共page_count页)',
  12620. select_ng: '请注意:请从列表中选择.',
  12621. select_ok: 'OK : 已经选择.',
  12622. not_found: '无查询结果',
  12623. ajax_error: '加载数据时发生了错误!',
  12624. clear: '清除内容',
  12625. select_all: '选择当前页项目',
  12626. unselect_all: '取消选择当前页项目',
  12627. clear_all: '清除全部已选择项目',
  12628. max_selected: '最多只能选择 max_selected_limit 个项目'
  12629. };
  12630. break;
  12631. }
  12632. this.message = message;
  12633. };
  12634. /**
  12635. * Css classname defined
  12636. */
  12637. SelectPage.prototype.setCssClass = function () {
  12638. var css_class = {
  12639. container: 'sp_container',
  12640. container_open: 'sp_container_open',
  12641. re_area: 'sp_result_area',
  12642. result_open: 'sp_result_area_open',
  12643. control_box: 'sp_control_box',
  12644. //multiple select mode
  12645. element_box: 'sp_element_box',
  12646. navi: 'sp_navi',
  12647. //result list
  12648. results: 'sp_results',
  12649. re_off: 'sp_results_off',
  12650. select: 'sp_over',
  12651. select_ok: 'sp_select_ok',
  12652. select_ng: 'sp_select_ng',
  12653. selected: 'sp_selected',
  12654. input_off: 'sp_input_off',
  12655. message_box: 'sp_message_box',
  12656. disabled: 'sp_disabled',
  12657. button: 'sp_button',
  12658. caret_open: 'sp_caret_open',
  12659. btn_on: 'sp_btn_on',
  12660. btn_out: 'sp_btn_out',
  12661. input: 'sp_input',
  12662. clear_btn: 'sp_clear_btn',
  12663. align_right: 'sp_align_right'
  12664. };
  12665. this.css_class = css_class;
  12666. };
  12667. /**
  12668. * Plugin inner properties
  12669. */
  12670. SelectPage.prototype.setProp = function () {
  12671. this.prop = {
  12672. //input disabled status
  12673. disabled: false,
  12674. current_page: 1,
  12675. //total page
  12676. max_page: 1,
  12677. //ajax data loading status
  12678. is_loading: false,
  12679. xhr: false,
  12680. key_paging: false,
  12681. key_select: false,
  12682. //last selected item value
  12683. prev_value: '',
  12684. //last selected item text
  12685. selected_text: '',
  12686. last_input_time: undefined,
  12687. init_set: false
  12688. };
  12689. this.template = {
  12690. tag: {
  12691. content: '<li class="selected_tag" itemvalue="#item_value#">#item_text#<span class="tag_close"><i class="spfont sp-close"></i></span></li>',
  12692. textKey: '#item_text#',
  12693. valueKey: '#item_value#'
  12694. },
  12695. page: {
  12696. current: 'page_num',
  12697. total: 'page_count'
  12698. },
  12699. msg: {
  12700. maxSelectLimit: 'max_selected_limit'
  12701. }
  12702. };
  12703. };
  12704. /**
  12705. * Get the actual width/height of invisible DOM elements with jQuery.
  12706. * Source code come from dreamerslab/jquery.actual
  12707. * @param element
  12708. * @param method
  12709. * @returns {*}
  12710. */
  12711. SelectPage.prototype.elementRealSize = function (element, method) {
  12712. var defaults = {
  12713. absolute: false,
  12714. clone: false,
  12715. includeMargin: false,
  12716. display: 'block'
  12717. };
  12718. var configs = defaults, $target = element.eq(0), fix, restore, tmp = [], style = '', $hidden;
  12719. fix = function () {
  12720. // get all hidden parents
  12721. $hidden = $target.parents().addBack().filter(':hidden');
  12722. style += 'visibility: hidden !important; display: ' + configs.display + ' !important; ';
  12723. if (configs.absolute === true) style += 'position: absolute !important;';
  12724. // save the origin style props
  12725. // set the hidden el css to be got the actual value later
  12726. $hidden.each(function () {
  12727. // Save original style. If no style was set, attr() returns undefined
  12728. var $this = $(this), thisStyle = $this.attr('style');
  12729. tmp.push(thisStyle);
  12730. // Retain as much of the original style as possible, if there is one
  12731. $this.attr('style', thisStyle ? thisStyle + ';' + style : style);
  12732. });
  12733. };
  12734. restore = function () {
  12735. // restore origin style values
  12736. $hidden.each(function (i) {
  12737. var $this = $(this), _tmp = tmp[i];
  12738. if (_tmp === undefined) $this.removeAttr('style');
  12739. else $this.attr('style', _tmp);
  12740. });
  12741. };
  12742. fix();
  12743. // get the actual value with user specific methed
  12744. // it can be 'width', 'height', 'outerWidth', 'innerWidth'... etc
  12745. // configs.includeMargin only works for 'outerWidth' and 'outerHeight'
  12746. var actual = /(outer)/.test(method) ?
  12747. $target[method](configs.includeMargin) :
  12748. $target[method]();
  12749. restore();
  12750. // IMPORTANT, this plugin only return the value of the first element
  12751. return actual;
  12752. };
  12753. /**
  12754. * Dom building
  12755. * @param {Object} combo_input - original input element
  12756. */
  12757. SelectPage.prototype.setElem = function (combo_input) {
  12758. // 1. build Dom object
  12759. var elem = {}, p = this.option, css = this.css_class, msg = this.message, input = $(combo_input);
  12760. var cssWidth = input.css("width");
  12761. var orgWidth = input.outerWidth();
  12762. if (cssWidth.indexOf("%") > -1 || input.parent().length > 0 && input.parent().width() == orgWidth) {
  12763. orgWidth = "100%";
  12764. } else {
  12765. // fix input width in hidden situation
  12766. if (orgWidth <= 0) orgWidth = this.elementRealSize(input, 'outerWidth');
  12767. if (orgWidth < 150) orgWidth = 150;
  12768. }
  12769. elem.combo_input = input.attr({'autocomplete': 'off'}).addClass(css.input).wrap('<div>');
  12770. if (p.selectOnly) elem.combo_input.prop('readonly', true);
  12771. elem.container = elem.combo_input.parent().addClass(css.container);
  12772. if (elem.combo_input.prop('disabled')) {
  12773. if (p.multiple) elem.container.addClass(css.disabled);
  12774. else elem.combo_input.addClass(css.input_off);
  12775. }
  12776. // set outer box width
  12777. elem.container.width(orgWidth);
  12778. elem.button = $('<div>').addClass(css.button);
  12779. //drop down button
  12780. elem.dropdown = $('<span class="sp_caret"></span>');
  12781. //clear button 'X' in single mode
  12782. elem.clear_btn = $('<div>').html($('<i>').addClass('spfont sp-close')).addClass(css.clear_btn).attr('title', msg.clear);
  12783. if (!p.dropButton) elem.clear_btn.addClass(css.align_right);
  12784. //main box in multiple mode
  12785. elem.element_box = $('<ul>').addClass(css.element_box);
  12786. if (p.multiple && p.multipleControlbar)
  12787. elem.control = $('<div>').addClass(css.control_box);
  12788. //result list box
  12789. elem.result_area = $('<div>').addClass(css.re_area);
  12790. //pagination bar
  12791. if (p.pagination) elem.navi = $('<div>').addClass('sp_pagination').append('<ul>');
  12792. elem.results = $('<ul>').addClass(css.results);
  12793. var namePrefix = '_text',
  12794. input_id = elem.combo_input.attr('id') || elem.combo_input.attr('name'),
  12795. input_name = elem.combo_input.attr('name') || 'selectPage',
  12796. hidden_name = input_name,
  12797. hidden_id = input_id;
  12798. //switch the id and name attributes of input/hidden element
  12799. elem.hidden = $('<input type="hidden" class="sp_hidden" />').attr({
  12800. name: hidden_name,
  12801. id: hidden_id
  12802. }).val('');
  12803. elem.combo_input.attr({
  12804. name: typeof input.data('name') !== 'undefined' ? input.data('name') : input_name + namePrefix,
  12805. id: input_id + namePrefix
  12806. });
  12807. elem.hidden.attr("data-rule", elem.combo_input.data("rule") || '');
  12808. elem.combo_input.attr("novalidate", "novalidate");
  12809. // 2. DOM element put
  12810. elem.container.append(elem.hidden);
  12811. if (p.dropButton) {
  12812. elem.container.append(elem.button)
  12813. elem.button.append(elem.dropdown);
  12814. }
  12815. $(document.body).append(elem.result_area);
  12816. elem.result_area.append(elem.results);
  12817. if (p.pagination) elem.result_area.append(elem.navi);
  12818. //Multiple select mode
  12819. if (p.multiple) {
  12820. if (p.multipleControlbar) {
  12821. elem.control.append('<button type="button" class="btn btn-default sp_clear_all" ><i class="spfont sp-clear"></i></button>');
  12822. elem.control.append('<button type="button" class="btn btn-default sp_unselect_all" ><i class="spfont sp-unselect-all"></i></button>');
  12823. elem.control.append('<button type="button" class="btn btn-default sp_select_all" ><i class="spfont sp-select-all"></i></button>');
  12824. elem.control_text = $('<p>');
  12825. elem.control.append(elem.control_text);
  12826. elem.result_area.prepend(elem.control);
  12827. }
  12828. elem.container.addClass('sp_container_combo');
  12829. elem.combo_input.addClass('sp_combo_input').before(elem.element_box);
  12830. var li = $('<li>').addClass('input_box');
  12831. li.append(elem.combo_input);
  12832. elem.element_box.append(li);
  12833. if (elem.combo_input.attr('placeholder')) elem.combo_input.attr('placeholder_bak', elem.combo_input.attr('placeholder'));
  12834. }
  12835. this.elem = elem;
  12836. };
  12837. /**
  12838. * Drop down button set to default
  12839. */
  12840. SelectPage.prototype.setButtonAttrDefault = function () {
  12841. /*
  12842. if (this.option.selectOnly) {
  12843. if ($(this.elem.combo_input).val() !== '') {
  12844. if ($(this.elem.hidden).val() !== '') {
  12845. //选择条件
  12846. $(this.elem.combo_input).attr('title', this.message.select_ok).removeClass(this.css_class.select_ng).addClass(this.css_class.select_ok);
  12847. } else {
  12848. //输入方式
  12849. $(this.elem.combo_input).attr('title', this.message.select_ng).removeClass(this.css_class.select_ok).addClass(this.css_class.select_ng);
  12850. }
  12851. } else {
  12852. $(this.elem.hidden).val('');
  12853. $(this.elem.combo_input).removeAttr('title').removeClass(this.css_class.select_ng);
  12854. }
  12855. }
  12856. */
  12857. //this.elem.button.attr('title', this.message.get_all_btn);
  12858. if (this.option.dropButton)
  12859. this.elem.button.attr('title', this.message.close_btn);
  12860. };
  12861. /**
  12862. * Set item need selected after init
  12863. * set selected item ways:
  12864. * <input value="key">
  12865. * <input data-init="key">
  12866. */
  12867. SelectPage.prototype.setInitRecord = function (refresh) {
  12868. var self = this, p = self.option, el = self.elem, key = '';
  12869. if ($.type(el.combo_input.data('init')) != 'undefined')
  12870. p.initRecord = String(el.combo_input.data('init'));
  12871. //data-init and value attribute can be init plugin selected item
  12872. //but, if set data-init and value attribute in the same time, plugin will choose data-init attribute first
  12873. if (!refresh && !p.initRecord && el.combo_input.val())
  12874. p.initRecord = el.combo_input.val();
  12875. el.combo_input.val('');
  12876. if (!refresh) el.hidden.val(p.initRecord);
  12877. key = refresh && el.hidden.val() ? el.hidden.val() : p.initRecord;
  12878. if (key) {
  12879. if (typeof p.data === 'object') {
  12880. var data = new Array();
  12881. var keyarr = key.split(',');
  12882. $.each(keyarr, function (index, row) {
  12883. for (var i = 0; i < p.data.length; i++) {
  12884. if (p.data[i][p.keyField] == row) {
  12885. data.push(p.data[i]);
  12886. break;
  12887. }
  12888. }
  12889. });
  12890. if (!p.multiple && data.length > 1) data = [data[0]];
  12891. self.afterInit(self, data);
  12892. } else {//ajax data source mode to init selected item
  12893. var _paramsFunc = p.params, _params = {}, searchKey = p.searchField;
  12894. var _orgParams = {
  12895. searchTable: p.dbTable,
  12896. searchKey: p.keyField,
  12897. searchValue: key,
  12898. orderBy: p.orderBy,
  12899. showField: p.showField,
  12900. keyField: p.keyField,
  12901. keyValue: key,
  12902. searchField: p.searchField
  12903. };
  12904. if (_paramsFunc) {
  12905. var result = $.isFunction(_paramsFunc) ? _paramsFunc(self) : _paramsFunc;
  12906. if (result && $.isPlainObject(result)) {
  12907. _params = $.extend({}, _orgParams, result);
  12908. } else {
  12909. _params = _orgParams;
  12910. }
  12911. } else {
  12912. _params = _orgParams;
  12913. }
  12914. $.ajax({
  12915. dataType: 'json',
  12916. type: 'POST',
  12917. url: p.data,
  12918. data: _params,
  12919. success: function (json) {
  12920. var d = null;
  12921. if (p.eAjaxSuccess && $.isFunction(p.eAjaxSuccess))
  12922. d = p.eAjaxSuccess(json);
  12923. self.afterInit(self, d.list);
  12924. },
  12925. error: function (jqXHR, textStatus, errorThrown) {
  12926. self.ajaxErrorNotify(self, errorThrown);
  12927. }
  12928. });
  12929. }
  12930. }
  12931. };
  12932. /**
  12933. * Selected item set to plugin
  12934. * @param {Object} self
  12935. * @param {Object} data - selected item data
  12936. */
  12937. SelectPage.prototype.afterInit = function (self, data) {
  12938. if (!data || ($.isArray(data) && data.length === 0)) return;
  12939. if (!$.isArray(data)) data = [data];
  12940. var p = self.option, css = self.css_class;
  12941. self.data = data;
  12942. if (p.multiple) {
  12943. self.prop.init_set = true;
  12944. self.clearAll(self);
  12945. $.each(data, function (i, row) {
  12946. var value = row[p.keyField];
  12947. var text = row[p.showField];
  12948. var item = {text: text, value: value};
  12949. if (!self.isAlreadySelected(self, item)) self.addNewTag(self, row, item);
  12950. });
  12951. self.tagValuesSet(self);
  12952. self.inputResize(self);
  12953. self.elem.hidden.blur();
  12954. self.prop.init_set = false;
  12955. } else {
  12956. var row = data[0];
  12957. var value = row[p.keyField];
  12958. var text = row[p.showField];
  12959. self.elem.combo_input.val(text);
  12960. self.elem.hidden.val(value);
  12961. self.prop.prev_value = text;
  12962. self.prop.selected_text = text;
  12963. if (p.selectOnly) {
  12964. self.elem.combo_input.attr('title', self.message.select_ok).removeClass(css.select_ng).addClass(css.select_ok);
  12965. }
  12966. self.putClearButton();
  12967. }
  12968. };
  12969. /**
  12970. * Drop down button event bind
  12971. */
  12972. SelectPage.prototype.eDropdownButton = function () {
  12973. var self = this;
  12974. if (self.option.dropButton) {
  12975. self.elem.button.mouseup(function (ev) {
  12976. ev.stopPropagation();
  12977. if (self.elem.result_area.is(':hidden') && !self.elem.combo_input.prop('disabled')) {
  12978. self.elem.combo_input.focus();
  12979. } else self.hideResults(self);
  12980. });
  12981. }
  12982. };
  12983. /**
  12984. * Events bind
  12985. */
  12986. SelectPage.prototype.eInput = function () {
  12987. var self = this, p = self.option, el = self.elem, msg = self.message;
  12988. var showList = function () {
  12989. self.prop.page_move = false;
  12990. self.suggest(self);
  12991. self.setCssFocusedInput(self);
  12992. };
  12993. el.combo_input.keyup(function (e) {
  12994. self.processKey(self, e);
  12995. }).keydown(function (e) {
  12996. self.processControl(self, e);
  12997. }).focus(function (e) {
  12998. //When focus on input, show the result list
  12999. if (el.result_area.is(':hidden')) {
  13000. e.stopPropagation();
  13001. self.prop.first_show = true;
  13002. showList();
  13003. }
  13004. });
  13005. el.container.on('click.SelectPage', 'div.' + self.css_class.clear_btn, function (e) {
  13006. e.stopPropagation();
  13007. if (!self.disabled(self)) {
  13008. self.clearAll(self, true);
  13009. self.elem.hidden.change();
  13010. if (p.eClear && $.isFunction(p.eClear)) p.eClear(self);
  13011. }
  13012. });
  13013. el.result_area.on('mousedown.SelectPage', function (e) {
  13014. e.stopPropagation();
  13015. });
  13016. if (p.multiple) {
  13017. if (p.multipleControlbar) {
  13018. //Select all item of current page
  13019. el.control.find('.sp_select_all').on('click.SelectPage', function (e) {
  13020. self.selectAllLine(self);
  13021. }).hover(function () {
  13022. el.control_text.html(msg.select_all);
  13023. }, function () {
  13024. el.control_text.html('');
  13025. });
  13026. //Cancel select all item of current page
  13027. el.control.find('.sp_unselect_all').on('click.SelectPage', function (e) {
  13028. self.unSelectAllLine(self);
  13029. }).hover(function () {
  13030. el.control_text.html(msg.unselect_all);
  13031. }, function () {
  13032. el.control_text.html('');
  13033. });
  13034. //Clear all selected item
  13035. el.control.find('.sp_clear_all').on('click.SelectPage', function (e) {
  13036. self.clearAll(self, true);
  13037. }).hover(function () {
  13038. el.control_text.html(msg.clear_all);
  13039. }, function () {
  13040. el.control_text.html('');
  13041. });
  13042. }
  13043. el.element_box.on('click.SelectPage', function (e) {
  13044. var srcEl = e.target || e.srcElement;
  13045. if ($(srcEl).is('ul')) el.combo_input.focus();
  13046. });
  13047. //Tag close
  13048. el.element_box.on('click.SelectPage', 'span.tag_close', function () {
  13049. var li = $(this).closest('li'), data = li.data('dataObj');
  13050. self.removeTag(self, li);
  13051. showList();
  13052. if (p.eTagRemove && $.isFunction(p.eTagRemove)) p.eTagRemove([data]);
  13053. });
  13054. self.inputResize(self);
  13055. }
  13056. };
  13057. /**
  13058. * Out of plugin area click event handler
  13059. */
  13060. SelectPage.prototype.eWhole = function () {
  13061. var self = this, css = self.css_class;
  13062. var cleanContent = function (obj) {
  13063. obj.elem.combo_input.val('');
  13064. if (!obj.option.multiple) obj.elem.hidden.val('');
  13065. obj.prop.selected_text = '';
  13066. };
  13067. //Out of plugin area
  13068. $(document.body).off('mousedown.selectPage').on('mousedown.selectPage', function (e) {
  13069. var ele = e.target || e.srcElement;
  13070. var sp = $(ele).closest('div.' + css.container);
  13071. //Open status result list
  13072. $('div.' + css.container + '.' + css.container_open).each(function () {
  13073. if (this == sp[0]) return;
  13074. var $this = $(this), d = $this.find('input.' + css.input).data(SelectPage.dataKey);
  13075. if (!d.elem.combo_input.val() && d.elem.hidden.val() && !d.option.multiple) {
  13076. d.prop.current_page = 1;//reset page to 1
  13077. cleanContent(d);
  13078. d.hideResults(d);
  13079. return true;
  13080. }
  13081. if (d.elem.results.find('li').not('.' + css.message_box).length) {
  13082. if (d.option.autoFillResult) {
  13083. //have selected item, then hide result list
  13084. if (d.elem.hidden.val()) d.hideResults(d);
  13085. else if (d.elem.results.find('li.sp_over').length) {
  13086. //no one selected and have highlight item, select the highlight item
  13087. d.selectCurrentLine(d, true);
  13088. } else if (d.option.autoSelectFirst) {
  13089. //no one selected, no one highlight, select the first item
  13090. d.nextLine(d);
  13091. d.selectCurrentLine(d, true);
  13092. } else d.hideResults(d);
  13093. } else d.hideResults(d);
  13094. } else {
  13095. //when no one item match, clear search keywords
  13096. if (d.option.noResultClean) cleanContent(d);
  13097. else {
  13098. if (!d.option.multiple) d.elem.hidden.val('');
  13099. }
  13100. d.hideResults(d);
  13101. }
  13102. });
  13103. });
  13104. };
  13105. /**
  13106. * Result list event bind
  13107. */
  13108. SelectPage.prototype.eResultList = function () {
  13109. var self = this, css = this.css_class;
  13110. self.elem.results.children('li').hover(function () {
  13111. if (self.prop.key_select) {
  13112. self.prop.key_select = false;
  13113. return;
  13114. }
  13115. if (!$(this).hasClass(css.selected) && !$(this).hasClass(css.message_box)) {
  13116. $(this).addClass(css.select);
  13117. self.setCssFocusedResults(self);
  13118. }
  13119. }, function () {
  13120. $(this).removeClass(css.select);
  13121. }).click(function (e) {
  13122. if (self.prop.key_select) {
  13123. self.prop.key_select = false;
  13124. return;
  13125. }
  13126. e.preventDefault();
  13127. e.stopPropagation();
  13128. if (!$(this).hasClass(css.selected)) self.selectCurrentLine(self, false);
  13129. });
  13130. };
  13131. /**
  13132. * Reposition result list when list beyond the visible area
  13133. */
  13134. SelectPage.prototype.eScroll = function () {
  13135. var self = this, css = this.css_class;
  13136. $(window).on('scroll.SelectPage', function (e) {
  13137. $('div.' + css.container + '.' + css.container_open).each(function () {
  13138. var $this = $(this), d = $this.find('input.' + css.input).data(SelectPage.dataKey),
  13139. offset = d.elem.result_area.offset(),
  13140. screenScrollTop = $(window).scrollTop(),
  13141. docHeight = $(document).height(),
  13142. viewHeight = $(window).height(),
  13143. listHeight = d.elem.result_area.outerHeight(),
  13144. listBottom = offset.top + listHeight,
  13145. hasOverflow = docHeight > viewHeight,
  13146. down = d.elem.result_area.hasClass('shadowDown');
  13147. if (hasOverflow) {
  13148. if (down) {//open down
  13149. if (listBottom > (viewHeight + screenScrollTop)) d.calcResultsSize(d);
  13150. } else {//open up
  13151. if (offset.top < screenScrollTop) d.calcResultsSize(d);
  13152. }
  13153. }
  13154. });
  13155. });
  13156. };
  13157. /**
  13158. * Page bar button event bind
  13159. */
  13160. SelectPage.prototype.ePaging = function () {
  13161. var self = this;
  13162. if (!self.option.pagination) return;
  13163. self.elem.navi.find('li.csFirstPage').off('click').on('click', function (ev) {
  13164. //$(self.elem.combo_input).focus();
  13165. ev.preventDefault();
  13166. self.firstPage(self);
  13167. });
  13168. self.elem.navi.find('li.csPreviousPage').off('click').on('click', function (ev) {
  13169. //$(self.elem.combo_input).focus();
  13170. ev.preventDefault();
  13171. self.prevPage(self);
  13172. });
  13173. self.elem.navi.find('li.csNextPage').off('click').on('click', function (ev) {
  13174. //$(self.elem.combo_input).focus();
  13175. ev.preventDefault();
  13176. self.nextPage(self);
  13177. });
  13178. self.elem.navi.find('li.csLastPage').off('click').on('click', function (ev) {
  13179. //$(self.elem.combo_input).focus();
  13180. ev.preventDefault();
  13181. self.lastPage(self);
  13182. });
  13183. };
  13184. /**
  13185. * Ajax request fail
  13186. * @param {Object} self
  13187. * @param {string} errorThrown
  13188. */
  13189. SelectPage.prototype.ajaxErrorNotify = function (self, errorThrown) {
  13190. self.showMessage(self, self.message.ajax_error);
  13191. };
  13192. /**
  13193. * Message box
  13194. * @param {Object} self
  13195. * @param msg {string} the text need to show
  13196. */
  13197. SelectPage.prototype.showMessage = function (self, msg) {
  13198. if (!msg) return;
  13199. var msgLi = '<li class="' + self.css_class.message_box + '"><i class="spfont sp-warning"></i> ' + msg + '</li>';
  13200. self.elem.results.empty().append(msgLi).show();
  13201. self.calcResultsSize(self);
  13202. self.setOpenStatus(self, true);
  13203. if(self.elem.control) self.elem.control.hide();
  13204. if (self.option.pagination) self.elem.navi.hide();
  13205. };
  13206. /**
  13207. * @desc Scroll
  13208. * @param {Object} self
  13209. * @param {boolean} enforce
  13210. */
  13211. SelectPage.prototype.scrollWindow = function (self, enforce) {
  13212. var current_result = self.getCurrentLine(self),
  13213. target_top = (current_result && !enforce) ? current_result.offset().top : self.elem.container.offset().top,
  13214. target_size;
  13215. self.prop.size_li = self.elem.results.children('li:first').outerHeight();
  13216. target_size = self.prop.size_li;
  13217. var gap, client_height = $(window).height(),
  13218. scroll_top = $(window).scrollTop(),
  13219. scroll_bottom = scroll_top + client_height - target_size;
  13220. if (current_result.length) {
  13221. if (target_top < scroll_top || target_size > client_height) {
  13222. //scroll to top
  13223. gap = target_top - scroll_top;
  13224. } else if (target_top > scroll_bottom) {
  13225. //scroll down
  13226. gap = target_top - scroll_bottom;
  13227. } else return; //do not scroll
  13228. } else if (target_top < scroll_top) gap = target_top - scroll_top;
  13229. window.scrollBy(0, gap);
  13230. };
  13231. /**
  13232. * change css class by status
  13233. * @param self
  13234. * @param status {boolean} true: open, false: close
  13235. */
  13236. SelectPage.prototype.setOpenStatus = function (self, status) {
  13237. var el = self.elem, css = self.css_class;
  13238. if (status) {
  13239. el.container.addClass(css.container_open);
  13240. el.result_area.addClass(css.result_open);
  13241. } else {
  13242. el.container.removeClass(css.container_open);
  13243. el.result_area.removeClass(css.result_open);
  13244. }
  13245. };
  13246. /**
  13247. * input element in focus css class set
  13248. * @param {Object} self
  13249. */
  13250. SelectPage.prototype.setCssFocusedInput = function (self) {
  13251. //$(self.elem.results).addClass(self.css_class.re_off);
  13252. //$(self.elem.combo_input).removeClass(self.css_class.input_off);
  13253. };
  13254. /**
  13255. * set result list get focus and input element lost focus
  13256. * @param {Object} self
  13257. */
  13258. SelectPage.prototype.setCssFocusedResults = function (self) {
  13259. //$(self.elem.results).removeClass(self.css_class.re_off);
  13260. //$(self.elem.combo_input).addClass(self.css_class.input_off);
  13261. };
  13262. /**
  13263. * Quick search input keywords listener
  13264. * @param {Object} self
  13265. */
  13266. SelectPage.prototype.checkValue = function (self) {
  13267. var now_value = self.elem.combo_input.val();
  13268. if (now_value != self.prop.prev_value) {
  13269. self.prop.prev_value = now_value;
  13270. self.prop.first_show = false;
  13271. if (self.option.selectOnly) self.setButtonAttrDefault();
  13272. if (!self.option.multiple && !now_value) {
  13273. self.elem.combo_input.val('');
  13274. self.elem.hidden.val('');
  13275. self.elem.clear_btn.remove();
  13276. }
  13277. self.suggest(self);
  13278. }
  13279. };
  13280. /**
  13281. * Input handle(regular input)
  13282. * @param {Object} self
  13283. * @param {Object} e - event object
  13284. */
  13285. SelectPage.prototype.processKey = function (self, e) {
  13286. if ($.inArray(e.keyCode, [37, 38, 39, 40, 27, 9, 13]) === -1) {
  13287. if (e.keyCode != 16) self.setCssFocusedInput(self); // except Shift(16)
  13288. self.inputResize(self);
  13289. if ($.type(self.option.data) === 'string') {
  13290. self.prop.last_input_time = e.timeStamp;
  13291. setTimeout(function () {
  13292. if ((e.timeStamp - self.prop.last_input_time) === 0)
  13293. self.checkValue(self);
  13294. }, self.option.inputDelay * 1000);
  13295. } else {
  13296. self.checkValue(self);
  13297. }
  13298. }
  13299. }
  13300. /**
  13301. * Input handle(control key)
  13302. * @param {Object} self
  13303. * @param {Object} e - event object
  13304. */
  13305. SelectPage.prototype.processControl = function (self, e) {
  13306. if (($.inArray(e.keyCode, [37, 38, 39, 40, 27, 9]) > -1 && self.elem.result_area.is(':visible')) ||
  13307. ($.inArray(e.keyCode, [13, 9]) > -1 && self.getCurrentLine(self))) {
  13308. e.preventDefault();
  13309. e.stopPropagation();
  13310. e.cancelBubble = true;
  13311. e.returnValue = false;
  13312. switch (e.keyCode) {
  13313. case 37:// left
  13314. if (e.shiftKey) self.firstPage(self);
  13315. else self.prevPage(self);
  13316. break;
  13317. case 38:// up
  13318. self.prop.key_select = true;
  13319. self.prevLine(self);
  13320. break;
  13321. case 39:// right
  13322. if (e.shiftKey) self.lastPage(self);
  13323. else self.nextPage(self);
  13324. break;
  13325. case 40:// down
  13326. if (self.elem.results.children('li').length) {
  13327. self.prop.key_select = true;
  13328. self.nextLine(self);
  13329. } else self.suggest(self);
  13330. break;
  13331. case 9:// tab
  13332. self.prop.key_paging = true;
  13333. self.selectCurrentLine(self, true);
  13334. //self.hideResults(self);
  13335. break;
  13336. case 13:// return
  13337. self.selectCurrentLine(self, true);
  13338. break;
  13339. case 27:// escape
  13340. self.prop.key_paging = true;
  13341. self.hideResults(self);
  13342. break;
  13343. }
  13344. }
  13345. };
  13346. /**
  13347. * Abort Ajax request
  13348. * @param {Object} self
  13349. */
  13350. SelectPage.prototype.abortAjax = function (self) {
  13351. if (self.prop.xhr) {
  13352. self.prop.xhr.abort();
  13353. self.prop.xhr = false;
  13354. }
  13355. };
  13356. /**
  13357. * Suggest result of search keywords
  13358. * @param {Object} self
  13359. */
  13360. SelectPage.prototype.suggest = function (self) {
  13361. var q_word, val = $.trim(self.elem.combo_input.val());
  13362. if (self.option.multiple) q_word = val;
  13363. else {
  13364. if (val && val == self.prop.selected_text) q_word = '';
  13365. else q_word = val;
  13366. }
  13367. q_word = q_word.split(self.option.separator);
  13368. //Before show up result list callback
  13369. if (self.option.eOpen && $.isFunction(self.option.eOpen))
  13370. self.option.eOpen.call(self);
  13371. self.abortAjax(self);
  13372. //self.setLoading(self);
  13373. var which_page_num = self.prop.current_page || 1;
  13374. if (typeof self.option.data == 'object') self.searchForJson(self, q_word, which_page_num);
  13375. else self.searchForDb(self, q_word, which_page_num);
  13376. };
  13377. /**
  13378. * Loading
  13379. * @param {Object} self
  13380. */
  13381. SelectPage.prototype.setLoading = function (self) {
  13382. if (self.elem.results.html() === '') {
  13383. //self.calcResultsSize(self);
  13384. self.setOpenStatus(self, true);
  13385. }
  13386. };
  13387. /**
  13388. * Search for ajax
  13389. * @param {Object} self
  13390. * @param {Array} q_word - query keyword
  13391. * @param {number} which_page_num - target page number
  13392. */
  13393. SelectPage.prototype.searchForDb = function (self, q_word, which_page_num) {
  13394. var p = self.option;
  13395. if (!p.eAjaxSuccess || !$.isFunction(p.eAjaxSuccess)) self.hideResults(self);
  13396. var _paramsFunc = p.params, _params = {}, searchKey = p.searchField;
  13397. //when have new query keyword, then reset page number to 1.
  13398. if (q_word.length && q_word[0] && q_word.join(self.option.separator) !== self.prop.prev_value) which_page_num = 1;
  13399. var _orgParams = {
  13400. q_word: q_word,
  13401. pageNumber: which_page_num,
  13402. pageSize: p.pageSize,
  13403. andOr: p.andOr,
  13404. orderBy: p.orderBy,
  13405. searchTable: p.dbTable,
  13406. showField: self.option.showField,
  13407. keyField: self.option.keyField,
  13408. searchField: self.option.searchField
  13409. };
  13410. if (p.orderBy !== false) _orgParams.orderBy = p.orderBy;
  13411. // 这个应该是历史遗留了,没仔细追逻辑,先留着。
  13412. _orgParams[searchKey] = q_word[0];
  13413. if (_paramsFunc) {
  13414. var result = $.isFunction(_paramsFunc) ? _paramsFunc(self) : _paramsFunc;
  13415. if (result && $.isPlainObject(result)) {
  13416. _params = $.extend({}, _orgParams, result);
  13417. } else {
  13418. _params = _orgParams;
  13419. }
  13420. } else {
  13421. _params = _orgParams;
  13422. }
  13423. self.prop.xhr = $.ajax({
  13424. dataType: 'json',
  13425. url: p.data,
  13426. type: 'POST',
  13427. data: _params,
  13428. success: function (returnData) {
  13429. if (!returnData || !$.isPlainObject(returnData)) {
  13430. self.hideResults(self);
  13431. self.ajaxErrorNotify(self, errorThrown);
  13432. return;
  13433. }
  13434. var data = {}, json = {};
  13435. try {
  13436. data = p.eAjaxSuccess(returnData);
  13437. json.originalResult = data.list;
  13438. json.cnt_whole = data.totalRow;
  13439. } catch (e) {
  13440. self.showMessage(self, self.message.ajax_error);
  13441. return;
  13442. }
  13443. if (self.elem.navi) {
  13444. $(self.elem.navi).toggleClass("hide", json.cnt_whole <= json.originalResult.length);
  13445. }
  13446. json.candidate = [];
  13447. json.keyField = [];
  13448. if (typeof json.originalResult != 'object') {
  13449. self.prop.xhr = null;
  13450. self.notFoundSearch(self);
  13451. return;
  13452. }
  13453. json.cnt_page = json.originalResult.length;
  13454. for (var i = 0; i < json.cnt_page; i++) {
  13455. for (var key in json.originalResult[i]) {
  13456. if (key == p.keyField) {
  13457. json.keyField.push(json.originalResult[i][key]);
  13458. }
  13459. if (key == p.showField) {
  13460. json.candidate.push(json.originalResult[i][key]);
  13461. }
  13462. }
  13463. }
  13464. self.prepareResults(self, json, q_word, which_page_num);
  13465. },
  13466. error: function (jqXHR, textStatus, errorThrown) {
  13467. if (textStatus != 'abort') {
  13468. self.hideResults(self);
  13469. self.ajaxErrorNotify(self, errorThrown);
  13470. }
  13471. },
  13472. complete: function () {
  13473. self.prop.xhr = null;
  13474. }
  13475. });
  13476. };
  13477. /**
  13478. * Search for json data source
  13479. * @param {Object} self
  13480. * @param {Array} q_word
  13481. * @param {number} which_page_num
  13482. */
  13483. SelectPage.prototype.searchForJson = function (self, q_word, which_page_num) {
  13484. var p = self.option, matched = [], esc_q = [], sorted = [], json = {}, i = 0, arr_reg = [];
  13485. //query keyword filter
  13486. do {
  13487. //'/\W/g'正则代表全部不是字母,数字,下划线,汉字的字符
  13488. //将非法字符进行转义
  13489. esc_q[i] = q_word[i].replace(/\W/g, '\\$&').toString();
  13490. arr_reg[i] = new RegExp(esc_q[i], 'gi');
  13491. i++;
  13492. } while (i < q_word.length);
  13493. // SELECT * FROM data WHERE field LIKE q_word;
  13494. for (var i = 0; i < p.data.length; i++) {
  13495. var flag = false, row = p.data[i], itemText;
  13496. for (var j = 0; j < arr_reg.length; j++) {
  13497. itemText = row[p.searchField];
  13498. if (p.formatItem && $.isFunction(p.formatItem))
  13499. itemText = p.formatItem(row);
  13500. if (itemText.match(arr_reg[j])) {
  13501. flag = true;
  13502. if (p.andOr == 'OR') break;
  13503. } else {
  13504. flag = false;
  13505. if (p.andOr == 'AND') break;
  13506. }
  13507. }
  13508. if (flag) matched.push(row);
  13509. }
  13510. // (CASE WHEN ...) then く order some column
  13511. if (p.orderBy === false) sorted = matched.concat();
  13512. else {
  13513. var reg1 = new RegExp('^' + esc_q[0] + '$', 'gi'),
  13514. reg2 = new RegExp('^' + esc_q[0], 'gi'),
  13515. matched1 = [], matched2 = [], matched3 = [];
  13516. for (var i = 0; i < matched.length; i++) {
  13517. var orderField = p.orderBy[0][0];
  13518. var orderValue = String(matched[i][orderField]);
  13519. if (orderValue.match(reg1)) {
  13520. matched1.push(matched[i]);
  13521. } else if (orderValue.match(reg2)) {
  13522. matched2.push(matched[i]);
  13523. } else {
  13524. matched3.push(matched[i]);
  13525. }
  13526. }
  13527. if (p.orderBy[0][1].match(/^asc$/i)) {
  13528. matched1 = self.sortAsc(self, matched1);
  13529. matched2 = self.sortAsc(self, matched2);
  13530. matched3 = self.sortAsc(self, matched3);
  13531. } else {
  13532. matched1 = self.sortDesc(self, matched1);
  13533. matched2 = self.sortDesc(self, matched2);
  13534. matched3 = self.sortDesc(self, matched3);
  13535. }
  13536. sorted = sorted.concat(matched1).concat(matched2).concat(matched3);
  13537. }
  13538. /*
  13539. if (sorted.length === undefined || sorted.length === 0 ) {
  13540. self.notFoundSearch(self);
  13541. return;
  13542. }
  13543. */
  13544. json.cnt_whole = sorted.length;
  13545. //page_move used to distinguish between init plugin or page moving
  13546. if (!self.prop.page_move) {
  13547. //only single mode can be used page number relocation
  13548. if (!p.multiple) {
  13549. //get selected item belong page number
  13550. var currentValue = self.elem.hidden.val();
  13551. if ($.type(currentValue) !== 'undefined' && $.trim(currentValue) !== '') {
  13552. var index = 0;
  13553. $.each(sorted, function (i, row) {
  13554. if (row[p.keyField] == currentValue) {
  13555. index = i + 1;
  13556. return false;
  13557. }
  13558. });
  13559. which_page_num = Math.ceil(index / p.pageSize);
  13560. if (which_page_num < 1) which_page_num = 1;
  13561. self.prop.current_page = which_page_num;
  13562. }
  13563. }
  13564. } else {
  13565. //set page number to 1 when result number less then page size
  13566. if (sorted.length <= ((which_page_num - 1) * p.pageSize)) {
  13567. which_page_num = 1;
  13568. self.prop.current_page = 1;
  13569. }
  13570. }
  13571. //LIMIT xx OFFSET xx
  13572. var start = (which_page_num - 1) * p.pageSize, end = start + p.pageSize;
  13573. //save original data
  13574. json.originalResult = [];
  13575. //after data filter handle
  13576. for (var i = start; i < end; i++) {
  13577. if (sorted[i] === undefined) break;
  13578. json.originalResult.push(sorted[i]);
  13579. for (var key in sorted[i]) {
  13580. if (key == p.keyField) {
  13581. if (json.keyField === undefined) json.keyField = [];
  13582. json.keyField.push(sorted[i][key]);
  13583. }
  13584. if (key == p.showField) {
  13585. if (json.candidate === undefined) json.candidate = [];
  13586. json.candidate.push(sorted[i][key]);
  13587. }
  13588. }
  13589. }
  13590. if (json.candidate === undefined) json.candidate = [];
  13591. json.cnt_page = json.candidate.length;
  13592. self.prepareResults(self, json, q_word, which_page_num);
  13593. };
  13594. /**
  13595. * Set order asc
  13596. * @param {Object} self
  13597. * @param {Array} arr - result array
  13598. */
  13599. SelectPage.prototype.sortAsc = function (self, arr) {
  13600. arr.sort(function (a, b) {
  13601. var valA = a[self.option.orderBy[0][0]], valB = b[self.option.orderBy[0][0]];
  13602. return $.type(valA) === 'number' ? valA - valB : String(valA).localeCompare(String(valB));
  13603. });
  13604. return arr;
  13605. };
  13606. /**
  13607. * Set order desc
  13608. * @param {Object} self
  13609. * @param {Array} arr - result array
  13610. */
  13611. SelectPage.prototype.sortDesc = function (self, arr) {
  13612. arr.sort(function (a, b) {
  13613. var valA = a[self.option.orderBy[0][0]], valB = b[self.option.orderBy[0][0]];
  13614. return $.type(valA) === 'number' ? valB - valA : String(valB).localeCompare(String(valA));
  13615. });
  13616. return arr;
  13617. };
  13618. /**
  13619. * Not result found handle
  13620. * @param {Object} self
  13621. */
  13622. SelectPage.prototype.notFoundSearch = function (self) {
  13623. self.elem.results.empty();
  13624. self.calcResultsSize(self);
  13625. self.setOpenStatus(self, true);
  13626. self.setCssFocusedInput(self);
  13627. };
  13628. /**
  13629. * Prepare data to show
  13630. * @param {Object} self
  13631. * @param {Object} json - data result
  13632. * @param {Array} q_word - query keyword
  13633. * @param {number} which_page_num - target page number
  13634. */
  13635. SelectPage.prototype.prepareResults = function (self, json, q_word, which_page_num) {
  13636. self.data = json.originalResult;
  13637. if (self.option.pagination) self.setNavi(self, json.cnt_whole, json.cnt_page, which_page_num);
  13638. if (!json.keyField) json.keyField = false;
  13639. if (self.option.selectOnly && json.candidate.length === 1 && json.candidate[0] == q_word[0]) {
  13640. self.elem.hidden.val(json.keyField[0]);
  13641. this.setButtonAttrDefault();
  13642. }
  13643. var is_query = false;
  13644. if (q_word && q_word.length && q_word[0]) is_query = true;
  13645. self.displayResults(self, json, is_query);
  13646. };
  13647. /**
  13648. * Build page bar
  13649. * @param {Object} self
  13650. * @param {number} cnt_whole - total record count
  13651. * @param {number} cnt_page
  13652. * @param {number} page_num - current page number
  13653. */
  13654. SelectPage.prototype.setNavi = function (self, cnt_whole, cnt_page, page_num) {
  13655. var msg = self.message;
  13656. /**
  13657. * build pagination bar
  13658. */
  13659. var buildPageNav = function (self, pagebar, page_num, last_page) {
  13660. var updatePageInfo = function () {
  13661. var pageInfo = msg.page_info;
  13662. return pageInfo.replace(self.template.page.current, page_num).replace(self.template.page.total, last_page);
  13663. };
  13664. if (pagebar.find('li').length === 0) {
  13665. pagebar.hide().empty();
  13666. var iconFist = 'spfont sp-first',
  13667. iconPrev = 'spfont sp-previous',
  13668. iconNext = 'spfont sp-next',
  13669. iconLast = 'spfont sp-last';
  13670. pagebar.append('<li class="csFirstPage" title="' + msg.first_title + '" ><a href="javascript:void(0);"> <i class="' + iconFist + '"></i> </a></li>');
  13671. pagebar.append('<li class="csPreviousPage" title="' + msg.prev_title + '" ><a href="javascript:void(0);"><i class="' + iconPrev + '"></i></a></li>');
  13672. //pagination information
  13673. pagebar.append('<li class="pageInfoBox"><a href="javascript:void(0);"> ' + updatePageInfo() + ' </a></li>');
  13674. pagebar.append('<li class="csNextPage" title="' + msg.next_title + '" ><a href="javascript:void(0);"><i class="' + iconNext + '"></i></a></li>');
  13675. pagebar.append('<li class="csLastPage" title="' + msg.last_title + '" ><a href="javascript:void(0);"> <i class="' + iconLast + '"></i> </a></li>');
  13676. pagebar.show();
  13677. } else {
  13678. pagebar.find('li.pageInfoBox a').html(updatePageInfo());
  13679. }
  13680. };
  13681. var pagebar = self.elem.navi.find('ul'),
  13682. last_page = Math.ceil(cnt_whole / self.option.pageSize); //calculate total page
  13683. if (last_page === 0) page_num = 0;
  13684. else {
  13685. if (last_page < page_num) page_num = last_page;
  13686. else if (page_num === 0) page_num = 1;
  13687. }
  13688. self.prop.current_page = page_num;//update current page number
  13689. self.prop.max_page = last_page;//update page count
  13690. buildPageNav(self, pagebar, page_num, last_page);
  13691. //update paging status
  13692. var dClass = 'disabled',
  13693. first = pagebar.find('li.csFirstPage'),
  13694. previous = pagebar.find('li.csPreviousPage'),
  13695. next = pagebar.find('li.csNextPage'),
  13696. last = pagebar.find('li.csLastPage');
  13697. //first and previous
  13698. if (page_num === 1 || page_num === 0) {
  13699. if (!first.hasClass(dClass)) first.addClass(dClass);
  13700. if (!previous.hasClass(dClass)) previous.addClass(dClass);
  13701. } else {
  13702. if (first.hasClass(dClass)) first.removeClass(dClass);
  13703. if (previous.hasClass(dClass)) previous.removeClass(dClass);
  13704. }
  13705. //next and last
  13706. if (page_num === last_page || last_page === 0) {
  13707. if (!next.hasClass(dClass)) next.addClass(dClass);
  13708. if (!last.hasClass(dClass)) last.addClass(dClass);
  13709. } else {
  13710. if (next.hasClass(dClass)) next.removeClass(dClass);
  13711. if (last.hasClass(dClass)) last.removeClass(dClass);
  13712. }
  13713. if (last_page > 1) self.ePaging(); //pagination event bind
  13714. };
  13715. /**
  13716. * Render result list
  13717. * @param {Object} self
  13718. * @param {Object} json - result data
  13719. * @param {boolean} is_query - used to different from search to open and just click to open
  13720. */
  13721. SelectPage.prototype.displayResults = function (self, json, is_query) {
  13722. var p = self.option, el = self.elem;
  13723. el.results.hide().empty();
  13724. if (p.multiple && $.type(p.maxSelectLimit) === 'number' && p.maxSelectLimit > 0) {
  13725. var selectedSize = el.element_box.find('li.selected_tag').length;
  13726. if (selectedSize > 0 && selectedSize >= p.maxSelectLimit) {
  13727. var msg = self.message.max_selected;
  13728. self.showMessage(self, msg.replace(self.template.msg.maxSelectLimit, p.maxSelectLimit));
  13729. return;
  13730. }
  13731. }
  13732. if (json.candidate.length) {
  13733. var arr_candidate = json.candidate,
  13734. arr_primary_key = json.keyField,
  13735. keystr = el.hidden.val(),
  13736. keyArr = keystr ? keystr.split(',') : new Array(),
  13737. itemText = '';
  13738. for (var i = 0; i < arr_candidate.length; i++) {
  13739. if (p.formatItem && $.isFunction(p.formatItem)) {
  13740. try {
  13741. itemText = p.formatItem(json.originalResult[i]);
  13742. } catch (e) {
  13743. console.error('formatItem内容格式化函数内容设置不正确!');
  13744. itemText = arr_candidate[i];
  13745. }
  13746. } else itemText = arr_candidate[i];
  13747. var list = $('<li>').html(itemText).attr({
  13748. pkey: arr_primary_key[i],
  13749. index: i
  13750. });
  13751. if (!p.formatItem) list.attr('title', itemText);
  13752. //Set selected item highlight
  13753. if ($.inArray(arr_primary_key[i].toString(), keyArr) !== -1) {
  13754. list.addClass(self.css_class.selected);
  13755. }
  13756. //cache item data
  13757. list.data('dataObj', json.originalResult[i]);
  13758. el.results.append(list);
  13759. }
  13760. } else {
  13761. var li = '<li class="' + self.css_class.message_box + '"><i class="spfont sp-warning"></i> ' +
  13762. self.message.not_found + '</li>';
  13763. el.results.append(li);
  13764. }
  13765. el.results.show();
  13766. if (p.multiple && p.multipleControlbar) el.control.show();
  13767. if (p.pagination) el.navi.show();
  13768. self.calcResultsSize(self);
  13769. self.setOpenStatus(self, true);
  13770. //Result item event bind
  13771. self.eResultList();
  13772. //scrolling listen
  13773. self.eScroll();
  13774. //auto highlight first item in search, have result and set autoSelectFirst to true situation
  13775. if (is_query && json.candidate.length && p.autoSelectFirst) self.nextLine(self);
  13776. };
  13777. /**
  13778. * Calculate result list size and position
  13779. * @param {Object} self
  13780. */
  13781. SelectPage.prototype.calcResultsSize = function (self) {
  13782. var p = self.option, el = self.elem;
  13783. var rePosition = function () {
  13784. if (el.container.css('position') === 'static') {
  13785. // position: static
  13786. var offset = el.combo_input.offset();
  13787. el.result_area.css({
  13788. top: offset.top + el.combo_input.outerHeight() + 'px',
  13789. left: offset.left + 'px'
  13790. });
  13791. } else {
  13792. if (!p.pagination) {
  13793. var itemHeight = el.results.find('li:first').outerHeight(true),
  13794. listHeight = itemHeight * p.listSize;
  13795. el.results.css({
  13796. 'max-height': listHeight,
  13797. 'overflow-y': 'auto'
  13798. });
  13799. }
  13800. //handle result list show up side(left, right, up or down)
  13801. var docWidth = $(document).width(),
  13802. docHeight = $(document).height(), //the document full height
  13803. viewHeight = $(window).height(), //browser visible area height
  13804. offset = el.container.offset(),
  13805. screenScrollTop = $(window).scrollTop(),
  13806. listWidth = el.result_area.outerWidth(),
  13807. //result list height
  13808. listHeight = el.result_area.outerHeight(),
  13809. //default left used input element left
  13810. defaultLeft = offset.left, //p.multiple ? -1 : 0;
  13811. //input element height
  13812. inputHeight = el.container.outerHeight(),
  13813. left = (offset.left + listWidth) > docWidth ?
  13814. defaultLeft - (listWidth - el.container.outerWidth()) :
  13815. defaultLeft,
  13816. //the actual top coordinate of input element(outer div)
  13817. screenTop = offset.top, //$(el.container).scrollTop();//offset.top - screenScrollTop;
  13818. top = 0, dist = 5, //set distance between input element and result list
  13819. //the actual top coordinate of result list
  13820. listBottom = screenTop + inputHeight + listHeight + dist,
  13821. listTop = screenTop + listHeight + dist,
  13822. hasOverflow = docHeight > viewHeight;
  13823. if ((screenTop - screenScrollTop - dist > listHeight) &&
  13824. (hasOverflow && listBottom > (viewHeight + screenScrollTop)) ||
  13825. (!hasOverflow && listBottom > viewHeight && screenTop >= listTop)) {
  13826. //open up
  13827. top = offset.top - listHeight - dist;
  13828. el.result_area.removeClass('shadowUp shadowDown').addClass('shadowUp');
  13829. } else {
  13830. //open down
  13831. top = offset.top + (p.multiple ? el.container.outerHeight() : inputHeight);
  13832. el.result_area.removeClass('shadowUp shadowDown').addClass('shadowDown');
  13833. top += dist;
  13834. }
  13835. return {
  13836. top: top + 'px', left: left + 'px'
  13837. };
  13838. }
  13839. };
  13840. if (el.result_area.is(':visible')) {
  13841. el.result_area.css(rePosition());
  13842. } else {
  13843. var pss = rePosition();
  13844. el.result_area.css(pss).show(1, function () {
  13845. var repss = rePosition();
  13846. if (pss.top !== repss.top || pss.left !== repss.left) el.result_area.css(repss);
  13847. });
  13848. }
  13849. };
  13850. /**
  13851. * hide result list
  13852. * @param {Object} self
  13853. */
  13854. SelectPage.prototype.hideResults = function (self) {
  13855. if (self.prop.key_paging) {
  13856. self.scrollWindow(self, true);
  13857. self.prop.key_paging = false;
  13858. }
  13859. self.setCssFocusedInput(self);
  13860. if (self.option.autoFillResult) {
  13861. //self.selectCurrentLine(self, true);
  13862. }
  13863. self.elem.results.empty();
  13864. self.elem.result_area.hide();
  13865. self.setOpenStatus(self, false);
  13866. //unbind window scroll listen
  13867. $(window).off('scroll.SelectPage');
  13868. self.abortAjax(self);
  13869. self.setButtonAttrDefault();
  13870. };
  13871. /**
  13872. * set plugin to disabled / enabled
  13873. * @param self
  13874. * @param disabled
  13875. */
  13876. SelectPage.prototype.disabled = function (self, disabled) {
  13877. var p = self.option, el = self.elem;
  13878. if ($.type(disabled) === 'undefined') return el.combo_input.prop('disabled');
  13879. if ($.type(disabled) === 'boolean') {
  13880. el.combo_input.prop('disabled', disabled);
  13881. if (disabled) el.container.addClass(self.css_class.disabled);
  13882. else el.container.removeClass(self.css_class.disabled);
  13883. }
  13884. };
  13885. /**
  13886. * Go fist page
  13887. * @param {Object} self
  13888. */
  13889. SelectPage.prototype.firstPage = function (self) {
  13890. if (self.prop.current_page > 1) {
  13891. self.prop.current_page = 1;
  13892. self.prop.page_move = true;
  13893. self.suggest(self);
  13894. }
  13895. };
  13896. /**
  13897. * Go previous page
  13898. * @param {Object} self
  13899. */
  13900. SelectPage.prototype.prevPage = function (self) {
  13901. if (self.prop.current_page > 1) {
  13902. self.prop.current_page--;
  13903. self.prop.page_move = true;
  13904. self.suggest(self);
  13905. }
  13906. };
  13907. /**
  13908. * Go next page
  13909. * @param {Object} self
  13910. */
  13911. SelectPage.prototype.nextPage = function (self) {
  13912. if (self.prop.current_page < self.prop.max_page) {
  13913. self.prop.current_page++;
  13914. self.prop.page_move = true;
  13915. self.suggest(self);
  13916. }
  13917. };
  13918. /**
  13919. * Go last page
  13920. * @param {Object} self
  13921. */
  13922. SelectPage.prototype.lastPage = function (self) {
  13923. if (self.prop.current_page < self.prop.max_page) {
  13924. self.prop.current_page = self.prop.max_page;
  13925. self.prop.page_move = true;
  13926. self.suggest(self);
  13927. }
  13928. };
  13929. /**
  13930. * do something after select/unSelect action
  13931. * @param {Object} self
  13932. * @param {boolean} reOpen
  13933. */
  13934. SelectPage.prototype.afterAction = function (self, reOpen) {
  13935. self.inputResize(self);
  13936. self.elem.combo_input.change();
  13937. self.setCssFocusedInput(self);
  13938. if (self.prop.init_set) return;
  13939. if (self.option.multiple) {
  13940. if (self.option.selectToCloseList) {
  13941. self.hideResults(self);
  13942. self.elem.combo_input.blur();
  13943. }
  13944. if (!self.option.selectToCloseList && reOpen) {
  13945. self.suggest(self);
  13946. self.elem.combo_input.focus();
  13947. }
  13948. } else {
  13949. self.hideResults(self);
  13950. self.elem.combo_input.blur();
  13951. }
  13952. };
  13953. /**
  13954. * Select current list item
  13955. * @param {Object} self
  13956. * @param {boolean} is_enter_key
  13957. */
  13958. SelectPage.prototype.selectCurrentLine = function (self, is_enter_key) {
  13959. self.scrollWindow(self, true);
  13960. var p = self.option, current = self.getCurrentLine(self);
  13961. if (current) {
  13962. var data = current.data('dataObj');
  13963. var text = data[p.showField] || current.text();
  13964. var value = current.attr('pkey');
  13965. if (!p.multiple) {
  13966. self.elem.combo_input.val(text);
  13967. self.elem.hidden.val(value);
  13968. } else {
  13969. //build tags in multiple selection mode
  13970. self.elem.combo_input.val('');
  13971. var item = {text: text, value: value};
  13972. if (!self.isAlreadySelected(self, item)) {
  13973. self.addNewTag(self, data, item);
  13974. self.tagValuesSet(self);
  13975. }
  13976. }
  13977. if (p.selectOnly) self.setButtonAttrDefault();
  13978. //Select item callback
  13979. if (p.eSelect && $.isFunction(p.eSelect)) p.eSelect(data, self);
  13980. self.prop.prev_value = self.elem.combo_input.val();
  13981. self.prop.selected_text = self.elem.combo_input.val();
  13982. self.putClearButton();
  13983. }
  13984. self.afterAction(self, true);
  13985. };
  13986. /**
  13987. * Show clear button when item selected in single selection mode
  13988. */
  13989. SelectPage.prototype.putClearButton = function () {
  13990. if (!this.option.multiple && !this.elem.combo_input.prop('disabled')) this.elem.container.append(this.elem.clear_btn);
  13991. };
  13992. /**
  13993. * Select all list item
  13994. * @param {Object} self
  13995. */
  13996. SelectPage.prototype.selectAllLine = function (self) {
  13997. var p = self.option, jsonarr = new Array();
  13998. self.elem.results.find('li').each(function (i, row) {
  13999. var $row = $(row), data = $row.data('dataObj');
  14000. var text = data[p.showField] || $row.text();
  14001. var value = $row.attr('pkey');
  14002. var item = {text: text, value: value};
  14003. if (!self.isAlreadySelected(self, item)) {
  14004. self.addNewTag(self, data, item);
  14005. self.tagValuesSet(self);
  14006. }
  14007. jsonarr.push(data);
  14008. //limited max selected items
  14009. if ($.type(p.maxSelectLimit) === 'number' &&
  14010. p.maxSelectLimit > 0 &&
  14011. p.maxSelectLimit === self.elem.element_box.find('li.selected_tag').length) {
  14012. return false;
  14013. }
  14014. });
  14015. if (p.eSelect && $.isFunction(p.eSelect)) p.eSelect(jsonarr, self);
  14016. self.afterAction(self, true);
  14017. };
  14018. /**
  14019. * Cancel select all item in current page
  14020. * @param {Object} self
  14021. */
  14022. SelectPage.prototype.unSelectAllLine = function (self) {
  14023. var p = self.option, size = self.elem.results.find('li').length, ds = [];
  14024. self.elem.results.find('li').each(function (i, row) {
  14025. var key = $(row).attr('pkey');
  14026. var tag = self.elem.element_box.find('li.selected_tag[itemvalue="' + key + '"]');
  14027. if (tag.length) ds.push(tag.data('dataObj'));
  14028. self.removeTag(self, tag);
  14029. });
  14030. self.afterAction(self, true);
  14031. if (p.eTagRemove && $.isFunction(p.eTagRemove)) p.eTagRemove(ds);
  14032. };
  14033. /**
  14034. * Clear all selected items
  14035. * @param {Object} self
  14036. * @param {boolean} open - open list after clear selected item
  14037. */
  14038. SelectPage.prototype.clearAll = function (self, open) {
  14039. var p = self.option, ds = [];
  14040. if (p.multiple) {
  14041. self.elem.element_box.find('li.selected_tag').each(function (i, row) {
  14042. ds.push($(row).data('dataObj'));
  14043. row.remove();
  14044. });
  14045. self.elem.element_box.find('li.selected_tag').remove();
  14046. }
  14047. self.reset(self);
  14048. self.afterAction(self, open);
  14049. if (p.multiple) {
  14050. if (p.eTagRemove && $.isFunction(p.eTagRemove)) p.eTagRemove(ds);
  14051. } else self.elem.clear_btn.remove();
  14052. };
  14053. /**
  14054. * reset
  14055. */
  14056. SelectPage.prototype.reset = function (self) {
  14057. self.elem.combo_input.val('');
  14058. self.elem.hidden.val('');
  14059. self.prop.prev_value = '';
  14060. self.prop.selected_text = '';
  14061. self.prop.current_page = 1;
  14062. };
  14063. /**
  14064. * Get current highlight item
  14065. * @param {Object} self
  14066. */
  14067. SelectPage.prototype.getCurrentLine = function (self) {
  14068. if (self.elem.result_area.is(':hidden')) return false;
  14069. var obj = self.elem.results.find('li.' + self.css_class.select);
  14070. if (obj.length) return obj;
  14071. else return false;
  14072. };
  14073. /**
  14074. * Check the result item is already selected or not
  14075. * @param {Object} self
  14076. * @param {Object} item - item info
  14077. */
  14078. SelectPage.prototype.isAlreadySelected = function (self, item) {
  14079. var isExist = false;
  14080. if (item.value) {
  14081. var keys = self.elem.hidden.val();
  14082. if (keys) {
  14083. var karr = keys.split(',');
  14084. if (karr && karr.length && $.inArray(item.value, karr) != -1) isExist = true;
  14085. }
  14086. }
  14087. return isExist;
  14088. };
  14089. /**
  14090. * Add a new tag in multiple selection mode
  14091. * @param {Object} self
  14092. * @param {object} data - raw row data
  14093. * @param {Object} item
  14094. */
  14095. SelectPage.prototype.addNewTag = function (self, data, item) {
  14096. if (!self.option.multiple || !data || !item) return;
  14097. var tmp = self.template.tag.content, tag;
  14098. tmp = tmp.replace(self.template.tag.textKey, item.text);
  14099. tmp = tmp.replace(self.template.tag.valueKey, item.value);
  14100. tag = $(tmp);
  14101. tag.data('dataObj', data);
  14102. if (self.elem.combo_input.prop('disabled')) tag.find('span.tag_close').hide();
  14103. self.elem.combo_input.closest('li').before(tag);
  14104. };
  14105. /**
  14106. * Remove a tag in multiple selection mode
  14107. * @param {Object} self
  14108. * @param {Object} item
  14109. */
  14110. SelectPage.prototype.removeTag = function (self, item) {
  14111. var key = $(item).attr('itemvalue');
  14112. var keys = self.elem.hidden.val();
  14113. if ($.type(key) != 'undefined' && keys) {
  14114. var keyarr = keys.split(','),
  14115. index = $.inArray(key.toString(), keyarr);
  14116. if (index != -1) {
  14117. keyarr.splice(index, 1);
  14118. self.elem.hidden.val(keyarr.toString()).trigger("change");
  14119. }
  14120. }
  14121. $(item).remove();
  14122. self.inputResize(self);
  14123. };
  14124. /**
  14125. * Selected item value(keyField) put in to hidden element
  14126. * @param {Object} self
  14127. */
  14128. SelectPage.prototype.tagValuesSet = function (self) {
  14129. if (!self.option.multiple) return;
  14130. var tags = self.elem.element_box.find('li.selected_tag');
  14131. if (tags && tags.length) {
  14132. var result = new Array();
  14133. $.each(tags, function (i, li) {
  14134. var v = $(li).attr('itemvalue');
  14135. if ($.type(v) !== 'undefined') result.push(v);
  14136. });
  14137. if (result.length) {
  14138. self.elem.hidden.val(result.join(',')).trigger("change");
  14139. }
  14140. }
  14141. };
  14142. /**
  14143. * auto resize input element width in multiple select mode
  14144. * @param {Object} self
  14145. */
  14146. SelectPage.prototype.inputResize = function (self) {
  14147. if (!self.option.multiple) return;
  14148. var width = '',
  14149. inputLi = self.elem.combo_input.closest('li');
  14150. var setDefaultSize = function (self, inputLi) {
  14151. inputLi.removeClass('full_width');
  14152. var minimumWidth = self.elem.combo_input.val().length + 1,
  14153. width = (minimumWidth * 0.75) + 'em';
  14154. self.elem.combo_input.css('width', width).removeAttr('placeholder');
  14155. };
  14156. if (self.elem.element_box.find('li.selected_tag').length === 0) {
  14157. if (!inputLi.hasClass('full_width')) inputLi.addClass('full_width');
  14158. if (self.elem.combo_input.attr('placeholder_bak')) {
  14159. self.elem.combo_input.attr('placeholder', self.elem.combo_input.attr('placeholder_bak')).removeAttr('style');
  14160. }
  14161. } else setDefaultSize(self, inputLi);
  14162. };
  14163. /**
  14164. * Move to next line
  14165. * @param {Object} self
  14166. */
  14167. SelectPage.prototype.nextLine = function (self) {
  14168. var obj = self.getCurrentLine(self), idx;
  14169. if (!obj) idx = -1;
  14170. else {
  14171. idx = self.elem.results.children('li').index(obj);
  14172. obj.removeClass(self.css_class.select);
  14173. }
  14174. idx++;
  14175. if (idx < self.elem.results.children('li').length) {
  14176. var next = self.elem.results.children('li').eq(idx);
  14177. next.addClass(self.css_class.select);
  14178. self.setCssFocusedResults(self);
  14179. } else self.setCssFocusedInput(self);
  14180. self.scrollWindow(self, false);
  14181. };
  14182. /**
  14183. * Move to previous line
  14184. * @param {Object} self
  14185. */
  14186. SelectPage.prototype.prevLine = function (self) {
  14187. var obj = self.getCurrentLine(self), idx;
  14188. if (!obj) idx = self.elem.results.children('li').length;
  14189. else {
  14190. idx = self.elem.results.children('li').index(obj);
  14191. obj.removeClass(self.css_class.select);
  14192. }
  14193. idx--;
  14194. if (idx > -1) {
  14195. var prev = self.elem.results.children('li').eq(idx);
  14196. prev.addClass(self.css_class.select);
  14197. self.setCssFocusedResults(self);
  14198. } else self.setCssFocusedInput(self);
  14199. self.scrollWindow(self, false);
  14200. };
  14201. /**
  14202. * SelectPage plugin definition
  14203. * @global
  14204. * @param option {Object} init plugin option
  14205. */
  14206. function Plugin(option) {
  14207. return this.each(function () {
  14208. var $this = $(this),
  14209. data = $this.data(SelectPage.dataKey),
  14210. params = $.extend({}, defaults, $this.data(), data && data.option, typeof option === 'object' && option);
  14211. if (!data) $this.data(SelectPage.dataKey, (data = new SelectPage(this, params)));
  14212. });
  14213. }
  14214. /**
  14215. * Get plugin object
  14216. * @param {object} obj
  14217. * @returns
  14218. */
  14219. function getPlugin(obj) {
  14220. return $(obj).closest('div.sp_container').find('input.sp_input');
  14221. }
  14222. /**
  14223. * Clear all selected item
  14224. */
  14225. function ClearSelected() {
  14226. return this.each(function () {
  14227. var $this = getPlugin(this),
  14228. data = $this.data(SelectPage.dataKey);
  14229. if (data) {
  14230. data.prop.init_set = true;
  14231. data.clearAll(data);
  14232. data.prop.init_set = false;
  14233. }
  14234. });
  14235. }
  14236. /**
  14237. * Refresh result list
  14238. * use case:
  14239. * 1.use $(obj).val('xxx') to modify selectpage selected item key
  14240. * 2.refresh selected item show content/tag text
  14241. */
  14242. function SelectedRefresh() {
  14243. return this.each(function () {
  14244. var $this = getPlugin(this),
  14245. data = $this.data(SelectPage.dataKey);
  14246. if (data && data.elem.hidden.val())
  14247. data.setInitRecord(true);
  14248. });
  14249. }
  14250. /**
  14251. * Modify plugin datasource, only work on json datasource mode
  14252. * @param {array} data - new datasource
  14253. * @example
  14254. * [{name:'aa',sex:1},{name:'bb',sex:0},{...}]
  14255. */
  14256. function ModifyDataSource(data) {
  14257. return this.each(function () {
  14258. if (data && $.isArray(data)) {
  14259. var $this = getPlugin(this),
  14260. plugin = $this.data(SelectPage.dataKey);
  14261. if (plugin) {
  14262. plugin.clearAll(plugin);
  14263. plugin.option.data = data;
  14264. }
  14265. }
  14266. });
  14267. }
  14268. /**
  14269. * Get plugin disabled status or Modify plugin disabled status
  14270. * @param disabled {boolean} set disabled status
  14271. */
  14272. function PluginDisabled(disabled) {
  14273. var status = false;
  14274. this.each(function () {
  14275. var $this = getPlugin(this),
  14276. plugin = $this.data(SelectPage.dataKey);
  14277. if (plugin) {
  14278. if ($.type(disabled) !== 'undefined')
  14279. plugin.disabled(plugin, disabled);
  14280. else
  14281. status = plugin.disabled(plugin);
  14282. }
  14283. });
  14284. return status;
  14285. }
  14286. /**
  14287. * Get selected item text
  14288. * @returns {string}
  14289. */
  14290. function GetInputText() {
  14291. var str = '';
  14292. this.each(function () {
  14293. var $this = getPlugin(this), data = $this.data(SelectPage.dataKey);
  14294. if (data) {
  14295. if (data.option.multiple) {
  14296. var tags = [];
  14297. data.elem.element_box.find('li.selected_tag').each(function (i, tag) {
  14298. tags.push($(tag).text());
  14299. });
  14300. str += tags.toString();
  14301. } else {
  14302. str += data.elem.combo_input.val();
  14303. }
  14304. }
  14305. });
  14306. return str;
  14307. }
  14308. /**
  14309. * Get selected item raw data
  14310. * @returns {any[]}
  14311. */
  14312. function GetSelectedData () {
  14313. var results = [];
  14314. this.each(function () {
  14315. var $this = getPlugin(this), data = $this.data(SelectPage.dataKey);
  14316. if (data) {
  14317. if (data.option.multiple) {
  14318. data.elem.element_box.find('li.selected_tag').each(function (i, tag) {
  14319. results.push($(tag).data('dataObj'));
  14320. });
  14321. } else {
  14322. var selected = data.elem.combo_input.data('dataObj');
  14323. if (selected) results.push(selected);
  14324. }
  14325. }
  14326. });
  14327. return results;
  14328. }
  14329. var old = $.fn.selectPage;
  14330. $.fn.selectPage = Plugin;
  14331. $.fn.selectPage.Constructor = SelectPage;
  14332. $.fn.selectPageClear = ClearSelected;
  14333. $.fn.selectPageRefresh = SelectedRefresh;
  14334. $.fn.selectPageData = ModifyDataSource;
  14335. $.fn.selectPageDisabled = PluginDisabled;
  14336. $.fn.selectPageText = GetInputText;
  14337. $.fn.selectPageSelectedData = GetSelectedData;
  14338. // SelectPage no conflict
  14339. // =================
  14340. $.fn.selectPage.noConflict = function () {
  14341. $.fn.selectPage = old;
  14342. return this;
  14343. };
  14344. })(window.jQuery);
  14345. define("selectpage", ["jquery"], (function (global) {
  14346. return function () {
  14347. var ret, fn;
  14348. return ret || global.$.fn.extend;
  14349. };
  14350. }(this)));
  14351. /**
  14352. * @version: 2.1.30
  14353. * @author: Dan Grossman http://www.dangrossman.info/
  14354. * @copyright: Copyright (c) 2012-2017 Dan Grossman. All rights reserved.
  14355. * @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php
  14356. * @website: http://www.daterangepicker.com/
  14357. */
  14358. // Follow the UMD template https://github.com/umdjs/umd/blob/master/templates/returnExportsGlobal.js
  14359. (function (root, factory) {
  14360. if (typeof define === 'function' && define.amd) {
  14361. // AMD. Make globaly available as well
  14362. define('bootstrap-daterangepicker',['moment', 'jquery'], function (moment, jquery) {
  14363. if (!jquery.fn) jquery.fn = {}; // webpack server rendering
  14364. return factory(moment, jquery);
  14365. });
  14366. } else if (typeof module === 'object' && module.exports) {
  14367. // Node / Browserify
  14368. //isomorphic issue
  14369. var jQuery = (typeof window != 'undefined') ? window.jQuery : undefined;
  14370. if (!jQuery) {
  14371. jQuery = require('jquery');
  14372. if (!jQuery.fn) jQuery.fn = {};
  14373. }
  14374. var moment = (typeof window != 'undefined' && typeof window.moment != 'undefined') ? window.moment : require('moment');
  14375. module.exports = factory(moment, jQuery);
  14376. } else {
  14377. // Browser globals
  14378. root.daterangepicker = factory(root.moment, root.jQuery);
  14379. }
  14380. }(this, function(moment, $) {
  14381. var DateRangePicker = function(element, options, cb) {
  14382. //default settings for options
  14383. this.parentEl = 'body';
  14384. this.element = $(element);
  14385. this.startDate = moment().startOf('day');
  14386. this.endDate = moment().endOf('day');
  14387. this.minDate = false;
  14388. this.maxDate = false;
  14389. this.dateLimit = false;
  14390. this.autoApply = false;
  14391. this.singleDatePicker = false;
  14392. this.showDropdowns = false;
  14393. this.showWeekNumbers = false;
  14394. this.showISOWeekNumbers = false;
  14395. this.showCustomRangeLabel = true;
  14396. this.timePicker = false;
  14397. this.timePicker24Hour = false;
  14398. this.timePickerIncrement = 1;
  14399. this.timePickerSeconds = false;
  14400. this.linkedCalendars = true;
  14401. this.autoUpdateInput = true;
  14402. this.alwaysShowCalendars = false;
  14403. this.ranges = {};
  14404. this.opens = 'right';
  14405. if (this.element.hasClass('pull-right'))
  14406. this.opens = 'left';
  14407. this.drops = 'down';
  14408. if (this.element.hasClass('dropup'))
  14409. this.drops = 'up';
  14410. this.buttonClasses = 'btn btn-sm';
  14411. this.applyClass = 'btn-success';
  14412. this.cancelClass = 'btn-default';
  14413. this.locale = {
  14414. direction: 'ltr',
  14415. format: moment.localeData().longDateFormat('L'),
  14416. separator: ' - ',
  14417. applyLabel: 'Apply',
  14418. cancelLabel: 'Cancel',
  14419. weekLabel: 'W',
  14420. customRangeLabel: 'Custom Range',
  14421. daysOfWeek: moment.weekdaysMin(),
  14422. monthNames: moment.monthsShort(),
  14423. firstDay: moment.localeData().firstDayOfWeek()
  14424. };
  14425. this.callback = function() { };
  14426. //some state information
  14427. this.isShowing = false;
  14428. this.leftCalendar = {};
  14429. this.rightCalendar = {};
  14430. //custom options from user
  14431. if (typeof options !== 'object' || options === null)
  14432. options = {};
  14433. //allow setting options with data attributes
  14434. //data-api options will be overwritten with custom javascript options
  14435. options = $.extend(this.element.data(), options);
  14436. //html template for the picker UI
  14437. if (typeof options.template !== 'string' && !(options.template instanceof $))
  14438. options.template = '<div class="daterangepicker dropdown-menu">' +
  14439. '<div class="calendar left">' +
  14440. '<div class="daterangepicker_input">' +
  14441. '<input class="input-mini form-control" type="text" name="daterangepicker_start" value="" />' +
  14442. '<i class="fa fa-calendar glyphicon glyphicon-calendar"></i>' +
  14443. '<div class="calendar-time">' +
  14444. '<div></div>' +
  14445. '<i class="fa fa-clock-o glyphicon glyphicon-time"></i>' +
  14446. '</div>' +
  14447. '</div>' +
  14448. '<div class="calendar-table"></div>' +
  14449. '</div>' +
  14450. '<div class="calendar right">' +
  14451. '<div class="daterangepicker_input">' +
  14452. '<input class="input-mini form-control" type="text" name="daterangepicker_end" value="" />' +
  14453. '<i class="fa fa-calendar glyphicon glyphicon-calendar"></i>' +
  14454. '<div class="calendar-time">' +
  14455. '<div></div>' +
  14456. '<i class="fa fa-clock-o glyphicon glyphicon-time"></i>' +
  14457. '</div>' +
  14458. '</div>' +
  14459. '<div class="calendar-table"></div>' +
  14460. '</div>' +
  14461. '<div class="ranges">' +
  14462. '<div class="range_inputs">' +
  14463. '<button class="applyBtn" disabled="disabled" type="button"></button> ' +
  14464. '<button class="cancelBtn" type="button"></button>' +
  14465. '</div>' +
  14466. '</div>' +
  14467. '</div>';
  14468. this.parentEl = (options.parentEl && $(options.parentEl).length) ? $(options.parentEl) : $(this.parentEl);
  14469. this.container = $(options.template).appendTo(this.parentEl);
  14470. //
  14471. // handle all the possible options overriding defaults
  14472. //
  14473. if (typeof options.locale === 'object') {
  14474. if (typeof options.locale.direction === 'string')
  14475. this.locale.direction = options.locale.direction;
  14476. if (typeof options.locale.format === 'string')
  14477. this.locale.format = options.locale.format;
  14478. if (typeof options.locale.separator === 'string')
  14479. this.locale.separator = options.locale.separator;
  14480. if (typeof options.locale.daysOfWeek === 'object')
  14481. this.locale.daysOfWeek = options.locale.daysOfWeek.slice();
  14482. if (typeof options.locale.monthNames === 'object')
  14483. this.locale.monthNames = options.locale.monthNames.slice();
  14484. if (typeof options.locale.firstDay === 'number')
  14485. this.locale.firstDay = options.locale.firstDay;
  14486. if (typeof options.locale.applyLabel === 'string')
  14487. this.locale.applyLabel = options.locale.applyLabel;
  14488. if (typeof options.locale.cancelLabel === 'string')
  14489. this.locale.cancelLabel = options.locale.cancelLabel;
  14490. if (typeof options.locale.weekLabel === 'string')
  14491. this.locale.weekLabel = options.locale.weekLabel;
  14492. if (typeof options.locale.customRangeLabel === 'string'){
  14493. //Support unicode chars in the custom range name.
  14494. var elem = document.createElement('textarea');
  14495. elem.innerHTML = options.locale.customRangeLabel;
  14496. var rangeHtml = elem.value;
  14497. this.locale.customRangeLabel = rangeHtml;
  14498. }
  14499. }
  14500. this.container.addClass(this.locale.direction);
  14501. if (typeof options.startDate === 'string')
  14502. this.startDate = moment(options.startDate, this.locale.format);
  14503. if (typeof options.endDate === 'string')
  14504. this.endDate = moment(options.endDate, this.locale.format);
  14505. if (typeof options.minDate === 'string')
  14506. this.minDate = moment(options.minDate, this.locale.format);
  14507. if (typeof options.maxDate === 'string')
  14508. this.maxDate = moment(options.maxDate, this.locale.format);
  14509. if (typeof options.startDate === 'object')
  14510. this.startDate = moment(options.startDate);
  14511. if (typeof options.endDate === 'object')
  14512. this.endDate = moment(options.endDate);
  14513. if (typeof options.minDate === 'object')
  14514. this.minDate = moment(options.minDate);
  14515. if (typeof options.maxDate === 'object')
  14516. this.maxDate = moment(options.maxDate);
  14517. // sanity check for bad options
  14518. if (this.minDate && this.startDate.isBefore(this.minDate))
  14519. this.startDate = this.minDate.clone();
  14520. // sanity check for bad options
  14521. if (this.maxDate && this.endDate.isAfter(this.maxDate))
  14522. this.endDate = this.maxDate.clone();
  14523. if (typeof options.applyClass === 'string')
  14524. this.applyClass = options.applyClass;
  14525. if (typeof options.cancelClass === 'string')
  14526. this.cancelClass = options.cancelClass;
  14527. if (typeof options.dateLimit === 'object')
  14528. this.dateLimit = options.dateLimit;
  14529. if (typeof options.opens === 'string')
  14530. this.opens = options.opens;
  14531. if (typeof options.drops === 'string')
  14532. this.drops = options.drops;
  14533. if (typeof options.showWeekNumbers === 'boolean')
  14534. this.showWeekNumbers = options.showWeekNumbers;
  14535. if (typeof options.showISOWeekNumbers === 'boolean')
  14536. this.showISOWeekNumbers = options.showISOWeekNumbers;
  14537. if (typeof options.buttonClasses === 'string')
  14538. this.buttonClasses = options.buttonClasses;
  14539. if (typeof options.buttonClasses === 'object')
  14540. this.buttonClasses = options.buttonClasses.join(' ');
  14541. if (typeof options.showDropdowns === 'boolean')
  14542. this.showDropdowns = options.showDropdowns;
  14543. if (typeof options.showCustomRangeLabel === 'boolean')
  14544. this.showCustomRangeLabel = options.showCustomRangeLabel;
  14545. if (typeof options.singleDatePicker === 'boolean') {
  14546. this.singleDatePicker = options.singleDatePicker;
  14547. if (this.singleDatePicker)
  14548. this.endDate = this.startDate.clone();
  14549. }
  14550. if (typeof options.timePicker === 'boolean')
  14551. this.timePicker = options.timePicker;
  14552. if (typeof options.timePickerSeconds === 'boolean')
  14553. this.timePickerSeconds = options.timePickerSeconds;
  14554. if (typeof options.timePickerIncrement === 'number')
  14555. this.timePickerIncrement = options.timePickerIncrement;
  14556. if (typeof options.timePicker24Hour === 'boolean')
  14557. this.timePicker24Hour = options.timePicker24Hour;
  14558. if (typeof options.autoApply === 'boolean')
  14559. this.autoApply = options.autoApply;
  14560. if (typeof options.autoUpdateInput === 'boolean')
  14561. this.autoUpdateInput = options.autoUpdateInput;
  14562. if (typeof options.linkedCalendars === 'boolean')
  14563. this.linkedCalendars = options.linkedCalendars;
  14564. if (typeof options.isInvalidDate === 'function')
  14565. this.isInvalidDate = options.isInvalidDate;
  14566. if (typeof options.isCustomDate === 'function')
  14567. this.isCustomDate = options.isCustomDate;
  14568. if (typeof options.alwaysShowCalendars === 'boolean')
  14569. this.alwaysShowCalendars = options.alwaysShowCalendars;
  14570. // update day names order to firstDay
  14571. if (this.locale.firstDay != 0) {
  14572. var iterator = this.locale.firstDay;
  14573. while (iterator > 0) {
  14574. this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift());
  14575. iterator--;
  14576. }
  14577. }
  14578. var start, end, range;
  14579. //if no start/end dates set, check if an input element contains initial values
  14580. if (typeof options.startDate === 'undefined' && typeof options.endDate === 'undefined') {
  14581. if ($(this.element).is('input[type=text]')) {
  14582. var val = $(this.element).val(),
  14583. split = val.split(this.locale.separator);
  14584. start = end = null;
  14585. if (split.length == 2) {
  14586. start = moment(split[0], this.locale.format);
  14587. end = moment(split[1], this.locale.format);
  14588. } else if (this.singleDatePicker && val !== "") {
  14589. start = moment(val, this.locale.format);
  14590. end = moment(val, this.locale.format);
  14591. }
  14592. if (start !== null && end !== null) {
  14593. this.setStartDate(start);
  14594. this.setEndDate(end);
  14595. }
  14596. }
  14597. }
  14598. if (typeof options.ranges === 'object') {
  14599. for (range in options.ranges) {
  14600. if (typeof options.ranges[range][0] === 'string')
  14601. start = moment(options.ranges[range][0], this.locale.format);
  14602. else
  14603. start = moment(options.ranges[range][0]);
  14604. if (typeof options.ranges[range][1] === 'string')
  14605. end = moment(options.ranges[range][1], this.locale.format);
  14606. else
  14607. end = moment(options.ranges[range][1]);
  14608. // If the start or end date exceed those allowed by the minDate or dateLimit
  14609. // options, shorten the range to the allowable period.
  14610. if (this.minDate && start.isBefore(this.minDate))
  14611. start = this.minDate.clone();
  14612. var maxDate = this.maxDate;
  14613. if (this.dateLimit && maxDate && start.clone().add(this.dateLimit).isAfter(maxDate))
  14614. maxDate = start.clone().add(this.dateLimit);
  14615. if (maxDate && end.isAfter(maxDate))
  14616. end = maxDate.clone();
  14617. // If the end of the range is before the minimum or the start of the range is
  14618. // after the maximum, don't display this range option at all.
  14619. if ((this.minDate && end.isBefore(this.minDate, this.timepicker ? 'minute' : 'day'))
  14620. || (maxDate && start.isAfter(maxDate, this.timepicker ? 'minute' : 'day')))
  14621. continue;
  14622. //Support unicode chars in the range names.
  14623. var elem = document.createElement('textarea');
  14624. elem.innerHTML = range;
  14625. var rangeHtml = elem.value;
  14626. this.ranges[rangeHtml] = [start, end];
  14627. }
  14628. var list = '<ul>';
  14629. for (range in this.ranges) {
  14630. list += '<li data-range-key="' + range + '">' + range + '</li>';
  14631. }
  14632. if (this.showCustomRangeLabel) {
  14633. list += '<li data-range-key="' + this.locale.customRangeLabel + '">' + this.locale.customRangeLabel + '</li>';
  14634. }
  14635. list += '</ul>';
  14636. this.container.find('.ranges').prepend(list);
  14637. }
  14638. if (typeof cb === 'function') {
  14639. this.callback = cb;
  14640. }
  14641. if (!this.timePicker) {
  14642. this.startDate = this.startDate.startOf('day');
  14643. this.endDate = this.endDate.endOf('day');
  14644. this.container.find('.calendar-time').hide();
  14645. }
  14646. //can't be used together for now
  14647. if (this.timePicker && this.autoApply)
  14648. this.autoApply = false;
  14649. if (this.autoApply && typeof options.ranges !== 'object') {
  14650. this.container.find('.ranges').hide();
  14651. } else if (this.autoApply) {
  14652. this.container.find('.applyBtn, .cancelBtn').addClass('hide');
  14653. }
  14654. if (this.singleDatePicker) {
  14655. this.container.addClass('single');
  14656. this.container.find('.calendar.left').addClass('single');
  14657. this.container.find('.calendar.left').show();
  14658. this.container.find('.calendar.right').hide();
  14659. this.container.find('.daterangepicker_input input, .daterangepicker_input > i').hide();
  14660. if (this.timePicker) {
  14661. this.container.find('.ranges ul').hide();
  14662. } else {
  14663. this.container.find('.ranges').hide();
  14664. }
  14665. }
  14666. if ((typeof options.ranges === 'undefined' && !this.singleDatePicker) || this.alwaysShowCalendars) {
  14667. this.container.addClass('show-calendar');
  14668. }
  14669. this.container.addClass('opens' + this.opens);
  14670. //swap the position of the predefined ranges if opens right
  14671. if (typeof options.ranges !== 'undefined' && this.opens == 'right') {
  14672. this.container.find('.ranges').prependTo( this.container.find('.calendar.left').parent() );
  14673. }
  14674. //apply CSS classes and labels to buttons
  14675. this.container.find('.applyBtn, .cancelBtn').addClass(this.buttonClasses);
  14676. if (this.applyClass.length)
  14677. this.container.find('.applyBtn').addClass(this.applyClass);
  14678. if (this.cancelClass.length)
  14679. this.container.find('.cancelBtn').addClass(this.cancelClass);
  14680. this.container.find('.applyBtn').html(this.locale.applyLabel);
  14681. this.container.find('.cancelBtn').html(this.locale.cancelLabel);
  14682. //
  14683. // event listeners
  14684. //
  14685. this.container.find('.calendar')
  14686. .on('click.daterangepicker', '.prev', $.proxy(this.clickPrev, this))
  14687. .on('click.daterangepicker', '.next', $.proxy(this.clickNext, this))
  14688. .on('mousedown.daterangepicker', 'td.available', $.proxy(this.clickDate, this))
  14689. .on('mouseenter.daterangepicker', 'td.available', $.proxy(this.hoverDate, this))
  14690. .on('mouseleave.daterangepicker', 'td.available', $.proxy(this.updateFormInputs, this))
  14691. .on('change.daterangepicker', 'select.yearselect', $.proxy(this.monthOrYearChanged, this))
  14692. .on('change.daterangepicker', 'select.monthselect', $.proxy(this.monthOrYearChanged, this))
  14693. .on('change.daterangepicker', 'select.hourselect,select.minuteselect,select.secondselect,select.ampmselect', $.proxy(this.timeChanged, this))
  14694. .on('click.daterangepicker', '.daterangepicker_input input', $.proxy(this.showCalendars, this))
  14695. .on('focus.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsFocused, this))
  14696. .on('blur.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsBlurred, this))
  14697. .on('change.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsChanged, this))
  14698. .on('keydown.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsKeydown, this));
  14699. this.container.find('.ranges')
  14700. .on('click.daterangepicker', 'button.applyBtn', $.proxy(this.clickApply, this))
  14701. .on('click.daterangepicker', 'button.cancelBtn', $.proxy(this.clickCancel, this))
  14702. .on('click.daterangepicker', 'li', $.proxy(this.clickRange, this))
  14703. .on('mouseenter.daterangepicker', 'li', $.proxy(this.hoverRange, this))
  14704. .on('mouseleave.daterangepicker', 'li', $.proxy(this.updateFormInputs, this));
  14705. if (this.element.is('input') || this.element.is('button')) {
  14706. this.element.on({
  14707. 'click.daterangepicker': $.proxy(this.show, this),
  14708. 'focus.daterangepicker': $.proxy(this.show, this),
  14709. 'keyup.daterangepicker': $.proxy(this.elementChanged, this),
  14710. 'keydown.daterangepicker': $.proxy(this.keydown, this) //IE 11 compatibility
  14711. });
  14712. } else {
  14713. this.element.on('click.daterangepicker', $.proxy(this.toggle, this));
  14714. this.element.on('keydown.daterangepicker', $.proxy(this.toggle, this));
  14715. }
  14716. //
  14717. // if attached to a text input, set the initial value
  14718. //
  14719. if (this.element.is('input') && !this.singleDatePicker && this.autoUpdateInput) {
  14720. this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
  14721. this.element.trigger('change');
  14722. } else if (this.element.is('input') && this.autoUpdateInput) {
  14723. this.element.val(this.startDate.format(this.locale.format));
  14724. this.element.trigger('change');
  14725. }
  14726. };
  14727. DateRangePicker.prototype = {
  14728. constructor: DateRangePicker,
  14729. setStartDate: function(startDate) {
  14730. if (typeof startDate === 'string')
  14731. this.startDate = moment(startDate, this.locale.format);
  14732. if (typeof startDate === 'object')
  14733. this.startDate = moment(startDate);
  14734. if (!this.timePicker)
  14735. this.startDate = this.startDate.startOf('day');
  14736. if (this.timePicker && this.timePickerIncrement)
  14737. this.startDate.minute(Math.round(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
  14738. if (this.minDate && this.startDate.isBefore(this.minDate)) {
  14739. this.startDate = this.minDate.clone();
  14740. if (this.timePicker && this.timePickerIncrement)
  14741. this.startDate.minute(Math.round(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
  14742. }
  14743. if (this.maxDate && this.startDate.isAfter(this.maxDate)) {
  14744. this.startDate = this.maxDate.clone();
  14745. if (this.timePicker && this.timePickerIncrement)
  14746. this.startDate.minute(Math.floor(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
  14747. }
  14748. if (!this.isShowing)
  14749. this.updateElement();
  14750. this.updateMonthsInView();
  14751. },
  14752. setEndDate: function(endDate) {
  14753. if (typeof endDate === 'string')
  14754. this.endDate = moment(endDate, this.locale.format);
  14755. if (typeof endDate === 'object')
  14756. this.endDate = moment(endDate);
  14757. if (!this.timePicker)
  14758. this.endDate = this.endDate.add(1,'d').startOf('day').subtract(1,'second');
  14759. if (this.timePicker && this.timePickerIncrement)
  14760. this.endDate.minute(Math.round(this.endDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
  14761. if (this.endDate.isBefore(this.startDate))
  14762. this.endDate = this.startDate.clone();
  14763. if (this.maxDate && this.endDate.isAfter(this.maxDate))
  14764. this.endDate = this.maxDate.clone();
  14765. if (this.dateLimit && this.startDate.clone().add(this.dateLimit).isBefore(this.endDate))
  14766. this.endDate = this.startDate.clone().add(this.dateLimit);
  14767. this.previousRightTime = this.endDate.clone();
  14768. if (!this.isShowing)
  14769. this.updateElement();
  14770. this.updateMonthsInView();
  14771. },
  14772. isInvalidDate: function() {
  14773. return false;
  14774. },
  14775. isCustomDate: function() {
  14776. return false;
  14777. },
  14778. updateView: function() {
  14779. if (this.timePicker) {
  14780. this.renderTimePicker('left');
  14781. this.renderTimePicker('right');
  14782. if (!this.endDate) {
  14783. this.container.find('.right .calendar-time select').attr('disabled', 'disabled').addClass('disabled');
  14784. } else {
  14785. this.container.find('.right .calendar-time select').removeAttr('disabled').removeClass('disabled');
  14786. }
  14787. }
  14788. if (this.endDate) {
  14789. this.container.find('input[name="daterangepicker_end"]').removeClass('active');
  14790. this.container.find('input[name="daterangepicker_start"]').addClass('active');
  14791. } else {
  14792. this.container.find('input[name="daterangepicker_end"]').addClass('active');
  14793. this.container.find('input[name="daterangepicker_start"]').removeClass('active');
  14794. }
  14795. this.updateMonthsInView();
  14796. this.updateCalendars();
  14797. this.updateFormInputs();
  14798. },
  14799. updateMonthsInView: function() {
  14800. if (this.endDate) {
  14801. //if both dates are visible already, do nothing
  14802. if (!this.singleDatePicker && this.leftCalendar.month && this.rightCalendar.month &&
  14803. (this.startDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.startDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM'))
  14804. &&
  14805. (this.endDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.endDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM'))
  14806. ) {
  14807. return;
  14808. }
  14809. this.leftCalendar.month = this.startDate.clone().date(2);
  14810. if (!this.linkedCalendars && (this.endDate.month() != this.startDate.month() || this.endDate.year() != this.startDate.year())) {
  14811. this.rightCalendar.month = this.endDate.clone().date(2);
  14812. } else {
  14813. this.rightCalendar.month = this.startDate.clone().date(2).add(1, 'month');
  14814. }
  14815. } else {
  14816. if (this.leftCalendar.month.format('YYYY-MM') != this.startDate.format('YYYY-MM') && this.rightCalendar.month.format('YYYY-MM') != this.startDate.format('YYYY-MM')) {
  14817. this.leftCalendar.month = this.startDate.clone().date(2);
  14818. this.rightCalendar.month = this.startDate.clone().date(2).add(1, 'month');
  14819. }
  14820. }
  14821. if (this.maxDate && this.linkedCalendars && !this.singleDatePicker && this.rightCalendar.month > this.maxDate) {
  14822. this.rightCalendar.month = this.maxDate.clone().date(2);
  14823. this.leftCalendar.month = this.maxDate.clone().date(2).subtract(1, 'month');
  14824. }
  14825. },
  14826. updateCalendars: function() {
  14827. if (this.timePicker) {
  14828. var hour, minute, second;
  14829. if (this.endDate) {
  14830. hour = parseInt(this.container.find('.left .hourselect').val(), 10);
  14831. minute = parseInt(this.container.find('.left .minuteselect').val(), 10);
  14832. second = this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10) : 0;
  14833. if (!this.timePicker24Hour) {
  14834. var ampm = this.container.find('.left .ampmselect').val();
  14835. if (ampm === 'PM' && hour < 12)
  14836. hour += 12;
  14837. if (ampm === 'AM' && hour === 12)
  14838. hour = 0;
  14839. }
  14840. } else {
  14841. hour = parseInt(this.container.find('.right .hourselect').val(), 10);
  14842. minute = parseInt(this.container.find('.right .minuteselect').val(), 10);
  14843. second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0;
  14844. if (!this.timePicker24Hour) {
  14845. var ampm = this.container.find('.right .ampmselect').val();
  14846. if (ampm === 'PM' && hour < 12)
  14847. hour += 12;
  14848. if (ampm === 'AM' && hour === 12)
  14849. hour = 0;
  14850. }
  14851. }
  14852. this.leftCalendar.month.hour(hour).minute(minute).second(second);
  14853. this.rightCalendar.month.hour(hour).minute(minute).second(second);
  14854. }
  14855. this.renderCalendar('left');
  14856. this.renderCalendar('right');
  14857. //highlight any predefined range matching the current start and end dates
  14858. this.container.find('.ranges li').removeClass('active');
  14859. if (this.endDate == null) return;
  14860. this.calculateChosenLabel();
  14861. },
  14862. renderCalendar: function(side) {
  14863. //
  14864. // Build the matrix of dates that will populate the calendar
  14865. //
  14866. var calendar = side == 'left' ? this.leftCalendar : this.rightCalendar;
  14867. var month = calendar.month.month();
  14868. var year = calendar.month.year();
  14869. var hour = calendar.month.hour();
  14870. var minute = calendar.month.minute();
  14871. var second = calendar.month.second();
  14872. var daysInMonth = moment([year, month]).daysInMonth();
  14873. var firstDay = moment([year, month, 1]);
  14874. var lastDay = moment([year, month, daysInMonth]);
  14875. var lastMonth = moment(firstDay).subtract(1, 'month').month();
  14876. var lastYear = moment(firstDay).subtract(1, 'month').year();
  14877. var daysInLastMonth = moment([lastYear, lastMonth]).daysInMonth();
  14878. var dayOfWeek = firstDay.day();
  14879. //initialize a 6 rows x 7 columns array for the calendar
  14880. var calendar = [];
  14881. calendar.firstDay = firstDay;
  14882. calendar.lastDay = lastDay;
  14883. for (var i = 0; i < 6; i++) {
  14884. calendar[i] = [];
  14885. }
  14886. //populate the calendar with date objects
  14887. var startDay = daysInLastMonth - dayOfWeek + this.locale.firstDay + 1;
  14888. if (startDay > daysInLastMonth)
  14889. startDay -= 7;
  14890. if (dayOfWeek == this.locale.firstDay)
  14891. startDay = daysInLastMonth - 6;
  14892. var curDate = moment([lastYear, lastMonth, startDay, 12, minute, second]);
  14893. var col, row;
  14894. for (var i = 0, col = 0, row = 0; i < 42; i++, col++, curDate = moment(curDate).add(24, 'hour')) {
  14895. if (i > 0 && col % 7 === 0) {
  14896. col = 0;
  14897. row++;
  14898. }
  14899. calendar[row][col] = curDate.clone().hour(hour).minute(minute).second(second);
  14900. curDate.hour(12);
  14901. if (this.minDate && calendar[row][col].format('YYYY-MM-DD') == this.minDate.format('YYYY-MM-DD') && calendar[row][col].isBefore(this.minDate) && side == 'left') {
  14902. calendar[row][col] = this.minDate.clone();
  14903. }
  14904. if (this.maxDate && calendar[row][col].format('YYYY-MM-DD') == this.maxDate.format('YYYY-MM-DD') && calendar[row][col].isAfter(this.maxDate) && side == 'right') {
  14905. calendar[row][col] = this.maxDate.clone();
  14906. }
  14907. }
  14908. //make the calendar object available to hoverDate/clickDate
  14909. if (side == 'left') {
  14910. this.leftCalendar.calendar = calendar;
  14911. } else {
  14912. this.rightCalendar.calendar = calendar;
  14913. }
  14914. //
  14915. // Display the calendar
  14916. //
  14917. var minDate = side == 'left' ? this.minDate : this.startDate;
  14918. var maxDate = this.maxDate;
  14919. var selected = side == 'left' ? this.startDate : this.endDate;
  14920. var arrow = this.locale.direction == 'ltr' ? {left: 'chevron-left', right: 'chevron-right'} : {left: 'chevron-right', right: 'chevron-left'};
  14921. var html = '<table class="table-condensed">';
  14922. html += '<thead>';
  14923. html += '<tr>';
  14924. // add empty cell for week number
  14925. if (this.showWeekNumbers || this.showISOWeekNumbers)
  14926. html += '<th></th>';
  14927. if ((!minDate || minDate.isBefore(calendar.firstDay)) && (!this.linkedCalendars || side == 'left')) {
  14928. html += '<th class="prev available"><i class="fa fa-' + arrow.left + ' glyphicon glyphicon-' + arrow.left + '"></i></th>';
  14929. } else {
  14930. html += '<th></th>';
  14931. }
  14932. var dateHtml = this.locale.monthNames[calendar[1][1].month()] + calendar[1][1].format(" YYYY");
  14933. if (this.showDropdowns) {
  14934. var currentMonth = calendar[1][1].month();
  14935. var currentYear = calendar[1][1].year();
  14936. var maxYear = (maxDate && maxDate.year()) || (currentYear + 5);
  14937. var minYear = (minDate && minDate.year()) || (currentYear - 50);
  14938. var inMinYear = currentYear == minYear;
  14939. var inMaxYear = currentYear == maxYear;
  14940. var monthHtml = '<select class="monthselect">';
  14941. for (var m = 0; m < 12; m++) {
  14942. if ((!inMinYear || m >= minDate.month()) && (!inMaxYear || m <= maxDate.month())) {
  14943. monthHtml += "<option value='" + m + "'" +
  14944. (m === currentMonth ? " selected='selected'" : "") +
  14945. ">" + this.locale.monthNames[m] + "</option>";
  14946. } else {
  14947. monthHtml += "<option value='" + m + "'" +
  14948. (m === currentMonth ? " selected='selected'" : "") +
  14949. " disabled='disabled'>" + this.locale.monthNames[m] + "</option>";
  14950. }
  14951. }
  14952. monthHtml += "</select>";
  14953. var yearHtml = '<select class="yearselect">';
  14954. for (var y = minYear; y <= maxYear; y++) {
  14955. yearHtml += '<option value="' + y + '"' +
  14956. (y === currentYear ? ' selected="selected"' : '') +
  14957. '>' + y + '</option>';
  14958. }
  14959. yearHtml += '</select>';
  14960. dateHtml = monthHtml + yearHtml;
  14961. }
  14962. html += '<th colspan="5" class="month">' + dateHtml + '</th>';
  14963. if ((!maxDate || maxDate.isAfter(calendar.lastDay)) && (!this.linkedCalendars || side == 'right' || this.singleDatePicker)) {
  14964. html += '<th class="next available"><i class="fa fa-' + arrow.right + ' glyphicon glyphicon-' + arrow.right + '"></i></th>';
  14965. } else {
  14966. html += '<th></th>';
  14967. }
  14968. html += '</tr>';
  14969. html += '<tr>';
  14970. // add week number label
  14971. if (this.showWeekNumbers || this.showISOWeekNumbers)
  14972. html += '<th class="week">' + this.locale.weekLabel + '</th>';
  14973. $.each(this.locale.daysOfWeek, function(index, dayOfWeek) {
  14974. html += '<th>' + dayOfWeek + '</th>';
  14975. });
  14976. html += '</tr>';
  14977. html += '</thead>';
  14978. html += '<tbody>';
  14979. //adjust maxDate to reflect the dateLimit setting in order to
  14980. //grey out end dates beyond the dateLimit
  14981. if (this.endDate == null && this.dateLimit) {
  14982. var maxLimit = this.startDate.clone().add(this.dateLimit).endOf('day');
  14983. if (!maxDate || maxLimit.isBefore(maxDate)) {
  14984. maxDate = maxLimit;
  14985. }
  14986. }
  14987. for (var row = 0; row < 6; row++) {
  14988. html += '<tr>';
  14989. // add week number
  14990. if (this.showWeekNumbers)
  14991. html += '<td class="week">' + calendar[row][0].week() + '</td>';
  14992. else if (this.showISOWeekNumbers)
  14993. html += '<td class="week">' + calendar[row][0].isoWeek() + '</td>';
  14994. for (var col = 0; col < 7; col++) {
  14995. var classes = [];
  14996. //highlight today's date
  14997. if (calendar[row][col].isSame(new Date(), "day"))
  14998. classes.push('today');
  14999. //highlight weekends
  15000. if (calendar[row][col].isoWeekday() > 5)
  15001. classes.push('weekend');
  15002. //grey out the dates in other months displayed at beginning and end of this calendar
  15003. if (calendar[row][col].month() != calendar[1][1].month())
  15004. classes.push('off');
  15005. //don't allow selection of dates before the minimum date
  15006. if (this.minDate && calendar[row][col].isBefore(this.minDate, 'day'))
  15007. classes.push('off', 'disabled');
  15008. //don't allow selection of dates after the maximum date
  15009. if (maxDate && calendar[row][col].isAfter(maxDate, 'day'))
  15010. classes.push('off', 'disabled');
  15011. //don't allow selection of date if a custom function decides it's invalid
  15012. if (this.isInvalidDate(calendar[row][col]))
  15013. classes.push('off', 'disabled');
  15014. //highlight the currently selected start date
  15015. if (calendar[row][col].format('YYYY-MM-DD') == this.startDate.format('YYYY-MM-DD'))
  15016. classes.push('active', 'start-date');
  15017. //highlight the currently selected end date
  15018. if (this.endDate != null && calendar[row][col].format('YYYY-MM-DD') == this.endDate.format('YYYY-MM-DD'))
  15019. classes.push('active', 'end-date');
  15020. //highlight dates in-between the selected dates
  15021. if (this.endDate != null && calendar[row][col] > this.startDate && calendar[row][col] < this.endDate)
  15022. classes.push('in-range');
  15023. //apply custom classes for this date
  15024. var isCustom = this.isCustomDate(calendar[row][col]);
  15025. if (isCustom !== false) {
  15026. if (typeof isCustom === 'string')
  15027. classes.push(isCustom);
  15028. else
  15029. Array.prototype.push.apply(classes, isCustom);
  15030. }
  15031. var cname = '', disabled = false;
  15032. for (var i = 0; i < classes.length; i++) {
  15033. cname += classes[i] + ' ';
  15034. if (classes[i] == 'disabled')
  15035. disabled = true;
  15036. }
  15037. if (!disabled)
  15038. cname += 'available';
  15039. html += '<td class="' + cname.replace(/^\s+|\s+$/g, '') + '" data-title="' + 'r' + row + 'c' + col + '">' + calendar[row][col].date() + '</td>';
  15040. }
  15041. html += '</tr>';
  15042. }
  15043. html += '</tbody>';
  15044. html += '</table>';
  15045. this.container.find('.calendar.' + side + ' .calendar-table').html(html);
  15046. },
  15047. renderTimePicker: function(side) {
  15048. // Don't bother updating the time picker if it's currently disabled
  15049. // because an end date hasn't been clicked yet
  15050. if (side == 'right' && !this.endDate) return;
  15051. var html, selected, minDate, maxDate = this.maxDate;
  15052. if (this.dateLimit && (!this.maxDate || this.startDate.clone().add(this.dateLimit).isAfter(this.maxDate)))
  15053. maxDate = this.startDate.clone().add(this.dateLimit);
  15054. if (side == 'left') {
  15055. selected = this.startDate.clone();
  15056. minDate = this.minDate;
  15057. } else if (side == 'right') {
  15058. selected = this.endDate.clone();
  15059. minDate = this.startDate;
  15060. //Preserve the time already selected
  15061. var timeSelector = this.container.find('.calendar.right .calendar-time div');
  15062. if (timeSelector.html() != '') {
  15063. selected.hour(timeSelector.find('.hourselect option:selected').val() || selected.hour());
  15064. selected.minute(timeSelector.find('.minuteselect option:selected').val() || selected.minute());
  15065. selected.second(timeSelector.find('.secondselect option:selected').val() || selected.second());
  15066. if (!this.timePicker24Hour) {
  15067. var ampm = timeSelector.find('.ampmselect option:selected').val();
  15068. if (ampm === 'PM' && selected.hour() < 12)
  15069. selected.hour(selected.hour() + 12);
  15070. if (ampm === 'AM' && selected.hour() === 12)
  15071. selected.hour(0);
  15072. }
  15073. }
  15074. if (selected.isBefore(this.startDate))
  15075. selected = this.startDate.clone();
  15076. if (maxDate && selected.isAfter(maxDate))
  15077. selected = maxDate.clone();
  15078. }
  15079. //
  15080. // hours
  15081. //
  15082. html = '<select class="hourselect">';
  15083. var start = this.timePicker24Hour ? 0 : 1;
  15084. var end = this.timePicker24Hour ? 23 : 12;
  15085. for (var i = start; i <= end; i++) {
  15086. var i_in_24 = i;
  15087. if (!this.timePicker24Hour)
  15088. i_in_24 = selected.hour() >= 12 ? (i == 12 ? 12 : i + 12) : (i == 12 ? 0 : i);
  15089. var time = selected.clone().hour(i_in_24);
  15090. var disabled = false;
  15091. if (minDate && time.minute(59).isBefore(minDate))
  15092. disabled = true;
  15093. if (maxDate && time.minute(0).isAfter(maxDate))
  15094. disabled = true;
  15095. if (i_in_24 == selected.hour() && !disabled) {
  15096. html += '<option value="' + i + '" selected="selected">' + i + '</option>';
  15097. } else if (disabled) {
  15098. html += '<option value="' + i + '" disabled="disabled" class="disabled">' + i + '</option>';
  15099. } else {
  15100. html += '<option value="' + i + '">' + i + '</option>';
  15101. }
  15102. }
  15103. html += '</select> ';
  15104. //
  15105. // minutes
  15106. //
  15107. html += ': <select class="minuteselect">';
  15108. for (var i = 0; i < 60; i += this.timePickerIncrement) {
  15109. var padded = i < 10 ? '0' + i : i;
  15110. var time = selected.clone().minute(i);
  15111. var disabled = false;
  15112. if (minDate && time.second(59).isBefore(minDate))
  15113. disabled = true;
  15114. if (maxDate && time.second(0).isAfter(maxDate))
  15115. disabled = true;
  15116. if (selected.minute() == i && !disabled) {
  15117. html += '<option value="' + i + '" selected="selected">' + padded + '</option>';
  15118. } else if (disabled) {
  15119. html += '<option value="' + i + '" disabled="disabled" class="disabled">' + padded + '</option>';
  15120. } else {
  15121. html += '<option value="' + i + '">' + padded + '</option>';
  15122. }
  15123. }
  15124. html += '</select> ';
  15125. //
  15126. // seconds
  15127. //
  15128. if (this.timePickerSeconds) {
  15129. html += ': <select class="secondselect">';
  15130. for (var i = 0; i < 60; i++) {
  15131. var padded = i < 10 ? '0' + i : i;
  15132. var time = selected.clone().second(i);
  15133. var disabled = false;
  15134. if (minDate && time.isBefore(minDate))
  15135. disabled = true;
  15136. if (maxDate && time.isAfter(maxDate))
  15137. disabled = true;
  15138. if (selected.second() == i && !disabled) {
  15139. html += '<option value="' + i + '" selected="selected">' + padded + '</option>';
  15140. } else if (disabled) {
  15141. html += '<option value="' + i + '" disabled="disabled" class="disabled">' + padded + '</option>';
  15142. } else {
  15143. html += '<option value="' + i + '">' + padded + '</option>';
  15144. }
  15145. }
  15146. html += '</select> ';
  15147. }
  15148. //
  15149. // AM/PM
  15150. //
  15151. if (!this.timePicker24Hour) {
  15152. html += '<select class="ampmselect">';
  15153. var am_html = '';
  15154. var pm_html = '';
  15155. if (minDate && selected.clone().hour(12).minute(0).second(0).isBefore(minDate))
  15156. am_html = ' disabled="disabled" class="disabled"';
  15157. if (maxDate && selected.clone().hour(0).minute(0).second(0).isAfter(maxDate))
  15158. pm_html = ' disabled="disabled" class="disabled"';
  15159. if (selected.hour() >= 12) {
  15160. html += '<option value="AM"' + am_html + '>AM</option><option value="PM" selected="selected"' + pm_html + '>PM</option>';
  15161. } else {
  15162. html += '<option value="AM" selected="selected"' + am_html + '>AM</option><option value="PM"' + pm_html + '>PM</option>';
  15163. }
  15164. html += '</select>';
  15165. }
  15166. this.container.find('.calendar.' + side + ' .calendar-time div').html(html);
  15167. },
  15168. updateFormInputs: function() {
  15169. //ignore mouse movements while an above-calendar text input has focus
  15170. if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus"))
  15171. return;
  15172. this.container.find('input[name=daterangepicker_start]').val(this.startDate.format(this.locale.format));
  15173. if (this.endDate)
  15174. this.container.find('input[name=daterangepicker_end]').val(this.endDate.format(this.locale.format));
  15175. if (this.singleDatePicker || (this.endDate && (this.startDate.isBefore(this.endDate) || this.startDate.isSame(this.endDate)))) {
  15176. this.container.find('button.applyBtn').removeAttr('disabled');
  15177. } else {
  15178. this.container.find('button.applyBtn').attr('disabled', 'disabled');
  15179. }
  15180. },
  15181. move: function() {
  15182. var parentOffset = { top: 0, left: 0 },
  15183. containerTop;
  15184. var parentRightEdge = $(window).width();
  15185. if (!this.parentEl.is('body')) {
  15186. parentOffset = {
  15187. top: this.parentEl.offset().top - this.parentEl.scrollTop(),
  15188. left: this.parentEl.offset().left - this.parentEl.scrollLeft()
  15189. };
  15190. parentRightEdge = this.parentEl[0].clientWidth + this.parentEl.offset().left;
  15191. }
  15192. if (this.drops == 'up')
  15193. containerTop = this.element.offset().top - this.container.outerHeight() - parentOffset.top;
  15194. else
  15195. containerTop = this.element.offset().top + this.element.outerHeight() - parentOffset.top;
  15196. this.container[this.drops == 'up' ? 'addClass' : 'removeClass']('dropup');
  15197. if (this.opens == 'left') {
  15198. this.container.css({
  15199. top: containerTop,
  15200. right: parentRightEdge - this.element.offset().left - this.element.outerWidth(),
  15201. left: 'auto'
  15202. });
  15203. if (this.container.offset().left < 0) {
  15204. this.container.css({
  15205. right: 'auto',
  15206. left: 9
  15207. });
  15208. }
  15209. } else if (this.opens == 'center') {
  15210. this.container.css({
  15211. top: containerTop,
  15212. left: this.element.offset().left - parentOffset.left + this.element.outerWidth() / 2
  15213. - this.container.outerWidth() / 2,
  15214. right: 'auto'
  15215. });
  15216. if (this.container.offset().left < 0) {
  15217. this.container.css({
  15218. right: 'auto',
  15219. left: 9
  15220. });
  15221. }
  15222. } else {
  15223. this.container.css({
  15224. top: containerTop,
  15225. left: this.element.offset().left - parentOffset.left,
  15226. right: 'auto'
  15227. });
  15228. if (this.container.offset().left + this.container.outerWidth() > $(window).width()) {
  15229. this.container.css({
  15230. left: 'auto',
  15231. right: 0
  15232. });
  15233. }
  15234. }
  15235. },
  15236. show: function(e) {
  15237. if (this.isShowing) return;
  15238. // Create a click proxy that is private to this instance of datepicker, for unbinding
  15239. this._outsideClickProxy = $.proxy(function(e) { this.outsideClick(e); }, this);
  15240. // Bind global datepicker mousedown for hiding and
  15241. $(document)
  15242. .on('mousedown.daterangepicker', this._outsideClickProxy)
  15243. // also support mobile devices
  15244. .on('touchend.daterangepicker', this._outsideClickProxy)
  15245. // also explicitly play nice with Bootstrap dropdowns, which stopPropagation when clicking them
  15246. .on('click.daterangepicker', '[data-toggle=dropdown]', this._outsideClickProxy)
  15247. // and also close when focus changes to outside the picker (eg. tabbing between controls)
  15248. .on('focusin.daterangepicker', this._outsideClickProxy);
  15249. // Reposition the picker if the window is resized while it's open
  15250. $(window).on('resize.daterangepicker', $.proxy(function(e) { this.move(e); }, this));
  15251. this.oldStartDate = this.startDate.clone();
  15252. this.oldEndDate = this.endDate.clone();
  15253. this.previousRightTime = this.endDate.clone();
  15254. this.updateView();
  15255. this.container.show();
  15256. this.move();
  15257. this.element.trigger('show.daterangepicker', this);
  15258. this.isShowing = true;
  15259. },
  15260. hide: function(e) {
  15261. if (!this.isShowing) return;
  15262. //incomplete date selection, revert to last values
  15263. if (!this.endDate) {
  15264. this.startDate = this.oldStartDate.clone();
  15265. this.endDate = this.oldEndDate.clone();
  15266. }
  15267. //if a new date range was selected, invoke the user callback function
  15268. if (!this.startDate.isSame(this.oldStartDate) || !this.endDate.isSame(this.oldEndDate))
  15269. this.callback(this.startDate, this.endDate, this.chosenLabel);
  15270. //if picker is attached to a text input, update it
  15271. this.updateElement();
  15272. $(document).off('.daterangepicker');
  15273. $(window).off('.daterangepicker');
  15274. this.container.hide();
  15275. this.element.trigger('hide.daterangepicker', this);
  15276. this.isShowing = false;
  15277. },
  15278. toggle: function(e) {
  15279. if (this.isShowing) {
  15280. this.hide();
  15281. } else {
  15282. this.show();
  15283. }
  15284. },
  15285. outsideClick: function(e) {
  15286. var target = $(e.target);
  15287. // if the page is clicked anywhere except within the daterangerpicker/button
  15288. // itself then call this.hide()
  15289. if (
  15290. // ie modal dialog fix
  15291. e.type == "focusin" ||
  15292. target.closest(this.element).length ||
  15293. target.closest(this.container).length ||
  15294. target.closest('.calendar-table').length
  15295. ) return;
  15296. this.hide();
  15297. this.element.trigger('outsideClick.daterangepicker', this);
  15298. },
  15299. showCalendars: function() {
  15300. this.container.addClass('show-calendar');
  15301. this.move();
  15302. this.element.trigger('showCalendar.daterangepicker', this);
  15303. },
  15304. hideCalendars: function() {
  15305. this.container.removeClass('show-calendar');
  15306. this.element.trigger('hideCalendar.daterangepicker', this);
  15307. },
  15308. hoverRange: function(e) {
  15309. //ignore mouse movements while an above-calendar text input has focus
  15310. if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus"))
  15311. return;
  15312. var label = e.target.getAttribute('data-range-key');
  15313. if (label == this.locale.customRangeLabel) {
  15314. this.updateView();
  15315. } else {
  15316. var dates = this.ranges[label];
  15317. this.container.find('input[name=daterangepicker_start]').val(dates[0].format(this.locale.format));
  15318. this.container.find('input[name=daterangepicker_end]').val(dates[1].format(this.locale.format));
  15319. }
  15320. },
  15321. clickRange: function(e) {
  15322. var label = e.target.getAttribute('data-range-key');
  15323. this.chosenLabel = label;
  15324. if (label == this.locale.customRangeLabel) {
  15325. this.showCalendars();
  15326. } else {
  15327. var dates = this.ranges[label];
  15328. this.startDate = dates[0];
  15329. this.endDate = dates[1];
  15330. if (!this.timePicker) {
  15331. this.startDate.startOf('day');
  15332. this.endDate.endOf('day');
  15333. }
  15334. if (!this.alwaysShowCalendars)
  15335. this.hideCalendars();
  15336. this.clickApply();
  15337. }
  15338. },
  15339. clickPrev: function(e) {
  15340. var cal = $(e.target).parents('.calendar');
  15341. if (cal.hasClass('left')) {
  15342. this.leftCalendar.month.subtract(1, 'month');
  15343. if (this.linkedCalendars)
  15344. this.rightCalendar.month.subtract(1, 'month');
  15345. } else {
  15346. this.rightCalendar.month.subtract(1, 'month');
  15347. }
  15348. this.updateCalendars();
  15349. },
  15350. clickNext: function(e) {
  15351. var cal = $(e.target).parents('.calendar');
  15352. if (cal.hasClass('left')) {
  15353. this.leftCalendar.month.add(1, 'month');
  15354. } else {
  15355. this.rightCalendar.month.add(1, 'month');
  15356. if (this.linkedCalendars)
  15357. this.leftCalendar.month.add(1, 'month');
  15358. }
  15359. this.updateCalendars();
  15360. },
  15361. hoverDate: function(e) {
  15362. //ignore mouse movements while an above-calendar text input has focus
  15363. //if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus"))
  15364. // return;
  15365. //ignore dates that can't be selected
  15366. if (!$(e.target).hasClass('available')) return;
  15367. //have the text inputs above calendars reflect the date being hovered over
  15368. var title = $(e.target).attr('data-title');
  15369. var row = title.substr(1, 1);
  15370. var col = title.substr(3, 1);
  15371. var cal = $(e.target).parents('.calendar');
  15372. var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col];
  15373. if (this.endDate && !this.container.find('input[name=daterangepicker_start]').is(":focus")) {
  15374. this.container.find('input[name=daterangepicker_start]').val(date.format(this.locale.format));
  15375. } else if (!this.endDate && !this.container.find('input[name=daterangepicker_end]').is(":focus")) {
  15376. this.container.find('input[name=daterangepicker_end]').val(date.format(this.locale.format));
  15377. }
  15378. //highlight the dates between the start date and the date being hovered as a potential end date
  15379. var leftCalendar = this.leftCalendar;
  15380. var rightCalendar = this.rightCalendar;
  15381. var startDate = this.startDate;
  15382. if (!this.endDate) {
  15383. this.container.find('.calendar tbody td').each(function(index, el) {
  15384. //skip week numbers, only look at dates
  15385. if ($(el).hasClass('week')) return;
  15386. var title = $(el).attr('data-title');
  15387. var row = title.substr(1, 1);
  15388. var col = title.substr(3, 1);
  15389. var cal = $(el).parents('.calendar');
  15390. var dt = cal.hasClass('left') ? leftCalendar.calendar[row][col] : rightCalendar.calendar[row][col];
  15391. if ((dt.isAfter(startDate) && dt.isBefore(date)) || dt.isSame(date, 'day')) {
  15392. $(el).addClass('in-range');
  15393. } else {
  15394. $(el).removeClass('in-range');
  15395. }
  15396. });
  15397. }
  15398. },
  15399. clickDate: function(e) {
  15400. if (!$(e.target).hasClass('available')) return;
  15401. var title = $(e.target).attr('data-title');
  15402. var row = title.substr(1, 1);
  15403. var col = title.substr(3, 1);
  15404. var cal = $(e.target).parents('.calendar');
  15405. var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col];
  15406. //
  15407. // this function needs to do a few things:
  15408. // * alternate between selecting a start and end date for the range,
  15409. // * if the time picker is enabled, apply the hour/minute/second from the select boxes to the clicked date
  15410. // * if autoapply is enabled, and an end date was chosen, apply the selection
  15411. // * if single date picker mode, and time picker isn't enabled, apply the selection immediately
  15412. // * if one of the inputs above the calendars was focused, cancel that manual input
  15413. //
  15414. if (this.endDate || date.isBefore(this.startDate, 'day')) { //picking start
  15415. if (this.timePicker) {
  15416. var hour = parseInt(this.container.find('.left .hourselect').val(), 10);
  15417. if (!this.timePicker24Hour) {
  15418. var ampm = this.container.find('.left .ampmselect').val();
  15419. if (ampm === 'PM' && hour < 12)
  15420. hour += 12;
  15421. if (ampm === 'AM' && hour === 12)
  15422. hour = 0;
  15423. }
  15424. var minute = parseInt(this.container.find('.left .minuteselect').val(), 10);
  15425. var second = this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10) : 0;
  15426. date = date.clone().hour(hour).minute(minute).second(second);
  15427. }
  15428. this.endDate = null;
  15429. this.setStartDate(date.clone());
  15430. } else if (!this.endDate && date.isBefore(this.startDate)) {
  15431. //special case: clicking the same date for start/end,
  15432. //but the time of the end date is before the start date
  15433. this.setEndDate(this.startDate.clone());
  15434. } else { // picking end
  15435. if (this.timePicker) {
  15436. var hour = parseInt(this.container.find('.right .hourselect').val(), 10);
  15437. if (!this.timePicker24Hour) {
  15438. var ampm = this.container.find('.right .ampmselect').val();
  15439. if (ampm === 'PM' && hour < 12)
  15440. hour += 12;
  15441. if (ampm === 'AM' && hour === 12)
  15442. hour = 0;
  15443. }
  15444. var minute = parseInt(this.container.find('.right .minuteselect').val(), 10);
  15445. var second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0;
  15446. date = date.clone().hour(hour).minute(minute).second(second);
  15447. }
  15448. this.setEndDate(date.clone());
  15449. if (this.autoApply) {
  15450. this.calculateChosenLabel();
  15451. this.clickApply();
  15452. }
  15453. }
  15454. if (this.singleDatePicker) {
  15455. this.setEndDate(this.startDate);
  15456. if (!this.timePicker)
  15457. this.clickApply();
  15458. }
  15459. this.updateView();
  15460. //This is to cancel the blur event handler if the mouse was in one of the inputs
  15461. e.stopPropagation();
  15462. },
  15463. calculateChosenLabel: function () {
  15464. var customRange = true;
  15465. var i = 0;
  15466. for (var range in this.ranges) {
  15467. if (this.timePicker) {
  15468. var format = this.timePickerSeconds ? "YYYY-MM-DD hh:mm:ss" : "YYYY-MM-DD hh:mm";
  15469. //ignore times when comparing dates if time picker seconds is not enabled
  15470. if (this.startDate.format(format) == this.ranges[range][0].format(format) && this.endDate.format(format) == this.ranges[range][1].format(format)) {
  15471. customRange = false;
  15472. this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').html();
  15473. break;
  15474. }
  15475. } else {
  15476. //ignore times when comparing dates if time picker is not enabled
  15477. if (this.startDate.format('YYYY-MM-DD') == this.ranges[range][0].format('YYYY-MM-DD') && this.endDate.format('YYYY-MM-DD') == this.ranges[range][1].format('YYYY-MM-DD')) {
  15478. customRange = false;
  15479. this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').html();
  15480. break;
  15481. }
  15482. }
  15483. i++;
  15484. }
  15485. if (customRange) {
  15486. if (this.showCustomRangeLabel) {
  15487. this.chosenLabel = this.container.find('.ranges li:last').addClass('active').html();
  15488. } else {
  15489. this.chosenLabel = null;
  15490. }
  15491. this.showCalendars();
  15492. }
  15493. },
  15494. clickApply: function(e) {
  15495. this.hide();
  15496. this.element.trigger('apply.daterangepicker', this);
  15497. },
  15498. clickCancel: function(e) {
  15499. this.startDate = this.oldStartDate;
  15500. this.endDate = this.oldEndDate;
  15501. this.hide();
  15502. this.element.trigger('cancel.daterangepicker', this);
  15503. },
  15504. monthOrYearChanged: function(e) {
  15505. var isLeft = $(e.target).closest('.calendar').hasClass('left'),
  15506. leftOrRight = isLeft ? 'left' : 'right',
  15507. cal = this.container.find('.calendar.'+leftOrRight);
  15508. // Month must be Number for new moment versions
  15509. var month = parseInt(cal.find('.monthselect').val(), 10);
  15510. var year = cal.find('.yearselect').val();
  15511. if (!isLeft) {
  15512. if (year < this.startDate.year() || (year == this.startDate.year() && month < this.startDate.month())) {
  15513. month = this.startDate.month();
  15514. year = this.startDate.year();
  15515. }
  15516. }
  15517. if (this.minDate) {
  15518. if (year < this.minDate.year() || (year == this.minDate.year() && month < this.minDate.month())) {
  15519. month = this.minDate.month();
  15520. year = this.minDate.year();
  15521. }
  15522. }
  15523. if (this.maxDate) {
  15524. if (year > this.maxDate.year() || (year == this.maxDate.year() && month > this.maxDate.month())) {
  15525. month = this.maxDate.month();
  15526. year = this.maxDate.year();
  15527. }
  15528. }
  15529. if (isLeft) {
  15530. this.leftCalendar.month.month(month).year(year);
  15531. if (this.linkedCalendars)
  15532. this.rightCalendar.month = this.leftCalendar.month.clone().add(1, 'month');
  15533. } else {
  15534. this.rightCalendar.month.month(month).year(year);
  15535. if (this.linkedCalendars)
  15536. this.leftCalendar.month = this.rightCalendar.month.clone().subtract(1, 'month');
  15537. }
  15538. this.updateCalendars();
  15539. },
  15540. timeChanged: function(e) {
  15541. var cal = $(e.target).closest('.calendar'),
  15542. isLeft = cal.hasClass('left');
  15543. var hour = parseInt(cal.find('.hourselect').val(), 10);
  15544. var minute = parseInt(cal.find('.minuteselect').val(), 10);
  15545. var second = this.timePickerSeconds ? parseInt(cal.find('.secondselect').val(), 10) : 0;
  15546. if (!this.timePicker24Hour) {
  15547. var ampm = cal.find('.ampmselect').val();
  15548. if (ampm === 'PM' && hour < 12)
  15549. hour += 12;
  15550. if (ampm === 'AM' && hour === 12)
  15551. hour = 0;
  15552. }
  15553. if (isLeft) {
  15554. var start = this.startDate.clone();
  15555. start.hour(hour);
  15556. start.minute(minute);
  15557. start.second(second);
  15558. this.setStartDate(start);
  15559. if (this.singleDatePicker) {
  15560. this.endDate = this.startDate.clone();
  15561. } else if (this.endDate && this.endDate.format('YYYY-MM-DD') == start.format('YYYY-MM-DD') && this.endDate.isBefore(start)) {
  15562. this.setEndDate(start.clone());
  15563. }
  15564. } else if (this.endDate) {
  15565. var end = this.endDate.clone();
  15566. end.hour(hour);
  15567. end.minute(minute);
  15568. end.second(second);
  15569. this.setEndDate(end);
  15570. }
  15571. //update the calendars so all clickable dates reflect the new time component
  15572. this.updateCalendars();
  15573. //update the form inputs above the calendars with the new time
  15574. this.updateFormInputs();
  15575. //re-render the time pickers because changing one selection can affect what's enabled in another
  15576. this.renderTimePicker('left');
  15577. this.renderTimePicker('right');
  15578. },
  15579. formInputsChanged: function(e) {
  15580. var isRight = $(e.target).closest('.calendar').hasClass('right');
  15581. var start = moment(this.container.find('input[name="daterangepicker_start"]').val(), this.locale.format);
  15582. var end = moment(this.container.find('input[name="daterangepicker_end"]').val(), this.locale.format);
  15583. if (start.isValid() && end.isValid()) {
  15584. if (isRight && end.isBefore(start))
  15585. start = end.clone();
  15586. this.setStartDate(start);
  15587. this.setEndDate(end);
  15588. if (isRight) {
  15589. this.container.find('input[name="daterangepicker_start"]').val(this.startDate.format(this.locale.format));
  15590. } else {
  15591. this.container.find('input[name="daterangepicker_end"]').val(this.endDate.format(this.locale.format));
  15592. }
  15593. }
  15594. this.updateView();
  15595. },
  15596. formInputsFocused: function(e) {
  15597. // Highlight the focused input
  15598. this.container.find('input[name="daterangepicker_start"], input[name="daterangepicker_end"]').removeClass('active');
  15599. $(e.target).addClass('active');
  15600. // Set the state such that if the user goes back to using a mouse,
  15601. // the calendars are aware we're selecting the end of the range, not
  15602. // the start. This allows someone to edit the end of a date range without
  15603. // re-selecting the beginning, by clicking on the end date input then
  15604. // using the calendar.
  15605. var isRight = $(e.target).closest('.calendar').hasClass('right');
  15606. if (isRight) {
  15607. this.endDate = null;
  15608. this.setStartDate(this.startDate.clone());
  15609. this.updateView();
  15610. }
  15611. },
  15612. formInputsBlurred: function(e) {
  15613. // this function has one purpose right now: if you tab from the first
  15614. // text input to the second in the UI, the endDate is nulled so that
  15615. // you can click another, but if you tab out without clicking anything
  15616. // or changing the input value, the old endDate should be retained
  15617. if (!this.endDate) {
  15618. var val = this.container.find('input[name="daterangepicker_end"]').val();
  15619. var end = moment(val, this.locale.format);
  15620. if (end.isValid()) {
  15621. this.setEndDate(end);
  15622. this.updateView();
  15623. }
  15624. }
  15625. },
  15626. formInputsKeydown: function(e) {
  15627. // This function ensures that if the 'enter' key was pressed in the input, then the calendars
  15628. // are updated with the startDate and endDate.
  15629. // This behaviour is automatic in Chrome/Firefox/Edge but not in IE 11 hence why this exists.
  15630. // Other browsers and versions of IE are untested and the behaviour is unknown.
  15631. if (e.keyCode === 13) {
  15632. // Prevent the calendar from being updated twice on Chrome/Firefox/Edge
  15633. e.preventDefault();
  15634. this.formInputsChanged(e);
  15635. }
  15636. },
  15637. elementChanged: function() {
  15638. if (!this.element.is('input')) return;
  15639. if (!this.element.val().length) return;
  15640. var dateString = this.element.val().split(this.locale.separator),
  15641. start = null,
  15642. end = null;
  15643. if (dateString.length === 2) {
  15644. start = moment(dateString[0], this.locale.format);
  15645. end = moment(dateString[1], this.locale.format);
  15646. }
  15647. if (this.singleDatePicker || start === null || end === null) {
  15648. start = moment(this.element.val(), this.locale.format);
  15649. end = start;
  15650. }
  15651. if (!start.isValid() || !end.isValid()) return;
  15652. this.setStartDate(start);
  15653. this.setEndDate(end);
  15654. this.updateView();
  15655. },
  15656. keydown: function(e) {
  15657. //hide on tab or enter
  15658. if ((e.keyCode === 9) || (e.keyCode === 13)) {
  15659. this.hide();
  15660. }
  15661. //hide on esc and prevent propagation
  15662. if (e.keyCode === 27) {
  15663. e.preventDefault();
  15664. e.stopPropagation();
  15665. this.hide();
  15666. }
  15667. },
  15668. updateElement: function() {
  15669. if (this.element.is('input') && !this.singleDatePicker && this.autoUpdateInput) {
  15670. this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
  15671. this.element.trigger('change');
  15672. } else if (this.element.is('input') && this.autoUpdateInput) {
  15673. this.element.val(this.startDate.format(this.locale.format));
  15674. this.element.trigger('change');
  15675. }
  15676. },
  15677. remove: function() {
  15678. this.container.remove();
  15679. this.element.off('.daterangepicker');
  15680. this.element.removeData();
  15681. }
  15682. };
  15683. $.fn.daterangepicker = function(options, callback) {
  15684. var implementOptions = $.extend(true, {}, $.fn.daterangepicker.defaultOptions, options);
  15685. this.each(function() {
  15686. var el = $(this);
  15687. if (el.data('daterangepicker'))
  15688. el.data('daterangepicker').remove();
  15689. el.data('daterangepicker', new DateRangePicker(el, implementOptions, callback));
  15690. });
  15691. return this;
  15692. };
  15693. return DateRangePicker;
  15694. }));