require-backend.min.js 943 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350
  1. /*! jQuery v3.6.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(C,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,y=n.hasOwnProperty,a=y.toString,l=a.call(Object),v={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},x=function(e){return null!=e&&e===e.window},E=C.document,c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.6.1",S=function(e,t){return new S.fn.init(e,t)};function p(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0<t&&t-1 in e)}S.fn=S.prototype={jquery:f,constructor:S,length:0,toArray:function(){return s.call(this)},get:function(e){return null==e?s.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=S.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return S.each(this,e)},map:function(n){return this.pushStack(S.map(this,function(e,t){return n.call(e,t,e)}))},slice:function(){return this.pushStack(s.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(S.grep(this,function(e,t){return(t+1)%2}))},odd:function(){return this.pushStack(S.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:u,sort:t.sort,splice:t.splice},S.extend=S.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||m(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&&(S.isPlainObject(r)||(i=Array.isArray(r)))?(n=a[t],o=i&&!Array.isArray(n)?[]:i||S.isPlainObject(n)?n:{},i=!1,a[t]=S.extend(l,o,r)):void 0!==r&&(a[t]=r));return a},S.extend({expando:"jQuery"+(f+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]"!==o.call(e))&&(!(t=r(e))||"function"==typeof(n=y.call(t,"constructor")&&t.constructor)&&a.call(n)===l)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},globalEval:function(e,t,n){b(e,{nonce:t&&t.nonce},n)},each:function(e,t){var n,r=0;if(p(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},makeArray:function(e,t){var n=t||[];return null!=e&&(p(Object(e))?S.merge(n,"string"==typeof e?[e]:e):u.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:i.call(t,e,n)},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(p(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:v}),"function"==typeof Symbol&&(S.fn[Symbol.iterator]=t[Symbol.iterator]),S.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){n["[object "+t+"]"]=t.toLowerCase()});var d=function(n){var e,d,b,o,i,h,f,g,w,u,l,T,C,a,E,y,s,c,v,S="sizzle"+1*new Date,p=n.document,k=0,r=0,m=ue(),x=ue(),A=ue(),N=ue(),j=function(e,t){return e===t&&(l=!0),0},D={}.hasOwnProperty,t=[],q=t.pop,L=t.push,H=t.push,O=t.slice,P=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},R="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",I="(?:\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",W="\\["+M+"*("+I+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+I+"))|)"+M+"*\\]",F=":("+I+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+W+")*)|.*)\\)|)",$=new RegExp(M+"+","g"),B=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),_=new RegExp("^"+M+"*,"+M+"*"),z=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp(F),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\([^\\r\\n\\f])","g"),ne=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))},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(p.childNodes),p.childNodes),t[p.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(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&&(T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&v(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!N[t+" "]&&(!y||!y.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&(U.test(t)||z.test(t))){(f=ee.test(t)&&ve(e.parentNode)||e)===e&&d.scope||((s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=S)),o=(l=h(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+xe(l[o]);c=l.join(",")}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){N(t,!0)}finally{s===S&&e.removeAttribute("id")}}}return g(t.replace(B,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[S]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(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&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ye(a){return le(function(o){return o=+o,le(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 ve(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e&&e.namespaceURI,n=e&&(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:p;return r!=C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),p!=C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.scope=ce(function(e){return a.appendChild(e).appendChild(C.createElement("div")),"undefined"!=typeof e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length}),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=S,!C.getElementsByName||!C.getElementsByName(S).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);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&&E){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=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],y=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){var t;a.appendChild(e).innerHTML="<a id='"+S+"'></a><select id='"+S+"-\r\\' msallowcapture=''><option selected=''></option></select>",e.querySelectorAll("[msallowcapture^='']").length&&y.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||y.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+S+"-]").length||y.push("~="),(t=C.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||y.push("\\["+M+"*name"+M+"*="+M+"*(?:''|\"\")"),e.querySelectorAll(":checked").length||y.push(":checked"),e.querySelectorAll("a#"+S+"+*").length||y.push(".#.+[+~]"),e.querySelectorAll("\\\f"),y.push("[\\r\\n\\f]")}),ce(function(e){e.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&y.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&y.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&y.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),y.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",F)}),y=y.length&&new RegExp(y.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),v=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},j=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e==C||e.ownerDocument==p&&v(p,e)?-1:t==C||t.ownerDocument==p&&v(p,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e==C?-1:t==C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]==p?-1:s[r]==p?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if(T(e),d.matchesSelector&&E&&!N[t+" "]&&(!s||!s.test(t))&&(!y||!y.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){N(t,!0)}return 0<se(t,C,null,[e]).length},se.contains=function(e,t){return(e.ownerDocument||e)!=C&&T(e),v(e,t)},se.attr=function(e,t){(e.ownerDocument||e)!=C&&T(e);var n=b.attrHandle[t.toLowerCase()],r=n&&D.call(b.attrHandle,t.toLowerCase())?n(e,t,!E):void 0;return void 0!==r?r:d.attributes||!E?e.getAttribute(t):(r=e.getAttributeNode(t))&&r.specified?r.value:null},se.escape=function(e){return(e+"").replace(re,ie)},se.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},se.uniqueSort=function(e){var t,n=[],r=0,i=0;if(l=!d.detectDuplicates,u=!d.sortStable&&e.slice(0),e.sort(j),l){while(t=e[i++])t===e[i]&&(r=n.push(i));while(r--)e.splice(n[r],1)}return u=null,e},o=se.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=o(e)}else if(3===i||4===i)return e.nodeValue}else while(t=e[r++])n+=o(t);return n},(b=se.selectors={cacheLength:50,createPseudo:le,match:G,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(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===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]||se.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]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(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(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=m[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&m(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=se.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($," ")+" ").indexOf(i):"|="===r&&(t===i||t.slice(0,i.length+1)===i+"-"))}},CHILD:function(h,e,t,g,y){var v="nth"!==h.slice(0,3),m="last"!==h.slice(-4),x="of-type"===e;return 1===g&&0===y?function(e){return!!e.parentNode}:function(e,t,n){var r,i,o,a,s,u,l=v!==m?"nextSibling":"previousSibling",c=e.parentNode,f=x&&e.nodeName.toLowerCase(),p=!n&&!x,d=!1;if(c){if(v){while(l){a=e;while(a=a[l])if(x?a.nodeName.toLowerCase()===f:1===a.nodeType)return!1;u=l="only"===h&&!u&&"nextSibling"}return!0}if(u=[m?c.firstChild:c.lastChild],m&&p){d=(s=(r=(i=(o=(a=c)[S]||(a[S]={}))[a.uniqueID]||(o[a.uniqueID]={}))[h]||[])[0]===k&&r[1])&&r[2],a=s&&c.childNodes[s];while(a=++s&&a&&a[l]||(d=s=0)||u.pop())if(1===a.nodeType&&++d&&a===e){i[h]=[k,s,d];break}}else if(p&&(d=s=(r=(i=(o=(a=e)[S]||(a[S]={}))[a.uniqueID]||(o[a.uniqueID]={}))[h]||[])[0]===k&&r[1]),!1===d)while(a=++s&&a&&a[l]||(d=s=0)||u.pop())if((x?a.nodeName.toLowerCase()===f:1===a.nodeType)&&++d&&(p&&((i=(o=a[S]||(a[S]={}))[a.uniqueID]||(o[a.uniqueID]={}))[h]=[k,d]),a===e))break;return(d-=y)===g||d%g==0&&0<=d/g}}},PSEUDO:function(e,o){var t,a=b.pseudos[e]||b.setFilters[e.toLowerCase()]||se.error("unsupported pseudo: "+e);return a[S]?a(o):1<a.length?(t=[e,e,"",o],b.setFilters.hasOwnProperty(e.toLowerCase())?le(function(e,t){var n,r=a(e,o),i=r.length;while(i--)e[n=P(e,r[i])]=!(t[n]=r[i])}):function(e){return a(e,0,t)}):a}},pseudos:{not:le(function(e){var r=[],i=[],s=f(e.replace(B,"$1"));return s[S]?le(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:le(function(t){return function(e){return 0<se(t,e).length}}),contains:le(function(t){return t=t.replace(te,ne),function(e){return-1<(e.textContent||o(e)).indexOf(t)}}),lang:le(function(n){return V.test(n||"")||se.error("unsupported lang: "+n),n=n.replace(te,ne).toLowerCase(),function(e){var t;do{if(t=E?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=n.location&&n.location.hash;return t&&t.slice(1)===e.id},root:function(e){return e===a},focus:function(e){return e===C.activeElement&&(!C.hasFocus||C.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:ge(!1),disabled:ge(!0),checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!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 J.test(e.nodeName)},input:function(e){return Q.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:ye(function(){return[0]}),last:ye(function(e,t){return[t-1]}),eq:ye(function(e,t,n){return[n<0?n+t:n]}),even:ye(function(e,t){for(var n=0;n<t;n+=2)e.push(n);return e}),odd:ye(function(e,t){for(var n=1;n<t;n+=2)e.push(n);return e}),lt:ye(function(e,t,n){for(var r=n<0?n+t:t<n?t:n;0<=--r;)e.push(r);return e}),gt:ye(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]=de(e);for(e in{submit:!0,reset:!0})b.pseudos[e]=he(e);function me(){}function xe(e){for(var t=0,n=e.length,r="";t<n;t++)r+=e[t].value;return r}function be(s,e,t){var u=e.dir,l=e.next,c=l||u,f=t&&"parentNode"===c,p=r++;return e.first?function(e,t,n){while(e=e[u])if(1===e.nodeType||f)return s(e,t,n);return!1}:function(e,t,n){var r,i,o,a=[k,p];if(n){while(e=e[u])if((1===e.nodeType||f)&&s(e,t,n))return!0}else while(e=e[u])if(1===e.nodeType||f)if(i=(o=e[S]||(e[S]={}))[e.uniqueID]||(o[e.uniqueID]={}),l&&l===e.nodeName.toLowerCase())e=e[u]||e;else{if((r=i[c])&&r[0]===k&&r[1]===p)return a[2]=r[2];if((i[c]=a)[2]=s(e,t,n))return!0}return!1}}function we(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 Te(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 Ce(d,h,g,y,v,e){return y&&!y[S]&&(y=Ce(y)),v&&!v[S]&&(v=Ce(v,e)),le(function(e,t,n,r){var i,o,a,s=[],u=[],l=t.length,c=e||function(e,t,n){for(var r=0,i=t.length;r<i;r++)se(e,t[r],n);return n}(h||"*",n.nodeType?[n]:n,[]),f=!d||!e&&h?c:Te(c,s,d,n,r),p=g?v||(e?d:l||y)?[]:t:f;if(g&&g(f,p,n,r),y){i=Te(p,u),y(i,[],n,r),o=i.length;while(o--)(a=i[o])&&(p[u[o]]=!(f[u[o]]=a))}if(e){if(v||d){if(v){i=[],o=p.length;while(o--)(a=p[o])&&i.push(f[o]=a);v(null,p=[],i,r)}o=p.length;while(o--)(a=p[o])&&-1<(i=v?P(e,a):s[o])&&(e[i]=!(t[i]=a))}}else p=Te(p===t?p.splice(l,p.length):p),v?v(null,t,p,r):H.apply(t,p)})}function Ee(e){for(var i,t,n,r=e.length,o=b.relative[e[0].type],a=o||b.relative[" "],s=o?1:0,u=be(function(e){return e===i},a,!0),l=be(function(e){return-1<P(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=[be(we(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 Ce(1<s&&we(c),1<s&&xe(e.slice(0,s-1).concat({value:" "===e[s-2].type?"*":""})).replace(B,"$1"),t,s<n&&Ee(e.slice(s,n)),n<r&&Ee(e=e.slice(n)),n<r&&xe(e))}c.push(t)}return we(c)}return me.prototype=b.filters=b.pseudos,b.setFilters=new me,h=se.tokenize=function(e,t){var n,r,i,o,a,s,u,l=x[e+" "];if(l)return t?0:l.slice(0);a=e,s=[],u=b.preFilter;while(a){for(o in n&&!(r=_.exec(a))||(r&&(a=a.slice(r[0].length)||a),s.push(i=[])),n=!1,(r=z.exec(a))&&(n=r.shift(),i.push({value:n,type:r[0].replace(B," ")}),a=a.slice(n.length)),b.filter)!(r=G[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?se.error(e):x(e,s).slice(0)},f=se.compile=function(e,t){var n,y,v,m,x,r,i=[],o=[],a=A[e+" "];if(!a){t||(t=h(e)),n=t.length;while(n--)(a=Ee(t[n]))[S]?i.push(a):o.push(a);(a=A(e,(y=o,m=0<(v=i).length,x=0<y.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=k+=null==p?1:Math.random()||.1,g=d.length;for(i&&(w=t==C||t||i);l!==g&&null!=(o=d[l]);l++){if(x&&o){a=0,t||o.ownerDocument==C||(T(o),n=!E);while(s=y[a++])if(s(o,t||C,n)){r.push(o);break}i&&(k=h)}m&&((o=!s&&o)&&u--,e&&c.push(o))}if(u+=l,m&&l!==u){a=0;while(s=v[a++])s(c,f,t,n);if(e){if(0<u)while(l--)c[l]||f[l]||(f[l]=q.call(r));f=Te(f)}H.apply(r,f),i&&!e&&0<f.length&&1<u+v.length&&se.uniqueSort(r)}return i&&(k=h,w=p),c},m?le(r):r))).selector=e}return a},g=se.select=function(e,t,n,r){var i,o,a,s,u,l="function"==typeof e&&e,c=!r&&h(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&&E&&b.relative[o[1].type]){if(!(t=(b.find.ID(a.matches[0].replace(te,ne),t)||[])[0]))return n;l&&(t=t.parentNode),e=e.slice(o.shift().value.length)}i=G.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(te,ne),ee.test(o[0].type)&&ve(t.parentNode)||t))){if(o.splice(i,1),!(e=r.length&&xe(o)))return H.apply(n,r),n;break}}}return(l||f(e,c))(r,t,!E,n,!t||ee.test(e)&&ve(t.parentNode)||t),n},d.sortStable=S.split("").sort(j).join("")===S,d.detectDuplicates=!!l,T(),d.sortDetached=ce(function(e){return 1&e.compareDocumentPosition(C.createElement("fieldset"))}),ce(function(e){return e.innerHTML="<a href='#'></a>","#"===e.firstChild.getAttribute("href")})||fe("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),d.attributes&&ce(function(e){return e.innerHTML="<input/>",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||fe("value",function(e,t,n){if(!n&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),ce(function(e){return null==e.getAttribute("disabled")})||fe(R,function(e,t,n){var r;if(!n)return!0===e[t]?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null}),se}(C);S.find=d,S.expr=d.selectors,S.expr[":"]=S.expr.pseudos,S.uniqueSort=S.unique=d.uniqueSort,S.text=d.getText,S.isXMLDoc=d.isXML,S.contains=d.contains,S.escapeSelector=d.escape;var h=function(e,t,n){var r=[],i=void 0!==n;while((e=e[t])&&9!==e.nodeType)if(1===e.nodeType){if(i&&S(e).is(n))break;r.push(e)}return r},T=function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n},k=S.expr.match.needsContext;function A(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}var N=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,n,r){return m(n)?S.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?S.grep(e,function(e){return e===n!==r}):"string"!=typeof n?S.grep(e,function(e){return-1<i.call(n,e)!==r}):S.filter(n,e,r)}S.filter=function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?S.find.matchesSelector(r,e)?[r]:[]:S.find.matches(e,S.grep(t,function(e){return 1===e.nodeType}))},S.fn.extend({find:function(e){var t,n,r=this.length,i=this;if("string"!=typeof e)return this.pushStack(S(e).filter(function(){for(t=0;t<r;t++)if(S.contains(i[t],this))return!0}));for(n=this.pushStack([]),t=0;t<r;t++)S.find(e,i[t],n);return 1<r?S.uniqueSort(n):n},filter:function(e){return this.pushStack(j(this,e||[],!1))},not:function(e){return this.pushStack(j(this,e||[],!0))},is:function(e){return!!j(this,"string"==typeof e&&k.test(e)?S(e):e||[],!1).length}});var D,q=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(S.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||D,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:q.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 S?t[0]:t,S.merge(this,S.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),N.test(r[1])&&S.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(S):S.makeArray(e,this)}).prototype=S.fn,D=S(E);var L=/^(?:parents|prev(?:Until|All))/,H={children:!0,contents:!0,next:!0,prev:!0};function O(e,t){while((e=e[t])&&1!==e.nodeType);return e}S.fn.extend({has:function(e){var t=S(e,this),n=t.length;return this.filter(function(){for(var e=0;e<n;e++)if(S.contains(this,t[e]))return!0})},closest:function(e,t){var n,r=0,i=this.length,o=[],a="string"!=typeof e&&S(e);if(!k.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&&S.find.matchesSelector(n,e))){o.push(n);break}return this.pushStack(1<o.length?S.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?i.call(S(e),this[0]):i.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(S.uniqueSort(S.merge(this.get(),S(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),S.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return h(e,"parentNode")},parentsUntil:function(e,t,n){return h(e,"parentNode",n)},next:function(e){return O(e,"nextSibling")},prev:function(e){return O(e,"previousSibling")},nextAll:function(e){return h(e,"nextSibling")},prevAll:function(e){return h(e,"previousSibling")},nextUntil:function(e,t,n){return h(e,"nextSibling",n)},prevUntil:function(e,t,n){return h(e,"previousSibling",n)},siblings:function(e){return T((e.parentNode||{}).firstChild,e)},children:function(e){return T(e.firstChild)},contents:function(e){return null!=e.contentDocument&&r(e.contentDocument)?e.contentDocument:(A(e,"template")&&(e=e.content||e),S.merge([],e.childNodes))}},function(r,i){S.fn[r]=function(e,t){var n=S.map(this,i,e);return"Until"!==r.slice(-5)&&(t=e),t&&"string"==typeof t&&(n=S.filter(t,n)),1<this.length&&(H[r]||S.uniqueSort(n),L.test(r)&&n.reverse()),this.pushStack(n)}});var P=/[^\x20\t\r\n\f]+/g;function R(e){return e}function M(e){throw e}function I(e,t,n,r){var i;try{e&&m(i=e.promise)?i.call(e).done(t).fail(n):e&&m(i=e.then)?i.call(e,t,n):t.apply(void 0,[e].slice(r))}catch(e){n.apply(void 0,[e])}}S.Callbacks=function(r){var e,n;r="string"==typeof r?(e=r,n={},S.each(e.match(P)||[],function(e,t){n[t]=!0}),n):S.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){S.each(e,function(e,t){m(t)?r.unique&&f.has(t)||s.push(t):t&&t.length&&"string"!==w(t)&&n(t)})}(arguments),t&&!i&&c()),this},remove:function(){return S.each(arguments,function(e,t){var n;while(-1<(n=S.inArray(t,s,n)))s.splice(n,1),n<=l&&l--}),this},has:function(e){return e?-1<S.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},S.extend({Deferred:function(e){var o=[["notify","progress",S.Callbacks("memory"),S.Callbacks("memory"),2],["resolve","done",S.Callbacks("once memory"),S.Callbacks("once memory"),0,"resolved"],["reject","fail",S.Callbacks("once memory"),S.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 S.Deferred(function(r){S.each(o,function(e,t){var n=m(i[t[4]])&&i[t[4]];s[t[1]](function(){var e=n&&n.apply(this,arguments);e&&m(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,m(t)?s?t.call(e,l(u,o,R,s),l(u,o,M,s)):(u++,t.call(e,l(u,o,R,s),l(u,o,M,s),l(u,o,R,o.notifyWith))):(a!==R&&(n=void 0,r=[e]),(s||o.resolveWith)(n,r))}},t=s?e:function(){try{e()}catch(e){S.Deferred.exceptionHook&&S.Deferred.exceptionHook(e,t.stackTrace),u<=i+1&&(a!==M&&(n=void 0,r=[e]),o.rejectWith(n,r))}};i?t():(S.Deferred.getStackHook&&(t.stackTrace=S.Deferred.getStackHook()),C.setTimeout(t))}}return S.Deferred(function(e){o[0][3].add(l(0,e,m(r)?r:R,e.notifyWith)),o[1][3].add(l(0,e,m(t)?t:R)),o[2][3].add(l(0,e,m(n)?n:M))}).promise()},promise:function(e){return null!=e?S.extend(e,a):a}},s={};return S.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=s.call(arguments),o=S.Deferred(),a=function(t){return function(e){r[t]=this,i[t]=1<arguments.length?s.call(arguments):e,--n||o.resolveWith(r,i)}};if(n<=1&&(I(e,o.done(a(t)).resolve,o.reject,!n),"pending"===o.state()||m(i[t]&&i[t].then)))return o.then();while(t--)I(i[t],a(t),o.reject);return o.promise()}});var W=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;S.Deferred.exceptionHook=function(e,t){C.console&&C.console.warn&&e&&W.test(e.name)&&C.console.warn("jQuery.Deferred exception: "+e.message,e.stack,t)},S.readyException=function(e){C.setTimeout(function(){throw e})};var F=S.Deferred();function $(){E.removeEventListener("DOMContentLoaded",$),C.removeEventListener("load",$),S.ready()}S.fn.ready=function(e){return F.then(e)["catch"](function(e){S.readyException(e)}),this},S.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--S.readyWait:S.isReady)||(S.isReady=!0)!==e&&0<--S.readyWait||F.resolveWith(E,[S])}}),S.ready.then=F.then,"complete"===E.readyState||"loading"!==E.readyState&&!E.documentElement.doScroll?C.setTimeout(S.ready):(E.addEventListener("DOMContentLoaded",$),C.addEventListener("load",$));var B=function(e,t,n,r,i,o,a){var s=0,u=e.length,l=null==n;if("object"===w(n))for(s in i=!0,n)B(e,t,s,n[s],!0,o,a);else if(void 0!==r&&(i=!0,m(r)||(a=!0),l&&(a?(t.call(e,r),t=null):(l=t,t=function(e,t,n){return l.call(S(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},_=/^-ms-/,z=/-([a-z])/g;function U(e,t){return t.toUpperCase()}function X(e){return e.replace(_,"ms-").replace(z,U)}var V=function(e){return 1===e.nodeType||9===e.nodeType||!+e.nodeType};function G(){this.expando=S.expando+G.uid++}G.uid=1,G.prototype={cache:function(e){var t=e[this.expando];return t||(t={},V(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[X(t)]=n;else for(r in t)i[X(r)]=t[r];return i},get:function(e,t){return void 0===t?this.cache(e):e[this.expando]&&e[this.expando][X(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(X):(t=X(t))in r?[t]:t.match(P)||[]).length;while(n--)delete r[t[n]]}(void 0===t||S.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&&!S.isEmptyObject(t)}};var Y=new G,Q=new G,J=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,K=/[A-Z]/g;function Z(e,t,n){var r,i;if(void 0===n&&1===e.nodeType)if(r="data-"+t.replace(K,"-$&").toLowerCase(),"string"==typeof(n=e.getAttribute(r))){try{n="true"===(i=n)||"false"!==i&&("null"===i?null:i===+i+""?+i:J.test(i)?JSON.parse(i):i)}catch(e){}Q.set(e,t,n)}else n=void 0;return n}S.extend({hasData:function(e){return Q.hasData(e)||Y.hasData(e)},data:function(e,t,n){return Q.access(e,t,n)},removeData:function(e,t){Q.remove(e,t)},_data:function(e,t,n){return Y.access(e,t,n)},_removeData:function(e,t){Y.remove(e,t)}}),S.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=Q.get(o),1===o.nodeType&&!Y.get(o,"hasDataAttrs"))){t=a.length;while(t--)a[t]&&0===(r=a[t].name).indexOf("data-")&&(r=X(r.slice(5)),Z(o,r,i[r]));Y.set(o,"hasDataAttrs",!0)}return i}return"object"==typeof n?this.each(function(){Q.set(this,n)}):B(this,function(e){var t;if(o&&void 0===e)return void 0!==(t=Q.get(o,n))?t:void 0!==(t=Z(o,n))?t:void 0;this.each(function(){Q.set(this,n,e)})},null,e,1<arguments.length,null,!0)},removeData:function(e){return this.each(function(){Q.remove(this,e)})}}),S.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=Y.get(e,t),n&&(!r||Array.isArray(n)?r=Y.access(e,t,S.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=S.queue(e,t),r=n.length,i=n.shift(),o=S._queueHooks(e,t);"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,function(){S.dequeue(e,t)},o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return Y.get(e,n)||Y.access(e,n,{empty:S.Callbacks("once memory").add(function(){Y.remove(e,[t+"queue",n])})})}}),S.fn.extend({queue:function(t,n){var e=2;return"string"!=typeof t&&(n=t,t="fx",e--),arguments.length<e?S.queue(this[0],t):void 0===n?this:this.each(function(){var e=S.queue(this,t,n);S._queueHooks(this,t),"fx"===t&&"inprogress"!==e[0]&&S.dequeue(this,t)})},dequeue:function(e){return this.each(function(){S.dequeue(this,e)})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,t){var n,r=1,i=S.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=Y.get(o[a],e+"queueHooks"))&&n.empty&&(r++,n.empty.add(s));return s(),i.promise(t)}});var ee=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,te=new RegExp("^(?:([+-])=|)("+ee+")([a-z%]*)$","i"),ne=["Top","Right","Bottom","Left"],re=E.documentElement,ie=function(e){return S.contains(e.ownerDocument,e)},oe={composed:!0};re.getRootNode&&(ie=function(e){return S.contains(e.ownerDocument,e)||e.getRootNode(oe)===e.ownerDocument});var ae=function(e,t){return"none"===(e=t||e).style.display||""===e.style.display&&ie(e)&&"none"===S.css(e,"display")};function se(e,t,n,r){var i,o,a=20,s=r?function(){return r.cur()}:function(){return S.css(e,t,"")},u=s(),l=n&&n[3]||(S.cssNumber[t]?"":"px"),c=e.nodeType&&(S.cssNumber[t]||"px"!==l&&+u)&&te.exec(S.css(e,t));if(c&&c[3]!==l){u/=2,l=l||c[3],c=+u||1;while(a--)S.style(e,t,c+l),(1-o)*(1-(o=s()/u||.5))<=0&&(a=0),c/=o;c*=2,S.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 ue={};function le(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]=Y.get(r,"display")||null,l[c]||(r.style.display="")),""===r.style.display&&ae(r)&&(l[c]=(u=a=o=void 0,a=(i=r).ownerDocument,s=i.nodeName,(u=ue[s])||(o=a.body.appendChild(a.createElement(s)),u=S.css(o,"display"),o.parentNode.removeChild(o),"none"===u&&(u="block"),ue[s]=u)))):"none"!==n&&(l[c]="none",Y.set(r,"display",n)));for(c=0;c<f;c++)null!=l[c]&&(e[c].style.display=l[c]);return e}S.fn.extend({show:function(){return le(this,!0)},hide:function(){return le(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){ae(this)?S(this).show():S(this).hide()})}});var ce,fe,pe=/^(?:checkbox|radio)$/i,de=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i;ce=E.createDocumentFragment().appendChild(E.createElement("div")),(fe=E.createElement("input")).setAttribute("type","radio"),fe.setAttribute("checked","checked"),fe.setAttribute("name","t"),ce.appendChild(fe),v.checkClone=ce.cloneNode(!0).cloneNode(!0).lastChild.checked,ce.innerHTML="<textarea>x</textarea>",v.noCloneChecked=!!ce.cloneNode(!0).lastChild.defaultValue,ce.innerHTML="<option></option>",v.option=!!ce.lastChild;var ge={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 ye(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?S.merge([e],n):n}function ve(e,t){for(var n=0,r=e.length;n<r;n++)Y.set(e[n],"globalEval",!t||Y.get(t[n],"globalEval"))}ge.tbody=ge.tfoot=ge.colgroup=ge.caption=ge.thead,ge.th=ge.td,v.option||(ge.optgroup=ge.option=[1,"<select multiple='multiple'>","</select>"]);var me=/<|&#?\w+;/;function xe(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"===w(o))S.merge(p,o.nodeType?[o]:o);else if(me.test(o)){a=a||f.appendChild(t.createElement("div")),s=(de.exec(o)||["",""])[1].toLowerCase(),u=ge[s]||ge._default,a.innerHTML=u[1]+S.htmlPrefilter(o)+u[2],c=u[0];while(c--)a=a.lastChild;S.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<S.inArray(o,r))i&&i.push(o);else if(l=ie(o),a=ye(f.appendChild(o),"script"),l&&ve(a),n){c=0;while(o=a[c++])he.test(o.type||"")&&n.push(o)}return f}var be=/^([^.]*)(?:\.(.+)|)/;function we(){return!0}function Te(){return!1}function Ce(e,t){return e===function(){try{return E.activeElement}catch(e){}}()==("focus"===t)}function Ee(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)Ee(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=Te;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return S().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=S.guid++)),e.each(function(){S.event.add(this,t,i,r,n)})}function Se(e,i,o){o?(Y.set(e,i,!1),S.event.add(e,i,{namespace:!1,handler:function(e){var t,n,r=Y.get(this,i);if(1&e.isTrigger&&this[i]){if(r.length)(S.event.special[i]||{}).delegateType&&e.stopPropagation();else if(r=s.call(arguments),Y.set(this,i,r),t=o(this,i),this[i](),r!==(n=Y.get(this,i))||t?Y.set(this,i,!1):n={},r!==n)return e.stopImmediatePropagation(),e.preventDefault(),n&&n.value}else r.length&&(Y.set(this,i,{value:S.event.trigger(S.extend(r[0],S.Event.prototype),r.slice(1),this)}),e.stopImmediatePropagation())}})):void 0===Y.get(e,i)&&S.event.add(e,i,we)}S.event={global:{},add:function(t,e,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=Y.get(t);if(V(t)){n.handler&&(n=(o=n).handler,i=o.selector),i&&S.find.matchesSelector(re,i),n.guid||(n.guid=S.guid++),(u=y.events)||(u=y.events=Object.create(null)),(a=y.handle)||(a=y.handle=function(e){return"undefined"!=typeof S&&S.event.triggered!==e.type?S.event.dispatch.apply(t,arguments):void 0}),l=(e=(e||"").match(P)||[""]).length;while(l--)d=g=(s=be.exec(e[l])||[])[1],h=(s[2]||"").split(".").sort(),d&&(f=S.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=S.event.special[d]||{},c=S.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&S.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),S.event.global[d]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=Y.hasData(e)&&Y.get(e);if(y&&(u=y.events)){l=(t=(t||"").match(P)||[""]).length;while(l--)if(d=g=(s=be.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),d){f=S.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,y.handle)||S.removeEvent(e,d,y.handle),delete u[d])}else for(d in u)S.event.remove(e,d+t[l],n,r,!0);S.isEmptyObject(u)&&Y.remove(e,"handle events")}},dispatch:function(e){var t,n,r,i,o,a,s=new Array(arguments.length),u=S.event.fix(e),l=(Y.get(this,"events")||Object.create(null))[u.type]||[],c=S.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=S.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=((S.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<S(i,this).index(l):S.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(S.Event.prototype,t,{enumerable:!0,configurable:!0,get:m(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[S.expando]?e:new S.Event(e)},special:{load:{noBubble:!0},click:{setup:function(e){var t=this||e;return pe.test(t.type)&&t.click&&A(t,"input")&&Se(t,"click",we),!1},trigger:function(e){var t=this||e;return pe.test(t.type)&&t.click&&A(t,"input")&&Se(t,"click"),!0},_default:function(e){var t=e.target;return pe.test(t.type)&&t.click&&A(t,"input")&&Y.get(t,"click")||A(t,"a")}},beforeunload:{postDispatch:function(e){void 0!==e.result&&e.originalEvent&&(e.originalEvent.returnValue=e.result)}}}},S.removeEvent=function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n)},S.Event=function(e,t){if(!(this instanceof S.Event))return new S.Event(e,t);e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||void 0===e.defaultPrevented&&!1===e.returnValue?we:Te,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&&S.extend(this,t),this.timeStamp=e&&e.timeStamp||Date.now(),this[S.expando]=!0},S.Event.prototype={constructor:S.Event,isDefaultPrevented:Te,isPropagationStopped:Te,isImmediatePropagationStopped:Te,isSimulated:!1,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=we,e&&!this.isSimulated&&e.preventDefault()},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=we,e&&!this.isSimulated&&e.stopPropagation()},stopImmediatePropagation:function(){var e=this.originalEvent;this.isImmediatePropagationStopped=we,e&&!this.isSimulated&&e.stopImmediatePropagation(),this.stopPropagation()}},S.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},S.event.addProp),S.each({focus:"focusin",blur:"focusout"},function(t,e){S.event.special[t]={setup:function(){return Se(this,t,Ce),!1},trigger:function(){return Se(this,t),!0},_default:function(e){return Y.get(e.target,t)},delegateType:e}}),S.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(e,i){S.event.special[e]={delegateType:i,bindType:i,handle:function(e){var t,n=e.relatedTarget,r=e.handleObj;return n&&(n===this||S.contains(this,n))||(e.type=r.origType,t=r.handler.apply(this,arguments),e.type=i),t}}}),S.fn.extend({on:function(e,t,n,r){return Ee(this,e,t,n,r)},one:function(e,t,n,r){return Ee(this,e,t,n,r,1)},off:function(e,t,n){var r,i;if(e&&e.preventDefault&&e.handleObj)return r=e.handleObj,S(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=Te),this.each(function(){S.event.remove(this,e,n,t)})}});var ke=/<script|<style|<link/i,Ae=/checked\s*(?:[^=]|=\s*.checked.)/i,Ne=/^\s*<!\[CDATA\[|\]\]>\s*$/g;function je(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&S(e).children("tbody")[0]||e}function De(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function qe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Le(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(Y.hasData(e)&&(s=Y.get(e).events))for(i in Y.remove(t,"handle events"),s)for(n=0,r=s[i].length;n<r;n++)S.event.add(t,i,s[i][n]);Q.hasData(e)&&(o=Q.access(e),a=S.extend({},o),Q.set(t,a))}}function He(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=m(d);if(h||1<f&&"string"==typeof d&&!v.checkClone&&Ae.test(d))return n.each(function(e){var t=n.eq(e);h&&(r[0]=d.call(this,e,t.html())),He(t,r,i,o)});if(f&&(t=(e=xe(r,n[0].ownerDocument,!1,n,o)).firstChild,1===e.childNodes.length&&(e=t),t||o)){for(s=(a=S.map(ye(e,"script"),De)).length;c<f;c++)u=e,c!==p&&(u=S.clone(u,!0,!0),s&&S.merge(a,ye(u,"script"))),i.call(n[c],u,c);if(s)for(l=a[a.length-1].ownerDocument,S.map(a,qe),c=0;c<s;c++)u=a[c],he.test(u.type||"")&&!Y.access(u,"globalEval")&&S.contains(l,u)&&(u.src&&"module"!==(u.type||"").toLowerCase()?S._evalUrl&&!u.noModule&&S._evalUrl(u.src,{nonce:u.nonce||u.getAttribute("nonce")},l):b(u.textContent.replace(Ne,""),u,l))}return n}function Oe(e,t,n){for(var r,i=t?S.filter(t,e):e,o=0;null!=(r=i[o]);o++)n||1!==r.nodeType||S.cleanData(ye(r)),r.parentNode&&(n&&ie(r)&&ve(ye(r,"script")),r.parentNode.removeChild(r));return e}S.extend({htmlPrefilter:function(e){return e},clone:function(e,t,n){var r,i,o,a,s,u,l,c=e.cloneNode(!0),f=ie(e);if(!(v.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||S.isXMLDoc(e)))for(a=ye(c),r=0,i=(o=ye(e)).length;r<i;r++)s=o[r],u=a[r],void 0,"input"===(l=u.nodeName.toLowerCase())&&pe.test(s.type)?u.checked=s.checked:"input"!==l&&"textarea"!==l||(u.defaultValue=s.defaultValue);if(t)if(n)for(o=o||ye(e),a=a||ye(c),r=0,i=o.length;r<i;r++)Le(o[r],a[r]);else Le(e,c);return 0<(a=ye(c,"script")).length&&ve(a,!f&&ye(e,"script")),c},cleanData:function(e){for(var t,n,r,i=S.event.special,o=0;void 0!==(n=e[o]);o++)if(V(n)){if(t=n[Y.expando]){if(t.events)for(r in t.events)i[r]?S.event.remove(n,r):S.removeEvent(n,r,t.handle);n[Y.expando]=void 0}n[Q.expando]&&(n[Q.expando]=void 0)}}}),S.fn.extend({detach:function(e){return Oe(this,e,!0)},remove:function(e){return Oe(this,e)},text:function(e){return B(this,function(e){return void 0===e?S.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 He(this,arguments,function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||je(this,e).appendChild(e)})},prepend:function(){return He(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=je(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return He(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return He(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&&(S.cleanData(ye(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return S.clone(this,e,t)})},html:function(e){return B(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&&!ke.test(e)&&!ge[(de.exec(e)||["",""])[1].toLowerCase()]){e=S.htmlPrefilter(e);try{for(;n<r;n++)1===(t=this[n]||{}).nodeType&&(S.cleanData(ye(t,!1)),t.innerHTML=e);t=0}catch(e){}}t&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var n=[];return He(this,arguments,function(e){var t=this.parentNode;S.inArray(this,n)<0&&(S.cleanData(ye(this)),t&&t.replaceChild(e,this))},n)}}),S.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,a){S.fn[e]=function(e){for(var t,n=[],r=S(e),i=r.length-1,o=0;o<=i;o++)t=o===i?this:this.clone(!0),S(r[o])[a](t),u.apply(n,t.get());return this.pushStack(n)}});var Pe=new RegExp("^("+ee+")(?!px)[a-z%]+$","i"),Re=/^--/,Me=function(e){var t=e.ownerDocument.defaultView;return t&&t.opener||(t=C),t.getComputedStyle(e)},Ie=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},We=new RegExp(ne.join("|"),"i"),Fe="[\\x20\\t\\r\\n\\f]",$e=new RegExp("^"+Fe+"+|((?:^|[^\\\\])(?:\\\\.)*)"+Fe+"+$","g");function Be(e,t,n){var r,i,o,a,s=Re.test(t),u=e.style;return(n=n||Me(e))&&(a=n.getPropertyValue(t)||n[t],s&&(a=a.replace($e,"$1")),""!==a||ie(e)||(a=S.style(e,t)),!v.pixelBoxStyles()&&Pe.test(a)&&We.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 _e(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%",re.appendChild(u).appendChild(l);var e=C.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),re.removeChild(u),l=null}}function t(e){return Math.round(parseFloat(e))}var n,r,i,o,a,s,u=E.createElement("div"),l=E.createElement("div");l.style&&(l.style.backgroundClip="content-box",l.cloneNode(!0).style.backgroundClip="",v.clearCloneStyle="content-box"===l.style.backgroundClip,S.extend(v,{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=E.createElement("table"),t=E.createElement("tr"),n=E.createElement("div"),e.style.cssText="position:absolute;left:-11111px;border-collapse:separate",t.style.cssText="border:1px solid",t.style.height="1px",n.style.height="9px",n.style.display="block",re.appendChild(e).appendChild(t).appendChild(n),r=C.getComputedStyle(t),a=parseInt(r.height,10)+parseInt(r.borderTopWidth,10)+parseInt(r.borderBottomWidth,10)===t.offsetHeight,re.removeChild(e)),a}}))}();var ze=["Webkit","Moz","ms"],Ue=E.createElement("div").style,Xe={};function Ve(e){var t=S.cssProps[e]||Xe[e];return t||(e in Ue?e:Xe[e]=function(e){var t=e[0].toUpperCase()+e.slice(1),n=ze.length;while(n--)if((e=ze[n]+t)in Ue)return e}(e)||e)}var Ge=/^(none|table(?!-c[ea]).+)/,Ye={position:"absolute",visibility:"hidden",display:"block"},Qe={letterSpacing:"0",fontWeight:"400"};function Je(e,t,n){var r=te.exec(t);return r?Math.max(0,r[2]-(n||0))+(r[3]||"px"):t}function Ke(e,t,n,r,i,o){var a="width"===t?1:0,s=0,u=0;if(n===(r?"border":"content"))return 0;for(;a<4;a+=2)"margin"===n&&(u+=S.css(e,n+ne[a],!0,i)),r?("content"===n&&(u-=S.css(e,"padding"+ne[a],!0,i)),"margin"!==n&&(u-=S.css(e,"border"+ne[a]+"Width",!0,i))):(u+=S.css(e,"padding"+ne[a],!0,i),"padding"!==n?u+=S.css(e,"border"+ne[a]+"Width",!0,i):s+=S.css(e,"border"+ne[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}function Ze(e,t,n){var r=Me(e),i=(!v.boxSizingReliable()||n)&&"border-box"===S.css(e,"boxSizing",!1,r),o=i,a=Be(e,t,r),s="offset"+t[0].toUpperCase()+t.slice(1);if(Pe.test(a)){if(!n)return a;a="auto"}return(!v.boxSizingReliable()&&i||!v.reliableTrDimensions()&&A(e,"tr")||"auto"===a||!parseFloat(a)&&"inline"===S.css(e,"display",!1,r))&&e.getClientRects().length&&(i="border-box"===S.css(e,"boxSizing",!1,r),(o=s in e)&&(a=e[s])),(a=parseFloat(a)||0)+Ke(e,t,n||(i?"border":"content"),o,r,a)+"px"}function et(e,t,n,r,i){return new et.prototype.init(e,t,n,r,i)}S.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Be(e,"opacity");return""===n?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!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,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,a,s=X(t),u=Re.test(t),l=e.style;if(u||(t=Ve(s)),a=S.cssHooks[t]||S.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=te.exec(n))&&i[1]&&(n=se(e,t,i),o="number"),null!=n&&n==n&&("number"!==o||u||(n+=i&&i[3]||(S.cssNumber[s]?"":"px")),v.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=X(t);return Re.test(t)||(t=Ve(s)),(a=S.cssHooks[t]||S.cssHooks[s])&&"get"in a&&(i=a.get(e,!0,n)),void 0===i&&(i=Be(e,t,r)),"normal"===i&&t in Qe&&(i=Qe[t]),""===n||n?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),S.each(["height","width"],function(e,u){S.cssHooks[u]={get:function(e,t,n){if(t)return!Ge.test(S.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?Ze(e,u,n):Ie(e,Ye,function(){return Ze(e,u,n)})},set:function(e,t,n){var r,i=Me(e),o=!v.scrollboxSize()&&"absolute"===i.position,a=(o||n)&&"border-box"===S.css(e,"boxSizing",!1,i),s=n?Ke(e,u,n,a,i):0;return a&&o&&(s-=Math.ceil(e["offset"+u[0].toUpperCase()+u.slice(1)]-parseFloat(i[u])-Ke(e,u,"border",!1,i)-.5)),s&&(r=te.exec(t))&&"px"!==(r[3]||"px")&&(e.style[u]=t,t=S.css(e,u)),Je(0,t,s)}}}),S.cssHooks.marginLeft=_e(v.reliableMarginLeft,function(e,t){if(t)return(parseFloat(Be(e,"marginLeft"))||e.getBoundingClientRect().left-Ie(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),S.each({margin:"",padding:"",border:"Width"},function(i,o){S.cssHooks[i+o]={expand:function(e){for(var t=0,n={},r="string"==typeof e?e.split(" "):[e];t<4;t++)n[i+ne[t]+o]=r[t]||r[t-2]||r[0];return n}},"margin"!==i&&(S.cssHooks[i+o].set=Je)}),S.fn.extend({css:function(e,t){return B(this,function(e,t,n){var r,i,o={},a=0;if(Array.isArray(t)){for(r=Me(e),i=t.length;a<i;a++)o[t[a]]=S.css(e,t[a],!1,r);return o}return void 0!==n?S.style(e,t,n):S.css(e,t)},e,t,1<arguments.length)}}),((S.Tween=et).prototype={constructor:et,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||S.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(S.cssNumber[n]?"":"px")},cur:function(){var e=et.propHooks[this.prop];return e&&e.get?e.get(this):et.propHooks._default.get(this)},run:function(e){var t,n=et.propHooks[this.prop];return this.options.duration?this.pos=t=S.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):et.propHooks._default.set(this),this}}).init.prototype=et.prototype,(et.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=S.css(e.elem,e.prop,""))&&"auto"!==t?t:0},set:function(e){S.fx.step[e.prop]?S.fx.step[e.prop](e):1!==e.elem.nodeType||!S.cssHooks[e.prop]&&null==e.elem.style[Ve(e.prop)]?e.elem[e.prop]=e.now:S.style(e.elem,e.prop,e.now+e.unit)}}}).scrollTop=et.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},S.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},S.fx=et.prototype.init,S.fx.step={};var tt,nt,rt,it,ot=/^(?:toggle|show|hide)$/,at=/queueHooks$/;function st(){nt&&(!1===E.hidden&&C.requestAnimationFrame?C.requestAnimationFrame(st):C.setTimeout(st,S.fx.interval),S.fx.tick())}function ut(){return C.setTimeout(function(){tt=void 0}),tt=Date.now()}function lt(e,t){var n,r=0,i={height:e};for(t=t?1:0;r<4;r+=2-t)i["margin"+(n=ne[r])]=i["padding"+n]=e;return t&&(i.opacity=i.width=e),i}function ct(e,t,n){for(var r,i=(ft.tweeners[t]||[]).concat(ft.tweeners["*"]),o=0,a=i.length;o<a;o++)if(r=i[o].call(n,t,e))return r}function ft(o,e,t){var n,a,r=0,i=ft.prefilters.length,s=S.Deferred().always(function(){delete u.elem}),u=function(){if(a)return!1;for(var e=tt||ut(),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:S.extend({},e),opts:S.extend(!0,{specialEasing:{},easing:S.easing._default},t),originalProperties:e,originalOptions:t,startTime:tt||ut(),duration:t.duration,tweens:[],createTween:function(e,t){var n=S.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=X(n)],o=e[n],Array.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),(a=S.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=ft.prefilters[r].call(l,o,c,l.opts))return m(n.stop)&&(S._queueHooks(l.elem,l.opts.queue).stop=n.stop.bind(n)),n;return S.map(c,ct,l),m(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),S.fx.timer(S.extend(u,{elem:o,anim:l,queue:l.opts.queue})),l}S.Animation=S.extend(ft,{tweeners:{"*":[function(e,t){var n=this.createTween(e,t);return se(n.elem,e,te.exec(t),n),n}]},tweener:function(e,t){m(e)?(t=e,e=["*"]):e=e.match(P);for(var n,r=0,i=e.length;r<i;r++)n=e[r],ft.tweeners[n]=ft.tweeners[n]||[],ft.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&&ae(e),y=Y.get(e,"fxshow");for(r in n.queue||(null==(a=S._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--,S.queue(e,"fx").length||a.empty.fire()})})),t)if(i=t[r],ot.test(i)){if(delete t[r],o=o||"toggle"===i,i===(g?"hide":"show")){if("show"!==i||!y||void 0===y[r])continue;g=!0}d[r]=y&&y[r]||S.style(e,r)}if((u=!S.isEmptyObject(t))||!S.isEmptyObject(d))for(r in f&&1===e.nodeType&&(n.overflow=[h.overflow,h.overflowX,h.overflowY],null==(l=y&&y.display)&&(l=Y.get(e,"display")),"none"===(c=S.css(e,"display"))&&(l?c=l:(le([e],!0),l=e.style.display||l,c=S.css(e,"display"),le([e]))),("inline"===c||"inline-block"===c&&null!=l)&&"none"===S.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||(y?"hidden"in y&&(g=y.hidden):y=Y.access(e,"fxshow",{display:l}),o&&(y.hidden=!g),g&&le([e],!0),p.done(function(){for(r in g||le([e]),Y.remove(e,"fxshow"),d)S.style(e,r,d[r])})),u=ct(g?y[r]:0,r,p),r in y||(y[r]=u.start,g&&(u.end=u.start,u.start=0))}],prefilter:function(e,t){t?ft.prefilters.unshift(e):ft.prefilters.push(e)}}),S.speed=function(e,t,n){var r=e&&"object"==typeof e?S.extend({},e):{complete:n||!n&&t||m(e)&&e,duration:e,easing:n&&t||t&&!m(t)&&t};return S.fx.off?r.duration=0:"number"!=typeof r.duration&&(r.duration in S.fx.speeds?r.duration=S.fx.speeds[r.duration]:r.duration=S.fx.speeds._default),null!=r.queue&&!0!==r.queue||(r.queue="fx"),r.old=r.complete,r.complete=function(){m(r.old)&&r.old.call(this),r.queue&&S.dequeue(this,r.queue)},r},S.fn.extend({fadeTo:function(e,t,n,r){return this.filter(ae).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(t,e,n,r){var i=S.isEmptyObject(t),o=S.speed(e,n,r),a=function(){var e=ft(this,S.extend({},t),o);(i||Y.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=S.timers,r=Y.get(this);if(t)r[t]&&r[t].stop&&a(r[t]);else for(t in r)r[t]&&r[t].stop&&at.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||S.dequeue(this,i)})},finish:function(a){return!1!==a&&(a=a||"fx"),this.each(function(){var e,t=Y.get(this),n=t[a+"queue"],r=t[a+"queueHooks"],i=S.timers,o=n?n.length:0;for(t.finish=!0,S.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})}}),S.each(["toggle","show","hide"],function(e,r){var i=S.fn[r];S.fn[r]=function(e,t,n){return null==e||"boolean"==typeof e?i.apply(this,arguments):this.animate(lt(r,!0),e,t,n)}}),S.each({slideDown:lt("show"),slideUp:lt("hide"),slideToggle:lt("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,r){S.fn[e]=function(e,t,n){return this.animate(r,e,t,n)}}),S.timers=[],S.fx.tick=function(){var e,t=0,n=S.timers;for(tt=Date.now();t<n.length;t++)(e=n[t])()||n[t]!==e||n.splice(t--,1);n.length||S.fx.stop(),tt=void 0},S.fx.timer=function(e){S.timers.push(e),S.fx.start()},S.fx.interval=13,S.fx.start=function(){nt||(nt=!0,st())},S.fx.stop=function(){nt=null},S.fx.speeds={slow:600,fast:200,_default:400},S.fn.delay=function(r,e){return r=S.fx&&S.fx.speeds[r]||r,e=e||"fx",this.queue(e,function(e,t){var n=C.setTimeout(e,r);t.stop=function(){C.clearTimeout(n)}})},rt=E.createElement("input"),it=E.createElement("select").appendChild(E.createElement("option")),rt.type="checkbox",v.checkOn=""!==rt.value,v.optSelected=it.selected,(rt=E.createElement("input")).value="t",rt.type="radio",v.radioValue="t"===rt.value;var pt,dt=S.expr.attrHandle;S.fn.extend({attr:function(e,t){return B(this,S.attr,e,t,1<arguments.length)},removeAttr:function(e){return this.each(function(){S.removeAttr(this,e)})}}),S.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return"undefined"==typeof e.getAttribute?S.prop(e,t,n):(1===o&&S.isXMLDoc(e)||(i=S.attrHooks[t.toLowerCase()]||(S.expr.match.bool.test(t)?pt:void 0)),void 0!==n?null===n?void S.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=S.find.attr(e,t))?void 0:r)},attrHooks:{type:{set:function(e,t){if(!v.radioValue&&"radio"===t&&A(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(P);if(i&&1===e.nodeType)while(n=i[r++])e.removeAttribute(n)}}),pt={set:function(e,t,n){return!1===t?S.removeAttr(e,n):e.setAttribute(n,n),n}},S.each(S.expr.match.bool.source.match(/\w+/g),function(e,t){var a=dt[t]||S.find.attr;dt[t]=function(e,t,n){var r,i,o=t.toLowerCase();return n||(i=dt[o],dt[o]=r,r=null!=a(e,t,n)?o:null,dt[o]=i),r}});var ht=/^(?:input|select|textarea|button)$/i,gt=/^(?:a|area)$/i;function yt(e){return(e.match(P)||[]).join(" ")}function vt(e){return e.getAttribute&&e.getAttribute("class")||""}function mt(e){return Array.isArray(e)?e:"string"==typeof e&&e.match(P)||[]}S.fn.extend({prop:function(e,t){return B(this,S.prop,e,t,1<arguments.length)},removeProp:function(e){return this.each(function(){delete this[S.propFix[e]||e]})}}),S.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&S.isXMLDoc(e)||(t=S.propFix[t]||t,i=S.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=S.find.attr(e,"tabindex");return t?parseInt(t,10):ht.test(e.nodeName)||gt.test(e.nodeName)&&e.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),v.optSelected||(S.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)}}),S.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){S.propFix[this.toLowerCase()]=this}),S.fn.extend({addClass:function(t){var e,n,r,i,o,a;return m(t)?this.each(function(e){S(this).addClass(t.call(this,e,vt(this)))}):(e=mt(t)).length?this.each(function(){if(r=vt(this),n=1===this.nodeType&&" "+yt(r)+" "){for(o=0;o<e.length;o++)i=e[o],n.indexOf(" "+i+" ")<0&&(n+=i+" ");a=yt(n),r!==a&&this.setAttribute("class",a)}}):this},removeClass:function(t){var e,n,r,i,o,a;return m(t)?this.each(function(e){S(this).removeClass(t.call(this,e,vt(this)))}):arguments.length?(e=mt(t)).length?this.each(function(){if(r=vt(this),n=1===this.nodeType&&" "+yt(r)+" "){for(o=0;o<e.length;o++){i=e[o];while(-1<n.indexOf(" "+i+" "))n=n.replace(" "+i+" "," ")}a=yt(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 m(t)?this.each(function(e){S(this).toggleClass(t.call(this,e,vt(this),n),n)}):"boolean"==typeof n&&s?n?this.addClass(t):this.removeClass(t):(e=mt(t),this.each(function(){if(s)for(o=S(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=vt(this))&&Y.set(this,"__className__",r),this.setAttribute&&this.setAttribute("class",r||!1===t?"":Y.get(this,"__className__")||""))}))},hasClass:function(e){var t,n,r=0;t=" "+e+" ";while(n=this[r++])if(1===n.nodeType&&-1<(" "+yt(vt(n))+" ").indexOf(t))return!0;return!1}});var xt=/\r/g;S.fn.extend({val:function(n){var r,e,i,t=this[0];return arguments.length?(i=m(n),this.each(function(e){var t;1===this.nodeType&&(null==(t=i?n.call(this,e,S(this).val()):n)?t="":"number"==typeof t?t+="":Array.isArray(t)&&(t=S.map(t,function(e){return null==e?"":e+""})),(r=S.valHooks[this.type]||S.valHooks[this.nodeName.toLowerCase()])&&"set"in r&&void 0!==r.set(this,t,"value")||(this.value=t))})):t?(r=S.valHooks[t.type]||S.valHooks[t.nodeName.toLowerCase()])&&"get"in r&&void 0!==(e=r.get(t,"value"))?e:"string"==typeof(e=t.value)?e.replace(xt,""):null==e?"":e:void 0}}),S.extend({valHooks:{option:{get:function(e){var t=S.find.attr(e,"value");return null!=t?t:yt(S.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||!A(n.parentNode,"optgroup"))){if(t=S(n).val(),a)return t;s.push(t)}return s},set:function(e,t){var n,r,i=e.options,o=S.makeArray(t),a=i.length;while(a--)((r=i[a]).selected=-1<S.inArray(S.valHooks.option.get(r),o))&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),S.each(["radio","checkbox"],function(){S.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=-1<S.inArray(S(e).val(),t)}},v.checkOn||(S.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})}),v.focusin="onfocusin"in C;var bt=/^(?:focusinfocus|focusoutblur)$/,wt=function(e){e.stopPropagation()};S.extend(S.event,{trigger:function(e,t,n,r){var i,o,a,s,u,l,c,f,p=[n||E],d=y.call(e,"type")?e.type:e,h=y.call(e,"namespace")?e.namespace.split("."):[];if(o=f=a=n=n||E,3!==n.nodeType&&8!==n.nodeType&&!bt.test(d+S.event.triggered)&&(-1<d.indexOf(".")&&(d=(h=d.split(".")).shift(),h.sort()),u=d.indexOf(":")<0&&"on"+d,(e=e[S.expando]?e:new S.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]:S.makeArray(t,[e]),c=S.event.special[d]||{},r||!c.trigger||!1!==c.trigger.apply(n,t))){if(!r&&!c.noBubble&&!x(n)){for(s=c.delegateType||d,bt.test(s+d)||(o=o.parentNode);o;o=o.parentNode)p.push(o),a=o;a===(n.ownerDocument||E)&&p.push(a.defaultView||a.parentWindow||C)}i=0;while((o=p[i++])&&!e.isPropagationStopped())f=o,e.type=1<i?s:c.bindType||d,(l=(Y.get(o,"events")||Object.create(null))[e.type]&&Y.get(o,"handle"))&&l.apply(o,t),(l=u&&o[u])&&l.apply&&V(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)||!V(n)||u&&m(n[d])&&!x(n)&&((a=n[u])&&(n[u]=null),S.event.triggered=d,e.isPropagationStopped()&&f.addEventListener(d,wt),n[d](),e.isPropagationStopped()&&f.removeEventListener(d,wt),S.event.triggered=void 0,a&&(n[u]=a)),e.result}},simulate:function(e,t,n){var r=S.extend(new S.Event,n,{type:e,isSimulated:!0});S.event.trigger(r,null,t)}}),S.fn.extend({trigger:function(e,t){return this.each(function(){S.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return S.event.trigger(e,t,n,!0)}}),v.focusin||S.each({focus:"focusin",blur:"focusout"},function(n,r){var i=function(e){S.event.simulate(r,e.target,S.event.fix(e))};S.event.special[r]={setup:function(){var e=this.ownerDocument||this.document||this,t=Y.access(e,r);t||e.addEventListener(n,i,!0),Y.access(e,r,(t||0)+1)},teardown:function(){var e=this.ownerDocument||this.document||this,t=Y.access(e,r)-1;t?Y.access(e,r,t):(e.removeEventListener(n,i,!0),Y.remove(e,r))}}});var Tt=C.location,Ct={guid:Date.now()},Et=/\?/;S.parseXML=function(e){var t,n;if(!e||"string"!=typeof e)return null;try{t=(new C.DOMParser).parseFromString(e,"text/xml")}catch(e){}return n=t&&t.getElementsByTagName("parsererror")[0],t&&!n||S.error("Invalid XML: "+(n?S.map(n.childNodes,function(e){return e.textContent}).join("\n"):e)),t};var St=/\[\]$/,kt=/\r?\n/g,At=/^(?:submit|button|image|reset|file)$/i,Nt=/^(?:input|select|textarea|keygen)/i;function jt(n,e,r,i){var t;if(Array.isArray(e))S.each(e,function(e,t){r||St.test(n)?i(n,t):jt(n+"["+("object"==typeof t&&null!=t?e:"")+"]",t,r,i)});else if(r||"object"!==w(e))i(n,e);else for(t in e)jt(n+"["+t+"]",e[t],r,i)}S.param=function(e,t){var n,r=[],i=function(e,t){var n=m(t)?t():t;r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(null==e)return"";if(Array.isArray(e)||e.jquery&&!S.isPlainObject(e))S.each(e,function(){i(this.name,this.value)});else for(n in e)jt(n,e[n],t,i);return r.join("&")},S.fn.extend({serialize:function(){return S.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=S.prop(this,"elements");return e?S.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!S(this).is(":disabled")&&Nt.test(this.nodeName)&&!At.test(e)&&(this.checked||!pe.test(e))}).map(function(e,t){var n=S(this).val();return null==n?null:Array.isArray(n)?S.map(n,function(e){return{name:t.name,value:e.replace(kt,"\r\n")}}):{name:t.name,value:n.replace(kt,"\r\n")}}).get()}});var Dt=/%20/g,qt=/#.*$/,Lt=/([?&])_=[^&]*/,Ht=/^(.*?):[ \t]*([^\r\n]*)$/gm,Ot=/^(?:GET|HEAD)$/,Pt=/^\/\//,Rt={},Mt={},It="*/".concat("*"),Wt=E.createElement("a");function Ft(o){return function(e,t){"string"!=typeof e&&(t=e,e="*");var n,r=0,i=e.toLowerCase().match(P)||[];if(m(t))while(n=i[r++])"+"===n[0]?(n=n.slice(1)||"*",(o[n]=o[n]||[]).unshift(t)):(o[n]=o[n]||[]).push(t)}}function $t(t,i,o,a){var s={},u=t===Mt;function l(e){var r;return s[e]=!0,S.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 Bt(e,t){var n,r,i=S.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&S.extend(!0,e,r),e}Wt.href=Tt.href,S.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Tt.href,type:"GET",isLocal:/^(?:about|app|app-storage|.+-extension|file|res|widget):$/.test(Tt.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":It,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":S.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?Bt(Bt(e,S.ajaxSettings),t):Bt(S.ajaxSettings,e)},ajaxPrefilter:Ft(Rt),ajaxTransport:Ft(Mt),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,y=S.ajaxSetup({},t),v=y.context||y,m=y.context&&(v.nodeType||v.jquery)?S(v):S.event,x=S.Deferred(),b=S.Callbacks("once memory"),w=y.statusCode||{},a={},s={},u="canceled",T={readyState:0,getResponseHeader:function(e){var t;if(h){if(!n){n={};while(t=Ht.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&&(y.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),y.url=((e||y.url||Tt.href)+"").replace(Pt,Tt.protocol+"//"),y.type=t.method||t.type||y.method||y.type,y.dataTypes=(y.dataType||"*").toLowerCase().match(P)||[""],null==y.crossDomain){r=E.createElement("a");try{r.href=y.url,r.href=r.href,y.crossDomain=Wt.protocol+"//"+Wt.host!=r.protocol+"//"+r.host}catch(e){y.crossDomain=!0}}if(y.data&&y.processData&&"string"!=typeof y.data&&(y.data=S.param(y.data,y.traditional)),$t(Rt,y,t,T),h)return T;for(i in(g=S.event&&y.global)&&0==S.active++&&S.event.trigger("ajaxStart"),y.type=y.type.toUpperCase(),y.hasContent=!Ot.test(y.type),f=y.url.replace(qt,""),y.hasContent?y.data&&y.processData&&0===(y.contentType||"").indexOf("application/x-www-form-urlencoded")&&(y.data=y.data.replace(Dt,"+")):(o=y.url.slice(f.length),y.data&&(y.processData||"string"==typeof y.data)&&(f+=(Et.test(f)?"&":"?")+y.data,delete y.data),!1===y.cache&&(f=f.replace(Lt,"$1"),o=(Et.test(f)?"&":"?")+"_="+Ct.guid+++o),y.url=f+o),y.ifModified&&(S.lastModified[f]&&T.setRequestHeader("If-Modified-Since",S.lastModified[f]),S.etag[f]&&T.setRequestHeader("If-None-Match",S.etag[f])),(y.data&&y.hasContent&&!1!==y.contentType||t.contentType)&&T.setRequestHeader("Content-Type",y.contentType),T.setRequestHeader("Accept",y.dataTypes[0]&&y.accepts[y.dataTypes[0]]?y.accepts[y.dataTypes[0]]+("*"!==y.dataTypes[0]?", "+It+"; q=0.01":""):y.accepts["*"]),y.headers)T.setRequestHeader(i,y.headers[i]);if(y.beforeSend&&(!1===y.beforeSend.call(v,T,y)||h))return T.abort();if(u="abort",b.add(y.complete),T.done(y.success),T.fail(y.error),c=$t(Mt,y,t,T)){if(T.readyState=1,g&&m.trigger("ajaxSend",[T,y]),h)return T;y.async&&0<y.timeout&&(d=C.setTimeout(function(){T.abort("timeout")},y.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&&C.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]}(y,T,n)),!i&&-1<S.inArray("script",y.dataTypes)&&S.inArray("json",y.dataTypes)<0&&(y.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}}(y,s,T,i),i?(y.ifModified&&((u=T.getResponseHeader("Last-Modified"))&&(S.lastModified[f]=u),(u=T.getResponseHeader("etag"))&&(S.etag[f]=u)),204===e||"HEAD"===y.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(v,[o,l,T]):x.rejectWith(v,[T,l,a]),T.statusCode(w),w=void 0,g&&m.trigger(i?"ajaxSuccess":"ajaxError",[T,y,i?o:a]),b.fireWith(v,[T,l]),g&&(m.trigger("ajaxComplete",[T,y]),--S.active||S.event.trigger("ajaxStop")))}return T},getJSON:function(e,t,n){return S.get(e,t,n,"json")},getScript:function(e,t){return S.get(e,void 0,t,"script")}}),S.each(["get","post"],function(e,i){S[i]=function(e,t,n,r){return m(t)&&(r=r||n,n=t,t=void 0),S.ajax(S.extend({url:e,type:i,dataType:r,data:t,success:n},S.isPlainObject(e)&&e))}}),S.ajaxPrefilter(function(e){var t;for(t in e.headers)"content-type"===t.toLowerCase()&&(e.contentType=e.headers[t]||"")}),S._evalUrl=function(e,t,n){return S.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,converters:{"text script":function(){}},dataFilter:function(e){S.globalEval(e,t,n)}})},S.fn.extend({wrapAll:function(e){var t;return this[0]&&(m(e)&&(e=e.call(this[0])),t=S(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 m(n)?this.each(function(e){S(this).wrapInner(n.call(this,e))}):this.each(function(){var e=S(this),t=e.contents();t.length?t.wrapAll(n):e.append(n)})},wrap:function(t){var n=m(t);return this.each(function(e){S(this).wrapAll(n?t.call(this,e):t)})},unwrap:function(e){return this.parent(e).not("body").each(function(){S(this).replaceWith(this.childNodes)}),this}}),S.expr.pseudos.hidden=function(e){return!S.expr.pseudos.visible(e)},S.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},S.ajaxSettings.xhr=function(){try{return new C.XMLHttpRequest}catch(e){}};var _t={0:200,1223:204},zt=S.ajaxSettings.xhr();v.cors=!!zt&&"withCredentials"in zt,v.ajax=zt=!!zt,S.ajaxTransport(function(i){var o,a;if(v.cors||zt&&!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(_t[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&&C.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()}}}),S.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),S.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 S.globalEval(e),e}}}),S.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),S.ajaxTransport("script",function(n){var r,i;if(n.crossDomain||n.scriptAttrs)return{send:function(e,t){r=S("<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)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var Ut,Xt=[],Vt=/(=)\?(?=&|$)|\?\?/;S.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Xt.pop()||S.expando+"_"+Ct.guid++;return this[e]=!0,e}}),S.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Vt.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Vt.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Vt,"$1"+r):!1!==e.jsonp&&(e.url+=(Et.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||S.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?S(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,Xt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),v.createHTMLDocument=((Ut=E.implementation.createHTMLDocument("").body).innerHTML="<form></form><form></form>",2===Ut.childNodes.length),S.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(v.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=N.exec(e))?[t.createElement(i[1])]:(i=xe([e],t,o),o&&o.length&&S(o).remove(),S.merge([],i.childNodes)));var r,i,o},S.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1<s&&(r=yt(e.slice(s)),e=e.slice(0,s)),m(t)?(n=t,t=void 0):t&&"object"==typeof t&&(i="POST"),0<a.length&&S.ajax({url:e,type:i||"GET",dataType:"html",data:t}).done(function(e){o=arguments,a.html(r?S("<div>").append(S.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},S.expr.pseudos.animated=function(t){return S.grep(S.timers,function(e){return t===e.elem}).length},S.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=S.css(e,"position"),c=S(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=S.css(e,"top"),u=S.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),m(t)&&(t=t.call(e,n,S.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)}},S.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){S.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"===S.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"===S.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=S(e).offset()).top+=S.css(e,"borderTopWidth",!0),i.left+=S.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-S.css(r,"marginTop",!0),left:t.left-i.left-S.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===S.css(e,"position"))e=e.offsetParent;return e||re})}}),S.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;S.fn[t]=function(e){return B(this,function(e,t,n){var r;if(x(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)}}),S.each(["top","left"],function(e,n){S.cssHooks[n]=_e(v.pixelPosition,function(e,t){if(t)return t=Be(e,n),Pe.test(t)?S(e).position()[n]+"px":t})}),S.each({Height:"height",Width:"width"},function(a,s){S.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){S.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return B(this,function(e,t,n){var r;return x(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?S.css(e,t,i):S.style(e,t,n,i)},s,n?e:void 0,n)}})}),S.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){S.fn[t]=function(e){return this.on(t,e)}}),S.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.mouseenter(e).mouseleave(t||e)}}),S.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){S.fn[n]=function(e,t){return 0<arguments.length?this.on(n,null,e,t):this.trigger(n)}});var Gt=/^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;S.proxy=function(e,t){var n,r,i;if("string"==typeof t&&(n=e[t],t=e,e=n),m(e))return r=s.call(arguments,2),(i=function(){return e.apply(t||this,r.concat(s.call(arguments)))}).guid=e.guid=e.guid||S.guid++,i},S.holdReady=function(e){e?S.readyWait++:S.ready(!0)},S.isArray=Array.isArray,S.parseJSON=JSON.parse,S.nodeName=A,S.isFunction=m,S.isWindow=x,S.camelCase=X,S.type=w,S.now=Date.now,S.isNumeric=function(e){var t=S.type(e);return("number"===t||"string"===t)&&!isNaN(e-parseFloat(e))},S.trim=function(e){return null==e?"":(e+"").replace(Gt,"$1")},"function"==typeof define&&define.amd&&define("jquery",[],function(){return S});var Yt=C.jQuery,Qt=C.$;return S.noConflict=function(e){return C.$===S&&(C.$=Qt),e&&C.jQuery===S&&(C.jQuery=Yt),S},"undefined"==typeof e&&(C.jQuery=C.$=S),S});
  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', 'drag', 'drop', 'addtabs', 'selectpage', 'bootstrap-daterangepicker'],
  19. paths: {
  20. 'lang': "empty:",
  21. 'form': 'require-form',
  22. 'table': 'require-table',
  23. 'upload': 'require-upload',
  24. 'drag': 'jquery.drag.min',
  25. 'drop': 'jquery.drop.min',
  26. 'dropzone': 'dropzone.min',
  27. 'echarts': 'echarts.min',
  28. 'echarts-theme': 'echarts-theme',
  29. 'adminlte': 'adminlte',
  30. 'bootstrap-table-commonsearch': 'bootstrap-table-commonsearch',
  31. 'bootstrap-table-template': 'bootstrap-table-template',
  32. // 以下的包从libs目录加载
  33. 'jquery': '../libs/jquery/dist/jquery.min',
  34. 'bootstrap': '../libs/bootstrap/dist/js/bootstrap.min',
  35. 'bootstrap-datetimepicker': '../libs/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min',
  36. 'bootstrap-daterangepicker': '../libs/bootstrap-daterangepicker/daterangepicker',
  37. 'bootstrap-select': '../libs/bootstrap-select/dist/js/bootstrap-select.min',
  38. 'bootstrap-select-lang': '../libs/bootstrap-select/dist/js/i18n/defaults-zh_CN',
  39. 'bootstrap-table': '../libs/fastadmin-bootstraptable/dist/bootstrap-table.min',
  40. 'bootstrap-table-export': '../libs/fastadmin-bootstraptable/dist/extensions/export/bootstrap-table-export',
  41. 'bootstrap-table-fixed-columns': '../libs/fastadmin-bootstraptable/dist/extensions/fixed-columns/bootstrap-table-fixed-columns',
  42. 'bootstrap-table-mobile': '../libs/fastadmin-bootstraptable/dist/extensions/mobile/bootstrap-table-mobile.min',
  43. 'bootstrap-table-lang': '../libs/fastadmin-bootstraptable/dist/locale/bootstrap-table-zh-CN',
  44. 'bootstrap-table-jumpto': '../libs/fastadmin-bootstraptable/dist/extensions/page-jumpto/bootstrap-table-jumpto',
  45. 'bootstrap-slider': '../libs/bootstrap-slider/dist/bootstrap-slider.min',
  46. 'tableexport': '../libs/tableexport.jquery.plugin/tableExport.min',
  47. 'dragsort': '../libs/fastadmin-dragsort/jquery.dragsort',
  48. 'sortable': '../libs/sortablejs/Sortable.min',
  49. 'addtabs': '../libs/fastadmin-addtabs/jquery.addtabs',
  50. 'slimscroll': '../libs/jquery-slimscroll/jquery.slimscroll',
  51. 'validator': '../libs/nice-validator/dist/jquery.validator',
  52. 'validator-lang': '../libs/nice-validator/dist/local/zh-CN',
  53. 'toastr': '../libs/toastr/toastr',
  54. 'jstree': '../libs/jstree/dist/jstree.min',
  55. 'layer': '../libs/fastadmin-layer/dist/layer',
  56. 'cookie': '../libs/jquery.cookie/jquery.cookie',
  57. 'cxselect': '../libs/fastadmin-cxselect/js/jquery.cxselect',
  58. 'template': '../libs/art-template/dist/template-native',
  59. 'selectpage': '../libs/fastadmin-selectpage/selectpage',
  60. 'coloris': '../libs/coloris/dist/umd/coloris.min',
  61. 'citypicker': '../libs/fastadmin-citypicker/dist/js/city-picker.min',
  62. 'citypicker-data': '../libs/fastadmin-citypicker/dist/js/city-picker.data',
  63. },
  64. // shim依赖配置
  65. shim: {
  66. 'addons': ['backend'],
  67. 'bootstrap': ['jquery'],
  68. 'bootstrap-table': {
  69. deps: ['bootstrap'],
  70. exports: '$.fn.bootstrapTable'
  71. },
  72. 'bootstrap-table-lang': {
  73. deps: ['bootstrap-table'],
  74. exports: '$.fn.bootstrapTable.defaults'
  75. },
  76. 'bootstrap-table-export': {
  77. deps: ['bootstrap-table'],
  78. exports: '$.fn.bootstrapTable.defaults'
  79. },
  80. 'bootstrap-table-fixed-columns': {
  81. deps: ['bootstrap-table'],
  82. exports: '$.fn.bootstrapTable.defaults'
  83. },
  84. 'bootstrap-table-mobile': {
  85. deps: ['bootstrap-table'],
  86. exports: '$.fn.bootstrapTable.defaults'
  87. },
  88. 'bootstrap-table-advancedsearch': {
  89. deps: ['bootstrap-table'],
  90. exports: '$.fn.bootstrapTable.defaults'
  91. },
  92. 'bootstrap-table-commonsearch': {
  93. deps: ['bootstrap-table'],
  94. exports: '$.fn.bootstrapTable.defaults'
  95. },
  96. 'bootstrap-table-template': {
  97. deps: ['bootstrap-table', 'template'],
  98. exports: '$.fn.bootstrapTable.defaults'
  99. },
  100. 'bootstrap-table-jumpto': {
  101. deps: ['bootstrap-table'],
  102. exports: '$.fn.bootstrapTable.defaults'
  103. },
  104. 'tableexport': {
  105. deps: ['jquery'],
  106. exports: '$.fn.extend'
  107. },
  108. 'slimscroll': {
  109. deps: ['jquery'],
  110. exports: '$.fn.extend'
  111. },
  112. 'adminlte': {
  113. deps: ['bootstrap', 'slimscroll'],
  114. exports: '$.AdminLTE'
  115. },
  116. 'table': [
  117. 'moment', 'moment/locale/zh-cn',
  118. 'bootstrap-table',
  119. 'bootstrap-table-lang', 'bootstrap-table-export', 'bootstrap-table-commonsearch', 'bootstrap-table-template',
  120. 'bootstrap-table-jumpto', 'bootstrap-table-fixed-columns'
  121. ],
  122. 'bootstrap-daterangepicker': ['moment', 'moment/locale/zh-cn'],
  123. 'bootstrap-datetimepicker': ['moment', 'moment/locale/zh-cn'],
  124. 'bootstrap-select-lang': ['bootstrap-select'],
  125. 'selectpage': {
  126. deps: ['jquery'],
  127. exports: '$.fn.extend'
  128. },
  129. 'layer': {
  130. deps: ['jquery']
  131. },
  132. 'jstree': ['css!../libs/jstree/dist/themes/default/style.css'],
  133. 'validator-lang': ['validator'],
  134. 'coloris': ['css!../libs/coloris/dist/coloris.min.css'],
  135. 'citypicker': ['citypicker-data', 'css!../libs/fastadmin-citypicker/dist/css/city-picker.css']
  136. },
  137. baseUrl: requirejs.s.contexts._.config.config.site.cdnurl + '/assets/js/', //资源基础路径
  138. map: {
  139. '*': {
  140. 'css': '../libs/require-css/css.min'
  141. }
  142. },
  143. waitSeconds: 60,
  144. charset: 'utf-8' // 文件编码
  145. });
  146. require(['jquery', 'bootstrap'], function ($, undefined) {
  147. //初始配置
  148. var Config = requirejs.s.contexts._.config.config;
  149. //将Config渲染到全局
  150. window.Config = Config;
  151. // 配置语言包的路径
  152. var paths = {};
  153. paths['lang'] = Config.moduleurl + '/ajax/lang?callback=define&controllername=' + Config.controllername + '&lang=' + Config.language + '&v=' + Config.site.version;
  154. // 避免目录冲突
  155. paths['backend/'] = 'backend/';
  156. // 如果是英文,则移除默认的定义
  157. if (Config.language === 'en') {
  158. $.each(requirejs.s.contexts._.config.paths, function (key, value) {
  159. if (key.match(/\-lang$/)) {
  160. define('require-backend',key);
  161. }
  162. });
  163. define('moment/locale/zh-cn');
  164. }
  165. require.config({paths: paths});
  166. // 初始化
  167. $(function () {
  168. require(['fast'], function (Fast) {
  169. require(['backend', 'backend-init', 'addons'], function (Backend, undefined, Addons) {
  170. //加载相应模块
  171. if (Config.jsname) {
  172. require([Config.jsname], function (Controller) {
  173. if (Controller.hasOwnProperty(Config.actionname)) {
  174. Controller[Config.actionname]();
  175. } else {
  176. if (Controller.hasOwnProperty("_empty")) {
  177. Controller._empty();
  178. }
  179. }
  180. }, function (e) {
  181. console.error(e);
  182. // 这里可捕获模块加载的错误
  183. });
  184. }
  185. });
  186. });
  187. });
  188. });
  189. 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});
  190. /*! layer-v3.5.3 Web 通用弹出层组件 MIT License http://layer.layui.com/ By 贤心 */
  191. ;!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(),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);
  192. /*
  193. * Toastr
  194. * Copyright 2012-2015
  195. * Authors: John Papa, Hans Fjällemark, and Tim Ferrell.
  196. * All Rights Reserved.
  197. * Use, reproduction, distribution, and modification of this code is subject to the terms and
  198. * conditions of the MIT license, available at http://www.opensource.org/licenses/mit-license.php
  199. *
  200. * ARIA Support: Greta Krafsig
  201. *
  202. * Project: https://github.com/CodeSeven/toastr
  203. */
  204. /* global define */
  205. (function (define) {
  206. define('toastr',['jquery'], function ($) {
  207. return (function () {
  208. var $container;
  209. var listener;
  210. var toastId = 0;
  211. var toastType = {
  212. error: 'error',
  213. info: 'info',
  214. success: 'success',
  215. warning: 'warning'
  216. };
  217. var toastr = {
  218. clear: clear,
  219. remove: remove,
  220. error: error,
  221. getContainer: getContainer,
  222. info: info,
  223. options: {},
  224. subscribe: subscribe,
  225. success: success,
  226. version: '2.1.4',
  227. warning: warning
  228. };
  229. var previousToast;
  230. return toastr;
  231. ////////////////
  232. function error(message, title, optionsOverride) {
  233. return notify({
  234. type: toastType.error,
  235. iconClass: getOptions().iconClasses.error,
  236. message: message,
  237. optionsOverride: optionsOverride,
  238. title: title
  239. });
  240. }
  241. function getContainer(options, create) {
  242. if (!options) { options = getOptions(); }
  243. $container = $('#' + options.containerId);
  244. if ($container.length) {
  245. return $container;
  246. }
  247. if (create) {
  248. $container = createContainer(options);
  249. }
  250. return $container;
  251. }
  252. function info(message, title, optionsOverride) {
  253. return notify({
  254. type: toastType.info,
  255. iconClass: getOptions().iconClasses.info,
  256. message: message,
  257. optionsOverride: optionsOverride,
  258. title: title
  259. });
  260. }
  261. function subscribe(callback) {
  262. listener = callback;
  263. }
  264. function success(message, title, optionsOverride) {
  265. return notify({
  266. type: toastType.success,
  267. iconClass: getOptions().iconClasses.success,
  268. message: message,
  269. optionsOverride: optionsOverride,
  270. title: title
  271. });
  272. }
  273. function warning(message, title, optionsOverride) {
  274. return notify({
  275. type: toastType.warning,
  276. iconClass: getOptions().iconClasses.warning,
  277. message: message,
  278. optionsOverride: optionsOverride,
  279. title: title
  280. });
  281. }
  282. function clear($toastElement, clearOptions) {
  283. var options = getOptions();
  284. if (!$container) { getContainer(options); }
  285. if (!clearToast($toastElement, options, clearOptions)) {
  286. clearContainer(options);
  287. }
  288. }
  289. function remove($toastElement) {
  290. var options = getOptions();
  291. if (!$container) { getContainer(options); }
  292. if ($toastElement && $(':focus', $toastElement).length === 0) {
  293. removeToast($toastElement);
  294. return;
  295. }
  296. if ($container.children().length) {
  297. $container.remove();
  298. }
  299. }
  300. // internal functions
  301. function clearContainer (options) {
  302. var toastsToClear = $container.children();
  303. for (var i = toastsToClear.length - 1; i >= 0; i--) {
  304. clearToast($(toastsToClear[i]), options);
  305. }
  306. }
  307. function clearToast ($toastElement, options, clearOptions) {
  308. var force = clearOptions && clearOptions.force ? clearOptions.force : false;
  309. if ($toastElement && (force || $(':focus', $toastElement).length === 0)) {
  310. $toastElement[options.hideMethod]({
  311. duration: options.hideDuration,
  312. easing: options.hideEasing,
  313. complete: function () { removeToast($toastElement); }
  314. });
  315. return true;
  316. }
  317. return false;
  318. }
  319. function createContainer(options) {
  320. $container = $('<div/>')
  321. .attr('id', options.containerId)
  322. .addClass(options.positionClass);
  323. $container.appendTo($(options.target));
  324. return $container;
  325. }
  326. function getDefaults() {
  327. return {
  328. tapToDismiss: true,
  329. toastClass: 'toast',
  330. containerId: 'toast-container',
  331. debug: false,
  332. showMethod: 'fadeIn', //fadeIn, slideDown, and show are built into jQuery
  333. showDuration: 300,
  334. showEasing: 'swing', //swing and linear are built into jQuery
  335. onShown: undefined,
  336. hideMethod: 'fadeOut',
  337. hideDuration: 1000,
  338. hideEasing: 'swing',
  339. onHidden: undefined,
  340. closeMethod: false,
  341. closeDuration: false,
  342. closeEasing: false,
  343. closeOnHover: true,
  344. extendedTimeOut: 1000,
  345. iconClasses: {
  346. error: 'toast-error',
  347. info: 'toast-info',
  348. success: 'toast-success',
  349. warning: 'toast-warning'
  350. },
  351. iconClass: 'toast-info',
  352. positionClass: 'toast-top-right',
  353. timeOut: 5000, // Set timeOut and extendedTimeOut to 0 to make it sticky
  354. titleClass: 'toast-title',
  355. messageClass: 'toast-message',
  356. escapeHtml: false,
  357. target: 'body',
  358. closeHtml: '<button type="button">&times;</button>',
  359. closeClass: 'toast-close-button',
  360. newestOnTop: true,
  361. preventDuplicates: false,
  362. progressBar: false,
  363. progressClass: 'toast-progress',
  364. rtl: false
  365. };
  366. }
  367. function publish(args) {
  368. if (!listener) { return; }
  369. listener(args);
  370. }
  371. function notify(map) {
  372. var options = getOptions();
  373. var iconClass = map.iconClass || options.iconClass;
  374. if (typeof (map.optionsOverride) !== 'undefined') {
  375. options = $.extend(options, map.optionsOverride);
  376. iconClass = map.optionsOverride.iconClass || iconClass;
  377. }
  378. if (shouldExit(options, map)) { return; }
  379. toastId++;
  380. $container = getContainer(options, true);
  381. var intervalId = null;
  382. var $toastElement = $('<div/>');
  383. var $titleElement = $('<div/>');
  384. var $messageElement = $('<div/>');
  385. var $progressElement = $('<div/>');
  386. var $closeElement = $(options.closeHtml);
  387. var progressBar = {
  388. intervalId: null,
  389. hideEta: null,
  390. maxHideTime: null
  391. };
  392. var response = {
  393. toastId: toastId,
  394. state: 'visible',
  395. startTime: new Date(),
  396. options: options,
  397. map: map
  398. };
  399. personalizeToast();
  400. displayToast();
  401. handleEvents();
  402. publish(response);
  403. if (options.debug && console) {
  404. console.log(response);
  405. }
  406. return $toastElement;
  407. function escapeHtml(source) {
  408. if (source == null) {
  409. source = '';
  410. }
  411. return source
  412. .replace(/&/g, '&amp;')
  413. .replace(/"/g, '&quot;')
  414. .replace(/'/g, '&#39;')
  415. .replace(/</g, '&lt;')
  416. .replace(/>/g, '&gt;');
  417. }
  418. function personalizeToast() {
  419. setIcon();
  420. setTitle();
  421. setMessage();
  422. setCloseButton();
  423. setProgressBar();
  424. setRTL();
  425. setSequence();
  426. setAria();
  427. }
  428. function setAria() {
  429. var ariaValue = '';
  430. switch (map.iconClass) {
  431. case 'toast-success':
  432. case 'toast-info':
  433. ariaValue = 'polite';
  434. break;
  435. default:
  436. ariaValue = 'assertive';
  437. }
  438. $toastElement.attr('aria-live', ariaValue);
  439. }
  440. function handleEvents() {
  441. if (options.closeOnHover) {
  442. $toastElement.hover(stickAround, delayedHideToast);
  443. }
  444. if (!options.onclick && options.tapToDismiss) {
  445. $toastElement.click(hideToast);
  446. }
  447. if (options.closeButton && $closeElement) {
  448. $closeElement.click(function (event) {
  449. if (event.stopPropagation) {
  450. event.stopPropagation();
  451. } else if (event.cancelBubble !== undefined && event.cancelBubble !== true) {
  452. event.cancelBubble = true;
  453. }
  454. if (options.onCloseClick) {
  455. options.onCloseClick(event);
  456. }
  457. hideToast(true);
  458. });
  459. }
  460. if (options.onclick) {
  461. $toastElement.click(function (event) {
  462. options.onclick(event);
  463. hideToast();
  464. });
  465. }
  466. }
  467. function displayToast() {
  468. $toastElement.hide();
  469. $toastElement[options.showMethod](
  470. {duration: options.showDuration, easing: options.showEasing, complete: options.onShown}
  471. );
  472. if (options.timeOut > 0) {
  473. intervalId = setTimeout(hideToast, options.timeOut);
  474. progressBar.maxHideTime = parseFloat(options.timeOut);
  475. progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime;
  476. if (options.progressBar) {
  477. progressBar.intervalId = setInterval(updateProgress, 10);
  478. }
  479. }
  480. }
  481. function setIcon() {
  482. if (map.iconClass) {
  483. $toastElement.addClass(options.toastClass).addClass(iconClass);
  484. }
  485. }
  486. function setSequence() {
  487. if (options.newestOnTop) {
  488. $container.prepend($toastElement);
  489. } else {
  490. $container.append($toastElement);
  491. }
  492. }
  493. function setTitle() {
  494. if (map.title) {
  495. var suffix = map.title;
  496. if (options.escapeHtml) {
  497. suffix = escapeHtml(map.title);
  498. }
  499. $titleElement.append(suffix).addClass(options.titleClass);
  500. $toastElement.append($titleElement);
  501. }
  502. }
  503. function setMessage() {
  504. if (map.message) {
  505. var suffix = map.message;
  506. if (options.escapeHtml) {
  507. suffix = escapeHtml(map.message);
  508. }
  509. $messageElement.append(suffix).addClass(options.messageClass);
  510. $toastElement.append($messageElement);
  511. }
  512. }
  513. function setCloseButton() {
  514. if (options.closeButton) {
  515. $closeElement.addClass(options.closeClass).attr('role', 'button');
  516. $toastElement.prepend($closeElement);
  517. }
  518. }
  519. function setProgressBar() {
  520. if (options.progressBar) {
  521. $progressElement.addClass(options.progressClass);
  522. $toastElement.prepend($progressElement);
  523. }
  524. }
  525. function setRTL() {
  526. if (options.rtl) {
  527. $toastElement.addClass('rtl');
  528. }
  529. }
  530. function shouldExit(options, map) {
  531. if (options.preventDuplicates) {
  532. if (map.message === previousToast) {
  533. return true;
  534. } else {
  535. previousToast = map.message;
  536. }
  537. }
  538. return false;
  539. }
  540. function hideToast(override) {
  541. var method = override && options.closeMethod !== false ? options.closeMethod : options.hideMethod;
  542. var duration = override && options.closeDuration !== false ?
  543. options.closeDuration : options.hideDuration;
  544. var easing = override && options.closeEasing !== false ? options.closeEasing : options.hideEasing;
  545. if ($(':focus', $toastElement).length && !override) {
  546. return;
  547. }
  548. clearTimeout(progressBar.intervalId);
  549. return $toastElement[method]({
  550. duration: duration,
  551. easing: easing,
  552. complete: function () {
  553. removeToast($toastElement);
  554. clearTimeout(intervalId);
  555. if (options.onHidden && response.state !== 'hidden') {
  556. options.onHidden();
  557. }
  558. response.state = 'hidden';
  559. response.endTime = new Date();
  560. publish(response);
  561. }
  562. });
  563. }
  564. function delayedHideToast() {
  565. if (options.timeOut > 0 || options.extendedTimeOut > 0) {
  566. intervalId = setTimeout(hideToast, options.extendedTimeOut);
  567. progressBar.maxHideTime = parseFloat(options.extendedTimeOut);
  568. progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime;
  569. }
  570. }
  571. function stickAround() {
  572. clearTimeout(intervalId);
  573. progressBar.hideEta = 0;
  574. $toastElement.stop(true, true)[options.showMethod](
  575. {duration: options.showDuration, easing: options.showEasing}
  576. );
  577. }
  578. function updateProgress() {
  579. var percentage = ((progressBar.hideEta - (new Date().getTime())) / progressBar.maxHideTime) * 100;
  580. $progressElement.width(percentage + '%');
  581. }
  582. }
  583. function getOptions() {
  584. return $.extend({}, getDefaults(), toastr.options);
  585. }
  586. function removeToast($toastElement) {
  587. if (!$container) { $container = getContainer(); }
  588. if ($toastElement.is(':visible')) {
  589. return;
  590. }
  591. $toastElement.remove();
  592. $toastElement = null;
  593. if ($container.children().length === 0) {
  594. $container.remove();
  595. previousToast = undefined;
  596. }
  597. }
  598. })();
  599. });
  600. }(typeof define === 'function' && define.amd ? define : function (deps, factory) {
  601. if (typeof module !== 'undefined' && module.exports) { //Node
  602. module.exports = factory(require('jquery'));
  603. } else {
  604. window.toastr = factory(window.jQuery);
  605. }
  606. }));
  607. define('fast',['jquery', 'bootstrap', 'toastr', 'layer', 'lang'], function ($, undefined, Toastr, Layer, Lang) {
  608. var Fast = {
  609. config: {
  610. //toastr默认配置
  611. toastr: {
  612. "closeButton": true,
  613. "debug": false,
  614. "newestOnTop": false,
  615. "progressBar": false,
  616. "positionClass": "toast-top-center",
  617. "preventDuplicates": false,
  618. "onclick": null,
  619. "showDuration": "300",
  620. "hideDuration": "1000",
  621. "timeOut": "5000",
  622. "extendedTimeOut": "1000",
  623. "showEasing": "swing",
  624. "hideEasing": "linear",
  625. "showMethod": "fadeIn",
  626. "hideMethod": "fadeOut"
  627. }
  628. },
  629. events: {
  630. //请求成功的回调
  631. onAjaxSuccess: function (ret, onAjaxSuccess) {
  632. var data = typeof ret.data !== 'undefined' ? ret.data : null;
  633. var msg = typeof ret.msg !== 'undefined' && ret.msg ? ret.msg : __('Operation completed');
  634. if (typeof onAjaxSuccess === 'function') {
  635. var result = onAjaxSuccess.call(this, data, ret);
  636. if (result === false)
  637. return;
  638. }
  639. Toastr.success(msg);
  640. },
  641. //请求错误的回调
  642. onAjaxError: function (ret, onAjaxError) {
  643. var data = typeof ret.data !== 'undefined' ? ret.data : null;
  644. if (typeof onAjaxError === 'function') {
  645. var result = onAjaxError.call(this, data, ret);
  646. if (result === false) {
  647. return;
  648. }
  649. }
  650. Toastr.error(ret.msg);
  651. },
  652. //服务器响应数据后
  653. onAjaxResponse: function (response) {
  654. try {
  655. var ret = typeof response === 'object' ? response : JSON.parse(response);
  656. if (!ret.hasOwnProperty('code')) {
  657. $.extend(ret, {code: -2, msg: response, data: null});
  658. }
  659. } catch (e) {
  660. var ret = {code: -1, msg: e.message, data: null};
  661. }
  662. return ret;
  663. }
  664. },
  665. api: {
  666. //发送Ajax请求
  667. ajax: function (options, success, error) {
  668. options = typeof options === 'string' ? {url: options} : options;
  669. var index;
  670. if (typeof options.loading === 'undefined' || options.loading) {
  671. index = Layer.load(options.loading || 0);
  672. }
  673. options = $.extend({
  674. type: "POST",
  675. dataType: "json",
  676. xhrFields: {
  677. withCredentials: true
  678. },
  679. success: function (ret) {
  680. index && Layer.close(index);
  681. ret = Fast.events.onAjaxResponse(ret);
  682. if (ret.code === 1) {
  683. Fast.events.onAjaxSuccess(ret, success);
  684. } else {
  685. Fast.events.onAjaxError(ret, error);
  686. }
  687. },
  688. error: function (xhr) {
  689. index && Layer.close(index);
  690. var ret = {code: xhr.status, msg: xhr.statusText, data: null};
  691. Fast.events.onAjaxError(ret, error);
  692. }
  693. }, options);
  694. return $.ajax(options);
  695. },
  696. //修复URL
  697. fixurl: function (url) {
  698. if (url.substr(0, 1) !== "/") {
  699. var r = new RegExp('^(?:[a-z]+:)?//', 'i');
  700. if (!r.test(url)) {
  701. url = Config.moduleurl + "/" + url;
  702. }
  703. } else if (url.substr(0, 8) === "/addons/") {
  704. url = Config.__PUBLIC__.replace(/(\/*$)/g, "") + url;
  705. }
  706. return url;
  707. },
  708. //获取修复后可访问的cdn链接
  709. cdnurl: function (url, domain) {
  710. var rule = new RegExp("^((?:[a-z]+:)?\\/\\/|data:image\\/)", "i");
  711. if(typeof domain === 'undefined'){
  712. var cdnurl = Config.upload.cdnurl;
  713. url = rule.test(url) || (cdnurl && url.indexOf(cdnurl) === 0) ? url : cdnurl + url;
  714. }
  715. if (domain && !rule.test(url)) {
  716. domain = typeof domain === 'string' ? domain : location.origin;
  717. url = domain + url;
  718. }
  719. return url;
  720. },
  721. //查询Url参数
  722. query: function (name, url) {
  723. if (!url) {
  724. url = window.location.href;
  725. }
  726. name = name.replace(/[\[\]]/g, "\\$&");
  727. var regex = new RegExp("[?&/]" + name + "([=/]([^&#/?]*)|&|#|$)"),
  728. results = regex.exec(url);
  729. if (!results)
  730. return null;
  731. if (!results[2])
  732. return '';
  733. return decodeURIComponent(results[2].replace(/\+/g, " "));
  734. },
  735. //打开一个弹出窗口
  736. open: function (url, title, options) {
  737. title = options && options.title ? options.title : (title ? title : "");
  738. url = Fast.api.fixurl(url);
  739. url = url + (url.indexOf("?") > -1 ? "&" : "?") + "dialog=1";
  740. var area = Fast.config.openArea != undefined ? Fast.config.openArea : [$(window).width() > 800 ? '800px' : '95%', $(window).height() > 600 ? '600px' : '95%'];
  741. options = $.extend({
  742. type: 2,
  743. title: title,
  744. shadeClose: true,
  745. shade: false,
  746. maxmin: true,
  747. moveOut: true,
  748. area: area,
  749. content: url,
  750. zIndex: Layer.zIndex,
  751. success: function (layero, index) {
  752. var that = this;
  753. //存储callback事件
  754. $(layero).data("callback", that.callback);
  755. //$(layero).removeClass("layui-layer-border");
  756. Layer.setTop(layero);
  757. try {
  758. var frame = Layer.getChildFrame('html', index);
  759. var layerfooter = frame.find(".layer-footer");
  760. Fast.api.layerfooter(layero, index, that);
  761. //绑定事件
  762. if (layerfooter.length > 0) {
  763. // 监听窗口内的元素及属性变化
  764. // Firefox和Chrome早期版本中带有前缀
  765. var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
  766. if (MutationObserver) {
  767. // 选择目标节点
  768. var target = layerfooter[0];
  769. // 创建观察者对象
  770. var observer = new MutationObserver(function (mutations) {
  771. Fast.api.layerfooter(layero, index, that);
  772. mutations.forEach(function (mutation) {
  773. });
  774. });
  775. // 配置观察选项:
  776. var config = {attributes: true, childList: true, characterData: true, subtree: true}
  777. // 传入目标节点和观察选项
  778. observer.observe(target, config);
  779. // 随后,你还可以停止观察
  780. // observer.disconnect();
  781. }
  782. }
  783. } catch (e) {
  784. }
  785. if ($(layero).height() > $(window).height()) {
  786. //当弹出窗口大于浏览器可视高度时,重定位
  787. Layer.style(index, {
  788. top: 0,
  789. height: $(window).height()
  790. });
  791. }
  792. }
  793. }, options ? options : {});
  794. if ($(window).width() < 480 || (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream && top.$(".tab-pane.active").length > 0)) {
  795. if (top.$(".tab-pane.active").length > 0) {
  796. options.area = [top.$(".tab-pane.active").width() + "px", top.$(".tab-pane.active").height() + "px"];
  797. options.offset = [top.$(".tab-pane.active").scrollTop() + "px", "0px"];
  798. } else {
  799. options.area = [$(window).width() + "px", $(window).height() + "px"];
  800. options.offset = ["0px", "0px"];
  801. }
  802. }
  803. return Layer.open(options);
  804. },
  805. //关闭窗口并回传数据
  806. close: function (data) {
  807. var index = parent.Layer.getFrameIndex(window.name);
  808. var callback = parent.$("#layui-layer" + index).data("callback");
  809. //再执行关闭
  810. parent.Layer.close(index);
  811. //再调用回传函数
  812. if (typeof callback === 'function') {
  813. callback.call(undefined, data);
  814. }
  815. },
  816. layerfooter: function (layero, index, that) {
  817. var frame = Layer.getChildFrame('html', index);
  818. var layerfooter = frame.find(".layer-footer");
  819. if (layerfooter.length > 0) {
  820. $(".layui-layer-footer", layero).remove();
  821. var footer = $("<div />").addClass('layui-layer-btn layui-layer-footer');
  822. footer.html(layerfooter.html());
  823. if ($(".row", footer).length === 0) {
  824. $(">", footer).wrapAll("<div class='row'></div>");
  825. }
  826. footer.insertAfter(layero.find('.layui-layer-content'));
  827. //绑定事件
  828. footer.on("click", ".btn", function () {
  829. if ($(this).hasClass("disabled") || $(this).parent().hasClass("disabled")) {
  830. return;
  831. }
  832. var index = footer.find('.btn').index(this);
  833. $(".btn:eq(" + index + ")", layerfooter).trigger("click");
  834. });
  835. var titHeight = layero.find('.layui-layer-title').outerHeight() || 0;
  836. var btnHeight = layero.find('.layui-layer-btn').outerHeight() || 0;
  837. //重设iframe高度
  838. $("iframe", layero).height(layero.height() - titHeight - btnHeight);
  839. }
  840. //修复iOS下弹出窗口的高度和iOS下iframe无法滚动的BUG
  841. if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
  842. var titHeight = layero.find('.layui-layer-title').outerHeight() || 0;
  843. var btnHeight = layero.find('.layui-layer-btn').outerHeight() || 0;
  844. $("iframe", layero).parent().css("height", layero.height() - titHeight - btnHeight);
  845. $("iframe", layero).css("height", "100%");
  846. }
  847. },
  848. success: function (options, callback) {
  849. var type = typeof options === 'function';
  850. if (type) {
  851. callback = options;
  852. }
  853. return Layer.msg(__('Operation completed'), $.extend({
  854. offset: 0, icon: 1
  855. }, type ? {} : options), callback);
  856. },
  857. error: function (options, callback) {
  858. var type = typeof options === 'function';
  859. if (type) {
  860. callback = options;
  861. }
  862. return Layer.msg(__('Operation failed'), $.extend({
  863. offset: 0, icon: 2
  864. }, type ? {} : options), callback);
  865. },
  866. msg: function (message, url) {
  867. var callback = typeof url === 'function' ? url : function () {
  868. if (typeof url !== 'undefined' && url) {
  869. location.href = url;
  870. }
  871. };
  872. Layer.msg(message, {
  873. time: 2000
  874. }, callback);
  875. },
  876. toastr: Toastr,
  877. layer: Layer
  878. },
  879. lang: function () {
  880. var args = arguments,
  881. string = args[0],
  882. i = 1;
  883. string = string.toLowerCase();
  884. //string = typeof Lang[string] != 'undefined' ? Lang[string] : string;
  885. if (typeof Lang !== 'undefined' && typeof Lang[string] !== 'undefined') {
  886. if (typeof Lang[string] == 'object')
  887. return Lang[string];
  888. string = Lang[string];
  889. } else if (string.indexOf('.') !== -1 && false) {
  890. var arr = string.split('.');
  891. var current = Lang[arr[0]];
  892. for (var i = 1; i < arr.length; i++) {
  893. current = typeof current[arr[i]] != 'undefined' ? current[arr[i]] : '';
  894. if (typeof current != 'object')
  895. break;
  896. }
  897. if (typeof current == 'object')
  898. return current;
  899. string = current;
  900. } else {
  901. string = args[0];
  902. }
  903. return string.replace(/%((%)|s|d)/g, function (m) {
  904. // m is the matched format, e.g. %s, %d
  905. var val = null;
  906. if (m[2]) {
  907. val = m[2];
  908. } else {
  909. val = args[i];
  910. // A switch statement so that the formatter can be extended. Default is %s
  911. switch (m) {
  912. case '%d':
  913. val = parseFloat(val);
  914. if (isNaN(val)) {
  915. val = 0;
  916. }
  917. break;
  918. }
  919. i++;
  920. }
  921. return val;
  922. });
  923. },
  924. init: function () {
  925. // 对相对地址进行处理
  926. $.ajaxSetup({
  927. beforeSend: function (xhr, setting) {
  928. setting.url = Fast.api.fixurl(setting.url);
  929. }
  930. });
  931. Layer.config({
  932. skin: 'layui-layer-fast'
  933. });
  934. // 绑定ESC关闭窗口事件
  935. $(window).keyup(function (e) {
  936. if (e.keyCode == 27) {
  937. if ($(".layui-layer").length > 0) {
  938. var index = 0;
  939. $(".layui-layer").each(function () {
  940. index = Math.max(index, parseInt($(this).attr("times")));
  941. });
  942. if (index) {
  943. Layer.close(index);
  944. }
  945. }
  946. }
  947. });
  948. //公共代码
  949. //配置Toastr的参数
  950. Toastr.options = Fast.config.toastr;
  951. }
  952. };
  953. //将Layer暴露到全局中去
  954. window.Layer = Layer;
  955. //将Toastr暴露到全局中去
  956. window.Toastr = Toastr;
  957. //将语言方法暴露到全局中去
  958. window.__ = Fast.lang;
  959. //将Fast渲染至全局
  960. window.Fast = Fast;
  961. //默认初始化执行的代码
  962. Fast.init();
  963. return Fast;
  964. });
  965. /*!art-template - Template Engine | http://aui.github.com/artTemplate/*/
  966. !function(){function a(a){return a.replace(t,"").replace(u,",").replace(v,"").replace(w,"").replace(x,"").split(y)}function b(a){return"'"+a.replace(/('|\\)/g,"\\$1").replace(/\r/g,"\\r").replace(/\n/g,"\\n")+"'"}function c(c,d){function e(a){return m+=a.split(/\n/).length-1,k&&(a=a.replace(/\s+/g," ").replace(/<!--[\w\W]*?-->/g,"")),a&&(a=s[1]+b(a)+s[2]+"\n"),a}function f(b){var c=m;if(j?b=j(b,d):g&&(b=b.replace(/\n/g,function(){return m++,"$line="+m+";"})),0===b.indexOf("=")){var e=l&&!/^=[=#]/.test(b);if(b=b.replace(/^=[=#]?|[\s;]*$/g,""),e){var f=b.replace(/\s*\([^\)]+\)/,"");n[f]||/^(include|print)$/.test(f)||(b="$escape("+b+")")}else b="$string("+b+")";b=s[1]+b+s[2]}return g&&(b="$line="+c+";"+b),r(a(b),function(a){if(a&&!p[a]){var b;b="print"===a?u:"include"===a?v:n[a]?"$utils."+a:o[a]?"$helpers."+a:"$data."+a,w+=a+"="+b+",",p[a]=!0}}),b+"\n"}var g=d.debug,h=d.openTag,i=d.closeTag,j=d.parser,k=d.compress,l=d.escape,m=1,p={$data:1,$filename:1,$utils:1,$helpers:1,$out:1,$line:1},q="".trim,s=q?["$out='';","$out+=",";","$out"]:["$out=[];","$out.push(",");","$out.join('')"],t=q?"$out+=text;return $out;":"$out.push(text);",u="function(){var text=''.concat.apply('',arguments);"+t+"}",v="function(filename,data){data=data||$data;var text=$utils.$include(filename,data,$filename);"+t+"}",w="'use strict';var $utils=this,$helpers=$utils.$helpers,"+(g?"$line=0,":""),x=s[0],y="return new String("+s[3]+");";r(c.split(h),function(a){a=a.split(i);var b=a[0],c=a[1];1===a.length?x+=e(b):(x+=f(b),c&&(x+=e(c)))});var z=w+x+y;g&&(z="try{"+z+"}catch(e){throw {filename:$filename,name:'Render Error',message:e.message,line:$line,source:"+b(c)+".split(/\\n/)[$line-1].replace(/^\\s+/,'')};}");try{var A=new Function("$data","$filename",z);return A.prototype=n,A}catch(a){throw a.temp="function anonymous($data,$filename) {"+z+"}",a}}var d=function(a,b){return"string"==typeof b?q(b,{filename:a}):g(a,b)};d.version="3.0.0",d.config=function(a,b){e[a]=b};var e=d.defaults={openTag:"<%",closeTag:"%>",escape:!0,cache:!0,compress:!1,parser:null},f=d.cache={};d.render=function(a,b){return q(a)(b)};var g=d.renderFile=function(a,b){var c=d.get(a)||p({filename:a,name:"Render Error",message:"Template not found"});return b?c(b):c};d.get=function(a){var b;if(f[a])b=f[a];else if("object"==typeof document){var c=document.getElementById(a);if(c){var d=(c.value||c.innerHTML).replace(/^\s*|\s*$/g,"");b=q(d,{filename:a})}}return b};var h=function(a,b){return"string"!=typeof a&&(b=typeof a,"number"===b?a+="":a="function"===b?h(a.call(a)):""),a},i={"<":"&#60;",">":"&#62;",'"':"&#34;","'":"&#39;","&":"&#38;"},j=function(a){return i[a]},k=function(a){return h(a).replace(/&(?![\w#]+;)|[<>"']/g,j)},l=Array.isArray||function(a){return"[object Array]"==={}.toString.call(a)},m=function(a,b){var c,d;if(l(a))for(c=0,d=a.length;c<d;c++)b.call(a,a[c],c,a);else for(c in a)b.call(a,a[c],c)},n=d.utils={$helpers:{},$include:g,$string:h,$escape:k,$each:m};d.helper=function(a,b){o[a]=b};var o=d.helpers=n.$helpers;d.onerror=function(a){var b="Template Error\n\n";for(var c in a)b+="<"+c+">\n"+a[c]+"\n\n";"object"==typeof console&&console.error(b)};var p=function(a){return d.onerror(a),function(){return"{Template Error}"}},q=d.compile=function(a,b){function d(c){try{return new i(c,h)+""}catch(d){return b.debug?p(d)():(b.debug=!0,q(a,b)(c))}}b=b||{};for(var g in e)void 0===b[g]&&(b[g]=e[g]);var h=b.filename;try{var i=c(a,b)}catch(a){return a.filename=h||"anonymous",a.name="Syntax Error",p(a)}return d.prototype=i.prototype,d.toString=function(){return i.toString()},h&&b.cache&&(f[h]=d),d},r=n.$each,s="break,case,catch,continue,debugger,default,delete,do,else,false,finally,for,function,if,in,instanceof,new,null,return,switch,this,throw,true,try,typeof,var,void,while,with,abstract,boolean,byte,char,class,const,double,enum,export,extends,final,float,goto,implements,import,int,interface,long,native,package,private,protected,public,short,static,super,synchronized,throws,transient,volatile,arguments,let,yield,undefined",t=/\/\*[\w\W]*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|"(?:[^"\\]|\\[\w\W])*"|'(?:[^'\\]|\\[\w\W])*'|\s*\.\s*[$\w\.]+/g,u=/[^\w$]+/g,v=new RegExp(["\\b"+s.replace(/,/g,"\\b|\\b")+"\\b"].join("|"),"g"),w=/^\d[^,]*|,\d[^,]*/g,x=/^,+|,+$/g,y=/^$|,+/;"function"==typeof define?define('template',[],function(){return d}):"undefined"!=typeof exports?module.exports=d:this.template=d}();
  967. //! moment.js
  968. //! version : 2.29.4
  969. //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
  970. //! license : MIT
  971. //! momentjs.com
  972. ;(function (global, factory) {
  973. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  974. typeof define === 'function' && define.amd ? define('moment/moment',factory) :
  975. global.moment = factory()
  976. }(this, (function () { 'use strict';
  977. var hookCallback;
  978. function hooks() {
  979. return hookCallback.apply(null, arguments);
  980. }
  981. // This is done to register the method called with moment()
  982. // without creating circular dependencies.
  983. function setHookCallback(callback) {
  984. hookCallback = callback;
  985. }
  986. function isArray(input) {
  987. return (
  988. input instanceof Array ||
  989. Object.prototype.toString.call(input) === '[object Array]'
  990. );
  991. }
  992. function isObject(input) {
  993. // IE8 will treat undefined and null as object if it wasn't for
  994. // input != null
  995. return (
  996. input != null &&
  997. Object.prototype.toString.call(input) === '[object Object]'
  998. );
  999. }
  1000. function hasOwnProp(a, b) {
  1001. return Object.prototype.hasOwnProperty.call(a, b);
  1002. }
  1003. function isObjectEmpty(obj) {
  1004. if (Object.getOwnPropertyNames) {
  1005. return Object.getOwnPropertyNames(obj).length === 0;
  1006. } else {
  1007. var k;
  1008. for (k in obj) {
  1009. if (hasOwnProp(obj, k)) {
  1010. return false;
  1011. }
  1012. }
  1013. return true;
  1014. }
  1015. }
  1016. function isUndefined(input) {
  1017. return input === void 0;
  1018. }
  1019. function isNumber(input) {
  1020. return (
  1021. typeof input === 'number' ||
  1022. Object.prototype.toString.call(input) === '[object Number]'
  1023. );
  1024. }
  1025. function isDate(input) {
  1026. return (
  1027. input instanceof Date ||
  1028. Object.prototype.toString.call(input) === '[object Date]'
  1029. );
  1030. }
  1031. function map(arr, fn) {
  1032. var res = [],
  1033. i,
  1034. arrLen = arr.length;
  1035. for (i = 0; i < arrLen; ++i) {
  1036. res.push(fn(arr[i], i));
  1037. }
  1038. return res;
  1039. }
  1040. function extend(a, b) {
  1041. for (var i in b) {
  1042. if (hasOwnProp(b, i)) {
  1043. a[i] = b[i];
  1044. }
  1045. }
  1046. if (hasOwnProp(b, 'toString')) {
  1047. a.toString = b.toString;
  1048. }
  1049. if (hasOwnProp(b, 'valueOf')) {
  1050. a.valueOf = b.valueOf;
  1051. }
  1052. return a;
  1053. }
  1054. function createUTC(input, format, locale, strict) {
  1055. return createLocalOrUTC(input, format, locale, strict, true).utc();
  1056. }
  1057. function defaultParsingFlags() {
  1058. // We need to deep clone this object.
  1059. return {
  1060. empty: false,
  1061. unusedTokens: [],
  1062. unusedInput: [],
  1063. overflow: -2,
  1064. charsLeftOver: 0,
  1065. nullInput: false,
  1066. invalidEra: null,
  1067. invalidMonth: null,
  1068. invalidFormat: false,
  1069. userInvalidated: false,
  1070. iso: false,
  1071. parsedDateParts: [],
  1072. era: null,
  1073. meridiem: null,
  1074. rfc2822: false,
  1075. weekdayMismatch: false,
  1076. };
  1077. }
  1078. function getParsingFlags(m) {
  1079. if (m._pf == null) {
  1080. m._pf = defaultParsingFlags();
  1081. }
  1082. return m._pf;
  1083. }
  1084. var some;
  1085. if (Array.prototype.some) {
  1086. some = Array.prototype.some;
  1087. } else {
  1088. some = function (fun) {
  1089. var t = Object(this),
  1090. len = t.length >>> 0,
  1091. i;
  1092. for (i = 0; i < len; i++) {
  1093. if (i in t && fun.call(this, t[i], i, t)) {
  1094. return true;
  1095. }
  1096. }
  1097. return false;
  1098. };
  1099. }
  1100. function isValid(m) {
  1101. if (m._isValid == null) {
  1102. var flags = getParsingFlags(m),
  1103. parsedParts = some.call(flags.parsedDateParts, function (i) {
  1104. return i != null;
  1105. }),
  1106. isNowValid =
  1107. !isNaN(m._d.getTime()) &&
  1108. flags.overflow < 0 &&
  1109. !flags.empty &&
  1110. !flags.invalidEra &&
  1111. !flags.invalidMonth &&
  1112. !flags.invalidWeekday &&
  1113. !flags.weekdayMismatch &&
  1114. !flags.nullInput &&
  1115. !flags.invalidFormat &&
  1116. !flags.userInvalidated &&
  1117. (!flags.meridiem || (flags.meridiem && parsedParts));
  1118. if (m._strict) {
  1119. isNowValid =
  1120. isNowValid &&
  1121. flags.charsLeftOver === 0 &&
  1122. flags.unusedTokens.length === 0 &&
  1123. flags.bigHour === undefined;
  1124. }
  1125. if (Object.isFrozen == null || !Object.isFrozen(m)) {
  1126. m._isValid = isNowValid;
  1127. } else {
  1128. return isNowValid;
  1129. }
  1130. }
  1131. return m._isValid;
  1132. }
  1133. function createInvalid(flags) {
  1134. var m = createUTC(NaN);
  1135. if (flags != null) {
  1136. extend(getParsingFlags(m), flags);
  1137. } else {
  1138. getParsingFlags(m).userInvalidated = true;
  1139. }
  1140. return m;
  1141. }
  1142. // Plugins that add properties should also add the key here (null value),
  1143. // so we can properly clone ourselves.
  1144. var momentProperties = (hooks.momentProperties = []),
  1145. updateInProgress = false;
  1146. function copyConfig(to, from) {
  1147. var i,
  1148. prop,
  1149. val,
  1150. momentPropertiesLen = momentProperties.length;
  1151. if (!isUndefined(from._isAMomentObject)) {
  1152. to._isAMomentObject = from._isAMomentObject;
  1153. }
  1154. if (!isUndefined(from._i)) {
  1155. to._i = from._i;
  1156. }
  1157. if (!isUndefined(from._f)) {
  1158. to._f = from._f;
  1159. }
  1160. if (!isUndefined(from._l)) {
  1161. to._l = from._l;
  1162. }
  1163. if (!isUndefined(from._strict)) {
  1164. to._strict = from._strict;
  1165. }
  1166. if (!isUndefined(from._tzm)) {
  1167. to._tzm = from._tzm;
  1168. }
  1169. if (!isUndefined(from._isUTC)) {
  1170. to._isUTC = from._isUTC;
  1171. }
  1172. if (!isUndefined(from._offset)) {
  1173. to._offset = from._offset;
  1174. }
  1175. if (!isUndefined(from._pf)) {
  1176. to._pf = getParsingFlags(from);
  1177. }
  1178. if (!isUndefined(from._locale)) {
  1179. to._locale = from._locale;
  1180. }
  1181. if (momentPropertiesLen > 0) {
  1182. for (i = 0; i < momentPropertiesLen; i++) {
  1183. prop = momentProperties[i];
  1184. val = from[prop];
  1185. if (!isUndefined(val)) {
  1186. to[prop] = val;
  1187. }
  1188. }
  1189. }
  1190. return to;
  1191. }
  1192. // Moment prototype object
  1193. function Moment(config) {
  1194. copyConfig(this, config);
  1195. this._d = new Date(config._d != null ? config._d.getTime() : NaN);
  1196. if (!this.isValid()) {
  1197. this._d = new Date(NaN);
  1198. }
  1199. // Prevent infinite loop in case updateOffset creates new moment
  1200. // objects.
  1201. if (updateInProgress === false) {
  1202. updateInProgress = true;
  1203. hooks.updateOffset(this);
  1204. updateInProgress = false;
  1205. }
  1206. }
  1207. function isMoment(obj) {
  1208. return (
  1209. obj instanceof Moment || (obj != null && obj._isAMomentObject != null)
  1210. );
  1211. }
  1212. function warn(msg) {
  1213. if (
  1214. hooks.suppressDeprecationWarnings === false &&
  1215. typeof console !== 'undefined' &&
  1216. console.warn
  1217. ) {
  1218. console.warn('Deprecation warning: ' + msg);
  1219. }
  1220. }
  1221. function deprecate(msg, fn) {
  1222. var firstTime = true;
  1223. return extend(function () {
  1224. if (hooks.deprecationHandler != null) {
  1225. hooks.deprecationHandler(null, msg);
  1226. }
  1227. if (firstTime) {
  1228. var args = [],
  1229. arg,
  1230. i,
  1231. key,
  1232. argLen = arguments.length;
  1233. for (i = 0; i < argLen; i++) {
  1234. arg = '';
  1235. if (typeof arguments[i] === 'object') {
  1236. arg += '\n[' + i + '] ';
  1237. for (key in arguments[0]) {
  1238. if (hasOwnProp(arguments[0], key)) {
  1239. arg += key + ': ' + arguments[0][key] + ', ';
  1240. }
  1241. }
  1242. arg = arg.slice(0, -2); // Remove trailing comma and space
  1243. } else {
  1244. arg = arguments[i];
  1245. }
  1246. args.push(arg);
  1247. }
  1248. warn(
  1249. msg +
  1250. '\nArguments: ' +
  1251. Array.prototype.slice.call(args).join('') +
  1252. '\n' +
  1253. new Error().stack
  1254. );
  1255. firstTime = false;
  1256. }
  1257. return fn.apply(this, arguments);
  1258. }, fn);
  1259. }
  1260. var deprecations = {};
  1261. function deprecateSimple(name, msg) {
  1262. if (hooks.deprecationHandler != null) {
  1263. hooks.deprecationHandler(name, msg);
  1264. }
  1265. if (!deprecations[name]) {
  1266. warn(msg);
  1267. deprecations[name] = true;
  1268. }
  1269. }
  1270. hooks.suppressDeprecationWarnings = false;
  1271. hooks.deprecationHandler = null;
  1272. function isFunction(input) {
  1273. return (
  1274. (typeof Function !== 'undefined' && input instanceof Function) ||
  1275. Object.prototype.toString.call(input) === '[object Function]'
  1276. );
  1277. }
  1278. function set(config) {
  1279. var prop, i;
  1280. for (i in config) {
  1281. if (hasOwnProp(config, i)) {
  1282. prop = config[i];
  1283. if (isFunction(prop)) {
  1284. this[i] = prop;
  1285. } else {
  1286. this['_' + i] = prop;
  1287. }
  1288. }
  1289. }
  1290. this._config = config;
  1291. // Lenient ordinal parsing accepts just a number in addition to
  1292. // number + (possibly) stuff coming from _dayOfMonthOrdinalParse.
  1293. // TODO: Remove "ordinalParse" fallback in next major release.
  1294. this._dayOfMonthOrdinalParseLenient = new RegExp(
  1295. (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
  1296. '|' +
  1297. /\d{1,2}/.source
  1298. );
  1299. }
  1300. function mergeConfigs(parentConfig, childConfig) {
  1301. var res = extend({}, parentConfig),
  1302. prop;
  1303. for (prop in childConfig) {
  1304. if (hasOwnProp(childConfig, prop)) {
  1305. if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
  1306. res[prop] = {};
  1307. extend(res[prop], parentConfig[prop]);
  1308. extend(res[prop], childConfig[prop]);
  1309. } else if (childConfig[prop] != null) {
  1310. res[prop] = childConfig[prop];
  1311. } else {
  1312. delete res[prop];
  1313. }
  1314. }
  1315. }
  1316. for (prop in parentConfig) {
  1317. if (
  1318. hasOwnProp(parentConfig, prop) &&
  1319. !hasOwnProp(childConfig, prop) &&
  1320. isObject(parentConfig[prop])
  1321. ) {
  1322. // make sure changes to properties don't modify parent config
  1323. res[prop] = extend({}, res[prop]);
  1324. }
  1325. }
  1326. return res;
  1327. }
  1328. function Locale(config) {
  1329. if (config != null) {
  1330. this.set(config);
  1331. }
  1332. }
  1333. var keys;
  1334. if (Object.keys) {
  1335. keys = Object.keys;
  1336. } else {
  1337. keys = function (obj) {
  1338. var i,
  1339. res = [];
  1340. for (i in obj) {
  1341. if (hasOwnProp(obj, i)) {
  1342. res.push(i);
  1343. }
  1344. }
  1345. return res;
  1346. };
  1347. }
  1348. var defaultCalendar = {
  1349. sameDay: '[Today at] LT',
  1350. nextDay: '[Tomorrow at] LT',
  1351. nextWeek: 'dddd [at] LT',
  1352. lastDay: '[Yesterday at] LT',
  1353. lastWeek: '[Last] dddd [at] LT',
  1354. sameElse: 'L',
  1355. };
  1356. function calendar(key, mom, now) {
  1357. var output = this._calendar[key] || this._calendar['sameElse'];
  1358. return isFunction(output) ? output.call(mom, now) : output;
  1359. }
  1360. function zeroFill(number, targetLength, forceSign) {
  1361. var absNumber = '' + Math.abs(number),
  1362. zerosToFill = targetLength - absNumber.length,
  1363. sign = number >= 0;
  1364. return (
  1365. (sign ? (forceSign ? '+' : '') : '-') +
  1366. Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) +
  1367. absNumber
  1368. );
  1369. }
  1370. var formattingTokens =
  1371. /(\[[^\[]*\])|(\\)?([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,
  1372. localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,
  1373. formatFunctions = {},
  1374. formatTokenFunctions = {};
  1375. // token: 'M'
  1376. // padded: ['MM', 2]
  1377. // ordinal: 'Mo'
  1378. // callback: function () { this.month() + 1 }
  1379. function addFormatToken(token, padded, ordinal, callback) {
  1380. var func = callback;
  1381. if (typeof callback === 'string') {
  1382. func = function () {
  1383. return this[callback]();
  1384. };
  1385. }
  1386. if (token) {
  1387. formatTokenFunctions[token] = func;
  1388. }
  1389. if (padded) {
  1390. formatTokenFunctions[padded[0]] = function () {
  1391. return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
  1392. };
  1393. }
  1394. if (ordinal) {
  1395. formatTokenFunctions[ordinal] = function () {
  1396. return this.localeData().ordinal(
  1397. func.apply(this, arguments),
  1398. token
  1399. );
  1400. };
  1401. }
  1402. }
  1403. function removeFormattingTokens(input) {
  1404. if (input.match(/\[[\s\S]/)) {
  1405. return input.replace(/^\[|\]$/g, '');
  1406. }
  1407. return input.replace(/\\/g, '');
  1408. }
  1409. function makeFormatFunction(format) {
  1410. var array = format.match(formattingTokens),
  1411. i,
  1412. length;
  1413. for (i = 0, length = array.length; i < length; i++) {
  1414. if (formatTokenFunctions[array[i]]) {
  1415. array[i] = formatTokenFunctions[array[i]];
  1416. } else {
  1417. array[i] = removeFormattingTokens(array[i]);
  1418. }
  1419. }
  1420. return function (mom) {
  1421. var output = '',
  1422. i;
  1423. for (i = 0; i < length; i++) {
  1424. output += isFunction(array[i])
  1425. ? array[i].call(mom, format)
  1426. : array[i];
  1427. }
  1428. return output;
  1429. };
  1430. }
  1431. // format date using native date object
  1432. function formatMoment(m, format) {
  1433. if (!m.isValid()) {
  1434. return m.localeData().invalidDate();
  1435. }
  1436. format = expandFormat(format, m.localeData());
  1437. formatFunctions[format] =
  1438. formatFunctions[format] || makeFormatFunction(format);
  1439. return formatFunctions[format](m);
  1440. }
  1441. function expandFormat(format, locale) {
  1442. var i = 5;
  1443. function replaceLongDateFormatTokens(input) {
  1444. return locale.longDateFormat(input) || input;
  1445. }
  1446. localFormattingTokens.lastIndex = 0;
  1447. while (i >= 0 && localFormattingTokens.test(format)) {
  1448. format = format.replace(
  1449. localFormattingTokens,
  1450. replaceLongDateFormatTokens
  1451. );
  1452. localFormattingTokens.lastIndex = 0;
  1453. i -= 1;
  1454. }
  1455. return format;
  1456. }
  1457. var defaultLongDateFormat = {
  1458. LTS: 'h:mm:ss A',
  1459. LT: 'h:mm A',
  1460. L: 'MM/DD/YYYY',
  1461. LL: 'MMMM D, YYYY',
  1462. LLL: 'MMMM D, YYYY h:mm A',
  1463. LLLL: 'dddd, MMMM D, YYYY h:mm A',
  1464. };
  1465. function longDateFormat(key) {
  1466. var format = this._longDateFormat[key],
  1467. formatUpper = this._longDateFormat[key.toUpperCase()];
  1468. if (format || !formatUpper) {
  1469. return format;
  1470. }
  1471. this._longDateFormat[key] = formatUpper
  1472. .match(formattingTokens)
  1473. .map(function (tok) {
  1474. if (
  1475. tok === 'MMMM' ||
  1476. tok === 'MM' ||
  1477. tok === 'DD' ||
  1478. tok === 'dddd'
  1479. ) {
  1480. return tok.slice(1);
  1481. }
  1482. return tok;
  1483. })
  1484. .join('');
  1485. return this._longDateFormat[key];
  1486. }
  1487. var defaultInvalidDate = 'Invalid date';
  1488. function invalidDate() {
  1489. return this._invalidDate;
  1490. }
  1491. var defaultOrdinal = '%d',
  1492. defaultDayOfMonthOrdinalParse = /\d{1,2}/;
  1493. function ordinal(number) {
  1494. return this._ordinal.replace('%d', number);
  1495. }
  1496. var defaultRelativeTime = {
  1497. future: 'in %s',
  1498. past: '%s ago',
  1499. s: 'a few seconds',
  1500. ss: '%d seconds',
  1501. m: 'a minute',
  1502. mm: '%d minutes',
  1503. h: 'an hour',
  1504. hh: '%d hours',
  1505. d: 'a day',
  1506. dd: '%d days',
  1507. w: 'a week',
  1508. ww: '%d weeks',
  1509. M: 'a month',
  1510. MM: '%d months',
  1511. y: 'a year',
  1512. yy: '%d years',
  1513. };
  1514. function relativeTime(number, withoutSuffix, string, isFuture) {
  1515. var output = this._relativeTime[string];
  1516. return isFunction(output)
  1517. ? output(number, withoutSuffix, string, isFuture)
  1518. : output.replace(/%d/i, number);
  1519. }
  1520. function pastFuture(diff, output) {
  1521. var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
  1522. return isFunction(format) ? format(output) : format.replace(/%s/i, output);
  1523. }
  1524. var aliases = {};
  1525. function addUnitAlias(unit, shorthand) {
  1526. var lowerCase = unit.toLowerCase();
  1527. aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
  1528. }
  1529. function normalizeUnits(units) {
  1530. return typeof units === 'string'
  1531. ? aliases[units] || aliases[units.toLowerCase()]
  1532. : undefined;
  1533. }
  1534. function normalizeObjectUnits(inputObject) {
  1535. var normalizedInput = {},
  1536. normalizedProp,
  1537. prop;
  1538. for (prop in inputObject) {
  1539. if (hasOwnProp(inputObject, prop)) {
  1540. normalizedProp = normalizeUnits(prop);
  1541. if (normalizedProp) {
  1542. normalizedInput[normalizedProp] = inputObject[prop];
  1543. }
  1544. }
  1545. }
  1546. return normalizedInput;
  1547. }
  1548. var priorities = {};
  1549. function addUnitPriority(unit, priority) {
  1550. priorities[unit] = priority;
  1551. }
  1552. function getPrioritizedUnits(unitsObj) {
  1553. var units = [],
  1554. u;
  1555. for (u in unitsObj) {
  1556. if (hasOwnProp(unitsObj, u)) {
  1557. units.push({ unit: u, priority: priorities[u] });
  1558. }
  1559. }
  1560. units.sort(function (a, b) {
  1561. return a.priority - b.priority;
  1562. });
  1563. return units;
  1564. }
  1565. function isLeapYear(year) {
  1566. return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
  1567. }
  1568. function absFloor(number) {
  1569. if (number < 0) {
  1570. // -0 -> 0
  1571. return Math.ceil(number) || 0;
  1572. } else {
  1573. return Math.floor(number);
  1574. }
  1575. }
  1576. function toInt(argumentForCoercion) {
  1577. var coercedNumber = +argumentForCoercion,
  1578. value = 0;
  1579. if (coercedNumber !== 0 && isFinite(coercedNumber)) {
  1580. value = absFloor(coercedNumber);
  1581. }
  1582. return value;
  1583. }
  1584. function makeGetSet(unit, keepTime) {
  1585. return function (value) {
  1586. if (value != null) {
  1587. set$1(this, unit, value);
  1588. hooks.updateOffset(this, keepTime);
  1589. return this;
  1590. } else {
  1591. return get(this, unit);
  1592. }
  1593. };
  1594. }
  1595. function get(mom, unit) {
  1596. return mom.isValid()
  1597. ? mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]()
  1598. : NaN;
  1599. }
  1600. function set$1(mom, unit, value) {
  1601. if (mom.isValid() && !isNaN(value)) {
  1602. if (
  1603. unit === 'FullYear' &&
  1604. isLeapYear(mom.year()) &&
  1605. mom.month() === 1 &&
  1606. mom.date() === 29
  1607. ) {
  1608. value = toInt(value);
  1609. mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](
  1610. value,
  1611. mom.month(),
  1612. daysInMonth(value, mom.month())
  1613. );
  1614. } else {
  1615. mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
  1616. }
  1617. }
  1618. }
  1619. // MOMENTS
  1620. function stringGet(units) {
  1621. units = normalizeUnits(units);
  1622. if (isFunction(this[units])) {
  1623. return this[units]();
  1624. }
  1625. return this;
  1626. }
  1627. function stringSet(units, value) {
  1628. if (typeof units === 'object') {
  1629. units = normalizeObjectUnits(units);
  1630. var prioritized = getPrioritizedUnits(units),
  1631. i,
  1632. prioritizedLen = prioritized.length;
  1633. for (i = 0; i < prioritizedLen; i++) {
  1634. this[prioritized[i].unit](units[prioritized[i].unit]);
  1635. }
  1636. } else {
  1637. units = normalizeUnits(units);
  1638. if (isFunction(this[units])) {
  1639. return this[units](value);
  1640. }
  1641. }
  1642. return this;
  1643. }
  1644. var match1 = /\d/, // 0 - 9
  1645. match2 = /\d\d/, // 00 - 99
  1646. match3 = /\d{3}/, // 000 - 999
  1647. match4 = /\d{4}/, // 0000 - 9999
  1648. match6 = /[+-]?\d{6}/, // -999999 - 999999
  1649. match1to2 = /\d\d?/, // 0 - 99
  1650. match3to4 = /\d\d\d\d?/, // 999 - 9999
  1651. match5to6 = /\d\d\d\d\d\d?/, // 99999 - 999999
  1652. match1to3 = /\d{1,3}/, // 0 - 999
  1653. match1to4 = /\d{1,4}/, // 0 - 9999
  1654. match1to6 = /[+-]?\d{1,6}/, // -999999 - 999999
  1655. matchUnsigned = /\d+/, // 0 - inf
  1656. matchSigned = /[+-]?\d+/, // -inf - inf
  1657. matchOffset = /Z|[+-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z
  1658. matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi, // +00 -00 +00:00 -00:00 +0000 -0000 or Z
  1659. matchTimestamp = /[+-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123
  1660. // any word (or two) characters or numbers including two/three word month in arabic.
  1661. // includes scottish gaelic two word and hyphenated months
  1662. matchWord =
  1663. /[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,
  1664. regexes;
  1665. regexes = {};
  1666. function addRegexToken(token, regex, strictRegex) {
  1667. regexes[token] = isFunction(regex)
  1668. ? regex
  1669. : function (isStrict, localeData) {
  1670. return isStrict && strictRegex ? strictRegex : regex;
  1671. };
  1672. }
  1673. function getParseRegexForToken(token, config) {
  1674. if (!hasOwnProp(regexes, token)) {
  1675. return new RegExp(unescapeFormat(token));
  1676. }
  1677. return regexes[token](config._strict, config._locale);
  1678. }
  1679. // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
  1680. function unescapeFormat(s) {
  1681. return regexEscape(
  1682. s
  1683. .replace('\\', '')
  1684. .replace(
  1685. /\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,
  1686. function (matched, p1, p2, p3, p4) {
  1687. return p1 || p2 || p3 || p4;
  1688. }
  1689. )
  1690. );
  1691. }
  1692. function regexEscape(s) {
  1693. return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
  1694. }
  1695. var tokens = {};
  1696. function addParseToken(token, callback) {
  1697. var i,
  1698. func = callback,
  1699. tokenLen;
  1700. if (typeof token === 'string') {
  1701. token = [token];
  1702. }
  1703. if (isNumber(callback)) {
  1704. func = function (input, array) {
  1705. array[callback] = toInt(input);
  1706. };
  1707. }
  1708. tokenLen = token.length;
  1709. for (i = 0; i < tokenLen; i++) {
  1710. tokens[token[i]] = func;
  1711. }
  1712. }
  1713. function addWeekParseToken(token, callback) {
  1714. addParseToken(token, function (input, array, config, token) {
  1715. config._w = config._w || {};
  1716. callback(input, config._w, config, token);
  1717. });
  1718. }
  1719. function addTimeToArrayFromToken(token, input, config) {
  1720. if (input != null && hasOwnProp(tokens, token)) {
  1721. tokens[token](input, config._a, config, token);
  1722. }
  1723. }
  1724. var YEAR = 0,
  1725. MONTH = 1,
  1726. DATE = 2,
  1727. HOUR = 3,
  1728. MINUTE = 4,
  1729. SECOND = 5,
  1730. MILLISECOND = 6,
  1731. WEEK = 7,
  1732. WEEKDAY = 8;
  1733. function mod(n, x) {
  1734. return ((n % x) + x) % x;
  1735. }
  1736. var indexOf;
  1737. if (Array.prototype.indexOf) {
  1738. indexOf = Array.prototype.indexOf;
  1739. } else {
  1740. indexOf = function (o) {
  1741. // I know
  1742. var i;
  1743. for (i = 0; i < this.length; ++i) {
  1744. if (this[i] === o) {
  1745. return i;
  1746. }
  1747. }
  1748. return -1;
  1749. };
  1750. }
  1751. function daysInMonth(year, month) {
  1752. if (isNaN(year) || isNaN(month)) {
  1753. return NaN;
  1754. }
  1755. var modMonth = mod(month, 12);
  1756. year += (month - modMonth) / 12;
  1757. return modMonth === 1
  1758. ? isLeapYear(year)
  1759. ? 29
  1760. : 28
  1761. : 31 - ((modMonth % 7) % 2);
  1762. }
  1763. // FORMATTING
  1764. addFormatToken('M', ['MM', 2], 'Mo', function () {
  1765. return this.month() + 1;
  1766. });
  1767. addFormatToken('MMM', 0, 0, function (format) {
  1768. return this.localeData().monthsShort(this, format);
  1769. });
  1770. addFormatToken('MMMM', 0, 0, function (format) {
  1771. return this.localeData().months(this, format);
  1772. });
  1773. // ALIASES
  1774. addUnitAlias('month', 'M');
  1775. // PRIORITY
  1776. addUnitPriority('month', 8);
  1777. // PARSING
  1778. addRegexToken('M', match1to2);
  1779. addRegexToken('MM', match1to2, match2);
  1780. addRegexToken('MMM', function (isStrict, locale) {
  1781. return locale.monthsShortRegex(isStrict);
  1782. });
  1783. addRegexToken('MMMM', function (isStrict, locale) {
  1784. return locale.monthsRegex(isStrict);
  1785. });
  1786. addParseToken(['M', 'MM'], function (input, array) {
  1787. array[MONTH] = toInt(input) - 1;
  1788. });
  1789. addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
  1790. var month = config._locale.monthsParse(input, token, config._strict);
  1791. // if we didn't find a month name, mark the date as invalid.
  1792. if (month != null) {
  1793. array[MONTH] = month;
  1794. } else {
  1795. getParsingFlags(config).invalidMonth = input;
  1796. }
  1797. });
  1798. // LOCALES
  1799. var defaultLocaleMonths =
  1800. 'January_February_March_April_May_June_July_August_September_October_November_December'.split(
  1801. '_'
  1802. ),
  1803. defaultLocaleMonthsShort =
  1804. 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
  1805. MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,
  1806. defaultMonthsShortRegex = matchWord,
  1807. defaultMonthsRegex = matchWord;
  1808. function localeMonths(m, format) {
  1809. if (!m) {
  1810. return isArray(this._months)
  1811. ? this._months
  1812. : this._months['standalone'];
  1813. }
  1814. return isArray(this._months)
  1815. ? this._months[m.month()]
  1816. : this._months[
  1817. (this._months.isFormat || MONTHS_IN_FORMAT).test(format)
  1818. ? 'format'
  1819. : 'standalone'
  1820. ][m.month()];
  1821. }
  1822. function localeMonthsShort(m, format) {
  1823. if (!m) {
  1824. return isArray(this._monthsShort)
  1825. ? this._monthsShort
  1826. : this._monthsShort['standalone'];
  1827. }
  1828. return isArray(this._monthsShort)
  1829. ? this._monthsShort[m.month()]
  1830. : this._monthsShort[
  1831. MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'
  1832. ][m.month()];
  1833. }
  1834. function handleStrictParse(monthName, format, strict) {
  1835. var i,
  1836. ii,
  1837. mom,
  1838. llc = monthName.toLocaleLowerCase();
  1839. if (!this._monthsParse) {
  1840. // this is not used
  1841. this._monthsParse = [];
  1842. this._longMonthsParse = [];
  1843. this._shortMonthsParse = [];
  1844. for (i = 0; i < 12; ++i) {
  1845. mom = createUTC([2000, i]);
  1846. this._shortMonthsParse[i] = this.monthsShort(
  1847. mom,
  1848. ''
  1849. ).toLocaleLowerCase();
  1850. this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
  1851. }
  1852. }
  1853. if (strict) {
  1854. if (format === 'MMM') {
  1855. ii = indexOf.call(this._shortMonthsParse, llc);
  1856. return ii !== -1 ? ii : null;
  1857. } else {
  1858. ii = indexOf.call(this._longMonthsParse, llc);
  1859. return ii !== -1 ? ii : null;
  1860. }
  1861. } else {
  1862. if (format === 'MMM') {
  1863. ii = indexOf.call(this._shortMonthsParse, llc);
  1864. if (ii !== -1) {
  1865. return ii;
  1866. }
  1867. ii = indexOf.call(this._longMonthsParse, llc);
  1868. return ii !== -1 ? ii : null;
  1869. } else {
  1870. ii = indexOf.call(this._longMonthsParse, llc);
  1871. if (ii !== -1) {
  1872. return ii;
  1873. }
  1874. ii = indexOf.call(this._shortMonthsParse, llc);
  1875. return ii !== -1 ? ii : null;
  1876. }
  1877. }
  1878. }
  1879. function localeMonthsParse(monthName, format, strict) {
  1880. var i, mom, regex;
  1881. if (this._monthsParseExact) {
  1882. return handleStrictParse.call(this, monthName, format, strict);
  1883. }
  1884. if (!this._monthsParse) {
  1885. this._monthsParse = [];
  1886. this._longMonthsParse = [];
  1887. this._shortMonthsParse = [];
  1888. }
  1889. // TODO: add sorting
  1890. // Sorting makes sure if one month (or abbr) is a prefix of another
  1891. // see sorting in computeMonthsParse
  1892. for (i = 0; i < 12; i++) {
  1893. // make the regex if we don't have it already
  1894. mom = createUTC([2000, i]);
  1895. if (strict && !this._longMonthsParse[i]) {
  1896. this._longMonthsParse[i] = new RegExp(
  1897. '^' + this.months(mom, '').replace('.', '') + '$',
  1898. 'i'
  1899. );
  1900. this._shortMonthsParse[i] = new RegExp(
  1901. '^' + this.monthsShort(mom, '').replace('.', '') + '$',
  1902. 'i'
  1903. );
  1904. }
  1905. if (!strict && !this._monthsParse[i]) {
  1906. regex =
  1907. '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
  1908. this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
  1909. }
  1910. // test the regex
  1911. if (
  1912. strict &&
  1913. format === 'MMMM' &&
  1914. this._longMonthsParse[i].test(monthName)
  1915. ) {
  1916. return i;
  1917. } else if (
  1918. strict &&
  1919. format === 'MMM' &&
  1920. this._shortMonthsParse[i].test(monthName)
  1921. ) {
  1922. return i;
  1923. } else if (!strict && this._monthsParse[i].test(monthName)) {
  1924. return i;
  1925. }
  1926. }
  1927. }
  1928. // MOMENTS
  1929. function setMonth(mom, value) {
  1930. var dayOfMonth;
  1931. if (!mom.isValid()) {
  1932. // No op
  1933. return mom;
  1934. }
  1935. if (typeof value === 'string') {
  1936. if (/^\d+$/.test(value)) {
  1937. value = toInt(value);
  1938. } else {
  1939. value = mom.localeData().monthsParse(value);
  1940. // TODO: Another silent failure?
  1941. if (!isNumber(value)) {
  1942. return mom;
  1943. }
  1944. }
  1945. }
  1946. dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
  1947. mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
  1948. return mom;
  1949. }
  1950. function getSetMonth(value) {
  1951. if (value != null) {
  1952. setMonth(this, value);
  1953. hooks.updateOffset(this, true);
  1954. return this;
  1955. } else {
  1956. return get(this, 'Month');
  1957. }
  1958. }
  1959. function getDaysInMonth() {
  1960. return daysInMonth(this.year(), this.month());
  1961. }
  1962. function monthsShortRegex(isStrict) {
  1963. if (this._monthsParseExact) {
  1964. if (!hasOwnProp(this, '_monthsRegex')) {
  1965. computeMonthsParse.call(this);
  1966. }
  1967. if (isStrict) {
  1968. return this._monthsShortStrictRegex;
  1969. } else {
  1970. return this._monthsShortRegex;
  1971. }
  1972. } else {
  1973. if (!hasOwnProp(this, '_monthsShortRegex')) {
  1974. this._monthsShortRegex = defaultMonthsShortRegex;
  1975. }
  1976. return this._monthsShortStrictRegex && isStrict
  1977. ? this._monthsShortStrictRegex
  1978. : this._monthsShortRegex;
  1979. }
  1980. }
  1981. function monthsRegex(isStrict) {
  1982. if (this._monthsParseExact) {
  1983. if (!hasOwnProp(this, '_monthsRegex')) {
  1984. computeMonthsParse.call(this);
  1985. }
  1986. if (isStrict) {
  1987. return this._monthsStrictRegex;
  1988. } else {
  1989. return this._monthsRegex;
  1990. }
  1991. } else {
  1992. if (!hasOwnProp(this, '_monthsRegex')) {
  1993. this._monthsRegex = defaultMonthsRegex;
  1994. }
  1995. return this._monthsStrictRegex && isStrict
  1996. ? this._monthsStrictRegex
  1997. : this._monthsRegex;
  1998. }
  1999. }
  2000. function computeMonthsParse() {
  2001. function cmpLenRev(a, b) {
  2002. return b.length - a.length;
  2003. }
  2004. var shortPieces = [],
  2005. longPieces = [],
  2006. mixedPieces = [],
  2007. i,
  2008. mom;
  2009. for (i = 0; i < 12; i++) {
  2010. // make the regex if we don't have it already
  2011. mom = createUTC([2000, i]);
  2012. shortPieces.push(this.monthsShort(mom, ''));
  2013. longPieces.push(this.months(mom, ''));
  2014. mixedPieces.push(this.months(mom, ''));
  2015. mixedPieces.push(this.monthsShort(mom, ''));
  2016. }
  2017. // Sorting makes sure if one month (or abbr) is a prefix of another it
  2018. // will match the longer piece.
  2019. shortPieces.sort(cmpLenRev);
  2020. longPieces.sort(cmpLenRev);
  2021. mixedPieces.sort(cmpLenRev);
  2022. for (i = 0; i < 12; i++) {
  2023. shortPieces[i] = regexEscape(shortPieces[i]);
  2024. longPieces[i] = regexEscape(longPieces[i]);
  2025. }
  2026. for (i = 0; i < 24; i++) {
  2027. mixedPieces[i] = regexEscape(mixedPieces[i]);
  2028. }
  2029. this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  2030. this._monthsShortRegex = this._monthsRegex;
  2031. this._monthsStrictRegex = new RegExp(
  2032. '^(' + longPieces.join('|') + ')',
  2033. 'i'
  2034. );
  2035. this._monthsShortStrictRegex = new RegExp(
  2036. '^(' + shortPieces.join('|') + ')',
  2037. 'i'
  2038. );
  2039. }
  2040. // FORMATTING
  2041. addFormatToken('Y', 0, 0, function () {
  2042. var y = this.year();
  2043. return y <= 9999 ? zeroFill(y, 4) : '+' + y;
  2044. });
  2045. addFormatToken(0, ['YY', 2], 0, function () {
  2046. return this.year() % 100;
  2047. });
  2048. addFormatToken(0, ['YYYY', 4], 0, 'year');
  2049. addFormatToken(0, ['YYYYY', 5], 0, 'year');
  2050. addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
  2051. // ALIASES
  2052. addUnitAlias('year', 'y');
  2053. // PRIORITIES
  2054. addUnitPriority('year', 1);
  2055. // PARSING
  2056. addRegexToken('Y', matchSigned);
  2057. addRegexToken('YY', match1to2, match2);
  2058. addRegexToken('YYYY', match1to4, match4);
  2059. addRegexToken('YYYYY', match1to6, match6);
  2060. addRegexToken('YYYYYY', match1to6, match6);
  2061. addParseToken(['YYYYY', 'YYYYYY'], YEAR);
  2062. addParseToken('YYYY', function (input, array) {
  2063. array[YEAR] =
  2064. input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
  2065. });
  2066. addParseToken('YY', function (input, array) {
  2067. array[YEAR] = hooks.parseTwoDigitYear(input);
  2068. });
  2069. addParseToken('Y', function (input, array) {
  2070. array[YEAR] = parseInt(input, 10);
  2071. });
  2072. // HELPERS
  2073. function daysInYear(year) {
  2074. return isLeapYear(year) ? 366 : 365;
  2075. }
  2076. // HOOKS
  2077. hooks.parseTwoDigitYear = function (input) {
  2078. return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
  2079. };
  2080. // MOMENTS
  2081. var getSetYear = makeGetSet('FullYear', true);
  2082. function getIsLeapYear() {
  2083. return isLeapYear(this.year());
  2084. }
  2085. function createDate(y, m, d, h, M, s, ms) {
  2086. // can't just apply() to create a date:
  2087. // https://stackoverflow.com/q/181348
  2088. var date;
  2089. // the date constructor remaps years 0-99 to 1900-1999
  2090. if (y < 100 && y >= 0) {
  2091. // preserve leap years using a full 400 year cycle, then reset
  2092. date = new Date(y + 400, m, d, h, M, s, ms);
  2093. if (isFinite(date.getFullYear())) {
  2094. date.setFullYear(y);
  2095. }
  2096. } else {
  2097. date = new Date(y, m, d, h, M, s, ms);
  2098. }
  2099. return date;
  2100. }
  2101. function createUTCDate(y) {
  2102. var date, args;
  2103. // the Date.UTC function remaps years 0-99 to 1900-1999
  2104. if (y < 100 && y >= 0) {
  2105. args = Array.prototype.slice.call(arguments);
  2106. // preserve leap years using a full 400 year cycle, then reset
  2107. args[0] = y + 400;
  2108. date = new Date(Date.UTC.apply(null, args));
  2109. if (isFinite(date.getUTCFullYear())) {
  2110. date.setUTCFullYear(y);
  2111. }
  2112. } else {
  2113. date = new Date(Date.UTC.apply(null, arguments));
  2114. }
  2115. return date;
  2116. }
  2117. // start-of-first-week - start-of-year
  2118. function firstWeekOffset(year, dow, doy) {
  2119. var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
  2120. fwd = 7 + dow - doy,
  2121. // first-week day local weekday -- which local weekday is fwd
  2122. fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
  2123. return -fwdlw + fwd - 1;
  2124. }
  2125. // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
  2126. function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
  2127. var localWeekday = (7 + weekday - dow) % 7,
  2128. weekOffset = firstWeekOffset(year, dow, doy),
  2129. dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
  2130. resYear,
  2131. resDayOfYear;
  2132. if (dayOfYear <= 0) {
  2133. resYear = year - 1;
  2134. resDayOfYear = daysInYear(resYear) + dayOfYear;
  2135. } else if (dayOfYear > daysInYear(year)) {
  2136. resYear = year + 1;
  2137. resDayOfYear = dayOfYear - daysInYear(year);
  2138. } else {
  2139. resYear = year;
  2140. resDayOfYear = dayOfYear;
  2141. }
  2142. return {
  2143. year: resYear,
  2144. dayOfYear: resDayOfYear,
  2145. };
  2146. }
  2147. function weekOfYear(mom, dow, doy) {
  2148. var weekOffset = firstWeekOffset(mom.year(), dow, doy),
  2149. week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
  2150. resWeek,
  2151. resYear;
  2152. if (week < 1) {
  2153. resYear = mom.year() - 1;
  2154. resWeek = week + weeksInYear(resYear, dow, doy);
  2155. } else if (week > weeksInYear(mom.year(), dow, doy)) {
  2156. resWeek = week - weeksInYear(mom.year(), dow, doy);
  2157. resYear = mom.year() + 1;
  2158. } else {
  2159. resYear = mom.year();
  2160. resWeek = week;
  2161. }
  2162. return {
  2163. week: resWeek,
  2164. year: resYear,
  2165. };
  2166. }
  2167. function weeksInYear(year, dow, doy) {
  2168. var weekOffset = firstWeekOffset(year, dow, doy),
  2169. weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
  2170. return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
  2171. }
  2172. // FORMATTING
  2173. addFormatToken('w', ['ww', 2], 'wo', 'week');
  2174. addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
  2175. // ALIASES
  2176. addUnitAlias('week', 'w');
  2177. addUnitAlias('isoWeek', 'W');
  2178. // PRIORITIES
  2179. addUnitPriority('week', 5);
  2180. addUnitPriority('isoWeek', 5);
  2181. // PARSING
  2182. addRegexToken('w', match1to2);
  2183. addRegexToken('ww', match1to2, match2);
  2184. addRegexToken('W', match1to2);
  2185. addRegexToken('WW', match1to2, match2);
  2186. addWeekParseToken(
  2187. ['w', 'ww', 'W', 'WW'],
  2188. function (input, week, config, token) {
  2189. week[token.substr(0, 1)] = toInt(input);
  2190. }
  2191. );
  2192. // HELPERS
  2193. // LOCALES
  2194. function localeWeek(mom) {
  2195. return weekOfYear(mom, this._week.dow, this._week.doy).week;
  2196. }
  2197. var defaultLocaleWeek = {
  2198. dow: 0, // Sunday is the first day of the week.
  2199. doy: 6, // The week that contains Jan 6th is the first week of the year.
  2200. };
  2201. function localeFirstDayOfWeek() {
  2202. return this._week.dow;
  2203. }
  2204. function localeFirstDayOfYear() {
  2205. return this._week.doy;
  2206. }
  2207. // MOMENTS
  2208. function getSetWeek(input) {
  2209. var week = this.localeData().week(this);
  2210. return input == null ? week : this.add((input - week) * 7, 'd');
  2211. }
  2212. function getSetISOWeek(input) {
  2213. var week = weekOfYear(this, 1, 4).week;
  2214. return input == null ? week : this.add((input - week) * 7, 'd');
  2215. }
  2216. // FORMATTING
  2217. addFormatToken('d', 0, 'do', 'day');
  2218. addFormatToken('dd', 0, 0, function (format) {
  2219. return this.localeData().weekdaysMin(this, format);
  2220. });
  2221. addFormatToken('ddd', 0, 0, function (format) {
  2222. return this.localeData().weekdaysShort(this, format);
  2223. });
  2224. addFormatToken('dddd', 0, 0, function (format) {
  2225. return this.localeData().weekdays(this, format);
  2226. });
  2227. addFormatToken('e', 0, 0, 'weekday');
  2228. addFormatToken('E', 0, 0, 'isoWeekday');
  2229. // ALIASES
  2230. addUnitAlias('day', 'd');
  2231. addUnitAlias('weekday', 'e');
  2232. addUnitAlias('isoWeekday', 'E');
  2233. // PRIORITY
  2234. addUnitPriority('day', 11);
  2235. addUnitPriority('weekday', 11);
  2236. addUnitPriority('isoWeekday', 11);
  2237. // PARSING
  2238. addRegexToken('d', match1to2);
  2239. addRegexToken('e', match1to2);
  2240. addRegexToken('E', match1to2);
  2241. addRegexToken('dd', function (isStrict, locale) {
  2242. return locale.weekdaysMinRegex(isStrict);
  2243. });
  2244. addRegexToken('ddd', function (isStrict, locale) {
  2245. return locale.weekdaysShortRegex(isStrict);
  2246. });
  2247. addRegexToken('dddd', function (isStrict, locale) {
  2248. return locale.weekdaysRegex(isStrict);
  2249. });
  2250. addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
  2251. var weekday = config._locale.weekdaysParse(input, token, config._strict);
  2252. // if we didn't get a weekday name, mark the date as invalid
  2253. if (weekday != null) {
  2254. week.d = weekday;
  2255. } else {
  2256. getParsingFlags(config).invalidWeekday = input;
  2257. }
  2258. });
  2259. addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
  2260. week[token] = toInt(input);
  2261. });
  2262. // HELPERS
  2263. function parseWeekday(input, locale) {
  2264. if (typeof input !== 'string') {
  2265. return input;
  2266. }
  2267. if (!isNaN(input)) {
  2268. return parseInt(input, 10);
  2269. }
  2270. input = locale.weekdaysParse(input);
  2271. if (typeof input === 'number') {
  2272. return input;
  2273. }
  2274. return null;
  2275. }
  2276. function parseIsoWeekday(input, locale) {
  2277. if (typeof input === 'string') {
  2278. return locale.weekdaysParse(input) % 7 || 7;
  2279. }
  2280. return isNaN(input) ? null : input;
  2281. }
  2282. // LOCALES
  2283. function shiftWeekdays(ws, n) {
  2284. return ws.slice(n, 7).concat(ws.slice(0, n));
  2285. }
  2286. var defaultLocaleWeekdays =
  2287. 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
  2288. defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
  2289. defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
  2290. defaultWeekdaysRegex = matchWord,
  2291. defaultWeekdaysShortRegex = matchWord,
  2292. defaultWeekdaysMinRegex = matchWord;
  2293. function localeWeekdays(m, format) {
  2294. var weekdays = isArray(this._weekdays)
  2295. ? this._weekdays
  2296. : this._weekdays[
  2297. m && m !== true && this._weekdays.isFormat.test(format)
  2298. ? 'format'
  2299. : 'standalone'
  2300. ];
  2301. return m === true
  2302. ? shiftWeekdays(weekdays, this._week.dow)
  2303. : m
  2304. ? weekdays[m.day()]
  2305. : weekdays;
  2306. }
  2307. function localeWeekdaysShort(m) {
  2308. return m === true
  2309. ? shiftWeekdays(this._weekdaysShort, this._week.dow)
  2310. : m
  2311. ? this._weekdaysShort[m.day()]
  2312. : this._weekdaysShort;
  2313. }
  2314. function localeWeekdaysMin(m) {
  2315. return m === true
  2316. ? shiftWeekdays(this._weekdaysMin, this._week.dow)
  2317. : m
  2318. ? this._weekdaysMin[m.day()]
  2319. : this._weekdaysMin;
  2320. }
  2321. function handleStrictParse$1(weekdayName, format, strict) {
  2322. var i,
  2323. ii,
  2324. mom,
  2325. llc = weekdayName.toLocaleLowerCase();
  2326. if (!this._weekdaysParse) {
  2327. this._weekdaysParse = [];
  2328. this._shortWeekdaysParse = [];
  2329. this._minWeekdaysParse = [];
  2330. for (i = 0; i < 7; ++i) {
  2331. mom = createUTC([2000, 1]).day(i);
  2332. this._minWeekdaysParse[i] = this.weekdaysMin(
  2333. mom,
  2334. ''
  2335. ).toLocaleLowerCase();
  2336. this._shortWeekdaysParse[i] = this.weekdaysShort(
  2337. mom,
  2338. ''
  2339. ).toLocaleLowerCase();
  2340. this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
  2341. }
  2342. }
  2343. if (strict) {
  2344. if (format === 'dddd') {
  2345. ii = indexOf.call(this._weekdaysParse, llc);
  2346. return ii !== -1 ? ii : null;
  2347. } else if (format === 'ddd') {
  2348. ii = indexOf.call(this._shortWeekdaysParse, llc);
  2349. return ii !== -1 ? ii : null;
  2350. } else {
  2351. ii = indexOf.call(this._minWeekdaysParse, llc);
  2352. return ii !== -1 ? ii : null;
  2353. }
  2354. } else {
  2355. if (format === 'dddd') {
  2356. ii = indexOf.call(this._weekdaysParse, llc);
  2357. if (ii !== -1) {
  2358. return ii;
  2359. }
  2360. ii = indexOf.call(this._shortWeekdaysParse, llc);
  2361. if (ii !== -1) {
  2362. return ii;
  2363. }
  2364. ii = indexOf.call(this._minWeekdaysParse, llc);
  2365. return ii !== -1 ? ii : null;
  2366. } else if (format === 'ddd') {
  2367. ii = indexOf.call(this._shortWeekdaysParse, llc);
  2368. if (ii !== -1) {
  2369. return ii;
  2370. }
  2371. ii = indexOf.call(this._weekdaysParse, llc);
  2372. if (ii !== -1) {
  2373. return ii;
  2374. }
  2375. ii = indexOf.call(this._minWeekdaysParse, llc);
  2376. return ii !== -1 ? ii : null;
  2377. } else {
  2378. ii = indexOf.call(this._minWeekdaysParse, llc);
  2379. if (ii !== -1) {
  2380. return ii;
  2381. }
  2382. ii = indexOf.call(this._weekdaysParse, llc);
  2383. if (ii !== -1) {
  2384. return ii;
  2385. }
  2386. ii = indexOf.call(this._shortWeekdaysParse, llc);
  2387. return ii !== -1 ? ii : null;
  2388. }
  2389. }
  2390. }
  2391. function localeWeekdaysParse(weekdayName, format, strict) {
  2392. var i, mom, regex;
  2393. if (this._weekdaysParseExact) {
  2394. return handleStrictParse$1.call(this, weekdayName, format, strict);
  2395. }
  2396. if (!this._weekdaysParse) {
  2397. this._weekdaysParse = [];
  2398. this._minWeekdaysParse = [];
  2399. this._shortWeekdaysParse = [];
  2400. this._fullWeekdaysParse = [];
  2401. }
  2402. for (i = 0; i < 7; i++) {
  2403. // make the regex if we don't have it already
  2404. mom = createUTC([2000, 1]).day(i);
  2405. if (strict && !this._fullWeekdaysParse[i]) {
  2406. this._fullWeekdaysParse[i] = new RegExp(
  2407. '^' + this.weekdays(mom, '').replace('.', '\\.?') + '$',
  2408. 'i'
  2409. );
  2410. this._shortWeekdaysParse[i] = new RegExp(
  2411. '^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$',
  2412. 'i'
  2413. );
  2414. this._minWeekdaysParse[i] = new RegExp(
  2415. '^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$',
  2416. 'i'
  2417. );
  2418. }
  2419. if (!this._weekdaysParse[i]) {
  2420. regex =
  2421. '^' +
  2422. this.weekdays(mom, '') +
  2423. '|^' +
  2424. this.weekdaysShort(mom, '') +
  2425. '|^' +
  2426. this.weekdaysMin(mom, '');
  2427. this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
  2428. }
  2429. // test the regex
  2430. if (
  2431. strict &&
  2432. format === 'dddd' &&
  2433. this._fullWeekdaysParse[i].test(weekdayName)
  2434. ) {
  2435. return i;
  2436. } else if (
  2437. strict &&
  2438. format === 'ddd' &&
  2439. this._shortWeekdaysParse[i].test(weekdayName)
  2440. ) {
  2441. return i;
  2442. } else if (
  2443. strict &&
  2444. format === 'dd' &&
  2445. this._minWeekdaysParse[i].test(weekdayName)
  2446. ) {
  2447. return i;
  2448. } else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
  2449. return i;
  2450. }
  2451. }
  2452. }
  2453. // MOMENTS
  2454. function getSetDayOfWeek(input) {
  2455. if (!this.isValid()) {
  2456. return input != null ? this : NaN;
  2457. }
  2458. var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
  2459. if (input != null) {
  2460. input = parseWeekday(input, this.localeData());
  2461. return this.add(input - day, 'd');
  2462. } else {
  2463. return day;
  2464. }
  2465. }
  2466. function getSetLocaleDayOfWeek(input) {
  2467. if (!this.isValid()) {
  2468. return input != null ? this : NaN;
  2469. }
  2470. var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
  2471. return input == null ? weekday : this.add(input - weekday, 'd');
  2472. }
  2473. function getSetISODayOfWeek(input) {
  2474. if (!this.isValid()) {
  2475. return input != null ? this : NaN;
  2476. }
  2477. // behaves the same as moment#day except
  2478. // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
  2479. // as a setter, sunday should belong to the previous week.
  2480. if (input != null) {
  2481. var weekday = parseIsoWeekday(input, this.localeData());
  2482. return this.day(this.day() % 7 ? weekday : weekday - 7);
  2483. } else {
  2484. return this.day() || 7;
  2485. }
  2486. }
  2487. function weekdaysRegex(isStrict) {
  2488. if (this._weekdaysParseExact) {
  2489. if (!hasOwnProp(this, '_weekdaysRegex')) {
  2490. computeWeekdaysParse.call(this);
  2491. }
  2492. if (isStrict) {
  2493. return this._weekdaysStrictRegex;
  2494. } else {
  2495. return this._weekdaysRegex;
  2496. }
  2497. } else {
  2498. if (!hasOwnProp(this, '_weekdaysRegex')) {
  2499. this._weekdaysRegex = defaultWeekdaysRegex;
  2500. }
  2501. return this._weekdaysStrictRegex && isStrict
  2502. ? this._weekdaysStrictRegex
  2503. : this._weekdaysRegex;
  2504. }
  2505. }
  2506. function weekdaysShortRegex(isStrict) {
  2507. if (this._weekdaysParseExact) {
  2508. if (!hasOwnProp(this, '_weekdaysRegex')) {
  2509. computeWeekdaysParse.call(this);
  2510. }
  2511. if (isStrict) {
  2512. return this._weekdaysShortStrictRegex;
  2513. } else {
  2514. return this._weekdaysShortRegex;
  2515. }
  2516. } else {
  2517. if (!hasOwnProp(this, '_weekdaysShortRegex')) {
  2518. this._weekdaysShortRegex = defaultWeekdaysShortRegex;
  2519. }
  2520. return this._weekdaysShortStrictRegex && isStrict
  2521. ? this._weekdaysShortStrictRegex
  2522. : this._weekdaysShortRegex;
  2523. }
  2524. }
  2525. function weekdaysMinRegex(isStrict) {
  2526. if (this._weekdaysParseExact) {
  2527. if (!hasOwnProp(this, '_weekdaysRegex')) {
  2528. computeWeekdaysParse.call(this);
  2529. }
  2530. if (isStrict) {
  2531. return this._weekdaysMinStrictRegex;
  2532. } else {
  2533. return this._weekdaysMinRegex;
  2534. }
  2535. } else {
  2536. if (!hasOwnProp(this, '_weekdaysMinRegex')) {
  2537. this._weekdaysMinRegex = defaultWeekdaysMinRegex;
  2538. }
  2539. return this._weekdaysMinStrictRegex && isStrict
  2540. ? this._weekdaysMinStrictRegex
  2541. : this._weekdaysMinRegex;
  2542. }
  2543. }
  2544. function computeWeekdaysParse() {
  2545. function cmpLenRev(a, b) {
  2546. return b.length - a.length;
  2547. }
  2548. var minPieces = [],
  2549. shortPieces = [],
  2550. longPieces = [],
  2551. mixedPieces = [],
  2552. i,
  2553. mom,
  2554. minp,
  2555. shortp,
  2556. longp;
  2557. for (i = 0; i < 7; i++) {
  2558. // make the regex if we don't have it already
  2559. mom = createUTC([2000, 1]).day(i);
  2560. minp = regexEscape(this.weekdaysMin(mom, ''));
  2561. shortp = regexEscape(this.weekdaysShort(mom, ''));
  2562. longp = regexEscape(this.weekdays(mom, ''));
  2563. minPieces.push(minp);
  2564. shortPieces.push(shortp);
  2565. longPieces.push(longp);
  2566. mixedPieces.push(minp);
  2567. mixedPieces.push(shortp);
  2568. mixedPieces.push(longp);
  2569. }
  2570. // Sorting makes sure if one weekday (or abbr) is a prefix of another it
  2571. // will match the longer piece.
  2572. minPieces.sort(cmpLenRev);
  2573. shortPieces.sort(cmpLenRev);
  2574. longPieces.sort(cmpLenRev);
  2575. mixedPieces.sort(cmpLenRev);
  2576. this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  2577. this._weekdaysShortRegex = this._weekdaysRegex;
  2578. this._weekdaysMinRegex = this._weekdaysRegex;
  2579. this._weekdaysStrictRegex = new RegExp(
  2580. '^(' + longPieces.join('|') + ')',
  2581. 'i'
  2582. );
  2583. this._weekdaysShortStrictRegex = new RegExp(
  2584. '^(' + shortPieces.join('|') + ')',
  2585. 'i'
  2586. );
  2587. this._weekdaysMinStrictRegex = new RegExp(
  2588. '^(' + minPieces.join('|') + ')',
  2589. 'i'
  2590. );
  2591. }
  2592. // FORMATTING
  2593. function hFormat() {
  2594. return this.hours() % 12 || 12;
  2595. }
  2596. function kFormat() {
  2597. return this.hours() || 24;
  2598. }
  2599. addFormatToken('H', ['HH', 2], 0, 'hour');
  2600. addFormatToken('h', ['hh', 2], 0, hFormat);
  2601. addFormatToken('k', ['kk', 2], 0, kFormat);
  2602. addFormatToken('hmm', 0, 0, function () {
  2603. return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
  2604. });
  2605. addFormatToken('hmmss', 0, 0, function () {
  2606. return (
  2607. '' +
  2608. hFormat.apply(this) +
  2609. zeroFill(this.minutes(), 2) +
  2610. zeroFill(this.seconds(), 2)
  2611. );
  2612. });
  2613. addFormatToken('Hmm', 0, 0, function () {
  2614. return '' + this.hours() + zeroFill(this.minutes(), 2);
  2615. });
  2616. addFormatToken('Hmmss', 0, 0, function () {
  2617. return (
  2618. '' +
  2619. this.hours() +
  2620. zeroFill(this.minutes(), 2) +
  2621. zeroFill(this.seconds(), 2)
  2622. );
  2623. });
  2624. function meridiem(token, lowercase) {
  2625. addFormatToken(token, 0, 0, function () {
  2626. return this.localeData().meridiem(
  2627. this.hours(),
  2628. this.minutes(),
  2629. lowercase
  2630. );
  2631. });
  2632. }
  2633. meridiem('a', true);
  2634. meridiem('A', false);
  2635. // ALIASES
  2636. addUnitAlias('hour', 'h');
  2637. // PRIORITY
  2638. addUnitPriority('hour', 13);
  2639. // PARSING
  2640. function matchMeridiem(isStrict, locale) {
  2641. return locale._meridiemParse;
  2642. }
  2643. addRegexToken('a', matchMeridiem);
  2644. addRegexToken('A', matchMeridiem);
  2645. addRegexToken('H', match1to2);
  2646. addRegexToken('h', match1to2);
  2647. addRegexToken('k', match1to2);
  2648. addRegexToken('HH', match1to2, match2);
  2649. addRegexToken('hh', match1to2, match2);
  2650. addRegexToken('kk', match1to2, match2);
  2651. addRegexToken('hmm', match3to4);
  2652. addRegexToken('hmmss', match5to6);
  2653. addRegexToken('Hmm', match3to4);
  2654. addRegexToken('Hmmss', match5to6);
  2655. addParseToken(['H', 'HH'], HOUR);
  2656. addParseToken(['k', 'kk'], function (input, array, config) {
  2657. var kInput = toInt(input);
  2658. array[HOUR] = kInput === 24 ? 0 : kInput;
  2659. });
  2660. addParseToken(['a', 'A'], function (input, array, config) {
  2661. config._isPm = config._locale.isPM(input);
  2662. config._meridiem = input;
  2663. });
  2664. addParseToken(['h', 'hh'], function (input, array, config) {
  2665. array[HOUR] = toInt(input);
  2666. getParsingFlags(config).bigHour = true;
  2667. });
  2668. addParseToken('hmm', function (input, array, config) {
  2669. var pos = input.length - 2;
  2670. array[HOUR] = toInt(input.substr(0, pos));
  2671. array[MINUTE] = toInt(input.substr(pos));
  2672. getParsingFlags(config).bigHour = true;
  2673. });
  2674. addParseToken('hmmss', function (input, array, config) {
  2675. var pos1 = input.length - 4,
  2676. pos2 = input.length - 2;
  2677. array[HOUR] = toInt(input.substr(0, pos1));
  2678. array[MINUTE] = toInt(input.substr(pos1, 2));
  2679. array[SECOND] = toInt(input.substr(pos2));
  2680. getParsingFlags(config).bigHour = true;
  2681. });
  2682. addParseToken('Hmm', function (input, array, config) {
  2683. var pos = input.length - 2;
  2684. array[HOUR] = toInt(input.substr(0, pos));
  2685. array[MINUTE] = toInt(input.substr(pos));
  2686. });
  2687. addParseToken('Hmmss', function (input, array, config) {
  2688. var pos1 = input.length - 4,
  2689. pos2 = input.length - 2;
  2690. array[HOUR] = toInt(input.substr(0, pos1));
  2691. array[MINUTE] = toInt(input.substr(pos1, 2));
  2692. array[SECOND] = toInt(input.substr(pos2));
  2693. });
  2694. // LOCALES
  2695. function localeIsPM(input) {
  2696. // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
  2697. // Using charAt should be more compatible.
  2698. return (input + '').toLowerCase().charAt(0) === 'p';
  2699. }
  2700. var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i,
  2701. // Setting the hour should keep the time, because the user explicitly
  2702. // specified which hour they want. So trying to maintain the same hour (in
  2703. // a new timezone) makes sense. Adding/subtracting hours does not follow
  2704. // this rule.
  2705. getSetHour = makeGetSet('Hours', true);
  2706. function localeMeridiem(hours, minutes, isLower) {
  2707. if (hours > 11) {
  2708. return isLower ? 'pm' : 'PM';
  2709. } else {
  2710. return isLower ? 'am' : 'AM';
  2711. }
  2712. }
  2713. var baseConfig = {
  2714. calendar: defaultCalendar,
  2715. longDateFormat: defaultLongDateFormat,
  2716. invalidDate: defaultInvalidDate,
  2717. ordinal: defaultOrdinal,
  2718. dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
  2719. relativeTime: defaultRelativeTime,
  2720. months: defaultLocaleMonths,
  2721. monthsShort: defaultLocaleMonthsShort,
  2722. week: defaultLocaleWeek,
  2723. weekdays: defaultLocaleWeekdays,
  2724. weekdaysMin: defaultLocaleWeekdaysMin,
  2725. weekdaysShort: defaultLocaleWeekdaysShort,
  2726. meridiemParse: defaultLocaleMeridiemParse,
  2727. };
  2728. // internal storage for locale config files
  2729. var locales = {},
  2730. localeFamilies = {},
  2731. globalLocale;
  2732. function commonPrefix(arr1, arr2) {
  2733. var i,
  2734. minl = Math.min(arr1.length, arr2.length);
  2735. for (i = 0; i < minl; i += 1) {
  2736. if (arr1[i] !== arr2[i]) {
  2737. return i;
  2738. }
  2739. }
  2740. return minl;
  2741. }
  2742. function normalizeLocale(key) {
  2743. return key ? key.toLowerCase().replace('_', '-') : key;
  2744. }
  2745. // pick the locale from the array
  2746. // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
  2747. // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
  2748. function chooseLocale(names) {
  2749. var i = 0,
  2750. j,
  2751. next,
  2752. locale,
  2753. split;
  2754. while (i < names.length) {
  2755. split = normalizeLocale(names[i]).split('-');
  2756. j = split.length;
  2757. next = normalizeLocale(names[i + 1]);
  2758. next = next ? next.split('-') : null;
  2759. while (j > 0) {
  2760. locale = loadLocale(split.slice(0, j).join('-'));
  2761. if (locale) {
  2762. return locale;
  2763. }
  2764. if (
  2765. next &&
  2766. next.length >= j &&
  2767. commonPrefix(split, next) >= j - 1
  2768. ) {
  2769. //the next array item is better than a shallower substring of this one
  2770. break;
  2771. }
  2772. j--;
  2773. }
  2774. i++;
  2775. }
  2776. return globalLocale;
  2777. }
  2778. function isLocaleNameSane(name) {
  2779. // Prevent names that look like filesystem paths, i.e contain '/' or '\'
  2780. return name.match('^[^/\\\\]*$') != null;
  2781. }
  2782. function loadLocale(name) {
  2783. var oldLocale = null,
  2784. aliasedRequire;
  2785. // TODO: Find a better way to register and load all the locales in Node
  2786. if (
  2787. locales[name] === undefined &&
  2788. typeof module !== 'undefined' &&
  2789. module &&
  2790. module.exports &&
  2791. isLocaleNameSane(name)
  2792. ) {
  2793. try {
  2794. oldLocale = globalLocale._abbr;
  2795. aliasedRequire = require;
  2796. aliasedRequire('./locale/' + name);
  2797. getSetGlobalLocale(oldLocale);
  2798. } catch (e) {
  2799. // mark as not found to avoid repeating expensive file require call causing high CPU
  2800. // when trying to find en-US, en_US, en-us for every format call
  2801. locales[name] = null; // null means not found
  2802. }
  2803. }
  2804. return locales[name];
  2805. }
  2806. // This function will load locale and then set the global locale. If
  2807. // no arguments are passed in, it will simply return the current global
  2808. // locale key.
  2809. function getSetGlobalLocale(key, values) {
  2810. var data;
  2811. if (key) {
  2812. if (isUndefined(values)) {
  2813. data = getLocale(key);
  2814. } else {
  2815. data = defineLocale(key, values);
  2816. }
  2817. if (data) {
  2818. // moment.duration._locale = moment._locale = data;
  2819. globalLocale = data;
  2820. } else {
  2821. if (typeof console !== 'undefined' && console.warn) {
  2822. //warn user if arguments are passed but the locale could not be set
  2823. console.warn(
  2824. 'Locale ' + key + ' not found. Did you forget to load it?'
  2825. );
  2826. }
  2827. }
  2828. }
  2829. return globalLocale._abbr;
  2830. }
  2831. function defineLocale(name, config) {
  2832. if (config !== null) {
  2833. var locale,
  2834. parentConfig = baseConfig;
  2835. config.abbr = name;
  2836. if (locales[name] != null) {
  2837. deprecateSimple(
  2838. 'defineLocaleOverride',
  2839. 'use moment.updateLocale(localeName, config) to change ' +
  2840. 'an existing locale. moment.defineLocale(localeName, ' +
  2841. 'config) should only be used for creating a new locale ' +
  2842. 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.'
  2843. );
  2844. parentConfig = locales[name]._config;
  2845. } else if (config.parentLocale != null) {
  2846. if (locales[config.parentLocale] != null) {
  2847. parentConfig = locales[config.parentLocale]._config;
  2848. } else {
  2849. locale = loadLocale(config.parentLocale);
  2850. if (locale != null) {
  2851. parentConfig = locale._config;
  2852. } else {
  2853. if (!localeFamilies[config.parentLocale]) {
  2854. localeFamilies[config.parentLocale] = [];
  2855. }
  2856. localeFamilies[config.parentLocale].push({
  2857. name: name,
  2858. config: config,
  2859. });
  2860. return null;
  2861. }
  2862. }
  2863. }
  2864. locales[name] = new Locale(mergeConfigs(parentConfig, config));
  2865. if (localeFamilies[name]) {
  2866. localeFamilies[name].forEach(function (x) {
  2867. defineLocale(x.name, x.config);
  2868. });
  2869. }
  2870. // backwards compat for now: also set the locale
  2871. // make sure we set the locale AFTER all child locales have been
  2872. // created, so we won't end up with the child locale set.
  2873. getSetGlobalLocale(name);
  2874. return locales[name];
  2875. } else {
  2876. // useful for testing
  2877. delete locales[name];
  2878. return null;
  2879. }
  2880. }
  2881. function updateLocale(name, config) {
  2882. if (config != null) {
  2883. var locale,
  2884. tmpLocale,
  2885. parentConfig = baseConfig;
  2886. if (locales[name] != null && locales[name].parentLocale != null) {
  2887. // Update existing child locale in-place to avoid memory-leaks
  2888. locales[name].set(mergeConfigs(locales[name]._config, config));
  2889. } else {
  2890. // MERGE
  2891. tmpLocale = loadLocale(name);
  2892. if (tmpLocale != null) {
  2893. parentConfig = tmpLocale._config;
  2894. }
  2895. config = mergeConfigs(parentConfig, config);
  2896. if (tmpLocale == null) {
  2897. // updateLocale is called for creating a new locale
  2898. // Set abbr so it will have a name (getters return
  2899. // undefined otherwise).
  2900. config.abbr = name;
  2901. }
  2902. locale = new Locale(config);
  2903. locale.parentLocale = locales[name];
  2904. locales[name] = locale;
  2905. }
  2906. // backwards compat for now: also set the locale
  2907. getSetGlobalLocale(name);
  2908. } else {
  2909. // pass null for config to unupdate, useful for tests
  2910. if (locales[name] != null) {
  2911. if (locales[name].parentLocale != null) {
  2912. locales[name] = locales[name].parentLocale;
  2913. if (name === getSetGlobalLocale()) {
  2914. getSetGlobalLocale(name);
  2915. }
  2916. } else if (locales[name] != null) {
  2917. delete locales[name];
  2918. }
  2919. }
  2920. }
  2921. return locales[name];
  2922. }
  2923. // returns locale data
  2924. function getLocale(key) {
  2925. var locale;
  2926. if (key && key._locale && key._locale._abbr) {
  2927. key = key._locale._abbr;
  2928. }
  2929. if (!key) {
  2930. return globalLocale;
  2931. }
  2932. if (!isArray(key)) {
  2933. //short-circuit everything else
  2934. locale = loadLocale(key);
  2935. if (locale) {
  2936. return locale;
  2937. }
  2938. key = [key];
  2939. }
  2940. return chooseLocale(key);
  2941. }
  2942. function listLocales() {
  2943. return keys(locales);
  2944. }
  2945. function checkOverflow(m) {
  2946. var overflow,
  2947. a = m._a;
  2948. if (a && getParsingFlags(m).overflow === -2) {
  2949. overflow =
  2950. a[MONTH] < 0 || a[MONTH] > 11
  2951. ? MONTH
  2952. : a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH])
  2953. ? DATE
  2954. : a[HOUR] < 0 ||
  2955. a[HOUR] > 24 ||
  2956. (a[HOUR] === 24 &&
  2957. (a[MINUTE] !== 0 ||
  2958. a[SECOND] !== 0 ||
  2959. a[MILLISECOND] !== 0))
  2960. ? HOUR
  2961. : a[MINUTE] < 0 || a[MINUTE] > 59
  2962. ? MINUTE
  2963. : a[SECOND] < 0 || a[SECOND] > 59
  2964. ? SECOND
  2965. : a[MILLISECOND] < 0 || a[MILLISECOND] > 999
  2966. ? MILLISECOND
  2967. : -1;
  2968. if (
  2969. getParsingFlags(m)._overflowDayOfYear &&
  2970. (overflow < YEAR || overflow > DATE)
  2971. ) {
  2972. overflow = DATE;
  2973. }
  2974. if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
  2975. overflow = WEEK;
  2976. }
  2977. if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
  2978. overflow = WEEKDAY;
  2979. }
  2980. getParsingFlags(m).overflow = overflow;
  2981. }
  2982. return m;
  2983. }
  2984. // iso 8601 regex
  2985. // 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)
  2986. var extendedIsoRegex =
  2987. /^\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)?)?$/,
  2988. basicIsoRegex =
  2989. /^\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)?)?$/,
  2990. tzRegex = /Z|[+-]\d\d(?::?\d\d)?/,
  2991. isoDates = [
  2992. ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/],
  2993. ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/],
  2994. ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/],
  2995. ['GGGG-[W]WW', /\d{4}-W\d\d/, false],
  2996. ['YYYY-DDD', /\d{4}-\d{3}/],
  2997. ['YYYY-MM', /\d{4}-\d\d/, false],
  2998. ['YYYYYYMMDD', /[+-]\d{10}/],
  2999. ['YYYYMMDD', /\d{8}/],
  3000. ['GGGG[W]WWE', /\d{4}W\d{3}/],
  3001. ['GGGG[W]WW', /\d{4}W\d{2}/, false],
  3002. ['YYYYDDD', /\d{7}/],
  3003. ['YYYYMM', /\d{6}/, false],
  3004. ['YYYY', /\d{4}/, false],
  3005. ],
  3006. // iso time formats and regexes
  3007. isoTimes = [
  3008. ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/],
  3009. ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/],
  3010. ['HH:mm:ss', /\d\d:\d\d:\d\d/],
  3011. ['HH:mm', /\d\d:\d\d/],
  3012. ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/],
  3013. ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/],
  3014. ['HHmmss', /\d\d\d\d\d\d/],
  3015. ['HHmm', /\d\d\d\d/],
  3016. ['HH', /\d\d/],
  3017. ],
  3018. aspNetJsonRegex = /^\/?Date\((-?\d+)/i,
  3019. // RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3
  3020. rfc2822 =
  3021. /^(?:(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}))$/,
  3022. obsOffsets = {
  3023. UT: 0,
  3024. GMT: 0,
  3025. EDT: -4 * 60,
  3026. EST: -5 * 60,
  3027. CDT: -5 * 60,
  3028. CST: -6 * 60,
  3029. MDT: -6 * 60,
  3030. MST: -7 * 60,
  3031. PDT: -7 * 60,
  3032. PST: -8 * 60,
  3033. };
  3034. // date from iso format
  3035. function configFromISO(config) {
  3036. var i,
  3037. l,
  3038. string = config._i,
  3039. match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
  3040. allowTime,
  3041. dateFormat,
  3042. timeFormat,
  3043. tzFormat,
  3044. isoDatesLen = isoDates.length,
  3045. isoTimesLen = isoTimes.length;
  3046. if (match) {
  3047. getParsingFlags(config).iso = true;
  3048. for (i = 0, l = isoDatesLen; i < l; i++) {
  3049. if (isoDates[i][1].exec(match[1])) {
  3050. dateFormat = isoDates[i][0];
  3051. allowTime = isoDates[i][2] !== false;
  3052. break;
  3053. }
  3054. }
  3055. if (dateFormat == null) {
  3056. config._isValid = false;
  3057. return;
  3058. }
  3059. if (match[3]) {
  3060. for (i = 0, l = isoTimesLen; i < l; i++) {
  3061. if (isoTimes[i][1].exec(match[3])) {
  3062. // match[2] should be 'T' or space
  3063. timeFormat = (match[2] || ' ') + isoTimes[i][0];
  3064. break;
  3065. }
  3066. }
  3067. if (timeFormat == null) {
  3068. config._isValid = false;
  3069. return;
  3070. }
  3071. }
  3072. if (!allowTime && timeFormat != null) {
  3073. config._isValid = false;
  3074. return;
  3075. }
  3076. if (match[4]) {
  3077. if (tzRegex.exec(match[4])) {
  3078. tzFormat = 'Z';
  3079. } else {
  3080. config._isValid = false;
  3081. return;
  3082. }
  3083. }
  3084. config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
  3085. configFromStringAndFormat(config);
  3086. } else {
  3087. config._isValid = false;
  3088. }
  3089. }
  3090. function extractFromRFC2822Strings(
  3091. yearStr,
  3092. monthStr,
  3093. dayStr,
  3094. hourStr,
  3095. minuteStr,
  3096. secondStr
  3097. ) {
  3098. var result = [
  3099. untruncateYear(yearStr),
  3100. defaultLocaleMonthsShort.indexOf(monthStr),
  3101. parseInt(dayStr, 10),
  3102. parseInt(hourStr, 10),
  3103. parseInt(minuteStr, 10),
  3104. ];
  3105. if (secondStr) {
  3106. result.push(parseInt(secondStr, 10));
  3107. }
  3108. return result;
  3109. }
  3110. function untruncateYear(yearStr) {
  3111. var year = parseInt(yearStr, 10);
  3112. if (year <= 49) {
  3113. return 2000 + year;
  3114. } else if (year <= 999) {
  3115. return 1900 + year;
  3116. }
  3117. return year;
  3118. }
  3119. function preprocessRFC2822(s) {
  3120. // Remove comments and folding whitespace and replace multiple-spaces with a single space
  3121. return s
  3122. .replace(/\([^()]*\)|[\n\t]/g, ' ')
  3123. .replace(/(\s\s+)/g, ' ')
  3124. .replace(/^\s\s*/, '')
  3125. .replace(/\s\s*$/, '');
  3126. }
  3127. function checkWeekday(weekdayStr, parsedInput, config) {
  3128. if (weekdayStr) {
  3129. // TODO: Replace the vanilla JS Date object with an independent day-of-week check.
  3130. var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr),
  3131. weekdayActual = new Date(
  3132. parsedInput[0],
  3133. parsedInput[1],
  3134. parsedInput[2]
  3135. ).getDay();
  3136. if (weekdayProvided !== weekdayActual) {
  3137. getParsingFlags(config).weekdayMismatch = true;
  3138. config._isValid = false;
  3139. return false;
  3140. }
  3141. }
  3142. return true;
  3143. }
  3144. function calculateOffset(obsOffset, militaryOffset, numOffset) {
  3145. if (obsOffset) {
  3146. return obsOffsets[obsOffset];
  3147. } else if (militaryOffset) {
  3148. // the only allowed military tz is Z
  3149. return 0;
  3150. } else {
  3151. var hm = parseInt(numOffset, 10),
  3152. m = hm % 100,
  3153. h = (hm - m) / 100;
  3154. return h * 60 + m;
  3155. }
  3156. }
  3157. // date and time from ref 2822 format
  3158. function configFromRFC2822(config) {
  3159. var match = rfc2822.exec(preprocessRFC2822(config._i)),
  3160. parsedArray;
  3161. if (match) {
  3162. parsedArray = extractFromRFC2822Strings(
  3163. match[4],
  3164. match[3],
  3165. match[2],
  3166. match[5],
  3167. match[6],
  3168. match[7]
  3169. );
  3170. if (!checkWeekday(match[1], parsedArray, config)) {
  3171. return;
  3172. }
  3173. config._a = parsedArray;
  3174. config._tzm = calculateOffset(match[8], match[9], match[10]);
  3175. config._d = createUTCDate.apply(null, config._a);
  3176. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  3177. getParsingFlags(config).rfc2822 = true;
  3178. } else {
  3179. config._isValid = false;
  3180. }
  3181. }
  3182. // date from 1) ASP.NET, 2) ISO, 3) RFC 2822 formats, or 4) optional fallback if parsing isn't strict
  3183. function configFromString(config) {
  3184. var matched = aspNetJsonRegex.exec(config._i);
  3185. if (matched !== null) {
  3186. config._d = new Date(+matched[1]);
  3187. return;
  3188. }
  3189. configFromISO(config);
  3190. if (config._isValid === false) {
  3191. delete config._isValid;
  3192. } else {
  3193. return;
  3194. }
  3195. configFromRFC2822(config);
  3196. if (config._isValid === false) {
  3197. delete config._isValid;
  3198. } else {
  3199. return;
  3200. }
  3201. if (config._strict) {
  3202. config._isValid = false;
  3203. } else {
  3204. // Final attempt, use Input Fallback
  3205. hooks.createFromInputFallback(config);
  3206. }
  3207. }
  3208. hooks.createFromInputFallback = deprecate(
  3209. 'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' +
  3210. 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' +
  3211. 'discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.',
  3212. function (config) {
  3213. config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
  3214. }
  3215. );
  3216. // Pick the first defined of two or three arguments.
  3217. function defaults(a, b, c) {
  3218. if (a != null) {
  3219. return a;
  3220. }
  3221. if (b != null) {
  3222. return b;
  3223. }
  3224. return c;
  3225. }
  3226. function currentDateArray(config) {
  3227. // hooks is actually the exported moment object
  3228. var nowValue = new Date(hooks.now());
  3229. if (config._useUTC) {
  3230. return [
  3231. nowValue.getUTCFullYear(),
  3232. nowValue.getUTCMonth(),
  3233. nowValue.getUTCDate(),
  3234. ];
  3235. }
  3236. return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
  3237. }
  3238. // convert an array to a date.
  3239. // the array should mirror the parameters below
  3240. // note: all values past the year are optional and will default to the lowest possible value.
  3241. // [year, month, day , hour, minute, second, millisecond]
  3242. function configFromArray(config) {
  3243. var i,
  3244. date,
  3245. input = [],
  3246. currentDate,
  3247. expectedWeekday,
  3248. yearToUse;
  3249. if (config._d) {
  3250. return;
  3251. }
  3252. currentDate = currentDateArray(config);
  3253. //compute day of the year from weeks and weekdays
  3254. if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
  3255. dayOfYearFromWeekInfo(config);
  3256. }
  3257. //if the day of the year is set, figure out what it is
  3258. if (config._dayOfYear != null) {
  3259. yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
  3260. if (
  3261. config._dayOfYear > daysInYear(yearToUse) ||
  3262. config._dayOfYear === 0
  3263. ) {
  3264. getParsingFlags(config)._overflowDayOfYear = true;
  3265. }
  3266. date = createUTCDate(yearToUse, 0, config._dayOfYear);
  3267. config._a[MONTH] = date.getUTCMonth();
  3268. config._a[DATE] = date.getUTCDate();
  3269. }
  3270. // Default to current date.
  3271. // * if no year, month, day of month are given, default to today
  3272. // * if day of month is given, default month and year
  3273. // * if month is given, default only year
  3274. // * if year is given, don't default anything
  3275. for (i = 0; i < 3 && config._a[i] == null; ++i) {
  3276. config._a[i] = input[i] = currentDate[i];
  3277. }
  3278. // Zero out whatever was not defaulted, including time
  3279. for (; i < 7; i++) {
  3280. config._a[i] = input[i] =
  3281. config._a[i] == null ? (i === 2 ? 1 : 0) : config._a[i];
  3282. }
  3283. // Check for 24:00:00.000
  3284. if (
  3285. config._a[HOUR] === 24 &&
  3286. config._a[MINUTE] === 0 &&
  3287. config._a[SECOND] === 0 &&
  3288. config._a[MILLISECOND] === 0
  3289. ) {
  3290. config._nextDay = true;
  3291. config._a[HOUR] = 0;
  3292. }
  3293. config._d = (config._useUTC ? createUTCDate : createDate).apply(
  3294. null,
  3295. input
  3296. );
  3297. expectedWeekday = config._useUTC
  3298. ? config._d.getUTCDay()
  3299. : config._d.getDay();
  3300. // Apply timezone offset from input. The actual utcOffset can be changed
  3301. // with parseZone.
  3302. if (config._tzm != null) {
  3303. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  3304. }
  3305. if (config._nextDay) {
  3306. config._a[HOUR] = 24;
  3307. }
  3308. // check for mismatching day of week
  3309. if (
  3310. config._w &&
  3311. typeof config._w.d !== 'undefined' &&
  3312. config._w.d !== expectedWeekday
  3313. ) {
  3314. getParsingFlags(config).weekdayMismatch = true;
  3315. }
  3316. }
  3317. function dayOfYearFromWeekInfo(config) {
  3318. var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow, curWeek;
  3319. w = config._w;
  3320. if (w.GG != null || w.W != null || w.E != null) {
  3321. dow = 1;
  3322. doy = 4;
  3323. // TODO: We need to take the current isoWeekYear, but that depends on
  3324. // how we interpret now (local, utc, fixed offset). So create
  3325. // a now version of current config (take local/utc/offset flags, and
  3326. // create now).
  3327. weekYear = defaults(
  3328. w.GG,
  3329. config._a[YEAR],
  3330. weekOfYear(createLocal(), 1, 4).year
  3331. );
  3332. week = defaults(w.W, 1);
  3333. weekday = defaults(w.E, 1);
  3334. if (weekday < 1 || weekday > 7) {
  3335. weekdayOverflow = true;
  3336. }
  3337. } else {
  3338. dow = config._locale._week.dow;
  3339. doy = config._locale._week.doy;
  3340. curWeek = weekOfYear(createLocal(), dow, doy);
  3341. weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
  3342. // Default to current week.
  3343. week = defaults(w.w, curWeek.week);
  3344. if (w.d != null) {
  3345. // weekday -- low day numbers are considered next week
  3346. weekday = w.d;
  3347. if (weekday < 0 || weekday > 6) {
  3348. weekdayOverflow = true;
  3349. }
  3350. } else if (w.e != null) {
  3351. // local weekday -- counting starts from beginning of week
  3352. weekday = w.e + dow;
  3353. if (w.e < 0 || w.e > 6) {
  3354. weekdayOverflow = true;
  3355. }
  3356. } else {
  3357. // default to beginning of week
  3358. weekday = dow;
  3359. }
  3360. }
  3361. if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
  3362. getParsingFlags(config)._overflowWeeks = true;
  3363. } else if (weekdayOverflow != null) {
  3364. getParsingFlags(config)._overflowWeekday = true;
  3365. } else {
  3366. temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
  3367. config._a[YEAR] = temp.year;
  3368. config._dayOfYear = temp.dayOfYear;
  3369. }
  3370. }
  3371. // constant that refers to the ISO standard
  3372. hooks.ISO_8601 = function () {};
  3373. // constant that refers to the RFC 2822 form
  3374. hooks.RFC_2822 = function () {};
  3375. // date from string and format string
  3376. function configFromStringAndFormat(config) {
  3377. // TODO: Move this to another part of the creation flow to prevent circular deps
  3378. if (config._f === hooks.ISO_8601) {
  3379. configFromISO(config);
  3380. return;
  3381. }
  3382. if (config._f === hooks.RFC_2822) {
  3383. configFromRFC2822(config);
  3384. return;
  3385. }
  3386. config._a = [];
  3387. getParsingFlags(config).empty = true;
  3388. // This array is used to make a Date, either with `new Date` or `Date.UTC`
  3389. var string = '' + config._i,
  3390. i,
  3391. parsedInput,
  3392. tokens,
  3393. token,
  3394. skipped,
  3395. stringLength = string.length,
  3396. totalParsedInputLength = 0,
  3397. era,
  3398. tokenLen;
  3399. tokens =
  3400. expandFormat(config._f, config._locale).match(formattingTokens) || [];
  3401. tokenLen = tokens.length;
  3402. for (i = 0; i < tokenLen; i++) {
  3403. token = tokens[i];
  3404. parsedInput = (string.match(getParseRegexForToken(token, config)) ||
  3405. [])[0];
  3406. if (parsedInput) {
  3407. skipped = string.substr(0, string.indexOf(parsedInput));
  3408. if (skipped.length > 0) {
  3409. getParsingFlags(config).unusedInput.push(skipped);
  3410. }
  3411. string = string.slice(
  3412. string.indexOf(parsedInput) + parsedInput.length
  3413. );
  3414. totalParsedInputLength += parsedInput.length;
  3415. }
  3416. // don't parse if it's not a known token
  3417. if (formatTokenFunctions[token]) {
  3418. if (parsedInput) {
  3419. getParsingFlags(config).empty = false;
  3420. } else {
  3421. getParsingFlags(config).unusedTokens.push(token);
  3422. }
  3423. addTimeToArrayFromToken(token, parsedInput, config);
  3424. } else if (config._strict && !parsedInput) {
  3425. getParsingFlags(config).unusedTokens.push(token);
  3426. }
  3427. }
  3428. // add remaining unparsed input length to the string
  3429. getParsingFlags(config).charsLeftOver =
  3430. stringLength - totalParsedInputLength;
  3431. if (string.length > 0) {
  3432. getParsingFlags(config).unusedInput.push(string);
  3433. }
  3434. // clear _12h flag if hour is <= 12
  3435. if (
  3436. config._a[HOUR] <= 12 &&
  3437. getParsingFlags(config).bigHour === true &&
  3438. config._a[HOUR] > 0
  3439. ) {
  3440. getParsingFlags(config).bigHour = undefined;
  3441. }
  3442. getParsingFlags(config).parsedDateParts = config._a.slice(0);
  3443. getParsingFlags(config).meridiem = config._meridiem;
  3444. // handle meridiem
  3445. config._a[HOUR] = meridiemFixWrap(
  3446. config._locale,
  3447. config._a[HOUR],
  3448. config._meridiem
  3449. );
  3450. // handle era
  3451. era = getParsingFlags(config).era;
  3452. if (era !== null) {
  3453. config._a[YEAR] = config._locale.erasConvertYear(era, config._a[YEAR]);
  3454. }
  3455. configFromArray(config);
  3456. checkOverflow(config);
  3457. }
  3458. function meridiemFixWrap(locale, hour, meridiem) {
  3459. var isPm;
  3460. if (meridiem == null) {
  3461. // nothing to do
  3462. return hour;
  3463. }
  3464. if (locale.meridiemHour != null) {
  3465. return locale.meridiemHour(hour, meridiem);
  3466. } else if (locale.isPM != null) {
  3467. // Fallback
  3468. isPm = locale.isPM(meridiem);
  3469. if (isPm && hour < 12) {
  3470. hour += 12;
  3471. }
  3472. if (!isPm && hour === 12) {
  3473. hour = 0;
  3474. }
  3475. return hour;
  3476. } else {
  3477. // this is not supposed to happen
  3478. return hour;
  3479. }
  3480. }
  3481. // date from string and array of format strings
  3482. function configFromStringAndArray(config) {
  3483. var tempConfig,
  3484. bestMoment,
  3485. scoreToBeat,
  3486. i,
  3487. currentScore,
  3488. validFormatFound,
  3489. bestFormatIsValid = false,
  3490. configfLen = config._f.length;
  3491. if (configfLen === 0) {
  3492. getParsingFlags(config).invalidFormat = true;
  3493. config._d = new Date(NaN);
  3494. return;
  3495. }
  3496. for (i = 0; i < configfLen; i++) {
  3497. currentScore = 0;
  3498. validFormatFound = false;
  3499. tempConfig = copyConfig({}, config);
  3500. if (config._useUTC != null) {
  3501. tempConfig._useUTC = config._useUTC;
  3502. }
  3503. tempConfig._f = config._f[i];
  3504. configFromStringAndFormat(tempConfig);
  3505. if (isValid(tempConfig)) {
  3506. validFormatFound = true;
  3507. }
  3508. // if there is any input that was not parsed add a penalty for that format
  3509. currentScore += getParsingFlags(tempConfig).charsLeftOver;
  3510. //or tokens
  3511. currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
  3512. getParsingFlags(tempConfig).score = currentScore;
  3513. if (!bestFormatIsValid) {
  3514. if (
  3515. scoreToBeat == null ||
  3516. currentScore < scoreToBeat ||
  3517. validFormatFound
  3518. ) {
  3519. scoreToBeat = currentScore;
  3520. bestMoment = tempConfig;
  3521. if (validFormatFound) {
  3522. bestFormatIsValid = true;
  3523. }
  3524. }
  3525. } else {
  3526. if (currentScore < scoreToBeat) {
  3527. scoreToBeat = currentScore;
  3528. bestMoment = tempConfig;
  3529. }
  3530. }
  3531. }
  3532. extend(config, bestMoment || tempConfig);
  3533. }
  3534. function configFromObject(config) {
  3535. if (config._d) {
  3536. return;
  3537. }
  3538. var i = normalizeObjectUnits(config._i),
  3539. dayOrDate = i.day === undefined ? i.date : i.day;
  3540. config._a = map(
  3541. [i.year, i.month, dayOrDate, i.hour, i.minute, i.second, i.millisecond],
  3542. function (obj) {
  3543. return obj && parseInt(obj, 10);
  3544. }
  3545. );
  3546. configFromArray(config);
  3547. }
  3548. function createFromConfig(config) {
  3549. var res = new Moment(checkOverflow(prepareConfig(config)));
  3550. if (res._nextDay) {
  3551. // Adding is smart enough around DST
  3552. res.add(1, 'd');
  3553. res._nextDay = undefined;
  3554. }
  3555. return res;
  3556. }
  3557. function prepareConfig(config) {
  3558. var input = config._i,
  3559. format = config._f;
  3560. config._locale = config._locale || getLocale(config._l);
  3561. if (input === null || (format === undefined && input === '')) {
  3562. return createInvalid({ nullInput: true });
  3563. }
  3564. if (typeof input === 'string') {
  3565. config._i = input = config._locale.preparse(input);
  3566. }
  3567. if (isMoment(input)) {
  3568. return new Moment(checkOverflow(input));
  3569. } else if (isDate(input)) {
  3570. config._d = input;
  3571. } else if (isArray(format)) {
  3572. configFromStringAndArray(config);
  3573. } else if (format) {
  3574. configFromStringAndFormat(config);
  3575. } else {
  3576. configFromInput(config);
  3577. }
  3578. if (!isValid(config)) {
  3579. config._d = null;
  3580. }
  3581. return config;
  3582. }
  3583. function configFromInput(config) {
  3584. var input = config._i;
  3585. if (isUndefined(input)) {
  3586. config._d = new Date(hooks.now());
  3587. } else if (isDate(input)) {
  3588. config._d = new Date(input.valueOf());
  3589. } else if (typeof input === 'string') {
  3590. configFromString(config);
  3591. } else if (isArray(input)) {
  3592. config._a = map(input.slice(0), function (obj) {
  3593. return parseInt(obj, 10);
  3594. });
  3595. configFromArray(config);
  3596. } else if (isObject(input)) {
  3597. configFromObject(config);
  3598. } else if (isNumber(input)) {
  3599. // from milliseconds
  3600. config._d = new Date(input);
  3601. } else {
  3602. hooks.createFromInputFallback(config);
  3603. }
  3604. }
  3605. function createLocalOrUTC(input, format, locale, strict, isUTC) {
  3606. var c = {};
  3607. if (format === true || format === false) {
  3608. strict = format;
  3609. format = undefined;
  3610. }
  3611. if (locale === true || locale === false) {
  3612. strict = locale;
  3613. locale = undefined;
  3614. }
  3615. if (
  3616. (isObject(input) && isObjectEmpty(input)) ||
  3617. (isArray(input) && input.length === 0)
  3618. ) {
  3619. input = undefined;
  3620. }
  3621. // object construction must be done this way.
  3622. // https://github.com/moment/moment/issues/1423
  3623. c._isAMomentObject = true;
  3624. c._useUTC = c._isUTC = isUTC;
  3625. c._l = locale;
  3626. c._i = input;
  3627. c._f = format;
  3628. c._strict = strict;
  3629. return createFromConfig(c);
  3630. }
  3631. function createLocal(input, format, locale, strict) {
  3632. return createLocalOrUTC(input, format, locale, strict, false);
  3633. }
  3634. var prototypeMin = deprecate(
  3635. 'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',
  3636. function () {
  3637. var other = createLocal.apply(null, arguments);
  3638. if (this.isValid() && other.isValid()) {
  3639. return other < this ? this : other;
  3640. } else {
  3641. return createInvalid();
  3642. }
  3643. }
  3644. ),
  3645. prototypeMax = deprecate(
  3646. 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',
  3647. function () {
  3648. var other = createLocal.apply(null, arguments);
  3649. if (this.isValid() && other.isValid()) {
  3650. return other > this ? this : other;
  3651. } else {
  3652. return createInvalid();
  3653. }
  3654. }
  3655. );
  3656. // Pick a moment m from moments so that m[fn](other) is true for all
  3657. // other. This relies on the function fn to be transitive.
  3658. //
  3659. // moments should either be an array of moment objects or an array, whose
  3660. // first element is an array of moment objects.
  3661. function pickBy(fn, moments) {
  3662. var res, i;
  3663. if (moments.length === 1 && isArray(moments[0])) {
  3664. moments = moments[0];
  3665. }
  3666. if (!moments.length) {
  3667. return createLocal();
  3668. }
  3669. res = moments[0];
  3670. for (i = 1; i < moments.length; ++i) {
  3671. if (!moments[i].isValid() || moments[i][fn](res)) {
  3672. res = moments[i];
  3673. }
  3674. }
  3675. return res;
  3676. }
  3677. // TODO: Use [].sort instead?
  3678. function min() {
  3679. var args = [].slice.call(arguments, 0);
  3680. return pickBy('isBefore', args);
  3681. }
  3682. function max() {
  3683. var args = [].slice.call(arguments, 0);
  3684. return pickBy('isAfter', args);
  3685. }
  3686. var now = function () {
  3687. return Date.now ? Date.now() : +new Date();
  3688. };
  3689. var ordering = [
  3690. 'year',
  3691. 'quarter',
  3692. 'month',
  3693. 'week',
  3694. 'day',
  3695. 'hour',
  3696. 'minute',
  3697. 'second',
  3698. 'millisecond',
  3699. ];
  3700. function isDurationValid(m) {
  3701. var key,
  3702. unitHasDecimal = false,
  3703. i,
  3704. orderLen = ordering.length;
  3705. for (key in m) {
  3706. if (
  3707. hasOwnProp(m, key) &&
  3708. !(
  3709. indexOf.call(ordering, key) !== -1 &&
  3710. (m[key] == null || !isNaN(m[key]))
  3711. )
  3712. ) {
  3713. return false;
  3714. }
  3715. }
  3716. for (i = 0; i < orderLen; ++i) {
  3717. if (m[ordering[i]]) {
  3718. if (unitHasDecimal) {
  3719. return false; // only allow non-integers for smallest unit
  3720. }
  3721. if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
  3722. unitHasDecimal = true;
  3723. }
  3724. }
  3725. }
  3726. return true;
  3727. }
  3728. function isValid$1() {
  3729. return this._isValid;
  3730. }
  3731. function createInvalid$1() {
  3732. return createDuration(NaN);
  3733. }
  3734. function Duration(duration) {
  3735. var normalizedInput = normalizeObjectUnits(duration),
  3736. years = normalizedInput.year || 0,
  3737. quarters = normalizedInput.quarter || 0,
  3738. months = normalizedInput.month || 0,
  3739. weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
  3740. days = normalizedInput.day || 0,
  3741. hours = normalizedInput.hour || 0,
  3742. minutes = normalizedInput.minute || 0,
  3743. seconds = normalizedInput.second || 0,
  3744. milliseconds = normalizedInput.millisecond || 0;
  3745. this._isValid = isDurationValid(normalizedInput);
  3746. // representation for dateAddRemove
  3747. this._milliseconds =
  3748. +milliseconds +
  3749. seconds * 1e3 + // 1000
  3750. minutes * 6e4 + // 1000 * 60
  3751. hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
  3752. // Because of dateAddRemove treats 24 hours as different from a
  3753. // day when working around DST, we need to store them separately
  3754. this._days = +days + weeks * 7;
  3755. // It is impossible to translate months into days without knowing
  3756. // which months you are are talking about, so we have to store
  3757. // it separately.
  3758. this._months = +months + quarters * 3 + years * 12;
  3759. this._data = {};
  3760. this._locale = getLocale();
  3761. this._bubble();
  3762. }
  3763. function isDuration(obj) {
  3764. return obj instanceof Duration;
  3765. }
  3766. function absRound(number) {
  3767. if (number < 0) {
  3768. return Math.round(-1 * number) * -1;
  3769. } else {
  3770. return Math.round(number);
  3771. }
  3772. }
  3773. // compare two arrays, return the number of differences
  3774. function compareArrays(array1, array2, dontConvert) {
  3775. var len = Math.min(array1.length, array2.length),
  3776. lengthDiff = Math.abs(array1.length - array2.length),
  3777. diffs = 0,
  3778. i;
  3779. for (i = 0; i < len; i++) {
  3780. if (
  3781. (dontConvert && array1[i] !== array2[i]) ||
  3782. (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))
  3783. ) {
  3784. diffs++;
  3785. }
  3786. }
  3787. return diffs + lengthDiff;
  3788. }
  3789. // FORMATTING
  3790. function offset(token, separator) {
  3791. addFormatToken(token, 0, 0, function () {
  3792. var offset = this.utcOffset(),
  3793. sign = '+';
  3794. if (offset < 0) {
  3795. offset = -offset;
  3796. sign = '-';
  3797. }
  3798. return (
  3799. sign +
  3800. zeroFill(~~(offset / 60), 2) +
  3801. separator +
  3802. zeroFill(~~offset % 60, 2)
  3803. );
  3804. });
  3805. }
  3806. offset('Z', ':');
  3807. offset('ZZ', '');
  3808. // PARSING
  3809. addRegexToken('Z', matchShortOffset);
  3810. addRegexToken('ZZ', matchShortOffset);
  3811. addParseToken(['Z', 'ZZ'], function (input, array, config) {
  3812. config._useUTC = true;
  3813. config._tzm = offsetFromString(matchShortOffset, input);
  3814. });
  3815. // HELPERS
  3816. // timezone chunker
  3817. // '+10:00' > ['10', '00']
  3818. // '-1530' > ['-15', '30']
  3819. var chunkOffset = /([\+\-]|\d\d)/gi;
  3820. function offsetFromString(matcher, string) {
  3821. var matches = (string || '').match(matcher),
  3822. chunk,
  3823. parts,
  3824. minutes;
  3825. if (matches === null) {
  3826. return null;
  3827. }
  3828. chunk = matches[matches.length - 1] || [];
  3829. parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
  3830. minutes = +(parts[1] * 60) + toInt(parts[2]);
  3831. return minutes === 0 ? 0 : parts[0] === '+' ? minutes : -minutes;
  3832. }
  3833. // Return a moment from input, that is local/utc/zone equivalent to model.
  3834. function cloneWithOffset(input, model) {
  3835. var res, diff;
  3836. if (model._isUTC) {
  3837. res = model.clone();
  3838. diff =
  3839. (isMoment(input) || isDate(input)
  3840. ? input.valueOf()
  3841. : createLocal(input).valueOf()) - res.valueOf();
  3842. // Use low-level api, because this fn is low-level api.
  3843. res._d.setTime(res._d.valueOf() + diff);
  3844. hooks.updateOffset(res, false);
  3845. return res;
  3846. } else {
  3847. return createLocal(input).local();
  3848. }
  3849. }
  3850. function getDateOffset(m) {
  3851. // On Firefox.24 Date#getTimezoneOffset returns a floating point.
  3852. // https://github.com/moment/moment/pull/1871
  3853. return -Math.round(m._d.getTimezoneOffset());
  3854. }
  3855. // HOOKS
  3856. // This function will be called whenever a moment is mutated.
  3857. // It is intended to keep the offset in sync with the timezone.
  3858. hooks.updateOffset = function () {};
  3859. // MOMENTS
  3860. // keepLocalTime = true means only change the timezone, without
  3861. // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
  3862. // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
  3863. // +0200, so we adjust the time as needed, to be valid.
  3864. //
  3865. // Keeping the time actually adds/subtracts (one hour)
  3866. // from the actual represented time. That is why we call updateOffset
  3867. // a second time. In case it wants us to change the offset again
  3868. // _changeInProgress == true case, then we have to adjust, because
  3869. // there is no such time in the given timezone.
  3870. function getSetOffset(input, keepLocalTime, keepMinutes) {
  3871. var offset = this._offset || 0,
  3872. localAdjust;
  3873. if (!this.isValid()) {
  3874. return input != null ? this : NaN;
  3875. }
  3876. if (input != null) {
  3877. if (typeof input === 'string') {
  3878. input = offsetFromString(matchShortOffset, input);
  3879. if (input === null) {
  3880. return this;
  3881. }
  3882. } else if (Math.abs(input) < 16 && !keepMinutes) {
  3883. input = input * 60;
  3884. }
  3885. if (!this._isUTC && keepLocalTime) {
  3886. localAdjust = getDateOffset(this);
  3887. }
  3888. this._offset = input;
  3889. this._isUTC = true;
  3890. if (localAdjust != null) {
  3891. this.add(localAdjust, 'm');
  3892. }
  3893. if (offset !== input) {
  3894. if (!keepLocalTime || this._changeInProgress) {
  3895. addSubtract(
  3896. this,
  3897. createDuration(input - offset, 'm'),
  3898. 1,
  3899. false
  3900. );
  3901. } else if (!this._changeInProgress) {
  3902. this._changeInProgress = true;
  3903. hooks.updateOffset(this, true);
  3904. this._changeInProgress = null;
  3905. }
  3906. }
  3907. return this;
  3908. } else {
  3909. return this._isUTC ? offset : getDateOffset(this);
  3910. }
  3911. }
  3912. function getSetZone(input, keepLocalTime) {
  3913. if (input != null) {
  3914. if (typeof input !== 'string') {
  3915. input = -input;
  3916. }
  3917. this.utcOffset(input, keepLocalTime);
  3918. return this;
  3919. } else {
  3920. return -this.utcOffset();
  3921. }
  3922. }
  3923. function setOffsetToUTC(keepLocalTime) {
  3924. return this.utcOffset(0, keepLocalTime);
  3925. }
  3926. function setOffsetToLocal(keepLocalTime) {
  3927. if (this._isUTC) {
  3928. this.utcOffset(0, keepLocalTime);
  3929. this._isUTC = false;
  3930. if (keepLocalTime) {
  3931. this.subtract(getDateOffset(this), 'm');
  3932. }
  3933. }
  3934. return this;
  3935. }
  3936. function setOffsetToParsedOffset() {
  3937. if (this._tzm != null) {
  3938. this.utcOffset(this._tzm, false, true);
  3939. } else if (typeof this._i === 'string') {
  3940. var tZone = offsetFromString(matchOffset, this._i);
  3941. if (tZone != null) {
  3942. this.utcOffset(tZone);
  3943. } else {
  3944. this.utcOffset(0, true);
  3945. }
  3946. }
  3947. return this;
  3948. }
  3949. function hasAlignedHourOffset(input) {
  3950. if (!this.isValid()) {
  3951. return false;
  3952. }
  3953. input = input ? createLocal(input).utcOffset() : 0;
  3954. return (this.utcOffset() - input) % 60 === 0;
  3955. }
  3956. function isDaylightSavingTime() {
  3957. return (
  3958. this.utcOffset() > this.clone().month(0).utcOffset() ||
  3959. this.utcOffset() > this.clone().month(5).utcOffset()
  3960. );
  3961. }
  3962. function isDaylightSavingTimeShifted() {
  3963. if (!isUndefined(this._isDSTShifted)) {
  3964. return this._isDSTShifted;
  3965. }
  3966. var c = {},
  3967. other;
  3968. copyConfig(c, this);
  3969. c = prepareConfig(c);
  3970. if (c._a) {
  3971. other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
  3972. this._isDSTShifted =
  3973. this.isValid() && compareArrays(c._a, other.toArray()) > 0;
  3974. } else {
  3975. this._isDSTShifted = false;
  3976. }
  3977. return this._isDSTShifted;
  3978. }
  3979. function isLocal() {
  3980. return this.isValid() ? !this._isUTC : false;
  3981. }
  3982. function isUtcOffset() {
  3983. return this.isValid() ? this._isUTC : false;
  3984. }
  3985. function isUtc() {
  3986. return this.isValid() ? this._isUTC && this._offset === 0 : false;
  3987. }
  3988. // ASP.NET json date format regex
  3989. var aspNetRegex = /^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,
  3990. // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
  3991. // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
  3992. // and further modified to allow for strings containing both week and day
  3993. isoRegex =
  3994. /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
  3995. function createDuration(input, key) {
  3996. var duration = input,
  3997. // matching against regexp is expensive, do it on demand
  3998. match = null,
  3999. sign,
  4000. ret,
  4001. diffRes;
  4002. if (isDuration(input)) {
  4003. duration = {
  4004. ms: input._milliseconds,
  4005. d: input._days,
  4006. M: input._months,
  4007. };
  4008. } else if (isNumber(input) || !isNaN(+input)) {
  4009. duration = {};
  4010. if (key) {
  4011. duration[key] = +input;
  4012. } else {
  4013. duration.milliseconds = +input;
  4014. }
  4015. } else if ((match = aspNetRegex.exec(input))) {
  4016. sign = match[1] === '-' ? -1 : 1;
  4017. duration = {
  4018. y: 0,
  4019. d: toInt(match[DATE]) * sign,
  4020. h: toInt(match[HOUR]) * sign,
  4021. m: toInt(match[MINUTE]) * sign,
  4022. s: toInt(match[SECOND]) * sign,
  4023. ms: toInt(absRound(match[MILLISECOND] * 1000)) * sign, // the millisecond decimal point is included in the match
  4024. };
  4025. } else if ((match = isoRegex.exec(input))) {
  4026. sign = match[1] === '-' ? -1 : 1;
  4027. duration = {
  4028. y: parseIso(match[2], sign),
  4029. M: parseIso(match[3], sign),
  4030. w: parseIso(match[4], sign),
  4031. d: parseIso(match[5], sign),
  4032. h: parseIso(match[6], sign),
  4033. m: parseIso(match[7], sign),
  4034. s: parseIso(match[8], sign),
  4035. };
  4036. } else if (duration == null) {
  4037. // checks for null or undefined
  4038. duration = {};
  4039. } else if (
  4040. typeof duration === 'object' &&
  4041. ('from' in duration || 'to' in duration)
  4042. ) {
  4043. diffRes = momentsDifference(
  4044. createLocal(duration.from),
  4045. createLocal(duration.to)
  4046. );
  4047. duration = {};
  4048. duration.ms = diffRes.milliseconds;
  4049. duration.M = diffRes.months;
  4050. }
  4051. ret = new Duration(duration);
  4052. if (isDuration(input) && hasOwnProp(input, '_locale')) {
  4053. ret._locale = input._locale;
  4054. }
  4055. if (isDuration(input) && hasOwnProp(input, '_isValid')) {
  4056. ret._isValid = input._isValid;
  4057. }
  4058. return ret;
  4059. }
  4060. createDuration.fn = Duration.prototype;
  4061. createDuration.invalid = createInvalid$1;
  4062. function parseIso(inp, sign) {
  4063. // We'd normally use ~~inp for this, but unfortunately it also
  4064. // converts floats to ints.
  4065. // inp may be undefined, so careful calling replace on it.
  4066. var res = inp && parseFloat(inp.replace(',', '.'));
  4067. // apply sign while we're at it
  4068. return (isNaN(res) ? 0 : res) * sign;
  4069. }
  4070. function positiveMomentsDifference(base, other) {
  4071. var res = {};
  4072. res.months =
  4073. other.month() - base.month() + (other.year() - base.year()) * 12;
  4074. if (base.clone().add(res.months, 'M').isAfter(other)) {
  4075. --res.months;
  4076. }
  4077. res.milliseconds = +other - +base.clone().add(res.months, 'M');
  4078. return res;
  4079. }
  4080. function momentsDifference(base, other) {
  4081. var res;
  4082. if (!(base.isValid() && other.isValid())) {
  4083. return { milliseconds: 0, months: 0 };
  4084. }
  4085. other = cloneWithOffset(other, base);
  4086. if (base.isBefore(other)) {
  4087. res = positiveMomentsDifference(base, other);
  4088. } else {
  4089. res = positiveMomentsDifference(other, base);
  4090. res.milliseconds = -res.milliseconds;
  4091. res.months = -res.months;
  4092. }
  4093. return res;
  4094. }
  4095. // TODO: remove 'name' arg after deprecation is removed
  4096. function createAdder(direction, name) {
  4097. return function (val, period) {
  4098. var dur, tmp;
  4099. //invert the arguments, but complain about it
  4100. if (period !== null && !isNaN(+period)) {
  4101. deprecateSimple(
  4102. name,
  4103. 'moment().' +
  4104. name +
  4105. '(period, number) is deprecated. Please use moment().' +
  4106. name +
  4107. '(number, period). ' +
  4108. 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.'
  4109. );
  4110. tmp = val;
  4111. val = period;
  4112. period = tmp;
  4113. }
  4114. dur = createDuration(val, period);
  4115. addSubtract(this, dur, direction);
  4116. return this;
  4117. };
  4118. }
  4119. function addSubtract(mom, duration, isAdding, updateOffset) {
  4120. var milliseconds = duration._milliseconds,
  4121. days = absRound(duration._days),
  4122. months = absRound(duration._months);
  4123. if (!mom.isValid()) {
  4124. // No op
  4125. return;
  4126. }
  4127. updateOffset = updateOffset == null ? true : updateOffset;
  4128. if (months) {
  4129. setMonth(mom, get(mom, 'Month') + months * isAdding);
  4130. }
  4131. if (days) {
  4132. set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
  4133. }
  4134. if (milliseconds) {
  4135. mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
  4136. }
  4137. if (updateOffset) {
  4138. hooks.updateOffset(mom, days || months);
  4139. }
  4140. }
  4141. var add = createAdder(1, 'add'),
  4142. subtract = createAdder(-1, 'subtract');
  4143. function isString(input) {
  4144. return typeof input === 'string' || input instanceof String;
  4145. }
  4146. // type MomentInput = Moment | Date | string | number | (number | string)[] | MomentInputObject | void; // null | undefined
  4147. function isMomentInput(input) {
  4148. return (
  4149. isMoment(input) ||
  4150. isDate(input) ||
  4151. isString(input) ||
  4152. isNumber(input) ||
  4153. isNumberOrStringArray(input) ||
  4154. isMomentInputObject(input) ||
  4155. input === null ||
  4156. input === undefined
  4157. );
  4158. }
  4159. function isMomentInputObject(input) {
  4160. var objectTest = isObject(input) && !isObjectEmpty(input),
  4161. propertyTest = false,
  4162. properties = [
  4163. 'years',
  4164. 'year',
  4165. 'y',
  4166. 'months',
  4167. 'month',
  4168. 'M',
  4169. 'days',
  4170. 'day',
  4171. 'd',
  4172. 'dates',
  4173. 'date',
  4174. 'D',
  4175. 'hours',
  4176. 'hour',
  4177. 'h',
  4178. 'minutes',
  4179. 'minute',
  4180. 'm',
  4181. 'seconds',
  4182. 'second',
  4183. 's',
  4184. 'milliseconds',
  4185. 'millisecond',
  4186. 'ms',
  4187. ],
  4188. i,
  4189. property,
  4190. propertyLen = properties.length;
  4191. for (i = 0; i < propertyLen; i += 1) {
  4192. property = properties[i];
  4193. propertyTest = propertyTest || hasOwnProp(input, property);
  4194. }
  4195. return objectTest && propertyTest;
  4196. }
  4197. function isNumberOrStringArray(input) {
  4198. var arrayTest = isArray(input),
  4199. dataTypeTest = false;
  4200. if (arrayTest) {
  4201. dataTypeTest =
  4202. input.filter(function (item) {
  4203. return !isNumber(item) && isString(input);
  4204. }).length === 0;
  4205. }
  4206. return arrayTest && dataTypeTest;
  4207. }
  4208. function isCalendarSpec(input) {
  4209. var objectTest = isObject(input) && !isObjectEmpty(input),
  4210. propertyTest = false,
  4211. properties = [
  4212. 'sameDay',
  4213. 'nextDay',
  4214. 'lastDay',
  4215. 'nextWeek',
  4216. 'lastWeek',
  4217. 'sameElse',
  4218. ],
  4219. i,
  4220. property;
  4221. for (i = 0; i < properties.length; i += 1) {
  4222. property = properties[i];
  4223. propertyTest = propertyTest || hasOwnProp(input, property);
  4224. }
  4225. return objectTest && propertyTest;
  4226. }
  4227. function getCalendarFormat(myMoment, now) {
  4228. var diff = myMoment.diff(now, 'days', true);
  4229. return diff < -6
  4230. ? 'sameElse'
  4231. : diff < -1
  4232. ? 'lastWeek'
  4233. : diff < 0
  4234. ? 'lastDay'
  4235. : diff < 1
  4236. ? 'sameDay'
  4237. : diff < 2
  4238. ? 'nextDay'
  4239. : diff < 7
  4240. ? 'nextWeek'
  4241. : 'sameElse';
  4242. }
  4243. function calendar$1(time, formats) {
  4244. // Support for single parameter, formats only overload to the calendar function
  4245. if (arguments.length === 1) {
  4246. if (!arguments[0]) {
  4247. time = undefined;
  4248. formats = undefined;
  4249. } else if (isMomentInput(arguments[0])) {
  4250. time = arguments[0];
  4251. formats = undefined;
  4252. } else if (isCalendarSpec(arguments[0])) {
  4253. formats = arguments[0];
  4254. time = undefined;
  4255. }
  4256. }
  4257. // We want to compare the start of today, vs this.
  4258. // Getting start-of-today depends on whether we're local/utc/offset or not.
  4259. var now = time || createLocal(),
  4260. sod = cloneWithOffset(now, this).startOf('day'),
  4261. format = hooks.calendarFormat(this, sod) || 'sameElse',
  4262. output =
  4263. formats &&
  4264. (isFunction(formats[format])
  4265. ? formats[format].call(this, now)
  4266. : formats[format]);
  4267. return this.format(
  4268. output || this.localeData().calendar(format, this, createLocal(now))
  4269. );
  4270. }
  4271. function clone() {
  4272. return new Moment(this);
  4273. }
  4274. function isAfter(input, units) {
  4275. var localInput = isMoment(input) ? input : createLocal(input);
  4276. if (!(this.isValid() && localInput.isValid())) {
  4277. return false;
  4278. }
  4279. units = normalizeUnits(units) || 'millisecond';
  4280. if (units === 'millisecond') {
  4281. return this.valueOf() > localInput.valueOf();
  4282. } else {
  4283. return localInput.valueOf() < this.clone().startOf(units).valueOf();
  4284. }
  4285. }
  4286. function isBefore(input, units) {
  4287. var localInput = isMoment(input) ? input : createLocal(input);
  4288. if (!(this.isValid() && localInput.isValid())) {
  4289. return false;
  4290. }
  4291. units = normalizeUnits(units) || 'millisecond';
  4292. if (units === 'millisecond') {
  4293. return this.valueOf() < localInput.valueOf();
  4294. } else {
  4295. return this.clone().endOf(units).valueOf() < localInput.valueOf();
  4296. }
  4297. }
  4298. function isBetween(from, to, units, inclusivity) {
  4299. var localFrom = isMoment(from) ? from : createLocal(from),
  4300. localTo = isMoment(to) ? to : createLocal(to);
  4301. if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
  4302. return false;
  4303. }
  4304. inclusivity = inclusivity || '()';
  4305. return (
  4306. (inclusivity[0] === '('
  4307. ? this.isAfter(localFrom, units)
  4308. : !this.isBefore(localFrom, units)) &&
  4309. (inclusivity[1] === ')'
  4310. ? this.isBefore(localTo, units)
  4311. : !this.isAfter(localTo, units))
  4312. );
  4313. }
  4314. function isSame(input, units) {
  4315. var localInput = isMoment(input) ? input : createLocal(input),
  4316. inputMs;
  4317. if (!(this.isValid() && localInput.isValid())) {
  4318. return false;
  4319. }
  4320. units = normalizeUnits(units) || 'millisecond';
  4321. if (units === 'millisecond') {
  4322. return this.valueOf() === localInput.valueOf();
  4323. } else {
  4324. inputMs = localInput.valueOf();
  4325. return (
  4326. this.clone().startOf(units).valueOf() <= inputMs &&
  4327. inputMs <= this.clone().endOf(units).valueOf()
  4328. );
  4329. }
  4330. }
  4331. function isSameOrAfter(input, units) {
  4332. return this.isSame(input, units) || this.isAfter(input, units);
  4333. }
  4334. function isSameOrBefore(input, units) {
  4335. return this.isSame(input, units) || this.isBefore(input, units);
  4336. }
  4337. function diff(input, units, asFloat) {
  4338. var that, zoneDelta, output;
  4339. if (!this.isValid()) {
  4340. return NaN;
  4341. }
  4342. that = cloneWithOffset(input, this);
  4343. if (!that.isValid()) {
  4344. return NaN;
  4345. }
  4346. zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
  4347. units = normalizeUnits(units);
  4348. switch (units) {
  4349. case 'year':
  4350. output = monthDiff(this, that) / 12;
  4351. break;
  4352. case 'month':
  4353. output = monthDiff(this, that);
  4354. break;
  4355. case 'quarter':
  4356. output = monthDiff(this, that) / 3;
  4357. break;
  4358. case 'second':
  4359. output = (this - that) / 1e3;
  4360. break; // 1000
  4361. case 'minute':
  4362. output = (this - that) / 6e4;
  4363. break; // 1000 * 60
  4364. case 'hour':
  4365. output = (this - that) / 36e5;
  4366. break; // 1000 * 60 * 60
  4367. case 'day':
  4368. output = (this - that - zoneDelta) / 864e5;
  4369. break; // 1000 * 60 * 60 * 24, negate dst
  4370. case 'week':
  4371. output = (this - that - zoneDelta) / 6048e5;
  4372. break; // 1000 * 60 * 60 * 24 * 7, negate dst
  4373. default:
  4374. output = this - that;
  4375. }
  4376. return asFloat ? output : absFloor(output);
  4377. }
  4378. function monthDiff(a, b) {
  4379. if (a.date() < b.date()) {
  4380. // end-of-month calculations work correct when the start month has more
  4381. // days than the end month.
  4382. return -monthDiff(b, a);
  4383. }
  4384. // difference in months
  4385. var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month()),
  4386. // b is in (anchor - 1 month, anchor + 1 month)
  4387. anchor = a.clone().add(wholeMonthDiff, 'months'),
  4388. anchor2,
  4389. adjust;
  4390. if (b - anchor < 0) {
  4391. anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
  4392. // linear across the month
  4393. adjust = (b - anchor) / (anchor - anchor2);
  4394. } else {
  4395. anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
  4396. // linear across the month
  4397. adjust = (b - anchor) / (anchor2 - anchor);
  4398. }
  4399. //check for negative zero, return zero if negative zero
  4400. return -(wholeMonthDiff + adjust) || 0;
  4401. }
  4402. hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
  4403. hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
  4404. function toString() {
  4405. return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
  4406. }
  4407. function toISOString(keepOffset) {
  4408. if (!this.isValid()) {
  4409. return null;
  4410. }
  4411. var utc = keepOffset !== true,
  4412. m = utc ? this.clone().utc() : this;
  4413. if (m.year() < 0 || m.year() > 9999) {
  4414. return formatMoment(
  4415. m,
  4416. utc
  4417. ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]'
  4418. : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ'
  4419. );
  4420. }
  4421. if (isFunction(Date.prototype.toISOString)) {
  4422. // native implementation is ~50x faster, use it when we can
  4423. if (utc) {
  4424. return this.toDate().toISOString();
  4425. } else {
  4426. return new Date(this.valueOf() + this.utcOffset() * 60 * 1000)
  4427. .toISOString()
  4428. .replace('Z', formatMoment(m, 'Z'));
  4429. }
  4430. }
  4431. return formatMoment(
  4432. m,
  4433. utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ'
  4434. );
  4435. }
  4436. /**
  4437. * Return a human readable representation of a moment that can
  4438. * also be evaluated to get a new moment which is the same
  4439. *
  4440. * @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects
  4441. */
  4442. function inspect() {
  4443. if (!this.isValid()) {
  4444. return 'moment.invalid(/* ' + this._i + ' */)';
  4445. }
  4446. var func = 'moment',
  4447. zone = '',
  4448. prefix,
  4449. year,
  4450. datetime,
  4451. suffix;
  4452. if (!this.isLocal()) {
  4453. func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
  4454. zone = 'Z';
  4455. }
  4456. prefix = '[' + func + '("]';
  4457. year = 0 <= this.year() && this.year() <= 9999 ? 'YYYY' : 'YYYYYY';
  4458. datetime = '-MM-DD[T]HH:mm:ss.SSS';
  4459. suffix = zone + '[")]';
  4460. return this.format(prefix + year + datetime + suffix);
  4461. }
  4462. function format(inputString) {
  4463. if (!inputString) {
  4464. inputString = this.isUtc()
  4465. ? hooks.defaultFormatUtc
  4466. : hooks.defaultFormat;
  4467. }
  4468. var output = formatMoment(this, inputString);
  4469. return this.localeData().postformat(output);
  4470. }
  4471. function from(time, withoutSuffix) {
  4472. if (
  4473. this.isValid() &&
  4474. ((isMoment(time) && time.isValid()) || createLocal(time).isValid())
  4475. ) {
  4476. return createDuration({ to: this, from: time })
  4477. .locale(this.locale())
  4478. .humanize(!withoutSuffix);
  4479. } else {
  4480. return this.localeData().invalidDate();
  4481. }
  4482. }
  4483. function fromNow(withoutSuffix) {
  4484. return this.from(createLocal(), withoutSuffix);
  4485. }
  4486. function to(time, withoutSuffix) {
  4487. if (
  4488. this.isValid() &&
  4489. ((isMoment(time) && time.isValid()) || createLocal(time).isValid())
  4490. ) {
  4491. return createDuration({ from: this, to: time })
  4492. .locale(this.locale())
  4493. .humanize(!withoutSuffix);
  4494. } else {
  4495. return this.localeData().invalidDate();
  4496. }
  4497. }
  4498. function toNow(withoutSuffix) {
  4499. return this.to(createLocal(), withoutSuffix);
  4500. }
  4501. // If passed a locale key, it will set the locale for this
  4502. // instance. Otherwise, it will return the locale configuration
  4503. // variables for this instance.
  4504. function locale(key) {
  4505. var newLocaleData;
  4506. if (key === undefined) {
  4507. return this._locale._abbr;
  4508. } else {
  4509. newLocaleData = getLocale(key);
  4510. if (newLocaleData != null) {
  4511. this._locale = newLocaleData;
  4512. }
  4513. return this;
  4514. }
  4515. }
  4516. var lang = deprecate(
  4517. 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
  4518. function (key) {
  4519. if (key === undefined) {
  4520. return this.localeData();
  4521. } else {
  4522. return this.locale(key);
  4523. }
  4524. }
  4525. );
  4526. function localeData() {
  4527. return this._locale;
  4528. }
  4529. var MS_PER_SECOND = 1000,
  4530. MS_PER_MINUTE = 60 * MS_PER_SECOND,
  4531. MS_PER_HOUR = 60 * MS_PER_MINUTE,
  4532. MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
  4533. // actual modulo - handles negative numbers (for dates before 1970):
  4534. function mod$1(dividend, divisor) {
  4535. return ((dividend % divisor) + divisor) % divisor;
  4536. }
  4537. function localStartOfDate(y, m, d) {
  4538. // the date constructor remaps years 0-99 to 1900-1999
  4539. if (y < 100 && y >= 0) {
  4540. // preserve leap years using a full 400 year cycle, then reset
  4541. return new Date(y + 400, m, d) - MS_PER_400_YEARS;
  4542. } else {
  4543. return new Date(y, m, d).valueOf();
  4544. }
  4545. }
  4546. function utcStartOfDate(y, m, d) {
  4547. // Date.UTC remaps years 0-99 to 1900-1999
  4548. if (y < 100 && y >= 0) {
  4549. // preserve leap years using a full 400 year cycle, then reset
  4550. return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
  4551. } else {
  4552. return Date.UTC(y, m, d);
  4553. }
  4554. }
  4555. function startOf(units) {
  4556. var time, startOfDate;
  4557. units = normalizeUnits(units);
  4558. if (units === undefined || units === 'millisecond' || !this.isValid()) {
  4559. return this;
  4560. }
  4561. startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
  4562. switch (units) {
  4563. case 'year':
  4564. time = startOfDate(this.year(), 0, 1);
  4565. break;
  4566. case 'quarter':
  4567. time = startOfDate(
  4568. this.year(),
  4569. this.month() - (this.month() % 3),
  4570. 1
  4571. );
  4572. break;
  4573. case 'month':
  4574. time = startOfDate(this.year(), this.month(), 1);
  4575. break;
  4576. case 'week':
  4577. time = startOfDate(
  4578. this.year(),
  4579. this.month(),
  4580. this.date() - this.weekday()
  4581. );
  4582. break;
  4583. case 'isoWeek':
  4584. time = startOfDate(
  4585. this.year(),
  4586. this.month(),
  4587. this.date() - (this.isoWeekday() - 1)
  4588. );
  4589. break;
  4590. case 'day':
  4591. case 'date':
  4592. time = startOfDate(this.year(), this.month(), this.date());
  4593. break;
  4594. case 'hour':
  4595. time = this._d.valueOf();
  4596. time -= mod$1(
  4597. time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
  4598. MS_PER_HOUR
  4599. );
  4600. break;
  4601. case 'minute':
  4602. time = this._d.valueOf();
  4603. time -= mod$1(time, MS_PER_MINUTE);
  4604. break;
  4605. case 'second':
  4606. time = this._d.valueOf();
  4607. time -= mod$1(time, MS_PER_SECOND);
  4608. break;
  4609. }
  4610. this._d.setTime(time);
  4611. hooks.updateOffset(this, true);
  4612. return this;
  4613. }
  4614. function endOf(units) {
  4615. var time, startOfDate;
  4616. units = normalizeUnits(units);
  4617. if (units === undefined || units === 'millisecond' || !this.isValid()) {
  4618. return this;
  4619. }
  4620. startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
  4621. switch (units) {
  4622. case 'year':
  4623. time = startOfDate(this.year() + 1, 0, 1) - 1;
  4624. break;
  4625. case 'quarter':
  4626. time =
  4627. startOfDate(
  4628. this.year(),
  4629. this.month() - (this.month() % 3) + 3,
  4630. 1
  4631. ) - 1;
  4632. break;
  4633. case 'month':
  4634. time = startOfDate(this.year(), this.month() + 1, 1) - 1;
  4635. break;
  4636. case 'week':
  4637. time =
  4638. startOfDate(
  4639. this.year(),
  4640. this.month(),
  4641. this.date() - this.weekday() + 7
  4642. ) - 1;
  4643. break;
  4644. case 'isoWeek':
  4645. time =
  4646. startOfDate(
  4647. this.year(),
  4648. this.month(),
  4649. this.date() - (this.isoWeekday() - 1) + 7
  4650. ) - 1;
  4651. break;
  4652. case 'day':
  4653. case 'date':
  4654. time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
  4655. break;
  4656. case 'hour':
  4657. time = this._d.valueOf();
  4658. time +=
  4659. MS_PER_HOUR -
  4660. mod$1(
  4661. time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
  4662. MS_PER_HOUR
  4663. ) -
  4664. 1;
  4665. break;
  4666. case 'minute':
  4667. time = this._d.valueOf();
  4668. time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
  4669. break;
  4670. case 'second':
  4671. time = this._d.valueOf();
  4672. time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
  4673. break;
  4674. }
  4675. this._d.setTime(time);
  4676. hooks.updateOffset(this, true);
  4677. return this;
  4678. }
  4679. function valueOf() {
  4680. return this._d.valueOf() - (this._offset || 0) * 60000;
  4681. }
  4682. function unix() {
  4683. return Math.floor(this.valueOf() / 1000);
  4684. }
  4685. function toDate() {
  4686. return new Date(this.valueOf());
  4687. }
  4688. function toArray() {
  4689. var m = this;
  4690. return [
  4691. m.year(),
  4692. m.month(),
  4693. m.date(),
  4694. m.hour(),
  4695. m.minute(),
  4696. m.second(),
  4697. m.millisecond(),
  4698. ];
  4699. }
  4700. function toObject() {
  4701. var m = this;
  4702. return {
  4703. years: m.year(),
  4704. months: m.month(),
  4705. date: m.date(),
  4706. hours: m.hours(),
  4707. minutes: m.minutes(),
  4708. seconds: m.seconds(),
  4709. milliseconds: m.milliseconds(),
  4710. };
  4711. }
  4712. function toJSON() {
  4713. // new Date(NaN).toJSON() === null
  4714. return this.isValid() ? this.toISOString() : null;
  4715. }
  4716. function isValid$2() {
  4717. return isValid(this);
  4718. }
  4719. function parsingFlags() {
  4720. return extend({}, getParsingFlags(this));
  4721. }
  4722. function invalidAt() {
  4723. return getParsingFlags(this).overflow;
  4724. }
  4725. function creationData() {
  4726. return {
  4727. input: this._i,
  4728. format: this._f,
  4729. locale: this._locale,
  4730. isUTC: this._isUTC,
  4731. strict: this._strict,
  4732. };
  4733. }
  4734. addFormatToken('N', 0, 0, 'eraAbbr');
  4735. addFormatToken('NN', 0, 0, 'eraAbbr');
  4736. addFormatToken('NNN', 0, 0, 'eraAbbr');
  4737. addFormatToken('NNNN', 0, 0, 'eraName');
  4738. addFormatToken('NNNNN', 0, 0, 'eraNarrow');
  4739. addFormatToken('y', ['y', 1], 'yo', 'eraYear');
  4740. addFormatToken('y', ['yy', 2], 0, 'eraYear');
  4741. addFormatToken('y', ['yyy', 3], 0, 'eraYear');
  4742. addFormatToken('y', ['yyyy', 4], 0, 'eraYear');
  4743. addRegexToken('N', matchEraAbbr);
  4744. addRegexToken('NN', matchEraAbbr);
  4745. addRegexToken('NNN', matchEraAbbr);
  4746. addRegexToken('NNNN', matchEraName);
  4747. addRegexToken('NNNNN', matchEraNarrow);
  4748. addParseToken(
  4749. ['N', 'NN', 'NNN', 'NNNN', 'NNNNN'],
  4750. function (input, array, config, token) {
  4751. var era = config._locale.erasParse(input, token, config._strict);
  4752. if (era) {
  4753. getParsingFlags(config).era = era;
  4754. } else {
  4755. getParsingFlags(config).invalidEra = input;
  4756. }
  4757. }
  4758. );
  4759. addRegexToken('y', matchUnsigned);
  4760. addRegexToken('yy', matchUnsigned);
  4761. addRegexToken('yyy', matchUnsigned);
  4762. addRegexToken('yyyy', matchUnsigned);
  4763. addRegexToken('yo', matchEraYearOrdinal);
  4764. addParseToken(['y', 'yy', 'yyy', 'yyyy'], YEAR);
  4765. addParseToken(['yo'], function (input, array, config, token) {
  4766. var match;
  4767. if (config._locale._eraYearOrdinalRegex) {
  4768. match = input.match(config._locale._eraYearOrdinalRegex);
  4769. }
  4770. if (config._locale.eraYearOrdinalParse) {
  4771. array[YEAR] = config._locale.eraYearOrdinalParse(input, match);
  4772. } else {
  4773. array[YEAR] = parseInt(input, 10);
  4774. }
  4775. });
  4776. function localeEras(m, format) {
  4777. var i,
  4778. l,
  4779. date,
  4780. eras = this._eras || getLocale('en')._eras;
  4781. for (i = 0, l = eras.length; i < l; ++i) {
  4782. switch (typeof eras[i].since) {
  4783. case 'string':
  4784. // truncate time
  4785. date = hooks(eras[i].since).startOf('day');
  4786. eras[i].since = date.valueOf();
  4787. break;
  4788. }
  4789. switch (typeof eras[i].until) {
  4790. case 'undefined':
  4791. eras[i].until = +Infinity;
  4792. break;
  4793. case 'string':
  4794. // truncate time
  4795. date = hooks(eras[i].until).startOf('day').valueOf();
  4796. eras[i].until = date.valueOf();
  4797. break;
  4798. }
  4799. }
  4800. return eras;
  4801. }
  4802. function localeErasParse(eraName, format, strict) {
  4803. var i,
  4804. l,
  4805. eras = this.eras(),
  4806. name,
  4807. abbr,
  4808. narrow;
  4809. eraName = eraName.toUpperCase();
  4810. for (i = 0, l = eras.length; i < l; ++i) {
  4811. name = eras[i].name.toUpperCase();
  4812. abbr = eras[i].abbr.toUpperCase();
  4813. narrow = eras[i].narrow.toUpperCase();
  4814. if (strict) {
  4815. switch (format) {
  4816. case 'N':
  4817. case 'NN':
  4818. case 'NNN':
  4819. if (abbr === eraName) {
  4820. return eras[i];
  4821. }
  4822. break;
  4823. case 'NNNN':
  4824. if (name === eraName) {
  4825. return eras[i];
  4826. }
  4827. break;
  4828. case 'NNNNN':
  4829. if (narrow === eraName) {
  4830. return eras[i];
  4831. }
  4832. break;
  4833. }
  4834. } else if ([name, abbr, narrow].indexOf(eraName) >= 0) {
  4835. return eras[i];
  4836. }
  4837. }
  4838. }
  4839. function localeErasConvertYear(era, year) {
  4840. var dir = era.since <= era.until ? +1 : -1;
  4841. if (year === undefined) {
  4842. return hooks(era.since).year();
  4843. } else {
  4844. return hooks(era.since).year() + (year - era.offset) * dir;
  4845. }
  4846. }
  4847. function getEraName() {
  4848. var i,
  4849. l,
  4850. val,
  4851. eras = this.localeData().eras();
  4852. for (i = 0, l = eras.length; i < l; ++i) {
  4853. // truncate time
  4854. val = this.clone().startOf('day').valueOf();
  4855. if (eras[i].since <= val && val <= eras[i].until) {
  4856. return eras[i].name;
  4857. }
  4858. if (eras[i].until <= val && val <= eras[i].since) {
  4859. return eras[i].name;
  4860. }
  4861. }
  4862. return '';
  4863. }
  4864. function getEraNarrow() {
  4865. var i,
  4866. l,
  4867. val,
  4868. eras = this.localeData().eras();
  4869. for (i = 0, l = eras.length; i < l; ++i) {
  4870. // truncate time
  4871. val = this.clone().startOf('day').valueOf();
  4872. if (eras[i].since <= val && val <= eras[i].until) {
  4873. return eras[i].narrow;
  4874. }
  4875. if (eras[i].until <= val && val <= eras[i].since) {
  4876. return eras[i].narrow;
  4877. }
  4878. }
  4879. return '';
  4880. }
  4881. function getEraAbbr() {
  4882. var i,
  4883. l,
  4884. val,
  4885. eras = this.localeData().eras();
  4886. for (i = 0, l = eras.length; i < l; ++i) {
  4887. // truncate time
  4888. val = this.clone().startOf('day').valueOf();
  4889. if (eras[i].since <= val && val <= eras[i].until) {
  4890. return eras[i].abbr;
  4891. }
  4892. if (eras[i].until <= val && val <= eras[i].since) {
  4893. return eras[i].abbr;
  4894. }
  4895. }
  4896. return '';
  4897. }
  4898. function getEraYear() {
  4899. var i,
  4900. l,
  4901. dir,
  4902. val,
  4903. eras = this.localeData().eras();
  4904. for (i = 0, l = eras.length; i < l; ++i) {
  4905. dir = eras[i].since <= eras[i].until ? +1 : -1;
  4906. // truncate time
  4907. val = this.clone().startOf('day').valueOf();
  4908. if (
  4909. (eras[i].since <= val && val <= eras[i].until) ||
  4910. (eras[i].until <= val && val <= eras[i].since)
  4911. ) {
  4912. return (
  4913. (this.year() - hooks(eras[i].since).year()) * dir +
  4914. eras[i].offset
  4915. );
  4916. }
  4917. }
  4918. return this.year();
  4919. }
  4920. function erasNameRegex(isStrict) {
  4921. if (!hasOwnProp(this, '_erasNameRegex')) {
  4922. computeErasParse.call(this);
  4923. }
  4924. return isStrict ? this._erasNameRegex : this._erasRegex;
  4925. }
  4926. function erasAbbrRegex(isStrict) {
  4927. if (!hasOwnProp(this, '_erasAbbrRegex')) {
  4928. computeErasParse.call(this);
  4929. }
  4930. return isStrict ? this._erasAbbrRegex : this._erasRegex;
  4931. }
  4932. function erasNarrowRegex(isStrict) {
  4933. if (!hasOwnProp(this, '_erasNarrowRegex')) {
  4934. computeErasParse.call(this);
  4935. }
  4936. return isStrict ? this._erasNarrowRegex : this._erasRegex;
  4937. }
  4938. function matchEraAbbr(isStrict, locale) {
  4939. return locale.erasAbbrRegex(isStrict);
  4940. }
  4941. function matchEraName(isStrict, locale) {
  4942. return locale.erasNameRegex(isStrict);
  4943. }
  4944. function matchEraNarrow(isStrict, locale) {
  4945. return locale.erasNarrowRegex(isStrict);
  4946. }
  4947. function matchEraYearOrdinal(isStrict, locale) {
  4948. return locale._eraYearOrdinalRegex || matchUnsigned;
  4949. }
  4950. function computeErasParse() {
  4951. var abbrPieces = [],
  4952. namePieces = [],
  4953. narrowPieces = [],
  4954. mixedPieces = [],
  4955. i,
  4956. l,
  4957. eras = this.eras();
  4958. for (i = 0, l = eras.length; i < l; ++i) {
  4959. namePieces.push(regexEscape(eras[i].name));
  4960. abbrPieces.push(regexEscape(eras[i].abbr));
  4961. narrowPieces.push(regexEscape(eras[i].narrow));
  4962. mixedPieces.push(regexEscape(eras[i].name));
  4963. mixedPieces.push(regexEscape(eras[i].abbr));
  4964. mixedPieces.push(regexEscape(eras[i].narrow));
  4965. }
  4966. this._erasRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  4967. this._erasNameRegex = new RegExp('^(' + namePieces.join('|') + ')', 'i');
  4968. this._erasAbbrRegex = new RegExp('^(' + abbrPieces.join('|') + ')', 'i');
  4969. this._erasNarrowRegex = new RegExp(
  4970. '^(' + narrowPieces.join('|') + ')',
  4971. 'i'
  4972. );
  4973. }
  4974. // FORMATTING
  4975. addFormatToken(0, ['gg', 2], 0, function () {
  4976. return this.weekYear() % 100;
  4977. });
  4978. addFormatToken(0, ['GG', 2], 0, function () {
  4979. return this.isoWeekYear() % 100;
  4980. });
  4981. function addWeekYearFormatToken(token, getter) {
  4982. addFormatToken(0, [token, token.length], 0, getter);
  4983. }
  4984. addWeekYearFormatToken('gggg', 'weekYear');
  4985. addWeekYearFormatToken('ggggg', 'weekYear');
  4986. addWeekYearFormatToken('GGGG', 'isoWeekYear');
  4987. addWeekYearFormatToken('GGGGG', 'isoWeekYear');
  4988. // ALIASES
  4989. addUnitAlias('weekYear', 'gg');
  4990. addUnitAlias('isoWeekYear', 'GG');
  4991. // PRIORITY
  4992. addUnitPriority('weekYear', 1);
  4993. addUnitPriority('isoWeekYear', 1);
  4994. // PARSING
  4995. addRegexToken('G', matchSigned);
  4996. addRegexToken('g', matchSigned);
  4997. addRegexToken('GG', match1to2, match2);
  4998. addRegexToken('gg', match1to2, match2);
  4999. addRegexToken('GGGG', match1to4, match4);
  5000. addRegexToken('gggg', match1to4, match4);
  5001. addRegexToken('GGGGG', match1to6, match6);
  5002. addRegexToken('ggggg', match1to6, match6);
  5003. addWeekParseToken(
  5004. ['gggg', 'ggggg', 'GGGG', 'GGGGG'],
  5005. function (input, week, config, token) {
  5006. week[token.substr(0, 2)] = toInt(input);
  5007. }
  5008. );
  5009. addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
  5010. week[token] = hooks.parseTwoDigitYear(input);
  5011. });
  5012. // MOMENTS
  5013. function getSetWeekYear(input) {
  5014. return getSetWeekYearHelper.call(
  5015. this,
  5016. input,
  5017. this.week(),
  5018. this.weekday(),
  5019. this.localeData()._week.dow,
  5020. this.localeData()._week.doy
  5021. );
  5022. }
  5023. function getSetISOWeekYear(input) {
  5024. return getSetWeekYearHelper.call(
  5025. this,
  5026. input,
  5027. this.isoWeek(),
  5028. this.isoWeekday(),
  5029. 1,
  5030. 4
  5031. );
  5032. }
  5033. function getISOWeeksInYear() {
  5034. return weeksInYear(this.year(), 1, 4);
  5035. }
  5036. function getISOWeeksInISOWeekYear() {
  5037. return weeksInYear(this.isoWeekYear(), 1, 4);
  5038. }
  5039. function getWeeksInYear() {
  5040. var weekInfo = this.localeData()._week;
  5041. return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
  5042. }
  5043. function getWeeksInWeekYear() {
  5044. var weekInfo = this.localeData()._week;
  5045. return weeksInYear(this.weekYear(), weekInfo.dow, weekInfo.doy);
  5046. }
  5047. function getSetWeekYearHelper(input, week, weekday, dow, doy) {
  5048. var weeksTarget;
  5049. if (input == null) {
  5050. return weekOfYear(this, dow, doy).year;
  5051. } else {
  5052. weeksTarget = weeksInYear(input, dow, doy);
  5053. if (week > weeksTarget) {
  5054. week = weeksTarget;
  5055. }
  5056. return setWeekAll.call(this, input, week, weekday, dow, doy);
  5057. }
  5058. }
  5059. function setWeekAll(weekYear, week, weekday, dow, doy) {
  5060. var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
  5061. date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
  5062. this.year(date.getUTCFullYear());
  5063. this.month(date.getUTCMonth());
  5064. this.date(date.getUTCDate());
  5065. return this;
  5066. }
  5067. // FORMATTING
  5068. addFormatToken('Q', 0, 'Qo', 'quarter');
  5069. // ALIASES
  5070. addUnitAlias('quarter', 'Q');
  5071. // PRIORITY
  5072. addUnitPriority('quarter', 7);
  5073. // PARSING
  5074. addRegexToken('Q', match1);
  5075. addParseToken('Q', function (input, array) {
  5076. array[MONTH] = (toInt(input) - 1) * 3;
  5077. });
  5078. // MOMENTS
  5079. function getSetQuarter(input) {
  5080. return input == null
  5081. ? Math.ceil((this.month() + 1) / 3)
  5082. : this.month((input - 1) * 3 + (this.month() % 3));
  5083. }
  5084. // FORMATTING
  5085. addFormatToken('D', ['DD', 2], 'Do', 'date');
  5086. // ALIASES
  5087. addUnitAlias('date', 'D');
  5088. // PRIORITY
  5089. addUnitPriority('date', 9);
  5090. // PARSING
  5091. addRegexToken('D', match1to2);
  5092. addRegexToken('DD', match1to2, match2);
  5093. addRegexToken('Do', function (isStrict, locale) {
  5094. // TODO: Remove "ordinalParse" fallback in next major release.
  5095. return isStrict
  5096. ? locale._dayOfMonthOrdinalParse || locale._ordinalParse
  5097. : locale._dayOfMonthOrdinalParseLenient;
  5098. });
  5099. addParseToken(['D', 'DD'], DATE);
  5100. addParseToken('Do', function (input, array) {
  5101. array[DATE] = toInt(input.match(match1to2)[0]);
  5102. });
  5103. // MOMENTS
  5104. var getSetDayOfMonth = makeGetSet('Date', true);
  5105. // FORMATTING
  5106. addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
  5107. // ALIASES
  5108. addUnitAlias('dayOfYear', 'DDD');
  5109. // PRIORITY
  5110. addUnitPriority('dayOfYear', 4);
  5111. // PARSING
  5112. addRegexToken('DDD', match1to3);
  5113. addRegexToken('DDDD', match3);
  5114. addParseToken(['DDD', 'DDDD'], function (input, array, config) {
  5115. config._dayOfYear = toInt(input);
  5116. });
  5117. // HELPERS
  5118. // MOMENTS
  5119. function getSetDayOfYear(input) {
  5120. var dayOfYear =
  5121. Math.round(
  5122. (this.clone().startOf('day') - this.clone().startOf('year')) / 864e5
  5123. ) + 1;
  5124. return input == null ? dayOfYear : this.add(input - dayOfYear, 'd');
  5125. }
  5126. // FORMATTING
  5127. addFormatToken('m', ['mm', 2], 0, 'minute');
  5128. // ALIASES
  5129. addUnitAlias('minute', 'm');
  5130. // PRIORITY
  5131. addUnitPriority('minute', 14);
  5132. // PARSING
  5133. addRegexToken('m', match1to2);
  5134. addRegexToken('mm', match1to2, match2);
  5135. addParseToken(['m', 'mm'], MINUTE);
  5136. // MOMENTS
  5137. var getSetMinute = makeGetSet('Minutes', false);
  5138. // FORMATTING
  5139. addFormatToken('s', ['ss', 2], 0, 'second');
  5140. // ALIASES
  5141. addUnitAlias('second', 's');
  5142. // PRIORITY
  5143. addUnitPriority('second', 15);
  5144. // PARSING
  5145. addRegexToken('s', match1to2);
  5146. addRegexToken('ss', match1to2, match2);
  5147. addParseToken(['s', 'ss'], SECOND);
  5148. // MOMENTS
  5149. var getSetSecond = makeGetSet('Seconds', false);
  5150. // FORMATTING
  5151. addFormatToken('S', 0, 0, function () {
  5152. return ~~(this.millisecond() / 100);
  5153. });
  5154. addFormatToken(0, ['SS', 2], 0, function () {
  5155. return ~~(this.millisecond() / 10);
  5156. });
  5157. addFormatToken(0, ['SSS', 3], 0, 'millisecond');
  5158. addFormatToken(0, ['SSSS', 4], 0, function () {
  5159. return this.millisecond() * 10;
  5160. });
  5161. addFormatToken(0, ['SSSSS', 5], 0, function () {
  5162. return this.millisecond() * 100;
  5163. });
  5164. addFormatToken(0, ['SSSSSS', 6], 0, function () {
  5165. return this.millisecond() * 1000;
  5166. });
  5167. addFormatToken(0, ['SSSSSSS', 7], 0, function () {
  5168. return this.millisecond() * 10000;
  5169. });
  5170. addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
  5171. return this.millisecond() * 100000;
  5172. });
  5173. addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
  5174. return this.millisecond() * 1000000;
  5175. });
  5176. // ALIASES
  5177. addUnitAlias('millisecond', 'ms');
  5178. // PRIORITY
  5179. addUnitPriority('millisecond', 16);
  5180. // PARSING
  5181. addRegexToken('S', match1to3, match1);
  5182. addRegexToken('SS', match1to3, match2);
  5183. addRegexToken('SSS', match1to3, match3);
  5184. var token, getSetMillisecond;
  5185. for (token = 'SSSS'; token.length <= 9; token += 'S') {
  5186. addRegexToken(token, matchUnsigned);
  5187. }
  5188. function parseMs(input, array) {
  5189. array[MILLISECOND] = toInt(('0.' + input) * 1000);
  5190. }
  5191. for (token = 'S'; token.length <= 9; token += 'S') {
  5192. addParseToken(token, parseMs);
  5193. }
  5194. getSetMillisecond = makeGetSet('Milliseconds', false);
  5195. // FORMATTING
  5196. addFormatToken('z', 0, 0, 'zoneAbbr');
  5197. addFormatToken('zz', 0, 0, 'zoneName');
  5198. // MOMENTS
  5199. function getZoneAbbr() {
  5200. return this._isUTC ? 'UTC' : '';
  5201. }
  5202. function getZoneName() {
  5203. return this._isUTC ? 'Coordinated Universal Time' : '';
  5204. }
  5205. var proto = Moment.prototype;
  5206. proto.add = add;
  5207. proto.calendar = calendar$1;
  5208. proto.clone = clone;
  5209. proto.diff = diff;
  5210. proto.endOf = endOf;
  5211. proto.format = format;
  5212. proto.from = from;
  5213. proto.fromNow = fromNow;
  5214. proto.to = to;
  5215. proto.toNow = toNow;
  5216. proto.get = stringGet;
  5217. proto.invalidAt = invalidAt;
  5218. proto.isAfter = isAfter;
  5219. proto.isBefore = isBefore;
  5220. proto.isBetween = isBetween;
  5221. proto.isSame = isSame;
  5222. proto.isSameOrAfter = isSameOrAfter;
  5223. proto.isSameOrBefore = isSameOrBefore;
  5224. proto.isValid = isValid$2;
  5225. proto.lang = lang;
  5226. proto.locale = locale;
  5227. proto.localeData = localeData;
  5228. proto.max = prototypeMax;
  5229. proto.min = prototypeMin;
  5230. proto.parsingFlags = parsingFlags;
  5231. proto.set = stringSet;
  5232. proto.startOf = startOf;
  5233. proto.subtract = subtract;
  5234. proto.toArray = toArray;
  5235. proto.toObject = toObject;
  5236. proto.toDate = toDate;
  5237. proto.toISOString = toISOString;
  5238. proto.inspect = inspect;
  5239. if (typeof Symbol !== 'undefined' && Symbol.for != null) {
  5240. proto[Symbol.for('nodejs.util.inspect.custom')] = function () {
  5241. return 'Moment<' + this.format() + '>';
  5242. };
  5243. }
  5244. proto.toJSON = toJSON;
  5245. proto.toString = toString;
  5246. proto.unix = unix;
  5247. proto.valueOf = valueOf;
  5248. proto.creationData = creationData;
  5249. proto.eraName = getEraName;
  5250. proto.eraNarrow = getEraNarrow;
  5251. proto.eraAbbr = getEraAbbr;
  5252. proto.eraYear = getEraYear;
  5253. proto.year = getSetYear;
  5254. proto.isLeapYear = getIsLeapYear;
  5255. proto.weekYear = getSetWeekYear;
  5256. proto.isoWeekYear = getSetISOWeekYear;
  5257. proto.quarter = proto.quarters = getSetQuarter;
  5258. proto.month = getSetMonth;
  5259. proto.daysInMonth = getDaysInMonth;
  5260. proto.week = proto.weeks = getSetWeek;
  5261. proto.isoWeek = proto.isoWeeks = getSetISOWeek;
  5262. proto.weeksInYear = getWeeksInYear;
  5263. proto.weeksInWeekYear = getWeeksInWeekYear;
  5264. proto.isoWeeksInYear = getISOWeeksInYear;
  5265. proto.isoWeeksInISOWeekYear = getISOWeeksInISOWeekYear;
  5266. proto.date = getSetDayOfMonth;
  5267. proto.day = proto.days = getSetDayOfWeek;
  5268. proto.weekday = getSetLocaleDayOfWeek;
  5269. proto.isoWeekday = getSetISODayOfWeek;
  5270. proto.dayOfYear = getSetDayOfYear;
  5271. proto.hour = proto.hours = getSetHour;
  5272. proto.minute = proto.minutes = getSetMinute;
  5273. proto.second = proto.seconds = getSetSecond;
  5274. proto.millisecond = proto.milliseconds = getSetMillisecond;
  5275. proto.utcOffset = getSetOffset;
  5276. proto.utc = setOffsetToUTC;
  5277. proto.local = setOffsetToLocal;
  5278. proto.parseZone = setOffsetToParsedOffset;
  5279. proto.hasAlignedHourOffset = hasAlignedHourOffset;
  5280. proto.isDST = isDaylightSavingTime;
  5281. proto.isLocal = isLocal;
  5282. proto.isUtcOffset = isUtcOffset;
  5283. proto.isUtc = isUtc;
  5284. proto.isUTC = isUtc;
  5285. proto.zoneAbbr = getZoneAbbr;
  5286. proto.zoneName = getZoneName;
  5287. proto.dates = deprecate(
  5288. 'dates accessor is deprecated. Use date instead.',
  5289. getSetDayOfMonth
  5290. );
  5291. proto.months = deprecate(
  5292. 'months accessor is deprecated. Use month instead',
  5293. getSetMonth
  5294. );
  5295. proto.years = deprecate(
  5296. 'years accessor is deprecated. Use year instead',
  5297. getSetYear
  5298. );
  5299. proto.zone = deprecate(
  5300. 'moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/',
  5301. getSetZone
  5302. );
  5303. proto.isDSTShifted = deprecate(
  5304. 'isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information',
  5305. isDaylightSavingTimeShifted
  5306. );
  5307. function createUnix(input) {
  5308. return createLocal(input * 1000);
  5309. }
  5310. function createInZone() {
  5311. return createLocal.apply(null, arguments).parseZone();
  5312. }
  5313. function preParsePostFormat(string) {
  5314. return string;
  5315. }
  5316. var proto$1 = Locale.prototype;
  5317. proto$1.calendar = calendar;
  5318. proto$1.longDateFormat = longDateFormat;
  5319. proto$1.invalidDate = invalidDate;
  5320. proto$1.ordinal = ordinal;
  5321. proto$1.preparse = preParsePostFormat;
  5322. proto$1.postformat = preParsePostFormat;
  5323. proto$1.relativeTime = relativeTime;
  5324. proto$1.pastFuture = pastFuture;
  5325. proto$1.set = set;
  5326. proto$1.eras = localeEras;
  5327. proto$1.erasParse = localeErasParse;
  5328. proto$1.erasConvertYear = localeErasConvertYear;
  5329. proto$1.erasAbbrRegex = erasAbbrRegex;
  5330. proto$1.erasNameRegex = erasNameRegex;
  5331. proto$1.erasNarrowRegex = erasNarrowRegex;
  5332. proto$1.months = localeMonths;
  5333. proto$1.monthsShort = localeMonthsShort;
  5334. proto$1.monthsParse = localeMonthsParse;
  5335. proto$1.monthsRegex = monthsRegex;
  5336. proto$1.monthsShortRegex = monthsShortRegex;
  5337. proto$1.week = localeWeek;
  5338. proto$1.firstDayOfYear = localeFirstDayOfYear;
  5339. proto$1.firstDayOfWeek = localeFirstDayOfWeek;
  5340. proto$1.weekdays = localeWeekdays;
  5341. proto$1.weekdaysMin = localeWeekdaysMin;
  5342. proto$1.weekdaysShort = localeWeekdaysShort;
  5343. proto$1.weekdaysParse = localeWeekdaysParse;
  5344. proto$1.weekdaysRegex = weekdaysRegex;
  5345. proto$1.weekdaysShortRegex = weekdaysShortRegex;
  5346. proto$1.weekdaysMinRegex = weekdaysMinRegex;
  5347. proto$1.isPM = localeIsPM;
  5348. proto$1.meridiem = localeMeridiem;
  5349. function get$1(format, index, field, setter) {
  5350. var locale = getLocale(),
  5351. utc = createUTC().set(setter, index);
  5352. return locale[field](utc, format);
  5353. }
  5354. function listMonthsImpl(format, index, field) {
  5355. if (isNumber(format)) {
  5356. index = format;
  5357. format = undefined;
  5358. }
  5359. format = format || '';
  5360. if (index != null) {
  5361. return get$1(format, index, field, 'month');
  5362. }
  5363. var i,
  5364. out = [];
  5365. for (i = 0; i < 12; i++) {
  5366. out[i] = get$1(format, i, field, 'month');
  5367. }
  5368. return out;
  5369. }
  5370. // ()
  5371. // (5)
  5372. // (fmt, 5)
  5373. // (fmt)
  5374. // (true)
  5375. // (true, 5)
  5376. // (true, fmt, 5)
  5377. // (true, fmt)
  5378. function listWeekdaysImpl(localeSorted, format, index, field) {
  5379. if (typeof localeSorted === 'boolean') {
  5380. if (isNumber(format)) {
  5381. index = format;
  5382. format = undefined;
  5383. }
  5384. format = format || '';
  5385. } else {
  5386. format = localeSorted;
  5387. index = format;
  5388. localeSorted = false;
  5389. if (isNumber(format)) {
  5390. index = format;
  5391. format = undefined;
  5392. }
  5393. format = format || '';
  5394. }
  5395. var locale = getLocale(),
  5396. shift = localeSorted ? locale._week.dow : 0,
  5397. i,
  5398. out = [];
  5399. if (index != null) {
  5400. return get$1(format, (index + shift) % 7, field, 'day');
  5401. }
  5402. for (i = 0; i < 7; i++) {
  5403. out[i] = get$1(format, (i + shift) % 7, field, 'day');
  5404. }
  5405. return out;
  5406. }
  5407. function listMonths(format, index) {
  5408. return listMonthsImpl(format, index, 'months');
  5409. }
  5410. function listMonthsShort(format, index) {
  5411. return listMonthsImpl(format, index, 'monthsShort');
  5412. }
  5413. function listWeekdays(localeSorted, format, index) {
  5414. return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
  5415. }
  5416. function listWeekdaysShort(localeSorted, format, index) {
  5417. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
  5418. }
  5419. function listWeekdaysMin(localeSorted, format, index) {
  5420. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
  5421. }
  5422. getSetGlobalLocale('en', {
  5423. eras: [
  5424. {
  5425. since: '0001-01-01',
  5426. until: +Infinity,
  5427. offset: 1,
  5428. name: 'Anno Domini',
  5429. narrow: 'AD',
  5430. abbr: 'AD',
  5431. },
  5432. {
  5433. since: '0000-12-31',
  5434. until: -Infinity,
  5435. offset: 1,
  5436. name: 'Before Christ',
  5437. narrow: 'BC',
  5438. abbr: 'BC',
  5439. },
  5440. ],
  5441. dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
  5442. ordinal: function (number) {
  5443. var b = number % 10,
  5444. output =
  5445. toInt((number % 100) / 10) === 1
  5446. ? 'th'
  5447. : b === 1
  5448. ? 'st'
  5449. : b === 2
  5450. ? 'nd'
  5451. : b === 3
  5452. ? 'rd'
  5453. : 'th';
  5454. return number + output;
  5455. },
  5456. });
  5457. // Side effect imports
  5458. hooks.lang = deprecate(
  5459. 'moment.lang is deprecated. Use moment.locale instead.',
  5460. getSetGlobalLocale
  5461. );
  5462. hooks.langData = deprecate(
  5463. 'moment.langData is deprecated. Use moment.localeData instead.',
  5464. getLocale
  5465. );
  5466. var mathAbs = Math.abs;
  5467. function abs() {
  5468. var data = this._data;
  5469. this._milliseconds = mathAbs(this._milliseconds);
  5470. this._days = mathAbs(this._days);
  5471. this._months = mathAbs(this._months);
  5472. data.milliseconds = mathAbs(data.milliseconds);
  5473. data.seconds = mathAbs(data.seconds);
  5474. data.minutes = mathAbs(data.minutes);
  5475. data.hours = mathAbs(data.hours);
  5476. data.months = mathAbs(data.months);
  5477. data.years = mathAbs(data.years);
  5478. return this;
  5479. }
  5480. function addSubtract$1(duration, input, value, direction) {
  5481. var other = createDuration(input, value);
  5482. duration._milliseconds += direction * other._milliseconds;
  5483. duration._days += direction * other._days;
  5484. duration._months += direction * other._months;
  5485. return duration._bubble();
  5486. }
  5487. // supports only 2.0-style add(1, 's') or add(duration)
  5488. function add$1(input, value) {
  5489. return addSubtract$1(this, input, value, 1);
  5490. }
  5491. // supports only 2.0-style subtract(1, 's') or subtract(duration)
  5492. function subtract$1(input, value) {
  5493. return addSubtract$1(this, input, value, -1);
  5494. }
  5495. function absCeil(number) {
  5496. if (number < 0) {
  5497. return Math.floor(number);
  5498. } else {
  5499. return Math.ceil(number);
  5500. }
  5501. }
  5502. function bubble() {
  5503. var milliseconds = this._milliseconds,
  5504. days = this._days,
  5505. months = this._months,
  5506. data = this._data,
  5507. seconds,
  5508. minutes,
  5509. hours,
  5510. years,
  5511. monthsFromDays;
  5512. // if we have a mix of positive and negative values, bubble down first
  5513. // check: https://github.com/moment/moment/issues/2166
  5514. if (
  5515. !(
  5516. (milliseconds >= 0 && days >= 0 && months >= 0) ||
  5517. (milliseconds <= 0 && days <= 0 && months <= 0)
  5518. )
  5519. ) {
  5520. milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
  5521. days = 0;
  5522. months = 0;
  5523. }
  5524. // The following code bubbles up values, see the tests for
  5525. // examples of what that means.
  5526. data.milliseconds = milliseconds % 1000;
  5527. seconds = absFloor(milliseconds / 1000);
  5528. data.seconds = seconds % 60;
  5529. minutes = absFloor(seconds / 60);
  5530. data.minutes = minutes % 60;
  5531. hours = absFloor(minutes / 60);
  5532. data.hours = hours % 24;
  5533. days += absFloor(hours / 24);
  5534. // convert days to months
  5535. monthsFromDays = absFloor(daysToMonths(days));
  5536. months += monthsFromDays;
  5537. days -= absCeil(monthsToDays(monthsFromDays));
  5538. // 12 months -> 1 year
  5539. years = absFloor(months / 12);
  5540. months %= 12;
  5541. data.days = days;
  5542. data.months = months;
  5543. data.years = years;
  5544. return this;
  5545. }
  5546. function daysToMonths(days) {
  5547. // 400 years have 146097 days (taking into account leap year rules)
  5548. // 400 years have 12 months === 4800
  5549. return (days * 4800) / 146097;
  5550. }
  5551. function monthsToDays(months) {
  5552. // the reverse of daysToMonths
  5553. return (months * 146097) / 4800;
  5554. }
  5555. function as(units) {
  5556. if (!this.isValid()) {
  5557. return NaN;
  5558. }
  5559. var days,
  5560. months,
  5561. milliseconds = this._milliseconds;
  5562. units = normalizeUnits(units);
  5563. if (units === 'month' || units === 'quarter' || units === 'year') {
  5564. days = this._days + milliseconds / 864e5;
  5565. months = this._months + daysToMonths(days);
  5566. switch (units) {
  5567. case 'month':
  5568. return months;
  5569. case 'quarter':
  5570. return months / 3;
  5571. case 'year':
  5572. return months / 12;
  5573. }
  5574. } else {
  5575. // handle milliseconds separately because of floating point math errors (issue #1867)
  5576. days = this._days + Math.round(monthsToDays(this._months));
  5577. switch (units) {
  5578. case 'week':
  5579. return days / 7 + milliseconds / 6048e5;
  5580. case 'day':
  5581. return days + milliseconds / 864e5;
  5582. case 'hour':
  5583. return days * 24 + milliseconds / 36e5;
  5584. case 'minute':
  5585. return days * 1440 + milliseconds / 6e4;
  5586. case 'second':
  5587. return days * 86400 + milliseconds / 1000;
  5588. // Math.floor prevents floating point math errors here
  5589. case 'millisecond':
  5590. return Math.floor(days * 864e5) + milliseconds;
  5591. default:
  5592. throw new Error('Unknown unit ' + units);
  5593. }
  5594. }
  5595. }
  5596. // TODO: Use this.as('ms')?
  5597. function valueOf$1() {
  5598. if (!this.isValid()) {
  5599. return NaN;
  5600. }
  5601. return (
  5602. this._milliseconds +
  5603. this._days * 864e5 +
  5604. (this._months % 12) * 2592e6 +
  5605. toInt(this._months / 12) * 31536e6
  5606. );
  5607. }
  5608. function makeAs(alias) {
  5609. return function () {
  5610. return this.as(alias);
  5611. };
  5612. }
  5613. var asMilliseconds = makeAs('ms'),
  5614. asSeconds = makeAs('s'),
  5615. asMinutes = makeAs('m'),
  5616. asHours = makeAs('h'),
  5617. asDays = makeAs('d'),
  5618. asWeeks = makeAs('w'),
  5619. asMonths = makeAs('M'),
  5620. asQuarters = makeAs('Q'),
  5621. asYears = makeAs('y');
  5622. function clone$1() {
  5623. return createDuration(this);
  5624. }
  5625. function get$2(units) {
  5626. units = normalizeUnits(units);
  5627. return this.isValid() ? this[units + 's']() : NaN;
  5628. }
  5629. function makeGetter(name) {
  5630. return function () {
  5631. return this.isValid() ? this._data[name] : NaN;
  5632. };
  5633. }
  5634. var milliseconds = makeGetter('milliseconds'),
  5635. seconds = makeGetter('seconds'),
  5636. minutes = makeGetter('minutes'),
  5637. hours = makeGetter('hours'),
  5638. days = makeGetter('days'),
  5639. months = makeGetter('months'),
  5640. years = makeGetter('years');
  5641. function weeks() {
  5642. return absFloor(this.days() / 7);
  5643. }
  5644. var round = Math.round,
  5645. thresholds = {
  5646. ss: 44, // a few seconds to seconds
  5647. s: 45, // seconds to minute
  5648. m: 45, // minutes to hour
  5649. h: 22, // hours to day
  5650. d: 26, // days to month/week
  5651. w: null, // weeks to month
  5652. M: 11, // months to year
  5653. };
  5654. // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
  5655. function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
  5656. return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
  5657. }
  5658. function relativeTime$1(posNegDuration, withoutSuffix, thresholds, locale) {
  5659. var duration = createDuration(posNegDuration).abs(),
  5660. seconds = round(duration.as('s')),
  5661. minutes = round(duration.as('m')),
  5662. hours = round(duration.as('h')),
  5663. days = round(duration.as('d')),
  5664. months = round(duration.as('M')),
  5665. weeks = round(duration.as('w')),
  5666. years = round(duration.as('y')),
  5667. a =
  5668. (seconds <= thresholds.ss && ['s', seconds]) ||
  5669. (seconds < thresholds.s && ['ss', seconds]) ||
  5670. (minutes <= 1 && ['m']) ||
  5671. (minutes < thresholds.m && ['mm', minutes]) ||
  5672. (hours <= 1 && ['h']) ||
  5673. (hours < thresholds.h && ['hh', hours]) ||
  5674. (days <= 1 && ['d']) ||
  5675. (days < thresholds.d && ['dd', days]);
  5676. if (thresholds.w != null) {
  5677. a =
  5678. a ||
  5679. (weeks <= 1 && ['w']) ||
  5680. (weeks < thresholds.w && ['ww', weeks]);
  5681. }
  5682. a = a ||
  5683. (months <= 1 && ['M']) ||
  5684. (months < thresholds.M && ['MM', months]) ||
  5685. (years <= 1 && ['y']) || ['yy', years];
  5686. a[2] = withoutSuffix;
  5687. a[3] = +posNegDuration > 0;
  5688. a[4] = locale;
  5689. return substituteTimeAgo.apply(null, a);
  5690. }
  5691. // This function allows you to set the rounding function for relative time strings
  5692. function getSetRelativeTimeRounding(roundingFunction) {
  5693. if (roundingFunction === undefined) {
  5694. return round;
  5695. }
  5696. if (typeof roundingFunction === 'function') {
  5697. round = roundingFunction;
  5698. return true;
  5699. }
  5700. return false;
  5701. }
  5702. // This function allows you to set a threshold for relative time strings
  5703. function getSetRelativeTimeThreshold(threshold, limit) {
  5704. if (thresholds[threshold] === undefined) {
  5705. return false;
  5706. }
  5707. if (limit === undefined) {
  5708. return thresholds[threshold];
  5709. }
  5710. thresholds[threshold] = limit;
  5711. if (threshold === 's') {
  5712. thresholds.ss = limit - 1;
  5713. }
  5714. return true;
  5715. }
  5716. function humanize(argWithSuffix, argThresholds) {
  5717. if (!this.isValid()) {
  5718. return this.localeData().invalidDate();
  5719. }
  5720. var withSuffix = false,
  5721. th = thresholds,
  5722. locale,
  5723. output;
  5724. if (typeof argWithSuffix === 'object') {
  5725. argThresholds = argWithSuffix;
  5726. argWithSuffix = false;
  5727. }
  5728. if (typeof argWithSuffix === 'boolean') {
  5729. withSuffix = argWithSuffix;
  5730. }
  5731. if (typeof argThresholds === 'object') {
  5732. th = Object.assign({}, thresholds, argThresholds);
  5733. if (argThresholds.s != null && argThresholds.ss == null) {
  5734. th.ss = argThresholds.s - 1;
  5735. }
  5736. }
  5737. locale = this.localeData();
  5738. output = relativeTime$1(this, !withSuffix, th, locale);
  5739. if (withSuffix) {
  5740. output = locale.pastFuture(+this, output);
  5741. }
  5742. return locale.postformat(output);
  5743. }
  5744. var abs$1 = Math.abs;
  5745. function sign(x) {
  5746. return (x > 0) - (x < 0) || +x;
  5747. }
  5748. function toISOString$1() {
  5749. // for ISO strings we do not use the normal bubbling rules:
  5750. // * milliseconds bubble up until they become hours
  5751. // * days do not bubble at all
  5752. // * months bubble up until they become years
  5753. // This is because there is no context-free conversion between hours and days
  5754. // (think of clock changes)
  5755. // and also not between days and months (28-31 days per month)
  5756. if (!this.isValid()) {
  5757. return this.localeData().invalidDate();
  5758. }
  5759. var seconds = abs$1(this._milliseconds) / 1000,
  5760. days = abs$1(this._days),
  5761. months = abs$1(this._months),
  5762. minutes,
  5763. hours,
  5764. years,
  5765. s,
  5766. total = this.asSeconds(),
  5767. totalSign,
  5768. ymSign,
  5769. daysSign,
  5770. hmsSign;
  5771. if (!total) {
  5772. // this is the same as C#'s (Noda) and python (isodate)...
  5773. // but not other JS (goog.date)
  5774. return 'P0D';
  5775. }
  5776. // 3600 seconds -> 60 minutes -> 1 hour
  5777. minutes = absFloor(seconds / 60);
  5778. hours = absFloor(minutes / 60);
  5779. seconds %= 60;
  5780. minutes %= 60;
  5781. // 12 months -> 1 year
  5782. years = absFloor(months / 12);
  5783. months %= 12;
  5784. // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
  5785. s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : '';
  5786. totalSign = total < 0 ? '-' : '';
  5787. ymSign = sign(this._months) !== sign(total) ? '-' : '';
  5788. daysSign = sign(this._days) !== sign(total) ? '-' : '';
  5789. hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : '';
  5790. return (
  5791. totalSign +
  5792. 'P' +
  5793. (years ? ymSign + years + 'Y' : '') +
  5794. (months ? ymSign + months + 'M' : '') +
  5795. (days ? daysSign + days + 'D' : '') +
  5796. (hours || minutes || seconds ? 'T' : '') +
  5797. (hours ? hmsSign + hours + 'H' : '') +
  5798. (minutes ? hmsSign + minutes + 'M' : '') +
  5799. (seconds ? hmsSign + s + 'S' : '')
  5800. );
  5801. }
  5802. var proto$2 = Duration.prototype;
  5803. proto$2.isValid = isValid$1;
  5804. proto$2.abs = abs;
  5805. proto$2.add = add$1;
  5806. proto$2.subtract = subtract$1;
  5807. proto$2.as = as;
  5808. proto$2.asMilliseconds = asMilliseconds;
  5809. proto$2.asSeconds = asSeconds;
  5810. proto$2.asMinutes = asMinutes;
  5811. proto$2.asHours = asHours;
  5812. proto$2.asDays = asDays;
  5813. proto$2.asWeeks = asWeeks;
  5814. proto$2.asMonths = asMonths;
  5815. proto$2.asQuarters = asQuarters;
  5816. proto$2.asYears = asYears;
  5817. proto$2.valueOf = valueOf$1;
  5818. proto$2._bubble = bubble;
  5819. proto$2.clone = clone$1;
  5820. proto$2.get = get$2;
  5821. proto$2.milliseconds = milliseconds;
  5822. proto$2.seconds = seconds;
  5823. proto$2.minutes = minutes;
  5824. proto$2.hours = hours;
  5825. proto$2.days = days;
  5826. proto$2.weeks = weeks;
  5827. proto$2.months = months;
  5828. proto$2.years = years;
  5829. proto$2.humanize = humanize;
  5830. proto$2.toISOString = toISOString$1;
  5831. proto$2.toString = toISOString$1;
  5832. proto$2.toJSON = toISOString$1;
  5833. proto$2.locale = locale;
  5834. proto$2.localeData = localeData;
  5835. proto$2.toIsoString = deprecate(
  5836. 'toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)',
  5837. toISOString$1
  5838. );
  5839. proto$2.lang = lang;
  5840. // FORMATTING
  5841. addFormatToken('X', 0, 0, 'unix');
  5842. addFormatToken('x', 0, 0, 'valueOf');
  5843. // PARSING
  5844. addRegexToken('x', matchSigned);
  5845. addRegexToken('X', matchTimestamp);
  5846. addParseToken('X', function (input, array, config) {
  5847. config._d = new Date(parseFloat(input) * 1000);
  5848. });
  5849. addParseToken('x', function (input, array, config) {
  5850. config._d = new Date(toInt(input));
  5851. });
  5852. //! moment.js
  5853. hooks.version = '2.29.4';
  5854. setHookCallback(createLocal);
  5855. hooks.fn = proto;
  5856. hooks.min = min;
  5857. hooks.max = max;
  5858. hooks.now = now;
  5859. hooks.utc = createUTC;
  5860. hooks.unix = createUnix;
  5861. hooks.months = listMonths;
  5862. hooks.isDate = isDate;
  5863. hooks.locale = getSetGlobalLocale;
  5864. hooks.invalid = createInvalid;
  5865. hooks.duration = createDuration;
  5866. hooks.isMoment = isMoment;
  5867. hooks.weekdays = listWeekdays;
  5868. hooks.parseZone = createInZone;
  5869. hooks.localeData = getLocale;
  5870. hooks.isDuration = isDuration;
  5871. hooks.monthsShort = listMonthsShort;
  5872. hooks.weekdaysMin = listWeekdaysMin;
  5873. hooks.defineLocale = defineLocale;
  5874. hooks.updateLocale = updateLocale;
  5875. hooks.locales = listLocales;
  5876. hooks.weekdaysShort = listWeekdaysShort;
  5877. hooks.normalizeUnits = normalizeUnits;
  5878. hooks.relativeTimeRounding = getSetRelativeTimeRounding;
  5879. hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
  5880. hooks.calendarFormat = getCalendarFormat;
  5881. hooks.prototype = proto;
  5882. // currently HTML5 input type only supports 24-hour formats
  5883. hooks.HTML5_FMT = {
  5884. DATETIME_LOCAL: 'YYYY-MM-DDTHH:mm', // <input type="datetime-local" />
  5885. DATETIME_LOCAL_SECONDS: 'YYYY-MM-DDTHH:mm:ss', // <input type="datetime-local" step="1" />
  5886. DATETIME_LOCAL_MS: 'YYYY-MM-DDTHH:mm:ss.SSS', // <input type="datetime-local" step="0.001" />
  5887. DATE: 'YYYY-MM-DD', // <input type="date" />
  5888. TIME: 'HH:mm', // <input type="time" />
  5889. TIME_SECONDS: 'HH:mm:ss', // <input type="time" step="1" />
  5890. TIME_MS: 'HH:mm:ss.SSS', // <input type="time" step="0.001" />
  5891. WEEK: 'GGGG-[W]WW', // <input type="week" />
  5892. MONTH: 'YYYY-MM', // <input type="month" />
  5893. };
  5894. return hooks;
  5895. })));
  5896. define('moment', ['moment/moment'], function (main) { return main; });
  5897. define('backend',['fast', 'template', 'moment'], function (Fast, Template, Moment) {
  5898. var Backend = {
  5899. api: {
  5900. sidebar: function (params) {
  5901. colorArr = ['red', 'green', 'yellow', 'blue', 'teal', 'orange', 'purple'];
  5902. $colorNums = colorArr.length;
  5903. badgeList = {};
  5904. $.each(params, function (k, v) {
  5905. $url = Fast.api.fixurl(k);
  5906. if ($.isArray(v)) {
  5907. $nums = typeof v[0] !== 'undefined' ? v[0] : 0;
  5908. $color = typeof v[1] !== 'undefined' ? v[1] : colorArr[(!isNaN($nums) ? $nums : $nums.length) % $colorNums];
  5909. $class = typeof v[2] !== 'undefined' ? v[2] : 'label';
  5910. } else {
  5911. $nums = v;
  5912. $color = colorArr[(!isNaN($nums) ? $nums : $nums.length) % $colorNums];
  5913. $class = 'label';
  5914. }
  5915. //必须nums大于0才显示
  5916. badgeList[$url] = $nums > 0 ? '<small class="' + $class + ' pull-right bg-' + $color + '">' + $nums + '</small>' : '';
  5917. });
  5918. $.each(badgeList, function (k, v) {
  5919. var anchor = top.window.$("li a[addtabs][url='" + k + "']");
  5920. if (anchor) {
  5921. top.window.$(".pull-right-container", anchor).html(v);
  5922. top.window.$(".nav-addtabs li a[node-id='" + anchor.attr("addtabs") + "'] .pull-right-container").html(v);
  5923. }
  5924. });
  5925. },
  5926. addtabs: function (url, title, icon) {
  5927. var dom = "a[url='{url}']"
  5928. var leftlink = top.window.$(dom.replace(/\{url\}/, url));
  5929. if (leftlink.length > 0) {
  5930. leftlink.trigger("click");
  5931. } else {
  5932. url = Fast.api.fixurl(url);
  5933. leftlink = top.window.$(dom.replace(/\{url\}/, url));
  5934. if (leftlink.length > 0) {
  5935. var event = leftlink.parent().hasClass("active") ? "dblclick" : "click";
  5936. leftlink.trigger(event);
  5937. } else {
  5938. var baseurl = url.substr(0, url.indexOf("?") > -1 ? url.indexOf("?") : url.length);
  5939. leftlink = top.window.$(dom.replace(/\{url\}/, baseurl));
  5940. //能找到相对地址
  5941. if (leftlink.length > 0) {
  5942. icon = typeof icon !== 'undefined' ? icon : leftlink.find("i").attr("class");
  5943. title = typeof title !== 'undefined' ? title : leftlink.find("span:first").text();
  5944. leftlink.trigger("fa.event.toggleitem");
  5945. }
  5946. var navnode = top.window.$(".nav-tabs ul li a[node-url='" + url + "']");
  5947. if (navnode.length > 0) {
  5948. navnode.trigger("click");
  5949. } else {
  5950. //追加新的tab
  5951. var id = Math.floor(new Date().valueOf() * Math.random());
  5952. icon = typeof icon !== 'undefined' ? icon : 'fa fa-circle-o';
  5953. title = typeof title !== 'undefined' ? title : '';
  5954. top.window.$("<a />").append('<i class="' + icon + '"></i> <span>' + title + '</span>').prop("href", url).attr({
  5955. url: url,
  5956. addtabs: id
  5957. }).addClass("hide").appendTo(top.window.document.body).trigger("click");
  5958. }
  5959. }
  5960. }
  5961. },
  5962. closetabs: function (url) {
  5963. if (typeof url === 'undefined') {
  5964. top.window.$("ul.nav-addtabs li.active .close-tab").trigger("click");
  5965. } else {
  5966. var dom = "a[url='{url}']"
  5967. var navlink = top.window.$(dom.replace(/\{url\}/, url));
  5968. if (navlink.length === 0) {
  5969. url = Fast.api.fixurl(url);
  5970. navlink = top.window.$(dom.replace(/\{url\}/, url));
  5971. if (navlink.length === 0) {
  5972. } else {
  5973. var baseurl = url.substr(0, url.indexOf("?") > -1 ? url.indexOf("?") : url.length);
  5974. navlink = top.window.$(dom.replace(/\{url\}/, baseurl));
  5975. //能找到相对地址
  5976. if (navlink.length === 0) {
  5977. navlink = top.window.$(".nav-tabs ul li a[node-url='" + url + "']");
  5978. }
  5979. }
  5980. }
  5981. if (navlink.length > 0 && navlink.attr('addtabs')) {
  5982. top.window.$("ul.nav-addtabs li#tab_" + navlink.attr('addtabs') + " .close-tab").trigger("click");
  5983. }
  5984. }
  5985. },
  5986. replaceids: function (elem, url) {
  5987. //如果有需要替换ids的
  5988. if (url.indexOf("{ids}") > -1) {
  5989. var ids = 0;
  5990. var tableId = $(elem).data("table-id");
  5991. if (tableId && $("#" + tableId).length > 0 && $("#" + tableId).data("bootstrap.table")) {
  5992. var Table = require("table");
  5993. ids = Table.api.selectedids($("#" + tableId)).join(",");
  5994. }
  5995. url = url.replace(/\{ids\}/g, ids);
  5996. }
  5997. return url;
  5998. },
  5999. refreshmenu: function () {
  6000. top.window.$(".sidebar-menu").trigger("refresh");
  6001. },
  6002. gettablecolumnbutton: function (options) {
  6003. if (typeof options.tableId !== 'undefined' && typeof options.fieldIndex !== 'undefined' && typeof options.buttonIndex !== 'undefined') {
  6004. var tableOptions = $("#" + options.tableId).bootstrapTable('getOptions');
  6005. if (tableOptions) {
  6006. var columnObj = null;
  6007. $.each(tableOptions.columns, function (i, columns) {
  6008. $.each(columns, function (j, column) {
  6009. if (typeof column.fieldIndex !== 'undefined' && column.fieldIndex === options.fieldIndex) {
  6010. columnObj = column;
  6011. return false;
  6012. }
  6013. });
  6014. if (columnObj) {
  6015. return false;
  6016. }
  6017. });
  6018. if (columnObj) {
  6019. return columnObj['buttons'][options.buttonIndex];
  6020. }
  6021. }
  6022. }
  6023. return null;
  6024. },
  6025. },
  6026. init: function () {
  6027. //公共代码
  6028. //添加ios-fix兼容iOS下的iframe
  6029. if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
  6030. $("html").addClass("ios-fix");
  6031. }
  6032. //配置Toastr的参数
  6033. Toastr.options.positionClass = Config.controllername === 'index' ? "toast-top-right-index" : "toast-top-right";
  6034. //点击包含.btn-dialog的元素时弹出dialog
  6035. $(document).on('click', '.btn-dialog,.dialogit', function (e) {
  6036. var that = this;
  6037. var options = $.extend({}, $(that).data() || {});
  6038. var url = Backend.api.replaceids(that, $(that).data("url") || $(that).attr('href'));
  6039. var title = $(that).attr("title") || $(that).data("title") || $(that).data('original-title');
  6040. var button = Backend.api.gettablecolumnbutton(options);
  6041. if (button && typeof button.callback === 'function') {
  6042. options.callback = button.callback;
  6043. }
  6044. if (typeof options.confirm !== 'undefined') {
  6045. Layer.confirm(options.confirm, function (index) {
  6046. Backend.api.open(url, title, options);
  6047. Layer.close(index);
  6048. });
  6049. } else {
  6050. window[$(that).data("window") || 'self'].Backend.api.open(url, title, options);
  6051. }
  6052. return false;
  6053. });
  6054. //点击包含.btn-addtabs的元素时新增选项卡
  6055. $(document).on('click', '.btn-addtabs,.addtabsit', function (e) {
  6056. var that = this;
  6057. var options = $.extend({}, $(that).data() || {});
  6058. var url = Backend.api.replaceids(that, $(that).data("url") || $(that).attr('href'));
  6059. var title = $(that).attr("title") || $(that).data("title") || $(that).data('original-title');
  6060. var icon = $(that).attr("icon") || $(that).data("icon");
  6061. if (typeof options.confirm !== 'undefined') {
  6062. Layer.confirm(options.confirm, function (index) {
  6063. Backend.api.addtabs(url, title, icon);
  6064. Layer.close(index);
  6065. });
  6066. } else {
  6067. Backend.api.addtabs(url, title, icon);
  6068. }
  6069. return false;
  6070. });
  6071. //点击包含.btn-ajax的元素时发送Ajax请求
  6072. $(document).on('click', '.btn-ajax,.ajaxit', function (e) {
  6073. var that = this;
  6074. var options = $.extend({}, $(that).data() || {});
  6075. if (typeof options.url === 'undefined' && $(that).attr("href")) {
  6076. options.url = $(that).attr("href");
  6077. }
  6078. options.url = Backend.api.replaceids(this, options.url);
  6079. var success = typeof options.success === 'function' ? options.success : null;
  6080. var error = typeof options.error === 'function' ? options.error : null;
  6081. delete options.success;
  6082. delete options.error;
  6083. var button = Backend.api.gettablecolumnbutton(options);
  6084. if (button) {
  6085. if (typeof button.success === 'function') {
  6086. success = button.success;
  6087. }
  6088. if (typeof button.error === 'function') {
  6089. error = button.error;
  6090. }
  6091. }
  6092. //如果未设备成功的回调,设定了自动刷新的情况下自动进行刷新
  6093. if (!success && typeof options.tableId !== 'undefined' && typeof options.refresh !== 'undefined' && options.refresh) {
  6094. success = function () {
  6095. $("#" + options.tableId).bootstrapTable('refresh');
  6096. }
  6097. }
  6098. if (typeof options.confirm !== 'undefined') {
  6099. Layer.confirm(options.confirm, function (index) {
  6100. Backend.api.ajax(options, success, error);
  6101. Layer.close(index);
  6102. });
  6103. } else {
  6104. Backend.api.ajax(options, success, error);
  6105. }
  6106. return false;
  6107. });
  6108. $(document).on('click', '.btn-click,.clickit', function (e) {
  6109. var that = this;
  6110. var options = $.extend({}, $(that).data() || {});
  6111. var row = {};
  6112. if (typeof options.tableId !== 'undefined') {
  6113. var index = parseInt(options.rowIndex);
  6114. var data = $("#" + options.tableId).bootstrapTable('getData');
  6115. row = typeof data[index] !== 'undefined' ? data[index] : {};
  6116. }
  6117. var button = Backend.api.gettablecolumnbutton(options);
  6118. var click = typeof button.click === 'function' ? button.click : $.noop;
  6119. if (typeof options.confirm !== 'undefined') {
  6120. Layer.confirm(options.confirm, function (index) {
  6121. click.apply(that, [options, row, button]);
  6122. Layer.close(index);
  6123. });
  6124. } else {
  6125. click.apply(that, [options, row, button]);
  6126. }
  6127. return false;
  6128. });
  6129. //修复含有fixed-footer类的body边距
  6130. if ($(".fixed-footer").length > 0) {
  6131. $(document.body).css("padding-bottom", $(".fixed-footer").outerHeight());
  6132. }
  6133. //修复不在iframe时layer-footer隐藏的问题
  6134. if ($(".layer-footer").length > 0 && self === top) {
  6135. $(".layer-footer").show();
  6136. }
  6137. //tooltip和popover
  6138. if (!('ontouchstart' in document.documentElement)) {
  6139. $('body').tooltip({selector: '[data-toggle="tooltip"]'});
  6140. }
  6141. $('body').popover({selector: '[data-toggle="popover"]'});
  6142. }
  6143. };
  6144. Backend.api = $.extend(Fast.api, Backend.api);
  6145. //将Template渲染至全局,以便于在子框架中调用
  6146. window.Template = Template;
  6147. //将Moment渲染至全局,以便于在子框架中调用
  6148. window.Moment = Moment;
  6149. //将Backend渲染至全局,以便于在子框架中调用
  6150. window.Backend = Backend;
  6151. Backend.init();
  6152. return Backend;
  6153. });
  6154. define('backend-init',['backend'], function (Backend) {
  6155. });
  6156. //! moment.js locale configuration
  6157. //! locale : Chinese (China) [zh-cn]
  6158. //! author : suupic : https://github.com/suupic
  6159. //! author : Zeno Zeng : https://github.com/zenozeng
  6160. //! author : uu109 : https://github.com/uu109
  6161. ;(function (global, factory) {
  6162. typeof exports === 'object' && typeof module !== 'undefined'
  6163. && typeof require === 'function' ? factory(require('../moment')) :
  6164. typeof define === 'function' && define.amd ? define('moment/locale/zh-cn',['../moment'], factory) :
  6165. factory(global.moment)
  6166. }(this, (function (moment) { 'use strict';
  6167. //! moment.js locale configuration
  6168. var zhCn = moment.defineLocale('zh-cn', {
  6169. months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split(
  6170. '_'
  6171. ),
  6172. monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split(
  6173. '_'
  6174. ),
  6175. weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
  6176. weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'),
  6177. weekdaysMin: '日_一_二_三_四_五_六'.split('_'),
  6178. longDateFormat: {
  6179. LT: 'HH:mm',
  6180. LTS: 'HH:mm:ss',
  6181. L: 'YYYY/MM/DD',
  6182. LL: 'YYYY年M月D日',
  6183. LLL: 'YYYY年M月D日Ah点mm分',
  6184. LLLL: 'YYYY年M月D日ddddAh点mm分',
  6185. l: 'YYYY/M/D',
  6186. ll: 'YYYY年M月D日',
  6187. lll: 'YYYY年M月D日 HH:mm',
  6188. llll: 'YYYY年M月D日dddd HH:mm',
  6189. },
  6190. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  6191. meridiemHour: function (hour, meridiem) {
  6192. if (hour === 12) {
  6193. hour = 0;
  6194. }
  6195. if (meridiem === '凌晨' || meridiem === '早上' || meridiem === '上午') {
  6196. return hour;
  6197. } else if (meridiem === '下午' || meridiem === '晚上') {
  6198. return hour + 12;
  6199. } else {
  6200. // '中午'
  6201. return hour >= 11 ? hour : hour + 12;
  6202. }
  6203. },
  6204. meridiem: function (hour, minute, isLower) {
  6205. var hm = hour * 100 + minute;
  6206. if (hm < 600) {
  6207. return '凌晨';
  6208. } else if (hm < 900) {
  6209. return '早上';
  6210. } else if (hm < 1130) {
  6211. return '上午';
  6212. } else if (hm < 1230) {
  6213. return '中午';
  6214. } else if (hm < 1800) {
  6215. return '下午';
  6216. } else {
  6217. return '晚上';
  6218. }
  6219. },
  6220. calendar: {
  6221. sameDay: '[今天]LT',
  6222. nextDay: '[明天]LT',
  6223. nextWeek: function (now) {
  6224. if (now.week() !== this.week()) {
  6225. return '[下]dddLT';
  6226. } else {
  6227. return '[本]dddLT';
  6228. }
  6229. },
  6230. lastDay: '[昨天]LT',
  6231. lastWeek: function (now) {
  6232. if (this.week() !== now.week()) {
  6233. return '[上]dddLT';
  6234. } else {
  6235. return '[本]dddLT';
  6236. }
  6237. },
  6238. sameElse: 'L',
  6239. },
  6240. dayOfMonthOrdinalParse: /\d{1,2}(日|月|周)/,
  6241. ordinal: function (number, period) {
  6242. switch (period) {
  6243. case 'd':
  6244. case 'D':
  6245. case 'DDD':
  6246. return number + '日';
  6247. case 'M':
  6248. return number + '月';
  6249. case 'w':
  6250. case 'W':
  6251. return number + '周';
  6252. default:
  6253. return number;
  6254. }
  6255. },
  6256. relativeTime: {
  6257. future: '%s后',
  6258. past: '%s前',
  6259. s: '几秒',
  6260. ss: '%d 秒',
  6261. m: '1 分钟',
  6262. mm: '%d 分钟',
  6263. h: '1 小时',
  6264. hh: '%d 小时',
  6265. d: '1 天',
  6266. dd: '%d 天',
  6267. w: '1 周',
  6268. ww: '%d 周',
  6269. M: '1 个月',
  6270. MM: '%d 个月',
  6271. y: '1 年',
  6272. yy: '%d 年',
  6273. },
  6274. week: {
  6275. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  6276. dow: 1, // Monday is the first day of the week.
  6277. doy: 4, // The week that contains Jan 4th is the first week of the year.
  6278. },
  6279. });
  6280. return zhCn;
  6281. })));
  6282. /*
  6283. * bootstrap-table - v1.11.9 - 2022-10-27
  6284. https://github.com/wenzhixin/bootstrap-table
  6285. * Copyright (c) 2017 zhixin wen
  6286. * Licensed MIT License
  6287. */
  6288. !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);
  6289. define("bootstrap-table", ["bootstrap"], (function (global) {
  6290. return function () {
  6291. var ret, fn;
  6292. return ret || global.$.fn.bootstrapTable;
  6293. };
  6294. }(this)));
  6295. /**
  6296. * Bootstrap Table Chinese translation
  6297. * Author: Zhixin Wen<wenzhixin2010@gmail.com>
  6298. */
  6299. (function ($) {
  6300. 'use strict';
  6301. $.fn.bootstrapTable.locales['zh-CN'] = {
  6302. formatLoadingMessage: function () {
  6303. return '正在努力地加载数据中,请稍候……';
  6304. },
  6305. formatRecordsPerPage: function (pageNumber) {
  6306. return '每页显示 ' + pageNumber + ' 条记录';
  6307. },
  6308. formatShowingRows: function (pageFrom, pageTo, totalRows) {
  6309. return '显示第 ' + pageFrom + ' 到第 ' + pageTo + ' 条记录,总共 ' + totalRows + ' 条记录';
  6310. },
  6311. formatSearch: function () {
  6312. return '搜索';
  6313. },
  6314. formatNoMatches: function () {
  6315. return '没有找到匹配的记录';
  6316. },
  6317. formatPaginationSwitch: function () {
  6318. return '隐藏/显示分页';
  6319. },
  6320. formatRefresh: function () {
  6321. return '刷新';
  6322. },
  6323. formatToggle: function () {
  6324. return '切换';
  6325. },
  6326. formatColumns: function () {
  6327. return '列';
  6328. },
  6329. formatExport: function () {
  6330. return '导出数据';
  6331. },
  6332. formatClearFilters: function () {
  6333. return '清空过滤';
  6334. }
  6335. };
  6336. $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['zh-CN']);
  6337. })(jQuery);
  6338. define("bootstrap-table-lang", ["bootstrap-table"], (function (global) {
  6339. return function () {
  6340. var ret, fn;
  6341. return ret || global.$.fn.bootstrapTable.defaults;
  6342. };
  6343. }(this)));
  6344. /**
  6345. * @author zhixin wen <wenzhixin2010@gmail.com>
  6346. * extensions: https://github.com/kayalshri/tableExport.jquery.plugin
  6347. */
  6348. (function ($) {
  6349. 'use strict';
  6350. var sprintf = $.fn.bootstrapTable.utils.sprintf;
  6351. var TYPE_NAME = {
  6352. json: 'JSON',
  6353. xml: 'XML',
  6354. png: 'PNG',
  6355. csv: 'CSV',
  6356. txt: 'TXT',
  6357. sql: 'SQL',
  6358. doc: 'MS-Word',
  6359. excel: 'MS-Excel',
  6360. xlsx: 'MS-Excel (OpenXML)',
  6361. powerpoint: 'MS-Powerpoint',
  6362. pdf: 'PDF'
  6363. };
  6364. $.extend($.fn.bootstrapTable.defaults, {
  6365. showExport: false,
  6366. exportDataType: 'basic', // basic, all, selected
  6367. // 'json', 'xml', 'png', 'csv', 'txt', 'sql', 'doc', 'excel', 'powerpoint', 'pdf'
  6368. exportTypes: ['json', 'xml', 'csv', 'txt', 'sql', 'excel'],
  6369. exportOptions: {}
  6370. });
  6371. $.extend($.fn.bootstrapTable.defaults.icons, {
  6372. export: 'glyphicon-export icon-share'
  6373. });
  6374. $.extend($.fn.bootstrapTable.locales, {
  6375. formatExport: function () {
  6376. return 'Export data';
  6377. }
  6378. });
  6379. $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);
  6380. var BootstrapTable = $.fn.bootstrapTable.Constructor,
  6381. _initToolbar = BootstrapTable.prototype.initToolbar;
  6382. BootstrapTable.prototype.initToolbar = function () {
  6383. this.showToolbar = this.options.showExport;
  6384. _initToolbar.apply(this, Array.prototype.slice.apply(arguments));
  6385. if (this.options.showExport) {
  6386. var that = this,
  6387. $btnGroup = this.$toolbar.find('>.btn-group'),
  6388. $export = $btnGroup.find('div.export');
  6389. if (!$export.length) {
  6390. $export = $([
  6391. '<div class="export btn-group">',
  6392. '<button class="btn' +
  6393. sprintf(' btn-%s', this.options.buttonsClass) +
  6394. sprintf(' btn-%s', this.options.iconSize) +
  6395. ' dropdown-toggle" aria-label="export type" ' +
  6396. 'title="' + this.options.formatExport() + '" ' +
  6397. 'data-toggle="dropdown" type="button">',
  6398. sprintf('<i class="%s %s"></i> ', this.options.iconsPrefix, this.options.icons.export),
  6399. '<span class="caret"></span>',
  6400. '</button>',
  6401. '<ul class="dropdown-menu" role="menu">',
  6402. '</ul>',
  6403. '</div>'].join('')).appendTo($btnGroup);
  6404. var $menu = $export.find('.dropdown-menu'),
  6405. exportTypes = this.options.exportTypes;
  6406. if (typeof this.options.exportTypes === 'string') {
  6407. var types = this.options.exportTypes.slice(1, -1).replace(/ /g, '').split(',');
  6408. exportTypes = [];
  6409. $.each(types, function (i, value) {
  6410. exportTypes.push(value.slice(1, -1));
  6411. });
  6412. }
  6413. $.each(exportTypes, function (i, type) {
  6414. if (TYPE_NAME.hasOwnProperty(type)) {
  6415. $menu.append(['<li role="menuitem" data-type="' + type + '">',
  6416. '<a href="javascript:void(0)">',
  6417. TYPE_NAME[type],
  6418. '</a>',
  6419. '</li>'].join(''));
  6420. }
  6421. });
  6422. $menu.find('li').click(function () {
  6423. var type = $(this).data('type'),
  6424. doExport = function () {
  6425. if (typeof require === 'function') {
  6426. require(['tableexport'], function () {
  6427. that.$el.tableExport($.extend({}, that.options.exportOptions, {
  6428. type: type,
  6429. escape: false
  6430. }));
  6431. });
  6432. } else {
  6433. throw new Error("RequireJS not found");
  6434. }
  6435. };
  6436. if (that.options.exportDataType === 'all' && that.options.pagination) {
  6437. that.$el.one(that.options.sidePagination === 'server' ? 'post-body.bs.table' : 'page-change.bs.table', function () {
  6438. doExport();
  6439. that.togglePagination();
  6440. });
  6441. that.togglePagination();
  6442. } else if (that.options.exportDataType === 'selected') {
  6443. var data = that.getData(),
  6444. selectedData = that.getAllSelections();
  6445. // Quick fix #2220
  6446. if (that.options.sidePagination === 'server') {
  6447. data = {total: that.options.totalRows};
  6448. data[that.options.dataField] = that.getData();
  6449. var Table = typeof require === 'function' ? require('table') : null;
  6450. selectedData = {total: that.options.totalRows};
  6451. selectedData[that.options.dataField] = Table && that.options.maintainSelected ? Table.api.selecteddata(that.$el) : that.getAllSelections();
  6452. }
  6453. that.load(selectedData);
  6454. doExport();
  6455. that.load(data);
  6456. } else {
  6457. doExport();
  6458. }
  6459. });
  6460. }
  6461. }
  6462. };
  6463. })(jQuery);
  6464. define("bootstrap-table-export", ["bootstrap-table"], (function (global) {
  6465. return function () {
  6466. var ret, fn;
  6467. return ret || global.$.fn.bootstrapTable.defaults;
  6468. };
  6469. }(this)));
  6470. (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});
  6471. define('upload',['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined, Dropzone, Template) {
  6472. var Upload = {
  6473. list: {},
  6474. options: {},
  6475. config: {
  6476. container: document.body,
  6477. classname: '.plupload:not([initialized]),.faupload:not([initialized])',
  6478. 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>',
  6479. },
  6480. events: {
  6481. //初始化
  6482. onInit: function () {
  6483. },
  6484. //上传成功的回调
  6485. onUploadSuccess: function (up, ret, file) {
  6486. var button = up.element;
  6487. var onUploadSuccess = up.options.onUploadSuccess;
  6488. var data = typeof ret.data !== 'undefined' ? ret.data : null;
  6489. //上传成功后回调
  6490. if (button) {
  6491. //如果有文本框则填充
  6492. var input_id = $(button).data("input-id") ? $(button).data("input-id") : "";
  6493. if (input_id) {
  6494. var urlArr = [];
  6495. var inputObj = $("#" + input_id);
  6496. if ($(button).data("multiple") && inputObj.val() !== "") {
  6497. urlArr.push(inputObj.val());
  6498. }
  6499. var url = Config.upload.fullmode ? (data.fullurl ? data.fullurl : Fast.api.cdnurl(data.url)) : data.url;
  6500. urlArr.push(url);
  6501. inputObj.val(urlArr.join(",")).trigger("change").trigger("validate");
  6502. }
  6503. //如果有回调函数
  6504. var onDomUploadSuccess = $(button).data("upload-success");
  6505. if (onDomUploadSuccess) {
  6506. if (typeof onDomUploadSuccess !== 'function' && typeof Upload.api.custom[onDomUploadSuccess] === 'function') {
  6507. onDomUploadSuccess = Upload.api.custom[onDomUploadSuccess];
  6508. }
  6509. if (typeof onDomUploadSuccess === 'function') {
  6510. var result = onDomUploadSuccess.call(button, data, ret);
  6511. if (result === false)
  6512. return;
  6513. }
  6514. }
  6515. }
  6516. if (typeof onUploadSuccess === 'function') {
  6517. var result = onUploadSuccess.call(button, data, ret);
  6518. if (result === false)
  6519. return;
  6520. }
  6521. },
  6522. //上传错误的回调
  6523. onUploadError: function (up, ret, file) {
  6524. var button = up.element;
  6525. var onUploadError = up.options.onUploadError;
  6526. var data = typeof ret.data !== 'undefined' ? ret.data : null;
  6527. if (button) {
  6528. var onDomUploadError = $(button).data("upload-error");
  6529. if (onDomUploadError) {
  6530. if (typeof onDomUploadError !== 'function' && typeof Upload.api.custom[onDomUploadError] === 'function') {
  6531. onDomUploadError = Upload.api.custom[onDomUploadError];
  6532. }
  6533. if (typeof onDomUploadError === 'function') {
  6534. var result = onDomUploadError.call(button, data, ret);
  6535. if (result === false)
  6536. return;
  6537. }
  6538. }
  6539. }
  6540. if (typeof onUploadError === 'function') {
  6541. var result = onUploadError.call(button, data, ret);
  6542. if (result === false) {
  6543. return;
  6544. }
  6545. }
  6546. Toastr.error(ret.msg.toString().replace(/(<([^>]+)>)/gi, "") + "(code:" + ret.code + ")");
  6547. },
  6548. //服务器响应数据后
  6549. onUploadResponse: function (response, up, file) {
  6550. try {
  6551. var ret = typeof response === 'object' ? response : JSON.parse(response);
  6552. if (!ret.hasOwnProperty('code')) {
  6553. $.extend(ret, {code: -2, msg: response, data: null});
  6554. }
  6555. } catch (e) {
  6556. var ret = {code: -1, msg: e.message, data: null};
  6557. }
  6558. return ret;
  6559. },
  6560. //上传全部结束后
  6561. onUploadComplete: function (up, files) {
  6562. var button = up.element;
  6563. var onUploadComplete = up.options.onUploadComplete;
  6564. if (button) {
  6565. var onDomUploadComplete = $(button).data("upload-complete");
  6566. if (onDomUploadComplete) {
  6567. if (typeof onDomUploadComplete !== 'function' && typeof Upload.api.custom[onDomUploadComplete] === 'function') {
  6568. onDomUploadComplete = Upload.api.custom[onDomUploadComplete];
  6569. }
  6570. if (typeof onDomUploadComplete === 'function') {
  6571. var result = onDomUploadComplete.call(button, files);
  6572. if (result === false)
  6573. return;
  6574. }
  6575. }
  6576. }
  6577. if (typeof onUploadComplete === 'function') {
  6578. var result = onUploadComplete.call(button, files);
  6579. if (result === false) {
  6580. return;
  6581. }
  6582. }
  6583. }
  6584. },
  6585. api: {
  6586. //上传接口
  6587. upload: function (element, onUploadSuccess, onUploadError, onUploadComplete) {
  6588. element = typeof element === 'undefined' ? Upload.config.classname : element;
  6589. $(element, Upload.config.container).each(function () {
  6590. if ($(this).attr("initialized")) {
  6591. return true;
  6592. }
  6593. $(this).attr("initialized", true);
  6594. var that = this;
  6595. var id = $(this).prop("id") || $(this).prop("name") || Dropzone.uuidv4();
  6596. var url = $(this).data("url");
  6597. var maxsize = $(this).data("maxsize");
  6598. var maxcount = $(this).data("maxcount");
  6599. var mimetype = $(this).data("mimetype");
  6600. var multipart = $(this).data("multipart");
  6601. var multiple = $(this).data("multiple");
  6602. //填充ID
  6603. var input_id = $(that).data("input-id") ? $(that).data("input-id") : "";
  6604. //预览ID
  6605. var preview_id = $(that).data("preview-id") ? $(that).data("preview-id") : "";
  6606. //上传URL
  6607. url = url ? url : Config.upload.uploadurl;
  6608. url = Fast.api.fixurl(url);
  6609. var chunking = false, chunkSize = Config.upload.chunksize || 2097152, timeout = Config.upload.timeout || 600000;
  6610. //最大可上传文件大小
  6611. maxsize = typeof maxsize !== "undefined" ? maxsize : Config.upload.maxsize;
  6612. //文件类型
  6613. mimetype = typeof mimetype !== "undefined" ? mimetype : Config.upload.mimetype;
  6614. //请求的表单参数
  6615. multipart = typeof multipart !== "undefined" ? multipart : Config.upload.multipart;
  6616. //是否支持批量上传
  6617. multiple = typeof multiple !== "undefined" ? multiple : Config.upload.multiple;
  6618. //后缀特殊处理
  6619. mimetype = mimetype.split(",").map(function (k) {
  6620. return k.indexOf("/") > -1 ? k : (!k || k === "*" || k.charAt(0) === "." ? k : "." + k);
  6621. }).join(",");
  6622. mimetype = mimetype === '*' ? null : mimetype;
  6623. //最大文件限制转换成mb
  6624. var maxFilesize = (function (maxsize) {
  6625. var matches = maxsize.toString().match(/^([0-9\.]+)(\w+)$/);
  6626. var size = matches ? parseFloat(matches[1]) : parseFloat(maxsize),
  6627. unit = matches ? matches[2].toLowerCase() : 'b';
  6628. var unitDict = {'b': 0, 'k': 1, 'kb': 1, 'm': 2, 'mb': 2, 'gb': 3, 'g': 3, 'tb': 4, 't': 4};
  6629. var y = typeof unitDict[unit] !== 'undefined' ? unitDict[unit] : 0;
  6630. var bytes = size * Math.pow(1024, y);
  6631. return bytes / Math.pow(1024, 2);
  6632. }(maxsize));
  6633. var options = $(this).data() || {};
  6634. options = $.extend(true, {}, options, $(this).data("upload-options") || {});
  6635. delete options.success;
  6636. delete options.url;
  6637. // delete options.params;
  6638. multipart = $.isArray(multipart) ? {} : multipart;
  6639. Upload.list[id] = new Dropzone(this, $.extend({
  6640. url: url,
  6641. params: function (files, xhr, chunk) {
  6642. var params = multipart;
  6643. if (chunk) {
  6644. return $.extend({}, params, {
  6645. filesize: chunk.file.size,
  6646. filename: chunk.file.name,
  6647. chunkid: chunk.file.upload.uuid,
  6648. chunkindex: chunk.index,
  6649. chunkcount: chunk.file.upload.totalChunkCount,
  6650. chunksize: this.options.chunkSize,
  6651. chunkfilesize: chunk.dataBlock.data.size,
  6652. width: chunk.file.width || 0,
  6653. height: chunk.file.height || 0,
  6654. type: chunk.file.type,
  6655. });
  6656. }
  6657. return params;
  6658. },
  6659. chunking: chunking,
  6660. chunkSize: chunkSize,
  6661. maxFilesize: maxFilesize,
  6662. acceptedFiles: mimetype,
  6663. maxFiles: (maxcount && parseInt(maxcount) > 1 ? maxcount : (multiple ? null : 1)),
  6664. timeout: timeout,
  6665. parallelUploads: 1,
  6666. previewsContainer: false,
  6667. dictDefaultMessage: __("Drop files here to upload"),
  6668. dictFallbackMessage: __("Your browser does not support drag'n'drop file uploads"),
  6669. dictFallbackText: __("Please use the fallback form below to upload your files like in the olden days"),
  6670. dictFileTooBig: __("File is too big (%sMiB), Max filesize: %sMiB", "{{filesize}}", "{{maxFilesize}}"),
  6671. dictInvalidFileType: __("You can't upload files of this type"),
  6672. dictResponseError: __("Server responded with %s code.", "{{statusCode}}"),
  6673. dictCancelUpload: __("Cancel upload"),
  6674. dictUploadCanceled: __("Upload canceled"),
  6675. dictCancelUploadConfirmation: __("Are you sure you want to cancel this upload?"),
  6676. dictRemoveFile: __("Remove file"),
  6677. dictMaxFilesExceeded: __("You can only upload a maximum of %s files", "{{maxFiles}}"),
  6678. init: function () {
  6679. Upload.events.onInit.call(this);
  6680. //必须添加dz-message,否则点击icon无法唤起上传窗口
  6681. $(">i", this.element).addClass("dz-message");
  6682. this.options.elementHtml = $(this.element).html();
  6683. },
  6684. sending: function (file, xhr, formData) {
  6685. if (typeof file.category !== 'undefined') {
  6686. formData.append('category', file.category);
  6687. }
  6688. },
  6689. addedfile: function (file) {
  6690. var params = $(this.element).data("params") || {};
  6691. params = typeof params === 'function' ? params.call(this, file) : params;
  6692. var category = typeof params.category !== 'undefined' ? params.category : ($(this.element).data("category") || '');
  6693. file.category = typeof category === 'function' ? category.call(this, file) : category;
  6694. },
  6695. addedfiles: function (files) {
  6696. if (this.options.maxFiles && (!this.options.maxFiles || this.options.maxFiles > 1) && this.options.inputId) {
  6697. var inputObj = $("#" + this.options.inputId);
  6698. if (inputObj.length > 0) {
  6699. var value = $.trim(inputObj.val());
  6700. var nums = value === '' ? 0 : value.split(/\,/).length;
  6701. var remain = this.options.maxFiles - nums;
  6702. if (remain === 0 || files.length > remain) {
  6703. files = Array.prototype.slice.call(files, remain);
  6704. for (var i = 0; i < files.length; i++) {
  6705. this.removeFile(files[i]);
  6706. }
  6707. Toastr.error(__("You can only upload a maximum of %s files", this.options.maxFiles));
  6708. }
  6709. }
  6710. }
  6711. },
  6712. success: function (file, response) {
  6713. var ret = Upload.events.onUploadResponse(response, this, file);
  6714. file.ret = ret;
  6715. if (ret.code === 1) {
  6716. Upload.events.onUploadSuccess(this, ret, file);
  6717. } else {
  6718. Upload.events.onUploadError(this, ret, file);
  6719. }
  6720. },
  6721. error: function (file, response, xhr) {
  6722. var responseObj = $("<div>" + (xhr && typeof xhr.responseText !== 'undefined' ? xhr.responseText : response) + "</div>");
  6723. responseObj.find("style, title, script").remove();
  6724. var msg = responseObj.text() || __('Network error');
  6725. var ret = {code: 0, data: null, msg: msg};
  6726. Upload.events.onUploadError(this, ret, file);
  6727. },
  6728. uploadprogress: function (file, progress, bytesSent) {
  6729. if (file.upload.chunked) {
  6730. $(this.element).prop("disabled", true).html("<i class='fa fa-upload'></i> " + __('Upload') + Math.floor((file.upload.bytesSent / file.size) * 100) + "%");
  6731. }
  6732. },
  6733. totaluploadprogress: function (progress, bytesSent) {
  6734. if (this.getActiveFiles().length > 0 && !this.options.chunking) {
  6735. $(this.element).prop("disabled", true).html("<i class='fa fa-upload'></i> " + __('Upload') + Math.floor(progress) + "%");
  6736. }
  6737. },
  6738. queuecomplete: function () {
  6739. Upload.events.onUploadComplete(this, this.files);
  6740. this.removeAllFiles(true);
  6741. $(this.element).prop("disabled", false).html(this.options.elementHtml);
  6742. },
  6743. chunkSuccess: function (chunk, file, response) {
  6744. },
  6745. chunksUploaded: function (file, done) {
  6746. var that = this;
  6747. Fast.api.ajax({
  6748. url: this.options.url,
  6749. data: $.extend({}, multipart, {
  6750. action: 'merge',
  6751. filesize: file.size,
  6752. filename: file.name,
  6753. chunkid: file.upload.uuid,
  6754. chunkcount: file.upload.totalChunkCount,
  6755. })
  6756. }, function (data, ret) {
  6757. done(JSON.stringify(ret));
  6758. return false;
  6759. }, function (data, ret) {
  6760. file.accepted = false;
  6761. that._errorProcessing([file], ret.msg);
  6762. });
  6763. },
  6764. onUploadSuccess: onUploadSuccess,
  6765. onUploadError: onUploadError,
  6766. onUploadComplete: onUploadComplete,
  6767. }, Upload.options, options));
  6768. //拖动排序
  6769. if (preview_id && multiple) {
  6770. require(['dragsort'], function () {
  6771. $("#" + preview_id).dragsort({
  6772. dragSelector: "li a:not(.btn-trash)",
  6773. dragEnd: function () {
  6774. $("#" + preview_id).trigger("fa.preview.change");
  6775. },
  6776. placeHolderTemplate: '<li class="col-xs-3"></li>'
  6777. });
  6778. });
  6779. }
  6780. //刷新隐藏textarea的值
  6781. var refresh = function (name) {
  6782. var data = {};
  6783. var textarea = $("textarea[name='" + name + "']");
  6784. var container = textarea.prev("ul");
  6785. $.each($("input,select,textarea", container).serializeArray(), function (i, j) {
  6786. var reg = /\[?(\w+)\]?\[(\w+)\]$/g;
  6787. var match = reg.exec(j.name);
  6788. if (!match)
  6789. return true;
  6790. if (!isNaN(match[2])) {
  6791. data[i] = j.value;
  6792. } else {
  6793. match[1] = "x" + parseInt(match[1]);
  6794. if (typeof data[match[1]] === 'undefined') {
  6795. data[match[1]] = {};
  6796. }
  6797. data[match[1]][match[2]] = j.value;
  6798. }
  6799. });
  6800. var result = [];
  6801. $.each(data, function (i, j) {
  6802. result.push(j);
  6803. });
  6804. textarea.val(JSON.stringify(result));
  6805. };
  6806. if (preview_id && input_id) {
  6807. $(document.body).on("keyup change", "#" + input_id, function (e) {
  6808. var inputStr = $("#" + input_id).val();
  6809. var inputArr = inputStr.split(/\,/);
  6810. var previewObj = $("#" + preview_id);
  6811. previewObj.empty();
  6812. var tpl = previewObj.data("template") ? previewObj.data("template") : "";
  6813. var extend = previewObj.next().is("textarea") ? previewObj.next("textarea").val() : "{}";
  6814. var json = {};
  6815. try {
  6816. json = JSON.parse(extend);
  6817. } catch (e) {
  6818. }
  6819. $.each(inputArr, function (i, j) {
  6820. if (!j) {
  6821. return true;
  6822. }
  6823. var suffix = /[\.]?([a-zA-Z0-9]+)$/.exec(j);
  6824. suffix = suffix ? suffix[1] : 'file';
  6825. var btnData = $(that).data();
  6826. var fullurl = typeof btnData.cdnurl!=='undefined' ? Fast.api.cdnurl(j, btnData.cdnurl) : Fast.api.cdnurl(j);
  6827. j = Config.upload.fullmode ? fullurl : j;
  6828. var value = (json && typeof json[i] !== 'undefined' ? json[i] : null);
  6829. var data = {url: j, fullurl: fullurl, data: btnData, key: i, index: i, value: value, row: value, suffix: suffix};
  6830. var html = tpl ? Template(tpl, data) : Template.render(Upload.config.previewtpl, data);
  6831. previewObj.append(html);
  6832. });
  6833. refresh(previewObj.data("name"));
  6834. });
  6835. $("#" + input_id).trigger("change");
  6836. }
  6837. if (preview_id) {
  6838. //监听文本框改变事件
  6839. $("#" + preview_id).on('change keyup', "input,textarea,select", function () {
  6840. refresh($(this).closest("ul").data("name"));
  6841. });
  6842. // 监听事件
  6843. $(document.body).on("fa.preview.change", "#" + preview_id, function () {
  6844. var urlArr = [];
  6845. $("#" + preview_id + " [data-url]").each(function (i, j) {
  6846. urlArr.push($(this).data("url"));
  6847. });
  6848. if (input_id) {
  6849. $("#" + input_id).val(urlArr.join(","));
  6850. }
  6851. refresh($("#" + preview_id).data("name"));
  6852. });
  6853. // 移除按钮事件
  6854. $(document.body).on("click", "#" + preview_id + " .btn-trash", function () {
  6855. $(this).closest("li").remove();
  6856. $("#" + preview_id).trigger("fa.preview.change");
  6857. });
  6858. }
  6859. if (input_id) {
  6860. //粘贴上传、拖拽上传
  6861. $("body").on('paste drop', "#" + input_id, function (event) {
  6862. var originEvent = event.originalEvent;
  6863. var button = $(".plupload[data-input-id='" + $(this).attr("id") + "'],.faupload[data-input-id='" + $(this).attr("id") + "']");
  6864. if (event.type === 'paste' && originEvent.clipboardData && originEvent.clipboardData.items) {
  6865. var items = originEvent.clipboardData.items;
  6866. if ((items.length === 1 && items[0].type.indexOf("text") > -1) || (items.length === 2 && items[1].type.indexOf("text") > -1)) {
  6867. } else {
  6868. Upload.list[button.attr("id")].paste(originEvent);
  6869. return false;
  6870. }
  6871. }
  6872. if (event.type === 'drop' && originEvent.dataTransfer && originEvent.dataTransfer.files) {
  6873. Upload.list[button.attr("id")].drop(originEvent);
  6874. return false;
  6875. }
  6876. });
  6877. }
  6878. });
  6879. },
  6880. /**
  6881. * @deprecated Use upload instead.
  6882. */
  6883. plupload: function (element, onUploadSuccess, onUploadError, onUploadComplete) {
  6884. return Upload.api.upload(element, onUploadSuccess, onUploadError, onUploadComplete);
  6885. },
  6886. /**
  6887. * @deprecated Use upload instead.
  6888. */
  6889. faupload: function (element, onUploadSuccess, onUploadError, onUploadComplete) {
  6890. return Upload.api.upload(element, onUploadSuccess, onUploadError, onUploadComplete);
  6891. },
  6892. // AJAX异步上传
  6893. send: function (file, onUploadSuccess, onUploadError, onUploadComplete) {
  6894. var index = Layer.msg(__('Uploading'), {offset: 't', time: 0});
  6895. var id = "dropzone-" + Dropzone.uuidv4();
  6896. $('<button type="button" id="' + id + '" class="btn btn-danger hidden faupload" />').appendTo("body");
  6897. $("#" + id).data("upload-complete", function (files) {
  6898. Layer.close(index);
  6899. Upload.list[id].removeAllFiles(true);
  6900. });
  6901. Upload.api.upload("#" + id, onUploadSuccess, onUploadError, onUploadComplete);
  6902. setTimeout(function () {
  6903. Upload.list[id].addFile(file);
  6904. }, 1);
  6905. },
  6906. custom: {
  6907. //自定义上传完成回调
  6908. afteruploadcallback: function (response) {
  6909. console.log(this, response);
  6910. alert("Custom Callback,Response URL:" + response.url);
  6911. },
  6912. }
  6913. }
  6914. }
  6915. ;
  6916. return Upload;
  6917. });
  6918. /*! nice-validator 1.1.5
  6919. * (c) 2012-2020 Jony Zhang <niceue@live.com>, MIT Licensed
  6920. * https://github.com/niceue/nice-validator
  6921. */
  6922. ;(function(factory) {
  6923. typeof module === 'object' && module.exports ? module.exports = factory( require( 'jquery' ) ) :
  6924. typeof define === 'function' && define.amd ? define('validator',['jquery'], factory) :
  6925. factory(jQuery);
  6926. }(function($, undefined) {
  6927. 'use strict';
  6928. var NS = 'validator',
  6929. CLS_NS = '.' + NS,
  6930. CLS_NS_RULE = '.rule',
  6931. CLS_NS_FIELD = '.field',
  6932. CLS_NS_FORM = '.form',
  6933. CLS_WRAPPER = 'nice-' + NS,
  6934. CLS_MSG_BOX = 'msg-box',
  6935. ARIA_INVALID = 'aria-invalid',
  6936. DATA_RULE = 'data-rule',
  6937. DATA_MSG = 'data-msg',
  6938. DATA_TIP = 'data-tip',
  6939. DATA_OK = 'data-ok',
  6940. DATA_TIMELY = 'data-timely',
  6941. DATA_TARGET = 'data-target',
  6942. DATA_DISPLAY = 'data-display',
  6943. DATA_MUST = 'data-must',
  6944. NOVALIDATE = 'novalidate',
  6945. INPUT_SELECTOR = ':verifiable',
  6946. rRules = /(&)?(!)?\b(\w+)(?:\[\s*(.*?\]?)\s*\]|\(\s*(.*?\)?)\s*\))?\s*(;|\|)?/g,
  6947. rRule = /(\w+)(?:\[\s*(.*?\]?)\s*\]|\(\s*(.*?\)?)\s*\))?/,
  6948. rDisplay = /(?:([^:;\(\[]*):)?(.*)/,
  6949. rDoubleBytes = /[^\x00-\xff]/g,
  6950. rPos = /top|right|bottom|left/,
  6951. rAjaxType = /(?:(cors|jsonp):)?(?:(post|get):)?(.+)/i,
  6952. rUnsafe = /[<>'"`\\]|&#x?\d+[A-F]?;?|%3[A-F]/gmi,
  6953. noop = $.noop,
  6954. proxy = $.proxy,
  6955. trim = $.trim,
  6956. isFunction = $.isFunction,
  6957. isString = function(s) {
  6958. return typeof s === 'string';
  6959. },
  6960. isObject = function(o) {
  6961. return o && Object.prototype.toString.call(o) === '[object Object]';
  6962. },
  6963. isIE = document.documentMode || +(navigator.userAgent.match(/MSIE (\d+)/) && RegExp.$1),
  6964. attr = function(el, key, value) {
  6965. if (!el || !el.tagName) return null;
  6966. if (value !== undefined) {
  6967. if (value === null) el.removeAttribute(key);
  6968. else el.setAttribute(key, '' + value);
  6969. } else {
  6970. return el.getAttribute(key);
  6971. }
  6972. },
  6973. novalidateonce,
  6974. preinitialized = {},
  6975. defaults = {
  6976. debug: 0,
  6977. theme: 'default',
  6978. ignore: '',
  6979. focusInvalid: true,
  6980. focusCleanup: false,
  6981. stopOnError: false,
  6982. beforeSubmit: null,
  6983. valid: null,
  6984. invalid: null,
  6985. validation: null,
  6986. formClass: 'n-default',
  6987. validClass: 'n-valid',
  6988. invalidClass: 'n-invalid',
  6989. bindClassTo: null
  6990. },
  6991. fieldDefaults = {
  6992. timely: 1,
  6993. display: null,
  6994. target: null,
  6995. ignoreBlank: false,
  6996. showOk: true,
  6997. // Translate ajax response to validation result
  6998. dataFilter: function (data) {
  6999. if ( isString(data) || ( isObject(data) && ('error' in data || 'ok' in data) ) ) {
  7000. return data;
  7001. }
  7002. },
  7003. msgMaker: function(opt) {
  7004. var html;
  7005. html = '<span role="alert" class="msg-wrap n-'+ opt.type + '">' + opt.arrow;
  7006. if (opt.result) {
  7007. $.each(opt.result, function(i, obj){
  7008. html += '<span class="n-'+ obj.type +'">' + opt.icon + '<span class="n-msg">' + obj.msg + '</span></span>';
  7009. });
  7010. } else {
  7011. html += opt.icon + '<span class="n-msg">' + opt.msg + '</span>';
  7012. }
  7013. html += '</span>';
  7014. return html;
  7015. },
  7016. msgWrapper: 'span',
  7017. msgArrow: '',
  7018. msgIcon: '<span class="n-icon"></span>',
  7019. msgClass: 'n-right',
  7020. msgStyle: '',
  7021. msgShow: null,
  7022. msgHide: null
  7023. },
  7024. themes = {};
  7025. /** jQuery Plugin
  7026. * @param {Object} options
  7027. debug {Boolean} 0 Whether to enable debug mode
  7028. timely {Number} 1 Whether to enable timely validation
  7029. theme {String} 'default' Theme name
  7030. stopOnError {Boolean} false Whether to stop validate when found an error input
  7031. focusCleanup {Boolean} false Whether to clean up the field message when focus the field
  7032. focusInvalid {Boolean} true Whether to focus the field that is invalid
  7033. ignoreBlank {Boolean} false When the field has no value, whether to ignore validation
  7034. ignore {jqSelector} '' Ignored fields (Using jQuery selector)
  7035. beforeSubmit {Function} Do something before submit form
  7036. dataFilter {Function} Convert ajax results
  7037. valid {Function} Triggered when the form is valid
  7038. invalid {Function} Triggered when the form is invalid
  7039. validClass {String} 'n-valid' Add this class name to a valid field
  7040. invalidClass {String} 'n-invalid' Add this class name to a invalid field
  7041. bindClassTo {jqSelector} ':verifiable' Which element should the className binding to
  7042. display {Function} Callback function to get dynamic display
  7043. target {Function} Callback function to get dynamic target
  7044. msgShow {Function} Trigger this callback when show message
  7045. msgHide {Function} Trigger this callback when hide message
  7046. msgWrapper {String} 'span' Message wrapper tag name
  7047. msgMaker {Function} Callback function to make message HTML
  7048. msgArrow {String} Message arrow template
  7049. msgIcon {String} Message icon template
  7050. msgStyle {String} Custom message css style
  7051. msgClass {String} Additional added to the message class names
  7052. formClass {String} Additional added to the form class names
  7053. messages {Object} Custom messages for the current instance
  7054. rules {Object} Custom rules for the current instance
  7055. fields {Object} Field validation configuration
  7056. {String} key name|#id
  7057. {String|Object} value Rule string or an object which can pass more arguments
  7058. fields[key][rule] {String} Rule string
  7059. fields[key][display] {String|Function}
  7060. fields[key][tip] {String} Custom tip message
  7061. fields[key][ok] {String} Custom success message
  7062. fields[key][msg] {Object} Custom error message
  7063. fields[key][msgStyle] {String} Custom message style
  7064. fields[key][msgClass] {String} A className which added to message placeholder element
  7065. fields[key][msgWrapper] {String} Tag name of the message placeholder element
  7066. fields[key][msgMaker] {Function} A function to custom message HTML
  7067. fields[key][dataFilter] {Function} A function to convert ajax results
  7068. fields[key][valid] {Function} A function triggered when field is valid
  7069. fields[key][invalid] {Function} A function triggered when field is invalid
  7070. fields[key][must] {Boolean} If set true, we always check the field even has remote checking
  7071. fields[key][timely] {Boolean} Whether to enable timely validation
  7072. fields[key][target] {jqSelector} Define placement of a message
  7073. */
  7074. $.fn.validator = function(options) {
  7075. var that = this,
  7076. args = arguments;
  7077. if (that.is(INPUT_SELECTOR)) return that;
  7078. if (!that.is('form')) that = this.find('form');
  7079. if (!that.length) that = this;
  7080. that.each(function() {
  7081. var instance = $(this).data(NS);
  7082. if (instance) {
  7083. if ( isString(options) ) {
  7084. if ( options.charAt(0) === '_' ) return;
  7085. instance[options].apply(instance, [].slice.call(args, 1));
  7086. }
  7087. else if (options) {
  7088. instance._reset(true);
  7089. instance._init(this, options);
  7090. }
  7091. } else {
  7092. new Validator(this, options);
  7093. }
  7094. });
  7095. return this;
  7096. };
  7097. // Validate a field, or an area
  7098. $.fn.isValid = function(callback, hideMsg) {
  7099. var me = _getInstance(this[0]),
  7100. hasCallback = isFunction(callback),
  7101. ret, opt;
  7102. if (!me) return true;
  7103. if (!hasCallback && hideMsg === undefined) hideMsg = callback;
  7104. me.checkOnly = !!hideMsg;
  7105. opt = me.options;
  7106. ret = me._multiValidate(
  7107. this.is(INPUT_SELECTOR) ? this : this.find(INPUT_SELECTOR),
  7108. function(isValid){
  7109. if (!isValid && opt.focusInvalid && !me.checkOnly) {
  7110. // navigate to the error element
  7111. me.$el.find('[' + ARIA_INVALID + ']:first').focus();
  7112. }
  7113. if (hasCallback) {
  7114. if (callback.length) {
  7115. callback(isValid);
  7116. } else if (isValid) {
  7117. callback();
  7118. }
  7119. }
  7120. me.checkOnly = false;
  7121. }
  7122. );
  7123. // If you pass a callback, we maintain the jQuery object chain
  7124. return hasCallback ? this : ret;
  7125. };
  7126. $.extend($.expr.pseudos || $.expr[':'], {
  7127. // A faster selector than ":input:not(:submit,:button,:reset,:image,:disabled,[contenteditable])"
  7128. verifiable: function(elem) {
  7129. var name = elem.nodeName.toLowerCase();
  7130. return ( name === 'input' && !({submit: 1, button: 1, reset: 1, image: 1})[elem.type] ||
  7131. name === 'select' ||
  7132. name === 'textarea' ||
  7133. elem.contentEditable === 'true'
  7134. ) && !elem.disabled;
  7135. },
  7136. // any value, but not only whitespace
  7137. filled: function(elem) {
  7138. return !!trim($(elem).val());
  7139. }
  7140. });
  7141. /**
  7142. * Creates a new Validator
  7143. *
  7144. * @class
  7145. * @param {Element} element - form element
  7146. * @param {Object} options - options for validator
  7147. */
  7148. function Validator(element, options) {
  7149. var me = this;
  7150. if ( !(me instanceof Validator) ) {
  7151. return new Validator(element, options);
  7152. }
  7153. if (Validator.pending) {
  7154. $(window).on('validatorready', init);
  7155. } else {
  7156. init();
  7157. }
  7158. function init() {
  7159. me.$el = $(element);
  7160. if (me.$el.length) {
  7161. me._init(me.$el[0], options);
  7162. }
  7163. else if (isString(element)) {
  7164. preinitialized[element] = options;
  7165. }
  7166. }
  7167. }
  7168. Validator.prototype = {
  7169. _init: function(element, options) {
  7170. var me = this,
  7171. opt, themeOpt, dataOpt;
  7172. // Initialization options
  7173. if ( isFunction(options) ) {
  7174. options = {
  7175. valid: options
  7176. };
  7177. }
  7178. options = me._opt = options || {};
  7179. dataOpt = attr(element, 'data-'+ NS +'-option');
  7180. dataOpt = me._dataOpt = dataOpt && dataOpt.charAt(0) === '{' ? (new Function('return ' + dataOpt))() : {};
  7181. themeOpt = me._themeOpt = themes[ options.theme || dataOpt.theme || defaults.theme ];
  7182. opt = me.options = $.extend({}, defaults, fieldDefaults, themeOpt, me.options, options, dataOpt);
  7183. me.rules = new Rules(opt.rules, true);
  7184. me.messages = new Messages(opt.messages, true);
  7185. me.Field = _createFieldFactory(me);
  7186. me.elements = me.elements || {};
  7187. me.deferred = {};
  7188. me.errors = {};
  7189. me.fields = {};
  7190. // Initialization fields
  7191. me._initFields(opt.fields);
  7192. // Initialization events and make a cache
  7193. if ( !me.$el.data(NS) ) {
  7194. me.$el.data(NS, me).addClass(CLS_WRAPPER +' '+ opt.formClass)
  7195. .on('form-submit-validate', function(e, a, $form, opts, veto) {
  7196. me.vetoed = veto.veto = !me.isValid;
  7197. me.ajaxFormOptions = opts;
  7198. })
  7199. .on('submit'+ CLS_NS +' validate'+ CLS_NS, proxy(me, '_submit'))
  7200. .on('reset'+ CLS_NS, proxy(me, '_reset'))
  7201. .on('showmsg'+ CLS_NS, proxy(me, '_showmsg'))
  7202. .on('hidemsg'+ CLS_NS, proxy(me, '_hidemsg'))
  7203. .on('focusin'+ CLS_NS + ' click'+ CLS_NS, INPUT_SELECTOR, proxy(me, '_focusin'))
  7204. .on('focusout'+ CLS_NS +' validate'+ CLS_NS, INPUT_SELECTOR, proxy(me, '_focusout'))
  7205. .on('keyup'+ CLS_NS +' input'+ CLS_NS + ' compositionstart compositionend', INPUT_SELECTOR, proxy(me, '_focusout'))
  7206. .on('click'+ CLS_NS, ':radio,:checkbox', 'click', proxy(me, '_focusout'))
  7207. .on('change'+ CLS_NS, 'select,input[type="file"]', 'change', proxy(me, '_focusout'));
  7208. // cache the novalidate attribute value
  7209. me._NOVALIDATE = attr(element, NOVALIDATE);
  7210. // Initialization is complete, stop off default HTML5 form validation
  7211. // If use "jQuery.attr('novalidate')" in IE7 will complain: "SCRIPT3: Member not found."
  7212. attr(element, NOVALIDATE, NOVALIDATE);
  7213. }
  7214. // Display all messages in target container
  7215. if ( isString(opt.target) ) {
  7216. me.$el.find(opt.target).addClass('msg-container');
  7217. }
  7218. },
  7219. // Guess whether the form use ajax submit
  7220. _guessAjax: function(form) {
  7221. var me = this;
  7222. if ( !(me.isAjaxSubmit = !!me.options.valid) ) {
  7223. // if there is a "valid.form" event
  7224. var events = ($._data || $.data)(form, 'events');
  7225. me.isAjaxSubmit = issetEvent(events, 'valid', 'form') || issetEvent(events, 'submit', 'form-plugin');
  7226. }
  7227. function issetEvent(events, name, namespace) {
  7228. return !!(
  7229. events && events[name]
  7230. && $.map(events[name], function(e){
  7231. return ~e.namespace.indexOf(namespace) ? 1 : null;
  7232. }).length )
  7233. }
  7234. },
  7235. _initFields: function(fields) {
  7236. var me = this, k, arr, i,
  7237. clear = fields === null;
  7238. // Processing field information
  7239. if (clear) fields = me.fields;
  7240. if ( isObject(fields) ) {
  7241. for (k in fields) {
  7242. if (~k.indexOf(',')) {
  7243. arr = k.split(',');
  7244. i = arr.length;
  7245. while (i--) {
  7246. initField(trim(arr[i]), fields[k]);
  7247. }
  7248. } else {
  7249. initField(k, fields[k]);
  7250. }
  7251. }
  7252. }
  7253. // Parsing DOM rules
  7254. me.$el.find(INPUT_SELECTOR).each(function() {
  7255. me._parse(this);
  7256. });
  7257. function initField(k, v) {
  7258. // delete a field from settings
  7259. if ( v === null || clear ) {
  7260. var el = me.elements[k];
  7261. if (el) me._resetElement(el, true);
  7262. delete me.fields[k];
  7263. } else {
  7264. me.fields[k] = new me.Field(k, isString(v) ? {rule: v} : v, me.fields[k]);
  7265. }
  7266. }
  7267. },
  7268. // Parsing a field
  7269. _parse: function(el) {
  7270. var me = this,
  7271. field,
  7272. key = el.name,
  7273. display,
  7274. timely,
  7275. dataRule = attr(el, DATA_RULE);
  7276. dataRule && attr(el, DATA_RULE, null);
  7277. // If the field has passed the key as id mode, or it doesn't has a name
  7278. if ( el.id && (
  7279. ('#' + el.id in me.fields) ||
  7280. !key ||
  7281. // If dataRule and element are diffrent from old's, we use ID mode.
  7282. (dataRule !== null && (field = me.fields[key]) && dataRule !== field.rule && el.id !== field.key)
  7283. )
  7284. ) {
  7285. key = '#' + el.id;
  7286. }
  7287. // Generate id
  7288. if (!key) {
  7289. key = '#' + (el.id = 'N' + String(Math.random()).slice(-12));
  7290. }
  7291. field = me.getField(key, true);
  7292. // The priority of passing parameter by DOM is higher than by JS.
  7293. field.rule = dataRule || field.rule;
  7294. if (display = attr(el, DATA_DISPLAY)) {
  7295. field.display = display;
  7296. }
  7297. if (field.rule) {
  7298. if ( attr(el, DATA_MUST) !== null || /\b(?:match|checked)\b/.test(field.rule) ) {
  7299. field.must = true;
  7300. }
  7301. if ( /\brequired\b/.test(field.rule) ) {
  7302. field.required = true;
  7303. }
  7304. if (timely = attr(el, DATA_TIMELY)) {
  7305. field.timely = +timely;
  7306. } else if (field.timely > 3) {
  7307. attr(el, DATA_TIMELY, field.timely);
  7308. }
  7309. me._parseRule(field);
  7310. field.old = {};
  7311. }
  7312. if ( isString(field.target) ) {
  7313. attr(el, DATA_TARGET, field.target);
  7314. }
  7315. if ( isString(field.tip) ) {
  7316. attr(el, DATA_TIP, field.tip);
  7317. }
  7318. return me.fields[key] = field;
  7319. },
  7320. // Parsing field rules
  7321. _parseRule: function(field) {
  7322. var arr = rDisplay.exec(field.rule);
  7323. if (!arr) return;
  7324. // current rule index
  7325. field._i = 0;
  7326. if (arr[1]) {
  7327. field.display = arr[1];
  7328. }
  7329. if (arr[2]) {
  7330. field._rules = [];
  7331. arr[2].replace(rRules, function(){
  7332. var args = arguments;
  7333. args[4] = args[4] || args[5];
  7334. field._rules.push({
  7335. and: args[1] === '&',
  7336. not: args[2] === '!',
  7337. or: args[6] === '|',
  7338. method: args[3],
  7339. params: args[4] ? $.map( args[4].split(', '), trim ) : undefined
  7340. });
  7341. });
  7342. }
  7343. },
  7344. // Verify a zone
  7345. _multiValidate: function($inputs, doneCallback){
  7346. var me = this,
  7347. opt = me.options;
  7348. me.hasError = false;
  7349. if (opt.ignore) {
  7350. $inputs = $inputs.not(opt.ignore);
  7351. }
  7352. $inputs.each(function() {
  7353. me._validate(this);
  7354. if (me.hasError && opt.stopOnError) {
  7355. // stop the validation
  7356. return false;
  7357. }
  7358. });
  7359. // Need to wait for all fields validation complete, especially asynchronous validation
  7360. if (doneCallback) {
  7361. me.validating = true;
  7362. $.when.apply(
  7363. null,
  7364. $.map(me.deferred, function(v){return v;})
  7365. ).done(function(){
  7366. doneCallback.call(me, !me.hasError);
  7367. me.validating = false;
  7368. });
  7369. }
  7370. // If the form does not contain asynchronous validation, the return value is correct.
  7371. // Otherwise, you should detect form validation result through "doneCallback".
  7372. return !$.isEmptyObject(me.deferred) ? undefined : !me.hasError;
  7373. },
  7374. // Validate the whole form
  7375. _submit: function(e) {
  7376. var me = this,
  7377. opt = me.options,
  7378. form = e.target,
  7379. canSubmit = e.type === 'submit' && form.tagName === 'FORM' && !e.isDefaultPrevented();
  7380. e.preventDefault();
  7381. if (
  7382. novalidateonce && ~(novalidateonce = false) ||
  7383. // Prevent duplicate submission
  7384. me.submiting ||
  7385. // Receive the "validate" event only from the form.
  7386. e.type === 'validate' && me.$el[0] !== form ||
  7387. // trigger the beforeSubmit callback.
  7388. isFunction(opt.beforeSubmit) && opt.beforeSubmit.call(me, form) === false
  7389. ) {
  7390. return;
  7391. }
  7392. if (me.isAjaxSubmit === undefined) {
  7393. me._guessAjax(form);
  7394. }
  7395. me._debug('log', '\n<<< event: ' + e.type);
  7396. me._reset();
  7397. me.submiting = true;
  7398. me._multiValidate(
  7399. me.$el.find(INPUT_SELECTOR),
  7400. function(isValid){
  7401. var ret = (isValid || opt.debug === 2) ? 'valid' : 'invalid',
  7402. errors;
  7403. if (!isValid) {
  7404. if (opt.focusInvalid) {
  7405. // navigate to the error element
  7406. me.$el.find('[' + ARIA_INVALID + ']:first').focus();
  7407. }
  7408. errors = $.map(me.errors, function(err){return err;});
  7409. }
  7410. // releasing submit
  7411. me.submiting = false;
  7412. me.isValid = isValid;
  7413. // trigger callback and event
  7414. isFunction(opt[ret]) && opt[ret].call(me, form, errors);
  7415. me.$el.trigger(ret + CLS_NS_FORM, [form, errors]);
  7416. me._debug('log', '>>> ' + ret);
  7417. if (!isValid) return;
  7418. // For jquery.form plugin
  7419. if (me.vetoed) {
  7420. $(form).ajaxSubmit(me.ajaxFormOptions);
  7421. }
  7422. else if (canSubmit && !me.isAjaxSubmit) {
  7423. document.createElement('form').submit.call(form);
  7424. }
  7425. }
  7426. );
  7427. },
  7428. _reset: function(e) {
  7429. var me = this;
  7430. me.errors = {};
  7431. if (e) {
  7432. me.reseting = true;
  7433. me.$el.find(INPUT_SELECTOR).each( function(){
  7434. me._resetElement(this);
  7435. });
  7436. delete me.reseting;
  7437. }
  7438. },
  7439. _resetElement: function(el, all) {
  7440. this._setClass(el, null);
  7441. this.hideMsg(el);
  7442. },
  7443. // Handle events: "focusin/click"
  7444. _focusin: function(e) {
  7445. var me = this,
  7446. opt = me.options,
  7447. el = e.target,
  7448. timely,
  7449. msg;
  7450. if ( me.validating || ( e.type==='click' && document.activeElement === el ) ) {
  7451. return;
  7452. }
  7453. if (opt.focusCleanup) {
  7454. if ( attr(el, ARIA_INVALID) === 'true' ) {
  7455. me._setClass(el, null);
  7456. me.hideMsg(el);
  7457. }
  7458. }
  7459. msg = attr(el, DATA_TIP);
  7460. if (msg) {
  7461. me.showMsg(el, {
  7462. type: 'tip',
  7463. msg: msg
  7464. });
  7465. } else {
  7466. if (attr(el, DATA_RULE)) {
  7467. me._parse(el);
  7468. }
  7469. if (timely = attr(el, DATA_TIMELY)) {
  7470. if ( timely === 8 || timely === 9 ) {
  7471. me._focusout(e);
  7472. }
  7473. }
  7474. }
  7475. },
  7476. // Handle events: "focusout/validate/keyup/click/change/input/compositionstart/compositionend"
  7477. _focusout: function(e) {
  7478. var me = this,
  7479. opt = me.options,
  7480. el = e.target,
  7481. etype = e.type,
  7482. etype0,
  7483. focusin = etype === 'focusin',
  7484. special = etype === 'validate',
  7485. elem,
  7486. field,
  7487. old,
  7488. value,
  7489. timestamp,
  7490. key, specialKey,
  7491. timely,
  7492. timer = 0;
  7493. if (etype === 'compositionstart') {
  7494. me.pauseValidate = true;
  7495. }
  7496. if (etype === 'compositionend') {
  7497. me.pauseValidate = false;
  7498. }
  7499. if (me.pauseValidate) {
  7500. return;
  7501. }
  7502. // For checkbox and radio
  7503. elem = el.name && _checkable(el) ? me.$el.find('input[name="'+ el.name +'"]').get(0) : el;
  7504. // Get field
  7505. if (!(field = me.getField(elem)) || !field.rule) {
  7506. return;
  7507. }
  7508. // Cache event type
  7509. etype0 = field._e;
  7510. field._e = etype;
  7511. timely = field.timely;
  7512. if (!special) {
  7513. if (!timely || (_checkable(el) && etype !== 'click')) {
  7514. return;
  7515. }
  7516. value = field.getValue();
  7517. // not validate field unless fill a value
  7518. if ( field.ignoreBlank && !value && !focusin ) {
  7519. me.hideMsg(el);
  7520. return;
  7521. }
  7522. if ( etype === 'focusout' ) {
  7523. if (etype0 === 'change') {
  7524. return;
  7525. }
  7526. if ( timely === 2 || timely === 8 ) {
  7527. old = field.old;
  7528. if (value && old) {
  7529. if (field.isValid && !old.showOk) {
  7530. me.hideMsg(el);
  7531. } else {
  7532. me._makeMsg(el, field, old);
  7533. }
  7534. } else {
  7535. return;
  7536. }
  7537. }
  7538. }
  7539. else {
  7540. if ( timely < 2 && !e.data ) {
  7541. return;
  7542. }
  7543. // mark timestamp to reduce the frequency of the received event
  7544. timestamp = +new Date();
  7545. if ( timestamp - (el._ts || 0) < 100 ) {
  7546. return;
  7547. }
  7548. el._ts = timestamp;
  7549. // handle keyup
  7550. if ( etype === 'keyup' ) {
  7551. if (etype0 === 'input') {
  7552. return;
  7553. }
  7554. key = e.keyCode;
  7555. specialKey = {
  7556. 8: 1, // Backspace
  7557. 9: 1, // Tab
  7558. 16: 1, // Shift
  7559. 32: 1, // Space
  7560. 46: 1 // Delete
  7561. };
  7562. // only gets focus, no validation
  7563. if ( key === 9 && !value ) {
  7564. return;
  7565. }
  7566. // do not validate, if triggered by these keys
  7567. if ( key < 48 && !specialKey[key] ) {
  7568. return;
  7569. }
  7570. }
  7571. if ( !focusin ) {
  7572. // keyboard events, reducing the frequency of validation
  7573. timer = timely <100 ? (etype === 'click' || el.tagName === 'SELECT') ? 0 : 400 : timely;
  7574. }
  7575. }
  7576. }
  7577. // if the current field is ignored
  7578. if ( opt.ignore && $(el).is(opt.ignore) ) {
  7579. return;
  7580. }
  7581. clearTimeout(field._t);
  7582. if (timer) {
  7583. field._t = setTimeout(function() {
  7584. me._validate(el, field);
  7585. }, timer);
  7586. } else {
  7587. if (special) field.old = {};
  7588. me._validate(el, field);
  7589. }
  7590. },
  7591. _setClass: function(el, isValid) {
  7592. var $el = $(el), opt = this.options;
  7593. if (opt.bindClassTo) {
  7594. $el = $el.closest(opt.bindClassTo);
  7595. }
  7596. $el.removeClass( opt.invalidClass + ' ' + opt.validClass );
  7597. if (isValid !== null) {
  7598. $el.addClass( isValid ? opt.validClass : opt.invalidClass );
  7599. }
  7600. },
  7601. _showmsg: function(e, type, msg) {
  7602. var me = this,
  7603. el = e.target;
  7604. if ( me.$el.is(el) ) {
  7605. if (isObject(type)) {
  7606. me.showMsg(type)
  7607. }
  7608. else if ( type === 'tip' ) {
  7609. me.$el.find(INPUT_SELECTOR +'['+ DATA_TIP +']', el).each(function(){
  7610. me.showMsg(this, {type: type, msg: msg});
  7611. });
  7612. }
  7613. }
  7614. else {
  7615. me.showMsg(el, {type: type, msg: msg});
  7616. }
  7617. },
  7618. _hidemsg: function(e) {
  7619. var $el = $(e.target);
  7620. if ( $el.is(INPUT_SELECTOR) ) {
  7621. this.hideMsg($el);
  7622. }
  7623. },
  7624. // Validated a field
  7625. _validatedField: function(el, field, ret) {
  7626. var me = this,
  7627. opt = me.options,
  7628. isValid = field.isValid = ret.isValid = !!ret.isValid,
  7629. callback = isValid ? 'valid' : 'invalid';
  7630. ret.key = field.key;
  7631. ret.ruleName = field._r;
  7632. ret.id = el.id;
  7633. ret.value = field.value;
  7634. me.elements[field.key] = ret.element = el;
  7635. me.isValid = me.$el[0].isValid = isValid ? me.isFormValid() : isValid;
  7636. if (isValid) {
  7637. ret.type = 'ok';
  7638. } else {
  7639. if (me.submiting) {
  7640. me.errors[field.key] = ret.msg;
  7641. }
  7642. me.hasError = true;
  7643. }
  7644. // cache result
  7645. field.old = ret;
  7646. // trigger callback
  7647. isFunction(field[callback]) && field[callback].call(me, el, ret);
  7648. isFunction(opt.validation) && opt.validation.call(me, el, ret);
  7649. // trigger event
  7650. $(el).attr( ARIA_INVALID, isValid ? null : true )
  7651. .trigger( callback + CLS_NS_FIELD, [ret, me] );
  7652. me.$el.triggerHandler('validation', [ret, me]);
  7653. if (me.checkOnly) return;
  7654. // set className
  7655. me._setClass(el, ret.skip || ret.type === 'tip' ? null : isValid);
  7656. me._makeMsg.apply(me, arguments);
  7657. },
  7658. _makeMsg: function(el, field, ret) {
  7659. // show or hide the message
  7660. if (field.msgMaker) {
  7661. ret = $.extend({}, ret);
  7662. if (field._e === 'focusin') {
  7663. ret.type = 'tip';
  7664. }
  7665. this[ ret.showOk || ret.msg || ret.type === 'tip' ? 'showMsg' : 'hideMsg' ](el, ret, field);
  7666. }
  7667. },
  7668. // Validated a rule
  7669. _validatedRule: function(el, field, ret, msgOpt) {
  7670. field = field || me.getField(el);
  7671. msgOpt = msgOpt || {};
  7672. var me = this,
  7673. msg,
  7674. rule,
  7675. method = field._r,
  7676. timely = field.timely,
  7677. special = timely === 9 || timely === 8,
  7678. transfer,
  7679. temp,
  7680. isValid = false;
  7681. // use null to break validation from a field
  7682. if (ret === null) {
  7683. me._validatedField(el, field, {isValid: true, skip: true});
  7684. field._i = 0;
  7685. return;
  7686. }
  7687. else if (ret === undefined) {
  7688. transfer = true;
  7689. }
  7690. else if (ret === true || ret === '') {
  7691. isValid = true;
  7692. }
  7693. else if (isString(ret)) {
  7694. msg = ret;
  7695. }
  7696. else if (isObject(ret)) {
  7697. if (ret.error) {
  7698. msg = ret.error;
  7699. } else {
  7700. msg = ret.ok;
  7701. isValid = true;
  7702. }
  7703. }
  7704. else {
  7705. isValid = !!ret
  7706. }
  7707. rule = field._rules[field._i];
  7708. if (rule.not) {
  7709. msg = undefined;
  7710. isValid = method === 'required' || !isValid;
  7711. }
  7712. if (rule.or) {
  7713. if (isValid) {
  7714. while ( field._i < field._rules.length && field._rules[field._i].or ) {
  7715. field._i++;
  7716. }
  7717. } else {
  7718. transfer = true;
  7719. }
  7720. }
  7721. else if (rule.and) {
  7722. if (!field.isValid) transfer = true;
  7723. }
  7724. if (transfer) {
  7725. isValid = true;
  7726. }
  7727. // message analysis, and throw rule level event
  7728. else {
  7729. if (isValid) {
  7730. if (field.showOk !== false) {
  7731. temp = attr(el, DATA_OK);
  7732. msg = temp === null ? isString(field.ok) ? field.ok : msg : temp;
  7733. if (!isString(msg) && isString(field.showOk)) {
  7734. msg = field.showOk;
  7735. }
  7736. if (isString(msg)) {
  7737. msgOpt.showOk = isValid;
  7738. }
  7739. }
  7740. }
  7741. if (!isValid || special) {
  7742. /* rule message priority:
  7743. 1. custom DOM message
  7744. 2. custom field message;
  7745. 3. global defined message;
  7746. 4. rule returned message;
  7747. 5. default message;
  7748. */
  7749. msg = (_getDataMsg(el, field, msg || rule.msg || me.messages[method]) || me.messages.fallback).replace(/\{0\|?([^\}]*)\}/, function(m, defaultDisplay){
  7750. return me._getDisplay(el, field.display) || defaultDisplay || me.messages[0];
  7751. });
  7752. }
  7753. if (!isValid) field.isValid = isValid;
  7754. msgOpt.msg = msg;
  7755. $(el).trigger( (isValid ? 'valid' : 'invalid') + CLS_NS_RULE, [method, msg]);
  7756. }
  7757. if (special && (!transfer || rule.and)) {
  7758. if (!isValid && !field._m) field._m = msg;
  7759. field._v = field._v || [];
  7760. field._v.push({
  7761. type: isValid ? !transfer ? 'ok' : 'tip' : 'error',
  7762. msg: msg || rule.msg
  7763. });
  7764. }
  7765. me._debug('log', ' ' + field._i + ': ' + method + ' => ' + (isValid || msg));
  7766. // the current rule has passed, continue to validate
  7767. if ( (isValid || special) && field._i < field._rules.length - 1) {
  7768. field._i++;
  7769. me._checkRule(el, field);
  7770. }
  7771. // field was invalid, or all fields was valid
  7772. else {
  7773. field._i = 0;
  7774. if (special) {
  7775. msgOpt.isValid = field.isValid;
  7776. msgOpt.result = field._v;
  7777. msgOpt.msg = field._m || '';
  7778. if (!field.value && (field._e === 'focusin')) {
  7779. msgOpt.type = 'tip';
  7780. }
  7781. } else {
  7782. msgOpt.isValid = isValid;
  7783. }
  7784. me._validatedField(el, field, msgOpt);
  7785. delete field._m;
  7786. delete field._v;
  7787. }
  7788. },
  7789. // Verify a rule form a field
  7790. _checkRule: function(el, field) {
  7791. var me = this,
  7792. ret,
  7793. fn,
  7794. old,
  7795. key = field.key,
  7796. rule = field._rules[field._i],
  7797. method = rule.method,
  7798. params = rule.params;
  7799. // request has been sent, wait it
  7800. if (me.submiting && me.deferred[key]) {
  7801. return;
  7802. }
  7803. old = field.old;
  7804. field._r = method;
  7805. if (old && !field.must && !rule.must && rule.result !== undefined &&
  7806. old.ruleName === method && old.id === el.id &&
  7807. field.value && old.value === field.value )
  7808. {
  7809. // get result from cache
  7810. ret = rule.result;
  7811. }
  7812. else {
  7813. // get result from current rule
  7814. fn = _getDataRule(el, method) || me.rules[method] || noop;
  7815. ret = fn.call(field, el, params, field);
  7816. if (fn.msg) rule.msg = fn.msg;
  7817. }
  7818. // asynchronous validation
  7819. if (isObject(ret) && isFunction(ret.then)) {
  7820. me.deferred[key] = ret;
  7821. // whether the field valid is unknown
  7822. field.isValid = undefined;
  7823. // show loading message
  7824. !me.checkOnly && me.showMsg(el, {
  7825. type: 'loading',
  7826. msg: me.messages.loading
  7827. }, field);
  7828. // waiting to parse the response data
  7829. ret.then(
  7830. function(d, textStatus, jqXHR) {
  7831. var data = trim(jqXHR.responseText),
  7832. result,
  7833. dataFilter = field.dataFilter;
  7834. // detect if data is json or jsonp format
  7835. if (/jsonp?/.test(this.dataType)) {
  7836. data = d;
  7837. } else if (data.charAt(0) === '{') {
  7838. data = $.parseJSON(data);
  7839. }
  7840. // filter data
  7841. result = dataFilter.call(this, data, field);
  7842. if (result === undefined) result = dataFilter.call(this, data.data, field);
  7843. rule.data = this.data;
  7844. rule.result = field.old ? result : undefined;
  7845. me._validatedRule(el, field, result);
  7846. },
  7847. function(jqXHR, textStatus){
  7848. me._validatedRule(el, field, me.messages[textStatus] || textStatus);
  7849. }
  7850. ).always(function(){
  7851. delete me.deferred[key];
  7852. });
  7853. }
  7854. // other result
  7855. else {
  7856. me._validatedRule(el, field, ret);
  7857. }
  7858. },
  7859. // Processing the validation
  7860. _validate: function(el, field) {
  7861. var me = this;
  7862. // doesn't validate the element that has "disabled" or "novalidate" attribute
  7863. if ( el.disabled || attr(el, NOVALIDATE) !== null ) {
  7864. return;
  7865. }
  7866. field = field || me.getField(el);
  7867. if (!field) return;
  7868. if (!field._rules) me._parse(el);
  7869. if (!field._rules) return;
  7870. me._debug('info', field.key);
  7871. field.isValid = true;
  7872. field.element = el;
  7873. // Cache the value
  7874. field.value = field.getValue();
  7875. // if the field is not required, and that has a blank value
  7876. if (!field.required && !field.must && !field.value) {
  7877. if (!_checkable(el)) {
  7878. me._validatedField(el, field, {isValid: true});
  7879. return true;
  7880. }
  7881. }
  7882. me._checkRule(el, field);
  7883. return field.isValid;
  7884. },
  7885. _debug: function(type, messages) {
  7886. if (window.console && this.options.debug) {
  7887. console[type](messages);
  7888. }
  7889. },
  7890. /**
  7891. * Detecting whether the value of an element that matches a rule
  7892. *
  7893. * @method test
  7894. * @param {Element} el - input element
  7895. * @param {String} rule - rule name
  7896. */
  7897. test: function(el, rule) {
  7898. var me = this,
  7899. ret,
  7900. parts = rRule.exec(rule),
  7901. field,
  7902. method,
  7903. params;
  7904. if (parts) {
  7905. method = parts[1];
  7906. if (method in me.rules) {
  7907. params = parts[2] || parts[3];
  7908. params = params ? params.split(', ') : undefined;
  7909. field = me.getField(el, true);
  7910. field._r = method;
  7911. field.value = field.getValue();
  7912. ret = me.rules[method].call(field, el, params);
  7913. }
  7914. }
  7915. return ret === true || ret === undefined || ret === null;
  7916. },
  7917. _getDisplay: function(el, str) {
  7918. return !isString(str) ? isFunction(str) ? str.call(this, el) : '' : str;
  7919. },
  7920. _getMsgOpt: function(obj, field) {
  7921. var opt = field ? field : this.options;
  7922. return $.extend({
  7923. type: 'error',
  7924. pos: _getPos(opt.msgClass),
  7925. target: opt.target,
  7926. wrapper: opt.msgWrapper,
  7927. style: opt.msgStyle,
  7928. cls: opt.msgClass,
  7929. arrow: opt.msgArrow,
  7930. icon: opt.msgIcon
  7931. }, isString(obj) ? {msg: obj} : obj);
  7932. },
  7933. _getMsgDOM: function(el, msgOpt) {
  7934. var $el = $(el), $msgbox, datafor, tgt, container;
  7935. if ( $el.is(INPUT_SELECTOR) ) {
  7936. tgt = msgOpt.target || attr(el, DATA_TARGET);
  7937. if (tgt) {
  7938. tgt = !isFunction(tgt) ? tgt.charAt(0) === '#' ? $(tgt) : this.$el.find(tgt) : tgt.call(this, el);
  7939. if (tgt.length) {
  7940. if ( tgt.is(INPUT_SELECTOR) ) {
  7941. $el = tgt
  7942. el = tgt.get(0);
  7943. } else if ( tgt.hasClass(CLS_MSG_BOX) ) {
  7944. $msgbox = tgt;
  7945. } else {
  7946. container = tgt;
  7947. }
  7948. }
  7949. }
  7950. if (!$msgbox) {
  7951. datafor = (!_checkable(el) || !el.name) && el.id ? el.id : el.name;
  7952. $msgbox = (container || this.$el).find(msgOpt.wrapper + '.' + CLS_MSG_BOX + '[for="' + datafor + '"]');
  7953. }
  7954. } else {
  7955. $msgbox = $el;
  7956. }
  7957. // Create new message box
  7958. if (!msgOpt.hide && !$msgbox.length) {
  7959. $msgbox = $('<'+ msgOpt.wrapper + '>').attr({
  7960. 'class': CLS_MSG_BOX + (msgOpt.cls ? ' ' + msgOpt.cls : ''),
  7961. 'style': msgOpt.style || undefined,
  7962. 'for': datafor
  7963. });
  7964. if (container) {
  7965. $msgbox.appendTo(container);
  7966. } else {
  7967. if ( _checkable(el) ) {
  7968. var $parent = $el.parent();
  7969. $msgbox.appendTo( $parent.is('label') ? $parent.parent() : $parent );
  7970. } else {
  7971. $msgbox[!msgOpt.pos || msgOpt.pos === 'right' ? 'insertAfter' : 'insertBefore']($el);
  7972. }
  7973. }
  7974. }
  7975. return $msgbox;
  7976. },
  7977. /**
  7978. * Show validation message
  7979. *
  7980. * @method showMsg
  7981. * @param {Element} el - input element
  7982. * @param {Object} msgOpt
  7983. */
  7984. showMsg: function(el, msgOpt, /*INTERNAL*/ field) {
  7985. if (!el) return;
  7986. var me = this,
  7987. opt = me.options,
  7988. msgShow,
  7989. msgMaker,
  7990. temp,
  7991. $msgbox;
  7992. if (isObject(el) && !el.jquery && !msgOpt) {
  7993. $.each(el, function(key, msg) {
  7994. var el = me.elements[key] || me.$el.find(_key2selector(key))[0];
  7995. me.showMsg(el, msg);
  7996. });
  7997. return;
  7998. }
  7999. if ($(el).is(INPUT_SELECTOR)) {
  8000. field = field || me.getField(el);
  8001. }
  8002. if (!(msgMaker = (field || opt).msgMaker)) {
  8003. return;
  8004. }
  8005. msgOpt = me._getMsgOpt(msgOpt, field);
  8006. el = (el.name && _checkable(el) ? me.$el.find('input[name="'+ el.name +'"]') : $(el)).get(0);
  8007. // ok or tip
  8008. if (!msgOpt.msg && msgOpt.type !== 'error') {
  8009. temp = attr(el, 'data-' + msgOpt.type);
  8010. if (temp !== null) msgOpt.msg = temp;
  8011. }
  8012. if ( !isString(msgOpt.msg) ) {
  8013. return;
  8014. }
  8015. $msgbox = me._getMsgDOM(el, msgOpt);
  8016. !rPos.test($msgbox[0].className) && $msgbox.addClass(msgOpt.cls);
  8017. if ( isIE === 6 && msgOpt.pos === 'bottom' ) {
  8018. $msgbox[0].style.marginTop = $(el).outerHeight() + 'px';
  8019. }
  8020. $msgbox.html( msgMaker.call(me, msgOpt) )[0].style.display = '';
  8021. if (isFunction(msgShow = field && field.msgShow || opt.msgShow)) {
  8022. msgShow.call(me, $msgbox, msgOpt.type);
  8023. }
  8024. },
  8025. /**
  8026. * Hide validation message
  8027. *
  8028. * @method hideMsg
  8029. * @param {Element} el - input element
  8030. * @param {Object} msgOpt optional
  8031. */
  8032. hideMsg: function(el, msgOpt, /*INTERNAL*/ field) {
  8033. var me = this,
  8034. opt = me.options,
  8035. msgHide,
  8036. $msgbox;
  8037. el = $(el).get(0);
  8038. if ($(el).is(INPUT_SELECTOR)) {
  8039. field = field || me.getField(el);
  8040. if (field) {
  8041. if (field.isValid || me.reseting) attr(el, ARIA_INVALID, null);
  8042. }
  8043. }
  8044. msgOpt = me._getMsgOpt(msgOpt, field);
  8045. msgOpt.hide = true;
  8046. $msgbox = me._getMsgDOM(el, msgOpt);
  8047. if (!$msgbox.length) return;
  8048. if ( isFunction(msgHide = field && field.msgHide || opt.msgHide) ) {
  8049. msgHide.call(me, $msgbox, msgOpt.type);
  8050. } else {
  8051. $msgbox[0].style.display = 'none';
  8052. $msgbox[0].innerHTML = '';
  8053. }
  8054. },
  8055. /**
  8056. * Get field information
  8057. *
  8058. * @method getField
  8059. * @param {Element} - input element
  8060. * @return {Object} field
  8061. */
  8062. getField: function(el, must) {
  8063. var me = this,
  8064. key,
  8065. field;
  8066. if (isString(el)) {
  8067. key = el;
  8068. el = undefined;
  8069. } else {
  8070. if (attr(el, DATA_RULE)) {
  8071. return me._parse(el);
  8072. }
  8073. if (el.id && '#' + el.id in me.fields || !el.name) {
  8074. key = '#' + el.id;
  8075. } else {
  8076. key = el.name;
  8077. }
  8078. }
  8079. if ( (field = me.fields[key]) || must && (field = new me.Field(key)) ) {
  8080. field.element = el;
  8081. }
  8082. return field;
  8083. },
  8084. /**
  8085. * Config a field
  8086. *
  8087. * @method: setField
  8088. * @param {String} key
  8089. * @param {Object} obj
  8090. */
  8091. setField: function(key, obj) {
  8092. var fields = {};
  8093. if (!key) return;
  8094. // update this field
  8095. if (isString(key)) {
  8096. fields[key] = obj;
  8097. }
  8098. // update fields
  8099. else {
  8100. fields = key;
  8101. }
  8102. this._initFields(fields);
  8103. },
  8104. /**
  8105. * Detecting whether the form is valid
  8106. *
  8107. * @method isFormValid
  8108. * @return {Boolean}
  8109. */
  8110. isFormValid: function() {
  8111. var fields = this.fields, k, field;
  8112. for (k in fields) {
  8113. field = fields[k];
  8114. if (!field._rules || !field.required && !field.must && !field.value) continue;
  8115. if (!field.isValid) return false;
  8116. }
  8117. return true;
  8118. },
  8119. /**
  8120. * Prevent submission form
  8121. *
  8122. * @method holdSubmit
  8123. * @param {Boolean} hold - If set to false, will release the hold
  8124. */
  8125. holdSubmit: function(hold) {
  8126. this.submiting = hold === undefined || hold;
  8127. },
  8128. /**
  8129. * Clean validation messages
  8130. *
  8131. * @method cleanUp
  8132. */
  8133. cleanUp: function() {
  8134. this._reset(1);
  8135. },
  8136. /**
  8137. * Destroy the validation
  8138. *
  8139. * @method destroy
  8140. */
  8141. destroy: function() {
  8142. this._reset(1);
  8143. this.$el.off(CLS_NS).removeData(NS);
  8144. attr(this.$el[0], NOVALIDATE, this._NOVALIDATE);
  8145. }
  8146. };
  8147. /**
  8148. * Create Field Factory
  8149. *
  8150. * @class
  8151. * @param {Object} context
  8152. * @return {Function} Factory
  8153. */
  8154. function _createFieldFactory(context) {
  8155. function FieldFactory() {
  8156. var options = this.options;
  8157. for (var i in options) {
  8158. if (i in fieldDefaults) this[i] = options[i];
  8159. }
  8160. $.extend(this, {
  8161. _valHook: function() {
  8162. return this.element.contentEditable === 'true' ? 'text' : 'val';
  8163. },
  8164. getValue: function() {
  8165. var elem = this.element;
  8166. if (elem.type === 'number' && elem.validity && elem.validity.badInput) {
  8167. return 'NaN';
  8168. }
  8169. return $(elem)[this._valHook()]();
  8170. },
  8171. setValue: function(value) {
  8172. $(this.element)[this._valHook()](this.value = value);
  8173. },
  8174. // Get a range of validation messages
  8175. getRangeMsg: function(value, params, suffix) {
  8176. if (!params) return;
  8177. var me = this,
  8178. msg = me.messages[me._r] || '',
  8179. result,
  8180. p = params[0].split('~'),
  8181. e = params[1] === 'false',
  8182. a = p[0],
  8183. b = p[1],
  8184. c = 'rg',
  8185. args = [''],
  8186. isNumber = trim(value) && +value === +value;
  8187. function compare(large, small) {
  8188. return !e ? large >= small : large > small;
  8189. }
  8190. if (p.length === 2) {
  8191. if (a && b) {
  8192. if (isNumber && compare(value, +a) && compare(+b, value)) {
  8193. result = true;
  8194. }
  8195. args = args.concat(p);
  8196. c = e ? 'gtlt' : 'rg';
  8197. }
  8198. else if (a && !b) {
  8199. if (isNumber && compare(value, +a)) {
  8200. result = true;
  8201. }
  8202. args.push(a);
  8203. c = e ? 'gt' : 'gte';
  8204. }
  8205. else if (!a && b) {
  8206. if (isNumber && compare(+b, value)) {
  8207. result = true;
  8208. }
  8209. args.push(b);
  8210. c = e ? 'lt' : 'lte';
  8211. }
  8212. }
  8213. else {
  8214. if (value === +a) {
  8215. result = true;
  8216. }
  8217. args.push(a);
  8218. c = 'eq';
  8219. }
  8220. if (msg) {
  8221. if (suffix && msg[c + suffix]) {
  8222. c += suffix;
  8223. }
  8224. args[0] = msg[c];
  8225. }
  8226. return result || me._rules && ( me._rules[me._i].msg = me.renderMsg.apply(null, args) );
  8227. },
  8228. // Render message template
  8229. renderMsg: function() {
  8230. var args = arguments,
  8231. tpl = args[0],
  8232. i = args.length;
  8233. if (!tpl) return;
  8234. while (--i) {
  8235. tpl = tpl.replace('{' + i + '}', args[i]);
  8236. }
  8237. return tpl;
  8238. }
  8239. });
  8240. }
  8241. function Field(key, obj, oldField) {
  8242. this.key = key;
  8243. this.validator = context;
  8244. $.extend(this, oldField, obj);
  8245. }
  8246. FieldFactory.prototype = context;
  8247. Field.prototype = new FieldFactory();
  8248. return Field;
  8249. }
  8250. /**
  8251. * Create Rules
  8252. *
  8253. * @class
  8254. * @param {Object} obj rules
  8255. * @param {Object} context context
  8256. */
  8257. function Rules(obj, context) {
  8258. if (!isObject(obj)) return;
  8259. var k, that = context ? context === true ? this : context : Rules.prototype;
  8260. for (k in obj) {
  8261. if (_checkRuleName(k)) {
  8262. that[k] = _getRule(obj[k]);
  8263. }
  8264. }
  8265. }
  8266. /**
  8267. * Create Messages
  8268. *
  8269. * @class
  8270. * @param {Object} obj rules
  8271. * @param {Object} context context
  8272. */
  8273. function Messages(obj, context) {
  8274. if (!isObject(obj)) return;
  8275. var k, that = context ? context === true ? this : context : Messages.prototype;
  8276. for (k in obj) {
  8277. that[k] = obj[k];
  8278. }
  8279. }
  8280. // Rule converted factory
  8281. function _getRule(fn) {
  8282. switch ($.type(fn)) {
  8283. case 'function':
  8284. return fn;
  8285. case 'array':
  8286. var f = function() {
  8287. return fn[0].test(this.value) || fn[1] || false;
  8288. };
  8289. f.msg = fn[1];
  8290. return f;
  8291. case 'regexp':
  8292. return function() {
  8293. return fn.test(this.value);
  8294. };
  8295. }
  8296. }
  8297. // Get instance by an element
  8298. function _getInstance(el) {
  8299. var wrap, k, options;
  8300. if (!el || !el.tagName) return;
  8301. switch (el.tagName) {
  8302. case 'INPUT':
  8303. case 'SELECT':
  8304. case 'TEXTAREA':
  8305. case 'BUTTON':
  8306. case 'FIELDSET':
  8307. wrap = el.form || $(el).closest('.' + CLS_WRAPPER);
  8308. break;
  8309. case 'FORM':
  8310. wrap = el;
  8311. break;
  8312. default:
  8313. wrap = $(el).closest('.' + CLS_WRAPPER);
  8314. }
  8315. for (k in preinitialized) {
  8316. if ($(wrap).is(k)) {
  8317. options = preinitialized[k];
  8318. break;
  8319. }
  8320. }
  8321. return $(wrap).data(NS) || $(wrap)[NS](options).data(NS);
  8322. }
  8323. // Get custom rules on the node
  8324. function _getDataRule(el, method) {
  8325. var fn = trim(attr(el, DATA_RULE + '-' + method));
  8326. if ( fn && (fn = new Function('return ' + fn)()) ) {
  8327. return _getRule(fn);
  8328. }
  8329. }
  8330. // Get custom messages on the node
  8331. function _getDataMsg(el, field, m) {
  8332. var msg = field.msg,
  8333. item = field._r;
  8334. if ( isObject(msg) ) msg = msg[item];
  8335. if ( !isString(msg) ) {
  8336. msg = attr(el, DATA_MSG + '-' + item) || attr(el, DATA_MSG) || ( m ? isString(m) ? m : m[item] : '');
  8337. }
  8338. return msg;
  8339. }
  8340. // Get message position
  8341. function _getPos(str) {
  8342. var pos;
  8343. if (str) pos = rPos.exec(str);
  8344. return pos && pos[0];
  8345. }
  8346. // Check whether the element is checkbox or radio
  8347. function _checkable(el) {
  8348. return el.tagName === 'INPUT' && el.type === 'checkbox' || el.type === 'radio';
  8349. }
  8350. // Parse date string to timestamp
  8351. function _parseDate(str) {
  8352. return Date.parse(str.replace(/\.|\-/g, '/'));
  8353. }
  8354. // Rule name only allows alphanumeric characters and underscores
  8355. function _checkRuleName(name) {
  8356. return /^\w+$/.test(name);
  8357. }
  8358. // Translate field key to jQuery selector.
  8359. function _key2selector(key) {
  8360. var isID = key.charAt(0) === '#';
  8361. key = key.replace(/([:.{(|)}/\[\]])/g, '\\$1');
  8362. return isID ? key : '[name="'+ key +'"]:first';
  8363. }
  8364. // Fixed a issue cause by refresh page in IE.
  8365. $(window).on('beforeunload', function(){
  8366. this.focus();
  8367. });
  8368. $(document)
  8369. .on('click', ':submit', function(){
  8370. var input = this, attrNode;
  8371. if (!input.form) return;
  8372. // Shim for "formnovalidate"
  8373. attrNode = input.getAttributeNode('formnovalidate');
  8374. if (attrNode && attrNode.nodeValue !== null || attr(input, NOVALIDATE)!== null) {
  8375. novalidateonce = true;
  8376. }
  8377. })
  8378. // Automatic initializing form validation
  8379. .on('focusin submit validate', 'form,.'+CLS_WRAPPER, function(e) {
  8380. if ( attr(this, NOVALIDATE) !== null ) return;
  8381. var $form = $(this), me;
  8382. if ( !$form.data(NS) && (me = _getInstance(this)) ) {
  8383. if ( !$.isEmptyObject(me.fields) ) {
  8384. // Execute event handler
  8385. if (e.type === 'focusin') {
  8386. me._focusin(e);
  8387. } else {
  8388. me._submit(e);
  8389. }
  8390. } else {
  8391. attr(this, NOVALIDATE, NOVALIDATE);
  8392. $form.off(CLS_NS).removeData(NS);
  8393. }
  8394. }
  8395. });
  8396. new Messages({
  8397. fallback: 'This field is not valid.',
  8398. loading: 'Validating...'
  8399. });
  8400. // Built-in rules (global)
  8401. new Rules({
  8402. /**
  8403. * required
  8404. *
  8405. * @example:
  8406. required
  8407. required(jqSelector)
  8408. required(anotherRule)
  8409. required(not, -1)
  8410. required(from, .contact)
  8411. */
  8412. required: function(element, params) {
  8413. var me = this,
  8414. val = trim(me.value),
  8415. isValid = true;
  8416. if (params) {
  8417. if ( params.length === 1 ) {
  8418. if ( !_checkRuleName(params[0]) ) {
  8419. if (!val && !$(params[0], me.$el).length ) {
  8420. return null;
  8421. }
  8422. }
  8423. else if ( me.rules[params[0]] ) {
  8424. if ( !val && !me.test(element, params[0]) ) {
  8425. return null;
  8426. }
  8427. me._r = 'required'
  8428. }
  8429. }
  8430. else if ( params[0] === 'not' ) {
  8431. $.each(params.slice(1), function() {
  8432. return (isValid = val !== trim(this));
  8433. });
  8434. }
  8435. else if ( params[0] === 'from' ) {
  8436. var $elements = me.$el.find(params[1]),
  8437. VALIDATED = '_validated_',
  8438. ret;
  8439. isValid = $elements.filter(function(){
  8440. var field = me.getField(this);
  8441. return field && !!trim(field.getValue());
  8442. }).length >= (params[2] || 1);
  8443. if (isValid) {
  8444. if (!val) ret = null;
  8445. } else {
  8446. ret = _getDataMsg($elements[0], me) || false;
  8447. }
  8448. if ( !$(element).data(VALIDATED) ) {
  8449. $elements.data(VALIDATED, 1).each(function(){
  8450. if (element !== this) {
  8451. me._validate(this);
  8452. }
  8453. }).removeData(VALIDATED);
  8454. }
  8455. return ret;
  8456. }
  8457. }
  8458. return isValid && !!val;
  8459. },
  8460. /**
  8461. * integer
  8462. *
  8463. * @example:
  8464. integer
  8465. integer[+]
  8466. integer[+0]
  8467. integer[-]
  8468. integer[-0]
  8469. */
  8470. integer: function(element, params) {
  8471. var re, z = '0|',
  8472. p = '[1-9]\\d*',
  8473. key = params ? params[0] : '*';
  8474. switch (key) {
  8475. case '+':
  8476. re = p;
  8477. break;
  8478. case '-':
  8479. re = '-' + p;
  8480. break;
  8481. case '+0':
  8482. re = z + p;
  8483. break;
  8484. case '-0':
  8485. re = z + '-' + p;
  8486. break;
  8487. default:
  8488. re = z + '-?' + p;
  8489. }
  8490. re = '^(?:' + re + ')$';
  8491. return new RegExp(re).test(this.value) || (this.messages.integer && this.messages.integer[key]);
  8492. },
  8493. /**
  8494. * match another field
  8495. *
  8496. * @example:
  8497. match[password] Match the password field (two values ​​must be the same)
  8498. match[eq, password] Ditto
  8499. match[neq, count] The value must be not equal to the value of the count field
  8500. match[lt, count] The value must be less than the value of the count field
  8501. match[lte, count] The value must be less than or equal to the value of the count field
  8502. match[gt, count] The value must be greater than the value of the count field
  8503. match[gte, count] The value must be greater than or equal to the value of the count field
  8504. match[gte, startDate, date]
  8505. match[gte, startTime, time]
  8506. **/
  8507. match: function(element, params) {
  8508. if (!params) return;
  8509. var me = this,
  8510. isValid = true,
  8511. a, b,
  8512. key, msg, type = 'eq', parser,
  8513. selector2, elem2, field2;
  8514. if (params.length === 1) {
  8515. key = params[0];
  8516. } else {
  8517. type = params[0];
  8518. key = params[1];
  8519. }
  8520. selector2 = _key2selector(key);
  8521. elem2 = me.$el.find(selector2)[0];
  8522. // If the compared field is not exist
  8523. if (!elem2) return;
  8524. field2 = me.getField(elem2);
  8525. a = me.value;
  8526. b = field2.getValue();
  8527. if (!me._match) {
  8528. me.$el.on('valid'+CLS_NS_FIELD+CLS_NS, selector2, function(){
  8529. $(element).trigger('validate');
  8530. });
  8531. me._match = field2._match = 1;
  8532. }
  8533. // If both fields are blank
  8534. if (!me.required && a === '' && b === '') {
  8535. return null;
  8536. }
  8537. parser = params[2];
  8538. if (parser) {
  8539. if (/^date(time)?$/i.test(parser)) {
  8540. a = _parseDate(a);
  8541. b = _parseDate(b);
  8542. } else if (parser === 'time') {
  8543. a = +a.replace(/:/g, '');
  8544. b = +b.replace(/:/g, '');
  8545. }
  8546. }
  8547. // If the compared field is incorrect, we only ensure that this field is correct.
  8548. if (type !== 'eq' && !isNaN(+a) && isNaN(+b)) {
  8549. return true;
  8550. }
  8551. switch (type) {
  8552. case 'lt':
  8553. isValid = +a < +b; break;
  8554. case 'lte':
  8555. isValid = +a <= +b; break;
  8556. case 'gte':
  8557. isValid = +a >= +b; break;
  8558. case 'gt':
  8559. isValid = +a > +b; break;
  8560. case 'neq':
  8561. isValid = a !== b; break;
  8562. default:
  8563. isValid = a === b;
  8564. }
  8565. return isValid || (
  8566. isObject(me.messages.match)
  8567. && me.messages.match[type].replace( '{1}', me._getDisplay( elem2, field2.display || key ) )
  8568. );
  8569. },
  8570. /**
  8571. * range numbers
  8572. *
  8573. * @example:
  8574. range[0~99] Number 0-99
  8575. range[0~] Number greater than or equal to 0
  8576. range[~100] Number less than or equal to 100
  8577. **/
  8578. range: function(element, params) {
  8579. return this.getRangeMsg(this.value, params);
  8580. },
  8581. /**
  8582. * how many checkbox or radio inputs that checked
  8583. *
  8584. * @example:
  8585. checked; no empty, same to required
  8586. checked[1~3] 1-3 items
  8587. checked[1~] greater than 1 item
  8588. checked[~3] less than 3 items
  8589. checked[3] 3 items
  8590. **/
  8591. checked: function(element, params) {
  8592. if ( !_checkable(element) ) return;
  8593. var me = this,
  8594. elem, count;
  8595. if (element.name) {
  8596. count = me.$el.find('input[name="' + element.name + '"]').filter(function() {
  8597. var el = this;
  8598. if (!elem && _checkable(el)) elem = el;
  8599. return !el.disabled && el.checked;
  8600. }).length;
  8601. } else {
  8602. elem = element;
  8603. count = elem.checked;
  8604. }
  8605. if (params) {
  8606. return me.getRangeMsg(count, params);
  8607. } else {
  8608. return !!count || _getDataMsg(elem, me, '') || me.messages.required || false;
  8609. }
  8610. },
  8611. /**
  8612. * length of a characters (You can pass the second parameter "true", will calculate the length in bytes)
  8613. *
  8614. * @example:
  8615. length[6~16] 6-16 characters
  8616. length[6~] Greater than 6 characters
  8617. length[~16] Less than 16 characters
  8618. length[~16, true] Less than 16 characters, non-ASCII characters calculating two-character
  8619. **/
  8620. length: function(element, params) {
  8621. var value = this.value,
  8622. len = (params[1] === 'true' ? value.replace(rDoubleBytes, 'xx') : value).length;
  8623. return this.getRangeMsg(len, params, (params[1] ? '_2' : ''));
  8624. },
  8625. /**
  8626. * remote validation
  8627. *
  8628. * @description
  8629. * remote([get:]url [, name1, [name2 ...]]);
  8630. * Adaptation three kinds of results (Front for the successful, followed by a failure):
  8631. 1. text:
  8632. '' 'Error Message'
  8633. 2. json:
  8634. {"ok": ""} {"error": "Error Message"}
  8635. 3. json wrapper:
  8636. {"status": 1, "data": {"ok": ""}} {"status": 1, "data": {"error": "Error Message"}}
  8637. * @example
  8638. The simplest: remote(path/to/server);
  8639. With parameters: remote(path/to/server, name1, name2, ...);
  8640. By GET: remote(get:path/to/server, name1, name2, ...);
  8641. Name proxy: remote(path/to/server, name1, proxyname2:name2, proxyname3:#id3, ...)
  8642. Query String remote(path/to/server, foo=1&bar=2, name1, name2, ...)
  8643. CORS remote(cors:path/to/server)
  8644. JSONP remote(jsonp:path/to/server)
  8645. */
  8646. remote: function(element, params) {
  8647. if (!params) return;
  8648. var me = this,
  8649. arr = rAjaxType.exec(params[0]),
  8650. rule = me._rules[me._i],
  8651. data = {},
  8652. queryString = '',
  8653. url = arr[3],
  8654. type = arr[2] || 'POST', // GET / POST
  8655. rType = (arr[1]||'').toLowerCase(), // CORS / JSONP
  8656. dataType;
  8657. rule.must = true;
  8658. data[element.name] = me.value;
  8659. // There are extra fields
  8660. if (params[1]) {
  8661. $.map(params.slice(1), function(name) {
  8662. var arr, key;
  8663. if (~name.indexOf('=')) {
  8664. queryString += '&' + name;
  8665. } else {
  8666. arr = name.split(':');
  8667. name = trim(arr[0]);
  8668. key = trim(arr[1]) || name;
  8669. data[ name ] = me.$el.find( _key2selector(key) ).val();
  8670. }
  8671. });
  8672. }
  8673. data = $.param(data) + queryString;
  8674. if (!me.must && rule.data && rule.data === data) {
  8675. return rule.result;
  8676. }
  8677. // Cross-domain request, force jsonp dataType
  8678. if (rType !== 'cors' && /^https?:/.test(url) && !~url.indexOf(location.host)) {
  8679. dataType = 'jsonp';
  8680. }
  8681. // Asynchronous validation need return jqXHR objects
  8682. return $.ajax({
  8683. url: url,
  8684. type: type,
  8685. data: data,
  8686. dataType: dataType
  8687. });
  8688. },
  8689. /**
  8690. * filter characters, direct filtration without prompting error (support custom regular expressions)
  8691. *
  8692. * @example
  8693. * filter filtering unsafe characters
  8694. * filter(regexp) filtering the "regexp" matched characters
  8695. */
  8696. filter: function(element, params) {
  8697. var value = this.value,
  8698. temp = value.replace( params ? (new RegExp('[' + params[0] + ']', 'gm')) : rUnsafe, '' );
  8699. if (temp !== value) this.setValue(temp);
  8700. }
  8701. });
  8702. /**
  8703. * Config global options
  8704. *
  8705. * @static config
  8706. * @param {Object} options
  8707. */
  8708. Validator.config = function(key, value) {
  8709. if (isObject(key)) {
  8710. $.each(key, _config);
  8711. }
  8712. else if (isString(key)) {
  8713. _config(key, value);
  8714. }
  8715. function _config(k, o) {
  8716. if (k === 'rules') {
  8717. new Rules(o);
  8718. }
  8719. else if (k === 'messages') {
  8720. new Messages(o);
  8721. }
  8722. else if (k in fieldDefaults) {
  8723. fieldDefaults[k] = o;
  8724. }
  8725. else {
  8726. defaults[k] = o;
  8727. }
  8728. }
  8729. };
  8730. /**
  8731. * Config themes
  8732. *
  8733. * @static setTheme
  8734. * @param {String|Object} name
  8735. * @param {Object} obj
  8736. * @example
  8737. .setTheme( themeName, themeOptions )
  8738. .setTheme( multiThemes )
  8739. */
  8740. Validator.setTheme = function(name, obj) {
  8741. if ( isObject(name) ) {
  8742. $.extend(true, themes, name);
  8743. }
  8744. else if ( isString(name) && isObject(obj) ) {
  8745. themes[name] = $.extend(themes[name], obj);
  8746. }
  8747. };
  8748. /**
  8749. * Resource loader
  8750. *
  8751. * @static load
  8752. * @param {String} str
  8753. * @example
  8754. .load('local=zh-CN') // load: local/zh-CN.js and jquery.validator.css
  8755. .load('local=zh-CN&css=') // load: local/zh-CN.js
  8756. .load('local&css') // load: local/en.js (set <html lang="en">) and jquery.validator.css
  8757. .load('local') // dito
  8758. */
  8759. Validator.load = function(str) {
  8760. if (!str) return;
  8761. var doc = document,
  8762. params = {},
  8763. node = doc.scripts[0],
  8764. dir, el, ONLOAD;
  8765. str.replace(/([^?=&]+)=([^&#]*)/g, function(m, key, value){
  8766. params[key] = value;
  8767. });
  8768. dir = params.dir || Validator.dir;
  8769. if (!Validator.css && params.css !== '') {
  8770. el = doc.createElement('link');
  8771. el.rel = 'stylesheet';
  8772. el.href = Validator.css = dir + 'jquery.validator.css';
  8773. node.parentNode.insertBefore(el, node);
  8774. }
  8775. if (!Validator.local && ~str.indexOf('local') && params.local !== '') {
  8776. Validator.local = (params.local || doc.documentElement.lang || 'en').replace('_','-');
  8777. Validator.pending = 1;
  8778. el = doc.createElement('script');
  8779. el.src = dir + 'local/' + Validator.local + '.js';
  8780. ONLOAD = 'onload' in el ? 'onload' : 'onreadystatechange';
  8781. el[ONLOAD] = function() {
  8782. if (!el.readyState || /loaded|complete/.test(el.readyState)) {
  8783. el = el[ONLOAD] = null;
  8784. delete Validator.pending;
  8785. $(window).triggerHandler('validatorready');
  8786. }
  8787. };
  8788. node.parentNode.insertBefore(el, node);
  8789. }
  8790. };
  8791. // Auto loading resources
  8792. (function(){
  8793. var scripts = document.scripts,
  8794. i = scripts.length, node, arr,
  8795. re = /(.*validator(?:\.min)?.js)(\?.*(?:local|css|dir)(?:=[\w\-]*)?)?/;
  8796. while (i-- && !arr) {
  8797. node = scripts[i];
  8798. arr = (node.hasAttribute ? node.src : node.getAttribute('src',4)||'').match(re);
  8799. }
  8800. if (!arr) return;
  8801. Validator.dir = arr[1].split('/').slice(0, -1).join('/')+'/';
  8802. Validator.load(arr[2]);
  8803. })();
  8804. return $[NS] = Validator;
  8805. }));
  8806. /*********************************
  8807. * Themes, rules, and i18n support
  8808. * Locale: Chinese; 中文
  8809. *********************************/
  8810. (function(factory) {
  8811. typeof module === "object" && module.exports ? module.exports = factory( require( "jquery" ) ) :
  8812. typeof define === 'function' && define.amd ? define('validator-lang',['jquery'], factory) :
  8813. factory(jQuery);
  8814. }(function($) {
  8815. /* Global configuration
  8816. */
  8817. $.validator.config({
  8818. //stopOnError: true,
  8819. //focusCleanup: true,
  8820. //theme: 'yellow_right',
  8821. //timely: 2,
  8822. // Custom rules
  8823. rules: {
  8824. digits: [/^\d+$/, "请填写数字"]
  8825. ,letters: [/^[a-z]+$/i, "请填写字母"]
  8826. ,date: [/^\d{4}-\d{2}-\d{2}$/, "请填写有效的日期,格式:yyyy-mm-dd"]
  8827. ,time: [/^([01]\d|2[0-3])(:[0-5]\d){1,2}$/, "请填写有效的时间,00:00到23:59之间"]
  8828. ,email: [/^[\w\+\-]+(\.[\w\+\-]+)*@[a-z\d\-]+(\.[a-z\d\-]+)*\.([a-z]{2,4})$/i, "请填写有效的邮箱"]
  8829. ,url: [/^(https?|s?ftp):\/\/\S+$/i, "请填写有效的网址"]
  8830. ,qq: [/^[1-9]\d{4,}$/, "请填写有效的QQ号"]
  8831. ,IDcard: [/^\d{6}(19|2\d)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)?$/, "请填写正确的身份证号码"]
  8832. ,tel: [/^(?:(?:0\d{2,3}[\- ]?[1-9]\d{6,7})|(?:[48]00[\- ]?[1-9]\d{6}))$/, "请填写有效的电话号码"]
  8833. ,mobile: [/^1[3-9]\d{9}$/, "请填写有效的手机号"]
  8834. ,zipcode: [/^\d{6}$/, "请检查邮政编码格式"]
  8835. ,chinese: [/^[\u0391-\uFFE5]+$/, "请填写中文字符"]
  8836. ,username: [/^\w{3,12}$/, "请填写3-12位数字、字母、下划线"]
  8837. ,password: [/^[\S]{6,16}$/, "请填写6-16位字符,不能包含空格"]
  8838. ,accept: function (element, params){
  8839. if (!params) return true;
  8840. var ext = params[0],
  8841. value = $(element).val();
  8842. return (ext === '*') ||
  8843. (new RegExp(".(?:" + ext + ")$", "i")).test(value) ||
  8844. this.renderMsg("只接受{1}后缀的文件", ext.replace(/\|/g, ','));
  8845. }
  8846. },
  8847. // Default error messages
  8848. messages: {
  8849. 0: "此处",
  8850. fallback: "{0}格式不正确",
  8851. loading: "正在验证...",
  8852. error: "网络异常",
  8853. timeout: "请求超时",
  8854. required: "{0}不能为空",
  8855. remote: "{0}已被使用",
  8856. integer: {
  8857. '*': "请填写整数",
  8858. '+': "请填写正整数",
  8859. '+0': "请填写正整数或0",
  8860. '-': "请填写负整数",
  8861. '-0': "请填写负整数或0"
  8862. },
  8863. match: {
  8864. eq: "{0}与{1}不一致",
  8865. neq: "{0}与{1}不能相同",
  8866. lt: "{0}必须小于{1}",
  8867. gt: "{0}必须大于{1}",
  8868. lte: "{0}不能大于{1}",
  8869. gte: "{0}不能小于{1}"
  8870. },
  8871. range: {
  8872. rg: "请填写{1}到{2}的数",
  8873. gte: "请填写不小于{1}的数",
  8874. lte: "请填写最大{1}的数",
  8875. gtlt: "请填写{1}到{2}之间的数",
  8876. gt: "请填写大于{1}的数",
  8877. lt: "请填写小于{1}的数"
  8878. },
  8879. checked: {
  8880. eq: "请选择{1}项",
  8881. rg: "请选择{1}到{2}项",
  8882. gte: "请至少选择{1}项",
  8883. lte: "请最多选择{1}项"
  8884. },
  8885. length: {
  8886. eq: "请填写{1}个字符",
  8887. rg: "请填写{1}到{2}个字符",
  8888. gte: "请至少填写{1}个字符",
  8889. lte: "请最多填写{1}个字符",
  8890. eq_2: "",
  8891. rg_2: "",
  8892. gte_2: "",
  8893. lte_2: ""
  8894. }
  8895. }
  8896. });
  8897. /* Themes
  8898. */
  8899. var TPL_ARROW = '<span class="n-arrow"><b>◆</b><i>◆</i></span>';
  8900. $.validator.setTheme({
  8901. 'simple_right': {
  8902. formClass: 'n-simple',
  8903. msgClass: 'n-right'
  8904. },
  8905. 'simple_bottom': {
  8906. formClass: 'n-simple',
  8907. msgClass: 'n-bottom'
  8908. },
  8909. 'yellow_top': {
  8910. formClass: 'n-yellow',
  8911. msgClass: 'n-top',
  8912. msgArrow: TPL_ARROW
  8913. },
  8914. 'yellow_right': {
  8915. formClass: 'n-yellow',
  8916. msgClass: 'n-right',
  8917. msgArrow: TPL_ARROW
  8918. },
  8919. 'yellow_right_effect': {
  8920. formClass: 'n-yellow',
  8921. msgClass: 'n-right',
  8922. msgArrow: TPL_ARROW,
  8923. msgShow: function($msgbox, type){
  8924. var $el = $msgbox.children();
  8925. if ($el.is(':animated')) return;
  8926. if (type === 'error') {
  8927. $el.css({left: '20px', opacity: 0})
  8928. .delay(100).show().stop()
  8929. .animate({left: '-4px', opacity: 1}, 150)
  8930. .animate({left: '3px'}, 80)
  8931. .animate({left: 0}, 80);
  8932. } else {
  8933. $el.css({left: 0, opacity: 1}).fadeIn(200);
  8934. }
  8935. },
  8936. msgHide: function($msgbox, type){
  8937. var $el = $msgbox.children();
  8938. $el.stop().delay(100).show()
  8939. .animate({left: '20px', opacity: 0}, 300, function(){
  8940. $msgbox.hide();
  8941. });
  8942. }
  8943. }
  8944. });
  8945. }));
  8946. define('form',['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], function ($, undefined, Upload, Validator, undefined) {
  8947. var Form = {
  8948. config: {
  8949. 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>'
  8950. },
  8951. events: {
  8952. validator: function (form, success, error, submit) {
  8953. if (!form.is("form"))
  8954. return;
  8955. //绑定表单事件
  8956. form.validator($.extend({
  8957. rules: {
  8958. username: [/^\w{3,30}$/, __('Username must be 3 to 30 characters')],
  8959. password: [/^[\S]{6,30}$/, __('Password must be 6 to 30 characters')]
  8960. },
  8961. validClass: 'has-success',
  8962. invalidClass: 'has-error',
  8963. bindClassTo: '.form-group',
  8964. formClass: 'n-default n-bootstrap',
  8965. msgClass: 'n-right',
  8966. stopOnError: true,
  8967. display: function (elem) {
  8968. return $(elem).closest('.form-group').find(".control-label").text().replace(/\:/, '');
  8969. },
  8970. dataFilter: function (data) {
  8971. if (data.code === 1) {
  8972. return data.msg ? {"ok": data.msg} : '';
  8973. } else {
  8974. return data.msg;
  8975. }
  8976. },
  8977. target: function (input) {
  8978. var target = $(input).data("target");
  8979. if (target && $(target).length > 0) {
  8980. return $(target);
  8981. }
  8982. var $formitem = $(input).closest('.form-group'),
  8983. $msgbox = $formitem.find('span.msg-box');
  8984. if (!$msgbox.length) {
  8985. return [];
  8986. }
  8987. return $msgbox;
  8988. },
  8989. valid: function (ret) {
  8990. var that = this, submitBtn = $(".layer-footer [type=submit]", form);
  8991. that.holdSubmit(true);
  8992. submitBtn.addClass("disabled");
  8993. //验证通过提交表单
  8994. var submitResult = Form.api.submit($(ret), function (data, ret) {
  8995. that.holdSubmit(false);
  8996. submitBtn.removeClass("disabled");
  8997. if (false === $(this).triggerHandler("success.form", [data, ret])) {
  8998. return false;
  8999. }
  9000. if (typeof success === 'function') {
  9001. if (false === success.call($(this), data, ret)) {
  9002. return false;
  9003. }
  9004. }
  9005. //提示及关闭当前窗口
  9006. var msg = ret.hasOwnProperty("msg") && ret.msg !== "" ? ret.msg : __('Operation completed');
  9007. parent.Toastr.success(msg);
  9008. parent.$(".btn-refresh").trigger("click");
  9009. if (window.name) {
  9010. var index = parent.Layer.getFrameIndex(window.name);
  9011. parent.Layer.close(index);
  9012. }
  9013. return false;
  9014. }, function (data, ret) {
  9015. that.holdSubmit(false);
  9016. if (false === $(this).triggerHandler("error.form", [data, ret])) {
  9017. return false;
  9018. }
  9019. submitBtn.removeClass("disabled");
  9020. if (typeof error === 'function') {
  9021. if (false === error.call($(this), data, ret)) {
  9022. return false;
  9023. }
  9024. }
  9025. }, submit);
  9026. //如果提交失败则释放锁定
  9027. if (!submitResult) {
  9028. that.holdSubmit(false);
  9029. submitBtn.removeClass("disabled");
  9030. }
  9031. return false;
  9032. }
  9033. }, form.data("validator-options") || {}));
  9034. //移除提交按钮的disabled类
  9035. $(".layer-footer [type=submit],.fixed-footer [type=submit],.normal-footer [type=submit]", form).removeClass("disabled");
  9036. //自定义关闭按钮事件
  9037. form.on("click", ".layer-close", function () {
  9038. if (window.name) {
  9039. var index = parent.Layer.getFrameIndex(window.name);
  9040. parent.Layer.close(index);
  9041. }
  9042. return false;
  9043. });
  9044. },
  9045. selectpicker: function (form) {
  9046. //绑定select元素事件
  9047. if ($(".selectpicker", form).length > 0) {
  9048. require(['bootstrap-select', 'bootstrap-select-lang'], function () {
  9049. $.fn.selectpicker.Constructor.BootstrapVersion = '3';
  9050. $('.selectpicker', form).selectpicker();
  9051. $(form).on("reset", function () {
  9052. setTimeout(function () {
  9053. $('.selectpicker').selectpicker('refresh').trigger("change");
  9054. }, 1);
  9055. });
  9056. });
  9057. }
  9058. },
  9059. selectpage: function (form) {
  9060. //绑定selectpage元素事件
  9061. if ($(".selectpage", form).length > 0) {
  9062. require(['selectpage'], function () {
  9063. $('.selectpage', form).selectPage({
  9064. eAjaxSuccess: function (data) {
  9065. data.list = typeof data.rows !== 'undefined' ? data.rows : (typeof data.list !== 'undefined' ? data.list : []);
  9066. data.totalRow = typeof data.total !== 'undefined' ? data.total : (typeof data.totalRow !== 'undefined' ? data.totalRow : data.list.length);
  9067. return data;
  9068. }
  9069. });
  9070. });
  9071. //给隐藏的元素添加上validate验证触发事件
  9072. $(document).on("change", ".sp_hidden", function () {
  9073. $(this).trigger("validate");
  9074. });
  9075. $(document).on("change", ".sp_input", function () {
  9076. $(this).closest(".sp_container").find(".sp_hidden").trigger("change");
  9077. });
  9078. $(form).on("reset", function () {
  9079. setTimeout(function () {
  9080. $('.selectpage', form).selectPageClear();
  9081. }, 1);
  9082. });
  9083. }
  9084. },
  9085. cxselect: function (form) {
  9086. //绑定cxselect元素事件
  9087. if ($("[data-toggle='cxselect']", form).length > 0) {
  9088. require(['cxselect'], function () {
  9089. $.cxSelect.defaults.jsonName = 'name';
  9090. $.cxSelect.defaults.jsonValue = 'value';
  9091. $.cxSelect.defaults.jsonSpace = 'data';
  9092. $("[data-toggle='cxselect']", form).cxSelect();
  9093. });
  9094. }
  9095. },
  9096. citypicker: function (form) {
  9097. //绑定城市远程插件
  9098. if ($("[data-toggle='city-picker']", form).length > 0) {
  9099. require(['citypicker'], function () {
  9100. $(form).on("reset", function () {
  9101. setTimeout(function () {
  9102. $("[data-toggle='city-picker']").citypicker('refresh');
  9103. }, 1);
  9104. });
  9105. });
  9106. }
  9107. },
  9108. datetimepicker: function (form) {
  9109. //绑定日期时间元素事件
  9110. if ($(".datetimepicker", form).length > 0) {
  9111. require(['bootstrap-datetimepicker'], function () {
  9112. var options = {
  9113. format: 'YYYY-MM-DD HH:mm:ss',
  9114. icons: {
  9115. time: 'fa fa-clock-o',
  9116. date: 'fa fa-calendar',
  9117. up: 'fa fa-chevron-up',
  9118. down: 'fa fa-chevron-down',
  9119. previous: 'fa fa-chevron-left',
  9120. next: 'fa fa-chevron-right',
  9121. today: 'fa fa-history',
  9122. clear: 'fa fa-trash',
  9123. close: 'fa fa-remove'
  9124. },
  9125. showTodayButton: true,
  9126. showClose: true
  9127. };
  9128. $('.datetimepicker', form).parent().css('position', 'relative');
  9129. $('.datetimepicker', form).datetimepicker(options).on('dp.change', function (e) {
  9130. $(this, document).trigger("changed");
  9131. });
  9132. });
  9133. }
  9134. },
  9135. daterangepicker: function (form) {
  9136. //绑定日期时间元素事件
  9137. if ($(".datetimerange", form).length > 0) {
  9138. require(['bootstrap-daterangepicker'], function () {
  9139. var ranges = {};
  9140. ranges[__('Today')] = [Moment().startOf('day'), Moment().endOf('day')];
  9141. ranges[__('Yesterday')] = [Moment().subtract(1, 'days').startOf('day'), Moment().subtract(1, 'days').endOf('day')];
  9142. ranges[__('Last 7 Days')] = [Moment().subtract(6, 'days').startOf('day'), Moment().endOf('day')];
  9143. ranges[__('Last 30 Days')] = [Moment().subtract(29, 'days').startOf('day'), Moment().endOf('day')];
  9144. ranges[__('This Month')] = [Moment().startOf('month'), Moment().endOf('month')];
  9145. ranges[__('Last Month')] = [Moment().subtract(1, 'month').startOf('month'), Moment().subtract(1, 'month').endOf('month')];
  9146. var options = {
  9147. timePicker: false,
  9148. autoUpdateInput: false,
  9149. timePickerSeconds: true,
  9150. timePicker24Hour: true,
  9151. autoApply: true,
  9152. locale: {
  9153. format: 'YYYY-MM-DD HH:mm:ss',
  9154. customRangeLabel: __("Custom Range"),
  9155. applyLabel: __("Apply"),
  9156. cancelLabel: __("Clear"),
  9157. },
  9158. ranges: ranges,
  9159. };
  9160. var origincallback = function (start, end) {
  9161. $(this.element).val(start.format(this.locale.format) + " - " + end.format(this.locale.format));
  9162. $(this.element).trigger('change');
  9163. };
  9164. $(".datetimerange", form).each(function () {
  9165. var callback = typeof $(this).data('callback') == 'function' ? $(this).data('callback') : origincallback;
  9166. $(this).on('apply.daterangepicker', function (ev, picker) {
  9167. callback.call(picker, picker.startDate, picker.endDate);
  9168. });
  9169. $(this).on('cancel.daterangepicker', function (ev, picker) {
  9170. $(this).val('').trigger('change');
  9171. });
  9172. $(this).daterangepicker($.extend(true, options, $(this).data() || {}, $(this).data("daterangepicker-options") || {}));
  9173. });
  9174. });
  9175. }
  9176. },
  9177. /**
  9178. * 绑定上传事件
  9179. * @param form
  9180. * @deprecated Use faupload instead.
  9181. */
  9182. plupload: function (form) {
  9183. Form.events.faupload(form);
  9184. },
  9185. /**
  9186. * 绑定上传事件
  9187. * @param form
  9188. */
  9189. faupload: function (form) {
  9190. //绑定上传元素事件
  9191. if ($(".plupload,.faupload", form).length > 0) {
  9192. Upload.api.upload($(".plupload,.faupload", form));
  9193. }
  9194. },
  9195. faselect: function (form) {
  9196. //绑定fachoose选择附件事件
  9197. if ($(".faselect,.fachoose", form).length > 0) {
  9198. $(".faselect,.fachoose", form).off('click').on('click', function () {
  9199. var that = this;
  9200. var multiple = $(this).data("multiple") ? $(this).data("multiple") : false;
  9201. var mimetype = $(this).data("mimetype") ? $(this).data("mimetype") : '';
  9202. var admin_id = $(this).data("admin-id") ? $(this).data("admin-id") : '';
  9203. var user_id = $(this).data("user-id") ? $(this).data("user-id") : '';
  9204. mimetype = mimetype.replace(/\/\*/ig, '/');
  9205. var url = $(this).data("url") ? $(this).data("url") : (typeof Backend !== 'undefined' ? "general/attachment/select" : "user/attachment");
  9206. parent.Fast.api.open(url + "?element_id=" + $(this).attr("id") + "&multiple=" + multiple + "&mimetype=" + mimetype + "&admin_id=" + admin_id + "&user_id=" + user_id, __('Choose'), {
  9207. callback: function (data) {
  9208. var button = $("#" + $(that).attr("id"));
  9209. var maxcount = $(button).data("maxcount");
  9210. var input_id = $(button).data("input-id") ? $(button).data("input-id") : "";
  9211. maxcount = typeof maxcount !== "undefined" ? maxcount : 0;
  9212. if (input_id && data.multiple) {
  9213. var urlArr = [];
  9214. var inputObj = $("#" + input_id);
  9215. var value = $.trim(inputObj.val());
  9216. if (value !== "") {
  9217. urlArr.push(inputObj.val());
  9218. }
  9219. var nums = value === '' ? 0 : value.split(/\,/).length;
  9220. var files = data.url !== "" ? data.url.split(/\,/) : [];
  9221. $.each(files, function (i, j) {
  9222. var url = Config.upload.fullmode ? Fast.api.cdnurl(j) : j;
  9223. urlArr.push(url);
  9224. });
  9225. if (maxcount > 0) {
  9226. var remains = maxcount - nums;
  9227. if (files.length > remains) {
  9228. Toastr.error(__('You can choose up to %d file%s', remains));
  9229. return false;
  9230. }
  9231. }
  9232. var result = urlArr.join(",");
  9233. inputObj.val(result).trigger("change").trigger("validate");
  9234. } else if (input_id) {
  9235. var url = Config.upload.fullmode ? Fast.api.cdnurl(data.url) : data.url;
  9236. $("#" + input_id).val(url).trigger("change").trigger("validate");
  9237. }
  9238. }
  9239. });
  9240. return false;
  9241. });
  9242. }
  9243. },
  9244. fieldlist: function (form) {
  9245. //绑定fieldlist
  9246. if ($(".fieldlist", form).length > 0) {
  9247. require(['dragsort', 'template'], function (undefined, Template) {
  9248. //刷新隐藏textarea的值
  9249. var refresh = function (container) {
  9250. var data = {};
  9251. var name = container.data("name");
  9252. var textarea = $("textarea[name='" + name + "']", form);
  9253. var template = container.data("template");
  9254. $.each($("input,select,textarea", container).serializeArray(), function (i, j) {
  9255. var reg = /\[(\w+)\]\[(\w+)\]$/g;
  9256. var match = reg.exec(j.name);
  9257. if (!match)
  9258. return true;
  9259. match[1] = "x" + parseInt(match[1]);
  9260. if (typeof data[match[1]] == 'undefined') {
  9261. data[match[1]] = {};
  9262. }
  9263. data[match[1]][match[2]] = j.value;
  9264. });
  9265. var result = template ? [] : {};
  9266. $.each(data, function (i, j) {
  9267. if (j) {
  9268. if (!template) {
  9269. if (j.key !== '') {
  9270. result['__PLACEHOLDKEY__' + j.key] = j.value;
  9271. }
  9272. } else {
  9273. result.push(j);
  9274. }
  9275. }
  9276. });
  9277. textarea.val(JSON.stringify(result).replace(/__PLACEHOLDKEY__/g, ''));
  9278. };
  9279. //追加一行数据
  9280. var append = function (container, row, initial) {
  9281. var tagName = container.data("tag") || (container.is("table") ? "tr" : "dd");
  9282. var index = container.data("index");
  9283. var name = container.data("name");
  9284. var template = container.data("template");
  9285. var data = container.data();
  9286. index = index ? parseInt(index) : 0;
  9287. container.data("index", index + 1);
  9288. row = row ? row : {};
  9289. row = typeof row.key === 'undefined' || typeof row.value === 'undefined' ? {key: '', value: row} : row;
  9290. var options = container.data("fieldlist-options") || {};
  9291. var vars = {index: index, name: name, data: data, options: options, key: row.key, value: row.value, row: row.value};
  9292. var html = template ? Template(template, vars) : Template.render(Form.config.fieldlisttpl, vars);
  9293. var obj = $(html);
  9294. if ((options.deleteBtn === false || options.removeBtn === false) && initial)
  9295. obj.find(".btn-remove").remove();
  9296. if (options.dragsortBtn === false && initial)
  9297. obj.find(".btn-dragsort").remove();
  9298. if ((options.readonlyKey === true || options.disableKey === true) && initial) {
  9299. obj.find("input[name$='[key]']").prop("readonly", true);
  9300. }
  9301. obj.attr("fieldlist-item", true);
  9302. obj.insertAfter($(tagName + "[fieldlist-item]", container).length > 0 ? $(tagName + "[fieldlist-item]:last", container) : $(tagName + ":first", container));
  9303. if ($(".btn-append,.append", container).length > 0) {
  9304. //兼容旧版本事件
  9305. $(".btn-append,.append", container).trigger("fa.event.appendfieldlist", obj);
  9306. } else {
  9307. //新版本事件
  9308. container.trigger("fa.event.appendfieldlist", obj);
  9309. }
  9310. return obj;
  9311. };
  9312. var fieldlist = $(".fieldlist", form);
  9313. //监听文本框改变事件
  9314. $(document).on('change keyup changed', ".fieldlist input,.fieldlist textarea,.fieldlist select", function () {
  9315. var container = $(this).closest(".fieldlist");
  9316. refresh(container);
  9317. });
  9318. //追加控制(点击按钮)
  9319. fieldlist.on("click", ".btn-append,.append", function (e, row) {
  9320. var container = $(this).closest(".fieldlist");
  9321. append(container, row);
  9322. // refresh(container);
  9323. });
  9324. //移除控制(点击按钮)
  9325. fieldlist.on("click", ".btn-remove", function () {
  9326. var container = $(this).closest(".fieldlist");
  9327. var tagName = container.data("tag") || (container.is("table") ? "tr" : "dd");
  9328. $(this).closest(tagName).remove();
  9329. refresh(container);
  9330. });
  9331. //追加控制(通过事件)
  9332. fieldlist.on("fa.event.appendtofieldlist", function (e, row) {
  9333. var container = $(this);
  9334. append(container, row);
  9335. refresh(container);
  9336. });
  9337. //根据textarea内容重新渲染
  9338. fieldlist.on("fa.event.refreshfieldlist", function () {
  9339. var container = $(this);
  9340. var textarea = $("textarea[name='" + container.data("name") + "']", form);
  9341. //先清空已有的数据
  9342. $("[fieldlist-item]", container).remove();
  9343. var json = {};
  9344. try {
  9345. var val = textarea.val().replace(/"(\d+)"\:/g, "\"__PLACEHOLDERKEY__$1\":");
  9346. json = JSON.parse(val);
  9347. } catch (e) {
  9348. }
  9349. $.each(json, function (i, j) {
  9350. append(container, {key: i.toString().replace("__PLACEHOLDERKEY__", ""), value: j}, true);
  9351. });
  9352. });
  9353. //拖拽排序
  9354. fieldlist.each(function () {
  9355. var container = $(this);
  9356. var tagName = container.data("tag") || (container.is("table") ? "tr" : "dd");
  9357. container.dragsort({
  9358. itemSelector: tagName,
  9359. dragSelector: ".btn-dragsort",
  9360. dragEnd: function () {
  9361. refresh(container);
  9362. },
  9363. placeHolderTemplate: $("<" + tagName + "/>")
  9364. });
  9365. if (typeof container.data("options") === 'object' && container.data("options").appendBtn === false) {
  9366. $(".btn-append,.append", container).hide();
  9367. }
  9368. $("textarea[name='" + container.data("name") + "']", form).on("fa.event.refreshfieldlist", function () {
  9369. //兼容旧版本事件
  9370. $(this).closest(".fieldlist").trigger("fa.event.refreshfieldlist");
  9371. });
  9372. });
  9373. fieldlist.trigger("fa.event.refreshfieldlist");
  9374. });
  9375. }
  9376. },
  9377. switcher: function (form) {
  9378. form.on("click", "[data-toggle='switcher']", function () {
  9379. if ($(this).hasClass("disabled")) {
  9380. return false;
  9381. }
  9382. var switcher = $.proxy(function () {
  9383. var input = $(this).prev("input");
  9384. input = $(this).data("input-id") ? $("#" + $(this).data("input-id")) : input;
  9385. if (input.length > 0) {
  9386. var yes = $(this).data("yes");
  9387. var no = $(this).data("no");
  9388. if (input.val() == yes) {
  9389. input.val(no);
  9390. $("i", this).addClass("fa-flip-horizontal text-gray");
  9391. } else {
  9392. input.val(yes);
  9393. $("i", this).removeClass("fa-flip-horizontal text-gray");
  9394. }
  9395. input.trigger('change');
  9396. }
  9397. }, this);
  9398. if (typeof $(this).data("confirm") !== 'undefined') {
  9399. Layer.confirm($(this).data("confirm"), function (index) {
  9400. switcher();
  9401. Layer.close(index);
  9402. });
  9403. } else {
  9404. switcher();
  9405. }
  9406. return false;
  9407. });
  9408. },
  9409. bindevent: function (form) {
  9410. },
  9411. slider: function (form) {
  9412. if ($(".slider", form).length > 0) {
  9413. require(['bootstrap-slider'], function () {
  9414. $('.slider').removeClass('hidden').css('width', function (index, value) {
  9415. return $(this).parents('.form-control').width();
  9416. }).slider().on('slide', function (ev) {
  9417. var data = $(this).data();
  9418. if (typeof data.unit !== 'undefined') {
  9419. $(this).parents('.form-control').siblings('.value').text(ev.value + data.unit);
  9420. }
  9421. });
  9422. });
  9423. }
  9424. },
  9425. tagsinput: function (form) {
  9426. if ($("[data-role='tagsinput']", form).length > 0) {
  9427. require(['tagsinput', 'autocomplete'], function () {
  9428. $("[data-role='tagsinput']").tagsinput();
  9429. });
  9430. }
  9431. },
  9432. autocomplete: function (form) {
  9433. if ($("[data-role='autocomplete']", form).length > 0) {
  9434. require(['autocomplete'], function () {
  9435. $("[data-role='autocomplete']").autocomplete();
  9436. });
  9437. }
  9438. },
  9439. favisible: function (form) {
  9440. if ($("[data-favisible]", form).length == 0) {
  9441. return;
  9442. }
  9443. var checkCondition = function (condition) {
  9444. var conditionArr = condition.split(/&&/);
  9445. var success = 0;
  9446. var baseregex = /^([a-z0-9\_]+)([>|<|=|\!]=?)(.*)$/i, strregex = /^('|")(.*)('|")$/, regregex = /^regex:(.*)$/;
  9447. // @formatter:off
  9448. var operator_result = {
  9449. '>': function(a, b) { return a > b; },
  9450. '>=': function(a, b) { return a >= b; },
  9451. '<': function(a, b) { return a < b; },
  9452. '<=': function(a, b) { return a <= b; },
  9453. '==': function(a, b) { return a == b; },
  9454. '!=': function(a, b) { return a != b; },
  9455. 'in': function(a, b) { return b.split(/\,/).indexOf(a) > -1; },
  9456. 'regex': function (a, b) {
  9457. var regParts = b.match(/^\/(.*?)\/([gim]*)$/);
  9458. var regexp = regParts ? new RegExp(regParts[1], regParts[2]) : new RegExp(b);
  9459. return regexp.test(a);
  9460. }
  9461. };
  9462. // @formatter:on
  9463. var dataArr = form.serializeArray(), dataObj = {}, fieldName, fieldValue;
  9464. $(dataArr).each(function (i, field) {
  9465. fieldName = field.name;
  9466. fieldValue = field.value;
  9467. fieldName = fieldName.substr(-2) === '[]' ? fieldName.substr(0, fieldName.length - 2) : fieldName;
  9468. dataObj[fieldName] = typeof dataObj[fieldName] !== 'undefined' ? [dataObj[fieldName], fieldValue].join(',') : fieldValue;
  9469. });
  9470. $.each(conditionArr, function (i, item) {
  9471. var basematches = baseregex.exec(item);
  9472. if (basematches) {
  9473. var name = basematches[1], operator = basematches[2], value = basematches[3].toString();
  9474. if (operator === '=') {
  9475. var strmatches = strregex.exec(value);
  9476. operator = strmatches ? '==' : 'in';
  9477. value = strmatches ? strmatches[2] : value;
  9478. }
  9479. var regmatches = regregex.exec(value);
  9480. if (regmatches) {
  9481. operator = 'regex';
  9482. value = regmatches[1];
  9483. }
  9484. var chkname = "row[" + name + "]";
  9485. if (typeof dataObj[chkname] === 'undefined') {
  9486. return false;
  9487. }
  9488. var objvalue = dataObj[chkname];
  9489. if ($.isArray(objvalue)) {
  9490. objvalue = dataObj[chkname].join(",");
  9491. }
  9492. if (['>', '>=', '<', '<='].indexOf(operator) > -1) {
  9493. objvalue = parseFloat(objvalue);
  9494. value = parseFloat(value);
  9495. }
  9496. var result = operator_result[operator](objvalue, value);
  9497. success += (result ? 1 : 0);
  9498. }
  9499. });
  9500. return success === conditionArr.length;
  9501. };
  9502. form.on("keyup change click configchange", "input,select", function () {
  9503. $("[data-favisible][data-favisible!='']", form).each(function () {
  9504. var visible = $(this).data("favisible");
  9505. var groupArr = visible.split(/\|\|/);
  9506. var success = 0;
  9507. $.each(groupArr, function (i, j) {
  9508. if (checkCondition(j)) {
  9509. success++;
  9510. }
  9511. });
  9512. if (success > 0) {
  9513. $(this).removeClass("hidden");
  9514. } else {
  9515. $(this).addClass("hidden");
  9516. }
  9517. });
  9518. });
  9519. //追加上忽略元素
  9520. setTimeout(function () {
  9521. form.data('validator').options.ignore += ((form.data('validator').options.ignore ? ',' : '') + '[data-favisible] :hidden,[data-favisible]:hidden');
  9522. }, 0);
  9523. $("input,select", form).trigger("configchange");
  9524. }
  9525. },
  9526. api: {
  9527. submit: function (form, success, error, submit) {
  9528. if (form.length === 0) {
  9529. Toastr.error("表单未初始化完成,无法提交");
  9530. return false;
  9531. }
  9532. if (typeof submit === 'function') {
  9533. if (false === submit.call(form, success, error)) {
  9534. return false;
  9535. }
  9536. }
  9537. var type = form.attr("method") ? form.attr("method").toUpperCase() : 'GET';
  9538. type = type && (type === 'GET' || type === 'POST') ? type : 'GET';
  9539. url = form.attr("action");
  9540. url = url ? url : location.href;
  9541. //修复当存在多选项元素时提交的BUG
  9542. var params = {};
  9543. var multipleList = $("[name$='[]']", form);
  9544. if (multipleList.length > 0) {
  9545. var postFields = form.serializeArray().map(function (obj) {
  9546. return $(obj).prop("name");
  9547. });
  9548. $.each(multipleList, function (i, j) {
  9549. if (postFields.indexOf($(this).prop("name")) < 0) {
  9550. params[$(this).prop("name")] = '';
  9551. }
  9552. });
  9553. }
  9554. //调用Ajax请求方法
  9555. Fast.api.ajax({
  9556. type: type,
  9557. url: url,
  9558. data: form.serialize() + (Object.keys(params).length > 0 ? '&' + $.param(params) : ''),
  9559. dataType: 'json',
  9560. complete: function (xhr) {
  9561. var token = xhr.getResponseHeader('__token__');
  9562. if (token) {
  9563. $("input[name='__token__']").val(token);
  9564. }
  9565. }
  9566. }, function (data, ret) {
  9567. $('.form-group', form).removeClass('has-feedback has-success has-error');
  9568. if (data && typeof data === 'object') {
  9569. //刷新客户端token
  9570. if (typeof data.token !== 'undefined') {
  9571. $("input[name='__token__']").val(data.token);
  9572. }
  9573. //调用客户端事件
  9574. if (typeof data.callback !== 'undefined' && typeof data.callback === 'function') {
  9575. data.callback.call(form, data);
  9576. }
  9577. }
  9578. if (typeof success === 'function') {
  9579. if (false === success.call(form, data, ret)) {
  9580. return false;
  9581. }
  9582. }
  9583. }, function (data, ret) {
  9584. if (data && typeof data === 'object' && typeof data.token !== 'undefined') {
  9585. $("input[name='__token__']").val(data.token);
  9586. }
  9587. if (typeof error === 'function') {
  9588. if (false === error.call(form, data, ret)) {
  9589. return false;
  9590. }
  9591. }
  9592. });
  9593. return true;
  9594. },
  9595. bindevent: function (form, success, error, submit) {
  9596. form = typeof form === 'object' ? form : $(form);
  9597. var events = Form.events;
  9598. events.bindevent(form);
  9599. events.validator(form, success, error, submit);
  9600. events.selectpicker(form);
  9601. events.daterangepicker(form);
  9602. events.selectpage(form);
  9603. events.cxselect(form);
  9604. events.citypicker(form);
  9605. events.datetimepicker(form);
  9606. events.faupload(form);
  9607. events.faselect(form);
  9608. events.fieldlist(form);
  9609. events.slider(form);
  9610. events.switcher(form);
  9611. events.tagsinput(form);
  9612. events.autocomplete(form);
  9613. events.favisible(form);
  9614. },
  9615. custom: {}
  9616. },
  9617. };
  9618. return Form;
  9619. });
  9620. /**
  9621. * FastAdmin通用搜索
  9622. *
  9623. * @author: pppscn <35696959@qq.com>
  9624. * @update 2017-05-07 <https://gitee.com/pp/fastadmin>
  9625. *
  9626. * @author: Karson <karson@fastadmin.net>
  9627. * @update 2018-04-05 <https://gitee.com/karson/fastadmin>
  9628. */
  9629. !function ($) {
  9630. 'use strict';
  9631. var ColumnsForSearch = [];
  9632. var sprintf = $.fn.bootstrapTable.utils.sprintf;
  9633. var initCommonSearch = function (pColumns, that) {
  9634. var vFormCommon = createFormCommon(pColumns, that);
  9635. var vModal = sprintf("<div class=\"commonsearch-table %s\">", that.options.searchFormVisible ? "" : "hidden");
  9636. vModal += vFormCommon;
  9637. vModal += "</div>";
  9638. that.$container.prepend($(vModal));
  9639. that.$commonsearch = $(".commonsearch-table", that.$container);
  9640. var form = $("form.form-commonsearch", that.$commonsearch);
  9641. require(['form'], function (Form) {
  9642. Form.api.bindevent(form);
  9643. form.validator("destroy");
  9644. });
  9645. // 表单提交
  9646. form.on("submit", function (event) {
  9647. event.preventDefault();
  9648. that.onCommonSearch();
  9649. return false;
  9650. });
  9651. // 重置搜索
  9652. form.on("click", "button[type=reset]", function (event) {
  9653. form[0].reset();
  9654. setTimeout(function () {
  9655. that.onCommonSearch();
  9656. }, 10);
  9657. });
  9658. };
  9659. var createFormCommon = function (pColumns, that) {
  9660. // 如果有使用模板则直接返回模板的内容
  9661. if (that.options.searchFormTemplate) {
  9662. return Template(that.options.searchFormTemplate, {columns: pColumns, table: that});
  9663. }
  9664. var htmlForm = [];
  9665. htmlForm.push(sprintf('<form class="form-horizontal form-commonsearch" novalidate method="post" action="%s" >', that.options.actionForm));
  9666. htmlForm.push('<fieldset>');
  9667. if (that.options.titleForm.length > 0)
  9668. htmlForm.push(sprintf("<legend>%s</legend>", that.options.titleForm));
  9669. htmlForm.push('<div class="row">');
  9670. for (var i in pColumns) {
  9671. var vObjCol = pColumns[i];
  9672. if (!vObjCol.checkbox && vObjCol.field !== 'operate' && vObjCol.searchable && vObjCol.operate !== false) {
  9673. var query = Fast.api.query(vObjCol.field);
  9674. var operate = Fast.api.query(vObjCol.field + "-operate");
  9675. var renderDefault = that.options.renderDefault && (typeof vObjCol.renderDefault == 'undefined' || vObjCol.renderDefault);
  9676. vObjCol.defaultValue = renderDefault && query ? query : (typeof vObjCol.defaultValue === 'undefined' ? '' : vObjCol.defaultValue);
  9677. vObjCol.operate = renderDefault && operate ? operate : (typeof vObjCol.operate === 'undefined' ? '=' : vObjCol.operate);
  9678. ColumnsForSearch.push(vObjCol);
  9679. htmlForm.push('<div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">');
  9680. htmlForm.push(sprintf('<label for="%s" class="control-label col-xs-4">%s</label>', vObjCol.field, vObjCol.title));
  9681. htmlForm.push('<div class="col-xs-8">');
  9682. vObjCol.operate = vObjCol.operate ? vObjCol.operate.toUpperCase() : '=';
  9683. 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));
  9684. var addClass = typeof vObjCol.addClass === 'undefined' ? (typeof vObjCol.addclass === 'undefined' ? 'form-control' : 'form-control ' + vObjCol.addclass) : 'form-control ' + vObjCol.addClass;
  9685. var extend = typeof vObjCol.extend === 'undefined' ? '' : vObjCol.extend;
  9686. var style = typeof vObjCol.style === 'undefined' ? '' : sprintf('style="%s"', vObjCol.style);
  9687. extend = typeof vObjCol.data !== 'undefined' && extend == '' ? vObjCol.data : extend;
  9688. extend = typeof vObjCol.autocomplete !== 'undefined' ? extend + ' autocomplete="' + (vObjCol.autocomplete === false || vObjCol.autocomplete === 'off' ? 'off' : 'on') + '"' : extend;
  9689. if (vObjCol.searchList) {
  9690. if (typeof vObjCol.searchList === 'function') {
  9691. htmlForm.push(vObjCol.searchList.call(this, vObjCol));
  9692. } else {
  9693. var optionList = [sprintf('<option value="">%s</option>', that.options.formatCommonChoose())];
  9694. if (typeof vObjCol.searchList === 'object' && typeof vObjCol.searchList.then === 'function') {
  9695. (function (vObjCol, that) {
  9696. $.when(vObjCol.searchList).done(function (ret) {
  9697. var searchList = [];
  9698. if (ret.data && ret.data.searchlist && $.isArray(ret.data.searchlist)) {
  9699. searchList = ret.data.searchlist;
  9700. } else if (ret.constructor === Array || ret.constructor === Object) {
  9701. searchList = ret;
  9702. }
  9703. var optionList = createOptionList(searchList, vObjCol, that);
  9704. $("form.form-commonsearch select[name='" + vObjCol.field + "']", that.$container).html(optionList.join('')).trigger("change");
  9705. });
  9706. })(vObjCol, that);
  9707. } else {
  9708. optionList = createOptionList(vObjCol.searchList, vObjCol, that);
  9709. }
  9710. htmlForm.push(sprintf('<select class="%s" name="%s" %s %s>%s</select>', addClass, vObjCol.field, style, extend, optionList.join('')));
  9711. }
  9712. } else {
  9713. var placeholder = typeof vObjCol.placeholder === 'undefined' ? vObjCol.title : vObjCol.placeholder;
  9714. var type = typeof vObjCol.type === 'undefined' ? 'text' : vObjCol.type;
  9715. var defaultValue = typeof vObjCol.defaultValue === 'undefined' ? '' : vObjCol.defaultValue;
  9716. if (/BETWEEN$/.test(vObjCol.operate)) {
  9717. var defaultValueArr = defaultValue.toString().match(/\|/) ? defaultValue.split('|') : ['', ''];
  9718. var placeholderArr = placeholder.toString().match(/\|/) ? placeholder.split('|') : [placeholder, placeholder];
  9719. htmlForm.push('<div class="row row-between">');
  9720. 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));
  9721. 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));
  9722. htmlForm.push('</div>');
  9723. } else {
  9724. 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));
  9725. }
  9726. }
  9727. htmlForm.push('</div>');
  9728. htmlForm.push('</div>');
  9729. }
  9730. }
  9731. htmlForm.push('<div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">');
  9732. htmlForm.push(createFormBtn(that).join(''));
  9733. htmlForm.push('</div>');
  9734. htmlForm.push('</div>');
  9735. htmlForm.push('</fieldset>');
  9736. htmlForm.push('</form>');
  9737. return htmlForm.join('');
  9738. };
  9739. var createFormBtn = function (that) {
  9740. var htmlBtn = [];
  9741. var searchSubmit = that.options.formatCommonSubmitButton();
  9742. var searchReset = that.options.formatCommonResetButton();
  9743. htmlBtn.push('<div class="col-sm-8 col-xs-offset-4">');
  9744. htmlBtn.push(sprintf('<button type="submit" class="btn btn-success" formnovalidate>%s</button> ', searchSubmit));
  9745. htmlBtn.push(sprintf('<button type="reset" class="btn btn-default" >%s</button> ', searchReset));
  9746. htmlBtn.push('</div>');
  9747. return htmlBtn;
  9748. };
  9749. var createOptionList = function (searchList, vObjCol, that) {
  9750. var isArray = searchList.constructor === Array;
  9751. var optionList = [];
  9752. optionList.push(sprintf('<option value="">%s</option>', that.options.formatCommonChoose()));
  9753. $.each(searchList, function (key, value) {
  9754. if (value.constructor === Object) {
  9755. key = value.id;
  9756. value = value.name;
  9757. } else {
  9758. key = isArray ? value : key;
  9759. }
  9760. optionList.push(sprintf("<option value='" + key + "' %s>" + value + "</option>", key == vObjCol.defaultValue ? 'selected' : ''));
  9761. });
  9762. return optionList;
  9763. };
  9764. var isSearchAvailble = function (that) {
  9765. //只支持服务端搜索
  9766. if (!that.options.commonSearch || that.options.sidePagination != 'server' || !that.options.url) {
  9767. return false;
  9768. }
  9769. return true;
  9770. };
  9771. var getSearchQuery = function (that, removeempty) {
  9772. var op = {};
  9773. var filter = {};
  9774. var value = '';
  9775. $("form.form-commonsearch .operate", that.$commonsearch).each(function (i) {
  9776. var name = $(this).data("name");
  9777. var sym = $(this).is("select") ? $("option:selected", this).val() : $(this).val().toUpperCase();
  9778. var obj = $("[name='" + name + "']", that.$commonsearch);
  9779. if (obj.length == 0)
  9780. return true;
  9781. var vObjCol = ColumnsForSearch[i];
  9782. var process = !that.options.searchFormTemplate && vObjCol && typeof vObjCol.process == 'function' ? vObjCol.process : null;
  9783. if (obj.length > 1) {
  9784. if (/BETWEEN$/.test(sym)) {
  9785. var value_begin = $.trim($("[name='" + name + "']:first", that.$commonsearch).val()),
  9786. value_end = $.trim($("[name='" + name + "']:last", that.$commonsearch).val());
  9787. if (value_begin.length || value_end.length) {
  9788. if (process) {
  9789. value_begin = process(value_begin, 'begin');
  9790. value_end = process(value_end, 'end');
  9791. }
  9792. value = value_begin + ',' + value_end;
  9793. } else {
  9794. value = '';
  9795. }
  9796. //如果是时间筛选,将operate置为RANGE
  9797. if ($("[name='" + name + "']:first", that.$commonsearch).hasClass("datetimepicker")) {
  9798. sym = 'RANGE';
  9799. }
  9800. } else {
  9801. value = $("[name='" + name + "']:checked", that.$commonsearch).val();
  9802. value = process ? process(value) : value;
  9803. }
  9804. } else {
  9805. value = process ? process(obj.val()) : obj.val();
  9806. }
  9807. if (removeempty && (value === '' || value == null || ($.isArray(value) && value.length === 0)) && !sym.match(/null/i)) {
  9808. return true;
  9809. }
  9810. op[name] = sym;
  9811. filter[name] = value;
  9812. });
  9813. if (that.options.searchCountTips) {
  9814. var count = 0;
  9815. $.each(filter, function (key, value) {
  9816. if ((value === '' || value == null || ($.isArray(value) && value.length === 0))) {
  9817. return true;
  9818. }
  9819. count++;
  9820. });
  9821. that.$toolbar.find(".btn-commonsearch > span").text(count).toggleClass("hidden", count === 0);
  9822. }
  9823. return {op: op, filter: filter};
  9824. };
  9825. var getQueryParams = function (params, searchQuery, removeempty) {
  9826. params.filter = typeof params.filter === 'Object' ? params.filter : (params.filter ? JSON.parse(params.filter) : {});
  9827. params.op = typeof params.op === 'Object' ? params.op : (params.op ? JSON.parse(params.op) : {});
  9828. params.filter = $.extend({}, params.filter, searchQuery.filter);
  9829. params.op = $.extend({}, params.op, searchQuery.op);
  9830. //移除empty的值
  9831. if (removeempty) {
  9832. $.each(params.filter, function (i, j) {
  9833. if ((j == '' || j == null || ($.isArray(j) && j.length == 0)) && !params.op[i].match(/null/i)) {
  9834. delete params.filter[i];
  9835. delete params.op[i];
  9836. }
  9837. });
  9838. }
  9839. params.filter = JSON.stringify(params.filter);
  9840. params.op = JSON.stringify(params.op);
  9841. return params;
  9842. };
  9843. $.extend($.fn.bootstrapTable.defaults, {
  9844. commonSearch: false,
  9845. titleForm: "Common search",
  9846. actionForm: "",
  9847. searchFormTemplate: "",
  9848. searchFormVisible: true,
  9849. searchCountTips: true,
  9850. searchClass: 'searchit',
  9851. showSearch: true,
  9852. renderDefault: true,
  9853. onCommonSearch: function (field, text) {
  9854. return false;
  9855. },
  9856. onPostCommonSearch: function (table) {
  9857. return false;
  9858. }
  9859. });
  9860. $.extend($.fn.bootstrapTable.defaults.icons, {
  9861. commonSearchIcon: 'glyphicon-search'
  9862. });
  9863. $.extend($.fn.bootstrapTable.Constructor.EVENTS, {
  9864. 'common-search.bs.table': 'onCommonSearch',
  9865. 'post-common-search.bs.table': 'onPostCommonSearch'
  9866. });
  9867. $.extend($.fn.bootstrapTable.locales[$.fn.bootstrapTable.defaults.locale], {
  9868. formatCommonSearch: function () {
  9869. return "Common search";
  9870. },
  9871. formatCommonSubmitButton: function () {
  9872. return "Search";
  9873. },
  9874. formatCommonResetButton: function () {
  9875. return "Reset";
  9876. },
  9877. formatCommonCloseButton: function () {
  9878. return "Close";
  9879. },
  9880. formatCommonChoose: function () {
  9881. return "Choose";
  9882. }
  9883. });
  9884. $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);
  9885. var BootstrapTable = $.fn.bootstrapTable.Constructor,
  9886. _initHeader = BootstrapTable.prototype.initHeader,
  9887. _initToolbar = BootstrapTable.prototype.initToolbar,
  9888. _load = BootstrapTable.prototype.load,
  9889. _initSearch = BootstrapTable.prototype.initSearch;
  9890. BootstrapTable.prototype.initHeader = function () {
  9891. _initHeader.apply(this, Array.prototype.slice.apply(arguments));
  9892. this.$header.find('th[data-field]').each(function (i) {
  9893. var column = $(this).data();
  9894. if (typeof column['width'] !== 'undefined' && column['width'].toString().indexOf("%") === -1) {
  9895. $(".th-inner", this).outerWidth(column['width']);
  9896. $(this).css("max-width", column['width']);
  9897. }
  9898. });
  9899. this.options.stateField = this.header.stateField;
  9900. };
  9901. BootstrapTable.prototype.initToolbar = function () {
  9902. _initToolbar.apply(this, Array.prototype.slice.apply(arguments));
  9903. if (!isSearchAvailble(this)) {
  9904. return;
  9905. }
  9906. var that = this,
  9907. html = [];
  9908. if (that.options.showSearch) {
  9909. html.push(sprintf('<div class="columns-%s pull-%s" style="margin-top:10px;margin-bottom:10px;">', this.options.buttonsAlign, this.options.buttonsAlign));
  9910. html.push(sprintf('<button class="btn btn-default btn-commonsearch %s' + '" type="button" name="commonSearch" title="%s">', that.options.iconSize === undefined ? '' : ' btn-' + that.options.iconSize, that.options.formatCommonSearch()));
  9911. if (that.options.searchCountTips) {
  9912. html.push(sprintf('<span class="label label-danger hidden">0</span>'));
  9913. }
  9914. html.push(sprintf('<i class="%s %s"></i>', that.options.iconsPrefix, that.options.icons.commonSearchIcon));
  9915. html.push('</button></div>');
  9916. }
  9917. if (that.$toolbar.find(".pull-right").length > 0) {
  9918. $(html.join('')).insertBefore(that.$toolbar.find(".pull-right:first"));
  9919. } else {
  9920. that.$toolbar.append(html.join(''));
  9921. }
  9922. initCommonSearch(that.columns, that);
  9923. that.$toolbar.find('button[name="commonSearch"]')
  9924. .off('click').on('click', function () {
  9925. that.$commonsearch.toggleClass("hidden");
  9926. return;
  9927. });
  9928. that.$container.on("click", "." + that.options.searchClass, function () {
  9929. var value = $(this).data("value");
  9930. var field = $(this).data("field");
  9931. var ul = that.$container.closest(".panel-intro").find("ul[data-field='" + field + "']");
  9932. if (ul.length > 0) {
  9933. $('li a[data-value="' + value + '"][data-toggle="tab"]', ul).trigger('click');
  9934. return;
  9935. }
  9936. var obj = $("form [name='" + field + "']", that.$commonsearch);
  9937. if (obj.length > 0) {
  9938. if (obj.is("select")) {
  9939. $("option[value='" + value + "']", obj).prop("selected", true);
  9940. } else if (obj.length > 1) {
  9941. $("form [name='" + field + "'][value='" + value + "']", that.$commonsearch).prop("checked", true);
  9942. } else {
  9943. obj.val(value + "");
  9944. }
  9945. obj.trigger("change");
  9946. $("form", that.$commonsearch).trigger("submit");
  9947. }
  9948. });
  9949. var queryParams = that.options.queryParams;
  9950. //匹配默认搜索值
  9951. this.options.queryParams = function (params) {
  9952. return queryParams(getQueryParams(params, getSearchQuery(that, true)));
  9953. };
  9954. this.trigger('post-common-search', that);
  9955. };
  9956. BootstrapTable.prototype.onCommonSearch = function () {
  9957. var searchQuery = getSearchQuery(this);
  9958. this.trigger('common-search', this, searchQuery);
  9959. this.options.pageNumber = 1;
  9960. //this.options.pageSize = $.fn.bootstrapTable.defaults.pageSize;
  9961. this.refresh({});
  9962. };
  9963. BootstrapTable.prototype.load = function (data) {
  9964. _load.apply(this, Array.prototype.slice.apply(arguments));
  9965. if (!isSearchAvailble(this)) {
  9966. return;
  9967. }
  9968. };
  9969. BootstrapTable.prototype.initSearch = function () {
  9970. _initSearch.apply(this, Array.prototype.slice.apply(arguments));
  9971. if (!isSearchAvailble(this)) {
  9972. return;
  9973. }
  9974. var that = this;
  9975. var fp = $.isEmptyObject(this.filterColumnsPartial) ? null : this.filterColumnsPartial;
  9976. this.data = fp ? $.grep(this.data, function (item, i) {
  9977. for (var key in fp) {
  9978. var fval = fp[key].toLowerCase();
  9979. var value = item[key];
  9980. value = $.fn.bootstrapTable.utils.calculateObjectValue(that.header,
  9981. that.header.formatters[$.inArray(key, that.header.fields)],
  9982. [value, item, i], value);
  9983. if (!($.inArray(key, that.header.fields) !== -1 &&
  9984. (typeof value === 'string' || typeof value === 'number') &&
  9985. (value + '').toLowerCase().indexOf(fval) !== -1)) {
  9986. return false;
  9987. }
  9988. }
  9989. return true;
  9990. }) : this.data;
  9991. };
  9992. }(jQuery);
  9993. define("bootstrap-table-commonsearch", ["bootstrap-table"], (function (global) {
  9994. return function () {
  9995. var ret, fn;
  9996. return ret || global.$.fn.bootstrapTable.defaults;
  9997. };
  9998. }(this)));
  9999. /**
  10000. * 将BootstrapTable的行使用自定义的模板来渲染
  10001. *
  10002. * @author: karson
  10003. * @version: v0.0.1
  10004. *
  10005. * @update 2017-06-24 <http://github.com/karsonzhang/fastadmin>
  10006. */
  10007. !function ($) {
  10008. 'use strict';
  10009. $.extend($.fn.bootstrapTable.defaults, {
  10010. //是否启用模板渲染
  10011. templateView: false,
  10012. //数据格式化的模板ID或格式函数
  10013. templateFormatter: "itemtpl",
  10014. //添加的父类的class
  10015. templateParentClass: "row row-flex",
  10016. //向table添加的class
  10017. templateTableClass: "table-template",
  10018. });
  10019. var BootstrapTable = $.fn.bootstrapTable.Constructor,
  10020. _initContainer = BootstrapTable.prototype.initContainer,
  10021. _initBody = BootstrapTable.prototype.initBody,
  10022. _initRow = BootstrapTable.prototype.initRow;
  10023. BootstrapTable.prototype.initContainer = function () {
  10024. _initContainer.apply(this, Array.prototype.slice.apply(arguments));
  10025. var that = this;
  10026. if (!that.options.templateView) {
  10027. return;
  10028. }
  10029. that.options.cardView = true;
  10030. };
  10031. BootstrapTable.prototype.initBody = function () {
  10032. var that = this;
  10033. $.extend(that.options, {
  10034. showHeader: !that.options.templateView ? $.fn.bootstrapTable.defaults.showHeader : false,
  10035. showFooter: !that.options.templateView ? $.fn.bootstrapTable.defaults.showFooter : false,
  10036. });
  10037. $(that.$el).toggleClass(that.options.templateTableClass, that.options.templateView);
  10038. _initBody.apply(this, Array.prototype.slice.apply(arguments));
  10039. if (!that.options.templateView) {
  10040. return;
  10041. } else {
  10042. //由于Bootstrap是基于Table的,添加一个父类容器
  10043. $("> *:not(.no-records-found)", that.$body).wrapAll($("<div />").addClass(that.options.templateParentClass));
  10044. }
  10045. };
  10046. BootstrapTable.prototype.initRow = function (item, i, data, parentDom) {
  10047. var that = this;
  10048. //如果未启用则使用原生的initRow方法
  10049. if (!that.options.templateView) {
  10050. return _initRow.apply(that, Array.prototype.slice.apply(arguments));
  10051. }
  10052. var $content = '';
  10053. if (typeof that.options.templateFormatter === 'function') {
  10054. $content = that.options.templateFormatter.call(that, item, i, data);
  10055. } else {
  10056. var Template = require('template');
  10057. $content = Template(that.options.templateFormatter, {item: item, i: i, data: data});
  10058. }
  10059. return $content;
  10060. };
  10061. }(jQuery);
  10062. define("bootstrap-table-template", ["bootstrap-table","template"], (function (global) {
  10063. return function () {
  10064. var ret, fn;
  10065. return ret || global.$.fn.bootstrapTable.defaults;
  10066. };
  10067. }(this)));
  10068. /**
  10069. * @author Jay <jwang@dizsoft.com>
  10070. */
  10071. (function ($) {
  10072. 'use strict';
  10073. var sprintf = $.fn.bootstrapTable.utils.sprintf;
  10074. $.extend($.fn.bootstrapTable.defaults, {
  10075. showJumpto: false,
  10076. exportOptions: {}
  10077. });
  10078. $.extend($.fn.bootstrapTable.locales, {
  10079. formatJumpto: function () {
  10080. return 'GO';
  10081. }
  10082. });
  10083. $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);
  10084. var BootstrapTable = $.fn.bootstrapTable.Constructor,
  10085. _initPagination = BootstrapTable.prototype.initPagination;
  10086. BootstrapTable.prototype.initPagination = function () {
  10087. this.showToolbar = this.options.showExport;
  10088. _initPagination.apply(this, Array.prototype.slice.apply(arguments));
  10089. if (this.options.showJumpto) {
  10090. var that = this,
  10091. $pageGroup = this.$pagination.find('ul.pagination'),
  10092. $jumpto = $pageGroup.find('li.jumpto');
  10093. if (!$jumpto.length) {
  10094. $jumpto = $([
  10095. '<li class="jumpto">',
  10096. '<input type="text" class="form-control">',
  10097. '<button class="btn' +
  10098. sprintf(' btn-%s', this.options.buttonsClass) +
  10099. sprintf(' btn-%s', this.options.iconSize) +
  10100. '" title="' + this.options.formatJumpto() + '" ' +
  10101. ' type="button">'+this.options.formatJumpto(),
  10102. '</button>',
  10103. '</li>'].join('')).appendTo($pageGroup);
  10104. $jumpto.find('button').click(function () {
  10105. that.selectPage(parseInt($jumpto.find('input').val()));
  10106. });
  10107. }
  10108. }
  10109. };
  10110. })(jQuery);
  10111. define("bootstrap-table-jumpto", ["bootstrap-table"], (function (global) {
  10112. return function () {
  10113. var ret, fn;
  10114. return ret || global.$.fn.bootstrapTable.defaults;
  10115. };
  10116. }(this)));
  10117. (function ($) {
  10118. 'use strict';
  10119. // Reasonable defaults
  10120. var PIXEL_STEP = 10;
  10121. var LINE_HEIGHT = 40;
  10122. var PAGE_HEIGHT = 800;
  10123. function normalizeWheel(event) {
  10124. var sX = 0; // spinX
  10125. var sY = 0; // spinY
  10126. var pX = 0; // pixelX
  10127. var pY = 0; // pixelY
  10128. // Legacy
  10129. if ('detail' in event) {
  10130. sY = event.detail;
  10131. }
  10132. if ('wheelDelta' in event) {
  10133. sY = -event.wheelDelta / 120;
  10134. }
  10135. if ('wheelDeltaY' in event) {
  10136. sY = -event.wheelDeltaY / 120;
  10137. }
  10138. if ('wheelDeltaX' in event) {
  10139. sX = -event.wheelDeltaX / 120;
  10140. }
  10141. // side scrolling on FF with DOMMouseScroll
  10142. if ('axis' in event && event.axis === event.HORIZONTAL_AXIS) {
  10143. sX = sY;
  10144. sY = 0;
  10145. }
  10146. pX = sX * PIXEL_STEP;
  10147. pY = sY * PIXEL_STEP;
  10148. if ('deltaY' in event) {
  10149. pY = event.deltaY;
  10150. }
  10151. if ('deltaX' in event) {
  10152. pX = event.deltaX;
  10153. }
  10154. if ((pX || pY) && event.deltaMode) {
  10155. if (event.deltaMode === 1) {
  10156. // delta in LINE units
  10157. pX *= LINE_HEIGHT;
  10158. pY *= LINE_HEIGHT;
  10159. } else {
  10160. // delta in PAGE units
  10161. pX *= PAGE_HEIGHT;
  10162. pY *= PAGE_HEIGHT;
  10163. }
  10164. }
  10165. // Fall-back if spin cannot be determined
  10166. if (pX && !sX) {
  10167. sX = pX < 1 ? -1 : 1;
  10168. }
  10169. if (pY && !sY) {
  10170. sY = pY < 1 ? -1 : 1;
  10171. }
  10172. return {
  10173. spinX: sX,
  10174. spinY: sY,
  10175. pixelX: pX,
  10176. pixelY: pY
  10177. };
  10178. }
  10179. var cachedWidth = null;
  10180. var getScrollBarWidth = function getScrollBarWidth() {
  10181. if (cachedWidth === null) {
  10182. var inner = $('<p/>').addClass('fixed-table-scroll-inner'),
  10183. outer = $('<div/>').addClass('fixed-table-scroll-outer'),
  10184. w1 = void 0,
  10185. w2 = void 0;
  10186. outer.append(inner);
  10187. $('body').append(outer);
  10188. w1 = inner[0].offsetWidth;
  10189. outer.css('overflow', 'scroll');
  10190. w2 = inner[0].offsetWidth;
  10191. if (w1 === w2) {
  10192. w2 = outer[0].clientWidth;
  10193. }
  10194. outer.remove();
  10195. cachedWidth = w1 - w2;
  10196. }
  10197. return cachedWidth;
  10198. };
  10199. //获取原本表格体的滑块宽度
  10200. var getTableBodyScrollBarWidth = function getTableBodyScrollBarWidth(tableBody) {
  10201. return tableBody[0].scrollHeight > tableBody[0].clientHeight ? 15 : 0;
  10202. };
  10203. $.extend($.fn.bootstrapTable.defaults, {
  10204. fixedColumns: false,
  10205. fixedNumber: 0,
  10206. fixedRightNumber: 0
  10207. });
  10208. var BootstrapTable = $.fn.bootstrapTable.Constructor,
  10209. _initBody = BootstrapTable.prototype.initBody,
  10210. _initContainer = BootstrapTable.prototype.initContainer,
  10211. _trigger = BootstrapTable.prototype.trigger,
  10212. _hideLoading = BootstrapTable.prototype.hideLoading,
  10213. _updateSelected = BootstrapTable.prototype.updateSelected;
  10214. BootstrapTable.prototype.fixedColumnsSupported = function () {
  10215. var that = this;
  10216. return that.options.fixedColumns && !that.options.detailView && !that.options.cardView;
  10217. };
  10218. BootstrapTable.prototype.initFixedContainer = function () {
  10219. if (!this.fixedColumnsSupported()) {
  10220. return;
  10221. }
  10222. if (this.options.fixedNumber) {
  10223. this.$tableContainer.find('.fixed-columns').length == 0 && this.$tableContainer.append('<div class="fixed-columns"></div>');
  10224. this.$fixedColumns = this.$tableContainer.find('.fixed-columns');
  10225. }
  10226. if (this.options.fixedRightNumber) {
  10227. this.$tableContainer.find('.fixed-columns-right').length == 0 && this.$tableContainer.append('<div class="fixed-columns-right"></div>');
  10228. this.$fixedColumnsRight = this.$tableContainer.find('.fixed-columns-right');
  10229. }
  10230. };
  10231. BootstrapTable.prototype.initContainer = function () {
  10232. _initContainer.apply(this, Array.prototype.slice.apply(arguments));
  10233. this.initFixedContainer();
  10234. };
  10235. BootstrapTable.prototype.initBody = function () {
  10236. _initBody.apply(this, Array.prototype.slice.apply(arguments));
  10237. if (!this.fixedColumnsSupported()) {
  10238. return;
  10239. }
  10240. if (this.options.showHeader && this.options.height) {
  10241. return;
  10242. }
  10243. this.initFixedColumnsBody();
  10244. this.initFixedColumnsEvents();
  10245. };
  10246. BootstrapTable.prototype.trigger = function () {
  10247. var that = this;
  10248. _trigger.apply(this, Array.prototype.slice.apply(arguments));
  10249. if (arguments[0] === 'pre-body') {
  10250. //如果上来就是cardView 设置表格高度为auto
  10251. if (this.options.cardView) {
  10252. this.$tableBody.css("height", "auto");
  10253. }
  10254. }
  10255. //监听cardView 显示/隐藏fixed部分
  10256. if (arguments[0] === 'toggle') {
  10257. if (arguments[1]) {
  10258. this.$tableBody.css("height", "auto");
  10259. this.$fixedColumns && this.$fixedColumns.hide();
  10260. this.$fixedColumnsRight && this.$fixedColumnsRight.hide();
  10261. } else {
  10262. this.$tableBody.css("height", "100%");
  10263. this.$fixedColumns && this.$fixedColumns.show();
  10264. this.$fixedColumnsRight && this.$fixedColumnsRight.show();
  10265. this.$fixedHeaderRight && this.$fixedHeaderRight.scrollLeft(this.$tableBody.find('table').width());
  10266. this.$fixedBodyRight && this.$fixedBodyRight.scrollLeft(this.$tableBody.find('table').width());
  10267. }
  10268. }
  10269. if (!that.fixedColumnsSupported()) {
  10270. return;
  10271. }
  10272. if (arguments[0] === 'post-header') {
  10273. this.initFixedColumnsHeader();
  10274. } else if (arguments[0] === 'scroll-body') {
  10275. if (this.needFixedColumns && this.options.fixedNumber) {
  10276. this.$fixedBody && this.$fixedBody.scrollTop(this.$tableBody.scrollTop());
  10277. }
  10278. if (this.needFixedColumns && this.options.fixedRightNumber) {
  10279. this.$fixedBodyRight && this.$fixedBodyRight.scrollTop(this.$tableBody.scrollTop());
  10280. }
  10281. } else if (arguments[0] === 'load-success') {
  10282. this.hideLoading();
  10283. }
  10284. };
  10285. BootstrapTable.prototype.updateSelected = function () {
  10286. var that = this;
  10287. _updateSelected.apply(this, Array.prototype.slice.apply(arguments));
  10288. if (!this.fixedColumnsSupported()) {
  10289. return;
  10290. }
  10291. this.$tableBody.find('tr').each(function (i, el) {
  10292. var $el = $(el);
  10293. var index = $el.data('index');
  10294. var classes = $el.attr('class');
  10295. var inputSelector = '[name="' + that.options.selectItemName + '"]';
  10296. var $input = $el.find(inputSelector);
  10297. if (typeof index === 'undefined') {
  10298. return;
  10299. }
  10300. var updateFixedBody = function updateFixedBody($fixedHeader, $fixedBody) {
  10301. var $tr = $fixedBody.find('tr[data-index="' + index + '"]');
  10302. $tr.attr('class', classes);
  10303. if ($input.length) {
  10304. $tr.find(inputSelector).prop('checked', $input.prop('checked'));
  10305. }
  10306. if (that.$selectAll.length) {
  10307. $fixedHeader.add($fixedBody).find('[name="btSelectAll"]').prop('checked', that.$selectAll.prop('checked'));
  10308. }
  10309. };
  10310. if (that.$fixedBody && that.options.fixedNumber) {
  10311. updateFixedBody(that.$fixedHeader, that.$fixedBody);
  10312. }
  10313. if (that.$fixedBodyRight && that.options.fixedRightNumber) {
  10314. updateFixedBody(that.$fixedHeaderRight, that.$fixedBodyRight);
  10315. }
  10316. });
  10317. };
  10318. BootstrapTable.prototype.hideLoading = function () {
  10319. _hideLoading.apply(this, Array.prototype.slice.apply(arguments));
  10320. if (this.needFixedColumns && this.options.fixedNumber) {
  10321. this.$fixedColumns.find('.fixed-table-loading').hide();
  10322. }
  10323. if (this.needFixedColumns && this.options.fixedRightNumber) {
  10324. this.$fixedColumnsRight.find('.fixed-table-loading').hide();
  10325. }
  10326. };
  10327. BootstrapTable.prototype.initFixedColumnsHeader = function () {
  10328. var that = this;
  10329. if (this.options.height) {
  10330. this.needFixedColumns = this.$tableHeader.outerWidth(true) < this.$tableHeader.find('table').outerWidth(true);
  10331. } else {
  10332. this.needFixedColumns = this.$tableBody.outerWidth(true) < this.$tableBody.find('table').outerWidth(true);
  10333. }
  10334. var initFixedHeader = function initFixedHeader($fixedColumns, isRight) {
  10335. $fixedColumns.find('.fixed-table-header').remove();
  10336. $fixedColumns.append(that.$tableHeader.clone(true));
  10337. $fixedColumns.find('.fixed-table-header').css('margin-right', "");
  10338. $fixedColumns.css({
  10339. width: that.getFixedColumnsWidth(isRight)
  10340. });
  10341. return $fixedColumns.find('.fixed-table-header');
  10342. };
  10343. if (this.needFixedColumns && this.options.fixedNumber) {
  10344. this.$fixedHeader = initFixedHeader(this.$fixedColumns);
  10345. this.$fixedHeader.css('margin-right', '');
  10346. } else if (this.$fixedColumns) {
  10347. this.$fixedColumns.html('').css('width', '');
  10348. }
  10349. if (this.needFixedColumns && this.options.fixedRightNumber) {
  10350. this.$fixedHeaderRight = initFixedHeader(this.$fixedColumnsRight, true);
  10351. this.$fixedHeaderRight.scrollLeft(this.$fixedHeaderRight.find('table').width());
  10352. } else if (this.$fixedColumnsRight) {
  10353. this.$fixedColumnsRight.html('').css('width', '');
  10354. }
  10355. this.initFixedColumnsBody();
  10356. this.initFixedColumnsEvents();
  10357. };
  10358. BootstrapTable.prototype.initFixedColumnsBody = function () {
  10359. var that = this;
  10360. var initFixedBody = function initFixedBody($fixedColumns, $fixedHeader) {
  10361. $fixedColumns.find('.fixed-table-body').remove();
  10362. $fixedColumns.append(that.$tableBody.clone(true));
  10363. var $fixedBody = $fixedColumns.find('.fixed-table-body');
  10364. var tableBody = that.$tableBody.get(0);
  10365. var scrollHeight = tableBody.scrollWidth > tableBody.clientWidth ? getScrollBarWidth() : 0;
  10366. var paginationHeight = $(".fixed-table-pagination", that.$tableContainer).height();
  10367. if (typeof that.options.height !== 'undefined') paginationHeight = 0;
  10368. var height = that.$tableContainer.outerHeight(true) - scrollHeight - paginationHeight + 1;
  10369. $fixedColumns.css({
  10370. height: height,
  10371. "min-height": "calc(100% - " + (paginationHeight + scrollHeight) + "px)"
  10372. });
  10373. $fixedBody.css({
  10374. height: height - $fixedHeader.height(),
  10375. "min-height": "calc(100% - " + $fixedHeader.height() + "px)",
  10376. overflow: "hidden"
  10377. });
  10378. return $fixedBody;
  10379. };
  10380. if (this.needFixedColumns && this.options.fixedNumber) {
  10381. this.$fixedBody = initFixedBody(this.$fixedColumns, this.$fixedHeader);
  10382. }
  10383. if (this.needFixedColumns && this.options.fixedRightNumber) {
  10384. this.$fixedBodyRight = initFixedBody(this.$fixedColumnsRight, this.$fixedHeaderRight);
  10385. this.$fixedBodyRight.scrollLeft(this.$fixedBodyRight.find('table').width());
  10386. this.$fixedBodyRight.css('overflow-y', 'hidden');
  10387. }
  10388. };
  10389. BootstrapTable.prototype.getFixedColumnsWidth = function (isRight) {
  10390. var visibleFields = this.getVisibleFields();
  10391. var width = 0;
  10392. var fixedNumber = this.options.fixedNumber;
  10393. var marginRight = 0;
  10394. if (isRight) {
  10395. visibleFields = visibleFields.reverse();
  10396. fixedNumber = this.options.fixedRightNumber;
  10397. //右侧固定列距离
  10398. this.$fixedColumnsRight.css('right', getTableBodyScrollBarWidth(this.$tableBody));
  10399. }
  10400. for (var i = 0; i < fixedNumber; i++) {
  10401. width += this.$header.find('th[data-field="' + visibleFields[i] + '"]').outerWidth();
  10402. }
  10403. return width + 1;
  10404. };
  10405. BootstrapTable.prototype.initFixedColumnsEvents = function () {
  10406. var that = this;
  10407. var toggleHover = function toggleHover(e, toggle) {
  10408. var tr = 'tr[data-index="' + $(e.currentTarget).data('index') + '"]';
  10409. var $trs = that.$tableBody.find(tr);
  10410. if (that.$fixedBody) {
  10411. $trs = $trs.add(that.$fixedBody.find(tr));
  10412. }
  10413. if (that.$fixedBodyRight) {
  10414. $trs = $trs.add(that.$fixedBodyRight.find(tr));
  10415. }
  10416. $trs.css('background-color', toggle ? $(e.currentTarget).css('background-color') : '');
  10417. };
  10418. this.$tableBody.find('tr').hover(function (e) {
  10419. toggleHover(e, true);
  10420. }, function (e) {
  10421. toggleHover(e, false);
  10422. });
  10423. var isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
  10424. var mousewheel = isFirefox ? 'DOMMouseScroll' : 'mousewheel';
  10425. var updateScroll = function updateScroll(e, fixedBody) {
  10426. var normalized = normalizeWheel(e);
  10427. var deltaY = Math.ceil(normalized.pixelY);
  10428. var top = that.$tableBody.scrollTop() + deltaY;
  10429. if (deltaY < 0 && top > 0 || deltaY > 0 && top < fixedBody.scrollHeight - fixedBody.clientHeight) {
  10430. e.preventDefault();
  10431. }
  10432. that.$tableBody.scrollTop(top);
  10433. if (that.$fixedBody) {
  10434. that.$fixedBody.scrollTop(top);
  10435. }
  10436. if (that.$fixedBodyRight) {
  10437. that.$fixedBodyRight.scrollTop(top);
  10438. }
  10439. };
  10440. if (this.needFixedColumns && this.options.fixedNumber) {
  10441. this.$fixedBody.find('tr').hover(function (e) {
  10442. toggleHover(e, true);
  10443. }, function (e) {
  10444. toggleHover(e, false);
  10445. });
  10446. this.$fixedBody[0].addEventListener(mousewheel, function (e) {
  10447. //给鼠标滑轮绑定事件
  10448. updateScroll(e, that.$fixedBody[0]);
  10449. });
  10450. //给固定表格的checkbox绑定事件
  10451. this.$fixedBody.find('input[name="' + this.options.selectItemName + '"]').off("click").on('click', function (e) {
  10452. e.stopImmediatePropagation();
  10453. var index = $(e.target).data("index");
  10454. $(that.$selectItem[index]).trigger("click");
  10455. });
  10456. //绑定TD点击事件
  10457. this.$fixedBody.find('> table > tbody > tr[data-index] > td').off('click dblclick').on('click dblclick', function (e) {
  10458. var index = $(this).closest("tr[data-index]").data("index");
  10459. $(that.$selectItem[index]).closest("tr[data-index]").find(">td:eq(" + $(this).index() + ")").trigger("click");
  10460. });
  10461. }
  10462. //给原本表格绑定scroll事件
  10463. $('div.fixed-table-body').off('scroll'); //给所有的body解绑 scroll
  10464. this.$tableBody.off('scroll').on('scroll', function (e) {
  10465. that.$tableHeader.scrollLeft(0);
  10466. if (that.$tableBody.scrollLeft() > 0) {
  10467. that.$tableHeader.scrollLeft(that.$tableBody.scrollLeft());
  10468. if (that.options.showFooter && !that.options.cardView) {
  10469. that.$tableFooter.scrollLeft(that.$tableBody.scrollLeft());
  10470. }
  10471. }
  10472. var top = that.$tableBody.scrollTop();
  10473. if (that.$fixedBody) {
  10474. that.$fixedBody.scrollTop(top);
  10475. }
  10476. if (that.$fixedBodyRight) {
  10477. that.$fixedBodyRight.scrollTop(top);
  10478. }
  10479. });
  10480. if (this.needFixedColumns && this.options.fixedRightNumber) {
  10481. this.$fixedBodyRight.find('tr').hover(function (e) {
  10482. toggleHover(e, true);
  10483. }, function (e) {
  10484. toggleHover(e, false);
  10485. });
  10486. this.$fixedBodyRight[0].addEventListener(mousewheel, function (e) {
  10487. //给鼠标滑轮绑定事件
  10488. updateScroll(e, that.$fixedBodyRight[0]);
  10489. });
  10490. //给固定表格的checkbox绑定事件
  10491. this.$fixedBodyRight.find('input[name="' + this.options.selectItemName + '"]').off("click").on('click', function (e) {
  10492. e.stopImmediatePropagation();
  10493. var index = $(e.target).data("index");
  10494. $(that.$selectItem[index]).trigger("click");
  10495. });
  10496. //绑定TD点击事件
  10497. this.$fixedBodyRight.find('> table > tbody > tr[data-index] > td').off('click dblclick').on('click dblclick', function (e) {
  10498. var index = $(this).closest("tr[data-index]").data("index");
  10499. $(that.$selectItem[index]).closest("tr[data-index]").find(">td:eq(" + $(this).index() + ")").trigger("click");
  10500. });
  10501. }
  10502. if (this.options.filterControl) {
  10503. $(this.$fixedColumns).off('keyup change').on('keyup change', function (e) {
  10504. var $target = $(e.target);
  10505. var value = $target.val();
  10506. var field = $target.parents('th').data('field');
  10507. var $coreTh = that.$header.find('th[data-field="' + field + '"]');
  10508. if ($target.is('input')) {
  10509. $coreTh.find('input').val(value);
  10510. } else if ($target.is('select')) {
  10511. var $select = $coreTh.find('select');
  10512. $select.find('option[selected]').removeAttr('selected');
  10513. $select.find('option[value="' + value + '"]').attr('selected', true);
  10514. }
  10515. that.triggerSearch();
  10516. });
  10517. }
  10518. };
  10519. })(jQuery);
  10520. define("bootstrap-table-fixed-columns", ["bootstrap-table"], (function (global) {
  10521. return function () {
  10522. var ret, fn;
  10523. return ret || global.$.fn.bootstrapTable.defaults;
  10524. };
  10525. }(this)));
  10526. define('table',['jquery', 'bootstrap'], function ($, undefined) {
  10527. var Table = {
  10528. list: {},
  10529. // Bootstrap-table 基础配置
  10530. defaults: {
  10531. url: '',
  10532. sidePagination: 'server',
  10533. method: 'get', //请求方法
  10534. toolbar: ".toolbar", //工具栏
  10535. search: true, //是否启用快速搜索
  10536. cache: false,
  10537. commonSearch: true, //是否启用通用搜索
  10538. searchFormVisible: false, //是否始终显示搜索表单
  10539. titleForm: '', //为空则不显示标题,不定义默认显示:普通搜索
  10540. idTable: 'commonTable',
  10541. showExport: true,
  10542. exportDataType: "auto",
  10543. exportTypes: ['json', 'xml', 'csv', 'txt', 'doc', 'excel'],
  10544. exportOptions: {
  10545. fileName: 'export_' + Moment().format("YYYY-MM-DD"),
  10546. preventInjection: false,
  10547. mso: {
  10548. onMsoNumberFormat: function (cell, row, col) {
  10549. return !isNaN($(cell).text()) ? '\\@' : '';
  10550. },
  10551. },
  10552. ignoreColumn: [0, 'operate'] //默认不导出第一列(checkbox)与操作(operate)列
  10553. },
  10554. pageSize: Config.pagesize || localStorage.getItem("pagesize") || 10,
  10555. pageList: [10, 15, 20, 25, 50, 'All'],
  10556. pagination: true,
  10557. clickToSelect: true, //是否启用点击选中
  10558. dblClickToEdit: true, //是否启用双击编辑
  10559. singleSelect: false, //是否启用单选
  10560. showRefresh: false,
  10561. showJumpto: true,
  10562. locale: Config.language === 'en' ? 'en-US' : Config.language.replace(/\-(\w+)$/, function (value) {
  10563. return value.toUpperCase();
  10564. }),
  10565. showToggle: true,
  10566. showColumns: true,
  10567. pk: 'id',
  10568. sortName: 'id',
  10569. sortOrder: 'desc',
  10570. paginationFirstText: __("First"),
  10571. paginationPreText: __("Previous"),
  10572. paginationNextText: __("Next"),
  10573. paginationLastText: __("Last"),
  10574. cardView: false, //卡片视图
  10575. iosCardView: true, //ios卡片视图
  10576. checkOnInit: true, //是否在初始化时判断
  10577. escape: true, //是否对内容进行转义
  10578. fixDropdownPosition: true, //是否修复下拉的定位
  10579. selectedIds: [],
  10580. selectedData: [],
  10581. extend: {
  10582. index_url: '',
  10583. add_url: '',
  10584. edit_url: '',
  10585. del_url: '',
  10586. import_url: '',
  10587. multi_url: '',
  10588. dragsort_url: 'ajax/weigh',
  10589. }
  10590. },
  10591. // Bootstrap-table 列配置
  10592. columnDefaults: {
  10593. align: 'center',
  10594. valign: 'middle',
  10595. },
  10596. config: {
  10597. checkboxtd: 'tbody>tr>td.bs-checkbox',
  10598. toolbar: '.toolbar',
  10599. refreshbtn: '.btn-refresh',
  10600. addbtn: '.btn-add',
  10601. editbtn: '.btn-edit',
  10602. delbtn: '.btn-del',
  10603. importbtn: '.btn-import',
  10604. multibtn: '.btn-multi',
  10605. disabledbtn: '.btn-disabled',
  10606. editonebtn: '.btn-editone',
  10607. restoreonebtn: '.btn-restoreone',
  10608. destroyonebtn: '.btn-destroyone',
  10609. restoreallbtn: '.btn-restoreall',
  10610. destroyallbtn: '.btn-destroyall',
  10611. dragsortfield: 'weigh',
  10612. },
  10613. button: {
  10614. edit: {
  10615. name: 'edit',
  10616. icon: 'fa fa-pencil',
  10617. title: __('Edit'),
  10618. extend: 'data-toggle="tooltip"',
  10619. classname: 'btn btn-xs btn-success btn-editone'
  10620. },
  10621. del: {
  10622. name: 'del',
  10623. icon: 'fa fa-trash',
  10624. title: __('Del'),
  10625. extend: 'data-toggle="tooltip"',
  10626. classname: 'btn btn-xs btn-danger btn-delone'
  10627. },
  10628. dragsort: {
  10629. name: 'dragsort',
  10630. icon: 'fa fa-arrows',
  10631. title: __('Drag to sort'),
  10632. extend: 'data-toggle="tooltip"',
  10633. classname: 'btn btn-xs btn-primary btn-dragsort'
  10634. }
  10635. },
  10636. api: {
  10637. init: function (defaults, columnDefaults, locales) {
  10638. defaults = defaults ? defaults : {};
  10639. columnDefaults = columnDefaults ? columnDefaults : {};
  10640. locales = locales ? locales : {};
  10641. $.fn.bootstrapTable.Constructor.prototype.getSelectItem = function () {
  10642. return this.$selectItem;
  10643. };
  10644. var _onPageListChange = $.fn.bootstrapTable.Constructor.prototype.onPageListChange;
  10645. $.fn.bootstrapTable.Constructor.prototype.onPageListChange = function () {
  10646. _onPageListChange.apply(this, Array.prototype.slice.apply(arguments));
  10647. localStorage.setItem('pagesize', this.options.pageSize);
  10648. return false;
  10649. };
  10650. // 写入bootstrap-table默认配置
  10651. $.extend(true, $.fn.bootstrapTable.defaults, Table.defaults, defaults);
  10652. // 写入bootstrap-table column配置
  10653. $.extend($.fn.bootstrapTable.columnDefaults, Table.columnDefaults, columnDefaults);
  10654. // 写入bootstrap-table locale配置
  10655. $.extend($.fn.bootstrapTable.locales[Table.defaults.locale], {
  10656. formatCommonSearch: function () {
  10657. return __('Common search');
  10658. },
  10659. formatCommonSubmitButton: function () {
  10660. return __('Search');
  10661. },
  10662. formatCommonResetButton: function () {
  10663. return __('Reset');
  10664. },
  10665. formatCommonCloseButton: function () {
  10666. return __('Close');
  10667. },
  10668. formatCommonChoose: function () {
  10669. return __('Choose');
  10670. },
  10671. formatJumpto: function () {
  10672. return __('Go');
  10673. }
  10674. }, locales);
  10675. // 如果是iOS设备则判断是否启用卡片视图
  10676. if ($.fn.bootstrapTable.defaults.iosCardView && navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
  10677. Table.defaults.cardView = true;
  10678. $.fn.bootstrapTable.defaults.cardView = true;
  10679. }
  10680. if (typeof defaults.exportTypes != 'undefined') {
  10681. $.fn.bootstrapTable.defaults.exportTypes = defaults.exportTypes;
  10682. }
  10683. },
  10684. // 绑定事件
  10685. bindevent: function (table) {
  10686. //Bootstrap-table的父元素,包含table,toolbar,pagnation
  10687. var parenttable = table.closest('.bootstrap-table');
  10688. //Bootstrap-table配置
  10689. var options = table.bootstrapTable('getOptions');
  10690. //Bootstrap操作区
  10691. var toolbar = $(options.toolbar, parenttable);
  10692. //跨页提示按钮
  10693. var tipsBtn = $(".btn-selected-tips", parenttable);
  10694. if (tipsBtn.length === 0) {
  10695. 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);
  10696. }
  10697. //点击提示按钮
  10698. tipsBtn.off("click").on("click", function (e) {
  10699. table.trigger("uncheckbox");
  10700. table.bootstrapTable("refresh");
  10701. });
  10702. //当刷新表格时
  10703. table.on('uncheckbox', function (status, res, e) {
  10704. options.selectedIds = [];
  10705. options.selectedData = [];
  10706. tipsBtn.tooltip('hide');
  10707. tipsBtn.addClass('hide');
  10708. });
  10709. //表格加载出错时
  10710. table.on('load-error.bs.table', function (status, res, e) {
  10711. if (e.status === 0) {
  10712. return;
  10713. }
  10714. Toastr.error(__('Unknown data format'));
  10715. });
  10716. //当加载数据成功时
  10717. table.on('load-success.bs.table', function (e, data) {
  10718. if (typeof data.rows === 'undefined' && typeof data.code != 'undefined') {
  10719. Toastr.error(data.msg);
  10720. }
  10721. });
  10722. //当刷新表格时
  10723. table.on('refresh.bs.table', function (e, settings, data) {
  10724. $(Table.config.refreshbtn, toolbar).find(".fa").addClass("fa-spin");
  10725. });
  10726. //当执行搜索时
  10727. table.on('search.bs.table common-search.bs.table', function (e, settings, data) {
  10728. table.trigger("uncheckbox");
  10729. });
  10730. if (options.dblClickToEdit) {
  10731. //当双击单元格时
  10732. table.on('dbl-click-row.bs.table', function (e, row, element, field) {
  10733. $(Table.config.editonebtn, element).trigger("click");
  10734. });
  10735. }
  10736. //渲染内容前
  10737. table.on('pre-body.bs.table', function (e, data) {
  10738. if (options.maintainSelected) {
  10739. $.each(data, function (i, row) {
  10740. row[options.stateField] = $.inArray(row[options.pk], options.selectedIds) > -1;
  10741. });
  10742. }
  10743. });
  10744. //当内容渲染完成后
  10745. table.on('post-body.bs.table', function (e, data) {
  10746. $(Table.config.refreshbtn, toolbar).find(".fa").removeClass("fa-spin");
  10747. if ($(Table.config.checkboxtd + ":first", table).find("input[type='checkbox'][data-index]").length > 0) {
  10748. // 拖拽选择,需要重新绑定事件
  10749. require(['drag', 'drop'], function () {
  10750. var checkboxtd = $(Table.config.checkboxtd, table);
  10751. checkboxtd.drag("start", function (ev, dd) {
  10752. return $('<div class="selection" />').css('opacity', .65).appendTo(document.body);
  10753. }).drag(function (ev, dd) {
  10754. setTimeout(function () {
  10755. $(dd.proxy).css({
  10756. top: Math.min(ev.pageY, dd.startY),
  10757. left: Math.min(ev.pageX, dd.startX),
  10758. height: Math.abs(ev.pageY - dd.startY),
  10759. width: Math.abs(ev.pageX - dd.startX)
  10760. });
  10761. }, 0);
  10762. }).drag("end", function (ev, dd) {
  10763. $(dd.proxy).remove();
  10764. });
  10765. checkboxtd.drop("start", function () {
  10766. Table.api.toggleattr(this);
  10767. }).drop(function () {
  10768. // Table.api.toggleattr(this);
  10769. }).drop("end", function (e) {
  10770. var that = this;
  10771. setTimeout(function () {
  10772. if (e.type === 'mousemove') {
  10773. Table.api.toggleattr(that);
  10774. }
  10775. }, 0);
  10776. });
  10777. $.drop({
  10778. multi: true
  10779. });
  10780. });
  10781. }
  10782. });
  10783. var exportDataType = options.exportDataType;
  10784. // 处理选中筛选框后按钮的状态统一变更
  10785. table.on('check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table post-body.bs.table', function (e) {
  10786. var allIds = [];
  10787. $.each(table.bootstrapTable("getData"), function (i, item) {
  10788. allIds.push(typeof item[options.pk] != 'undefined' ? item[options.pk] : '');
  10789. });
  10790. var selectedIds = Table.api.selectedids(table, true),
  10791. selectedData = Table.api.selecteddata(table, true);
  10792. //开启分页checkbox分页记忆
  10793. if (options.maintainSelected) {
  10794. options.selectedIds = options.selectedIds.filter(function (element, index, self) {
  10795. return $.inArray(element, allIds) === -1;
  10796. }).concat(selectedIds);
  10797. options.selectedData = options.selectedData.filter(function (element, index, self) {
  10798. return $.inArray(element[options.pk], allIds) === -1;
  10799. }).concat(selectedData);
  10800. if (options.selectedIds.length > selectedIds.length) {
  10801. $("b", tipsBtn).text(options.selectedIds.length);
  10802. tipsBtn.removeClass('hide');
  10803. } else {
  10804. tipsBtn.addClass('hide');
  10805. }
  10806. } else {
  10807. options.selectedIds = selectedIds;
  10808. options.selectedData = selectedData;
  10809. }
  10810. //如果导出类型为auto时则自动判断
  10811. if (exportDataType === 'auto') {
  10812. options.exportDataType = selectedIds.length > 0 ? 'selected' : 'all';
  10813. }
  10814. $(Table.config.disabledbtn, toolbar).toggleClass('disabled', !options.selectedIds.length);
  10815. });
  10816. // 绑定TAB事件
  10817. $('.panel-heading [data-field] a[data-toggle="tab"]', table.closest(".panel-intro")).on('shown.bs.tab', function (e) {
  10818. var field = $(this).closest("[data-field]").data("field");
  10819. var value = $(this).data("value");
  10820. var object = $("[name='" + field + "']", table.closest(".bootstrap-table").find(".commonsearch-table"));
  10821. if (object.prop('tagName') == "SELECT") {
  10822. $("option[value='" + value + "']", object).prop("selected", true);
  10823. } else {
  10824. object.val(value);
  10825. }
  10826. table.trigger("uncheckbox");
  10827. table.bootstrapTable('refresh', {pageNumber: 1});
  10828. return false;
  10829. });
  10830. // 修复重置事件
  10831. $("form", table.closest(".bootstrap-table").find(".commonsearch-table")).on('reset', function () {
  10832. setTimeout(function () {
  10833. // $('.panel-heading [data-field] li.active a[data-toggle="tab"]').trigger('shown.bs.tab');
  10834. }, 0);
  10835. $('.panel-heading [data-field] li', table.closest(".panel-intro")).removeClass('active');
  10836. $('.panel-heading [data-field] li:first', table.closest(".panel-intro")).addClass('active');
  10837. });
  10838. // 刷新按钮事件
  10839. toolbar.on('click', Table.config.refreshbtn, function () {
  10840. table.bootstrapTable('refresh');
  10841. });
  10842. // 添加按钮事件
  10843. toolbar.on('click', Table.config.addbtn, function () {
  10844. var ids = Table.api.selectedids(table);
  10845. var url = options.extend.add_url;
  10846. if (url.indexOf("{ids}") !== -1) {
  10847. url = Table.api.replaceurl(url, {ids: ids.length > 0 ? ids.join(",") : 0}, table);
  10848. }
  10849. Fast.api.open(url, $(this).data("original-title") || $(this).attr("title") || __('Add'), $(this).data() || {});
  10850. });
  10851. // 导入按钮事件
  10852. if ($(Table.config.importbtn, toolbar).length > 0) {
  10853. require(['upload'], function (Upload) {
  10854. Upload.api.upload($(Table.config.importbtn, toolbar), function (data, ret) {
  10855. Fast.api.ajax({
  10856. url: options.extend.import_url,
  10857. data: {file: data.url},
  10858. }, function (data, ret) {
  10859. table.trigger("uncheckbox");
  10860. table.bootstrapTable('refresh');
  10861. });
  10862. });
  10863. });
  10864. }
  10865. // 批量编辑按钮事件
  10866. toolbar.on('click', Table.config.editbtn, function () {
  10867. var that = this;
  10868. var ids = Table.api.selectedids(table);
  10869. if (ids.length > 10) {
  10870. return;
  10871. }
  10872. var title = $(that).data('title') || $(that).attr("title") || __('Edit');
  10873. var data = $(that).data() || {};
  10874. delete data.title;
  10875. //循环弹出多个编辑框
  10876. $.each(Table.api.selecteddata(table), function (index, row) {
  10877. var url = options.extend.edit_url;
  10878. row = $.extend({}, row ? row : {}, {ids: row[options.pk]});
  10879. url = Table.api.replaceurl(url, row, table);
  10880. Fast.api.open(url, typeof title === 'function' ? title.call(table, row) : title, data);
  10881. });
  10882. });
  10883. //清空回收站
  10884. $(document).on('click', Table.config.destroyallbtn, function () {
  10885. var that = this;
  10886. Layer.confirm(__('Are you sure you want to truncate?'), function () {
  10887. var url = $(that).data("url") ? $(that).data("url") : $(that).attr("href");
  10888. Fast.api.ajax(url, function () {
  10889. Layer.closeAll();
  10890. table.trigger("uncheckbox");
  10891. table.bootstrapTable('refresh');
  10892. }, function () {
  10893. Layer.closeAll();
  10894. });
  10895. });
  10896. return false;
  10897. });
  10898. //全部还原
  10899. $(document).on('click', Table.config.restoreallbtn, function () {
  10900. var that = this;
  10901. var url = $(that).data("url") ? $(that).data("url") : $(that).attr("href");
  10902. Fast.api.ajax(url, function () {
  10903. Layer.closeAll();
  10904. table.trigger("uncheckbox");
  10905. table.bootstrapTable('refresh');
  10906. }, function () {
  10907. Layer.closeAll();
  10908. });
  10909. return false;
  10910. });
  10911. //销毁或删除
  10912. $(document).on('click', Table.config.restoreonebtn + ',' + Table.config.destroyonebtn, function () {
  10913. var that = this;
  10914. var url = $(that).data("url") ? $(that).data("url") : $(that).attr("href");
  10915. var row = Table.api.getrowbyindex(table, $(that).data("row-index"));
  10916. Fast.api.ajax({
  10917. url: url,
  10918. data: {ids: row[options.pk]}
  10919. }, function () {
  10920. table.trigger("uncheckbox");
  10921. table.bootstrapTable('refresh');
  10922. });
  10923. return false;
  10924. });
  10925. // 批量操作按钮事件
  10926. toolbar.on('click', Table.config.multibtn, function () {
  10927. var ids = Table.api.selectedids(table);
  10928. Table.api.multi($(this).data("action"), ids, table, this);
  10929. });
  10930. // 批量删除按钮事件
  10931. toolbar.on('click', Table.config.delbtn, function () {
  10932. var that = this;
  10933. var ids = Table.api.selectedids(table);
  10934. Layer.confirm(
  10935. __('Are you sure you want to delete the %s selected item?', ids.length),
  10936. {icon: 3, title: __('Warning'), offset: 0, shadeClose: true, btn: [__('OK'), __('Cancel')]},
  10937. function (index) {
  10938. Table.api.multi("del", ids, table, that);
  10939. Layer.close(index);
  10940. }
  10941. );
  10942. });
  10943. // 拖拽排序
  10944. require(['dragsort'], function () {
  10945. //绑定拖动排序
  10946. $("tbody", table).dragsort({
  10947. itemSelector: 'tr:visible',
  10948. dragSelector: "a.btn-dragsort",
  10949. dragEnd: function (a, b) {
  10950. var element = $("a.btn-dragsort", this);
  10951. var data = table.bootstrapTable('getData');
  10952. var current = data[parseInt($(this).data("index"))];
  10953. var options = table.bootstrapTable('getOptions');
  10954. //改变的值和改变的ID集合
  10955. var ids = $.map($("tbody tr:visible", table), function (tr) {
  10956. return data[parseInt($(tr).data("index"))][options.pk];
  10957. });
  10958. var changeid = current[options.pk];
  10959. var pid = typeof current.pid != 'undefined' ? current.pid : '';
  10960. var params = {
  10961. url: table.bootstrapTable('getOptions').extend.dragsort_url,
  10962. data: {
  10963. ids: ids.join(','),
  10964. changeid: changeid,
  10965. pid: pid,
  10966. field: Table.config.dragsortfield,
  10967. orderway: options.sortOrder,
  10968. table: options.extend.table,
  10969. pk: options.pk
  10970. }
  10971. };
  10972. Fast.api.ajax(params, function (data, ret) {
  10973. var success = $(element).data("success") || $.noop;
  10974. if (typeof success === 'function') {
  10975. if (false === success.call(element, data, ret)) {
  10976. return false;
  10977. }
  10978. }
  10979. table.bootstrapTable('refresh');
  10980. }, function (data, ret) {
  10981. var error = $(element).data("error") || $.noop;
  10982. if (typeof error === 'function') {
  10983. if (false === error.call(element, data, ret)) {
  10984. return false;
  10985. }
  10986. }
  10987. table.bootstrapTable('refresh');
  10988. });
  10989. },
  10990. placeHolderTemplate: ""
  10991. });
  10992. });
  10993. table.on("click", "input[data-id][name='checkbox']", function (e) {
  10994. var ids = $(this).data("id");
  10995. table.bootstrapTable($(this).prop("checked") ? 'checkBy' : 'uncheckBy', {field: options.pk, values: [ids]});
  10996. });
  10997. table.on("click", "[data-id].btn-change", function (e) {
  10998. e.preventDefault();
  10999. var changer = $.proxy(function () {
  11000. Table.api.multi($(this).data("action") ? $(this).data("action") : '', [$(this).data("id")], table, this);
  11001. }, this);
  11002. if (typeof $(this).data("confirm") !== 'undefined') {
  11003. Layer.confirm($(this).data("confirm"), function (index) {
  11004. changer();
  11005. Layer.close(index);
  11006. });
  11007. } else {
  11008. changer();
  11009. }
  11010. });
  11011. table.on("click", "[data-id].btn-edit", function (e) {
  11012. e.preventDefault();
  11013. var ids = $(this).data("id");
  11014. var row = Table.api.getrowbyid(table, ids);
  11015. row.ids = ids;
  11016. var url = Table.api.replaceurl(options.extend.edit_url, row, table);
  11017. Fast.api.open(url, $(this).data("original-title") || $(this).attr("title") || __('Edit'), $(this).data() || {});
  11018. });
  11019. table.on("click", "[data-id].btn-del", function (e) {
  11020. e.preventDefault();
  11021. var id = $(this).data("id");
  11022. var that = this;
  11023. Layer.confirm(
  11024. __('Are you sure you want to delete this item?'),
  11025. {icon: 3, title: __('Warning'), shadeClose: true, btn: [__('OK'), __('Cancel')]},
  11026. function (index) {
  11027. Table.api.multi("del", id, table, that);
  11028. Layer.close(index);
  11029. }
  11030. );
  11031. });
  11032. //修复dropdown定位溢出的情况
  11033. if (options.fixDropdownPosition) {
  11034. var tableBody = table.closest(".fixed-table-body");
  11035. table.on('show.bs.dropdown fa.event.refreshdropdown', ".btn-group", function (e) {
  11036. var dropdownMenu = $(".dropdown-menu", this);
  11037. var btnGroup = $(this);
  11038. var isPullRight = dropdownMenu.hasClass("pull-right") || dropdownMenu.hasClass("dropdown-menu-right");
  11039. var left, top, position;
  11040. if (true || dropdownMenu.outerHeight() + btnGroup.outerHeight() > tableBody.outerHeight() - 41) {
  11041. position = 'fixed';
  11042. top = btnGroup.offset().top - $(window).scrollTop() + btnGroup.outerHeight();
  11043. if ((top + dropdownMenu.outerHeight()) > $(window).height()) {
  11044. top = btnGroup.offset().top - dropdownMenu.outerHeight() - 5;
  11045. }
  11046. left = isPullRight ? btnGroup.offset().left + btnGroup.outerWidth() - dropdownMenu.outerWidth() : btnGroup.offset().left;
  11047. }
  11048. if (left || top) {
  11049. dropdownMenu.css({
  11050. position: position, left: left, top: top, right: 'inherit'
  11051. });
  11052. }
  11053. });
  11054. var checkdropdown = function () {
  11055. if ($(".btn-group.open", table).length > 0 && $(".btn-group.open .dropdown-menu", table).css("position") == 'fixed') {
  11056. $(".btn-group.open", table).trigger("fa.event.refreshdropdown");
  11057. }
  11058. };
  11059. $(window).on("scroll", function () {
  11060. checkdropdown();
  11061. });
  11062. tableBody.on("scroll", function () {
  11063. checkdropdown();
  11064. });
  11065. }
  11066. var id = table.attr("id");
  11067. Table.list[id] = table;
  11068. return table;
  11069. },
  11070. // 批量操作请求
  11071. multi: function (action, ids, table, element) {
  11072. var options = table.bootstrapTable('getOptions');
  11073. var data = element ? $(element).data() : {};
  11074. ids = ($.isArray(ids) ? ids.join(",") : ids);
  11075. var url = typeof data.url !== "undefined" ? data.url : (action == "del" ? options.extend.del_url : options.extend.multi_url);
  11076. var params = typeof data.params !== "undefined" ? (typeof data.params == 'object' ? $.param(data.params) : data.params) : '';
  11077. options = {url: url, data: {action: action, ids: ids, params: params}};
  11078. Fast.api.ajax(options, function (data, ret) {
  11079. table.trigger("uncheckbox");
  11080. var success = $(element).data("success") || $.noop;
  11081. if (typeof success === 'function') {
  11082. if (false === success.call(element, data, ret)) {
  11083. return false;
  11084. }
  11085. }
  11086. table.bootstrapTable('refresh');
  11087. }, function (data, ret) {
  11088. var error = $(element).data("error") || $.noop;
  11089. if (typeof error === 'function') {
  11090. if (false === error.call(element, data, ret)) {
  11091. return false;
  11092. }
  11093. }
  11094. });
  11095. },
  11096. // 单元格元素事件
  11097. events: {
  11098. operate: {
  11099. 'click .btn-editone': function (e, value, row, index) {
  11100. e.stopPropagation();
  11101. e.preventDefault();
  11102. var table = $(this).closest('table');
  11103. var options = table.bootstrapTable('getOptions');
  11104. var ids = row[options.pk];
  11105. row = $.extend({}, row ? row : {}, {ids: ids});
  11106. var url = options.extend.edit_url;
  11107. Fast.api.open(Table.api.replaceurl(url, row, table), $(this).data("original-title") || $(this).attr("title") || __('Edit'), $(this).data() || {});
  11108. },
  11109. 'click .btn-delone': function (e, value, row, index) {
  11110. e.stopPropagation();
  11111. e.preventDefault();
  11112. var that = this;
  11113. var top = $(that).offset().top - $(window).scrollTop();
  11114. var left = $(that).offset().left - $(window).scrollLeft() - 260;
  11115. if (top + 154 > $(window).height()) {
  11116. top = top - 154;
  11117. }
  11118. if ($(window).width() < 480) {
  11119. top = left = undefined;
  11120. }
  11121. Layer.confirm(
  11122. __('Are you sure you want to delete this item?'),
  11123. {icon: 3, title: __('Warning'), offset: [top, left], shadeClose: true, btn: [__('OK'), __('Cancel')]},
  11124. function (index) {
  11125. var table = $(that).closest('table');
  11126. var options = table.bootstrapTable('getOptions');
  11127. Table.api.multi("del", row[options.pk], table, that);
  11128. Layer.close(index);
  11129. }
  11130. );
  11131. }
  11132. },//单元格图片预览
  11133. image: {
  11134. 'click .img-center': function (e, value, row, index) {
  11135. var data = [];
  11136. value = value === null ? '' : value.toString();
  11137. var arr = value != '' ? value.split(",") : [];
  11138. var url;
  11139. $.each(arr, function (index, value) {
  11140. url = Fast.api.cdnurl(value);
  11141. data.push({
  11142. src: url,
  11143. thumb: url.match(/^(\/|data:image\\)/) ? url : url + Config.upload.thumbstyle
  11144. });
  11145. });
  11146. Layer.photos({
  11147. photos: {
  11148. "start": $(this).parent().index(),
  11149. "data": data
  11150. },
  11151. anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)
  11152. });
  11153. },
  11154. }
  11155. },
  11156. // 单元格数据格式化
  11157. formatter: {
  11158. icon: function (value, row, index) {
  11159. value = value === null ? '' : value.toString();
  11160. value = value.indexOf(" ") > -1 ? value : "fa fa-" + value;
  11161. //渲染fontawesome图标
  11162. return '<i class="' + value + '"></i> ' + value;
  11163. },
  11164. image: function (value, row, index) {
  11165. return Table.api.formatter.images.call(this, value, row, index);
  11166. },
  11167. images: function (value, row, index) {
  11168. value = value == null || value.length === 0 ? '' : value.toString();
  11169. var classname = typeof this.classname !== 'undefined' ? this.classname : 'img-sm img-center';
  11170. var arr = value !== '' ? value.split(',') : [];
  11171. var html = [];
  11172. var url;
  11173. $.each(arr, function (i, value) {
  11174. value = value ? value : '/assets/img/blank.gif';
  11175. url = Fast.api.cdnurl(value, true);
  11176. url = url.match(/^(\/|data:image\\)/) ? url : url + Config.upload.thumbstyle;
  11177. html.push('<a href="javascript:"><img class="' + classname + '" src="' + url + '" width="30" height="30" /></a>');
  11178. });
  11179. return html.join(' ');
  11180. },
  11181. file: function (value, row, index) {
  11182. return Table.api.formatter.files.call(this, value, row, index);
  11183. },
  11184. files: function (value, row, index) {
  11185. value = value == null || value.length === 0 ? '' : value.toString();
  11186. var classname = typeof this.classname !== 'undefined' ? this.classname : 'img-sm img-center';
  11187. var arr = value !== '' ? value.split(',') : [];
  11188. var html = [];
  11189. var suffix, url;
  11190. $.each(arr, function (i, value) {
  11191. value = Fast.api.cdnurl(value, true);
  11192. suffix = /[\.]?([a-zA-Z0-9]+)$/.exec(value);
  11193. suffix = suffix ? suffix[1] : 'file';
  11194. url = Fast.api.fixurl("ajax/icon?suffix=" + suffix);
  11195. html.push('<a href="' + value + '" target="_blank"><img src="' + url + '" class="' + classname + '" width="30" height="30"></a>');
  11196. });
  11197. return html.join(' ');
  11198. },
  11199. content: function (value, row, index) {
  11200. var width = this.width != undefined ? (this.width.match(/^\d+$/) ? this.width + "px" : this.width) : "250px";
  11201. return "<div style='white-space: nowrap; text-overflow:ellipsis; overflow: hidden; max-width:" + width + ";'>" + value + "</div>";
  11202. },
  11203. status: function (value, row, index) {
  11204. var custom = {normal: 'success', hidden: 'gray', deleted: 'danger', locked: 'info'};
  11205. if (typeof this.custom !== 'undefined') {
  11206. custom = $.extend(custom, this.custom);
  11207. }
  11208. this.custom = custom;
  11209. this.icon = 'fa fa-circle';
  11210. return Table.api.formatter.normal.call(this, value, row, index);
  11211. },
  11212. normal: function (value, row, index) {
  11213. var colorArr = ["primary", "success", "danger", "warning", "info", "gray", "red", "yellow", "aqua", "blue", "navy", "teal", "olive", "lime", "fuchsia", "purple", "maroon"];
  11214. var custom = {};
  11215. if (typeof this.custom !== 'undefined') {
  11216. custom = $.extend(custom, this.custom);
  11217. }
  11218. value = value == null || value.length === 0 ? '' : value.toString();
  11219. var keys = typeof this.searchList === 'object' ? Object.keys(this.searchList) : [];
  11220. var index = keys.indexOf(value);
  11221. var color = value && typeof custom[value] !== 'undefined' ? custom[value] : null;
  11222. var display = index > -1 ? this.searchList[value] : null;
  11223. var icon = typeof this.icon !== 'undefined' ? this.icon : null;
  11224. if (!color) {
  11225. color = index > -1 && typeof colorArr[index] !== 'undefined' ? colorArr[index] : 'primary';
  11226. }
  11227. if (!display) {
  11228. display = __(value.charAt(0).toUpperCase() + value.slice(1));
  11229. }
  11230. var html = '<span class="text-' + color + '">' + (icon ? '<i class="' + icon + '"></i> ' : '') + display + '</span>';
  11231. if (this.operate != false) {
  11232. html = '<a href="javascript:;" class="searchit" data-toggle="tooltip" title="' + __('Click to search %s', display) + '" data-field="' + this.field + '" data-value="' + value + '">' + html + '</a>';
  11233. }
  11234. return html;
  11235. },
  11236. toggle: function (value, row, index) {
  11237. var table = this.table;
  11238. var options = table ? table.bootstrapTable('getOptions') : {};
  11239. var pk = options.pk || "id";
  11240. var color = typeof this.color !== 'undefined' ? this.color : 'success';
  11241. var yes = typeof this.yes !== 'undefined' ? this.yes : 1;
  11242. var no = typeof this.no !== 'undefined' ? this.no : 0;
  11243. var url = typeof this.url !== 'undefined' ? this.url : '';
  11244. var confirm = '';
  11245. var disable = false;
  11246. if (typeof this.confirm !== "undefined") {
  11247. confirm = typeof this.confirm === "function" ? this.confirm.call(this, value, row, index) : this.confirm;
  11248. }
  11249. if (typeof this.disable !== "undefined") {
  11250. disable = typeof this.disable === "function" ? this.disable.call(this, value, row, index) : this.disable;
  11251. }
  11252. return "<a href='javascript:;' data-toggle='tooltip' title='" + __('Click to toggle') + "' class='btn-change " + (disable ? 'btn disabled no-padding' : '') + "' data-index='" + index + "' data-id='"
  11253. + 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>";
  11254. },
  11255. url: function (value, row, index) {
  11256. value = value == null || value.length === 0 ? '' : value.toString();
  11257. 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>';
  11258. },
  11259. search: function (value, row, index) {
  11260. var field = this.field;
  11261. if (typeof this.customField !== 'undefined' && typeof row[this.customField] !== 'undefined') {
  11262. value = row[this.customField];
  11263. field = this.customField;
  11264. }
  11265. return '<a href="javascript:;" class="searchit" data-toggle="tooltip" title="' + __('Click to search %s', value) + '" data-field="' + field + '" data-value="' + value + '">' + value + '</a>';
  11266. },
  11267. addtabs: function (value, row, index) {
  11268. var url = Table.api.replaceurl(this.url || '', row, this.table);
  11269. var title = this.atitle ? this.atitle : __("Search %s", value);
  11270. return '<a href="' + Fast.api.fixurl(url) + '" class="addtabsit" data-value="' + value + '" title="' + title + '">' + value + '</a>';
  11271. },
  11272. dialog: function (value, row, index) {
  11273. var url = Table.api.replaceurl(this.url || '', row, this.table);
  11274. var title = this.atitle ? this.atitle : __("View %s", value);
  11275. return '<a href="' + Fast.api.fixurl(url) + '" class="dialogit" data-value="' + value + '" title="' + title + '">' + value + '</a>';
  11276. },
  11277. flag: function (value, row, index) {
  11278. var that = this;
  11279. value = value == null || value.length === 0 ? '' : value.toString();
  11280. var colorArr = {index: 'success', hot: 'warning', recommend: 'danger', 'new': 'info'};
  11281. //如果字段列有定义custom
  11282. if (typeof this.custom !== 'undefined') {
  11283. colorArr = $.extend(colorArr, this.custom);
  11284. }
  11285. var field = this.field;
  11286. if (typeof this.customField !== 'undefined' && typeof row[this.customField] !== 'undefined') {
  11287. value = row[this.customField];
  11288. field = this.customField;
  11289. }
  11290. if (typeof that.searchList === 'object' && typeof that.custom === 'undefined') {
  11291. var i = 0;
  11292. var searchValues = Object.keys(colorArr).map(function (e) {
  11293. return colorArr[e];
  11294. });
  11295. $.each(that.searchList, function (key, val) {
  11296. if (typeof colorArr[key] == 'undefined') {
  11297. colorArr[key] = searchValues[i];
  11298. i = typeof searchValues[i + 1] === 'undefined' ? 0 : i + 1;
  11299. }
  11300. });
  11301. }
  11302. //渲染Flag
  11303. var html = [];
  11304. var arr = value !== '' ? value.split(',') : [];
  11305. var color, display, label;
  11306. $.each(arr, function (i, value) {
  11307. value = value == null || value.length === 0 ? '' : value.toString();
  11308. if (value === '')
  11309. return true;
  11310. color = value && typeof colorArr[value] !== 'undefined' ? colorArr[value] : 'primary';
  11311. display = typeof that.searchList !== 'undefined' && typeof that.searchList[value] !== 'undefined' ? that.searchList[value] : __(value.charAt(0).toUpperCase() + value.slice(1));
  11312. label = '<span class="label label-' + color + '">' + display + '</span>';
  11313. if (that.operate) {
  11314. html.push('<a href="javascript:;" class="searchit" data-toggle="tooltip" title="' + __('Click to search %s', display) + '" data-field="' + field + '" data-value="' + value + '">' + label + '</a>');
  11315. } else {
  11316. html.push(label);
  11317. }
  11318. });
  11319. return html.join(' ');
  11320. },
  11321. label: function (value, row, index) {
  11322. return Table.api.formatter.flag.call(this, value, row, index);
  11323. },
  11324. datetime: function (value, row, index) {
  11325. var datetimeFormat = typeof this.datetimeFormat === 'undefined' ? 'YYYY-MM-DD HH:mm:ss' : this.datetimeFormat;
  11326. if (isNaN(value)) {
  11327. return value ? Moment(value).format(datetimeFormat) : __('None');
  11328. } else {
  11329. return value ? Moment(parseInt(value) * 1000).format(datetimeFormat) : __('None');
  11330. }
  11331. },
  11332. operate: function (value, row, index) {
  11333. var table = this.table;
  11334. // 操作配置
  11335. var options = table ? table.bootstrapTable('getOptions') : {};
  11336. // 默认按钮组
  11337. var buttons = $.extend([], this.buttons || []);
  11338. // 所有按钮名称
  11339. var names = [];
  11340. buttons.forEach(function (item) {
  11341. names.push(item.name);
  11342. });
  11343. if (options.extend.dragsort_url !== '' && names.indexOf('dragsort') === -1) {
  11344. buttons.push(Table.button.dragsort);
  11345. }
  11346. if (options.extend.edit_url !== '' && names.indexOf('edit') === -1) {
  11347. Table.button.edit.url = options.extend.edit_url;
  11348. buttons.push(Table.button.edit);
  11349. }
  11350. if (options.extend.del_url !== '' && names.indexOf('del') === -1) {
  11351. buttons.push(Table.button.del);
  11352. }
  11353. return Table.api.buttonlink(this, buttons, value, row, index, 'operate');
  11354. }
  11355. ,
  11356. buttons: function (value, row, index) {
  11357. // 默认按钮组
  11358. var buttons = $.extend([], this.buttons || []);
  11359. return Table.api.buttonlink(this, buttons, value, row, index, 'buttons');
  11360. }
  11361. },
  11362. buttonlink: function (column, buttons, value, row, index, type) {
  11363. var table = column.table;
  11364. column.clickToSelect = false;
  11365. type = typeof type === 'undefined' ? 'buttons' : type;
  11366. var options = table ? table.bootstrapTable('getOptions') : {};
  11367. var html = [];
  11368. var hidden, visible, disable, url, classname, icon, text, title, refresh, confirm, extend,
  11369. dropdown, link;
  11370. var fieldIndex = column.fieldIndex;
  11371. var dropdowns = {};
  11372. $.each(buttons, function (i, j) {
  11373. if (type === 'operate') {
  11374. if (j.name === 'dragsort' && typeof row[Table.config.dragsortfield] === 'undefined') {
  11375. return true;
  11376. }
  11377. if (['add', 'edit', 'del', 'multi', 'dragsort'].indexOf(j.name) > -1 && !options.extend[j.name + "_url"]) {
  11378. return true;
  11379. }
  11380. }
  11381. var attr = table.data(type + "-" + j.name);
  11382. if (typeof attr === 'undefined' || attr) {
  11383. hidden = typeof j.hidden === 'function' ? j.hidden.call(table, row, j) : (typeof j.hidden !== 'undefined' ? j.hidden : false);
  11384. if (hidden) {
  11385. return true;
  11386. }
  11387. visible = typeof j.visible === 'function' ? j.visible.call(table, row, j) : (typeof j.visible !== 'undefined' ? j.visible : true);
  11388. if (!visible) {
  11389. return true;
  11390. }
  11391. dropdown = j.dropdown ? j.dropdown : '';
  11392. url = j.url ? j.url : '';
  11393. url = typeof url === 'function' ? url.call(table, row, j) : (url ? Fast.api.fixurl(Table.api.replaceurl(url, row, table)) : 'javascript:;');
  11394. classname = j.classname ? j.classname : (dropdown ? 'btn-' + name + 'one' : 'btn-primary btn-' + name + 'one');
  11395. icon = j.icon ? j.icon : '';
  11396. text = typeof j.text === 'function' ? j.text.call(table, row, j) : j.text ? j.text : '';
  11397. title = typeof j.title === 'function' ? j.title.call(table, row, j) : j.title ? j.title : text;
  11398. refresh = j.refresh ? 'data-refresh="' + j.refresh + '"' : '';
  11399. confirm = typeof j.confirm === 'function' ? j.confirm.call(table, row, j) : (typeof j.confirm !== 'undefined' ? j.confirm : false);
  11400. confirm = confirm ? 'data-confirm="' + confirm + '"' : '';
  11401. extend = j.extend ? j.extend : '';
  11402. disable = typeof j.disable === 'function' ? j.disable.call(table, row, j) : (typeof j.disable !== 'undefined' ? j.disable : false);
  11403. if (disable) {
  11404. classname = classname + ' disabled';
  11405. }
  11406. 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>';
  11407. if (dropdown) {
  11408. if (typeof dropdowns[dropdown] == 'undefined') {
  11409. dropdowns[dropdown] = [];
  11410. }
  11411. dropdowns[dropdown].push(link);
  11412. } else {
  11413. html.push(link);
  11414. }
  11415. }
  11416. });
  11417. if (!$.isEmptyObject(dropdowns)) {
  11418. var dropdownHtml = [];
  11419. $.each(dropdowns, function (i, j) {
  11420. 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>');
  11421. });
  11422. html.unshift(dropdownHtml);
  11423. }
  11424. return html.join(' ');
  11425. },
  11426. //替换URL中的数据
  11427. replaceurl: function (url, row, table) {
  11428. var options = table ? table.bootstrapTable('getOptions') : null;
  11429. var ids = options ? row[options.pk] : 0;
  11430. row.ids = ids ? ids : (typeof row.ids !== 'undefined' ? row.ids : 0);
  11431. url = url == null || url.length === 0 ? '' : url.toString();
  11432. //自动添加ids参数
  11433. url = !url.match(/\{ids\}/i) ? url + (url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + '{ids}' : url;
  11434. url = url.replace(/\{(.*?)\}/gi, function (matched) {
  11435. matched = matched.substring(1, matched.length - 1);
  11436. if (matched.indexOf(".") !== -1) {
  11437. var temp = row;
  11438. var arr = matched.split(/\./);
  11439. for (var i = 0; i < arr.length; i++) {
  11440. if (typeof temp[arr[i]] !== 'undefined') {
  11441. temp = temp[arr[i]];
  11442. }
  11443. }
  11444. return typeof temp === 'object' ? '' : temp;
  11445. }
  11446. return row[matched];
  11447. });
  11448. return url;
  11449. },
  11450. // 获取选中的条目ID集合
  11451. selectedids: function (table, current) {
  11452. var options = table.bootstrapTable('getOptions');
  11453. //如果有设置翻页记忆模式
  11454. if (!current && options.maintainSelected) {
  11455. return options.selectedIds;
  11456. }
  11457. return $.map(table.bootstrapTable('getSelections'), function (row) {
  11458. return row[options.pk];
  11459. });
  11460. },
  11461. //获取选中的数据
  11462. selecteddata: function (table, current) {
  11463. var options = table.bootstrapTable('getOptions');
  11464. //如果有设置翻页记忆模式
  11465. if (!current && options.maintainSelected) {
  11466. return options.selectedData;
  11467. }
  11468. return table.bootstrapTable('getSelections');
  11469. },
  11470. // 切换复选框状态
  11471. toggleattr: function (table) {
  11472. $("input[type='checkbox']", table).trigger('click');
  11473. },
  11474. // 根据行索引获取行数据
  11475. getrowdata: function (table, index) {
  11476. index = parseInt(index);
  11477. var data = table.bootstrapTable('getData');
  11478. return typeof data[index] !== 'undefined' ? data[index] : null;
  11479. },
  11480. // 根据行索引获取行数据
  11481. getrowbyindex: function (table, index) {
  11482. return Table.api.getrowdata(table, index);
  11483. },
  11484. // 根据主键ID获取行数据
  11485. getrowbyid: function (table, id) {
  11486. var row = {};
  11487. var options = table.bootstrapTable("getOptions");
  11488. $.each(Table.api.selecteddata(table), function (i, j) {
  11489. if (j[options.pk] == id) {
  11490. row = j;
  11491. return false;
  11492. }
  11493. });
  11494. return row;
  11495. }
  11496. },
  11497. };
  11498. return Table;
  11499. });
  11500. // jQuery List DragSort v0.5.2
  11501. // Website: http://dragsort.codeplex.com/
  11502. // License: http://dragsort.codeplex.com/license
  11503. (function($) {
  11504. $.fn.dragsort = function(options) {
  11505. if (options == "destroy") {
  11506. $(this.selector).trigger("dragsort-uninit");
  11507. return;
  11508. }
  11509. var opts = $.extend({}, $.fn.dragsort.defaults, options);
  11510. var lists = [];
  11511. var list = null, lastPos = null;
  11512. this.each(function(i, cont) {
  11513. //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
  11514. if ($(cont).is("table") && $(cont).children().length == 1 && $(cont).children().is("tbody"))
  11515. cont = $(cont).children().get(0);
  11516. var newList = {
  11517. draggedItem: null,
  11518. placeHolderItem: null,
  11519. pos: null,
  11520. offset: null,
  11521. offsetLimit: null,
  11522. scroll: null,
  11523. container: cont,
  11524. init: function() {
  11525. //set options to default values if not set
  11526. opts.tagName = opts.tagName == "" ? ($(this.container).children().length == 0 ? "li" : $(this.container).children().get(0).tagName.toLowerCase()) : opts.tagName;
  11527. if (opts.itemSelector == "")
  11528. opts.itemSelector = opts.tagName;
  11529. if (opts.dragSelector == "")
  11530. opts.dragSelector = opts.tagName;
  11531. if (opts.placeHolderTemplate == "")
  11532. opts.placeHolderTemplate = "<" + opts.tagName + ">&nbsp;</" + opts.tagName + ">";
  11533. //listidx allows reference back to correct list variable instance
  11534. $(this.container).attr("data-listidx", i).mousedown(this.grabItem).bind("dragsort-uninit", this.uninit);
  11535. this.styleDragHandlers(true);
  11536. },
  11537. uninit: function() {
  11538. var list = lists[$(this).attr("data-listidx")];
  11539. $(list.container).unbind("mousedown", list.grabItem).unbind("dragsort-uninit");
  11540. list.styleDragHandlers(false);
  11541. },
  11542. getItems: function() {
  11543. return $(this.container).children(opts.itemSelector);
  11544. },
  11545. styleDragHandlers: function(cursor) {
  11546. this.getItems().map(function() { return $(this).is(opts.dragSelector) ? this : $(this).find(opts.dragSelector).get(); }).css("cursor", cursor ? "pointer" : "");
  11547. },
  11548. grabItem: function(e) {
  11549. var list = lists[$(this).attr("data-listidx")];
  11550. var item = $(e.target).closest("[data-listidx] > " + opts.tagName).get(0);
  11551. var insideMoveableItem = list.getItems().filter(function() { return this == item; }).length > 0;
  11552. //if not left click or if clicked on excluded element (e.g. text box) or not a moveable list item return
  11553. if (e.which != 1 || $(e.target).is(opts.dragSelectorExclude) || $(e.target).closest(opts.dragSelectorExclude).length > 0 || !insideMoveableItem)
  11554. return;
  11555. //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,
  11556. //does also stop being able to click text boxes hence dragging on text boxes by default is disabled in dragSelectorExclude
  11557. //e.preventDefault();
  11558. //change cursor to move while dragging
  11559. var dragHandle = e.target;
  11560. while (!$(dragHandle).is(opts.dragSelector)) {
  11561. if (dragHandle == this) return;
  11562. dragHandle = dragHandle.parentNode;
  11563. }
  11564. $(dragHandle).attr("data-cursor", $(dragHandle).css("cursor"));
  11565. $(dragHandle).css("cursor", "move");
  11566. //on mousedown wait for movement of mouse before triggering dragsort script (dragStart) to allow clicking of hyperlinks to work
  11567. var listElem = this;
  11568. var trigger = function() {
  11569. list.dragStart.call(listElem, e);
  11570. $(list.container).unbind("mousemove", trigger);
  11571. };
  11572. $(list.container).mousemove(trigger).mouseup(function() { $(list.container).unbind("mousemove", trigger); $(dragHandle).css("cursor", $(dragHandle).attr("data-cursor")); });
  11573. },
  11574. dragStart: function(e) {
  11575. if (list != null && list.draggedItem != null)
  11576. list.dropItem();
  11577. list = lists[$(this).attr("data-listidx")];
  11578. list.draggedItem = $(e.target).closest("[data-listidx] > " + opts.tagName)
  11579. //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
  11580. list.draggedItem.attr("data-origpos", $(this).attr("data-listidx") + "-" + $(list.container).children().index(list.draggedItem));
  11581. //calculate mouse offset relative to draggedItem
  11582. var mt = parseInt(list.draggedItem.css("marginTop"));
  11583. var ml = parseInt(list.draggedItem.css("marginLeft"));
  11584. list.offset = list.draggedItem.offset();
  11585. list.offset.top = e.pageY - list.offset.top + (isNaN(mt) ? 0 : mt) - 1;
  11586. list.offset.left = e.pageX - list.offset.left + (isNaN(ml) ? 0 : ml) - 1;
  11587. //calculate box the dragged item can't be dragged outside of
  11588. if (!opts.dragBetween) {
  11589. 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();
  11590. list.offsetLimit = $(list.container).offset();
  11591. list.offsetLimit.right = list.offsetLimit.left + $(list.container).outerWidth() - list.draggedItem.outerWidth();
  11592. list.offsetLimit.bottom = list.offsetLimit.top + containerHeight - list.draggedItem.outerHeight();
  11593. }
  11594. //create placeholder item
  11595. var h = list.draggedItem.height();
  11596. var w = list.draggedItem.width();
  11597. if (opts.tagName == "tr") {
  11598. list.draggedItem.children().each(function() { $(this).width($(this).width()); });
  11599. list.placeHolderItem = list.draggedItem.clone().attr("data-placeholder", true);
  11600. list.draggedItem.after(list.placeHolderItem);
  11601. //list.placeHolderItem.children().each(function() { $(this).css({ borderWidth:0, width: $(this).width() + 1, height: $(this).height() + 1 }).html("&nbsp;"); });
  11602. list.placeHolderItem.children().each(function() { $(this).html("&nbsp;"); });
  11603. } else {
  11604. list.draggedItem.after(opts.placeHolderTemplate);
  11605. list.placeHolderItem = list.draggedItem.next().css({ height: h, width: w }).attr("data-placeholder", true);
  11606. }
  11607. if (opts.tagName == "td") {
  11608. var listTable = list.draggedItem.closest("table").get(0);
  11609. $("<table id='" + listTable.id + "' style='border-width: 0px;' class='dragSortItem " + listTable.className + "'><tr></tr></table>").appendTo("body").children().append(list.draggedItem);
  11610. }
  11611. //style draggedItem while dragging
  11612. var orig = list.draggedItem.attr("style");
  11613. list.draggedItem.attr("data-origstyle", orig ? orig : "");
  11614. list.draggedItem.css({ position: "absolute", opacity: 0.8, "z-index": 999, height: h, width: w });
  11615. //auto-scroll setup
  11616. list.scroll = { moveX: 0, moveY: 0, maxX: $(document).width() - $(window).width(), maxY: $(document).height() - $(window).height() };
  11617. list.scroll.scrollY = window.setInterval(function() {
  11618. if (opts.scrollContainer != window) {
  11619. $(opts.scrollContainer).scrollTop($(opts.scrollContainer).scrollTop() + list.scroll.moveY);
  11620. return;
  11621. }
  11622. var t = $(opts.scrollContainer).scrollTop();
  11623. if (list.scroll.moveY > 0 && t < list.scroll.maxY || list.scroll.moveY < 0 && t > 0) {
  11624. $(opts.scrollContainer).scrollTop(t + list.scroll.moveY);
  11625. list.draggedItem.css("top", list.draggedItem.offset().top + list.scroll.moveY + 1);
  11626. }
  11627. }, 10);
  11628. list.scroll.scrollX = window.setInterval(function() {
  11629. if (opts.scrollContainer != window) {
  11630. $(opts.scrollContainer).scrollLeft($(opts.scrollContainer).scrollLeft() + list.scroll.moveX);
  11631. return;
  11632. }
  11633. var l = $(opts.scrollContainer).scrollLeft();
  11634. if (list.scroll.moveX > 0 && l < list.scroll.maxX || list.scroll.moveX < 0 && l > 0) {
  11635. $(opts.scrollContainer).scrollLeft(l + list.scroll.moveX);
  11636. list.draggedItem.css("left", list.draggedItem.offset().left + list.scroll.moveX + 1);
  11637. }
  11638. }, 10);
  11639. //misc
  11640. $(lists).each(function(i, l) { l.createDropTargets(); l.buildPositionTable(); });
  11641. list.setPos(e.pageX, e.pageY);
  11642. $(document).bind("mousemove", list.swapItems);
  11643. $(document).bind("mouseup", list.dropItem);
  11644. if (opts.scrollContainer != window)
  11645. $(window).bind("wheel", list.wheel);
  11646. },
  11647. //set position of draggedItem
  11648. setPos: function(x, y) {
  11649. //remove mouse offset so mouse cursor remains in same place on draggedItem instead of top left corner
  11650. var top = y - this.offset.top;
  11651. var left = x - this.offset.left;
  11652. //limit top, left to within box draggedItem can't be dragged outside of
  11653. if (!opts.dragBetween) {
  11654. top = Math.min(this.offsetLimit.bottom, Math.max(top, this.offsetLimit.top));
  11655. left = Math.min(this.offsetLimit.right, Math.max(left, this.offsetLimit.left));
  11656. }
  11657. //adjust top & left calculations to parent offset
  11658. var parent = this.draggedItem.offsetParent().not("body").offset(); //offsetParent returns body even when it's static, if not static offset is only factoring margin
  11659. if (parent != null) {
  11660. top -= parent.top;
  11661. left -= parent.left;
  11662. }
  11663. //set x or y auto-scroll amount
  11664. if (opts.scrollContainer == window) {
  11665. y -= $(window).scrollTop();
  11666. x -= $(window).scrollLeft();
  11667. y = Math.max(0, y - $(window).height() + 5) + Math.min(0, y - 5);
  11668. x = Math.max(0, x - $(window).width() + 5) + Math.min(0, x - 5);
  11669. } else {
  11670. var cont = $(opts.scrollContainer);
  11671. var offset = cont.offset();
  11672. y = Math.max(0, y - cont.height() - offset.top) + Math.min(0, y - offset.top);
  11673. x = Math.max(0, x - cont.width() - offset.left) + Math.min(0, x - offset.left);
  11674. }
  11675. list.scroll.moveX = x == 0 ? 0 : x * opts.scrollSpeed / Math.abs(x);
  11676. list.scroll.moveY = y == 0 ? 0 : y * opts.scrollSpeed / Math.abs(y);
  11677. //move draggedItem to new mouse cursor location
  11678. this.draggedItem.css({ top: top, left: left });
  11679. },
  11680. //if scroll container is a div allow mouse wheel to scroll div instead of window when mouse is hovering over
  11681. wheel: function(e) {
  11682. if (list && opts.scrollContainer != window) {
  11683. var cont = $(opts.scrollContainer);
  11684. var offset = cont.offset();
  11685. e = e.originalEvent;
  11686. if (e.clientX > offset.left && e.clientX < offset.left + cont.width() && e.clientY > offset.top && e.clientY < offset.top + cont.height()) {
  11687. var deltaY = (e.deltaMode == 0 ? 1 : 10) * e.deltaY;
  11688. cont.scrollTop(cont.scrollTop() + deltaY);
  11689. e.preventDefault();
  11690. }
  11691. }
  11692. },
  11693. //build a table recording all the positions of the moveable list items
  11694. buildPositionTable: function() {
  11695. var pos = [];
  11696. this.getItems().not([list.draggedItem[0], list.placeHolderItem[0]]).each(function(i) {
  11697. var loc = $(this).offset();
  11698. loc.right = loc.left + $(this).outerWidth();
  11699. loc.bottom = loc.top + $(this).outerHeight();
  11700. loc.elm = this;
  11701. pos[i] = loc;
  11702. });
  11703. this.pos = pos;
  11704. },
  11705. dropItem: function() {
  11706. if (list.draggedItem == null)
  11707. return;
  11708. //list.draggedItem.attr("style", "") doesn't work on IE8 and jQuery 1.5 or lower
  11709. //list.draggedItem.removeAttr("style") doesn't work on chrome and jQuery 1.6 (works jQuery 1.5 or lower)
  11710. var orig = list.draggedItem.attr("data-origstyle");
  11711. list.draggedItem.attr("style", orig);
  11712. if (orig == "")
  11713. list.draggedItem.removeAttr("style");
  11714. list.draggedItem.removeAttr("data-origstyle");
  11715. list.styleDragHandlers(true);
  11716. list.placeHolderItem.before(list.draggedItem);
  11717. list.placeHolderItem.remove();
  11718. $("[data-droptarget], .dragSortItem").remove();
  11719. window.clearInterval(list.scroll.scrollY);
  11720. window.clearInterval(list.scroll.scrollX);
  11721. //if position changed call dragEnd
  11722. if (list.draggedItem.attr("data-origpos") != $(lists).index(list) + "-" + $(list.container).children().index(list.draggedItem))
  11723. if (opts.dragEnd.apply(list.draggedItem) == false) { //if dragEnd returns false revert order
  11724. var pos = list.draggedItem.attr("data-origpos").split('-');
  11725. var nextItem = $(lists[pos[0]].container).children().not(list.draggedItem).eq(pos[1]);
  11726. if (nextItem.length > 0)
  11727. nextItem.before(list.draggedItem);
  11728. else if (pos[1] == 0) //was the only item in list
  11729. $(lists[pos[0]].container).prepend(list.draggedItem);
  11730. else //was the last item in list
  11731. $(lists[pos[0]].container).append(list.draggedItem);
  11732. }
  11733. list.draggedItem.removeAttr("data-origpos");
  11734. list.draggedItem = null;
  11735. $(document).unbind("mousemove", list.swapItems);
  11736. $(document).unbind("mouseup", list.dropItem);
  11737. if (opts.scrollContainer != window)
  11738. $(window).unbind("wheel", list.wheel);
  11739. return false;
  11740. },
  11741. //swap the draggedItem (represented visually by placeholder) with the list item the it has been dragged on top of
  11742. swapItems: function(e) {
  11743. if (list.draggedItem == null)
  11744. return false;
  11745. //move draggedItem to mouse location
  11746. list.setPos(e.pageX, e.pageY);
  11747. //retrieve list and item position mouse cursor is over
  11748. var ei = list.findPos(e.pageX, e.pageY);
  11749. var nlist = list;
  11750. for (var i = 0; ei == -1 && opts.dragBetween && i < lists.length; i++) {
  11751. ei = lists[i].findPos(e.pageX, e.pageY);
  11752. nlist = lists[i];
  11753. }
  11754. //if not over another moveable list item return
  11755. if (ei == -1)
  11756. return false;
  11757. //save fixed items locations
  11758. var children = function() { return $(nlist.container).children().not(nlist.draggedItem); };
  11759. var fixed = children().not(opts.itemSelector).each(function(i) { this.idx = children().index(this); });
  11760. //if moving draggedItem up or left place placeHolder before list item the dragged item is hovering over otherwise place it after
  11761. if (lastPos == null || lastPos.top > list.draggedItem.offset().top || lastPos.left > list.draggedItem.offset().left)
  11762. $(nlist.pos[ei].elm).before(list.placeHolderItem);
  11763. else
  11764. $(nlist.pos[ei].elm).after(list.placeHolderItem);
  11765. //restore fixed items location
  11766. fixed.each(function() {
  11767. var elm = children().eq(this.idx).get(0);
  11768. if (this != elm && children().index(this) < this.idx)
  11769. $(this).insertAfter(elm);
  11770. else if (this != elm)
  11771. $(this).insertBefore(elm);
  11772. });
  11773. //misc
  11774. $(lists).each(function(i, l) { l.createDropTargets(); l.buildPositionTable(); });
  11775. lastPos = list.draggedItem.offset();
  11776. return false;
  11777. },
  11778. //returns the index of the list item the mouse is over
  11779. findPos: function(x, y) {
  11780. for (var i = 0; i < this.pos.length; i++) {
  11781. if (this.pos[i].left < x && this.pos[i].right > x && this.pos[i].top < y && this.pos[i].bottom > y)
  11782. return i;
  11783. }
  11784. return -1;
  11785. },
  11786. //create drop targets which are placeholders at the end of other lists to allow dragging straight to the last position
  11787. createDropTargets: function() {
  11788. if (!opts.dragBetween)
  11789. return;
  11790. $(lists).each(function() {
  11791. var ph = $(this.container).find("[data-placeholder]");
  11792. var dt = $(this.container).find("[data-droptarget]");
  11793. if (ph.length > 0 && dt.length > 0)
  11794. dt.remove();
  11795. else if (ph.length == 0 && dt.length == 0) {
  11796. if (opts.tagName == "td")
  11797. $(opts.placeHolderTemplate).attr("data-droptarget", true).appendTo(this.container);
  11798. else
  11799. //list.placeHolderItem.clone().removeAttr("data-placeholder") crashes in IE7 and jquery 1.5.1 (doesn't in jquery 1.4.2 or IE8)
  11800. $(this.container).append(list.placeHolderItem.removeAttr("data-placeholder").clone().attr("data-droptarget", true));
  11801. list.placeHolderItem.attr("data-placeholder", true);
  11802. }
  11803. });
  11804. }
  11805. };
  11806. newList.init();
  11807. lists.push(newList);
  11808. });
  11809. return this;
  11810. };
  11811. $.fn.dragsort.defaults = {
  11812. tagName:"",
  11813. itemSelector: "",
  11814. dragSelector: "",
  11815. dragSelectorExclude: "input, textarea",
  11816. dragEnd: function() { },
  11817. dragBetween: false,
  11818. placeHolderTemplate: "",
  11819. scrollContainer: window,
  11820. scrollSpeed: 5
  11821. };
  11822. })(jQuery);
  11823. define("dragsort", function(){});
  11824. /*!
  11825. * jquery.event.drag - v 2.2
  11826. * Copyright (c) 2010 Three Dub Media - http://threedubmedia.com
  11827. * Open Source MIT License - http://threedubmedia.com/code/license
  11828. */
  11829. ;(function(e){e.fn.drag=function(k,g,j){var i=typeof k=="string"?k:"",h=e.isFunction(k)?k:e.isFunction(g)?g:null;if(i.indexOf("drag")!==0){i="drag"+i}j=(k==h?g:j)||{};return h?this.bind(i,j,h):this.trigger(i)};var b=e.event,a=b.special,d=a.drag={defaults:{which:1,distance:0,not:":input",handle:null,relative:false,drop:true,click:false},datakey:"dragdata",noBubble:true,add:function(i){var h=e.data(this,d.datakey),g=i.data||{};h.related+=1;e.each(d.defaults,function(j,k){if(g[j]!==undefined){h[j]=g[j]}})},remove:function(){e.data(this,d.datakey).related-=1},setup:function(){if(e.data(this,d.datakey)){return}var g=e.extend({related:0},d.defaults);e.data(this,d.datakey,g);b.add(this,"touchstart mousedown",d.init,g);if(this.attachEvent){this.attachEvent("ondragstart",d.dontstart)}},teardown:function(){var g=e.data(this,d.datakey)||{};if(g.related){return}e.removeData(this,d.datakey);b.remove(this,"touchstart mousedown",d.init);d.textselect(true);if(this.detachEvent){this.detachEvent("ondragstart",d.dontstart)}},init:function(i){if(d.touched){return}var g=i.data,h;if(i.which!=0&&g.which>0&&i.which!=g.which){return}if(e(i.target).is(g.not)){return}if(g.handle&&!e(i.target).closest(g.handle,i.currentTarget).length){return}d.touched=i.type=="touchstart"?this:null;g.propagates=1;g.mousedown=this;g.interactions=[d.interaction(this,g)];g.target=i.target;g.pageX=i.pageX;g.pageY=i.pageY;g.dragging=null;h=d.hijack(i,"draginit",g);if(!g.propagates){return}h=d.flatten(h);if(h&&h.length){g.interactions=[];e.each(h,function(){g.interactions.push(d.interaction(this,g))})}g.propagates=g.interactions.length;if(g.drop!==false&&a.drop){a.drop.handler(i,g)}d.textselect(false);if(d.touched){b.add(d.touched,"touchmove touchend",d.handler,g)}else{b.add(document,"mousemove mouseup",d.handler,g)}if(!d.touched||g.live){return false}},interaction:function(h,g){var i=e(h)[g.relative?"position":"offset"]()||{top:0,left:0};return{drag:h,callback:new d.callback(),droppable:[],offset:i}},handler:function(h){var g=h.data;switch(h.type){case !g.dragging&&"touchmove":h.preventDefault();case !g.dragging&&"mousemove":if(Math.pow(h.pageX-g.pageX,2)+Math.pow(h.pageY-g.pageY,2)<Math.pow(g.distance,2)){break}h.target=g.target;d.hijack(h,"dragstart",g);if(g.propagates){g.dragging=true}case"touchmove":h.preventDefault();case"mousemove":if(g.dragging){d.hijack(h,"drag",g);if(g.propagates){if(g.drop!==false&&a.drop){a.drop.handler(h,g)}break}h.type="mouseup"}case"touchend":case"mouseup":default:if(d.touched){b.remove(d.touched,"touchmove touchend",d.handler)}else{b.remove(document,"mousemove mouseup",d.handler)}if(g.dragging){if(g.drop!==false&&a.drop){a.drop.handler(h,g)}d.hijack(h,"dragend",g)}d.textselect(true);if(g.click===false&&g.dragging){e.data(g.mousedown,"suppress.click",new Date().getTime()+5)}g.dragging=d.touched=false;break}},hijack:function(h,o,r,p,k){if(!r){return}var q={event:h.originalEvent,type:h.type},m=o.indexOf("drop")?"drag":"drop",t,l=p||0,j,g,s,n=!isNaN(p)?p:r.interactions.length;h.type=o;h.originalEvent=null;r.results=[];do{if(j=r.interactions[l]){if(o!=="dragend"&&j.cancelled){continue}s=d.properties(h,r,j);j.results=[];e(k||j[m]||r.droppable).each(function(u,i){s.target=i;h.isPropagationStopped=function(){return false};t=i?b.dispatch.call(i,h,s):null;if(t===false){if(m=="drag"){j.cancelled=true;r.propagates-=1}if(o=="drop"){j[m][u]=null}}else{if(o=="dropinit"){j.droppable.push(d.element(t)||i)}}if(o=="dragstart"){j.proxy=e(d.element(t)||j.drag)[0]}j.results.push(t);delete h.result;if(o!=="dropinit"){return t}});r.results[l]=d.flatten(j.results);if(o=="dropinit"){j.droppable=d.flatten(j.droppable)}if(o=="dragstart"&&!j.cancelled){s.update()}}}while(++l<n);h.type=q.type;h.originalEvent=q.event;return d.flatten(r.results)},properties:function(i,g,h){var j=h.callback;j.drag=h.drag;j.proxy=h.proxy||h.drag;j.startX=g.pageX;j.startY=g.pageY;j.deltaX=i.pageX-g.pageX;j.deltaY=i.pageY-g.pageY;j.originalX=h.offset.left;j.originalY=h.offset.top;j.offsetX=j.originalX+j.deltaX;j.offsetY=j.originalY+j.deltaY;j.drop=d.flatten((h.drop||[]).slice());j.available=d.flatten((h.droppable||[]).slice());return j},element:function(g){if(g&&(g.jquery||g.nodeType==1)){return g}},flatten:function(g){return e.map(g,function(h){return h&&h.jquery?e.makeArray(h):h&&h.length?d.flatten(h):h})},textselect:function(g){e(document)[g?"unbind":"bind"]("selectstart",d.dontstart).css("MozUserSelect",g?"":"none");document.unselectable=g?"off":"on"},dontstart:function(){return false},callback:function(){}};d.callback.prototype={update:function(){if(a.drop&&this.available.length){e.each(this.available,function(g){a.drop.locate(this,g)})}}};var f=b.dispatch;b.dispatch=function(g){if(e.data(this,"suppress."+g.type)-new Date().getTime()>0){e.removeData(this,"suppress."+g.type);return}return f.apply(this,arguments)};b.fixHooks=b.fixHooks||{};var c=b.fixHooks.touchstart=b.fixHooks.touchmove=b.fixHooks.touchend=b.fixHooks.touchcancel={props:"clientX clientY pageX pageY screenX screenY".split(" "),filter:function(h,i){if(i){var g=(i.touches&&i.touches[0])||(i.changedTouches&&i.changedTouches[0])||null;if(g){e.each(c.props,function(j,k){h[k]=g[k]})}}return h}};a.draginit=a.dragstart=a.dragend=d})(jQuery);
  11830. define("drag", function(){});
  11831. /*!
  11832. * jquery.event.drop - v 2.2
  11833. * Copyright (c) 2010 Three Dub Media - http://threedubmedia.com
  11834. * Open Source MIT License - http://threedubmedia.com/code/license
  11835. */
  11836. ;(function(d){d.fn.drop=function(i,e,h){var g=typeof i=="string"?i:"",f=d.isFunction(i)?i:d.isFunction(e)?e:null;if(g.indexOf("drop")!==0){g="drop"+g}h=(i==f?e:h)||{};return f?this.bind(g,h,f):this.trigger(g)};d.drop=function(e){e=e||{};b.multi=e.multi===true?Infinity:e.multi===false?1:!isNaN(e.multi)?e.multi:b.multi;b.delay=e.delay||b.delay;b.tolerance=d.isFunction(e.tolerance)?e.tolerance:e.tolerance===null?null:b.tolerance;b.mode=e.mode||b.mode||"intersect"};var c=d.event,a=c.special,b=d.event.special.drop={multi:1,delay:20,mode:"overlap",targets:[],datakey:"dropdata",noBubble:true,add:function(f){var e=d.data(this,b.datakey);e.related+=1},remove:function(){d.data(this,b.datakey).related-=1},setup:function(){if(d.data(this,b.datakey)){return}var e={related:0,active:[],anyactive:0,winner:0,location:{}};d.data(this,b.datakey,e);b.targets.push(this);return false},teardown:function(){var f=d.data(this,b.datakey)||{};if(f.related){return}d.removeData(this,b.datakey);var e=this;b.targets=d.grep(b.targets,function(g){return(g!==e)})},handler:function(g,e){var f,h;if(!e){return}switch(g.type){case"mousedown":case"touchstart":h=d(b.targets);if(typeof e.drop=="string"){h=h.filter(e.drop)}h.each(function(){var i=d.data(this,b.datakey);i.active=[];i.anyactive=0;i.winner=0});e.droppable=h;a.drag.hijack(g,"dropinit",e);break;case"mousemove":case"touchmove":b.event=g;if(!b.timer){b.tolerate(e)}break;case"mouseup":case"touchend":b.timer=clearTimeout(b.timer);if(e.propagates){a.drag.hijack(g,"drop",e);a.drag.hijack(g,"dropend",e)}break}},locate:function(k,h){var l=d.data(k,b.datakey),g=d(k),i=g.offset()||{},e=g.outerHeight(),j=g.outerWidth(),f={elem:k,width:j,height:e,top:i.top,left:i.left,right:i.left+j,bottom:i.top+e};if(l){l.location=f;l.index=h;l.elem=k}return f},contains:function(e,f){return((f[0]||f.left)>=e.left&&(f[0]||f.right)<=e.right&&(f[1]||f.top)>=e.top&&(f[1]||f.bottom)<=e.bottom)},modes:{intersect:function(f,e,g){return this.contains(g,[f.pageX,f.pageY])?1000000000:this.modes.overlap.apply(this,arguments)},overlap:function(f,e,g){return Math.max(0,Math.min(g.bottom,e.bottom)-Math.max(g.top,e.top))*Math.max(0,Math.min(g.right,e.right)-Math.max(g.left,e.left))},fit:function(f,e,g){return this.contains(g,e)?1:0},middle:function(f,e,g){return this.contains(g,[e.left+e.width*0.5,e.top+e.height*0.5])?1:0}},sort:function(f,e){return(e.winner-f.winner)||(f.index-e.index)},tolerate:function(q){var k,e,n,j,l,m,g,p=0,f,h=q.interactions.length,r=[b.event.pageX,b.event.pageY],o=b.tolerance||b.modes[b.mode];do{if(f=q.interactions[p]){if(!f){return}f.drop=[];l=[];m=f.droppable.length;if(o){n=b.locate(f.proxy)}k=0;do{if(g=f.droppable[k]){j=d.data(g,b.datakey);e=j.location;if(!e){continue}j.winner=o?o.call(b,b.event,n,e):b.contains(e,r)?1:0;l.push(j)}}while(++k<m);l.sort(b.sort);k=0;do{if(j=l[k]){if(j.winner&&f.drop.length<b.multi){if(!j.active[p]&&!j.anyactive){if(a.drag.hijack(b.event,"dropstart",q,p,j.elem)[0]!==false){j.active[p]=1;j.anyactive+=1}else{j.winner=0}}if(j.winner){f.drop.push(j.elem)}}else{if(j.active[p]&&j.anyactive==1){a.drag.hijack(b.event,"dropend",q,p,j.elem);j.active[p]=0;j.anyactive-=1}}}}while(++k<m)}}while(++p<h);if(b.last&&r[0]==b.last.pageX&&r[1]==b.last.pageY){delete b.timer}else{b.timer=setTimeout(function(){b.tolerate(q)},b.delay)}b.last=b.event}};a.dropinit=a.dropstart=a.dropend=b})(jQuery);
  11837. define("drop", function(){});
  11838. /**
  11839. * http://git.oschina.net/hbbcs/bootStrap-addTabs
  11840. * Created by joe on 2015-12-19.
  11841. * Modified by FastAdmin
  11842. */
  11843. (function ($) {
  11844. $.fn.addtabs = function (options) {
  11845. var obj = $(this);
  11846. options = $.extend({
  11847. content: '', //直接指定所有页面TABS内容
  11848. close: true, //是否可以关闭
  11849. monitor: 'body', //监视的区域
  11850. nav: '.nav-addtabs',
  11851. tab: '.tab-addtabs',
  11852. iframeUse: true, //使用iframe还是ajax
  11853. simple: false, //是否启用简洁模式,简洁模式下将不启用nav和tab
  11854. iframeHeight: $(window).height() - 50, //固定TAB中IFRAME高度,根据需要自己修改
  11855. iframeForceRefresh: false, //点击后强制加载对应的iframe
  11856. iframeForceRefreshTable: false, //点击后强制刷新对应的iframe中的table
  11857. callback: function () {
  11858. //关闭后回调函数
  11859. }
  11860. }, options || {});
  11861. var navobj = $(options.nav);
  11862. var tabobj = $(options.tab);
  11863. if (history.pushState) {
  11864. //浏览器前进后退事件
  11865. $(window).on("popstate", function (e) {
  11866. var state = e.originalEvent.state;
  11867. if (state) {
  11868. $("a[addtabs=" + state.id + "]", options.monitor).data("pushstate", true).trigger("click");
  11869. }
  11870. });
  11871. }
  11872. $(options.monitor).on('click', '[addtabs]', function (e) {
  11873. if ($(this).attr('url').indexOf("javascript:") !== 0) {
  11874. if ($(this).is("a")) {
  11875. e.preventDefault();
  11876. }
  11877. var id = $(this).attr('addtabs');
  11878. var title = $(this).attr('title') ? $(this).attr('title') : $.trim($(this).text());
  11879. var url = $(this).attr('url');
  11880. var content = options.content ? options.content : $(this).attr('content');
  11881. var ajax = $(this).attr('ajax') === '1' || $(this).attr('ajax') === 'true';
  11882. var state = ({
  11883. url: url, title: title, id: id, content: content, ajax: ajax
  11884. });
  11885. document.title = title;
  11886. if (history.pushState && !$(this).data("pushstate")) {
  11887. var pushurl = url.indexOf("ref=addtabs") === -1 ? (url + (url.indexOf("?") > -1 ? "&" : "?") + "ref=addtabs") : url;
  11888. try {
  11889. window.history.pushState(state, title, pushurl);
  11890. } catch (e) {
  11891. }
  11892. }
  11893. $(this).data("pushstate", null);
  11894. _add.call(this, {
  11895. id: id,
  11896. title: $(this).attr('title') ? $(this).attr('title') : $(this).html(),
  11897. content: content,
  11898. url: url,
  11899. ajax: ajax
  11900. });
  11901. }
  11902. });
  11903. navobj.on('click', '.close-tab', function () {
  11904. var id = $(this).prev("a").attr("aria-controls");
  11905. _close(id);
  11906. return false;
  11907. });
  11908. navobj.on('dblclick', 'li[role=presentation]', function () {
  11909. $(this).find(".close-tab").trigger("click");
  11910. });
  11911. navobj.on('click', 'li[role=presentation]', function () {
  11912. $("a[addtabs=" + $("a", this).attr("node-id") + "]").trigger("click");
  11913. });
  11914. $(window).resize(function () {
  11915. if (typeof options.nav === 'object') {
  11916. var siblingsWidth = 0;
  11917. navobj.siblings().each(function () {
  11918. siblingsWidth += $(this).outerWidth();
  11919. });
  11920. navobj.width(navobj.parent().width() - siblingsWidth);
  11921. } else {
  11922. $("#nav").width($("#header").find("> .navbar").width() - $(".sidebar-toggle").outerWidth() - $(".navbar-custom-menu").outerWidth() - 20);
  11923. }
  11924. _drop();
  11925. });
  11926. var _add = function (opts) {
  11927. var id, tabid, conid, url;
  11928. id = opts.id;
  11929. tabid = 'tab_' + opts.id;
  11930. conid = 'con_' + opts.id;
  11931. url = opts.url;
  11932. url += (opts.url.indexOf("?") > -1 ? "&addtabs=1" : "?addtabs=1");
  11933. if (options.simple) {
  11934. navobj.find("[role='presentation']").remove();
  11935. tabobj.find("[role='tabpanel']").remove();
  11936. }
  11937. var tabitem = $('#' + tabid, navobj);
  11938. var conitem = $('#' + conid, tabobj);
  11939. navobj.find("[role='presentation']").removeClass('active');
  11940. tabobj.find("[role='tabpanel']").removeClass('active');
  11941. //如果TAB不存在,创建一个新的TAB
  11942. if (tabitem.length === 0) {
  11943. //创建新TAB的title
  11944. 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>');
  11945. //是否允许关闭
  11946. if (options.close && $("li", navobj).length > 0) {
  11947. tabitem.append(' <i class="close-tab fa fa-remove"></i>');
  11948. }
  11949. if (conitem.length === 0) {
  11950. //创建新TAB的内容
  11951. conitem = $('<div role="tabpanel" class="tab-pane" id="' + conid + '"></div>');
  11952. //是否指定TAB内容
  11953. if (opts.content) {
  11954. conitem.append(opts.content);
  11955. } else if (options.iframeUse && !opts.ajax) {//没有内容,使用IFRAME打开链接
  11956. var height = options.iframeHeight;
  11957. 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>');
  11958. } else {
  11959. $.get(url, function (data) {
  11960. conitem.append(data);
  11961. });
  11962. }
  11963. tabobj.append(conitem);
  11964. }
  11965. if (opts.simple) {
  11966. //加入TABS
  11967. if ($('.tabdrop li', navobj).length > 0) {
  11968. $('.tabdrop ul', navobj).append(tabitem);
  11969. } else {
  11970. navobj.append(tabitem);
  11971. }
  11972. }
  11973. } else {
  11974. //强制刷新iframe
  11975. if (options.iframeForceRefresh) {
  11976. $("#" + conid + " iframe").attr('src', function (i, val) {
  11977. return val;
  11978. });
  11979. } else if (options.iframeForceRefreshTable) {
  11980. try {
  11981. //检测iframe中是否存在刷新按钮
  11982. if ($("#" + conid + " iframe").contents().find(".btn-refresh:not([data-force-refresh=false])").length > 0) {
  11983. $("#" + conid + " iframe")[0].contentWindow.$(".btn-refresh:not([data-force-refresh=false])").trigger("click");
  11984. }
  11985. } catch (e) {
  11986. }
  11987. }
  11988. }
  11989. // localStorage.setItem("addtabs", $(this).prop('outerHTML'));
  11990. //激活TAB
  11991. tabitem.addClass('active');
  11992. conitem.addClass("active");
  11993. _drop();
  11994. };
  11995. var _close = function (id) {
  11996. var tabid = 'tab_' + id;
  11997. var conid = 'con_' + id;
  11998. var tabitem = $('#' + tabid, navobj);
  11999. var conitem = $('#' + conid, tabobj);
  12000. //如果关闭的是当前激活的TAB,激活他的前一个TAB
  12001. if (obj.find("li.active").not('.tabdrop').attr('id') === tabid) {
  12002. var prev = tabitem.prev().not(".tabdrop");
  12003. var next = tabitem.next().not(".tabdrop");
  12004. if (prev.length > 0) {
  12005. prev.find('a').trigger("click");
  12006. } else if (next.length > 0) {
  12007. next.find('a').trigger("click");
  12008. } else {
  12009. $(">li:not(.tabdrop):last > a", navobj).trigger('click');
  12010. }
  12011. }
  12012. //关闭TAB
  12013. tabitem.remove();
  12014. conitem.remove();
  12015. _drop();
  12016. options.callback();
  12017. };
  12018. var _drop = function () {
  12019. navobj.refreshAddtabs();
  12020. };
  12021. };
  12022. //刷新Addtabs
  12023. $.fn.refreshAddtabs = function () {
  12024. var navobj = $(this);
  12025. var dropdown = $(".tabdrop", navobj);
  12026. if (dropdown.length === 0) {
  12027. dropdown = $('<li class="dropdown pull-right hide tabdrop"><a class="dropdown-toggle" data-toggle="dropdown" href="javascript:;">' +
  12028. '<i class="glyphicon glyphicon-align-justify"></i>' +
  12029. ' <b class="caret"></b></a><ul class="dropdown-menu"></ul></li>');
  12030. dropdown.prependTo(navobj);
  12031. }
  12032. //检测是否有下拉样式
  12033. if (navobj.parent().is('.tabs-below')) {
  12034. dropdown.addClass('dropup');
  12035. }
  12036. var collection = 0;
  12037. var maxwidth = navobj.width() - 65;
  12038. var liwidth = 0;
  12039. //检查超过一行的标签页
  12040. var litabs = navobj.append(dropdown.find('li')).find('>li').not('.tabdrop');
  12041. var totalwidth = 0;
  12042. litabs.each(function () {
  12043. totalwidth += $(this).outerWidth(true);
  12044. });
  12045. if (navobj.width() < totalwidth) {
  12046. litabs.each(function () {
  12047. liwidth += $(this).outerWidth(true);
  12048. if (liwidth > maxwidth) {
  12049. dropdown.find('ul').append($(this));
  12050. collection++;
  12051. }
  12052. });
  12053. if (collection > 0) {
  12054. dropdown.removeClass('hide');
  12055. if (dropdown.find('.active').length === 1) {
  12056. dropdown.addClass('active');
  12057. } else {
  12058. dropdown.removeClass('active');
  12059. }
  12060. }
  12061. } else {
  12062. dropdown.addClass('hide');
  12063. }
  12064. };
  12065. })(jQuery);
  12066. define("addtabs", function(){});
  12067. /**
  12068. * @summary SelectPage
  12069. * @desc Simple and powerful selection plugin
  12070. * @file selectpage.js
  12071. * @version 2.20
  12072. * @author TerryZeng
  12073. * @contact https://terryz.github.io/
  12074. * @license MIT License
  12075. *
  12076. */
  12077. ;(function ($) {
  12078. "use strict";
  12079. /**
  12080. * Default options
  12081. */
  12082. var defaults = {
  12083. /**
  12084. * Data source
  12085. * @type {string|Object}
  12086. *
  12087. * string:server side request url address
  12088. * Object:JSON array,format:[{a:1,b:2,c:3},{...}]
  12089. */
  12090. data: undefined,
  12091. /**
  12092. * Language ('cn', 'en')
  12093. * @type string
  12094. * @default 'cn'
  12095. */
  12096. lang: 'cn',
  12097. /**
  12098. * Multiple select mode(tags)
  12099. * @type boolean
  12100. * @default false
  12101. */
  12102. multiple: false,
  12103. /**
  12104. * pagination or not
  12105. * @type boolean
  12106. * @default true
  12107. */
  12108. pagination: true,
  12109. /**
  12110. * Show up menu button
  12111. * @type boolean
  12112. * @default true
  12113. */
  12114. dropButton: true,
  12115. /**
  12116. * Result list visible size in pagination bar close
  12117. * @type number
  12118. * @default 10
  12119. */
  12120. listSize: 10,
  12121. /**
  12122. * Show control bar in multiple select mode
  12123. * @type boolean
  12124. * @default true
  12125. */
  12126. multipleControlbar: true,
  12127. /**
  12128. * Max selected item limited in multiple select mode
  12129. * @type number
  12130. * @default 0(unlimited)
  12131. */
  12132. maxSelectLimit: 0,
  12133. /**
  12134. * Select result item to close list, work on multiple select mode
  12135. * @type boolean
  12136. * @default false
  12137. */
  12138. selectToCloseList: false,
  12139. /**
  12140. * Init selected item key, the result will match to option.keyField option
  12141. * @type string
  12142. */
  12143. initRecord: undefined,
  12144. /**
  12145. * The table parameter in server side mode
  12146. * @type string
  12147. */
  12148. dbTable: 'tbl',
  12149. /**
  12150. * The value field, the value will fill to hidden element
  12151. * @type string
  12152. * @default 'id'
  12153. */
  12154. keyField: 'id',
  12155. /**
  12156. * The show text field, the text will show to input element or tags(multiple mode)
  12157. * @type string
  12158. * @default 'name'
  12159. */
  12160. showField: 'name',
  12161. /**
  12162. * Actually used to search field
  12163. * @type string
  12164. */
  12165. searchField: undefined,
  12166. /**
  12167. * Search type ('AND' or 'OR')
  12168. * @type string
  12169. * @default 'AND'
  12170. */
  12171. andOr: 'OR',
  12172. /**
  12173. * Used to separate search content
  12174. * @see SelectPage.prototype.suggest()
  12175. */
  12176. separator: ',',
  12177. /**
  12178. * Result sort type
  12179. * @type array|boolean - if not set, will default used showField field
  12180. * @example
  12181. * orderBy : ['id desc']
  12182. */
  12183. orderBy: undefined,
  12184. /**
  12185. * Page size
  12186. * @type number
  12187. * @default 10
  12188. */
  12189. pageSize: 10,
  12190. /**
  12191. * Server side request parameters
  12192. * @type function
  12193. * @return object
  12194. * @example params : function(){return {'name':'aa','sex':1};}
  12195. */
  12196. params: undefined,
  12197. /**
  12198. * Custom result list item show text
  12199. * @type function
  12200. * @param data {object} row data
  12201. * @return string
  12202. */
  12203. formatItem: undefined,
  12204. /**
  12205. * Have some highlight item and lost focus, auto select the highlight item
  12206. * @type boolean
  12207. * @default false
  12208. */
  12209. autoFillResult: false,
  12210. /**
  12211. * Auto select first item in show up result list or search result
  12212. * depend on `autoFillResult` option set to true
  12213. * @type boolean
  12214. * @default false
  12215. */
  12216. autoSelectFirst: false,
  12217. /**
  12218. * Whether clear input element text when enter some keywords to search and no result return
  12219. * @type boolean
  12220. * @default true
  12221. */
  12222. noResultClean: true,
  12223. /**
  12224. * Select only mode
  12225. * @type boolean
  12226. */
  12227. selectOnly: false,
  12228. /**
  12229. * Input to search delay time, work on ajax data source
  12230. * @type number
  12231. * @default 0.5
  12232. */
  12233. inputDelay: 0.5,
  12234. /**
  12235. * -----------------------------------------Callback--------------------------------------------
  12236. */
  12237. /**
  12238. * Result list item selected callback
  12239. * @type function
  12240. * @param object - selected item json data
  12241. * @param self - plugin object
  12242. */
  12243. eSelect: undefined,
  12244. /**
  12245. * Before result list show up callback, you can do anything prepared
  12246. * @param self - plugin object
  12247. */
  12248. eOpen: undefined,
  12249. /**
  12250. * Server side return data convert callback
  12251. * @type function
  12252. * @param data {object} server side return data
  12253. * @param self {object} plugin object
  12254. * @return {object} return data format:
  12255. * @example
  12256. * {
  12257. * list : [{name:'aa',sex:1},{name:'bb',sex:1}...],
  12258. * totalRow : 100
  12259. * }
  12260. */
  12261. eAjaxSuccess: undefined,
  12262. /**
  12263. * Close selected item tag callback (multiple mode)
  12264. * @type function
  12265. * @param removeCount {number} remove item count
  12266. * @param self {object} plugin object
  12267. */
  12268. eTagRemove: undefined,
  12269. /**
  12270. * Clear selected item callback(single select mode)
  12271. * @type function
  12272. * @param self {object} plugin object
  12273. */
  12274. eClear: undefined
  12275. };
  12276. /**
  12277. * SelectPage class definition
  12278. * @constructor
  12279. * @param {Object} input - input element
  12280. * @param {Object} option
  12281. */
  12282. var SelectPage = function (input, option) {
  12283. //特殊字段处理
  12284. $.each({data: 'source', keyField: 'primaryKey', showField: 'field', pageSize: 'perPage'}, function (i, j) {
  12285. if (typeof option[j] !== 'undefined') {
  12286. option[i] = option[j];
  12287. delete option[j];
  12288. }
  12289. });
  12290. this.setOption(option);
  12291. this.setLanguage();
  12292. this.setCssClass();
  12293. this.setProp();
  12294. this.setElem(input);
  12295. this.setButtonAttrDefault();
  12296. this.setInitRecord();
  12297. this.eDropdownButton();
  12298. this.eInput();
  12299. this.eWhole();
  12300. };
  12301. /**
  12302. * Plugin version number
  12303. */
  12304. SelectPage.version = '2.19';
  12305. /**
  12306. * Plugin object cache key
  12307. */
  12308. SelectPage.dataKey = 'selectPageObject';
  12309. /**
  12310. * Options set
  12311. * @param {Object} option
  12312. */
  12313. SelectPage.prototype.setOption = function (option) {
  12314. //use showField to default
  12315. option.searchField = option.searchField || option.showField;
  12316. option.andOr = option.andOr.toUpperCase();
  12317. if (option.andOr !== 'AND' && option.andOr !== 'OR') option.andOr = 'AND';
  12318. //support multiple field set
  12319. var arr = ['searchField'];
  12320. for (var i = 0; i < arr.length; i++) {
  12321. option[arr[i]] = this.strToArray(option[arr[i]]);
  12322. }
  12323. //set default order field
  12324. option.orderBy = option.orderBy || option.showField;
  12325. //set multiple order field
  12326. //example: [ ['id', 'ASC'], ['name', 'DESC'] ]
  12327. if (option.orderBy !== false) option.orderBy = this.setOrderbyOption(option.orderBy, option.showField);
  12328. //close auto fill result and auto select first in multiple mode and select item not close list
  12329. if (option.multiple && !option.selectToCloseList) {
  12330. option.autoFillResult = false;
  12331. option.autoSelectFirst = false;
  12332. }
  12333. //show all item when pagination bar close, limited 200
  12334. if (!option.pagination) option.pageSize = 200;
  12335. if ($.type(option.listSize) !== 'number' || option.listSize < 0) option.listSize = 10;
  12336. if (typeof option.formatItem === 'string') {
  12337. var _formatItem = option.formatItem;
  12338. option.formatItem = function (row) {
  12339. if (typeof Template === 'function' && _formatItem.match(/\#([a-zA-Z0-9_\-]+)$/)) {
  12340. return Template(_formatItem.substring(1), row);
  12341. } else {
  12342. return _formatItem.replace(/\{(.*?)\}/gi, function (matched) {
  12343. matched = matched.substring(1, matched.length - 1);
  12344. return typeof row[matched] !== 'undefined' ? row[matched] : '';
  12345. });
  12346. }
  12347. };
  12348. }
  12349. this.option = option;
  12350. };
  12351. /**
  12352. * String convert to array
  12353. * @param str {string}
  12354. * @return {Array}
  12355. */
  12356. SelectPage.prototype.strToArray = function (str) {
  12357. return str ? str.replace(/[\s ]+/g, '').split(',') : '';
  12358. };
  12359. /**
  12360. * Set order field
  12361. * @param {Array} arg_order
  12362. * @param {string} arg_field - default sort field
  12363. * @return {Array}
  12364. */
  12365. SelectPage.prototype.setOrderbyOption = function (arg_order, arg_field) {
  12366. var arr = [], orders = [];
  12367. if (typeof arg_order === 'object') {
  12368. for (var i = 0; i < arg_order.length; i++) {
  12369. orders = $.trim(arg_order[i]).split(' ');
  12370. if (orders.length)
  12371. arr.push((orders.length === 2) ? orders.concat() : [orders[0], 'ASC']);
  12372. }
  12373. } else {
  12374. orders = $.trim(arg_order).split(' ');
  12375. arr[0] = (orders.length === 2) ? orders.concat() : (orders[0].toUpperCase().match(/^(ASC|DESC)$/i)) ? [arg_field, orders[0].toUpperCase()] : [orders[0], 'ASC'];
  12376. }
  12377. return arr;
  12378. };
  12379. /**
  12380. * i18n
  12381. */
  12382. SelectPage.prototype.setLanguage = function () {
  12383. var message, p = this.option;
  12384. switch (p.lang) {
  12385. // English
  12386. case 'en':
  12387. message = {
  12388. add_btn: 'Add button',
  12389. add_title: 'add a box',
  12390. del_btn: 'Del button',
  12391. del_title: 'delete a box',
  12392. next: 'Next',
  12393. next_title: 'Next' + p.pageSize + ' (Right key)',
  12394. prev: 'Prev',
  12395. prev_title: 'Prev' + p.pageSize + ' (Left key)',
  12396. first_title: 'First (Shift + Left key)',
  12397. last_title: 'Last (Shift + Right key)',
  12398. get_all_btn: 'Get All (Down key)',
  12399. get_all_alt: '(button)',
  12400. close_btn: 'Close (Tab key)',
  12401. close_alt: '(button)',
  12402. loading: 'loading...',
  12403. loading_alt: '(loading)',
  12404. page_info: 'page_num of page_count',
  12405. select_ng: 'Attention : Please choose from among the list.',
  12406. select_ok: 'OK : Correctly selected.',
  12407. not_found: 'not found',
  12408. ajax_error: 'An error occurred while loading data.',
  12409. clear: 'Clear content',
  12410. select_all: 'Select current page',
  12411. unselect_all: 'Clear current page',
  12412. clear_all: 'Clear all selected',
  12413. max_selected: 'You can only select up to max_selected_limit items'
  12414. };
  12415. break;
  12416. // 中文
  12417. case 'cn':
  12418. default:
  12419. message = {
  12420. add_btn: '添加按钮',
  12421. add_title: '添加区域',
  12422. del_btn: '删除按钮',
  12423. del_title: '删除区域',
  12424. next: '下一页',
  12425. next_title: '下' + p.pageSize + ' (→)',
  12426. prev: '上一页',
  12427. prev_title: '上' + p.pageSize + ' (←)',
  12428. first_title: '首页 (Shift + ←)',
  12429. last_title: '尾页 (Shift + →)',
  12430. get_all_btn: '获得全部 (↓)',
  12431. get_all_alt: '(按钮)',
  12432. close_btn: '关闭 (Tab键)',
  12433. close_alt: '(按钮)',
  12434. loading: '读取中...',
  12435. loading_alt: '(读取中)',
  12436. page_info: '第 page_num 页(共page_count页)',
  12437. select_ng: '请注意:请从列表中选择.',
  12438. select_ok: 'OK : 已经选择.',
  12439. not_found: '无查询结果',
  12440. ajax_error: '加载数据时发生了错误!',
  12441. clear: '清除内容',
  12442. select_all: '选择当前页项目',
  12443. unselect_all: '取消选择当前页项目',
  12444. clear_all: '清除全部已选择项目',
  12445. max_selected: '最多只能选择 max_selected_limit 个项目'
  12446. };
  12447. break;
  12448. }
  12449. this.message = message;
  12450. };
  12451. /**
  12452. * Css classname defined
  12453. */
  12454. SelectPage.prototype.setCssClass = function () {
  12455. var css_class = {
  12456. container: 'sp_container',
  12457. container_open: 'sp_container_open',
  12458. re_area: 'sp_result_area',
  12459. result_open: 'sp_result_area_open',
  12460. control_box: 'sp_control_box',
  12461. //multiple select mode
  12462. element_box: 'sp_element_box',
  12463. navi: 'sp_navi',
  12464. //result list
  12465. results: 'sp_results',
  12466. re_off: 'sp_results_off',
  12467. select: 'sp_over',
  12468. select_ok: 'sp_select_ok',
  12469. select_ng: 'sp_select_ng',
  12470. selected: 'sp_selected',
  12471. input_off: 'sp_input_off',
  12472. message_box: 'sp_message_box',
  12473. disabled: 'sp_disabled',
  12474. button: 'sp_button',
  12475. caret_open: 'sp_caret_open',
  12476. btn_on: 'sp_btn_on',
  12477. btn_out: 'sp_btn_out',
  12478. input: 'sp_input',
  12479. clear_btn: 'sp_clear_btn',
  12480. align_right: 'sp_align_right'
  12481. };
  12482. this.css_class = css_class;
  12483. };
  12484. /**
  12485. * Plugin inner properties
  12486. */
  12487. SelectPage.prototype.setProp = function () {
  12488. this.prop = {
  12489. //input disabled status
  12490. disabled: false,
  12491. current_page: 1,
  12492. //total page
  12493. max_page: 1,
  12494. //ajax data loading status
  12495. is_loading: false,
  12496. xhr: false,
  12497. key_paging: false,
  12498. key_select: false,
  12499. //last selected item value
  12500. prev_value: '',
  12501. //last selected item text
  12502. selected_text: '',
  12503. last_input_time: undefined,
  12504. init_set: false
  12505. };
  12506. this.template = {
  12507. tag: {
  12508. content: '<li class="selected_tag" itemvalue="#item_value#">#item_text#<span class="tag_close"><i class="spfont sp-close"></i></span></li>',
  12509. textKey: '#item_text#',
  12510. valueKey: '#item_value#'
  12511. },
  12512. page: {
  12513. current: 'page_num',
  12514. total: 'page_count'
  12515. },
  12516. msg: {
  12517. maxSelectLimit: 'max_selected_limit'
  12518. }
  12519. };
  12520. };
  12521. /**
  12522. * Get the actual width/height of invisible DOM elements with jQuery.
  12523. * Source code come from dreamerslab/jquery.actual
  12524. * @param element
  12525. * @param method
  12526. * @returns {*}
  12527. */
  12528. SelectPage.prototype.elementRealSize = function (element, method) {
  12529. var defaults = {
  12530. absolute: false,
  12531. clone: false,
  12532. includeMargin: false,
  12533. display: 'block'
  12534. };
  12535. var configs = defaults, $target = element.eq(0), fix, restore, tmp = [], style = '', $hidden;
  12536. fix = function () {
  12537. // get all hidden parents
  12538. $hidden = $target.parents().addBack().filter(':hidden');
  12539. style += 'visibility: hidden !important; display: ' + configs.display + ' !important; ';
  12540. if (configs.absolute === true) style += 'position: absolute !important;';
  12541. // save the origin style props
  12542. // set the hidden el css to be got the actual value later
  12543. $hidden.each(function () {
  12544. // Save original style. If no style was set, attr() returns undefined
  12545. var $this = $(this), thisStyle = $this.attr('style');
  12546. tmp.push(thisStyle);
  12547. // Retain as much of the original style as possible, if there is one
  12548. $this.attr('style', thisStyle ? thisStyle + ';' + style : style);
  12549. });
  12550. };
  12551. restore = function () {
  12552. // restore origin style values
  12553. $hidden.each(function (i) {
  12554. var $this = $(this), _tmp = tmp[i];
  12555. if (_tmp === undefined) $this.removeAttr('style');
  12556. else $this.attr('style', _tmp);
  12557. });
  12558. };
  12559. fix();
  12560. // get the actual value with user specific methed
  12561. // it can be 'width', 'height', 'outerWidth', 'innerWidth'... etc
  12562. // configs.includeMargin only works for 'outerWidth' and 'outerHeight'
  12563. var actual = /(outer)/.test(method) ?
  12564. $target[method](configs.includeMargin) :
  12565. $target[method]();
  12566. restore();
  12567. // IMPORTANT, this plugin only return the value of the first element
  12568. return actual;
  12569. };
  12570. /**
  12571. * Dom building
  12572. * @param {Object} combo_input - original input element
  12573. */
  12574. SelectPage.prototype.setElem = function (combo_input) {
  12575. // 1. build Dom object
  12576. var elem = {}, p = this.option, css = this.css_class, msg = this.message, input = $(combo_input);
  12577. var cssWidth = input.css("width");
  12578. var orgWidth = input.outerWidth();
  12579. if (cssWidth.indexOf("%") > -1 || input.parent().length > 0 && input.parent().width() == orgWidth) {
  12580. orgWidth = "100%";
  12581. } else {
  12582. // fix input width in hidden situation
  12583. if (orgWidth <= 0) orgWidth = this.elementRealSize(input, 'outerWidth');
  12584. if (orgWidth < 150) orgWidth = 150;
  12585. }
  12586. elem.combo_input = input.attr({'autocomplete': 'off'}).addClass(css.input).wrap('<div>');
  12587. if (p.selectOnly) elem.combo_input.prop('readonly', true);
  12588. elem.container = elem.combo_input.parent().addClass(css.container);
  12589. if (elem.combo_input.prop('disabled')) {
  12590. if (p.multiple) elem.container.addClass(css.disabled);
  12591. else elem.combo_input.addClass(css.input_off);
  12592. }
  12593. // set outer box width
  12594. elem.container.width(orgWidth);
  12595. elem.button = $('<div>').addClass(css.button);
  12596. //drop down button
  12597. elem.dropdown = $('<span class="sp_caret"></span>');
  12598. //clear button 'X' in single mode
  12599. elem.clear_btn = $('<div>').html($('<i>').addClass('spfont sp-close')).addClass(css.clear_btn).attr('title', msg.clear);
  12600. if (!p.dropButton) elem.clear_btn.addClass(css.align_right);
  12601. //main box in multiple mode
  12602. elem.element_box = $('<ul>').addClass(css.element_box);
  12603. if (p.multiple && p.multipleControlbar)
  12604. elem.control = $('<div>').addClass(css.control_box);
  12605. //result list box
  12606. elem.result_area = $('<div>').addClass(css.re_area);
  12607. //pagination bar
  12608. if (p.pagination) elem.navi = $('<div>').addClass('sp_pagination').append('<ul>');
  12609. elem.results = $('<ul>').addClass(css.results);
  12610. var namePrefix = '_text',
  12611. input_id = elem.combo_input.attr('id') || elem.combo_input.attr('name'),
  12612. input_name = elem.combo_input.attr('name') || 'selectPage',
  12613. hidden_name = input_name,
  12614. hidden_id = input_id;
  12615. //switch the id and name attributes of input/hidden element
  12616. elem.hidden = elem.combo_input.clone().attr({
  12617. name: hidden_name,
  12618. id: hidden_id,
  12619. type: 'hidden',
  12620. class: 'sp_hidden'
  12621. }).val('');
  12622. elem.combo_input.attr({
  12623. name: typeof input.data('name') !== 'undefined' ? input.data('name') : input_name + namePrefix,
  12624. id: input_id + namePrefix
  12625. });
  12626. elem.hidden.attr("data-rule", elem.combo_input.data("rule") || '');
  12627. elem.combo_input.attr("novalidate", "novalidate");
  12628. // 2. DOM element put
  12629. elem.container.append(elem.hidden);
  12630. if (p.dropButton) {
  12631. elem.container.append(elem.button)
  12632. elem.button.append(elem.dropdown);
  12633. }
  12634. $(document.body).append(elem.result_area);
  12635. elem.result_area.append(elem.results);
  12636. if (p.pagination) elem.result_area.append(elem.navi);
  12637. //Multiple select mode
  12638. if (p.multiple) {
  12639. if (p.multipleControlbar) {
  12640. elem.control.append('<button type="button" class="btn btn-default sp_clear_all" ><i class="spfont sp-clear"></i></button>');
  12641. elem.control.append('<button type="button" class="btn btn-default sp_unselect_all" ><i class="spfont sp-unselect-all"></i></button>');
  12642. elem.control.append('<button type="button" class="btn btn-default sp_select_all" ><i class="spfont sp-select-all"></i></button>');
  12643. elem.control_text = $('<p>');
  12644. elem.control.append(elem.control_text);
  12645. elem.result_area.prepend(elem.control);
  12646. }
  12647. elem.container.addClass('sp_container_combo');
  12648. elem.combo_input.addClass('sp_combo_input').before(elem.element_box);
  12649. var li = $('<li>').addClass('input_box');
  12650. li.append(elem.combo_input);
  12651. elem.element_box.append(li);
  12652. if (elem.combo_input.attr('placeholder')) elem.combo_input.attr('placeholder_bak', elem.combo_input.attr('placeholder'));
  12653. }
  12654. this.elem = elem;
  12655. };
  12656. /**
  12657. * Drop down button set to default
  12658. */
  12659. SelectPage.prototype.setButtonAttrDefault = function () {
  12660. /*
  12661. if (this.option.selectOnly) {
  12662. if ($(this.elem.combo_input).val() !== '') {
  12663. if ($(this.elem.hidden).val() !== '') {
  12664. //选择条件
  12665. $(this.elem.combo_input).attr('title', this.message.select_ok).removeClass(this.css_class.select_ng).addClass(this.css_class.select_ok);
  12666. } else {
  12667. //输入方式
  12668. $(this.elem.combo_input).attr('title', this.message.select_ng).removeClass(this.css_class.select_ok).addClass(this.css_class.select_ng);
  12669. }
  12670. } else {
  12671. $(this.elem.hidden).val('');
  12672. $(this.elem.combo_input).removeAttr('title').removeClass(this.css_class.select_ng);
  12673. }
  12674. }
  12675. */
  12676. //this.elem.button.attr('title', this.message.get_all_btn);
  12677. if (this.option.dropButton)
  12678. this.elem.button.attr('title', this.message.close_btn);
  12679. };
  12680. /**
  12681. * Set item need selected after init
  12682. * set selected item ways:
  12683. * <input value="key">
  12684. * <input data-init="key">
  12685. */
  12686. SelectPage.prototype.setInitRecord = function (refresh) {
  12687. var self = this, p = self.option, el = self.elem, key = '';
  12688. if ($.type(el.combo_input.data('init')) != 'undefined')
  12689. p.initRecord = String(el.combo_input.data('init'));
  12690. //data-init and value attribute can be init plugin selected item
  12691. //but, if set data-init and value attribute in the same time, plugin will choose data-init attribute first
  12692. if (!refresh && !p.initRecord && el.combo_input.val())
  12693. p.initRecord = el.combo_input.val();
  12694. el.combo_input.val('');
  12695. if (!refresh) el.hidden.val(p.initRecord);
  12696. key = refresh && el.hidden.val() ? el.hidden.val() : p.initRecord;
  12697. if (key) {
  12698. if (typeof p.data === 'object') {
  12699. var data = new Array();
  12700. var keyarr = key.split(',');
  12701. $.each(keyarr, function (index, row) {
  12702. for (var i = 0; i < p.data.length; i++) {
  12703. if (p.data[i][p.keyField] == row) {
  12704. data.push(p.data[i]);
  12705. break;
  12706. }
  12707. }
  12708. });
  12709. if (!p.multiple && data.length > 1) data = [data[0]];
  12710. self.afterInit(self, data);
  12711. } else {//ajax data source mode to init selected item
  12712. var _paramsFunc = p.params, _params = {}, searchKey = p.searchField;
  12713. var _orgParams = {
  12714. searchTable: p.dbTable,
  12715. searchKey: p.keyField,
  12716. searchValue: key,
  12717. orderBy: p.orderBy,
  12718. showField: p.showField,
  12719. keyField: p.keyField,
  12720. keyValue: key,
  12721. searchField: p.searchField
  12722. };
  12723. if (_paramsFunc) {
  12724. var result = $.isFunction(_paramsFunc) ? _paramsFunc(self) : _paramsFunc;
  12725. if (result && $.isPlainObject(result)) {
  12726. _params = $.extend({}, _orgParams, result);
  12727. } else {
  12728. _params = _orgParams;
  12729. }
  12730. } else {
  12731. _params = _orgParams;
  12732. }
  12733. $.ajax({
  12734. dataType: 'json',
  12735. type: 'POST',
  12736. url: p.data,
  12737. data: _params,
  12738. success: function (json) {
  12739. var d = null;
  12740. if (p.eAjaxSuccess && $.isFunction(p.eAjaxSuccess))
  12741. d = p.eAjaxSuccess(json);
  12742. self.afterInit(self, d.list);
  12743. },
  12744. error: function (jqXHR, textStatus, errorThrown) {
  12745. self.ajaxErrorNotify(self, errorThrown);
  12746. }
  12747. });
  12748. }
  12749. }
  12750. };
  12751. /**
  12752. * Selected item set to plugin
  12753. * @param {Object} self
  12754. * @param {Object} data - selected item data
  12755. */
  12756. SelectPage.prototype.afterInit = function (self, data) {
  12757. if (!data || ($.isArray(data) && data.length === 0)) return;
  12758. if (!$.isArray(data)) data = [data];
  12759. var p = self.option, css = self.css_class;
  12760. self.data = data;
  12761. if (p.multiple) {
  12762. self.prop.init_set = true;
  12763. self.clearAll(self);
  12764. $.each(data, function (i, row) {
  12765. var value = row[p.keyField];
  12766. var text = row[p.showField];
  12767. var item = {text: text, value: value};
  12768. if (!self.isAlreadySelected(self, item)) self.addNewTag(self, row, item);
  12769. });
  12770. self.tagValuesSet(self);
  12771. self.inputResize(self);
  12772. self.elem.hidden.blur();
  12773. self.prop.init_set = false;
  12774. } else {
  12775. var row = data[0];
  12776. var value = row[p.keyField];
  12777. var text = row[p.showField];
  12778. self.elem.combo_input.val(text);
  12779. self.elem.hidden.val(value);
  12780. self.prop.prev_value = text;
  12781. self.prop.selected_text = text;
  12782. if (p.selectOnly) {
  12783. self.elem.combo_input.attr('title', self.message.select_ok).removeClass(css.select_ng).addClass(css.select_ok);
  12784. }
  12785. self.putClearButton();
  12786. }
  12787. };
  12788. /**
  12789. * Drop down button event bind
  12790. */
  12791. SelectPage.prototype.eDropdownButton = function () {
  12792. var self = this;
  12793. if (self.option.dropButton) {
  12794. self.elem.button.mouseup(function (ev) {
  12795. ev.stopPropagation();
  12796. if (self.elem.result_area.is(':hidden') && !self.elem.combo_input.prop('disabled')) {
  12797. self.elem.combo_input.focus();
  12798. } else self.hideResults(self);
  12799. });
  12800. }
  12801. };
  12802. /**
  12803. * Events bind
  12804. */
  12805. SelectPage.prototype.eInput = function () {
  12806. var self = this, p = self.option, el = self.elem, msg = self.message;
  12807. var showList = function () {
  12808. self.prop.page_move = false;
  12809. self.suggest(self);
  12810. self.setCssFocusedInput(self);
  12811. };
  12812. el.combo_input.keyup(function (e) {
  12813. self.processKey(self, e);
  12814. }).keydown(function (e) {
  12815. self.processControl(self, e);
  12816. }).focus(function (e) {
  12817. //When focus on input, show the result list
  12818. if (el.result_area.is(':hidden')) {
  12819. e.stopPropagation();
  12820. self.prop.first_show = true;
  12821. showList();
  12822. }
  12823. });
  12824. el.container.on('click.SelectPage', 'div.' + self.css_class.clear_btn, function (e) {
  12825. e.stopPropagation();
  12826. if (!self.disabled(self)) {
  12827. self.clearAll(self, true);
  12828. self.elem.hidden.change();
  12829. if (p.eClear && $.isFunction(p.eClear)) p.eClear(self);
  12830. }
  12831. });
  12832. el.result_area.on('mousedown.SelectPage', function (e) {
  12833. e.stopPropagation();
  12834. });
  12835. if (p.multiple) {
  12836. if (p.multipleControlbar) {
  12837. //Select all item of current page
  12838. el.control.find('.sp_select_all').on('click.SelectPage', function (e) {
  12839. self.selectAllLine(self);
  12840. }).hover(function () {
  12841. el.control_text.html(msg.select_all);
  12842. }, function () {
  12843. el.control_text.html('');
  12844. });
  12845. //Cancel select all item of current page
  12846. el.control.find('.sp_unselect_all').on('click.SelectPage', function (e) {
  12847. self.unSelectAllLine(self);
  12848. }).hover(function () {
  12849. el.control_text.html(msg.unselect_all);
  12850. }, function () {
  12851. el.control_text.html('');
  12852. });
  12853. //Clear all selected item
  12854. el.control.find('.sp_clear_all').on('click.SelectPage', function (e) {
  12855. self.clearAll(self, true);
  12856. }).hover(function () {
  12857. el.control_text.html(msg.clear_all);
  12858. }, function () {
  12859. el.control_text.html('');
  12860. });
  12861. }
  12862. el.element_box.on('click.SelectPage', function (e) {
  12863. var srcEl = e.target || e.srcElement;
  12864. if ($(srcEl).is('ul')) el.combo_input.focus();
  12865. });
  12866. //Tag close
  12867. el.element_box.on('click.SelectPage', 'span.tag_close', function () {
  12868. var li = $(this).closest('li'), data = li.data('dataObj');
  12869. self.removeTag(self, li);
  12870. showList();
  12871. if (p.eTagRemove && $.isFunction(p.eTagRemove)) p.eTagRemove([data]);
  12872. });
  12873. self.inputResize(self);
  12874. }
  12875. };
  12876. /**
  12877. * Out of plugin area click event handler
  12878. */
  12879. SelectPage.prototype.eWhole = function () {
  12880. var self = this, css = self.css_class;
  12881. var cleanContent = function (obj) {
  12882. obj.elem.combo_input.val('');
  12883. if (!obj.option.multiple) obj.elem.hidden.val('');
  12884. obj.prop.selected_text = '';
  12885. };
  12886. //Out of plugin area
  12887. $(document.body).off('mousedown.selectPage').on('mousedown.selectPage', function (e) {
  12888. var ele = e.target || e.srcElement;
  12889. var sp = $(ele).closest('div.' + css.container);
  12890. //Open status result list
  12891. $('div.' + css.container + '.' + css.container_open).each(function () {
  12892. if (this == sp[0]) return;
  12893. var $this = $(this), d = $this.find('input.' + css.input).data(SelectPage.dataKey);
  12894. if (!d.elem.combo_input.val() && d.elem.hidden.val() && !d.option.multiple) {
  12895. d.prop.current_page = 1;//reset page to 1
  12896. cleanContent(d);
  12897. d.hideResults(d);
  12898. return true;
  12899. }
  12900. if (d.elem.results.find('li').not('.' + css.message_box).length) {
  12901. if (d.option.autoFillResult) {
  12902. //have selected item, then hide result list
  12903. if (d.elem.hidden.val()) d.hideResults(d);
  12904. else if (d.elem.results.find('li.sp_over').length) {
  12905. //no one selected and have highlight item, select the highlight item
  12906. d.selectCurrentLine(d, true);
  12907. } else if (d.option.autoSelectFirst) {
  12908. //no one selected, no one highlight, select the first item
  12909. d.nextLine(d);
  12910. d.selectCurrentLine(d, true);
  12911. } else d.hideResults(d);
  12912. } else d.hideResults(d);
  12913. } else {
  12914. //when no one item match, clear search keywords
  12915. if (d.option.noResultClean) cleanContent(d);
  12916. else {
  12917. if (!d.option.multiple) d.elem.hidden.val('');
  12918. }
  12919. d.hideResults(d);
  12920. }
  12921. });
  12922. });
  12923. };
  12924. /**
  12925. * Result list event bind
  12926. */
  12927. SelectPage.prototype.eResultList = function () {
  12928. var self = this, css = this.css_class;
  12929. self.elem.results.children('li').hover(function () {
  12930. if (self.prop.key_select) {
  12931. self.prop.key_select = false;
  12932. return;
  12933. }
  12934. if (!$(this).hasClass(css.selected) && !$(this).hasClass(css.message_box)) {
  12935. $(this).addClass(css.select);
  12936. self.setCssFocusedResults(self);
  12937. }
  12938. }, function () {
  12939. $(this).removeClass(css.select);
  12940. }).click(function (e) {
  12941. if (self.prop.key_select) {
  12942. self.prop.key_select = false;
  12943. return;
  12944. }
  12945. e.preventDefault();
  12946. e.stopPropagation();
  12947. if (!$(this).hasClass(css.selected)) self.selectCurrentLine(self, false);
  12948. });
  12949. };
  12950. /**
  12951. * Reposition result list when list beyond the visible area
  12952. */
  12953. SelectPage.prototype.eScroll = function () {
  12954. var self = this, css = this.css_class;
  12955. $(window).on('scroll.SelectPage', function (e) {
  12956. $('div.' + css.container + '.' + css.container_open).each(function () {
  12957. var $this = $(this), d = $this.find('input.' + css.input).data(SelectPage.dataKey),
  12958. offset = d.elem.result_area.offset(),
  12959. screenScrollTop = $(window).scrollTop(),
  12960. docHeight = $(document).height(),
  12961. viewHeight = $(window).height(),
  12962. listHeight = d.elem.result_area.outerHeight(),
  12963. listBottom = offset.top + listHeight,
  12964. hasOverflow = docHeight > viewHeight,
  12965. down = d.elem.result_area.hasClass('shadowDown');
  12966. if (hasOverflow) {
  12967. if (down) {//open down
  12968. if (listBottom > (viewHeight + screenScrollTop)) d.calcResultsSize(d);
  12969. } else {//open up
  12970. if (offset.top < screenScrollTop) d.calcResultsSize(d);
  12971. }
  12972. }
  12973. });
  12974. });
  12975. };
  12976. /**
  12977. * Page bar button event bind
  12978. */
  12979. SelectPage.prototype.ePaging = function () {
  12980. var self = this;
  12981. if (!self.option.pagination) return;
  12982. self.elem.navi.find('li.csFirstPage').off('click').on('click', function (ev) {
  12983. //$(self.elem.combo_input).focus();
  12984. ev.preventDefault();
  12985. self.firstPage(self);
  12986. });
  12987. self.elem.navi.find('li.csPreviousPage').off('click').on('click', function (ev) {
  12988. //$(self.elem.combo_input).focus();
  12989. ev.preventDefault();
  12990. self.prevPage(self);
  12991. });
  12992. self.elem.navi.find('li.csNextPage').off('click').on('click', function (ev) {
  12993. //$(self.elem.combo_input).focus();
  12994. ev.preventDefault();
  12995. self.nextPage(self);
  12996. });
  12997. self.elem.navi.find('li.csLastPage').off('click').on('click', function (ev) {
  12998. //$(self.elem.combo_input).focus();
  12999. ev.preventDefault();
  13000. self.lastPage(self);
  13001. });
  13002. };
  13003. /**
  13004. * Ajax request fail
  13005. * @param {Object} self
  13006. * @param {string} errorThrown
  13007. */
  13008. SelectPage.prototype.ajaxErrorNotify = function (self, errorThrown) {
  13009. self.showMessage(self, self.message.ajax_error);
  13010. };
  13011. /**
  13012. * Message box
  13013. * @param {Object} self
  13014. * @param msg {string} the text need to show
  13015. */
  13016. SelectPage.prototype.showMessage = function (self, msg) {
  13017. if (!msg) return;
  13018. var msgLi = '<li class="' + self.css_class.message_box + '"><i class="spfont sp-warning"></i> ' + msg + '</li>';
  13019. self.elem.results.empty().append(msgLi).show();
  13020. self.calcResultsSize(self);
  13021. self.setOpenStatus(self, true);
  13022. if (self.elem.control) self.elem.control.hide();
  13023. if (self.option.pagination) self.elem.navi.hide();
  13024. };
  13025. /**
  13026. * @desc Scroll
  13027. * @param {Object} self
  13028. * @param {boolean} enforce
  13029. */
  13030. SelectPage.prototype.scrollWindow = function (self, enforce) {
  13031. var current_result = self.getCurrentLine(self),
  13032. target_top = (current_result && !enforce) ? current_result.offset().top : self.elem.container.offset().top,
  13033. target_size;
  13034. self.prop.size_li = self.elem.results.children('li:first').outerHeight();
  13035. target_size = self.prop.size_li;
  13036. var gap, client_height = $(window).height(),
  13037. scroll_top = $(window).scrollTop(),
  13038. scroll_bottom = scroll_top + client_height - target_size;
  13039. if (current_result.length) {
  13040. if (target_top < scroll_top || target_size > client_height) {
  13041. //scroll to top
  13042. gap = target_top - scroll_top;
  13043. } else if (target_top > scroll_bottom) {
  13044. //scroll down
  13045. gap = target_top - scroll_bottom;
  13046. } else return; //do not scroll
  13047. } else if (target_top < scroll_top) gap = target_top - scroll_top;
  13048. window.scrollBy(0, gap);
  13049. };
  13050. /**
  13051. * change css class by status
  13052. * @param self
  13053. * @param status {boolean} true: open, false: close
  13054. */
  13055. SelectPage.prototype.setOpenStatus = function (self, status) {
  13056. var el = self.elem, css = self.css_class;
  13057. if (status) {
  13058. el.container.addClass(css.container_open);
  13059. el.result_area.addClass(css.result_open);
  13060. } else {
  13061. el.container.removeClass(css.container_open);
  13062. el.result_area.removeClass(css.result_open);
  13063. }
  13064. };
  13065. /**
  13066. * input element in focus css class set
  13067. * @param {Object} self
  13068. */
  13069. SelectPage.prototype.setCssFocusedInput = function (self) {
  13070. //$(self.elem.results).addClass(self.css_class.re_off);
  13071. //$(self.elem.combo_input).removeClass(self.css_class.input_off);
  13072. };
  13073. /**
  13074. * set result list get focus and input element lost focus
  13075. * @param {Object} self
  13076. */
  13077. SelectPage.prototype.setCssFocusedResults = function (self) {
  13078. //$(self.elem.results).removeClass(self.css_class.re_off);
  13079. //$(self.elem.combo_input).addClass(self.css_class.input_off);
  13080. };
  13081. /**
  13082. * Quick search input keywords listener
  13083. * @param {Object} self
  13084. */
  13085. SelectPage.prototype.checkValue = function (self) {
  13086. var now_value = self.elem.combo_input.val();
  13087. if (now_value != self.prop.prev_value) {
  13088. self.prop.prev_value = now_value;
  13089. self.prop.first_show = false;
  13090. if (self.option.selectOnly) self.setButtonAttrDefault();
  13091. if (!self.option.multiple && !now_value) {
  13092. self.elem.combo_input.val('');
  13093. self.elem.hidden.val('');
  13094. self.elem.clear_btn.remove();
  13095. }
  13096. self.suggest(self);
  13097. }
  13098. };
  13099. /**
  13100. * Input handle(regular input)
  13101. * @param {Object} self
  13102. * @param {Object} e - event object
  13103. */
  13104. SelectPage.prototype.processKey = function (self, e) {
  13105. if ($.inArray(e.keyCode, [37, 38, 39, 40, 27, 9, 13]) === -1) {
  13106. if (e.keyCode != 16) self.setCssFocusedInput(self); // except Shift(16)
  13107. self.inputResize(self);
  13108. if ($.type(self.option.data) === 'string') {
  13109. self.prop.last_input_time = e.timeStamp;
  13110. setTimeout(function () {
  13111. if ((e.timeStamp - self.prop.last_input_time) === 0)
  13112. self.checkValue(self);
  13113. }, self.option.inputDelay * 1000);
  13114. } else {
  13115. self.checkValue(self);
  13116. }
  13117. }
  13118. }
  13119. /**
  13120. * Input handle(control key)
  13121. * @param {Object} self
  13122. * @param {Object} e - event object
  13123. */
  13124. SelectPage.prototype.processControl = function (self, e) {
  13125. if (($.inArray(e.keyCode, [37, 38, 39, 40, 27, 9]) > -1 && self.elem.result_area.is(':visible')) ||
  13126. ($.inArray(e.keyCode, [13, 9]) > -1 && self.getCurrentLine(self))) {
  13127. e.preventDefault();
  13128. e.stopPropagation();
  13129. e.cancelBubble = true;
  13130. e.returnValue = false;
  13131. switch (e.keyCode) {
  13132. case 37:// left
  13133. if (e.shiftKey) self.firstPage(self);
  13134. else self.prevPage(self);
  13135. break;
  13136. case 38:// up
  13137. self.prop.key_select = true;
  13138. self.prevLine(self);
  13139. break;
  13140. case 39:// right
  13141. if (e.shiftKey) self.lastPage(self);
  13142. else self.nextPage(self);
  13143. break;
  13144. case 40:// down
  13145. if (self.elem.results.children('li').length) {
  13146. self.prop.key_select = true;
  13147. self.nextLine(self);
  13148. } else self.suggest(self);
  13149. break;
  13150. case 9:// tab
  13151. self.prop.key_paging = true;
  13152. self.selectCurrentLine(self, true);
  13153. //self.hideResults(self);
  13154. break;
  13155. case 13:// return
  13156. self.selectCurrentLine(self, true);
  13157. break;
  13158. case 27:// escape
  13159. self.prop.key_paging = true;
  13160. self.hideResults(self);
  13161. break;
  13162. }
  13163. }
  13164. };
  13165. /**
  13166. * Abort Ajax request
  13167. * @param {Object} self
  13168. */
  13169. SelectPage.prototype.abortAjax = function (self) {
  13170. if (self.prop.xhr) {
  13171. self.prop.xhr.abort();
  13172. self.prop.xhr = false;
  13173. }
  13174. };
  13175. /**
  13176. * Suggest result of search keywords
  13177. * @param {Object} self
  13178. */
  13179. SelectPage.prototype.suggest = function (self) {
  13180. var q_word, val = $.trim(self.elem.combo_input.val());
  13181. if (self.option.multiple) q_word = val;
  13182. else {
  13183. if (val && val === self.prop.selected_text) q_word = '';
  13184. else q_word = val;
  13185. }
  13186. q_word = q_word.split(self.option.separator);
  13187. //Before show up result list callback
  13188. if (self.option.eOpen && $.isFunction(self.option.eOpen))
  13189. self.option.eOpen.call(self);
  13190. self.abortAjax(self);
  13191. //self.setLoading(self);
  13192. var which_page_num = self.prop.current_page || 1;
  13193. if (typeof self.option.data == 'object') self.searchForJson(self, q_word, which_page_num);
  13194. else self.searchForDb(self, q_word, which_page_num);
  13195. };
  13196. /**
  13197. * Loading
  13198. * @param {Object} self
  13199. */
  13200. SelectPage.prototype.setLoading = function (self) {
  13201. if (self.elem.results.html() === '') {
  13202. //self.calcResultsSize(self);
  13203. self.setOpenStatus(self, true);
  13204. }
  13205. };
  13206. /**
  13207. * Search for ajax
  13208. * @param {Object} self
  13209. * @param {Array} q_word - query keyword
  13210. * @param {number} which_page_num - target page number
  13211. */
  13212. SelectPage.prototype.searchForDb = function (self, q_word, which_page_num) {
  13213. var p = self.option;
  13214. if (!p.eAjaxSuccess || !$.isFunction(p.eAjaxSuccess)) self.hideResults(self);
  13215. var _paramsFunc = p.params, _params = {}, searchKey = p.searchField;
  13216. //when have new query keyword, then reset page number to 1.
  13217. if (q_word.length && q_word[0] && q_word.join(self.option.separator) !== self.prop.prev_value) which_page_num = 1;
  13218. var _orgParams = {
  13219. q_word: q_word,
  13220. pageNumber: which_page_num,
  13221. pageSize: p.pageSize,
  13222. andOr: p.andOr,
  13223. orderBy: p.orderBy,
  13224. searchTable: p.dbTable,
  13225. showField: self.option.showField,
  13226. keyField: self.option.keyField,
  13227. searchField: self.option.searchField
  13228. };
  13229. if (p.orderBy !== false) _orgParams.orderBy = p.orderBy;
  13230. // 这个应该是历史遗留了,没仔细追逻辑,先留着。
  13231. _orgParams[searchKey] = q_word[0];
  13232. if (_paramsFunc) {
  13233. var result = $.isFunction(_paramsFunc) ? _paramsFunc(self) : _paramsFunc;
  13234. if (result && $.isPlainObject(result)) {
  13235. _params = $.extend({}, _orgParams, result);
  13236. } else {
  13237. _params = _orgParams;
  13238. }
  13239. } else {
  13240. _params = _orgParams;
  13241. }
  13242. self.prop.xhr = $.ajax({
  13243. dataType: 'json',
  13244. url: p.data,
  13245. type: 'POST',
  13246. data: _params,
  13247. success: function (returnData) {
  13248. if (!returnData || !$.isPlainObject(returnData)) {
  13249. self.hideResults(self);
  13250. self.ajaxErrorNotify(self, errorThrown);
  13251. return;
  13252. }
  13253. var data = {}, json = {};
  13254. try {
  13255. data = p.eAjaxSuccess(returnData);
  13256. json.originalResult = data.list;
  13257. json.cnt_whole = data.totalRow;
  13258. } catch (e) {
  13259. self.showMessage(self, self.message.ajax_error);
  13260. return;
  13261. }
  13262. if (self.elem.navi) {
  13263. $(self.elem.navi).toggleClass("hide", json.cnt_whole <= json.originalResult.length);
  13264. }
  13265. json.candidate = [];
  13266. json.keyField = [];
  13267. if (typeof json.originalResult != 'object') {
  13268. self.prop.xhr = null;
  13269. self.notFoundSearch(self);
  13270. return;
  13271. }
  13272. json.cnt_page = json.originalResult.length;
  13273. for (var i = 0; i < json.cnt_page; i++) {
  13274. for (var key in json.originalResult[i]) {
  13275. if (key == p.keyField) {
  13276. json.keyField.push(json.originalResult[i][key]);
  13277. }
  13278. if (key == p.showField) {
  13279. json.candidate.push(json.originalResult[i][key]);
  13280. }
  13281. }
  13282. }
  13283. self.prepareResults(self, json, q_word, which_page_num);
  13284. },
  13285. error: function (jqXHR, textStatus, errorThrown) {
  13286. if (textStatus != 'abort') {
  13287. self.hideResults(self);
  13288. self.ajaxErrorNotify(self, errorThrown);
  13289. }
  13290. },
  13291. complete: function () {
  13292. self.prop.xhr = null;
  13293. }
  13294. });
  13295. };
  13296. /**
  13297. * Search for json data source
  13298. * @param {Object} self
  13299. * @param {Array} q_word
  13300. * @param {number} which_page_num
  13301. */
  13302. SelectPage.prototype.searchForJson = function (self, q_word, which_page_num) {
  13303. var p = self.option, matched = [], esc_q = [], sorted = [], json = {}, i = 0, arr_reg = [];
  13304. //query keyword filter
  13305. do {
  13306. //'/\W/g'正则代表全部不是字母,数字,下划线,汉字的字符
  13307. //将非法字符进行转义
  13308. esc_q[i] = q_word[i].replace(/\W/g, '\\$&').toString();
  13309. arr_reg[i] = new RegExp(esc_q[i], 'gi');
  13310. i++;
  13311. } while (i < q_word.length);
  13312. // SELECT * FROM data WHERE field LIKE q_word;
  13313. for (var i = 0; i < p.data.length; i++) {
  13314. var flag = false, row = p.data[i], itemText;
  13315. for (var j = 0; j < arr_reg.length; j++) {
  13316. itemText = row[p.searchField];
  13317. if (p.formatItem && $.isFunction(p.formatItem))
  13318. itemText = p.formatItem(row);
  13319. if (itemText.match(arr_reg[j])) {
  13320. flag = true;
  13321. if (p.andOr == 'OR') break;
  13322. } else {
  13323. flag = false;
  13324. if (p.andOr == 'AND') break;
  13325. }
  13326. }
  13327. if (flag) matched.push(row);
  13328. }
  13329. // (CASE WHEN ...) then く order some column
  13330. if (p.orderBy === false) sorted = matched.concat();
  13331. else {
  13332. var reg1 = new RegExp('^' + esc_q[0] + '$', 'gi'),
  13333. reg2 = new RegExp('^' + esc_q[0], 'gi'),
  13334. matched1 = [], matched2 = [], matched3 = [];
  13335. for (var i = 0; i < matched.length; i++) {
  13336. var orderField = p.orderBy[0][0];
  13337. var orderValue = String(matched[i][orderField]);
  13338. if (orderValue.match(reg1)) {
  13339. matched1.push(matched[i]);
  13340. } else if (orderValue.match(reg2)) {
  13341. matched2.push(matched[i]);
  13342. } else {
  13343. matched3.push(matched[i]);
  13344. }
  13345. }
  13346. if (p.orderBy[0][1].match(/^asc$/i)) {
  13347. matched1 = self.sortAsc(self, matched1);
  13348. matched2 = self.sortAsc(self, matched2);
  13349. matched3 = self.sortAsc(self, matched3);
  13350. } else {
  13351. matched1 = self.sortDesc(self, matched1);
  13352. matched2 = self.sortDesc(self, matched2);
  13353. matched3 = self.sortDesc(self, matched3);
  13354. }
  13355. sorted = sorted.concat(matched1).concat(matched2).concat(matched3);
  13356. }
  13357. /*
  13358. if (sorted.length === undefined || sorted.length === 0 ) {
  13359. self.notFoundSearch(self);
  13360. return;
  13361. }
  13362. */
  13363. json.cnt_whole = sorted.length;
  13364. //page_move used to distinguish between init plugin or page moving
  13365. if (!self.prop.page_move) {
  13366. //only single mode can be used page number relocation
  13367. if (!p.multiple) {
  13368. //get selected item belong page number
  13369. var currentValue = self.elem.hidden.val();
  13370. if ($.type(currentValue) !== 'undefined' && $.trim(currentValue) !== '') {
  13371. var index = 0;
  13372. $.each(sorted, function (i, row) {
  13373. if (row[p.keyField] == currentValue) {
  13374. index = i + 1;
  13375. return false;
  13376. }
  13377. });
  13378. which_page_num = Math.ceil(index / p.pageSize);
  13379. if (which_page_num < 1) which_page_num = 1;
  13380. self.prop.current_page = which_page_num;
  13381. }
  13382. }
  13383. } else {
  13384. //set page number to 1 when result number less then page size
  13385. if (sorted.length <= ((which_page_num - 1) * p.pageSize)) {
  13386. which_page_num = 1;
  13387. self.prop.current_page = 1;
  13388. }
  13389. }
  13390. //LIMIT xx OFFSET xx
  13391. var start = (which_page_num - 1) * p.pageSize, end = start + p.pageSize;
  13392. //save original data
  13393. json.originalResult = [];
  13394. //after data filter handle
  13395. for (var i = start; i < end; i++) {
  13396. if (sorted[i] === undefined) break;
  13397. json.originalResult.push(sorted[i]);
  13398. for (var key in sorted[i]) {
  13399. if (key == p.keyField) {
  13400. if (json.keyField === undefined) json.keyField = [];
  13401. json.keyField.push(sorted[i][key]);
  13402. }
  13403. if (key == p.showField) {
  13404. if (json.candidate === undefined) json.candidate = [];
  13405. json.candidate.push(sorted[i][key]);
  13406. }
  13407. }
  13408. }
  13409. if (json.candidate === undefined) json.candidate = [];
  13410. json.cnt_page = json.candidate.length;
  13411. self.prepareResults(self, json, q_word, which_page_num);
  13412. };
  13413. /**
  13414. * Set order asc
  13415. * @param {Object} self
  13416. * @param {Array} arr - result array
  13417. */
  13418. SelectPage.prototype.sortAsc = function (self, arr) {
  13419. arr.sort(function (a, b) {
  13420. var valA = a[self.option.orderBy[0][0]], valB = b[self.option.orderBy[0][0]];
  13421. return $.type(valA) === 'number' ? valA - valB : String(valA).localeCompare(String(valB));
  13422. });
  13423. return arr;
  13424. };
  13425. /**
  13426. * Set order desc
  13427. * @param {Object} self
  13428. * @param {Array} arr - result array
  13429. */
  13430. SelectPage.prototype.sortDesc = function (self, arr) {
  13431. arr.sort(function (a, b) {
  13432. var valA = a[self.option.orderBy[0][0]], valB = b[self.option.orderBy[0][0]];
  13433. return $.type(valA) === 'number' ? valB - valA : String(valB).localeCompare(String(valA));
  13434. });
  13435. return arr;
  13436. };
  13437. /**
  13438. * Not result found handle
  13439. * @param {Object} self
  13440. */
  13441. SelectPage.prototype.notFoundSearch = function (self) {
  13442. self.elem.results.empty();
  13443. self.calcResultsSize(self);
  13444. self.setOpenStatus(self, true);
  13445. self.setCssFocusedInput(self);
  13446. };
  13447. /**
  13448. * Prepare data to show
  13449. * @param {Object} self
  13450. * @param {Object} json - data result
  13451. * @param {Array} q_word - query keyword
  13452. * @param {number} which_page_num - target page number
  13453. */
  13454. SelectPage.prototype.prepareResults = function (self, json, q_word, which_page_num) {
  13455. self.data = json.originalResult;
  13456. if (self.option.pagination) self.setNavi(self, json.cnt_whole, json.cnt_page, which_page_num);
  13457. if (!json.keyField) json.keyField = false;
  13458. if (self.option.selectOnly && json.candidate.length === 1 && json.candidate[0] == q_word[0]) {
  13459. self.elem.hidden.val(json.keyField[0]);
  13460. this.setButtonAttrDefault();
  13461. }
  13462. var is_query = false;
  13463. if (q_word && q_word.length && q_word[0]) is_query = true;
  13464. self.displayResults(self, json, is_query);
  13465. };
  13466. /**
  13467. * Build page bar
  13468. * @param {Object} self
  13469. * @param {number} cnt_whole - total record count
  13470. * @param {number} cnt_page
  13471. * @param {number} page_num - current page number
  13472. */
  13473. SelectPage.prototype.setNavi = function (self, cnt_whole, cnt_page, page_num) {
  13474. var msg = self.message;
  13475. /**
  13476. * build pagination bar
  13477. */
  13478. var buildPageNav = function (self, pagebar, page_num, last_page) {
  13479. var updatePageInfo = function () {
  13480. var pageInfo = msg.page_info;
  13481. return pageInfo.replace(self.template.page.current, page_num).replace(self.template.page.total, last_page);
  13482. };
  13483. if (pagebar.find('li').length === 0) {
  13484. pagebar.hide().empty();
  13485. var iconFist = 'spfont sp-first',
  13486. iconPrev = 'spfont sp-previous',
  13487. iconNext = 'spfont sp-next',
  13488. iconLast = 'spfont sp-last';
  13489. pagebar.append('<li class="csFirstPage" title="' + msg.first_title + '" ><a href="javascript:void(0);"> <i class="' + iconFist + '"></i> </a></li>');
  13490. pagebar.append('<li class="csPreviousPage" title="' + msg.prev_title + '" ><a href="javascript:void(0);"><i class="' + iconPrev + '"></i></a></li>');
  13491. //pagination information
  13492. pagebar.append('<li class="pageInfoBox"><a href="javascript:void(0);"> ' + updatePageInfo() + ' </a></li>');
  13493. pagebar.append('<li class="csNextPage" title="' + msg.next_title + '" ><a href="javascript:void(0);"><i class="' + iconNext + '"></i></a></li>');
  13494. pagebar.append('<li class="csLastPage" title="' + msg.last_title + '" ><a href="javascript:void(0);"> <i class="' + iconLast + '"></i> </a></li>');
  13495. pagebar.show();
  13496. } else {
  13497. pagebar.find('li.pageInfoBox a').html(updatePageInfo());
  13498. }
  13499. };
  13500. var pagebar = self.elem.navi.find('ul'),
  13501. last_page = Math.ceil(cnt_whole / self.option.pageSize); //calculate total page
  13502. if (last_page === 0) page_num = 0;
  13503. else {
  13504. if (last_page < page_num) page_num = last_page;
  13505. else if (page_num === 0) page_num = 1;
  13506. }
  13507. self.prop.current_page = page_num;//update current page number
  13508. self.prop.max_page = last_page;//update page count
  13509. buildPageNav(self, pagebar, page_num, last_page);
  13510. //update paging status
  13511. var dClass = 'disabled',
  13512. first = pagebar.find('li.csFirstPage'),
  13513. previous = pagebar.find('li.csPreviousPage'),
  13514. next = pagebar.find('li.csNextPage'),
  13515. last = pagebar.find('li.csLastPage');
  13516. //first and previous
  13517. if (page_num === 1 || page_num === 0) {
  13518. if (!first.hasClass(dClass)) first.addClass(dClass);
  13519. if (!previous.hasClass(dClass)) previous.addClass(dClass);
  13520. } else {
  13521. if (first.hasClass(dClass)) first.removeClass(dClass);
  13522. if (previous.hasClass(dClass)) previous.removeClass(dClass);
  13523. }
  13524. //next and last
  13525. if (page_num === last_page || last_page === 0) {
  13526. if (!next.hasClass(dClass)) next.addClass(dClass);
  13527. if (!last.hasClass(dClass)) last.addClass(dClass);
  13528. } else {
  13529. if (next.hasClass(dClass)) next.removeClass(dClass);
  13530. if (last.hasClass(dClass)) last.removeClass(dClass);
  13531. }
  13532. if (last_page > 1) self.ePaging(); //pagination event bind
  13533. };
  13534. /**
  13535. * Render result list
  13536. * @param {Object} self
  13537. * @param {Object} json - result data
  13538. * @param {boolean} is_query - used to different from search to open and just click to open
  13539. */
  13540. SelectPage.prototype.displayResults = function (self, json, is_query) {
  13541. var p = self.option, el = self.elem;
  13542. el.results.hide().empty();
  13543. if (p.multiple && $.type(p.maxSelectLimit) === 'number' && p.maxSelectLimit > 0) {
  13544. var selectedSize = el.element_box.find('li.selected_tag').length;
  13545. if (selectedSize > 0 && selectedSize >= p.maxSelectLimit) {
  13546. var msg = self.message.max_selected;
  13547. self.showMessage(self, msg.replace(self.template.msg.maxSelectLimit, p.maxSelectLimit));
  13548. return;
  13549. }
  13550. }
  13551. if (json.candidate.length) {
  13552. var arr_candidate = json.candidate,
  13553. arr_primary_key = json.keyField,
  13554. keystr = el.hidden.val(),
  13555. keyArr = keystr ? keystr.split(',') : new Array(),
  13556. itemText = '';
  13557. for (var i = 0; i < arr_candidate.length; i++) {
  13558. if (p.formatItem && $.isFunction(p.formatItem)) {
  13559. try {
  13560. itemText = p.formatItem(json.originalResult[i]);
  13561. } catch (e) {
  13562. console.error('formatItem内容格式化函数内容设置不正确!');
  13563. itemText = arr_candidate[i];
  13564. }
  13565. } else itemText = arr_candidate[i];
  13566. var list = $('<li>').html(itemText).attr({
  13567. pkey: arr_primary_key[i],
  13568. index: i
  13569. });
  13570. if (!p.formatItem) list.attr('title', itemText);
  13571. //Set selected item highlight
  13572. if ($.inArray(arr_primary_key[i].toString(), keyArr) !== -1) {
  13573. list.addClass(self.css_class.selected);
  13574. }
  13575. //cache item data
  13576. list.data('dataObj', json.originalResult[i]);
  13577. el.results.append(list);
  13578. }
  13579. } else {
  13580. var li = '<li class="' + self.css_class.message_box + '"><i class="spfont sp-warning"></i> ' +
  13581. self.message.not_found + '</li>';
  13582. el.results.append(li);
  13583. }
  13584. el.results.show();
  13585. if (p.multiple && p.multipleControlbar) el.control.show();
  13586. if (p.pagination) el.navi.show();
  13587. self.calcResultsSize(self);
  13588. self.setOpenStatus(self, true);
  13589. //Result item event bind
  13590. self.eResultList();
  13591. //scrolling listen
  13592. self.eScroll();
  13593. //auto highlight first item in search, have result and set autoSelectFirst to true situation
  13594. if (is_query && json.candidate.length && p.autoSelectFirst) self.nextLine(self);
  13595. };
  13596. /**
  13597. * Calculate result list size and position
  13598. * @param {Object} self
  13599. */
  13600. SelectPage.prototype.calcResultsSize = function (self) {
  13601. var p = self.option, el = self.elem;
  13602. var rePosition = function () {
  13603. if (el.container.css('position') === 'static') {
  13604. // position: static
  13605. var offset = el.combo_input.offset();
  13606. el.result_area.css({
  13607. top: offset.top + el.combo_input.outerHeight() + 'px',
  13608. left: offset.left + 'px'
  13609. });
  13610. } else {
  13611. if (!p.pagination) {
  13612. var itemHeight = el.results.find('li:first').outerHeight(true),
  13613. listHeight = itemHeight * p.listSize;
  13614. el.results.css({
  13615. 'max-height': listHeight,
  13616. 'overflow-y': 'auto'
  13617. });
  13618. }
  13619. //handle result list show up side(left, right, up or down)
  13620. var docWidth = $(document).width(),
  13621. docHeight = $(document).height(), //the document full height
  13622. viewHeight = $(window).height(), //browser visible area height
  13623. offset = el.container.offset(),
  13624. screenScrollTop = $(window).scrollTop(),
  13625. listWidth = el.result_area.outerWidth(),
  13626. //result list height
  13627. listHeight = el.result_area.outerHeight(),
  13628. //default left used input element left
  13629. defaultLeft = offset.left, //p.multiple ? -1 : 0;
  13630. //input element height
  13631. inputHeight = el.container.outerHeight(),
  13632. left = (offset.left + listWidth) > docWidth ?
  13633. defaultLeft - (listWidth - el.container.outerWidth()) :
  13634. defaultLeft,
  13635. //the actual top coordinate of input element(outer div)
  13636. screenTop = offset.top, //$(el.container).scrollTop();//offset.top - screenScrollTop;
  13637. top = 0, dist = 5, //set distance between input element and result list
  13638. //the actual top coordinate of result list
  13639. listBottom = screenTop + inputHeight + listHeight + dist,
  13640. listTop = screenTop + listHeight + dist,
  13641. hasOverflow = docHeight > viewHeight;
  13642. if ((screenTop - screenScrollTop - dist > listHeight) &&
  13643. (hasOverflow && listBottom > (viewHeight + screenScrollTop)) ||
  13644. (!hasOverflow && listBottom > viewHeight && screenTop >= listTop)) {
  13645. //open up
  13646. top = offset.top - listHeight - dist;
  13647. el.result_area.removeClass('shadowUp shadowDown').addClass('shadowUp');
  13648. } else {
  13649. //open down
  13650. top = offset.top + (p.multiple ? el.container.outerHeight() : inputHeight);
  13651. el.result_area.removeClass('shadowUp shadowDown').addClass('shadowDown');
  13652. top += dist;
  13653. }
  13654. return {
  13655. top: top + 'px', left: left + 'px'
  13656. };
  13657. }
  13658. };
  13659. if (el.result_area.is(':visible')) {
  13660. el.result_area.css(rePosition());
  13661. } else {
  13662. var pss = rePosition();
  13663. el.result_area.css(pss).show(1, function () {
  13664. var repss = rePosition();
  13665. if (pss.top !== repss.top || pss.left !== repss.left) el.result_area.css(repss);
  13666. });
  13667. }
  13668. };
  13669. /**
  13670. * hide result list
  13671. * @param {Object} self
  13672. */
  13673. SelectPage.prototype.hideResults = function (self) {
  13674. if (self.prop.key_paging) {
  13675. self.scrollWindow(self, true);
  13676. self.prop.key_paging = false;
  13677. }
  13678. self.setCssFocusedInput(self);
  13679. if (self.option.autoFillResult) {
  13680. //self.selectCurrentLine(self, true);
  13681. }
  13682. self.elem.results.empty();
  13683. self.elem.result_area.hide();
  13684. self.setOpenStatus(self, false);
  13685. //unbind window scroll listen
  13686. $(window).off('scroll.SelectPage');
  13687. self.abortAjax(self);
  13688. self.setButtonAttrDefault();
  13689. };
  13690. /**
  13691. * set plugin to disabled / enabled
  13692. * @param self
  13693. * @param disabled
  13694. */
  13695. SelectPage.prototype.disabled = function (self, disabled) {
  13696. var p = self.option, el = self.elem;
  13697. if ($.type(disabled) === 'undefined') return el.combo_input.prop('disabled');
  13698. if ($.type(disabled) === 'boolean') {
  13699. el.combo_input.prop('disabled', disabled);
  13700. if (disabled) el.container.addClass(self.css_class.disabled);
  13701. else el.container.removeClass(self.css_class.disabled);
  13702. }
  13703. };
  13704. /**
  13705. * Go fist page
  13706. * @param {Object} self
  13707. */
  13708. SelectPage.prototype.firstPage = function (self) {
  13709. if (self.prop.current_page > 1) {
  13710. self.prop.current_page = 1;
  13711. self.prop.page_move = true;
  13712. self.suggest(self);
  13713. }
  13714. };
  13715. /**
  13716. * Go previous page
  13717. * @param {Object} self
  13718. */
  13719. SelectPage.prototype.prevPage = function (self) {
  13720. if (self.prop.current_page > 1) {
  13721. self.prop.current_page--;
  13722. self.prop.page_move = true;
  13723. self.suggest(self);
  13724. }
  13725. };
  13726. /**
  13727. * Go next page
  13728. * @param {Object} self
  13729. */
  13730. SelectPage.prototype.nextPage = function (self) {
  13731. if (self.prop.current_page < self.prop.max_page) {
  13732. self.prop.current_page++;
  13733. self.prop.page_move = true;
  13734. self.suggest(self);
  13735. }
  13736. };
  13737. /**
  13738. * Go last page
  13739. * @param {Object} self
  13740. */
  13741. SelectPage.prototype.lastPage = function (self) {
  13742. if (self.prop.current_page < self.prop.max_page) {
  13743. self.prop.current_page = self.prop.max_page;
  13744. self.prop.page_move = true;
  13745. self.suggest(self);
  13746. }
  13747. };
  13748. /**
  13749. * do something after select/unSelect action
  13750. * @param {Object} self
  13751. * @param {boolean} reOpen
  13752. */
  13753. SelectPage.prototype.afterAction = function (self, reOpen) {
  13754. self.inputResize(self);
  13755. self.elem.combo_input.change();
  13756. self.setCssFocusedInput(self);
  13757. if (self.prop.init_set) return;
  13758. if (self.option.multiple) {
  13759. if (self.option.selectToCloseList) {
  13760. self.hideResults(self);
  13761. self.elem.combo_input.blur();
  13762. }
  13763. if (!self.option.selectToCloseList && reOpen) {
  13764. self.suggest(self);
  13765. self.elem.combo_input.focus();
  13766. }
  13767. } else {
  13768. self.hideResults(self);
  13769. self.elem.combo_input.blur();
  13770. }
  13771. };
  13772. /**
  13773. * Select current list item
  13774. * @param {Object} self
  13775. * @param {boolean} is_enter_key
  13776. */
  13777. SelectPage.prototype.selectCurrentLine = function (self, is_enter_key) {
  13778. self.scrollWindow(self, true);
  13779. var p = self.option, current = self.getCurrentLine(self);
  13780. if (current) {
  13781. var data = current.data('dataObj');
  13782. var text = data[p.showField] || current.text();
  13783. var value = current.attr('pkey');
  13784. if (!p.multiple) {
  13785. self.elem.combo_input.val(text);
  13786. self.elem.hidden.val(value);
  13787. } else {
  13788. //build tags in multiple selection mode
  13789. self.elem.combo_input.val('');
  13790. var item = {text: text, value: value};
  13791. if (!self.isAlreadySelected(self, item)) {
  13792. self.addNewTag(self, data, item);
  13793. self.tagValuesSet(self);
  13794. }
  13795. }
  13796. if (p.selectOnly) self.setButtonAttrDefault();
  13797. //Select item callback
  13798. if (p.eSelect && $.isFunction(p.eSelect)) p.eSelect(data, self);
  13799. self.prop.prev_value = self.elem.combo_input.val();
  13800. self.prop.selected_text = self.elem.combo_input.val();
  13801. self.putClearButton();
  13802. }
  13803. self.afterAction(self, true);
  13804. };
  13805. /**
  13806. * Show clear button when item selected in single selection mode
  13807. */
  13808. SelectPage.prototype.putClearButton = function () {
  13809. if (!this.option.multiple && !this.elem.combo_input.prop('disabled')) this.elem.container.append(this.elem.clear_btn);
  13810. };
  13811. /**
  13812. * Select all list item
  13813. * @param {Object} self
  13814. */
  13815. SelectPage.prototype.selectAllLine = function (self) {
  13816. var p = self.option, jsonarr = new Array();
  13817. self.elem.results.find('li').each(function (i, row) {
  13818. var $row = $(row), data = $row.data('dataObj');
  13819. var text = data[p.showField] || $row.text();
  13820. var value = $row.attr('pkey');
  13821. var item = {text: text, value: value};
  13822. if (!self.isAlreadySelected(self, item)) {
  13823. self.addNewTag(self, data, item);
  13824. self.tagValuesSet(self);
  13825. }
  13826. jsonarr.push(data);
  13827. //limited max selected items
  13828. if ($.type(p.maxSelectLimit) === 'number' &&
  13829. p.maxSelectLimit > 0 &&
  13830. p.maxSelectLimit === self.elem.element_box.find('li.selected_tag').length) {
  13831. return false;
  13832. }
  13833. });
  13834. if (p.eSelect && $.isFunction(p.eSelect)) p.eSelect(jsonarr, self);
  13835. self.afterAction(self, true);
  13836. };
  13837. /**
  13838. * Cancel select all item in current page
  13839. * @param {Object} self
  13840. */
  13841. SelectPage.prototype.unSelectAllLine = function (self) {
  13842. var p = self.option, size = self.elem.results.find('li').length, ds = [];
  13843. self.elem.results.find('li').each(function (i, row) {
  13844. var key = $(row).attr('pkey');
  13845. var tag = self.elem.element_box.find('li.selected_tag[itemvalue="' + key + '"]');
  13846. if (tag.length) ds.push(tag.data('dataObj'));
  13847. self.removeTag(self, tag);
  13848. });
  13849. self.afterAction(self, true);
  13850. if (p.eTagRemove && $.isFunction(p.eTagRemove)) p.eTagRemove(ds);
  13851. };
  13852. /**
  13853. * Clear all selected items
  13854. * @param {Object} self
  13855. * @param {boolean} open - open list after clear selected item
  13856. */
  13857. SelectPage.prototype.clearAll = function (self, open) {
  13858. var p = self.option, ds = [];
  13859. if (p.multiple) {
  13860. self.elem.element_box.find('li.selected_tag').each(function (i, row) {
  13861. ds.push($(row).data('dataObj'));
  13862. row.remove();
  13863. });
  13864. self.elem.element_box.find('li.selected_tag').remove();
  13865. }
  13866. self.reset(self);
  13867. self.afterAction(self, open);
  13868. if (p.multiple) {
  13869. if (p.eTagRemove && $.isFunction(p.eTagRemove)) p.eTagRemove(ds);
  13870. } else self.elem.clear_btn.remove();
  13871. };
  13872. /**
  13873. * reset
  13874. */
  13875. SelectPage.prototype.reset = function (self) {
  13876. self.elem.combo_input.val('');
  13877. self.elem.hidden.val('');
  13878. self.prop.prev_value = '';
  13879. self.prop.selected_text = '';
  13880. self.prop.current_page = 1;
  13881. };
  13882. /**
  13883. * Get current highlight item
  13884. * @param {Object} self
  13885. */
  13886. SelectPage.prototype.getCurrentLine = function (self) {
  13887. if (self.elem.result_area.is(':hidden')) return false;
  13888. var obj = self.elem.results.find('li.' + self.css_class.select);
  13889. if (obj.length) return obj;
  13890. else return false;
  13891. };
  13892. /**
  13893. * Check the result item is already selected or not
  13894. * @param {Object} self
  13895. * @param {Object} item - item info
  13896. */
  13897. SelectPage.prototype.isAlreadySelected = function (self, item) {
  13898. var isExist = false;
  13899. if (item.value) {
  13900. var keys = self.elem.hidden.val();
  13901. if (keys) {
  13902. var karr = keys.split(',');
  13903. if (karr && karr.length && $.inArray(item.value, karr) != -1) isExist = true;
  13904. }
  13905. }
  13906. return isExist;
  13907. };
  13908. /**
  13909. * Add a new tag in multiple selection mode
  13910. * @param {Object} self
  13911. * @param {object} data - raw row data
  13912. * @param {Object} item
  13913. */
  13914. SelectPage.prototype.addNewTag = function (self, data, item) {
  13915. if (!self.option.multiple || !data || !item) return;
  13916. var tmp = self.template.tag.content, tag;
  13917. tmp = tmp.replace(self.template.tag.textKey, item.text);
  13918. tmp = tmp.replace(self.template.tag.valueKey, item.value);
  13919. tag = $(tmp);
  13920. tag.data('dataObj', data);
  13921. if (self.elem.combo_input.prop('disabled')) tag.find('span.tag_close').hide();
  13922. self.elem.combo_input.closest('li').before(tag);
  13923. };
  13924. /**
  13925. * Remove a tag in multiple selection mode
  13926. * @param {Object} self
  13927. * @param {Object} item
  13928. */
  13929. SelectPage.prototype.removeTag = function (self, item) {
  13930. var key = $(item).attr('itemvalue');
  13931. var keys = self.elem.hidden.val();
  13932. if ($.type(key) != 'undefined' && keys) {
  13933. var keyarr = keys.split(','),
  13934. index = $.inArray(key.toString(), keyarr);
  13935. if (index != -1) {
  13936. keyarr.splice(index, 1);
  13937. self.elem.hidden.val(keyarr.toString()).trigger("change");
  13938. }
  13939. }
  13940. $(item).remove();
  13941. self.inputResize(self);
  13942. };
  13943. /**
  13944. * Selected item value(keyField) put in to hidden element
  13945. * @param {Object} self
  13946. */
  13947. SelectPage.prototype.tagValuesSet = function (self) {
  13948. if (!self.option.multiple) return;
  13949. var tags = self.elem.element_box.find('li.selected_tag');
  13950. if (tags && tags.length) {
  13951. var result = new Array();
  13952. $.each(tags, function (i, li) {
  13953. var v = $(li).attr('itemvalue');
  13954. if ($.type(v) !== 'undefined') result.push(v);
  13955. });
  13956. if (result.length) {
  13957. self.elem.hidden.val(result.join(',')).trigger("change");
  13958. }
  13959. }
  13960. };
  13961. /**
  13962. * auto resize input element width in multiple select mode
  13963. * @param {Object} self
  13964. */
  13965. SelectPage.prototype.inputResize = function (self) {
  13966. if (!self.option.multiple) return;
  13967. var width = '',
  13968. inputLi = self.elem.combo_input.closest('li');
  13969. var setDefaultSize = function (self, inputLi) {
  13970. inputLi.removeClass('full_width');
  13971. var minimumWidth = self.elem.combo_input.val().length + 1,
  13972. width = (minimumWidth * 0.75) + 'em';
  13973. self.elem.combo_input.css('width', width).removeAttr('placeholder');
  13974. };
  13975. if (self.elem.element_box.find('li.selected_tag').length === 0) {
  13976. if (!inputLi.hasClass('full_width')) inputLi.addClass('full_width');
  13977. if (self.elem.combo_input.attr('placeholder_bak')) {
  13978. self.elem.combo_input.attr('placeholder', self.elem.combo_input.attr('placeholder_bak')).removeAttr('style');
  13979. }
  13980. } else setDefaultSize(self, inputLi);
  13981. };
  13982. /**
  13983. * Move to next line
  13984. * @param {Object} self
  13985. */
  13986. SelectPage.prototype.nextLine = function (self) {
  13987. var obj = self.getCurrentLine(self), idx;
  13988. if (!obj) idx = -1;
  13989. else {
  13990. idx = self.elem.results.children('li').index(obj);
  13991. obj.removeClass(self.css_class.select);
  13992. }
  13993. idx++;
  13994. if (idx < self.elem.results.children('li').length) {
  13995. var next = self.elem.results.children('li').eq(idx);
  13996. next.addClass(self.css_class.select);
  13997. self.setCssFocusedResults(self);
  13998. } else self.setCssFocusedInput(self);
  13999. self.scrollWindow(self, false);
  14000. };
  14001. /**
  14002. * Move to previous line
  14003. * @param {Object} self
  14004. */
  14005. SelectPage.prototype.prevLine = function (self) {
  14006. var obj = self.getCurrentLine(self), idx;
  14007. if (!obj) idx = self.elem.results.children('li').length;
  14008. else {
  14009. idx = self.elem.results.children('li').index(obj);
  14010. obj.removeClass(self.css_class.select);
  14011. }
  14012. idx--;
  14013. if (idx > -1) {
  14014. var prev = self.elem.results.children('li').eq(idx);
  14015. prev.addClass(self.css_class.select);
  14016. self.setCssFocusedResults(self);
  14017. } else self.setCssFocusedInput(self);
  14018. self.scrollWindow(self, false);
  14019. };
  14020. /**
  14021. * SelectPage plugin definition
  14022. * @global
  14023. * @param option {Object} init plugin option
  14024. */
  14025. function Plugin(option) {
  14026. return this.each(function () {
  14027. var $this = $(this),
  14028. data = $this.data(SelectPage.dataKey),
  14029. params = $.extend({}, defaults, $this.data(), data && data.option, typeof option === 'object' && option);
  14030. if (!data) $this.data(SelectPage.dataKey, (data = new SelectPage(this, params)));
  14031. });
  14032. }
  14033. /**
  14034. * Get plugin object
  14035. * @param {object} obj
  14036. * @returns
  14037. */
  14038. function getPlugin(obj) {
  14039. return $(obj).closest('div.sp_container').find('input.sp_input');
  14040. }
  14041. /**
  14042. * Clear all selected item
  14043. */
  14044. function ClearSelected() {
  14045. return this.each(function () {
  14046. var $this = getPlugin(this),
  14047. data = $this.data(SelectPage.dataKey);
  14048. if (data) {
  14049. data.prop.init_set = true;
  14050. data.clearAll(data);
  14051. data.prop.init_set = false;
  14052. }
  14053. });
  14054. }
  14055. /**
  14056. * Refresh result list
  14057. * use case:
  14058. * 1.use $(obj).val('xxx') to modify selectpage selected item key
  14059. * 2.refresh selected item show content/tag text
  14060. */
  14061. function SelectedRefresh() {
  14062. return this.each(function () {
  14063. var $this = getPlugin(this),
  14064. data = $this.data(SelectPage.dataKey);
  14065. if (data && data.elem.hidden.val())
  14066. data.setInitRecord(true);
  14067. });
  14068. }
  14069. /**
  14070. * Modify plugin datasource, only work on json datasource mode
  14071. * @param {array} data - new datasource
  14072. * @example
  14073. * [{name:'aa',sex:1},{name:'bb',sex:0},{...}]
  14074. */
  14075. function ModifyDataSource(data) {
  14076. return this.each(function () {
  14077. if (data && $.isArray(data)) {
  14078. var $this = getPlugin(this),
  14079. plugin = $this.data(SelectPage.dataKey);
  14080. if (plugin) {
  14081. plugin.clearAll(plugin);
  14082. plugin.option.data = data;
  14083. }
  14084. }
  14085. });
  14086. }
  14087. /**
  14088. * Get plugin disabled status or Modify plugin disabled status
  14089. * @param disabled {boolean} set disabled status
  14090. */
  14091. function PluginDisabled(disabled) {
  14092. var status = false;
  14093. this.each(function () {
  14094. var $this = getPlugin(this),
  14095. plugin = $this.data(SelectPage.dataKey);
  14096. if (plugin) {
  14097. if ($.type(disabled) !== 'undefined')
  14098. plugin.disabled(plugin, disabled);
  14099. else
  14100. status = plugin.disabled(plugin);
  14101. }
  14102. });
  14103. return status;
  14104. }
  14105. /**
  14106. * Get selected item text
  14107. * @returns {string}
  14108. */
  14109. function GetInputText() {
  14110. var str = '';
  14111. this.each(function () {
  14112. var $this = getPlugin(this), data = $this.data(SelectPage.dataKey);
  14113. if (data) {
  14114. if (data.option.multiple) {
  14115. var tags = [];
  14116. data.elem.element_box.find('li.selected_tag').each(function (i, tag) {
  14117. tags.push($(tag).text());
  14118. });
  14119. str += tags.toString();
  14120. } else {
  14121. str += data.elem.combo_input.val();
  14122. }
  14123. }
  14124. });
  14125. return str;
  14126. }
  14127. /**
  14128. * Get selected item raw data
  14129. * @returns {any[]}
  14130. */
  14131. function GetSelectedData() {
  14132. var results = [];
  14133. this.each(function () {
  14134. var $this = getPlugin(this), data = $this.data(SelectPage.dataKey);
  14135. if (data) {
  14136. if (data.option.multiple) {
  14137. data.elem.element_box.find('li.selected_tag').each(function (i, tag) {
  14138. results.push($(tag).data('dataObj'));
  14139. });
  14140. } else {
  14141. var selected = data.elem.combo_input.data('dataObj');
  14142. if (selected) results.push(selected);
  14143. }
  14144. }
  14145. });
  14146. return results;
  14147. }
  14148. var old = $.fn.selectPage;
  14149. $.fn.selectPage = Plugin;
  14150. $.fn.selectPage.Constructor = SelectPage;
  14151. $.fn.selectPageClear = ClearSelected;
  14152. $.fn.selectPageRefresh = SelectedRefresh;
  14153. $.fn.selectPageData = ModifyDataSource;
  14154. $.fn.selectPageDisabled = PluginDisabled;
  14155. $.fn.selectPageText = GetInputText;
  14156. $.fn.selectPageSelectedData = GetSelectedData;
  14157. // SelectPage no conflict
  14158. // =================
  14159. $.fn.selectPage.noConflict = function () {
  14160. $.fn.selectPage = old;
  14161. return this;
  14162. };
  14163. })(window.jQuery);
  14164. define("selectpage", ["jquery"], (function (global) {
  14165. return function () {
  14166. var ret, fn;
  14167. return ret || global.$.fn.extend;
  14168. };
  14169. }(this)));
  14170. /**
  14171. * @version: 2.1.30
  14172. * @author: Dan Grossman http://www.dangrossman.info/
  14173. * @copyright: Copyright (c) 2012-2017 Dan Grossman. All rights reserved.
  14174. * @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php
  14175. * @website: http://www.daterangepicker.com/
  14176. */
  14177. // Follow the UMD template https://github.com/umdjs/umd/blob/master/templates/returnExportsGlobal.js
  14178. (function (root, factory) {
  14179. if (typeof define === 'function' && define.amd) {
  14180. // AMD. Make globaly available as well
  14181. define('bootstrap-daterangepicker',['moment', 'jquery'], function (moment, jquery) {
  14182. if (!jquery.fn) jquery.fn = {}; // webpack server rendering
  14183. return factory(moment, jquery);
  14184. });
  14185. } else if (typeof module === 'object' && module.exports) {
  14186. // Node / Browserify
  14187. //isomorphic issue
  14188. var jQuery = (typeof window != 'undefined') ? window.jQuery : undefined;
  14189. if (!jQuery) {
  14190. jQuery = require('jquery');
  14191. if (!jQuery.fn) jQuery.fn = {};
  14192. }
  14193. var moment = (typeof window != 'undefined' && typeof window.moment != 'undefined') ? window.moment : require('moment');
  14194. module.exports = factory(moment, jQuery);
  14195. } else {
  14196. // Browser globals
  14197. root.daterangepicker = factory(root.moment, root.jQuery);
  14198. }
  14199. }(this, function(moment, $) {
  14200. var DateRangePicker = function(element, options, cb) {
  14201. //default settings for options
  14202. this.parentEl = 'body';
  14203. this.element = $(element);
  14204. this.startDate = moment().startOf('day');
  14205. this.endDate = moment().endOf('day');
  14206. this.minDate = false;
  14207. this.maxDate = false;
  14208. this.dateLimit = false;
  14209. this.autoApply = false;
  14210. this.singleDatePicker = false;
  14211. this.showDropdowns = false;
  14212. this.showWeekNumbers = false;
  14213. this.showISOWeekNumbers = false;
  14214. this.showCustomRangeLabel = true;
  14215. this.timePicker = false;
  14216. this.timePicker24Hour = false;
  14217. this.timePickerIncrement = 1;
  14218. this.timePickerSeconds = false;
  14219. this.linkedCalendars = true;
  14220. this.autoUpdateInput = true;
  14221. this.alwaysShowCalendars = false;
  14222. this.ranges = {};
  14223. this.opens = 'right';
  14224. if (this.element.hasClass('pull-right'))
  14225. this.opens = 'left';
  14226. this.drops = 'down';
  14227. if (this.element.hasClass('dropup'))
  14228. this.drops = 'up';
  14229. this.buttonClasses = 'btn btn-sm';
  14230. this.applyClass = 'btn-success';
  14231. this.cancelClass = 'btn-default';
  14232. this.locale = {
  14233. direction: 'ltr',
  14234. format: moment.localeData().longDateFormat('L'),
  14235. separator: ' - ',
  14236. applyLabel: 'Apply',
  14237. cancelLabel: 'Cancel',
  14238. weekLabel: 'W',
  14239. customRangeLabel: 'Custom Range',
  14240. daysOfWeek: moment.weekdaysMin(),
  14241. monthNames: moment.monthsShort(),
  14242. firstDay: moment.localeData().firstDayOfWeek()
  14243. };
  14244. this.callback = function() { };
  14245. //some state information
  14246. this.isShowing = false;
  14247. this.leftCalendar = {};
  14248. this.rightCalendar = {};
  14249. //custom options from user
  14250. if (typeof options !== 'object' || options === null)
  14251. options = {};
  14252. //allow setting options with data attributes
  14253. //data-api options will be overwritten with custom javascript options
  14254. options = $.extend(this.element.data(), options);
  14255. //html template for the picker UI
  14256. if (typeof options.template !== 'string' && !(options.template instanceof $))
  14257. options.template = '<div class="daterangepicker dropdown-menu">' +
  14258. '<div class="calendar left">' +
  14259. '<div class="daterangepicker_input">' +
  14260. '<input class="input-mini form-control" type="text" name="daterangepicker_start" value="" />' +
  14261. '<i class="fa fa-calendar glyphicon glyphicon-calendar"></i>' +
  14262. '<div class="calendar-time">' +
  14263. '<div></div>' +
  14264. '<i class="fa fa-clock-o glyphicon glyphicon-time"></i>' +
  14265. '</div>' +
  14266. '</div>' +
  14267. '<div class="calendar-table"></div>' +
  14268. '</div>' +
  14269. '<div class="calendar right">' +
  14270. '<div class="daterangepicker_input">' +
  14271. '<input class="input-mini form-control" type="text" name="daterangepicker_end" value="" />' +
  14272. '<i class="fa fa-calendar glyphicon glyphicon-calendar"></i>' +
  14273. '<div class="calendar-time">' +
  14274. '<div></div>' +
  14275. '<i class="fa fa-clock-o glyphicon glyphicon-time"></i>' +
  14276. '</div>' +
  14277. '</div>' +
  14278. '<div class="calendar-table"></div>' +
  14279. '</div>' +
  14280. '<div class="ranges">' +
  14281. '<div class="range_inputs">' +
  14282. '<button class="applyBtn" disabled="disabled" type="button"></button> ' +
  14283. '<button class="cancelBtn" type="button"></button>' +
  14284. '</div>' +
  14285. '</div>' +
  14286. '</div>';
  14287. this.parentEl = (options.parentEl && $(options.parentEl).length) ? $(options.parentEl) : $(this.parentEl);
  14288. this.container = $(options.template).appendTo(this.parentEl);
  14289. //
  14290. // handle all the possible options overriding defaults
  14291. //
  14292. if (typeof options.locale === 'object') {
  14293. if (typeof options.locale.direction === 'string')
  14294. this.locale.direction = options.locale.direction;
  14295. if (typeof options.locale.format === 'string')
  14296. this.locale.format = options.locale.format;
  14297. if (typeof options.locale.separator === 'string')
  14298. this.locale.separator = options.locale.separator;
  14299. if (typeof options.locale.daysOfWeek === 'object')
  14300. this.locale.daysOfWeek = options.locale.daysOfWeek.slice();
  14301. if (typeof options.locale.monthNames === 'object')
  14302. this.locale.monthNames = options.locale.monthNames.slice();
  14303. if (typeof options.locale.firstDay === 'number')
  14304. this.locale.firstDay = options.locale.firstDay;
  14305. if (typeof options.locale.applyLabel === 'string')
  14306. this.locale.applyLabel = options.locale.applyLabel;
  14307. if (typeof options.locale.cancelLabel === 'string')
  14308. this.locale.cancelLabel = options.locale.cancelLabel;
  14309. if (typeof options.locale.weekLabel === 'string')
  14310. this.locale.weekLabel = options.locale.weekLabel;
  14311. if (typeof options.locale.customRangeLabel === 'string'){
  14312. //Support unicode chars in the custom range name.
  14313. var elem = document.createElement('textarea');
  14314. elem.innerHTML = options.locale.customRangeLabel;
  14315. var rangeHtml = elem.value;
  14316. this.locale.customRangeLabel = rangeHtml;
  14317. }
  14318. }
  14319. this.container.addClass(this.locale.direction);
  14320. if (typeof options.startDate === 'string')
  14321. this.startDate = moment(options.startDate, this.locale.format);
  14322. if (typeof options.endDate === 'string')
  14323. this.endDate = moment(options.endDate, this.locale.format);
  14324. if (typeof options.minDate === 'string')
  14325. this.minDate = moment(options.minDate, this.locale.format);
  14326. if (typeof options.maxDate === 'string')
  14327. this.maxDate = moment(options.maxDate, this.locale.format);
  14328. if (typeof options.startDate === 'object')
  14329. this.startDate = moment(options.startDate);
  14330. if (typeof options.endDate === 'object')
  14331. this.endDate = moment(options.endDate);
  14332. if (typeof options.minDate === 'object')
  14333. this.minDate = moment(options.minDate);
  14334. if (typeof options.maxDate === 'object')
  14335. this.maxDate = moment(options.maxDate);
  14336. // sanity check for bad options
  14337. if (this.minDate && this.startDate.isBefore(this.minDate))
  14338. this.startDate = this.minDate.clone();
  14339. // sanity check for bad options
  14340. if (this.maxDate && this.endDate.isAfter(this.maxDate))
  14341. this.endDate = this.maxDate.clone();
  14342. if (typeof options.applyClass === 'string')
  14343. this.applyClass = options.applyClass;
  14344. if (typeof options.cancelClass === 'string')
  14345. this.cancelClass = options.cancelClass;
  14346. if (typeof options.dateLimit === 'object')
  14347. this.dateLimit = options.dateLimit;
  14348. if (typeof options.opens === 'string')
  14349. this.opens = options.opens;
  14350. if (typeof options.drops === 'string')
  14351. this.drops = options.drops;
  14352. if (typeof options.showWeekNumbers === 'boolean')
  14353. this.showWeekNumbers = options.showWeekNumbers;
  14354. if (typeof options.showISOWeekNumbers === 'boolean')
  14355. this.showISOWeekNumbers = options.showISOWeekNumbers;
  14356. if (typeof options.buttonClasses === 'string')
  14357. this.buttonClasses = options.buttonClasses;
  14358. if (typeof options.buttonClasses === 'object')
  14359. this.buttonClasses = options.buttonClasses.join(' ');
  14360. if (typeof options.showDropdowns === 'boolean')
  14361. this.showDropdowns = options.showDropdowns;
  14362. if (typeof options.showCustomRangeLabel === 'boolean')
  14363. this.showCustomRangeLabel = options.showCustomRangeLabel;
  14364. if (typeof options.singleDatePicker === 'boolean') {
  14365. this.singleDatePicker = options.singleDatePicker;
  14366. if (this.singleDatePicker)
  14367. this.endDate = this.startDate.clone();
  14368. }
  14369. if (typeof options.timePicker === 'boolean')
  14370. this.timePicker = options.timePicker;
  14371. if (typeof options.timePickerSeconds === 'boolean')
  14372. this.timePickerSeconds = options.timePickerSeconds;
  14373. if (typeof options.timePickerIncrement === 'number')
  14374. this.timePickerIncrement = options.timePickerIncrement;
  14375. if (typeof options.timePicker24Hour === 'boolean')
  14376. this.timePicker24Hour = options.timePicker24Hour;
  14377. if (typeof options.autoApply === 'boolean')
  14378. this.autoApply = options.autoApply;
  14379. if (typeof options.autoUpdateInput === 'boolean')
  14380. this.autoUpdateInput = options.autoUpdateInput;
  14381. if (typeof options.linkedCalendars === 'boolean')
  14382. this.linkedCalendars = options.linkedCalendars;
  14383. if (typeof options.isInvalidDate === 'function')
  14384. this.isInvalidDate = options.isInvalidDate;
  14385. if (typeof options.isCustomDate === 'function')
  14386. this.isCustomDate = options.isCustomDate;
  14387. if (typeof options.alwaysShowCalendars === 'boolean')
  14388. this.alwaysShowCalendars = options.alwaysShowCalendars;
  14389. // update day names order to firstDay
  14390. if (this.locale.firstDay != 0) {
  14391. var iterator = this.locale.firstDay;
  14392. while (iterator > 0) {
  14393. this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift());
  14394. iterator--;
  14395. }
  14396. }
  14397. var start, end, range;
  14398. //if no start/end dates set, check if an input element contains initial values
  14399. if (typeof options.startDate === 'undefined' && typeof options.endDate === 'undefined') {
  14400. if ($(this.element).is('input[type=text]')) {
  14401. var val = $(this.element).val(),
  14402. split = val.split(this.locale.separator);
  14403. start = end = null;
  14404. if (split.length == 2) {
  14405. start = moment(split[0], this.locale.format);
  14406. end = moment(split[1], this.locale.format);
  14407. } else if (this.singleDatePicker && val !== "") {
  14408. start = moment(val, this.locale.format);
  14409. end = moment(val, this.locale.format);
  14410. }
  14411. if (start !== null && end !== null) {
  14412. this.setStartDate(start);
  14413. this.setEndDate(end);
  14414. }
  14415. }
  14416. }
  14417. if (typeof options.ranges === 'object') {
  14418. for (range in options.ranges) {
  14419. if (typeof options.ranges[range][0] === 'string')
  14420. start = moment(options.ranges[range][0], this.locale.format);
  14421. else
  14422. start = moment(options.ranges[range][0]);
  14423. if (typeof options.ranges[range][1] === 'string')
  14424. end = moment(options.ranges[range][1], this.locale.format);
  14425. else
  14426. end = moment(options.ranges[range][1]);
  14427. // If the start or end date exceed those allowed by the minDate or dateLimit
  14428. // options, shorten the range to the allowable period.
  14429. if (this.minDate && start.isBefore(this.minDate))
  14430. start = this.minDate.clone();
  14431. var maxDate = this.maxDate;
  14432. if (this.dateLimit && maxDate && start.clone().add(this.dateLimit).isAfter(maxDate))
  14433. maxDate = start.clone().add(this.dateLimit);
  14434. if (maxDate && end.isAfter(maxDate))
  14435. end = maxDate.clone();
  14436. // If the end of the range is before the minimum or the start of the range is
  14437. // after the maximum, don't display this range option at all.
  14438. if ((this.minDate && end.isBefore(this.minDate, this.timepicker ? 'minute' : 'day'))
  14439. || (maxDate && start.isAfter(maxDate, this.timepicker ? 'minute' : 'day')))
  14440. continue;
  14441. //Support unicode chars in the range names.
  14442. var elem = document.createElement('textarea');
  14443. elem.innerHTML = range;
  14444. var rangeHtml = elem.value;
  14445. this.ranges[rangeHtml] = [start, end];
  14446. }
  14447. var list = '<ul>';
  14448. for (range in this.ranges) {
  14449. list += '<li data-range-key="' + range + '">' + range + '</li>';
  14450. }
  14451. if (this.showCustomRangeLabel) {
  14452. list += '<li data-range-key="' + this.locale.customRangeLabel + '">' + this.locale.customRangeLabel + '</li>';
  14453. }
  14454. list += '</ul>';
  14455. this.container.find('.ranges').prepend(list);
  14456. }
  14457. if (typeof cb === 'function') {
  14458. this.callback = cb;
  14459. }
  14460. if (!this.timePicker) {
  14461. this.startDate = this.startDate.startOf('day');
  14462. this.endDate = this.endDate.endOf('day');
  14463. this.container.find('.calendar-time').hide();
  14464. }
  14465. //can't be used together for now
  14466. if (this.timePicker && this.autoApply)
  14467. this.autoApply = false;
  14468. if (this.autoApply && typeof options.ranges !== 'object') {
  14469. this.container.find('.ranges').hide();
  14470. } else if (this.autoApply) {
  14471. this.container.find('.applyBtn, .cancelBtn').addClass('hide');
  14472. }
  14473. if (this.singleDatePicker) {
  14474. this.container.addClass('single');
  14475. this.container.find('.calendar.left').addClass('single');
  14476. this.container.find('.calendar.left').show();
  14477. this.container.find('.calendar.right').hide();
  14478. this.container.find('.daterangepicker_input input, .daterangepicker_input > i').hide();
  14479. if (this.timePicker) {
  14480. this.container.find('.ranges ul').hide();
  14481. } else {
  14482. this.container.find('.ranges').hide();
  14483. }
  14484. }
  14485. if ((typeof options.ranges === 'undefined' && !this.singleDatePicker) || this.alwaysShowCalendars) {
  14486. this.container.addClass('show-calendar');
  14487. }
  14488. this.container.addClass('opens' + this.opens);
  14489. //swap the position of the predefined ranges if opens right
  14490. if (typeof options.ranges !== 'undefined' && this.opens == 'right') {
  14491. this.container.find('.ranges').prependTo( this.container.find('.calendar.left').parent() );
  14492. }
  14493. //apply CSS classes and labels to buttons
  14494. this.container.find('.applyBtn, .cancelBtn').addClass(this.buttonClasses);
  14495. if (this.applyClass.length)
  14496. this.container.find('.applyBtn').addClass(this.applyClass);
  14497. if (this.cancelClass.length)
  14498. this.container.find('.cancelBtn').addClass(this.cancelClass);
  14499. this.container.find('.applyBtn').html(this.locale.applyLabel);
  14500. this.container.find('.cancelBtn').html(this.locale.cancelLabel);
  14501. //
  14502. // event listeners
  14503. //
  14504. this.container.find('.calendar')
  14505. .on('click.daterangepicker', '.prev', $.proxy(this.clickPrev, this))
  14506. .on('click.daterangepicker', '.next', $.proxy(this.clickNext, this))
  14507. .on('mousedown.daterangepicker', 'td.available', $.proxy(this.clickDate, this))
  14508. .on('mouseenter.daterangepicker', 'td.available', $.proxy(this.hoverDate, this))
  14509. .on('mouseleave.daterangepicker', 'td.available', $.proxy(this.updateFormInputs, this))
  14510. .on('change.daterangepicker', 'select.yearselect', $.proxy(this.monthOrYearChanged, this))
  14511. .on('change.daterangepicker', 'select.monthselect', $.proxy(this.monthOrYearChanged, this))
  14512. .on('change.daterangepicker', 'select.hourselect,select.minuteselect,select.secondselect,select.ampmselect', $.proxy(this.timeChanged, this))
  14513. .on('click.daterangepicker', '.daterangepicker_input input', $.proxy(this.showCalendars, this))
  14514. .on('focus.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsFocused, this))
  14515. .on('blur.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsBlurred, this))
  14516. .on('change.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsChanged, this))
  14517. .on('keydown.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsKeydown, this));
  14518. this.container.find('.ranges')
  14519. .on('click.daterangepicker', 'button.applyBtn', $.proxy(this.clickApply, this))
  14520. .on('click.daterangepicker', 'button.cancelBtn', $.proxy(this.clickCancel, this))
  14521. .on('click.daterangepicker', 'li', $.proxy(this.clickRange, this))
  14522. .on('mouseenter.daterangepicker', 'li', $.proxy(this.hoverRange, this))
  14523. .on('mouseleave.daterangepicker', 'li', $.proxy(this.updateFormInputs, this));
  14524. if (this.element.is('input') || this.element.is('button')) {
  14525. this.element.on({
  14526. 'click.daterangepicker': $.proxy(this.show, this),
  14527. 'focus.daterangepicker': $.proxy(this.show, this),
  14528. 'keyup.daterangepicker': $.proxy(this.elementChanged, this),
  14529. 'keydown.daterangepicker': $.proxy(this.keydown, this) //IE 11 compatibility
  14530. });
  14531. } else {
  14532. this.element.on('click.daterangepicker', $.proxy(this.toggle, this));
  14533. this.element.on('keydown.daterangepicker', $.proxy(this.toggle, this));
  14534. }
  14535. //
  14536. // if attached to a text input, set the initial value
  14537. //
  14538. if (this.element.is('input') && !this.singleDatePicker && this.autoUpdateInput) {
  14539. this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
  14540. this.element.trigger('change');
  14541. } else if (this.element.is('input') && this.autoUpdateInput) {
  14542. this.element.val(this.startDate.format(this.locale.format));
  14543. this.element.trigger('change');
  14544. }
  14545. };
  14546. DateRangePicker.prototype = {
  14547. constructor: DateRangePicker,
  14548. setStartDate: function(startDate) {
  14549. if (typeof startDate === 'string')
  14550. this.startDate = moment(startDate, this.locale.format);
  14551. if (typeof startDate === 'object')
  14552. this.startDate = moment(startDate);
  14553. if (!this.timePicker)
  14554. this.startDate = this.startDate.startOf('day');
  14555. if (this.timePicker && this.timePickerIncrement)
  14556. this.startDate.minute(Math.round(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
  14557. if (this.minDate && this.startDate.isBefore(this.minDate)) {
  14558. this.startDate = this.minDate.clone();
  14559. if (this.timePicker && this.timePickerIncrement)
  14560. this.startDate.minute(Math.round(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
  14561. }
  14562. if (this.maxDate && this.startDate.isAfter(this.maxDate)) {
  14563. this.startDate = this.maxDate.clone();
  14564. if (this.timePicker && this.timePickerIncrement)
  14565. this.startDate.minute(Math.floor(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
  14566. }
  14567. if (!this.isShowing)
  14568. this.updateElement();
  14569. this.updateMonthsInView();
  14570. },
  14571. setEndDate: function(endDate) {
  14572. if (typeof endDate === 'string')
  14573. this.endDate = moment(endDate, this.locale.format);
  14574. if (typeof endDate === 'object')
  14575. this.endDate = moment(endDate);
  14576. if (!this.timePicker)
  14577. this.endDate = this.endDate.add(1,'d').startOf('day').subtract(1,'second');
  14578. if (this.timePicker && this.timePickerIncrement)
  14579. this.endDate.minute(Math.round(this.endDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
  14580. if (this.endDate.isBefore(this.startDate))
  14581. this.endDate = this.startDate.clone();
  14582. if (this.maxDate && this.endDate.isAfter(this.maxDate))
  14583. this.endDate = this.maxDate.clone();
  14584. if (this.dateLimit && this.startDate.clone().add(this.dateLimit).isBefore(this.endDate))
  14585. this.endDate = this.startDate.clone().add(this.dateLimit);
  14586. this.previousRightTime = this.endDate.clone();
  14587. if (!this.isShowing)
  14588. this.updateElement();
  14589. this.updateMonthsInView();
  14590. },
  14591. isInvalidDate: function() {
  14592. return false;
  14593. },
  14594. isCustomDate: function() {
  14595. return false;
  14596. },
  14597. updateView: function() {
  14598. if (this.timePicker) {
  14599. this.renderTimePicker('left');
  14600. this.renderTimePicker('right');
  14601. if (!this.endDate) {
  14602. this.container.find('.right .calendar-time select').attr('disabled', 'disabled').addClass('disabled');
  14603. } else {
  14604. this.container.find('.right .calendar-time select').removeAttr('disabled').removeClass('disabled');
  14605. }
  14606. }
  14607. if (this.endDate) {
  14608. this.container.find('input[name="daterangepicker_end"]').removeClass('active');
  14609. this.container.find('input[name="daterangepicker_start"]').addClass('active');
  14610. } else {
  14611. this.container.find('input[name="daterangepicker_end"]').addClass('active');
  14612. this.container.find('input[name="daterangepicker_start"]').removeClass('active');
  14613. }
  14614. this.updateMonthsInView();
  14615. this.updateCalendars();
  14616. this.updateFormInputs();
  14617. },
  14618. updateMonthsInView: function() {
  14619. if (this.endDate) {
  14620. //if both dates are visible already, do nothing
  14621. if (!this.singleDatePicker && this.leftCalendar.month && this.rightCalendar.month &&
  14622. (this.startDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.startDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM'))
  14623. &&
  14624. (this.endDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.endDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM'))
  14625. ) {
  14626. return;
  14627. }
  14628. this.leftCalendar.month = this.startDate.clone().date(2);
  14629. if (!this.linkedCalendars && (this.endDate.month() != this.startDate.month() || this.endDate.year() != this.startDate.year())) {
  14630. this.rightCalendar.month = this.endDate.clone().date(2);
  14631. } else {
  14632. this.rightCalendar.month = this.startDate.clone().date(2).add(1, 'month');
  14633. }
  14634. } else {
  14635. if (this.leftCalendar.month.format('YYYY-MM') != this.startDate.format('YYYY-MM') && this.rightCalendar.month.format('YYYY-MM') != this.startDate.format('YYYY-MM')) {
  14636. this.leftCalendar.month = this.startDate.clone().date(2);
  14637. this.rightCalendar.month = this.startDate.clone().date(2).add(1, 'month');
  14638. }
  14639. }
  14640. if (this.maxDate && this.linkedCalendars && !this.singleDatePicker && this.rightCalendar.month > this.maxDate) {
  14641. this.rightCalendar.month = this.maxDate.clone().date(2);
  14642. this.leftCalendar.month = this.maxDate.clone().date(2).subtract(1, 'month');
  14643. }
  14644. },
  14645. updateCalendars: function() {
  14646. if (this.timePicker) {
  14647. var hour, minute, second;
  14648. if (this.endDate) {
  14649. hour = parseInt(this.container.find('.left .hourselect').val(), 10);
  14650. minute = parseInt(this.container.find('.left .minuteselect').val(), 10);
  14651. second = this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10) : 0;
  14652. if (!this.timePicker24Hour) {
  14653. var ampm = this.container.find('.left .ampmselect').val();
  14654. if (ampm === 'PM' && hour < 12)
  14655. hour += 12;
  14656. if (ampm === 'AM' && hour === 12)
  14657. hour = 0;
  14658. }
  14659. } else {
  14660. hour = parseInt(this.container.find('.right .hourselect').val(), 10);
  14661. minute = parseInt(this.container.find('.right .minuteselect').val(), 10);
  14662. second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0;
  14663. if (!this.timePicker24Hour) {
  14664. var ampm = this.container.find('.right .ampmselect').val();
  14665. if (ampm === 'PM' && hour < 12)
  14666. hour += 12;
  14667. if (ampm === 'AM' && hour === 12)
  14668. hour = 0;
  14669. }
  14670. }
  14671. this.leftCalendar.month.hour(hour).minute(minute).second(second);
  14672. this.rightCalendar.month.hour(hour).minute(minute).second(second);
  14673. }
  14674. this.renderCalendar('left');
  14675. this.renderCalendar('right');
  14676. //highlight any predefined range matching the current start and end dates
  14677. this.container.find('.ranges li').removeClass('active');
  14678. if (this.endDate == null) return;
  14679. this.calculateChosenLabel();
  14680. },
  14681. renderCalendar: function(side) {
  14682. //
  14683. // Build the matrix of dates that will populate the calendar
  14684. //
  14685. var calendar = side == 'left' ? this.leftCalendar : this.rightCalendar;
  14686. var month = calendar.month.month();
  14687. var year = calendar.month.year();
  14688. var hour = calendar.month.hour();
  14689. var minute = calendar.month.minute();
  14690. var second = calendar.month.second();
  14691. var daysInMonth = moment([year, month]).daysInMonth();
  14692. var firstDay = moment([year, month, 1]);
  14693. var lastDay = moment([year, month, daysInMonth]);
  14694. var lastMonth = moment(firstDay).subtract(1, 'month').month();
  14695. var lastYear = moment(firstDay).subtract(1, 'month').year();
  14696. var daysInLastMonth = moment([lastYear, lastMonth]).daysInMonth();
  14697. var dayOfWeek = firstDay.day();
  14698. //initialize a 6 rows x 7 columns array for the calendar
  14699. var calendar = [];
  14700. calendar.firstDay = firstDay;
  14701. calendar.lastDay = lastDay;
  14702. for (var i = 0; i < 6; i++) {
  14703. calendar[i] = [];
  14704. }
  14705. //populate the calendar with date objects
  14706. var startDay = daysInLastMonth - dayOfWeek + this.locale.firstDay + 1;
  14707. if (startDay > daysInLastMonth)
  14708. startDay -= 7;
  14709. if (dayOfWeek == this.locale.firstDay)
  14710. startDay = daysInLastMonth - 6;
  14711. var curDate = moment([lastYear, lastMonth, startDay, 12, minute, second]);
  14712. var col, row;
  14713. for (var i = 0, col = 0, row = 0; i < 42; i++, col++, curDate = moment(curDate).add(24, 'hour')) {
  14714. if (i > 0 && col % 7 === 0) {
  14715. col = 0;
  14716. row++;
  14717. }
  14718. calendar[row][col] = curDate.clone().hour(hour).minute(minute).second(second);
  14719. curDate.hour(12);
  14720. if (this.minDate && calendar[row][col].format('YYYY-MM-DD') == this.minDate.format('YYYY-MM-DD') && calendar[row][col].isBefore(this.minDate) && side == 'left') {
  14721. calendar[row][col] = this.minDate.clone();
  14722. }
  14723. if (this.maxDate && calendar[row][col].format('YYYY-MM-DD') == this.maxDate.format('YYYY-MM-DD') && calendar[row][col].isAfter(this.maxDate) && side == 'right') {
  14724. calendar[row][col] = this.maxDate.clone();
  14725. }
  14726. }
  14727. //make the calendar object available to hoverDate/clickDate
  14728. if (side == 'left') {
  14729. this.leftCalendar.calendar = calendar;
  14730. } else {
  14731. this.rightCalendar.calendar = calendar;
  14732. }
  14733. //
  14734. // Display the calendar
  14735. //
  14736. var minDate = side == 'left' ? this.minDate : this.startDate;
  14737. var maxDate = this.maxDate;
  14738. var selected = side == 'left' ? this.startDate : this.endDate;
  14739. var arrow = this.locale.direction == 'ltr' ? {left: 'chevron-left', right: 'chevron-right'} : {left: 'chevron-right', right: 'chevron-left'};
  14740. var html = '<table class="table-condensed">';
  14741. html += '<thead>';
  14742. html += '<tr>';
  14743. // add empty cell for week number
  14744. if (this.showWeekNumbers || this.showISOWeekNumbers)
  14745. html += '<th></th>';
  14746. if ((!minDate || minDate.isBefore(calendar.firstDay)) && (!this.linkedCalendars || side == 'left')) {
  14747. html += '<th class="prev available"><i class="fa fa-' + arrow.left + ' glyphicon glyphicon-' + arrow.left + '"></i></th>';
  14748. } else {
  14749. html += '<th></th>';
  14750. }
  14751. var dateHtml = this.locale.monthNames[calendar[1][1].month()] + calendar[1][1].format(" YYYY");
  14752. if (this.showDropdowns) {
  14753. var currentMonth = calendar[1][1].month();
  14754. var currentYear = calendar[1][1].year();
  14755. var maxYear = (maxDate && maxDate.year()) || (currentYear + 5);
  14756. var minYear = (minDate && minDate.year()) || (currentYear - 50);
  14757. var inMinYear = currentYear == minYear;
  14758. var inMaxYear = currentYear == maxYear;
  14759. var monthHtml = '<select class="monthselect">';
  14760. for (var m = 0; m < 12; m++) {
  14761. if ((!inMinYear || m >= minDate.month()) && (!inMaxYear || m <= maxDate.month())) {
  14762. monthHtml += "<option value='" + m + "'" +
  14763. (m === currentMonth ? " selected='selected'" : "") +
  14764. ">" + this.locale.monthNames[m] + "</option>";
  14765. } else {
  14766. monthHtml += "<option value='" + m + "'" +
  14767. (m === currentMonth ? " selected='selected'" : "") +
  14768. " disabled='disabled'>" + this.locale.monthNames[m] + "</option>";
  14769. }
  14770. }
  14771. monthHtml += "</select>";
  14772. var yearHtml = '<select class="yearselect">';
  14773. for (var y = minYear; y <= maxYear; y++) {
  14774. yearHtml += '<option value="' + y + '"' +
  14775. (y === currentYear ? ' selected="selected"' : '') +
  14776. '>' + y + '</option>';
  14777. }
  14778. yearHtml += '</select>';
  14779. dateHtml = monthHtml + yearHtml;
  14780. }
  14781. html += '<th colspan="5" class="month">' + dateHtml + '</th>';
  14782. if ((!maxDate || maxDate.isAfter(calendar.lastDay)) && (!this.linkedCalendars || side == 'right' || this.singleDatePicker)) {
  14783. html += '<th class="next available"><i class="fa fa-' + arrow.right + ' glyphicon glyphicon-' + arrow.right + '"></i></th>';
  14784. } else {
  14785. html += '<th></th>';
  14786. }
  14787. html += '</tr>';
  14788. html += '<tr>';
  14789. // add week number label
  14790. if (this.showWeekNumbers || this.showISOWeekNumbers)
  14791. html += '<th class="week">' + this.locale.weekLabel + '</th>';
  14792. $.each(this.locale.daysOfWeek, function(index, dayOfWeek) {
  14793. html += '<th>' + dayOfWeek + '</th>';
  14794. });
  14795. html += '</tr>';
  14796. html += '</thead>';
  14797. html += '<tbody>';
  14798. //adjust maxDate to reflect the dateLimit setting in order to
  14799. //grey out end dates beyond the dateLimit
  14800. if (this.endDate == null && this.dateLimit) {
  14801. var maxLimit = this.startDate.clone().add(this.dateLimit).endOf('day');
  14802. if (!maxDate || maxLimit.isBefore(maxDate)) {
  14803. maxDate = maxLimit;
  14804. }
  14805. }
  14806. for (var row = 0; row < 6; row++) {
  14807. html += '<tr>';
  14808. // add week number
  14809. if (this.showWeekNumbers)
  14810. html += '<td class="week">' + calendar[row][0].week() + '</td>';
  14811. else if (this.showISOWeekNumbers)
  14812. html += '<td class="week">' + calendar[row][0].isoWeek() + '</td>';
  14813. for (var col = 0; col < 7; col++) {
  14814. var classes = [];
  14815. //highlight today's date
  14816. if (calendar[row][col].isSame(new Date(), "day"))
  14817. classes.push('today');
  14818. //highlight weekends
  14819. if (calendar[row][col].isoWeekday() > 5)
  14820. classes.push('weekend');
  14821. //grey out the dates in other months displayed at beginning and end of this calendar
  14822. if (calendar[row][col].month() != calendar[1][1].month())
  14823. classes.push('off');
  14824. //don't allow selection of dates before the minimum date
  14825. if (this.minDate && calendar[row][col].isBefore(this.minDate, 'day'))
  14826. classes.push('off', 'disabled');
  14827. //don't allow selection of dates after the maximum date
  14828. if (maxDate && calendar[row][col].isAfter(maxDate, 'day'))
  14829. classes.push('off', 'disabled');
  14830. //don't allow selection of date if a custom function decides it's invalid
  14831. if (this.isInvalidDate(calendar[row][col]))
  14832. classes.push('off', 'disabled');
  14833. //highlight the currently selected start date
  14834. if (calendar[row][col].format('YYYY-MM-DD') == this.startDate.format('YYYY-MM-DD'))
  14835. classes.push('active', 'start-date');
  14836. //highlight the currently selected end date
  14837. if (this.endDate != null && calendar[row][col].format('YYYY-MM-DD') == this.endDate.format('YYYY-MM-DD'))
  14838. classes.push('active', 'end-date');
  14839. //highlight dates in-between the selected dates
  14840. if (this.endDate != null && calendar[row][col] > this.startDate && calendar[row][col] < this.endDate)
  14841. classes.push('in-range');
  14842. //apply custom classes for this date
  14843. var isCustom = this.isCustomDate(calendar[row][col]);
  14844. if (isCustom !== false) {
  14845. if (typeof isCustom === 'string')
  14846. classes.push(isCustom);
  14847. else
  14848. Array.prototype.push.apply(classes, isCustom);
  14849. }
  14850. var cname = '', disabled = false;
  14851. for (var i = 0; i < classes.length; i++) {
  14852. cname += classes[i] + ' ';
  14853. if (classes[i] == 'disabled')
  14854. disabled = true;
  14855. }
  14856. if (!disabled)
  14857. cname += 'available';
  14858. html += '<td class="' + cname.replace(/^\s+|\s+$/g, '') + '" data-title="' + 'r' + row + 'c' + col + '">' + calendar[row][col].date() + '</td>';
  14859. }
  14860. html += '</tr>';
  14861. }
  14862. html += '</tbody>';
  14863. html += '</table>';
  14864. this.container.find('.calendar.' + side + ' .calendar-table').html(html);
  14865. },
  14866. renderTimePicker: function(side) {
  14867. // Don't bother updating the time picker if it's currently disabled
  14868. // because an end date hasn't been clicked yet
  14869. if (side == 'right' && !this.endDate) return;
  14870. var html, selected, minDate, maxDate = this.maxDate;
  14871. if (this.dateLimit && (!this.maxDate || this.startDate.clone().add(this.dateLimit).isAfter(this.maxDate)))
  14872. maxDate = this.startDate.clone().add(this.dateLimit);
  14873. if (side == 'left') {
  14874. selected = this.startDate.clone();
  14875. minDate = this.minDate;
  14876. } else if (side == 'right') {
  14877. selected = this.endDate.clone();
  14878. minDate = this.startDate;
  14879. //Preserve the time already selected
  14880. var timeSelector = this.container.find('.calendar.right .calendar-time div');
  14881. if (timeSelector.html() != '') {
  14882. selected.hour(timeSelector.find('.hourselect option:selected').val() || selected.hour());
  14883. selected.minute(timeSelector.find('.minuteselect option:selected').val() || selected.minute());
  14884. selected.second(timeSelector.find('.secondselect option:selected').val() || selected.second());
  14885. if (!this.timePicker24Hour) {
  14886. var ampm = timeSelector.find('.ampmselect option:selected').val();
  14887. if (ampm === 'PM' && selected.hour() < 12)
  14888. selected.hour(selected.hour() + 12);
  14889. if (ampm === 'AM' && selected.hour() === 12)
  14890. selected.hour(0);
  14891. }
  14892. }
  14893. if (selected.isBefore(this.startDate))
  14894. selected = this.startDate.clone();
  14895. if (maxDate && selected.isAfter(maxDate))
  14896. selected = maxDate.clone();
  14897. }
  14898. //
  14899. // hours
  14900. //
  14901. html = '<select class="hourselect">';
  14902. var start = this.timePicker24Hour ? 0 : 1;
  14903. var end = this.timePicker24Hour ? 23 : 12;
  14904. for (var i = start; i <= end; i++) {
  14905. var i_in_24 = i;
  14906. if (!this.timePicker24Hour)
  14907. i_in_24 = selected.hour() >= 12 ? (i == 12 ? 12 : i + 12) : (i == 12 ? 0 : i);
  14908. var time = selected.clone().hour(i_in_24);
  14909. var disabled = false;
  14910. if (minDate && time.minute(59).isBefore(minDate))
  14911. disabled = true;
  14912. if (maxDate && time.minute(0).isAfter(maxDate))
  14913. disabled = true;
  14914. if (i_in_24 == selected.hour() && !disabled) {
  14915. html += '<option value="' + i + '" selected="selected">' + i + '</option>';
  14916. } else if (disabled) {
  14917. html += '<option value="' + i + '" disabled="disabled" class="disabled">' + i + '</option>';
  14918. } else {
  14919. html += '<option value="' + i + '">' + i + '</option>';
  14920. }
  14921. }
  14922. html += '</select> ';
  14923. //
  14924. // minutes
  14925. //
  14926. html += ': <select class="minuteselect">';
  14927. for (var i = 0; i < 60; i += this.timePickerIncrement) {
  14928. var padded = i < 10 ? '0' + i : i;
  14929. var time = selected.clone().minute(i);
  14930. var disabled = false;
  14931. if (minDate && time.second(59).isBefore(minDate))
  14932. disabled = true;
  14933. if (maxDate && time.second(0).isAfter(maxDate))
  14934. disabled = true;
  14935. if (selected.minute() == i && !disabled) {
  14936. html += '<option value="' + i + '" selected="selected">' + padded + '</option>';
  14937. } else if (disabled) {
  14938. html += '<option value="' + i + '" disabled="disabled" class="disabled">' + padded + '</option>';
  14939. } else {
  14940. html += '<option value="' + i + '">' + padded + '</option>';
  14941. }
  14942. }
  14943. html += '</select> ';
  14944. //
  14945. // seconds
  14946. //
  14947. if (this.timePickerSeconds) {
  14948. html += ': <select class="secondselect">';
  14949. for (var i = 0; i < 60; i++) {
  14950. var padded = i < 10 ? '0' + i : i;
  14951. var time = selected.clone().second(i);
  14952. var disabled = false;
  14953. if (minDate && time.isBefore(minDate))
  14954. disabled = true;
  14955. if (maxDate && time.isAfter(maxDate))
  14956. disabled = true;
  14957. if (selected.second() == i && !disabled) {
  14958. html += '<option value="' + i + '" selected="selected">' + padded + '</option>';
  14959. } else if (disabled) {
  14960. html += '<option value="' + i + '" disabled="disabled" class="disabled">' + padded + '</option>';
  14961. } else {
  14962. html += '<option value="' + i + '">' + padded + '</option>';
  14963. }
  14964. }
  14965. html += '</select> ';
  14966. }
  14967. //
  14968. // AM/PM
  14969. //
  14970. if (!this.timePicker24Hour) {
  14971. html += '<select class="ampmselect">';
  14972. var am_html = '';
  14973. var pm_html = '';
  14974. if (minDate && selected.clone().hour(12).minute(0).second(0).isBefore(minDate))
  14975. am_html = ' disabled="disabled" class="disabled"';
  14976. if (maxDate && selected.clone().hour(0).minute(0).second(0).isAfter(maxDate))
  14977. pm_html = ' disabled="disabled" class="disabled"';
  14978. if (selected.hour() >= 12) {
  14979. html += '<option value="AM"' + am_html + '>AM</option><option value="PM" selected="selected"' + pm_html + '>PM</option>';
  14980. } else {
  14981. html += '<option value="AM" selected="selected"' + am_html + '>AM</option><option value="PM"' + pm_html + '>PM</option>';
  14982. }
  14983. html += '</select>';
  14984. }
  14985. this.container.find('.calendar.' + side + ' .calendar-time div').html(html);
  14986. },
  14987. updateFormInputs: function() {
  14988. //ignore mouse movements while an above-calendar text input has focus
  14989. if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus"))
  14990. return;
  14991. this.container.find('input[name=daterangepicker_start]').val(this.startDate.format(this.locale.format));
  14992. if (this.endDate)
  14993. this.container.find('input[name=daterangepicker_end]').val(this.endDate.format(this.locale.format));
  14994. if (this.singleDatePicker || (this.endDate && (this.startDate.isBefore(this.endDate) || this.startDate.isSame(this.endDate)))) {
  14995. this.container.find('button.applyBtn').removeAttr('disabled');
  14996. } else {
  14997. this.container.find('button.applyBtn').attr('disabled', 'disabled');
  14998. }
  14999. },
  15000. move: function() {
  15001. var parentOffset = { top: 0, left: 0 },
  15002. containerTop;
  15003. var parentRightEdge = $(window).width();
  15004. if (!this.parentEl.is('body')) {
  15005. parentOffset = {
  15006. top: this.parentEl.offset().top - this.parentEl.scrollTop(),
  15007. left: this.parentEl.offset().left - this.parentEl.scrollLeft()
  15008. };
  15009. parentRightEdge = this.parentEl[0].clientWidth + this.parentEl.offset().left;
  15010. }
  15011. if (this.drops == 'up')
  15012. containerTop = this.element.offset().top - this.container.outerHeight() - parentOffset.top;
  15013. else
  15014. containerTop = this.element.offset().top + this.element.outerHeight() - parentOffset.top;
  15015. this.container[this.drops == 'up' ? 'addClass' : 'removeClass']('dropup');
  15016. if (this.opens == 'left') {
  15017. this.container.css({
  15018. top: containerTop,
  15019. right: parentRightEdge - this.element.offset().left - this.element.outerWidth(),
  15020. left: 'auto'
  15021. });
  15022. if (this.container.offset().left < 0) {
  15023. this.container.css({
  15024. right: 'auto',
  15025. left: 9
  15026. });
  15027. }
  15028. } else if (this.opens == 'center') {
  15029. this.container.css({
  15030. top: containerTop,
  15031. left: this.element.offset().left - parentOffset.left + this.element.outerWidth() / 2
  15032. - this.container.outerWidth() / 2,
  15033. right: 'auto'
  15034. });
  15035. if (this.container.offset().left < 0) {
  15036. this.container.css({
  15037. right: 'auto',
  15038. left: 9
  15039. });
  15040. }
  15041. } else {
  15042. this.container.css({
  15043. top: containerTop,
  15044. left: this.element.offset().left - parentOffset.left,
  15045. right: 'auto'
  15046. });
  15047. if (this.container.offset().left + this.container.outerWidth() > $(window).width()) {
  15048. this.container.css({
  15049. left: 'auto',
  15050. right: 0
  15051. });
  15052. }
  15053. }
  15054. },
  15055. show: function(e) {
  15056. if (this.isShowing) return;
  15057. // Create a click proxy that is private to this instance of datepicker, for unbinding
  15058. this._outsideClickProxy = $.proxy(function(e) { this.outsideClick(e); }, this);
  15059. // Bind global datepicker mousedown for hiding and
  15060. $(document)
  15061. .on('mousedown.daterangepicker', this._outsideClickProxy)
  15062. // also support mobile devices
  15063. .on('touchend.daterangepicker', this._outsideClickProxy)
  15064. // also explicitly play nice with Bootstrap dropdowns, which stopPropagation when clicking them
  15065. .on('click.daterangepicker', '[data-toggle=dropdown]', this._outsideClickProxy)
  15066. // and also close when focus changes to outside the picker (eg. tabbing between controls)
  15067. .on('focusin.daterangepicker', this._outsideClickProxy);
  15068. // Reposition the picker if the window is resized while it's open
  15069. $(window).on('resize.daterangepicker', $.proxy(function(e) { this.move(e); }, this));
  15070. this.oldStartDate = this.startDate.clone();
  15071. this.oldEndDate = this.endDate.clone();
  15072. this.previousRightTime = this.endDate.clone();
  15073. this.updateView();
  15074. this.container.show();
  15075. this.move();
  15076. this.element.trigger('show.daterangepicker', this);
  15077. this.isShowing = true;
  15078. },
  15079. hide: function(e) {
  15080. if (!this.isShowing) return;
  15081. //incomplete date selection, revert to last values
  15082. if (!this.endDate) {
  15083. this.startDate = this.oldStartDate.clone();
  15084. this.endDate = this.oldEndDate.clone();
  15085. }
  15086. //if a new date range was selected, invoke the user callback function
  15087. if (!this.startDate.isSame(this.oldStartDate) || !this.endDate.isSame(this.oldEndDate))
  15088. this.callback(this.startDate, this.endDate, this.chosenLabel);
  15089. //if picker is attached to a text input, update it
  15090. this.updateElement();
  15091. $(document).off('.daterangepicker');
  15092. $(window).off('.daterangepicker');
  15093. this.container.hide();
  15094. this.element.trigger('hide.daterangepicker', this);
  15095. this.isShowing = false;
  15096. },
  15097. toggle: function(e) {
  15098. if (this.isShowing) {
  15099. this.hide();
  15100. } else {
  15101. this.show();
  15102. }
  15103. },
  15104. outsideClick: function(e) {
  15105. var target = $(e.target);
  15106. // if the page is clicked anywhere except within the daterangerpicker/button
  15107. // itself then call this.hide()
  15108. if (
  15109. // ie modal dialog fix
  15110. e.type == "focusin" ||
  15111. target.closest(this.element).length ||
  15112. target.closest(this.container).length ||
  15113. target.closest('.calendar-table').length
  15114. ) return;
  15115. this.hide();
  15116. this.element.trigger('outsideClick.daterangepicker', this);
  15117. },
  15118. showCalendars: function() {
  15119. this.container.addClass('show-calendar');
  15120. this.move();
  15121. this.element.trigger('showCalendar.daterangepicker', this);
  15122. },
  15123. hideCalendars: function() {
  15124. this.container.removeClass('show-calendar');
  15125. this.element.trigger('hideCalendar.daterangepicker', this);
  15126. },
  15127. hoverRange: function(e) {
  15128. //ignore mouse movements while an above-calendar text input has focus
  15129. if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus"))
  15130. return;
  15131. var label = e.target.getAttribute('data-range-key');
  15132. if (label == this.locale.customRangeLabel) {
  15133. this.updateView();
  15134. } else {
  15135. var dates = this.ranges[label];
  15136. this.container.find('input[name=daterangepicker_start]').val(dates[0].format(this.locale.format));
  15137. this.container.find('input[name=daterangepicker_end]').val(dates[1].format(this.locale.format));
  15138. }
  15139. },
  15140. clickRange: function(e) {
  15141. var label = e.target.getAttribute('data-range-key');
  15142. this.chosenLabel = label;
  15143. if (label == this.locale.customRangeLabel) {
  15144. this.showCalendars();
  15145. } else {
  15146. var dates = this.ranges[label];
  15147. this.startDate = dates[0];
  15148. this.endDate = dates[1];
  15149. if (!this.timePicker) {
  15150. this.startDate.startOf('day');
  15151. this.endDate.endOf('day');
  15152. }
  15153. if (!this.alwaysShowCalendars)
  15154. this.hideCalendars();
  15155. this.clickApply();
  15156. }
  15157. },
  15158. clickPrev: function(e) {
  15159. var cal = $(e.target).parents('.calendar');
  15160. if (cal.hasClass('left')) {
  15161. this.leftCalendar.month.subtract(1, 'month');
  15162. if (this.linkedCalendars)
  15163. this.rightCalendar.month.subtract(1, 'month');
  15164. } else {
  15165. this.rightCalendar.month.subtract(1, 'month');
  15166. }
  15167. this.updateCalendars();
  15168. },
  15169. clickNext: function(e) {
  15170. var cal = $(e.target).parents('.calendar');
  15171. if (cal.hasClass('left')) {
  15172. this.leftCalendar.month.add(1, 'month');
  15173. } else {
  15174. this.rightCalendar.month.add(1, 'month');
  15175. if (this.linkedCalendars)
  15176. this.leftCalendar.month.add(1, 'month');
  15177. }
  15178. this.updateCalendars();
  15179. },
  15180. hoverDate: function(e) {
  15181. //ignore mouse movements while an above-calendar text input has focus
  15182. //if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus"))
  15183. // return;
  15184. //ignore dates that can't be selected
  15185. if (!$(e.target).hasClass('available')) return;
  15186. //have the text inputs above calendars reflect the date being hovered over
  15187. var title = $(e.target).attr('data-title');
  15188. var row = title.substr(1, 1);
  15189. var col = title.substr(3, 1);
  15190. var cal = $(e.target).parents('.calendar');
  15191. var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col];
  15192. if (this.endDate && !this.container.find('input[name=daterangepicker_start]').is(":focus")) {
  15193. this.container.find('input[name=daterangepicker_start]').val(date.format(this.locale.format));
  15194. } else if (!this.endDate && !this.container.find('input[name=daterangepicker_end]').is(":focus")) {
  15195. this.container.find('input[name=daterangepicker_end]').val(date.format(this.locale.format));
  15196. }
  15197. //highlight the dates between the start date and the date being hovered as a potential end date
  15198. var leftCalendar = this.leftCalendar;
  15199. var rightCalendar = this.rightCalendar;
  15200. var startDate = this.startDate;
  15201. if (!this.endDate) {
  15202. this.container.find('.calendar tbody td').each(function(index, el) {
  15203. //skip week numbers, only look at dates
  15204. if ($(el).hasClass('week')) return;
  15205. var title = $(el).attr('data-title');
  15206. var row = title.substr(1, 1);
  15207. var col = title.substr(3, 1);
  15208. var cal = $(el).parents('.calendar');
  15209. var dt = cal.hasClass('left') ? leftCalendar.calendar[row][col] : rightCalendar.calendar[row][col];
  15210. if ((dt.isAfter(startDate) && dt.isBefore(date)) || dt.isSame(date, 'day')) {
  15211. $(el).addClass('in-range');
  15212. } else {
  15213. $(el).removeClass('in-range');
  15214. }
  15215. });
  15216. }
  15217. },
  15218. clickDate: function(e) {
  15219. if (!$(e.target).hasClass('available')) return;
  15220. var title = $(e.target).attr('data-title');
  15221. var row = title.substr(1, 1);
  15222. var col = title.substr(3, 1);
  15223. var cal = $(e.target).parents('.calendar');
  15224. var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col];
  15225. //
  15226. // this function needs to do a few things:
  15227. // * alternate between selecting a start and end date for the range,
  15228. // * if the time picker is enabled, apply the hour/minute/second from the select boxes to the clicked date
  15229. // * if autoapply is enabled, and an end date was chosen, apply the selection
  15230. // * if single date picker mode, and time picker isn't enabled, apply the selection immediately
  15231. // * if one of the inputs above the calendars was focused, cancel that manual input
  15232. //
  15233. if (this.endDate || date.isBefore(this.startDate, 'day')) { //picking start
  15234. if (this.timePicker) {
  15235. var hour = parseInt(this.container.find('.left .hourselect').val(), 10);
  15236. if (!this.timePicker24Hour) {
  15237. var ampm = this.container.find('.left .ampmselect').val();
  15238. if (ampm === 'PM' && hour < 12)
  15239. hour += 12;
  15240. if (ampm === 'AM' && hour === 12)
  15241. hour = 0;
  15242. }
  15243. var minute = parseInt(this.container.find('.left .minuteselect').val(), 10);
  15244. var second = this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10) : 0;
  15245. date = date.clone().hour(hour).minute(minute).second(second);
  15246. }
  15247. this.endDate = null;
  15248. this.setStartDate(date.clone());
  15249. } else if (!this.endDate && date.isBefore(this.startDate)) {
  15250. //special case: clicking the same date for start/end,
  15251. //but the time of the end date is before the start date
  15252. this.setEndDate(this.startDate.clone());
  15253. } else { // picking end
  15254. if (this.timePicker) {
  15255. var hour = parseInt(this.container.find('.right .hourselect').val(), 10);
  15256. if (!this.timePicker24Hour) {
  15257. var ampm = this.container.find('.right .ampmselect').val();
  15258. if (ampm === 'PM' && hour < 12)
  15259. hour += 12;
  15260. if (ampm === 'AM' && hour === 12)
  15261. hour = 0;
  15262. }
  15263. var minute = parseInt(this.container.find('.right .minuteselect').val(), 10);
  15264. var second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0;
  15265. date = date.clone().hour(hour).minute(minute).second(second);
  15266. }
  15267. this.setEndDate(date.clone());
  15268. if (this.autoApply) {
  15269. this.calculateChosenLabel();
  15270. this.clickApply();
  15271. }
  15272. }
  15273. if (this.singleDatePicker) {
  15274. this.setEndDate(this.startDate);
  15275. if (!this.timePicker)
  15276. this.clickApply();
  15277. }
  15278. this.updateView();
  15279. //This is to cancel the blur event handler if the mouse was in one of the inputs
  15280. e.stopPropagation();
  15281. },
  15282. calculateChosenLabel: function () {
  15283. var customRange = true;
  15284. var i = 0;
  15285. for (var range in this.ranges) {
  15286. if (this.timePicker) {
  15287. var format = this.timePickerSeconds ? "YYYY-MM-DD hh:mm:ss" : "YYYY-MM-DD hh:mm";
  15288. //ignore times when comparing dates if time picker seconds is not enabled
  15289. if (this.startDate.format(format) == this.ranges[range][0].format(format) && this.endDate.format(format) == this.ranges[range][1].format(format)) {
  15290. customRange = false;
  15291. this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').html();
  15292. break;
  15293. }
  15294. } else {
  15295. //ignore times when comparing dates if time picker is not enabled
  15296. 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')) {
  15297. customRange = false;
  15298. this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').html();
  15299. break;
  15300. }
  15301. }
  15302. i++;
  15303. }
  15304. if (customRange) {
  15305. if (this.showCustomRangeLabel) {
  15306. this.chosenLabel = this.container.find('.ranges li:last').addClass('active').html();
  15307. } else {
  15308. this.chosenLabel = null;
  15309. }
  15310. this.showCalendars();
  15311. }
  15312. },
  15313. clickApply: function(e) {
  15314. this.hide();
  15315. this.element.trigger('apply.daterangepicker', this);
  15316. },
  15317. clickCancel: function(e) {
  15318. this.startDate = this.oldStartDate;
  15319. this.endDate = this.oldEndDate;
  15320. this.hide();
  15321. this.element.trigger('cancel.daterangepicker', this);
  15322. },
  15323. monthOrYearChanged: function(e) {
  15324. var isLeft = $(e.target).closest('.calendar').hasClass('left'),
  15325. leftOrRight = isLeft ? 'left' : 'right',
  15326. cal = this.container.find('.calendar.'+leftOrRight);
  15327. // Month must be Number for new moment versions
  15328. var month = parseInt(cal.find('.monthselect').val(), 10);
  15329. var year = cal.find('.yearselect').val();
  15330. if (!isLeft) {
  15331. if (year < this.startDate.year() || (year == this.startDate.year() && month < this.startDate.month())) {
  15332. month = this.startDate.month();
  15333. year = this.startDate.year();
  15334. }
  15335. }
  15336. if (this.minDate) {
  15337. if (year < this.minDate.year() || (year == this.minDate.year() && month < this.minDate.month())) {
  15338. month = this.minDate.month();
  15339. year = this.minDate.year();
  15340. }
  15341. }
  15342. if (this.maxDate) {
  15343. if (year > this.maxDate.year() || (year == this.maxDate.year() && month > this.maxDate.month())) {
  15344. month = this.maxDate.month();
  15345. year = this.maxDate.year();
  15346. }
  15347. }
  15348. if (isLeft) {
  15349. this.leftCalendar.month.month(month).year(year);
  15350. if (this.linkedCalendars)
  15351. this.rightCalendar.month = this.leftCalendar.month.clone().add(1, 'month');
  15352. } else {
  15353. this.rightCalendar.month.month(month).year(year);
  15354. if (this.linkedCalendars)
  15355. this.leftCalendar.month = this.rightCalendar.month.clone().subtract(1, 'month');
  15356. }
  15357. this.updateCalendars();
  15358. },
  15359. timeChanged: function(e) {
  15360. var cal = $(e.target).closest('.calendar'),
  15361. isLeft = cal.hasClass('left');
  15362. var hour = parseInt(cal.find('.hourselect').val(), 10);
  15363. var minute = parseInt(cal.find('.minuteselect').val(), 10);
  15364. var second = this.timePickerSeconds ? parseInt(cal.find('.secondselect').val(), 10) : 0;
  15365. if (!this.timePicker24Hour) {
  15366. var ampm = cal.find('.ampmselect').val();
  15367. if (ampm === 'PM' && hour < 12)
  15368. hour += 12;
  15369. if (ampm === 'AM' && hour === 12)
  15370. hour = 0;
  15371. }
  15372. if (isLeft) {
  15373. var start = this.startDate.clone();
  15374. start.hour(hour);
  15375. start.minute(minute);
  15376. start.second(second);
  15377. this.setStartDate(start);
  15378. if (this.singleDatePicker) {
  15379. this.endDate = this.startDate.clone();
  15380. } else if (this.endDate && this.endDate.format('YYYY-MM-DD') == start.format('YYYY-MM-DD') && this.endDate.isBefore(start)) {
  15381. this.setEndDate(start.clone());
  15382. }
  15383. } else if (this.endDate) {
  15384. var end = this.endDate.clone();
  15385. end.hour(hour);
  15386. end.minute(minute);
  15387. end.second(second);
  15388. this.setEndDate(end);
  15389. }
  15390. //update the calendars so all clickable dates reflect the new time component
  15391. this.updateCalendars();
  15392. //update the form inputs above the calendars with the new time
  15393. this.updateFormInputs();
  15394. //re-render the time pickers because changing one selection can affect what's enabled in another
  15395. this.renderTimePicker('left');
  15396. this.renderTimePicker('right');
  15397. },
  15398. formInputsChanged: function(e) {
  15399. var isRight = $(e.target).closest('.calendar').hasClass('right');
  15400. var start = moment(this.container.find('input[name="daterangepicker_start"]').val(), this.locale.format);
  15401. var end = moment(this.container.find('input[name="daterangepicker_end"]').val(), this.locale.format);
  15402. if (start.isValid() && end.isValid()) {
  15403. if (isRight && end.isBefore(start))
  15404. start = end.clone();
  15405. this.setStartDate(start);
  15406. this.setEndDate(end);
  15407. if (isRight) {
  15408. this.container.find('input[name="daterangepicker_start"]').val(this.startDate.format(this.locale.format));
  15409. } else {
  15410. this.container.find('input[name="daterangepicker_end"]').val(this.endDate.format(this.locale.format));
  15411. }
  15412. }
  15413. this.updateView();
  15414. },
  15415. formInputsFocused: function(e) {
  15416. // Highlight the focused input
  15417. this.container.find('input[name="daterangepicker_start"], input[name="daterangepicker_end"]').removeClass('active');
  15418. $(e.target).addClass('active');
  15419. // Set the state such that if the user goes back to using a mouse,
  15420. // the calendars are aware we're selecting the end of the range, not
  15421. // the start. This allows someone to edit the end of a date range without
  15422. // re-selecting the beginning, by clicking on the end date input then
  15423. // using the calendar.
  15424. var isRight = $(e.target).closest('.calendar').hasClass('right');
  15425. if (isRight) {
  15426. this.endDate = null;
  15427. this.setStartDate(this.startDate.clone());
  15428. this.updateView();
  15429. }
  15430. },
  15431. formInputsBlurred: function(e) {
  15432. // this function has one purpose right now: if you tab from the first
  15433. // text input to the second in the UI, the endDate is nulled so that
  15434. // you can click another, but if you tab out without clicking anything
  15435. // or changing the input value, the old endDate should be retained
  15436. if (!this.endDate) {
  15437. var val = this.container.find('input[name="daterangepicker_end"]').val();
  15438. var end = moment(val, this.locale.format);
  15439. if (end.isValid()) {
  15440. this.setEndDate(end);
  15441. this.updateView();
  15442. }
  15443. }
  15444. },
  15445. formInputsKeydown: function(e) {
  15446. // This function ensures that if the 'enter' key was pressed in the input, then the calendars
  15447. // are updated with the startDate and endDate.
  15448. // This behaviour is automatic in Chrome/Firefox/Edge but not in IE 11 hence why this exists.
  15449. // Other browsers and versions of IE are untested and the behaviour is unknown.
  15450. if (e.keyCode === 13) {
  15451. // Prevent the calendar from being updated twice on Chrome/Firefox/Edge
  15452. e.preventDefault();
  15453. this.formInputsChanged(e);
  15454. }
  15455. },
  15456. elementChanged: function() {
  15457. if (!this.element.is('input')) return;
  15458. if (!this.element.val().length) return;
  15459. var dateString = this.element.val().split(this.locale.separator),
  15460. start = null,
  15461. end = null;
  15462. if (dateString.length === 2) {
  15463. start = moment(dateString[0], this.locale.format);
  15464. end = moment(dateString[1], this.locale.format);
  15465. }
  15466. if (this.singleDatePicker || start === null || end === null) {
  15467. start = moment(this.element.val(), this.locale.format);
  15468. end = start;
  15469. }
  15470. if (!start.isValid() || !end.isValid()) return;
  15471. this.setStartDate(start);
  15472. this.setEndDate(end);
  15473. this.updateView();
  15474. },
  15475. keydown: function(e) {
  15476. //hide on tab or enter
  15477. if ((e.keyCode === 9) || (e.keyCode === 13)) {
  15478. this.hide();
  15479. }
  15480. //hide on esc and prevent propagation
  15481. if (e.keyCode === 27) {
  15482. e.preventDefault();
  15483. e.stopPropagation();
  15484. this.hide();
  15485. }
  15486. },
  15487. updateElement: function() {
  15488. if (this.element.is('input') && !this.singleDatePicker && this.autoUpdateInput) {
  15489. this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
  15490. this.element.trigger('change');
  15491. } else if (this.element.is('input') && this.autoUpdateInput) {
  15492. this.element.val(this.startDate.format(this.locale.format));
  15493. this.element.trigger('change');
  15494. }
  15495. },
  15496. remove: function() {
  15497. this.container.remove();
  15498. this.element.off('.daterangepicker');
  15499. this.element.removeData();
  15500. }
  15501. };
  15502. $.fn.daterangepicker = function(options, callback) {
  15503. var implementOptions = $.extend(true, {}, $.fn.daterangepicker.defaultOptions, options);
  15504. this.each(function() {
  15505. var el = $(this);
  15506. if (el.data('daterangepicker'))
  15507. el.data('daterangepicker').remove();
  15508. el.data('daterangepicker', new DateRangePicker(el, implementOptions, callback));
  15509. });
  15510. return this;
  15511. };
  15512. return DateRangePicker;
  15513. }));