require-backend.min.js 939 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426
  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. //
  31. // 以下的包从bower的libs目录加载
  32. 'jquery': '../libs/jquery/dist/jquery.min',
  33. 'bootstrap': '../libs/bootstrap/dist/js/bootstrap.min',
  34. 'bootstrap-datetimepicker': '../libs/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min',
  35. 'bootstrap-daterangepicker': '../libs/bootstrap-daterangepicker/daterangepicker',
  36. 'bootstrap-select': '../libs/bootstrap-select/dist/js/bootstrap-select.min',
  37. 'bootstrap-select-lang': '../libs/bootstrap-select/dist/js/i18n/defaults-zh_CN',
  38. 'bootstrap-table': '../libs/bootstrap-table/dist/bootstrap-table.min',
  39. 'bootstrap-table-export': '../libs/bootstrap-table/dist/extensions/export/bootstrap-table-export.min',
  40. 'bootstrap-table-fixed-columns': '../libs/bootstrap-table/dist/extensions/fixed-columns/bootstrap-table-fixed-columns',
  41. 'bootstrap-table-mobile': '../libs/bootstrap-table/dist/extensions/mobile/bootstrap-table-mobile',
  42. 'bootstrap-table-lang': '../libs/bootstrap-table/dist/locale/bootstrap-table-zh-CN',
  43. 'bootstrap-table-jumpto': '../libs/bootstrap-table/dist/extensions/page-jumpto/bootstrap-table-jumpto',
  44. 'bootstrap-slider': '../libs/bootstrap-slider/bootstrap-slider',
  45. 'tableexport': '../libs/tableExport.jquery.plugin/tableExport.min',
  46. 'dragsort': '../libs/fastadmin-dragsort/jquery.dragsort',
  47. 'sortable': '../libs/Sortable/Sortable.min',
  48. 'addtabs': '../libs/fastadmin-addtabs/jquery.addtabs',
  49. 'slimscroll': '../libs/jquery-slimscroll/jquery.slimscroll',
  50. 'validator': '../libs/nice-validator/dist/jquery.validator',
  51. 'validator-lang': '../libs/nice-validator/dist/local/zh-CN',
  52. 'toastr': '../libs/toastr/toastr',
  53. 'jstree': '../libs/jstree/dist/jstree.min',
  54. 'layer': '../libs/fastadmin-layer/dist/layer',
  55. 'cookie': '../libs/jquery.cookie/jquery.cookie',
  56. 'cxselect': '../libs/fastadmin-cxselect/js/jquery.cxselect',
  57. 'template': '../libs/art-template/dist/template-native',
  58. 'selectpage': '../libs/fastadmin-selectpage/selectpage',
  59. 'citypicker': '../libs/fastadmin-citypicker/dist/js/city-picker.min',
  60. 'citypicker-data': '../libs/fastadmin-citypicker/dist/js/city-picker.data',
  61. },
  62. // shim依赖配置
  63. shim: {
  64. 'addons': ['backend'],
  65. 'bootstrap': ['jquery'],
  66. 'bootstrap-table': {
  67. deps: ['bootstrap'],
  68. exports: '$.fn.bootstrapTable'
  69. },
  70. 'bootstrap-table-lang': {
  71. deps: ['bootstrap-table'],
  72. exports: '$.fn.bootstrapTable.defaults'
  73. },
  74. 'bootstrap-table-export': {
  75. deps: ['bootstrap-table'],
  76. exports: '$.fn.bootstrapTable.defaults'
  77. },
  78. 'bootstrap-table-fixed-columns': {
  79. deps: ['bootstrap-table'],
  80. exports: '$.fn.bootstrapTable.defaults'
  81. },
  82. 'bootstrap-table-mobile': {
  83. deps: ['bootstrap-table'],
  84. exports: '$.fn.bootstrapTable.defaults'
  85. },
  86. 'bootstrap-table-advancedsearch': {
  87. deps: ['bootstrap-table'],
  88. exports: '$.fn.bootstrapTable.defaults'
  89. },
  90. 'bootstrap-table-commonsearch': {
  91. deps: ['bootstrap-table'],
  92. exports: '$.fn.bootstrapTable.defaults'
  93. },
  94. 'bootstrap-table-template': {
  95. deps: ['bootstrap-table', 'template'],
  96. exports: '$.fn.bootstrapTable.defaults'
  97. },
  98. 'bootstrap-table-jumpto': {
  99. deps: ['bootstrap-table'],
  100. exports: '$.fn.bootstrapTable.defaults'
  101. },
  102. 'tableexport': {
  103. deps: ['jquery'],
  104. exports: '$.fn.extend'
  105. },
  106. 'slimscroll': {
  107. deps: ['jquery'],
  108. exports: '$.fn.extend'
  109. },
  110. 'adminlte': {
  111. deps: ['bootstrap', 'slimscroll'],
  112. exports: '$.AdminLTE'
  113. },
  114. 'bootstrap-daterangepicker': [
  115. 'moment/locale/zh-cn'
  116. ],
  117. 'bootstrap-datetimepicker': [
  118. 'moment/locale/zh-cn',
  119. ],
  120. 'bootstrap-select-lang': ['bootstrap-select'],
  121. 'jstree': ['css!../libs/jstree/dist/themes/default/style.css'],
  122. 'validator-lang': ['validator'],
  123. 'citypicker': ['citypicker-data', 'css!../libs/fastadmin-citypicker/dist/css/city-picker.css']
  124. },
  125. baseUrl: requirejs.s.contexts._.config.config.site.cdnurl + '/assets/js/', //资源基础路径
  126. map: {
  127. '*': {
  128. 'css': '../libs/require-css/css.min'
  129. }
  130. },
  131. waitSeconds: 60,
  132. charset: 'utf-8' // 文件编码
  133. });
  134. require(['jquery', 'bootstrap'], function ($, undefined) {
  135. //初始配置
  136. var Config = requirejs.s.contexts._.config.config;
  137. //将Config渲染到全局
  138. window.Config = Config;
  139. // 配置语言包的路径
  140. var paths = {};
  141. paths['lang'] = Config.moduleurl + '/ajax/lang?callback=define&controllername=' + Config.controllername + '&lang=' + Config.language;
  142. // 避免目录冲突
  143. paths['backend/'] = 'backend/';
  144. require.config({paths: paths});
  145. // 初始化
  146. $(function () {
  147. require(['fast'], function (Fast) {
  148. require(['backend', 'backend-init', 'addons'], function (Backend, undefined, Addons) {
  149. //加载相应模块
  150. if (Config.jsname) {
  151. require([Config.jsname], function (Controller) {
  152. if (Controller.hasOwnProperty(Config.actionname)) {
  153. Controller[Config.actionname]();
  154. } else {
  155. if (Controller.hasOwnProperty("_empty")) {
  156. Controller._empty();
  157. }
  158. }
  159. }, function (e) {
  160. console.error(e);
  161. // 这里可捕获模块加载的错误
  162. });
  163. }
  164. });
  165. });
  166. });
  167. });
  168. define("require-backend", function(){});
  169. 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});
  170. /*! layer-v3.5.5 Web 通用弹出层组件 MIT License http://layer.layui.com/ By 贤心 */
  171. ;!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);
  172. /*
  173. * Toastr
  174. * Copyright 2012-2015
  175. * Authors: John Papa, Hans Fjällemark, and Tim Ferrell.
  176. * All Rights Reserved.
  177. * Use, reproduction, distribution, and modification of this code is subject to the terms and
  178. * conditions of the MIT license, available at http://www.opensource.org/licenses/mit-license.php
  179. *
  180. * ARIA Support: Greta Krafsig
  181. *
  182. * Project: https://github.com/CodeSeven/toastr
  183. */
  184. /* global define */
  185. (function (define) {
  186. define('toastr',['jquery'], function ($) {
  187. return (function () {
  188. var $container;
  189. var listener;
  190. var toastId = 0;
  191. var toastType = {
  192. error: 'error',
  193. info: 'info',
  194. success: 'success',
  195. warning: 'warning'
  196. };
  197. var toastr = {
  198. clear: clear,
  199. remove: remove,
  200. error: error,
  201. getContainer: getContainer,
  202. info: info,
  203. options: {},
  204. subscribe: subscribe,
  205. success: success,
  206. version: '2.1.3',
  207. warning: warning
  208. };
  209. var previousToast;
  210. return toastr;
  211. ////////////////
  212. function error(message, title, optionsOverride) {
  213. return notify({
  214. type: toastType.error,
  215. iconClass: getOptions().iconClasses.error,
  216. message: message,
  217. optionsOverride: optionsOverride,
  218. title: title
  219. });
  220. }
  221. function getContainer(options, create) {
  222. if (!options) { options = getOptions(); }
  223. $container = $('#' + options.containerId);
  224. if ($container.length) {
  225. return $container;
  226. }
  227. if (create) {
  228. $container = createContainer(options);
  229. }
  230. return $container;
  231. }
  232. function info(message, title, optionsOverride) {
  233. return notify({
  234. type: toastType.info,
  235. iconClass: getOptions().iconClasses.info,
  236. message: message,
  237. optionsOverride: optionsOverride,
  238. title: title
  239. });
  240. }
  241. function subscribe(callback) {
  242. listener = callback;
  243. }
  244. function success(message, title, optionsOverride) {
  245. return notify({
  246. type: toastType.success,
  247. iconClass: getOptions().iconClasses.success,
  248. message: message,
  249. optionsOverride: optionsOverride,
  250. title: title
  251. });
  252. }
  253. function warning(message, title, optionsOverride) {
  254. return notify({
  255. type: toastType.warning,
  256. iconClass: getOptions().iconClasses.warning,
  257. message: message,
  258. optionsOverride: optionsOverride,
  259. title: title
  260. });
  261. }
  262. function clear($toastElement, clearOptions) {
  263. var options = getOptions();
  264. if (!$container) { getContainer(options); }
  265. if (!clearToast($toastElement, options, clearOptions)) {
  266. clearContainer(options);
  267. }
  268. }
  269. function remove($toastElement) {
  270. var options = getOptions();
  271. if (!$container) { getContainer(options); }
  272. if ($toastElement && $(':focus', $toastElement).length === 0) {
  273. removeToast($toastElement);
  274. return;
  275. }
  276. if ($container.children().length) {
  277. $container.remove();
  278. }
  279. }
  280. // internal functions
  281. function clearContainer (options) {
  282. var toastsToClear = $container.children();
  283. for (var i = toastsToClear.length - 1; i >= 0; i--) {
  284. clearToast($(toastsToClear[i]), options);
  285. }
  286. }
  287. function clearToast ($toastElement, options, clearOptions) {
  288. var force = clearOptions && clearOptions.force ? clearOptions.force : false;
  289. if ($toastElement && (force || $(':focus', $toastElement).length === 0)) {
  290. $toastElement[options.hideMethod]({
  291. duration: options.hideDuration,
  292. easing: options.hideEasing,
  293. complete: function () { removeToast($toastElement); }
  294. });
  295. return true;
  296. }
  297. return false;
  298. }
  299. function createContainer(options) {
  300. $container = $('<div/>')
  301. .attr('id', options.containerId)
  302. .addClass(options.positionClass);
  303. $container.appendTo($(options.target));
  304. return $container;
  305. }
  306. function getDefaults() {
  307. return {
  308. tapToDismiss: true,
  309. toastClass: 'toast',
  310. containerId: 'toast-container',
  311. debug: false,
  312. showMethod: 'fadeIn', //fadeIn, slideDown, and show are built into jQuery
  313. showDuration: 300,
  314. showEasing: 'swing', //swing and linear are built into jQuery
  315. onShown: undefined,
  316. hideMethod: 'fadeOut',
  317. hideDuration: 1000,
  318. hideEasing: 'swing',
  319. onHidden: undefined,
  320. closeMethod: false,
  321. closeDuration: false,
  322. closeEasing: false,
  323. closeOnHover: true,
  324. extendedTimeOut: 1000,
  325. iconClasses: {
  326. error: 'toast-error',
  327. info: 'toast-info',
  328. success: 'toast-success',
  329. warning: 'toast-warning'
  330. },
  331. iconClass: 'toast-info',
  332. positionClass: 'toast-top-right',
  333. timeOut: 5000, // Set timeOut and extendedTimeOut to 0 to make it sticky
  334. titleClass: 'toast-title',
  335. messageClass: 'toast-message',
  336. escapeHtml: false,
  337. target: 'body',
  338. closeHtml: '<button type="button">&times;</button>',
  339. closeClass: 'toast-close-button',
  340. newestOnTop: true,
  341. preventDuplicates: false,
  342. progressBar: false,
  343. progressClass: 'toast-progress',
  344. rtl: false
  345. };
  346. }
  347. function publish(args) {
  348. if (!listener) { return; }
  349. listener(args);
  350. }
  351. function notify(map) {
  352. var options = getOptions();
  353. var iconClass = map.iconClass || options.iconClass;
  354. if (typeof (map.optionsOverride) !== 'undefined') {
  355. options = $.extend(options, map.optionsOverride);
  356. iconClass = map.optionsOverride.iconClass || iconClass;
  357. }
  358. if (shouldExit(options, map)) { return; }
  359. toastId++;
  360. $container = getContainer(options, true);
  361. var intervalId = null;
  362. var $toastElement = $('<div/>');
  363. var $titleElement = $('<div/>');
  364. var $messageElement = $('<div/>');
  365. var $progressElement = $('<div/>');
  366. var $closeElement = $(options.closeHtml);
  367. var progressBar = {
  368. intervalId: null,
  369. hideEta: null,
  370. maxHideTime: null
  371. };
  372. var response = {
  373. toastId: toastId,
  374. state: 'visible',
  375. startTime: new Date(),
  376. options: options,
  377. map: map
  378. };
  379. personalizeToast();
  380. displayToast();
  381. handleEvents();
  382. publish(response);
  383. if (options.debug && console) {
  384. console.log(response);
  385. }
  386. return $toastElement;
  387. function escapeHtml(source) {
  388. if (source == null) {
  389. source = '';
  390. }
  391. return source
  392. .replace(/&/g, '&amp;')
  393. .replace(/"/g, '&quot;')
  394. .replace(/'/g, '&#39;')
  395. .replace(/</g, '&lt;')
  396. .replace(/>/g, '&gt;');
  397. }
  398. function personalizeToast() {
  399. setIcon();
  400. setTitle();
  401. setMessage();
  402. setCloseButton();
  403. setProgressBar();
  404. setRTL();
  405. setSequence();
  406. setAria();
  407. }
  408. function setAria() {
  409. var ariaValue = '';
  410. switch (map.iconClass) {
  411. case 'toast-success':
  412. case 'toast-info':
  413. ariaValue = 'polite';
  414. break;
  415. default:
  416. ariaValue = 'assertive';
  417. }
  418. $toastElement.attr('aria-live', ariaValue);
  419. }
  420. function handleEvents() {
  421. if (options.closeOnHover) {
  422. $toastElement.hover(stickAround, delayedHideToast);
  423. }
  424. if (!options.onclick && options.tapToDismiss) {
  425. $toastElement.click(hideToast);
  426. }
  427. if (options.closeButton && $closeElement) {
  428. $closeElement.click(function (event) {
  429. if (event.stopPropagation) {
  430. event.stopPropagation();
  431. } else if (event.cancelBubble !== undefined && event.cancelBubble !== true) {
  432. event.cancelBubble = true;
  433. }
  434. if (options.onCloseClick) {
  435. options.onCloseClick(event);
  436. }
  437. hideToast(true);
  438. });
  439. }
  440. if (options.onclick) {
  441. $toastElement.click(function (event) {
  442. options.onclick(event);
  443. hideToast();
  444. });
  445. }
  446. }
  447. function displayToast() {
  448. $toastElement.hide();
  449. $toastElement[options.showMethod](
  450. {duration: options.showDuration, easing: options.showEasing, complete: options.onShown}
  451. );
  452. if (options.timeOut > 0) {
  453. intervalId = setTimeout(hideToast, options.timeOut);
  454. progressBar.maxHideTime = parseFloat(options.timeOut);
  455. progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime;
  456. if (options.progressBar) {
  457. progressBar.intervalId = setInterval(updateProgress, 10);
  458. }
  459. }
  460. }
  461. function setIcon() {
  462. if (map.iconClass) {
  463. $toastElement.addClass(options.toastClass).addClass(iconClass);
  464. }
  465. }
  466. function setSequence() {
  467. if (options.newestOnTop) {
  468. $container.prepend($toastElement);
  469. } else {
  470. $container.append($toastElement);
  471. }
  472. }
  473. function setTitle() {
  474. if (map.title) {
  475. var suffix = map.title;
  476. if (options.escapeHtml) {
  477. suffix = escapeHtml(map.title);
  478. }
  479. $titleElement.append(suffix).addClass(options.titleClass);
  480. $toastElement.append($titleElement);
  481. }
  482. }
  483. function setMessage() {
  484. if (map.message) {
  485. var suffix = map.message;
  486. if (options.escapeHtml) {
  487. suffix = escapeHtml(map.message);
  488. }
  489. $messageElement.append(suffix).addClass(options.messageClass);
  490. $toastElement.append($messageElement);
  491. }
  492. }
  493. function setCloseButton() {
  494. if (options.closeButton) {
  495. $closeElement.addClass(options.closeClass).attr('role', 'button');
  496. $toastElement.prepend($closeElement);
  497. }
  498. }
  499. function setProgressBar() {
  500. if (options.progressBar) {
  501. $progressElement.addClass(options.progressClass);
  502. $toastElement.prepend($progressElement);
  503. }
  504. }
  505. function setRTL() {
  506. if (options.rtl) {
  507. $toastElement.addClass('rtl');
  508. }
  509. }
  510. function shouldExit(options, map) {
  511. if (options.preventDuplicates) {
  512. if (map.message === previousToast) {
  513. return true;
  514. } else {
  515. previousToast = map.message;
  516. }
  517. }
  518. return false;
  519. }
  520. function hideToast(override) {
  521. var method = override && options.closeMethod !== false ? options.closeMethod : options.hideMethod;
  522. var duration = override && options.closeDuration !== false ?
  523. options.closeDuration : options.hideDuration;
  524. var easing = override && options.closeEasing !== false ? options.closeEasing : options.hideEasing;
  525. if ($(':focus', $toastElement).length && !override) {
  526. return;
  527. }
  528. clearTimeout(progressBar.intervalId);
  529. return $toastElement[method]({
  530. duration: duration,
  531. easing: easing,
  532. complete: function () {
  533. removeToast($toastElement);
  534. clearTimeout(intervalId);
  535. if (options.onHidden && response.state !== 'hidden') {
  536. options.onHidden();
  537. }
  538. response.state = 'hidden';
  539. response.endTime = new Date();
  540. publish(response);
  541. }
  542. });
  543. }
  544. function delayedHideToast() {
  545. if (options.timeOut > 0 || options.extendedTimeOut > 0) {
  546. intervalId = setTimeout(hideToast, options.extendedTimeOut);
  547. progressBar.maxHideTime = parseFloat(options.extendedTimeOut);
  548. progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime;
  549. }
  550. }
  551. function stickAround() {
  552. clearTimeout(intervalId);
  553. progressBar.hideEta = 0;
  554. $toastElement.stop(true, true)[options.showMethod](
  555. {duration: options.showDuration, easing: options.showEasing}
  556. );
  557. }
  558. function updateProgress() {
  559. var percentage = ((progressBar.hideEta - (new Date().getTime())) / progressBar.maxHideTime) * 100;
  560. $progressElement.width(percentage + '%');
  561. }
  562. }
  563. function getOptions() {
  564. return $.extend({}, getDefaults(), toastr.options);
  565. }
  566. function removeToast($toastElement) {
  567. if (!$container) { $container = getContainer(); }
  568. if ($toastElement.is(':visible')) {
  569. return;
  570. }
  571. $toastElement.remove();
  572. $toastElement = null;
  573. if ($container.children().length === 0) {
  574. $container.remove();
  575. previousToast = undefined;
  576. }
  577. }
  578. })();
  579. });
  580. }(typeof define === 'function' && define.amd ? define : function (deps, factory) {
  581. if (typeof module !== 'undefined' && module.exports) { //Node
  582. module.exports = factory(require('jquery'));
  583. } else {
  584. window.toastr = factory(window.jQuery);
  585. }
  586. }));
  587. define('fast',['jquery', 'bootstrap', 'toastr', 'layer', 'lang'], function ($, undefined, Toastr, Layer, Lang) {
  588. var Fast = {
  589. config: {
  590. //toastr默认配置
  591. toastr: {
  592. "closeButton": true,
  593. "debug": false,
  594. "newestOnTop": false,
  595. "progressBar": false,
  596. "positionClass": "toast-top-center",
  597. "preventDuplicates": false,
  598. "onclick": null,
  599. "showDuration": "300",
  600. "hideDuration": "1000",
  601. "timeOut": "5000",
  602. "extendedTimeOut": "1000",
  603. "showEasing": "swing",
  604. "hideEasing": "linear",
  605. "showMethod": "fadeIn",
  606. "hideMethod": "fadeOut"
  607. }
  608. },
  609. events: {
  610. //请求成功的回调
  611. onAjaxSuccess: function (ret, onAjaxSuccess) {
  612. var data = typeof ret.data !== 'undefined' ? ret.data : null;
  613. var msg = typeof ret.msg !== 'undefined' && ret.msg ? ret.msg : __('Operation completed');
  614. if (typeof onAjaxSuccess === 'function') {
  615. var result = onAjaxSuccess.call(this, data, ret);
  616. if (result === false)
  617. return;
  618. }
  619. Toastr.success(msg);
  620. },
  621. //请求错误的回调
  622. onAjaxError: function (ret, onAjaxError) {
  623. var data = typeof ret.data !== 'undefined' ? ret.data : null;
  624. if (typeof onAjaxError === 'function') {
  625. var result = onAjaxError.call(this, data, ret);
  626. if (result === false) {
  627. return;
  628. }
  629. }
  630. Toastr.error(ret.msg);
  631. },
  632. //服务器响应数据后
  633. onAjaxResponse: function (response) {
  634. try {
  635. var ret = typeof response === 'object' ? response : JSON.parse(response);
  636. if (!ret.hasOwnProperty('code')) {
  637. $.extend(ret, {code: -2, msg: response, data: null});
  638. }
  639. } catch (e) {
  640. var ret = {code: -1, msg: e.message, data: null};
  641. }
  642. return ret;
  643. }
  644. },
  645. api: {
  646. //发送Ajax请求
  647. ajax: function (options, success, error) {
  648. options = typeof options === 'string' ? {url: options} : options;
  649. var index;
  650. if (typeof options.loading === 'undefined' || options.loading) {
  651. index = Layer.load(options.loading || 0);
  652. }
  653. options = $.extend({
  654. type: "POST",
  655. dataType: "json",
  656. xhrFields: {
  657. withCredentials: true
  658. },
  659. success: function (ret) {
  660. index && Layer.close(index);
  661. ret = Fast.events.onAjaxResponse(ret);
  662. if (ret.code === 1) {
  663. Fast.events.onAjaxSuccess(ret, success);
  664. } else {
  665. Fast.events.onAjaxError(ret, error);
  666. }
  667. },
  668. error: function (xhr) {
  669. index && Layer.close(index);
  670. var ret = {code: xhr.status, msg: xhr.statusText, data: null};
  671. Fast.events.onAjaxError(ret, error);
  672. }
  673. }, options);
  674. return $.ajax(options);
  675. },
  676. //修复URL
  677. fixurl: function (url) {
  678. if (url.substr(0, 1) !== "/") {
  679. var r = new RegExp('^(?:[a-z]+:)?//', 'i');
  680. if (!r.test(url)) {
  681. url = Config.moduleurl + "/" + url;
  682. }
  683. } else if (url.substr(0, 8) === "/addons/") {
  684. url = Config.__PUBLIC__.replace(/(\/*$)/g, "") + url;
  685. }
  686. return url;
  687. },
  688. //获取修复后可访问的cdn链接
  689. cdnurl: function (url, domain) {
  690. var rule = new RegExp("^((?:[a-z]+:)?\\/\\/|data:image\\/)", "i");
  691. var cdnurl = Config.upload.cdnurl;
  692. if (typeof domain === 'undefined' || domain === true || cdnurl.indexOf("/") === 0) {
  693. url = rule.test(url) || (cdnurl && url.indexOf(cdnurl) === 0) ? url : cdnurl + url;
  694. }
  695. if (domain && !rule.test(url)) {
  696. domain = typeof domain === 'string' ? domain : location.origin;
  697. url = domain + url;
  698. }
  699. return url;
  700. },
  701. //查询Url参数
  702. query: function (name, url) {
  703. if (!url) {
  704. url = window.location.href;
  705. }
  706. if (!name)
  707. return '';
  708. name = name.replace(/[\[\]]/g, "\\$&");
  709. var regex = new RegExp("[?&/]" + name + "([=/]([^&#/?]*)|&|#|$)"),
  710. results = regex.exec(url);
  711. if (!results)
  712. return null;
  713. if (!results[2])
  714. return '';
  715. return decodeURIComponent(results[2].replace(/\+/g, " "));
  716. },
  717. //打开一个弹出窗口
  718. open: function (url, title, options) {
  719. title = options && options.title ? options.title : (title ? title : "");
  720. url = Fast.api.fixurl(url);
  721. url = url + (url.indexOf("?") > -1 ? "&" : "?") + "dialog=1";
  722. var area = Fast.config.openArea != undefined ? Fast.config.openArea : [$(window).width() > 800 ? '800px' : '95%', $(window).height() > 600 ? '600px' : '95%'];
  723. var success = options && typeof options.success === 'function' ? options.success : $.noop;
  724. if (options && typeof options.success === 'function') {
  725. delete options.success;
  726. }
  727. options = $.extend({
  728. type: 2,
  729. title: title,
  730. shadeClose: true,
  731. shade: false,
  732. maxmin: true,
  733. moveOut: true,
  734. area: area,
  735. content: url,
  736. zIndex: Layer.zIndex,
  737. success: function (layero, index) {
  738. var that = this;
  739. //存储callback事件
  740. $(layero).data("callback", that.callback);
  741. //$(layero).removeClass("layui-layer-border");
  742. Layer.setTop(layero);
  743. try {
  744. var frame = Layer.getChildFrame('html', index);
  745. var layerfooter = frame.find(".layer-footer");
  746. Fast.api.layerfooter(layero, index, that);
  747. //绑定事件
  748. if (layerfooter.length > 0) {
  749. // 监听窗口内的元素及属性变化
  750. // Firefox和Chrome早期版本中带有前缀
  751. var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
  752. if (MutationObserver) {
  753. // 选择目标节点
  754. var target = layerfooter[0];
  755. // 创建观察者对象
  756. var observer = new MutationObserver(function (mutations) {
  757. Fast.api.layerfooter(layero, index, that);
  758. mutations.forEach(function (mutation) {
  759. });
  760. });
  761. // 配置观察选项:
  762. var config = {attributes: true, childList: true, characterData: true, subtree: true}
  763. // 传入目标节点和观察选项
  764. observer.observe(target, config);
  765. // 随后,你还可以停止观察
  766. // observer.disconnect();
  767. }
  768. }
  769. } catch (e) {
  770. }
  771. if ($(layero).height() > $(window).height()) {
  772. //当弹出窗口大于浏览器可视高度时,重定位
  773. Layer.style(index, {
  774. top: 0,
  775. height: $(window).height()
  776. });
  777. }
  778. success.call(this, layero, index);
  779. }
  780. }, options ? options : {});
  781. if ($(window).width() < 480 || (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream && top.$(".tab-pane.active").length > 0)) {
  782. if (top.$(".tab-pane.active").length > 0) {
  783. options.area = [top.$(".tab-pane.active").width() + "px", top.$(".tab-pane.active").height() + "px"];
  784. options.offset = [top.$(".tab-pane.active").scrollTop() + "px", "0px"];
  785. } else {
  786. options.area = [$(window).width() + "px", $(window).height() + "px"];
  787. options.offset = ["0px", "0px"];
  788. }
  789. }
  790. return Layer.open(options);
  791. },
  792. //关闭窗口并回传数据
  793. close: function (data) {
  794. var index = parent.Layer.getFrameIndex(window.name);
  795. var callback = parent.$("#layui-layer" + index).data("callback");
  796. //再执行关闭
  797. parent.Layer.close(index);
  798. //再调用回传函数
  799. if (typeof callback === 'function') {
  800. callback.call(undefined, data);
  801. }
  802. },
  803. layerfooter: function (layero, index, that) {
  804. var frame = Layer.getChildFrame('html', index);
  805. var layerfooter = frame.find(".layer-footer");
  806. if (layerfooter.length > 0) {
  807. $(".layui-layer-footer", layero).remove();
  808. var footer = $("<div />").addClass('layui-layer-btn layui-layer-footer');
  809. footer.html(layerfooter.html());
  810. if ($(".row", footer).length === 0) {
  811. $(">", footer).wrapAll("<div class='row'></div>");
  812. }
  813. footer.insertAfter(layero.find('.layui-layer-content'));
  814. //绑定事件
  815. footer.on("click", ".btn", function () {
  816. if ($(this).hasClass("disabled") || $(this).parent().hasClass("disabled")) {
  817. return;
  818. }
  819. var index = footer.find('.btn').index(this);
  820. $(".btn:eq(" + index + ")", layerfooter).trigger("click");
  821. });
  822. var titHeight = layero.find('.layui-layer-title').outerHeight() || 0;
  823. var btnHeight = layero.find('.layui-layer-btn').outerHeight() || 0;
  824. //重设iframe高度
  825. $("iframe", layero).height(layero.height() - titHeight - btnHeight);
  826. }
  827. //修复iOS下弹出窗口的高度和iOS下iframe无法滚动的BUG
  828. if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
  829. var titHeight = layero.find('.layui-layer-title').outerHeight() || 0;
  830. var btnHeight = layero.find('.layui-layer-btn').outerHeight() || 0;
  831. $("iframe", layero).parent().css("height", layero.height() - titHeight - btnHeight);
  832. $("iframe", layero).css("height", "100%");
  833. }
  834. },
  835. success: function (options, callback) {
  836. var type = typeof options === 'function';
  837. if (type) {
  838. callback = options;
  839. }
  840. return Layer.msg(__('Operation completed'), $.extend({
  841. offset: 0, icon: 1
  842. }, type ? {} : options), callback);
  843. },
  844. error: function (options, callback) {
  845. var type = typeof options === 'function';
  846. if (type) {
  847. callback = options;
  848. }
  849. return Layer.msg(__('Operation failed'), $.extend({
  850. offset: 0, icon: 2
  851. }, type ? {} : options), callback);
  852. },
  853. msg: function (message, url) {
  854. var callback = typeof url === 'function' ? url : function () {
  855. if (typeof url !== 'undefined' && url) {
  856. location.href = url;
  857. }
  858. };
  859. Layer.msg(message, {
  860. time: 2000
  861. }, callback);
  862. },
  863. escape: function (text) {
  864. if (typeof text === 'string') {
  865. return text
  866. .replace(/&/g, '&amp;')
  867. .replace(/</g, '&lt;')
  868. .replace(/>/g, '&gt;')
  869. .replace(/"/g, '&quot;')
  870. .replace(/'/g, '&#039;')
  871. .replace(/`/g, '&#x60;');
  872. }
  873. return text;
  874. },
  875. toastr: Toastr,
  876. layer: Layer
  877. },
  878. lang: function () {
  879. var args = arguments,
  880. string = args[0],
  881. i = 1;
  882. string = string.toLowerCase();
  883. //string = typeof Lang[string] != 'undefined' ? Lang[string] : string;
  884. if (typeof Lang !== 'undefined' && typeof Lang[string] !== 'undefined') {
  885. if (typeof Lang[string] == 'object')
  886. return Lang[string];
  887. string = Lang[string];
  888. } else if (string.indexOf('.') !== -1 && false) {
  889. var arr = string.split('.');
  890. var current = Lang[arr[0]];
  891. for (var i = 1; i < arr.length; i++) {
  892. current = typeof current[arr[i]] != 'undefined' ? current[arr[i]] : '';
  893. if (typeof current != 'object')
  894. break;
  895. }
  896. if (typeof current == 'object')
  897. return current;
  898. string = current;
  899. } else {
  900. string = args[0];
  901. }
  902. return string.replace(/%((%)|s|d)/g, function (m) {
  903. // m is the matched format, e.g. %s, %d
  904. var val = null;
  905. if (m[2]) {
  906. val = m[2];
  907. } else {
  908. val = args[i];
  909. // A switch statement so that the formatter can be extended. Default is %s
  910. switch (m) {
  911. case '%d':
  912. val = parseFloat(val);
  913. if (isNaN(val)) {
  914. val = 0;
  915. }
  916. break;
  917. }
  918. i++;
  919. }
  920. return val;
  921. });
  922. },
  923. init: function () {
  924. // jQuery兼容处理
  925. $.fn.extend({
  926. size: function () {
  927. return $(this).length;
  928. }
  929. });
  930. // 对相对地址进行处理
  931. $.ajaxSetup({
  932. beforeSend: function (xhr, setting) {
  933. setting.url = Fast.api.fixurl(setting.url);
  934. }
  935. });
  936. Layer.config({
  937. skin: 'layui-layer-fast'
  938. });
  939. // 绑定ESC关闭窗口事件
  940. $(window).keyup(function (e) {
  941. if (e.keyCode == 27) {
  942. if ($(".layui-layer").length > 0) {
  943. var index = 0;
  944. $(".layui-layer").each(function () {
  945. index = Math.max(index, parseInt($(this).attr("times")));
  946. });
  947. if (index) {
  948. Layer.close(index);
  949. }
  950. }
  951. }
  952. });
  953. //公共代码
  954. //配置Toastr的参数
  955. Toastr.options = Fast.config.toastr;
  956. }
  957. };
  958. //将Layer暴露到全局中去
  959. window.Layer = Layer;
  960. //将Toastr暴露到全局中去
  961. window.Toastr = Toastr;
  962. //将语言方法暴露到全局中去
  963. window.__ = Fast.lang;
  964. //将Fast渲染至全局
  965. window.Fast = Fast;
  966. //默认初始化执行的代码
  967. Fast.init();
  968. return Fast;
  969. });
  970. /*!art-template - Template Engine | http://aui.github.com/artTemplate/*/
  971. !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=/^$|,+/;"object"==typeof exports&&"undefined"!=typeof module?module.exports=d:"function"==typeof define?define('template',[],function(){return d}):this.template=d}();
  972. //! moment.js
  973. //! version : 2.29.4
  974. //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
  975. //! license : MIT
  976. //! momentjs.com
  977. ;(function (global, factory) {
  978. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  979. typeof define === 'function' && define.amd ? define('moment/moment',factory) :
  980. global.moment = factory()
  981. }(this, (function () { 'use strict';
  982. var hookCallback;
  983. function hooks() {
  984. return hookCallback.apply(null, arguments);
  985. }
  986. // This is done to register the method called with moment()
  987. // without creating circular dependencies.
  988. function setHookCallback(callback) {
  989. hookCallback = callback;
  990. }
  991. function isArray(input) {
  992. return (
  993. input instanceof Array ||
  994. Object.prototype.toString.call(input) === '[object Array]'
  995. );
  996. }
  997. function isObject(input) {
  998. // IE8 will treat undefined and null as object if it wasn't for
  999. // input != null
  1000. return (
  1001. input != null &&
  1002. Object.prototype.toString.call(input) === '[object Object]'
  1003. );
  1004. }
  1005. function hasOwnProp(a, b) {
  1006. return Object.prototype.hasOwnProperty.call(a, b);
  1007. }
  1008. function isObjectEmpty(obj) {
  1009. if (Object.getOwnPropertyNames) {
  1010. return Object.getOwnPropertyNames(obj).length === 0;
  1011. } else {
  1012. var k;
  1013. for (k in obj) {
  1014. if (hasOwnProp(obj, k)) {
  1015. return false;
  1016. }
  1017. }
  1018. return true;
  1019. }
  1020. }
  1021. function isUndefined(input) {
  1022. return input === void 0;
  1023. }
  1024. function isNumber(input) {
  1025. return (
  1026. typeof input === 'number' ||
  1027. Object.prototype.toString.call(input) === '[object Number]'
  1028. );
  1029. }
  1030. function isDate(input) {
  1031. return (
  1032. input instanceof Date ||
  1033. Object.prototype.toString.call(input) === '[object Date]'
  1034. );
  1035. }
  1036. function map(arr, fn) {
  1037. var res = [],
  1038. i,
  1039. arrLen = arr.length;
  1040. for (i = 0; i < arrLen; ++i) {
  1041. res.push(fn(arr[i], i));
  1042. }
  1043. return res;
  1044. }
  1045. function extend(a, b) {
  1046. for (var i in b) {
  1047. if (hasOwnProp(b, i)) {
  1048. a[i] = b[i];
  1049. }
  1050. }
  1051. if (hasOwnProp(b, 'toString')) {
  1052. a.toString = b.toString;
  1053. }
  1054. if (hasOwnProp(b, 'valueOf')) {
  1055. a.valueOf = b.valueOf;
  1056. }
  1057. return a;
  1058. }
  1059. function createUTC(input, format, locale, strict) {
  1060. return createLocalOrUTC(input, format, locale, strict, true).utc();
  1061. }
  1062. function defaultParsingFlags() {
  1063. // We need to deep clone this object.
  1064. return {
  1065. empty: false,
  1066. unusedTokens: [],
  1067. unusedInput: [],
  1068. overflow: -2,
  1069. charsLeftOver: 0,
  1070. nullInput: false,
  1071. invalidEra: null,
  1072. invalidMonth: null,
  1073. invalidFormat: false,
  1074. userInvalidated: false,
  1075. iso: false,
  1076. parsedDateParts: [],
  1077. era: null,
  1078. meridiem: null,
  1079. rfc2822: false,
  1080. weekdayMismatch: false,
  1081. };
  1082. }
  1083. function getParsingFlags(m) {
  1084. if (m._pf == null) {
  1085. m._pf = defaultParsingFlags();
  1086. }
  1087. return m._pf;
  1088. }
  1089. var some;
  1090. if (Array.prototype.some) {
  1091. some = Array.prototype.some;
  1092. } else {
  1093. some = function (fun) {
  1094. var t = Object(this),
  1095. len = t.length >>> 0,
  1096. i;
  1097. for (i = 0; i < len; i++) {
  1098. if (i in t && fun.call(this, t[i], i, t)) {
  1099. return true;
  1100. }
  1101. }
  1102. return false;
  1103. };
  1104. }
  1105. function isValid(m) {
  1106. if (m._isValid == null) {
  1107. var flags = getParsingFlags(m),
  1108. parsedParts = some.call(flags.parsedDateParts, function (i) {
  1109. return i != null;
  1110. }),
  1111. isNowValid =
  1112. !isNaN(m._d.getTime()) &&
  1113. flags.overflow < 0 &&
  1114. !flags.empty &&
  1115. !flags.invalidEra &&
  1116. !flags.invalidMonth &&
  1117. !flags.invalidWeekday &&
  1118. !flags.weekdayMismatch &&
  1119. !flags.nullInput &&
  1120. !flags.invalidFormat &&
  1121. !flags.userInvalidated &&
  1122. (!flags.meridiem || (flags.meridiem && parsedParts));
  1123. if (m._strict) {
  1124. isNowValid =
  1125. isNowValid &&
  1126. flags.charsLeftOver === 0 &&
  1127. flags.unusedTokens.length === 0 &&
  1128. flags.bigHour === undefined;
  1129. }
  1130. if (Object.isFrozen == null || !Object.isFrozen(m)) {
  1131. m._isValid = isNowValid;
  1132. } else {
  1133. return isNowValid;
  1134. }
  1135. }
  1136. return m._isValid;
  1137. }
  1138. function createInvalid(flags) {
  1139. var m = createUTC(NaN);
  1140. if (flags != null) {
  1141. extend(getParsingFlags(m), flags);
  1142. } else {
  1143. getParsingFlags(m).userInvalidated = true;
  1144. }
  1145. return m;
  1146. }
  1147. // Plugins that add properties should also add the key here (null value),
  1148. // so we can properly clone ourselves.
  1149. var momentProperties = (hooks.momentProperties = []),
  1150. updateInProgress = false;
  1151. function copyConfig(to, from) {
  1152. var i,
  1153. prop,
  1154. val,
  1155. momentPropertiesLen = momentProperties.length;
  1156. if (!isUndefined(from._isAMomentObject)) {
  1157. to._isAMomentObject = from._isAMomentObject;
  1158. }
  1159. if (!isUndefined(from._i)) {
  1160. to._i = from._i;
  1161. }
  1162. if (!isUndefined(from._f)) {
  1163. to._f = from._f;
  1164. }
  1165. if (!isUndefined(from._l)) {
  1166. to._l = from._l;
  1167. }
  1168. if (!isUndefined(from._strict)) {
  1169. to._strict = from._strict;
  1170. }
  1171. if (!isUndefined(from._tzm)) {
  1172. to._tzm = from._tzm;
  1173. }
  1174. if (!isUndefined(from._isUTC)) {
  1175. to._isUTC = from._isUTC;
  1176. }
  1177. if (!isUndefined(from._offset)) {
  1178. to._offset = from._offset;
  1179. }
  1180. if (!isUndefined(from._pf)) {
  1181. to._pf = getParsingFlags(from);
  1182. }
  1183. if (!isUndefined(from._locale)) {
  1184. to._locale = from._locale;
  1185. }
  1186. if (momentPropertiesLen > 0) {
  1187. for (i = 0; i < momentPropertiesLen; i++) {
  1188. prop = momentProperties[i];
  1189. val = from[prop];
  1190. if (!isUndefined(val)) {
  1191. to[prop] = val;
  1192. }
  1193. }
  1194. }
  1195. return to;
  1196. }
  1197. // Moment prototype object
  1198. function Moment(config) {
  1199. copyConfig(this, config);
  1200. this._d = new Date(config._d != null ? config._d.getTime() : NaN);
  1201. if (!this.isValid()) {
  1202. this._d = new Date(NaN);
  1203. }
  1204. // Prevent infinite loop in case updateOffset creates new moment
  1205. // objects.
  1206. if (updateInProgress === false) {
  1207. updateInProgress = true;
  1208. hooks.updateOffset(this);
  1209. updateInProgress = false;
  1210. }
  1211. }
  1212. function isMoment(obj) {
  1213. return (
  1214. obj instanceof Moment || (obj != null && obj._isAMomentObject != null)
  1215. );
  1216. }
  1217. function warn(msg) {
  1218. if (
  1219. hooks.suppressDeprecationWarnings === false &&
  1220. typeof console !== 'undefined' &&
  1221. console.warn
  1222. ) {
  1223. console.warn('Deprecation warning: ' + msg);
  1224. }
  1225. }
  1226. function deprecate(msg, fn) {
  1227. var firstTime = true;
  1228. return extend(function () {
  1229. if (hooks.deprecationHandler != null) {
  1230. hooks.deprecationHandler(null, msg);
  1231. }
  1232. if (firstTime) {
  1233. var args = [],
  1234. arg,
  1235. i,
  1236. key,
  1237. argLen = arguments.length;
  1238. for (i = 0; i < argLen; i++) {
  1239. arg = '';
  1240. if (typeof arguments[i] === 'object') {
  1241. arg += '\n[' + i + '] ';
  1242. for (key in arguments[0]) {
  1243. if (hasOwnProp(arguments[0], key)) {
  1244. arg += key + ': ' + arguments[0][key] + ', ';
  1245. }
  1246. }
  1247. arg = arg.slice(0, -2); // Remove trailing comma and space
  1248. } else {
  1249. arg = arguments[i];
  1250. }
  1251. args.push(arg);
  1252. }
  1253. warn(
  1254. msg +
  1255. '\nArguments: ' +
  1256. Array.prototype.slice.call(args).join('') +
  1257. '\n' +
  1258. new Error().stack
  1259. );
  1260. firstTime = false;
  1261. }
  1262. return fn.apply(this, arguments);
  1263. }, fn);
  1264. }
  1265. var deprecations = {};
  1266. function deprecateSimple(name, msg) {
  1267. if (hooks.deprecationHandler != null) {
  1268. hooks.deprecationHandler(name, msg);
  1269. }
  1270. if (!deprecations[name]) {
  1271. warn(msg);
  1272. deprecations[name] = true;
  1273. }
  1274. }
  1275. hooks.suppressDeprecationWarnings = false;
  1276. hooks.deprecationHandler = null;
  1277. function isFunction(input) {
  1278. return (
  1279. (typeof Function !== 'undefined' && input instanceof Function) ||
  1280. Object.prototype.toString.call(input) === '[object Function]'
  1281. );
  1282. }
  1283. function set(config) {
  1284. var prop, i;
  1285. for (i in config) {
  1286. if (hasOwnProp(config, i)) {
  1287. prop = config[i];
  1288. if (isFunction(prop)) {
  1289. this[i] = prop;
  1290. } else {
  1291. this['_' + i] = prop;
  1292. }
  1293. }
  1294. }
  1295. this._config = config;
  1296. // Lenient ordinal parsing accepts just a number in addition to
  1297. // number + (possibly) stuff coming from _dayOfMonthOrdinalParse.
  1298. // TODO: Remove "ordinalParse" fallback in next major release.
  1299. this._dayOfMonthOrdinalParseLenient = new RegExp(
  1300. (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
  1301. '|' +
  1302. /\d{1,2}/.source
  1303. );
  1304. }
  1305. function mergeConfigs(parentConfig, childConfig) {
  1306. var res = extend({}, parentConfig),
  1307. prop;
  1308. for (prop in childConfig) {
  1309. if (hasOwnProp(childConfig, prop)) {
  1310. if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
  1311. res[prop] = {};
  1312. extend(res[prop], parentConfig[prop]);
  1313. extend(res[prop], childConfig[prop]);
  1314. } else if (childConfig[prop] != null) {
  1315. res[prop] = childConfig[prop];
  1316. } else {
  1317. delete res[prop];
  1318. }
  1319. }
  1320. }
  1321. for (prop in parentConfig) {
  1322. if (
  1323. hasOwnProp(parentConfig, prop) &&
  1324. !hasOwnProp(childConfig, prop) &&
  1325. isObject(parentConfig[prop])
  1326. ) {
  1327. // make sure changes to properties don't modify parent config
  1328. res[prop] = extend({}, res[prop]);
  1329. }
  1330. }
  1331. return res;
  1332. }
  1333. function Locale(config) {
  1334. if (config != null) {
  1335. this.set(config);
  1336. }
  1337. }
  1338. var keys;
  1339. if (Object.keys) {
  1340. keys = Object.keys;
  1341. } else {
  1342. keys = function (obj) {
  1343. var i,
  1344. res = [];
  1345. for (i in obj) {
  1346. if (hasOwnProp(obj, i)) {
  1347. res.push(i);
  1348. }
  1349. }
  1350. return res;
  1351. };
  1352. }
  1353. var defaultCalendar = {
  1354. sameDay: '[Today at] LT',
  1355. nextDay: '[Tomorrow at] LT',
  1356. nextWeek: 'dddd [at] LT',
  1357. lastDay: '[Yesterday at] LT',
  1358. lastWeek: '[Last] dddd [at] LT',
  1359. sameElse: 'L',
  1360. };
  1361. function calendar(key, mom, now) {
  1362. var output = this._calendar[key] || this._calendar['sameElse'];
  1363. return isFunction(output) ? output.call(mom, now) : output;
  1364. }
  1365. function zeroFill(number, targetLength, forceSign) {
  1366. var absNumber = '' + Math.abs(number),
  1367. zerosToFill = targetLength - absNumber.length,
  1368. sign = number >= 0;
  1369. return (
  1370. (sign ? (forceSign ? '+' : '') : '-') +
  1371. Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) +
  1372. absNumber
  1373. );
  1374. }
  1375. var formattingTokens =
  1376. /(\[[^\[]*\])|(\\)?([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,
  1377. localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,
  1378. formatFunctions = {},
  1379. formatTokenFunctions = {};
  1380. // token: 'M'
  1381. // padded: ['MM', 2]
  1382. // ordinal: 'Mo'
  1383. // callback: function () { this.month() + 1 }
  1384. function addFormatToken(token, padded, ordinal, callback) {
  1385. var func = callback;
  1386. if (typeof callback === 'string') {
  1387. func = function () {
  1388. return this[callback]();
  1389. };
  1390. }
  1391. if (token) {
  1392. formatTokenFunctions[token] = func;
  1393. }
  1394. if (padded) {
  1395. formatTokenFunctions[padded[0]] = function () {
  1396. return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
  1397. };
  1398. }
  1399. if (ordinal) {
  1400. formatTokenFunctions[ordinal] = function () {
  1401. return this.localeData().ordinal(
  1402. func.apply(this, arguments),
  1403. token
  1404. );
  1405. };
  1406. }
  1407. }
  1408. function removeFormattingTokens(input) {
  1409. if (input.match(/\[[\s\S]/)) {
  1410. return input.replace(/^\[|\]$/g, '');
  1411. }
  1412. return input.replace(/\\/g, '');
  1413. }
  1414. function makeFormatFunction(format) {
  1415. var array = format.match(formattingTokens),
  1416. i,
  1417. length;
  1418. for (i = 0, length = array.length; i < length; i++) {
  1419. if (formatTokenFunctions[array[i]]) {
  1420. array[i] = formatTokenFunctions[array[i]];
  1421. } else {
  1422. array[i] = removeFormattingTokens(array[i]);
  1423. }
  1424. }
  1425. return function (mom) {
  1426. var output = '',
  1427. i;
  1428. for (i = 0; i < length; i++) {
  1429. output += isFunction(array[i])
  1430. ? array[i].call(mom, format)
  1431. : array[i];
  1432. }
  1433. return output;
  1434. };
  1435. }
  1436. // format date using native date object
  1437. function formatMoment(m, format) {
  1438. if (!m.isValid()) {
  1439. return m.localeData().invalidDate();
  1440. }
  1441. format = expandFormat(format, m.localeData());
  1442. formatFunctions[format] =
  1443. formatFunctions[format] || makeFormatFunction(format);
  1444. return formatFunctions[format](m);
  1445. }
  1446. function expandFormat(format, locale) {
  1447. var i = 5;
  1448. function replaceLongDateFormatTokens(input) {
  1449. return locale.longDateFormat(input) || input;
  1450. }
  1451. localFormattingTokens.lastIndex = 0;
  1452. while (i >= 0 && localFormattingTokens.test(format)) {
  1453. format = format.replace(
  1454. localFormattingTokens,
  1455. replaceLongDateFormatTokens
  1456. );
  1457. localFormattingTokens.lastIndex = 0;
  1458. i -= 1;
  1459. }
  1460. return format;
  1461. }
  1462. var defaultLongDateFormat = {
  1463. LTS: 'h:mm:ss A',
  1464. LT: 'h:mm A',
  1465. L: 'MM/DD/YYYY',
  1466. LL: 'MMMM D, YYYY',
  1467. LLL: 'MMMM D, YYYY h:mm A',
  1468. LLLL: 'dddd, MMMM D, YYYY h:mm A',
  1469. };
  1470. function longDateFormat(key) {
  1471. var format = this._longDateFormat[key],
  1472. formatUpper = this._longDateFormat[key.toUpperCase()];
  1473. if (format || !formatUpper) {
  1474. return format;
  1475. }
  1476. this._longDateFormat[key] = formatUpper
  1477. .match(formattingTokens)
  1478. .map(function (tok) {
  1479. if (
  1480. tok === 'MMMM' ||
  1481. tok === 'MM' ||
  1482. tok === 'DD' ||
  1483. tok === 'dddd'
  1484. ) {
  1485. return tok.slice(1);
  1486. }
  1487. return tok;
  1488. })
  1489. .join('');
  1490. return this._longDateFormat[key];
  1491. }
  1492. var defaultInvalidDate = 'Invalid date';
  1493. function invalidDate() {
  1494. return this._invalidDate;
  1495. }
  1496. var defaultOrdinal = '%d',
  1497. defaultDayOfMonthOrdinalParse = /\d{1,2}/;
  1498. function ordinal(number) {
  1499. return this._ordinal.replace('%d', number);
  1500. }
  1501. var defaultRelativeTime = {
  1502. future: 'in %s',
  1503. past: '%s ago',
  1504. s: 'a few seconds',
  1505. ss: '%d seconds',
  1506. m: 'a minute',
  1507. mm: '%d minutes',
  1508. h: 'an hour',
  1509. hh: '%d hours',
  1510. d: 'a day',
  1511. dd: '%d days',
  1512. w: 'a week',
  1513. ww: '%d weeks',
  1514. M: 'a month',
  1515. MM: '%d months',
  1516. y: 'a year',
  1517. yy: '%d years',
  1518. };
  1519. function relativeTime(number, withoutSuffix, string, isFuture) {
  1520. var output = this._relativeTime[string];
  1521. return isFunction(output)
  1522. ? output(number, withoutSuffix, string, isFuture)
  1523. : output.replace(/%d/i, number);
  1524. }
  1525. function pastFuture(diff, output) {
  1526. var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
  1527. return isFunction(format) ? format(output) : format.replace(/%s/i, output);
  1528. }
  1529. var aliases = {};
  1530. function addUnitAlias(unit, shorthand) {
  1531. var lowerCase = unit.toLowerCase();
  1532. aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
  1533. }
  1534. function normalizeUnits(units) {
  1535. return typeof units === 'string'
  1536. ? aliases[units] || aliases[units.toLowerCase()]
  1537. : undefined;
  1538. }
  1539. function normalizeObjectUnits(inputObject) {
  1540. var normalizedInput = {},
  1541. normalizedProp,
  1542. prop;
  1543. for (prop in inputObject) {
  1544. if (hasOwnProp(inputObject, prop)) {
  1545. normalizedProp = normalizeUnits(prop);
  1546. if (normalizedProp) {
  1547. normalizedInput[normalizedProp] = inputObject[prop];
  1548. }
  1549. }
  1550. }
  1551. return normalizedInput;
  1552. }
  1553. var priorities = {};
  1554. function addUnitPriority(unit, priority) {
  1555. priorities[unit] = priority;
  1556. }
  1557. function getPrioritizedUnits(unitsObj) {
  1558. var units = [],
  1559. u;
  1560. for (u in unitsObj) {
  1561. if (hasOwnProp(unitsObj, u)) {
  1562. units.push({ unit: u, priority: priorities[u] });
  1563. }
  1564. }
  1565. units.sort(function (a, b) {
  1566. return a.priority - b.priority;
  1567. });
  1568. return units;
  1569. }
  1570. function isLeapYear(year) {
  1571. return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
  1572. }
  1573. function absFloor(number) {
  1574. if (number < 0) {
  1575. // -0 -> 0
  1576. return Math.ceil(number) || 0;
  1577. } else {
  1578. return Math.floor(number);
  1579. }
  1580. }
  1581. function toInt(argumentForCoercion) {
  1582. var coercedNumber = +argumentForCoercion,
  1583. value = 0;
  1584. if (coercedNumber !== 0 && isFinite(coercedNumber)) {
  1585. value = absFloor(coercedNumber);
  1586. }
  1587. return value;
  1588. }
  1589. function makeGetSet(unit, keepTime) {
  1590. return function (value) {
  1591. if (value != null) {
  1592. set$1(this, unit, value);
  1593. hooks.updateOffset(this, keepTime);
  1594. return this;
  1595. } else {
  1596. return get(this, unit);
  1597. }
  1598. };
  1599. }
  1600. function get(mom, unit) {
  1601. return mom.isValid()
  1602. ? mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]()
  1603. : NaN;
  1604. }
  1605. function set$1(mom, unit, value) {
  1606. if (mom.isValid() && !isNaN(value)) {
  1607. if (
  1608. unit === 'FullYear' &&
  1609. isLeapYear(mom.year()) &&
  1610. mom.month() === 1 &&
  1611. mom.date() === 29
  1612. ) {
  1613. value = toInt(value);
  1614. mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](
  1615. value,
  1616. mom.month(),
  1617. daysInMonth(value, mom.month())
  1618. );
  1619. } else {
  1620. mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
  1621. }
  1622. }
  1623. }
  1624. // MOMENTS
  1625. function stringGet(units) {
  1626. units = normalizeUnits(units);
  1627. if (isFunction(this[units])) {
  1628. return this[units]();
  1629. }
  1630. return this;
  1631. }
  1632. function stringSet(units, value) {
  1633. if (typeof units === 'object') {
  1634. units = normalizeObjectUnits(units);
  1635. var prioritized = getPrioritizedUnits(units),
  1636. i,
  1637. prioritizedLen = prioritized.length;
  1638. for (i = 0; i < prioritizedLen; i++) {
  1639. this[prioritized[i].unit](units[prioritized[i].unit]);
  1640. }
  1641. } else {
  1642. units = normalizeUnits(units);
  1643. if (isFunction(this[units])) {
  1644. return this[units](value);
  1645. }
  1646. }
  1647. return this;
  1648. }
  1649. var match1 = /\d/, // 0 - 9
  1650. match2 = /\d\d/, // 00 - 99
  1651. match3 = /\d{3}/, // 000 - 999
  1652. match4 = /\d{4}/, // 0000 - 9999
  1653. match6 = /[+-]?\d{6}/, // -999999 - 999999
  1654. match1to2 = /\d\d?/, // 0 - 99
  1655. match3to4 = /\d\d\d\d?/, // 999 - 9999
  1656. match5to6 = /\d\d\d\d\d\d?/, // 99999 - 999999
  1657. match1to3 = /\d{1,3}/, // 0 - 999
  1658. match1to4 = /\d{1,4}/, // 0 - 9999
  1659. match1to6 = /[+-]?\d{1,6}/, // -999999 - 999999
  1660. matchUnsigned = /\d+/, // 0 - inf
  1661. matchSigned = /[+-]?\d+/, // -inf - inf
  1662. matchOffset = /Z|[+-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z
  1663. matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi, // +00 -00 +00:00 -00:00 +0000 -0000 or Z
  1664. matchTimestamp = /[+-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123
  1665. // any word (or two) characters or numbers including two/three word month in arabic.
  1666. // includes scottish gaelic two word and hyphenated months
  1667. matchWord =
  1668. /[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,
  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. var tokens = {};
  1701. function addParseToken(token, callback) {
  1702. var i,
  1703. func = callback,
  1704. tokenLen;
  1705. if (typeof token === 'string') {
  1706. token = [token];
  1707. }
  1708. if (isNumber(callback)) {
  1709. func = function (input, array) {
  1710. array[callback] = toInt(input);
  1711. };
  1712. }
  1713. tokenLen = token.length;
  1714. for (i = 0; i < tokenLen; i++) {
  1715. tokens[token[i]] = func;
  1716. }
  1717. }
  1718. function addWeekParseToken(token, callback) {
  1719. addParseToken(token, function (input, array, config, token) {
  1720. config._w = config._w || {};
  1721. callback(input, config._w, config, token);
  1722. });
  1723. }
  1724. function addTimeToArrayFromToken(token, input, config) {
  1725. if (input != null && hasOwnProp(tokens, token)) {
  1726. tokens[token](input, config._a, config, token);
  1727. }
  1728. }
  1729. var YEAR = 0,
  1730. MONTH = 1,
  1731. DATE = 2,
  1732. HOUR = 3,
  1733. MINUTE = 4,
  1734. SECOND = 5,
  1735. MILLISECOND = 6,
  1736. WEEK = 7,
  1737. WEEKDAY = 8;
  1738. function mod(n, x) {
  1739. return ((n % x) + x) % x;
  1740. }
  1741. var indexOf;
  1742. if (Array.prototype.indexOf) {
  1743. indexOf = Array.prototype.indexOf;
  1744. } else {
  1745. indexOf = function (o) {
  1746. // I know
  1747. var i;
  1748. for (i = 0; i < this.length; ++i) {
  1749. if (this[i] === o) {
  1750. return i;
  1751. }
  1752. }
  1753. return -1;
  1754. };
  1755. }
  1756. function daysInMonth(year, month) {
  1757. if (isNaN(year) || isNaN(month)) {
  1758. return NaN;
  1759. }
  1760. var modMonth = mod(month, 12);
  1761. year += (month - modMonth) / 12;
  1762. return modMonth === 1
  1763. ? isLeapYear(year)
  1764. ? 29
  1765. : 28
  1766. : 31 - ((modMonth % 7) % 2);
  1767. }
  1768. // FORMATTING
  1769. addFormatToken('M', ['MM', 2], 'Mo', function () {
  1770. return this.month() + 1;
  1771. });
  1772. addFormatToken('MMM', 0, 0, function (format) {
  1773. return this.localeData().monthsShort(this, format);
  1774. });
  1775. addFormatToken('MMMM', 0, 0, function (format) {
  1776. return this.localeData().months(this, format);
  1777. });
  1778. // ALIASES
  1779. addUnitAlias('month', 'M');
  1780. // PRIORITY
  1781. addUnitPriority('month', 8);
  1782. // PARSING
  1783. addRegexToken('M', match1to2);
  1784. addRegexToken('MM', match1to2, match2);
  1785. addRegexToken('MMM', function (isStrict, locale) {
  1786. return locale.monthsShortRegex(isStrict);
  1787. });
  1788. addRegexToken('MMMM', function (isStrict, locale) {
  1789. return locale.monthsRegex(isStrict);
  1790. });
  1791. addParseToken(['M', 'MM'], function (input, array) {
  1792. array[MONTH] = toInt(input) - 1;
  1793. });
  1794. addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
  1795. var month = config._locale.monthsParse(input, token, config._strict);
  1796. // if we didn't find a month name, mark the date as invalid.
  1797. if (month != null) {
  1798. array[MONTH] = month;
  1799. } else {
  1800. getParsingFlags(config).invalidMonth = input;
  1801. }
  1802. });
  1803. // LOCALES
  1804. var defaultLocaleMonths =
  1805. 'January_February_March_April_May_June_July_August_September_October_November_December'.split(
  1806. '_'
  1807. ),
  1808. defaultLocaleMonthsShort =
  1809. 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
  1810. MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,
  1811. defaultMonthsShortRegex = matchWord,
  1812. defaultMonthsRegex = matchWord;
  1813. function localeMonths(m, format) {
  1814. if (!m) {
  1815. return isArray(this._months)
  1816. ? this._months
  1817. : this._months['standalone'];
  1818. }
  1819. return isArray(this._months)
  1820. ? this._months[m.month()]
  1821. : this._months[
  1822. (this._months.isFormat || MONTHS_IN_FORMAT).test(format)
  1823. ? 'format'
  1824. : 'standalone'
  1825. ][m.month()];
  1826. }
  1827. function localeMonthsShort(m, format) {
  1828. if (!m) {
  1829. return isArray(this._monthsShort)
  1830. ? this._monthsShort
  1831. : this._monthsShort['standalone'];
  1832. }
  1833. return isArray(this._monthsShort)
  1834. ? this._monthsShort[m.month()]
  1835. : this._monthsShort[
  1836. MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'
  1837. ][m.month()];
  1838. }
  1839. function handleStrictParse(monthName, format, strict) {
  1840. var i,
  1841. ii,
  1842. mom,
  1843. llc = monthName.toLocaleLowerCase();
  1844. if (!this._monthsParse) {
  1845. // this is not used
  1846. this._monthsParse = [];
  1847. this._longMonthsParse = [];
  1848. this._shortMonthsParse = [];
  1849. for (i = 0; i < 12; ++i) {
  1850. mom = createUTC([2000, i]);
  1851. this._shortMonthsParse[i] = this.monthsShort(
  1852. mom,
  1853. ''
  1854. ).toLocaleLowerCase();
  1855. this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
  1856. }
  1857. }
  1858. if (strict) {
  1859. if (format === 'MMM') {
  1860. ii = indexOf.call(this._shortMonthsParse, llc);
  1861. return ii !== -1 ? ii : null;
  1862. } else {
  1863. ii = indexOf.call(this._longMonthsParse, llc);
  1864. return ii !== -1 ? ii : null;
  1865. }
  1866. } else {
  1867. if (format === 'MMM') {
  1868. ii = indexOf.call(this._shortMonthsParse, llc);
  1869. if (ii !== -1) {
  1870. return ii;
  1871. }
  1872. ii = indexOf.call(this._longMonthsParse, llc);
  1873. return ii !== -1 ? ii : null;
  1874. } else {
  1875. ii = indexOf.call(this._longMonthsParse, llc);
  1876. if (ii !== -1) {
  1877. return ii;
  1878. }
  1879. ii = indexOf.call(this._shortMonthsParse, llc);
  1880. return ii !== -1 ? ii : null;
  1881. }
  1882. }
  1883. }
  1884. function localeMonthsParse(monthName, format, strict) {
  1885. var i, mom, regex;
  1886. if (this._monthsParseExact) {
  1887. return handleStrictParse.call(this, monthName, format, strict);
  1888. }
  1889. if (!this._monthsParse) {
  1890. this._monthsParse = [];
  1891. this._longMonthsParse = [];
  1892. this._shortMonthsParse = [];
  1893. }
  1894. // TODO: add sorting
  1895. // Sorting makes sure if one month (or abbr) is a prefix of another
  1896. // see sorting in computeMonthsParse
  1897. for (i = 0; i < 12; i++) {
  1898. // make the regex if we don't have it already
  1899. mom = createUTC([2000, i]);
  1900. if (strict && !this._longMonthsParse[i]) {
  1901. this._longMonthsParse[i] = new RegExp(
  1902. '^' + this.months(mom, '').replace('.', '') + '$',
  1903. 'i'
  1904. );
  1905. this._shortMonthsParse[i] = new RegExp(
  1906. '^' + this.monthsShort(mom, '').replace('.', '') + '$',
  1907. 'i'
  1908. );
  1909. }
  1910. if (!strict && !this._monthsParse[i]) {
  1911. regex =
  1912. '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
  1913. this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
  1914. }
  1915. // test the regex
  1916. if (
  1917. strict &&
  1918. format === 'MMMM' &&
  1919. this._longMonthsParse[i].test(monthName)
  1920. ) {
  1921. return i;
  1922. } else if (
  1923. strict &&
  1924. format === 'MMM' &&
  1925. this._shortMonthsParse[i].test(monthName)
  1926. ) {
  1927. return i;
  1928. } else if (!strict && this._monthsParse[i].test(monthName)) {
  1929. return i;
  1930. }
  1931. }
  1932. }
  1933. // MOMENTS
  1934. function setMonth(mom, value) {
  1935. var dayOfMonth;
  1936. if (!mom.isValid()) {
  1937. // No op
  1938. return mom;
  1939. }
  1940. if (typeof value === 'string') {
  1941. if (/^\d+$/.test(value)) {
  1942. value = toInt(value);
  1943. } else {
  1944. value = mom.localeData().monthsParse(value);
  1945. // TODO: Another silent failure?
  1946. if (!isNumber(value)) {
  1947. return mom;
  1948. }
  1949. }
  1950. }
  1951. dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
  1952. mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
  1953. return mom;
  1954. }
  1955. function getSetMonth(value) {
  1956. if (value != null) {
  1957. setMonth(this, value);
  1958. hooks.updateOffset(this, true);
  1959. return this;
  1960. } else {
  1961. return get(this, 'Month');
  1962. }
  1963. }
  1964. function getDaysInMonth() {
  1965. return daysInMonth(this.year(), this.month());
  1966. }
  1967. function monthsShortRegex(isStrict) {
  1968. if (this._monthsParseExact) {
  1969. if (!hasOwnProp(this, '_monthsRegex')) {
  1970. computeMonthsParse.call(this);
  1971. }
  1972. if (isStrict) {
  1973. return this._monthsShortStrictRegex;
  1974. } else {
  1975. return this._monthsShortRegex;
  1976. }
  1977. } else {
  1978. if (!hasOwnProp(this, '_monthsShortRegex')) {
  1979. this._monthsShortRegex = defaultMonthsShortRegex;
  1980. }
  1981. return this._monthsShortStrictRegex && isStrict
  1982. ? this._monthsShortStrictRegex
  1983. : this._monthsShortRegex;
  1984. }
  1985. }
  1986. function monthsRegex(isStrict) {
  1987. if (this._monthsParseExact) {
  1988. if (!hasOwnProp(this, '_monthsRegex')) {
  1989. computeMonthsParse.call(this);
  1990. }
  1991. if (isStrict) {
  1992. return this._monthsStrictRegex;
  1993. } else {
  1994. return this._monthsRegex;
  1995. }
  1996. } else {
  1997. if (!hasOwnProp(this, '_monthsRegex')) {
  1998. this._monthsRegex = defaultMonthsRegex;
  1999. }
  2000. return this._monthsStrictRegex && isStrict
  2001. ? this._monthsStrictRegex
  2002. : this._monthsRegex;
  2003. }
  2004. }
  2005. function computeMonthsParse() {
  2006. function cmpLenRev(a, b) {
  2007. return b.length - a.length;
  2008. }
  2009. var shortPieces = [],
  2010. longPieces = [],
  2011. mixedPieces = [],
  2012. i,
  2013. mom;
  2014. for (i = 0; i < 12; i++) {
  2015. // make the regex if we don't have it already
  2016. mom = createUTC([2000, i]);
  2017. shortPieces.push(this.monthsShort(mom, ''));
  2018. longPieces.push(this.months(mom, ''));
  2019. mixedPieces.push(this.months(mom, ''));
  2020. mixedPieces.push(this.monthsShort(mom, ''));
  2021. }
  2022. // Sorting makes sure if one month (or abbr) is a prefix of another it
  2023. // will match the longer piece.
  2024. shortPieces.sort(cmpLenRev);
  2025. longPieces.sort(cmpLenRev);
  2026. mixedPieces.sort(cmpLenRev);
  2027. for (i = 0; i < 12; i++) {
  2028. shortPieces[i] = regexEscape(shortPieces[i]);
  2029. longPieces[i] = regexEscape(longPieces[i]);
  2030. }
  2031. for (i = 0; i < 24; i++) {
  2032. mixedPieces[i] = regexEscape(mixedPieces[i]);
  2033. }
  2034. this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  2035. this._monthsShortRegex = this._monthsRegex;
  2036. this._monthsStrictRegex = new RegExp(
  2037. '^(' + longPieces.join('|') + ')',
  2038. 'i'
  2039. );
  2040. this._monthsShortStrictRegex = new RegExp(
  2041. '^(' + shortPieces.join('|') + ')',
  2042. 'i'
  2043. );
  2044. }
  2045. // FORMATTING
  2046. addFormatToken('Y', 0, 0, function () {
  2047. var y = this.year();
  2048. return y <= 9999 ? zeroFill(y, 4) : '+' + y;
  2049. });
  2050. addFormatToken(0, ['YY', 2], 0, function () {
  2051. return this.year() % 100;
  2052. });
  2053. addFormatToken(0, ['YYYY', 4], 0, 'year');
  2054. addFormatToken(0, ['YYYYY', 5], 0, 'year');
  2055. addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
  2056. // ALIASES
  2057. addUnitAlias('year', 'y');
  2058. // PRIORITIES
  2059. addUnitPriority('year', 1);
  2060. // PARSING
  2061. addRegexToken('Y', matchSigned);
  2062. addRegexToken('YY', match1to2, match2);
  2063. addRegexToken('YYYY', match1to4, match4);
  2064. addRegexToken('YYYYY', match1to6, match6);
  2065. addRegexToken('YYYYYY', match1to6, match6);
  2066. addParseToken(['YYYYY', 'YYYYYY'], YEAR);
  2067. addParseToken('YYYY', function (input, array) {
  2068. array[YEAR] =
  2069. input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
  2070. });
  2071. addParseToken('YY', function (input, array) {
  2072. array[YEAR] = hooks.parseTwoDigitYear(input);
  2073. });
  2074. addParseToken('Y', function (input, array) {
  2075. array[YEAR] = parseInt(input, 10);
  2076. });
  2077. // HELPERS
  2078. function daysInYear(year) {
  2079. return isLeapYear(year) ? 366 : 365;
  2080. }
  2081. // HOOKS
  2082. hooks.parseTwoDigitYear = function (input) {
  2083. return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
  2084. };
  2085. // MOMENTS
  2086. var getSetYear = makeGetSet('FullYear', true);
  2087. function getIsLeapYear() {
  2088. return isLeapYear(this.year());
  2089. }
  2090. function createDate(y, m, d, h, M, s, ms) {
  2091. // can't just apply() to create a date:
  2092. // https://stackoverflow.com/q/181348
  2093. var date;
  2094. // the date constructor remaps years 0-99 to 1900-1999
  2095. if (y < 100 && y >= 0) {
  2096. // preserve leap years using a full 400 year cycle, then reset
  2097. date = new Date(y + 400, m, d, h, M, s, ms);
  2098. if (isFinite(date.getFullYear())) {
  2099. date.setFullYear(y);
  2100. }
  2101. } else {
  2102. date = new Date(y, m, d, h, M, s, ms);
  2103. }
  2104. return date;
  2105. }
  2106. function createUTCDate(y) {
  2107. var date, args;
  2108. // the Date.UTC function remaps years 0-99 to 1900-1999
  2109. if (y < 100 && y >= 0) {
  2110. args = Array.prototype.slice.call(arguments);
  2111. // preserve leap years using a full 400 year cycle, then reset
  2112. args[0] = y + 400;
  2113. date = new Date(Date.UTC.apply(null, args));
  2114. if (isFinite(date.getUTCFullYear())) {
  2115. date.setUTCFullYear(y);
  2116. }
  2117. } else {
  2118. date = new Date(Date.UTC.apply(null, arguments));
  2119. }
  2120. return date;
  2121. }
  2122. // start-of-first-week - start-of-year
  2123. function firstWeekOffset(year, dow, doy) {
  2124. var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
  2125. fwd = 7 + dow - doy,
  2126. // first-week day local weekday -- which local weekday is fwd
  2127. fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
  2128. return -fwdlw + fwd - 1;
  2129. }
  2130. // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
  2131. function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
  2132. var localWeekday = (7 + weekday - dow) % 7,
  2133. weekOffset = firstWeekOffset(year, dow, doy),
  2134. dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
  2135. resYear,
  2136. resDayOfYear;
  2137. if (dayOfYear <= 0) {
  2138. resYear = year - 1;
  2139. resDayOfYear = daysInYear(resYear) + dayOfYear;
  2140. } else if (dayOfYear > daysInYear(year)) {
  2141. resYear = year + 1;
  2142. resDayOfYear = dayOfYear - daysInYear(year);
  2143. } else {
  2144. resYear = year;
  2145. resDayOfYear = dayOfYear;
  2146. }
  2147. return {
  2148. year: resYear,
  2149. dayOfYear: resDayOfYear,
  2150. };
  2151. }
  2152. function weekOfYear(mom, dow, doy) {
  2153. var weekOffset = firstWeekOffset(mom.year(), dow, doy),
  2154. week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
  2155. resWeek,
  2156. resYear;
  2157. if (week < 1) {
  2158. resYear = mom.year() - 1;
  2159. resWeek = week + weeksInYear(resYear, dow, doy);
  2160. } else if (week > weeksInYear(mom.year(), dow, doy)) {
  2161. resWeek = week - weeksInYear(mom.year(), dow, doy);
  2162. resYear = mom.year() + 1;
  2163. } else {
  2164. resYear = mom.year();
  2165. resWeek = week;
  2166. }
  2167. return {
  2168. week: resWeek,
  2169. year: resYear,
  2170. };
  2171. }
  2172. function weeksInYear(year, dow, doy) {
  2173. var weekOffset = firstWeekOffset(year, dow, doy),
  2174. weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
  2175. return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
  2176. }
  2177. // FORMATTING
  2178. addFormatToken('w', ['ww', 2], 'wo', 'week');
  2179. addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
  2180. // ALIASES
  2181. addUnitAlias('week', 'w');
  2182. addUnitAlias('isoWeek', 'W');
  2183. // PRIORITIES
  2184. addUnitPriority('week', 5);
  2185. addUnitPriority('isoWeek', 5);
  2186. // PARSING
  2187. addRegexToken('w', match1to2);
  2188. addRegexToken('ww', match1to2, match2);
  2189. addRegexToken('W', match1to2);
  2190. addRegexToken('WW', match1to2, match2);
  2191. addWeekParseToken(
  2192. ['w', 'ww', 'W', 'WW'],
  2193. function (input, week, config, token) {
  2194. week[token.substr(0, 1)] = toInt(input);
  2195. }
  2196. );
  2197. // HELPERS
  2198. // LOCALES
  2199. function localeWeek(mom) {
  2200. return weekOfYear(mom, this._week.dow, this._week.doy).week;
  2201. }
  2202. var defaultLocaleWeek = {
  2203. dow: 0, // Sunday is the first day of the week.
  2204. doy: 6, // The week that contains Jan 6th is the first week of the year.
  2205. };
  2206. function localeFirstDayOfWeek() {
  2207. return this._week.dow;
  2208. }
  2209. function localeFirstDayOfYear() {
  2210. return this._week.doy;
  2211. }
  2212. // MOMENTS
  2213. function getSetWeek(input) {
  2214. var week = this.localeData().week(this);
  2215. return input == null ? week : this.add((input - week) * 7, 'd');
  2216. }
  2217. function getSetISOWeek(input) {
  2218. var week = weekOfYear(this, 1, 4).week;
  2219. return input == null ? week : this.add((input - week) * 7, 'd');
  2220. }
  2221. // FORMATTING
  2222. addFormatToken('d', 0, 'do', 'day');
  2223. addFormatToken('dd', 0, 0, function (format) {
  2224. return this.localeData().weekdaysMin(this, format);
  2225. });
  2226. addFormatToken('ddd', 0, 0, function (format) {
  2227. return this.localeData().weekdaysShort(this, format);
  2228. });
  2229. addFormatToken('dddd', 0, 0, function (format) {
  2230. return this.localeData().weekdays(this, format);
  2231. });
  2232. addFormatToken('e', 0, 0, 'weekday');
  2233. addFormatToken('E', 0, 0, 'isoWeekday');
  2234. // ALIASES
  2235. addUnitAlias('day', 'd');
  2236. addUnitAlias('weekday', 'e');
  2237. addUnitAlias('isoWeekday', 'E');
  2238. // PRIORITY
  2239. addUnitPriority('day', 11);
  2240. addUnitPriority('weekday', 11);
  2241. addUnitPriority('isoWeekday', 11);
  2242. // PARSING
  2243. addRegexToken('d', match1to2);
  2244. addRegexToken('e', match1to2);
  2245. addRegexToken('E', match1to2);
  2246. addRegexToken('dd', function (isStrict, locale) {
  2247. return locale.weekdaysMinRegex(isStrict);
  2248. });
  2249. addRegexToken('ddd', function (isStrict, locale) {
  2250. return locale.weekdaysShortRegex(isStrict);
  2251. });
  2252. addRegexToken('dddd', function (isStrict, locale) {
  2253. return locale.weekdaysRegex(isStrict);
  2254. });
  2255. addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
  2256. var weekday = config._locale.weekdaysParse(input, token, config._strict);
  2257. // if we didn't get a weekday name, mark the date as invalid
  2258. if (weekday != null) {
  2259. week.d = weekday;
  2260. } else {
  2261. getParsingFlags(config).invalidWeekday = input;
  2262. }
  2263. });
  2264. addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
  2265. week[token] = toInt(input);
  2266. });
  2267. // HELPERS
  2268. function parseWeekday(input, locale) {
  2269. if (typeof input !== 'string') {
  2270. return input;
  2271. }
  2272. if (!isNaN(input)) {
  2273. return parseInt(input, 10);
  2274. }
  2275. input = locale.weekdaysParse(input);
  2276. if (typeof input === 'number') {
  2277. return input;
  2278. }
  2279. return null;
  2280. }
  2281. function parseIsoWeekday(input, locale) {
  2282. if (typeof input === 'string') {
  2283. return locale.weekdaysParse(input) % 7 || 7;
  2284. }
  2285. return isNaN(input) ? null : input;
  2286. }
  2287. // LOCALES
  2288. function shiftWeekdays(ws, n) {
  2289. return ws.slice(n, 7).concat(ws.slice(0, n));
  2290. }
  2291. var defaultLocaleWeekdays =
  2292. 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
  2293. defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
  2294. defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
  2295. defaultWeekdaysRegex = matchWord,
  2296. defaultWeekdaysShortRegex = matchWord,
  2297. defaultWeekdaysMinRegex = matchWord;
  2298. function localeWeekdays(m, format) {
  2299. var weekdays = isArray(this._weekdays)
  2300. ? this._weekdays
  2301. : this._weekdays[
  2302. m && m !== true && this._weekdays.isFormat.test(format)
  2303. ? 'format'
  2304. : 'standalone'
  2305. ];
  2306. return m === true
  2307. ? shiftWeekdays(weekdays, this._week.dow)
  2308. : m
  2309. ? weekdays[m.day()]
  2310. : weekdays;
  2311. }
  2312. function localeWeekdaysShort(m) {
  2313. return m === true
  2314. ? shiftWeekdays(this._weekdaysShort, this._week.dow)
  2315. : m
  2316. ? this._weekdaysShort[m.day()]
  2317. : this._weekdaysShort;
  2318. }
  2319. function localeWeekdaysMin(m) {
  2320. return m === true
  2321. ? shiftWeekdays(this._weekdaysMin, this._week.dow)
  2322. : m
  2323. ? this._weekdaysMin[m.day()]
  2324. : this._weekdaysMin;
  2325. }
  2326. function handleStrictParse$1(weekdayName, format, strict) {
  2327. var i,
  2328. ii,
  2329. mom,
  2330. llc = weekdayName.toLocaleLowerCase();
  2331. if (!this._weekdaysParse) {
  2332. this._weekdaysParse = [];
  2333. this._shortWeekdaysParse = [];
  2334. this._minWeekdaysParse = [];
  2335. for (i = 0; i < 7; ++i) {
  2336. mom = createUTC([2000, 1]).day(i);
  2337. this._minWeekdaysParse[i] = this.weekdaysMin(
  2338. mom,
  2339. ''
  2340. ).toLocaleLowerCase();
  2341. this._shortWeekdaysParse[i] = this.weekdaysShort(
  2342. mom,
  2343. ''
  2344. ).toLocaleLowerCase();
  2345. this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
  2346. }
  2347. }
  2348. if (strict) {
  2349. if (format === 'dddd') {
  2350. ii = indexOf.call(this._weekdaysParse, llc);
  2351. return ii !== -1 ? ii : null;
  2352. } else if (format === 'ddd') {
  2353. ii = indexOf.call(this._shortWeekdaysParse, llc);
  2354. return ii !== -1 ? ii : null;
  2355. } else {
  2356. ii = indexOf.call(this._minWeekdaysParse, llc);
  2357. return ii !== -1 ? ii : null;
  2358. }
  2359. } else {
  2360. if (format === 'dddd') {
  2361. ii = indexOf.call(this._weekdaysParse, llc);
  2362. if (ii !== -1) {
  2363. return ii;
  2364. }
  2365. ii = indexOf.call(this._shortWeekdaysParse, llc);
  2366. if (ii !== -1) {
  2367. return ii;
  2368. }
  2369. ii = indexOf.call(this._minWeekdaysParse, llc);
  2370. return ii !== -1 ? ii : null;
  2371. } else if (format === 'ddd') {
  2372. ii = indexOf.call(this._shortWeekdaysParse, llc);
  2373. if (ii !== -1) {
  2374. return ii;
  2375. }
  2376. ii = indexOf.call(this._weekdaysParse, llc);
  2377. if (ii !== -1) {
  2378. return ii;
  2379. }
  2380. ii = indexOf.call(this._minWeekdaysParse, llc);
  2381. return ii !== -1 ? ii : null;
  2382. } else {
  2383. ii = indexOf.call(this._minWeekdaysParse, llc);
  2384. if (ii !== -1) {
  2385. return ii;
  2386. }
  2387. ii = indexOf.call(this._weekdaysParse, llc);
  2388. if (ii !== -1) {
  2389. return ii;
  2390. }
  2391. ii = indexOf.call(this._shortWeekdaysParse, llc);
  2392. return ii !== -1 ? ii : null;
  2393. }
  2394. }
  2395. }
  2396. function localeWeekdaysParse(weekdayName, format, strict) {
  2397. var i, mom, regex;
  2398. if (this._weekdaysParseExact) {
  2399. return handleStrictParse$1.call(this, weekdayName, format, strict);
  2400. }
  2401. if (!this._weekdaysParse) {
  2402. this._weekdaysParse = [];
  2403. this._minWeekdaysParse = [];
  2404. this._shortWeekdaysParse = [];
  2405. this._fullWeekdaysParse = [];
  2406. }
  2407. for (i = 0; i < 7; i++) {
  2408. // make the regex if we don't have it already
  2409. mom = createUTC([2000, 1]).day(i);
  2410. if (strict && !this._fullWeekdaysParse[i]) {
  2411. this._fullWeekdaysParse[i] = new RegExp(
  2412. '^' + this.weekdays(mom, '').replace('.', '\\.?') + '$',
  2413. 'i'
  2414. );
  2415. this._shortWeekdaysParse[i] = new RegExp(
  2416. '^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$',
  2417. 'i'
  2418. );
  2419. this._minWeekdaysParse[i] = new RegExp(
  2420. '^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$',
  2421. 'i'
  2422. );
  2423. }
  2424. if (!this._weekdaysParse[i]) {
  2425. regex =
  2426. '^' +
  2427. this.weekdays(mom, '') +
  2428. '|^' +
  2429. this.weekdaysShort(mom, '') +
  2430. '|^' +
  2431. this.weekdaysMin(mom, '');
  2432. this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
  2433. }
  2434. // test the regex
  2435. if (
  2436. strict &&
  2437. format === 'dddd' &&
  2438. this._fullWeekdaysParse[i].test(weekdayName)
  2439. ) {
  2440. return i;
  2441. } else if (
  2442. strict &&
  2443. format === 'ddd' &&
  2444. this._shortWeekdaysParse[i].test(weekdayName)
  2445. ) {
  2446. return i;
  2447. } else if (
  2448. strict &&
  2449. format === 'dd' &&
  2450. this._minWeekdaysParse[i].test(weekdayName)
  2451. ) {
  2452. return i;
  2453. } else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
  2454. return i;
  2455. }
  2456. }
  2457. }
  2458. // MOMENTS
  2459. function getSetDayOfWeek(input) {
  2460. if (!this.isValid()) {
  2461. return input != null ? this : NaN;
  2462. }
  2463. var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
  2464. if (input != null) {
  2465. input = parseWeekday(input, this.localeData());
  2466. return this.add(input - day, 'd');
  2467. } else {
  2468. return day;
  2469. }
  2470. }
  2471. function getSetLocaleDayOfWeek(input) {
  2472. if (!this.isValid()) {
  2473. return input != null ? this : NaN;
  2474. }
  2475. var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
  2476. return input == null ? weekday : this.add(input - weekday, 'd');
  2477. }
  2478. function getSetISODayOfWeek(input) {
  2479. if (!this.isValid()) {
  2480. return input != null ? this : NaN;
  2481. }
  2482. // behaves the same as moment#day except
  2483. // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
  2484. // as a setter, sunday should belong to the previous week.
  2485. if (input != null) {
  2486. var weekday = parseIsoWeekday(input, this.localeData());
  2487. return this.day(this.day() % 7 ? weekday : weekday - 7);
  2488. } else {
  2489. return this.day() || 7;
  2490. }
  2491. }
  2492. function weekdaysRegex(isStrict) {
  2493. if (this._weekdaysParseExact) {
  2494. if (!hasOwnProp(this, '_weekdaysRegex')) {
  2495. computeWeekdaysParse.call(this);
  2496. }
  2497. if (isStrict) {
  2498. return this._weekdaysStrictRegex;
  2499. } else {
  2500. return this._weekdaysRegex;
  2501. }
  2502. } else {
  2503. if (!hasOwnProp(this, '_weekdaysRegex')) {
  2504. this._weekdaysRegex = defaultWeekdaysRegex;
  2505. }
  2506. return this._weekdaysStrictRegex && isStrict
  2507. ? this._weekdaysStrictRegex
  2508. : this._weekdaysRegex;
  2509. }
  2510. }
  2511. function weekdaysShortRegex(isStrict) {
  2512. if (this._weekdaysParseExact) {
  2513. if (!hasOwnProp(this, '_weekdaysRegex')) {
  2514. computeWeekdaysParse.call(this);
  2515. }
  2516. if (isStrict) {
  2517. return this._weekdaysShortStrictRegex;
  2518. } else {
  2519. return this._weekdaysShortRegex;
  2520. }
  2521. } else {
  2522. if (!hasOwnProp(this, '_weekdaysShortRegex')) {
  2523. this._weekdaysShortRegex = defaultWeekdaysShortRegex;
  2524. }
  2525. return this._weekdaysShortStrictRegex && isStrict
  2526. ? this._weekdaysShortStrictRegex
  2527. : this._weekdaysShortRegex;
  2528. }
  2529. }
  2530. function weekdaysMinRegex(isStrict) {
  2531. if (this._weekdaysParseExact) {
  2532. if (!hasOwnProp(this, '_weekdaysRegex')) {
  2533. computeWeekdaysParse.call(this);
  2534. }
  2535. if (isStrict) {
  2536. return this._weekdaysMinStrictRegex;
  2537. } else {
  2538. return this._weekdaysMinRegex;
  2539. }
  2540. } else {
  2541. if (!hasOwnProp(this, '_weekdaysMinRegex')) {
  2542. this._weekdaysMinRegex = defaultWeekdaysMinRegex;
  2543. }
  2544. return this._weekdaysMinStrictRegex && isStrict
  2545. ? this._weekdaysMinStrictRegex
  2546. : this._weekdaysMinRegex;
  2547. }
  2548. }
  2549. function computeWeekdaysParse() {
  2550. function cmpLenRev(a, b) {
  2551. return b.length - a.length;
  2552. }
  2553. var minPieces = [],
  2554. shortPieces = [],
  2555. longPieces = [],
  2556. mixedPieces = [],
  2557. i,
  2558. mom,
  2559. minp,
  2560. shortp,
  2561. longp;
  2562. for (i = 0; i < 7; i++) {
  2563. // make the regex if we don't have it already
  2564. mom = createUTC([2000, 1]).day(i);
  2565. minp = regexEscape(this.weekdaysMin(mom, ''));
  2566. shortp = regexEscape(this.weekdaysShort(mom, ''));
  2567. longp = regexEscape(this.weekdays(mom, ''));
  2568. minPieces.push(minp);
  2569. shortPieces.push(shortp);
  2570. longPieces.push(longp);
  2571. mixedPieces.push(minp);
  2572. mixedPieces.push(shortp);
  2573. mixedPieces.push(longp);
  2574. }
  2575. // Sorting makes sure if one weekday (or abbr) is a prefix of another it
  2576. // will match the longer piece.
  2577. minPieces.sort(cmpLenRev);
  2578. shortPieces.sort(cmpLenRev);
  2579. longPieces.sort(cmpLenRev);
  2580. mixedPieces.sort(cmpLenRev);
  2581. this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  2582. this._weekdaysShortRegex = this._weekdaysRegex;
  2583. this._weekdaysMinRegex = this._weekdaysRegex;
  2584. this._weekdaysStrictRegex = new RegExp(
  2585. '^(' + longPieces.join('|') + ')',
  2586. 'i'
  2587. );
  2588. this._weekdaysShortStrictRegex = new RegExp(
  2589. '^(' + shortPieces.join('|') + ')',
  2590. 'i'
  2591. );
  2592. this._weekdaysMinStrictRegex = new RegExp(
  2593. '^(' + minPieces.join('|') + ')',
  2594. 'i'
  2595. );
  2596. }
  2597. // FORMATTING
  2598. function hFormat() {
  2599. return this.hours() % 12 || 12;
  2600. }
  2601. function kFormat() {
  2602. return this.hours() || 24;
  2603. }
  2604. addFormatToken('H', ['HH', 2], 0, 'hour');
  2605. addFormatToken('h', ['hh', 2], 0, hFormat);
  2606. addFormatToken('k', ['kk', 2], 0, kFormat);
  2607. addFormatToken('hmm', 0, 0, function () {
  2608. return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
  2609. });
  2610. addFormatToken('hmmss', 0, 0, function () {
  2611. return (
  2612. '' +
  2613. hFormat.apply(this) +
  2614. zeroFill(this.minutes(), 2) +
  2615. zeroFill(this.seconds(), 2)
  2616. );
  2617. });
  2618. addFormatToken('Hmm', 0, 0, function () {
  2619. return '' + this.hours() + zeroFill(this.minutes(), 2);
  2620. });
  2621. addFormatToken('Hmmss', 0, 0, function () {
  2622. return (
  2623. '' +
  2624. this.hours() +
  2625. zeroFill(this.minutes(), 2) +
  2626. zeroFill(this.seconds(), 2)
  2627. );
  2628. });
  2629. function meridiem(token, lowercase) {
  2630. addFormatToken(token, 0, 0, function () {
  2631. return this.localeData().meridiem(
  2632. this.hours(),
  2633. this.minutes(),
  2634. lowercase
  2635. );
  2636. });
  2637. }
  2638. meridiem('a', true);
  2639. meridiem('A', false);
  2640. // ALIASES
  2641. addUnitAlias('hour', 'h');
  2642. // PRIORITY
  2643. addUnitPriority('hour', 13);
  2644. // PARSING
  2645. function matchMeridiem(isStrict, locale) {
  2646. return locale._meridiemParse;
  2647. }
  2648. addRegexToken('a', matchMeridiem);
  2649. addRegexToken('A', matchMeridiem);
  2650. addRegexToken('H', match1to2);
  2651. addRegexToken('h', match1to2);
  2652. addRegexToken('k', match1to2);
  2653. addRegexToken('HH', match1to2, match2);
  2654. addRegexToken('hh', match1to2, match2);
  2655. addRegexToken('kk', match1to2, match2);
  2656. addRegexToken('hmm', match3to4);
  2657. addRegexToken('hmmss', match5to6);
  2658. addRegexToken('Hmm', match3to4);
  2659. addRegexToken('Hmmss', match5to6);
  2660. addParseToken(['H', 'HH'], HOUR);
  2661. addParseToken(['k', 'kk'], function (input, array, config) {
  2662. var kInput = toInt(input);
  2663. array[HOUR] = kInput === 24 ? 0 : kInput;
  2664. });
  2665. addParseToken(['a', 'A'], function (input, array, config) {
  2666. config._isPm = config._locale.isPM(input);
  2667. config._meridiem = input;
  2668. });
  2669. addParseToken(['h', 'hh'], function (input, array, config) {
  2670. array[HOUR] = toInt(input);
  2671. getParsingFlags(config).bigHour = true;
  2672. });
  2673. addParseToken('hmm', function (input, array, config) {
  2674. var pos = input.length - 2;
  2675. array[HOUR] = toInt(input.substr(0, pos));
  2676. array[MINUTE] = toInt(input.substr(pos));
  2677. getParsingFlags(config).bigHour = true;
  2678. });
  2679. addParseToken('hmmss', function (input, array, config) {
  2680. var pos1 = input.length - 4,
  2681. pos2 = input.length - 2;
  2682. array[HOUR] = toInt(input.substr(0, pos1));
  2683. array[MINUTE] = toInt(input.substr(pos1, 2));
  2684. array[SECOND] = toInt(input.substr(pos2));
  2685. getParsingFlags(config).bigHour = true;
  2686. });
  2687. addParseToken('Hmm', function (input, array, config) {
  2688. var pos = input.length - 2;
  2689. array[HOUR] = toInt(input.substr(0, pos));
  2690. array[MINUTE] = toInt(input.substr(pos));
  2691. });
  2692. addParseToken('Hmmss', function (input, array, config) {
  2693. var pos1 = input.length - 4,
  2694. pos2 = input.length - 2;
  2695. array[HOUR] = toInt(input.substr(0, pos1));
  2696. array[MINUTE] = toInt(input.substr(pos1, 2));
  2697. array[SECOND] = toInt(input.substr(pos2));
  2698. });
  2699. // LOCALES
  2700. function localeIsPM(input) {
  2701. // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
  2702. // Using charAt should be more compatible.
  2703. return (input + '').toLowerCase().charAt(0) === 'p';
  2704. }
  2705. var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i,
  2706. // Setting the hour should keep the time, because the user explicitly
  2707. // specified which hour they want. So trying to maintain the same hour (in
  2708. // a new timezone) makes sense. Adding/subtracting hours does not follow
  2709. // this rule.
  2710. getSetHour = makeGetSet('Hours', true);
  2711. function localeMeridiem(hours, minutes, isLower) {
  2712. if (hours > 11) {
  2713. return isLower ? 'pm' : 'PM';
  2714. } else {
  2715. return isLower ? 'am' : 'AM';
  2716. }
  2717. }
  2718. var baseConfig = {
  2719. calendar: defaultCalendar,
  2720. longDateFormat: defaultLongDateFormat,
  2721. invalidDate: defaultInvalidDate,
  2722. ordinal: defaultOrdinal,
  2723. dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
  2724. relativeTime: defaultRelativeTime,
  2725. months: defaultLocaleMonths,
  2726. monthsShort: defaultLocaleMonthsShort,
  2727. week: defaultLocaleWeek,
  2728. weekdays: defaultLocaleWeekdays,
  2729. weekdaysMin: defaultLocaleWeekdaysMin,
  2730. weekdaysShort: defaultLocaleWeekdaysShort,
  2731. meridiemParse: defaultLocaleMeridiemParse,
  2732. };
  2733. // internal storage for locale config files
  2734. var locales = {},
  2735. localeFamilies = {},
  2736. globalLocale;
  2737. function commonPrefix(arr1, arr2) {
  2738. var i,
  2739. minl = Math.min(arr1.length, arr2.length);
  2740. for (i = 0; i < minl; i += 1) {
  2741. if (arr1[i] !== arr2[i]) {
  2742. return i;
  2743. }
  2744. }
  2745. return minl;
  2746. }
  2747. function normalizeLocale(key) {
  2748. return key ? key.toLowerCase().replace('_', '-') : key;
  2749. }
  2750. // pick the locale from the array
  2751. // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
  2752. // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
  2753. function chooseLocale(names) {
  2754. var i = 0,
  2755. j,
  2756. next,
  2757. locale,
  2758. split;
  2759. while (i < names.length) {
  2760. split = normalizeLocale(names[i]).split('-');
  2761. j = split.length;
  2762. next = normalizeLocale(names[i + 1]);
  2763. next = next ? next.split('-') : null;
  2764. while (j > 0) {
  2765. locale = loadLocale(split.slice(0, j).join('-'));
  2766. if (locale) {
  2767. return locale;
  2768. }
  2769. if (
  2770. next &&
  2771. next.length >= j &&
  2772. commonPrefix(split, next) >= j - 1
  2773. ) {
  2774. //the next array item is better than a shallower substring of this one
  2775. break;
  2776. }
  2777. j--;
  2778. }
  2779. i++;
  2780. }
  2781. return globalLocale;
  2782. }
  2783. function isLocaleNameSane(name) {
  2784. // Prevent names that look like filesystem paths, i.e contain '/' or '\'
  2785. return name.match('^[^/\\\\]*$') != null;
  2786. }
  2787. function loadLocale(name) {
  2788. var oldLocale = null,
  2789. aliasedRequire;
  2790. // TODO: Find a better way to register and load all the locales in Node
  2791. if (
  2792. locales[name] === undefined &&
  2793. typeof module !== 'undefined' &&
  2794. module &&
  2795. module.exports &&
  2796. isLocaleNameSane(name)
  2797. ) {
  2798. try {
  2799. oldLocale = globalLocale._abbr;
  2800. aliasedRequire = require;
  2801. aliasedRequire('./locale/' + name);
  2802. getSetGlobalLocale(oldLocale);
  2803. } catch (e) {
  2804. // mark as not found to avoid repeating expensive file require call causing high CPU
  2805. // when trying to find en-US, en_US, en-us for every format call
  2806. locales[name] = null; // null means not found
  2807. }
  2808. }
  2809. return locales[name];
  2810. }
  2811. // This function will load locale and then set the global locale. If
  2812. // no arguments are passed in, it will simply return the current global
  2813. // locale key.
  2814. function getSetGlobalLocale(key, values) {
  2815. var data;
  2816. if (key) {
  2817. if (isUndefined(values)) {
  2818. data = getLocale(key);
  2819. } else {
  2820. data = defineLocale(key, values);
  2821. }
  2822. if (data) {
  2823. // moment.duration._locale = moment._locale = data;
  2824. globalLocale = data;
  2825. } else {
  2826. if (typeof console !== 'undefined' && console.warn) {
  2827. //warn user if arguments are passed but the locale could not be set
  2828. console.warn(
  2829. 'Locale ' + key + ' not found. Did you forget to load it?'
  2830. );
  2831. }
  2832. }
  2833. }
  2834. return globalLocale._abbr;
  2835. }
  2836. function defineLocale(name, config) {
  2837. if (config !== null) {
  2838. var locale,
  2839. parentConfig = baseConfig;
  2840. config.abbr = name;
  2841. if (locales[name] != null) {
  2842. deprecateSimple(
  2843. 'defineLocaleOverride',
  2844. 'use moment.updateLocale(localeName, config) to change ' +
  2845. 'an existing locale. moment.defineLocale(localeName, ' +
  2846. 'config) should only be used for creating a new locale ' +
  2847. 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.'
  2848. );
  2849. parentConfig = locales[name]._config;
  2850. } else if (config.parentLocale != null) {
  2851. if (locales[config.parentLocale] != null) {
  2852. parentConfig = locales[config.parentLocale]._config;
  2853. } else {
  2854. locale = loadLocale(config.parentLocale);
  2855. if (locale != null) {
  2856. parentConfig = locale._config;
  2857. } else {
  2858. if (!localeFamilies[config.parentLocale]) {
  2859. localeFamilies[config.parentLocale] = [];
  2860. }
  2861. localeFamilies[config.parentLocale].push({
  2862. name: name,
  2863. config: config,
  2864. });
  2865. return null;
  2866. }
  2867. }
  2868. }
  2869. locales[name] = new Locale(mergeConfigs(parentConfig, config));
  2870. if (localeFamilies[name]) {
  2871. localeFamilies[name].forEach(function (x) {
  2872. defineLocale(x.name, x.config);
  2873. });
  2874. }
  2875. // backwards compat for now: also set the locale
  2876. // make sure we set the locale AFTER all child locales have been
  2877. // created, so we won't end up with the child locale set.
  2878. getSetGlobalLocale(name);
  2879. return locales[name];
  2880. } else {
  2881. // useful for testing
  2882. delete locales[name];
  2883. return null;
  2884. }
  2885. }
  2886. function updateLocale(name, config) {
  2887. if (config != null) {
  2888. var locale,
  2889. tmpLocale,
  2890. parentConfig = baseConfig;
  2891. if (locales[name] != null && locales[name].parentLocale != null) {
  2892. // Update existing child locale in-place to avoid memory-leaks
  2893. locales[name].set(mergeConfigs(locales[name]._config, config));
  2894. } else {
  2895. // MERGE
  2896. tmpLocale = loadLocale(name);
  2897. if (tmpLocale != null) {
  2898. parentConfig = tmpLocale._config;
  2899. }
  2900. config = mergeConfigs(parentConfig, config);
  2901. if (tmpLocale == null) {
  2902. // updateLocale is called for creating a new locale
  2903. // Set abbr so it will have a name (getters return
  2904. // undefined otherwise).
  2905. config.abbr = name;
  2906. }
  2907. locale = new Locale(config);
  2908. locale.parentLocale = locales[name];
  2909. locales[name] = locale;
  2910. }
  2911. // backwards compat for now: also set the locale
  2912. getSetGlobalLocale(name);
  2913. } else {
  2914. // pass null for config to unupdate, useful for tests
  2915. if (locales[name] != null) {
  2916. if (locales[name].parentLocale != null) {
  2917. locales[name] = locales[name].parentLocale;
  2918. if (name === getSetGlobalLocale()) {
  2919. getSetGlobalLocale(name);
  2920. }
  2921. } else if (locales[name] != null) {
  2922. delete locales[name];
  2923. }
  2924. }
  2925. }
  2926. return locales[name];
  2927. }
  2928. // returns locale data
  2929. function getLocale(key) {
  2930. var locale;
  2931. if (key && key._locale && key._locale._abbr) {
  2932. key = key._locale._abbr;
  2933. }
  2934. if (!key) {
  2935. return globalLocale;
  2936. }
  2937. if (!isArray(key)) {
  2938. //short-circuit everything else
  2939. locale = loadLocale(key);
  2940. if (locale) {
  2941. return locale;
  2942. }
  2943. key = [key];
  2944. }
  2945. return chooseLocale(key);
  2946. }
  2947. function listLocales() {
  2948. return keys(locales);
  2949. }
  2950. function checkOverflow(m) {
  2951. var overflow,
  2952. a = m._a;
  2953. if (a && getParsingFlags(m).overflow === -2) {
  2954. overflow =
  2955. a[MONTH] < 0 || a[MONTH] > 11
  2956. ? MONTH
  2957. : a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH])
  2958. ? DATE
  2959. : a[HOUR] < 0 ||
  2960. a[HOUR] > 24 ||
  2961. (a[HOUR] === 24 &&
  2962. (a[MINUTE] !== 0 ||
  2963. a[SECOND] !== 0 ||
  2964. a[MILLISECOND] !== 0))
  2965. ? HOUR
  2966. : a[MINUTE] < 0 || a[MINUTE] > 59
  2967. ? MINUTE
  2968. : a[SECOND] < 0 || a[SECOND] > 59
  2969. ? SECOND
  2970. : a[MILLISECOND] < 0 || a[MILLISECOND] > 999
  2971. ? MILLISECOND
  2972. : -1;
  2973. if (
  2974. getParsingFlags(m)._overflowDayOfYear &&
  2975. (overflow < YEAR || overflow > DATE)
  2976. ) {
  2977. overflow = DATE;
  2978. }
  2979. if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
  2980. overflow = WEEK;
  2981. }
  2982. if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
  2983. overflow = WEEKDAY;
  2984. }
  2985. getParsingFlags(m).overflow = overflow;
  2986. }
  2987. return m;
  2988. }
  2989. // iso 8601 regex
  2990. // 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)
  2991. var extendedIsoRegex =
  2992. /^\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)?)?$/,
  2993. basicIsoRegex =
  2994. /^\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)?)?$/,
  2995. tzRegex = /Z|[+-]\d\d(?::?\d\d)?/,
  2996. isoDates = [
  2997. ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/],
  2998. ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/],
  2999. ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/],
  3000. ['GGGG-[W]WW', /\d{4}-W\d\d/, false],
  3001. ['YYYY-DDD', /\d{4}-\d{3}/],
  3002. ['YYYY-MM', /\d{4}-\d\d/, false],
  3003. ['YYYYYYMMDD', /[+-]\d{10}/],
  3004. ['YYYYMMDD', /\d{8}/],
  3005. ['GGGG[W]WWE', /\d{4}W\d{3}/],
  3006. ['GGGG[W]WW', /\d{4}W\d{2}/, false],
  3007. ['YYYYDDD', /\d{7}/],
  3008. ['YYYYMM', /\d{6}/, false],
  3009. ['YYYY', /\d{4}/, false],
  3010. ],
  3011. // iso time formats and regexes
  3012. isoTimes = [
  3013. ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/],
  3014. ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/],
  3015. ['HH:mm:ss', /\d\d:\d\d:\d\d/],
  3016. ['HH:mm', /\d\d:\d\d/],
  3017. ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/],
  3018. ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/],
  3019. ['HHmmss', /\d\d\d\d\d\d/],
  3020. ['HHmm', /\d\d\d\d/],
  3021. ['HH', /\d\d/],
  3022. ],
  3023. aspNetJsonRegex = /^\/?Date\((-?\d+)/i,
  3024. // RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3
  3025. rfc2822 =
  3026. /^(?:(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}))$/,
  3027. obsOffsets = {
  3028. UT: 0,
  3029. GMT: 0,
  3030. EDT: -4 * 60,
  3031. EST: -5 * 60,
  3032. CDT: -5 * 60,
  3033. CST: -6 * 60,
  3034. MDT: -6 * 60,
  3035. MST: -7 * 60,
  3036. PDT: -7 * 60,
  3037. PST: -8 * 60,
  3038. };
  3039. // date from iso format
  3040. function configFromISO(config) {
  3041. var i,
  3042. l,
  3043. string = config._i,
  3044. match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
  3045. allowTime,
  3046. dateFormat,
  3047. timeFormat,
  3048. tzFormat,
  3049. isoDatesLen = isoDates.length,
  3050. isoTimesLen = isoTimes.length;
  3051. if (match) {
  3052. getParsingFlags(config).iso = true;
  3053. for (i = 0, l = isoDatesLen; i < l; i++) {
  3054. if (isoDates[i][1].exec(match[1])) {
  3055. dateFormat = isoDates[i][0];
  3056. allowTime = isoDates[i][2] !== false;
  3057. break;
  3058. }
  3059. }
  3060. if (dateFormat == null) {
  3061. config._isValid = false;
  3062. return;
  3063. }
  3064. if (match[3]) {
  3065. for (i = 0, l = isoTimesLen; i < l; i++) {
  3066. if (isoTimes[i][1].exec(match[3])) {
  3067. // match[2] should be 'T' or space
  3068. timeFormat = (match[2] || ' ') + isoTimes[i][0];
  3069. break;
  3070. }
  3071. }
  3072. if (timeFormat == null) {
  3073. config._isValid = false;
  3074. return;
  3075. }
  3076. }
  3077. if (!allowTime && timeFormat != null) {
  3078. config._isValid = false;
  3079. return;
  3080. }
  3081. if (match[4]) {
  3082. if (tzRegex.exec(match[4])) {
  3083. tzFormat = 'Z';
  3084. } else {
  3085. config._isValid = false;
  3086. return;
  3087. }
  3088. }
  3089. config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
  3090. configFromStringAndFormat(config);
  3091. } else {
  3092. config._isValid = false;
  3093. }
  3094. }
  3095. function extractFromRFC2822Strings(
  3096. yearStr,
  3097. monthStr,
  3098. dayStr,
  3099. hourStr,
  3100. minuteStr,
  3101. secondStr
  3102. ) {
  3103. var result = [
  3104. untruncateYear(yearStr),
  3105. defaultLocaleMonthsShort.indexOf(monthStr),
  3106. parseInt(dayStr, 10),
  3107. parseInt(hourStr, 10),
  3108. parseInt(minuteStr, 10),
  3109. ];
  3110. if (secondStr) {
  3111. result.push(parseInt(secondStr, 10));
  3112. }
  3113. return result;
  3114. }
  3115. function untruncateYear(yearStr) {
  3116. var year = parseInt(yearStr, 10);
  3117. if (year <= 49) {
  3118. return 2000 + year;
  3119. } else if (year <= 999) {
  3120. return 1900 + year;
  3121. }
  3122. return year;
  3123. }
  3124. function preprocessRFC2822(s) {
  3125. // Remove comments and folding whitespace and replace multiple-spaces with a single space
  3126. return s
  3127. .replace(/\([^()]*\)|[\n\t]/g, ' ')
  3128. .replace(/(\s\s+)/g, ' ')
  3129. .replace(/^\s\s*/, '')
  3130. .replace(/\s\s*$/, '');
  3131. }
  3132. function checkWeekday(weekdayStr, parsedInput, config) {
  3133. if (weekdayStr) {
  3134. // TODO: Replace the vanilla JS Date object with an independent day-of-week check.
  3135. var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr),
  3136. weekdayActual = new Date(
  3137. parsedInput[0],
  3138. parsedInput[1],
  3139. parsedInput[2]
  3140. ).getDay();
  3141. if (weekdayProvided !== weekdayActual) {
  3142. getParsingFlags(config).weekdayMismatch = true;
  3143. config._isValid = false;
  3144. return false;
  3145. }
  3146. }
  3147. return true;
  3148. }
  3149. function calculateOffset(obsOffset, militaryOffset, numOffset) {
  3150. if (obsOffset) {
  3151. return obsOffsets[obsOffset];
  3152. } else if (militaryOffset) {
  3153. // the only allowed military tz is Z
  3154. return 0;
  3155. } else {
  3156. var hm = parseInt(numOffset, 10),
  3157. m = hm % 100,
  3158. h = (hm - m) / 100;
  3159. return h * 60 + m;
  3160. }
  3161. }
  3162. // date and time from ref 2822 format
  3163. function configFromRFC2822(config) {
  3164. var match = rfc2822.exec(preprocessRFC2822(config._i)),
  3165. parsedArray;
  3166. if (match) {
  3167. parsedArray = extractFromRFC2822Strings(
  3168. match[4],
  3169. match[3],
  3170. match[2],
  3171. match[5],
  3172. match[6],
  3173. match[7]
  3174. );
  3175. if (!checkWeekday(match[1], parsedArray, config)) {
  3176. return;
  3177. }
  3178. config._a = parsedArray;
  3179. config._tzm = calculateOffset(match[8], match[9], match[10]);
  3180. config._d = createUTCDate.apply(null, config._a);
  3181. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  3182. getParsingFlags(config).rfc2822 = true;
  3183. } else {
  3184. config._isValid = false;
  3185. }
  3186. }
  3187. // date from 1) ASP.NET, 2) ISO, 3) RFC 2822 formats, or 4) optional fallback if parsing isn't strict
  3188. function configFromString(config) {
  3189. var matched = aspNetJsonRegex.exec(config._i);
  3190. if (matched !== null) {
  3191. config._d = new Date(+matched[1]);
  3192. return;
  3193. }
  3194. configFromISO(config);
  3195. if (config._isValid === false) {
  3196. delete config._isValid;
  3197. } else {
  3198. return;
  3199. }
  3200. configFromRFC2822(config);
  3201. if (config._isValid === false) {
  3202. delete config._isValid;
  3203. } else {
  3204. return;
  3205. }
  3206. if (config._strict) {
  3207. config._isValid = false;
  3208. } else {
  3209. // Final attempt, use Input Fallback
  3210. hooks.createFromInputFallback(config);
  3211. }
  3212. }
  3213. hooks.createFromInputFallback = deprecate(
  3214. 'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' +
  3215. 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' +
  3216. 'discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.',
  3217. function (config) {
  3218. config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
  3219. }
  3220. );
  3221. // Pick the first defined of two or three arguments.
  3222. function defaults(a, b, c) {
  3223. if (a != null) {
  3224. return a;
  3225. }
  3226. if (b != null) {
  3227. return b;
  3228. }
  3229. return c;
  3230. }
  3231. function currentDateArray(config) {
  3232. // hooks is actually the exported moment object
  3233. var nowValue = new Date(hooks.now());
  3234. if (config._useUTC) {
  3235. return [
  3236. nowValue.getUTCFullYear(),
  3237. nowValue.getUTCMonth(),
  3238. nowValue.getUTCDate(),
  3239. ];
  3240. }
  3241. return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
  3242. }
  3243. // convert an array to a date.
  3244. // the array should mirror the parameters below
  3245. // note: all values past the year are optional and will default to the lowest possible value.
  3246. // [year, month, day , hour, minute, second, millisecond]
  3247. function configFromArray(config) {
  3248. var i,
  3249. date,
  3250. input = [],
  3251. currentDate,
  3252. expectedWeekday,
  3253. yearToUse;
  3254. if (config._d) {
  3255. return;
  3256. }
  3257. currentDate = currentDateArray(config);
  3258. //compute day of the year from weeks and weekdays
  3259. if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
  3260. dayOfYearFromWeekInfo(config);
  3261. }
  3262. //if the day of the year is set, figure out what it is
  3263. if (config._dayOfYear != null) {
  3264. yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
  3265. if (
  3266. config._dayOfYear > daysInYear(yearToUse) ||
  3267. config._dayOfYear === 0
  3268. ) {
  3269. getParsingFlags(config)._overflowDayOfYear = true;
  3270. }
  3271. date = createUTCDate(yearToUse, 0, config._dayOfYear);
  3272. config._a[MONTH] = date.getUTCMonth();
  3273. config._a[DATE] = date.getUTCDate();
  3274. }
  3275. // Default to current date.
  3276. // * if no year, month, day of month are given, default to today
  3277. // * if day of month is given, default month and year
  3278. // * if month is given, default only year
  3279. // * if year is given, don't default anything
  3280. for (i = 0; i < 3 && config._a[i] == null; ++i) {
  3281. config._a[i] = input[i] = currentDate[i];
  3282. }
  3283. // Zero out whatever was not defaulted, including time
  3284. for (; i < 7; i++) {
  3285. config._a[i] = input[i] =
  3286. config._a[i] == null ? (i === 2 ? 1 : 0) : config._a[i];
  3287. }
  3288. // Check for 24:00:00.000
  3289. if (
  3290. config._a[HOUR] === 24 &&
  3291. config._a[MINUTE] === 0 &&
  3292. config._a[SECOND] === 0 &&
  3293. config._a[MILLISECOND] === 0
  3294. ) {
  3295. config._nextDay = true;
  3296. config._a[HOUR] = 0;
  3297. }
  3298. config._d = (config._useUTC ? createUTCDate : createDate).apply(
  3299. null,
  3300. input
  3301. );
  3302. expectedWeekday = config._useUTC
  3303. ? config._d.getUTCDay()
  3304. : config._d.getDay();
  3305. // Apply timezone offset from input. The actual utcOffset can be changed
  3306. // with parseZone.
  3307. if (config._tzm != null) {
  3308. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  3309. }
  3310. if (config._nextDay) {
  3311. config._a[HOUR] = 24;
  3312. }
  3313. // check for mismatching day of week
  3314. if (
  3315. config._w &&
  3316. typeof config._w.d !== 'undefined' &&
  3317. config._w.d !== expectedWeekday
  3318. ) {
  3319. getParsingFlags(config).weekdayMismatch = true;
  3320. }
  3321. }
  3322. function dayOfYearFromWeekInfo(config) {
  3323. var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow, curWeek;
  3324. w = config._w;
  3325. if (w.GG != null || w.W != null || w.E != null) {
  3326. dow = 1;
  3327. doy = 4;
  3328. // TODO: We need to take the current isoWeekYear, but that depends on
  3329. // how we interpret now (local, utc, fixed offset). So create
  3330. // a now version of current config (take local/utc/offset flags, and
  3331. // create now).
  3332. weekYear = defaults(
  3333. w.GG,
  3334. config._a[YEAR],
  3335. weekOfYear(createLocal(), 1, 4).year
  3336. );
  3337. week = defaults(w.W, 1);
  3338. weekday = defaults(w.E, 1);
  3339. if (weekday < 1 || weekday > 7) {
  3340. weekdayOverflow = true;
  3341. }
  3342. } else {
  3343. dow = config._locale._week.dow;
  3344. doy = config._locale._week.doy;
  3345. curWeek = weekOfYear(createLocal(), dow, doy);
  3346. weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
  3347. // Default to current week.
  3348. week = defaults(w.w, curWeek.week);
  3349. if (w.d != null) {
  3350. // weekday -- low day numbers are considered next week
  3351. weekday = w.d;
  3352. if (weekday < 0 || weekday > 6) {
  3353. weekdayOverflow = true;
  3354. }
  3355. } else if (w.e != null) {
  3356. // local weekday -- counting starts from beginning of week
  3357. weekday = w.e + dow;
  3358. if (w.e < 0 || w.e > 6) {
  3359. weekdayOverflow = true;
  3360. }
  3361. } else {
  3362. // default to beginning of week
  3363. weekday = dow;
  3364. }
  3365. }
  3366. if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
  3367. getParsingFlags(config)._overflowWeeks = true;
  3368. } else if (weekdayOverflow != null) {
  3369. getParsingFlags(config)._overflowWeekday = true;
  3370. } else {
  3371. temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
  3372. config._a[YEAR] = temp.year;
  3373. config._dayOfYear = temp.dayOfYear;
  3374. }
  3375. }
  3376. // constant that refers to the ISO standard
  3377. hooks.ISO_8601 = function () {};
  3378. // constant that refers to the RFC 2822 form
  3379. hooks.RFC_2822 = function () {};
  3380. // date from string and format string
  3381. function configFromStringAndFormat(config) {
  3382. // TODO: Move this to another part of the creation flow to prevent circular deps
  3383. if (config._f === hooks.ISO_8601) {
  3384. configFromISO(config);
  3385. return;
  3386. }
  3387. if (config._f === hooks.RFC_2822) {
  3388. configFromRFC2822(config);
  3389. return;
  3390. }
  3391. config._a = [];
  3392. getParsingFlags(config).empty = true;
  3393. // This array is used to make a Date, either with `new Date` or `Date.UTC`
  3394. var string = '' + config._i,
  3395. i,
  3396. parsedInput,
  3397. tokens,
  3398. token,
  3399. skipped,
  3400. stringLength = string.length,
  3401. totalParsedInputLength = 0,
  3402. era,
  3403. tokenLen;
  3404. tokens =
  3405. expandFormat(config._f, config._locale).match(formattingTokens) || [];
  3406. tokenLen = tokens.length;
  3407. for (i = 0; i < tokenLen; i++) {
  3408. token = tokens[i];
  3409. parsedInput = (string.match(getParseRegexForToken(token, config)) ||
  3410. [])[0];
  3411. if (parsedInput) {
  3412. skipped = string.substr(0, string.indexOf(parsedInput));
  3413. if (skipped.length > 0) {
  3414. getParsingFlags(config).unusedInput.push(skipped);
  3415. }
  3416. string = string.slice(
  3417. string.indexOf(parsedInput) + parsedInput.length
  3418. );
  3419. totalParsedInputLength += parsedInput.length;
  3420. }
  3421. // don't parse if it's not a known token
  3422. if (formatTokenFunctions[token]) {
  3423. if (parsedInput) {
  3424. getParsingFlags(config).empty = false;
  3425. } else {
  3426. getParsingFlags(config).unusedTokens.push(token);
  3427. }
  3428. addTimeToArrayFromToken(token, parsedInput, config);
  3429. } else if (config._strict && !parsedInput) {
  3430. getParsingFlags(config).unusedTokens.push(token);
  3431. }
  3432. }
  3433. // add remaining unparsed input length to the string
  3434. getParsingFlags(config).charsLeftOver =
  3435. stringLength - totalParsedInputLength;
  3436. if (string.length > 0) {
  3437. getParsingFlags(config).unusedInput.push(string);
  3438. }
  3439. // clear _12h flag if hour is <= 12
  3440. if (
  3441. config._a[HOUR] <= 12 &&
  3442. getParsingFlags(config).bigHour === true &&
  3443. config._a[HOUR] > 0
  3444. ) {
  3445. getParsingFlags(config).bigHour = undefined;
  3446. }
  3447. getParsingFlags(config).parsedDateParts = config._a.slice(0);
  3448. getParsingFlags(config).meridiem = config._meridiem;
  3449. // handle meridiem
  3450. config._a[HOUR] = meridiemFixWrap(
  3451. config._locale,
  3452. config._a[HOUR],
  3453. config._meridiem
  3454. );
  3455. // handle era
  3456. era = getParsingFlags(config).era;
  3457. if (era !== null) {
  3458. config._a[YEAR] = config._locale.erasConvertYear(era, config._a[YEAR]);
  3459. }
  3460. configFromArray(config);
  3461. checkOverflow(config);
  3462. }
  3463. function meridiemFixWrap(locale, hour, meridiem) {
  3464. var isPm;
  3465. if (meridiem == null) {
  3466. // nothing to do
  3467. return hour;
  3468. }
  3469. if (locale.meridiemHour != null) {
  3470. return locale.meridiemHour(hour, meridiem);
  3471. } else if (locale.isPM != null) {
  3472. // Fallback
  3473. isPm = locale.isPM(meridiem);
  3474. if (isPm && hour < 12) {
  3475. hour += 12;
  3476. }
  3477. if (!isPm && hour === 12) {
  3478. hour = 0;
  3479. }
  3480. return hour;
  3481. } else {
  3482. // this is not supposed to happen
  3483. return hour;
  3484. }
  3485. }
  3486. // date from string and array of format strings
  3487. function configFromStringAndArray(config) {
  3488. var tempConfig,
  3489. bestMoment,
  3490. scoreToBeat,
  3491. i,
  3492. currentScore,
  3493. validFormatFound,
  3494. bestFormatIsValid = false,
  3495. configfLen = config._f.length;
  3496. if (configfLen === 0) {
  3497. getParsingFlags(config).invalidFormat = true;
  3498. config._d = new Date(NaN);
  3499. return;
  3500. }
  3501. for (i = 0; i < configfLen; i++) {
  3502. currentScore = 0;
  3503. validFormatFound = false;
  3504. tempConfig = copyConfig({}, config);
  3505. if (config._useUTC != null) {
  3506. tempConfig._useUTC = config._useUTC;
  3507. }
  3508. tempConfig._f = config._f[i];
  3509. configFromStringAndFormat(tempConfig);
  3510. if (isValid(tempConfig)) {
  3511. validFormatFound = true;
  3512. }
  3513. // if there is any input that was not parsed add a penalty for that format
  3514. currentScore += getParsingFlags(tempConfig).charsLeftOver;
  3515. //or tokens
  3516. currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
  3517. getParsingFlags(tempConfig).score = currentScore;
  3518. if (!bestFormatIsValid) {
  3519. if (
  3520. scoreToBeat == null ||
  3521. currentScore < scoreToBeat ||
  3522. validFormatFound
  3523. ) {
  3524. scoreToBeat = currentScore;
  3525. bestMoment = tempConfig;
  3526. if (validFormatFound) {
  3527. bestFormatIsValid = true;
  3528. }
  3529. }
  3530. } else {
  3531. if (currentScore < scoreToBeat) {
  3532. scoreToBeat = currentScore;
  3533. bestMoment = tempConfig;
  3534. }
  3535. }
  3536. }
  3537. extend(config, bestMoment || tempConfig);
  3538. }
  3539. function configFromObject(config) {
  3540. if (config._d) {
  3541. return;
  3542. }
  3543. var i = normalizeObjectUnits(config._i),
  3544. dayOrDate = i.day === undefined ? i.date : i.day;
  3545. config._a = map(
  3546. [i.year, i.month, dayOrDate, i.hour, i.minute, i.second, i.millisecond],
  3547. function (obj) {
  3548. return obj && parseInt(obj, 10);
  3549. }
  3550. );
  3551. configFromArray(config);
  3552. }
  3553. function createFromConfig(config) {
  3554. var res = new Moment(checkOverflow(prepareConfig(config)));
  3555. if (res._nextDay) {
  3556. // Adding is smart enough around DST
  3557. res.add(1, 'd');
  3558. res._nextDay = undefined;
  3559. }
  3560. return res;
  3561. }
  3562. function prepareConfig(config) {
  3563. var input = config._i,
  3564. format = config._f;
  3565. config._locale = config._locale || getLocale(config._l);
  3566. if (input === null || (format === undefined && input === '')) {
  3567. return createInvalid({ nullInput: true });
  3568. }
  3569. if (typeof input === 'string') {
  3570. config._i = input = config._locale.preparse(input);
  3571. }
  3572. if (isMoment(input)) {
  3573. return new Moment(checkOverflow(input));
  3574. } else if (isDate(input)) {
  3575. config._d = input;
  3576. } else if (isArray(format)) {
  3577. configFromStringAndArray(config);
  3578. } else if (format) {
  3579. configFromStringAndFormat(config);
  3580. } else {
  3581. configFromInput(config);
  3582. }
  3583. if (!isValid(config)) {
  3584. config._d = null;
  3585. }
  3586. return config;
  3587. }
  3588. function configFromInput(config) {
  3589. var input = config._i;
  3590. if (isUndefined(input)) {
  3591. config._d = new Date(hooks.now());
  3592. } else if (isDate(input)) {
  3593. config._d = new Date(input.valueOf());
  3594. } else if (typeof input === 'string') {
  3595. configFromString(config);
  3596. } else if (isArray(input)) {
  3597. config._a = map(input.slice(0), function (obj) {
  3598. return parseInt(obj, 10);
  3599. });
  3600. configFromArray(config);
  3601. } else if (isObject(input)) {
  3602. configFromObject(config);
  3603. } else if (isNumber(input)) {
  3604. // from milliseconds
  3605. config._d = new Date(input);
  3606. } else {
  3607. hooks.createFromInputFallback(config);
  3608. }
  3609. }
  3610. function createLocalOrUTC(input, format, locale, strict, isUTC) {
  3611. var c = {};
  3612. if (format === true || format === false) {
  3613. strict = format;
  3614. format = undefined;
  3615. }
  3616. if (locale === true || locale === false) {
  3617. strict = locale;
  3618. locale = undefined;
  3619. }
  3620. if (
  3621. (isObject(input) && isObjectEmpty(input)) ||
  3622. (isArray(input) && input.length === 0)
  3623. ) {
  3624. input = undefined;
  3625. }
  3626. // object construction must be done this way.
  3627. // https://github.com/moment/moment/issues/1423
  3628. c._isAMomentObject = true;
  3629. c._useUTC = c._isUTC = isUTC;
  3630. c._l = locale;
  3631. c._i = input;
  3632. c._f = format;
  3633. c._strict = strict;
  3634. return createFromConfig(c);
  3635. }
  3636. function createLocal(input, format, locale, strict) {
  3637. return createLocalOrUTC(input, format, locale, strict, false);
  3638. }
  3639. var prototypeMin = deprecate(
  3640. 'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',
  3641. function () {
  3642. var other = createLocal.apply(null, arguments);
  3643. if (this.isValid() && other.isValid()) {
  3644. return other < this ? this : other;
  3645. } else {
  3646. return createInvalid();
  3647. }
  3648. }
  3649. ),
  3650. prototypeMax = deprecate(
  3651. 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',
  3652. function () {
  3653. var other = createLocal.apply(null, arguments);
  3654. if (this.isValid() && other.isValid()) {
  3655. return other > this ? this : other;
  3656. } else {
  3657. return createInvalid();
  3658. }
  3659. }
  3660. );
  3661. // Pick a moment m from moments so that m[fn](other) is true for all
  3662. // other. This relies on the function fn to be transitive.
  3663. //
  3664. // moments should either be an array of moment objects or an array, whose
  3665. // first element is an array of moment objects.
  3666. function pickBy(fn, moments) {
  3667. var res, i;
  3668. if (moments.length === 1 && isArray(moments[0])) {
  3669. moments = moments[0];
  3670. }
  3671. if (!moments.length) {
  3672. return createLocal();
  3673. }
  3674. res = moments[0];
  3675. for (i = 1; i < moments.length; ++i) {
  3676. if (!moments[i].isValid() || moments[i][fn](res)) {
  3677. res = moments[i];
  3678. }
  3679. }
  3680. return res;
  3681. }
  3682. // TODO: Use [].sort instead?
  3683. function min() {
  3684. var args = [].slice.call(arguments, 0);
  3685. return pickBy('isBefore', args);
  3686. }
  3687. function max() {
  3688. var args = [].slice.call(arguments, 0);
  3689. return pickBy('isAfter', args);
  3690. }
  3691. var now = function () {
  3692. return Date.now ? Date.now() : +new Date();
  3693. };
  3694. var ordering = [
  3695. 'year',
  3696. 'quarter',
  3697. 'month',
  3698. 'week',
  3699. 'day',
  3700. 'hour',
  3701. 'minute',
  3702. 'second',
  3703. 'millisecond',
  3704. ];
  3705. function isDurationValid(m) {
  3706. var key,
  3707. unitHasDecimal = false,
  3708. i,
  3709. orderLen = ordering.length;
  3710. for (key in m) {
  3711. if (
  3712. hasOwnProp(m, key) &&
  3713. !(
  3714. indexOf.call(ordering, key) !== -1 &&
  3715. (m[key] == null || !isNaN(m[key]))
  3716. )
  3717. ) {
  3718. return false;
  3719. }
  3720. }
  3721. for (i = 0; i < orderLen; ++i) {
  3722. if (m[ordering[i]]) {
  3723. if (unitHasDecimal) {
  3724. return false; // only allow non-integers for smallest unit
  3725. }
  3726. if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
  3727. unitHasDecimal = true;
  3728. }
  3729. }
  3730. }
  3731. return true;
  3732. }
  3733. function isValid$1() {
  3734. return this._isValid;
  3735. }
  3736. function createInvalid$1() {
  3737. return createDuration(NaN);
  3738. }
  3739. function Duration(duration) {
  3740. var normalizedInput = normalizeObjectUnits(duration),
  3741. years = normalizedInput.year || 0,
  3742. quarters = normalizedInput.quarter || 0,
  3743. months = normalizedInput.month || 0,
  3744. weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
  3745. days = normalizedInput.day || 0,
  3746. hours = normalizedInput.hour || 0,
  3747. minutes = normalizedInput.minute || 0,
  3748. seconds = normalizedInput.second || 0,
  3749. milliseconds = normalizedInput.millisecond || 0;
  3750. this._isValid = isDurationValid(normalizedInput);
  3751. // representation for dateAddRemove
  3752. this._milliseconds =
  3753. +milliseconds +
  3754. seconds * 1e3 + // 1000
  3755. minutes * 6e4 + // 1000 * 60
  3756. hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
  3757. // Because of dateAddRemove treats 24 hours as different from a
  3758. // day when working around DST, we need to store them separately
  3759. this._days = +days + weeks * 7;
  3760. // It is impossible to translate months into days without knowing
  3761. // which months you are are talking about, so we have to store
  3762. // it separately.
  3763. this._months = +months + quarters * 3 + years * 12;
  3764. this._data = {};
  3765. this._locale = getLocale();
  3766. this._bubble();
  3767. }
  3768. function isDuration(obj) {
  3769. return obj instanceof Duration;
  3770. }
  3771. function absRound(number) {
  3772. if (number < 0) {
  3773. return Math.round(-1 * number) * -1;
  3774. } else {
  3775. return Math.round(number);
  3776. }
  3777. }
  3778. // compare two arrays, return the number of differences
  3779. function compareArrays(array1, array2, dontConvert) {
  3780. var len = Math.min(array1.length, array2.length),
  3781. lengthDiff = Math.abs(array1.length - array2.length),
  3782. diffs = 0,
  3783. i;
  3784. for (i = 0; i < len; i++) {
  3785. if (
  3786. (dontConvert && array1[i] !== array2[i]) ||
  3787. (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))
  3788. ) {
  3789. diffs++;
  3790. }
  3791. }
  3792. return diffs + lengthDiff;
  3793. }
  3794. // FORMATTING
  3795. function offset(token, separator) {
  3796. addFormatToken(token, 0, 0, function () {
  3797. var offset = this.utcOffset(),
  3798. sign = '+';
  3799. if (offset < 0) {
  3800. offset = -offset;
  3801. sign = '-';
  3802. }
  3803. return (
  3804. sign +
  3805. zeroFill(~~(offset / 60), 2) +
  3806. separator +
  3807. zeroFill(~~offset % 60, 2)
  3808. );
  3809. });
  3810. }
  3811. offset('Z', ':');
  3812. offset('ZZ', '');
  3813. // PARSING
  3814. addRegexToken('Z', matchShortOffset);
  3815. addRegexToken('ZZ', matchShortOffset);
  3816. addParseToken(['Z', 'ZZ'], function (input, array, config) {
  3817. config._useUTC = true;
  3818. config._tzm = offsetFromString(matchShortOffset, input);
  3819. });
  3820. // HELPERS
  3821. // timezone chunker
  3822. // '+10:00' > ['10', '00']
  3823. // '-1530' > ['-15', '30']
  3824. var chunkOffset = /([\+\-]|\d\d)/gi;
  3825. function offsetFromString(matcher, string) {
  3826. var matches = (string || '').match(matcher),
  3827. chunk,
  3828. parts,
  3829. minutes;
  3830. if (matches === null) {
  3831. return null;
  3832. }
  3833. chunk = matches[matches.length - 1] || [];
  3834. parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
  3835. minutes = +(parts[1] * 60) + toInt(parts[2]);
  3836. return minutes === 0 ? 0 : parts[0] === '+' ? minutes : -minutes;
  3837. }
  3838. // Return a moment from input, that is local/utc/zone equivalent to model.
  3839. function cloneWithOffset(input, model) {
  3840. var res, diff;
  3841. if (model._isUTC) {
  3842. res = model.clone();
  3843. diff =
  3844. (isMoment(input) || isDate(input)
  3845. ? input.valueOf()
  3846. : createLocal(input).valueOf()) - res.valueOf();
  3847. // Use low-level api, because this fn is low-level api.
  3848. res._d.setTime(res._d.valueOf() + diff);
  3849. hooks.updateOffset(res, false);
  3850. return res;
  3851. } else {
  3852. return createLocal(input).local();
  3853. }
  3854. }
  3855. function getDateOffset(m) {
  3856. // On Firefox.24 Date#getTimezoneOffset returns a floating point.
  3857. // https://github.com/moment/moment/pull/1871
  3858. return -Math.round(m._d.getTimezoneOffset());
  3859. }
  3860. // HOOKS
  3861. // This function will be called whenever a moment is mutated.
  3862. // It is intended to keep the offset in sync with the timezone.
  3863. hooks.updateOffset = function () {};
  3864. // MOMENTS
  3865. // keepLocalTime = true means only change the timezone, without
  3866. // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
  3867. // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
  3868. // +0200, so we adjust the time as needed, to be valid.
  3869. //
  3870. // Keeping the time actually adds/subtracts (one hour)
  3871. // from the actual represented time. That is why we call updateOffset
  3872. // a second time. In case it wants us to change the offset again
  3873. // _changeInProgress == true case, then we have to adjust, because
  3874. // there is no such time in the given timezone.
  3875. function getSetOffset(input, keepLocalTime, keepMinutes) {
  3876. var offset = this._offset || 0,
  3877. localAdjust;
  3878. if (!this.isValid()) {
  3879. return input != null ? this : NaN;
  3880. }
  3881. if (input != null) {
  3882. if (typeof input === 'string') {
  3883. input = offsetFromString(matchShortOffset, input);
  3884. if (input === null) {
  3885. return this;
  3886. }
  3887. } else if (Math.abs(input) < 16 && !keepMinutes) {
  3888. input = input * 60;
  3889. }
  3890. if (!this._isUTC && keepLocalTime) {
  3891. localAdjust = getDateOffset(this);
  3892. }
  3893. this._offset = input;
  3894. this._isUTC = true;
  3895. if (localAdjust != null) {
  3896. this.add(localAdjust, 'm');
  3897. }
  3898. if (offset !== input) {
  3899. if (!keepLocalTime || this._changeInProgress) {
  3900. addSubtract(
  3901. this,
  3902. createDuration(input - offset, 'm'),
  3903. 1,
  3904. false
  3905. );
  3906. } else if (!this._changeInProgress) {
  3907. this._changeInProgress = true;
  3908. hooks.updateOffset(this, true);
  3909. this._changeInProgress = null;
  3910. }
  3911. }
  3912. return this;
  3913. } else {
  3914. return this._isUTC ? offset : getDateOffset(this);
  3915. }
  3916. }
  3917. function getSetZone(input, keepLocalTime) {
  3918. if (input != null) {
  3919. if (typeof input !== 'string') {
  3920. input = -input;
  3921. }
  3922. this.utcOffset(input, keepLocalTime);
  3923. return this;
  3924. } else {
  3925. return -this.utcOffset();
  3926. }
  3927. }
  3928. function setOffsetToUTC(keepLocalTime) {
  3929. return this.utcOffset(0, keepLocalTime);
  3930. }
  3931. function setOffsetToLocal(keepLocalTime) {
  3932. if (this._isUTC) {
  3933. this.utcOffset(0, keepLocalTime);
  3934. this._isUTC = false;
  3935. if (keepLocalTime) {
  3936. this.subtract(getDateOffset(this), 'm');
  3937. }
  3938. }
  3939. return this;
  3940. }
  3941. function setOffsetToParsedOffset() {
  3942. if (this._tzm != null) {
  3943. this.utcOffset(this._tzm, false, true);
  3944. } else if (typeof this._i === 'string') {
  3945. var tZone = offsetFromString(matchOffset, this._i);
  3946. if (tZone != null) {
  3947. this.utcOffset(tZone);
  3948. } else {
  3949. this.utcOffset(0, true);
  3950. }
  3951. }
  3952. return this;
  3953. }
  3954. function hasAlignedHourOffset(input) {
  3955. if (!this.isValid()) {
  3956. return false;
  3957. }
  3958. input = input ? createLocal(input).utcOffset() : 0;
  3959. return (this.utcOffset() - input) % 60 === 0;
  3960. }
  3961. function isDaylightSavingTime() {
  3962. return (
  3963. this.utcOffset() > this.clone().month(0).utcOffset() ||
  3964. this.utcOffset() > this.clone().month(5).utcOffset()
  3965. );
  3966. }
  3967. function isDaylightSavingTimeShifted() {
  3968. if (!isUndefined(this._isDSTShifted)) {
  3969. return this._isDSTShifted;
  3970. }
  3971. var c = {},
  3972. other;
  3973. copyConfig(c, this);
  3974. c = prepareConfig(c);
  3975. if (c._a) {
  3976. other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
  3977. this._isDSTShifted =
  3978. this.isValid() && compareArrays(c._a, other.toArray()) > 0;
  3979. } else {
  3980. this._isDSTShifted = false;
  3981. }
  3982. return this._isDSTShifted;
  3983. }
  3984. function isLocal() {
  3985. return this.isValid() ? !this._isUTC : false;
  3986. }
  3987. function isUtcOffset() {
  3988. return this.isValid() ? this._isUTC : false;
  3989. }
  3990. function isUtc() {
  3991. return this.isValid() ? this._isUTC && this._offset === 0 : false;
  3992. }
  3993. // ASP.NET json date format regex
  3994. var aspNetRegex = /^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,
  3995. // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
  3996. // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
  3997. // and further modified to allow for strings containing both week and day
  3998. isoRegex =
  3999. /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
  4000. function createDuration(input, key) {
  4001. var duration = input,
  4002. // matching against regexp is expensive, do it on demand
  4003. match = null,
  4004. sign,
  4005. ret,
  4006. diffRes;
  4007. if (isDuration(input)) {
  4008. duration = {
  4009. ms: input._milliseconds,
  4010. d: input._days,
  4011. M: input._months,
  4012. };
  4013. } else if (isNumber(input) || !isNaN(+input)) {
  4014. duration = {};
  4015. if (key) {
  4016. duration[key] = +input;
  4017. } else {
  4018. duration.milliseconds = +input;
  4019. }
  4020. } else if ((match = aspNetRegex.exec(input))) {
  4021. sign = match[1] === '-' ? -1 : 1;
  4022. duration = {
  4023. y: 0,
  4024. d: toInt(match[DATE]) * sign,
  4025. h: toInt(match[HOUR]) * sign,
  4026. m: toInt(match[MINUTE]) * sign,
  4027. s: toInt(match[SECOND]) * sign,
  4028. ms: toInt(absRound(match[MILLISECOND] * 1000)) * sign, // the millisecond decimal point is included in the match
  4029. };
  4030. } else if ((match = isoRegex.exec(input))) {
  4031. sign = match[1] === '-' ? -1 : 1;
  4032. duration = {
  4033. y: parseIso(match[2], sign),
  4034. M: parseIso(match[3], sign),
  4035. w: parseIso(match[4], sign),
  4036. d: parseIso(match[5], sign),
  4037. h: parseIso(match[6], sign),
  4038. m: parseIso(match[7], sign),
  4039. s: parseIso(match[8], sign),
  4040. };
  4041. } else if (duration == null) {
  4042. // checks for null or undefined
  4043. duration = {};
  4044. } else if (
  4045. typeof duration === 'object' &&
  4046. ('from' in duration || 'to' in duration)
  4047. ) {
  4048. diffRes = momentsDifference(
  4049. createLocal(duration.from),
  4050. createLocal(duration.to)
  4051. );
  4052. duration = {};
  4053. duration.ms = diffRes.milliseconds;
  4054. duration.M = diffRes.months;
  4055. }
  4056. ret = new Duration(duration);
  4057. if (isDuration(input) && hasOwnProp(input, '_locale')) {
  4058. ret._locale = input._locale;
  4059. }
  4060. if (isDuration(input) && hasOwnProp(input, '_isValid')) {
  4061. ret._isValid = input._isValid;
  4062. }
  4063. return ret;
  4064. }
  4065. createDuration.fn = Duration.prototype;
  4066. createDuration.invalid = createInvalid$1;
  4067. function parseIso(inp, sign) {
  4068. // We'd normally use ~~inp for this, but unfortunately it also
  4069. // converts floats to ints.
  4070. // inp may be undefined, so careful calling replace on it.
  4071. var res = inp && parseFloat(inp.replace(',', '.'));
  4072. // apply sign while we're at it
  4073. return (isNaN(res) ? 0 : res) * sign;
  4074. }
  4075. function positiveMomentsDifference(base, other) {
  4076. var res = {};
  4077. res.months =
  4078. other.month() - base.month() + (other.year() - base.year()) * 12;
  4079. if (base.clone().add(res.months, 'M').isAfter(other)) {
  4080. --res.months;
  4081. }
  4082. res.milliseconds = +other - +base.clone().add(res.months, 'M');
  4083. return res;
  4084. }
  4085. function momentsDifference(base, other) {
  4086. var res;
  4087. if (!(base.isValid() && other.isValid())) {
  4088. return { milliseconds: 0, months: 0 };
  4089. }
  4090. other = cloneWithOffset(other, base);
  4091. if (base.isBefore(other)) {
  4092. res = positiveMomentsDifference(base, other);
  4093. } else {
  4094. res = positiveMomentsDifference(other, base);
  4095. res.milliseconds = -res.milliseconds;
  4096. res.months = -res.months;
  4097. }
  4098. return res;
  4099. }
  4100. // TODO: remove 'name' arg after deprecation is removed
  4101. function createAdder(direction, name) {
  4102. return function (val, period) {
  4103. var dur, tmp;
  4104. //invert the arguments, but complain about it
  4105. if (period !== null && !isNaN(+period)) {
  4106. deprecateSimple(
  4107. name,
  4108. 'moment().' +
  4109. name +
  4110. '(period, number) is deprecated. Please use moment().' +
  4111. name +
  4112. '(number, period). ' +
  4113. 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.'
  4114. );
  4115. tmp = val;
  4116. val = period;
  4117. period = tmp;
  4118. }
  4119. dur = createDuration(val, period);
  4120. addSubtract(this, dur, direction);
  4121. return this;
  4122. };
  4123. }
  4124. function addSubtract(mom, duration, isAdding, updateOffset) {
  4125. var milliseconds = duration._milliseconds,
  4126. days = absRound(duration._days),
  4127. months = absRound(duration._months);
  4128. if (!mom.isValid()) {
  4129. // No op
  4130. return;
  4131. }
  4132. updateOffset = updateOffset == null ? true : updateOffset;
  4133. if (months) {
  4134. setMonth(mom, get(mom, 'Month') + months * isAdding);
  4135. }
  4136. if (days) {
  4137. set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
  4138. }
  4139. if (milliseconds) {
  4140. mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
  4141. }
  4142. if (updateOffset) {
  4143. hooks.updateOffset(mom, days || months);
  4144. }
  4145. }
  4146. var add = createAdder(1, 'add'),
  4147. subtract = createAdder(-1, 'subtract');
  4148. function isString(input) {
  4149. return typeof input === 'string' || input instanceof String;
  4150. }
  4151. // type MomentInput = Moment | Date | string | number | (number | string)[] | MomentInputObject | void; // null | undefined
  4152. function isMomentInput(input) {
  4153. return (
  4154. isMoment(input) ||
  4155. isDate(input) ||
  4156. isString(input) ||
  4157. isNumber(input) ||
  4158. isNumberOrStringArray(input) ||
  4159. isMomentInputObject(input) ||
  4160. input === null ||
  4161. input === undefined
  4162. );
  4163. }
  4164. function isMomentInputObject(input) {
  4165. var objectTest = isObject(input) && !isObjectEmpty(input),
  4166. propertyTest = false,
  4167. properties = [
  4168. 'years',
  4169. 'year',
  4170. 'y',
  4171. 'months',
  4172. 'month',
  4173. 'M',
  4174. 'days',
  4175. 'day',
  4176. 'd',
  4177. 'dates',
  4178. 'date',
  4179. 'D',
  4180. 'hours',
  4181. 'hour',
  4182. 'h',
  4183. 'minutes',
  4184. 'minute',
  4185. 'm',
  4186. 'seconds',
  4187. 'second',
  4188. 's',
  4189. 'milliseconds',
  4190. 'millisecond',
  4191. 'ms',
  4192. ],
  4193. i,
  4194. property,
  4195. propertyLen = properties.length;
  4196. for (i = 0; i < propertyLen; i += 1) {
  4197. property = properties[i];
  4198. propertyTest = propertyTest || hasOwnProp(input, property);
  4199. }
  4200. return objectTest && propertyTest;
  4201. }
  4202. function isNumberOrStringArray(input) {
  4203. var arrayTest = isArray(input),
  4204. dataTypeTest = false;
  4205. if (arrayTest) {
  4206. dataTypeTest =
  4207. input.filter(function (item) {
  4208. return !isNumber(item) && isString(input);
  4209. }).length === 0;
  4210. }
  4211. return arrayTest && dataTypeTest;
  4212. }
  4213. function isCalendarSpec(input) {
  4214. var objectTest = isObject(input) && !isObjectEmpty(input),
  4215. propertyTest = false,
  4216. properties = [
  4217. 'sameDay',
  4218. 'nextDay',
  4219. 'lastDay',
  4220. 'nextWeek',
  4221. 'lastWeek',
  4222. 'sameElse',
  4223. ],
  4224. i,
  4225. property;
  4226. for (i = 0; i < properties.length; i += 1) {
  4227. property = properties[i];
  4228. propertyTest = propertyTest || hasOwnProp(input, property);
  4229. }
  4230. return objectTest && propertyTest;
  4231. }
  4232. function getCalendarFormat(myMoment, now) {
  4233. var diff = myMoment.diff(now, 'days', true);
  4234. return diff < -6
  4235. ? 'sameElse'
  4236. : diff < -1
  4237. ? 'lastWeek'
  4238. : diff < 0
  4239. ? 'lastDay'
  4240. : diff < 1
  4241. ? 'sameDay'
  4242. : diff < 2
  4243. ? 'nextDay'
  4244. : diff < 7
  4245. ? 'nextWeek'
  4246. : 'sameElse';
  4247. }
  4248. function calendar$1(time, formats) {
  4249. // Support for single parameter, formats only overload to the calendar function
  4250. if (arguments.length === 1) {
  4251. if (!arguments[0]) {
  4252. time = undefined;
  4253. formats = undefined;
  4254. } else if (isMomentInput(arguments[0])) {
  4255. time = arguments[0];
  4256. formats = undefined;
  4257. } else if (isCalendarSpec(arguments[0])) {
  4258. formats = arguments[0];
  4259. time = undefined;
  4260. }
  4261. }
  4262. // We want to compare the start of today, vs this.
  4263. // Getting start-of-today depends on whether we're local/utc/offset or not.
  4264. var now = time || createLocal(),
  4265. sod = cloneWithOffset(now, this).startOf('day'),
  4266. format = hooks.calendarFormat(this, sod) || 'sameElse',
  4267. output =
  4268. formats &&
  4269. (isFunction(formats[format])
  4270. ? formats[format].call(this, now)
  4271. : formats[format]);
  4272. return this.format(
  4273. output || this.localeData().calendar(format, this, createLocal(now))
  4274. );
  4275. }
  4276. function clone() {
  4277. return new Moment(this);
  4278. }
  4279. function isAfter(input, units) {
  4280. var localInput = isMoment(input) ? input : createLocal(input);
  4281. if (!(this.isValid() && localInput.isValid())) {
  4282. return false;
  4283. }
  4284. units = normalizeUnits(units) || 'millisecond';
  4285. if (units === 'millisecond') {
  4286. return this.valueOf() > localInput.valueOf();
  4287. } else {
  4288. return localInput.valueOf() < this.clone().startOf(units).valueOf();
  4289. }
  4290. }
  4291. function isBefore(input, units) {
  4292. var localInput = isMoment(input) ? input : createLocal(input);
  4293. if (!(this.isValid() && localInput.isValid())) {
  4294. return false;
  4295. }
  4296. units = normalizeUnits(units) || 'millisecond';
  4297. if (units === 'millisecond') {
  4298. return this.valueOf() < localInput.valueOf();
  4299. } else {
  4300. return this.clone().endOf(units).valueOf() < localInput.valueOf();
  4301. }
  4302. }
  4303. function isBetween(from, to, units, inclusivity) {
  4304. var localFrom = isMoment(from) ? from : createLocal(from),
  4305. localTo = isMoment(to) ? to : createLocal(to);
  4306. if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
  4307. return false;
  4308. }
  4309. inclusivity = inclusivity || '()';
  4310. return (
  4311. (inclusivity[0] === '('
  4312. ? this.isAfter(localFrom, units)
  4313. : !this.isBefore(localFrom, units)) &&
  4314. (inclusivity[1] === ')'
  4315. ? this.isBefore(localTo, units)
  4316. : !this.isAfter(localTo, units))
  4317. );
  4318. }
  4319. function isSame(input, units) {
  4320. var localInput = isMoment(input) ? input : createLocal(input),
  4321. inputMs;
  4322. if (!(this.isValid() && localInput.isValid())) {
  4323. return false;
  4324. }
  4325. units = normalizeUnits(units) || 'millisecond';
  4326. if (units === 'millisecond') {
  4327. return this.valueOf() === localInput.valueOf();
  4328. } else {
  4329. inputMs = localInput.valueOf();
  4330. return (
  4331. this.clone().startOf(units).valueOf() <= inputMs &&
  4332. inputMs <= this.clone().endOf(units).valueOf()
  4333. );
  4334. }
  4335. }
  4336. function isSameOrAfter(input, units) {
  4337. return this.isSame(input, units) || this.isAfter(input, units);
  4338. }
  4339. function isSameOrBefore(input, units) {
  4340. return this.isSame(input, units) || this.isBefore(input, units);
  4341. }
  4342. function diff(input, units, asFloat) {
  4343. var that, zoneDelta, output;
  4344. if (!this.isValid()) {
  4345. return NaN;
  4346. }
  4347. that = cloneWithOffset(input, this);
  4348. if (!that.isValid()) {
  4349. return NaN;
  4350. }
  4351. zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
  4352. units = normalizeUnits(units);
  4353. switch (units) {
  4354. case 'year':
  4355. output = monthDiff(this, that) / 12;
  4356. break;
  4357. case 'month':
  4358. output = monthDiff(this, that);
  4359. break;
  4360. case 'quarter':
  4361. output = monthDiff(this, that) / 3;
  4362. break;
  4363. case 'second':
  4364. output = (this - that) / 1e3;
  4365. break; // 1000
  4366. case 'minute':
  4367. output = (this - that) / 6e4;
  4368. break; // 1000 * 60
  4369. case 'hour':
  4370. output = (this - that) / 36e5;
  4371. break; // 1000 * 60 * 60
  4372. case 'day':
  4373. output = (this - that - zoneDelta) / 864e5;
  4374. break; // 1000 * 60 * 60 * 24, negate dst
  4375. case 'week':
  4376. output = (this - that - zoneDelta) / 6048e5;
  4377. break; // 1000 * 60 * 60 * 24 * 7, negate dst
  4378. default:
  4379. output = this - that;
  4380. }
  4381. return asFloat ? output : absFloor(output);
  4382. }
  4383. function monthDiff(a, b) {
  4384. if (a.date() < b.date()) {
  4385. // end-of-month calculations work correct when the start month has more
  4386. // days than the end month.
  4387. return -monthDiff(b, a);
  4388. }
  4389. // difference in months
  4390. var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month()),
  4391. // b is in (anchor - 1 month, anchor + 1 month)
  4392. anchor = a.clone().add(wholeMonthDiff, 'months'),
  4393. anchor2,
  4394. adjust;
  4395. if (b - anchor < 0) {
  4396. anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
  4397. // linear across the month
  4398. adjust = (b - anchor) / (anchor - anchor2);
  4399. } else {
  4400. anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
  4401. // linear across the month
  4402. adjust = (b - anchor) / (anchor2 - anchor);
  4403. }
  4404. //check for negative zero, return zero if negative zero
  4405. return -(wholeMonthDiff + adjust) || 0;
  4406. }
  4407. hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
  4408. hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
  4409. function toString() {
  4410. return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
  4411. }
  4412. function toISOString(keepOffset) {
  4413. if (!this.isValid()) {
  4414. return null;
  4415. }
  4416. var utc = keepOffset !== true,
  4417. m = utc ? this.clone().utc() : this;
  4418. if (m.year() < 0 || m.year() > 9999) {
  4419. return formatMoment(
  4420. m,
  4421. utc
  4422. ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]'
  4423. : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ'
  4424. );
  4425. }
  4426. if (isFunction(Date.prototype.toISOString)) {
  4427. // native implementation is ~50x faster, use it when we can
  4428. if (utc) {
  4429. return this.toDate().toISOString();
  4430. } else {
  4431. return new Date(this.valueOf() + this.utcOffset() * 60 * 1000)
  4432. .toISOString()
  4433. .replace('Z', formatMoment(m, 'Z'));
  4434. }
  4435. }
  4436. return formatMoment(
  4437. m,
  4438. utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ'
  4439. );
  4440. }
  4441. /**
  4442. * Return a human readable representation of a moment that can
  4443. * also be evaluated to get a new moment which is the same
  4444. *
  4445. * @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects
  4446. */
  4447. function inspect() {
  4448. if (!this.isValid()) {
  4449. return 'moment.invalid(/* ' + this._i + ' */)';
  4450. }
  4451. var func = 'moment',
  4452. zone = '',
  4453. prefix,
  4454. year,
  4455. datetime,
  4456. suffix;
  4457. if (!this.isLocal()) {
  4458. func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
  4459. zone = 'Z';
  4460. }
  4461. prefix = '[' + func + '("]';
  4462. year = 0 <= this.year() && this.year() <= 9999 ? 'YYYY' : 'YYYYYY';
  4463. datetime = '-MM-DD[T]HH:mm:ss.SSS';
  4464. suffix = zone + '[")]';
  4465. return this.format(prefix + year + datetime + suffix);
  4466. }
  4467. function format(inputString) {
  4468. if (!inputString) {
  4469. inputString = this.isUtc()
  4470. ? hooks.defaultFormatUtc
  4471. : hooks.defaultFormat;
  4472. }
  4473. var output = formatMoment(this, inputString);
  4474. return this.localeData().postformat(output);
  4475. }
  4476. function from(time, withoutSuffix) {
  4477. if (
  4478. this.isValid() &&
  4479. ((isMoment(time) && time.isValid()) || createLocal(time).isValid())
  4480. ) {
  4481. return createDuration({ to: this, from: time })
  4482. .locale(this.locale())
  4483. .humanize(!withoutSuffix);
  4484. } else {
  4485. return this.localeData().invalidDate();
  4486. }
  4487. }
  4488. function fromNow(withoutSuffix) {
  4489. return this.from(createLocal(), withoutSuffix);
  4490. }
  4491. function to(time, withoutSuffix) {
  4492. if (
  4493. this.isValid() &&
  4494. ((isMoment(time) && time.isValid()) || createLocal(time).isValid())
  4495. ) {
  4496. return createDuration({ from: this, to: time })
  4497. .locale(this.locale())
  4498. .humanize(!withoutSuffix);
  4499. } else {
  4500. return this.localeData().invalidDate();
  4501. }
  4502. }
  4503. function toNow(withoutSuffix) {
  4504. return this.to(createLocal(), withoutSuffix);
  4505. }
  4506. // If passed a locale key, it will set the locale for this
  4507. // instance. Otherwise, it will return the locale configuration
  4508. // variables for this instance.
  4509. function locale(key) {
  4510. var newLocaleData;
  4511. if (key === undefined) {
  4512. return this._locale._abbr;
  4513. } else {
  4514. newLocaleData = getLocale(key);
  4515. if (newLocaleData != null) {
  4516. this._locale = newLocaleData;
  4517. }
  4518. return this;
  4519. }
  4520. }
  4521. var lang = deprecate(
  4522. 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
  4523. function (key) {
  4524. if (key === undefined) {
  4525. return this.localeData();
  4526. } else {
  4527. return this.locale(key);
  4528. }
  4529. }
  4530. );
  4531. function localeData() {
  4532. return this._locale;
  4533. }
  4534. var MS_PER_SECOND = 1000,
  4535. MS_PER_MINUTE = 60 * MS_PER_SECOND,
  4536. MS_PER_HOUR = 60 * MS_PER_MINUTE,
  4537. MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
  4538. // actual modulo - handles negative numbers (for dates before 1970):
  4539. function mod$1(dividend, divisor) {
  4540. return ((dividend % divisor) + divisor) % divisor;
  4541. }
  4542. function localStartOfDate(y, m, d) {
  4543. // the date constructor remaps years 0-99 to 1900-1999
  4544. if (y < 100 && y >= 0) {
  4545. // preserve leap years using a full 400 year cycle, then reset
  4546. return new Date(y + 400, m, d) - MS_PER_400_YEARS;
  4547. } else {
  4548. return new Date(y, m, d).valueOf();
  4549. }
  4550. }
  4551. function utcStartOfDate(y, m, d) {
  4552. // Date.UTC remaps years 0-99 to 1900-1999
  4553. if (y < 100 && y >= 0) {
  4554. // preserve leap years using a full 400 year cycle, then reset
  4555. return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
  4556. } else {
  4557. return Date.UTC(y, m, d);
  4558. }
  4559. }
  4560. function startOf(units) {
  4561. var time, startOfDate;
  4562. units = normalizeUnits(units);
  4563. if (units === undefined || units === 'millisecond' || !this.isValid()) {
  4564. return this;
  4565. }
  4566. startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
  4567. switch (units) {
  4568. case 'year':
  4569. time = startOfDate(this.year(), 0, 1);
  4570. break;
  4571. case 'quarter':
  4572. time = startOfDate(
  4573. this.year(),
  4574. this.month() - (this.month() % 3),
  4575. 1
  4576. );
  4577. break;
  4578. case 'month':
  4579. time = startOfDate(this.year(), this.month(), 1);
  4580. break;
  4581. case 'week':
  4582. time = startOfDate(
  4583. this.year(),
  4584. this.month(),
  4585. this.date() - this.weekday()
  4586. );
  4587. break;
  4588. case 'isoWeek':
  4589. time = startOfDate(
  4590. this.year(),
  4591. this.month(),
  4592. this.date() - (this.isoWeekday() - 1)
  4593. );
  4594. break;
  4595. case 'day':
  4596. case 'date':
  4597. time = startOfDate(this.year(), this.month(), this.date());
  4598. break;
  4599. case 'hour':
  4600. time = this._d.valueOf();
  4601. time -= mod$1(
  4602. time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
  4603. MS_PER_HOUR
  4604. );
  4605. break;
  4606. case 'minute':
  4607. time = this._d.valueOf();
  4608. time -= mod$1(time, MS_PER_MINUTE);
  4609. break;
  4610. case 'second':
  4611. time = this._d.valueOf();
  4612. time -= mod$1(time, MS_PER_SECOND);
  4613. break;
  4614. }
  4615. this._d.setTime(time);
  4616. hooks.updateOffset(this, true);
  4617. return this;
  4618. }
  4619. function endOf(units) {
  4620. var time, startOfDate;
  4621. units = normalizeUnits(units);
  4622. if (units === undefined || units === 'millisecond' || !this.isValid()) {
  4623. return this;
  4624. }
  4625. startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
  4626. switch (units) {
  4627. case 'year':
  4628. time = startOfDate(this.year() + 1, 0, 1) - 1;
  4629. break;
  4630. case 'quarter':
  4631. time =
  4632. startOfDate(
  4633. this.year(),
  4634. this.month() - (this.month() % 3) + 3,
  4635. 1
  4636. ) - 1;
  4637. break;
  4638. case 'month':
  4639. time = startOfDate(this.year(), this.month() + 1, 1) - 1;
  4640. break;
  4641. case 'week':
  4642. time =
  4643. startOfDate(
  4644. this.year(),
  4645. this.month(),
  4646. this.date() - this.weekday() + 7
  4647. ) - 1;
  4648. break;
  4649. case 'isoWeek':
  4650. time =
  4651. startOfDate(
  4652. this.year(),
  4653. this.month(),
  4654. this.date() - (this.isoWeekday() - 1) + 7
  4655. ) - 1;
  4656. break;
  4657. case 'day':
  4658. case 'date':
  4659. time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
  4660. break;
  4661. case 'hour':
  4662. time = this._d.valueOf();
  4663. time +=
  4664. MS_PER_HOUR -
  4665. mod$1(
  4666. time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
  4667. MS_PER_HOUR
  4668. ) -
  4669. 1;
  4670. break;
  4671. case 'minute':
  4672. time = this._d.valueOf();
  4673. time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
  4674. break;
  4675. case 'second':
  4676. time = this._d.valueOf();
  4677. time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
  4678. break;
  4679. }
  4680. this._d.setTime(time);
  4681. hooks.updateOffset(this, true);
  4682. return this;
  4683. }
  4684. function valueOf() {
  4685. return this._d.valueOf() - (this._offset || 0) * 60000;
  4686. }
  4687. function unix() {
  4688. return Math.floor(this.valueOf() / 1000);
  4689. }
  4690. function toDate() {
  4691. return new Date(this.valueOf());
  4692. }
  4693. function toArray() {
  4694. var m = this;
  4695. return [
  4696. m.year(),
  4697. m.month(),
  4698. m.date(),
  4699. m.hour(),
  4700. m.minute(),
  4701. m.second(),
  4702. m.millisecond(),
  4703. ];
  4704. }
  4705. function toObject() {
  4706. var m = this;
  4707. return {
  4708. years: m.year(),
  4709. months: m.month(),
  4710. date: m.date(),
  4711. hours: m.hours(),
  4712. minutes: m.minutes(),
  4713. seconds: m.seconds(),
  4714. milliseconds: m.milliseconds(),
  4715. };
  4716. }
  4717. function toJSON() {
  4718. // new Date(NaN).toJSON() === null
  4719. return this.isValid() ? this.toISOString() : null;
  4720. }
  4721. function isValid$2() {
  4722. return isValid(this);
  4723. }
  4724. function parsingFlags() {
  4725. return extend({}, getParsingFlags(this));
  4726. }
  4727. function invalidAt() {
  4728. return getParsingFlags(this).overflow;
  4729. }
  4730. function creationData() {
  4731. return {
  4732. input: this._i,
  4733. format: this._f,
  4734. locale: this._locale,
  4735. isUTC: this._isUTC,
  4736. strict: this._strict,
  4737. };
  4738. }
  4739. addFormatToken('N', 0, 0, 'eraAbbr');
  4740. addFormatToken('NN', 0, 0, 'eraAbbr');
  4741. addFormatToken('NNN', 0, 0, 'eraAbbr');
  4742. addFormatToken('NNNN', 0, 0, 'eraName');
  4743. addFormatToken('NNNNN', 0, 0, 'eraNarrow');
  4744. addFormatToken('y', ['y', 1], 'yo', 'eraYear');
  4745. addFormatToken('y', ['yy', 2], 0, 'eraYear');
  4746. addFormatToken('y', ['yyy', 3], 0, 'eraYear');
  4747. addFormatToken('y', ['yyyy', 4], 0, 'eraYear');
  4748. addRegexToken('N', matchEraAbbr);
  4749. addRegexToken('NN', matchEraAbbr);
  4750. addRegexToken('NNN', matchEraAbbr);
  4751. addRegexToken('NNNN', matchEraName);
  4752. addRegexToken('NNNNN', matchEraNarrow);
  4753. addParseToken(
  4754. ['N', 'NN', 'NNN', 'NNNN', 'NNNNN'],
  4755. function (input, array, config, token) {
  4756. var era = config._locale.erasParse(input, token, config._strict);
  4757. if (era) {
  4758. getParsingFlags(config).era = era;
  4759. } else {
  4760. getParsingFlags(config).invalidEra = input;
  4761. }
  4762. }
  4763. );
  4764. addRegexToken('y', matchUnsigned);
  4765. addRegexToken('yy', matchUnsigned);
  4766. addRegexToken('yyy', matchUnsigned);
  4767. addRegexToken('yyyy', matchUnsigned);
  4768. addRegexToken('yo', matchEraYearOrdinal);
  4769. addParseToken(['y', 'yy', 'yyy', 'yyyy'], YEAR);
  4770. addParseToken(['yo'], function (input, array, config, token) {
  4771. var match;
  4772. if (config._locale._eraYearOrdinalRegex) {
  4773. match = input.match(config._locale._eraYearOrdinalRegex);
  4774. }
  4775. if (config._locale.eraYearOrdinalParse) {
  4776. array[YEAR] = config._locale.eraYearOrdinalParse(input, match);
  4777. } else {
  4778. array[YEAR] = parseInt(input, 10);
  4779. }
  4780. });
  4781. function localeEras(m, format) {
  4782. var i,
  4783. l,
  4784. date,
  4785. eras = this._eras || getLocale('en')._eras;
  4786. for (i = 0, l = eras.length; i < l; ++i) {
  4787. switch (typeof eras[i].since) {
  4788. case 'string':
  4789. // truncate time
  4790. date = hooks(eras[i].since).startOf('day');
  4791. eras[i].since = date.valueOf();
  4792. break;
  4793. }
  4794. switch (typeof eras[i].until) {
  4795. case 'undefined':
  4796. eras[i].until = +Infinity;
  4797. break;
  4798. case 'string':
  4799. // truncate time
  4800. date = hooks(eras[i].until).startOf('day').valueOf();
  4801. eras[i].until = date.valueOf();
  4802. break;
  4803. }
  4804. }
  4805. return eras;
  4806. }
  4807. function localeErasParse(eraName, format, strict) {
  4808. var i,
  4809. l,
  4810. eras = this.eras(),
  4811. name,
  4812. abbr,
  4813. narrow;
  4814. eraName = eraName.toUpperCase();
  4815. for (i = 0, l = eras.length; i < l; ++i) {
  4816. name = eras[i].name.toUpperCase();
  4817. abbr = eras[i].abbr.toUpperCase();
  4818. narrow = eras[i].narrow.toUpperCase();
  4819. if (strict) {
  4820. switch (format) {
  4821. case 'N':
  4822. case 'NN':
  4823. case 'NNN':
  4824. if (abbr === eraName) {
  4825. return eras[i];
  4826. }
  4827. break;
  4828. case 'NNNN':
  4829. if (name === eraName) {
  4830. return eras[i];
  4831. }
  4832. break;
  4833. case 'NNNNN':
  4834. if (narrow === eraName) {
  4835. return eras[i];
  4836. }
  4837. break;
  4838. }
  4839. } else if ([name, abbr, narrow].indexOf(eraName) >= 0) {
  4840. return eras[i];
  4841. }
  4842. }
  4843. }
  4844. function localeErasConvertYear(era, year) {
  4845. var dir = era.since <= era.until ? +1 : -1;
  4846. if (year === undefined) {
  4847. return hooks(era.since).year();
  4848. } else {
  4849. return hooks(era.since).year() + (year - era.offset) * dir;
  4850. }
  4851. }
  4852. function getEraName() {
  4853. var i,
  4854. l,
  4855. val,
  4856. eras = this.localeData().eras();
  4857. for (i = 0, l = eras.length; i < l; ++i) {
  4858. // truncate time
  4859. val = this.clone().startOf('day').valueOf();
  4860. if (eras[i].since <= val && val <= eras[i].until) {
  4861. return eras[i].name;
  4862. }
  4863. if (eras[i].until <= val && val <= eras[i].since) {
  4864. return eras[i].name;
  4865. }
  4866. }
  4867. return '';
  4868. }
  4869. function getEraNarrow() {
  4870. var i,
  4871. l,
  4872. val,
  4873. eras = this.localeData().eras();
  4874. for (i = 0, l = eras.length; i < l; ++i) {
  4875. // truncate time
  4876. val = this.clone().startOf('day').valueOf();
  4877. if (eras[i].since <= val && val <= eras[i].until) {
  4878. return eras[i].narrow;
  4879. }
  4880. if (eras[i].until <= val && val <= eras[i].since) {
  4881. return eras[i].narrow;
  4882. }
  4883. }
  4884. return '';
  4885. }
  4886. function getEraAbbr() {
  4887. var i,
  4888. l,
  4889. val,
  4890. eras = this.localeData().eras();
  4891. for (i = 0, l = eras.length; i < l; ++i) {
  4892. // truncate time
  4893. val = this.clone().startOf('day').valueOf();
  4894. if (eras[i].since <= val && val <= eras[i].until) {
  4895. return eras[i].abbr;
  4896. }
  4897. if (eras[i].until <= val && val <= eras[i].since) {
  4898. return eras[i].abbr;
  4899. }
  4900. }
  4901. return '';
  4902. }
  4903. function getEraYear() {
  4904. var i,
  4905. l,
  4906. dir,
  4907. val,
  4908. eras = this.localeData().eras();
  4909. for (i = 0, l = eras.length; i < l; ++i) {
  4910. dir = eras[i].since <= eras[i].until ? +1 : -1;
  4911. // truncate time
  4912. val = this.clone().startOf('day').valueOf();
  4913. if (
  4914. (eras[i].since <= val && val <= eras[i].until) ||
  4915. (eras[i].until <= val && val <= eras[i].since)
  4916. ) {
  4917. return (
  4918. (this.year() - hooks(eras[i].since).year()) * dir +
  4919. eras[i].offset
  4920. );
  4921. }
  4922. }
  4923. return this.year();
  4924. }
  4925. function erasNameRegex(isStrict) {
  4926. if (!hasOwnProp(this, '_erasNameRegex')) {
  4927. computeErasParse.call(this);
  4928. }
  4929. return isStrict ? this._erasNameRegex : this._erasRegex;
  4930. }
  4931. function erasAbbrRegex(isStrict) {
  4932. if (!hasOwnProp(this, '_erasAbbrRegex')) {
  4933. computeErasParse.call(this);
  4934. }
  4935. return isStrict ? this._erasAbbrRegex : this._erasRegex;
  4936. }
  4937. function erasNarrowRegex(isStrict) {
  4938. if (!hasOwnProp(this, '_erasNarrowRegex')) {
  4939. computeErasParse.call(this);
  4940. }
  4941. return isStrict ? this._erasNarrowRegex : this._erasRegex;
  4942. }
  4943. function matchEraAbbr(isStrict, locale) {
  4944. return locale.erasAbbrRegex(isStrict);
  4945. }
  4946. function matchEraName(isStrict, locale) {
  4947. return locale.erasNameRegex(isStrict);
  4948. }
  4949. function matchEraNarrow(isStrict, locale) {
  4950. return locale.erasNarrowRegex(isStrict);
  4951. }
  4952. function matchEraYearOrdinal(isStrict, locale) {
  4953. return locale._eraYearOrdinalRegex || matchUnsigned;
  4954. }
  4955. function computeErasParse() {
  4956. var abbrPieces = [],
  4957. namePieces = [],
  4958. narrowPieces = [],
  4959. mixedPieces = [],
  4960. i,
  4961. l,
  4962. eras = this.eras();
  4963. for (i = 0, l = eras.length; i < l; ++i) {
  4964. namePieces.push(regexEscape(eras[i].name));
  4965. abbrPieces.push(regexEscape(eras[i].abbr));
  4966. narrowPieces.push(regexEscape(eras[i].narrow));
  4967. mixedPieces.push(regexEscape(eras[i].name));
  4968. mixedPieces.push(regexEscape(eras[i].abbr));
  4969. mixedPieces.push(regexEscape(eras[i].narrow));
  4970. }
  4971. this._erasRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  4972. this._erasNameRegex = new RegExp('^(' + namePieces.join('|') + ')', 'i');
  4973. this._erasAbbrRegex = new RegExp('^(' + abbrPieces.join('|') + ')', 'i');
  4974. this._erasNarrowRegex = new RegExp(
  4975. '^(' + narrowPieces.join('|') + ')',
  4976. 'i'
  4977. );
  4978. }
  4979. // FORMATTING
  4980. addFormatToken(0, ['gg', 2], 0, function () {
  4981. return this.weekYear() % 100;
  4982. });
  4983. addFormatToken(0, ['GG', 2], 0, function () {
  4984. return this.isoWeekYear() % 100;
  4985. });
  4986. function addWeekYearFormatToken(token, getter) {
  4987. addFormatToken(0, [token, token.length], 0, getter);
  4988. }
  4989. addWeekYearFormatToken('gggg', 'weekYear');
  4990. addWeekYearFormatToken('ggggg', 'weekYear');
  4991. addWeekYearFormatToken('GGGG', 'isoWeekYear');
  4992. addWeekYearFormatToken('GGGGG', 'isoWeekYear');
  4993. // ALIASES
  4994. addUnitAlias('weekYear', 'gg');
  4995. addUnitAlias('isoWeekYear', 'GG');
  4996. // PRIORITY
  4997. addUnitPriority('weekYear', 1);
  4998. addUnitPriority('isoWeekYear', 1);
  4999. // PARSING
  5000. addRegexToken('G', matchSigned);
  5001. addRegexToken('g', matchSigned);
  5002. addRegexToken('GG', match1to2, match2);
  5003. addRegexToken('gg', match1to2, match2);
  5004. addRegexToken('GGGG', match1to4, match4);
  5005. addRegexToken('gggg', match1to4, match4);
  5006. addRegexToken('GGGGG', match1to6, match6);
  5007. addRegexToken('ggggg', match1to6, match6);
  5008. addWeekParseToken(
  5009. ['gggg', 'ggggg', 'GGGG', 'GGGGG'],
  5010. function (input, week, config, token) {
  5011. week[token.substr(0, 2)] = toInt(input);
  5012. }
  5013. );
  5014. addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
  5015. week[token] = hooks.parseTwoDigitYear(input);
  5016. });
  5017. // MOMENTS
  5018. function getSetWeekYear(input) {
  5019. return getSetWeekYearHelper.call(
  5020. this,
  5021. input,
  5022. this.week(),
  5023. this.weekday(),
  5024. this.localeData()._week.dow,
  5025. this.localeData()._week.doy
  5026. );
  5027. }
  5028. function getSetISOWeekYear(input) {
  5029. return getSetWeekYearHelper.call(
  5030. this,
  5031. input,
  5032. this.isoWeek(),
  5033. this.isoWeekday(),
  5034. 1,
  5035. 4
  5036. );
  5037. }
  5038. function getISOWeeksInYear() {
  5039. return weeksInYear(this.year(), 1, 4);
  5040. }
  5041. function getISOWeeksInISOWeekYear() {
  5042. return weeksInYear(this.isoWeekYear(), 1, 4);
  5043. }
  5044. function getWeeksInYear() {
  5045. var weekInfo = this.localeData()._week;
  5046. return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
  5047. }
  5048. function getWeeksInWeekYear() {
  5049. var weekInfo = this.localeData()._week;
  5050. return weeksInYear(this.weekYear(), weekInfo.dow, weekInfo.doy);
  5051. }
  5052. function getSetWeekYearHelper(input, week, weekday, dow, doy) {
  5053. var weeksTarget;
  5054. if (input == null) {
  5055. return weekOfYear(this, dow, doy).year;
  5056. } else {
  5057. weeksTarget = weeksInYear(input, dow, doy);
  5058. if (week > weeksTarget) {
  5059. week = weeksTarget;
  5060. }
  5061. return setWeekAll.call(this, input, week, weekday, dow, doy);
  5062. }
  5063. }
  5064. function setWeekAll(weekYear, week, weekday, dow, doy) {
  5065. var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
  5066. date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
  5067. this.year(date.getUTCFullYear());
  5068. this.month(date.getUTCMonth());
  5069. this.date(date.getUTCDate());
  5070. return this;
  5071. }
  5072. // FORMATTING
  5073. addFormatToken('Q', 0, 'Qo', 'quarter');
  5074. // ALIASES
  5075. addUnitAlias('quarter', 'Q');
  5076. // PRIORITY
  5077. addUnitPriority('quarter', 7);
  5078. // PARSING
  5079. addRegexToken('Q', match1);
  5080. addParseToken('Q', function (input, array) {
  5081. array[MONTH] = (toInt(input) - 1) * 3;
  5082. });
  5083. // MOMENTS
  5084. function getSetQuarter(input) {
  5085. return input == null
  5086. ? Math.ceil((this.month() + 1) / 3)
  5087. : this.month((input - 1) * 3 + (this.month() % 3));
  5088. }
  5089. // FORMATTING
  5090. addFormatToken('D', ['DD', 2], 'Do', 'date');
  5091. // ALIASES
  5092. addUnitAlias('date', 'D');
  5093. // PRIORITY
  5094. addUnitPriority('date', 9);
  5095. // PARSING
  5096. addRegexToken('D', match1to2);
  5097. addRegexToken('DD', match1to2, match2);
  5098. addRegexToken('Do', function (isStrict, locale) {
  5099. // TODO: Remove "ordinalParse" fallback in next major release.
  5100. return isStrict
  5101. ? locale._dayOfMonthOrdinalParse || locale._ordinalParse
  5102. : locale._dayOfMonthOrdinalParseLenient;
  5103. });
  5104. addParseToken(['D', 'DD'], DATE);
  5105. addParseToken('Do', function (input, array) {
  5106. array[DATE] = toInt(input.match(match1to2)[0]);
  5107. });
  5108. // MOMENTS
  5109. var getSetDayOfMonth = makeGetSet('Date', true);
  5110. // FORMATTING
  5111. addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
  5112. // ALIASES
  5113. addUnitAlias('dayOfYear', 'DDD');
  5114. // PRIORITY
  5115. addUnitPriority('dayOfYear', 4);
  5116. // PARSING
  5117. addRegexToken('DDD', match1to3);
  5118. addRegexToken('DDDD', match3);
  5119. addParseToken(['DDD', 'DDDD'], function (input, array, config) {
  5120. config._dayOfYear = toInt(input);
  5121. });
  5122. // HELPERS
  5123. // MOMENTS
  5124. function getSetDayOfYear(input) {
  5125. var dayOfYear =
  5126. Math.round(
  5127. (this.clone().startOf('day') - this.clone().startOf('year')) / 864e5
  5128. ) + 1;
  5129. return input == null ? dayOfYear : this.add(input - dayOfYear, 'd');
  5130. }
  5131. // FORMATTING
  5132. addFormatToken('m', ['mm', 2], 0, 'minute');
  5133. // ALIASES
  5134. addUnitAlias('minute', 'm');
  5135. // PRIORITY
  5136. addUnitPriority('minute', 14);
  5137. // PARSING
  5138. addRegexToken('m', match1to2);
  5139. addRegexToken('mm', match1to2, match2);
  5140. addParseToken(['m', 'mm'], MINUTE);
  5141. // MOMENTS
  5142. var getSetMinute = makeGetSet('Minutes', false);
  5143. // FORMATTING
  5144. addFormatToken('s', ['ss', 2], 0, 'second');
  5145. // ALIASES
  5146. addUnitAlias('second', 's');
  5147. // PRIORITY
  5148. addUnitPriority('second', 15);
  5149. // PARSING
  5150. addRegexToken('s', match1to2);
  5151. addRegexToken('ss', match1to2, match2);
  5152. addParseToken(['s', 'ss'], SECOND);
  5153. // MOMENTS
  5154. var getSetSecond = makeGetSet('Seconds', false);
  5155. // FORMATTING
  5156. addFormatToken('S', 0, 0, function () {
  5157. return ~~(this.millisecond() / 100);
  5158. });
  5159. addFormatToken(0, ['SS', 2], 0, function () {
  5160. return ~~(this.millisecond() / 10);
  5161. });
  5162. addFormatToken(0, ['SSS', 3], 0, 'millisecond');
  5163. addFormatToken(0, ['SSSS', 4], 0, function () {
  5164. return this.millisecond() * 10;
  5165. });
  5166. addFormatToken(0, ['SSSSS', 5], 0, function () {
  5167. return this.millisecond() * 100;
  5168. });
  5169. addFormatToken(0, ['SSSSSS', 6], 0, function () {
  5170. return this.millisecond() * 1000;
  5171. });
  5172. addFormatToken(0, ['SSSSSSS', 7], 0, function () {
  5173. return this.millisecond() * 10000;
  5174. });
  5175. addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
  5176. return this.millisecond() * 100000;
  5177. });
  5178. addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
  5179. return this.millisecond() * 1000000;
  5180. });
  5181. // ALIASES
  5182. addUnitAlias('millisecond', 'ms');
  5183. // PRIORITY
  5184. addUnitPriority('millisecond', 16);
  5185. // PARSING
  5186. addRegexToken('S', match1to3, match1);
  5187. addRegexToken('SS', match1to3, match2);
  5188. addRegexToken('SSS', match1to3, match3);
  5189. var token, getSetMillisecond;
  5190. for (token = 'SSSS'; token.length <= 9; token += 'S') {
  5191. addRegexToken(token, matchUnsigned);
  5192. }
  5193. function parseMs(input, array) {
  5194. array[MILLISECOND] = toInt(('0.' + input) * 1000);
  5195. }
  5196. for (token = 'S'; token.length <= 9; token += 'S') {
  5197. addParseToken(token, parseMs);
  5198. }
  5199. getSetMillisecond = makeGetSet('Milliseconds', false);
  5200. // FORMATTING
  5201. addFormatToken('z', 0, 0, 'zoneAbbr');
  5202. addFormatToken('zz', 0, 0, 'zoneName');
  5203. // MOMENTS
  5204. function getZoneAbbr() {
  5205. return this._isUTC ? 'UTC' : '';
  5206. }
  5207. function getZoneName() {
  5208. return this._isUTC ? 'Coordinated Universal Time' : '';
  5209. }
  5210. var proto = Moment.prototype;
  5211. proto.add = add;
  5212. proto.calendar = calendar$1;
  5213. proto.clone = clone;
  5214. proto.diff = diff;
  5215. proto.endOf = endOf;
  5216. proto.format = format;
  5217. proto.from = from;
  5218. proto.fromNow = fromNow;
  5219. proto.to = to;
  5220. proto.toNow = toNow;
  5221. proto.get = stringGet;
  5222. proto.invalidAt = invalidAt;
  5223. proto.isAfter = isAfter;
  5224. proto.isBefore = isBefore;
  5225. proto.isBetween = isBetween;
  5226. proto.isSame = isSame;
  5227. proto.isSameOrAfter = isSameOrAfter;
  5228. proto.isSameOrBefore = isSameOrBefore;
  5229. proto.isValid = isValid$2;
  5230. proto.lang = lang;
  5231. proto.locale = locale;
  5232. proto.localeData = localeData;
  5233. proto.max = prototypeMax;
  5234. proto.min = prototypeMin;
  5235. proto.parsingFlags = parsingFlags;
  5236. proto.set = stringSet;
  5237. proto.startOf = startOf;
  5238. proto.subtract = subtract;
  5239. proto.toArray = toArray;
  5240. proto.toObject = toObject;
  5241. proto.toDate = toDate;
  5242. proto.toISOString = toISOString;
  5243. proto.inspect = inspect;
  5244. if (typeof Symbol !== 'undefined' && Symbol.for != null) {
  5245. proto[Symbol.for('nodejs.util.inspect.custom')] = function () {
  5246. return 'Moment<' + this.format() + '>';
  5247. };
  5248. }
  5249. proto.toJSON = toJSON;
  5250. proto.toString = toString;
  5251. proto.unix = unix;
  5252. proto.valueOf = valueOf;
  5253. proto.creationData = creationData;
  5254. proto.eraName = getEraName;
  5255. proto.eraNarrow = getEraNarrow;
  5256. proto.eraAbbr = getEraAbbr;
  5257. proto.eraYear = getEraYear;
  5258. proto.year = getSetYear;
  5259. proto.isLeapYear = getIsLeapYear;
  5260. proto.weekYear = getSetWeekYear;
  5261. proto.isoWeekYear = getSetISOWeekYear;
  5262. proto.quarter = proto.quarters = getSetQuarter;
  5263. proto.month = getSetMonth;
  5264. proto.daysInMonth = getDaysInMonth;
  5265. proto.week = proto.weeks = getSetWeek;
  5266. proto.isoWeek = proto.isoWeeks = getSetISOWeek;
  5267. proto.weeksInYear = getWeeksInYear;
  5268. proto.weeksInWeekYear = getWeeksInWeekYear;
  5269. proto.isoWeeksInYear = getISOWeeksInYear;
  5270. proto.isoWeeksInISOWeekYear = getISOWeeksInISOWeekYear;
  5271. proto.date = getSetDayOfMonth;
  5272. proto.day = proto.days = getSetDayOfWeek;
  5273. proto.weekday = getSetLocaleDayOfWeek;
  5274. proto.isoWeekday = getSetISODayOfWeek;
  5275. proto.dayOfYear = getSetDayOfYear;
  5276. proto.hour = proto.hours = getSetHour;
  5277. proto.minute = proto.minutes = getSetMinute;
  5278. proto.second = proto.seconds = getSetSecond;
  5279. proto.millisecond = proto.milliseconds = getSetMillisecond;
  5280. proto.utcOffset = getSetOffset;
  5281. proto.utc = setOffsetToUTC;
  5282. proto.local = setOffsetToLocal;
  5283. proto.parseZone = setOffsetToParsedOffset;
  5284. proto.hasAlignedHourOffset = hasAlignedHourOffset;
  5285. proto.isDST = isDaylightSavingTime;
  5286. proto.isLocal = isLocal;
  5287. proto.isUtcOffset = isUtcOffset;
  5288. proto.isUtc = isUtc;
  5289. proto.isUTC = isUtc;
  5290. proto.zoneAbbr = getZoneAbbr;
  5291. proto.zoneName = getZoneName;
  5292. proto.dates = deprecate(
  5293. 'dates accessor is deprecated. Use date instead.',
  5294. getSetDayOfMonth
  5295. );
  5296. proto.months = deprecate(
  5297. 'months accessor is deprecated. Use month instead',
  5298. getSetMonth
  5299. );
  5300. proto.years = deprecate(
  5301. 'years accessor is deprecated. Use year instead',
  5302. getSetYear
  5303. );
  5304. proto.zone = deprecate(
  5305. 'moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/',
  5306. getSetZone
  5307. );
  5308. proto.isDSTShifted = deprecate(
  5309. 'isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information',
  5310. isDaylightSavingTimeShifted
  5311. );
  5312. function createUnix(input) {
  5313. return createLocal(input * 1000);
  5314. }
  5315. function createInZone() {
  5316. return createLocal.apply(null, arguments).parseZone();
  5317. }
  5318. function preParsePostFormat(string) {
  5319. return string;
  5320. }
  5321. var proto$1 = Locale.prototype;
  5322. proto$1.calendar = calendar;
  5323. proto$1.longDateFormat = longDateFormat;
  5324. proto$1.invalidDate = invalidDate;
  5325. proto$1.ordinal = ordinal;
  5326. proto$1.preparse = preParsePostFormat;
  5327. proto$1.postformat = preParsePostFormat;
  5328. proto$1.relativeTime = relativeTime;
  5329. proto$1.pastFuture = pastFuture;
  5330. proto$1.set = set;
  5331. proto$1.eras = localeEras;
  5332. proto$1.erasParse = localeErasParse;
  5333. proto$1.erasConvertYear = localeErasConvertYear;
  5334. proto$1.erasAbbrRegex = erasAbbrRegex;
  5335. proto$1.erasNameRegex = erasNameRegex;
  5336. proto$1.erasNarrowRegex = erasNarrowRegex;
  5337. proto$1.months = localeMonths;
  5338. proto$1.monthsShort = localeMonthsShort;
  5339. proto$1.monthsParse = localeMonthsParse;
  5340. proto$1.monthsRegex = monthsRegex;
  5341. proto$1.monthsShortRegex = monthsShortRegex;
  5342. proto$1.week = localeWeek;
  5343. proto$1.firstDayOfYear = localeFirstDayOfYear;
  5344. proto$1.firstDayOfWeek = localeFirstDayOfWeek;
  5345. proto$1.weekdays = localeWeekdays;
  5346. proto$1.weekdaysMin = localeWeekdaysMin;
  5347. proto$1.weekdaysShort = localeWeekdaysShort;
  5348. proto$1.weekdaysParse = localeWeekdaysParse;
  5349. proto$1.weekdaysRegex = weekdaysRegex;
  5350. proto$1.weekdaysShortRegex = weekdaysShortRegex;
  5351. proto$1.weekdaysMinRegex = weekdaysMinRegex;
  5352. proto$1.isPM = localeIsPM;
  5353. proto$1.meridiem = localeMeridiem;
  5354. function get$1(format, index, field, setter) {
  5355. var locale = getLocale(),
  5356. utc = createUTC().set(setter, index);
  5357. return locale[field](utc, format);
  5358. }
  5359. function listMonthsImpl(format, index, field) {
  5360. if (isNumber(format)) {
  5361. index = format;
  5362. format = undefined;
  5363. }
  5364. format = format || '';
  5365. if (index != null) {
  5366. return get$1(format, index, field, 'month');
  5367. }
  5368. var i,
  5369. out = [];
  5370. for (i = 0; i < 12; i++) {
  5371. out[i] = get$1(format, i, field, 'month');
  5372. }
  5373. return out;
  5374. }
  5375. // ()
  5376. // (5)
  5377. // (fmt, 5)
  5378. // (fmt)
  5379. // (true)
  5380. // (true, 5)
  5381. // (true, fmt, 5)
  5382. // (true, fmt)
  5383. function listWeekdaysImpl(localeSorted, format, index, field) {
  5384. if (typeof localeSorted === 'boolean') {
  5385. if (isNumber(format)) {
  5386. index = format;
  5387. format = undefined;
  5388. }
  5389. format = format || '';
  5390. } else {
  5391. format = localeSorted;
  5392. index = format;
  5393. localeSorted = false;
  5394. if (isNumber(format)) {
  5395. index = format;
  5396. format = undefined;
  5397. }
  5398. format = format || '';
  5399. }
  5400. var locale = getLocale(),
  5401. shift = localeSorted ? locale._week.dow : 0,
  5402. i,
  5403. out = [];
  5404. if (index != null) {
  5405. return get$1(format, (index + shift) % 7, field, 'day');
  5406. }
  5407. for (i = 0; i < 7; i++) {
  5408. out[i] = get$1(format, (i + shift) % 7, field, 'day');
  5409. }
  5410. return out;
  5411. }
  5412. function listMonths(format, index) {
  5413. return listMonthsImpl(format, index, 'months');
  5414. }
  5415. function listMonthsShort(format, index) {
  5416. return listMonthsImpl(format, index, 'monthsShort');
  5417. }
  5418. function listWeekdays(localeSorted, format, index) {
  5419. return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
  5420. }
  5421. function listWeekdaysShort(localeSorted, format, index) {
  5422. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
  5423. }
  5424. function listWeekdaysMin(localeSorted, format, index) {
  5425. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
  5426. }
  5427. getSetGlobalLocale('en', {
  5428. eras: [
  5429. {
  5430. since: '0001-01-01',
  5431. until: +Infinity,
  5432. offset: 1,
  5433. name: 'Anno Domini',
  5434. narrow: 'AD',
  5435. abbr: 'AD',
  5436. },
  5437. {
  5438. since: '0000-12-31',
  5439. until: -Infinity,
  5440. offset: 1,
  5441. name: 'Before Christ',
  5442. narrow: 'BC',
  5443. abbr: 'BC',
  5444. },
  5445. ],
  5446. dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
  5447. ordinal: function (number) {
  5448. var b = number % 10,
  5449. output =
  5450. toInt((number % 100) / 10) === 1
  5451. ? 'th'
  5452. : b === 1
  5453. ? 'st'
  5454. : b === 2
  5455. ? 'nd'
  5456. : b === 3
  5457. ? 'rd'
  5458. : 'th';
  5459. return number + output;
  5460. },
  5461. });
  5462. // Side effect imports
  5463. hooks.lang = deprecate(
  5464. 'moment.lang is deprecated. Use moment.locale instead.',
  5465. getSetGlobalLocale
  5466. );
  5467. hooks.langData = deprecate(
  5468. 'moment.langData is deprecated. Use moment.localeData instead.',
  5469. getLocale
  5470. );
  5471. var mathAbs = Math.abs;
  5472. function abs() {
  5473. var data = this._data;
  5474. this._milliseconds = mathAbs(this._milliseconds);
  5475. this._days = mathAbs(this._days);
  5476. this._months = mathAbs(this._months);
  5477. data.milliseconds = mathAbs(data.milliseconds);
  5478. data.seconds = mathAbs(data.seconds);
  5479. data.minutes = mathAbs(data.minutes);
  5480. data.hours = mathAbs(data.hours);
  5481. data.months = mathAbs(data.months);
  5482. data.years = mathAbs(data.years);
  5483. return this;
  5484. }
  5485. function addSubtract$1(duration, input, value, direction) {
  5486. var other = createDuration(input, value);
  5487. duration._milliseconds += direction * other._milliseconds;
  5488. duration._days += direction * other._days;
  5489. duration._months += direction * other._months;
  5490. return duration._bubble();
  5491. }
  5492. // supports only 2.0-style add(1, 's') or add(duration)
  5493. function add$1(input, value) {
  5494. return addSubtract$1(this, input, value, 1);
  5495. }
  5496. // supports only 2.0-style subtract(1, 's') or subtract(duration)
  5497. function subtract$1(input, value) {
  5498. return addSubtract$1(this, input, value, -1);
  5499. }
  5500. function absCeil(number) {
  5501. if (number < 0) {
  5502. return Math.floor(number);
  5503. } else {
  5504. return Math.ceil(number);
  5505. }
  5506. }
  5507. function bubble() {
  5508. var milliseconds = this._milliseconds,
  5509. days = this._days,
  5510. months = this._months,
  5511. data = this._data,
  5512. seconds,
  5513. minutes,
  5514. hours,
  5515. years,
  5516. monthsFromDays;
  5517. // if we have a mix of positive and negative values, bubble down first
  5518. // check: https://github.com/moment/moment/issues/2166
  5519. if (
  5520. !(
  5521. (milliseconds >= 0 && days >= 0 && months >= 0) ||
  5522. (milliseconds <= 0 && days <= 0 && months <= 0)
  5523. )
  5524. ) {
  5525. milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
  5526. days = 0;
  5527. months = 0;
  5528. }
  5529. // The following code bubbles up values, see the tests for
  5530. // examples of what that means.
  5531. data.milliseconds = milliseconds % 1000;
  5532. seconds = absFloor(milliseconds / 1000);
  5533. data.seconds = seconds % 60;
  5534. minutes = absFloor(seconds / 60);
  5535. data.minutes = minutes % 60;
  5536. hours = absFloor(minutes / 60);
  5537. data.hours = hours % 24;
  5538. days += absFloor(hours / 24);
  5539. // convert days to months
  5540. monthsFromDays = absFloor(daysToMonths(days));
  5541. months += monthsFromDays;
  5542. days -= absCeil(monthsToDays(monthsFromDays));
  5543. // 12 months -> 1 year
  5544. years = absFloor(months / 12);
  5545. months %= 12;
  5546. data.days = days;
  5547. data.months = months;
  5548. data.years = years;
  5549. return this;
  5550. }
  5551. function daysToMonths(days) {
  5552. // 400 years have 146097 days (taking into account leap year rules)
  5553. // 400 years have 12 months === 4800
  5554. return (days * 4800) / 146097;
  5555. }
  5556. function monthsToDays(months) {
  5557. // the reverse of daysToMonths
  5558. return (months * 146097) / 4800;
  5559. }
  5560. function as(units) {
  5561. if (!this.isValid()) {
  5562. return NaN;
  5563. }
  5564. var days,
  5565. months,
  5566. milliseconds = this._milliseconds;
  5567. units = normalizeUnits(units);
  5568. if (units === 'month' || units === 'quarter' || units === 'year') {
  5569. days = this._days + milliseconds / 864e5;
  5570. months = this._months + daysToMonths(days);
  5571. switch (units) {
  5572. case 'month':
  5573. return months;
  5574. case 'quarter':
  5575. return months / 3;
  5576. case 'year':
  5577. return months / 12;
  5578. }
  5579. } else {
  5580. // handle milliseconds separately because of floating point math errors (issue #1867)
  5581. days = this._days + Math.round(monthsToDays(this._months));
  5582. switch (units) {
  5583. case 'week':
  5584. return days / 7 + milliseconds / 6048e5;
  5585. case 'day':
  5586. return days + milliseconds / 864e5;
  5587. case 'hour':
  5588. return days * 24 + milliseconds / 36e5;
  5589. case 'minute':
  5590. return days * 1440 + milliseconds / 6e4;
  5591. case 'second':
  5592. return days * 86400 + milliseconds / 1000;
  5593. // Math.floor prevents floating point math errors here
  5594. case 'millisecond':
  5595. return Math.floor(days * 864e5) + milliseconds;
  5596. default:
  5597. throw new Error('Unknown unit ' + units);
  5598. }
  5599. }
  5600. }
  5601. // TODO: Use this.as('ms')?
  5602. function valueOf$1() {
  5603. if (!this.isValid()) {
  5604. return NaN;
  5605. }
  5606. return (
  5607. this._milliseconds +
  5608. this._days * 864e5 +
  5609. (this._months % 12) * 2592e6 +
  5610. toInt(this._months / 12) * 31536e6
  5611. );
  5612. }
  5613. function makeAs(alias) {
  5614. return function () {
  5615. return this.as(alias);
  5616. };
  5617. }
  5618. var asMilliseconds = makeAs('ms'),
  5619. asSeconds = makeAs('s'),
  5620. asMinutes = makeAs('m'),
  5621. asHours = makeAs('h'),
  5622. asDays = makeAs('d'),
  5623. asWeeks = makeAs('w'),
  5624. asMonths = makeAs('M'),
  5625. asQuarters = makeAs('Q'),
  5626. asYears = makeAs('y');
  5627. function clone$1() {
  5628. return createDuration(this);
  5629. }
  5630. function get$2(units) {
  5631. units = normalizeUnits(units);
  5632. return this.isValid() ? this[units + 's']() : NaN;
  5633. }
  5634. function makeGetter(name) {
  5635. return function () {
  5636. return this.isValid() ? this._data[name] : NaN;
  5637. };
  5638. }
  5639. var milliseconds = makeGetter('milliseconds'),
  5640. seconds = makeGetter('seconds'),
  5641. minutes = makeGetter('minutes'),
  5642. hours = makeGetter('hours'),
  5643. days = makeGetter('days'),
  5644. months = makeGetter('months'),
  5645. years = makeGetter('years');
  5646. function weeks() {
  5647. return absFloor(this.days() / 7);
  5648. }
  5649. var round = Math.round,
  5650. thresholds = {
  5651. ss: 44, // a few seconds to seconds
  5652. s: 45, // seconds to minute
  5653. m: 45, // minutes to hour
  5654. h: 22, // hours to day
  5655. d: 26, // days to month/week
  5656. w: null, // weeks to month
  5657. M: 11, // months to year
  5658. };
  5659. // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
  5660. function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
  5661. return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
  5662. }
  5663. function relativeTime$1(posNegDuration, withoutSuffix, thresholds, locale) {
  5664. var duration = createDuration(posNegDuration).abs(),
  5665. seconds = round(duration.as('s')),
  5666. minutes = round(duration.as('m')),
  5667. hours = round(duration.as('h')),
  5668. days = round(duration.as('d')),
  5669. months = round(duration.as('M')),
  5670. weeks = round(duration.as('w')),
  5671. years = round(duration.as('y')),
  5672. a =
  5673. (seconds <= thresholds.ss && ['s', seconds]) ||
  5674. (seconds < thresholds.s && ['ss', seconds]) ||
  5675. (minutes <= 1 && ['m']) ||
  5676. (minutes < thresholds.m && ['mm', minutes]) ||
  5677. (hours <= 1 && ['h']) ||
  5678. (hours < thresholds.h && ['hh', hours]) ||
  5679. (days <= 1 && ['d']) ||
  5680. (days < thresholds.d && ['dd', days]);
  5681. if (thresholds.w != null) {
  5682. a =
  5683. a ||
  5684. (weeks <= 1 && ['w']) ||
  5685. (weeks < thresholds.w && ['ww', weeks]);
  5686. }
  5687. a = a ||
  5688. (months <= 1 && ['M']) ||
  5689. (months < thresholds.M && ['MM', months]) ||
  5690. (years <= 1 && ['y']) || ['yy', years];
  5691. a[2] = withoutSuffix;
  5692. a[3] = +posNegDuration > 0;
  5693. a[4] = locale;
  5694. return substituteTimeAgo.apply(null, a);
  5695. }
  5696. // This function allows you to set the rounding function for relative time strings
  5697. function getSetRelativeTimeRounding(roundingFunction) {
  5698. if (roundingFunction === undefined) {
  5699. return round;
  5700. }
  5701. if (typeof roundingFunction === 'function') {
  5702. round = roundingFunction;
  5703. return true;
  5704. }
  5705. return false;
  5706. }
  5707. // This function allows you to set a threshold for relative time strings
  5708. function getSetRelativeTimeThreshold(threshold, limit) {
  5709. if (thresholds[threshold] === undefined) {
  5710. return false;
  5711. }
  5712. if (limit === undefined) {
  5713. return thresholds[threshold];
  5714. }
  5715. thresholds[threshold] = limit;
  5716. if (threshold === 's') {
  5717. thresholds.ss = limit - 1;
  5718. }
  5719. return true;
  5720. }
  5721. function humanize(argWithSuffix, argThresholds) {
  5722. if (!this.isValid()) {
  5723. return this.localeData().invalidDate();
  5724. }
  5725. var withSuffix = false,
  5726. th = thresholds,
  5727. locale,
  5728. output;
  5729. if (typeof argWithSuffix === 'object') {
  5730. argThresholds = argWithSuffix;
  5731. argWithSuffix = false;
  5732. }
  5733. if (typeof argWithSuffix === 'boolean') {
  5734. withSuffix = argWithSuffix;
  5735. }
  5736. if (typeof argThresholds === 'object') {
  5737. th = Object.assign({}, thresholds, argThresholds);
  5738. if (argThresholds.s != null && argThresholds.ss == null) {
  5739. th.ss = argThresholds.s - 1;
  5740. }
  5741. }
  5742. locale = this.localeData();
  5743. output = relativeTime$1(this, !withSuffix, th, locale);
  5744. if (withSuffix) {
  5745. output = locale.pastFuture(+this, output);
  5746. }
  5747. return locale.postformat(output);
  5748. }
  5749. var abs$1 = Math.abs;
  5750. function sign(x) {
  5751. return (x > 0) - (x < 0) || +x;
  5752. }
  5753. function toISOString$1() {
  5754. // for ISO strings we do not use the normal bubbling rules:
  5755. // * milliseconds bubble up until they become hours
  5756. // * days do not bubble at all
  5757. // * months bubble up until they become years
  5758. // This is because there is no context-free conversion between hours and days
  5759. // (think of clock changes)
  5760. // and also not between days and months (28-31 days per month)
  5761. if (!this.isValid()) {
  5762. return this.localeData().invalidDate();
  5763. }
  5764. var seconds = abs$1(this._milliseconds) / 1000,
  5765. days = abs$1(this._days),
  5766. months = abs$1(this._months),
  5767. minutes,
  5768. hours,
  5769. years,
  5770. s,
  5771. total = this.asSeconds(),
  5772. totalSign,
  5773. ymSign,
  5774. daysSign,
  5775. hmsSign;
  5776. if (!total) {
  5777. // this is the same as C#'s (Noda) and python (isodate)...
  5778. // but not other JS (goog.date)
  5779. return 'P0D';
  5780. }
  5781. // 3600 seconds -> 60 minutes -> 1 hour
  5782. minutes = absFloor(seconds / 60);
  5783. hours = absFloor(minutes / 60);
  5784. seconds %= 60;
  5785. minutes %= 60;
  5786. // 12 months -> 1 year
  5787. years = absFloor(months / 12);
  5788. months %= 12;
  5789. // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
  5790. s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : '';
  5791. totalSign = total < 0 ? '-' : '';
  5792. ymSign = sign(this._months) !== sign(total) ? '-' : '';
  5793. daysSign = sign(this._days) !== sign(total) ? '-' : '';
  5794. hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : '';
  5795. return (
  5796. totalSign +
  5797. 'P' +
  5798. (years ? ymSign + years + 'Y' : '') +
  5799. (months ? ymSign + months + 'M' : '') +
  5800. (days ? daysSign + days + 'D' : '') +
  5801. (hours || minutes || seconds ? 'T' : '') +
  5802. (hours ? hmsSign + hours + 'H' : '') +
  5803. (minutes ? hmsSign + minutes + 'M' : '') +
  5804. (seconds ? hmsSign + s + 'S' : '')
  5805. );
  5806. }
  5807. var proto$2 = Duration.prototype;
  5808. proto$2.isValid = isValid$1;
  5809. proto$2.abs = abs;
  5810. proto$2.add = add$1;
  5811. proto$2.subtract = subtract$1;
  5812. proto$2.as = as;
  5813. proto$2.asMilliseconds = asMilliseconds;
  5814. proto$2.asSeconds = asSeconds;
  5815. proto$2.asMinutes = asMinutes;
  5816. proto$2.asHours = asHours;
  5817. proto$2.asDays = asDays;
  5818. proto$2.asWeeks = asWeeks;
  5819. proto$2.asMonths = asMonths;
  5820. proto$2.asQuarters = asQuarters;
  5821. proto$2.asYears = asYears;
  5822. proto$2.valueOf = valueOf$1;
  5823. proto$2._bubble = bubble;
  5824. proto$2.clone = clone$1;
  5825. proto$2.get = get$2;
  5826. proto$2.milliseconds = milliseconds;
  5827. proto$2.seconds = seconds;
  5828. proto$2.minutes = minutes;
  5829. proto$2.hours = hours;
  5830. proto$2.days = days;
  5831. proto$2.weeks = weeks;
  5832. proto$2.months = months;
  5833. proto$2.years = years;
  5834. proto$2.humanize = humanize;
  5835. proto$2.toISOString = toISOString$1;
  5836. proto$2.toString = toISOString$1;
  5837. proto$2.toJSON = toISOString$1;
  5838. proto$2.locale = locale;
  5839. proto$2.localeData = localeData;
  5840. proto$2.toIsoString = deprecate(
  5841. 'toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)',
  5842. toISOString$1
  5843. );
  5844. proto$2.lang = lang;
  5845. // FORMATTING
  5846. addFormatToken('X', 0, 0, 'unix');
  5847. addFormatToken('x', 0, 0, 'valueOf');
  5848. // PARSING
  5849. addRegexToken('x', matchSigned);
  5850. addRegexToken('X', matchTimestamp);
  5851. addParseToken('X', function (input, array, config) {
  5852. config._d = new Date(parseFloat(input) * 1000);
  5853. });
  5854. addParseToken('x', function (input, array, config) {
  5855. config._d = new Date(toInt(input));
  5856. });
  5857. //! moment.js
  5858. hooks.version = '2.29.4';
  5859. setHookCallback(createLocal);
  5860. hooks.fn = proto;
  5861. hooks.min = min;
  5862. hooks.max = max;
  5863. hooks.now = now;
  5864. hooks.utc = createUTC;
  5865. hooks.unix = createUnix;
  5866. hooks.months = listMonths;
  5867. hooks.isDate = isDate;
  5868. hooks.locale = getSetGlobalLocale;
  5869. hooks.invalid = createInvalid;
  5870. hooks.duration = createDuration;
  5871. hooks.isMoment = isMoment;
  5872. hooks.weekdays = listWeekdays;
  5873. hooks.parseZone = createInZone;
  5874. hooks.localeData = getLocale;
  5875. hooks.isDuration = isDuration;
  5876. hooks.monthsShort = listMonthsShort;
  5877. hooks.weekdaysMin = listWeekdaysMin;
  5878. hooks.defineLocale = defineLocale;
  5879. hooks.updateLocale = updateLocale;
  5880. hooks.locales = listLocales;
  5881. hooks.weekdaysShort = listWeekdaysShort;
  5882. hooks.normalizeUnits = normalizeUnits;
  5883. hooks.relativeTimeRounding = getSetRelativeTimeRounding;
  5884. hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
  5885. hooks.calendarFormat = getCalendarFormat;
  5886. hooks.prototype = proto;
  5887. // currently HTML5 input type only supports 24-hour formats
  5888. hooks.HTML5_FMT = {
  5889. DATETIME_LOCAL: 'YYYY-MM-DDTHH:mm', // <input type="datetime-local" />
  5890. DATETIME_LOCAL_SECONDS: 'YYYY-MM-DDTHH:mm:ss', // <input type="datetime-local" step="1" />
  5891. DATETIME_LOCAL_MS: 'YYYY-MM-DDTHH:mm:ss.SSS', // <input type="datetime-local" step="0.001" />
  5892. DATE: 'YYYY-MM-DD', // <input type="date" />
  5893. TIME: 'HH:mm', // <input type="time" />
  5894. TIME_SECONDS: 'HH:mm:ss', // <input type="time" step="1" />
  5895. TIME_MS: 'HH:mm:ss.SSS', // <input type="time" step="0.001" />
  5896. WEEK: 'GGGG-[W]WW', // <input type="week" />
  5897. MONTH: 'YYYY-MM', // <input type="month" />
  5898. };
  5899. return hooks;
  5900. })));
  5901. define('moment', ['moment/moment'], function (main) { return main; });
  5902. define('backend',['fast', 'template', 'moment'], function (Fast, Template, Moment) {
  5903. var Backend = {
  5904. api: {
  5905. sidebar: function (params) {
  5906. colorArr = ['red', 'green', 'yellow', 'blue', 'teal', 'orange', 'purple'];
  5907. $colorNums = colorArr.length;
  5908. badgeList = {};
  5909. $.each(params, function (k, v) {
  5910. $url = Fast.api.fixurl(k);
  5911. if ($.isArray(v)) {
  5912. $nums = typeof v[0] !== 'undefined' ? v[0] : 0;
  5913. $color = typeof v[1] !== 'undefined' ? v[1] : colorArr[(!isNaN($nums) ? $nums : $nums.length) % $colorNums];
  5914. $class = typeof v[2] !== 'undefined' ? v[2] : 'label';
  5915. } else {
  5916. $nums = v;
  5917. $color = colorArr[(!isNaN($nums) ? $nums : $nums.length) % $colorNums];
  5918. $class = 'label';
  5919. }
  5920. //必须nums大于0才显示
  5921. badgeList[$url] = $nums > 0 ? '<small class="' + $class + ' pull-right bg-' + $color + '">' + $nums + '</small>' : '';
  5922. });
  5923. $.each(badgeList, function (k, v) {
  5924. var anchor = top.window.$("li a[addtabs][url='" + k + "']");
  5925. if (anchor) {
  5926. top.window.$(".pull-right-container", anchor).html(v);
  5927. top.window.$(".nav-addtabs li a[node-id='" + anchor.attr("addtabs") + "'] .pull-right-container").html(v);
  5928. }
  5929. });
  5930. },
  5931. addtabs: function (url, title, icon) {
  5932. var dom = "a[url='{url}']"
  5933. var leftlink = top.window.$(dom.replace(/\{url\}/, url));
  5934. if (leftlink.length > 0) {
  5935. leftlink.trigger("click");
  5936. } else {
  5937. url = Fast.api.fixurl(url);
  5938. leftlink = top.window.$(dom.replace(/\{url\}/, url));
  5939. if (leftlink.length > 0) {
  5940. var event = leftlink.parent().hasClass("active") ? "dblclick" : "click";
  5941. leftlink.trigger(event);
  5942. } else {
  5943. var baseurl = url.substr(0, url.indexOf("?") > -1 ? url.indexOf("?") : url.length);
  5944. leftlink = top.window.$(dom.replace(/\{url\}/, baseurl));
  5945. //能找到相对地址
  5946. if (leftlink.length > 0) {
  5947. icon = typeof icon !== 'undefined' ? icon : leftlink.find("i").attr("class");
  5948. title = typeof title !== 'undefined' ? title : leftlink.find("span:first").text();
  5949. leftlink.trigger("fa.event.toggleitem");
  5950. }
  5951. var navnode = top.window.$(".nav-tabs ul li a[node-url='" + url + "']");
  5952. if (navnode.length > 0) {
  5953. navnode.trigger("click");
  5954. } else {
  5955. //追加新的tab
  5956. var id = Math.floor(new Date().valueOf() * Math.random());
  5957. icon = typeof icon !== 'undefined' ? icon : 'fa fa-circle-o';
  5958. title = typeof title !== 'undefined' ? title : '';
  5959. top.window.$("<a />").append('<i class="' + icon + '"></i> <span>' + title + '</span>').prop("href", url).attr({
  5960. url: url,
  5961. addtabs: id
  5962. }).addClass("hide").appendTo(top.window.document.body).trigger("click");
  5963. }
  5964. }
  5965. }
  5966. },
  5967. closetabs: function (url) {
  5968. if (typeof url === 'undefined') {
  5969. top.window.$("ul.nav-addtabs li.active .close-tab").trigger("click");
  5970. } else {
  5971. var dom = "a[url='{url}']"
  5972. var navlink = top.window.$(dom.replace(/\{url\}/, url));
  5973. if (navlink.length === 0) {
  5974. url = Fast.api.fixurl(url);
  5975. navlink = top.window.$(dom.replace(/\{url\}/, url));
  5976. if (navlink.length === 0) {
  5977. } else {
  5978. var baseurl = url.substr(0, url.indexOf("?") > -1 ? url.indexOf("?") : url.length);
  5979. navlink = top.window.$(dom.replace(/\{url\}/, baseurl));
  5980. //能找到相对地址
  5981. if (navlink.length === 0) {
  5982. navlink = top.window.$(".nav-tabs ul li a[node-url='" + url + "']");
  5983. }
  5984. }
  5985. }
  5986. if (navlink.length > 0 && navlink.attr('addtabs')) {
  5987. top.window.$("ul.nav-addtabs li#tab_" + navlink.attr('addtabs') + " .close-tab").trigger("click");
  5988. }
  5989. }
  5990. },
  5991. replaceids: function (elem, url) {
  5992. //如果有需要替换ids的
  5993. if (url.indexOf("{ids}") > -1) {
  5994. var ids = 0;
  5995. var tableId = $(elem).data("table-id");
  5996. if (tableId && $("#" + tableId).length > 0 && $("#" + tableId).data("bootstrap.table")) {
  5997. var Table = require("table");
  5998. ids = Table.api.selectedids($("#" + tableId)).join(",");
  5999. }
  6000. url = url.replace(/\{ids\}/g, ids);
  6001. }
  6002. return url;
  6003. },
  6004. refreshmenu: function () {
  6005. top.window.$(".sidebar-menu").trigger("refresh");
  6006. },
  6007. gettablecolumnbutton: function (options) {
  6008. if (typeof options.tableId !== 'undefined' && typeof options.fieldIndex !== 'undefined' && typeof options.buttonIndex !== 'undefined') {
  6009. var tableOptions = $("#" + options.tableId).bootstrapTable('getOptions');
  6010. if (tableOptions) {
  6011. var columnObj = null;
  6012. $.each(tableOptions.columns, function (i, columns) {
  6013. $.each(columns, function (j, column) {
  6014. if (typeof column.fieldIndex !== 'undefined' && column.fieldIndex === options.fieldIndex) {
  6015. columnObj = column;
  6016. return false;
  6017. }
  6018. });
  6019. if (columnObj) {
  6020. return false;
  6021. }
  6022. });
  6023. if (columnObj) {
  6024. return columnObj['buttons'][options.buttonIndex];
  6025. }
  6026. }
  6027. }
  6028. return null;
  6029. },
  6030. },
  6031. init: function () {
  6032. //公共代码
  6033. //添加ios-fix兼容iOS下的iframe
  6034. if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
  6035. $("html").addClass("ios-fix");
  6036. }
  6037. //配置Toastr的参数
  6038. Toastr.options.positionClass = Config.controllername === 'index' ? "toast-top-right-index" : "toast-top-right";
  6039. //点击包含.btn-dialog的元素时弹出dialog
  6040. $(document).on('click', '.btn-dialog,.dialogit', function (e) {
  6041. var that = this;
  6042. var options = $.extend({}, $(that).data() || {});
  6043. var url = Backend.api.replaceids(that, $(that).data("url") || $(that).attr('href'));
  6044. var title = $(that).attr("title") || $(that).data("title") || $(that).data('original-title');
  6045. var button = Backend.api.gettablecolumnbutton(options);
  6046. if (button && typeof button.callback === 'function') {
  6047. options.callback = button.callback;
  6048. }
  6049. if (typeof options.confirm !== 'undefined') {
  6050. Layer.confirm(options.confirm, function (index) {
  6051. Backend.api.open(url, title, options);
  6052. Layer.close(index);
  6053. });
  6054. } else {
  6055. window[$(that).data("window") || 'self'].Backend.api.open(url, title, options);
  6056. }
  6057. return false;
  6058. });
  6059. //点击包含.btn-addtabs的元素时新增选项卡
  6060. $(document).on('click', '.btn-addtabs,.addtabsit', function (e) {
  6061. var that = this;
  6062. var options = $.extend({}, $(that).data() || {});
  6063. var url = Backend.api.replaceids(that, $(that).data("url") || $(that).attr('href'));
  6064. var title = $(that).attr("title") || $(that).data("title") || $(that).data('original-title');
  6065. var icon = $(that).attr("icon") || $(that).data("icon");
  6066. if (typeof options.confirm !== 'undefined') {
  6067. Layer.confirm(options.confirm, function (index) {
  6068. Backend.api.addtabs(url, title, icon);
  6069. Layer.close(index);
  6070. });
  6071. } else {
  6072. Backend.api.addtabs(url, title, icon);
  6073. }
  6074. return false;
  6075. });
  6076. //点击包含.btn-ajax的元素时发送Ajax请求
  6077. $(document).on('click', '.btn-ajax,.ajaxit', function (e) {
  6078. var that = this;
  6079. var options = $.extend({}, $(that).data() || {});
  6080. if (typeof options.url === 'undefined' && $(that).attr("href")) {
  6081. options.url = $(that).attr("href");
  6082. }
  6083. options.url = Backend.api.replaceids(this, options.url);
  6084. var success = typeof options.success === 'function' ? options.success : null;
  6085. var error = typeof options.error === 'function' ? options.error : null;
  6086. delete options.success;
  6087. delete options.error;
  6088. var button = Backend.api.gettablecolumnbutton(options);
  6089. if (button) {
  6090. if (typeof button.success === 'function') {
  6091. success = button.success;
  6092. }
  6093. if (typeof button.error === 'function') {
  6094. error = button.error;
  6095. }
  6096. }
  6097. //如果未设备成功的回调,设定了自动刷新的情况下自动进行刷新
  6098. if (!success && typeof options.tableId !== 'undefined' && typeof options.refresh !== 'undefined' && options.refresh) {
  6099. success = function () {
  6100. $("#" + options.tableId).bootstrapTable('refresh');
  6101. }
  6102. }
  6103. if (typeof options.confirm !== 'undefined') {
  6104. Layer.confirm(options.confirm, function (index) {
  6105. Backend.api.ajax(options, success, error);
  6106. Layer.close(index);
  6107. });
  6108. } else {
  6109. Backend.api.ajax(options, success, error);
  6110. }
  6111. return false;
  6112. });
  6113. $(document).on('click', '.btn-click,.clickit', function (e) {
  6114. var that = this;
  6115. var options = $.extend({}, $(that).data() || {});
  6116. var row = {};
  6117. if (typeof options.tableId !== 'undefined') {
  6118. var index = parseInt(options.rowIndex);
  6119. var data = $("#" + options.tableId).bootstrapTable('getData');
  6120. row = typeof data[index] !== 'undefined' ? data[index] : {};
  6121. }
  6122. var button = Backend.api.gettablecolumnbutton(options);
  6123. var click = typeof button.click === 'function' ? button.click : $.noop;
  6124. if (typeof options.confirm !== 'undefined') {
  6125. Layer.confirm(options.confirm, function (index) {
  6126. click.apply(that, [options, row, button]);
  6127. Layer.close(index);
  6128. });
  6129. } else {
  6130. click.apply(that, [options, row, button]);
  6131. }
  6132. return false;
  6133. });
  6134. //修复含有fixed-footer类的body边距
  6135. if ($(".fixed-footer").length > 0) {
  6136. $(document.body).css("padding-bottom", $(".fixed-footer").outerHeight());
  6137. }
  6138. //修复不在iframe时layer-footer隐藏的问题
  6139. if ($(".layer-footer").length > 0 && self === top) {
  6140. $(".layer-footer").show();
  6141. }
  6142. //tooltip和popover
  6143. if (!('ontouchstart' in document.documentElement)) {
  6144. $('body').tooltip({selector: '[data-toggle="tooltip"]', trigger: 'hover'});
  6145. }
  6146. $('body').popover({selector: '[data-toggle="popover"]'});
  6147. }
  6148. };
  6149. Backend.api = $.extend(Fast.api, Backend.api);
  6150. //将Template渲染至全局,以便于在子框架中调用
  6151. window.Template = Template;
  6152. //将Moment渲染至全局,以便于在子框架中调用
  6153. window.Moment = Moment;
  6154. //将Backend渲染至全局,以便于在子框架中调用
  6155. window.Backend = Backend;
  6156. Backend.init();
  6157. return Backend;
  6158. });
  6159. define('backend-init',['backend'], function (Backend) {
  6160. });
  6161. //! moment.js locale configuration
  6162. //! locale : Chinese (China) [zh-cn]
  6163. //! author : suupic : https://github.com/suupic
  6164. //! author : Zeno Zeng : https://github.com/zenozeng
  6165. //! author : uu109 : https://github.com/uu109
  6166. ;(function (global, factory) {
  6167. typeof exports === 'object' && typeof module !== 'undefined'
  6168. && typeof require === 'function' ? factory(require('../moment')) :
  6169. typeof define === 'function' && define.amd ? define('moment/locale/zh-cn',['../moment'], factory) :
  6170. factory(global.moment)
  6171. }(this, (function (moment) { 'use strict';
  6172. //! moment.js locale configuration
  6173. var zhCn = moment.defineLocale('zh-cn', {
  6174. months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split(
  6175. '_'
  6176. ),
  6177. monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split(
  6178. '_'
  6179. ),
  6180. weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
  6181. weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'),
  6182. weekdaysMin: '日_一_二_三_四_五_六'.split('_'),
  6183. longDateFormat: {
  6184. LT: 'HH:mm',
  6185. LTS: 'HH:mm:ss',
  6186. L: 'YYYY/MM/DD',
  6187. LL: 'YYYY年M月D日',
  6188. LLL: 'YYYY年M月D日Ah点mm分',
  6189. LLLL: 'YYYY年M月D日ddddAh点mm分',
  6190. l: 'YYYY/M/D',
  6191. ll: 'YYYY年M月D日',
  6192. lll: 'YYYY年M月D日 HH:mm',
  6193. llll: 'YYYY年M月D日dddd HH:mm',
  6194. },
  6195. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  6196. meridiemHour: function (hour, meridiem) {
  6197. if (hour === 12) {
  6198. hour = 0;
  6199. }
  6200. if (meridiem === '凌晨' || meridiem === '早上' || meridiem === '上午') {
  6201. return hour;
  6202. } else if (meridiem === '下午' || meridiem === '晚上') {
  6203. return hour + 12;
  6204. } else {
  6205. // '中午'
  6206. return hour >= 11 ? hour : hour + 12;
  6207. }
  6208. },
  6209. meridiem: function (hour, minute, isLower) {
  6210. var hm = hour * 100 + minute;
  6211. if (hm < 600) {
  6212. return '凌晨';
  6213. } else if (hm < 900) {
  6214. return '早上';
  6215. } else if (hm < 1130) {
  6216. return '上午';
  6217. } else if (hm < 1230) {
  6218. return '中午';
  6219. } else if (hm < 1800) {
  6220. return '下午';
  6221. } else {
  6222. return '晚上';
  6223. }
  6224. },
  6225. calendar: {
  6226. sameDay: '[今天]LT',
  6227. nextDay: '[明天]LT',
  6228. nextWeek: function (now) {
  6229. if (now.week() !== this.week()) {
  6230. return '[下]dddLT';
  6231. } else {
  6232. return '[本]dddLT';
  6233. }
  6234. },
  6235. lastDay: '[昨天]LT',
  6236. lastWeek: function (now) {
  6237. if (this.week() !== now.week()) {
  6238. return '[上]dddLT';
  6239. } else {
  6240. return '[本]dddLT';
  6241. }
  6242. },
  6243. sameElse: 'L',
  6244. },
  6245. dayOfMonthOrdinalParse: /\d{1,2}(日|月|周)/,
  6246. ordinal: function (number, period) {
  6247. switch (period) {
  6248. case 'd':
  6249. case 'D':
  6250. case 'DDD':
  6251. return number + '日';
  6252. case 'M':
  6253. return number + '月';
  6254. case 'w':
  6255. case 'W':
  6256. return number + '周';
  6257. default:
  6258. return number;
  6259. }
  6260. },
  6261. relativeTime: {
  6262. future: '%s后',
  6263. past: '%s前',
  6264. s: '几秒',
  6265. ss: '%d 秒',
  6266. m: '1 分钟',
  6267. mm: '%d 分钟',
  6268. h: '1 小时',
  6269. hh: '%d 小时',
  6270. d: '1 天',
  6271. dd: '%d 天',
  6272. w: '1 周',
  6273. ww: '%d 周',
  6274. M: '1 个月',
  6275. MM: '%d 个月',
  6276. y: '1 年',
  6277. yy: '%d 年',
  6278. },
  6279. week: {
  6280. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  6281. dow: 1, // Monday is the first day of the week.
  6282. doy: 4, // The week that contains Jan 4th is the first week of the year.
  6283. },
  6284. });
  6285. return zhCn;
  6286. })));
  6287. /*
  6288. * bootstrap-table - v1.11.10 - 2023-06-14
  6289. https://github.com/wenzhixin/bootstrap-table
  6290. * Copyright (c) 2017 zhixin wen
  6291. * Licensed MIT License
  6292. */
  6293. !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);
  6294. define("bootstrap-table", ["bootstrap"], (function (global) {
  6295. return function () {
  6296. var ret, fn;
  6297. return ret || global.$.fn.bootstrapTable;
  6298. };
  6299. }(this)));
  6300. /**
  6301. * Bootstrap Table Chinese translation
  6302. * Author: Zhixin Wen<wenzhixin2010@gmail.com>
  6303. */
  6304. (function ($) {
  6305. 'use strict';
  6306. $.fn.bootstrapTable.locales['zh-CN'] = {
  6307. formatLoadingMessage: function () {
  6308. return '正在努力地加载数据中,请稍候……';
  6309. },
  6310. formatRecordsPerPage: function (pageNumber) {
  6311. return '每页显示 ' + pageNumber + ' 条记录';
  6312. },
  6313. formatShowingRows: function (pageFrom, pageTo, totalRows) {
  6314. return '显示第 ' + pageFrom + ' 到第 ' + pageTo + ' 条记录,总共 ' + totalRows + ' 条记录';
  6315. },
  6316. formatDetailPagination: function (totalRows) {
  6317. return '总共 ' + totalRows + ' 条记录';
  6318. },
  6319. formatSearch: function () {
  6320. return '搜索';
  6321. },
  6322. formatNoMatches: function () {
  6323. return '没有找到匹配的记录';
  6324. },
  6325. formatPaginationSwitch: function () {
  6326. return '隐藏/显示分页';
  6327. },
  6328. formatRefresh: function () {
  6329. return '刷新';
  6330. },
  6331. formatToggle: function () {
  6332. return '切换';
  6333. },
  6334. formatColumns: function () {
  6335. return '列';
  6336. },
  6337. formatExport: function () {
  6338. return '导出数据';
  6339. },
  6340. formatClearFilters: function () {
  6341. return '清空过滤';
  6342. }
  6343. };
  6344. $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['zh-CN']);
  6345. })(jQuery);
  6346. define("bootstrap-table-lang", ["bootstrap-table"], (function (global) {
  6347. return function () {
  6348. var ret, fn;
  6349. return ret || global.$.fn.bootstrapTable.defaults;
  6350. };
  6351. }(this)));
  6352. /*
  6353. * bootstrap-table - v1.11.12 - 2024-03-28
  6354. https://github.com/wenzhixin/bootstrap-table
  6355. * Copyright (c) 2017 zhixin wen
  6356. * Licensed MIT License
  6357. */
  6358. !function(p){"use strict";var o=p.fn.bootstrapTable.utils.sprintf,i={json:"JSON",xml:"XML",png:"PNG",csv:"CSV",txt:"TXT",sql:"SQL",doc:"MS-Word",excel:"MS-Excel",xlsx:"MS-Excel (OpenXML)",powerpoint:"MS-Powerpoint",pdf:"PDF"},t=(p.extend(p.fn.bootstrapTable.defaults,{showExport:!1,exportDataType:"basic",exportTypes:["json","xml","csv","txt","sql","excel"],exportOptions:{}}),p.extend(p.fn.bootstrapTable.defaults.icons,{export:"glyphicon-export icon-share"}),p.extend(p.fn.bootstrapTable.locales,{formatExport:function(){return"Export data"}}),p.extend(p.fn.bootstrapTable.defaults,p.fn.bootstrapTable.locales),p.fn.bootstrapTable.Constructor),s=t.prototype.initToolbar;t.prototype.initToolbar=function(){var a,e,t,n;this.showToolbar=this.options.showExport,s.apply(this,Array.prototype.slice.apply(arguments)),this.options.showExport&&!(t=(a=this).$toolbar.find(">.btn-group")).find("div.export").length&&(e=p(['<div class="export btn-group">','<button class="btn'+o(" btn-%s",this.options.buttonsClass)+o(" btn-%s",this.options.iconSize)+' dropdown-toggle" aria-label="export type" title="'+this.options.formatExport()+'" data-toggle="dropdown" type="button">',o('<i class="%s %s"></i> ',this.options.iconsPrefix,this.options.icons.export),'<span class="caret"></span>',"</button>",'<ul class="dropdown-menu" role="menu">',"</ul>","</div>"].join("")).appendTo(t).find(".dropdown-menu"),n=this.options.exportTypes,"string"==typeof this.options.exportTypes&&(t=this.options.exportTypes.slice(1,-1).replace(/ /g,"").split(","),n=[],p.each(t,function(t,o){n.push(o.slice(1,-1))})),p.each(n,function(t,o){i.hasOwnProperty(o)&&e.append(['<li role="menuitem" data-type="'+o+'">','<a href="javascript:void(0)">',i[o],"</a>","</li>"].join(""))}),e.find("li").click(function(){var s=this;if("function"!=typeof require)throw new Error("RequireJS not found");require(["tableexport"],function(){function t(){a.$el.tableExport(p.extend({},a.options.exportOptions,{type:i,escape:!1}))}var o,e,n,i=p(s).data("type");"all"===a.options.exportDataType&&a.options.pagination?(a.$el.one("server"===a.options.sidePagination?"post-body.bs.table":"page-change.bs.table",function(){t(),a.togglePagination()}),a.togglePagination()):"selected"===a.options.exportDataType?(o=a.getData(),n=a.getAllSelections(),"server"===a.options.sidePagination&&((o={total:a.options.totalRows})[a.options.dataField]=a.getData(),e="function"==typeof require?require("table"):null,(n={total:a.options.totalRows})[a.options.dataField]=e&&a.options.maintainSelected?e.api.selecteddata(a.$el):a.getAllSelections()),a.load(n),t(),a.load(o)):t()})}))}}(jQuery);
  6359. define("bootstrap-table-export", ["bootstrap-table"], (function (global) {
  6360. return function () {
  6361. var ret, fn;
  6362. return ret || global.$.fn.bootstrapTable.defaults;
  6363. };
  6364. }(this)));
  6365. (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});
  6366. define('upload',['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined, Dropzone, Template) {
  6367. var Upload = {
  6368. list: {},
  6369. options: {},
  6370. config: {
  6371. container: document.body,
  6372. classname: '.plupload:not([initialized]),.faupload:not([initialized])',
  6373. 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>',
  6374. },
  6375. events: {
  6376. //初始化
  6377. onInit: function () {
  6378. },
  6379. //上传成功的回调
  6380. onUploadSuccess: function (up, ret, file) {
  6381. var button = up.element;
  6382. var onUploadSuccess = up.options.onUploadSuccess;
  6383. var data = typeof ret.data !== 'undefined' ? ret.data : null;
  6384. //上传成功后回调
  6385. if (button) {
  6386. //如果有文本框则填充
  6387. var input_id = $(button).data("input-id") ? $(button).data("input-id") : "";
  6388. if (input_id) {
  6389. var urlArr = [];
  6390. var inputObj = $("#" + input_id);
  6391. if ($(button).data("multiple") && inputObj.val() !== "") {
  6392. urlArr.push(inputObj.val());
  6393. }
  6394. var url = Config.upload.fullmode ? (data.fullurl ? data.fullurl : Fast.api.cdnurl(data.url)) : data.url;
  6395. urlArr.push(url);
  6396. inputObj.val(urlArr.join(",")).trigger("change").trigger("validate");
  6397. }
  6398. //如果有回调函数
  6399. var onDomUploadSuccess = $(button).data("upload-success");
  6400. if (onDomUploadSuccess) {
  6401. if (typeof onDomUploadSuccess !== 'function' && typeof Upload.api.custom[onDomUploadSuccess] === 'function') {
  6402. onDomUploadSuccess = Upload.api.custom[onDomUploadSuccess];
  6403. }
  6404. if (typeof onDomUploadSuccess === 'function') {
  6405. var result = onDomUploadSuccess.call(button, data, ret, up, file);
  6406. if (result === false)
  6407. return;
  6408. }
  6409. }
  6410. }
  6411. if (typeof onUploadSuccess === 'function') {
  6412. var result = onUploadSuccess.call(button, data, ret, up, file);
  6413. if (result === false)
  6414. return;
  6415. }
  6416. },
  6417. //上传错误的回调
  6418. onUploadError: function (up, ret, file) {
  6419. var button = up.element;
  6420. var onUploadError = up.options.onUploadError;
  6421. var data = typeof ret.data !== 'undefined' ? ret.data : null;
  6422. if (button) {
  6423. var onDomUploadError = $(button).data("upload-error");
  6424. if (onDomUploadError) {
  6425. if (typeof onDomUploadError !== 'function' && typeof Upload.api.custom[onDomUploadError] === 'function') {
  6426. onDomUploadError = Upload.api.custom[onDomUploadError];
  6427. }
  6428. if (typeof onDomUploadError === 'function') {
  6429. var result = onDomUploadError.call(button, data, ret, up, file);
  6430. if (result === false)
  6431. return;
  6432. }
  6433. }
  6434. }
  6435. if (typeof onUploadError === 'function') {
  6436. var result = onUploadError.call(button, data, ret, up, file);
  6437. if (result === false) {
  6438. return;
  6439. }
  6440. }
  6441. Toastr.error(ret.msg.toString().replace(/(<([^>]+)>)/gi, "") + "(code:" + ret.code + ")");
  6442. },
  6443. //服务器响应数据后
  6444. onUploadResponse: function (response, up, file) {
  6445. try {
  6446. var ret = typeof response === 'object' ? response : JSON.parse(response);
  6447. if (!ret.hasOwnProperty('code')) {
  6448. $.extend(ret, {code: -2, msg: response, data: null});
  6449. }
  6450. } catch (e) {
  6451. var ret = {code: -1, msg: e.message, data: null};
  6452. }
  6453. return ret;
  6454. },
  6455. //上传全部结束后
  6456. onUploadComplete: function (up, files) {
  6457. var button = up.element;
  6458. var onUploadComplete = up.options.onUploadComplete;
  6459. if (button) {
  6460. var onDomUploadComplete = $(button).data("upload-complete");
  6461. if (onDomUploadComplete) {
  6462. if (typeof onDomUploadComplete !== 'function' && typeof Upload.api.custom[onDomUploadComplete] === 'function') {
  6463. onDomUploadComplete = Upload.api.custom[onDomUploadComplete];
  6464. }
  6465. if (typeof onDomUploadComplete === 'function') {
  6466. var result = onDomUploadComplete.call(button, files);
  6467. if (result === false)
  6468. return;
  6469. }
  6470. }
  6471. }
  6472. if (typeof onUploadComplete === 'function') {
  6473. var result = onUploadComplete.call(button, files);
  6474. if (result === false) {
  6475. return;
  6476. }
  6477. }
  6478. }
  6479. },
  6480. api: {
  6481. //上传接口
  6482. upload: function (element, onUploadSuccess, onUploadError, onUploadComplete) {
  6483. element = typeof element === 'undefined' ? Upload.config.classname : element;
  6484. $(element, Upload.config.container).each(function () {
  6485. if ($(this).attr("initialized")) {
  6486. return true;
  6487. }
  6488. $(this).attr("initialized", true);
  6489. var that = this;
  6490. var id = $(this).prop("id") || $(this).prop("name") || Dropzone.uuidv4();
  6491. var url = $(this).data("url");
  6492. var maxsize = $(this).data("maxsize");
  6493. var maxcount = $(this).data("maxcount");
  6494. var mimetype = $(this).data("mimetype");
  6495. var multipart = $(this).data("multipart");
  6496. var multiple = $(this).data("multiple");
  6497. //填充ID
  6498. var input_id = $(that).data("input-id") ? $(that).data("input-id") : "";
  6499. //预览ID
  6500. var preview_id = $(that).data("preview-id") ? $(that).data("preview-id") : "";
  6501. //上传URL
  6502. url = url ? url : Config.upload.uploadurl;
  6503. url = Fast.api.fixurl(url);
  6504. var chunking = false, chunkSize = Config.upload.chunksize || 2097152, timeout = Config.upload.timeout || 600000;
  6505. //最大可上传文件大小
  6506. maxsize = typeof maxsize !== "undefined" ? maxsize : Config.upload.maxsize;
  6507. //文件类型
  6508. mimetype = typeof mimetype !== "undefined" ? mimetype : Config.upload.mimetype;
  6509. //请求的表单参数
  6510. multipart = typeof multipart !== "undefined" ? multipart : Config.upload.multipart;
  6511. //是否支持批量上传
  6512. multiple = typeof multiple !== "undefined" ? multiple : Config.upload.multiple;
  6513. //后缀特殊处理
  6514. mimetype = mimetype.split(",").map(function (k) {
  6515. return k.indexOf("/") > -1 ? k : (!k || k === "*" || k.charAt(0) === "." ? k : "." + k);
  6516. }).join(",");
  6517. mimetype = mimetype === '*' ? null : mimetype;
  6518. //最大文件限制转换成mb
  6519. var maxFilesize = (function (maxsize) {
  6520. var matches = maxsize.toString().match(/^([0-9\.]+)(\w+)$/);
  6521. var size = matches ? parseFloat(matches[1]) : parseFloat(maxsize),
  6522. unit = matches ? matches[2].toLowerCase() : 'b';
  6523. var unitDict = {'b': 0, 'k': 1, 'kb': 1, 'm': 2, 'mb': 2, 'gb': 3, 'g': 3, 'tb': 4, 't': 4};
  6524. var y = typeof unitDict[unit] !== 'undefined' ? unitDict[unit] : 0;
  6525. var bytes = size * Math.pow(1024, y);
  6526. return bytes / Math.pow(1024, 2);
  6527. }(maxsize));
  6528. var options = $(this).data() || {};
  6529. options = $.extend(true, {}, options, $(this).data("upload-options") || {});
  6530. delete options.success;
  6531. delete options.url;
  6532. multipart = $.isArray(multipart) ? {} : multipart;
  6533. var params = $(this).data("params") || {};
  6534. var category = typeof params.category !== 'undefined' ? params.category : ($(this).data("category") || '');
  6535. if (category) {
  6536. // multipart.category = category;
  6537. }
  6538. Upload.list[id] = new Dropzone(this, $.extend({
  6539. url: url,
  6540. params: function (files, xhr, chunk) {
  6541. var params = multipart;
  6542. if (chunk) {
  6543. return $.extend({}, params, {
  6544. filesize: chunk.file.size,
  6545. filename: chunk.file.name,
  6546. chunkid: chunk.file.upload.uuid,
  6547. chunkindex: chunk.index,
  6548. chunkcount: chunk.file.upload.totalChunkCount,
  6549. chunksize: this.options.chunkSize,
  6550. chunkfilesize: chunk.dataBlock.data.size,
  6551. width: chunk.file.width || 0,
  6552. height: chunk.file.height || 0,
  6553. type: chunk.file.type,
  6554. });
  6555. }
  6556. return params;
  6557. },
  6558. chunking: chunking,
  6559. chunkSize: chunkSize,
  6560. maxFilesize: maxFilesize,
  6561. acceptedFiles: mimetype,
  6562. maxFiles: (maxcount && parseInt(maxcount) > 1 ? maxcount : (multiple ? null : 1)),
  6563. timeout: timeout,
  6564. parallelUploads: 1,
  6565. previewsContainer: false,
  6566. dictDefaultMessage: __("Drop files here to upload"),
  6567. dictFallbackMessage: __("Your browser does not support drag'n'drop file uploads"),
  6568. dictFallbackText: __("Please use the fallback form below to upload your files like in the olden days"),
  6569. dictFileTooBig: __("File is too big (%sMiB), Max filesize: %sMiB", "{{filesize}}", "{{maxFilesize}}"),
  6570. dictInvalidFileType: __("You can't upload files of this type"),
  6571. dictResponseError: __("Server responded with %s code.", "{{statusCode}}"),
  6572. dictCancelUpload: __("Cancel upload"),
  6573. dictUploadCanceled: __("Upload canceled"),
  6574. dictCancelUploadConfirmation: __("Are you sure you want to cancel this upload?"),
  6575. dictRemoveFile: __("Remove file"),
  6576. dictMaxFilesExceeded: __("You can only upload a maximum of %s files", "{{maxFiles}}"),
  6577. init: function () {
  6578. Upload.events.onInit.call(this);
  6579. //必须添加dz-message,否则点击icon无法唤起上传窗口
  6580. $(">i", this.element).addClass("dz-message");
  6581. this.options.elementHtml = $(this.element).html();
  6582. },
  6583. sending: function (file, xhr, formData) {
  6584. if (typeof file.category !== 'undefined') {
  6585. formData.append('category', file.category);
  6586. }
  6587. },
  6588. addedfile: function (file) {
  6589. var params = $(this.element).data("params") || {};
  6590. var category = typeof params.category !== 'undefined' ? params.category : ($(this.element).data("category") || '');
  6591. file.category = typeof category === 'function' ? category.call(this, file) : category;
  6592. },
  6593. addedfiles: function (files) {
  6594. if (this.options.maxFiles && (!this.options.maxFiles || this.options.maxFiles > 1) && this.options.inputId) {
  6595. var inputObj = $("#" + this.options.inputId);
  6596. if (inputObj.length > 0) {
  6597. var value = $.trim(inputObj.val());
  6598. var nums = value === '' ? 0 : value.split(/\,/).length;
  6599. var remain = this.options.maxFiles - nums;
  6600. if (remain === 0 || files.length > remain) {
  6601. files = Array.prototype.slice.call(files, remain);
  6602. for (var i = 0; i < files.length; i++) {
  6603. this.removeFile(files[i]);
  6604. }
  6605. Toastr.error(__("You can only upload a maximum of %s files", this.options.maxFiles));
  6606. }
  6607. }
  6608. }
  6609. },
  6610. success: function (file, response) {
  6611. var ret = Upload.events.onUploadResponse(response, this, file);
  6612. file.ret = ret;
  6613. if (ret.code === 1) {
  6614. Upload.events.onUploadSuccess(this, ret, file);
  6615. } else {
  6616. Upload.events.onUploadError(this, ret, file);
  6617. }
  6618. },
  6619. error: function (file, response, xhr) {
  6620. var responseObj = $("<div>" + (xhr && typeof xhr.responseText !== 'undefined' ? xhr.responseText : response) + "</div>");
  6621. responseObj.find("style, title, script").remove();
  6622. var msg = responseObj.text() || __('Network error');
  6623. var ret = {code: 0, data: null, msg: msg};
  6624. Upload.events.onUploadError(this, ret, file);
  6625. },
  6626. uploadprogress: function (file, progress, bytesSent) {
  6627. if (file.upload.chunked) {
  6628. $(this.element).prop("disabled", true).html("<i class='fa fa-upload'></i> " + __('Upload') + Math.floor((file.upload.bytesSent / file.size) * 100) + "%");
  6629. }
  6630. },
  6631. totaluploadprogress: function (progress, bytesSent) {
  6632. if (this.getActiveFiles().length > 0 && !this.options.chunking) {
  6633. $(this.element).prop("disabled", true).html("<i class='fa fa-upload'></i> " + __('Upload') + Math.floor(progress) + "%");
  6634. }
  6635. },
  6636. queuecomplete: function () {
  6637. Upload.events.onUploadComplete(this, this.files);
  6638. this.removeAllFiles(true);
  6639. $(this.element).prop("disabled", false).html(this.options.elementHtml);
  6640. },
  6641. chunkSuccess: function (chunk, file, response) {
  6642. },
  6643. chunksUploaded: function (file, done) {
  6644. var that = this;
  6645. Fast.api.ajax({
  6646. url: this.options.url,
  6647. data: $.extend({}, multipart, {
  6648. action: 'merge',
  6649. filesize: file.size,
  6650. filename: file.name,
  6651. chunkid: file.upload.uuid,
  6652. chunkcount: file.upload.totalChunkCount,
  6653. })
  6654. }, function (data, ret) {
  6655. done(JSON.stringify(ret));
  6656. return false;
  6657. }, function (data, ret) {
  6658. file.accepted = false;
  6659. that._errorProcessing([file], ret.msg);
  6660. });
  6661. },
  6662. onUploadSuccess: onUploadSuccess,
  6663. onUploadError: onUploadError,
  6664. onUploadComplete: onUploadComplete,
  6665. }, Upload.options, options));
  6666. //拖动排序
  6667. if (preview_id && multiple) {
  6668. require(['dragsort'], function () {
  6669. $("#" + preview_id).dragsort({
  6670. dragSelector: "li a:not(.btn-trash)",
  6671. dragEnd: function () {
  6672. $("#" + preview_id).trigger("fa.preview.change");
  6673. },
  6674. placeHolderTemplate: '<li class="col-xs-3"></li>'
  6675. });
  6676. });
  6677. }
  6678. //刷新隐藏textarea的值
  6679. var refresh = function (name) {
  6680. var data = {};
  6681. var textarea = $("textarea[name='" + name + "']");
  6682. var container = textarea.prev("ul");
  6683. $.each($("input,select,textarea", container).serializeArray(), function (i, j) {
  6684. var reg = /\[?(\w+)\]?\[(\w+)\]$/g;
  6685. var match = reg.exec(j.name);
  6686. if (!match)
  6687. return true;
  6688. if (!isNaN(match[2])) {
  6689. data[i] = j.value;
  6690. } else {
  6691. match[1] = "x" + parseInt(match[1]);
  6692. if (typeof data[match[1]] === 'undefined') {
  6693. data[match[1]] = {};
  6694. }
  6695. data[match[1]][match[2]] = j.value;
  6696. }
  6697. });
  6698. var result = [];
  6699. $.each(data, function (i, j) {
  6700. result.push(j);
  6701. });
  6702. textarea.val(JSON.stringify(result));
  6703. };
  6704. if (preview_id && input_id) {
  6705. $(document.body).on("keyup change", "#" + input_id, function (e) {
  6706. var inputStr = $("#" + input_id).val();
  6707. var inputArr = inputStr.split(/\,/);
  6708. var previewObj = $("#" + preview_id);
  6709. previewObj.empty();
  6710. var tpl = previewObj.data("template") ? previewObj.data("template") : "";
  6711. var extend = previewObj.next().is("textarea") ? previewObj.next("textarea").val() : "{}";
  6712. var json = {};
  6713. try {
  6714. json = JSON.parse(extend);
  6715. } catch (e) {
  6716. }
  6717. $.each(inputArr, function (i, j) {
  6718. if (!j) {
  6719. return true;
  6720. }
  6721. var suffix = /[\.]?([a-zA-Z0-9]+)$/.exec(j);
  6722. suffix = suffix ? suffix[1] : 'file';
  6723. var btnData = $(that).data();
  6724. var fullurl = typeof btnData.cdnurl!=='undefined' ? Fast.api.cdnurl(j, btnData.cdnurl) : Fast.api.cdnurl(j);
  6725. j = Config.upload.fullmode ? fullurl : j;
  6726. var value = (json && typeof json[i] !== 'undefined' ? json[i] : null);
  6727. var data = {url: j, fullurl: fullurl, data: btnData, key: i, index: i, value: value, row: value, suffix: suffix};
  6728. var html = tpl ? Template(tpl, data) : Template.render(Upload.config.previewtpl, data);
  6729. previewObj.append(html);
  6730. });
  6731. refresh(previewObj.data("name"));
  6732. });
  6733. $("#" + input_id).trigger("change");
  6734. }
  6735. if (preview_id) {
  6736. //监听文本框改变事件
  6737. $("#" + preview_id).on('change keyup', "input,textarea,select", function () {
  6738. refresh($(this).closest("ul").data("name"));
  6739. });
  6740. // 监听事件
  6741. $(document.body).on("fa.preview.change", "#" + preview_id, function () {
  6742. var urlArr = [];
  6743. $("#" + preview_id + " [data-url]").each(function (i, j) {
  6744. urlArr.push($(this).data("url"));
  6745. });
  6746. if (input_id) {
  6747. $("#" + input_id).val(urlArr.join(","));
  6748. }
  6749. refresh($("#" + preview_id).data("name"));
  6750. });
  6751. // 移除按钮事件
  6752. $(document.body).on("click", "#" + preview_id + " .btn-trash", function () {
  6753. $(this).closest("li").remove();
  6754. $("#" + preview_id).trigger("fa.preview.change");
  6755. });
  6756. }
  6757. if (input_id) {
  6758. $("#" + input_id).closest("form").on("reset", function () {
  6759. setTimeout($.proxy(function () {
  6760. $("#" + input_id, this).trigger("change");
  6761. }, this), 0);
  6762. });
  6763. //粘贴上传、拖拽上传
  6764. $("body").on('paste drop', "#" + input_id, function (event) {
  6765. var originEvent = event.originalEvent;
  6766. var button = $(".plupload[data-input-id='" + $(this).attr("id") + "'],.faupload[data-input-id='" + $(this).attr("id") + "']");
  6767. if (event.type === 'paste' && originEvent.clipboardData && originEvent.clipboardData.items) {
  6768. var items = originEvent.clipboardData.items;
  6769. if ((items.length === 1 && items[0].type.indexOf("text") > -1) || (items.length === 2 && items[1].type.indexOf("text") > -1)) {
  6770. } else {
  6771. Upload.list[button.attr("id")].paste(originEvent);
  6772. return false;
  6773. }
  6774. }
  6775. if (event.type === 'drop' && originEvent.dataTransfer && originEvent.dataTransfer.files) {
  6776. Upload.list[button.attr("id")].drop(originEvent);
  6777. return false;
  6778. }
  6779. });
  6780. }
  6781. });
  6782. },
  6783. /**
  6784. * @deprecated Use upload instead.
  6785. */
  6786. plupload: function (element, onUploadSuccess, onUploadError, onUploadComplete) {
  6787. return Upload.api.upload(element, onUploadSuccess, onUploadError, onUploadComplete);
  6788. },
  6789. /**
  6790. * @deprecated Use upload instead.
  6791. */
  6792. faupload: function (element, onUploadSuccess, onUploadError, onUploadComplete) {
  6793. return Upload.api.upload(element, onUploadSuccess, onUploadError, onUploadComplete);
  6794. },
  6795. // AJAX异步上传
  6796. send: function (file, onUploadSuccess, onUploadError, onUploadComplete) {
  6797. var index = Layer.msg(__('Uploading'), {offset: 't', time: 0});
  6798. var id = "dropzone-" + Dropzone.uuidv4();
  6799. $('<button type="button" id="' + id + '" class="btn btn-danger hidden faupload" />').appendTo("body");
  6800. $("#" + id).data("upload-complete", function (files) {
  6801. Layer.close(index);
  6802. Upload.list[id].removeAllFiles(true);
  6803. });
  6804. Upload.api.upload("#" + id, onUploadSuccess, onUploadError, onUploadComplete);
  6805. setTimeout(function () {
  6806. Upload.list[id].addFile(file);
  6807. }, 1);
  6808. },
  6809. custom: {
  6810. //自定义上传完成回调
  6811. afteruploadcallback: function (response) {
  6812. console.log(this, response);
  6813. alert("Custom Callback,Response URL:" + response.url);
  6814. },
  6815. }
  6816. }
  6817. }
  6818. ;
  6819. return Upload;
  6820. });
  6821. ;(function(factory) {
  6822. typeof module === 'object' && module.exports ? module.exports = factory( require( 'jquery' ) ) :
  6823. typeof define === 'function' && define.amd ? define('validator',['jquery'], factory) :
  6824. factory(jQuery);
  6825. }(function($, undefined) {
  6826. 'use strict';
  6827. var NS = 'validator',
  6828. CLS_NS = '.' + NS,
  6829. CLS_NS_RULE = '.rule',
  6830. CLS_NS_FIELD = '.field',
  6831. CLS_NS_FORM = '.form',
  6832. CLS_WRAPPER = 'nice-' + NS,
  6833. CLS_MSG_BOX = 'msg-box',
  6834. ARIA_INVALID = 'aria-invalid',
  6835. DATA_RULE = 'data-rule',
  6836. DATA_MSG = 'data-msg',
  6837. DATA_TIP = 'data-tip',
  6838. DATA_OK = 'data-ok',
  6839. DATA_TIMELY = 'data-timely',
  6840. DATA_TARGET = 'data-target',
  6841. DATA_DISPLAY = 'data-display',
  6842. DATA_MUST = 'data-must',
  6843. NOVALIDATE = 'novalidate',
  6844. INPUT_SELECTOR = ':verifiable',
  6845. rRules = /(&)?(!)?\b(\w+)(?:\[\s*(.*?\]?)\s*\]|\(\s*(.*?\)?)\s*\))?\s*(;|\|)?/g,
  6846. rRule = /(\w+)(?:\[\s*(.*?\]?)\s*\]|\(\s*(.*?\)?)\s*\))?/,
  6847. rDisplay = /(?:([^:;\(\[]*):)?(.*)/,
  6848. rDoubleBytes = /[^\x00-\xff]/g,
  6849. rPos = /top|right|bottom|left/,
  6850. rAjaxType = /(?:(cors|jsonp):)?(?:(post|get):)?(.+)/i,
  6851. rUnsafe = /[<>'"`\\]|&#x?\d+[A-F]?;?|%3[A-F]/gmi,
  6852. noop = $.noop,
  6853. proxy = $.proxy,
  6854. trim = $.trim,
  6855. isFunction = $.isFunction,
  6856. isString = function(s) {
  6857. return typeof s === 'string';
  6858. },
  6859. isObject = function(o) {
  6860. return o && Object.prototype.toString.call(o) === '[object Object]';
  6861. },
  6862. isIE = document.documentMode || +(navigator.userAgent.match(/MSIE (\d+)/) && RegExp.$1),
  6863. attr = function(el, key, value) {
  6864. if (!el || !el.tagName) return null;
  6865. if (value !== undefined) {
  6866. if (value === null) el.removeAttribute(key);
  6867. else el.setAttribute(key, '' + value);
  6868. } else {
  6869. return el.getAttribute(key);
  6870. }
  6871. },
  6872. novalidateonce,
  6873. preinitialized = {},
  6874. defaults = {
  6875. debug: 0,
  6876. theme: 'default',
  6877. ignore: '',
  6878. focusInvalid: true,
  6879. focusCleanup: false,
  6880. stopOnError: false,
  6881. beforeSubmit: null,
  6882. valid: null,
  6883. invalid: null,
  6884. validation: null,
  6885. formClass: 'n-default',
  6886. validClass: 'n-valid',
  6887. invalidClass: 'n-invalid',
  6888. bindClassTo: null,
  6889. remoteDataType: 'cors'
  6890. },
  6891. fieldDefaults = {
  6892. timely: 1,
  6893. display: null,
  6894. target: null,
  6895. ignoreBlank: false,
  6896. showOk: true,
  6897. // Translate ajax response to validation result
  6898. dataFilter: function (data) {
  6899. if ( isString(data) || ( isObject(data) && ('error' in data || 'ok' in data) ) ) {
  6900. return data;
  6901. }
  6902. },
  6903. msgMaker: function(opt) {
  6904. var html;
  6905. html = '<span role="alert" class="msg-wrap n-'+ opt.type + '">' + opt.arrow;
  6906. if (opt.result) {
  6907. $.each(opt.result, function(i, obj){
  6908. html += '<span class="n-'+ obj.type +'">' + opt.icon + '<span class="n-msg">' + obj.msg + '</span></span>';
  6909. });
  6910. } else {
  6911. html += opt.icon + '<span class="n-msg">' + opt.msg + '</span>';
  6912. }
  6913. html += '</span>';
  6914. return html;
  6915. },
  6916. msgWrapper: 'span',
  6917. msgArrow: '',
  6918. msgIcon: '<span class="n-icon"></span>',
  6919. msgClass: 'n-right',
  6920. msgStyle: '',
  6921. msgShow: null,
  6922. msgHide: null
  6923. },
  6924. themes = {};
  6925. /** jQuery Plugin
  6926. * @param {Object} options
  6927. debug {Boolean} 0 Whether to enable debug mode
  6928. timely {Number} 1 Whether to enable timely validation
  6929. theme {String} 'default' Theme name
  6930. stopOnError {Boolean} false Whether to stop validate when found an error input
  6931. focusCleanup {Boolean} false Whether to clean up the field message when focus the field
  6932. focusInvalid {Boolean} true Whether to focus the field that is invalid
  6933. ignoreBlank {Boolean} false When the field has no value, whether to ignore validation
  6934. ignore {jqSelector} '' Ignored fields (Using jQuery selector)
  6935. beforeSubmit {Function} Do something before submit form
  6936. dataFilter {Function} Convert ajax results
  6937. valid {Function} Triggered when the form is valid
  6938. invalid {Function} Triggered when the form is invalid
  6939. validClass {String} 'n-valid' Add this class name to a valid field
  6940. invalidClass {String} 'n-invalid' Add this class name to a invalid field
  6941. bindClassTo {jqSelector} ':verifiable' Which element should the className binding to
  6942. display {Function} Callback function to get dynamic display
  6943. target {Function} Callback function to get dynamic target
  6944. msgShow {Function} Trigger this callback when show message
  6945. msgHide {Function} Trigger this callback when hide message
  6946. msgWrapper {String} 'span' Message wrapper tag name
  6947. msgMaker {Function} Callback function to make message HTML
  6948. msgArrow {String} Message arrow template
  6949. msgIcon {String} Message icon template
  6950. msgStyle {String} Custom message css style
  6951. msgClass {String} Additional added to the message class names
  6952. formClass {String} Additional added to the form class names
  6953. messages {Object} Custom messages for the current instance
  6954. rules {Object} Custom rules for the current instance
  6955. fields {Object} Field validation configuration
  6956. {String} key name|#id
  6957. {String|Object} value Rule string or an object which can pass more arguments
  6958. fields[key][rule] {String} Rule string
  6959. fields[key][display] {String|Function}
  6960. fields[key][tip] {String} Custom tip message
  6961. fields[key][ok] {String} Custom success message
  6962. fields[key][msg] {Object} Custom error message
  6963. fields[key][msgStyle] {String} Custom message style
  6964. fields[key][msgClass] {String} A className which added to message placeholder element
  6965. fields[key][msgWrapper] {String} Tag name of the message placeholder element
  6966. fields[key][msgMaker] {Function} A function to custom message HTML
  6967. fields[key][dataFilter] {Function} A function to convert ajax results
  6968. fields[key][valid] {Function} A function triggered when field is valid
  6969. fields[key][invalid] {Function} A function triggered when field is invalid
  6970. fields[key][must] {Boolean} If set true, we always check the field even has remote checking
  6971. fields[key][timely] {Boolean} Whether to enable timely validation
  6972. fields[key][target] {jqSelector} Define placement of a message
  6973. */
  6974. $.fn.validator = function(options) {
  6975. var that = this,
  6976. args = arguments;
  6977. if (that.is(INPUT_SELECTOR)) return that;
  6978. if (!that.is('form')) that = this.find('form');
  6979. if (!that.length) that = this;
  6980. that.each(function() {
  6981. var instance = $(this).data(NS);
  6982. if (instance) {
  6983. if ( isString(options) ) {
  6984. if ( options.charAt(0) === '_' ) return;
  6985. instance[options].apply(instance, [].slice.call(args, 1));
  6986. }
  6987. else if (options) {
  6988. instance._reset(true);
  6989. instance._init(this, options);
  6990. }
  6991. } else {
  6992. new Validator(this, options);
  6993. }
  6994. });
  6995. return this;
  6996. };
  6997. // Validate a field, or an area
  6998. $.fn.isValid = function(callback, hideMsg) {
  6999. var me = _getInstance(this[0]),
  7000. hasCallback = isFunction(callback),
  7001. ret, opt;
  7002. if (!me) return true;
  7003. if (!hasCallback && hideMsg === undefined) hideMsg = callback;
  7004. me.checkOnly = !!hideMsg;
  7005. opt = me.options;
  7006. ret = me._multiValidate(
  7007. this.is(INPUT_SELECTOR) ? this : this.find(INPUT_SELECTOR),
  7008. function(isValid){
  7009. if (!isValid && opt.focusInvalid && !me.checkOnly) {
  7010. // navigate to the error element
  7011. me.$el.find('[' + ARIA_INVALID + ']:first').focus();
  7012. }
  7013. if (hasCallback) {
  7014. if (callback.length) {
  7015. callback(isValid);
  7016. } else if (isValid) {
  7017. callback();
  7018. }
  7019. }
  7020. me.checkOnly = false;
  7021. }
  7022. );
  7023. // If you pass a callback, we maintain the jQuery object chain
  7024. return hasCallback ? this : ret;
  7025. };
  7026. $.extend($.expr.pseudos || $.expr[':'], {
  7027. // A faster selector than ":input:not(:submit,:button,:reset,:image,:disabled,[contenteditable])"
  7028. verifiable: function(elem) {
  7029. var name = elem.nodeName.toLowerCase();
  7030. return ( name === 'input' && !({submit: 1, button: 1, reset: 1, image: 1})[elem.type] ||
  7031. name === 'select' ||
  7032. name === 'textarea' ||
  7033. elem.contentEditable === 'true'
  7034. ) && !elem.disabled;
  7035. },
  7036. // any value, but not only whitespace
  7037. filled: function(elem) {
  7038. return !!trim($(elem).val());
  7039. }
  7040. });
  7041. /**
  7042. * Creates a new Validator
  7043. *
  7044. * @class
  7045. * @param {Element} element - form element
  7046. * @param {Object} options - options for validator
  7047. */
  7048. function Validator(element, options) {
  7049. var me = this;
  7050. if ( !(me instanceof Validator) ) {
  7051. return new Validator(element, options);
  7052. }
  7053. if (Validator.pending) {
  7054. $(window).on('validatorready', init);
  7055. } else {
  7056. init();
  7057. }
  7058. function init() {
  7059. me.$el = $(element);
  7060. if (me.$el.length) {
  7061. me._init(me.$el[0], options);
  7062. }
  7063. else if (isString(element)) {
  7064. preinitialized[element] = options;
  7065. }
  7066. }
  7067. }
  7068. Validator.prototype = {
  7069. _init: function(element, options) {
  7070. var me = this,
  7071. opt, themeOpt, dataOpt;
  7072. // Initialization options
  7073. if ( isFunction(options) ) {
  7074. options = {
  7075. valid: options
  7076. };
  7077. }
  7078. options = me._opt = options || {};
  7079. dataOpt = attr(element, 'data-'+ NS +'-option');
  7080. dataOpt = me._dataOpt = dataOpt && dataOpt.charAt(0) === '{' ? (new Function('return ' + dataOpt))() : {};
  7081. themeOpt = me._themeOpt = themes[ options.theme || dataOpt.theme || defaults.theme ];
  7082. opt = me.options = $.extend({}, defaults, fieldDefaults, themeOpt, me.options, options, dataOpt);
  7083. me.rules = new Rules(opt.rules, true);
  7084. me.messages = new Messages(opt.messages, true);
  7085. me.Field = _createFieldFactory(me);
  7086. me.elements = me.elements || {};
  7087. me.deferred = {};
  7088. me.errors = {};
  7089. me.fields = {};
  7090. // Initialization fields
  7091. me._initFields(opt.fields);
  7092. // Initialization events and make a cache
  7093. if ( !me.$el.data(NS) ) {
  7094. me.$el.data(NS, me).addClass(CLS_WRAPPER +' '+ opt.formClass)
  7095. .on('form-submit-validate', function(e, a, $form, opts, veto) {
  7096. me.vetoed = veto.veto = !me.isValid;
  7097. me.ajaxFormOptions = opts;
  7098. })
  7099. .on('submit'+ CLS_NS +' validate'+ CLS_NS, proxy(me, '_submit'))
  7100. .on('reset'+ CLS_NS, proxy(me, '_reset'))
  7101. .on('showmsg'+ CLS_NS, proxy(me, '_showmsg'))
  7102. .on('hidemsg'+ CLS_NS, proxy(me, '_hidemsg'))
  7103. .on('focusin'+ CLS_NS + ' click'+ CLS_NS, INPUT_SELECTOR, proxy(me, '_focusin'))
  7104. .on('focusout'+ CLS_NS +' validate'+ CLS_NS, INPUT_SELECTOR, proxy(me, '_focusout'))
  7105. .on('keyup'+ CLS_NS +' input'+ CLS_NS + ' compositionstart compositionend', INPUT_SELECTOR, proxy(me, '_focusout'))
  7106. .on('click'+ CLS_NS, ':radio,:checkbox', 'click', proxy(me, '_focusout'))
  7107. .on('change'+ CLS_NS, 'select,input[type="file"]', 'change', proxy(me, '_focusout'));
  7108. // cache the novalidate attribute value
  7109. me._NOVALIDATE = attr(element, NOVALIDATE);
  7110. // Initialization is complete, stop off default HTML5 form validation
  7111. // If use "jQuery.attr('novalidate')" in IE7 will complain: "SCRIPT3: Member not found."
  7112. attr(element, NOVALIDATE, NOVALIDATE);
  7113. }
  7114. // Display all messages in target container
  7115. if ( isString(opt.target) ) {
  7116. me.$el.find(opt.target).addClass('msg-container');
  7117. }
  7118. },
  7119. // Guess whether the form use ajax submit
  7120. _guessAjax: function(form) {
  7121. var me = this;
  7122. if ( !(me.isAjaxSubmit = !!me.options.valid) ) {
  7123. // if there is a "valid.form" event
  7124. var events = ($._data || $.data)(form, 'events');
  7125. me.isAjaxSubmit = issetEvent(events, 'valid', 'form') || issetEvent(events, 'submit', 'form-plugin');
  7126. }
  7127. function issetEvent(events, name, namespace) {
  7128. return !!(
  7129. events && events[name]
  7130. && $.map(events[name], function(e){
  7131. return ~e.namespace.indexOf(namespace) ? 1 : null;
  7132. }).length )
  7133. }
  7134. },
  7135. _initFields: function(fields) {
  7136. var me = this, k, arr, i,
  7137. clear = fields === null;
  7138. // Processing field information
  7139. if (clear) fields = me.fields;
  7140. if ( isObject(fields) ) {
  7141. for (k in fields) {
  7142. if (~k.indexOf(',')) {
  7143. arr = k.split(',');
  7144. i = arr.length;
  7145. while (i--) {
  7146. initField(trim(arr[i]), fields[k]);
  7147. }
  7148. } else {
  7149. initField(k, fields[k]);
  7150. }
  7151. }
  7152. }
  7153. // Parsing DOM rules
  7154. me.$el.find(INPUT_SELECTOR).each(function() {
  7155. me._parse(this);
  7156. });
  7157. function initField(k, v) {
  7158. // delete a field from settings
  7159. if ( v === null || clear ) {
  7160. var el = me.elements[k];
  7161. if (el) me._resetElement(el, true);
  7162. delete me.fields[k];
  7163. } else {
  7164. me.fields[k] = new me.Field(k, isString(v) ? {rule: v} : v, me.fields[k]);
  7165. }
  7166. }
  7167. },
  7168. // Parsing a field
  7169. _parse: function(el) {
  7170. var me = this,
  7171. field,
  7172. key = el.name,
  7173. display,
  7174. timely,
  7175. dataRule = attr(el, DATA_RULE);
  7176. dataRule && attr(el, DATA_RULE, null);
  7177. // If the field has passed the key as id mode, or it doesn't has a name
  7178. if ( el.id && (
  7179. ('#' + el.id in me.fields) ||
  7180. !key ||
  7181. // If dataRule and element are diffrent from old's, we use ID mode.
  7182. (dataRule !== null && (field = me.fields[key]) && dataRule !== field.rule && el.id !== field.key)
  7183. )
  7184. ) {
  7185. key = '#' + el.id;
  7186. }
  7187. // Generate id
  7188. if (!key) {
  7189. key = '#' + (el.id = 'N' + String(Math.random()).slice(-12));
  7190. }
  7191. field = me.getField(key, true);
  7192. // The priority of passing parameter by DOM is higher than by JS.
  7193. field.rule = dataRule || field.rule;
  7194. if (display = attr(el, DATA_DISPLAY)) {
  7195. field.display = display;
  7196. }
  7197. if (field.rule) {
  7198. if ( attr(el, DATA_MUST) !== null || /\b(?:match|checked)\b/.test(field.rule) ) {
  7199. field.must = true;
  7200. }
  7201. if ( /\brequired\b/.test(field.rule) ) {
  7202. field.required = true;
  7203. }
  7204. if (timely = attr(el, DATA_TIMELY)) {
  7205. field.timely = +timely;
  7206. } else if (field.timely > 3) {
  7207. attr(el, DATA_TIMELY, field.timely);
  7208. }
  7209. me._parseRule(field);
  7210. field.old = {};
  7211. }
  7212. if ( isString(field.target) ) {
  7213. attr(el, DATA_TARGET, field.target);
  7214. }
  7215. if ( isString(field.tip) ) {
  7216. attr(el, DATA_TIP, field.tip);
  7217. }
  7218. return me.fields[key] = field;
  7219. },
  7220. // Parsing field rules
  7221. _parseRule: function(field) {
  7222. var arr = rDisplay.exec(field.rule);
  7223. if (!arr) return;
  7224. // current rule index
  7225. field._i = 0;
  7226. if (arr[1]) {
  7227. field.display = arr[1];
  7228. }
  7229. if (arr[2]) {
  7230. field._rules = [];
  7231. arr[2].replace(rRules, function(){
  7232. var args = arguments;
  7233. args[4] = args[4] || args[5];
  7234. field._rules.push({
  7235. and: args[1] === '&',
  7236. not: args[2] === '!',
  7237. or: args[6] === '|',
  7238. method: args[3],
  7239. params: args[4] ? $.map( args[4].split(', '), trim ) : undefined
  7240. });
  7241. });
  7242. }
  7243. },
  7244. // Verify a zone
  7245. _multiValidate: function($inputs, doneCallback){
  7246. var me = this,
  7247. opt = me.options;
  7248. me.hasError = false;
  7249. if (opt.ignore) {
  7250. $inputs = $inputs.not(opt.ignore);
  7251. }
  7252. $inputs.each(function() {
  7253. me._validate(this);
  7254. if (me.hasError && opt.stopOnError) {
  7255. // stop the validation
  7256. return false;
  7257. }
  7258. });
  7259. // Need to wait for all fields validation complete, especially asynchronous validation
  7260. if (doneCallback) {
  7261. me.validating = true;
  7262. $.when.apply(
  7263. null,
  7264. $.map(me.deferred, function(v){return v;})
  7265. ).done(function(){
  7266. doneCallback.call(me, !me.hasError);
  7267. me.validating = false;
  7268. });
  7269. }
  7270. // If the form does not contain asynchronous validation, the return value is correct.
  7271. // Otherwise, you should detect form validation result through "doneCallback".
  7272. return !$.isEmptyObject(me.deferred) ? undefined : !me.hasError;
  7273. },
  7274. // Validate the whole form
  7275. _submit: function(e) {
  7276. var me = this,
  7277. opt = me.options,
  7278. form = e.target,
  7279. canSubmit = e.type === 'submit' && form.tagName === 'FORM' && !e.isDefaultPrevented();
  7280. e.preventDefault();
  7281. if (
  7282. novalidateonce && ~(novalidateonce = false) ||
  7283. // Prevent duplicate submission
  7284. me.submiting ||
  7285. // Receive the "validate" event only from the form.
  7286. e.type === 'validate' && me.$el[0] !== form ||
  7287. // trigger the beforeSubmit callback.
  7288. isFunction(opt.beforeSubmit) && opt.beforeSubmit.call(me, form) === false
  7289. ) {
  7290. return;
  7291. }
  7292. if (me.isAjaxSubmit === undefined) {
  7293. me._guessAjax(form);
  7294. }
  7295. me._debug('log', '\n<<< event: ' + e.type);
  7296. me._reset();
  7297. me.submiting = true;
  7298. me._multiValidate(
  7299. me.$el.find(INPUT_SELECTOR),
  7300. function(isValid){
  7301. var ret = (isValid || opt.debug === 2) ? 'valid' : 'invalid',
  7302. errors;
  7303. if (!isValid) {
  7304. if (opt.focusInvalid) {
  7305. // navigate to the error element
  7306. me.$el.find('[' + ARIA_INVALID + ']:first').focus();
  7307. }
  7308. errors = $.map(me.errors, function(err){return err;});
  7309. }
  7310. // releasing submit
  7311. me.submiting = false;
  7312. me.isValid = isValid;
  7313. // trigger callback and event
  7314. isFunction(opt[ret]) && opt[ret].call(me, form, errors);
  7315. me.$el.trigger(ret + CLS_NS_FORM, [form, errors]);
  7316. me._debug('log', '>>> ' + ret);
  7317. if (!isValid) return;
  7318. // For jquery.form plugin
  7319. if (me.vetoed) {
  7320. $(form).ajaxSubmit(me.ajaxFormOptions);
  7321. }
  7322. else if (canSubmit && !me.isAjaxSubmit) {
  7323. document.createElement('form').submit.call(form);
  7324. }
  7325. }
  7326. );
  7327. },
  7328. _reset: function(e) {
  7329. var me = this;
  7330. me.errors = {};
  7331. if (e) {
  7332. me.reseting = true;
  7333. me.$el.find(INPUT_SELECTOR).each( function(){
  7334. me._resetElement(this);
  7335. });
  7336. delete me.reseting;
  7337. }
  7338. },
  7339. _resetElement: function(el, all) {
  7340. this._setClass(el, null);
  7341. this.hideMsg(el);
  7342. },
  7343. // Handle events: "focusin/click"
  7344. _focusin: function(e) {
  7345. var me = this,
  7346. opt = me.options,
  7347. el = e.target,
  7348. timely,
  7349. msg;
  7350. if ( me.validating || ( e.type==='click' && document.activeElement === el ) ) {
  7351. return;
  7352. }
  7353. if (opt.focusCleanup) {
  7354. if ( attr(el, ARIA_INVALID) === 'true' ) {
  7355. me._setClass(el, null);
  7356. me.hideMsg(el);
  7357. }
  7358. }
  7359. msg = attr(el, DATA_TIP);
  7360. if (msg) {
  7361. me.showMsg(el, {
  7362. type: 'tip',
  7363. msg: msg
  7364. });
  7365. } else {
  7366. if (attr(el, DATA_RULE)) {
  7367. me._parse(el);
  7368. }
  7369. if (timely = attr(el, DATA_TIMELY)) {
  7370. if ( timely === 8 || timely === 9 ) {
  7371. me._focusout(e);
  7372. }
  7373. }
  7374. }
  7375. },
  7376. // Handle events: "focusout/validate/keyup/click/change/input/compositionstart/compositionend"
  7377. _focusout: function(e) {
  7378. var me = this,
  7379. opt = me.options,
  7380. el = e.target,
  7381. etype = e.type,
  7382. etype0,
  7383. focusin = etype === 'focusin',
  7384. special = etype === 'validate',
  7385. elem,
  7386. field,
  7387. old,
  7388. value,
  7389. timestamp,
  7390. key, specialKey,
  7391. timely,
  7392. timer = 0;
  7393. if (etype === 'compositionstart') {
  7394. me.pauseValidate = true;
  7395. }
  7396. if (etype === 'compositionend') {
  7397. me.pauseValidate = false;
  7398. }
  7399. if (me.pauseValidate) {
  7400. return;
  7401. }
  7402. // For checkbox and radio
  7403. elem = el.name && _checkable(el) ? me.$el.find('input[name="'+ el.name +'"]').get(0) : el;
  7404. // Get field
  7405. if (!(field = me.getField(elem)) || !field.rule) {
  7406. return;
  7407. }
  7408. // Cache event type
  7409. etype0 = field._e;
  7410. field._e = etype;
  7411. timely = field.timely;
  7412. if (!special) {
  7413. if (!timely || (_checkable(el) && etype !== 'click')) {
  7414. return;
  7415. }
  7416. value = field.getValue();
  7417. // not validate field unless fill a value
  7418. if ( field.ignoreBlank && !value && !focusin ) {
  7419. me.hideMsg(el);
  7420. return;
  7421. }
  7422. if ( etype === 'focusout' ) {
  7423. if (etype0 === 'change') {
  7424. return;
  7425. }
  7426. if ( timely === 2 || timely === 8 ) {
  7427. old = field.old;
  7428. if (value && old) {
  7429. if (field.isValid && !old.showOk) {
  7430. me.hideMsg(el);
  7431. } else {
  7432. me._makeMsg(el, field, old);
  7433. }
  7434. } else {
  7435. return;
  7436. }
  7437. }
  7438. }
  7439. else {
  7440. if ( timely < 2 && !e.data ) {
  7441. return;
  7442. }
  7443. // mark timestamp to reduce the frequency of the received event
  7444. timestamp = +new Date();
  7445. if ( timestamp - (el._ts || 0) < 100 ) {
  7446. return;
  7447. }
  7448. el._ts = timestamp;
  7449. // handle keyup
  7450. if ( etype === 'keyup' ) {
  7451. if (etype0 === 'input') {
  7452. return;
  7453. }
  7454. key = e.keyCode;
  7455. specialKey = {
  7456. 8: 1, // Backspace
  7457. 9: 1, // Tab
  7458. 16: 1, // Shift
  7459. 32: 1, // Space
  7460. 46: 1 // Delete
  7461. };
  7462. // only gets focus, no validation
  7463. if ( key === 9 && !value ) {
  7464. return;
  7465. }
  7466. // do not validate, if triggered by these keys
  7467. if ( key < 48 && !specialKey[key] ) {
  7468. return;
  7469. }
  7470. }
  7471. if ( !focusin ) {
  7472. // keyboard events, reducing the frequency of validation
  7473. timer = timely <100 ? (etype === 'click' || el.tagName === 'SELECT') ? 0 : 400 : timely;
  7474. }
  7475. }
  7476. }
  7477. // if the current field is ignored
  7478. if ( opt.ignore && $(el).is(opt.ignore) ) {
  7479. return;
  7480. }
  7481. clearTimeout(field._t);
  7482. if (timer) {
  7483. field._t = setTimeout(function() {
  7484. me._validate(el, field);
  7485. }, timer);
  7486. } else {
  7487. if (special) field.old = {};
  7488. me._validate(el, field);
  7489. }
  7490. },
  7491. _setClass: function(el, isValid) {
  7492. var $el = $(el), opt = this.options;
  7493. if (opt.bindClassTo) {
  7494. $el = $el.closest(opt.bindClassTo);
  7495. }
  7496. $el.removeClass( opt.invalidClass + ' ' + opt.validClass );
  7497. if (isValid !== null) {
  7498. $el.addClass( isValid ? opt.validClass : opt.invalidClass );
  7499. }
  7500. },
  7501. _showmsg: function(e, type, msg) {
  7502. var me = this,
  7503. el = e.target;
  7504. if ( me.$el.is(el) ) {
  7505. if (isObject(type)) {
  7506. me.showMsg(type)
  7507. }
  7508. else if ( type === 'tip' ) {
  7509. me.$el.find(INPUT_SELECTOR +'['+ DATA_TIP +']', el).each(function(){
  7510. me.showMsg(this, {type: type, msg: msg});
  7511. });
  7512. }
  7513. }
  7514. else {
  7515. me.showMsg(el, {type: type, msg: msg});
  7516. }
  7517. },
  7518. _hidemsg: function(e) {
  7519. var $el = $(e.target);
  7520. if ( $el.is(INPUT_SELECTOR) ) {
  7521. this.hideMsg($el);
  7522. }
  7523. },
  7524. // Validated a field
  7525. _validatedField: function(el, field, ret) {
  7526. var me = this,
  7527. opt = me.options,
  7528. isValid = field.isValid = ret.isValid = !!ret.isValid,
  7529. callback = isValid ? 'valid' : 'invalid';
  7530. ret.key = field.key;
  7531. ret.ruleName = field._r;
  7532. ret.id = el.id;
  7533. ret.value = field.value;
  7534. me.elements[field.key] = ret.element = el;
  7535. me.isValid = me.$el[0].isValid = isValid ? me.isFormValid() : isValid;
  7536. if (isValid) {
  7537. ret.type = 'ok';
  7538. } else {
  7539. if (me.submiting) {
  7540. me.errors[field.key] = ret.msg;
  7541. }
  7542. me.hasError = true;
  7543. }
  7544. // cache result
  7545. field.old = ret;
  7546. // trigger callback
  7547. isFunction(field[callback]) && field[callback].call(me, el, ret);
  7548. isFunction(opt.validation) && opt.validation.call(me, el, ret);
  7549. // trigger event
  7550. $(el).attr( ARIA_INVALID, isValid ? null : true )
  7551. .trigger( callback + CLS_NS_FIELD, [ret, me] );
  7552. me.$el.triggerHandler('validation', [ret, me]);
  7553. if (me.checkOnly) return;
  7554. // set className
  7555. me._setClass(el, ret.skip || ret.type === 'tip' ? null : isValid);
  7556. me._makeMsg.apply(me, arguments);
  7557. },
  7558. _makeMsg: function(el, field, ret) {
  7559. // show or hide the message
  7560. if (field.msgMaker) {
  7561. ret = $.extend({}, ret);
  7562. if (field._e === 'focusin') {
  7563. ret.type = 'tip';
  7564. }
  7565. this[ ret.showOk || ret.msg || ret.type === 'tip' ? 'showMsg' : 'hideMsg' ](el, ret, field);
  7566. }
  7567. },
  7568. // Validated a rule
  7569. _validatedRule: function(el, field, ret, msgOpt) {
  7570. field = field || me.getField(el);
  7571. msgOpt = msgOpt || {};
  7572. var me = this,
  7573. msg,
  7574. rule,
  7575. method = field._r,
  7576. timely = field.timely,
  7577. special = timely === 9 || timely === 8,
  7578. transfer,
  7579. temp,
  7580. isValid = false;
  7581. // use null to break validation from a field
  7582. if (ret === null) {
  7583. me._validatedField(el, field, {isValid: true, skip: true});
  7584. field._i = 0;
  7585. return;
  7586. }
  7587. else if (ret === undefined) {
  7588. transfer = true;
  7589. }
  7590. else if (ret === true || ret === '') {
  7591. isValid = true;
  7592. }
  7593. else if (isString(ret)) {
  7594. msg = ret;
  7595. }
  7596. else if (isObject(ret)) {
  7597. if (ret.error) {
  7598. msg = ret.error;
  7599. } else {
  7600. msg = ret.ok;
  7601. isValid = true;
  7602. }
  7603. }
  7604. else {
  7605. isValid = !!ret
  7606. }
  7607. rule = field._rules[field._i];
  7608. if (rule.not) {
  7609. msg = undefined;
  7610. isValid = method === 'required' || !isValid;
  7611. }
  7612. if (rule.or) {
  7613. if (isValid) {
  7614. while ( field._i < field._rules.length && field._rules[field._i].or ) {
  7615. field._i++;
  7616. }
  7617. } else {
  7618. transfer = true;
  7619. }
  7620. }
  7621. else if (rule.and) {
  7622. if (!field.isValid) transfer = true;
  7623. }
  7624. if (transfer) {
  7625. isValid = true;
  7626. }
  7627. // message analysis, and throw rule level event
  7628. else {
  7629. if (isValid) {
  7630. if (field.showOk !== false) {
  7631. temp = attr(el, DATA_OK);
  7632. msg = temp === null ? isString(field.ok) ? field.ok : msg : temp;
  7633. if (!isString(msg) && isString(field.showOk)) {
  7634. msg = field.showOk;
  7635. }
  7636. if (isString(msg)) {
  7637. msgOpt.showOk = isValid;
  7638. }
  7639. }
  7640. }
  7641. if (!isValid || special) {
  7642. /* rule message priority:
  7643. 1. custom DOM message
  7644. 2. custom field message;
  7645. 3. global defined message;
  7646. 4. rule returned message;
  7647. 5. default message;
  7648. */
  7649. msg = (_getDataMsg(el, field, msg || rule.msg || me.messages[method]) || me.messages.fallback).replace(/\{0\|?([^\}]*)\}/, function(m, defaultDisplay){
  7650. return me._getDisplay(el, field.display) || defaultDisplay || me.messages[0];
  7651. });
  7652. }
  7653. if (!isValid) field.isValid = isValid;
  7654. msgOpt.msg = msg;
  7655. $(el).trigger( (isValid ? 'valid' : 'invalid') + CLS_NS_RULE, [method, msg]);
  7656. }
  7657. if (special && (!transfer || rule.and)) {
  7658. if (!isValid && !field._m) field._m = msg;
  7659. field._v = field._v || [];
  7660. field._v.push({
  7661. type: isValid ? !transfer ? 'ok' : 'tip' : 'error',
  7662. msg: msg || rule.msg
  7663. });
  7664. }
  7665. me._debug('log', ' ' + field._i + ': ' + method + ' => ' + (isValid || msg));
  7666. // the current rule has passed, continue to validate
  7667. if ( (isValid || special) && field._i < field._rules.length - 1) {
  7668. field._i++;
  7669. me._checkRule(el, field);
  7670. }
  7671. // field was invalid, or all fields was valid
  7672. else {
  7673. field._i = 0;
  7674. if (special) {
  7675. msgOpt.isValid = field.isValid;
  7676. msgOpt.result = field._v;
  7677. msgOpt.msg = field._m || '';
  7678. if (!field.value && (field._e === 'focusin')) {
  7679. msgOpt.type = 'tip';
  7680. }
  7681. } else {
  7682. msgOpt.isValid = isValid;
  7683. }
  7684. me._validatedField(el, field, msgOpt);
  7685. delete field._m;
  7686. delete field._v;
  7687. }
  7688. },
  7689. // Verify a rule form a field
  7690. _checkRule: function(el, field) {
  7691. var me = this,
  7692. ret,
  7693. fn,
  7694. old,
  7695. key = field.key,
  7696. rule = field._rules[field._i],
  7697. method = rule.method,
  7698. params = rule.params;
  7699. // request has been sent, wait it
  7700. if (me.submiting && me.deferred[key]) {
  7701. return;
  7702. }
  7703. old = field.old;
  7704. field._r = method;
  7705. if (old && !field.must && !rule.must && rule.result !== undefined &&
  7706. old.ruleName === method && old.id === el.id &&
  7707. field.value && old.value === field.value )
  7708. {
  7709. // get result from cache
  7710. ret = rule.result;
  7711. }
  7712. else {
  7713. // get result from current rule
  7714. fn = _getDataRule(el, method) || me.rules[method] || noop;
  7715. ret = fn.call(field, el, params, field);
  7716. if (fn.msg) rule.msg = fn.msg;
  7717. }
  7718. // asynchronous validation
  7719. if (isObject(ret) && isFunction(ret.then)) {
  7720. me.deferred[key] = ret;
  7721. // whether the field valid is unknown
  7722. field.isValid = undefined;
  7723. // show loading message
  7724. !me.checkOnly && me.showMsg(el, {
  7725. type: 'loading',
  7726. msg: me.messages.loading
  7727. }, field);
  7728. // waiting to parse the response data
  7729. ret.then(
  7730. function(d, textStatus, jqXHR) {
  7731. var data = trim(jqXHR.responseText),
  7732. result,
  7733. dataFilter = field.dataFilter;
  7734. // detect if data is json or jsonp format
  7735. if (/jsonp?/.test(this.dataType)) {
  7736. data = d;
  7737. } else if (data.charAt(0) === '{') {
  7738. data = $.parseJSON(data);
  7739. }
  7740. // filter data
  7741. result = dataFilter.call(this, data, field);
  7742. if (result === undefined) result = dataFilter.call(this, data.data, field);
  7743. rule.data = this.data;
  7744. rule.result = field.old ? result : undefined;
  7745. me._validatedRule(el, field, result);
  7746. },
  7747. function(jqXHR, textStatus){
  7748. me._validatedRule(el, field, me.messages[textStatus] || textStatus);
  7749. }
  7750. ).always(function(){
  7751. delete me.deferred[key];
  7752. });
  7753. }
  7754. // other result
  7755. else {
  7756. me._validatedRule(el, field, ret);
  7757. }
  7758. },
  7759. // Processing the validation
  7760. _validate: function(el, field) {
  7761. var me = this;
  7762. // doesn't validate the element that has "disabled" or "novalidate" attribute
  7763. if ( el.disabled || attr(el, NOVALIDATE) !== null ) {
  7764. return;
  7765. }
  7766. field = field || me.getField(el);
  7767. if (!field) return;
  7768. if (!field._rules) me._parse(el);
  7769. if (!field._rules) return;
  7770. me._debug('info', field.key);
  7771. field.isValid = true;
  7772. field.element = el;
  7773. // Cache the value
  7774. field.value = field.getValue();
  7775. // if the field is not required, and that has a blank value
  7776. if (!field.required && !field.must && !field.value) {
  7777. if (!_checkable(el)) {
  7778. me._validatedField(el, field, {isValid: true});
  7779. return true;
  7780. }
  7781. }
  7782. me._checkRule(el, field);
  7783. return field.isValid;
  7784. },
  7785. _debug: function(type, messages) {
  7786. if (window.console && this.options.debug) {
  7787. console[type](messages);
  7788. }
  7789. },
  7790. /**
  7791. * Detecting whether the value of an element that matches a rule
  7792. *
  7793. * @method test
  7794. * @param {Element} el - input element
  7795. * @param {String} rule - rule name
  7796. */
  7797. test: function(el, rule) {
  7798. var me = this,
  7799. ret,
  7800. parts = rRule.exec(rule),
  7801. field,
  7802. method,
  7803. params;
  7804. if (parts) {
  7805. method = parts[1];
  7806. if (method in me.rules) {
  7807. params = parts[2] || parts[3];
  7808. params = params ? params.split(', ') : undefined;
  7809. field = me.getField(el, true);
  7810. field._r = method;
  7811. field.value = field.getValue();
  7812. ret = me.rules[method].call(field, el, params);
  7813. }
  7814. }
  7815. return ret === true || ret === undefined || ret === null;
  7816. },
  7817. _getDisplay: function(el, str) {
  7818. return !isString(str) ? isFunction(str) ? str.call(this, el) : '' : str;
  7819. },
  7820. _getMsgOpt: function(obj, field) {
  7821. var opt = field ? field : this.options;
  7822. return $.extend({
  7823. type: 'error',
  7824. pos: _getPos(opt.msgClass),
  7825. target: opt.target,
  7826. wrapper: opt.msgWrapper,
  7827. style: opt.msgStyle,
  7828. cls: opt.msgClass,
  7829. arrow: opt.msgArrow,
  7830. icon: opt.msgIcon
  7831. }, isString(obj) ? {msg: obj} : obj);
  7832. },
  7833. _getMsgDOM: function(el, msgOpt) {
  7834. var $el = $(el), $msgbox, datafor, tgt, container;
  7835. if ( $el.is(INPUT_SELECTOR) ) {
  7836. tgt = msgOpt.target || attr(el, DATA_TARGET);
  7837. if (tgt) {
  7838. tgt = !isFunction(tgt) ? tgt.charAt(0) === '#' ? $(tgt) : this.$el.find(tgt) : tgt.call(this, el);
  7839. if (tgt.length) {
  7840. if ( tgt.is(INPUT_SELECTOR) ) {
  7841. $el = tgt
  7842. el = tgt.get(0);
  7843. } else if ( tgt.hasClass(CLS_MSG_BOX) ) {
  7844. $msgbox = tgt;
  7845. } else {
  7846. container = tgt;
  7847. }
  7848. }
  7849. }
  7850. if (!$msgbox) {
  7851. datafor = (!_checkable(el) || !el.name) && el.id ? el.id : el.name;
  7852. $msgbox = (container || this.$el).find(msgOpt.wrapper + '.' + CLS_MSG_BOX + '[for="' + datafor + '"]');
  7853. }
  7854. } else {
  7855. $msgbox = $el;
  7856. }
  7857. // Create new message box
  7858. if (!msgOpt.hide && !$msgbox.length) {
  7859. $msgbox = $('<'+ msgOpt.wrapper + '>').attr({
  7860. 'class': CLS_MSG_BOX + (msgOpt.cls ? ' ' + msgOpt.cls : ''),
  7861. 'style': msgOpt.style || undefined,
  7862. 'for': datafor
  7863. });
  7864. if (container) {
  7865. $msgbox.appendTo(container);
  7866. } else {
  7867. if ( _checkable(el) ) {
  7868. var $parent = $el.parent();
  7869. $msgbox.appendTo( $parent.is('label') ? $parent.parent() : $parent );
  7870. } else {
  7871. $msgbox[!msgOpt.pos || msgOpt.pos === 'right' ? 'insertAfter' : 'insertBefore']($el);
  7872. }
  7873. }
  7874. }
  7875. return $msgbox;
  7876. },
  7877. /**
  7878. * Show validation message
  7879. *
  7880. * @method showMsg
  7881. * @param {Element} el - input element
  7882. * @param {Object} msgOpt
  7883. */
  7884. showMsg: function(el, msgOpt, /*INTERNAL*/ field) {
  7885. if (!el) return;
  7886. var me = this,
  7887. opt = me.options,
  7888. msgShow,
  7889. msgMaker,
  7890. temp,
  7891. $msgbox;
  7892. if (isObject(el) && !el.jquery && !msgOpt) {
  7893. $.each(el, function(key, msg) {
  7894. var el = me.elements[key] || me.$el.find(_key2selector(key))[0];
  7895. me.showMsg(el, msg);
  7896. });
  7897. return;
  7898. }
  7899. if ($(el).is(INPUT_SELECTOR)) {
  7900. field = field || me.getField(el);
  7901. }
  7902. if (!(msgMaker = (field || opt).msgMaker)) {
  7903. return;
  7904. }
  7905. msgOpt = me._getMsgOpt(msgOpt, field);
  7906. el = (el.name && _checkable(el) ? me.$el.find('input[name="'+ el.name +'"]') : $(el)).get(0);
  7907. // ok or tip
  7908. if (!msgOpt.msg && msgOpt.type !== 'error') {
  7909. temp = attr(el, 'data-' + msgOpt.type);
  7910. if (temp !== null) msgOpt.msg = temp;
  7911. }
  7912. if ( !isString(msgOpt.msg) ) {
  7913. return;
  7914. }
  7915. $msgbox = me._getMsgDOM(el, msgOpt);
  7916. !rPos.test($msgbox[0].className) && $msgbox.addClass(msgOpt.cls);
  7917. if ( isIE === 6 && msgOpt.pos === 'bottom' ) {
  7918. $msgbox[0].style.marginTop = $(el).outerHeight() + 'px';
  7919. }
  7920. $msgbox.html( msgMaker.call(me, msgOpt) )[0].style.display = '';
  7921. if (isFunction(msgShow = field && field.msgShow || opt.msgShow)) {
  7922. msgShow.call(me, $msgbox, msgOpt.type);
  7923. }
  7924. },
  7925. /**
  7926. * Hide validation message
  7927. *
  7928. * @method hideMsg
  7929. * @param {Element} el - input element
  7930. * @param {Object} msgOpt optional
  7931. */
  7932. hideMsg: function(el, msgOpt, /*INTERNAL*/ field) {
  7933. var me = this,
  7934. opt = me.options,
  7935. msgHide,
  7936. $msgbox;
  7937. el = $(el).get(0);
  7938. if ($(el).is(INPUT_SELECTOR)) {
  7939. field = field || me.getField(el);
  7940. if (field) {
  7941. if (field.isValid || me.reseting) attr(el, ARIA_INVALID, null);
  7942. }
  7943. }
  7944. msgOpt = me._getMsgOpt(msgOpt, field);
  7945. msgOpt.hide = true;
  7946. $msgbox = me._getMsgDOM(el, msgOpt);
  7947. if (!$msgbox.length) return;
  7948. if ( isFunction(msgHide = field && field.msgHide || opt.msgHide) ) {
  7949. msgHide.call(me, $msgbox, msgOpt.type);
  7950. } else {
  7951. $msgbox[0].style.display = 'none';
  7952. $msgbox[0].innerHTML = '';
  7953. }
  7954. },
  7955. /**
  7956. * Get field information
  7957. *
  7958. * @method getField
  7959. * @param {Element} - input element
  7960. * @return {Object} field
  7961. */
  7962. getField: function(el, must) {
  7963. var me = this,
  7964. key,
  7965. field;
  7966. if (isString(el)) {
  7967. key = el;
  7968. el = undefined;
  7969. } else {
  7970. if (attr(el, DATA_RULE)) {
  7971. return me._parse(el);
  7972. }
  7973. if (el.id && '#' + el.id in me.fields || !el.name) {
  7974. key = '#' + el.id;
  7975. } else {
  7976. key = el.name;
  7977. }
  7978. }
  7979. if ( (field = me.fields[key]) || must && (field = new me.Field(key)) ) {
  7980. field.element = el;
  7981. }
  7982. return field;
  7983. },
  7984. /**
  7985. * Config a field
  7986. *
  7987. * @method: setField
  7988. * @param {String} key
  7989. * @param {Object} obj
  7990. */
  7991. setField: function(key, obj) {
  7992. var fields = {};
  7993. if (!key) return;
  7994. // update this field
  7995. if (isString(key)) {
  7996. fields[key] = obj;
  7997. }
  7998. // update fields
  7999. else {
  8000. fields = key;
  8001. }
  8002. this._initFields(fields);
  8003. },
  8004. /**
  8005. * Detecting whether the form is valid
  8006. *
  8007. * @method isFormValid
  8008. * @return {Boolean}
  8009. */
  8010. isFormValid: function() {
  8011. var fields = this.fields, k, field;
  8012. for (k in fields) {
  8013. field = fields[k];
  8014. if (!field._rules || !field.required && !field.must && !field.value) continue;
  8015. if (!field.isValid) return false;
  8016. }
  8017. return true;
  8018. },
  8019. /**
  8020. * Prevent submission form
  8021. *
  8022. * @method holdSubmit
  8023. * @param {Boolean} hold - If set to false, will release the hold
  8024. */
  8025. holdSubmit: function(hold) {
  8026. this.submiting = hold === undefined || hold;
  8027. },
  8028. /**
  8029. * Clean validation messages
  8030. *
  8031. * @method cleanUp
  8032. */
  8033. cleanUp: function() {
  8034. this._reset(1);
  8035. },
  8036. /**
  8037. * Destroy the validation
  8038. *
  8039. * @method destroy
  8040. */
  8041. destroy: function() {
  8042. this._reset(1);
  8043. this.$el.off(CLS_NS).removeData(NS);
  8044. attr(this.$el[0], NOVALIDATE, this._NOVALIDATE);
  8045. }
  8046. };
  8047. /**
  8048. * Create Field Factory
  8049. *
  8050. * @class
  8051. * @param {Object} context
  8052. * @return {Function} Factory
  8053. */
  8054. function _createFieldFactory(context) {
  8055. function FieldFactory() {
  8056. var options = this.options;
  8057. for (var i in options) {
  8058. if (i in fieldDefaults) this[i] = options[i];
  8059. }
  8060. $.extend(this, {
  8061. _valHook: function() {
  8062. return this.element.contentEditable === 'true' ? 'text' : 'val';
  8063. },
  8064. getValue: function() {
  8065. var elem = this.element;
  8066. if (elem.type === 'number' && elem.validity && elem.validity.badInput) {
  8067. return 'NaN';
  8068. }
  8069. return $(elem)[this._valHook()]();
  8070. },
  8071. setValue: function(value) {
  8072. $(this.element)[this._valHook()](this.value = value);
  8073. },
  8074. // Get a range of validation messages
  8075. getRangeMsg: function(value, params, suffix) {
  8076. if (!params) return;
  8077. var me = this,
  8078. msg = me.messages[me._r] || '',
  8079. result,
  8080. p = params[0].split('~'),
  8081. e = params[1] === 'false',
  8082. a = p[0],
  8083. b = p[1],
  8084. c = 'rg',
  8085. args = [''],
  8086. isNumber = trim(value) && +value === +value;
  8087. function compare(large, small) {
  8088. return !e ? large >= small : large > small;
  8089. }
  8090. if (p.length === 2) {
  8091. if (a && b) {
  8092. if (isNumber && compare(value, +a) && compare(+b, value)) {
  8093. result = true;
  8094. }
  8095. args = args.concat(p);
  8096. c = e ? 'gtlt' : 'rg';
  8097. }
  8098. else if (a && !b) {
  8099. if (isNumber && compare(value, +a)) {
  8100. result = true;
  8101. }
  8102. args.push(a);
  8103. c = e ? 'gt' : 'gte';
  8104. }
  8105. else if (!a && b) {
  8106. if (isNumber && compare(+b, value)) {
  8107. result = true;
  8108. }
  8109. args.push(b);
  8110. c = e ? 'lt' : 'lte';
  8111. }
  8112. }
  8113. else {
  8114. if (value === +a) {
  8115. result = true;
  8116. }
  8117. args.push(a);
  8118. c = 'eq';
  8119. }
  8120. if (msg) {
  8121. if (suffix && msg[c + suffix]) {
  8122. c += suffix;
  8123. }
  8124. args[0] = msg[c];
  8125. }
  8126. return result || me._rules && ( me._rules[me._i].msg = me.renderMsg.apply(null, args) );
  8127. },
  8128. // Render message template
  8129. renderMsg: function() {
  8130. var args = arguments,
  8131. tpl = args[0],
  8132. i = args.length;
  8133. if (!tpl) return;
  8134. while (--i) {
  8135. tpl = tpl.replace('{' + i + '}', args[i]);
  8136. }
  8137. return tpl;
  8138. }
  8139. });
  8140. }
  8141. function Field(key, obj, oldField) {
  8142. this.key = key;
  8143. this.validator = context;
  8144. $.extend(this, oldField, obj);
  8145. }
  8146. FieldFactory.prototype = context;
  8147. Field.prototype = new FieldFactory();
  8148. return Field;
  8149. }
  8150. /**
  8151. * Create Rules
  8152. *
  8153. * @class
  8154. * @param {Object} obj rules
  8155. * @param {Object} context context
  8156. */
  8157. function Rules(obj, context) {
  8158. if (!isObject(obj)) return;
  8159. var k, that = context ? context === true ? this : context : Rules.prototype;
  8160. for (k in obj) {
  8161. if (_checkRuleName(k)) {
  8162. that[k] = _getRule(obj[k]);
  8163. }
  8164. }
  8165. }
  8166. /**
  8167. * Create Messages
  8168. *
  8169. * @class
  8170. * @param {Object} obj rules
  8171. * @param {Object} context context
  8172. */
  8173. function Messages(obj, context) {
  8174. if (!isObject(obj)) return;
  8175. var k, that = context ? context === true ? this : context : Messages.prototype;
  8176. for (k in obj) {
  8177. that[k] = obj[k];
  8178. }
  8179. }
  8180. // Rule converted factory
  8181. function _getRule(fn) {
  8182. switch ($.type(fn)) {
  8183. case 'function':
  8184. return fn;
  8185. case 'array':
  8186. var f = function() {
  8187. return fn[0].test(this.value) || fn[1] || false;
  8188. };
  8189. f.msg = fn[1];
  8190. return f;
  8191. case 'regexp':
  8192. return function() {
  8193. return fn.test(this.value);
  8194. };
  8195. }
  8196. }
  8197. // Get instance by an element
  8198. function _getInstance(el) {
  8199. var wrap, k, options;
  8200. if (!el || !el.tagName) return;
  8201. switch (el.tagName) {
  8202. case 'INPUT':
  8203. case 'SELECT':
  8204. case 'TEXTAREA':
  8205. case 'BUTTON':
  8206. case 'FIELDSET':
  8207. wrap = el.form || $(el).closest('.' + CLS_WRAPPER);
  8208. break;
  8209. case 'FORM':
  8210. wrap = el;
  8211. break;
  8212. default:
  8213. wrap = $(el).closest('.' + CLS_WRAPPER);
  8214. }
  8215. for (k in preinitialized) {
  8216. if ($(wrap).is(k)) {
  8217. options = preinitialized[k];
  8218. break;
  8219. }
  8220. }
  8221. return $(wrap).data(NS) || $(wrap)[NS](options).data(NS);
  8222. }
  8223. // Get custom rules on the node
  8224. function _getDataRule(el, method) {
  8225. var fn = trim(attr(el, DATA_RULE + '-' + method));
  8226. if ( fn && (fn = new Function('return ' + fn)()) ) {
  8227. return _getRule(fn);
  8228. }
  8229. }
  8230. // Get custom messages on the node
  8231. function _getDataMsg(el, field, m) {
  8232. var msg = field.msg,
  8233. item = field._r;
  8234. if ( isObject(msg) ) msg = msg[item];
  8235. if ( !isString(msg) ) {
  8236. msg = attr(el, DATA_MSG + '-' + item) || attr(el, DATA_MSG) || ( m ? isString(m) ? m : m[item] : '');
  8237. }
  8238. return msg;
  8239. }
  8240. // Get message position
  8241. function _getPos(str) {
  8242. var pos;
  8243. if (str) pos = rPos.exec(str);
  8244. return pos && pos[0];
  8245. }
  8246. // Check whether the element is checkbox or radio
  8247. function _checkable(el) {
  8248. return el.tagName === 'INPUT' && el.type === 'checkbox' || el.type === 'radio';
  8249. }
  8250. // Parse date string to timestamp
  8251. function _parseDate(str) {
  8252. return Date.parse(str.replace(/\.|\-/g, '/'));
  8253. }
  8254. // Rule name only allows alphanumeric characters and underscores
  8255. function _checkRuleName(name) {
  8256. return /^\w+$/.test(name);
  8257. }
  8258. // Translate field key to jQuery selector.
  8259. function _key2selector(key) {
  8260. var isID = key.charAt(0) === '#';
  8261. key = key.replace(/([:.{(|)}/\[\]])/g, '\\$1');
  8262. return isID ? key : '[name="'+ key +'"]:first';
  8263. }
  8264. // Fixed a issue cause by refresh page in IE.
  8265. $(window).on('beforeunload', function(){
  8266. this.focus();
  8267. });
  8268. $(document)
  8269. .on('click', ':submit', function(){
  8270. var input = this, attrNode;
  8271. if (!input.form) return;
  8272. // Shim for "formnovalidate"
  8273. attrNode = input.getAttributeNode('formnovalidate');
  8274. if (attrNode && attrNode.nodeValue !== null || attr(input, NOVALIDATE)!== null) {
  8275. novalidateonce = true;
  8276. }
  8277. })
  8278. // Automatic initializing form validation
  8279. .on('focusin submit validate', 'form,.'+CLS_WRAPPER, function(e) {
  8280. if ( attr(this, NOVALIDATE) !== null ) return;
  8281. var $form = $(this), me;
  8282. if ( !$form.data(NS) && (me = _getInstance(this)) ) {
  8283. if ( !$.isEmptyObject(me.fields) ) {
  8284. // Execute event handler
  8285. if (e.type === 'focusin') {
  8286. me._focusin(e);
  8287. } else {
  8288. me._submit(e);
  8289. }
  8290. } else {
  8291. attr(this, NOVALIDATE, NOVALIDATE);
  8292. $form.off(CLS_NS).removeData(NS);
  8293. }
  8294. }
  8295. });
  8296. new Messages({
  8297. fallback: 'This field is not valid.',
  8298. loading: 'Validating...'
  8299. });
  8300. // Built-in rules (global)
  8301. new Rules({
  8302. /**
  8303. * required
  8304. *
  8305. * @example:
  8306. required
  8307. required(jqSelector)
  8308. required(anotherRule)
  8309. required(not, -1)
  8310. required(from, .contact)
  8311. */
  8312. required: function(element, params) {
  8313. var me = this,
  8314. val = trim(me.value),
  8315. isValid = true;
  8316. if (params) {
  8317. if ( params.length === 1 ) {
  8318. if ( !_checkRuleName(params[0]) ) {
  8319. if (!val && !$(params[0], me.$el).length ) {
  8320. return null;
  8321. }
  8322. }
  8323. else if ( me.rules[params[0]] ) {
  8324. if ( !val && !me.test(element, params[0]) ) {
  8325. return null;
  8326. }
  8327. me._r = 'required'
  8328. }
  8329. }
  8330. else if ( params[0] === 'not' ) {
  8331. $.each(params.slice(1), function() {
  8332. return (isValid = val !== trim(this));
  8333. });
  8334. }
  8335. else if ( params[0] === 'from' ) {
  8336. var $elements = me.$el.find(params[1]),
  8337. VALIDATED = '_validated_',
  8338. ret;
  8339. isValid = $elements.filter(function(){
  8340. var field = me.getField(this);
  8341. return field && !!trim(field.getValue());
  8342. }).length >= (params[2] || 1);
  8343. if (isValid) {
  8344. if (!val) ret = null;
  8345. } else {
  8346. ret = _getDataMsg($elements[0], me) || false;
  8347. }
  8348. if ( !$(element).data(VALIDATED) ) {
  8349. $elements.data(VALIDATED, 1).each(function(){
  8350. if (element !== this) {
  8351. me._validate(this);
  8352. }
  8353. }).removeData(VALIDATED);
  8354. }
  8355. return ret;
  8356. }
  8357. }
  8358. return isValid && !!val;
  8359. },
  8360. /**
  8361. * integer
  8362. *
  8363. * @example:
  8364. integer
  8365. integer[+]
  8366. integer[+0]
  8367. integer[-]
  8368. integer[-0]
  8369. */
  8370. integer: function(element, params) {
  8371. var re, z = '0|',
  8372. p = '[1-9]\\d*',
  8373. key = params ? params[0] : '*';
  8374. switch (key) {
  8375. case '+':
  8376. re = p;
  8377. break;
  8378. case '-':
  8379. re = '-' + p;
  8380. break;
  8381. case '+0':
  8382. re = z + p;
  8383. break;
  8384. case '-0':
  8385. re = z + '-' + p;
  8386. break;
  8387. default:
  8388. re = z + '-?' + p;
  8389. }
  8390. re = '^(?:' + re + ')$';
  8391. return new RegExp(re).test(this.value) || (this.messages.integer && this.messages.integer[key]);
  8392. },
  8393. /**
  8394. * match another field
  8395. *
  8396. * @example:
  8397. match[password] Match the password field (two values ​​must be the same)
  8398. match[eq, password] Ditto
  8399. match[neq, count] The value must be not equal to the value of the count field
  8400. match[lt, count] The value must be less than the value of the count field
  8401. match[lte, count] The value must be less than or equal to the value of the count field
  8402. match[gt, count] The value must be greater than the value of the count field
  8403. match[gte, count] The value must be greater than or equal to the value of the count field
  8404. match[gte, startDate, date]
  8405. match[gte, startTime, time]
  8406. **/
  8407. match: function(element, params) {
  8408. if (!params) return;
  8409. var me = this,
  8410. isValid = true,
  8411. a, b,
  8412. key, msg, type = 'eq', parser,
  8413. selector2, elem2, field2;
  8414. if (params.length === 1) {
  8415. key = params[0];
  8416. } else {
  8417. type = params[0];
  8418. key = params[1];
  8419. }
  8420. selector2 = _key2selector(key);
  8421. elem2 = me.$el.find(selector2)[0];
  8422. // If the compared field is not exist
  8423. if (!elem2) return;
  8424. field2 = me.getField(elem2);
  8425. a = me.value;
  8426. b = field2.getValue();
  8427. if (!me._match) {
  8428. me.$el.on('valid'+CLS_NS_FIELD+CLS_NS, selector2, function(){
  8429. $(element).trigger('validate');
  8430. });
  8431. me._match = field2._match = 1;
  8432. }
  8433. // If both fields are blank
  8434. if (!me.required && a === '' && b === '') {
  8435. return null;
  8436. }
  8437. parser = params[2];
  8438. if (parser) {
  8439. if (/^date(time)?$/i.test(parser)) {
  8440. a = _parseDate(a);
  8441. b = _parseDate(b);
  8442. } else if (parser === 'time') {
  8443. a = +a.replace(/:/g, '');
  8444. b = +b.replace(/:/g, '');
  8445. }
  8446. }
  8447. // If the compared field is incorrect, we only ensure that this field is correct.
  8448. if (type !== 'eq' && !isNaN(+a) && isNaN(+b)) {
  8449. return true;
  8450. }
  8451. switch (type) {
  8452. case 'lt':
  8453. isValid = +a < +b; break;
  8454. case 'lte':
  8455. isValid = +a <= +b; break;
  8456. case 'gte':
  8457. isValid = +a >= +b; break;
  8458. case 'gt':
  8459. isValid = +a > +b; break;
  8460. case 'neq':
  8461. isValid = a !== b; break;
  8462. default:
  8463. isValid = a === b;
  8464. }
  8465. return isValid || (
  8466. isObject(me.messages.match)
  8467. && me.messages.match[type].replace( '{1}', me._getDisplay( elem2, field2.display || key ) )
  8468. );
  8469. },
  8470. /**
  8471. * range numbers
  8472. *
  8473. * @example:
  8474. range[0~99] Number 0-99
  8475. range[0~] Number greater than or equal to 0
  8476. range[~100] Number less than or equal to 100
  8477. **/
  8478. range: function(element, params) {
  8479. return this.getRangeMsg(this.value, params);
  8480. },
  8481. /**
  8482. * how many checkbox or radio inputs that checked
  8483. *
  8484. * @example:
  8485. checked; no empty, same to required
  8486. checked[1~3] 1-3 items
  8487. checked[1~] greater than 1 item
  8488. checked[~3] less than 3 items
  8489. checked[3] 3 items
  8490. **/
  8491. checked: function(element, params) {
  8492. if ( !_checkable(element) ) return;
  8493. var me = this,
  8494. elem, count;
  8495. if (element.name) {
  8496. count = me.$el.find('input[name="' + element.name + '"]').filter(function() {
  8497. var el = this;
  8498. if (!elem && _checkable(el)) elem = el;
  8499. return !el.disabled && el.checked;
  8500. }).length;
  8501. } else {
  8502. elem = element;
  8503. count = elem.checked;
  8504. }
  8505. if (params) {
  8506. return me.getRangeMsg(count, params);
  8507. } else {
  8508. return !!count || _getDataMsg(elem, me, '') || me.messages.required || false;
  8509. }
  8510. },
  8511. /**
  8512. * length of a characters (You can pass the second parameter "true", will calculate the length in bytes)
  8513. *
  8514. * @example:
  8515. length[6~16] 6-16 characters
  8516. length[6~] Greater than 6 characters
  8517. length[~16] Less than 16 characters
  8518. length[~16, true] Less than 16 characters, non-ASCII characters calculating two-character
  8519. **/
  8520. length: function(element, params) {
  8521. var value = this.value,
  8522. len = (params[1] === 'true' ? value.replace(rDoubleBytes, 'xx') : value).length;
  8523. return this.getRangeMsg(len, params, (params[1] ? '_2' : ''));
  8524. },
  8525. /**
  8526. * remote validation
  8527. *
  8528. * @description
  8529. * remote([get:]url [, name1, [name2 ...]]);
  8530. * Adaptation three kinds of results (Front for the successful, followed by a failure):
  8531. 1. text:
  8532. '' 'Error Message'
  8533. 2. json:
  8534. {"ok": ""} {"error": "Error Message"}
  8535. 3. json wrapper:
  8536. {"status": 1, "data": {"ok": ""}} {"status": 1, "data": {"error": "Error Message"}}
  8537. * @example
  8538. The simplest: remote(path/to/server);
  8539. With parameters: remote(path/to/server, name1, name2, ...);
  8540. By GET: remote(get:path/to/server, name1, name2, ...);
  8541. Name proxy: remote(path/to/server, name1, proxyname2:name2, proxyname3:#id3, ...)
  8542. Query String remote(path/to/server, foo=1&bar=2, name1, name2, ...)
  8543. CORS remote(cors:path/to/server)
  8544. JSONP remote(jsonp:path/to/server)
  8545. */
  8546. remote: function(element, params) {
  8547. if (!params) return;
  8548. var me = this,
  8549. arr = rAjaxType.exec(params[0]),
  8550. rule = me._rules[me._i],
  8551. data = {},
  8552. queryString = '',
  8553. url = arr[3],
  8554. type = arr[2] || 'POST', // GET / POST
  8555. rType = (arr[1] || this.validator.options.remoteDataType || '').toLowerCase(), // CORS / JSONP
  8556. dataType;
  8557. rule.must = true;
  8558. data[element.name] = me.value;
  8559. // There are extra fields
  8560. if (params[1]) {
  8561. $.map(params.slice(1), function(name) {
  8562. var arr, key;
  8563. if (~name.indexOf('=')) {
  8564. queryString += '&' + name;
  8565. } else {
  8566. arr = name.split(':');
  8567. name = trim(arr[0]);
  8568. key = trim(arr[1]) || name;
  8569. data[ name ] = me.$el.find( _key2selector(key) ).val();
  8570. }
  8571. });
  8572. }
  8573. data = $.param(data) + queryString;
  8574. if (!me.must && rule.data && rule.data === data) {
  8575. return rule.result;
  8576. }
  8577. // Cross-domain request, force jsonp dataType
  8578. if (rType !== 'cors' && /^https?:/.test(url) && !~url.indexOf(location.host)) {
  8579. dataType = 'jsonp';
  8580. }
  8581. // Asynchronous validation need return jqXHR objects
  8582. return $.ajax({
  8583. url: url,
  8584. type: type,
  8585. data: data,
  8586. dataType: dataType
  8587. });
  8588. },
  8589. /**
  8590. * filter characters, direct filtration without prompting error (support custom regular expressions)
  8591. *
  8592. * @example
  8593. * filter filtering unsafe characters
  8594. * filter(regexp) filtering the "regexp" matched characters
  8595. */
  8596. filter: function(element, params) {
  8597. var value = this.value,
  8598. temp = value.replace( params ? (new RegExp('[' + params[0] + ']', 'gm')) : rUnsafe, '' );
  8599. if (temp !== value) this.setValue(temp);
  8600. }
  8601. });
  8602. /**
  8603. * Config global options
  8604. *
  8605. * @static config
  8606. * @param {Object} options
  8607. */
  8608. Validator.config = function(key, value) {
  8609. if (isObject(key)) {
  8610. $.each(key, _config);
  8611. }
  8612. else if (isString(key)) {
  8613. _config(key, value);
  8614. }
  8615. function _config(k, o) {
  8616. if (k === 'rules') {
  8617. new Rules(o);
  8618. }
  8619. else if (k === 'messages') {
  8620. new Messages(o);
  8621. }
  8622. else if (k in fieldDefaults) {
  8623. fieldDefaults[k] = o;
  8624. }
  8625. else {
  8626. defaults[k] = o;
  8627. }
  8628. }
  8629. };
  8630. /**
  8631. * Config themes
  8632. *
  8633. * @static setTheme
  8634. * @param {String|Object} name
  8635. * @param {Object} obj
  8636. * @example
  8637. .setTheme( themeName, themeOptions )
  8638. .setTheme( multiThemes )
  8639. */
  8640. Validator.setTheme = function(name, obj) {
  8641. if ( isObject(name) ) {
  8642. $.extend(true, themes, name);
  8643. }
  8644. else if ( isString(name) && isObject(obj) ) {
  8645. themes[name] = $.extend(themes[name], obj);
  8646. }
  8647. };
  8648. /**
  8649. * Resource loader
  8650. *
  8651. * @static load
  8652. * @param {String} str
  8653. * @example
  8654. .load('local=zh-CN') // load: local/zh-CN.js and jquery.validator.css
  8655. .load('local=zh-CN&css=') // load: local/zh-CN.js
  8656. .load('local&css') // load: local/en.js (set <html lang="en">) and jquery.validator.css
  8657. .load('local') // dito
  8658. */
  8659. Validator.load = function(str) {
  8660. if (!str) return;
  8661. var doc = document,
  8662. params = {},
  8663. node = doc.scripts[0],
  8664. dir, el, ONLOAD;
  8665. str.replace(/([^?=&]+)=([^&#]*)/g, function(m, key, value){
  8666. params[key] = value;
  8667. });
  8668. dir = params.dir || Validator.dir;
  8669. if (!Validator.css && params.css !== '') {
  8670. el = doc.createElement('link');
  8671. el.rel = 'stylesheet';
  8672. el.href = Validator.css = dir + 'jquery.validator.css';
  8673. node.parentNode.insertBefore(el, node);
  8674. }
  8675. if (!Validator.local && ~str.indexOf('local') && params.local !== '') {
  8676. Validator.local = (params.local || doc.documentElement.lang || 'en').replace('_','-');
  8677. Validator.pending = 1;
  8678. el = doc.createElement('script');
  8679. el.src = dir + 'local/' + Validator.local + '.js';
  8680. ONLOAD = 'onload' in el ? 'onload' : 'onreadystatechange';
  8681. el[ONLOAD] = function() {
  8682. if (!el.readyState || /loaded|complete/.test(el.readyState)) {
  8683. el = el[ONLOAD] = null;
  8684. delete Validator.pending;
  8685. $(window).triggerHandler('validatorready');
  8686. }
  8687. };
  8688. node.parentNode.insertBefore(el, node);
  8689. }
  8690. };
  8691. // Auto loading resources
  8692. (function(){
  8693. var scripts = document.scripts,
  8694. i = scripts.length, node, arr,
  8695. re = /(.*validator(?:\.min)?.js)(\?.*(?:local|css|dir)(?:=[\w\-]*)?)?/;
  8696. while (i-- && !arr) {
  8697. node = scripts[i];
  8698. arr = (node.hasAttribute ? node.src : node.getAttribute('src',4)||'').match(re);
  8699. }
  8700. if (!arr) return;
  8701. Validator.dir = arr[1].split('/').slice(0, -1).join('/')+'/';
  8702. Validator.load(arr[2]);
  8703. })();
  8704. return $[NS] = Validator;
  8705. }));
  8706. /*********************************
  8707. * Themes, rules, and i18n support
  8708. * Locale: Chinese; 中文
  8709. *********************************/
  8710. (function(factory) {
  8711. typeof module === "object" && module.exports ? module.exports = factory( require( "jquery" ) ) :
  8712. typeof define === 'function' && define.amd ? define('validator-lang',['jquery'], factory) :
  8713. factory(jQuery);
  8714. }(function($) {
  8715. /* Global configuration
  8716. */
  8717. $.validator.config({
  8718. //stopOnError: true,
  8719. //focusCleanup: true,
  8720. //theme: 'yellow_right',
  8721. //timely: 2,
  8722. // Custom rules
  8723. rules: {
  8724. digits: [/^\d+$/, "请填写数字"]
  8725. ,letters: [/^[a-z]+$/i, "请填写字母"]
  8726. ,date: [/^\d{4}-\d{2}-\d{2}$/, "请填写有效的日期,格式:yyyy-mm-dd"]
  8727. ,time: [/^([01]\d|2[0-3])(:[0-5]\d){1,2}$/, "请填写有效的时间,00:00到23:59之间"]
  8728. ,email: [/^[\w\+\-]+(\.[\w\+\-]+)*@[a-z\d\-]+(\.[a-z\d\-]+)*\.([a-z]{2,4})$/i, "请填写有效的邮箱"]
  8729. ,url: [/^(https?|s?ftp):\/\/\S+$/i, "请填写有效的网址"]
  8730. ,qq: [/^[1-9]\d{4,}$/, "请填写有效的QQ号"]
  8731. ,IDcard: [/^\d{6}(19|2\d)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)?$/, "请填写正确的身份证号码"]
  8732. ,tel: [/^(?:(?:0\d{2,3}[\- ]?[1-9]\d{6,7})|(?:[48]00[\- ]?[1-9]\d{6}))$/, "请填写有效的电话号码"]
  8733. ,mobile: [/^1[3-9]\d{9}$/, "请填写有效的手机号"]
  8734. ,zipcode: [/^\d{6}$/, "请检查邮政编码格式"]
  8735. ,chinese: [/^[\u0391-\uFFE5]+$/, "请填写中文字符"]
  8736. ,username: [/^\w{3,12}$/, "请填写3-12位数字、字母、下划线"]
  8737. ,password: [/^[\S]{6,16}$/, "请填写6-16位字符,不能包含空格"]
  8738. ,accept: function (element, params){
  8739. if (!params) return true;
  8740. var ext = params[0],
  8741. value = $(element).val();
  8742. return (ext === '*') ||
  8743. (new RegExp(".(?:" + ext + ")$", "i")).test(value) ||
  8744. this.renderMsg("只接受{1}后缀的文件", ext.replace(/\|/g, ','));
  8745. }
  8746. },
  8747. // Default error messages
  8748. messages: {
  8749. 0: "此处",
  8750. fallback: "{0}格式不正确",
  8751. loading: "正在验证...",
  8752. error: "网络异常",
  8753. timeout: "请求超时",
  8754. required: "{0}不能为空",
  8755. remote: "{0}已被使用",
  8756. integer: {
  8757. '*': "请填写整数",
  8758. '+': "请填写正整数",
  8759. '+0': "请填写正整数或0",
  8760. '-': "请填写负整数",
  8761. '-0': "请填写负整数或0"
  8762. },
  8763. match: {
  8764. eq: "{0}与{1}不一致",
  8765. neq: "{0}与{1}不能相同",
  8766. lt: "{0}必须小于{1}",
  8767. gt: "{0}必须大于{1}",
  8768. lte: "{0}不能大于{1}",
  8769. gte: "{0}不能小于{1}"
  8770. },
  8771. range: {
  8772. rg: "请填写{1}到{2}的数",
  8773. gte: "请填写不小于{1}的数",
  8774. lte: "请填写最大{1}的数",
  8775. gtlt: "请填写{1}到{2}之间的数",
  8776. gt: "请填写大于{1}的数",
  8777. lt: "请填写小于{1}的数"
  8778. },
  8779. checked: {
  8780. eq: "请选择{1}项",
  8781. rg: "请选择{1}到{2}项",
  8782. gte: "请至少选择{1}项",
  8783. lte: "请最多选择{1}项"
  8784. },
  8785. length: {
  8786. eq: "请填写{1}个字符",
  8787. rg: "请填写{1}到{2}个字符",
  8788. gte: "请至少填写{1}个字符",
  8789. lte: "请最多填写{1}个字符",
  8790. eq_2: "",
  8791. rg_2: "",
  8792. gte_2: "",
  8793. lte_2: ""
  8794. }
  8795. }
  8796. });
  8797. /* Themes
  8798. */
  8799. var TPL_ARROW = '<span class="n-arrow"><b>◆</b><i>◆</i></span>';
  8800. $.validator.setTheme({
  8801. 'simple_right': {
  8802. formClass: 'n-simple',
  8803. msgClass: 'n-right'
  8804. },
  8805. 'simple_bottom': {
  8806. formClass: 'n-simple',
  8807. msgClass: 'n-bottom'
  8808. },
  8809. 'yellow_top': {
  8810. formClass: 'n-yellow',
  8811. msgClass: 'n-top',
  8812. msgArrow: TPL_ARROW
  8813. },
  8814. 'yellow_right': {
  8815. formClass: 'n-yellow',
  8816. msgClass: 'n-right',
  8817. msgArrow: TPL_ARROW
  8818. },
  8819. 'yellow_right_effect': {
  8820. formClass: 'n-yellow',
  8821. msgClass: 'n-right',
  8822. msgArrow: TPL_ARROW,
  8823. msgShow: function($msgbox, type){
  8824. var $el = $msgbox.children();
  8825. if ($el.is(':animated')) return;
  8826. if (type === 'error') {
  8827. $el.css({left: '20px', opacity: 0})
  8828. .delay(100).show().stop()
  8829. .animate({left: '-4px', opacity: 1}, 150)
  8830. .animate({left: '3px'}, 80)
  8831. .animate({left: 0}, 80);
  8832. } else {
  8833. $el.css({left: 0, opacity: 1}).fadeIn(200);
  8834. }
  8835. },
  8836. msgHide: function($msgbox, type){
  8837. var $el = $msgbox.children();
  8838. $el.stop().delay(100).show()
  8839. .animate({left: '20px', opacity: 0}, 300, function(){
  8840. $msgbox.hide();
  8841. });
  8842. }
  8843. }
  8844. });
  8845. }));
  8846. define('form',['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], function ($, undefined, Upload, Validator, undefined) {
  8847. var Form = {
  8848. config: {
  8849. 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>'
  8850. },
  8851. events: {
  8852. validator: function (form, success, error, submit) {
  8853. if (!form.is("form"))
  8854. return;
  8855. //绑定表单事件
  8856. form.validator($.extend({
  8857. rules: {
  8858. username: [/^\w{3,30}$/, __('Username must be 3 to 30 characters')],
  8859. password: [/^[\S]{6,30}$/, __('Password must be 6 to 30 characters')]
  8860. },
  8861. validClass: 'has-success',
  8862. invalidClass: 'has-error',
  8863. bindClassTo: '.form-group',
  8864. formClass: 'n-default n-bootstrap',
  8865. msgClass: 'n-right',
  8866. stopOnError: true,
  8867. display: function (elem) {
  8868. return $(elem).closest('.form-group').find(".control-label").text().replace(/\:/, '');
  8869. },
  8870. dataFilter: function (data) {
  8871. if (data.code === 1) {
  8872. return data.msg ? {"ok": data.msg} : '';
  8873. } else {
  8874. return data.msg;
  8875. }
  8876. },
  8877. target: function (input) {
  8878. var target = $(input).data("target");
  8879. if (target && $(target).length > 0) {
  8880. return $(target);
  8881. }
  8882. var $formitem = $(input).closest('.form-group'),
  8883. $msgbox = $formitem.find('span.msg-box');
  8884. if (!$msgbox.length) {
  8885. return [];
  8886. }
  8887. return $msgbox;
  8888. },
  8889. valid: function (ret) {
  8890. var that = this, submitBtn = $(".layer-footer [type=submit]", form);
  8891. that.holdSubmit(true);
  8892. submitBtn.addClass("disabled");
  8893. //验证通过提交表单
  8894. var submitResult = Form.api.submit($(ret), function (data, ret) {
  8895. that.holdSubmit(false);
  8896. submitBtn.removeClass("disabled");
  8897. if (false === $(this).triggerHandler("success.form", [data, ret])) {
  8898. return false;
  8899. }
  8900. if (typeof success === 'function') {
  8901. if (false === success.call($(this), data, ret)) {
  8902. return false;
  8903. }
  8904. }
  8905. //提示及关闭当前窗口
  8906. var msg = ret.hasOwnProperty("msg") && ret.msg !== "" ? ret.msg : __('Operation completed');
  8907. parent.Toastr.success(msg);
  8908. parent.$(".btn-refresh").trigger("click");
  8909. if (window.name) {
  8910. var index = parent.Layer.getFrameIndex(window.name);
  8911. parent.Layer.close(index);
  8912. }
  8913. return false;
  8914. }, function (data, ret) {
  8915. that.holdSubmit(false);
  8916. if (false === $(this).triggerHandler("error.form", [data, ret])) {
  8917. return false;
  8918. }
  8919. submitBtn.removeClass("disabled");
  8920. if (typeof error === 'function') {
  8921. if (false === error.call($(this), data, ret)) {
  8922. return false;
  8923. }
  8924. }
  8925. }, submit);
  8926. //如果提交失败则释放锁定
  8927. if (!submitResult) {
  8928. that.holdSubmit(false);
  8929. submitBtn.removeClass("disabled");
  8930. }
  8931. return false;
  8932. }
  8933. }, form.data("validator-options") || {}));
  8934. //移除提交按钮的disabled类
  8935. $(".layer-footer [type=submit],.fixed-footer [type=submit],.normal-footer [type=submit]", form).removeClass("disabled");
  8936. //自定义关闭按钮事件
  8937. form.on("click", ".layer-close", function () {
  8938. if (window.name) {
  8939. var index = parent.Layer.getFrameIndex(window.name);
  8940. parent.Layer.close(index);
  8941. }
  8942. return false;
  8943. });
  8944. },
  8945. selectpicker: function (form) {
  8946. //绑定select元素事件
  8947. if ($(".selectpicker", form).length > 0) {
  8948. require(['bootstrap-select', 'bootstrap-select-lang'], function () {
  8949. $('.selectpicker', form).selectpicker();
  8950. $(form).on("reset", function () {
  8951. setTimeout(function () {
  8952. $('.selectpicker').selectpicker('refresh').trigger("change");
  8953. }, 1);
  8954. });
  8955. });
  8956. }
  8957. },
  8958. selectpage: function (form) {
  8959. //绑定selectpage元素事件
  8960. if ($(".selectpage", form).length > 0) {
  8961. require(['selectpage'], function () {
  8962. $('.selectpage', form).selectPage({
  8963. eAjaxSuccess: function (data) {
  8964. data.list = typeof data.rows !== 'undefined' ? data.rows : (typeof data.list !== 'undefined' ? data.list : []);
  8965. data.totalRow = typeof data.total !== 'undefined' ? data.total : (typeof data.totalRow !== 'undefined' ? data.totalRow : data.list.length);
  8966. return data;
  8967. }
  8968. });
  8969. });
  8970. //给隐藏的元素添加上validate验证触发事件
  8971. $(document).on("change", ".sp_hidden", function () {
  8972. $(this).trigger("validate");
  8973. });
  8974. $(document).on("change", ".sp_input", function () {
  8975. $(this).closest(".sp_container").find(".sp_hidden").trigger("change");
  8976. });
  8977. $(form).on("reset", function () {
  8978. setTimeout(function () {
  8979. $(".selectpage", form).each(function () {
  8980. var selectpage = $(this).data("selectPageObject");
  8981. selectpage.elem.hidden.val($(this).val());
  8982. $(this).selectPageRefresh();
  8983. });
  8984. }, 1);
  8985. });
  8986. }
  8987. },
  8988. cxselect: function (form) {
  8989. //绑定cxselect元素事件
  8990. if ($("[data-toggle='cxselect']", form).length > 0) {
  8991. require(['cxselect'], function () {
  8992. $.cxSelect.defaults.jsonName = 'name';
  8993. $.cxSelect.defaults.jsonValue = 'value';
  8994. $.cxSelect.defaults.jsonSpace = 'data';
  8995. $("[data-toggle='cxselect']", form).cxSelect();
  8996. });
  8997. }
  8998. },
  8999. citypicker: function (form) {
  9000. //绑定城市远程插件
  9001. if ($("[data-toggle='city-picker']", form).length > 0) {
  9002. require(['citypicker'], function () {
  9003. $(form).on("reset", function () {
  9004. setTimeout(function () {
  9005. $("[data-toggle='city-picker']").citypicker('refresh');
  9006. }, 1);
  9007. });
  9008. });
  9009. }
  9010. },
  9011. datetimepicker: function (form) {
  9012. //绑定日期时间元素事件
  9013. if ($(".datetimepicker", form).length > 0) {
  9014. require(['bootstrap-datetimepicker'], function () {
  9015. var options = {
  9016. format: 'YYYY-MM-DD HH:mm:ss',
  9017. icons: {
  9018. time: 'fa fa-clock-o',
  9019. date: 'fa fa-calendar',
  9020. up: 'fa fa-chevron-up',
  9021. down: 'fa fa-chevron-down',
  9022. previous: 'fa fa-chevron-left',
  9023. next: 'fa fa-chevron-right',
  9024. today: 'fa fa-history',
  9025. clear: 'fa fa-trash',
  9026. close: 'fa fa-remove'
  9027. },
  9028. showTodayButton: true,
  9029. showClose: true
  9030. };
  9031. $('.datetimepicker', form).parent().css('position', 'relative');
  9032. $('.datetimepicker', form).datetimepicker(options).on('dp.change', function (e) {
  9033. $(this, document).trigger("changed");
  9034. });
  9035. });
  9036. }
  9037. },
  9038. daterangepicker: function (form) {
  9039. //绑定日期时间元素事件
  9040. if ($(".datetimerange", form).length > 0) {
  9041. require(['bootstrap-daterangepicker'], function () {
  9042. var ranges = {};
  9043. ranges[__('Today')] = [Moment().startOf('day'), Moment().endOf('day')];
  9044. ranges[__('Yesterday')] = [Moment().subtract(1, 'days').startOf('day'), Moment().subtract(1, 'days').endOf('day')];
  9045. ranges[__('Last 7 Days')] = [Moment().subtract(6, 'days').startOf('day'), Moment().endOf('day')];
  9046. ranges[__('Last 30 Days')] = [Moment().subtract(29, 'days').startOf('day'), Moment().endOf('day')];
  9047. ranges[__('This Month')] = [Moment().startOf('month'), Moment().endOf('month')];
  9048. ranges[__('Last Month')] = [Moment().subtract(1, 'month').startOf('month'), Moment().subtract(1, 'month').endOf('month')];
  9049. var options = {
  9050. timePicker: false,
  9051. autoUpdateInput: false,
  9052. timePickerSeconds: true,
  9053. timePicker24Hour: true,
  9054. autoApply: true,
  9055. locale: {
  9056. format: 'YYYY-MM-DD HH:mm:ss',
  9057. customRangeLabel: __("Custom Range"),
  9058. applyLabel: __("Apply"),
  9059. cancelLabel: __("Clear"),
  9060. },
  9061. ranges: ranges,
  9062. };
  9063. var origincallback = function (start, end) {
  9064. $(this.element).val(start.format(this.locale.format) + " - " + end.format(this.locale.format));
  9065. $(this.element).trigger('change');
  9066. };
  9067. $(".datetimerange", form).each(function () {
  9068. var callback = typeof $(this).data('callback') == 'function' ? $(this).data('callback') : origincallback;
  9069. $(this).on('apply.daterangepicker', function (ev, picker) {
  9070. callback.call(picker, picker.startDate, picker.endDate);
  9071. });
  9072. $(this).on('cancel.daterangepicker', function (ev, picker) {
  9073. $(this).val('').trigger('change');
  9074. });
  9075. $(this).daterangepicker($.extend(true, {}, options, $(this).data() || {}, $(this).data("daterangepicker-options") || {}));
  9076. });
  9077. });
  9078. }
  9079. },
  9080. /**
  9081. * 绑定上传事件
  9082. * @param form
  9083. * @deprecated Use faupload instead.
  9084. */
  9085. plupload: function (form) {
  9086. Form.events.faupload(form);
  9087. },
  9088. /**
  9089. * 绑定上传事件
  9090. * @param form
  9091. */
  9092. faupload: function (form) {
  9093. //绑定上传元素事件
  9094. if ($(".plupload,.faupload", form).length > 0) {
  9095. Upload.api.upload($(".plupload,.faupload", form));
  9096. }
  9097. },
  9098. faselect: function (form) {
  9099. //绑定fachoose选择附件事件
  9100. if ($(".faselect,.fachoose", form).length > 0) {
  9101. $(".faselect,.fachoose", form).off('click').on('click', function () {
  9102. var that = this;
  9103. var multiple = $(this).data("multiple") ? $(this).data("multiple") : false;
  9104. var mimetype = $(this).data("mimetype") ? $(this).data("mimetype") : '';
  9105. var admin_id = $(this).data("admin-id") ? $(this).data("admin-id") : '';
  9106. var user_id = $(this).data("user-id") ? $(this).data("user-id") : '';
  9107. mimetype = mimetype.replace(/\/\*/ig, '/');
  9108. var url = $(this).data("url") ? $(this).data("url") : (typeof Backend !== 'undefined' ? "general/attachment/select" : "user/attachment");
  9109. parent.Fast.api.open(url + "?element_id=" + $(this).attr("id") + "&multiple=" + multiple + "&mimetype=" + mimetype + "&admin_id=" + admin_id + "&user_id=" + user_id, __('Choose'), {
  9110. callback: function (data) {
  9111. var button = $(that);
  9112. var maxcount = $(button).data("maxcount");
  9113. var input_id = $(button).data("input-id") ? $(button).data("input-id") : "";
  9114. maxcount = typeof maxcount !== "undefined" ? maxcount : 0;
  9115. if (input_id && data.multiple) {
  9116. var urlArr = [];
  9117. var inputObj = $("#" + input_id);
  9118. var value = $.trim(inputObj.val());
  9119. if (value !== "") {
  9120. urlArr.push(inputObj.val());
  9121. }
  9122. var nums = value === '' ? 0 : value.split(/\,/).length;
  9123. var files = data.url !== "" ? data.url.split(/\,/) : [];
  9124. $.each(files, function (i, j) {
  9125. var url = Config.upload.fullmode ? Fast.api.cdnurl(j) : j;
  9126. urlArr.push(url);
  9127. });
  9128. if (maxcount > 0) {
  9129. var remains = maxcount - nums;
  9130. if (files.length > remains) {
  9131. Toastr.error(__('You can choose up to %d file%s', remains));
  9132. return false;
  9133. }
  9134. }
  9135. var result = urlArr.join(",");
  9136. inputObj.val(result).trigger("change").trigger("validate");
  9137. } else if (input_id) {
  9138. var url = Config.upload.fullmode ? Fast.api.cdnurl(data.url) : data.url;
  9139. $("#" + input_id).val(url).trigger("change").trigger("validate");
  9140. }
  9141. }
  9142. });
  9143. return false;
  9144. });
  9145. }
  9146. },
  9147. fieldlist: function (form) {
  9148. //绑定fieldlist
  9149. if ($(".fieldlist", form).length > 0) {
  9150. require(['dragsort', 'template'], function (undefined, Template) {
  9151. //刷新隐藏textarea的值
  9152. var refresh = function (container) {
  9153. var data = {};
  9154. var name = container.data("name");
  9155. var textarea = $("textarea[name='" + name + "']", form);
  9156. var template = container.data("template");
  9157. $.each($("input,select,textarea", container).serializeArray(), function (i, j) {
  9158. var reg = /\[(\w+)\]\[(\w+)\]$/g;
  9159. var match = reg.exec(j.name);
  9160. if (!match)
  9161. return true;
  9162. match[1] = "x" + parseInt(match[1]);
  9163. if (typeof data[match[1]] == 'undefined') {
  9164. data[match[1]] = {};
  9165. }
  9166. data[match[1]][match[2]] = j.value;
  9167. });
  9168. //使用数组保存
  9169. var usearray = container.data("usearray") || false;
  9170. //保留空数据
  9171. var keepempty = container.data("keepempty") || false;
  9172. var result = template || usearray ? [] : {};
  9173. var keys = Object.keys(Object.values(data)[0] || {});
  9174. var isassociative = !usearray && keys.indexOf("value") > -1 && (keys.length === 1 || (keys.length === 2 && keys.indexOf("key") > -1));
  9175. if(isassociative && keys.length ===2){
  9176. result = {};
  9177. }
  9178. $.each(data, function (i, j) {
  9179. if (j) {
  9180. if (isassociative) {
  9181. if (keys.length === 2) {
  9182. if (j.key != '' || keepempty) {
  9183. result['__PLACEHOLDKEY__' + j.key] = j.value;
  9184. }
  9185. } else {
  9186. //一维数组
  9187. result.push(j.value);
  9188. }
  9189. } else {
  9190. result.push(j);
  9191. }
  9192. }
  9193. });
  9194. textarea.val(JSON.stringify(result).replace(/__PLACEHOLDKEY__/g, ''));
  9195. };
  9196. //追加一行数据
  9197. var append = function (container, row, initial) {
  9198. var tagName = container.data("tag") || (container.is("table") ? "tr" : "dd");
  9199. var index = container.data("index");
  9200. var name = container.data("name");
  9201. var template = container.data("template");
  9202. var data = container.data();
  9203. index = index ? parseInt(index) : 0;
  9204. container.data("index", index + 1);
  9205. row = row ? row : {};
  9206. row = typeof row.key === 'undefined' || typeof row.value === 'undefined' ? {key: '', value: row} : row;
  9207. var options = container.data("fieldlist-options") || {};
  9208. var vars = {index: index, name: name, data: data, options: options, key: row.key, value: row.value, row: row.value};
  9209. var html = template ? Template(template, vars) : Template.render(Form.config.fieldlisttpl, vars);
  9210. var obj = $(html);
  9211. if ((options.deleteBtn === false || options.removeBtn === false) && initial)
  9212. obj.find(".btn-remove").remove();
  9213. if (options.dragsortBtn === false && initial)
  9214. obj.find(".btn-dragsort").remove();
  9215. if ((options.readonlyKey === true || options.disableKey === true) && initial) {
  9216. obj.find("input[name$='[key]']").prop("readonly", true);
  9217. }
  9218. obj.attr("fieldlist-item", true);
  9219. obj.insertAfter($(tagName + "[fieldlist-item]", container).length > 0 ? $(tagName + "[fieldlist-item]:last", container) : $(tagName + ":first", container));
  9220. if ($(".btn-append,.append", container).length > 0) {
  9221. //兼容旧版本事件
  9222. $(".btn-append,.append", container).trigger("fa.event.appendfieldlist", obj);
  9223. } else {
  9224. //新版本事件
  9225. container.trigger("fa.event.appendfieldlist", obj);
  9226. }
  9227. return obj;
  9228. };
  9229. var fieldlist = $(".fieldlist", form);
  9230. //表单重置
  9231. form.on("reset", function () {
  9232. setTimeout(function () {
  9233. fieldlist.trigger("fa.event.refreshfieldlist");
  9234. });
  9235. });
  9236. //监听文本框改变事件
  9237. $(document).on('change keyup changed', ".fieldlist input,.fieldlist textarea,.fieldlist select", function () {
  9238. var container = $(this).closest(".fieldlist");
  9239. refresh(container);
  9240. });
  9241. //追加控制(点击按钮)
  9242. fieldlist.on("click", ".btn-append,.append", function (e, row) {
  9243. var container = $(this).closest(".fieldlist");
  9244. append(container, row);
  9245. refresh(container);
  9246. });
  9247. //移除控制(点击按钮)
  9248. fieldlist.on("click", ".btn-remove", function () {
  9249. var container = $(this).closest(".fieldlist");
  9250. var tagName = container.data("tag") || (container.is("table") ? "tr" : "dd");
  9251. $(this).closest(tagName).remove();
  9252. refresh(container);
  9253. });
  9254. //追加控制(通过事件)
  9255. fieldlist.on("fa.event.appendtofieldlist", function (e, row) {
  9256. var container = $(this);
  9257. append(container, row);
  9258. refresh(container);
  9259. });
  9260. //根据textarea内容重新渲染
  9261. fieldlist.on("fa.event.refreshfieldlist", function () {
  9262. var container = $(this);
  9263. var textarea = $("textarea[name='" + container.data("name") + "']", form);
  9264. //先清空已有的数据
  9265. $("[fieldlist-item]", container).remove();
  9266. var json = {};
  9267. try {
  9268. var val = textarea.val().replace(/"(\d+)"\:/g, "\"__PLACEHOLDERKEY__$1\":");
  9269. json = JSON.parse(val);
  9270. } catch (e) {
  9271. }
  9272. $.each(json, function (i, j) {
  9273. append(container, {key: i.toString().replace("__PLACEHOLDERKEY__", ""), value: j}, true);
  9274. });
  9275. });
  9276. //拖拽排序
  9277. fieldlist.each(function () {
  9278. var container = $(this);
  9279. var tagName = container.data("tag") || (container.is("table") ? "tr" : "dd");
  9280. container.dragsort({
  9281. itemSelector: tagName,
  9282. dragSelector: ".btn-dragsort",
  9283. dragEnd: function () {
  9284. refresh(container);
  9285. },
  9286. placeHolderTemplate: $("<" + tagName + "/>")
  9287. });
  9288. if (typeof container.data("options") === 'object' && container.data("options").appendBtn === false) {
  9289. $(".btn-append,.append", container).hide();
  9290. }
  9291. $("textarea[name='" + container.data("name") + "']", form).on("fa.event.refreshfieldlist", function () {
  9292. //兼容旧版本事件
  9293. $(this).closest(".fieldlist").trigger("fa.event.refreshfieldlist");
  9294. });
  9295. });
  9296. fieldlist.trigger("fa.event.refreshfieldlist");
  9297. });
  9298. }
  9299. },
  9300. switcher: function (form) {
  9301. form.on("click", "[data-toggle='switcher']", function () {
  9302. if ($(this).hasClass("disabled")) {
  9303. return false;
  9304. }
  9305. var switcher = $.proxy(function () {
  9306. var input = $(this).prev("input");
  9307. input = $(this).data("input-id") ? $("#" + $(this).data("input-id")) : input;
  9308. if (input.length > 0) {
  9309. var yes = $(this).data("yes");
  9310. var no = $(this).data("no");
  9311. if (input.val() == yes) {
  9312. input.val(no);
  9313. $("i", this).addClass("fa-flip-horizontal text-gray");
  9314. } else {
  9315. input.val(yes);
  9316. $("i", this).removeClass("fa-flip-horizontal text-gray");
  9317. }
  9318. input.trigger('change');
  9319. }
  9320. }, this);
  9321. if (typeof $(this).data("confirm") !== 'undefined') {
  9322. Layer.confirm($(this).data("confirm"), function (index) {
  9323. switcher();
  9324. Layer.close(index);
  9325. });
  9326. } else {
  9327. switcher();
  9328. }
  9329. return false;
  9330. });
  9331. },
  9332. bindevent: function (form) {
  9333. },
  9334. slider: function (form) {
  9335. if ($("[data-role='slider'],input.slider", form).length > 0) {
  9336. require(['bootstrap-slider'], function () {
  9337. $("[data-role='slider'],input.slider").removeClass('hidden').css('width', function (index, value) {
  9338. return $(this).parents('.form-control').width();
  9339. }).slider().on('slide', function (ev) {
  9340. var data = $(this).data();
  9341. if (typeof data.unit !== 'undefined') {
  9342. $(this).parents('.form-control').siblings('.value').text(ev.value + data.unit);
  9343. }
  9344. });
  9345. });
  9346. }
  9347. },
  9348. tagsinput: function (form) {
  9349. if ($("[data-role='tagsinput']", form).length > 0) {
  9350. require(['tagsinput', 'autocomplete'], function () {
  9351. $("[data-role='tagsinput']").tagsinput();
  9352. form.on("reset", function () {
  9353. setTimeout(function () {
  9354. $("[data-role='tagsinput']").tagsinput('reset');
  9355. }, 0);
  9356. });
  9357. });
  9358. }
  9359. },
  9360. autocomplete: function (form) {
  9361. if ($("[data-role='autocomplete']", form).length > 0) {
  9362. require(['autocomplete'], function () {
  9363. $("[data-role='autocomplete']").autocomplete({
  9364. onSelect: function () {
  9365. $(this).trigger('change').trigger('validate');
  9366. }
  9367. });
  9368. });
  9369. }
  9370. },
  9371. favisible: function (form) {
  9372. if ($("[data-favisible]", form).length == 0) {
  9373. return;
  9374. }
  9375. var checkCondition = function (condition) {
  9376. var conditionArr = condition.split(/&&/);
  9377. var success = 0;
  9378. var baseregex = /^([a-z0-9\_]+)([>|<|=|\!]=?)(.*)$/i, strregex = /^('|")(.*)('|")$/, regregex = /^regex:(.*)$/;
  9379. // @formatter:off
  9380. var operator_result = {
  9381. '>': function (a, b) {
  9382. return a > b;
  9383. },
  9384. '>=': function (a, b) {
  9385. return a >= b;
  9386. },
  9387. '<': function (a, b) {
  9388. return a < b;
  9389. },
  9390. '<=': function (a, b) {
  9391. return a <= b;
  9392. },
  9393. '==': function (a, b) {
  9394. return a == b;
  9395. },
  9396. '!=': function (a, b) {
  9397. return a != b;
  9398. },
  9399. 'in': function (a, b) {
  9400. return b.split(/\,/).indexOf(a) > -1;
  9401. },
  9402. 'regex': function (a, b) {
  9403. var regParts = b.match(/^\/(.*?)\/([gim]*)$/);
  9404. var regexp = regParts ? new RegExp(regParts[1], regParts[2]) : new RegExp(b);
  9405. return regexp.test(a);
  9406. }
  9407. };
  9408. // @formatter:on
  9409. var dataArr = form.serializeArray(), dataObj = {}, fieldName, fieldValue;
  9410. $(dataArr).each(function (i, field) {
  9411. fieldName = field.name;
  9412. fieldValue = field.value;
  9413. fieldName = fieldName.substr(-2) === '[]' ? fieldName.substr(0, fieldName.length - 2) : fieldName;
  9414. dataObj[fieldName] = typeof dataObj[fieldName] !== 'undefined' ? [dataObj[fieldName], fieldValue].join(',') : fieldValue;
  9415. });
  9416. $.each(conditionArr, function (i, item) {
  9417. var basematches = baseregex.exec(item);
  9418. if (basematches) {
  9419. var name = basematches[1], operator = basematches[2], value = basematches[3].toString();
  9420. if (operator === '=') {
  9421. var strmatches = strregex.exec(value);
  9422. operator = strmatches ? '==' : 'in';
  9423. value = strmatches ? strmatches[2] : value;
  9424. }
  9425. var regmatches = regregex.exec(value);
  9426. if (regmatches) {
  9427. operator = 'regex';
  9428. value = regmatches[1];
  9429. }
  9430. var chkname = "row[" + name + "]";
  9431. if (typeof dataObj[chkname] === 'undefined') {
  9432. return false;
  9433. }
  9434. var objvalue = dataObj[chkname];
  9435. if ($.isArray(objvalue)) {
  9436. objvalue = dataObj[chkname].join(",");
  9437. }
  9438. if (['>', '>=', '<', '<='].indexOf(operator) > -1) {
  9439. objvalue = parseFloat(objvalue);
  9440. value = parseFloat(value);
  9441. }
  9442. var result = operator_result[operator](objvalue, value);
  9443. success += (result ? 1 : 0);
  9444. }
  9445. });
  9446. return success === conditionArr.length;
  9447. };
  9448. form.on("keyup change click configchange", "input,textarea,select", function () {
  9449. $("[data-favisible][data-favisible!='']", form).each(function () {
  9450. var visible = $(this).data("favisible");
  9451. var groupArr = visible ? visible.toString().split(/\|\|/) : [];
  9452. var success = 0;
  9453. $.each(groupArr, function (i, j) {
  9454. if (checkCondition(j)) {
  9455. success++;
  9456. }
  9457. });
  9458. if (success > 0) {
  9459. $(this).removeClass("hidden");
  9460. } else {
  9461. $(this).addClass("hidden");
  9462. }
  9463. });
  9464. });
  9465. //追加上忽略元素
  9466. setTimeout(function () {
  9467. var validator = form.data('validator');
  9468. if (validator) {
  9469. validator.options.ignore += ((validator.options.ignore ? ',' : '') + '.hidden[data-favisible] :hidden,.hidden[data-favisible]:hidden');
  9470. }
  9471. }, 0);
  9472. $("input,textarea,select", form).trigger("configchange");
  9473. }
  9474. },
  9475. api: {
  9476. submit: function (form, success, error, submit) {
  9477. if (form.length === 0) {
  9478. Toastr.error("表单未初始化完成,无法提交");
  9479. return false;
  9480. }
  9481. if (typeof submit === 'function') {
  9482. if (false === submit.call(form, success, error)) {
  9483. return false;
  9484. }
  9485. }
  9486. var type = form.attr("method") ? form.attr("method").toUpperCase() : 'GET';
  9487. type = type && (type === 'GET' || type === 'POST') ? type : 'GET';
  9488. url = form.attr("action");
  9489. url = url ? url : location.href;
  9490. //修复当存在多选项元素时提交的BUG
  9491. var params = {};
  9492. var multipleList = $("[name$='[]']", form);
  9493. if (multipleList.length > 0) {
  9494. var postFields = form.serializeArray().map(function (obj) {
  9495. return $(obj).prop("name");
  9496. });
  9497. $.each(multipleList, function (i, j) {
  9498. if (postFields.indexOf($(this).prop("name")) < 0) {
  9499. params[$(this).prop("name")] = '';
  9500. }
  9501. });
  9502. }
  9503. //调用Ajax请求方法
  9504. Fast.api.ajax({
  9505. type: type,
  9506. url: url,
  9507. data: form.serialize() + (Object.keys(params).length > 0 ? '&' + $.param(params) : ''),
  9508. dataType: 'json',
  9509. complete: function (xhr) {
  9510. var token = xhr.getResponseHeader('__token__');
  9511. if (token) {
  9512. $("input[name='__token__']").val(token);
  9513. }
  9514. }
  9515. }, function (data, ret) {
  9516. $('.form-group', form).removeClass('has-feedback has-success has-error');
  9517. if (data && typeof data === 'object') {
  9518. //刷新客户端token
  9519. if (typeof data.token !== 'undefined') {
  9520. $("input[name='__token__']").val(data.token);
  9521. }
  9522. //调用客户端事件
  9523. if (typeof data.callback !== 'undefined' && typeof data.callback === 'function') {
  9524. data.callback.call(form, data);
  9525. }
  9526. }
  9527. if (typeof success === 'function') {
  9528. if (false === success.call(form, data, ret)) {
  9529. return false;
  9530. }
  9531. }
  9532. }, function (data, ret) {
  9533. if (data && typeof data === 'object' && typeof data.token !== 'undefined') {
  9534. $("input[name='__token__']").val(data.token);
  9535. }
  9536. if (typeof error === 'function') {
  9537. if (false === error.call(form, data, ret)) {
  9538. return false;
  9539. }
  9540. }
  9541. });
  9542. return true;
  9543. },
  9544. bindevent: function (form, success, error, submit) {
  9545. form = typeof form === 'object' ? form : $(form);
  9546. var events = Form.events;
  9547. events.bindevent(form);
  9548. events.validator(form, success, error, submit);
  9549. events.selectpicker(form);
  9550. events.daterangepicker(form);
  9551. events.selectpage(form);
  9552. events.cxselect(form);
  9553. events.citypicker(form);
  9554. events.datetimepicker(form);
  9555. events.faupload(form);
  9556. events.faselect(form);
  9557. events.fieldlist(form);
  9558. events.slider(form);
  9559. events.switcher(form);
  9560. events.tagsinput(form);
  9561. events.autocomplete(form);
  9562. events.favisible(form);
  9563. },
  9564. custom: {}
  9565. },
  9566. };
  9567. return Form;
  9568. });
  9569. /**
  9570. * FastAdmin通用搜索
  9571. *
  9572. * @author: pppscn <35696959@qq.com>
  9573. * @update 2017-05-07 <https://gitee.com/pp/fastadmin>
  9574. *
  9575. * @author: Karson <karson@fastadmin.net>
  9576. * @update 2018-04-05 <https://gitee.com/karson/fastadmin>
  9577. */
  9578. !function ($) {
  9579. 'use strict';
  9580. var ColumnsForSearch = [];
  9581. var sprintf = $.fn.bootstrapTable.utils.sprintf;
  9582. var initCommonSearch = function (pColumns, that) {
  9583. var vFormCommon = createFormCommon(pColumns, that);
  9584. var vModal = sprintf("<div class=\"commonsearch-table %s\">", that.options.searchFormVisible ? "" : "hidden");
  9585. vModal += vFormCommon;
  9586. vModal += "</div>";
  9587. that.$container.prepend($(vModal));
  9588. that.$commonsearch = $(".commonsearch-table", that.$container);
  9589. var form = $("form.form-commonsearch", that.$commonsearch);
  9590. require(['form'], function (Form) {
  9591. Form.api.bindevent(form);
  9592. form.validator("destroy");
  9593. });
  9594. // 表单提交
  9595. form.on("submit", function (event) {
  9596. event.preventDefault();
  9597. that.onCommonSearch();
  9598. return false;
  9599. });
  9600. // 重置搜索
  9601. form.on("click", "button[type=reset]", function (event) {
  9602. form[0].reset();
  9603. setTimeout(function () {
  9604. that.onCommonSearch();
  9605. }, 1);
  9606. });
  9607. };
  9608. var createFormCommon = function (pColumns, that) {
  9609. // 如果有使用模板则直接返回模板的内容
  9610. if (that.options.searchFormTemplate) {
  9611. return Template(that.options.searchFormTemplate, {columns: pColumns, table: that});
  9612. }
  9613. var htmlForm = [];
  9614. htmlForm.push(sprintf('<form class="form-horizontal form-commonsearch" novalidate method="post" action="%s" >', that.options.actionForm));
  9615. htmlForm.push('<fieldset>');
  9616. if (that.options.titleForm.length > 0)
  9617. htmlForm.push(sprintf("<legend>%s</legend>", that.options.titleForm));
  9618. htmlForm.push('<div class="row">');
  9619. for (var i in pColumns) {
  9620. var vObjCol = pColumns[i];
  9621. if (!vObjCol.checkbox && !vObjCol.radio && vObjCol.field && vObjCol.field !== 'operate' && vObjCol.searchable && vObjCol.operate !== false) {
  9622. var query = Fast.api.query(vObjCol.field);
  9623. var operate = Fast.api.query(vObjCol.field + "-operate");
  9624. var renderDefault = that.options.renderDefault && (typeof vObjCol.renderDefault == 'undefined' || vObjCol.renderDefault);
  9625. vObjCol.defaultValue = renderDefault && query ? query : (typeof vObjCol.defaultValue === 'undefined' ? '' : vObjCol.defaultValue);
  9626. vObjCol.operate = renderDefault && operate ? operate : (typeof vObjCol.operate === 'undefined' ? '=' : vObjCol.operate);
  9627. ColumnsForSearch.push(vObjCol);
  9628. htmlForm.push('<div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">');
  9629. htmlForm.push(sprintf('<label for="%s" class="control-label col-xs-4">%s</label>', vObjCol.field, vObjCol.title));
  9630. htmlForm.push('<div class="col-xs-8">');
  9631. vObjCol.operate = vObjCol.operate ? vObjCol.operate.toUpperCase() : '=';
  9632. 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));
  9633. var addClass = typeof vObjCol.addClass === 'undefined' ? (typeof vObjCol.addclass === 'undefined' ? 'form-control' : 'form-control ' + vObjCol.addclass) : 'form-control ' + vObjCol.addClass;
  9634. var extend = typeof vObjCol.extend === 'undefined' ? '' : vObjCol.extend;
  9635. var style = typeof vObjCol.style === 'undefined' ? '' : sprintf('style="%s"', vObjCol.style);
  9636. extend = typeof vObjCol.data !== 'undefined' && extend == '' ? vObjCol.data : extend;
  9637. extend = typeof vObjCol.autocomplete !== 'undefined' ? extend + ' autocomplete="' + (vObjCol.autocomplete === false || vObjCol.autocomplete === 'off' ? 'off' : 'on') + '"' : extend;
  9638. if (vObjCol.searchList) {
  9639. if (typeof vObjCol.searchList === 'function') {
  9640. htmlForm.push(vObjCol.searchList.call(this, vObjCol));
  9641. } else {
  9642. var optionList = [sprintf('<option value="">%s</option>', that.options.formatCommonChoose())];
  9643. if (typeof vObjCol.searchList === 'object' && typeof vObjCol.searchList.then === 'function') {
  9644. (function (vObjCol, that) {
  9645. $.when(vObjCol.searchList).done(function (ret) {
  9646. var searchList = [];
  9647. if (ret.data && ret.data.searchlist && $.isArray(ret.data.searchlist)) {
  9648. searchList = ret.data.searchlist;
  9649. } else if (ret.constructor === Array || ret.constructor === Object) {
  9650. searchList = ret;
  9651. }
  9652. var optionList = createOptionList(searchList, vObjCol, that);
  9653. $("form.form-commonsearch select[name='" + vObjCol.field + "']", that.$container).html(optionList.join('')).trigger("change");
  9654. });
  9655. })(vObjCol, that);
  9656. } else {
  9657. optionList = createOptionList(vObjCol.searchList, vObjCol, that);
  9658. }
  9659. htmlForm.push(sprintf('<select class="%s" name="%s" %s %s>%s</select>', addClass, vObjCol.field, style, extend, optionList.join('')));
  9660. }
  9661. } else {
  9662. var placeholder = typeof vObjCol.placeholder === 'undefined' ? vObjCol.title : vObjCol.placeholder;
  9663. var type = typeof vObjCol.type === 'undefined' ? 'text' : vObjCol.type;
  9664. var defaultValue = typeof vObjCol.defaultValue === 'undefined' ? '' : vObjCol.defaultValue;
  9665. if (/BETWEEN$/.test(vObjCol.operate)) {
  9666. var defaultValueArr = defaultValue.toString().match(/\|/) ? defaultValue.split('|') : ['', ''];
  9667. var placeholderArr = placeholder.toString().match(/\|/) ? placeholder.split('|') : [placeholder, placeholder];
  9668. htmlForm.push('<div class="row row-between">');
  9669. 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));
  9670. 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));
  9671. htmlForm.push('</div>');
  9672. } else {
  9673. 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));
  9674. }
  9675. }
  9676. htmlForm.push('</div>');
  9677. htmlForm.push('</div>');
  9678. }
  9679. }
  9680. htmlForm.push('<div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">');
  9681. htmlForm.push(createFormBtn(that).join(''));
  9682. htmlForm.push('</div>');
  9683. htmlForm.push('</div>');
  9684. htmlForm.push('</fieldset>');
  9685. htmlForm.push('</form>');
  9686. return htmlForm.join('');
  9687. };
  9688. var createFormBtn = function (that) {
  9689. var htmlBtn = [];
  9690. var searchSubmit = that.options.formatCommonSubmitButton();
  9691. var searchReset = that.options.formatCommonResetButton();
  9692. htmlBtn.push('<div class="col-sm-8 col-xs-offset-4">');
  9693. htmlBtn.push(sprintf('<button type="submit" class="btn btn-success" formnovalidate>%s</button> ', searchSubmit));
  9694. htmlBtn.push(sprintf('<button type="reset" class="btn btn-default" >%s</button> ', searchReset));
  9695. htmlBtn.push('</div>');
  9696. return htmlBtn;
  9697. };
  9698. var createOptionList = function (searchList, vObjCol, that) {
  9699. var isArray = searchList.constructor === Array;
  9700. var optionList = [];
  9701. optionList.push(sprintf('<option value="">%s</option>', that.options.formatCommonChoose()));
  9702. $.each(searchList, function (key, value) {
  9703. if (value.constructor === Object) {
  9704. key = value.id;
  9705. value = value.name;
  9706. } else {
  9707. key = isArray ? value : key;
  9708. }
  9709. optionList.push(sprintf("<option value='" + key + "' %s>" + value + "</option>", key == vObjCol.defaultValue ? 'selected' : ''));
  9710. });
  9711. return optionList;
  9712. };
  9713. var isSearchAvailble = function (that) {
  9714. //只支持服务端搜索
  9715. if (!that.options.commonSearch || that.options.sidePagination != 'server' || !that.options.url) {
  9716. return false;
  9717. }
  9718. return true;
  9719. };
  9720. var getSearchQuery = function (that, removeempty) {
  9721. var op = {};
  9722. var filter = {};
  9723. var value = '';
  9724. $("form.form-commonsearch .operate", that.$commonsearch).each(function (i) {
  9725. var name = $(this).data("name");
  9726. var sym = $(this).is("select") ? $("option:selected", this).val() : $(this).val().toUpperCase();
  9727. var obj = $("[name='" + name + "']", that.$commonsearch);
  9728. if (obj.length == 0)
  9729. return true;
  9730. var vObjCol = ColumnsForSearch[i];
  9731. var process = !that.options.searchFormTemplate && vObjCol && typeof vObjCol.process == 'function' ? vObjCol.process : null;
  9732. if (obj.length > 1) {
  9733. if (/BETWEEN$/.test(sym)) {
  9734. var value_begin = $.trim($("[name='" + name + "']:first", that.$commonsearch).val()),
  9735. value_end = $.trim($("[name='" + name + "']:last", that.$commonsearch).val());
  9736. if (value_begin.length || value_end.length) {
  9737. if (process) {
  9738. value_begin = process(value_begin, 'begin');
  9739. value_end = process(value_end, 'end');
  9740. }
  9741. value = value_begin + ',' + value_end;
  9742. } else {
  9743. value = '';
  9744. }
  9745. //如果是时间筛选,将operate置为RANGE
  9746. if ($("[name='" + name + "']:first", that.$commonsearch).hasClass("datetimepicker")) {
  9747. sym = 'RANGE';
  9748. }
  9749. } else {
  9750. value = $("[name='" + name + "']:checked", that.$commonsearch).val();
  9751. value = process ? process(value) : value;
  9752. }
  9753. } else {
  9754. value = process ? process(obj.val()) : obj.val();
  9755. }
  9756. if (removeempty && (value == '' || value == null || ($.isArray(value) && value.length == 0)) && !sym.match(/null/i)) {
  9757. return true;
  9758. }
  9759. op[name] = sym;
  9760. filter[name] = value;
  9761. });
  9762. return {op: op, filter: filter};
  9763. };
  9764. var getQueryParams = function (params, searchQuery, removeempty) {
  9765. params.filter = typeof params.filter === 'Object' ? params.filter : (params.filter ? JSON.parse(params.filter) : {});
  9766. params.op = typeof params.op === 'Object' ? params.op : (params.op ? JSON.parse(params.op) : {});
  9767. params.filter = $.extend({}, params.filter, searchQuery.filter);
  9768. params.op = $.extend({}, params.op, searchQuery.op);
  9769. //移除empty的值
  9770. if (removeempty) {
  9771. $.each(params.filter, function (i, j) {
  9772. if ((j == '' || j == null || ($.isArray(j) && j.length == 0)) && !params.op[i].match(/null/i)) {
  9773. delete params.filter[i];
  9774. delete params.op[i];
  9775. }
  9776. });
  9777. }
  9778. params.filter = JSON.stringify(params.filter);
  9779. params.op = JSON.stringify(params.op);
  9780. return params;
  9781. };
  9782. $.extend($.fn.bootstrapTable.defaults, {
  9783. commonSearch: false,
  9784. titleForm: "Common search",
  9785. actionForm: "",
  9786. searchFormTemplate: "",
  9787. searchFormVisible: true,
  9788. searchClass: 'searchit',
  9789. showSearch: true,
  9790. renderDefault: true,
  9791. onCommonSearch: function (field, text) {
  9792. return false;
  9793. },
  9794. onPostCommonSearch: function (table) {
  9795. return false;
  9796. }
  9797. });
  9798. $.extend($.fn.bootstrapTable.defaults.icons, {
  9799. commonSearchIcon: 'glyphicon-search'
  9800. });
  9801. $.extend($.fn.bootstrapTable.Constructor.EVENTS, {
  9802. 'common-search.bs.table': 'onCommonSearch',
  9803. 'post-common-search.bs.table': 'onPostCommonSearch'
  9804. });
  9805. $.extend($.fn.bootstrapTable.locales[$.fn.bootstrapTable.defaults.locale], {
  9806. formatCommonSearch: function () {
  9807. return "Common search";
  9808. },
  9809. formatCommonSubmitButton: function () {
  9810. return "Submit";
  9811. },
  9812. formatCommonResetButton: function () {
  9813. return "Reset";
  9814. },
  9815. formatCommonCloseButton: function () {
  9816. return "Close";
  9817. },
  9818. formatCommonChoose: function () {
  9819. return "Choose";
  9820. }
  9821. });
  9822. $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);
  9823. var BootstrapTable = $.fn.bootstrapTable.Constructor,
  9824. _initHeader = BootstrapTable.prototype.initHeader,
  9825. _initToolbar = BootstrapTable.prototype.initToolbar,
  9826. _load = BootstrapTable.prototype.load,
  9827. _initSearch = BootstrapTable.prototype.initSearch;
  9828. BootstrapTable.prototype.initHeader = function () {
  9829. _initHeader.apply(this, Array.prototype.slice.apply(arguments));
  9830. this.$header.find('th[data-field]').each(function (i) {
  9831. var column = $(this).data();
  9832. if (typeof column['width'] !== 'undefined' && column['width'].toString().indexOf("%") === -1) {
  9833. $(".th-inner", this).outerWidth(column['width']);
  9834. $(this).css("max-width", column['width']);
  9835. }
  9836. });
  9837. this.options.stateField = this.header.stateField;
  9838. };
  9839. BootstrapTable.prototype.initToolbar = function () {
  9840. _initToolbar.apply(this, Array.prototype.slice.apply(arguments));
  9841. if (!isSearchAvailble(this)) {
  9842. return;
  9843. }
  9844. var that = this,
  9845. html = [];
  9846. if (that.options.showSearch) {
  9847. html.push(sprintf('<div class="columns-%s pull-%s" style="margin-top:10px;margin-bottom:10px;">', this.options.buttonsAlign, this.options.buttonsAlign));
  9848. html.push(sprintf('<button class="btn btn-default%s' + '" type="button" name="commonSearch" title="%s">', that.options.iconSize === undefined ? '' : ' btn-' + that.options.iconSize, that.options.formatCommonSearch()));
  9849. html.push(sprintf('<i class="%s %s"></i>', that.options.iconsPrefix, that.options.icons.commonSearchIcon))
  9850. html.push('</button></div>');
  9851. }
  9852. if (that.$toolbar.find(".pull-right").length > 0) {
  9853. $(html.join('')).insertBefore(that.$toolbar.find(".pull-right:first"));
  9854. } else {
  9855. that.$toolbar.append(html.join(''));
  9856. }
  9857. initCommonSearch(that.columns, that);
  9858. that.$toolbar.find('button[name="commonSearch"]')
  9859. .off('click').on('click', function () {
  9860. that.$commonsearch.toggleClass("hidden");
  9861. return;
  9862. });
  9863. that.$container.on("click", "." + that.options.searchClass, function () {
  9864. var value = $(this).data("value");
  9865. var field = $(this).data("field");
  9866. var ul = that.$container.closest(".panel-intro").find("ul[data-field='" + field + "']");
  9867. if (ul.length > 0) {
  9868. $('li a[data-value="' + value + '"][data-toggle="tab"]', ul).trigger('click');
  9869. return;
  9870. }
  9871. var obj = $("form [name='" + field + "']", that.$commonsearch);
  9872. if (obj.length > 0) {
  9873. if (obj.is("select")) {
  9874. $("option[value='" + value + "']", obj).prop("selected", true);
  9875. } else if (obj.length > 1) {
  9876. $("form [name='" + field + "'][value='" + value + "']", that.$commonsearch).prop("checked", true);
  9877. } else {
  9878. obj.val(value + "");
  9879. }
  9880. obj.trigger("change");
  9881. $("form", that.$commonsearch).trigger("submit");
  9882. }
  9883. });
  9884. var queryParams = that.options.queryParams;
  9885. //匹配默认搜索值
  9886. this.options.queryParams = function (params) {
  9887. return queryParams(getQueryParams(params, getSearchQuery(that, true)));
  9888. };
  9889. this.trigger('post-common-search', that);
  9890. };
  9891. BootstrapTable.prototype.onCommonSearch = function () {
  9892. var searchQuery = getSearchQuery(this);
  9893. this.trigger('common-search', this, searchQuery);
  9894. this.options.pageNumber = 1;
  9895. //this.options.pageSize = $.fn.bootstrapTable.defaults.pageSize;
  9896. this.refresh({});
  9897. };
  9898. BootstrapTable.prototype.load = function (data) {
  9899. _load.apply(this, Array.prototype.slice.apply(arguments));
  9900. if (!isSearchAvailble(this)) {
  9901. return;
  9902. }
  9903. };
  9904. BootstrapTable.prototype.initSearch = function () {
  9905. _initSearch.apply(this, Array.prototype.slice.apply(arguments));
  9906. if (!isSearchAvailble(this)) {
  9907. return;
  9908. }
  9909. var that = this;
  9910. var fp = $.isEmptyObject(this.filterColumnsPartial) ? null : this.filterColumnsPartial;
  9911. this.data = fp ? $.grep(this.data, function (item, i) {
  9912. for (var key in fp) {
  9913. var fval = fp[key].toLowerCase();
  9914. var value = item[key];
  9915. value = $.fn.bootstrapTable.utils.calculateObjectValue(that.header,
  9916. that.header.formatters[$.inArray(key, that.header.fields)],
  9917. [value, item, i], value);
  9918. if (!($.inArray(key, that.header.fields) !== -1 &&
  9919. (typeof value === 'string' || typeof value === 'number') &&
  9920. (value + '').toLowerCase().indexOf(fval) !== -1)) {
  9921. return false;
  9922. }
  9923. }
  9924. return true;
  9925. }) : this.data;
  9926. };
  9927. }(jQuery);
  9928. define("bootstrap-table-commonsearch", ["bootstrap-table"], (function (global) {
  9929. return function () {
  9930. var ret, fn;
  9931. return ret || global.$.fn.bootstrapTable.defaults;
  9932. };
  9933. }(this)));
  9934. /**
  9935. * 将BootstrapTable的行使用自定义的模板来渲染
  9936. *
  9937. * @author: karson
  9938. * @version: v0.0.1
  9939. *
  9940. * @update 2017-06-24 <http://github.com/karsonzhang/fastadmin>
  9941. */
  9942. !function ($) {
  9943. 'use strict';
  9944. $.extend($.fn.bootstrapTable.defaults, {
  9945. //是否启用模板渲染
  9946. templateView: false,
  9947. //数据格式化的模板ID或格式函数
  9948. templateFormatter: "itemtpl",
  9949. //添加的父类的class
  9950. templateParentClass: "row row-flex",
  9951. //向table添加的class
  9952. templateTableClass: "table-template",
  9953. });
  9954. var BootstrapTable = $.fn.bootstrapTable.Constructor,
  9955. _initContainer = BootstrapTable.prototype.initContainer,
  9956. _initBody = BootstrapTable.prototype.initBody,
  9957. _initRow = BootstrapTable.prototype.initRow;
  9958. BootstrapTable.prototype.initContainer = function () {
  9959. _initContainer.apply(this, Array.prototype.slice.apply(arguments));
  9960. var that = this;
  9961. if (!that.options.templateView) {
  9962. return;
  9963. }
  9964. that.options.cardView = true;
  9965. };
  9966. BootstrapTable.prototype.initBody = function () {
  9967. var that = this;
  9968. $.extend(that.options, {
  9969. showHeader: !that.options.templateView ? $.fn.bootstrapTable.defaults.showHeader : false,
  9970. showFooter: !that.options.templateView ? $.fn.bootstrapTable.defaults.showFooter : false,
  9971. });
  9972. $(that.$el).toggleClass(that.options.templateTableClass, that.options.templateView);
  9973. _initBody.apply(this, Array.prototype.slice.apply(arguments));
  9974. if (!that.options.templateView) {
  9975. return;
  9976. } else {
  9977. //由于Bootstrap是基于Table的,添加一个父类容器
  9978. $("> *:not(.no-records-found)", that.$body).wrapAll($("<div />").addClass(that.options.templateParentClass));
  9979. }
  9980. };
  9981. BootstrapTable.prototype.initRow = function (item, i, data, parentDom) {
  9982. var that = this;
  9983. //如果未启用则使用原生的initRow方法
  9984. if (!that.options.templateView) {
  9985. return _initRow.apply(that, Array.prototype.slice.apply(arguments));
  9986. }
  9987. var $content = '';
  9988. if (typeof that.options.templateFormatter === 'function') {
  9989. $content = that.options.templateFormatter.call(that, item, i, data);
  9990. } else {
  9991. var Template = require('template');
  9992. $content = Template(that.options.templateFormatter, {item: item, i: i, data: data});
  9993. }
  9994. return $content;
  9995. };
  9996. }(jQuery);
  9997. define("bootstrap-table-template", ["bootstrap-table","template"], (function (global) {
  9998. return function () {
  9999. var ret, fn;
  10000. return ret || global.$.fn.bootstrapTable.defaults;
  10001. };
  10002. }(this)));
  10003. /**
  10004. * @author Jay <jwang@dizsoft.com>
  10005. */
  10006. (function ($) {
  10007. 'use strict';
  10008. var sprintf = $.fn.bootstrapTable.utils.sprintf;
  10009. $.extend($.fn.bootstrapTable.defaults, {
  10010. showJumpto: false,
  10011. exportOptions: {}
  10012. });
  10013. $.extend($.fn.bootstrapTable.locales, {
  10014. formatJumpto: function () {
  10015. return 'GO';
  10016. }
  10017. });
  10018. $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);
  10019. var BootstrapTable = $.fn.bootstrapTable.Constructor,
  10020. _initPagination = BootstrapTable.prototype.initPagination;
  10021. BootstrapTable.prototype.initPagination = function () {
  10022. this.showToolbar = this.options.showExport;
  10023. _initPagination.apply(this, Array.prototype.slice.apply(arguments));
  10024. if (this.options.showJumpto) {
  10025. var that = this,
  10026. $pageGroup = this.$pagination.find('ul.pagination'),
  10027. $jumpto = $pageGroup.find('li.jumpto');
  10028. if (!$jumpto.length) {
  10029. $jumpto = $([
  10030. '<li class="jumpto">',
  10031. '<input type="text" class="form-control">',
  10032. '<button class="btn' +
  10033. sprintf(' btn-%s', this.options.buttonsClass) +
  10034. sprintf(' btn-%s', this.options.iconSize) +
  10035. '" title="' + this.options.formatJumpto() + '" ' +
  10036. ' type="button">'+this.options.formatJumpto(),
  10037. '</button>',
  10038. '</li>'].join('')).appendTo($pageGroup);
  10039. $jumpto.find('button').click(function () {
  10040. that.selectPage(parseInt($jumpto.find('input').val()));
  10041. });
  10042. }
  10043. }
  10044. };
  10045. })(jQuery);
  10046. define("bootstrap-table-jumpto", ["bootstrap-table"], (function (global) {
  10047. return function () {
  10048. var ret, fn;
  10049. return ret || global.$.fn.bootstrapTable.defaults;
  10050. };
  10051. }(this)));
  10052. (function ($) {
  10053. 'use strict';
  10054. // Reasonable defaults
  10055. var PIXEL_STEP = 10;
  10056. var LINE_HEIGHT = 40;
  10057. var PAGE_HEIGHT = 800;
  10058. function normalizeWheel(event) {
  10059. var sX = 0; // spinX
  10060. var sY = 0; // spinY
  10061. var pX = 0; // pixelX
  10062. var pY = 0; // pixelY
  10063. // Legacy
  10064. if ('detail' in event) {
  10065. sY = event.detail;
  10066. }
  10067. if ('wheelDelta' in event) {
  10068. sY = -event.wheelDelta / 120;
  10069. }
  10070. if ('wheelDeltaY' in event) {
  10071. sY = -event.wheelDeltaY / 120;
  10072. }
  10073. if ('wheelDeltaX' in event) {
  10074. sX = -event.wheelDeltaX / 120;
  10075. }
  10076. // side scrolling on FF with DOMMouseScroll
  10077. if ('axis' in event && event.axis === event.HORIZONTAL_AXIS) {
  10078. sX = sY;
  10079. sY = 0;
  10080. }
  10081. pX = sX * PIXEL_STEP;
  10082. pY = sY * PIXEL_STEP;
  10083. if ('deltaY' in event) {
  10084. pY = event.deltaY;
  10085. }
  10086. if ('deltaX' in event) {
  10087. pX = event.deltaX;
  10088. }
  10089. if ((pX || pY) && event.deltaMode) {
  10090. if (event.deltaMode === 1) {
  10091. // delta in LINE units
  10092. pX *= LINE_HEIGHT;
  10093. pY *= LINE_HEIGHT;
  10094. } else {
  10095. // delta in PAGE units
  10096. pX *= PAGE_HEIGHT;
  10097. pY *= PAGE_HEIGHT;
  10098. }
  10099. }
  10100. // Fall-back if spin cannot be determined
  10101. if (pX && !sX) {
  10102. sX = pX < 1 ? -1 : 1;
  10103. }
  10104. if (pY && !sY) {
  10105. sY = pY < 1 ? -1 : 1;
  10106. }
  10107. return {
  10108. spinX: sX,
  10109. spinY: sY,
  10110. pixelX: pX,
  10111. pixelY: pY
  10112. };
  10113. }
  10114. var cachedWidth = null;
  10115. var getScrollBarWidth = function getScrollBarWidth() {
  10116. if (cachedWidth === null) {
  10117. var inner = $('<p/>').addClass('fixed-table-scroll-inner'),
  10118. outer = $('<div/>').addClass('fixed-table-scroll-outer'),
  10119. w1 = void 0,
  10120. w2 = void 0;
  10121. outer.append(inner);
  10122. $('body').append(outer);
  10123. w1 = inner[0].offsetWidth;
  10124. outer.css('overflow', 'scroll');
  10125. w2 = inner[0].offsetWidth;
  10126. if (w1 === w2) {
  10127. w2 = outer[0].clientWidth;
  10128. }
  10129. outer.remove();
  10130. cachedWidth = w1 - w2;
  10131. }
  10132. return cachedWidth;
  10133. };
  10134. //获取原本表格体的滑块宽度
  10135. var getTableBodyScrollBarWidth = function getTableBodyScrollBarWidth(tableBody) {
  10136. return tableBody[0].scrollHeight > tableBody[0].clientHeight ? 15 : 0;
  10137. };
  10138. $.extend($.fn.bootstrapTable.defaults, {
  10139. fixedColumns: false,
  10140. fixedNumber: 0,
  10141. fixedRightNumber: 0
  10142. });
  10143. var BootstrapTable = $.fn.bootstrapTable.Constructor,
  10144. _initBody = BootstrapTable.prototype.initBody,
  10145. _initContainer = BootstrapTable.prototype.initContainer,
  10146. _trigger = BootstrapTable.prototype.trigger,
  10147. _hideLoading = BootstrapTable.prototype.hideLoading,
  10148. _updateSelected = BootstrapTable.prototype.updateSelected;
  10149. BootstrapTable.prototype.fixedColumnsSupported = function () {
  10150. var that = this;
  10151. return that.options.fixedColumns && !that.options.detailView && !that.options.cardView;
  10152. };
  10153. BootstrapTable.prototype.initFixedContainer = function () {
  10154. if (this.options.fixedNumber) {
  10155. this.$tableContainer.find('.fixed-columns').length == 0 && this.$tableContainer.append('<div class="fixed-columns"></div>');
  10156. this.$fixedColumns = this.$tableContainer.find('.fixed-columns');
  10157. }
  10158. if (this.options.fixedRightNumber) {
  10159. this.$tableContainer.find('.fixed-columns-right').length == 0 && this.$tableContainer.append('<div class="fixed-columns-right"></div>');
  10160. this.$fixedColumnsRight = this.$tableContainer.find('.fixed-columns-right');
  10161. }
  10162. };
  10163. BootstrapTable.prototype.initContainer = function () {
  10164. _initContainer.apply(this, Array.prototype.slice.apply(arguments));
  10165. this.initFixedContainer();
  10166. };
  10167. BootstrapTable.prototype.initBody = function () {
  10168. _initBody.apply(this, Array.prototype.slice.apply(arguments));
  10169. if (!this.fixedColumnsSupported()) {
  10170. return;
  10171. }
  10172. if (this.options.showHeader && this.options.height) {
  10173. return;
  10174. }
  10175. this.initFixedColumnsBody();
  10176. this.initFixedColumnsEvents();
  10177. };
  10178. BootstrapTable.prototype.trigger = function () {
  10179. var that = this;
  10180. _trigger.apply(this, Array.prototype.slice.apply(arguments));
  10181. if (arguments[0] === 'pre-body') {
  10182. //如果上来就是cardView 设置表格高度为auto
  10183. if (this.options.cardView) {
  10184. this.$tableBody.css("height", "auto");
  10185. }
  10186. }
  10187. //监听cardView 显示/隐藏fixed部分
  10188. if (arguments[0] === 'toggle') {
  10189. if (arguments[1]) {
  10190. this.$tableBody.css("height", "auto");
  10191. this.$fixedColumns && this.$fixedColumns.hide();
  10192. this.$fixedColumnsRight && this.$fixedColumnsRight.hide();
  10193. } else {
  10194. this.$tableBody.css("height", "100%");
  10195. this.$fixedColumns && this.$fixedColumns.show();
  10196. this.$fixedColumnsRight && this.$fixedColumnsRight.show();
  10197. this.$fixedHeaderRight && this.$fixedHeaderRight.scrollLeft(this.$tableBody.find('table').width());
  10198. this.$fixedBodyRight && this.$fixedBodyRight.scrollLeft(this.$tableBody.find('table').width());
  10199. }
  10200. }
  10201. if (!that.fixedColumnsSupported()) {
  10202. return;
  10203. }
  10204. if (arguments[0] === 'post-header') {
  10205. this.initFixedColumnsHeader();
  10206. } else if (arguments[0] === 'scroll-body') {
  10207. if (this.needFixedColumns && this.options.fixedNumber) {
  10208. this.$fixedBody && this.$fixedBody.scrollTop(this.$tableBody.scrollTop());
  10209. }
  10210. if (this.needFixedColumns && this.options.fixedRightNumber) {
  10211. this.$fixedBodyRight && this.$fixedBodyRight.scrollTop(this.$tableBody.scrollTop());
  10212. }
  10213. } else if (arguments[0] === 'load-success') {
  10214. this.hideLoading();
  10215. }
  10216. };
  10217. BootstrapTable.prototype.updateSelected = function () {
  10218. var that = this;
  10219. _updateSelected.apply(this, Array.prototype.slice.apply(arguments));
  10220. if (!this.fixedColumnsSupported()) {
  10221. return;
  10222. }
  10223. this.$tableBody.find('tr').each(function (i, el) {
  10224. var $el = $(el);
  10225. var index = $el.data('index');
  10226. var classes = $el.attr('class');
  10227. var inputSelector = '[name="' + that.options.selectItemName + '"]';
  10228. var $input = $el.find(inputSelector);
  10229. if (typeof index === 'undefined') {
  10230. return;
  10231. }
  10232. var updateFixedBody = function updateFixedBody($fixedHeader, $fixedBody) {
  10233. var $tr = $fixedBody.find('tr[data-index="' + index + '"]');
  10234. $tr.attr('class', classes);
  10235. if ($input.length) {
  10236. $tr.find(inputSelector).prop('checked', $input.prop('checked'));
  10237. }
  10238. if (that.$selectAll.length) {
  10239. $fixedHeader.add($fixedBody).find('[name="btSelectAll"]').prop('checked', that.$selectAll.prop('checked'));
  10240. }
  10241. };
  10242. if (that.$fixedBody && that.options.fixedNumber) {
  10243. updateFixedBody(that.$fixedHeader, that.$fixedBody);
  10244. }
  10245. if (that.$fixedBodyRight && that.options.fixedRightNumber) {
  10246. updateFixedBody(that.$fixedHeaderRight, that.$fixedBodyRight);
  10247. }
  10248. });
  10249. };
  10250. BootstrapTable.prototype.hideLoading = function () {
  10251. _hideLoading.apply(this, Array.prototype.slice.apply(arguments));
  10252. if (this.needFixedColumns && this.options.fixedNumber) {
  10253. this.$fixedColumns.find('.fixed-table-loading').hide();
  10254. }
  10255. if (this.needFixedColumns && this.options.fixedRightNumber) {
  10256. this.$fixedColumnsRight.find('.fixed-table-loading').hide();
  10257. }
  10258. };
  10259. BootstrapTable.prototype.initFixedColumnsHeader = function () {
  10260. var that = this;
  10261. if (this.options.height) {
  10262. this.needFixedColumns = this.$tableHeader.outerWidth(true) < this.$tableHeader.find('table').outerWidth(true);
  10263. } else {
  10264. this.needFixedColumns = this.$tableBody.outerWidth(true) < this.$tableBody.find('table').outerWidth(true);
  10265. }
  10266. var initFixedHeader = function initFixedHeader($fixedColumns, isRight) {
  10267. $fixedColumns.find('.fixed-table-header').remove();
  10268. $fixedColumns.append(that.$tableHeader.clone(true));
  10269. $fixedColumns.find('.fixed-table-header').css('margin-right', "");
  10270. $fixedColumns.css({
  10271. width: that.getFixedColumnsWidth(isRight)
  10272. });
  10273. return $fixedColumns.find('.fixed-table-header');
  10274. };
  10275. if (this.needFixedColumns && this.options.fixedNumber) {
  10276. this.$fixedHeader = initFixedHeader(this.$fixedColumns);
  10277. this.$fixedHeader.css('margin-right', '');
  10278. } else if (this.$fixedColumns) {
  10279. this.$fixedColumns.html('').css('width', '');
  10280. }
  10281. if (this.needFixedColumns && this.options.fixedRightNumber) {
  10282. this.$fixedHeaderRight = initFixedHeader(this.$fixedColumnsRight, true);
  10283. this.$fixedHeaderRight.scrollLeft(this.$fixedHeaderRight.find('table').width());
  10284. } else if (this.$fixedColumnsRight) {
  10285. this.$fixedColumnsRight.html('').css('width', '');
  10286. }
  10287. this.initFixedColumnsBody();
  10288. this.initFixedColumnsEvents();
  10289. };
  10290. BootstrapTable.prototype.initFixedColumnsBody = function () {
  10291. var that = this;
  10292. var initFixedBody = function initFixedBody($fixedColumns, $fixedHeader) {
  10293. $fixedColumns.find('.fixed-table-body').remove();
  10294. $fixedColumns.append(that.$tableBody.clone(true));
  10295. var $fixedBody = $fixedColumns.find('.fixed-table-body');
  10296. var tableBody = that.$tableBody.get(0);
  10297. var resizeHeight = function (){
  10298. var scrollHeight = tableBody.scrollWidth > tableBody.clientWidth ? getScrollBarWidth() : 0;
  10299. var paginationHeight = $(".fixed-table-pagination", that.$tableContainer).height();
  10300. if (typeof that.options.height !== 'undefined') paginationHeight = 0;
  10301. $fixedColumns.css({
  10302. "height": "calc(100% - " + (paginationHeight + scrollHeight) + "px)"
  10303. });
  10304. $fixedBody.css({
  10305. "height": "calc(100% - " + $fixedHeader.height() + "px)",
  10306. overflow: "hidden"
  10307. });
  10308. };
  10309. $(window).on("resize", resizeHeight);
  10310. resizeHeight();
  10311. return $fixedBody;
  10312. };
  10313. if (this.needFixedColumns && this.options.fixedNumber) {
  10314. this.$fixedBody = initFixedBody(this.$fixedColumns, this.$fixedHeader);
  10315. }
  10316. if (this.needFixedColumns && this.options.fixedRightNumber) {
  10317. this.$fixedBodyRight = initFixedBody(this.$fixedColumnsRight, this.$fixedHeaderRight);
  10318. this.$fixedBodyRight.scrollLeft(this.$fixedBodyRight.find('table').width());
  10319. this.$fixedBodyRight.css('overflow-y', 'hidden');
  10320. }
  10321. };
  10322. BootstrapTable.prototype.getFixedColumnsWidth = function (isRight) {
  10323. var visibleFields = this.getVisibleFields();
  10324. var width = 0;
  10325. var fixedNumber = this.options.fixedNumber;
  10326. var marginRight = 0;
  10327. if (isRight) {
  10328. visibleFields = visibleFields.reverse();
  10329. fixedNumber = this.options.fixedRightNumber;
  10330. //右侧固定列距离
  10331. this.$fixedColumnsRight.css('right', getTableBodyScrollBarWidth(this.$tableBody));
  10332. }
  10333. for (var i = 0; i < fixedNumber; i++) {
  10334. width += this.$header.find('th[data-field="' + visibleFields[i] + '"]').outerWidth();
  10335. }
  10336. return width + 1;
  10337. };
  10338. BootstrapTable.prototype.initFixedColumnsEvents = function () {
  10339. var that = this;
  10340. var toggleHover = function toggleHover(e, toggle) {
  10341. var tr = 'tr[data-index="' + $(e.currentTarget).data('index') + '"]';
  10342. var $trs = that.$tableBody.find(tr);
  10343. if (that.$fixedBody) {
  10344. $trs = $trs.add(that.$fixedBody.find(tr));
  10345. }
  10346. if (that.$fixedBodyRight) {
  10347. $trs = $trs.add(that.$fixedBodyRight.find(tr));
  10348. }
  10349. $trs.css('background-color', toggle ? $(e.currentTarget).css('background-color') : '');
  10350. };
  10351. this.$tableBody.find('tr').hover(function (e) {
  10352. toggleHover(e, true);
  10353. }, function (e) {
  10354. toggleHover(e, false);
  10355. });
  10356. var isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
  10357. var mousewheel = isFirefox ? 'DOMMouseScroll' : 'mousewheel';
  10358. var updateScroll = function updateScroll(e, fixedBody) {
  10359. var normalized = normalizeWheel(e);
  10360. var deltaY = Math.ceil(normalized.pixelY);
  10361. var top = that.$tableBody.scrollTop() + deltaY;
  10362. if (deltaY < 0 && top > 0 || deltaY > 0 && top < fixedBody.scrollHeight - fixedBody.clientHeight) {
  10363. e.preventDefault();
  10364. }
  10365. that.$tableBody.scrollTop(top);
  10366. if (that.$fixedBody) {
  10367. that.$fixedBody.scrollTop(top);
  10368. }
  10369. if (that.$fixedBodyRight) {
  10370. that.$fixedBodyRight.scrollTop(top);
  10371. }
  10372. };
  10373. if (this.needFixedColumns && this.options.fixedNumber) {
  10374. this.$fixedBody.find('tr').hover(function (e) {
  10375. toggleHover(e, true);
  10376. }, function (e) {
  10377. toggleHover(e, false);
  10378. });
  10379. this.$fixedBody[0].addEventListener(mousewheel, function (e) {
  10380. //给鼠标滑轮绑定事件
  10381. updateScroll(e, that.$fixedBody[0]);
  10382. });
  10383. //给固定表格的checkbox绑定事件
  10384. this.$fixedBody.find('input[name="' + this.options.selectItemName + '"]').off("click").on('click', function (e) {
  10385. e.stopImmediatePropagation();
  10386. var index = $(e.target).data("index");
  10387. $(that.$selectItem[index]).trigger("click");
  10388. });
  10389. //绑定TD点击事件
  10390. this.$fixedBody.find('> table > tbody > tr[data-index] > td').off('click dblclick').on('click dblclick', function (e) {
  10391. var index = $(this).closest("tr[data-index]").data("index");
  10392. $(that.$selectItem[index]).closest("tr[data-index]").find(">td:eq(" + $(this).index() + ")").trigger("click");
  10393. });
  10394. }
  10395. //给原本表格绑定scroll事件
  10396. $('div.fixed-table-body').off('scroll'); //给所有的body解绑 scroll
  10397. this.$tableBody.off('scroll').on('scroll', function (e) {
  10398. that.$tableHeader.scrollLeft(0);
  10399. if (that.$tableBody.scrollLeft() > 0) {
  10400. that.$tableHeader.scrollLeft(that.$tableBody.scrollLeft());
  10401. if (that.options.showFooter && !that.options.cardView) {
  10402. that.$tableFooter.scrollLeft(that.$tableBody.scrollLeft());
  10403. }
  10404. }
  10405. var top = that.$tableBody.scrollTop();
  10406. if (that.$fixedBody) {
  10407. that.$fixedBody.scrollTop(top);
  10408. }
  10409. if (that.$fixedBodyRight) {
  10410. that.$fixedBodyRight.scrollTop(top);
  10411. }
  10412. });
  10413. if (this.needFixedColumns && this.options.fixedRightNumber) {
  10414. this.$fixedBodyRight.find('tr').hover(function (e) {
  10415. toggleHover(e, true);
  10416. }, function (e) {
  10417. toggleHover(e, false);
  10418. });
  10419. this.$fixedBodyRight[0].addEventListener(mousewheel, function (e) {
  10420. //给鼠标滑轮绑定事件
  10421. updateScroll(e, that.$fixedBodyRight[0]);
  10422. });
  10423. //给固定表格的checkbox绑定事件
  10424. this.$fixedBodyRight.find('input[name="' + this.options.selectItemName + '"]').off("click").on('click', function (e) {
  10425. e.stopImmediatePropagation();
  10426. var index = $(e.target).data("index");
  10427. $(that.$selectItem[index]).trigger("click");
  10428. });
  10429. //绑定TD点击事件
  10430. this.$fixedBodyRight.find('> table > tbody > tr[data-index] > td').off('click dblclick').on('click dblclick', function (e) {
  10431. var index = $(this).closest("tr[data-index]").data("index");
  10432. $(that.$selectItem[index]).closest("tr[data-index]").find(">td:eq(" + $(this).index() + ")").trigger("click");
  10433. });
  10434. }
  10435. if (this.options.filterControl) {
  10436. $(this.$fixedColumns).off('keyup change').on('keyup change', function (e) {
  10437. var $target = $(e.target);
  10438. var value = $target.val();
  10439. var field = $target.parents('th').data('field');
  10440. var $coreTh = that.$header.find('th[data-field="' + field + '"]');
  10441. if ($target.is('input')) {
  10442. $coreTh.find('input').val(value);
  10443. } else if ($target.is('select')) {
  10444. var $select = $coreTh.find('select');
  10445. $select.find('option[selected]').removeAttr('selected');
  10446. $select.find('option[value="' + value + '"]').attr('selected', true);
  10447. }
  10448. that.triggerSearch();
  10449. });
  10450. }
  10451. };
  10452. })(jQuery);
  10453. define("bootstrap-table-fixed-columns", ["bootstrap-table"], (function (global) {
  10454. return function () {
  10455. var ret, fn;
  10456. return ret || global.$.fn.bootstrapTable.defaults;
  10457. };
  10458. }(this)));
  10459. define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table', 'bootstrap-table-lang', 'bootstrap-table-export', 'bootstrap-table-commonsearch', 'bootstrap-table-template', 'bootstrap-table-jumpto', 'bootstrap-table-fixed-columns'], function ($, undefined, Moment) {
  10460. var Table = {
  10461. list: {},
  10462. // Bootstrap-table 基础配置
  10463. defaults: {
  10464. url: '',
  10465. sidePagination: 'server',
  10466. method: 'get', //请求方法
  10467. toolbar: ".toolbar", //工具栏
  10468. search: true, //是否启用快速搜索
  10469. cache: false,
  10470. commonSearch: true, //是否启用通用搜索
  10471. searchFormVisible: false, //是否始终显示搜索表单
  10472. titleForm: '', //为空则不显示标题,不定义默认显示:普通搜索
  10473. idTable: 'commonTable',
  10474. showExport: true,
  10475. exportDataType: "auto", //支持auto,selected,all 当设定为auto时自动时有选中则导出选中,没有选中则导出全部
  10476. exportTypes: ['json', 'xml', 'csv', 'txt', 'doc', 'excel'],
  10477. exportOptions: {
  10478. fileName: 'export_' + Moment().format("YYYY-MM-DD"),
  10479. preventInjection: false,
  10480. mso: {
  10481. onMsoNumberFormat: function (cell, row, col) {
  10482. return !isNaN($(cell).text()) ? '\\@' : '';
  10483. },
  10484. },
  10485. ignoreColumn: [0, 'operate'] //默认不导出第一列(checkbox)与操作(operate)列
  10486. },
  10487. pageSize: Config.pagesize || localStorage.getItem("pagesize") || 10,
  10488. pageList: [10, 15, 20, 25, 50, 'All'],
  10489. pagination: true,
  10490. clickToSelect: true, //是否启用点击选中
  10491. dblClickToEdit: true, //是否启用双击编辑
  10492. singleSelect: false, //是否启用单选
  10493. showRefresh: false,
  10494. showJumpto: true,
  10495. locale: Config.language === 'zh-cn' ? 'zh-CN' : 'en-US',
  10496. showToggle: true,
  10497. showColumns: true,
  10498. pk: 'id',
  10499. sortName: 'id',
  10500. sortOrder: 'desc',
  10501. paginationFirstText: __("First"),
  10502. paginationPreText: __("Previous"),
  10503. paginationNextText: __("Next"),
  10504. paginationLastText: __("Last"),
  10505. cardView: false, //卡片视图
  10506. iosCardView: true, //ios卡片视图
  10507. checkOnInit: true, //是否在初始化时判断
  10508. escape: true, //是否对内容进行转义
  10509. fixDropdownPosition: true, //是否修复下拉的定位
  10510. dragCheckboxMultiselect: true, //拖拽时复选框是否多选模式
  10511. selectedIds: [],
  10512. selectedData: [],
  10513. extend: {
  10514. index_url: '',
  10515. add_url: '',
  10516. edit_url: '',
  10517. del_url: '',
  10518. import_url: '',
  10519. multi_url: '',
  10520. dragsort_url: 'ajax/weigh',
  10521. }
  10522. },
  10523. // Bootstrap-table 列配置
  10524. columnDefaults: {
  10525. align: 'center',
  10526. valign: 'middle',
  10527. },
  10528. config: {
  10529. checkboxtd: 'tbody>tr>td.bs-checkbox',
  10530. toolbar: '.toolbar',
  10531. refreshbtn: '.btn-refresh',
  10532. addbtn: '.btn-add',
  10533. editbtn: '.btn-edit',
  10534. delbtn: '.btn-del',
  10535. importbtn: '.btn-import',
  10536. multibtn: '.btn-multi',
  10537. disabledbtn: '.btn-disabled',
  10538. editonebtn: '.btn-editone',
  10539. restoreonebtn: '.btn-restoreone',
  10540. destroyonebtn: '.btn-destroyone',
  10541. restoreallbtn: '.btn-restoreall',
  10542. destroyallbtn: '.btn-destroyall',
  10543. dragsortfield: 'weigh',
  10544. },
  10545. button: {
  10546. edit: {
  10547. name: 'edit',
  10548. icon: 'fa fa-pencil',
  10549. title: __('Edit'),
  10550. extend: 'data-toggle="tooltip" data-container="body"',
  10551. classname: 'btn btn-xs btn-success btn-editone'
  10552. },
  10553. del: {
  10554. name: 'del',
  10555. icon: 'fa fa-trash',
  10556. title: __('Del'),
  10557. extend: 'data-toggle="tooltip" data-container="body"',
  10558. classname: 'btn btn-xs btn-danger btn-delone'
  10559. },
  10560. dragsort: {
  10561. name: 'dragsort',
  10562. icon: 'fa fa-arrows',
  10563. title: __('Drag to sort'),
  10564. extend: 'data-toggle="tooltip"',
  10565. classname: 'btn btn-xs btn-primary btn-dragsort'
  10566. }
  10567. },
  10568. api: {
  10569. init: function (defaults, columnDefaults, locales) {
  10570. defaults = defaults ? defaults : {};
  10571. columnDefaults = columnDefaults ? columnDefaults : {};
  10572. locales = locales ? locales : {};
  10573. $.fn.bootstrapTable.Constructor.prototype.getSelectItem = function () {
  10574. return this.$selectItem;
  10575. };
  10576. var _onPageListChange = $.fn.bootstrapTable.Constructor.prototype.onPageListChange;
  10577. $.fn.bootstrapTable.Constructor.prototype.onPageListChange = function () {
  10578. _onPageListChange.apply(this, Array.prototype.slice.apply(arguments));
  10579. localStorage.setItem('pagesize', this.options.pageSize);
  10580. return false;
  10581. };
  10582. // 写入bootstrap-table默认配置
  10583. $.extend(true, $.fn.bootstrapTable.defaults, Table.defaults, defaults);
  10584. // 写入bootstrap-table column配置
  10585. $.extend($.fn.bootstrapTable.columnDefaults, Table.columnDefaults, columnDefaults);
  10586. // 写入bootstrap-table locale配置
  10587. $.extend($.fn.bootstrapTable.locales[Table.defaults.locale], {
  10588. formatCommonSearch: function () {
  10589. return __('Common search');
  10590. },
  10591. formatCommonSubmitButton: function () {
  10592. return __('搜索');
  10593. },
  10594. formatCommonResetButton: function () {
  10595. return __('Reset');
  10596. },
  10597. formatCommonCloseButton: function () {
  10598. return __('Close');
  10599. },
  10600. formatCommonChoose: function () {
  10601. return __('Choose');
  10602. },
  10603. formatJumpto: function () {
  10604. return __('Go');
  10605. }
  10606. }, locales);
  10607. // 如果是iOS设备则判断是否启用卡片视图
  10608. if ($.fn.bootstrapTable.defaults.iosCardView && navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
  10609. Table.defaults.cardView = true;
  10610. $.fn.bootstrapTable.defaults.cardView = true;
  10611. }
  10612. if (typeof defaults.exportTypes != 'undefined') {
  10613. $.fn.bootstrapTable.defaults.exportTypes = defaults.exportTypes;
  10614. }
  10615. },
  10616. // 绑定事件
  10617. bindevent: function (table) {
  10618. //Bootstrap-table的父元素,包含table,toolbar,pagnation
  10619. var parenttable = table.closest('.bootstrap-table');
  10620. //Bootstrap-table配置
  10621. var options = table.bootstrapTable('getOptions');
  10622. //Bootstrap操作区
  10623. var toolbar = $(options.toolbar, parenttable);
  10624. //跨页提示按钮
  10625. var tipsBtn = $(".btn-selected-tips", parenttable);
  10626. if (tipsBtn.length === 0) {
  10627. 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);
  10628. }
  10629. //点击提示按钮
  10630. tipsBtn.off("click").on("click", function (e) {
  10631. table.trigger("uncheckbox");
  10632. table.bootstrapTable("refresh");
  10633. });
  10634. //当刷新表格时
  10635. table.on('uncheckbox', function (status, res, e) {
  10636. options.selectedIds = [];
  10637. options.selectedData = [];
  10638. tipsBtn.tooltip('hide');
  10639. tipsBtn.addClass('hide');
  10640. });
  10641. //表格加载出错时
  10642. table.on('load-error.bs.table', function (status, res, e) {
  10643. if (e.status === 0) {
  10644. return;
  10645. }
  10646. Toastr.error(__('Unknown data format'));
  10647. });
  10648. //当加载数据成功时
  10649. table.on('load-success.bs.table', function (e, data) {
  10650. if (typeof data.rows === 'undefined' && typeof data.code != 'undefined') {
  10651. Toastr.error(data.msg);
  10652. }
  10653. });
  10654. //当刷新表格时
  10655. table.on('refresh.bs.table', function (e, settings, data) {
  10656. $(Table.config.refreshbtn, toolbar).find(".fa").addClass("fa-spin");
  10657. //移除指定浮动弹窗
  10658. $(".layui-layer-autocontent").remove();
  10659. });
  10660. //当执行搜索时
  10661. table.on('search.bs.table common-search.bs.table', function (e, settings, data) {
  10662. table.trigger("uncheckbox");
  10663. });
  10664. if (options.dblClickToEdit) {
  10665. //当双击单元格时
  10666. table.on('dbl-click-row.bs.table', function (e, row, element, field) {
  10667. $(Table.config.editonebtn, element).trigger("click");
  10668. });
  10669. }
  10670. //渲染内容前
  10671. table.on('pre-body.bs.table', function (e, data) {
  10672. if (options.maintainSelected) {
  10673. $.each(data, function (i, row) {
  10674. row[options.stateField] = $.inArray(row[options.pk], options.selectedIds) > -1;
  10675. });
  10676. }
  10677. });
  10678. //当内容渲染完成后
  10679. table.on('post-body.bs.table', function (e, data) {
  10680. $(Table.config.refreshbtn, toolbar).find(".fa").removeClass("fa-spin");
  10681. if ($(Table.config.checkboxtd + ":first", table).find("input[type='checkbox'][data-index]").length > 0) {
  10682. //拖拽选择复选框
  10683. var posx, posy, dragdiv, drag = false, prepare = false;
  10684. var mousemove = function (e) {
  10685. if (drag) {
  10686. var left = Math.min(e.pageX, posx);
  10687. var top = Math.min(e.pageY, posy);
  10688. var width = Math.abs(posx - e.pageX);
  10689. var height = Math.abs(posy - e.pageY);
  10690. dragdiv.css({left: left + "px", top: top + "px", width: width + "px", height: height + "px"});
  10691. var dragrect = {x: left, y: top, width: width, height: height};
  10692. $(Table.config.checkboxtd, table).each(function () {
  10693. var checkbox = $("input:checkbox", this);
  10694. var tdrect = this.getBoundingClientRect();
  10695. tdrect.x += document.documentElement.scrollLeft;
  10696. tdrect.y += document.documentElement.scrollTop;
  10697. var td_min_x = tdrect.x;
  10698. var td_min_y = tdrect.y;
  10699. var td_max_x = tdrect.x + tdrect.width;
  10700. var td_max_y = tdrect.y + tdrect.height;
  10701. var drag_min_x = dragrect.x;
  10702. var drag_min_y = dragrect.y;
  10703. var drag_max_x = dragrect.x + dragrect.width;
  10704. var drag_max_y = dragrect.y + dragrect.height;
  10705. 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;
  10706. if (overlapped) {
  10707. if (!$(this).hasClass("overlaped")) {
  10708. $(this).addClass("overlaped");
  10709. checkbox.trigger("click");
  10710. }
  10711. } else {
  10712. if ($(this).hasClass("overlaped")) {
  10713. $(this).removeClass("overlaped");
  10714. checkbox.trigger("click");
  10715. }
  10716. }
  10717. });
  10718. }
  10719. };
  10720. var selectstart = function () {
  10721. return false;
  10722. };
  10723. var mouseup = function () {
  10724. if (drag) {
  10725. $(document).off("mousemove", mousemove);
  10726. $(document).off("selectstart", selectstart);
  10727. dragdiv.remove();
  10728. }
  10729. drag = false;
  10730. prepare = false;
  10731. $(document.body).css({'MozUserSelect': '', 'webkitUserSelect': ''}).attr('unselectable', 'off');
  10732. };
  10733. $(Table.config.checkboxtd, table).on("mousedown", function (e) {
  10734. //禁止鼠标右键事件和文本框
  10735. if (e.button === 2 || $(e.target).is("input")) {
  10736. return false;
  10737. }
  10738. posx = e.pageX;
  10739. posy = e.pageY;
  10740. prepare = true;
  10741. }).on("mousemove", function (e) {
  10742. if (prepare && !drag) {
  10743. drag = true;
  10744. dragdiv = $("<div />");
  10745. dragdiv.css({position: 'absolute', width: 0, height: 0, border: "1px dashed blue", background: "#0029ff", left: e.pageX + "px", top: e.pageY + "px", opacity: .1});
  10746. dragdiv.appendTo(document.body);
  10747. $(document.body).css({'MozUserSelect': 'none', 'webkitUserSelect': 'none'}).attr('unselectable', 'on');
  10748. $(document).on("mousemove", mousemove).on("mouseup", mouseup).on("selectstart", selectstart);
  10749. if (options.dragCheckboxMultiselect) {
  10750. $(Table.config.checkboxtd, table).removeClass("overlaped");
  10751. }
  10752. }
  10753. });
  10754. }
  10755. });
  10756. var exportDataType = options.exportDataType;
  10757. // 处理选中筛选框后按钮的状态统一变更
  10758. table.on('check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table post-body.bs.table', function (e) {
  10759. var allIds = [];
  10760. $.each(table.bootstrapTable("getData"), function (i, item) {
  10761. allIds.push(typeof item[options.pk] != 'undefined' ? item[options.pk] : '');
  10762. });
  10763. var selectedIds = Table.api.selectedids(table, true),
  10764. selectedData = Table.api.selecteddata(table, true);
  10765. //开启分页checkbox分页记忆
  10766. if (options.maintainSelected) {
  10767. options.selectedIds = options.selectedIds.filter(function (element, index, self) {
  10768. return $.inArray(element, allIds) === -1;
  10769. }).concat(selectedIds);
  10770. options.selectedData = options.selectedData.filter(function (element, index, self) {
  10771. return $.inArray(element[options.pk], allIds) === -1;
  10772. }).concat(selectedData);
  10773. if (options.selectedIds.length > selectedIds.length) {
  10774. $("b", tipsBtn).text(options.selectedIds.length);
  10775. tipsBtn.removeClass('hide');
  10776. } else {
  10777. tipsBtn.addClass('hide');
  10778. }
  10779. } else {
  10780. options.selectedIds = selectedIds;
  10781. options.selectedData = selectedData;
  10782. }
  10783. //如果导出类型为auto时则自动判断
  10784. if (exportDataType === 'auto') {
  10785. options.exportDataType = selectedIds.length > 0 ? 'selected' : 'all';
  10786. if ($(".export .exporttips").length === 0) {
  10787. $(".export .dropdown-menu").prepend("<li class='exporttips alert alert-warning-light mb-0 no-border p-2'></li>")
  10788. }
  10789. $(".export .exporttips").html("导出记录:" + (selectedIds.length > 0 ? "选中" : "全部"));
  10790. }
  10791. $(Table.config.disabledbtn, toolbar).toggleClass('disabled', !options.selectedIds.length);
  10792. });
  10793. // 提交通用搜索时判断是否和Tabs筛选一致
  10794. table.on('common-search.bs.table', function (e, setting, query) {
  10795. var tabs = $('.panel-heading [data-field]', table.closest(".panel-intro"));
  10796. var field = tabs.data("field");
  10797. var value = $("li.active > a", tabs).data("value");
  10798. if (query.filter && typeof query.filter[field] !== 'undefined' && query.filter[field] != value) {
  10799. $("li", tabs).removeClass("active");
  10800. $("li > a[data-value='" + query.filter[field] + "']", tabs).parent().addClass("active");
  10801. }
  10802. });
  10803. // 绑定TAB事件
  10804. $('.panel-heading [data-field] a[data-toggle="tab"]', table.closest(".panel-intro")).on('shown.bs.tab', function (e) {
  10805. var field = $(this).closest("[data-field]").data("field");
  10806. var value = $(this).data("value");
  10807. var object = $("[name='" + field + "']", table.closest(".bootstrap-table").find(".commonsearch-table"));
  10808. if (object.prop('tagName') === "SELECT") {
  10809. $("option[value='" + value + "']", object).prop("selected", true);
  10810. } else {
  10811. object.val(value);
  10812. }
  10813. table.trigger("uncheckbox");
  10814. table.bootstrapTable('getOptions').totalRows = 0;
  10815. table.bootstrapTable('refresh', {pageNumber: 1});
  10816. return false;
  10817. });
  10818. // 修复重置事件
  10819. $("form", table.closest(".bootstrap-table").find(".commonsearch-table")).on('reset', function () {
  10820. setTimeout(function () {
  10821. // $('.panel-heading [data-field] li.active a[data-toggle="tab"]').trigger('shown.bs.tab');
  10822. }, 0);
  10823. $('.panel-heading [data-field] li', table.closest(".panel-intro")).removeClass('active');
  10824. $('.panel-heading [data-field] li:first', table.closest(".panel-intro")).addClass('active');
  10825. });
  10826. // 刷新按钮事件
  10827. toolbar.on('click', Table.config.refreshbtn, function () {
  10828. table.bootstrapTable('refresh');
  10829. });
  10830. // 添加按钮事件
  10831. toolbar.on('click', Table.config.addbtn, function () {
  10832. var ids = Table.api.selectedids(table);
  10833. var url = options.extend.add_url;
  10834. if (url.indexOf("{ids}") !== -1) {
  10835. url = Table.api.replaceurl(url, {ids: ids.length > 0 ? ids.join(",") : 0}, table);
  10836. }
  10837. Fast.api.open(url, $(this).data("original-title") || $(this).attr("title") || __('Add'), $(this).data() || {});
  10838. });
  10839. // 导入按钮事件
  10840. if ($(Table.config.importbtn, toolbar).length > 0) {
  10841. require(['upload'], function (Upload) {
  10842. Upload.api.upload($(Table.config.importbtn, toolbar), function (data, ret) {
  10843. Fast.api.ajax({
  10844. url: options.extend.import_url,
  10845. data: {file: data.url},
  10846. }, function (data, ret) {
  10847. table.trigger("uncheckbox");
  10848. table.bootstrapTable('refresh');
  10849. });
  10850. });
  10851. });
  10852. }
  10853. // 批量编辑按钮事件
  10854. toolbar.on('click', Table.config.editbtn, function () {
  10855. var that = this;
  10856. var ids = Table.api.selectedids(table);
  10857. if (ids.length > 10) {
  10858. return;
  10859. }
  10860. var title = $(that).data('title') || $(that).attr("title") || __('Edit');
  10861. var data = $(that).data() || {};
  10862. delete data.title;
  10863. //循环弹出多个编辑框
  10864. $.each(Table.api.selecteddata(table), function (index, row) {
  10865. var url = options.extend.edit_url;
  10866. row = $.extend({}, row ? row : {}, {ids: row[options.pk]});
  10867. url = Table.api.replaceurl(url, row, table);
  10868. Fast.api.open(url, typeof title === 'function' ? title.call(table, row) : title, data);
  10869. });
  10870. });
  10871. //清空回收站
  10872. $(document).on('click', Table.config.destroyallbtn, function () {
  10873. var that = this;
  10874. Layer.confirm(__('Are you sure you want to truncate?'), function () {
  10875. var url = $(that).data("url") ? $(that).data("url") : $(that).attr("href");
  10876. Fast.api.ajax(url, function () {
  10877. Layer.closeAll();
  10878. table.trigger("uncheckbox");
  10879. table.bootstrapTable('refresh');
  10880. }, function () {
  10881. Layer.closeAll();
  10882. });
  10883. });
  10884. return false;
  10885. });
  10886. //全部还原
  10887. $(document).on('click', Table.config.restoreallbtn, function () {
  10888. var that = this;
  10889. var url = $(that).data("url") ? $(that).data("url") : $(that).attr("href");
  10890. Fast.api.ajax(url, function () {
  10891. Layer.closeAll();
  10892. table.trigger("uncheckbox");
  10893. table.bootstrapTable('refresh');
  10894. }, function () {
  10895. Layer.closeAll();
  10896. });
  10897. return false;
  10898. });
  10899. //销毁或删除
  10900. $(document).on('click', Table.config.restoreonebtn + ',' + Table.config.destroyonebtn, function () {
  10901. var that = this;
  10902. var url = $(that).data("url") ? $(that).data("url") : $(that).attr("href");
  10903. var row = Table.api.getrowbyindex(table, $(that).data("row-index"));
  10904. Fast.api.ajax({
  10905. url: url,
  10906. data: {ids: row[options.pk]}
  10907. }, function () {
  10908. table.trigger("uncheckbox");
  10909. table.bootstrapTable('refresh');
  10910. });
  10911. return false;
  10912. });
  10913. // 批量操作按钮事件
  10914. toolbar.on('click', Table.config.multibtn, function () {
  10915. var ids = Table.api.selectedids(table);
  10916. Table.api.multi($(this).data("action"), ids, table, this);
  10917. });
  10918. // 批量删除按钮事件
  10919. toolbar.on('click', Table.config.delbtn, function () {
  10920. var that = this;
  10921. var ids = Table.api.selectedids(table);
  10922. Layer.confirm(
  10923. __('Are you sure you want to delete the %s selected item?', ids.length),
  10924. {icon: 3, title: __('Warning'), offset: 0, shadeClose: true, btn: [__('OK'), __('Cancel')]},
  10925. function (index) {
  10926. Table.api.multi("del", ids, table, that);
  10927. Layer.close(index);
  10928. }
  10929. );
  10930. });
  10931. // 拖拽排序
  10932. require(['dragsort'], function () {
  10933. //绑定拖动排序
  10934. $("tbody", table).dragsort({
  10935. itemSelector: 'tr:visible',
  10936. dragSelector: "a.btn-dragsort",
  10937. dragEnd: function (a, b) {
  10938. var element = $("a.btn-dragsort", this);
  10939. var data = table.bootstrapTable('getData');
  10940. var current = data[parseInt($(this).data("index"))];
  10941. var options = table.bootstrapTable('getOptions');
  10942. //改变的值和改变的ID集合
  10943. var ids = $.map($("tbody tr:visible", table), function (tr) {
  10944. return data[parseInt($(tr).data("index"))][options.pk];
  10945. });
  10946. var changeid = current[options.pk];
  10947. var pid = typeof current.pid != 'undefined' ? current.pid : '';
  10948. var params = {
  10949. url: table.bootstrapTable('getOptions').extend.dragsort_url,
  10950. data: {
  10951. ids: ids.join(','),
  10952. changeid: changeid,
  10953. pid: pid,
  10954. field: Table.config.dragsortfield,
  10955. orderway: options.sortOrder,
  10956. table: options.extend.table,
  10957. pk: options.pk
  10958. }
  10959. };
  10960. Fast.api.ajax(params, function (data, ret) {
  10961. var success = $(element).data("success") || $.noop;
  10962. if (typeof success === 'function') {
  10963. if (false === success.call(element, data, ret)) {
  10964. return false;
  10965. }
  10966. }
  10967. table.bootstrapTable('refresh');
  10968. }, function (data, ret) {
  10969. var error = $(element).data("error") || $.noop;
  10970. if (typeof error === 'function') {
  10971. if (false === error.call(element, data, ret)) {
  10972. return false;
  10973. }
  10974. }
  10975. table.bootstrapTable('refresh');
  10976. });
  10977. },
  10978. placeHolderTemplate: ""
  10979. });
  10980. });
  10981. table.on("click", "input[data-id][name='checkbox']", function (e) {
  10982. var ids = $(this).data("id");
  10983. table.bootstrapTable($(this).prop("checked") ? 'checkBy' : 'uncheckBy', {field: options.pk, values: [ids]});
  10984. });
  10985. table.on("click", "[data-id].btn-change", function (e) {
  10986. e.preventDefault();
  10987. var changer = $.proxy(function () {
  10988. Table.api.multi($(this).data("action") ? $(this).data("action") : '', [$(this).data("id")], table, this);
  10989. }, this);
  10990. if (typeof $(this).data("confirm") !== 'undefined') {
  10991. Layer.confirm($(this).data("confirm"), function (index) {
  10992. changer();
  10993. Layer.close(index);
  10994. });
  10995. } else {
  10996. changer();
  10997. }
  10998. });
  10999. table.on("click", "[data-id].btn-edit", function (e) {
  11000. e.preventDefault();
  11001. var ids = $(this).data("id");
  11002. var row = Table.api.getrowbyid(table, ids);
  11003. row.ids = ids;
  11004. var url = Table.api.replaceurl(options.extend.edit_url, row, table);
  11005. Fast.api.open(url, $(this).data("original-title") || $(this).attr("title") || __('Edit'), $(this).data() || {});
  11006. });
  11007. table.on("click", "[data-id].btn-del", function (e) {
  11008. e.preventDefault();
  11009. var id = $(this).data("id");
  11010. var that = this;
  11011. Layer.confirm(
  11012. __('Are you sure you want to delete this item?'),
  11013. {icon: 3, title: __('Warning'), shadeClose: true, btn: [__('OK'), __('Cancel')]},
  11014. function (index) {
  11015. Table.api.multi("del", id, table, that);
  11016. Layer.close(index);
  11017. }
  11018. );
  11019. });
  11020. table.on("mouseenter mouseleave", ".autocontent", function (e) {
  11021. var target = $(".autocontent-item", this).get(0);
  11022. if (!target) return;
  11023. if (e.type === 'mouseenter') {
  11024. if (target.scrollWidth > target.offsetWidth && $(".autocontent-caret", this).length === 0) {
  11025. $(this).append("<div class='autocontent-caret'><i class='fa fa-chevron-down'></div>");
  11026. }
  11027. } else {
  11028. $(".autocontent-caret", this).remove();
  11029. }
  11030. });
  11031. table.on("click mouseenter", ".autocontent-caret", function (e) {
  11032. var hover = $(this).prev().hasClass("autocontent-hover");
  11033. if (!hover && e.type === 'mouseenter') {
  11034. return;
  11035. }
  11036. var text = $(this).prev().text();
  11037. var tdrect = $(this).parent().get(0).getBoundingClientRect();
  11038. 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]});
  11039. if (hover) {
  11040. $(document).one("mouseleave", "#layui-layer" + index, function () {
  11041. Layer.close(index);
  11042. });
  11043. }
  11044. var mousedown = function (e) {
  11045. if ($(e.target).closest(".layui-layer").length === 0) {
  11046. Layer.close(index);
  11047. $(document).off("mousedown", mousedown);
  11048. }
  11049. };
  11050. $(document).off("mousedown", mousedown).on("mousedown", mousedown);
  11051. });
  11052. //修复dropdown定位溢出的情况
  11053. if (options.fixDropdownPosition) {
  11054. var tableBody = table.closest(".fixed-table-body");
  11055. table.on('show.bs.dropdown fa.event.refreshdropdown', ".btn-group", function (e) {
  11056. var dropdownMenu = $(".dropdown-menu", this);
  11057. var btnGroup = $(this);
  11058. var isPullRight = dropdownMenu.hasClass("pull-right") || dropdownMenu.hasClass("dropdown-menu-right");
  11059. var left, top, position;
  11060. if (true || dropdownMenu.outerHeight() + btnGroup.outerHeight() > tableBody.outerHeight() - 41) {
  11061. position = 'fixed';
  11062. top = btnGroup.offset().top - $(window).scrollTop() + btnGroup.outerHeight();
  11063. if ((top + dropdownMenu.outerHeight()) > $(window).height()) {
  11064. top = btnGroup.offset().top - dropdownMenu.outerHeight() - 5;
  11065. }
  11066. left = isPullRight ? btnGroup.offset().left + btnGroup.outerWidth() - dropdownMenu.outerWidth() : btnGroup.offset().left;
  11067. }
  11068. if (left || top) {
  11069. dropdownMenu.css({
  11070. position: position, left: left, top: top, right: 'inherit'
  11071. });
  11072. }
  11073. });
  11074. var checkdropdown = function () {
  11075. if ($(".btn-group.open", table).length > 0 && $(".btn-group.open .dropdown-menu", table).css("position") == 'fixed') {
  11076. $(".btn-group.open", table).trigger("fa.event.refreshdropdown");
  11077. }
  11078. };
  11079. $(window).on("scroll", function () {
  11080. checkdropdown();
  11081. });
  11082. tableBody.on("scroll", function () {
  11083. checkdropdown();
  11084. });
  11085. }
  11086. var id = table.attr("id");
  11087. Table.list[id] = table;
  11088. return table;
  11089. },
  11090. // 批量操作请求
  11091. multi: function (action, ids, table, element) {
  11092. var options = table.bootstrapTable('getOptions');
  11093. var data = element ? $(element).data() : {};
  11094. ids = ($.isArray(ids) ? ids.join(",") : ids);
  11095. var url = typeof data.url !== "undefined" ? data.url : (action == "del" ? options.extend.del_url : options.extend.multi_url);
  11096. var params = typeof data.params !== "undefined" ? (typeof data.params == 'object' ? $.param(data.params) : data.params) : '';
  11097. options = {url: url, data: {action: action, ids: ids, params: params}};
  11098. Fast.api.ajax(options, function (data, ret) {
  11099. table.trigger("uncheckbox");
  11100. var success = $(element).data("success") || $.noop;
  11101. if (typeof success === 'function') {
  11102. if (false === success.call(element, data, ret)) {
  11103. return false;
  11104. }
  11105. }
  11106. table.bootstrapTable('refresh');
  11107. }, function (data, ret) {
  11108. var error = $(element).data("error") || $.noop;
  11109. if (typeof error === 'function') {
  11110. if (false === error.call(element, data, ret)) {
  11111. return false;
  11112. }
  11113. }
  11114. });
  11115. },
  11116. // 单元格元素事件
  11117. events: {
  11118. operate: {
  11119. 'click .btn-editone': function (e, value, row, index) {
  11120. e.stopPropagation();
  11121. e.preventDefault();
  11122. var table = $(this).closest('table');
  11123. var options = table.bootstrapTable('getOptions');
  11124. var ids = row[options.pk];
  11125. row = $.extend({}, row ? row : {}, {ids: ids});
  11126. var url = options.extend.edit_url;
  11127. Fast.api.open(Table.api.replaceurl(url, row, table), $(this).data("original-title") || $(this).attr("title") || __('Edit'), $(this).data() || {});
  11128. },
  11129. 'click .btn-delone': function (e, value, row, index) {
  11130. e.stopPropagation();
  11131. e.preventDefault();
  11132. var that = this;
  11133. var top = $(that).offset().top - $(window).scrollTop();
  11134. var left = $(that).offset().left - $(window).scrollLeft() - 260;
  11135. if (top + 154 > $(window).height()) {
  11136. top = top - 154;
  11137. }
  11138. if ($(window).width() < 480) {
  11139. top = left = undefined;
  11140. }
  11141. Layer.confirm(
  11142. __('Are you sure you want to delete this item?'),
  11143. {icon: 3, title: __('Warning'), offset: [top, left], shadeClose: true, btn: [__('OK'), __('Cancel')]},
  11144. function (index) {
  11145. var table = $(that).closest('table');
  11146. var options = table.bootstrapTable('getOptions');
  11147. Table.api.multi("del", row[options.pk], table, that);
  11148. Layer.close(index);
  11149. }
  11150. );
  11151. }
  11152. },//单元格图片预览
  11153. image: {
  11154. 'click .img-center': function (e, value, row, index) {
  11155. var data = [];
  11156. value = value === null ? '' : value.toString();
  11157. var arr = value != '' ? value.split(",") : [];
  11158. var url;
  11159. $.each(arr, function (index, value) {
  11160. url = Fast.api.cdnurl(value);
  11161. data.push({
  11162. src: url,
  11163. thumb: url.match(/^(\/|data:image\\)/) ? url : url + Config.upload.thumbstyle
  11164. });
  11165. });
  11166. Layer.photos({
  11167. photos: {
  11168. "start": $(this).parent().index(),
  11169. "data": data
  11170. },
  11171. anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)
  11172. });
  11173. },
  11174. }
  11175. },
  11176. // 单元格数据格式化
  11177. formatter: {
  11178. icon: function (value, row, index) {
  11179. value = value === null ? '' : value.toString();
  11180. value = value.indexOf(" ") > -1 ? value : "fa fa-" + value;
  11181. //渲染fontawesome图标
  11182. return '<i class="' + value + '"></i> ' + value;
  11183. },
  11184. image: function (value, row, index) {
  11185. return Table.api.formatter.images.call(this, value, row, index);
  11186. },
  11187. images: function (value, row, index) {
  11188. value = value == null || value.length === 0 ? '' : value.toString();
  11189. var classname = typeof this.classname !== 'undefined' ? this.classname : 'img-sm img-center';
  11190. var arr = value !== '' ? (value.indexOf('data:image/') === -1 ? value.split(',') : [value]) : [];
  11191. var html = [];
  11192. var url;
  11193. $.each(arr, function (i, value) {
  11194. value = value ? value : '/assets/img/blank.gif';
  11195. url = Fast.api.cdnurl(value, true);
  11196. //匹配本地、data:image、或已包含标识符首字符
  11197. url = !Config.upload.thumbstyle || url.match(/^(\/|data:image\/)/) || url.indexOf(Config.upload.thumbstyle.substring(0, 1)) > -1 ? url : url + Config.upload.thumbstyle;
  11198. html.push('<a href="javascript:"><img class="' + classname + '" src="' + url + '" /></a>');
  11199. });
  11200. return html.join(' ');
  11201. },
  11202. file: function (value, row, index) {
  11203. return Table.api.formatter.files.call(this, value, row, index);
  11204. },
  11205. files: function (value, row, index) {
  11206. value = value == null || value.length === 0 ? '' : value.toString();
  11207. var classname = typeof this.classname !== 'undefined' ? this.classname : 'img-sm img-center';
  11208. var arr = value !== '' ? (value.indexOf('data:image/') === -1 ? value.split(',') : [value]) : [];
  11209. var html = [];
  11210. var suffix, url;
  11211. $.each(arr, function (i, value) {
  11212. value = Fast.api.cdnurl(value, true);
  11213. suffix = /[\.]?([a-zA-Z0-9]+)$/.exec(value);
  11214. suffix = suffix ? suffix[1] : 'file';
  11215. url = Fast.api.fixurl("ajax/icon?suffix=" + suffix);
  11216. html.push('<a href="' + value + '" target="_blank"><img src="' + url + '" class="' + classname + '"></a>');
  11217. });
  11218. return html.join(' ');
  11219. },
  11220. content: function (value, row, index) {
  11221. var width = this.width != undefined ? (this.width.toString().match(/^\d+$/) ? this.width + "px" : this.width) : "250px";
  11222. var hover = this.hover != undefined && this.hover ? "autocontent-hover" : "";
  11223. return "<div class='autocontent-item " + hover + "' style='white-space: nowrap; text-overflow:ellipsis; overflow: hidden; max-width:" + width + ";'>" + value + "</div>";
  11224. },
  11225. status: function (value, row, index) {
  11226. var custom = {normal: 'success', hidden: 'gray', deleted: 'danger', locked: 'info'};
  11227. if (typeof this.custom !== 'undefined') {
  11228. custom = $.extend(custom, this.custom);
  11229. }
  11230. this.custom = custom;
  11231. this.icon = 'fa fa-circle';
  11232. return Table.api.formatter.normal.call(this, value, row, index);
  11233. },
  11234. simtype: function (value, row, index) {
  11235. var custom = {'0001': 'success', '0002': 'info', '0003': 'warning'};
  11236. if (typeof this.custom !== 'undefined') {
  11237. custom = $.extend(custom, this.custom);
  11238. }
  11239. this.custom = custom;
  11240. return Table.api.formatter.normal.call(this, value, row, index);
  11241. },
  11242. // ["primary", "success", "danger", "warning", "info", "gray", "red", "yellow", "aqua", "blue", "navy", "teal", "olive", "lime", "fuchsia", "purple", "maroon"];
  11243. simexamstatus: function (value, row, index) {
  11244. var custom = {'0': 'gray', '1': 'info', '2': 'danger', '3': 'success','4': 'warning','5': 'aqua','6': 'navy','7': 'blue','80': 'red','81': 'yellow','90': 'maroon'};
  11245. if (typeof this.custom !== 'undefined') {
  11246. custom = $.extend(custom, this.custom);
  11247. }
  11248. this.custom = custom;
  11249. this.icon = 'fa fa-circle';
  11250. return Table.api.formatter.normal.call(this, value, row, index);
  11251. },
  11252. simmethod: function (value, row, index) {
  11253. var custom = {'1': 'danger', '2': 'info', '3': 'success'};
  11254. if (typeof this.custom !== 'undefined') {
  11255. custom = $.extend(custom, this.custom);
  11256. }
  11257. this.custom = custom;
  11258. return Table.api.formatter.normal.call(this, value, row, index);
  11259. },
  11260. answerName:function(value, row, index){
  11261. var text = '';
  11262. for (var i = 0;i<value.length;i++){
  11263. text +='<span class="btn btn-xs m-1" style="background:#444c69;display: inline-block; color: white;border: none;border-radius: 4px;white-space: nowrap;font-size: 12px;">'+value[i].cx_name+'</span>';
  11264. }
  11265. return text;
  11266. },
  11267. faultname:function(value, row, index){
  11268. if (!value || value.trim() === '-') {
  11269. // 当值为空或为 '-' 时,显示红色文本
  11270. return `<span class="text-danger"></span>`;
  11271. }
  11272. // 生成随机渐变颜色
  11273. function randomGradient() {
  11274. var color1 = `#${Math.floor(Math.random() * 16777215).toString(16).padStart(6, '0')}`;
  11275. var color2 = `#${Math.floor(Math.random() * 16777215).toString(16).padStart(6, '0')}`;
  11276. return '#444c69';//`linear-gradient(45deg, ${color1}, ${color2})`;
  11277. }
  11278. // 将逗号分隔的内容转换为带渐变背景的按钮
  11279. var items = value.split(',').map(function (item) {
  11280. var gradient = randomGradient();
  11281. return `<span class="btn btn-xs m-1"
  11282. style="
  11283. display: inline-block;
  11284. background: ${gradient};
  11285. color: white;
  11286. border: none;
  11287. /*padding: 5px 10px;*/
  11288. border-radius: 4px;
  11289. white-space: nowrap;
  11290. font-size: 12px;
  11291. ">
  11292. ${item.trim()}
  11293. </span>`;
  11294. });
  11295. return items.join(' ');
  11296. },
  11297. collectonstate: function (value, row, index) {
  11298. var table = this.table;
  11299. var options = table ? table.bootstrapTable('getOptions') : {};
  11300. var pk = options.pk || "id";
  11301. var color = typeof this.color !== 'undefined' ? this.color : 'success';
  11302. var yes = typeof this.yes !== 'undefined' ? this.yes : 2;
  11303. var no = typeof this.no !== 'undefined' ? this.no : 3;
  11304. var url = typeof this.url !== 'undefined' ? this.url : '';
  11305. var confirm = '';
  11306. var disable = false;
  11307. if (typeof this.confirm !== "undefined") {
  11308. confirm = typeof this.confirm === "function" ? this.confirm.call(this, value, row, index) : this.confirm;
  11309. }
  11310. if (typeof this.disable !== "undefined") {
  11311. disable = typeof this.disable === "function" ? this.disable.call(this, value, row, index) : this.disable;
  11312. }
  11313. return "<a href='javascript:;' data-toggle='tooltip' title='" + __('Click to toggle') + "' class='btn-change " + (disable ? 'btn disabled no-padding' : '') + "' data-index='" + index + "' data-id='"
  11314. + 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>";
  11315. },
  11316. normal: function (value, row, index) {
  11317. var colorArr = ["primary", "success", "danger", "warning", "info", "gray", "red", "yellow", "aqua", "blue", "navy", "teal", "olive", "lime", "fuchsia", "purple", "maroon"];
  11318. var custom = {};
  11319. if (typeof this.custom !== 'undefined') {
  11320. custom = $.extend(custom, this.custom);
  11321. }
  11322. value = value == null || value.length === 0 ? '' : value.toString();
  11323. var keys = typeof this.searchList === 'object' ? Object.keys(this.searchList) : [];
  11324. var index = keys.indexOf(value);
  11325. var color = value && typeof custom[value] !== 'undefined' ? custom[value] : null;
  11326. var display = index > -1 ? this.searchList[value] : null;
  11327. var icon = typeof this.icon !== 'undefined' ? this.icon : null;
  11328. if (!color) {
  11329. color = index > -1 && typeof colorArr[index] !== 'undefined' ? colorArr[index] : 'primary';
  11330. }
  11331. if (!display) {
  11332. display = __(value.charAt(0).toUpperCase() + value.slice(1));
  11333. }
  11334. var html = '<span class="text-' + color + '">' + (icon ? '<i class="' + icon + '"></i> ' : '') + display + '</span>';
  11335. if (this.operate != false) {
  11336. html = '<a href="javascript:;" class="searchit" data-toggle="tooltip" title="' + __('Click to search %s', display) + '" data-field="' + this.field + '" data-value="' + value + '">' + html + '</a>';
  11337. }
  11338. return html;
  11339. },
  11340. toggle: function (value, row, index) {
  11341. var table = this.table;
  11342. var options = table ? table.bootstrapTable('getOptions') : {};
  11343. var pk = options.pk || "id";
  11344. var color = typeof this.color !== 'undefined' ? this.color : 'success';
  11345. var yes = typeof this.yes !== 'undefined' ? this.yes : 1;
  11346. var no = typeof this.no !== 'undefined' ? this.no : 0;
  11347. var url = typeof this.url !== 'undefined' ? this.url : '';
  11348. var confirm = '';
  11349. var disable = false;
  11350. if (typeof this.confirm !== "undefined") {
  11351. confirm = typeof this.confirm === "function" ? this.confirm.call(this, value, row, index) : this.confirm;
  11352. }
  11353. if (typeof this.disable !== "undefined") {
  11354. disable = typeof this.disable === "function" ? this.disable.call(this, value, row, index) : this.disable;
  11355. }
  11356. return "<a href='javascript:;' data-toggle='tooltip' title='" + __('Click to toggle') + "' class='btn-change " + (disable ? 'btn disabled no-padding' : '') + "' data-index='" + index + "' data-id='"
  11357. + 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>";
  11358. },
  11359. url: function (value, row, index) {
  11360. value = value == null || value.length === 0 ? '' : value.toString();
  11361. 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>';
  11362. },
  11363. search: function (value, row, index) {
  11364. var field = this.field;
  11365. if (typeof this.customField !== 'undefined') {
  11366. var customValue = this.customField.split('.').reduce(function (obj, key) {
  11367. return obj === null || obj === undefined ? '' : obj[key];
  11368. }, row);
  11369. value = Fast.api.escape(customValue);
  11370. field = this.customField;
  11371. }
  11372. return '<a href="javascript:;" class="searchit" data-toggle="tooltip" title="' + __('Click to search %s', value) + '" data-field="' + field + '" data-value="' + value + '">' + value + '</a>';
  11373. },
  11374. addtabs: function (value, row, index) {
  11375. var url = Table.api.replaceurl(this.url || '', row, this.table);
  11376. var title = this.atitle ? this.atitle : __("Search %s", value);
  11377. return '<a href="' + Fast.api.fixurl(url) + '" class="addtabsit" data-value="' + value + '" title="' + title + '">' + value + '</a>';
  11378. },
  11379. dialog: function (value, row, index) {
  11380. var url = Table.api.replaceurl(this.url || '', row, this.table);
  11381. var title = this.atitle ? this.atitle : __("View %s", value);
  11382. return '<a href="' + Fast.api.fixurl(url) + '" class="dialogit" data-value="' + value + '" title="' + title + '">' + value + '</a>';
  11383. },
  11384. flag: function (value, row, index) {
  11385. var that = this;
  11386. value = value == null || value.length === 0 ? '' : value.toString();
  11387. var colorArr = {index: 'success', hot: 'warning', recommend: 'danger', 'new': 'info'};
  11388. //如果字段列有定义custom
  11389. if (typeof this.custom !== 'undefined') {
  11390. colorArr = $.extend(colorArr, this.custom);
  11391. }
  11392. var field = this.field;
  11393. if (typeof this.customField !== 'undefined') {
  11394. var customValue = this.customField.split('.').reduce(function (obj, key) {
  11395. return obj === null || obj === undefined ? '' : obj[key];
  11396. }, row);
  11397. value = Fast.api.escape(customValue);
  11398. field = this.customField;
  11399. }
  11400. if (typeof that.searchList === 'object' && typeof that.custom === 'undefined') {
  11401. var i = 0;
  11402. var searchValues = Object.values(colorArr);
  11403. $.each(that.searchList, function (key, val) {
  11404. if (typeof colorArr[key] == 'undefined') {
  11405. colorArr[key] = searchValues[i];
  11406. i = typeof searchValues[i + 1] === 'undefined' ? 0 : i + 1;
  11407. }
  11408. });
  11409. }
  11410. //渲染Flag
  11411. var html = [];
  11412. var arr = value != '' ? value.split(',') : [];
  11413. var color, display, label;
  11414. $.each(arr, function (i, value) {
  11415. value = value == null || value.length === 0 ? '' : value.toString();
  11416. if (value == '')
  11417. return true;
  11418. color = value && typeof colorArr[value] !== 'undefined' ? colorArr[value] : 'primary';
  11419. display = typeof that.searchList !== 'undefined' && typeof that.searchList[value] !== 'undefined' ? that.searchList[value] : __(value.charAt(0).toUpperCase() + value.slice(1));
  11420. label = '<span class="label label-' + color + '">' + display + '</span>';
  11421. if (that.operate) {
  11422. html.push('<a href="javascript:;" class="searchit" data-toggle="tooltip" title="' + __('Click to search %s', display) + '" data-field="' + field + '" data-value="' + value + '">' + label + '</a>');
  11423. } else {
  11424. html.push(label);
  11425. }
  11426. });
  11427. return html.join(' ');
  11428. },
  11429. label: function (value, row, index) {
  11430. return Table.api.formatter.flag.call(this, value, row, index);
  11431. },
  11432. datetime: function (value, row, index) {
  11433. var datetimeFormat = typeof this.datetimeFormat === 'undefined' ? 'YYYY-MM-DD HH:mm:ss' : this.datetimeFormat;
  11434. if (isNaN(value)) {
  11435. return value ? Moment(value).format(datetimeFormat) : __('None');
  11436. } else {
  11437. return value ? Moment(parseInt(value) * 1000).format(datetimeFormat) : __('None');
  11438. }
  11439. },
  11440. operate: function (value, row, index) {
  11441. var table = this.table;
  11442. // 操作配置
  11443. var options = table ? table.bootstrapTable('getOptions') : {};
  11444. // 默认按钮组
  11445. var buttons = $.extend([], this.buttons || []);
  11446. // 所有按钮名称
  11447. var names = [];
  11448. buttons.forEach(function (item) {
  11449. names.push(item.name);
  11450. });
  11451. if (options.extend.dragsort_url !== '' && names.indexOf('dragsort') === -1) {
  11452. buttons.push(Table.button.dragsort);
  11453. }
  11454. if (options.extend.edit_url !== '' && names.indexOf('edit') === -1) {
  11455. Table.button.edit.url = options.extend.edit_url;
  11456. buttons.push(Table.button.edit);
  11457. }
  11458. if (options.extend.del_url !== '' && names.indexOf('del') === -1) {
  11459. buttons.push(Table.button.del);
  11460. }
  11461. return Table.api.buttonlink(this, buttons, value, row, index, 'operate');
  11462. }
  11463. ,
  11464. buttons: function (value, row, index) {
  11465. // 默认按钮组
  11466. var buttons = $.extend([], this.buttons || []);
  11467. return Table.api.buttonlink(this, buttons, value, row, index, 'buttons');
  11468. }
  11469. },
  11470. buttonlink: function (column, buttons, value, row, index, type) {
  11471. var table = column.table;
  11472. column.clickToSelect = false;
  11473. type = typeof type === 'undefined' ? 'buttons' : type;
  11474. var options = table ? table.bootstrapTable('getOptions') : {};
  11475. var html = [];
  11476. var hidden, visible, disable, url, classname, icon, text, title, refresh, confirm, extend,
  11477. dropdown, link;
  11478. var fieldIndex = column.fieldIndex;
  11479. var dropdowns = {};
  11480. $.each(buttons, function (i, j) {
  11481. if (type === 'operate') {
  11482. if (j.name === 'dragsort' && typeof row[Table.config.dragsortfield] === 'undefined') {
  11483. return true;
  11484. }
  11485. if (['add', 'edit', 'del', 'multi', 'dragsort'].indexOf(j.name) > -1 && !options.extend[j.name + "_url"]) {
  11486. return true;
  11487. }
  11488. }
  11489. var attr = table.data(type + "-" + j.name);
  11490. if (typeof attr === 'undefined' || attr) {
  11491. hidden = typeof j.hidden === 'function' ? j.hidden.call(table, row, j) : (typeof j.hidden !== 'undefined' ? j.hidden : false);
  11492. if (hidden) {
  11493. return true;
  11494. }
  11495. visible = typeof j.visible === 'function' ? j.visible.call(table, row, j) : (typeof j.visible !== 'undefined' ? j.visible : true);
  11496. if (!visible) {
  11497. return true;
  11498. }
  11499. dropdown = j.dropdown ? j.dropdown : '';
  11500. url = j.url ? j.url : '';
  11501. url = typeof url === 'function' ? url.call(table, row, j) : (url ? Fast.api.fixurl(Table.api.replaceurl(url, row, table)) : 'javascript:;');
  11502. classname = j.classname ? j.classname : (dropdown ? 'btn-' + name + 'one' : 'btn-primary btn-' + name + 'one');
  11503. icon = j.icon ? j.icon : '';
  11504. text = typeof j.text === 'function' ? j.text.call(table, row, j) : j.text ? j.text : '';
  11505. title = typeof j.title === 'function' ? j.title.call(table, row, j) : j.title ? j.title : text;
  11506. refresh = j.refresh ? 'data-refresh="' + j.refresh + '"' : '';
  11507. confirm = typeof j.confirm === 'function' ? j.confirm.call(table, row, j) : (typeof j.confirm !== 'undefined' ? j.confirm : false);
  11508. confirm = confirm ? 'data-confirm="' + confirm + '"' : '';
  11509. extend = typeof j.extend === 'function' ? j.extend.call(table, row, j) : (typeof j.extend !== 'undefined' ? j.extend : '');
  11510. disable = typeof j.disable === 'function' ? j.disable.call(table, row, j) : (typeof j.disable !== 'undefined' ? j.disable : false);
  11511. if (disable) {
  11512. classname = classname + ' disabled';
  11513. }
  11514. 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>';
  11515. if (dropdown) {
  11516. if (typeof dropdowns[dropdown] == 'undefined') {
  11517. dropdowns[dropdown] = [];
  11518. }
  11519. dropdowns[dropdown].push(link);
  11520. } else {
  11521. html.push(link);
  11522. }
  11523. }
  11524. });
  11525. if (!$.isEmptyObject(dropdowns)) {
  11526. var dropdownHtml = [];
  11527. $.each(dropdowns, function (i, j) {
  11528. 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>');
  11529. });
  11530. html.unshift(dropdownHtml.join(' '));
  11531. }
  11532. return html.join(' ');
  11533. },
  11534. //替换URL中的数据
  11535. replaceurl: function (url, row, table) {
  11536. var options = table ? table.bootstrapTable('getOptions') : null;
  11537. var ids = options ? row[options.pk] : 0;
  11538. row.ids = ids ? ids : (typeof row.ids !== 'undefined' ? row.ids : 0);
  11539. url = url == null || url.length === 0 ? '' : url.toString();
  11540. //自动添加ids参数
  11541. url = !url.match(/(?=([?&]ids=)|(\/ids\/)|(\{ids}))/i) ?
  11542. url + (url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + '{ids}' : url;
  11543. url = url.replace(/\{(.*?)\}/gi, function (matched) {
  11544. matched = matched.substring(1, matched.length - 1);
  11545. var temp = matched.split('.').reduce(function (obj, key) {
  11546. return obj === null || obj === undefined ? '' : obj[key];
  11547. }, row);
  11548. temp = Fast.api.escape(temp);
  11549. return temp;
  11550. });
  11551. return url;
  11552. },
  11553. // 获取选中的条目ID集合
  11554. selectedids: function (table, current) {
  11555. var options = table.bootstrapTable('getOptions');
  11556. //如果有设置翻页记忆模式
  11557. if (!current && options.maintainSelected) {
  11558. return options.selectedIds;
  11559. }
  11560. return $.map(table.bootstrapTable('getSelections'), function (row) {
  11561. return row[options.pk];
  11562. });
  11563. },
  11564. //获取选中的数据
  11565. selecteddata: function (table, current) {
  11566. var options = table.bootstrapTable('getOptions');
  11567. //如果有设置翻页记忆模式
  11568. if (!current && options.maintainSelected) {
  11569. return options.selectedData;
  11570. }
  11571. return table.bootstrapTable('getSelections');
  11572. },
  11573. // 切换复选框状态
  11574. toggleattr: function (table) {
  11575. $("input[type='checkbox']", table).trigger('click');
  11576. },
  11577. // 根据行索引获取行数据
  11578. getrowdata: function (table, index) {
  11579. index = parseInt(index);
  11580. var data = table.bootstrapTable('getData');
  11581. return typeof data[index] !== 'undefined' ? data[index] : null;
  11582. },
  11583. // 根据行索引获取行数据
  11584. getrowbyindex: function (table, index) {
  11585. return Table.api.getrowdata(table, index);
  11586. },
  11587. // 根据主键ID获取行数据
  11588. getrowbyid: function (table, id) {
  11589. var row = {};
  11590. var options = table.bootstrapTable("getOptions");
  11591. $.each(Table.api.selecteddata(table), function (i, j) {
  11592. if (j[options.pk] == id) {
  11593. row = j;
  11594. return false;
  11595. }
  11596. });
  11597. return row;
  11598. }
  11599. },
  11600. };
  11601. return Table;
  11602. });
  11603. // jQuery List DragSort v0.5.3
  11604. // Website: http://dragsort.codeplex.com/
  11605. // License: http://dragsort.codeplex.com/license
  11606. (function($) {
  11607. $.fn.dragsort = function(options) {
  11608. if (options == "destroy") {
  11609. $(this.selector).trigger("dragsort-uninit");
  11610. return;
  11611. }
  11612. var opts = $.extend({}, $.fn.dragsort.defaults, options);
  11613. var lists = [];
  11614. var list = null, lastPos = null;
  11615. this.each(function(i, cont) {
  11616. //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
  11617. if ($(cont).is("table") && $(cont).children().length == 1 && $(cont).children().is("tbody"))
  11618. cont = $(cont).children().get(0);
  11619. var newList = {
  11620. draggedItem: null,
  11621. placeHolderItem: null,
  11622. pos: null,
  11623. offset: null,
  11624. offsetLimit: null,
  11625. scroll: null,
  11626. container: cont,
  11627. init: function() {
  11628. //set options to default values if not set
  11629. opts.tagName = opts.tagName == "" ? ($(this.container).children().length == 0 ? "li" : $(this.container).children().get(0).tagName.toLowerCase()) : opts.tagName;
  11630. if (opts.itemSelector == "")
  11631. opts.itemSelector = opts.tagName;
  11632. if (opts.dragSelector == "")
  11633. opts.dragSelector = opts.tagName;
  11634. if (opts.placeHolderTemplate == "")
  11635. opts.placeHolderTemplate = "<" + opts.tagName + ">&nbsp;</" + opts.tagName + ">";
  11636. //listidx allows reference back to correct list variable instance
  11637. $(this.container).attr("data-listidx", i).mousedown(this.grabItem).bind("dragsort-uninit", this.uninit);
  11638. this.styleDragHandlers(true);
  11639. },
  11640. uninit: function() {
  11641. var list = lists[$(this).attr("data-listidx")];
  11642. $(list.container).unbind("mousedown", list.grabItem).unbind("dragsort-uninit");
  11643. list.styleDragHandlers(false);
  11644. },
  11645. getItems: function() {
  11646. return $(this.container).children(opts.itemSelector);
  11647. },
  11648. styleDragHandlers: function(cursor) {
  11649. this.getItems().map(function() { return $(this).is(opts.dragSelector) ? this : $(this).find(opts.dragSelector).get(); }).css("cursor", cursor ? "pointer" : "");
  11650. },
  11651. grabItem: function(e) {
  11652. var list = lists[$(this).attr("data-listidx")];
  11653. var item = $(e.target).closest("[data-listidx] > " + opts.tagName).get(0);
  11654. var insideMoveableItem = list.getItems().filter(function() { return this == item; }).length > 0;
  11655. //if not left click or if clicked on excluded element (e.g. text box) or not a moveable list item return
  11656. if (e.which != 1 || $(e.target).is(opts.dragSelectorExclude) || $(e.target).closest(opts.dragSelectorExclude).length > 0 || !insideMoveableItem)
  11657. return;
  11658. // if not clicked on drag selector
  11659. if (!$(e.target).is(opts.dragSelector) && !$(e.target).closest(opts.dragSelector).length){
  11660. return;
  11661. }
  11662. //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,
  11663. //does also stop being able to click text boxes hence dragging on text boxes by default is disabled in dragSelectorExclude
  11664. e.preventDefault();
  11665. //change cursor to move while dragging
  11666. var dragHandle = e.target;
  11667. while (!$(dragHandle).is(opts.dragSelector)) {
  11668. if (dragHandle == this) return;
  11669. dragHandle = dragHandle.parentNode;
  11670. }
  11671. $(dragHandle).attr("data-cursor", $(dragHandle).css("cursor"));
  11672. $(dragHandle).css("cursor", "move");
  11673. //on mousedown wait for movement of mouse before triggering dragsort script (dragStart) to allow clicking of hyperlinks to work
  11674. var listElem = this;
  11675. var trigger = function() {
  11676. list.dragStart.call(listElem, e);
  11677. $(list.container).unbind("mousemove", trigger);
  11678. };
  11679. $(list.container).mousemove(trigger).mouseup(function() { $(list.container).unbind("mousemove", trigger); $(dragHandle).css("cursor", $(dragHandle).attr("data-cursor")); });
  11680. },
  11681. dragStart: function(e) {
  11682. if (list != null && list.draggedItem != null)
  11683. list.dropItem();
  11684. list = lists[$(this).attr("data-listidx")];
  11685. list.draggedItem = $(e.target).closest("[data-listidx] > " + opts.tagName)
  11686. //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
  11687. list.draggedItem.attr("data-origpos", $(this).attr("data-listidx") + "-" + $(list.container).children().index(list.draggedItem));
  11688. //calculate mouse offset relative to draggedItem
  11689. var mt = parseInt(list.draggedItem.css("marginTop"));
  11690. var ml = parseInt(list.draggedItem.css("marginLeft"));
  11691. list.offset = list.draggedItem.offset();
  11692. list.offset.top = e.pageY - list.offset.top + (isNaN(mt) ? 0 : mt) - 1;
  11693. list.offset.left = e.pageX - list.offset.left + (isNaN(ml) ? 0 : ml) - 1;
  11694. //calculate box the dragged item can't be dragged outside of
  11695. if (!opts.dragBetween) {
  11696. 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();
  11697. list.offsetLimit = $(list.container).offset();
  11698. list.offsetLimit.right = list.offsetLimit.left + $(list.container).outerWidth() - list.draggedItem.outerWidth();
  11699. list.offsetLimit.bottom = list.offsetLimit.top + containerHeight - list.draggedItem.outerHeight();
  11700. }
  11701. //create placeholder item
  11702. var h = list.draggedItem.height();
  11703. var w = list.draggedItem.width();
  11704. if (opts.tagName == "tr") {
  11705. list.draggedItem.children().each(function() { $(this).width($(this).width()); });
  11706. list.placeHolderItem = list.draggedItem.clone().attr("data-placeholder", true);
  11707. list.draggedItem.after(list.placeHolderItem);
  11708. //list.placeHolderItem.children().each(function() { $(this).css({ borderWidth:0, width: $(this).width() + 1, height: $(this).height() + 1 }).html("&nbsp;"); });
  11709. list.placeHolderItem.children().each(function() { $(this).html("&nbsp;"); });
  11710. } else {
  11711. list.draggedItem.after(opts.placeHolderTemplate);
  11712. list.placeHolderItem = list.draggedItem.next().css({ height: h, width: w }).attr("data-placeholder", true);
  11713. }
  11714. if (opts.tagName == "td") {
  11715. var listTable = list.draggedItem.closest("table").get(0);
  11716. $("<table id='" + listTable.id + "' style='border-width: 0px;' class='dragSortItem " + listTable.className + "'><tr></tr></table>").appendTo("body").children().append(list.draggedItem);
  11717. }
  11718. //style draggedItem while dragging
  11719. var orig = list.draggedItem.attr("style");
  11720. list.draggedItem.attr("data-origstyle", orig ? orig : "");
  11721. list.draggedItem.css({ position: "absolute", opacity: 0.8, "z-index": 999, height: h, width: w });
  11722. //auto-scroll setup
  11723. list.scroll = { moveX: 0, moveY: 0, maxX: $(document).width() - $(window).width(), maxY: $(document).height() - $(window).height() };
  11724. list.scroll.scrollY = window.setInterval(function() {
  11725. if (opts.scrollContainer != window) {
  11726. $(opts.scrollContainer).scrollTop($(opts.scrollContainer).scrollTop() + list.scroll.moveY);
  11727. return;
  11728. }
  11729. var t = $(opts.scrollContainer).scrollTop();
  11730. if (list.scroll.moveY > 0 && t < list.scroll.maxY || list.scroll.moveY < 0 && t > 0) {
  11731. $(opts.scrollContainer).scrollTop(t + list.scroll.moveY);
  11732. list.draggedItem.css("top", list.draggedItem.offset().top + list.scroll.moveY + 1);
  11733. }
  11734. }, 10);
  11735. list.scroll.scrollX = window.setInterval(function() {
  11736. if (opts.scrollContainer != window) {
  11737. $(opts.scrollContainer).scrollLeft($(opts.scrollContainer).scrollLeft() + list.scroll.moveX);
  11738. return;
  11739. }
  11740. var l = $(opts.scrollContainer).scrollLeft();
  11741. if (list.scroll.moveX > 0 && l < list.scroll.maxX || list.scroll.moveX < 0 && l > 0) {
  11742. $(opts.scrollContainer).scrollLeft(l + list.scroll.moveX);
  11743. list.draggedItem.css("left", list.draggedItem.offset().left + list.scroll.moveX + 1);
  11744. }
  11745. }, 10);
  11746. //misc
  11747. $(lists).each(function(i, l) { l.createDropTargets(); l.buildPositionTable(); });
  11748. list.setPos(e.pageX, e.pageY);
  11749. $(document).bind("mousemove", list.swapItems);
  11750. $(document).bind("mouseup", list.dropItem);
  11751. if (opts.scrollContainer != window)
  11752. $(window).bind("wheel", list.wheel);
  11753. },
  11754. //set position of draggedItem
  11755. setPos: function(x, y) {
  11756. //remove mouse offset so mouse cursor remains in same place on draggedItem instead of top left corner
  11757. var top = y - this.offset.top;
  11758. var left = x - this.offset.left;
  11759. //limit top, left to within box draggedItem can't be dragged outside of
  11760. if (!opts.dragBetween) {
  11761. top = Math.min(this.offsetLimit.bottom, Math.max(top, this.offsetLimit.top));
  11762. left = Math.min(this.offsetLimit.right, Math.max(left, this.offsetLimit.left));
  11763. }
  11764. //adjust top & left calculations to parent offset
  11765. var parent = this.draggedItem.offsetParent().not("body").offset(); //offsetParent returns body even when it's static, if not static offset is only factoring margin
  11766. if (parent != null) {
  11767. top -= parent.top;
  11768. left -= parent.left;
  11769. }
  11770. //set x or y auto-scroll amount
  11771. if (opts.scrollContainer == window) {
  11772. y -= $(window).scrollTop();
  11773. x -= $(window).scrollLeft();
  11774. y = Math.max(0, y - $(window).height() + 5) + Math.min(0, y - 5);
  11775. x = Math.max(0, x - $(window).width() + 5) + Math.min(0, x - 5);
  11776. } else {
  11777. var cont = $(opts.scrollContainer);
  11778. var offset = cont.offset();
  11779. y = Math.max(0, y - cont.height() - offset.top) + Math.min(0, y - offset.top);
  11780. x = Math.max(0, x - cont.width() - offset.left) + Math.min(0, x - offset.left);
  11781. }
  11782. list.scroll.moveX = x == 0 ? 0 : x * opts.scrollSpeed / Math.abs(x);
  11783. list.scroll.moveY = y == 0 ? 0 : y * opts.scrollSpeed / Math.abs(y);
  11784. //move draggedItem to new mouse cursor location
  11785. this.draggedItem.css({ top: top, left: left });
  11786. },
  11787. //if scroll container is a div allow mouse wheel to scroll div instead of window when mouse is hovering over
  11788. wheel: function(e) {
  11789. if (list && opts.scrollContainer != window) {
  11790. var cont = $(opts.scrollContainer);
  11791. var offset = cont.offset();
  11792. e = e.originalEvent;
  11793. if (e.clientX > offset.left && e.clientX < offset.left + cont.width() && e.clientY > offset.top && e.clientY < offset.top + cont.height()) {
  11794. var deltaY = (e.deltaMode == 0 ? 1 : 10) * e.deltaY;
  11795. cont.scrollTop(cont.scrollTop() + deltaY);
  11796. e.preventDefault();
  11797. }
  11798. }
  11799. },
  11800. //build a table recording all the positions of the moveable list items
  11801. buildPositionTable: function() {
  11802. var pos = [];
  11803. this.getItems().not([list.draggedItem[0], list.placeHolderItem[0]]).each(function(i) {
  11804. var loc = $(this).offset();
  11805. loc.right = loc.left + $(this).outerWidth();
  11806. loc.bottom = loc.top + $(this).outerHeight();
  11807. loc.elm = this;
  11808. pos[i] = loc;
  11809. });
  11810. this.pos = pos;
  11811. },
  11812. dropItem: function() {
  11813. if (list.draggedItem == null)
  11814. return;
  11815. //list.draggedItem.attr("style", "") doesn't work on IE8 and jQuery 1.5 or lower
  11816. //list.draggedItem.removeAttr("style") doesn't work on chrome and jQuery 1.6 (works jQuery 1.5 or lower)
  11817. var orig = list.draggedItem.attr("data-origstyle");
  11818. list.draggedItem.attr("style", orig);
  11819. if (orig == "")
  11820. list.draggedItem.removeAttr("style");
  11821. list.draggedItem.removeAttr("data-origstyle");
  11822. list.styleDragHandlers(true);
  11823. list.placeHolderItem.before(list.draggedItem);
  11824. list.placeHolderItem.remove();
  11825. $("[data-droptarget], .dragSortItem").remove();
  11826. window.clearInterval(list.scroll.scrollY);
  11827. window.clearInterval(list.scroll.scrollX);
  11828. //if position changed call dragEnd
  11829. if (list.draggedItem.attr("data-origpos") != $(lists).index(list) + "-" + $(list.container).children().index(list.draggedItem))
  11830. if (opts.dragEnd.apply(list.draggedItem) == false) { //if dragEnd returns false revert order
  11831. var pos = list.draggedItem.attr("data-origpos").split('-');
  11832. var nextItem = $(lists[pos[0]].container).children().not(list.draggedItem).eq(pos[1]);
  11833. if (nextItem.length > 0)
  11834. nextItem.before(list.draggedItem);
  11835. else if (pos[1] == 0) //was the only item in list
  11836. $(lists[pos[0]].container).prepend(list.draggedItem);
  11837. else //was the last item in list
  11838. $(lists[pos[0]].container).append(list.draggedItem);
  11839. }
  11840. list.draggedItem.removeAttr("data-origpos");
  11841. list.draggedItem = null;
  11842. $(document).unbind("mousemove", list.swapItems);
  11843. $(document).unbind("mouseup", list.dropItem);
  11844. if (opts.scrollContainer != window)
  11845. $(window).unbind("wheel", list.wheel);
  11846. return false;
  11847. },
  11848. //swap the draggedItem (represented visually by placeholder) with the list item the it has been dragged on top of
  11849. swapItems: function(e) {
  11850. if (list.draggedItem == null)
  11851. return false;
  11852. //move draggedItem to mouse location
  11853. list.setPos(e.pageX, e.pageY);
  11854. //retrieve list and item position mouse cursor is over
  11855. var ei = list.findPos(e.pageX, e.pageY);
  11856. var nlist = list;
  11857. for (var i = 0; ei == -1 && opts.dragBetween && i < lists.length; i++) {
  11858. ei = lists[i].findPos(e.pageX, e.pageY);
  11859. nlist = lists[i];
  11860. }
  11861. //if not over another moveable list item return
  11862. if (ei == -1)
  11863. return false;
  11864. //save fixed items locations
  11865. var children = function() { return $(nlist.container).children().not(nlist.draggedItem); };
  11866. var fixed = children().not(opts.itemSelector).each(function(i) { this.idx = children().index(this); });
  11867. //if moving draggedItem up or left place placeHolder before list item the dragged item is hovering over otherwise place it after
  11868. if (lastPos == null || lastPos.top > list.draggedItem.offset().top || lastPos.left > list.draggedItem.offset().left)
  11869. $(nlist.pos[ei].elm).before(list.placeHolderItem);
  11870. else
  11871. $(nlist.pos[ei].elm).after(list.placeHolderItem);
  11872. //restore fixed items location
  11873. fixed.each(function() {
  11874. var elm = children().eq(this.idx).get(0);
  11875. if (this != elm && children().index(this) < this.idx)
  11876. $(this).insertAfter(elm);
  11877. else if (this != elm)
  11878. $(this).insertBefore(elm);
  11879. });
  11880. //misc
  11881. $(lists).each(function(i, l) { l.createDropTargets(); l.buildPositionTable(); });
  11882. lastPos = list.draggedItem.offset();
  11883. return false;
  11884. },
  11885. //returns the index of the list item the mouse is over
  11886. findPos: function(x, y) {
  11887. for (var i = 0; i < this.pos.length; i++) {
  11888. if (this.pos[i].left < x && this.pos[i].right > x && this.pos[i].top < y && this.pos[i].bottom > y)
  11889. return i;
  11890. }
  11891. return -1;
  11892. },
  11893. //create drop targets which are placeholders at the end of other lists to allow dragging straight to the last position
  11894. createDropTargets: function() {
  11895. if (!opts.dragBetween)
  11896. return;
  11897. $(lists).each(function() {
  11898. var ph = $(this.container).find("[data-placeholder]");
  11899. var dt = $(this.container).find("[data-droptarget]");
  11900. if (ph.length > 0 && dt.length > 0)
  11901. dt.remove();
  11902. else if (ph.length == 0 && dt.length == 0) {
  11903. if (opts.tagName == "td")
  11904. $(opts.placeHolderTemplate).attr("data-droptarget", true).appendTo(this.container);
  11905. else
  11906. //list.placeHolderItem.clone().removeAttr("data-placeholder") crashes in IE7 and jquery 1.5.1 (doesn't in jquery 1.4.2 or IE8)
  11907. $(this.container).append(list.placeHolderItem.removeAttr("data-placeholder").clone().attr("data-droptarget", true));
  11908. list.placeHolderItem.attr("data-placeholder", true);
  11909. }
  11910. });
  11911. }
  11912. };
  11913. newList.init();
  11914. lists.push(newList);
  11915. });
  11916. return this;
  11917. };
  11918. $.fn.dragsort.defaults = {
  11919. tagName:"",
  11920. itemSelector: "",
  11921. dragSelector: "",
  11922. dragSelectorExclude: "input, textarea",
  11923. dragEnd: function() { },
  11924. dragBetween: false,
  11925. placeHolderTemplate: "",
  11926. scrollContainer: window,
  11927. scrollSpeed: 5
  11928. };
  11929. })(jQuery);
  11930. define("dragsort", function(){});
  11931. /**
  11932. * http://git.oschina.net/hbbcs/bootStrap-addTabs
  11933. * Created by joe on 2015-12-19.
  11934. * Modified by FastAdmin
  11935. */
  11936. (function ($) {
  11937. $.fn.addtabs = function (options) {
  11938. var obj = $(this);
  11939. options = $.extend({
  11940. content: '', //直接指定所有页面TABS内容
  11941. close: true, //是否可以关闭
  11942. monitor: 'body', //监视的区域
  11943. nav: '.nav-addtabs',
  11944. tab: '.tab-addtabs',
  11945. iframeUse: true, //使用iframe还是ajax
  11946. simple: false, //是否启用简洁模式,简洁模式下将不启用nav和tab
  11947. iframeHeight: $(window).height() - 50, //固定TAB中IFRAME高度,根据需要自己修改
  11948. iframeForceRefresh: false, //点击后强制加载对应的iframe
  11949. iframeForceRefreshTable: false, //点击后强制刷新对应的iframe中的table
  11950. callback: function () {
  11951. //关闭后回调函数
  11952. }
  11953. }, options || {});
  11954. var navobj = $(options.nav);
  11955. var tabobj = $(options.tab);
  11956. if (history.pushState) {
  11957. //浏览器前进后退事件
  11958. $(window).on("popstate", function (e) {
  11959. var state = e.originalEvent.state;
  11960. if (state) {
  11961. $("a[addtabs=" + state.id + "]", options.monitor).data("pushstate", true).trigger("click");
  11962. }
  11963. });
  11964. }
  11965. $(options.monitor).on('click', '[addtabs]', function (e) {
  11966. if ($(this).attr('url').indexOf("javascript:") !== 0) {
  11967. if ($(this).is("a")) {
  11968. e.preventDefault();
  11969. }
  11970. var id = $(this).attr('addtabs');
  11971. var title = $(this).attr('title') ? $(this).attr('title') : $.trim($(this).text());
  11972. var url = $(this).attr('url');
  11973. var content = options.content ? options.content : $(this).attr('content');
  11974. var ajax = $(this).attr('ajax') === '1' || $(this).attr('ajax') === 'true';
  11975. var state = ({
  11976. url: url, title: title, id: id, content: content, ajax: ajax
  11977. });
  11978. document.title = title;
  11979. if (history.pushState && !$(this).data("pushstate")) {
  11980. var pushurl = url.indexOf("ref=addtabs") === -1 ? (url + (url.indexOf("?") > -1 ? "&" : "?") + "ref=addtabs") : url;
  11981. try {
  11982. window.history.pushState(state, title, pushurl);
  11983. } catch (e) {
  11984. }
  11985. }
  11986. $(this).data("pushstate", null);
  11987. _add.call(this, {
  11988. id: id,
  11989. title: $(this).attr('title') ? $(this).attr('title') : $(this).html(),
  11990. content: content,
  11991. url: url,
  11992. ajax: ajax
  11993. });
  11994. }
  11995. });
  11996. navobj.on('click', '.close-tab', function () {
  11997. var id = $(this).prev("a").attr("aria-controls");
  11998. _close(id);
  11999. return false;
  12000. });
  12001. navobj.on('dblclick', 'li[role=presentation]', function () {
  12002. $(this).find(".close-tab").trigger("click");
  12003. });
  12004. navobj.on('click', 'li[role=presentation]', function () {
  12005. $("a[addtabs=" + $("a", this).attr("node-id") + "]").trigger("click");
  12006. });
  12007. $(window).resize(function () {
  12008. if (typeof options.nav === 'object') {
  12009. var siblingsWidth = 0;
  12010. navobj.siblings().each(function () {
  12011. siblingsWidth += $(this).outerWidth();
  12012. });
  12013. navobj.width(navobj.parent().width() - siblingsWidth);
  12014. } else {
  12015. $("#nav").width($("#header").find("> .navbar").width() - $(".sidebar-toggle").outerWidth() - $(".navbar-custom-menu").outerWidth() - 20);
  12016. }
  12017. _drop();
  12018. });
  12019. var _add = function (opts) {
  12020. var id, tabid, conid, url;
  12021. id = opts.id;
  12022. tabid = 'tab_' + opts.id;
  12023. conid = 'con_' + opts.id;
  12024. url = opts.url;
  12025. url += (opts.url.indexOf("?") > -1 ? "&addtabs=1" : "?addtabs=1");
  12026. if (options.simple) {
  12027. navobj.find("[role='presentation']").remove();
  12028. tabobj.find("[role='tabpanel']").remove();
  12029. }
  12030. var tabitem = $('#' + tabid, navobj);
  12031. var conitem = $('#' + conid, tabobj);
  12032. navobj.find("[role='presentation']").removeClass('active');
  12033. tabobj.find("[role='tabpanel']").removeClass('active');
  12034. //如果TAB不存在,创建一个新的TAB
  12035. if (tabitem.length === 0) {
  12036. //创建新TAB的title
  12037. 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>');
  12038. //是否允许关闭
  12039. if (options.close && $("li", navobj).length > 0) {
  12040. tabitem.append(' <i class="close-tab fa fa-remove"></i>');
  12041. }
  12042. if (conitem.length === 0) {
  12043. //创建新TAB的内容
  12044. conitem = $('<div role="tabpanel" class="tab-pane" id="' + conid + '"></div>');
  12045. //是否指定TAB内容
  12046. if (opts.content) {
  12047. conitem.append(opts.content);
  12048. } else if (options.iframeUse && !opts.ajax) {//没有内容,使用IFRAME打开链接
  12049. var height = options.iframeHeight;
  12050. 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>');
  12051. } else {
  12052. $.get(url, function (data) {
  12053. conitem.append(data);
  12054. });
  12055. }
  12056. tabobj.append(conitem);
  12057. }
  12058. if (!options.simple) {
  12059. //加入TABS
  12060. if ($('.tabdrop li', navobj).length > 0) {
  12061. $('.tabdrop ul', navobj).append(tabitem);
  12062. } else {
  12063. navobj.append(tabitem);
  12064. }
  12065. }
  12066. } else {
  12067. //强制刷新iframe
  12068. if (options.iframeForceRefresh) {
  12069. $("#" + conid + " iframe").attr('src', function (i, val) {
  12070. return val;
  12071. });
  12072. } else if (options.iframeForceRefreshTable) {
  12073. try {
  12074. //检测iframe中是否存在刷新按钮
  12075. if ($("#" + conid + " iframe").contents().find(".btn-refresh:not([data-force-refresh=false])").length > 0) {
  12076. $("#" + conid + " iframe")[0].contentWindow.$(".btn-refresh:not([data-force-refresh=false])").trigger("click");
  12077. }
  12078. } catch (e) {
  12079. }
  12080. }
  12081. }
  12082. sessionStorage.setItem("addtabs", $(this).prop('outerHTML'));
  12083. //激活TAB
  12084. tabitem.addClass('active');
  12085. conitem.addClass("active");
  12086. _drop();
  12087. };
  12088. var _close = function (id) {
  12089. var tabid = 'tab_' + id;
  12090. var conid = 'con_' + id;
  12091. var tabitem = $('#' + tabid, navobj);
  12092. var conitem = $('#' + conid, tabobj);
  12093. //如果关闭的是当前激活的TAB,激活他的前一个TAB
  12094. if (obj.find("li.active").not('.tabdrop').attr('id') === tabid) {
  12095. var prev = tabitem.prev().not(".tabdrop");
  12096. var next = tabitem.next().not(".tabdrop");
  12097. if (prev.length > 0) {
  12098. prev.find('a').trigger("click");
  12099. } else if (next.length > 0) {
  12100. next.find('a').trigger("click");
  12101. } else {
  12102. $(">li:not(.tabdrop):last > a", navobj).trigger('click');
  12103. }
  12104. }
  12105. //关闭TAB
  12106. tabitem.remove();
  12107. conitem.remove();
  12108. _drop();
  12109. options.callback();
  12110. };
  12111. var _drop = function () {
  12112. navobj.refreshAddtabs();
  12113. };
  12114. };
  12115. //刷新Addtabs
  12116. $.fn.refreshAddtabs = function () {
  12117. var navobj = $(this);
  12118. var dropdown = $(".tabdrop", navobj);
  12119. if (dropdown.length === 0) {
  12120. dropdown = $('<li class="dropdown pull-right hide tabdrop"><a class="dropdown-toggle" data-toggle="dropdown" href="javascript:;">' +
  12121. '<i class="glyphicon glyphicon-align-justify"></i>' +
  12122. ' <b class="caret"></b></a><ul class="dropdown-menu"></ul></li>');
  12123. dropdown.prependTo(navobj);
  12124. }
  12125. //检测是否有下拉样式
  12126. if (navobj.parent().is('.tabs-below')) {
  12127. dropdown.addClass('dropup');
  12128. }
  12129. var collection = 0;
  12130. var maxwidth = navobj.width() - 65;
  12131. var liwidth = 0;
  12132. //检查超过一行的标签页
  12133. var litabs = navobj.append(dropdown.find('li')).find('>li').not('.tabdrop');
  12134. var totalwidth = 0;
  12135. litabs.each(function () {
  12136. totalwidth += $(this).outerWidth(true);
  12137. });
  12138. if (navobj.width() < totalwidth) {
  12139. litabs.each(function () {
  12140. liwidth += $(this).outerWidth(true);
  12141. if (liwidth > maxwidth) {
  12142. dropdown.find('ul').append($(this));
  12143. collection++;
  12144. }
  12145. });
  12146. if (collection > 0) {
  12147. dropdown.removeClass('hide');
  12148. if (dropdown.find('.active').length === 1) {
  12149. dropdown.addClass('active');
  12150. } else {
  12151. dropdown.removeClass('active');
  12152. }
  12153. }
  12154. } else {
  12155. dropdown.addClass('hide');
  12156. }
  12157. };
  12158. })(jQuery);
  12159. define("addtabs", function(){});
  12160. /**
  12161. * @summary SelectPage
  12162. * @desc Simple and powerful selection plugin
  12163. * @file selectpage.js
  12164. * @version 2.20
  12165. * @author TerryZeng
  12166. * @contact https://terryz.github.io/
  12167. * @license MIT License
  12168. *
  12169. */
  12170. ;(function ($) {
  12171. "use strict";
  12172. /**
  12173. * Default options
  12174. */
  12175. var defaults = {
  12176. /**
  12177. * Data source
  12178. * @type {string|Object}
  12179. *
  12180. * string:server side request url address
  12181. * Object:JSON array,format:[{a:1,b:2,c:3},{...}]
  12182. */
  12183. data: undefined,
  12184. /**
  12185. * Language ('cn', 'en')
  12186. * @type string
  12187. * @default 'cn'
  12188. */
  12189. lang: 'cn',
  12190. /**
  12191. * Multiple select mode(tags)
  12192. * @type boolean
  12193. * @default false
  12194. */
  12195. multiple: false,
  12196. /**
  12197. * pagination or not
  12198. * @type boolean
  12199. * @default true
  12200. */
  12201. pagination: true,
  12202. /**
  12203. * Show up menu button
  12204. * @type boolean
  12205. * @default true
  12206. */
  12207. dropButton: true,
  12208. /**
  12209. * Result list visible size in pagination bar close
  12210. * @type number
  12211. * @default 10
  12212. */
  12213. listSize: 10,
  12214. /**
  12215. * Show control bar in multiple select mode
  12216. * @type boolean
  12217. * @default true
  12218. */
  12219. multipleControlbar: true,
  12220. /**
  12221. * Max selected item limited in multiple select mode
  12222. * @type number
  12223. * @default 0(unlimited)
  12224. */
  12225. maxSelectLimit: 0,
  12226. /**
  12227. * Select result item to close list, work on multiple select mode
  12228. * @type boolean
  12229. * @default false
  12230. */
  12231. selectToCloseList: false,
  12232. /**
  12233. * Init selected item key, the result will match to option.keyField option
  12234. * @type string
  12235. */
  12236. initRecord: undefined,
  12237. /**
  12238. * The table parameter in server side mode
  12239. * @type string
  12240. */
  12241. dbTable: 'tbl',
  12242. /**
  12243. * The value field, the value will fill to hidden element
  12244. * @type string
  12245. * @default 'id'
  12246. */
  12247. keyField: 'id',
  12248. /**
  12249. * The show text field, the text will show to input element or tags(multiple mode)
  12250. * @type string
  12251. * @default 'name'
  12252. */
  12253. showField: 'name',
  12254. /**
  12255. * Actually used to search field
  12256. * @type string
  12257. */
  12258. searchField: undefined,
  12259. /**
  12260. * Search type ('AND' or 'OR')
  12261. * @type string
  12262. * @default 'AND'
  12263. */
  12264. andOr: 'OR',
  12265. /**
  12266. * Used to separate search content
  12267. * @see SelectPage.prototype.suggest()
  12268. */
  12269. separator: ',',
  12270. /**
  12271. * Result sort type
  12272. * @type array|boolean - if not set, will default used showField field
  12273. * @example
  12274. * orderBy : ['id desc']
  12275. */
  12276. orderBy: undefined,
  12277. /**
  12278. * Page size
  12279. * @type number
  12280. * @default 10
  12281. */
  12282. pageSize: 10,
  12283. /**
  12284. * Server side request parameters
  12285. * @type function
  12286. * @return object
  12287. * @example params : function(){return {'name':'aa','sex':1};}
  12288. */
  12289. params: undefined,
  12290. /**
  12291. * Custom result list item show text
  12292. * @type function
  12293. * @param data {object} row data
  12294. * @return string
  12295. */
  12296. formatItem: undefined,
  12297. /**
  12298. * Have some highlight item and lost focus, auto select the highlight item
  12299. * @type boolean
  12300. * @default false
  12301. */
  12302. autoFillResult: false,
  12303. /**
  12304. * Auto select first item in show up result list or search result
  12305. * depend on `autoFillResult` option set to true
  12306. * @type boolean
  12307. * @default false
  12308. */
  12309. autoSelectFirst: false,
  12310. /**
  12311. * Whether clear input element text when enter some keywords to search and no result return
  12312. * @type boolean
  12313. * @default true
  12314. */
  12315. noResultClean: true,
  12316. /**
  12317. * Select only mode
  12318. * @type boolean
  12319. */
  12320. selectOnly: false,
  12321. /**
  12322. * Input to search delay time, work on ajax data source
  12323. * @type number
  12324. * @default 0.5
  12325. */
  12326. inputDelay: 0.5,
  12327. /**
  12328. * -----------------------------------------Callback--------------------------------------------
  12329. */
  12330. /**
  12331. * Result list item selected callback
  12332. * @type function
  12333. * @param object - selected item json data
  12334. * @param self - plugin object
  12335. */
  12336. eSelect: undefined,
  12337. /**
  12338. * Before result list show up callback, you can do anything prepared
  12339. * @param self - plugin object
  12340. */
  12341. eOpen: undefined,
  12342. /**
  12343. * Server side return data convert callback
  12344. * @type function
  12345. * @param data {object} server side return data
  12346. * @param self {object} plugin object
  12347. * @return {object} return data format:
  12348. * @example
  12349. * {
  12350. * list : [{name:'aa',sex:1},{name:'bb',sex:1}...],
  12351. * totalRow : 100
  12352. * }
  12353. */
  12354. eAjaxSuccess: undefined,
  12355. /**
  12356. * Close selected item tag callback (multiple mode)
  12357. * @type function
  12358. * @param removeCount {number} remove item count
  12359. * @param self {object} plugin object
  12360. */
  12361. eTagRemove: undefined,
  12362. /**
  12363. * Clear selected item callback(single select mode)
  12364. * @type function
  12365. * @param self {object} plugin object
  12366. */
  12367. eClear: undefined
  12368. };
  12369. /**
  12370. * SelectPage class definition
  12371. * @constructor
  12372. * @param {Object} input - input element
  12373. * @param {Object} option
  12374. */
  12375. var SelectPage = function (input, option) {
  12376. //特殊字段处理
  12377. $.each({data: 'source', keyField: 'primaryKey', showField: 'field', pageSize: 'perPage'}, function (i, j) {
  12378. if (typeof option[j] !== 'undefined') {
  12379. option[i] = option[j];
  12380. delete option[j];
  12381. }
  12382. });
  12383. this.setOption(option);
  12384. this.setLanguage();
  12385. this.setCssClass();
  12386. this.setProp();
  12387. this.setElem(input);
  12388. this.setButtonAttrDefault();
  12389. this.setInitRecord();
  12390. this.eDropdownButton();
  12391. this.eInput();
  12392. this.eWhole();
  12393. };
  12394. /**
  12395. * Plugin version number
  12396. */
  12397. SelectPage.version = '2.19';
  12398. /**
  12399. * Plugin object cache key
  12400. */
  12401. SelectPage.dataKey = 'selectPageObject';
  12402. /**
  12403. * Options set
  12404. * @param {Object} option
  12405. */
  12406. SelectPage.prototype.setOption = function (option) {
  12407. //use showField to default
  12408. option.searchField = option.searchField || option.showField;
  12409. option.andOr = option.andOr.toUpperCase();
  12410. if (option.andOr !== 'AND' && option.andOr !== 'OR') option.andOr = 'AND';
  12411. //support multiple field set
  12412. var arr = ['searchField'];
  12413. for (var i = 0; i < arr.length; i++) {
  12414. option[arr[i]] = this.strToArray(option[arr[i]]);
  12415. }
  12416. //set default order field
  12417. option.orderBy = option.orderBy || option.showField;
  12418. //set multiple order field
  12419. //example: [ ['id', 'ASC'], ['name', 'DESC'] ]
  12420. if (option.orderBy !== false) option.orderBy = this.setOrderbyOption(option.orderBy, option.showField);
  12421. //close auto fill result and auto select first in multiple mode and select item not close list
  12422. if (option.multiple && !option.selectToCloseList) {
  12423. option.autoFillResult = false;
  12424. option.autoSelectFirst = false;
  12425. }
  12426. //show all item when pagination bar close, limited 200
  12427. if (!option.pagination) option.pageSize = 200;
  12428. if ($.type(option.listSize) !== 'number' || option.listSize < 0) option.listSize = 10;
  12429. if (typeof option.formatItem === 'string') {
  12430. var _formatItem = option.formatItem;
  12431. option.formatItem = function (row) {
  12432. if (typeof Template === 'function' && _formatItem.match(/\#([a-zA-Z0-9_\-]+)$/)) {
  12433. return Template(_formatItem.substring(1), row);
  12434. } else {
  12435. return _formatItem.replace(/\{(.*?)\}/gi, function (matched) {
  12436. matched = matched.substring(1, matched.length - 1);
  12437. return typeof row[matched] !== 'undefined' ? row[matched] : '';
  12438. });
  12439. }
  12440. };
  12441. }
  12442. this.option = option;
  12443. };
  12444. /**
  12445. * String convert to array
  12446. * @param str {string}
  12447. * @return {Array}
  12448. */
  12449. SelectPage.prototype.strToArray = function (str) {
  12450. return str ? str.replace(/[\s ]+/g, '').split(',') : '';
  12451. };
  12452. /**
  12453. * Set order field
  12454. * @param {Array} arg_order
  12455. * @param {string} arg_field - default sort field
  12456. * @return {Array}
  12457. */
  12458. SelectPage.prototype.setOrderbyOption = function (arg_order, arg_field) {
  12459. var arr = [], orders = [];
  12460. if (typeof arg_order === 'object') {
  12461. for (var i = 0; i < arg_order.length; i++) {
  12462. orders = $.trim(arg_order[i]).split(' ');
  12463. if (orders.length)
  12464. arr.push((orders.length === 2) ? orders.concat() : [orders[0], 'ASC']);
  12465. }
  12466. } else {
  12467. orders = $.trim(arg_order).split(' ');
  12468. arr[0] = (orders.length === 2) ? orders.concat() : (orders[0].toUpperCase().match(/^(ASC|DESC)$/i)) ? [arg_field, orders[0].toUpperCase()] : [orders[0], 'ASC'];
  12469. }
  12470. return arr;
  12471. };
  12472. /**
  12473. * i18n
  12474. */
  12475. SelectPage.prototype.setLanguage = function () {
  12476. var message, p = this.option;
  12477. switch (p.lang) {
  12478. // English
  12479. case 'en':
  12480. message = {
  12481. add_btn: 'Add button',
  12482. add_title: 'add a box',
  12483. del_btn: 'Del button',
  12484. del_title: 'delete a box',
  12485. next: 'Next',
  12486. next_title: 'Next' + p.pageSize + ' (Right key)',
  12487. prev: 'Prev',
  12488. prev_title: 'Prev' + p.pageSize + ' (Left key)',
  12489. first_title: 'First (Shift + Left key)',
  12490. last_title: 'Last (Shift + Right key)',
  12491. get_all_btn: 'Get All (Down key)',
  12492. get_all_alt: '(button)',
  12493. close_btn: 'Close (Tab key)',
  12494. close_alt: '(button)',
  12495. loading: 'loading...',
  12496. loading_alt: '(loading)',
  12497. page_info: 'page_num of page_count',
  12498. select_ng: 'Attention : Please choose from among the list.',
  12499. select_ok: 'OK : Correctly selected.',
  12500. not_found: 'not found',
  12501. ajax_error: 'An error occurred while loading data.',
  12502. clear: 'Clear content',
  12503. select_all: 'Select current page',
  12504. unselect_all: 'Clear current page',
  12505. clear_all: 'Clear all selected',
  12506. max_selected: 'You can only select up to max_selected_limit items'
  12507. };
  12508. break;
  12509. // 中文
  12510. case 'cn':
  12511. default:
  12512. message = {
  12513. add_btn: '添加按钮',
  12514. add_title: '添加区域',
  12515. del_btn: '删除按钮',
  12516. del_title: '删除区域',
  12517. next: '下一页',
  12518. next_title: '下' + p.pageSize + ' (→)',
  12519. prev: '上一页',
  12520. prev_title: '上' + p.pageSize + ' (←)',
  12521. first_title: '首页 (Shift + ←)',
  12522. last_title: '尾页 (Shift + →)',
  12523. get_all_btn: '获得全部 (↓)',
  12524. get_all_alt: '(按钮)',
  12525. close_btn: '关闭 (Tab键)',
  12526. close_alt: '(按钮)',
  12527. loading: '读取中...',
  12528. loading_alt: '(读取中)',
  12529. page_info: '第 page_num 页(共page_count页)',
  12530. select_ng: '请注意:请从列表中选择.',
  12531. select_ok: 'OK : 已经选择.',
  12532. not_found: '无查询结果',
  12533. ajax_error: '加载数据时发生了错误!',
  12534. clear: '清除内容',
  12535. select_all: '选择当前页项目',
  12536. unselect_all: '取消选择当前页项目',
  12537. clear_all: '清除全部已选择项目',
  12538. max_selected: '最多只能选择 max_selected_limit 个项目'
  12539. };
  12540. break;
  12541. }
  12542. this.message = message;
  12543. };
  12544. /**
  12545. * Css classname defined
  12546. */
  12547. SelectPage.prototype.setCssClass = function () {
  12548. var css_class = {
  12549. container: 'sp_container',
  12550. container_open: 'sp_container_open',
  12551. re_area: 'sp_result_area',
  12552. result_open: 'sp_result_area_open',
  12553. control_box: 'sp_control_box',
  12554. //multiple select mode
  12555. element_box: 'sp_element_box',
  12556. navi: 'sp_navi',
  12557. //result list
  12558. results: 'sp_results',
  12559. re_off: 'sp_results_off',
  12560. select: 'sp_over',
  12561. select_ok: 'sp_select_ok',
  12562. select_ng: 'sp_select_ng',
  12563. selected: 'sp_selected',
  12564. input_off: 'sp_input_off',
  12565. message_box: 'sp_message_box',
  12566. disabled: 'sp_disabled',
  12567. button: 'sp_button',
  12568. caret_open: 'sp_caret_open',
  12569. btn_on: 'sp_btn_on',
  12570. btn_out: 'sp_btn_out',
  12571. input: 'sp_input',
  12572. clear_btn: 'sp_clear_btn',
  12573. align_right: 'sp_align_right'
  12574. };
  12575. this.css_class = css_class;
  12576. };
  12577. /**
  12578. * Plugin inner properties
  12579. */
  12580. SelectPage.prototype.setProp = function () {
  12581. this.prop = {
  12582. //input disabled status
  12583. disabled: false,
  12584. current_page: 1,
  12585. //total page
  12586. max_page: 1,
  12587. //ajax data loading status
  12588. is_loading: false,
  12589. xhr: false,
  12590. key_paging: false,
  12591. key_select: false,
  12592. //last selected item value
  12593. prev_value: '',
  12594. //last selected item text
  12595. selected_text: '',
  12596. last_input_time: undefined,
  12597. init_set: false
  12598. };
  12599. this.template = {
  12600. tag: {
  12601. content: '<li class="selected_tag" itemvalue="#item_value#">#item_text#<span class="tag_close"><i class="spfont sp-close"></i></span></li>',
  12602. textKey: '#item_text#',
  12603. valueKey: '#item_value#'
  12604. },
  12605. page: {
  12606. current: 'page_num',
  12607. total: 'page_count'
  12608. },
  12609. msg: {
  12610. maxSelectLimit: 'max_selected_limit'
  12611. }
  12612. };
  12613. };
  12614. /**
  12615. * Get the actual width/height of invisible DOM elements with jQuery.
  12616. * Source code come from dreamerslab/jquery.actual
  12617. * @param element
  12618. * @param method
  12619. * @returns {*}
  12620. */
  12621. SelectPage.prototype.elementRealSize = function (element, method) {
  12622. var defaults = {
  12623. absolute: false,
  12624. clone: false,
  12625. includeMargin: false,
  12626. display: 'block'
  12627. };
  12628. var configs = defaults, $target = element.eq(0), fix, restore, tmp = [], style = '', $hidden;
  12629. fix = function () {
  12630. // get all hidden parents
  12631. $hidden = $target.parents().addBack().filter(':hidden');
  12632. style += 'visibility: hidden !important; display: ' + configs.display + ' !important; ';
  12633. if (configs.absolute === true) style += 'position: absolute !important;';
  12634. // save the origin style props
  12635. // set the hidden el css to be got the actual value later
  12636. $hidden.each(function () {
  12637. // Save original style. If no style was set, attr() returns undefined
  12638. var $this = $(this), thisStyle = $this.attr('style');
  12639. tmp.push(thisStyle);
  12640. // Retain as much of the original style as possible, if there is one
  12641. $this.attr('style', thisStyle ? thisStyle + ';' + style : style);
  12642. });
  12643. };
  12644. restore = function () {
  12645. // restore origin style values
  12646. $hidden.each(function (i) {
  12647. var $this = $(this), _tmp = tmp[i];
  12648. if (_tmp === undefined) $this.removeAttr('style');
  12649. else $this.attr('style', _tmp);
  12650. });
  12651. };
  12652. fix();
  12653. // get the actual value with user specific methed
  12654. // it can be 'width', 'height', 'outerWidth', 'innerWidth'... etc
  12655. // configs.includeMargin only works for 'outerWidth' and 'outerHeight'
  12656. var actual = /(outer)/.test(method) ?
  12657. $target[method](configs.includeMargin) :
  12658. $target[method]();
  12659. restore();
  12660. // IMPORTANT, this plugin only return the value of the first element
  12661. return actual;
  12662. };
  12663. /**
  12664. * Dom building
  12665. * @param {Object} combo_input - original input element
  12666. */
  12667. SelectPage.prototype.setElem = function (combo_input) {
  12668. // 1. build Dom object
  12669. var elem = {}, p = this.option, css = this.css_class, msg = this.message, input = $(combo_input);
  12670. var cssWidth = input.css("width");
  12671. var orgWidth = input.outerWidth();
  12672. if (cssWidth.indexOf("%") > -1 || input.parent().length > 0 && input.parent().width() == orgWidth) {
  12673. orgWidth = "100%";
  12674. } else {
  12675. // fix input width in hidden situation
  12676. if (orgWidth <= 0) orgWidth = this.elementRealSize(input, 'outerWidth');
  12677. if (orgWidth < 150) orgWidth = 150;
  12678. }
  12679. elem.combo_input = input.attr({'autocomplete': 'off'}).addClass(css.input).wrap('<div>');
  12680. if (p.selectOnly) elem.combo_input.prop('readonly', true);
  12681. elem.container = elem.combo_input.parent().addClass(css.container);
  12682. if (elem.combo_input.prop('disabled')) {
  12683. if (p.multiple) elem.container.addClass(css.disabled);
  12684. else elem.combo_input.addClass(css.input_off);
  12685. }
  12686. // set outer box width
  12687. elem.container.width(orgWidth);
  12688. elem.button = $('<div>').addClass(css.button);
  12689. //drop down button
  12690. elem.dropdown = $('<span class="sp_caret"></span>');
  12691. //clear button 'X' in single mode
  12692. elem.clear_btn = $('<div>').html($('<i>').addClass('spfont sp-close')).addClass(css.clear_btn).attr('title', msg.clear);
  12693. if (!p.dropButton) elem.clear_btn.addClass(css.align_right);
  12694. //main box in multiple mode
  12695. elem.element_box = $('<ul>').addClass(css.element_box);
  12696. if (p.multiple && p.multipleControlbar)
  12697. elem.control = $('<div>').addClass(css.control_box);
  12698. //result list box
  12699. elem.result_area = $('<div>').addClass(css.re_area);
  12700. //pagination bar
  12701. if (p.pagination) elem.navi = $('<div>').addClass('sp_pagination').append('<ul>');
  12702. elem.results = $('<ul>').addClass(css.results);
  12703. var namePrefix = '_text',
  12704. input_id = elem.combo_input.attr('id') || elem.combo_input.attr('name'),
  12705. input_name = elem.combo_input.attr('name') || 'selectPage',
  12706. hidden_name = input_name,
  12707. hidden_id = input_id;
  12708. //switch the id and name attributes of input/hidden element
  12709. elem.hidden = $('<input type="hidden" class="sp_hidden" />').attr({
  12710. name: hidden_name,
  12711. id: hidden_id
  12712. }).val('');
  12713. elem.combo_input.attr({
  12714. name: typeof input.data('name') !== 'undefined' ? input.data('name') : input_name + namePrefix,
  12715. id: input_id + namePrefix
  12716. });
  12717. elem.hidden.attr("data-rule", elem.combo_input.data("rule") || '');
  12718. elem.combo_input.attr("novalidate", "novalidate");
  12719. // 2. DOM element put
  12720. elem.container.append(elem.hidden);
  12721. if (p.dropButton) {
  12722. elem.container.append(elem.button)
  12723. elem.button.append(elem.dropdown);
  12724. }
  12725. $(document.body).append(elem.result_area);
  12726. elem.result_area.append(elem.results);
  12727. if (p.pagination) elem.result_area.append(elem.navi);
  12728. //Multiple select mode
  12729. if (p.multiple) {
  12730. if (p.multipleControlbar) {
  12731. elem.control.append('<button type="button" class="btn btn-default sp_clear_all" ><i class="spfont sp-clear"></i></button>');
  12732. elem.control.append('<button type="button" class="btn btn-default sp_unselect_all" ><i class="spfont sp-unselect-all"></i></button>');
  12733. elem.control.append('<button type="button" class="btn btn-default sp_select_all" ><i class="spfont sp-select-all"></i></button>');
  12734. elem.control_text = $('<p>');
  12735. elem.control.append(elem.control_text);
  12736. elem.result_area.prepend(elem.control);
  12737. }
  12738. elem.container.addClass('sp_container_combo');
  12739. elem.combo_input.addClass('sp_combo_input').before(elem.element_box);
  12740. var li = $('<li>').addClass('input_box');
  12741. li.append(elem.combo_input);
  12742. elem.element_box.append(li);
  12743. if (elem.combo_input.attr('placeholder')) elem.combo_input.attr('placeholder_bak', elem.combo_input.attr('placeholder'));
  12744. }
  12745. this.elem = elem;
  12746. };
  12747. /**
  12748. * Drop down button set to default
  12749. */
  12750. SelectPage.prototype.setButtonAttrDefault = function () {
  12751. /*
  12752. if (this.option.selectOnly) {
  12753. if ($(this.elem.combo_input).val() !== '') {
  12754. if ($(this.elem.hidden).val() !== '') {
  12755. //选择条件
  12756. $(this.elem.combo_input).attr('title', this.message.select_ok).removeClass(this.css_class.select_ng).addClass(this.css_class.select_ok);
  12757. } else {
  12758. //输入方式
  12759. $(this.elem.combo_input).attr('title', this.message.select_ng).removeClass(this.css_class.select_ok).addClass(this.css_class.select_ng);
  12760. }
  12761. } else {
  12762. $(this.elem.hidden).val('');
  12763. $(this.elem.combo_input).removeAttr('title').removeClass(this.css_class.select_ng);
  12764. }
  12765. }
  12766. */
  12767. //this.elem.button.attr('title', this.message.get_all_btn);
  12768. if (this.option.dropButton)
  12769. this.elem.button.attr('title', this.message.close_btn);
  12770. };
  12771. /**
  12772. * Set item need selected after init
  12773. * set selected item ways:
  12774. * <input value="key">
  12775. * <input data-init="key">
  12776. */
  12777. SelectPage.prototype.setInitRecord = function (refresh) {
  12778. var self = this, p = self.option, el = self.elem, key = '';
  12779. if ($.type(el.combo_input.data('init')) != 'undefined')
  12780. p.initRecord = String(el.combo_input.data('init'));
  12781. //data-init and value attribute can be init plugin selected item
  12782. //but, if set data-init and value attribute in the same time, plugin will choose data-init attribute first
  12783. if (!refresh && !p.initRecord && el.combo_input.val())
  12784. p.initRecord = el.combo_input.val();
  12785. el.combo_input.val('');
  12786. if (!refresh) el.hidden.val(p.initRecord);
  12787. key = refresh && el.hidden.val() ? el.hidden.val() : p.initRecord;
  12788. if (key) {
  12789. if (typeof p.data === 'object') {
  12790. var data = new Array();
  12791. var keyarr = key.split(',');
  12792. $.each(keyarr, function (index, row) {
  12793. for (var i = 0; i < p.data.length; i++) {
  12794. if (p.data[i][p.keyField] == row) {
  12795. data.push(p.data[i]);
  12796. break;
  12797. }
  12798. }
  12799. });
  12800. if (!p.multiple && data.length > 1) data = [data[0]];
  12801. self.afterInit(self, data);
  12802. } else {//ajax data source mode to init selected item
  12803. var _paramsFunc = p.params, _params = {}, searchKey = p.searchField;
  12804. var _orgParams = {
  12805. searchTable: p.dbTable,
  12806. searchKey: p.keyField,
  12807. searchValue: key,
  12808. orderBy: p.orderBy,
  12809. showField: p.showField,
  12810. keyField: p.keyField,
  12811. keyValue: key,
  12812. searchField: p.searchField
  12813. };
  12814. if (_paramsFunc) {
  12815. var result = $.isFunction(_paramsFunc) ? _paramsFunc(self) : _paramsFunc;
  12816. if (result && $.isPlainObject(result)) {
  12817. _params = $.extend({}, _orgParams, result);
  12818. } else {
  12819. _params = _orgParams;
  12820. }
  12821. } else {
  12822. _params = _orgParams;
  12823. }
  12824. $.ajax({
  12825. dataType: 'json',
  12826. type: 'POST',
  12827. url: p.data,
  12828. data: _params,
  12829. success: function (json) {
  12830. var d = null;
  12831. if (p.eAjaxSuccess && $.isFunction(p.eAjaxSuccess))
  12832. d = p.eAjaxSuccess(json);
  12833. self.afterInit(self, d.list);
  12834. },
  12835. error: function (jqXHR, textStatus, errorThrown) {
  12836. self.ajaxErrorNotify(self, errorThrown);
  12837. }
  12838. });
  12839. }
  12840. }
  12841. };
  12842. /**
  12843. * Selected item set to plugin
  12844. * @param {Object} self
  12845. * @param {Object} data - selected item data
  12846. */
  12847. SelectPage.prototype.afterInit = function (self, data) {
  12848. if (!data || ($.isArray(data) && data.length === 0)) return;
  12849. if (!$.isArray(data)) data = [data];
  12850. var p = self.option, css = self.css_class;
  12851. self.data = data;
  12852. if (p.multiple) {
  12853. self.prop.init_set = true;
  12854. self.clearAll(self);
  12855. $.each(data, function (i, row) {
  12856. var value = row[p.keyField];
  12857. var text = row[p.showField];
  12858. var item = {text: text, value: value};
  12859. if (!self.isAlreadySelected(self, item)) self.addNewTag(self, row, item);
  12860. });
  12861. self.tagValuesSet(self);
  12862. self.inputResize(self);
  12863. self.elem.hidden.blur();
  12864. self.prop.init_set = false;
  12865. } else {
  12866. var row = data[0];
  12867. var value = row[p.keyField];
  12868. var text = row[p.showField];
  12869. self.elem.combo_input.val(text);
  12870. self.elem.hidden.val(value);
  12871. self.prop.prev_value = text;
  12872. self.prop.selected_text = text;
  12873. if (p.selectOnly) {
  12874. self.elem.combo_input.attr('title', self.message.select_ok).removeClass(css.select_ng).addClass(css.select_ok);
  12875. }
  12876. self.putClearButton();
  12877. }
  12878. };
  12879. /**
  12880. * Drop down button event bind
  12881. */
  12882. SelectPage.prototype.eDropdownButton = function () {
  12883. var self = this;
  12884. if (self.option.dropButton) {
  12885. self.elem.button.mouseup(function (ev) {
  12886. ev.stopPropagation();
  12887. if (self.elem.result_area.is(':hidden') && !self.elem.combo_input.prop('disabled')) {
  12888. self.elem.combo_input.focus();
  12889. } else self.hideResults(self);
  12890. });
  12891. }
  12892. };
  12893. /**
  12894. * Events bind
  12895. */
  12896. SelectPage.prototype.eInput = function () {
  12897. var self = this, p = self.option, el = self.elem, msg = self.message;
  12898. var showList = function () {
  12899. self.prop.page_move = false;
  12900. self.suggest(self);
  12901. self.setCssFocusedInput(self);
  12902. };
  12903. el.combo_input.keyup(function (e) {
  12904. self.processKey(self, e);
  12905. }).keydown(function (e) {
  12906. self.processControl(self, e);
  12907. }).focus(function (e) {
  12908. //When focus on input, show the result list
  12909. if (el.result_area.is(':hidden')) {
  12910. e.stopPropagation();
  12911. self.prop.first_show = true;
  12912. showList();
  12913. }
  12914. });
  12915. el.container.on('click.SelectPage', 'div.' + self.css_class.clear_btn, function (e) {
  12916. e.stopPropagation();
  12917. if (!self.disabled(self)) {
  12918. self.clearAll(self, true);
  12919. self.elem.hidden.change();
  12920. if (p.eClear && $.isFunction(p.eClear)) p.eClear(self);
  12921. }
  12922. });
  12923. el.result_area.on('mousedown.SelectPage', function (e) {
  12924. e.stopPropagation();
  12925. });
  12926. if (p.multiple) {
  12927. if (p.multipleControlbar) {
  12928. //Select all item of current page
  12929. el.control.find('.sp_select_all').on('click.SelectPage', function (e) {
  12930. self.selectAllLine(self);
  12931. }).hover(function () {
  12932. el.control_text.html(msg.select_all);
  12933. }, function () {
  12934. el.control_text.html('');
  12935. });
  12936. //Cancel select all item of current page
  12937. el.control.find('.sp_unselect_all').on('click.SelectPage', function (e) {
  12938. self.unSelectAllLine(self);
  12939. }).hover(function () {
  12940. el.control_text.html(msg.unselect_all);
  12941. }, function () {
  12942. el.control_text.html('');
  12943. });
  12944. //Clear all selected item
  12945. el.control.find('.sp_clear_all').on('click.SelectPage', function (e) {
  12946. self.clearAll(self, true);
  12947. }).hover(function () {
  12948. el.control_text.html(msg.clear_all);
  12949. }, function () {
  12950. el.control_text.html('');
  12951. });
  12952. }
  12953. el.element_box.on('click.SelectPage', function (e) {
  12954. var srcEl = e.target || e.srcElement;
  12955. if ($(srcEl).is('ul')) el.combo_input.focus();
  12956. });
  12957. //Tag close
  12958. el.element_box.on('click.SelectPage', 'span.tag_close', function () {
  12959. var li = $(this).closest('li'), data = li.data('dataObj');
  12960. self.removeTag(self, li);
  12961. showList();
  12962. if (p.eTagRemove && $.isFunction(p.eTagRemove)) p.eTagRemove([data]);
  12963. });
  12964. self.inputResize(self);
  12965. }
  12966. };
  12967. /**
  12968. * Out of plugin area click event handler
  12969. */
  12970. SelectPage.prototype.eWhole = function () {
  12971. var self = this, css = self.css_class;
  12972. var cleanContent = function (obj) {
  12973. obj.elem.combo_input.val('');
  12974. if (!obj.option.multiple) obj.elem.hidden.val('');
  12975. obj.prop.selected_text = '';
  12976. };
  12977. //Out of plugin area
  12978. $(document.body).off('mousedown.selectPage').on('mousedown.selectPage', function (e) {
  12979. var ele = e.target || e.srcElement;
  12980. var sp = $(ele).closest('div.' + css.container);
  12981. //Open status result list
  12982. $('div.' + css.container + '.' + css.container_open).each(function () {
  12983. if (this == sp[0]) return;
  12984. var $this = $(this), d = $this.find('input.' + css.input).data(SelectPage.dataKey);
  12985. if (!d.elem.combo_input.val() && d.elem.hidden.val() && !d.option.multiple) {
  12986. d.prop.current_page = 1;//reset page to 1
  12987. cleanContent(d);
  12988. d.hideResults(d);
  12989. return true;
  12990. }
  12991. if (d.elem.results.find('li').not('.' + css.message_box).length) {
  12992. if (d.option.autoFillResult) {
  12993. //have selected item, then hide result list
  12994. if (d.elem.hidden.val()) d.hideResults(d);
  12995. else if (d.elem.results.find('li.sp_over').length) {
  12996. //no one selected and have highlight item, select the highlight item
  12997. d.selectCurrentLine(d, true);
  12998. } else if (d.option.autoSelectFirst) {
  12999. //no one selected, no one highlight, select the first item
  13000. d.nextLine(d);
  13001. d.selectCurrentLine(d, true);
  13002. } else d.hideResults(d);
  13003. } else d.hideResults(d);
  13004. } else {
  13005. //when no one item match, clear search keywords
  13006. if (d.option.noResultClean) cleanContent(d);
  13007. else {
  13008. if (!d.option.multiple) d.elem.hidden.val('');
  13009. }
  13010. d.hideResults(d);
  13011. }
  13012. });
  13013. });
  13014. };
  13015. /**
  13016. * Result list event bind
  13017. */
  13018. SelectPage.prototype.eResultList = function () {
  13019. var self = this, css = this.css_class;
  13020. self.elem.results.children('li').hover(function () {
  13021. if (self.prop.key_select) {
  13022. self.prop.key_select = false;
  13023. return;
  13024. }
  13025. if (!$(this).hasClass(css.selected) && !$(this).hasClass(css.message_box)) {
  13026. $(this).addClass(css.select);
  13027. self.setCssFocusedResults(self);
  13028. }
  13029. }, function () {
  13030. $(this).removeClass(css.select);
  13031. }).click(function (e) {
  13032. if (self.prop.key_select) {
  13033. self.prop.key_select = false;
  13034. return;
  13035. }
  13036. e.preventDefault();
  13037. e.stopPropagation();
  13038. if (!$(this).hasClass(css.selected)) self.selectCurrentLine(self, false);
  13039. });
  13040. };
  13041. /**
  13042. * Reposition result list when list beyond the visible area
  13043. */
  13044. SelectPage.prototype.eScroll = function () {
  13045. var self = this, css = this.css_class;
  13046. $(window).on('scroll.SelectPage', function (e) {
  13047. $('div.' + css.container + '.' + css.container_open).each(function () {
  13048. var $this = $(this), d = $this.find('input.' + css.input).data(SelectPage.dataKey),
  13049. offset = d.elem.result_area.offset(),
  13050. screenScrollTop = $(window).scrollTop(),
  13051. docHeight = $(document).height(),
  13052. viewHeight = $(window).height(),
  13053. listHeight = d.elem.result_area.outerHeight(),
  13054. listBottom = offset.top + listHeight,
  13055. hasOverflow = docHeight > viewHeight,
  13056. down = d.elem.result_area.hasClass('shadowDown');
  13057. if (hasOverflow) {
  13058. if (down) {//open down
  13059. if (listBottom > (viewHeight + screenScrollTop)) d.calcResultsSize(d);
  13060. } else {//open up
  13061. if (offset.top < screenScrollTop) d.calcResultsSize(d);
  13062. }
  13063. }
  13064. });
  13065. });
  13066. };
  13067. /**
  13068. * Page bar button event bind
  13069. */
  13070. SelectPage.prototype.ePaging = function () {
  13071. var self = this;
  13072. if (!self.option.pagination) return;
  13073. self.elem.navi.find('li.csFirstPage').off('click').on('click', function (ev) {
  13074. //$(self.elem.combo_input).focus();
  13075. ev.preventDefault();
  13076. self.firstPage(self);
  13077. });
  13078. self.elem.navi.find('li.csPreviousPage').off('click').on('click', function (ev) {
  13079. //$(self.elem.combo_input).focus();
  13080. ev.preventDefault();
  13081. self.prevPage(self);
  13082. });
  13083. self.elem.navi.find('li.csNextPage').off('click').on('click', function (ev) {
  13084. //$(self.elem.combo_input).focus();
  13085. ev.preventDefault();
  13086. self.nextPage(self);
  13087. });
  13088. self.elem.navi.find('li.csLastPage').off('click').on('click', function (ev) {
  13089. //$(self.elem.combo_input).focus();
  13090. ev.preventDefault();
  13091. self.lastPage(self);
  13092. });
  13093. };
  13094. /**
  13095. * Ajax request fail
  13096. * @param {Object} self
  13097. * @param {string} errorThrown
  13098. */
  13099. SelectPage.prototype.ajaxErrorNotify = function (self, errorThrown) {
  13100. self.showMessage(self, self.message.ajax_error);
  13101. };
  13102. /**
  13103. * Message box
  13104. * @param {Object} self
  13105. * @param msg {string} the text need to show
  13106. */
  13107. SelectPage.prototype.showMessage = function (self, msg) {
  13108. if (!msg) return;
  13109. var msgLi = '<li class="' + self.css_class.message_box + '"><i class="spfont sp-warning"></i> ' + msg + '</li>';
  13110. self.elem.results.empty().append(msgLi).show();
  13111. self.calcResultsSize(self);
  13112. self.setOpenStatus(self, true);
  13113. if(self.elem.control) self.elem.control.hide();
  13114. if (self.option.pagination) self.elem.navi.hide();
  13115. };
  13116. /**
  13117. * @desc Scroll
  13118. * @param {Object} self
  13119. * @param {boolean} enforce
  13120. */
  13121. SelectPage.prototype.scrollWindow = function (self, enforce) {
  13122. var current_result = self.getCurrentLine(self),
  13123. target_top = (current_result && !enforce) ? current_result.offset().top : self.elem.container.offset().top,
  13124. target_size;
  13125. self.prop.size_li = self.elem.results.children('li:first').outerHeight();
  13126. target_size = self.prop.size_li;
  13127. var gap, client_height = $(window).height(),
  13128. scroll_top = $(window).scrollTop(),
  13129. scroll_bottom = scroll_top + client_height - target_size;
  13130. if (current_result.length) {
  13131. if (target_top < scroll_top || target_size > client_height) {
  13132. //scroll to top
  13133. gap = target_top - scroll_top;
  13134. } else if (target_top > scroll_bottom) {
  13135. //scroll down
  13136. gap = target_top - scroll_bottom;
  13137. } else return; //do not scroll
  13138. } else if (target_top < scroll_top) gap = target_top - scroll_top;
  13139. window.scrollBy(0, gap);
  13140. };
  13141. /**
  13142. * change css class by status
  13143. * @param self
  13144. * @param status {boolean} true: open, false: close
  13145. */
  13146. SelectPage.prototype.setOpenStatus = function (self, status) {
  13147. var el = self.elem, css = self.css_class;
  13148. if (status) {
  13149. el.container.addClass(css.container_open);
  13150. el.result_area.addClass(css.result_open);
  13151. } else {
  13152. el.container.removeClass(css.container_open);
  13153. el.result_area.removeClass(css.result_open);
  13154. }
  13155. };
  13156. /**
  13157. * input element in focus css class set
  13158. * @param {Object} self
  13159. */
  13160. SelectPage.prototype.setCssFocusedInput = function (self) {
  13161. //$(self.elem.results).addClass(self.css_class.re_off);
  13162. //$(self.elem.combo_input).removeClass(self.css_class.input_off);
  13163. };
  13164. /**
  13165. * set result list get focus and input element lost focus
  13166. * @param {Object} self
  13167. */
  13168. SelectPage.prototype.setCssFocusedResults = function (self) {
  13169. //$(self.elem.results).removeClass(self.css_class.re_off);
  13170. //$(self.elem.combo_input).addClass(self.css_class.input_off);
  13171. };
  13172. /**
  13173. * Quick search input keywords listener
  13174. * @param {Object} self
  13175. */
  13176. SelectPage.prototype.checkValue = function (self) {
  13177. var now_value = self.elem.combo_input.val();
  13178. if (now_value != self.prop.prev_value) {
  13179. self.prop.prev_value = now_value;
  13180. self.prop.first_show = false;
  13181. if (self.option.selectOnly) self.setButtonAttrDefault();
  13182. if (!self.option.multiple && !now_value) {
  13183. self.elem.combo_input.val('');
  13184. self.elem.hidden.val('');
  13185. self.elem.clear_btn.remove();
  13186. }
  13187. self.suggest(self);
  13188. }
  13189. };
  13190. /**
  13191. * Input handle(regular input)
  13192. * @param {Object} self
  13193. * @param {Object} e - event object
  13194. */
  13195. SelectPage.prototype.processKey = function (self, e) {
  13196. if ($.inArray(e.keyCode, [37, 38, 39, 40, 27, 9, 13]) === -1) {
  13197. if (e.keyCode != 16) self.setCssFocusedInput(self); // except Shift(16)
  13198. self.inputResize(self);
  13199. if ($.type(self.option.data) === 'string') {
  13200. self.prop.last_input_time = e.timeStamp;
  13201. setTimeout(function () {
  13202. if ((e.timeStamp - self.prop.last_input_time) === 0)
  13203. self.checkValue(self);
  13204. }, self.option.inputDelay * 1000);
  13205. } else {
  13206. self.checkValue(self);
  13207. }
  13208. }
  13209. }
  13210. /**
  13211. * Input handle(control key)
  13212. * @param {Object} self
  13213. * @param {Object} e - event object
  13214. */
  13215. SelectPage.prototype.processControl = function (self, e) {
  13216. if (($.inArray(e.keyCode, [37, 38, 39, 40, 27, 9]) > -1 && self.elem.result_area.is(':visible')) ||
  13217. ($.inArray(e.keyCode, [13, 9]) > -1 && self.getCurrentLine(self))) {
  13218. e.preventDefault();
  13219. e.stopPropagation();
  13220. e.cancelBubble = true;
  13221. e.returnValue = false;
  13222. switch (e.keyCode) {
  13223. case 37:// left
  13224. if (e.shiftKey) self.firstPage(self);
  13225. else self.prevPage(self);
  13226. break;
  13227. case 38:// up
  13228. self.prop.key_select = true;
  13229. self.prevLine(self);
  13230. break;
  13231. case 39:// right
  13232. if (e.shiftKey) self.lastPage(self);
  13233. else self.nextPage(self);
  13234. break;
  13235. case 40:// down
  13236. if (self.elem.results.children('li').length) {
  13237. self.prop.key_select = true;
  13238. self.nextLine(self);
  13239. } else self.suggest(self);
  13240. break;
  13241. case 9:// tab
  13242. self.prop.key_paging = true;
  13243. self.selectCurrentLine(self, true);
  13244. //self.hideResults(self);
  13245. break;
  13246. case 13:// return
  13247. self.selectCurrentLine(self, true);
  13248. break;
  13249. case 27:// escape
  13250. self.prop.key_paging = true;
  13251. self.hideResults(self);
  13252. break;
  13253. }
  13254. }
  13255. };
  13256. /**
  13257. * Abort Ajax request
  13258. * @param {Object} self
  13259. */
  13260. SelectPage.prototype.abortAjax = function (self) {
  13261. if (self.prop.xhr) {
  13262. self.prop.xhr.abort();
  13263. self.prop.xhr = false;
  13264. }
  13265. };
  13266. /**
  13267. * Suggest result of search keywords
  13268. * @param {Object} self
  13269. */
  13270. SelectPage.prototype.suggest = function (self) {
  13271. var q_word, val = $.trim(self.elem.combo_input.val());
  13272. if (self.option.multiple) q_word = val;
  13273. else {
  13274. if (val && val == self.prop.selected_text) q_word = '';
  13275. else q_word = val;
  13276. }
  13277. q_word = q_word.split(self.option.separator);
  13278. //Before show up result list callback
  13279. if (self.option.eOpen && $.isFunction(self.option.eOpen))
  13280. self.option.eOpen.call(self);
  13281. self.abortAjax(self);
  13282. //self.setLoading(self);
  13283. var which_page_num = self.prop.current_page || 1;
  13284. if (typeof self.option.data == 'object') self.searchForJson(self, q_word, which_page_num);
  13285. else self.searchForDb(self, q_word, which_page_num);
  13286. };
  13287. /**
  13288. * Loading
  13289. * @param {Object} self
  13290. */
  13291. SelectPage.prototype.setLoading = function (self) {
  13292. if (self.elem.results.html() === '') {
  13293. //self.calcResultsSize(self);
  13294. self.setOpenStatus(self, true);
  13295. }
  13296. };
  13297. /**
  13298. * Search for ajax
  13299. * @param {Object} self
  13300. * @param {Array} q_word - query keyword
  13301. * @param {number} which_page_num - target page number
  13302. */
  13303. SelectPage.prototype.searchForDb = function (self, q_word, which_page_num) {
  13304. var p = self.option;
  13305. if (!p.eAjaxSuccess || !$.isFunction(p.eAjaxSuccess)) self.hideResults(self);
  13306. var _paramsFunc = p.params, _params = {}, searchKey = p.searchField;
  13307. //when have new query keyword, then reset page number to 1.
  13308. if (q_word.length && q_word[0] && q_word.join(self.option.separator) !== self.prop.prev_value) which_page_num = 1;
  13309. var _orgParams = {
  13310. q_word: q_word,
  13311. pageNumber: which_page_num,
  13312. pageSize: p.pageSize,
  13313. andOr: p.andOr,
  13314. orderBy: p.orderBy,
  13315. searchTable: p.dbTable,
  13316. showField: self.option.showField,
  13317. keyField: self.option.keyField,
  13318. searchField: self.option.searchField
  13319. };
  13320. if (p.orderBy !== false) _orgParams.orderBy = p.orderBy;
  13321. // 这个应该是历史遗留了,没仔细追逻辑,先留着。
  13322. _orgParams[searchKey] = q_word[0];
  13323. if (_paramsFunc) {
  13324. var result = $.isFunction(_paramsFunc) ? _paramsFunc(self) : _paramsFunc;
  13325. if (result && $.isPlainObject(result)) {
  13326. _params = $.extend({}, _orgParams, result);
  13327. } else {
  13328. _params = _orgParams;
  13329. }
  13330. } else {
  13331. _params = _orgParams;
  13332. }
  13333. self.prop.xhr = $.ajax({
  13334. dataType: 'json',
  13335. url: p.data,
  13336. type: 'POST',
  13337. data: _params,
  13338. success: function (returnData) {
  13339. if (!returnData || !$.isPlainObject(returnData)) {
  13340. self.hideResults(self);
  13341. self.ajaxErrorNotify(self, errorThrown);
  13342. return;
  13343. }
  13344. var data = {}, json = {};
  13345. try {
  13346. data = p.eAjaxSuccess(returnData);
  13347. json.originalResult = data.list;
  13348. json.cnt_whole = data.totalRow;
  13349. } catch (e) {
  13350. self.showMessage(self, self.message.ajax_error);
  13351. return;
  13352. }
  13353. if (self.elem.navi) {
  13354. $(self.elem.navi).toggleClass("hide", json.cnt_whole <= json.originalResult.length);
  13355. }
  13356. json.candidate = [];
  13357. json.keyField = [];
  13358. if (typeof json.originalResult != 'object') {
  13359. self.prop.xhr = null;
  13360. self.notFoundSearch(self);
  13361. return;
  13362. }
  13363. json.cnt_page = json.originalResult.length;
  13364. for (var i = 0; i < json.cnt_page; i++) {
  13365. for (var key in json.originalResult[i]) {
  13366. if (key == p.keyField) {
  13367. json.keyField.push(json.originalResult[i][key]);
  13368. }
  13369. if (key == p.showField) {
  13370. json.candidate.push(json.originalResult[i][key]);
  13371. }
  13372. }
  13373. }
  13374. self.prepareResults(self, json, q_word, which_page_num);
  13375. },
  13376. error: function (jqXHR, textStatus, errorThrown) {
  13377. if (textStatus != 'abort') {
  13378. self.hideResults(self);
  13379. self.ajaxErrorNotify(self, errorThrown);
  13380. }
  13381. },
  13382. complete: function () {
  13383. self.prop.xhr = null;
  13384. }
  13385. });
  13386. };
  13387. /**
  13388. * Search for json data source
  13389. * @param {Object} self
  13390. * @param {Array} q_word
  13391. * @param {number} which_page_num
  13392. */
  13393. SelectPage.prototype.searchForJson = function (self, q_word, which_page_num) {
  13394. var p = self.option, matched = [], esc_q = [], sorted = [], json = {}, i = 0, arr_reg = [];
  13395. //query keyword filter
  13396. do {
  13397. //'/\W/g'正则代表全部不是字母,数字,下划线,汉字的字符
  13398. //将非法字符进行转义
  13399. esc_q[i] = q_word[i].replace(/\W/g, '\\$&').toString();
  13400. arr_reg[i] = new RegExp(esc_q[i], 'gi');
  13401. i++;
  13402. } while (i < q_word.length);
  13403. // SELECT * FROM data WHERE field LIKE q_word;
  13404. for (var i = 0; i < p.data.length; i++) {
  13405. var flag = false, row = p.data[i], itemText;
  13406. for (var j = 0; j < arr_reg.length; j++) {
  13407. itemText = row[p.searchField];
  13408. if (p.formatItem && $.isFunction(p.formatItem))
  13409. itemText = p.formatItem(row);
  13410. if (itemText.match(arr_reg[j])) {
  13411. flag = true;
  13412. if (p.andOr == 'OR') break;
  13413. } else {
  13414. flag = false;
  13415. if (p.andOr == 'AND') break;
  13416. }
  13417. }
  13418. if (flag) matched.push(row);
  13419. }
  13420. // (CASE WHEN ...) then く order some column
  13421. if (p.orderBy === false) sorted = matched.concat();
  13422. else {
  13423. var reg1 = new RegExp('^' + esc_q[0] + '$', 'gi'),
  13424. reg2 = new RegExp('^' + esc_q[0], 'gi'),
  13425. matched1 = [], matched2 = [], matched3 = [];
  13426. for (var i = 0; i < matched.length; i++) {
  13427. var orderField = p.orderBy[0][0];
  13428. var orderValue = String(matched[i][orderField]);
  13429. if (orderValue.match(reg1)) {
  13430. matched1.push(matched[i]);
  13431. } else if (orderValue.match(reg2)) {
  13432. matched2.push(matched[i]);
  13433. } else {
  13434. matched3.push(matched[i]);
  13435. }
  13436. }
  13437. if (p.orderBy[0][1].match(/^asc$/i)) {
  13438. matched1 = self.sortAsc(self, matched1);
  13439. matched2 = self.sortAsc(self, matched2);
  13440. matched3 = self.sortAsc(self, matched3);
  13441. } else {
  13442. matched1 = self.sortDesc(self, matched1);
  13443. matched2 = self.sortDesc(self, matched2);
  13444. matched3 = self.sortDesc(self, matched3);
  13445. }
  13446. sorted = sorted.concat(matched1).concat(matched2).concat(matched3);
  13447. }
  13448. /*
  13449. if (sorted.length === undefined || sorted.length === 0 ) {
  13450. self.notFoundSearch(self);
  13451. return;
  13452. }
  13453. */
  13454. json.cnt_whole = sorted.length;
  13455. //page_move used to distinguish between init plugin or page moving
  13456. if (!self.prop.page_move) {
  13457. //only single mode can be used page number relocation
  13458. if (!p.multiple) {
  13459. //get selected item belong page number
  13460. var currentValue = self.elem.hidden.val();
  13461. if ($.type(currentValue) !== 'undefined' && $.trim(currentValue) !== '') {
  13462. var index = 0;
  13463. $.each(sorted, function (i, row) {
  13464. if (row[p.keyField] == currentValue) {
  13465. index = i + 1;
  13466. return false;
  13467. }
  13468. });
  13469. which_page_num = Math.ceil(index / p.pageSize);
  13470. if (which_page_num < 1) which_page_num = 1;
  13471. self.prop.current_page = which_page_num;
  13472. }
  13473. }
  13474. } else {
  13475. //set page number to 1 when result number less then page size
  13476. if (sorted.length <= ((which_page_num - 1) * p.pageSize)) {
  13477. which_page_num = 1;
  13478. self.prop.current_page = 1;
  13479. }
  13480. }
  13481. //LIMIT xx OFFSET xx
  13482. var start = (which_page_num - 1) * p.pageSize, end = start + p.pageSize;
  13483. //save original data
  13484. json.originalResult = [];
  13485. //after data filter handle
  13486. for (var i = start; i < end; i++) {
  13487. if (sorted[i] === undefined) break;
  13488. json.originalResult.push(sorted[i]);
  13489. for (var key in sorted[i]) {
  13490. if (key == p.keyField) {
  13491. if (json.keyField === undefined) json.keyField = [];
  13492. json.keyField.push(sorted[i][key]);
  13493. }
  13494. if (key == p.showField) {
  13495. if (json.candidate === undefined) json.candidate = [];
  13496. json.candidate.push(sorted[i][key]);
  13497. }
  13498. }
  13499. }
  13500. if (json.candidate === undefined) json.candidate = [];
  13501. json.cnt_page = json.candidate.length;
  13502. self.prepareResults(self, json, q_word, which_page_num);
  13503. };
  13504. /**
  13505. * Set order asc
  13506. * @param {Object} self
  13507. * @param {Array} arr - result array
  13508. */
  13509. SelectPage.prototype.sortAsc = function (self, arr) {
  13510. arr.sort(function (a, b) {
  13511. var valA = a[self.option.orderBy[0][0]], valB = b[self.option.orderBy[0][0]];
  13512. return $.type(valA) === 'number' ? valA - valB : String(valA).localeCompare(String(valB));
  13513. });
  13514. return arr;
  13515. };
  13516. /**
  13517. * Set order desc
  13518. * @param {Object} self
  13519. * @param {Array} arr - result array
  13520. */
  13521. SelectPage.prototype.sortDesc = function (self, arr) {
  13522. arr.sort(function (a, b) {
  13523. var valA = a[self.option.orderBy[0][0]], valB = b[self.option.orderBy[0][0]];
  13524. return $.type(valA) === 'number' ? valB - valA : String(valB).localeCompare(String(valA));
  13525. });
  13526. return arr;
  13527. };
  13528. /**
  13529. * Not result found handle
  13530. * @param {Object} self
  13531. */
  13532. SelectPage.prototype.notFoundSearch = function (self) {
  13533. self.elem.results.empty();
  13534. self.calcResultsSize(self);
  13535. self.setOpenStatus(self, true);
  13536. self.setCssFocusedInput(self);
  13537. };
  13538. /**
  13539. * Prepare data to show
  13540. * @param {Object} self
  13541. * @param {Object} json - data result
  13542. * @param {Array} q_word - query keyword
  13543. * @param {number} which_page_num - target page number
  13544. */
  13545. SelectPage.prototype.prepareResults = function (self, json, q_word, which_page_num) {
  13546. self.data = json.originalResult;
  13547. if (self.option.pagination) self.setNavi(self, json.cnt_whole, json.cnt_page, which_page_num);
  13548. if (!json.keyField) json.keyField = false;
  13549. if (self.option.selectOnly && json.candidate.length === 1 && json.candidate[0] == q_word[0]) {
  13550. self.elem.hidden.val(json.keyField[0]);
  13551. this.setButtonAttrDefault();
  13552. }
  13553. var is_query = false;
  13554. if (q_word && q_word.length && q_word[0]) is_query = true;
  13555. self.displayResults(self, json, is_query);
  13556. };
  13557. /**
  13558. * Build page bar
  13559. * @param {Object} self
  13560. * @param {number} cnt_whole - total record count
  13561. * @param {number} cnt_page
  13562. * @param {number} page_num - current page number
  13563. */
  13564. SelectPage.prototype.setNavi = function (self, cnt_whole, cnt_page, page_num) {
  13565. var msg = self.message;
  13566. /**
  13567. * build pagination bar
  13568. */
  13569. var buildPageNav = function (self, pagebar, page_num, last_page) {
  13570. var updatePageInfo = function () {
  13571. var pageInfo = msg.page_info;
  13572. return pageInfo.replace(self.template.page.current, page_num).replace(self.template.page.total, last_page);
  13573. };
  13574. if (pagebar.find('li').length === 0) {
  13575. pagebar.hide().empty();
  13576. var iconFist = 'spfont sp-first',
  13577. iconPrev = 'spfont sp-previous',
  13578. iconNext = 'spfont sp-next',
  13579. iconLast = 'spfont sp-last';
  13580. pagebar.append('<li class="csFirstPage" title="' + msg.first_title + '" ><a href="javascript:void(0);"> <i class="' + iconFist + '"></i> </a></li>');
  13581. pagebar.append('<li class="csPreviousPage" title="' + msg.prev_title + '" ><a href="javascript:void(0);"><i class="' + iconPrev + '"></i></a></li>');
  13582. //pagination information
  13583. pagebar.append('<li class="pageInfoBox"><a href="javascript:void(0);"> ' + updatePageInfo() + ' </a></li>');
  13584. pagebar.append('<li class="csNextPage" title="' + msg.next_title + '" ><a href="javascript:void(0);"><i class="' + iconNext + '"></i></a></li>');
  13585. pagebar.append('<li class="csLastPage" title="' + msg.last_title + '" ><a href="javascript:void(0);"> <i class="' + iconLast + '"></i> </a></li>');
  13586. pagebar.show();
  13587. } else {
  13588. pagebar.find('li.pageInfoBox a').html(updatePageInfo());
  13589. }
  13590. };
  13591. var pagebar = self.elem.navi.find('ul'),
  13592. last_page = Math.ceil(cnt_whole / self.option.pageSize); //calculate total page
  13593. if (last_page === 0) page_num = 0;
  13594. else {
  13595. if (last_page < page_num) page_num = last_page;
  13596. else if (page_num === 0) page_num = 1;
  13597. }
  13598. self.prop.current_page = page_num;//update current page number
  13599. self.prop.max_page = last_page;//update page count
  13600. buildPageNav(self, pagebar, page_num, last_page);
  13601. //update paging status
  13602. var dClass = 'disabled',
  13603. first = pagebar.find('li.csFirstPage'),
  13604. previous = pagebar.find('li.csPreviousPage'),
  13605. next = pagebar.find('li.csNextPage'),
  13606. last = pagebar.find('li.csLastPage');
  13607. //first and previous
  13608. if (page_num === 1 || page_num === 0) {
  13609. if (!first.hasClass(dClass)) first.addClass(dClass);
  13610. if (!previous.hasClass(dClass)) previous.addClass(dClass);
  13611. } else {
  13612. if (first.hasClass(dClass)) first.removeClass(dClass);
  13613. if (previous.hasClass(dClass)) previous.removeClass(dClass);
  13614. }
  13615. //next and last
  13616. if (page_num === last_page || last_page === 0) {
  13617. if (!next.hasClass(dClass)) next.addClass(dClass);
  13618. if (!last.hasClass(dClass)) last.addClass(dClass);
  13619. } else {
  13620. if (next.hasClass(dClass)) next.removeClass(dClass);
  13621. if (last.hasClass(dClass)) last.removeClass(dClass);
  13622. }
  13623. if (last_page > 1) self.ePaging(); //pagination event bind
  13624. };
  13625. /**
  13626. * Render result list
  13627. * @param {Object} self
  13628. * @param {Object} json - result data
  13629. * @param {boolean} is_query - used to different from search to open and just click to open
  13630. */
  13631. SelectPage.prototype.displayResults = function (self, json, is_query) {
  13632. var p = self.option, el = self.elem;
  13633. el.results.hide().empty();
  13634. if (p.multiple && $.type(p.maxSelectLimit) === 'number' && p.maxSelectLimit > 0) {
  13635. var selectedSize = el.element_box.find('li.selected_tag').length;
  13636. if (selectedSize > 0 && selectedSize >= p.maxSelectLimit) {
  13637. var msg = self.message.max_selected;
  13638. self.showMessage(self, msg.replace(self.template.msg.maxSelectLimit, p.maxSelectLimit));
  13639. return;
  13640. }
  13641. }
  13642. if (json.candidate.length) {
  13643. var arr_candidate = json.candidate,
  13644. arr_primary_key = json.keyField,
  13645. keystr = el.hidden.val(),
  13646. keyArr = keystr ? keystr.split(',') : new Array(),
  13647. itemText = '';
  13648. for (var i = 0; i < arr_candidate.length; i++) {
  13649. if (p.formatItem && $.isFunction(p.formatItem)) {
  13650. try {
  13651. itemText = p.formatItem(json.originalResult[i]);
  13652. } catch (e) {
  13653. console.error('formatItem内容格式化函数内容设置不正确!');
  13654. itemText = arr_candidate[i];
  13655. }
  13656. } else itemText = arr_candidate[i];
  13657. var list = $('<li>').html(itemText).attr({
  13658. pkey: arr_primary_key[i],
  13659. index: i
  13660. });
  13661. if (!p.formatItem) list.attr('title', itemText);
  13662. //Set selected item highlight
  13663. if ($.inArray(arr_primary_key[i].toString(), keyArr) !== -1) {
  13664. list.addClass(self.css_class.selected);
  13665. }
  13666. //cache item data
  13667. list.data('dataObj', json.originalResult[i]);
  13668. el.results.append(list);
  13669. }
  13670. } else {
  13671. var li = '<li class="' + self.css_class.message_box + '"><i class="spfont sp-warning"></i> ' +
  13672. self.message.not_found + '</li>';
  13673. el.results.append(li);
  13674. }
  13675. el.results.show();
  13676. if (p.multiple && p.multipleControlbar) el.control.show();
  13677. if (p.pagination) el.navi.show();
  13678. self.calcResultsSize(self);
  13679. self.setOpenStatus(self, true);
  13680. //Result item event bind
  13681. self.eResultList();
  13682. //scrolling listen
  13683. self.eScroll();
  13684. //auto highlight first item in search, have result and set autoSelectFirst to true situation
  13685. if (is_query && json.candidate.length && p.autoSelectFirst) self.nextLine(self);
  13686. };
  13687. /**
  13688. * Calculate result list size and position
  13689. * @param {Object} self
  13690. */
  13691. SelectPage.prototype.calcResultsSize = function (self) {
  13692. var p = self.option, el = self.elem;
  13693. var rePosition = function () {
  13694. if (el.container.css('position') === 'static') {
  13695. // position: static
  13696. var offset = el.combo_input.offset();
  13697. el.result_area.css({
  13698. top: offset.top + el.combo_input.outerHeight() + 'px',
  13699. left: offset.left + 'px'
  13700. });
  13701. } else {
  13702. if (!p.pagination) {
  13703. var itemHeight = el.results.find('li:first').outerHeight(true),
  13704. listHeight = itemHeight * p.listSize;
  13705. el.results.css({
  13706. 'max-height': listHeight,
  13707. 'overflow-y': 'auto'
  13708. });
  13709. }
  13710. //handle result list show up side(left, right, up or down)
  13711. var docWidth = $(document).width(),
  13712. docHeight = $(document).height(), //the document full height
  13713. viewHeight = $(window).height(), //browser visible area height
  13714. offset = el.container.offset(),
  13715. screenScrollTop = $(window).scrollTop(),
  13716. listWidth = el.result_area.outerWidth(),
  13717. //result list height
  13718. listHeight = el.result_area.outerHeight(),
  13719. //default left used input element left
  13720. defaultLeft = offset.left, //p.multiple ? -1 : 0;
  13721. //input element height
  13722. inputHeight = el.container.outerHeight(),
  13723. left = (offset.left + listWidth) > docWidth ?
  13724. defaultLeft - (listWidth - el.container.outerWidth()) :
  13725. defaultLeft,
  13726. //the actual top coordinate of input element(outer div)
  13727. screenTop = offset.top, //$(el.container).scrollTop();//offset.top - screenScrollTop;
  13728. top = 0, dist = 5, //set distance between input element and result list
  13729. //the actual top coordinate of result list
  13730. listBottom = screenTop + inputHeight + listHeight + dist,
  13731. listTop = screenTop + listHeight + dist,
  13732. hasOverflow = docHeight > viewHeight;
  13733. if ((screenTop - screenScrollTop - dist > listHeight) &&
  13734. (hasOverflow && listBottom > (viewHeight + screenScrollTop)) ||
  13735. (!hasOverflow && listBottom > viewHeight && screenTop >= listTop)) {
  13736. //open up
  13737. top = offset.top - listHeight - dist;
  13738. el.result_area.removeClass('shadowUp shadowDown').addClass('shadowUp');
  13739. } else {
  13740. //open down
  13741. top = offset.top + (p.multiple ? el.container.outerHeight() : inputHeight);
  13742. el.result_area.removeClass('shadowUp shadowDown').addClass('shadowDown');
  13743. top += dist;
  13744. }
  13745. return {
  13746. top: top + 'px', left: left + 'px'
  13747. };
  13748. }
  13749. };
  13750. if (el.result_area.is(':visible')) {
  13751. el.result_area.css(rePosition());
  13752. } else {
  13753. var pss = rePosition();
  13754. el.result_area.css(pss).show(1, function () {
  13755. var repss = rePosition();
  13756. if (pss.top !== repss.top || pss.left !== repss.left) el.result_area.css(repss);
  13757. });
  13758. }
  13759. };
  13760. /**
  13761. * hide result list
  13762. * @param {Object} self
  13763. */
  13764. SelectPage.prototype.hideResults = function (self) {
  13765. if (self.prop.key_paging) {
  13766. self.scrollWindow(self, true);
  13767. self.prop.key_paging = false;
  13768. }
  13769. self.setCssFocusedInput(self);
  13770. if (self.option.autoFillResult) {
  13771. //self.selectCurrentLine(self, true);
  13772. }
  13773. self.elem.results.empty();
  13774. self.elem.result_area.hide();
  13775. self.setOpenStatus(self, false);
  13776. //unbind window scroll listen
  13777. $(window).off('scroll.SelectPage');
  13778. self.abortAjax(self);
  13779. self.setButtonAttrDefault();
  13780. };
  13781. /**
  13782. * set plugin to disabled / enabled
  13783. * @param self
  13784. * @param disabled
  13785. */
  13786. SelectPage.prototype.disabled = function (self, disabled) {
  13787. var p = self.option, el = self.elem;
  13788. if ($.type(disabled) === 'undefined') return el.combo_input.prop('disabled');
  13789. if ($.type(disabled) === 'boolean') {
  13790. el.combo_input.prop('disabled', disabled);
  13791. if (disabled) el.container.addClass(self.css_class.disabled);
  13792. else el.container.removeClass(self.css_class.disabled);
  13793. }
  13794. };
  13795. /**
  13796. * Go fist page
  13797. * @param {Object} self
  13798. */
  13799. SelectPage.prototype.firstPage = function (self) {
  13800. if (self.prop.current_page > 1) {
  13801. self.prop.current_page = 1;
  13802. self.prop.page_move = true;
  13803. self.suggest(self);
  13804. }
  13805. };
  13806. /**
  13807. * Go previous page
  13808. * @param {Object} self
  13809. */
  13810. SelectPage.prototype.prevPage = function (self) {
  13811. if (self.prop.current_page > 1) {
  13812. self.prop.current_page--;
  13813. self.prop.page_move = true;
  13814. self.suggest(self);
  13815. }
  13816. };
  13817. /**
  13818. * Go next page
  13819. * @param {Object} self
  13820. */
  13821. SelectPage.prototype.nextPage = function (self) {
  13822. if (self.prop.current_page < self.prop.max_page) {
  13823. self.prop.current_page++;
  13824. self.prop.page_move = true;
  13825. self.suggest(self);
  13826. }
  13827. };
  13828. /**
  13829. * Go last page
  13830. * @param {Object} self
  13831. */
  13832. SelectPage.prototype.lastPage = function (self) {
  13833. if (self.prop.current_page < self.prop.max_page) {
  13834. self.prop.current_page = self.prop.max_page;
  13835. self.prop.page_move = true;
  13836. self.suggest(self);
  13837. }
  13838. };
  13839. /**
  13840. * do something after select/unSelect action
  13841. * @param {Object} self
  13842. * @param {boolean} reOpen
  13843. */
  13844. SelectPage.prototype.afterAction = function (self, reOpen) {
  13845. self.inputResize(self);
  13846. self.elem.combo_input.change();
  13847. self.setCssFocusedInput(self);
  13848. if (self.prop.init_set) return;
  13849. if (self.option.multiple) {
  13850. if (self.option.selectToCloseList) {
  13851. self.hideResults(self);
  13852. self.elem.combo_input.blur();
  13853. }
  13854. if (!self.option.selectToCloseList && reOpen) {
  13855. self.suggest(self);
  13856. self.elem.combo_input.focus();
  13857. }
  13858. } else {
  13859. self.hideResults(self);
  13860. self.elem.combo_input.blur();
  13861. }
  13862. };
  13863. /**
  13864. * Select current list item
  13865. * @param {Object} self
  13866. * @param {boolean} is_enter_key
  13867. */
  13868. SelectPage.prototype.selectCurrentLine = function (self, is_enter_key) {
  13869. self.scrollWindow(self, true);
  13870. var p = self.option, current = self.getCurrentLine(self);
  13871. if (current) {
  13872. var data = current.data('dataObj');
  13873. var text = data[p.showField] || current.text();
  13874. var value = current.attr('pkey');
  13875. if (!p.multiple) {
  13876. self.elem.combo_input.val(text);
  13877. self.elem.hidden.val(value);
  13878. } else {
  13879. //build tags in multiple selection mode
  13880. self.elem.combo_input.val('');
  13881. var item = {text: text, value: value};
  13882. if (!self.isAlreadySelected(self, item)) {
  13883. self.addNewTag(self, data, item);
  13884. self.tagValuesSet(self);
  13885. }
  13886. }
  13887. if (p.selectOnly) self.setButtonAttrDefault();
  13888. //Select item callback
  13889. if (p.eSelect && $.isFunction(p.eSelect)) p.eSelect(data, self);
  13890. self.prop.prev_value = self.elem.combo_input.val();
  13891. self.prop.selected_text = self.elem.combo_input.val();
  13892. self.putClearButton();
  13893. }
  13894. self.afterAction(self, true);
  13895. };
  13896. /**
  13897. * Show clear button when item selected in single selection mode
  13898. */
  13899. SelectPage.prototype.putClearButton = function () {
  13900. if (!this.option.multiple && !this.elem.combo_input.prop('disabled')) this.elem.container.append(this.elem.clear_btn);
  13901. };
  13902. /**
  13903. * Select all list item
  13904. * @param {Object} self
  13905. */
  13906. SelectPage.prototype.selectAllLine = function (self) {
  13907. var p = self.option, jsonarr = new Array();
  13908. self.elem.results.find('li').each(function (i, row) {
  13909. var $row = $(row), data = $row.data('dataObj');
  13910. var text = data[p.showField] || $row.text();
  13911. var value = $row.attr('pkey');
  13912. var item = {text: text, value: value};
  13913. if (!self.isAlreadySelected(self, item)) {
  13914. self.addNewTag(self, data, item);
  13915. self.tagValuesSet(self);
  13916. }
  13917. jsonarr.push(data);
  13918. //limited max selected items
  13919. if ($.type(p.maxSelectLimit) === 'number' &&
  13920. p.maxSelectLimit > 0 &&
  13921. p.maxSelectLimit === self.elem.element_box.find('li.selected_tag').length) {
  13922. return false;
  13923. }
  13924. });
  13925. if (p.eSelect && $.isFunction(p.eSelect)) p.eSelect(jsonarr, self);
  13926. self.afterAction(self, true);
  13927. };
  13928. /**
  13929. * Cancel select all item in current page
  13930. * @param {Object} self
  13931. */
  13932. SelectPage.prototype.unSelectAllLine = function (self) {
  13933. var p = self.option, size = self.elem.results.find('li').length, ds = [];
  13934. self.elem.results.find('li').each(function (i, row) {
  13935. var key = $(row).attr('pkey');
  13936. var tag = self.elem.element_box.find('li.selected_tag[itemvalue="' + key + '"]');
  13937. if (tag.length) ds.push(tag.data('dataObj'));
  13938. self.removeTag(self, tag);
  13939. });
  13940. self.afterAction(self, true);
  13941. if (p.eTagRemove && $.isFunction(p.eTagRemove)) p.eTagRemove(ds);
  13942. };
  13943. /**
  13944. * Clear all selected items
  13945. * @param {Object} self
  13946. * @param {boolean} open - open list after clear selected item
  13947. */
  13948. SelectPage.prototype.clearAll = function (self, open) {
  13949. var p = self.option, ds = [];
  13950. if (p.multiple) {
  13951. self.elem.element_box.find('li.selected_tag').each(function (i, row) {
  13952. ds.push($(row).data('dataObj'));
  13953. row.remove();
  13954. });
  13955. self.elem.element_box.find('li.selected_tag').remove();
  13956. }
  13957. self.reset(self);
  13958. self.afterAction(self, open);
  13959. if (p.multiple) {
  13960. if (p.eTagRemove && $.isFunction(p.eTagRemove)) p.eTagRemove(ds);
  13961. } else self.elem.clear_btn.remove();
  13962. };
  13963. /**
  13964. * reset
  13965. */
  13966. SelectPage.prototype.reset = function (self) {
  13967. self.elem.combo_input.val('');
  13968. self.elem.hidden.val('');
  13969. self.prop.prev_value = '';
  13970. self.prop.selected_text = '';
  13971. self.prop.current_page = 1;
  13972. };
  13973. /**
  13974. * Get current highlight item
  13975. * @param {Object} self
  13976. */
  13977. SelectPage.prototype.getCurrentLine = function (self) {
  13978. if (self.elem.result_area.is(':hidden')) return false;
  13979. var obj = self.elem.results.find('li.' + self.css_class.select);
  13980. if (obj.length) return obj;
  13981. else return false;
  13982. };
  13983. /**
  13984. * Check the result item is already selected or not
  13985. * @param {Object} self
  13986. * @param {Object} item - item info
  13987. */
  13988. SelectPage.prototype.isAlreadySelected = function (self, item) {
  13989. var isExist = false;
  13990. if (item.value) {
  13991. var keys = self.elem.hidden.val();
  13992. if (keys) {
  13993. var karr = keys.split(',');
  13994. if (karr && karr.length && $.inArray(item.value, karr) != -1) isExist = true;
  13995. }
  13996. }
  13997. return isExist;
  13998. };
  13999. /**
  14000. * Add a new tag in multiple selection mode
  14001. * @param {Object} self
  14002. * @param {object} data - raw row data
  14003. * @param {Object} item
  14004. */
  14005. SelectPage.prototype.addNewTag = function (self, data, item) {
  14006. if (!self.option.multiple || !data || !item) return;
  14007. var tmp = self.template.tag.content, tag;
  14008. tmp = tmp.replace(self.template.tag.textKey, item.text);
  14009. tmp = tmp.replace(self.template.tag.valueKey, item.value);
  14010. tag = $(tmp);
  14011. tag.data('dataObj', data);
  14012. if (self.elem.combo_input.prop('disabled')) tag.find('span.tag_close').hide();
  14013. self.elem.combo_input.closest('li').before(tag);
  14014. };
  14015. /**
  14016. * Remove a tag in multiple selection mode
  14017. * @param {Object} self
  14018. * @param {Object} item
  14019. */
  14020. SelectPage.prototype.removeTag = function (self, item) {
  14021. var key = $(item).attr('itemvalue');
  14022. var keys = self.elem.hidden.val();
  14023. if ($.type(key) != 'undefined' && keys) {
  14024. var keyarr = keys.split(','),
  14025. index = $.inArray(key.toString(), keyarr);
  14026. if (index != -1) {
  14027. keyarr.splice(index, 1);
  14028. self.elem.hidden.val(keyarr.toString()).trigger("change");
  14029. }
  14030. }
  14031. $(item).remove();
  14032. self.inputResize(self);
  14033. };
  14034. /**
  14035. * Selected item value(keyField) put in to hidden element
  14036. * @param {Object} self
  14037. */
  14038. SelectPage.prototype.tagValuesSet = function (self) {
  14039. if (!self.option.multiple) return;
  14040. var tags = self.elem.element_box.find('li.selected_tag');
  14041. if (tags && tags.length) {
  14042. var result = new Array();
  14043. $.each(tags, function (i, li) {
  14044. var v = $(li).attr('itemvalue');
  14045. if ($.type(v) !== 'undefined') result.push(v);
  14046. });
  14047. if (result.length) {
  14048. self.elem.hidden.val(result.join(',')).trigger("change");
  14049. }
  14050. }
  14051. };
  14052. /**
  14053. * auto resize input element width in multiple select mode
  14054. * @param {Object} self
  14055. */
  14056. SelectPage.prototype.inputResize = function (self) {
  14057. if (!self.option.multiple) return;
  14058. var width = '',
  14059. inputLi = self.elem.combo_input.closest('li');
  14060. var setDefaultSize = function (self, inputLi) {
  14061. inputLi.removeClass('full_width');
  14062. var minimumWidth = self.elem.combo_input.val().length + 1,
  14063. width = (minimumWidth * 0.75) + 'em';
  14064. self.elem.combo_input.css('width', width).removeAttr('placeholder');
  14065. };
  14066. if (self.elem.element_box.find('li.selected_tag').length === 0) {
  14067. if (!inputLi.hasClass('full_width')) inputLi.addClass('full_width');
  14068. if (self.elem.combo_input.attr('placeholder_bak')) {
  14069. self.elem.combo_input.attr('placeholder', self.elem.combo_input.attr('placeholder_bak')).removeAttr('style');
  14070. }
  14071. } else setDefaultSize(self, inputLi);
  14072. };
  14073. /**
  14074. * Move to next line
  14075. * @param {Object} self
  14076. */
  14077. SelectPage.prototype.nextLine = function (self) {
  14078. var obj = self.getCurrentLine(self), idx;
  14079. if (!obj) idx = -1;
  14080. else {
  14081. idx = self.elem.results.children('li').index(obj);
  14082. obj.removeClass(self.css_class.select);
  14083. }
  14084. idx++;
  14085. if (idx < self.elem.results.children('li').length) {
  14086. var next = self.elem.results.children('li').eq(idx);
  14087. next.addClass(self.css_class.select);
  14088. self.setCssFocusedResults(self);
  14089. } else self.setCssFocusedInput(self);
  14090. self.scrollWindow(self, false);
  14091. };
  14092. /**
  14093. * Move to previous line
  14094. * @param {Object} self
  14095. */
  14096. SelectPage.prototype.prevLine = function (self) {
  14097. var obj = self.getCurrentLine(self), idx;
  14098. if (!obj) idx = self.elem.results.children('li').length;
  14099. else {
  14100. idx = self.elem.results.children('li').index(obj);
  14101. obj.removeClass(self.css_class.select);
  14102. }
  14103. idx--;
  14104. if (idx > -1) {
  14105. var prev = self.elem.results.children('li').eq(idx);
  14106. prev.addClass(self.css_class.select);
  14107. self.setCssFocusedResults(self);
  14108. } else self.setCssFocusedInput(self);
  14109. self.scrollWindow(self, false);
  14110. };
  14111. /**
  14112. * SelectPage plugin definition
  14113. * @global
  14114. * @param option {Object} init plugin option
  14115. */
  14116. function Plugin(option) {
  14117. return this.each(function () {
  14118. var $this = $(this),
  14119. data = $this.data(SelectPage.dataKey),
  14120. params = $.extend({}, defaults, $this.data(), data && data.option, typeof option === 'object' && option);
  14121. if (!data) $this.data(SelectPage.dataKey, (data = new SelectPage(this, params)));
  14122. });
  14123. }
  14124. /**
  14125. * Get plugin object
  14126. * @param {object} obj
  14127. * @returns
  14128. */
  14129. function getPlugin(obj) {
  14130. return $(obj).closest('div.sp_container').find('input.sp_input');
  14131. }
  14132. /**
  14133. * Clear all selected item
  14134. */
  14135. function ClearSelected() {
  14136. return this.each(function () {
  14137. var $this = getPlugin(this),
  14138. data = $this.data(SelectPage.dataKey);
  14139. if (data) {
  14140. data.prop.init_set = true;
  14141. data.clearAll(data);
  14142. data.prop.init_set = false;
  14143. }
  14144. });
  14145. }
  14146. /**
  14147. * Refresh result list
  14148. * use case:
  14149. * 1.use $(obj).val('xxx') to modify selectpage selected item key
  14150. * 2.refresh selected item show content/tag text
  14151. */
  14152. function SelectedRefresh() {
  14153. return this.each(function () {
  14154. var $this = getPlugin(this),
  14155. data = $this.data(SelectPage.dataKey);
  14156. if (data && data.elem.hidden.val())
  14157. data.setInitRecord(true);
  14158. });
  14159. }
  14160. /**
  14161. * Modify plugin datasource, only work on json datasource mode
  14162. * @param {array} data - new datasource
  14163. * @example
  14164. * [{name:'aa',sex:1},{name:'bb',sex:0},{...}]
  14165. */
  14166. function ModifyDataSource(data) {
  14167. return this.each(function () {
  14168. if (data && $.isArray(data)) {
  14169. var $this = getPlugin(this),
  14170. plugin = $this.data(SelectPage.dataKey);
  14171. if (plugin) {
  14172. plugin.clearAll(plugin);
  14173. plugin.option.data = data;
  14174. }
  14175. }
  14176. });
  14177. }
  14178. /**
  14179. * Get plugin disabled status or Modify plugin disabled status
  14180. * @param disabled {boolean} set disabled status
  14181. */
  14182. function PluginDisabled(disabled) {
  14183. var status = false;
  14184. this.each(function () {
  14185. var $this = getPlugin(this),
  14186. plugin = $this.data(SelectPage.dataKey);
  14187. if (plugin) {
  14188. if ($.type(disabled) !== 'undefined')
  14189. plugin.disabled(plugin, disabled);
  14190. else
  14191. status = plugin.disabled(plugin);
  14192. }
  14193. });
  14194. return status;
  14195. }
  14196. /**
  14197. * Get selected item text
  14198. * @returns {string}
  14199. */
  14200. function GetInputText() {
  14201. var str = '';
  14202. this.each(function () {
  14203. var $this = getPlugin(this), data = $this.data(SelectPage.dataKey);
  14204. if (data) {
  14205. if (data.option.multiple) {
  14206. var tags = [];
  14207. data.elem.element_box.find('li.selected_tag').each(function (i, tag) {
  14208. tags.push($(tag).text());
  14209. });
  14210. str += tags.toString();
  14211. } else {
  14212. str += data.elem.combo_input.val();
  14213. }
  14214. }
  14215. });
  14216. return str;
  14217. }
  14218. /**
  14219. * Get selected item raw data
  14220. * @returns {any[]}
  14221. */
  14222. function GetSelectedData () {
  14223. var results = [];
  14224. this.each(function () {
  14225. var $this = getPlugin(this), data = $this.data(SelectPage.dataKey);
  14226. if (data) {
  14227. if (data.option.multiple) {
  14228. data.elem.element_box.find('li.selected_tag').each(function (i, tag) {
  14229. results.push($(tag).data('dataObj'));
  14230. });
  14231. } else {
  14232. var selected = data.elem.combo_input.data('dataObj');
  14233. if (selected) results.push(selected);
  14234. }
  14235. }
  14236. });
  14237. return results;
  14238. }
  14239. var old = $.fn.selectPage;
  14240. $.fn.selectPage = Plugin;
  14241. $.fn.selectPage.Constructor = SelectPage;
  14242. $.fn.selectPageClear = ClearSelected;
  14243. $.fn.selectPageRefresh = SelectedRefresh;
  14244. $.fn.selectPageData = ModifyDataSource;
  14245. $.fn.selectPageDisabled = PluginDisabled;
  14246. $.fn.selectPageText = GetInputText;
  14247. $.fn.selectPageSelectedData = GetSelectedData;
  14248. // SelectPage no conflict
  14249. // =================
  14250. $.fn.selectPage.noConflict = function () {
  14251. $.fn.selectPage = old;
  14252. return this;
  14253. };
  14254. })(window.jQuery);
  14255. define("selectpage", function(){});
  14256. /**
  14257. * @version: 2.1.27
  14258. * @author: Dan Grossman http://www.dangrossman.info/
  14259. * @copyright: Copyright (c) 2012-2017 Dan Grossman. All rights reserved.
  14260. * @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php
  14261. * @website: http://www.daterangepicker.com/
  14262. */
  14263. // Follow the UMD template https://github.com/umdjs/umd/blob/master/templates/returnExportsGlobal.js
  14264. (function (root, factory) {
  14265. if (typeof define === 'function' && define.amd) {
  14266. // AMD. Make globaly available as well
  14267. define('bootstrap-daterangepicker',['moment', 'jquery'], function (moment, jquery) {
  14268. if (!jquery.fn) jquery.fn = {}; // webpack server rendering
  14269. return factory(moment, jquery);
  14270. });
  14271. } else if (typeof module === 'object' && module.exports) {
  14272. // Node / Browserify
  14273. //isomorphic issue
  14274. var jQuery = (typeof window != 'undefined') ? window.jQuery : undefined;
  14275. if (!jQuery) {
  14276. jQuery = require('jquery');
  14277. if (!jQuery.fn) jQuery.fn = {};
  14278. }
  14279. var moment = (typeof window != 'undefined' && typeof window.moment != 'undefined') ? window.moment : require('moment');
  14280. module.exports = factory(moment, jQuery);
  14281. } else {
  14282. // Browser globals
  14283. root.daterangepicker = factory(root.moment, root.jQuery);
  14284. }
  14285. }(this, function(moment, $) {
  14286. var DateRangePicker = function(element, options, cb) {
  14287. //default settings for options
  14288. this.parentEl = 'body';
  14289. this.element = $(element);
  14290. this.startDate = moment().startOf('day');
  14291. this.endDate = moment().endOf('day');
  14292. this.minDate = false;
  14293. this.maxDate = false;
  14294. this.dateLimit = false;
  14295. this.autoApply = false;
  14296. this.singleDatePicker = false;
  14297. this.showDropdowns = false;
  14298. this.showWeekNumbers = false;
  14299. this.showISOWeekNumbers = false;
  14300. this.showCustomRangeLabel = true;
  14301. this.timePicker = false;
  14302. this.timePicker24Hour = false;
  14303. this.timePickerIncrement = 1;
  14304. this.timePickerSeconds = false;
  14305. this.linkedCalendars = true;
  14306. this.autoUpdateInput = true;
  14307. this.alwaysShowCalendars = false;
  14308. this.ranges = {};
  14309. this.opens = 'right';
  14310. if (this.element.hasClass('pull-right'))
  14311. this.opens = 'left';
  14312. this.drops = 'down';
  14313. if (this.element.hasClass('dropup'))
  14314. this.drops = 'up';
  14315. this.buttonClasses = 'btn btn-sm';
  14316. this.applyClass = 'btn-success';
  14317. this.cancelClass = 'btn-default';
  14318. this.locale = {
  14319. direction: 'ltr',
  14320. format: moment.localeData().longDateFormat('L'),
  14321. separator: ' - ',
  14322. applyLabel: 'Apply',
  14323. cancelLabel: 'Cancel',
  14324. weekLabel: 'W',
  14325. customRangeLabel: 'Custom Range',
  14326. daysOfWeek: moment.weekdaysMin(),
  14327. monthNames: moment.monthsShort(),
  14328. firstDay: moment.localeData().firstDayOfWeek()
  14329. };
  14330. this.callback = function() { };
  14331. //some state information
  14332. this.isShowing = false;
  14333. this.leftCalendar = {};
  14334. this.rightCalendar = {};
  14335. //custom options from user
  14336. if (typeof options !== 'object' || options === null)
  14337. options = {};
  14338. //allow setting options with data attributes
  14339. //data-api options will be overwritten with custom javascript options
  14340. options = $.extend(this.element.data(), options);
  14341. //html template for the picker UI
  14342. if (typeof options.template !== 'string' && !(options.template instanceof $))
  14343. options.template = '<div class="daterangepicker dropdown-menu">' +
  14344. '<div class="calendar left">' +
  14345. '<div class="daterangepicker_input">' +
  14346. '<input class="input-mini form-control" type="text" name="daterangepicker_start" value="" />' +
  14347. '<i class="fa fa-calendar glyphicon glyphicon-calendar"></i>' +
  14348. '<div class="calendar-time">' +
  14349. '<div></div>' +
  14350. '<i class="fa fa-clock-o glyphicon glyphicon-time"></i>' +
  14351. '</div>' +
  14352. '</div>' +
  14353. '<div class="calendar-table"></div>' +
  14354. '</div>' +
  14355. '<div class="calendar right">' +
  14356. '<div class="daterangepicker_input">' +
  14357. '<input class="input-mini form-control" type="text" name="daterangepicker_end" value="" />' +
  14358. '<i class="fa fa-calendar glyphicon glyphicon-calendar"></i>' +
  14359. '<div class="calendar-time">' +
  14360. '<div></div>' +
  14361. '<i class="fa fa-clock-o glyphicon glyphicon-time"></i>' +
  14362. '</div>' +
  14363. '</div>' +
  14364. '<div class="calendar-table"></div>' +
  14365. '</div>' +
  14366. '<div class="ranges">' +
  14367. '<div class="range_inputs">' +
  14368. '<button class="applyBtn" disabled="disabled" type="button"></button> ' +
  14369. '<button class="cancelBtn" type="button"></button>' +
  14370. '</div>' +
  14371. '</div>' +
  14372. '</div>';
  14373. this.parentEl = (options.parentEl && $(options.parentEl).length) ? $(options.parentEl) : $(this.parentEl);
  14374. this.container = $(options.template).appendTo(this.parentEl);
  14375. //
  14376. // handle all the possible options overriding defaults
  14377. //
  14378. if (typeof options.locale === 'object') {
  14379. if (typeof options.locale.direction === 'string')
  14380. this.locale.direction = options.locale.direction;
  14381. if (typeof options.locale.format === 'string')
  14382. this.locale.format = options.locale.format;
  14383. if (typeof options.locale.separator === 'string')
  14384. this.locale.separator = options.locale.separator;
  14385. if (typeof options.locale.daysOfWeek === 'object')
  14386. this.locale.daysOfWeek = options.locale.daysOfWeek.slice();
  14387. if (typeof options.locale.monthNames === 'object')
  14388. this.locale.monthNames = options.locale.monthNames.slice();
  14389. if (typeof options.locale.firstDay === 'number')
  14390. this.locale.firstDay = options.locale.firstDay;
  14391. if (typeof options.locale.applyLabel === 'string')
  14392. this.locale.applyLabel = options.locale.applyLabel;
  14393. if (typeof options.locale.cancelLabel === 'string')
  14394. this.locale.cancelLabel = options.locale.cancelLabel;
  14395. if (typeof options.locale.weekLabel === 'string')
  14396. this.locale.weekLabel = options.locale.weekLabel;
  14397. if (typeof options.locale.customRangeLabel === 'string'){
  14398. //Support unicode chars in the custom range name.
  14399. var elem = document.createElement('textarea');
  14400. elem.innerHTML = options.locale.customRangeLabel;
  14401. var rangeHtml = elem.value;
  14402. this.locale.customRangeLabel = rangeHtml;
  14403. }
  14404. }
  14405. this.container.addClass(this.locale.direction);
  14406. if (typeof options.startDate === 'string')
  14407. this.startDate = moment(options.startDate, this.locale.format);
  14408. if (typeof options.endDate === 'string')
  14409. this.endDate = moment(options.endDate, this.locale.format);
  14410. if (typeof options.minDate === 'string')
  14411. this.minDate = moment(options.minDate, this.locale.format);
  14412. if (typeof options.maxDate === 'string')
  14413. this.maxDate = moment(options.maxDate, this.locale.format);
  14414. if (typeof options.startDate === 'object')
  14415. this.startDate = moment(options.startDate);
  14416. if (typeof options.endDate === 'object')
  14417. this.endDate = moment(options.endDate);
  14418. if (typeof options.minDate === 'object')
  14419. this.minDate = moment(options.minDate);
  14420. if (typeof options.maxDate === 'object')
  14421. this.maxDate = moment(options.maxDate);
  14422. // sanity check for bad options
  14423. if (this.minDate && this.startDate.isBefore(this.minDate))
  14424. this.startDate = this.minDate.clone();
  14425. // sanity check for bad options
  14426. if (this.maxDate && this.endDate.isAfter(this.maxDate))
  14427. this.endDate = this.maxDate.clone();
  14428. if (typeof options.applyClass === 'string')
  14429. this.applyClass = options.applyClass;
  14430. if (typeof options.cancelClass === 'string')
  14431. this.cancelClass = options.cancelClass;
  14432. if (typeof options.dateLimit === 'object')
  14433. this.dateLimit = options.dateLimit;
  14434. if (typeof options.opens === 'string')
  14435. this.opens = options.opens;
  14436. if (typeof options.drops === 'string')
  14437. this.drops = options.drops;
  14438. if (typeof options.showWeekNumbers === 'boolean')
  14439. this.showWeekNumbers = options.showWeekNumbers;
  14440. if (typeof options.showISOWeekNumbers === 'boolean')
  14441. this.showISOWeekNumbers = options.showISOWeekNumbers;
  14442. if (typeof options.buttonClasses === 'string')
  14443. this.buttonClasses = options.buttonClasses;
  14444. if (typeof options.buttonClasses === 'object')
  14445. this.buttonClasses = options.buttonClasses.join(' ');
  14446. if (typeof options.showDropdowns === 'boolean')
  14447. this.showDropdowns = options.showDropdowns;
  14448. if (typeof options.showCustomRangeLabel === 'boolean')
  14449. this.showCustomRangeLabel = options.showCustomRangeLabel;
  14450. if (typeof options.singleDatePicker === 'boolean') {
  14451. this.singleDatePicker = options.singleDatePicker;
  14452. if (this.singleDatePicker)
  14453. this.endDate = this.startDate.clone();
  14454. }
  14455. if (typeof options.timePicker === 'boolean')
  14456. this.timePicker = options.timePicker;
  14457. if (typeof options.timePickerSeconds === 'boolean')
  14458. this.timePickerSeconds = options.timePickerSeconds;
  14459. if (typeof options.timePickerIncrement === 'number')
  14460. this.timePickerIncrement = options.timePickerIncrement;
  14461. if (typeof options.timePicker24Hour === 'boolean')
  14462. this.timePicker24Hour = options.timePicker24Hour;
  14463. if (typeof options.autoApply === 'boolean')
  14464. this.autoApply = options.autoApply;
  14465. if (typeof options.autoUpdateInput === 'boolean')
  14466. this.autoUpdateInput = options.autoUpdateInput;
  14467. if (typeof options.linkedCalendars === 'boolean')
  14468. this.linkedCalendars = options.linkedCalendars;
  14469. if (typeof options.isInvalidDate === 'function')
  14470. this.isInvalidDate = options.isInvalidDate;
  14471. if (typeof options.isCustomDate === 'function')
  14472. this.isCustomDate = options.isCustomDate;
  14473. if (typeof options.alwaysShowCalendars === 'boolean')
  14474. this.alwaysShowCalendars = options.alwaysShowCalendars;
  14475. // update day names order to firstDay
  14476. if (this.locale.firstDay != 0) {
  14477. var iterator = this.locale.firstDay;
  14478. while (iterator > 0) {
  14479. this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift());
  14480. iterator--;
  14481. }
  14482. }
  14483. var start, end, range;
  14484. //if no start/end dates set, check if an input element contains initial values
  14485. if (typeof options.startDate === 'undefined' && typeof options.endDate === 'undefined') {
  14486. if ($(this.element).is('input[type=text]')) {
  14487. var val = $(this.element).val(),
  14488. split = val.split(this.locale.separator);
  14489. start = end = null;
  14490. if (split.length == 2) {
  14491. start = moment(split[0], this.locale.format);
  14492. end = moment(split[1], this.locale.format);
  14493. } else if (this.singleDatePicker && val !== "") {
  14494. start = moment(val, this.locale.format);
  14495. end = moment(val, this.locale.format);
  14496. }
  14497. if (start !== null && end !== null) {
  14498. this.setStartDate(start);
  14499. this.setEndDate(end);
  14500. }
  14501. }
  14502. }
  14503. if (typeof options.ranges === 'object') {
  14504. for (range in options.ranges) {
  14505. if (typeof options.ranges[range][0] === 'string')
  14506. start = moment(options.ranges[range][0], this.locale.format);
  14507. else
  14508. start = moment(options.ranges[range][0]);
  14509. if (typeof options.ranges[range][1] === 'string')
  14510. end = moment(options.ranges[range][1], this.locale.format);
  14511. else
  14512. end = moment(options.ranges[range][1]);
  14513. // If the start or end date exceed those allowed by the minDate or dateLimit
  14514. // options, shorten the range to the allowable period.
  14515. if (this.minDate && start.isBefore(this.minDate))
  14516. start = this.minDate.clone();
  14517. var maxDate = this.maxDate;
  14518. if (this.dateLimit && maxDate && start.clone().add(this.dateLimit).isAfter(maxDate))
  14519. maxDate = start.clone().add(this.dateLimit);
  14520. if (maxDate && end.isAfter(maxDate))
  14521. end = maxDate.clone();
  14522. // If the end of the range is before the minimum or the start of the range is
  14523. // after the maximum, don't display this range option at all.
  14524. if ((this.minDate && end.isBefore(this.minDate, this.timepicker ? 'minute' : 'day'))
  14525. || (maxDate && start.isAfter(maxDate, this.timepicker ? 'minute' : 'day')))
  14526. continue;
  14527. //Support unicode chars in the range names.
  14528. var elem = document.createElement('textarea');
  14529. elem.innerHTML = range;
  14530. var rangeHtml = elem.value;
  14531. this.ranges[rangeHtml] = [start, end];
  14532. }
  14533. var list = '<ul>';
  14534. for (range in this.ranges) {
  14535. list += '<li data-range-key="' + range + '">' + range + '</li>';
  14536. }
  14537. if (this.showCustomRangeLabel) {
  14538. list += '<li data-range-key="' + this.locale.customRangeLabel + '">' + this.locale.customRangeLabel + '</li>';
  14539. }
  14540. list += '</ul>';
  14541. this.container.find('.ranges').prepend(list);
  14542. }
  14543. if (typeof cb === 'function') {
  14544. this.callback = cb;
  14545. }
  14546. if (!this.timePicker) {
  14547. this.startDate = this.startDate.startOf('day');
  14548. this.endDate = this.endDate.endOf('day');
  14549. this.container.find('.calendar-time').hide();
  14550. }
  14551. //can't be used together for now
  14552. if (this.timePicker && this.autoApply)
  14553. this.autoApply = false;
  14554. if (this.autoApply && typeof options.ranges !== 'object') {
  14555. this.container.find('.ranges').hide();
  14556. } else if (this.autoApply) {
  14557. this.container.find('.applyBtn, .cancelBtn').addClass('hide');
  14558. }
  14559. if (this.singleDatePicker) {
  14560. this.container.addClass('single');
  14561. this.container.find('.calendar.left').addClass('single');
  14562. this.container.find('.calendar.left').show();
  14563. this.container.find('.calendar.right').hide();
  14564. this.container.find('.daterangepicker_input input, .daterangepicker_input > i').hide();
  14565. if (this.timePicker) {
  14566. this.container.find('.ranges ul').hide();
  14567. } else {
  14568. this.container.find('.ranges').hide();
  14569. }
  14570. }
  14571. if ((typeof options.ranges === 'undefined' && !this.singleDatePicker) || this.alwaysShowCalendars) {
  14572. this.container.addClass('show-calendar');
  14573. }
  14574. this.container.addClass('opens' + this.opens);
  14575. //swap the position of the predefined ranges if opens right
  14576. if (typeof options.ranges !== 'undefined' && this.opens == 'right') {
  14577. this.container.find('.ranges').prependTo( this.container.find('.calendar.left').parent() );
  14578. }
  14579. //apply CSS classes and labels to buttons
  14580. this.container.find('.applyBtn, .cancelBtn').addClass(this.buttonClasses);
  14581. if (this.applyClass.length)
  14582. this.container.find('.applyBtn').addClass(this.applyClass);
  14583. if (this.cancelClass.length)
  14584. this.container.find('.cancelBtn').addClass(this.cancelClass);
  14585. this.container.find('.applyBtn').html(this.locale.applyLabel);
  14586. this.container.find('.cancelBtn').html(this.locale.cancelLabel);
  14587. //
  14588. // event listeners
  14589. //
  14590. this.container.find('.calendar')
  14591. .on('click.daterangepicker', '.prev', $.proxy(this.clickPrev, this))
  14592. .on('click.daterangepicker', '.next', $.proxy(this.clickNext, this))
  14593. .on('mousedown.daterangepicker', 'td.available', $.proxy(this.clickDate, this))
  14594. .on('mouseenter.daterangepicker', 'td.available', $.proxy(this.hoverDate, this))
  14595. .on('mouseleave.daterangepicker', 'td.available', $.proxy(this.updateFormInputs, this))
  14596. .on('change.daterangepicker', 'select.yearselect', $.proxy(this.monthOrYearChanged, this))
  14597. .on('change.daterangepicker', 'select.monthselect', $.proxy(this.monthOrYearChanged, this))
  14598. .on('change.daterangepicker', 'select.hourselect,select.minuteselect,select.secondselect,select.ampmselect', $.proxy(this.timeChanged, this))
  14599. .on('click.daterangepicker', '.daterangepicker_input input', $.proxy(this.showCalendars, this))
  14600. .on('focus.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsFocused, this))
  14601. .on('blur.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsBlurred, this))
  14602. .on('change.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsChanged, this))
  14603. .on('keydown.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsKeydown, this));
  14604. this.container.find('.ranges')
  14605. .on('click.daterangepicker', 'button.applyBtn', $.proxy(this.clickApply, this))
  14606. .on('click.daterangepicker', 'button.cancelBtn', $.proxy(this.clickCancel, this))
  14607. .on('click.daterangepicker', 'li', $.proxy(this.clickRange, this))
  14608. .on('mouseenter.daterangepicker', 'li', $.proxy(this.hoverRange, this))
  14609. .on('mouseleave.daterangepicker', 'li', $.proxy(this.updateFormInputs, this));
  14610. if (this.element.is('input') || this.element.is('button')) {
  14611. this.element.on({
  14612. 'click.daterangepicker': $.proxy(this.show, this),
  14613. 'focus.daterangepicker': $.proxy(this.show, this),
  14614. 'keyup.daterangepicker': $.proxy(this.elementChanged, this),
  14615. 'keydown.daterangepicker': $.proxy(this.keydown, this) //IE 11 compatibility
  14616. });
  14617. } else {
  14618. this.element.on('click.daterangepicker', $.proxy(this.toggle, this));
  14619. this.element.on('keydown.daterangepicker', $.proxy(this.toggle, this));
  14620. }
  14621. //
  14622. // if attached to a text input, set the initial value
  14623. //
  14624. if (this.element.is('input') && !this.singleDatePicker && this.autoUpdateInput) {
  14625. this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
  14626. this.element.trigger('change');
  14627. } else if (this.element.is('input') && this.autoUpdateInput) {
  14628. this.element.val(this.startDate.format(this.locale.format));
  14629. this.element.trigger('change');
  14630. }
  14631. };
  14632. DateRangePicker.prototype = {
  14633. constructor: DateRangePicker,
  14634. setStartDate: function(startDate) {
  14635. if (typeof startDate === 'string')
  14636. this.startDate = moment(startDate, this.locale.format);
  14637. if (typeof startDate === 'object')
  14638. this.startDate = moment(startDate);
  14639. if (!this.timePicker)
  14640. this.startDate = this.startDate.startOf('day');
  14641. if (this.timePicker && this.timePickerIncrement)
  14642. this.startDate.minute(Math.round(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
  14643. if (this.minDate && this.startDate.isBefore(this.minDate)) {
  14644. this.startDate = this.minDate.clone();
  14645. if (this.timePicker && this.timePickerIncrement)
  14646. this.startDate.minute(Math.round(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
  14647. }
  14648. if (this.maxDate && this.startDate.isAfter(this.maxDate)) {
  14649. this.startDate = this.maxDate.clone();
  14650. if (this.timePicker && this.timePickerIncrement)
  14651. this.startDate.minute(Math.floor(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
  14652. }
  14653. if (!this.isShowing)
  14654. this.updateElement();
  14655. this.updateMonthsInView();
  14656. },
  14657. setEndDate: function(endDate) {
  14658. if (typeof endDate === 'string')
  14659. this.endDate = moment(endDate, this.locale.format);
  14660. if (typeof endDate === 'object')
  14661. this.endDate = moment(endDate);
  14662. if (!this.timePicker)
  14663. this.endDate = this.endDate.add(1,'d').startOf('day').subtract(1,'second');
  14664. if (this.timePicker && this.timePickerIncrement)
  14665. this.endDate.minute(Math.round(this.endDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
  14666. if (this.endDate.isBefore(this.startDate))
  14667. this.endDate = this.startDate.clone();
  14668. if (this.maxDate && this.endDate.isAfter(this.maxDate))
  14669. this.endDate = this.maxDate.clone();
  14670. if (this.dateLimit && this.startDate.clone().add(this.dateLimit).isBefore(this.endDate))
  14671. this.endDate = this.startDate.clone().add(this.dateLimit);
  14672. this.previousRightTime = this.endDate.clone();
  14673. if (!this.isShowing)
  14674. this.updateElement();
  14675. this.updateMonthsInView();
  14676. },
  14677. isInvalidDate: function() {
  14678. return false;
  14679. },
  14680. isCustomDate: function() {
  14681. return false;
  14682. },
  14683. updateView: function() {
  14684. if (this.timePicker) {
  14685. this.renderTimePicker('left');
  14686. this.renderTimePicker('right');
  14687. if (!this.endDate) {
  14688. this.container.find('.right .calendar-time select').attr('disabled', 'disabled').addClass('disabled');
  14689. } else {
  14690. this.container.find('.right .calendar-time select').removeAttr('disabled').removeClass('disabled');
  14691. }
  14692. }
  14693. if (this.endDate) {
  14694. this.container.find('input[name="daterangepicker_end"]').removeClass('active');
  14695. this.container.find('input[name="daterangepicker_start"]').addClass('active');
  14696. } else {
  14697. this.container.find('input[name="daterangepicker_end"]').addClass('active');
  14698. this.container.find('input[name="daterangepicker_start"]').removeClass('active');
  14699. }
  14700. this.updateMonthsInView();
  14701. this.updateCalendars();
  14702. this.updateFormInputs();
  14703. },
  14704. updateMonthsInView: function() {
  14705. if (this.endDate) {
  14706. //if both dates are visible already, do nothing
  14707. if (!this.singleDatePicker && this.leftCalendar.month && this.rightCalendar.month &&
  14708. (this.startDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.startDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM'))
  14709. &&
  14710. (this.endDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.endDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM'))
  14711. ) {
  14712. return;
  14713. }
  14714. this.leftCalendar.month = this.startDate.clone().date(2);
  14715. if (!this.linkedCalendars && (this.endDate.month() != this.startDate.month() || this.endDate.year() != this.startDate.year())) {
  14716. this.rightCalendar.month = this.endDate.clone().date(2);
  14717. } else {
  14718. this.rightCalendar.month = this.startDate.clone().date(2).add(1, 'month');
  14719. }
  14720. } else {
  14721. if (this.leftCalendar.month.format('YYYY-MM') != this.startDate.format('YYYY-MM') && this.rightCalendar.month.format('YYYY-MM') != this.startDate.format('YYYY-MM')) {
  14722. this.leftCalendar.month = this.startDate.clone().date(2);
  14723. this.rightCalendar.month = this.startDate.clone().date(2).add(1, 'month');
  14724. }
  14725. }
  14726. if (this.maxDate && this.linkedCalendars && !this.singleDatePicker && this.rightCalendar.month > this.maxDate) {
  14727. this.rightCalendar.month = this.maxDate.clone().date(2);
  14728. this.leftCalendar.month = this.maxDate.clone().date(2).subtract(1, 'month');
  14729. }
  14730. },
  14731. updateCalendars: function() {
  14732. if (this.timePicker) {
  14733. var hour, minute, second;
  14734. if (this.endDate) {
  14735. hour = parseInt(this.container.find('.left .hourselect').val(), 10);
  14736. minute = parseInt(this.container.find('.left .minuteselect').val(), 10);
  14737. second = this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10) : 0;
  14738. if (!this.timePicker24Hour) {
  14739. var ampm = this.container.find('.left .ampmselect').val();
  14740. if (ampm === 'PM' && hour < 12)
  14741. hour += 12;
  14742. if (ampm === 'AM' && hour === 12)
  14743. hour = 0;
  14744. }
  14745. } else {
  14746. hour = parseInt(this.container.find('.right .hourselect').val(), 10);
  14747. minute = parseInt(this.container.find('.right .minuteselect').val(), 10);
  14748. second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0;
  14749. if (!this.timePicker24Hour) {
  14750. var ampm = this.container.find('.right .ampmselect').val();
  14751. if (ampm === 'PM' && hour < 12)
  14752. hour += 12;
  14753. if (ampm === 'AM' && hour === 12)
  14754. hour = 0;
  14755. }
  14756. }
  14757. this.leftCalendar.month.hour(hour).minute(minute).second(second);
  14758. this.rightCalendar.month.hour(hour).minute(minute).second(second);
  14759. }
  14760. this.renderCalendar('left');
  14761. this.renderCalendar('right');
  14762. //highlight any predefined range matching the current start and end dates
  14763. this.container.find('.ranges li').removeClass('active');
  14764. if (this.endDate == null) return;
  14765. this.calculateChosenLabel();
  14766. },
  14767. renderCalendar: function(side) {
  14768. //
  14769. // Build the matrix of dates that will populate the calendar
  14770. //
  14771. var calendar = side == 'left' ? this.leftCalendar : this.rightCalendar;
  14772. var month = calendar.month.month();
  14773. var year = calendar.month.year();
  14774. var hour = calendar.month.hour();
  14775. var minute = calendar.month.minute();
  14776. var second = calendar.month.second();
  14777. var daysInMonth = moment([year, month]).daysInMonth();
  14778. var firstDay = moment([year, month, 1]);
  14779. var lastDay = moment([year, month, daysInMonth]);
  14780. var lastMonth = moment(firstDay).subtract(1, 'month').month();
  14781. var lastYear = moment(firstDay).subtract(1, 'month').year();
  14782. var daysInLastMonth = moment([lastYear, lastMonth]).daysInMonth();
  14783. var dayOfWeek = firstDay.day();
  14784. //initialize a 6 rows x 7 columns array for the calendar
  14785. var calendar = [];
  14786. calendar.firstDay = firstDay;
  14787. calendar.lastDay = lastDay;
  14788. for (var i = 0; i < 6; i++) {
  14789. calendar[i] = [];
  14790. }
  14791. //populate the calendar with date objects
  14792. var startDay = daysInLastMonth - dayOfWeek + this.locale.firstDay + 1;
  14793. if (startDay > daysInLastMonth)
  14794. startDay -= 7;
  14795. if (dayOfWeek == this.locale.firstDay)
  14796. startDay = daysInLastMonth - 6;
  14797. var curDate = moment([lastYear, lastMonth, startDay, 12, minute, second]);
  14798. var col, row;
  14799. for (var i = 0, col = 0, row = 0; i < 42; i++, col++, curDate = moment(curDate).add(24, 'hour')) {
  14800. if (i > 0 && col % 7 === 0) {
  14801. col = 0;
  14802. row++;
  14803. }
  14804. calendar[row][col] = curDate.clone().hour(hour).minute(minute).second(second);
  14805. curDate.hour(12);
  14806. if (this.minDate && calendar[row][col].format('YYYY-MM-DD') == this.minDate.format('YYYY-MM-DD') && calendar[row][col].isBefore(this.minDate) && side == 'left') {
  14807. calendar[row][col] = this.minDate.clone();
  14808. }
  14809. if (this.maxDate && calendar[row][col].format('YYYY-MM-DD') == this.maxDate.format('YYYY-MM-DD') && calendar[row][col].isAfter(this.maxDate) && side == 'right') {
  14810. calendar[row][col] = this.maxDate.clone();
  14811. }
  14812. }
  14813. //make the calendar object available to hoverDate/clickDate
  14814. if (side == 'left') {
  14815. this.leftCalendar.calendar = calendar;
  14816. } else {
  14817. this.rightCalendar.calendar = calendar;
  14818. }
  14819. //
  14820. // Display the calendar
  14821. //
  14822. var minDate = side == 'left' ? this.minDate : this.startDate;
  14823. var maxDate = this.maxDate;
  14824. var selected = side == 'left' ? this.startDate : this.endDate;
  14825. var arrow = this.locale.direction == 'ltr' ? {left: 'chevron-left', right: 'chevron-right'} : {left: 'chevron-right', right: 'chevron-left'};
  14826. var html = '<table class="table-condensed">';
  14827. html += '<thead>';
  14828. html += '<tr>';
  14829. // add empty cell for week number
  14830. if (this.showWeekNumbers || this.showISOWeekNumbers)
  14831. html += '<th></th>';
  14832. if ((!minDate || minDate.isBefore(calendar.firstDay)) && (!this.linkedCalendars || side == 'left')) {
  14833. html += '<th class="prev available"><i class="fa fa-' + arrow.left + ' glyphicon glyphicon-' + arrow.left + '"></i></th>';
  14834. } else {
  14835. html += '<th></th>';
  14836. }
  14837. var dateHtml = this.locale.monthNames[calendar[1][1].month()] + calendar[1][1].format(" YYYY");
  14838. if (this.showDropdowns) {
  14839. var currentMonth = calendar[1][1].month();
  14840. var currentYear = calendar[1][1].year();
  14841. var maxYear = (maxDate && maxDate.year()) || (currentYear + 5);
  14842. var minYear = (minDate && minDate.year()) || (currentYear - 50);
  14843. var inMinYear = currentYear == minYear;
  14844. var inMaxYear = currentYear == maxYear;
  14845. var monthHtml = '<select class="monthselect">';
  14846. for (var m = 0; m < 12; m++) {
  14847. if ((!inMinYear || m >= minDate.month()) && (!inMaxYear || m <= maxDate.month())) {
  14848. monthHtml += "<option value='" + m + "'" +
  14849. (m === currentMonth ? " selected='selected'" : "") +
  14850. ">" + this.locale.monthNames[m] + "</option>";
  14851. } else {
  14852. monthHtml += "<option value='" + m + "'" +
  14853. (m === currentMonth ? " selected='selected'" : "") +
  14854. " disabled='disabled'>" + this.locale.monthNames[m] + "</option>";
  14855. }
  14856. }
  14857. monthHtml += "</select>";
  14858. var yearHtml = '<select class="yearselect">';
  14859. for (var y = minYear; y <= maxYear; y++) {
  14860. yearHtml += '<option value="' + y + '"' +
  14861. (y === currentYear ? ' selected="selected"' : '') +
  14862. '>' + y + '</option>';
  14863. }
  14864. yearHtml += '</select>';
  14865. dateHtml = monthHtml + yearHtml;
  14866. }
  14867. html += '<th colspan="5" class="month">' + dateHtml + '</th>';
  14868. if ((!maxDate || maxDate.isAfter(calendar.lastDay)) && (!this.linkedCalendars || side == 'right' || this.singleDatePicker)) {
  14869. html += '<th class="next available"><i class="fa fa-' + arrow.right + ' glyphicon glyphicon-' + arrow.right + '"></i></th>';
  14870. } else {
  14871. html += '<th></th>';
  14872. }
  14873. html += '</tr>';
  14874. html += '<tr>';
  14875. // add week number label
  14876. if (this.showWeekNumbers || this.showISOWeekNumbers)
  14877. html += '<th class="week">' + this.locale.weekLabel + '</th>';
  14878. $.each(this.locale.daysOfWeek, function(index, dayOfWeek) {
  14879. html += '<th>' + dayOfWeek + '</th>';
  14880. });
  14881. html += '</tr>';
  14882. html += '</thead>';
  14883. html += '<tbody>';
  14884. //adjust maxDate to reflect the dateLimit setting in order to
  14885. //grey out end dates beyond the dateLimit
  14886. if (this.endDate == null && this.dateLimit) {
  14887. var maxLimit = this.startDate.clone().add(this.dateLimit).endOf('day');
  14888. if (!maxDate || maxLimit.isBefore(maxDate)) {
  14889. maxDate = maxLimit;
  14890. }
  14891. }
  14892. for (var row = 0; row < 6; row++) {
  14893. html += '<tr>';
  14894. // add week number
  14895. if (this.showWeekNumbers)
  14896. html += '<td class="week">' + calendar[row][0].week() + '</td>';
  14897. else if (this.showISOWeekNumbers)
  14898. html += '<td class="week">' + calendar[row][0].isoWeek() + '</td>';
  14899. for (var col = 0; col < 7; col++) {
  14900. var classes = [];
  14901. //highlight today's date
  14902. if (calendar[row][col].isSame(new Date(), "day"))
  14903. classes.push('today');
  14904. //highlight weekends
  14905. if (calendar[row][col].isoWeekday() > 5)
  14906. classes.push('weekend');
  14907. //grey out the dates in other months displayed at beginning and end of this calendar
  14908. if (calendar[row][col].month() != calendar[1][1].month())
  14909. classes.push('off');
  14910. //don't allow selection of dates before the minimum date
  14911. if (this.minDate && calendar[row][col].isBefore(this.minDate, 'day'))
  14912. classes.push('off', 'disabled');
  14913. //don't allow selection of dates after the maximum date
  14914. if (maxDate && calendar[row][col].isAfter(maxDate, 'day'))
  14915. classes.push('off', 'disabled');
  14916. //don't allow selection of date if a custom function decides it's invalid
  14917. if (this.isInvalidDate(calendar[row][col]))
  14918. classes.push('off', 'disabled');
  14919. //highlight the currently selected start date
  14920. if (calendar[row][col].format('YYYY-MM-DD') == this.startDate.format('YYYY-MM-DD'))
  14921. classes.push('active', 'start-date');
  14922. //highlight the currently selected end date
  14923. if (this.endDate != null && calendar[row][col].format('YYYY-MM-DD') == this.endDate.format('YYYY-MM-DD'))
  14924. classes.push('active', 'end-date');
  14925. //highlight dates in-between the selected dates
  14926. if (this.endDate != null && calendar[row][col] > this.startDate && calendar[row][col] < this.endDate)
  14927. classes.push('in-range');
  14928. //apply custom classes for this date
  14929. var isCustom = this.isCustomDate(calendar[row][col]);
  14930. if (isCustom !== false) {
  14931. if (typeof isCustom === 'string')
  14932. classes.push(isCustom);
  14933. else
  14934. Array.prototype.push.apply(classes, isCustom);
  14935. }
  14936. var cname = '', disabled = false;
  14937. for (var i = 0; i < classes.length; i++) {
  14938. cname += classes[i] + ' ';
  14939. if (classes[i] == 'disabled')
  14940. disabled = true;
  14941. }
  14942. if (!disabled)
  14943. cname += 'available';
  14944. html += '<td class="' + cname.replace(/^\s+|\s+$/g, '') + '" data-title="' + 'r' + row + 'c' + col + '">' + calendar[row][col].date() + '</td>';
  14945. }
  14946. html += '</tr>';
  14947. }
  14948. html += '</tbody>';
  14949. html += '</table>';
  14950. this.container.find('.calendar.' + side + ' .calendar-table').html(html);
  14951. },
  14952. renderTimePicker: function(side) {
  14953. // Don't bother updating the time picker if it's currently disabled
  14954. // because an end date hasn't been clicked yet
  14955. if (side == 'right' && !this.endDate) return;
  14956. var html, selected, minDate, maxDate = this.maxDate;
  14957. if (this.dateLimit && (!this.maxDate || this.startDate.clone().add(this.dateLimit).isAfter(this.maxDate)))
  14958. maxDate = this.startDate.clone().add(this.dateLimit);
  14959. if (side == 'left') {
  14960. selected = this.startDate.clone();
  14961. minDate = this.minDate;
  14962. } else if (side == 'right') {
  14963. selected = this.endDate.clone();
  14964. minDate = this.startDate;
  14965. //Preserve the time already selected
  14966. var timeSelector = this.container.find('.calendar.right .calendar-time div');
  14967. if (timeSelector.html() != '') {
  14968. selected.hour(timeSelector.find('.hourselect option:selected').val() || selected.hour());
  14969. selected.minute(timeSelector.find('.minuteselect option:selected').val() || selected.minute());
  14970. selected.second(timeSelector.find('.secondselect option:selected').val() || selected.second());
  14971. if (!this.timePicker24Hour) {
  14972. var ampm = timeSelector.find('.ampmselect option:selected').val();
  14973. if (ampm === 'PM' && selected.hour() < 12)
  14974. selected.hour(selected.hour() + 12);
  14975. if (ampm === 'AM' && selected.hour() === 12)
  14976. selected.hour(0);
  14977. }
  14978. }
  14979. if (selected.isBefore(this.startDate))
  14980. selected = this.startDate.clone();
  14981. if (maxDate && selected.isAfter(maxDate))
  14982. selected = maxDate.clone();
  14983. }
  14984. //
  14985. // hours
  14986. //
  14987. html = '<select class="hourselect">';
  14988. var start = this.timePicker24Hour ? 0 : 1;
  14989. var end = this.timePicker24Hour ? 23 : 12;
  14990. for (var i = start; i <= end; i++) {
  14991. var i_in_24 = i;
  14992. if (!this.timePicker24Hour)
  14993. i_in_24 = selected.hour() >= 12 ? (i == 12 ? 12 : i + 12) : (i == 12 ? 0 : i);
  14994. var time = selected.clone().hour(i_in_24);
  14995. var disabled = false;
  14996. if (minDate && time.minute(59).isBefore(minDate))
  14997. disabled = true;
  14998. if (maxDate && time.minute(0).isAfter(maxDate))
  14999. disabled = true;
  15000. if (i_in_24 == selected.hour() && !disabled) {
  15001. html += '<option value="' + i + '" selected="selected">' + i + '</option>';
  15002. } else if (disabled) {
  15003. html += '<option value="' + i + '" disabled="disabled" class="disabled">' + i + '</option>';
  15004. } else {
  15005. html += '<option value="' + i + '">' + i + '</option>';
  15006. }
  15007. }
  15008. html += '</select> ';
  15009. //
  15010. // minutes
  15011. //
  15012. html += ': <select class="minuteselect">';
  15013. for (var i = 0; i < 60; i += this.timePickerIncrement) {
  15014. var padded = i < 10 ? '0' + i : i;
  15015. var time = selected.clone().minute(i);
  15016. var disabled = false;
  15017. if (minDate && time.second(59).isBefore(minDate))
  15018. disabled = true;
  15019. if (maxDate && time.second(0).isAfter(maxDate))
  15020. disabled = true;
  15021. if (selected.minute() == i && !disabled) {
  15022. html += '<option value="' + i + '" selected="selected">' + padded + '</option>';
  15023. } else if (disabled) {
  15024. html += '<option value="' + i + '" disabled="disabled" class="disabled">' + padded + '</option>';
  15025. } else {
  15026. html += '<option value="' + i + '">' + padded + '</option>';
  15027. }
  15028. }
  15029. html += '</select> ';
  15030. //
  15031. // seconds
  15032. //
  15033. if (this.timePickerSeconds) {
  15034. html += ': <select class="secondselect">';
  15035. for (var i = 0; i < 60; i++) {
  15036. var padded = i < 10 ? '0' + i : i;
  15037. var time = selected.clone().second(i);
  15038. var disabled = false;
  15039. if (minDate && time.isBefore(minDate))
  15040. disabled = true;
  15041. if (maxDate && time.isAfter(maxDate))
  15042. disabled = true;
  15043. if (selected.second() == i && !disabled) {
  15044. html += '<option value="' + i + '" selected="selected">' + padded + '</option>';
  15045. } else if (disabled) {
  15046. html += '<option value="' + i + '" disabled="disabled" class="disabled">' + padded + '</option>';
  15047. } else {
  15048. html += '<option value="' + i + '">' + padded + '</option>';
  15049. }
  15050. }
  15051. html += '</select> ';
  15052. }
  15053. //
  15054. // AM/PM
  15055. //
  15056. if (!this.timePicker24Hour) {
  15057. html += '<select class="ampmselect">';
  15058. var am_html = '';
  15059. var pm_html = '';
  15060. if (minDate && selected.clone().hour(12).minute(0).second(0).isBefore(minDate))
  15061. am_html = ' disabled="disabled" class="disabled"';
  15062. if (maxDate && selected.clone().hour(0).minute(0).second(0).isAfter(maxDate))
  15063. pm_html = ' disabled="disabled" class="disabled"';
  15064. if (selected.hour() >= 12) {
  15065. html += '<option value="AM"' + am_html + '>AM</option><option value="PM" selected="selected"' + pm_html + '>PM</option>';
  15066. } else {
  15067. html += '<option value="AM" selected="selected"' + am_html + '>AM</option><option value="PM"' + pm_html + '>PM</option>';
  15068. }
  15069. html += '</select>';
  15070. }
  15071. this.container.find('.calendar.' + side + ' .calendar-time div').html(html);
  15072. },
  15073. updateFormInputs: function() {
  15074. //ignore mouse movements while an above-calendar text input has focus
  15075. if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus"))
  15076. return;
  15077. this.container.find('input[name=daterangepicker_start]').val(this.startDate.format(this.locale.format));
  15078. if (this.endDate)
  15079. this.container.find('input[name=daterangepicker_end]').val(this.endDate.format(this.locale.format));
  15080. if (this.singleDatePicker || (this.endDate && (this.startDate.isBefore(this.endDate) || this.startDate.isSame(this.endDate)))) {
  15081. this.container.find('button.applyBtn').removeAttr('disabled');
  15082. } else {
  15083. this.container.find('button.applyBtn').attr('disabled', 'disabled');
  15084. }
  15085. },
  15086. move: function() {
  15087. var parentOffset = { top: 0, left: 0 },
  15088. containerTop;
  15089. var parentRightEdge = $(window).width();
  15090. if (!this.parentEl.is('body')) {
  15091. parentOffset = {
  15092. top: this.parentEl.offset().top - this.parentEl.scrollTop(),
  15093. left: this.parentEl.offset().left - this.parentEl.scrollLeft()
  15094. };
  15095. parentRightEdge = this.parentEl[0].clientWidth + this.parentEl.offset().left;
  15096. }
  15097. if (this.drops == 'up')
  15098. containerTop = this.element.offset().top - this.container.outerHeight() - parentOffset.top;
  15099. else
  15100. containerTop = this.element.offset().top + this.element.outerHeight() - parentOffset.top;
  15101. this.container[this.drops == 'up' ? 'addClass' : 'removeClass']('dropup');
  15102. if (this.opens == 'left') {
  15103. this.container.css({
  15104. top: containerTop,
  15105. right: parentRightEdge - this.element.offset().left - this.element.outerWidth(),
  15106. left: 'auto'
  15107. });
  15108. if (this.container.offset().left < 0) {
  15109. this.container.css({
  15110. right: 'auto',
  15111. left: 9
  15112. });
  15113. }
  15114. } else if (this.opens == 'center') {
  15115. this.container.css({
  15116. top: containerTop,
  15117. left: this.element.offset().left - parentOffset.left + this.element.outerWidth() / 2
  15118. - this.container.outerWidth() / 2,
  15119. right: 'auto'
  15120. });
  15121. if (this.container.offset().left < 0) {
  15122. this.container.css({
  15123. right: 'auto',
  15124. left: 9
  15125. });
  15126. }
  15127. } else {
  15128. this.container.css({
  15129. top: containerTop,
  15130. left: this.element.offset().left - parentOffset.left,
  15131. right: 'auto'
  15132. });
  15133. if (this.container.offset().left + this.container.outerWidth() > $(window).width()) {
  15134. this.container.css({
  15135. left: 'auto',
  15136. right: 0
  15137. });
  15138. }
  15139. }
  15140. },
  15141. show: function(e) {
  15142. if (this.isShowing) return;
  15143. // Create a click proxy that is private to this instance of datepicker, for unbinding
  15144. this._outsideClickProxy = $.proxy(function(e) { this.outsideClick(e); }, this);
  15145. // Bind global datepicker mousedown for hiding and
  15146. $(document)
  15147. .on('mousedown.daterangepicker', this._outsideClickProxy)
  15148. // also support mobile devices
  15149. .on('touchend.daterangepicker', this._outsideClickProxy)
  15150. // also explicitly play nice with Bootstrap dropdowns, which stopPropagation when clicking them
  15151. .on('click.daterangepicker', '[data-toggle=dropdown]', this._outsideClickProxy)
  15152. // and also close when focus changes to outside the picker (eg. tabbing between controls)
  15153. .on('focusin.daterangepicker', this._outsideClickProxy);
  15154. // Reposition the picker if the window is resized while it's open
  15155. $(window).on('resize.daterangepicker', $.proxy(function(e) { this.move(e); }, this));
  15156. this.oldStartDate = this.startDate.clone();
  15157. this.oldEndDate = this.endDate.clone();
  15158. this.previousRightTime = this.endDate.clone();
  15159. this.updateView();
  15160. this.container.show();
  15161. this.move();
  15162. this.element.trigger('show.daterangepicker', this);
  15163. this.isShowing = true;
  15164. },
  15165. hide: function(e) {
  15166. if (!this.isShowing) return;
  15167. //incomplete date selection, revert to last values
  15168. if (!this.endDate) {
  15169. this.startDate = this.oldStartDate.clone();
  15170. this.endDate = this.oldEndDate.clone();
  15171. }
  15172. //if a new date range was selected, invoke the user callback function
  15173. if (!this.startDate.isSame(this.oldStartDate) || !this.endDate.isSame(this.oldEndDate))
  15174. this.callback(this.startDate, this.endDate, this.chosenLabel);
  15175. //if picker is attached to a text input, update it
  15176. this.updateElement();
  15177. $(document).off('.daterangepicker');
  15178. $(window).off('.daterangepicker');
  15179. this.container.hide();
  15180. this.element.trigger('hide.daterangepicker', this);
  15181. this.isShowing = false;
  15182. },
  15183. toggle: function(e) {
  15184. if (this.isShowing) {
  15185. this.hide();
  15186. } else {
  15187. this.show();
  15188. }
  15189. },
  15190. outsideClick: function(e) {
  15191. var target = $(e.target);
  15192. // if the page is clicked anywhere except within the daterangerpicker/button
  15193. // itself then call this.hide()
  15194. if (
  15195. // ie modal dialog fix
  15196. e.type == "focusin" ||
  15197. target.closest(this.element).length ||
  15198. target.closest(this.container).length ||
  15199. target.closest('.calendar-table').length
  15200. ) return;
  15201. this.hide();
  15202. this.element.trigger('outsideClick.daterangepicker', this);
  15203. },
  15204. showCalendars: function() {
  15205. this.container.addClass('show-calendar');
  15206. this.move();
  15207. this.element.trigger('showCalendar.daterangepicker', this);
  15208. },
  15209. hideCalendars: function() {
  15210. this.container.removeClass('show-calendar');
  15211. this.element.trigger('hideCalendar.daterangepicker', this);
  15212. },
  15213. hoverRange: function(e) {
  15214. //ignore mouse movements while an above-calendar text input has focus
  15215. if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus"))
  15216. return;
  15217. var label = e.target.getAttribute('data-range-key');
  15218. if (label == this.locale.customRangeLabel) {
  15219. this.updateView();
  15220. } else {
  15221. var dates = this.ranges[label];
  15222. this.container.find('input[name=daterangepicker_start]').val(dates[0].format(this.locale.format));
  15223. this.container.find('input[name=daterangepicker_end]').val(dates[1].format(this.locale.format));
  15224. }
  15225. },
  15226. clickRange: function(e) {
  15227. var label = e.target.getAttribute('data-range-key');
  15228. this.chosenLabel = label;
  15229. if (label == this.locale.customRangeLabel) {
  15230. this.showCalendars();
  15231. } else {
  15232. var dates = this.ranges[label];
  15233. this.startDate = dates[0];
  15234. this.endDate = dates[1];
  15235. if (!this.timePicker) {
  15236. this.startDate.startOf('day');
  15237. this.endDate.endOf('day');
  15238. }
  15239. if (!this.alwaysShowCalendars)
  15240. this.hideCalendars();
  15241. this.clickApply();
  15242. }
  15243. },
  15244. clickPrev: function(e) {
  15245. var cal = $(e.target).parents('.calendar');
  15246. if (cal.hasClass('left')) {
  15247. this.leftCalendar.month.subtract(1, 'month');
  15248. if (this.linkedCalendars)
  15249. this.rightCalendar.month.subtract(1, 'month');
  15250. } else {
  15251. this.rightCalendar.month.subtract(1, 'month');
  15252. }
  15253. this.updateCalendars();
  15254. },
  15255. clickNext: function(e) {
  15256. var cal = $(e.target).parents('.calendar');
  15257. if (cal.hasClass('left')) {
  15258. this.leftCalendar.month.add(1, 'month');
  15259. } else {
  15260. this.rightCalendar.month.add(1, 'month');
  15261. if (this.linkedCalendars)
  15262. this.leftCalendar.month.add(1, 'month');
  15263. }
  15264. this.updateCalendars();
  15265. },
  15266. hoverDate: function(e) {
  15267. //ignore mouse movements while an above-calendar text input has focus
  15268. //if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus"))
  15269. // return;
  15270. //ignore dates that can't be selected
  15271. if (!$(e.target).hasClass('available')) return;
  15272. //have the text inputs above calendars reflect the date being hovered over
  15273. var title = $(e.target).attr('data-title');
  15274. var row = title.substr(1, 1);
  15275. var col = title.substr(3, 1);
  15276. var cal = $(e.target).parents('.calendar');
  15277. var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col];
  15278. if (this.endDate && !this.container.find('input[name=daterangepicker_start]').is(":focus")) {
  15279. this.container.find('input[name=daterangepicker_start]').val(date.format(this.locale.format));
  15280. } else if (!this.endDate && !this.container.find('input[name=daterangepicker_end]').is(":focus")) {
  15281. this.container.find('input[name=daterangepicker_end]').val(date.format(this.locale.format));
  15282. }
  15283. //highlight the dates between the start date and the date being hovered as a potential end date
  15284. var leftCalendar = this.leftCalendar;
  15285. var rightCalendar = this.rightCalendar;
  15286. var startDate = this.startDate;
  15287. if (!this.endDate) {
  15288. this.container.find('.calendar tbody td').each(function(index, el) {
  15289. //skip week numbers, only look at dates
  15290. if ($(el).hasClass('week')) return;
  15291. var title = $(el).attr('data-title');
  15292. var row = title.substr(1, 1);
  15293. var col = title.substr(3, 1);
  15294. var cal = $(el).parents('.calendar');
  15295. var dt = cal.hasClass('left') ? leftCalendar.calendar[row][col] : rightCalendar.calendar[row][col];
  15296. if ((dt.isAfter(startDate) && dt.isBefore(date)) || dt.isSame(date, 'day')) {
  15297. $(el).addClass('in-range');
  15298. } else {
  15299. $(el).removeClass('in-range');
  15300. }
  15301. });
  15302. }
  15303. },
  15304. clickDate: function(e) {
  15305. if (!$(e.target).hasClass('available')) return;
  15306. var title = $(e.target).attr('data-title');
  15307. var row = title.substr(1, 1);
  15308. var col = title.substr(3, 1);
  15309. var cal = $(e.target).parents('.calendar');
  15310. var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col];
  15311. //
  15312. // this function needs to do a few things:
  15313. // * alternate between selecting a start and end date for the range,
  15314. // * if the time picker is enabled, apply the hour/minute/second from the select boxes to the clicked date
  15315. // * if autoapply is enabled, and an end date was chosen, apply the selection
  15316. // * if single date picker mode, and time picker isn't enabled, apply the selection immediately
  15317. // * if one of the inputs above the calendars was focused, cancel that manual input
  15318. //
  15319. if (this.endDate || date.isBefore(this.startDate, 'day')) { //picking start
  15320. if (this.timePicker) {
  15321. var hour = parseInt(this.container.find('.left .hourselect').val(), 10);
  15322. if (!this.timePicker24Hour) {
  15323. var ampm = this.container.find('.left .ampmselect').val();
  15324. if (ampm === 'PM' && hour < 12)
  15325. hour += 12;
  15326. if (ampm === 'AM' && hour === 12)
  15327. hour = 0;
  15328. }
  15329. var minute = parseInt(this.container.find('.left .minuteselect').val(), 10);
  15330. var second = this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10) : 0;
  15331. date = date.clone().hour(hour).minute(minute).second(second);
  15332. }
  15333. this.endDate = null;
  15334. this.setStartDate(date.clone());
  15335. } else if (!this.endDate && date.isBefore(this.startDate)) {
  15336. //special case: clicking the same date for start/end,
  15337. //but the time of the end date is before the start date
  15338. this.setEndDate(this.startDate.clone());
  15339. } else { // picking end
  15340. if (this.timePicker) {
  15341. var hour = parseInt(this.container.find('.right .hourselect').val(), 10);
  15342. if (!this.timePicker24Hour) {
  15343. var ampm = this.container.find('.right .ampmselect').val();
  15344. if (ampm === 'PM' && hour < 12)
  15345. hour += 12;
  15346. if (ampm === 'AM' && hour === 12)
  15347. hour = 0;
  15348. }
  15349. var minute = parseInt(this.container.find('.right .minuteselect').val(), 10);
  15350. var second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0;
  15351. date = date.clone().hour(hour).minute(minute).second(second);
  15352. }
  15353. this.setEndDate(date.clone());
  15354. if (this.autoApply) {
  15355. this.calculateChosenLabel();
  15356. this.clickApply();
  15357. }
  15358. }
  15359. if (this.singleDatePicker) {
  15360. this.setEndDate(this.startDate);
  15361. if (!this.timePicker)
  15362. this.clickApply();
  15363. }
  15364. this.updateView();
  15365. //This is to cancel the blur event handler if the mouse was in one of the inputs
  15366. e.stopPropagation();
  15367. },
  15368. calculateChosenLabel: function () {
  15369. var customRange = true;
  15370. var i = 0;
  15371. for (var range in this.ranges) {
  15372. if (this.timePicker) {
  15373. var format = this.timePickerSeconds ? "YYYY-MM-DD hh:mm:ss" : "YYYY-MM-DD hh:mm";
  15374. //ignore times when comparing dates if time picker seconds is not enabled
  15375. if (this.startDate.format(format) == this.ranges[range][0].format(format) && this.endDate.format(format) == this.ranges[range][1].format(format)) {
  15376. customRange = false;
  15377. this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').html();
  15378. break;
  15379. }
  15380. } else {
  15381. //ignore times when comparing dates if time picker is not enabled
  15382. 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')) {
  15383. customRange = false;
  15384. this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').html();
  15385. break;
  15386. }
  15387. }
  15388. i++;
  15389. }
  15390. if (customRange) {
  15391. if (this.showCustomRangeLabel) {
  15392. this.chosenLabel = this.container.find('.ranges li:last').addClass('active').html();
  15393. } else {
  15394. this.chosenLabel = null;
  15395. }
  15396. this.showCalendars();
  15397. }
  15398. },
  15399. clickApply: function(e) {
  15400. this.hide();
  15401. this.element.trigger('apply.daterangepicker', this);
  15402. },
  15403. clickCancel: function(e) {
  15404. this.startDate = this.oldStartDate;
  15405. this.endDate = this.oldEndDate;
  15406. this.hide();
  15407. this.element.trigger('cancel.daterangepicker', this);
  15408. },
  15409. monthOrYearChanged: function(e) {
  15410. var isLeft = $(e.target).closest('.calendar').hasClass('left'),
  15411. leftOrRight = isLeft ? 'left' : 'right',
  15412. cal = this.container.find('.calendar.'+leftOrRight);
  15413. // Month must be Number for new moment versions
  15414. var month = parseInt(cal.find('.monthselect').val(), 10);
  15415. var year = cal.find('.yearselect').val();
  15416. if (!isLeft) {
  15417. if (year < this.startDate.year() || (year == this.startDate.year() && month < this.startDate.month())) {
  15418. month = this.startDate.month();
  15419. year = this.startDate.year();
  15420. }
  15421. }
  15422. if (this.minDate) {
  15423. if (year < this.minDate.year() || (year == this.minDate.year() && month < this.minDate.month())) {
  15424. month = this.minDate.month();
  15425. year = this.minDate.year();
  15426. }
  15427. }
  15428. if (this.maxDate) {
  15429. if (year > this.maxDate.year() || (year == this.maxDate.year() && month > this.maxDate.month())) {
  15430. month = this.maxDate.month();
  15431. year = this.maxDate.year();
  15432. }
  15433. }
  15434. if (isLeft) {
  15435. this.leftCalendar.month.month(month).year(year);
  15436. if (this.linkedCalendars)
  15437. this.rightCalendar.month = this.leftCalendar.month.clone().add(1, 'month');
  15438. } else {
  15439. this.rightCalendar.month.month(month).year(year);
  15440. if (this.linkedCalendars)
  15441. this.leftCalendar.month = this.rightCalendar.month.clone().subtract(1, 'month');
  15442. }
  15443. this.updateCalendars();
  15444. },
  15445. timeChanged: function(e) {
  15446. var cal = $(e.target).closest('.calendar'),
  15447. isLeft = cal.hasClass('left');
  15448. var hour = parseInt(cal.find('.hourselect').val(), 10);
  15449. var minute = parseInt(cal.find('.minuteselect').val(), 10);
  15450. var second = this.timePickerSeconds ? parseInt(cal.find('.secondselect').val(), 10) : 0;
  15451. if (!this.timePicker24Hour) {
  15452. var ampm = cal.find('.ampmselect').val();
  15453. if (ampm === 'PM' && hour < 12)
  15454. hour += 12;
  15455. if (ampm === 'AM' && hour === 12)
  15456. hour = 0;
  15457. }
  15458. if (isLeft) {
  15459. var start = this.startDate.clone();
  15460. start.hour(hour);
  15461. start.minute(minute);
  15462. start.second(second);
  15463. this.setStartDate(start);
  15464. if (this.singleDatePicker) {
  15465. this.endDate = this.startDate.clone();
  15466. } else if (this.endDate && this.endDate.format('YYYY-MM-DD') == start.format('YYYY-MM-DD') && this.endDate.isBefore(start)) {
  15467. this.setEndDate(start.clone());
  15468. }
  15469. } else if (this.endDate) {
  15470. var end = this.endDate.clone();
  15471. end.hour(hour);
  15472. end.minute(minute);
  15473. end.second(second);
  15474. this.setEndDate(end);
  15475. }
  15476. //update the calendars so all clickable dates reflect the new time component
  15477. this.updateCalendars();
  15478. //update the form inputs above the calendars with the new time
  15479. this.updateFormInputs();
  15480. //re-render the time pickers because changing one selection can affect what's enabled in another
  15481. this.renderTimePicker('left');
  15482. this.renderTimePicker('right');
  15483. },
  15484. formInputsChanged: function(e) {
  15485. var isRight = $(e.target).closest('.calendar').hasClass('right');
  15486. var start = moment(this.container.find('input[name="daterangepicker_start"]').val(), this.locale.format);
  15487. var end = moment(this.container.find('input[name="daterangepicker_end"]').val(), this.locale.format);
  15488. if (start.isValid() && end.isValid()) {
  15489. if (isRight && end.isBefore(start))
  15490. start = end.clone();
  15491. this.setStartDate(start);
  15492. this.setEndDate(end);
  15493. if (isRight) {
  15494. this.container.find('input[name="daterangepicker_start"]').val(this.startDate.format(this.locale.format));
  15495. } else {
  15496. this.container.find('input[name="daterangepicker_end"]').val(this.endDate.format(this.locale.format));
  15497. }
  15498. }
  15499. this.updateView();
  15500. },
  15501. formInputsFocused: function(e) {
  15502. // Highlight the focused input
  15503. this.container.find('input[name="daterangepicker_start"], input[name="daterangepicker_end"]').removeClass('active');
  15504. $(e.target).addClass('active');
  15505. // Set the state such that if the user goes back to using a mouse,
  15506. // the calendars are aware we're selecting the end of the range, not
  15507. // the start. This allows someone to edit the end of a date range without
  15508. // re-selecting the beginning, by clicking on the end date input then
  15509. // using the calendar.
  15510. var isRight = $(e.target).closest('.calendar').hasClass('right');
  15511. if (isRight) {
  15512. this.endDate = null;
  15513. this.setStartDate(this.startDate.clone());
  15514. this.updateView();
  15515. }
  15516. },
  15517. formInputsBlurred: function(e) {
  15518. // this function has one purpose right now: if you tab from the first
  15519. // text input to the second in the UI, the endDate is nulled so that
  15520. // you can click another, but if you tab out without clicking anything
  15521. // or changing the input value, the old endDate should be retained
  15522. if (!this.endDate) {
  15523. var val = this.container.find('input[name="daterangepicker_end"]').val();
  15524. var end = moment(val, this.locale.format);
  15525. if (end.isValid()) {
  15526. this.setEndDate(end);
  15527. this.updateView();
  15528. }
  15529. }
  15530. },
  15531. formInputsKeydown: function(e) {
  15532. // This function ensures that if the 'enter' key was pressed in the input, then the calendars
  15533. // are updated with the startDate and endDate.
  15534. // This behaviour is automatic in Chrome/Firefox/Edge but not in IE 11 hence why this exists.
  15535. // Other browsers and versions of IE are untested and the behaviour is unknown.
  15536. if (e.keyCode === 13) {
  15537. // Prevent the calendar from being updated twice on Chrome/Firefox/Edge
  15538. e.preventDefault();
  15539. this.formInputsChanged(e);
  15540. }
  15541. },
  15542. elementChanged: function() {
  15543. if (!this.element.is('input')) return;
  15544. if (!this.element.val().length) return;
  15545. var dateString = this.element.val().split(this.locale.separator),
  15546. start = null,
  15547. end = null;
  15548. if (dateString.length === 2) {
  15549. start = moment(dateString[0], this.locale.format);
  15550. end = moment(dateString[1], this.locale.format);
  15551. }
  15552. if (this.singleDatePicker || start === null || end === null) {
  15553. start = moment(this.element.val(), this.locale.format);
  15554. end = start;
  15555. }
  15556. if (!start.isValid() || !end.isValid()) return;
  15557. this.setStartDate(start);
  15558. this.setEndDate(end);
  15559. this.updateView();
  15560. },
  15561. keydown: function(e) {
  15562. //hide on tab or enter
  15563. if ((e.keyCode === 9) || (e.keyCode === 13)) {
  15564. this.hide();
  15565. }
  15566. //hide on esc and prevent propagation
  15567. if (e.keyCode === 27) {
  15568. e.preventDefault();
  15569. e.stopPropagation();
  15570. this.hide();
  15571. }
  15572. },
  15573. updateElement: function() {
  15574. if (this.element.is('input') && !this.singleDatePicker && this.autoUpdateInput) {
  15575. this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
  15576. this.element.trigger('change');
  15577. } else if (this.element.is('input') && this.autoUpdateInput) {
  15578. this.element.val(this.startDate.format(this.locale.format));
  15579. this.element.trigger('change');
  15580. }
  15581. },
  15582. remove: function() {
  15583. this.container.remove();
  15584. this.element.off('.daterangepicker');
  15585. this.element.removeData();
  15586. }
  15587. };
  15588. $.fn.daterangepicker = function(options, callback) {
  15589. var implementOptions = $.extend(true, {}, $.fn.daterangepicker.defaultOptions, options);
  15590. this.each(function() {
  15591. var el = $(this);
  15592. if (el.data('daterangepicker'))
  15593. el.data('daterangepicker').remove();
  15594. el.data('daterangepicker', new DateRangePicker(el, implementOptions, callback));
  15595. });
  15596. return this;
  15597. };
  15598. return DateRangePicker;
  15599. }));