require-frontend.min.js 840 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730
  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', 'frontend', 'frontend-init', 'table', 'form', 'dragsort', 'drag', 'drop', 'selectpage'],
  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.min',
  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/build/toastr.min',
  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. 'citypicker': '../libs/fastadmin-citypicker/dist/js/city-picker.min',
  61. 'citypicker-data': '../libs/fastadmin-citypicker/dist/js/city-picker.data'
  62. },
  63. // shim依赖配置
  64. shim: {
  65. 'addons': ['frontend'],
  66. 'bootstrap': ['jquery'],
  67. 'bootstrap-table': {
  68. deps: ['bootstrap'],
  69. exports: '$.fn.bootstrapTable'
  70. },
  71. 'bootstrap-table-lang': {
  72. deps: ['bootstrap-table'],
  73. exports: '$.fn.bootstrapTable.defaults'
  74. },
  75. 'bootstrap-table-export': {
  76. deps: ['bootstrap-table'],
  77. exports: '$.fn.bootstrapTable.defaults'
  78. },
  79. 'bootstrap-table-fixed-columns': {
  80. deps: ['bootstrap-table'],
  81. exports: '$.fn.bootstrapTable.defaults'
  82. },
  83. 'bootstrap-table-mobile': {
  84. deps: ['bootstrap-table'],
  85. exports: '$.fn.bootstrapTable.defaults'
  86. },
  87. 'bootstrap-table-advancedsearch': {
  88. deps: ['bootstrap-table'],
  89. exports: '$.fn.bootstrapTable.defaults'
  90. },
  91. 'bootstrap-table-commonsearch': {
  92. deps: ['bootstrap-table'],
  93. exports: '$.fn.bootstrapTable.defaults'
  94. },
  95. 'bootstrap-table-template': {
  96. deps: ['bootstrap-table', 'template'],
  97. exports: '$.fn.bootstrapTable.defaults'
  98. },
  99. 'bootstrap-table-jumpto': {
  100. deps: ['bootstrap-table'],
  101. exports: '$.fn.bootstrapTable.defaults'
  102. },
  103. 'tableexport': {
  104. deps: ['jquery'],
  105. exports: '$.fn.extend'
  106. },
  107. 'slimscroll': {
  108. deps: ['jquery'],
  109. exports: '$.fn.extend'
  110. },
  111. 'adminlte': {
  112. deps: ['bootstrap', 'slimscroll'],
  113. exports: '$.AdminLTE'
  114. },
  115. 'table': [
  116. 'moment', 'moment/locale/zh-cn',
  117. 'bootstrap-table',
  118. 'bootstrap-table-lang', 'bootstrap-table-export', 'bootstrap-table-commonsearch', 'bootstrap-table-template',
  119. 'bootstrap-table-jumpto', 'bootstrap-table-fixed-columns'
  120. ],
  121. 'bootstrap-daterangepicker': ['moment', 'moment/locale/zh-cn'],
  122. 'bootstrap-datetimepicker': ['moment', 'moment/locale/zh-cn'],
  123. 'bootstrap-select-lang': ['bootstrap-select'],
  124. 'selectpage': {
  125. deps: ['jquery'],
  126. exports: '$.fn.extend'
  127. },
  128. 'layer': {
  129. deps: ['jquery']
  130. },
  131. 'jstree': ['css!../libs/jstree/dist/themes/default/style.css'],
  132. 'validator-lang': ['validator'],
  133. 'citypicker': ['citypicker-data', 'css!../libs/fastadmin-citypicker/dist/css/city-picker.css']
  134. },
  135. baseUrl: requirejs.s.contexts._.config.config.site.cdnurl + '/assets/js/', //资源基础路径
  136. map: {
  137. '*': {
  138. 'css': '../libs/require-css/css.min'
  139. }
  140. },
  141. waitSeconds: 60,
  142. charset: 'utf-8' // 文件编码
  143. });
  144. require(['jquery', 'bootstrap'], function ($, undefined) {
  145. //初始配置
  146. var Config = requirejs.s.contexts._.config.config;
  147. //将Config渲染到全局
  148. window.Config = Config;
  149. // 配置语言包的路径
  150. var paths = {};
  151. paths['lang'] = Config.moduleurl + '/ajax/lang?callback=define&controllername=' + Config.controllername + '&lang=' + Config.language + '&v=' + Config.site.version;
  152. // 避免目录冲突
  153. paths['frontend/'] = 'frontend/';
  154. // 如果是英文,则移除默认的定义
  155. if (Config.language === 'en') {
  156. $.each(requirejs.s.contexts._.config.paths, function (key, value) {
  157. if (key.match(/\-lang$/)) {
  158. define('require-frontend',key);
  159. }
  160. });
  161. define('moment/locale/zh-cn');
  162. }
  163. require.config({paths: paths});
  164. // 初始化
  165. $(function () {
  166. require(['fast'], function (Fast) {
  167. require(['frontend', 'frontend-init', 'addons'], function (Frontend, Addons) {
  168. //加载相应模块
  169. if (Config.jsname) {
  170. require([Config.jsname], function (Controller) {
  171. if (Controller.hasOwnProperty(Config.actionname)) {
  172. Controller[Config.actionname]();
  173. } else {
  174. if (Controller.hasOwnProperty("_empty")) {
  175. Controller._empty();
  176. }
  177. }
  178. }, function (e) {
  179. console.error(e);
  180. // 这里可捕获模块加载的错误
  181. });
  182. }
  183. });
  184. });
  185. });
  186. });
  187. 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});
  188. /*! layer-v3.5.3 Web 通用弹出层组件 MIT License http://layer.layui.com/ By 贤心 */
  189. ;!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);
  190. !function(e){e(["jquery"],function(e){return function(){function t(e,t,n){return g({type:O.error,iconClass:m().iconClasses.error,message:e,optionsOverride:n,title:t})}function n(t,n){return t||(t=m()),v=e("#"+t.containerId),v.length?v:(n&&(v=d(t)),v)}function o(e,t,n){return g({type:O.info,iconClass:m().iconClasses.info,message:e,optionsOverride:n,title:t})}function s(e){C=e}function i(e,t,n){return g({type:O.success,iconClass:m().iconClasses.success,message:e,optionsOverride:n,title:t})}function a(e,t,n){return g({type:O.warning,iconClass:m().iconClasses.warning,message:e,optionsOverride:n,title:t})}function r(e,t){var o=m();v||n(o),u(e,o,t)||l(o)}function c(t){var o=m();return v||n(o),t&&0===e(":focus",t).length?void h(t):void(v.children().length&&v.remove())}function l(t){for(var n=v.children(),o=n.length-1;o>=0;o--)u(e(n[o]),t)}function u(t,n,o){var s=!(!o||!o.force)&&o.force;return!(!t||!s&&0!==e(":focus",t).length)&&(t[n.hideMethod]({duration:n.hideDuration,easing:n.hideEasing,complete:function(){h(t)}}),!0)}function d(t){return v=e("<div/>").attr("id",t.containerId).addClass(t.positionClass),v.appendTo(e(t.target)),v}function p(){return{tapToDismiss:!0,toastClass:"toast",containerId:"toast-container",debug:!1,showMethod:"fadeIn",showDuration:300,showEasing:"swing",onShown:void 0,hideMethod:"fadeOut",hideDuration:1e3,hideEasing:"swing",onHidden:void 0,closeMethod:!1,closeDuration:!1,closeEasing:!1,closeOnHover:!0,extendedTimeOut:1e3,iconClasses:{error:"toast-error",info:"toast-info",success:"toast-success",warning:"toast-warning"},iconClass:"toast-info",positionClass:"toast-top-right",timeOut:5e3,titleClass:"toast-title",messageClass:"toast-message",escapeHtml:!1,target:"body",closeHtml:'<button type="button">&times;</button>',closeClass:"toast-close-button",newestOnTop:!0,preventDuplicates:!1,progressBar:!1,progressClass:"toast-progress",rtl:!1}}function f(e){C&&C(e)}function g(t){function o(e){return null==e&&(e=""),e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function s(){c(),u(),d(),p(),g(),C(),l(),i()}function i(){var e="";switch(t.iconClass){case"toast-success":case"toast-info":e="polite";break;default:e="assertive"}I.attr("aria-live",e)}function a(){E.closeOnHover&&I.hover(H,D),!E.onclick&&E.tapToDismiss&&I.click(b),E.closeButton&&j&&j.click(function(e){e.stopPropagation?e.stopPropagation():void 0!==e.cancelBubble&&e.cancelBubble!==!0&&(e.cancelBubble=!0),E.onCloseClick&&E.onCloseClick(e),b(!0)}),E.onclick&&I.click(function(e){E.onclick(e),b()})}function r(){I.hide(),I[E.showMethod]({duration:E.showDuration,easing:E.showEasing,complete:E.onShown}),E.timeOut>0&&(k=setTimeout(b,E.timeOut),F.maxHideTime=parseFloat(E.timeOut),F.hideEta=(new Date).getTime()+F.maxHideTime,E.progressBar&&(F.intervalId=setInterval(x,10)))}function c(){t.iconClass&&I.addClass(E.toastClass).addClass(y)}function l(){E.newestOnTop?v.prepend(I):v.append(I)}function u(){if(t.title){var e=t.title;E.escapeHtml&&(e=o(t.title)),M.append(e).addClass(E.titleClass),I.append(M)}}function d(){if(t.message){var e=t.message;E.escapeHtml&&(e=o(t.message)),B.append(e).addClass(E.messageClass),I.append(B)}}function p(){E.closeButton&&(j.addClass(E.closeClass).attr("role","button"),I.prepend(j))}function g(){E.progressBar&&(q.addClass(E.progressClass),I.prepend(q))}function C(){E.rtl&&I.addClass("rtl")}function O(e,t){if(e.preventDuplicates){if(t.message===w)return!0;w=t.message}return!1}function b(t){var n=t&&E.closeMethod!==!1?E.closeMethod:E.hideMethod,o=t&&E.closeDuration!==!1?E.closeDuration:E.hideDuration,s=t&&E.closeEasing!==!1?E.closeEasing:E.hideEasing;if(!e(":focus",I).length||t)return clearTimeout(F.intervalId),I[n]({duration:o,easing:s,complete:function(){h(I),clearTimeout(k),E.onHidden&&"hidden"!==P.state&&E.onHidden(),P.state="hidden",P.endTime=new Date,f(P)}})}function D(){(E.timeOut>0||E.extendedTimeOut>0)&&(k=setTimeout(b,E.extendedTimeOut),F.maxHideTime=parseFloat(E.extendedTimeOut),F.hideEta=(new Date).getTime()+F.maxHideTime)}function H(){clearTimeout(k),F.hideEta=0,I.stop(!0,!0)[E.showMethod]({duration:E.showDuration,easing:E.showEasing})}function x(){var e=(F.hideEta-(new Date).getTime())/F.maxHideTime*100;q.width(e+"%")}var E=m(),y=t.iconClass||E.iconClass;if("undefined"!=typeof t.optionsOverride&&(E=e.extend(E,t.optionsOverride),y=t.optionsOverride.iconClass||y),!O(E,t)){T++,v=n(E,!0);var k=null,I=e("<div/>"),M=e("<div/>"),B=e("<div/>"),q=e("<div/>"),j=e(E.closeHtml),F={intervalId:null,hideEta:null,maxHideTime:null},P={toastId:T,state:"visible",startTime:new Date,options:E,map:t};return s(),r(),a(),f(P),E.debug&&console&&console.log(P),I}}function m(){return e.extend({},p(),b.options)}function h(e){v||(v=n()),e.is(":visible")||(e.remove(),e=null,0===v.children().length&&(v.remove(),w=void 0))}var v,C,w,T=0,O={error:"error",info:"info",success:"success",warning:"warning"},b={clear:r,remove:c,error:t,getContainer:n,info:o,options:{},subscribe:s,success:i,version:"2.1.4",warning:a};return b}()})}("function"==typeof define&&define.amd?define:function(e,t){"undefined"!=typeof module&&module.exports?module.exports=t(require("jquery")):window.toastr=t(window.jQuery)});
  191. //# sourceMappingURL=toastr.js.map
  192. ;
  193. define("toastr", function(){});
  194. define('fast',['jquery', 'bootstrap', 'toastr', 'layer', 'lang'], function ($, undefined, Toastr, Layer, Lang) {
  195. var Fast = {
  196. config: {
  197. //toastr默认配置
  198. toastr: {
  199. "closeButton": true,
  200. "debug": false,
  201. "newestOnTop": false,
  202. "progressBar": false,
  203. "positionClass": "toast-top-center",
  204. "preventDuplicates": false,
  205. "onclick": null,
  206. "showDuration": "300",
  207. "hideDuration": "1000",
  208. "timeOut": "5000",
  209. "extendedTimeOut": "1000",
  210. "showEasing": "swing",
  211. "hideEasing": "linear",
  212. "showMethod": "fadeIn",
  213. "hideMethod": "fadeOut"
  214. }
  215. },
  216. events: {
  217. //请求成功的回调
  218. onAjaxSuccess: function (ret, onAjaxSuccess) {
  219. var data = typeof ret.data !== 'undefined' ? ret.data : null;
  220. var msg = typeof ret.msg !== 'undefined' && ret.msg ? ret.msg : __('Operation completed');
  221. if (typeof onAjaxSuccess === 'function') {
  222. var result = onAjaxSuccess.call(this, data, ret);
  223. if (result === false)
  224. return;
  225. }
  226. Toastr.success(msg);
  227. },
  228. //请求错误的回调
  229. onAjaxError: function (ret, onAjaxError) {
  230. var data = typeof ret.data !== 'undefined' ? ret.data : null;
  231. if (typeof onAjaxError === 'function') {
  232. var result = onAjaxError.call(this, data, ret);
  233. if (result === false) {
  234. return;
  235. }
  236. }
  237. Toastr.error(ret.msg);
  238. },
  239. //服务器响应数据后
  240. onAjaxResponse: function (response) {
  241. try {
  242. var ret = typeof response === 'object' ? response : JSON.parse(response);
  243. if (!ret.hasOwnProperty('code')) {
  244. $.extend(ret, {code: -2, msg: response, data: null});
  245. }
  246. } catch (e) {
  247. var ret = {code: -1, msg: e.message, data: null};
  248. }
  249. return ret;
  250. }
  251. },
  252. api: {
  253. //发送Ajax请求
  254. ajax: function (options, success, error) {
  255. options = typeof options === 'string' ? {url: options} : options;
  256. var index;
  257. if (typeof options.loading === 'undefined' || options.loading) {
  258. index = Layer.load(options.loading || 0);
  259. }
  260. options = $.extend({
  261. type: "POST",
  262. dataType: "json",
  263. xhrFields: {
  264. withCredentials: true
  265. },
  266. success: function (ret) {
  267. index && Layer.close(index);
  268. ret = Fast.events.onAjaxResponse(ret);
  269. if (ret.code === 1) {
  270. Fast.events.onAjaxSuccess(ret, success);
  271. } else {
  272. Fast.events.onAjaxError(ret, error);
  273. }
  274. },
  275. error: function (xhr) {
  276. index && Layer.close(index);
  277. var ret = {code: xhr.status, msg: xhr.statusText, data: null};
  278. Fast.events.onAjaxError(ret, error);
  279. }
  280. }, options);
  281. return $.ajax(options);
  282. },
  283. //修复URL
  284. fixurl: function (url) {
  285. if (url.substr(0, 1) !== "/") {
  286. var r = new RegExp('^(?:[a-z]+:)?//', 'i');
  287. if (!r.test(url)) {
  288. url = Config.moduleurl + "/" + url;
  289. }
  290. } else if (url.substr(0, 8) === "/addons/") {
  291. url = Config.__PUBLIC__.replace(/(\/*$)/g, "") + url;
  292. }
  293. return url;
  294. },
  295. //获取修复后可访问的cdn链接
  296. cdnurl: function (url, domain) {
  297. var rule = new RegExp("^((?:[a-z]+:)?\\/\\/|data:image\\/)", "i");
  298. if(typeof domain === 'undefined'){
  299. var cdnurl = Config.upload.cdnurl;
  300. url = rule.test(url) || (cdnurl && url.indexOf(cdnurl) === 0) ? url : cdnurl + url;
  301. }
  302. if (domain && !rule.test(url)) {
  303. domain = typeof domain === 'string' ? domain : location.origin;
  304. url = domain + url;
  305. }
  306. return url;
  307. },
  308. //查询Url参数
  309. query: function (name, url) {
  310. if (!url) {
  311. url = window.location.href;
  312. }
  313. name = name.replace(/[\[\]]/g, "\\$&");
  314. var regex = new RegExp("[?&/]" + name + "([=/]([^&#/?]*)|&|#|$)"),
  315. results = regex.exec(url);
  316. if (!results)
  317. return null;
  318. if (!results[2])
  319. return '';
  320. return decodeURIComponent(results[2].replace(/\+/g, " "));
  321. },
  322. //打开一个弹出窗口
  323. open: function (url, title, options) {
  324. title = options && options.title ? options.title : (title ? title : "");
  325. url = Fast.api.fixurl(url);
  326. url = url + (url.indexOf("?") > -1 ? "&" : "?") + "dialog=1";
  327. var area = Fast.config.openArea != undefined ? Fast.config.openArea : [$(window).width() > 800 ? '800px' : '95%', $(window).height() > 600 ? '600px' : '95%'];
  328. options = $.extend({
  329. type: 2,
  330. title: title,
  331. shadeClose: true,
  332. shade: false,
  333. maxmin: true,
  334. moveOut: true,
  335. area: area,
  336. content: url,
  337. zIndex: Layer.zIndex,
  338. success: function (layero, index) {
  339. var that = this;
  340. //存储callback事件
  341. $(layero).data("callback", that.callback);
  342. //$(layero).removeClass("layui-layer-border");
  343. Layer.setTop(layero);
  344. try {
  345. var frame = Layer.getChildFrame('html', index);
  346. var layerfooter = frame.find(".layer-footer");
  347. Fast.api.layerfooter(layero, index, that);
  348. //绑定事件
  349. if (layerfooter.length > 0) {
  350. // 监听窗口内的元素及属性变化
  351. // Firefox和Chrome早期版本中带有前缀
  352. var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
  353. if (MutationObserver) {
  354. // 选择目标节点
  355. var target = layerfooter[0];
  356. // 创建观察者对象
  357. var observer = new MutationObserver(function (mutations) {
  358. Fast.api.layerfooter(layero, index, that);
  359. mutations.forEach(function (mutation) {
  360. });
  361. });
  362. // 配置观察选项:
  363. var config = {attributes: true, childList: true, characterData: true, subtree: true}
  364. // 传入目标节点和观察选项
  365. observer.observe(target, config);
  366. // 随后,你还可以停止观察
  367. // observer.disconnect();
  368. }
  369. }
  370. } catch (e) {
  371. }
  372. if ($(layero).height() > $(window).height()) {
  373. //当弹出窗口大于浏览器可视高度时,重定位
  374. Layer.style(index, {
  375. top: 0,
  376. height: $(window).height()
  377. });
  378. }
  379. }
  380. }, options ? options : {});
  381. if ($(window).width() < 480 || (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream && top.$(".tab-pane.active").length > 0)) {
  382. if (top.$(".tab-pane.active").length > 0) {
  383. options.area = [top.$(".tab-pane.active").width() + "px", top.$(".tab-pane.active").height() + "px"];
  384. options.offset = [top.$(".tab-pane.active").scrollTop() + "px", "0px"];
  385. } else {
  386. options.area = [$(window).width() + "px", $(window).height() + "px"];
  387. options.offset = ["0px", "0px"];
  388. }
  389. }
  390. return Layer.open(options);
  391. },
  392. //关闭窗口并回传数据
  393. close: function (data) {
  394. var index = parent.Layer.getFrameIndex(window.name);
  395. var callback = parent.$("#layui-layer" + index).data("callback");
  396. //再执行关闭
  397. parent.Layer.close(index);
  398. //再调用回传函数
  399. if (typeof callback === 'function') {
  400. callback.call(undefined, data);
  401. }
  402. },
  403. layerfooter: function (layero, index, that) {
  404. var frame = Layer.getChildFrame('html', index);
  405. var layerfooter = frame.find(".layer-footer");
  406. if (layerfooter.length > 0) {
  407. $(".layui-layer-footer", layero).remove();
  408. var footer = $("<div />").addClass('layui-layer-btn layui-layer-footer');
  409. footer.html(layerfooter.html());
  410. if ($(".row", footer).length === 0) {
  411. $(">", footer).wrapAll("<div class='row'></div>");
  412. }
  413. footer.insertAfter(layero.find('.layui-layer-content'));
  414. //绑定事件
  415. footer.on("click", ".btn", function () {
  416. if ($(this).hasClass("disabled") || $(this).parent().hasClass("disabled")) {
  417. return;
  418. }
  419. var index = footer.find('.btn').index(this);
  420. $(".btn:eq(" + index + ")", layerfooter).trigger("click");
  421. });
  422. var titHeight = layero.find('.layui-layer-title').outerHeight() || 0;
  423. var btnHeight = layero.find('.layui-layer-btn').outerHeight() || 0;
  424. //重设iframe高度
  425. $("iframe", layero).height(layero.height() - titHeight - btnHeight);
  426. }
  427. //修复iOS下弹出窗口的高度和iOS下iframe无法滚动的BUG
  428. if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
  429. var titHeight = layero.find('.layui-layer-title').outerHeight() || 0;
  430. var btnHeight = layero.find('.layui-layer-btn').outerHeight() || 0;
  431. $("iframe", layero).parent().css("height", layero.height() - titHeight - btnHeight);
  432. $("iframe", layero).css("height", "100%");
  433. }
  434. },
  435. success: function (options, callback) {
  436. var type = typeof options === 'function';
  437. if (type) {
  438. callback = options;
  439. }
  440. return Layer.msg(__('Operation completed'), $.extend({
  441. offset: 0, icon: 1
  442. }, type ? {} : options), callback);
  443. },
  444. error: function (options, callback) {
  445. var type = typeof options === 'function';
  446. if (type) {
  447. callback = options;
  448. }
  449. return Layer.msg(__('Operation failed'), $.extend({
  450. offset: 0, icon: 2
  451. }, type ? {} : options), callback);
  452. },
  453. msg: function (message, url) {
  454. var callback = typeof url === 'function' ? url : function () {
  455. if (typeof url !== 'undefined' && url) {
  456. location.href = url;
  457. }
  458. };
  459. Layer.msg(message, {
  460. time: 2000
  461. }, callback);
  462. },
  463. toastr: Toastr,
  464. layer: Layer
  465. },
  466. lang: function () {
  467. var args = arguments,
  468. string = args[0],
  469. i = 1;
  470. string = string.toLowerCase();
  471. //string = typeof Lang[string] != 'undefined' ? Lang[string] : string;
  472. if (typeof Lang !== 'undefined' && typeof Lang[string] !== 'undefined') {
  473. if (typeof Lang[string] == 'object')
  474. return Lang[string];
  475. string = Lang[string];
  476. } else if (string.indexOf('.') !== -1 && false) {
  477. var arr = string.split('.');
  478. var current = Lang[arr[0]];
  479. for (var i = 1; i < arr.length; i++) {
  480. current = typeof current[arr[i]] != 'undefined' ? current[arr[i]] : '';
  481. if (typeof current != 'object')
  482. break;
  483. }
  484. if (typeof current == 'object')
  485. return current;
  486. string = current;
  487. } else {
  488. string = args[0];
  489. }
  490. return string.replace(/%((%)|s|d)/g, function (m) {
  491. // m is the matched format, e.g. %s, %d
  492. var val = null;
  493. if (m[2]) {
  494. val = m[2];
  495. } else {
  496. val = args[i];
  497. // A switch statement so that the formatter can be extended. Default is %s
  498. switch (m) {
  499. case '%d':
  500. val = parseFloat(val);
  501. if (isNaN(val)) {
  502. val = 0;
  503. }
  504. break;
  505. }
  506. i++;
  507. }
  508. return val;
  509. });
  510. },
  511. init: function () {
  512. // 对相对地址进行处理
  513. $.ajaxSetup({
  514. beforeSend: function (xhr, setting) {
  515. setting.url = Fast.api.fixurl(setting.url);
  516. }
  517. });
  518. Layer.config({
  519. skin: 'layui-layer-fast'
  520. });
  521. // 绑定ESC关闭窗口事件
  522. $(window).keyup(function (e) {
  523. if (e.keyCode == 27) {
  524. if ($(".layui-layer").length > 0) {
  525. var index = 0;
  526. $(".layui-layer").each(function () {
  527. index = Math.max(index, parseInt($(this).attr("times")));
  528. });
  529. if (index) {
  530. Layer.close(index);
  531. }
  532. }
  533. }
  534. });
  535. //公共代码
  536. //配置Toastr的参数
  537. Toastr.options = Fast.config.toastr;
  538. }
  539. };
  540. //将Layer暴露到全局中去
  541. window.Layer = Layer;
  542. //将Toastr暴露到全局中去
  543. window.Toastr = Toastr;
  544. //将语言方法暴露到全局中去
  545. window.__ = Fast.lang;
  546. //将Fast渲染至全局
  547. window.Fast = Fast;
  548. //默认初始化执行的代码
  549. Fast.init();
  550. return Fast;
  551. });
  552. /*!art-template - Template Engine | http://aui.github.com/artTemplate/*/
  553. !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}();
  554. //! moment.js
  555. //! version : 2.29.4
  556. //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
  557. //! license : MIT
  558. //! momentjs.com
  559. ;(function (global, factory) {
  560. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  561. typeof define === 'function' && define.amd ? define('moment/moment',factory) :
  562. global.moment = factory()
  563. }(this, (function () { 'use strict';
  564. var hookCallback;
  565. function hooks() {
  566. return hookCallback.apply(null, arguments);
  567. }
  568. // This is done to register the method called with moment()
  569. // without creating circular dependencies.
  570. function setHookCallback(callback) {
  571. hookCallback = callback;
  572. }
  573. function isArray(input) {
  574. return (
  575. input instanceof Array ||
  576. Object.prototype.toString.call(input) === '[object Array]'
  577. );
  578. }
  579. function isObject(input) {
  580. // IE8 will treat undefined and null as object if it wasn't for
  581. // input != null
  582. return (
  583. input != null &&
  584. Object.prototype.toString.call(input) === '[object Object]'
  585. );
  586. }
  587. function hasOwnProp(a, b) {
  588. return Object.prototype.hasOwnProperty.call(a, b);
  589. }
  590. function isObjectEmpty(obj) {
  591. if (Object.getOwnPropertyNames) {
  592. return Object.getOwnPropertyNames(obj).length === 0;
  593. } else {
  594. var k;
  595. for (k in obj) {
  596. if (hasOwnProp(obj, k)) {
  597. return false;
  598. }
  599. }
  600. return true;
  601. }
  602. }
  603. function isUndefined(input) {
  604. return input === void 0;
  605. }
  606. function isNumber(input) {
  607. return (
  608. typeof input === 'number' ||
  609. Object.prototype.toString.call(input) === '[object Number]'
  610. );
  611. }
  612. function isDate(input) {
  613. return (
  614. input instanceof Date ||
  615. Object.prototype.toString.call(input) === '[object Date]'
  616. );
  617. }
  618. function map(arr, fn) {
  619. var res = [],
  620. i,
  621. arrLen = arr.length;
  622. for (i = 0; i < arrLen; ++i) {
  623. res.push(fn(arr[i], i));
  624. }
  625. return res;
  626. }
  627. function extend(a, b) {
  628. for (var i in b) {
  629. if (hasOwnProp(b, i)) {
  630. a[i] = b[i];
  631. }
  632. }
  633. if (hasOwnProp(b, 'toString')) {
  634. a.toString = b.toString;
  635. }
  636. if (hasOwnProp(b, 'valueOf')) {
  637. a.valueOf = b.valueOf;
  638. }
  639. return a;
  640. }
  641. function createUTC(input, format, locale, strict) {
  642. return createLocalOrUTC(input, format, locale, strict, true).utc();
  643. }
  644. function defaultParsingFlags() {
  645. // We need to deep clone this object.
  646. return {
  647. empty: false,
  648. unusedTokens: [],
  649. unusedInput: [],
  650. overflow: -2,
  651. charsLeftOver: 0,
  652. nullInput: false,
  653. invalidEra: null,
  654. invalidMonth: null,
  655. invalidFormat: false,
  656. userInvalidated: false,
  657. iso: false,
  658. parsedDateParts: [],
  659. era: null,
  660. meridiem: null,
  661. rfc2822: false,
  662. weekdayMismatch: false,
  663. };
  664. }
  665. function getParsingFlags(m) {
  666. if (m._pf == null) {
  667. m._pf = defaultParsingFlags();
  668. }
  669. return m._pf;
  670. }
  671. var some;
  672. if (Array.prototype.some) {
  673. some = Array.prototype.some;
  674. } else {
  675. some = function (fun) {
  676. var t = Object(this),
  677. len = t.length >>> 0,
  678. i;
  679. for (i = 0; i < len; i++) {
  680. if (i in t && fun.call(this, t[i], i, t)) {
  681. return true;
  682. }
  683. }
  684. return false;
  685. };
  686. }
  687. function isValid(m) {
  688. if (m._isValid == null) {
  689. var flags = getParsingFlags(m),
  690. parsedParts = some.call(flags.parsedDateParts, function (i) {
  691. return i != null;
  692. }),
  693. isNowValid =
  694. !isNaN(m._d.getTime()) &&
  695. flags.overflow < 0 &&
  696. !flags.empty &&
  697. !flags.invalidEra &&
  698. !flags.invalidMonth &&
  699. !flags.invalidWeekday &&
  700. !flags.weekdayMismatch &&
  701. !flags.nullInput &&
  702. !flags.invalidFormat &&
  703. !flags.userInvalidated &&
  704. (!flags.meridiem || (flags.meridiem && parsedParts));
  705. if (m._strict) {
  706. isNowValid =
  707. isNowValid &&
  708. flags.charsLeftOver === 0 &&
  709. flags.unusedTokens.length === 0 &&
  710. flags.bigHour === undefined;
  711. }
  712. if (Object.isFrozen == null || !Object.isFrozen(m)) {
  713. m._isValid = isNowValid;
  714. } else {
  715. return isNowValid;
  716. }
  717. }
  718. return m._isValid;
  719. }
  720. function createInvalid(flags) {
  721. var m = createUTC(NaN);
  722. if (flags != null) {
  723. extend(getParsingFlags(m), flags);
  724. } else {
  725. getParsingFlags(m).userInvalidated = true;
  726. }
  727. return m;
  728. }
  729. // Plugins that add properties should also add the key here (null value),
  730. // so we can properly clone ourselves.
  731. var momentProperties = (hooks.momentProperties = []),
  732. updateInProgress = false;
  733. function copyConfig(to, from) {
  734. var i,
  735. prop,
  736. val,
  737. momentPropertiesLen = momentProperties.length;
  738. if (!isUndefined(from._isAMomentObject)) {
  739. to._isAMomentObject = from._isAMomentObject;
  740. }
  741. if (!isUndefined(from._i)) {
  742. to._i = from._i;
  743. }
  744. if (!isUndefined(from._f)) {
  745. to._f = from._f;
  746. }
  747. if (!isUndefined(from._l)) {
  748. to._l = from._l;
  749. }
  750. if (!isUndefined(from._strict)) {
  751. to._strict = from._strict;
  752. }
  753. if (!isUndefined(from._tzm)) {
  754. to._tzm = from._tzm;
  755. }
  756. if (!isUndefined(from._isUTC)) {
  757. to._isUTC = from._isUTC;
  758. }
  759. if (!isUndefined(from._offset)) {
  760. to._offset = from._offset;
  761. }
  762. if (!isUndefined(from._pf)) {
  763. to._pf = getParsingFlags(from);
  764. }
  765. if (!isUndefined(from._locale)) {
  766. to._locale = from._locale;
  767. }
  768. if (momentPropertiesLen > 0) {
  769. for (i = 0; i < momentPropertiesLen; i++) {
  770. prop = momentProperties[i];
  771. val = from[prop];
  772. if (!isUndefined(val)) {
  773. to[prop] = val;
  774. }
  775. }
  776. }
  777. return to;
  778. }
  779. // Moment prototype object
  780. function Moment(config) {
  781. copyConfig(this, config);
  782. this._d = new Date(config._d != null ? config._d.getTime() : NaN);
  783. if (!this.isValid()) {
  784. this._d = new Date(NaN);
  785. }
  786. // Prevent infinite loop in case updateOffset creates new moment
  787. // objects.
  788. if (updateInProgress === false) {
  789. updateInProgress = true;
  790. hooks.updateOffset(this);
  791. updateInProgress = false;
  792. }
  793. }
  794. function isMoment(obj) {
  795. return (
  796. obj instanceof Moment || (obj != null && obj._isAMomentObject != null)
  797. );
  798. }
  799. function warn(msg) {
  800. if (
  801. hooks.suppressDeprecationWarnings === false &&
  802. typeof console !== 'undefined' &&
  803. console.warn
  804. ) {
  805. console.warn('Deprecation warning: ' + msg);
  806. }
  807. }
  808. function deprecate(msg, fn) {
  809. var firstTime = true;
  810. return extend(function () {
  811. if (hooks.deprecationHandler != null) {
  812. hooks.deprecationHandler(null, msg);
  813. }
  814. if (firstTime) {
  815. var args = [],
  816. arg,
  817. i,
  818. key,
  819. argLen = arguments.length;
  820. for (i = 0; i < argLen; i++) {
  821. arg = '';
  822. if (typeof arguments[i] === 'object') {
  823. arg += '\n[' + i + '] ';
  824. for (key in arguments[0]) {
  825. if (hasOwnProp(arguments[0], key)) {
  826. arg += key + ': ' + arguments[0][key] + ', ';
  827. }
  828. }
  829. arg = arg.slice(0, -2); // Remove trailing comma and space
  830. } else {
  831. arg = arguments[i];
  832. }
  833. args.push(arg);
  834. }
  835. warn(
  836. msg +
  837. '\nArguments: ' +
  838. Array.prototype.slice.call(args).join('') +
  839. '\n' +
  840. new Error().stack
  841. );
  842. firstTime = false;
  843. }
  844. return fn.apply(this, arguments);
  845. }, fn);
  846. }
  847. var deprecations = {};
  848. function deprecateSimple(name, msg) {
  849. if (hooks.deprecationHandler != null) {
  850. hooks.deprecationHandler(name, msg);
  851. }
  852. if (!deprecations[name]) {
  853. warn(msg);
  854. deprecations[name] = true;
  855. }
  856. }
  857. hooks.suppressDeprecationWarnings = false;
  858. hooks.deprecationHandler = null;
  859. function isFunction(input) {
  860. return (
  861. (typeof Function !== 'undefined' && input instanceof Function) ||
  862. Object.prototype.toString.call(input) === '[object Function]'
  863. );
  864. }
  865. function set(config) {
  866. var prop, i;
  867. for (i in config) {
  868. if (hasOwnProp(config, i)) {
  869. prop = config[i];
  870. if (isFunction(prop)) {
  871. this[i] = prop;
  872. } else {
  873. this['_' + i] = prop;
  874. }
  875. }
  876. }
  877. this._config = config;
  878. // Lenient ordinal parsing accepts just a number in addition to
  879. // number + (possibly) stuff coming from _dayOfMonthOrdinalParse.
  880. // TODO: Remove "ordinalParse" fallback in next major release.
  881. this._dayOfMonthOrdinalParseLenient = new RegExp(
  882. (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
  883. '|' +
  884. /\d{1,2}/.source
  885. );
  886. }
  887. function mergeConfigs(parentConfig, childConfig) {
  888. var res = extend({}, parentConfig),
  889. prop;
  890. for (prop in childConfig) {
  891. if (hasOwnProp(childConfig, prop)) {
  892. if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
  893. res[prop] = {};
  894. extend(res[prop], parentConfig[prop]);
  895. extend(res[prop], childConfig[prop]);
  896. } else if (childConfig[prop] != null) {
  897. res[prop] = childConfig[prop];
  898. } else {
  899. delete res[prop];
  900. }
  901. }
  902. }
  903. for (prop in parentConfig) {
  904. if (
  905. hasOwnProp(parentConfig, prop) &&
  906. !hasOwnProp(childConfig, prop) &&
  907. isObject(parentConfig[prop])
  908. ) {
  909. // make sure changes to properties don't modify parent config
  910. res[prop] = extend({}, res[prop]);
  911. }
  912. }
  913. return res;
  914. }
  915. function Locale(config) {
  916. if (config != null) {
  917. this.set(config);
  918. }
  919. }
  920. var keys;
  921. if (Object.keys) {
  922. keys = Object.keys;
  923. } else {
  924. keys = function (obj) {
  925. var i,
  926. res = [];
  927. for (i in obj) {
  928. if (hasOwnProp(obj, i)) {
  929. res.push(i);
  930. }
  931. }
  932. return res;
  933. };
  934. }
  935. var defaultCalendar = {
  936. sameDay: '[Today at] LT',
  937. nextDay: '[Tomorrow at] LT',
  938. nextWeek: 'dddd [at] LT',
  939. lastDay: '[Yesterday at] LT',
  940. lastWeek: '[Last] dddd [at] LT',
  941. sameElse: 'L',
  942. };
  943. function calendar(key, mom, now) {
  944. var output = this._calendar[key] || this._calendar['sameElse'];
  945. return isFunction(output) ? output.call(mom, now) : output;
  946. }
  947. function zeroFill(number, targetLength, forceSign) {
  948. var absNumber = '' + Math.abs(number),
  949. zerosToFill = targetLength - absNumber.length,
  950. sign = number >= 0;
  951. return (
  952. (sign ? (forceSign ? '+' : '') : '-') +
  953. Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) +
  954. absNumber
  955. );
  956. }
  957. var formattingTokens =
  958. /(\[[^\[]*\])|(\\)?([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,
  959. localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,
  960. formatFunctions = {},
  961. formatTokenFunctions = {};
  962. // token: 'M'
  963. // padded: ['MM', 2]
  964. // ordinal: 'Mo'
  965. // callback: function () { this.month() + 1 }
  966. function addFormatToken(token, padded, ordinal, callback) {
  967. var func = callback;
  968. if (typeof callback === 'string') {
  969. func = function () {
  970. return this[callback]();
  971. };
  972. }
  973. if (token) {
  974. formatTokenFunctions[token] = func;
  975. }
  976. if (padded) {
  977. formatTokenFunctions[padded[0]] = function () {
  978. return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
  979. };
  980. }
  981. if (ordinal) {
  982. formatTokenFunctions[ordinal] = function () {
  983. return this.localeData().ordinal(
  984. func.apply(this, arguments),
  985. token
  986. );
  987. };
  988. }
  989. }
  990. function removeFormattingTokens(input) {
  991. if (input.match(/\[[\s\S]/)) {
  992. return input.replace(/^\[|\]$/g, '');
  993. }
  994. return input.replace(/\\/g, '');
  995. }
  996. function makeFormatFunction(format) {
  997. var array = format.match(formattingTokens),
  998. i,
  999. length;
  1000. for (i = 0, length = array.length; i < length; i++) {
  1001. if (formatTokenFunctions[array[i]]) {
  1002. array[i] = formatTokenFunctions[array[i]];
  1003. } else {
  1004. array[i] = removeFormattingTokens(array[i]);
  1005. }
  1006. }
  1007. return function (mom) {
  1008. var output = '',
  1009. i;
  1010. for (i = 0; i < length; i++) {
  1011. output += isFunction(array[i])
  1012. ? array[i].call(mom, format)
  1013. : array[i];
  1014. }
  1015. return output;
  1016. };
  1017. }
  1018. // format date using native date object
  1019. function formatMoment(m, format) {
  1020. if (!m.isValid()) {
  1021. return m.localeData().invalidDate();
  1022. }
  1023. format = expandFormat(format, m.localeData());
  1024. formatFunctions[format] =
  1025. formatFunctions[format] || makeFormatFunction(format);
  1026. return formatFunctions[format](m);
  1027. }
  1028. function expandFormat(format, locale) {
  1029. var i = 5;
  1030. function replaceLongDateFormatTokens(input) {
  1031. return locale.longDateFormat(input) || input;
  1032. }
  1033. localFormattingTokens.lastIndex = 0;
  1034. while (i >= 0 && localFormattingTokens.test(format)) {
  1035. format = format.replace(
  1036. localFormattingTokens,
  1037. replaceLongDateFormatTokens
  1038. );
  1039. localFormattingTokens.lastIndex = 0;
  1040. i -= 1;
  1041. }
  1042. return format;
  1043. }
  1044. var defaultLongDateFormat = {
  1045. LTS: 'h:mm:ss A',
  1046. LT: 'h:mm A',
  1047. L: 'MM/DD/YYYY',
  1048. LL: 'MMMM D, YYYY',
  1049. LLL: 'MMMM D, YYYY h:mm A',
  1050. LLLL: 'dddd, MMMM D, YYYY h:mm A',
  1051. };
  1052. function longDateFormat(key) {
  1053. var format = this._longDateFormat[key],
  1054. formatUpper = this._longDateFormat[key.toUpperCase()];
  1055. if (format || !formatUpper) {
  1056. return format;
  1057. }
  1058. this._longDateFormat[key] = formatUpper
  1059. .match(formattingTokens)
  1060. .map(function (tok) {
  1061. if (
  1062. tok === 'MMMM' ||
  1063. tok === 'MM' ||
  1064. tok === 'DD' ||
  1065. tok === 'dddd'
  1066. ) {
  1067. return tok.slice(1);
  1068. }
  1069. return tok;
  1070. })
  1071. .join('');
  1072. return this._longDateFormat[key];
  1073. }
  1074. var defaultInvalidDate = 'Invalid date';
  1075. function invalidDate() {
  1076. return this._invalidDate;
  1077. }
  1078. var defaultOrdinal = '%d',
  1079. defaultDayOfMonthOrdinalParse = /\d{1,2}/;
  1080. function ordinal(number) {
  1081. return this._ordinal.replace('%d', number);
  1082. }
  1083. var defaultRelativeTime = {
  1084. future: 'in %s',
  1085. past: '%s ago',
  1086. s: 'a few seconds',
  1087. ss: '%d seconds',
  1088. m: 'a minute',
  1089. mm: '%d minutes',
  1090. h: 'an hour',
  1091. hh: '%d hours',
  1092. d: 'a day',
  1093. dd: '%d days',
  1094. w: 'a week',
  1095. ww: '%d weeks',
  1096. M: 'a month',
  1097. MM: '%d months',
  1098. y: 'a year',
  1099. yy: '%d years',
  1100. };
  1101. function relativeTime(number, withoutSuffix, string, isFuture) {
  1102. var output = this._relativeTime[string];
  1103. return isFunction(output)
  1104. ? output(number, withoutSuffix, string, isFuture)
  1105. : output.replace(/%d/i, number);
  1106. }
  1107. function pastFuture(diff, output) {
  1108. var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
  1109. return isFunction(format) ? format(output) : format.replace(/%s/i, output);
  1110. }
  1111. var aliases = {};
  1112. function addUnitAlias(unit, shorthand) {
  1113. var lowerCase = unit.toLowerCase();
  1114. aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
  1115. }
  1116. function normalizeUnits(units) {
  1117. return typeof units === 'string'
  1118. ? aliases[units] || aliases[units.toLowerCase()]
  1119. : undefined;
  1120. }
  1121. function normalizeObjectUnits(inputObject) {
  1122. var normalizedInput = {},
  1123. normalizedProp,
  1124. prop;
  1125. for (prop in inputObject) {
  1126. if (hasOwnProp(inputObject, prop)) {
  1127. normalizedProp = normalizeUnits(prop);
  1128. if (normalizedProp) {
  1129. normalizedInput[normalizedProp] = inputObject[prop];
  1130. }
  1131. }
  1132. }
  1133. return normalizedInput;
  1134. }
  1135. var priorities = {};
  1136. function addUnitPriority(unit, priority) {
  1137. priorities[unit] = priority;
  1138. }
  1139. function getPrioritizedUnits(unitsObj) {
  1140. var units = [],
  1141. u;
  1142. for (u in unitsObj) {
  1143. if (hasOwnProp(unitsObj, u)) {
  1144. units.push({ unit: u, priority: priorities[u] });
  1145. }
  1146. }
  1147. units.sort(function (a, b) {
  1148. return a.priority - b.priority;
  1149. });
  1150. return units;
  1151. }
  1152. function isLeapYear(year) {
  1153. return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
  1154. }
  1155. function absFloor(number) {
  1156. if (number < 0) {
  1157. // -0 -> 0
  1158. return Math.ceil(number) || 0;
  1159. } else {
  1160. return Math.floor(number);
  1161. }
  1162. }
  1163. function toInt(argumentForCoercion) {
  1164. var coercedNumber = +argumentForCoercion,
  1165. value = 0;
  1166. if (coercedNumber !== 0 && isFinite(coercedNumber)) {
  1167. value = absFloor(coercedNumber);
  1168. }
  1169. return value;
  1170. }
  1171. function makeGetSet(unit, keepTime) {
  1172. return function (value) {
  1173. if (value != null) {
  1174. set$1(this, unit, value);
  1175. hooks.updateOffset(this, keepTime);
  1176. return this;
  1177. } else {
  1178. return get(this, unit);
  1179. }
  1180. };
  1181. }
  1182. function get(mom, unit) {
  1183. return mom.isValid()
  1184. ? mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]()
  1185. : NaN;
  1186. }
  1187. function set$1(mom, unit, value) {
  1188. if (mom.isValid() && !isNaN(value)) {
  1189. if (
  1190. unit === 'FullYear' &&
  1191. isLeapYear(mom.year()) &&
  1192. mom.month() === 1 &&
  1193. mom.date() === 29
  1194. ) {
  1195. value = toInt(value);
  1196. mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](
  1197. value,
  1198. mom.month(),
  1199. daysInMonth(value, mom.month())
  1200. );
  1201. } else {
  1202. mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
  1203. }
  1204. }
  1205. }
  1206. // MOMENTS
  1207. function stringGet(units) {
  1208. units = normalizeUnits(units);
  1209. if (isFunction(this[units])) {
  1210. return this[units]();
  1211. }
  1212. return this;
  1213. }
  1214. function stringSet(units, value) {
  1215. if (typeof units === 'object') {
  1216. units = normalizeObjectUnits(units);
  1217. var prioritized = getPrioritizedUnits(units),
  1218. i,
  1219. prioritizedLen = prioritized.length;
  1220. for (i = 0; i < prioritizedLen; i++) {
  1221. this[prioritized[i].unit](units[prioritized[i].unit]);
  1222. }
  1223. } else {
  1224. units = normalizeUnits(units);
  1225. if (isFunction(this[units])) {
  1226. return this[units](value);
  1227. }
  1228. }
  1229. return this;
  1230. }
  1231. var match1 = /\d/, // 0 - 9
  1232. match2 = /\d\d/, // 00 - 99
  1233. match3 = /\d{3}/, // 000 - 999
  1234. match4 = /\d{4}/, // 0000 - 9999
  1235. match6 = /[+-]?\d{6}/, // -999999 - 999999
  1236. match1to2 = /\d\d?/, // 0 - 99
  1237. match3to4 = /\d\d\d\d?/, // 999 - 9999
  1238. match5to6 = /\d\d\d\d\d\d?/, // 99999 - 999999
  1239. match1to3 = /\d{1,3}/, // 0 - 999
  1240. match1to4 = /\d{1,4}/, // 0 - 9999
  1241. match1to6 = /[+-]?\d{1,6}/, // -999999 - 999999
  1242. matchUnsigned = /\d+/, // 0 - inf
  1243. matchSigned = /[+-]?\d+/, // -inf - inf
  1244. matchOffset = /Z|[+-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z
  1245. matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi, // +00 -00 +00:00 -00:00 +0000 -0000 or Z
  1246. matchTimestamp = /[+-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123
  1247. // any word (or two) characters or numbers including two/three word month in arabic.
  1248. // includes scottish gaelic two word and hyphenated months
  1249. matchWord =
  1250. /[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,
  1251. regexes;
  1252. regexes = {};
  1253. function addRegexToken(token, regex, strictRegex) {
  1254. regexes[token] = isFunction(regex)
  1255. ? regex
  1256. : function (isStrict, localeData) {
  1257. return isStrict && strictRegex ? strictRegex : regex;
  1258. };
  1259. }
  1260. function getParseRegexForToken(token, config) {
  1261. if (!hasOwnProp(regexes, token)) {
  1262. return new RegExp(unescapeFormat(token));
  1263. }
  1264. return regexes[token](config._strict, config._locale);
  1265. }
  1266. // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
  1267. function unescapeFormat(s) {
  1268. return regexEscape(
  1269. s
  1270. .replace('\\', '')
  1271. .replace(
  1272. /\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,
  1273. function (matched, p1, p2, p3, p4) {
  1274. return p1 || p2 || p3 || p4;
  1275. }
  1276. )
  1277. );
  1278. }
  1279. function regexEscape(s) {
  1280. return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
  1281. }
  1282. var tokens = {};
  1283. function addParseToken(token, callback) {
  1284. var i,
  1285. func = callback,
  1286. tokenLen;
  1287. if (typeof token === 'string') {
  1288. token = [token];
  1289. }
  1290. if (isNumber(callback)) {
  1291. func = function (input, array) {
  1292. array[callback] = toInt(input);
  1293. };
  1294. }
  1295. tokenLen = token.length;
  1296. for (i = 0; i < tokenLen; i++) {
  1297. tokens[token[i]] = func;
  1298. }
  1299. }
  1300. function addWeekParseToken(token, callback) {
  1301. addParseToken(token, function (input, array, config, token) {
  1302. config._w = config._w || {};
  1303. callback(input, config._w, config, token);
  1304. });
  1305. }
  1306. function addTimeToArrayFromToken(token, input, config) {
  1307. if (input != null && hasOwnProp(tokens, token)) {
  1308. tokens[token](input, config._a, config, token);
  1309. }
  1310. }
  1311. var YEAR = 0,
  1312. MONTH = 1,
  1313. DATE = 2,
  1314. HOUR = 3,
  1315. MINUTE = 4,
  1316. SECOND = 5,
  1317. MILLISECOND = 6,
  1318. WEEK = 7,
  1319. WEEKDAY = 8;
  1320. function mod(n, x) {
  1321. return ((n % x) + x) % x;
  1322. }
  1323. var indexOf;
  1324. if (Array.prototype.indexOf) {
  1325. indexOf = Array.prototype.indexOf;
  1326. } else {
  1327. indexOf = function (o) {
  1328. // I know
  1329. var i;
  1330. for (i = 0; i < this.length; ++i) {
  1331. if (this[i] === o) {
  1332. return i;
  1333. }
  1334. }
  1335. return -1;
  1336. };
  1337. }
  1338. function daysInMonth(year, month) {
  1339. if (isNaN(year) || isNaN(month)) {
  1340. return NaN;
  1341. }
  1342. var modMonth = mod(month, 12);
  1343. year += (month - modMonth) / 12;
  1344. return modMonth === 1
  1345. ? isLeapYear(year)
  1346. ? 29
  1347. : 28
  1348. : 31 - ((modMonth % 7) % 2);
  1349. }
  1350. // FORMATTING
  1351. addFormatToken('M', ['MM', 2], 'Mo', function () {
  1352. return this.month() + 1;
  1353. });
  1354. addFormatToken('MMM', 0, 0, function (format) {
  1355. return this.localeData().monthsShort(this, format);
  1356. });
  1357. addFormatToken('MMMM', 0, 0, function (format) {
  1358. return this.localeData().months(this, format);
  1359. });
  1360. // ALIASES
  1361. addUnitAlias('month', 'M');
  1362. // PRIORITY
  1363. addUnitPriority('month', 8);
  1364. // PARSING
  1365. addRegexToken('M', match1to2);
  1366. addRegexToken('MM', match1to2, match2);
  1367. addRegexToken('MMM', function (isStrict, locale) {
  1368. return locale.monthsShortRegex(isStrict);
  1369. });
  1370. addRegexToken('MMMM', function (isStrict, locale) {
  1371. return locale.monthsRegex(isStrict);
  1372. });
  1373. addParseToken(['M', 'MM'], function (input, array) {
  1374. array[MONTH] = toInt(input) - 1;
  1375. });
  1376. addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
  1377. var month = config._locale.monthsParse(input, token, config._strict);
  1378. // if we didn't find a month name, mark the date as invalid.
  1379. if (month != null) {
  1380. array[MONTH] = month;
  1381. } else {
  1382. getParsingFlags(config).invalidMonth = input;
  1383. }
  1384. });
  1385. // LOCALES
  1386. var defaultLocaleMonths =
  1387. 'January_February_March_April_May_June_July_August_September_October_November_December'.split(
  1388. '_'
  1389. ),
  1390. defaultLocaleMonthsShort =
  1391. 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
  1392. MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,
  1393. defaultMonthsShortRegex = matchWord,
  1394. defaultMonthsRegex = matchWord;
  1395. function localeMonths(m, format) {
  1396. if (!m) {
  1397. return isArray(this._months)
  1398. ? this._months
  1399. : this._months['standalone'];
  1400. }
  1401. return isArray(this._months)
  1402. ? this._months[m.month()]
  1403. : this._months[
  1404. (this._months.isFormat || MONTHS_IN_FORMAT).test(format)
  1405. ? 'format'
  1406. : 'standalone'
  1407. ][m.month()];
  1408. }
  1409. function localeMonthsShort(m, format) {
  1410. if (!m) {
  1411. return isArray(this._monthsShort)
  1412. ? this._monthsShort
  1413. : this._monthsShort['standalone'];
  1414. }
  1415. return isArray(this._monthsShort)
  1416. ? this._monthsShort[m.month()]
  1417. : this._monthsShort[
  1418. MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'
  1419. ][m.month()];
  1420. }
  1421. function handleStrictParse(monthName, format, strict) {
  1422. var i,
  1423. ii,
  1424. mom,
  1425. llc = monthName.toLocaleLowerCase();
  1426. if (!this._monthsParse) {
  1427. // this is not used
  1428. this._monthsParse = [];
  1429. this._longMonthsParse = [];
  1430. this._shortMonthsParse = [];
  1431. for (i = 0; i < 12; ++i) {
  1432. mom = createUTC([2000, i]);
  1433. this._shortMonthsParse[i] = this.monthsShort(
  1434. mom,
  1435. ''
  1436. ).toLocaleLowerCase();
  1437. this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
  1438. }
  1439. }
  1440. if (strict) {
  1441. if (format === 'MMM') {
  1442. ii = indexOf.call(this._shortMonthsParse, llc);
  1443. return ii !== -1 ? ii : null;
  1444. } else {
  1445. ii = indexOf.call(this._longMonthsParse, llc);
  1446. return ii !== -1 ? ii : null;
  1447. }
  1448. } else {
  1449. if (format === 'MMM') {
  1450. ii = indexOf.call(this._shortMonthsParse, llc);
  1451. if (ii !== -1) {
  1452. return ii;
  1453. }
  1454. ii = indexOf.call(this._longMonthsParse, llc);
  1455. return ii !== -1 ? ii : null;
  1456. } else {
  1457. ii = indexOf.call(this._longMonthsParse, llc);
  1458. if (ii !== -1) {
  1459. return ii;
  1460. }
  1461. ii = indexOf.call(this._shortMonthsParse, llc);
  1462. return ii !== -1 ? ii : null;
  1463. }
  1464. }
  1465. }
  1466. function localeMonthsParse(monthName, format, strict) {
  1467. var i, mom, regex;
  1468. if (this._monthsParseExact) {
  1469. return handleStrictParse.call(this, monthName, format, strict);
  1470. }
  1471. if (!this._monthsParse) {
  1472. this._monthsParse = [];
  1473. this._longMonthsParse = [];
  1474. this._shortMonthsParse = [];
  1475. }
  1476. // TODO: add sorting
  1477. // Sorting makes sure if one month (or abbr) is a prefix of another
  1478. // see sorting in computeMonthsParse
  1479. for (i = 0; i < 12; i++) {
  1480. // make the regex if we don't have it already
  1481. mom = createUTC([2000, i]);
  1482. if (strict && !this._longMonthsParse[i]) {
  1483. this._longMonthsParse[i] = new RegExp(
  1484. '^' + this.months(mom, '').replace('.', '') + '$',
  1485. 'i'
  1486. );
  1487. this._shortMonthsParse[i] = new RegExp(
  1488. '^' + this.monthsShort(mom, '').replace('.', '') + '$',
  1489. 'i'
  1490. );
  1491. }
  1492. if (!strict && !this._monthsParse[i]) {
  1493. regex =
  1494. '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
  1495. this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
  1496. }
  1497. // test the regex
  1498. if (
  1499. strict &&
  1500. format === 'MMMM' &&
  1501. this._longMonthsParse[i].test(monthName)
  1502. ) {
  1503. return i;
  1504. } else if (
  1505. strict &&
  1506. format === 'MMM' &&
  1507. this._shortMonthsParse[i].test(monthName)
  1508. ) {
  1509. return i;
  1510. } else if (!strict && this._monthsParse[i].test(monthName)) {
  1511. return i;
  1512. }
  1513. }
  1514. }
  1515. // MOMENTS
  1516. function setMonth(mom, value) {
  1517. var dayOfMonth;
  1518. if (!mom.isValid()) {
  1519. // No op
  1520. return mom;
  1521. }
  1522. if (typeof value === 'string') {
  1523. if (/^\d+$/.test(value)) {
  1524. value = toInt(value);
  1525. } else {
  1526. value = mom.localeData().monthsParse(value);
  1527. // TODO: Another silent failure?
  1528. if (!isNumber(value)) {
  1529. return mom;
  1530. }
  1531. }
  1532. }
  1533. dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
  1534. mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
  1535. return mom;
  1536. }
  1537. function getSetMonth(value) {
  1538. if (value != null) {
  1539. setMonth(this, value);
  1540. hooks.updateOffset(this, true);
  1541. return this;
  1542. } else {
  1543. return get(this, 'Month');
  1544. }
  1545. }
  1546. function getDaysInMonth() {
  1547. return daysInMonth(this.year(), this.month());
  1548. }
  1549. function monthsShortRegex(isStrict) {
  1550. if (this._monthsParseExact) {
  1551. if (!hasOwnProp(this, '_monthsRegex')) {
  1552. computeMonthsParse.call(this);
  1553. }
  1554. if (isStrict) {
  1555. return this._monthsShortStrictRegex;
  1556. } else {
  1557. return this._monthsShortRegex;
  1558. }
  1559. } else {
  1560. if (!hasOwnProp(this, '_monthsShortRegex')) {
  1561. this._monthsShortRegex = defaultMonthsShortRegex;
  1562. }
  1563. return this._monthsShortStrictRegex && isStrict
  1564. ? this._monthsShortStrictRegex
  1565. : this._monthsShortRegex;
  1566. }
  1567. }
  1568. function monthsRegex(isStrict) {
  1569. if (this._monthsParseExact) {
  1570. if (!hasOwnProp(this, '_monthsRegex')) {
  1571. computeMonthsParse.call(this);
  1572. }
  1573. if (isStrict) {
  1574. return this._monthsStrictRegex;
  1575. } else {
  1576. return this._monthsRegex;
  1577. }
  1578. } else {
  1579. if (!hasOwnProp(this, '_monthsRegex')) {
  1580. this._monthsRegex = defaultMonthsRegex;
  1581. }
  1582. return this._monthsStrictRegex && isStrict
  1583. ? this._monthsStrictRegex
  1584. : this._monthsRegex;
  1585. }
  1586. }
  1587. function computeMonthsParse() {
  1588. function cmpLenRev(a, b) {
  1589. return b.length - a.length;
  1590. }
  1591. var shortPieces = [],
  1592. longPieces = [],
  1593. mixedPieces = [],
  1594. i,
  1595. mom;
  1596. for (i = 0; i < 12; i++) {
  1597. // make the regex if we don't have it already
  1598. mom = createUTC([2000, i]);
  1599. shortPieces.push(this.monthsShort(mom, ''));
  1600. longPieces.push(this.months(mom, ''));
  1601. mixedPieces.push(this.months(mom, ''));
  1602. mixedPieces.push(this.monthsShort(mom, ''));
  1603. }
  1604. // Sorting makes sure if one month (or abbr) is a prefix of another it
  1605. // will match the longer piece.
  1606. shortPieces.sort(cmpLenRev);
  1607. longPieces.sort(cmpLenRev);
  1608. mixedPieces.sort(cmpLenRev);
  1609. for (i = 0; i < 12; i++) {
  1610. shortPieces[i] = regexEscape(shortPieces[i]);
  1611. longPieces[i] = regexEscape(longPieces[i]);
  1612. }
  1613. for (i = 0; i < 24; i++) {
  1614. mixedPieces[i] = regexEscape(mixedPieces[i]);
  1615. }
  1616. this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  1617. this._monthsShortRegex = this._monthsRegex;
  1618. this._monthsStrictRegex = new RegExp(
  1619. '^(' + longPieces.join('|') + ')',
  1620. 'i'
  1621. );
  1622. this._monthsShortStrictRegex = new RegExp(
  1623. '^(' + shortPieces.join('|') + ')',
  1624. 'i'
  1625. );
  1626. }
  1627. // FORMATTING
  1628. addFormatToken('Y', 0, 0, function () {
  1629. var y = this.year();
  1630. return y <= 9999 ? zeroFill(y, 4) : '+' + y;
  1631. });
  1632. addFormatToken(0, ['YY', 2], 0, function () {
  1633. return this.year() % 100;
  1634. });
  1635. addFormatToken(0, ['YYYY', 4], 0, 'year');
  1636. addFormatToken(0, ['YYYYY', 5], 0, 'year');
  1637. addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
  1638. // ALIASES
  1639. addUnitAlias('year', 'y');
  1640. // PRIORITIES
  1641. addUnitPriority('year', 1);
  1642. // PARSING
  1643. addRegexToken('Y', matchSigned);
  1644. addRegexToken('YY', match1to2, match2);
  1645. addRegexToken('YYYY', match1to4, match4);
  1646. addRegexToken('YYYYY', match1to6, match6);
  1647. addRegexToken('YYYYYY', match1to6, match6);
  1648. addParseToken(['YYYYY', 'YYYYYY'], YEAR);
  1649. addParseToken('YYYY', function (input, array) {
  1650. array[YEAR] =
  1651. input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
  1652. });
  1653. addParseToken('YY', function (input, array) {
  1654. array[YEAR] = hooks.parseTwoDigitYear(input);
  1655. });
  1656. addParseToken('Y', function (input, array) {
  1657. array[YEAR] = parseInt(input, 10);
  1658. });
  1659. // HELPERS
  1660. function daysInYear(year) {
  1661. return isLeapYear(year) ? 366 : 365;
  1662. }
  1663. // HOOKS
  1664. hooks.parseTwoDigitYear = function (input) {
  1665. return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
  1666. };
  1667. // MOMENTS
  1668. var getSetYear = makeGetSet('FullYear', true);
  1669. function getIsLeapYear() {
  1670. return isLeapYear(this.year());
  1671. }
  1672. function createDate(y, m, d, h, M, s, ms) {
  1673. // can't just apply() to create a date:
  1674. // https://stackoverflow.com/q/181348
  1675. var date;
  1676. // the date constructor remaps years 0-99 to 1900-1999
  1677. if (y < 100 && y >= 0) {
  1678. // preserve leap years using a full 400 year cycle, then reset
  1679. date = new Date(y + 400, m, d, h, M, s, ms);
  1680. if (isFinite(date.getFullYear())) {
  1681. date.setFullYear(y);
  1682. }
  1683. } else {
  1684. date = new Date(y, m, d, h, M, s, ms);
  1685. }
  1686. return date;
  1687. }
  1688. function createUTCDate(y) {
  1689. var date, args;
  1690. // the Date.UTC function remaps years 0-99 to 1900-1999
  1691. if (y < 100 && y >= 0) {
  1692. args = Array.prototype.slice.call(arguments);
  1693. // preserve leap years using a full 400 year cycle, then reset
  1694. args[0] = y + 400;
  1695. date = new Date(Date.UTC.apply(null, args));
  1696. if (isFinite(date.getUTCFullYear())) {
  1697. date.setUTCFullYear(y);
  1698. }
  1699. } else {
  1700. date = new Date(Date.UTC.apply(null, arguments));
  1701. }
  1702. return date;
  1703. }
  1704. // start-of-first-week - start-of-year
  1705. function firstWeekOffset(year, dow, doy) {
  1706. var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
  1707. fwd = 7 + dow - doy,
  1708. // first-week day local weekday -- which local weekday is fwd
  1709. fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
  1710. return -fwdlw + fwd - 1;
  1711. }
  1712. // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
  1713. function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
  1714. var localWeekday = (7 + weekday - dow) % 7,
  1715. weekOffset = firstWeekOffset(year, dow, doy),
  1716. dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
  1717. resYear,
  1718. resDayOfYear;
  1719. if (dayOfYear <= 0) {
  1720. resYear = year - 1;
  1721. resDayOfYear = daysInYear(resYear) + dayOfYear;
  1722. } else if (dayOfYear > daysInYear(year)) {
  1723. resYear = year + 1;
  1724. resDayOfYear = dayOfYear - daysInYear(year);
  1725. } else {
  1726. resYear = year;
  1727. resDayOfYear = dayOfYear;
  1728. }
  1729. return {
  1730. year: resYear,
  1731. dayOfYear: resDayOfYear,
  1732. };
  1733. }
  1734. function weekOfYear(mom, dow, doy) {
  1735. var weekOffset = firstWeekOffset(mom.year(), dow, doy),
  1736. week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
  1737. resWeek,
  1738. resYear;
  1739. if (week < 1) {
  1740. resYear = mom.year() - 1;
  1741. resWeek = week + weeksInYear(resYear, dow, doy);
  1742. } else if (week > weeksInYear(mom.year(), dow, doy)) {
  1743. resWeek = week - weeksInYear(mom.year(), dow, doy);
  1744. resYear = mom.year() + 1;
  1745. } else {
  1746. resYear = mom.year();
  1747. resWeek = week;
  1748. }
  1749. return {
  1750. week: resWeek,
  1751. year: resYear,
  1752. };
  1753. }
  1754. function weeksInYear(year, dow, doy) {
  1755. var weekOffset = firstWeekOffset(year, dow, doy),
  1756. weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
  1757. return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
  1758. }
  1759. // FORMATTING
  1760. addFormatToken('w', ['ww', 2], 'wo', 'week');
  1761. addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
  1762. // ALIASES
  1763. addUnitAlias('week', 'w');
  1764. addUnitAlias('isoWeek', 'W');
  1765. // PRIORITIES
  1766. addUnitPriority('week', 5);
  1767. addUnitPriority('isoWeek', 5);
  1768. // PARSING
  1769. addRegexToken('w', match1to2);
  1770. addRegexToken('ww', match1to2, match2);
  1771. addRegexToken('W', match1to2);
  1772. addRegexToken('WW', match1to2, match2);
  1773. addWeekParseToken(
  1774. ['w', 'ww', 'W', 'WW'],
  1775. function (input, week, config, token) {
  1776. week[token.substr(0, 1)] = toInt(input);
  1777. }
  1778. );
  1779. // HELPERS
  1780. // LOCALES
  1781. function localeWeek(mom) {
  1782. return weekOfYear(mom, this._week.dow, this._week.doy).week;
  1783. }
  1784. var defaultLocaleWeek = {
  1785. dow: 0, // Sunday is the first day of the week.
  1786. doy: 6, // The week that contains Jan 6th is the first week of the year.
  1787. };
  1788. function localeFirstDayOfWeek() {
  1789. return this._week.dow;
  1790. }
  1791. function localeFirstDayOfYear() {
  1792. return this._week.doy;
  1793. }
  1794. // MOMENTS
  1795. function getSetWeek(input) {
  1796. var week = this.localeData().week(this);
  1797. return input == null ? week : this.add((input - week) * 7, 'd');
  1798. }
  1799. function getSetISOWeek(input) {
  1800. var week = weekOfYear(this, 1, 4).week;
  1801. return input == null ? week : this.add((input - week) * 7, 'd');
  1802. }
  1803. // FORMATTING
  1804. addFormatToken('d', 0, 'do', 'day');
  1805. addFormatToken('dd', 0, 0, function (format) {
  1806. return this.localeData().weekdaysMin(this, format);
  1807. });
  1808. addFormatToken('ddd', 0, 0, function (format) {
  1809. return this.localeData().weekdaysShort(this, format);
  1810. });
  1811. addFormatToken('dddd', 0, 0, function (format) {
  1812. return this.localeData().weekdays(this, format);
  1813. });
  1814. addFormatToken('e', 0, 0, 'weekday');
  1815. addFormatToken('E', 0, 0, 'isoWeekday');
  1816. // ALIASES
  1817. addUnitAlias('day', 'd');
  1818. addUnitAlias('weekday', 'e');
  1819. addUnitAlias('isoWeekday', 'E');
  1820. // PRIORITY
  1821. addUnitPriority('day', 11);
  1822. addUnitPriority('weekday', 11);
  1823. addUnitPriority('isoWeekday', 11);
  1824. // PARSING
  1825. addRegexToken('d', match1to2);
  1826. addRegexToken('e', match1to2);
  1827. addRegexToken('E', match1to2);
  1828. addRegexToken('dd', function (isStrict, locale) {
  1829. return locale.weekdaysMinRegex(isStrict);
  1830. });
  1831. addRegexToken('ddd', function (isStrict, locale) {
  1832. return locale.weekdaysShortRegex(isStrict);
  1833. });
  1834. addRegexToken('dddd', function (isStrict, locale) {
  1835. return locale.weekdaysRegex(isStrict);
  1836. });
  1837. addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
  1838. var weekday = config._locale.weekdaysParse(input, token, config._strict);
  1839. // if we didn't get a weekday name, mark the date as invalid
  1840. if (weekday != null) {
  1841. week.d = weekday;
  1842. } else {
  1843. getParsingFlags(config).invalidWeekday = input;
  1844. }
  1845. });
  1846. addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
  1847. week[token] = toInt(input);
  1848. });
  1849. // HELPERS
  1850. function parseWeekday(input, locale) {
  1851. if (typeof input !== 'string') {
  1852. return input;
  1853. }
  1854. if (!isNaN(input)) {
  1855. return parseInt(input, 10);
  1856. }
  1857. input = locale.weekdaysParse(input);
  1858. if (typeof input === 'number') {
  1859. return input;
  1860. }
  1861. return null;
  1862. }
  1863. function parseIsoWeekday(input, locale) {
  1864. if (typeof input === 'string') {
  1865. return locale.weekdaysParse(input) % 7 || 7;
  1866. }
  1867. return isNaN(input) ? null : input;
  1868. }
  1869. // LOCALES
  1870. function shiftWeekdays(ws, n) {
  1871. return ws.slice(n, 7).concat(ws.slice(0, n));
  1872. }
  1873. var defaultLocaleWeekdays =
  1874. 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
  1875. defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
  1876. defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
  1877. defaultWeekdaysRegex = matchWord,
  1878. defaultWeekdaysShortRegex = matchWord,
  1879. defaultWeekdaysMinRegex = matchWord;
  1880. function localeWeekdays(m, format) {
  1881. var weekdays = isArray(this._weekdays)
  1882. ? this._weekdays
  1883. : this._weekdays[
  1884. m && m !== true && this._weekdays.isFormat.test(format)
  1885. ? 'format'
  1886. : 'standalone'
  1887. ];
  1888. return m === true
  1889. ? shiftWeekdays(weekdays, this._week.dow)
  1890. : m
  1891. ? weekdays[m.day()]
  1892. : weekdays;
  1893. }
  1894. function localeWeekdaysShort(m) {
  1895. return m === true
  1896. ? shiftWeekdays(this._weekdaysShort, this._week.dow)
  1897. : m
  1898. ? this._weekdaysShort[m.day()]
  1899. : this._weekdaysShort;
  1900. }
  1901. function localeWeekdaysMin(m) {
  1902. return m === true
  1903. ? shiftWeekdays(this._weekdaysMin, this._week.dow)
  1904. : m
  1905. ? this._weekdaysMin[m.day()]
  1906. : this._weekdaysMin;
  1907. }
  1908. function handleStrictParse$1(weekdayName, format, strict) {
  1909. var i,
  1910. ii,
  1911. mom,
  1912. llc = weekdayName.toLocaleLowerCase();
  1913. if (!this._weekdaysParse) {
  1914. this._weekdaysParse = [];
  1915. this._shortWeekdaysParse = [];
  1916. this._minWeekdaysParse = [];
  1917. for (i = 0; i < 7; ++i) {
  1918. mom = createUTC([2000, 1]).day(i);
  1919. this._minWeekdaysParse[i] = this.weekdaysMin(
  1920. mom,
  1921. ''
  1922. ).toLocaleLowerCase();
  1923. this._shortWeekdaysParse[i] = this.weekdaysShort(
  1924. mom,
  1925. ''
  1926. ).toLocaleLowerCase();
  1927. this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
  1928. }
  1929. }
  1930. if (strict) {
  1931. if (format === 'dddd') {
  1932. ii = indexOf.call(this._weekdaysParse, llc);
  1933. return ii !== -1 ? ii : null;
  1934. } else if (format === 'ddd') {
  1935. ii = indexOf.call(this._shortWeekdaysParse, llc);
  1936. return ii !== -1 ? ii : null;
  1937. } else {
  1938. ii = indexOf.call(this._minWeekdaysParse, llc);
  1939. return ii !== -1 ? ii : null;
  1940. }
  1941. } else {
  1942. if (format === 'dddd') {
  1943. ii = indexOf.call(this._weekdaysParse, llc);
  1944. if (ii !== -1) {
  1945. return ii;
  1946. }
  1947. ii = indexOf.call(this._shortWeekdaysParse, llc);
  1948. if (ii !== -1) {
  1949. return ii;
  1950. }
  1951. ii = indexOf.call(this._minWeekdaysParse, llc);
  1952. return ii !== -1 ? ii : null;
  1953. } else if (format === 'ddd') {
  1954. ii = indexOf.call(this._shortWeekdaysParse, llc);
  1955. if (ii !== -1) {
  1956. return ii;
  1957. }
  1958. ii = indexOf.call(this._weekdaysParse, llc);
  1959. if (ii !== -1) {
  1960. return ii;
  1961. }
  1962. ii = indexOf.call(this._minWeekdaysParse, llc);
  1963. return ii !== -1 ? ii : null;
  1964. } else {
  1965. ii = indexOf.call(this._minWeekdaysParse, llc);
  1966. if (ii !== -1) {
  1967. return ii;
  1968. }
  1969. ii = indexOf.call(this._weekdaysParse, llc);
  1970. if (ii !== -1) {
  1971. return ii;
  1972. }
  1973. ii = indexOf.call(this._shortWeekdaysParse, llc);
  1974. return ii !== -1 ? ii : null;
  1975. }
  1976. }
  1977. }
  1978. function localeWeekdaysParse(weekdayName, format, strict) {
  1979. var i, mom, regex;
  1980. if (this._weekdaysParseExact) {
  1981. return handleStrictParse$1.call(this, weekdayName, format, strict);
  1982. }
  1983. if (!this._weekdaysParse) {
  1984. this._weekdaysParse = [];
  1985. this._minWeekdaysParse = [];
  1986. this._shortWeekdaysParse = [];
  1987. this._fullWeekdaysParse = [];
  1988. }
  1989. for (i = 0; i < 7; i++) {
  1990. // make the regex if we don't have it already
  1991. mom = createUTC([2000, 1]).day(i);
  1992. if (strict && !this._fullWeekdaysParse[i]) {
  1993. this._fullWeekdaysParse[i] = new RegExp(
  1994. '^' + this.weekdays(mom, '').replace('.', '\\.?') + '$',
  1995. 'i'
  1996. );
  1997. this._shortWeekdaysParse[i] = new RegExp(
  1998. '^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$',
  1999. 'i'
  2000. );
  2001. this._minWeekdaysParse[i] = new RegExp(
  2002. '^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$',
  2003. 'i'
  2004. );
  2005. }
  2006. if (!this._weekdaysParse[i]) {
  2007. regex =
  2008. '^' +
  2009. this.weekdays(mom, '') +
  2010. '|^' +
  2011. this.weekdaysShort(mom, '') +
  2012. '|^' +
  2013. this.weekdaysMin(mom, '');
  2014. this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
  2015. }
  2016. // test the regex
  2017. if (
  2018. strict &&
  2019. format === 'dddd' &&
  2020. this._fullWeekdaysParse[i].test(weekdayName)
  2021. ) {
  2022. return i;
  2023. } else if (
  2024. strict &&
  2025. format === 'ddd' &&
  2026. this._shortWeekdaysParse[i].test(weekdayName)
  2027. ) {
  2028. return i;
  2029. } else if (
  2030. strict &&
  2031. format === 'dd' &&
  2032. this._minWeekdaysParse[i].test(weekdayName)
  2033. ) {
  2034. return i;
  2035. } else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
  2036. return i;
  2037. }
  2038. }
  2039. }
  2040. // MOMENTS
  2041. function getSetDayOfWeek(input) {
  2042. if (!this.isValid()) {
  2043. return input != null ? this : NaN;
  2044. }
  2045. var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
  2046. if (input != null) {
  2047. input = parseWeekday(input, this.localeData());
  2048. return this.add(input - day, 'd');
  2049. } else {
  2050. return day;
  2051. }
  2052. }
  2053. function getSetLocaleDayOfWeek(input) {
  2054. if (!this.isValid()) {
  2055. return input != null ? this : NaN;
  2056. }
  2057. var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
  2058. return input == null ? weekday : this.add(input - weekday, 'd');
  2059. }
  2060. function getSetISODayOfWeek(input) {
  2061. if (!this.isValid()) {
  2062. return input != null ? this : NaN;
  2063. }
  2064. // behaves the same as moment#day except
  2065. // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
  2066. // as a setter, sunday should belong to the previous week.
  2067. if (input != null) {
  2068. var weekday = parseIsoWeekday(input, this.localeData());
  2069. return this.day(this.day() % 7 ? weekday : weekday - 7);
  2070. } else {
  2071. return this.day() || 7;
  2072. }
  2073. }
  2074. function weekdaysRegex(isStrict) {
  2075. if (this._weekdaysParseExact) {
  2076. if (!hasOwnProp(this, '_weekdaysRegex')) {
  2077. computeWeekdaysParse.call(this);
  2078. }
  2079. if (isStrict) {
  2080. return this._weekdaysStrictRegex;
  2081. } else {
  2082. return this._weekdaysRegex;
  2083. }
  2084. } else {
  2085. if (!hasOwnProp(this, '_weekdaysRegex')) {
  2086. this._weekdaysRegex = defaultWeekdaysRegex;
  2087. }
  2088. return this._weekdaysStrictRegex && isStrict
  2089. ? this._weekdaysStrictRegex
  2090. : this._weekdaysRegex;
  2091. }
  2092. }
  2093. function weekdaysShortRegex(isStrict) {
  2094. if (this._weekdaysParseExact) {
  2095. if (!hasOwnProp(this, '_weekdaysRegex')) {
  2096. computeWeekdaysParse.call(this);
  2097. }
  2098. if (isStrict) {
  2099. return this._weekdaysShortStrictRegex;
  2100. } else {
  2101. return this._weekdaysShortRegex;
  2102. }
  2103. } else {
  2104. if (!hasOwnProp(this, '_weekdaysShortRegex')) {
  2105. this._weekdaysShortRegex = defaultWeekdaysShortRegex;
  2106. }
  2107. return this._weekdaysShortStrictRegex && isStrict
  2108. ? this._weekdaysShortStrictRegex
  2109. : this._weekdaysShortRegex;
  2110. }
  2111. }
  2112. function weekdaysMinRegex(isStrict) {
  2113. if (this._weekdaysParseExact) {
  2114. if (!hasOwnProp(this, '_weekdaysRegex')) {
  2115. computeWeekdaysParse.call(this);
  2116. }
  2117. if (isStrict) {
  2118. return this._weekdaysMinStrictRegex;
  2119. } else {
  2120. return this._weekdaysMinRegex;
  2121. }
  2122. } else {
  2123. if (!hasOwnProp(this, '_weekdaysMinRegex')) {
  2124. this._weekdaysMinRegex = defaultWeekdaysMinRegex;
  2125. }
  2126. return this._weekdaysMinStrictRegex && isStrict
  2127. ? this._weekdaysMinStrictRegex
  2128. : this._weekdaysMinRegex;
  2129. }
  2130. }
  2131. function computeWeekdaysParse() {
  2132. function cmpLenRev(a, b) {
  2133. return b.length - a.length;
  2134. }
  2135. var minPieces = [],
  2136. shortPieces = [],
  2137. longPieces = [],
  2138. mixedPieces = [],
  2139. i,
  2140. mom,
  2141. minp,
  2142. shortp,
  2143. longp;
  2144. for (i = 0; i < 7; i++) {
  2145. // make the regex if we don't have it already
  2146. mom = createUTC([2000, 1]).day(i);
  2147. minp = regexEscape(this.weekdaysMin(mom, ''));
  2148. shortp = regexEscape(this.weekdaysShort(mom, ''));
  2149. longp = regexEscape(this.weekdays(mom, ''));
  2150. minPieces.push(minp);
  2151. shortPieces.push(shortp);
  2152. longPieces.push(longp);
  2153. mixedPieces.push(minp);
  2154. mixedPieces.push(shortp);
  2155. mixedPieces.push(longp);
  2156. }
  2157. // Sorting makes sure if one weekday (or abbr) is a prefix of another it
  2158. // will match the longer piece.
  2159. minPieces.sort(cmpLenRev);
  2160. shortPieces.sort(cmpLenRev);
  2161. longPieces.sort(cmpLenRev);
  2162. mixedPieces.sort(cmpLenRev);
  2163. this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  2164. this._weekdaysShortRegex = this._weekdaysRegex;
  2165. this._weekdaysMinRegex = this._weekdaysRegex;
  2166. this._weekdaysStrictRegex = new RegExp(
  2167. '^(' + longPieces.join('|') + ')',
  2168. 'i'
  2169. );
  2170. this._weekdaysShortStrictRegex = new RegExp(
  2171. '^(' + shortPieces.join('|') + ')',
  2172. 'i'
  2173. );
  2174. this._weekdaysMinStrictRegex = new RegExp(
  2175. '^(' + minPieces.join('|') + ')',
  2176. 'i'
  2177. );
  2178. }
  2179. // FORMATTING
  2180. function hFormat() {
  2181. return this.hours() % 12 || 12;
  2182. }
  2183. function kFormat() {
  2184. return this.hours() || 24;
  2185. }
  2186. addFormatToken('H', ['HH', 2], 0, 'hour');
  2187. addFormatToken('h', ['hh', 2], 0, hFormat);
  2188. addFormatToken('k', ['kk', 2], 0, kFormat);
  2189. addFormatToken('hmm', 0, 0, function () {
  2190. return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
  2191. });
  2192. addFormatToken('hmmss', 0, 0, function () {
  2193. return (
  2194. '' +
  2195. hFormat.apply(this) +
  2196. zeroFill(this.minutes(), 2) +
  2197. zeroFill(this.seconds(), 2)
  2198. );
  2199. });
  2200. addFormatToken('Hmm', 0, 0, function () {
  2201. return '' + this.hours() + zeroFill(this.minutes(), 2);
  2202. });
  2203. addFormatToken('Hmmss', 0, 0, function () {
  2204. return (
  2205. '' +
  2206. this.hours() +
  2207. zeroFill(this.minutes(), 2) +
  2208. zeroFill(this.seconds(), 2)
  2209. );
  2210. });
  2211. function meridiem(token, lowercase) {
  2212. addFormatToken(token, 0, 0, function () {
  2213. return this.localeData().meridiem(
  2214. this.hours(),
  2215. this.minutes(),
  2216. lowercase
  2217. );
  2218. });
  2219. }
  2220. meridiem('a', true);
  2221. meridiem('A', false);
  2222. // ALIASES
  2223. addUnitAlias('hour', 'h');
  2224. // PRIORITY
  2225. addUnitPriority('hour', 13);
  2226. // PARSING
  2227. function matchMeridiem(isStrict, locale) {
  2228. return locale._meridiemParse;
  2229. }
  2230. addRegexToken('a', matchMeridiem);
  2231. addRegexToken('A', matchMeridiem);
  2232. addRegexToken('H', match1to2);
  2233. addRegexToken('h', match1to2);
  2234. addRegexToken('k', match1to2);
  2235. addRegexToken('HH', match1to2, match2);
  2236. addRegexToken('hh', match1to2, match2);
  2237. addRegexToken('kk', match1to2, match2);
  2238. addRegexToken('hmm', match3to4);
  2239. addRegexToken('hmmss', match5to6);
  2240. addRegexToken('Hmm', match3to4);
  2241. addRegexToken('Hmmss', match5to6);
  2242. addParseToken(['H', 'HH'], HOUR);
  2243. addParseToken(['k', 'kk'], function (input, array, config) {
  2244. var kInput = toInt(input);
  2245. array[HOUR] = kInput === 24 ? 0 : kInput;
  2246. });
  2247. addParseToken(['a', 'A'], function (input, array, config) {
  2248. config._isPm = config._locale.isPM(input);
  2249. config._meridiem = input;
  2250. });
  2251. addParseToken(['h', 'hh'], function (input, array, config) {
  2252. array[HOUR] = toInt(input);
  2253. getParsingFlags(config).bigHour = true;
  2254. });
  2255. addParseToken('hmm', function (input, array, config) {
  2256. var pos = input.length - 2;
  2257. array[HOUR] = toInt(input.substr(0, pos));
  2258. array[MINUTE] = toInt(input.substr(pos));
  2259. getParsingFlags(config).bigHour = true;
  2260. });
  2261. addParseToken('hmmss', function (input, array, config) {
  2262. var pos1 = input.length - 4,
  2263. pos2 = input.length - 2;
  2264. array[HOUR] = toInt(input.substr(0, pos1));
  2265. array[MINUTE] = toInt(input.substr(pos1, 2));
  2266. array[SECOND] = toInt(input.substr(pos2));
  2267. getParsingFlags(config).bigHour = true;
  2268. });
  2269. addParseToken('Hmm', function (input, array, config) {
  2270. var pos = input.length - 2;
  2271. array[HOUR] = toInt(input.substr(0, pos));
  2272. array[MINUTE] = toInt(input.substr(pos));
  2273. });
  2274. addParseToken('Hmmss', function (input, array, config) {
  2275. var pos1 = input.length - 4,
  2276. pos2 = input.length - 2;
  2277. array[HOUR] = toInt(input.substr(0, pos1));
  2278. array[MINUTE] = toInt(input.substr(pos1, 2));
  2279. array[SECOND] = toInt(input.substr(pos2));
  2280. });
  2281. // LOCALES
  2282. function localeIsPM(input) {
  2283. // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
  2284. // Using charAt should be more compatible.
  2285. return (input + '').toLowerCase().charAt(0) === 'p';
  2286. }
  2287. var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i,
  2288. // Setting the hour should keep the time, because the user explicitly
  2289. // specified which hour they want. So trying to maintain the same hour (in
  2290. // a new timezone) makes sense. Adding/subtracting hours does not follow
  2291. // this rule.
  2292. getSetHour = makeGetSet('Hours', true);
  2293. function localeMeridiem(hours, minutes, isLower) {
  2294. if (hours > 11) {
  2295. return isLower ? 'pm' : 'PM';
  2296. } else {
  2297. return isLower ? 'am' : 'AM';
  2298. }
  2299. }
  2300. var baseConfig = {
  2301. calendar: defaultCalendar,
  2302. longDateFormat: defaultLongDateFormat,
  2303. invalidDate: defaultInvalidDate,
  2304. ordinal: defaultOrdinal,
  2305. dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
  2306. relativeTime: defaultRelativeTime,
  2307. months: defaultLocaleMonths,
  2308. monthsShort: defaultLocaleMonthsShort,
  2309. week: defaultLocaleWeek,
  2310. weekdays: defaultLocaleWeekdays,
  2311. weekdaysMin: defaultLocaleWeekdaysMin,
  2312. weekdaysShort: defaultLocaleWeekdaysShort,
  2313. meridiemParse: defaultLocaleMeridiemParse,
  2314. };
  2315. // internal storage for locale config files
  2316. var locales = {},
  2317. localeFamilies = {},
  2318. globalLocale;
  2319. function commonPrefix(arr1, arr2) {
  2320. var i,
  2321. minl = Math.min(arr1.length, arr2.length);
  2322. for (i = 0; i < minl; i += 1) {
  2323. if (arr1[i] !== arr2[i]) {
  2324. return i;
  2325. }
  2326. }
  2327. return minl;
  2328. }
  2329. function normalizeLocale(key) {
  2330. return key ? key.toLowerCase().replace('_', '-') : key;
  2331. }
  2332. // pick the locale from the array
  2333. // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
  2334. // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
  2335. function chooseLocale(names) {
  2336. var i = 0,
  2337. j,
  2338. next,
  2339. locale,
  2340. split;
  2341. while (i < names.length) {
  2342. split = normalizeLocale(names[i]).split('-');
  2343. j = split.length;
  2344. next = normalizeLocale(names[i + 1]);
  2345. next = next ? next.split('-') : null;
  2346. while (j > 0) {
  2347. locale = loadLocale(split.slice(0, j).join('-'));
  2348. if (locale) {
  2349. return locale;
  2350. }
  2351. if (
  2352. next &&
  2353. next.length >= j &&
  2354. commonPrefix(split, next) >= j - 1
  2355. ) {
  2356. //the next array item is better than a shallower substring of this one
  2357. break;
  2358. }
  2359. j--;
  2360. }
  2361. i++;
  2362. }
  2363. return globalLocale;
  2364. }
  2365. function isLocaleNameSane(name) {
  2366. // Prevent names that look like filesystem paths, i.e contain '/' or '\'
  2367. return name.match('^[^/\\\\]*$') != null;
  2368. }
  2369. function loadLocale(name) {
  2370. var oldLocale = null,
  2371. aliasedRequire;
  2372. // TODO: Find a better way to register and load all the locales in Node
  2373. if (
  2374. locales[name] === undefined &&
  2375. typeof module !== 'undefined' &&
  2376. module &&
  2377. module.exports &&
  2378. isLocaleNameSane(name)
  2379. ) {
  2380. try {
  2381. oldLocale = globalLocale._abbr;
  2382. aliasedRequire = require;
  2383. aliasedRequire('./locale/' + name);
  2384. getSetGlobalLocale(oldLocale);
  2385. } catch (e) {
  2386. // mark as not found to avoid repeating expensive file require call causing high CPU
  2387. // when trying to find en-US, en_US, en-us for every format call
  2388. locales[name] = null; // null means not found
  2389. }
  2390. }
  2391. return locales[name];
  2392. }
  2393. // This function will load locale and then set the global locale. If
  2394. // no arguments are passed in, it will simply return the current global
  2395. // locale key.
  2396. function getSetGlobalLocale(key, values) {
  2397. var data;
  2398. if (key) {
  2399. if (isUndefined(values)) {
  2400. data = getLocale(key);
  2401. } else {
  2402. data = defineLocale(key, values);
  2403. }
  2404. if (data) {
  2405. // moment.duration._locale = moment._locale = data;
  2406. globalLocale = data;
  2407. } else {
  2408. if (typeof console !== 'undefined' && console.warn) {
  2409. //warn user if arguments are passed but the locale could not be set
  2410. console.warn(
  2411. 'Locale ' + key + ' not found. Did you forget to load it?'
  2412. );
  2413. }
  2414. }
  2415. }
  2416. return globalLocale._abbr;
  2417. }
  2418. function defineLocale(name, config) {
  2419. if (config !== null) {
  2420. var locale,
  2421. parentConfig = baseConfig;
  2422. config.abbr = name;
  2423. if (locales[name] != null) {
  2424. deprecateSimple(
  2425. 'defineLocaleOverride',
  2426. 'use moment.updateLocale(localeName, config) to change ' +
  2427. 'an existing locale. moment.defineLocale(localeName, ' +
  2428. 'config) should only be used for creating a new locale ' +
  2429. 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.'
  2430. );
  2431. parentConfig = locales[name]._config;
  2432. } else if (config.parentLocale != null) {
  2433. if (locales[config.parentLocale] != null) {
  2434. parentConfig = locales[config.parentLocale]._config;
  2435. } else {
  2436. locale = loadLocale(config.parentLocale);
  2437. if (locale != null) {
  2438. parentConfig = locale._config;
  2439. } else {
  2440. if (!localeFamilies[config.parentLocale]) {
  2441. localeFamilies[config.parentLocale] = [];
  2442. }
  2443. localeFamilies[config.parentLocale].push({
  2444. name: name,
  2445. config: config,
  2446. });
  2447. return null;
  2448. }
  2449. }
  2450. }
  2451. locales[name] = new Locale(mergeConfigs(parentConfig, config));
  2452. if (localeFamilies[name]) {
  2453. localeFamilies[name].forEach(function (x) {
  2454. defineLocale(x.name, x.config);
  2455. });
  2456. }
  2457. // backwards compat for now: also set the locale
  2458. // make sure we set the locale AFTER all child locales have been
  2459. // created, so we won't end up with the child locale set.
  2460. getSetGlobalLocale(name);
  2461. return locales[name];
  2462. } else {
  2463. // useful for testing
  2464. delete locales[name];
  2465. return null;
  2466. }
  2467. }
  2468. function updateLocale(name, config) {
  2469. if (config != null) {
  2470. var locale,
  2471. tmpLocale,
  2472. parentConfig = baseConfig;
  2473. if (locales[name] != null && locales[name].parentLocale != null) {
  2474. // Update existing child locale in-place to avoid memory-leaks
  2475. locales[name].set(mergeConfigs(locales[name]._config, config));
  2476. } else {
  2477. // MERGE
  2478. tmpLocale = loadLocale(name);
  2479. if (tmpLocale != null) {
  2480. parentConfig = tmpLocale._config;
  2481. }
  2482. config = mergeConfigs(parentConfig, config);
  2483. if (tmpLocale == null) {
  2484. // updateLocale is called for creating a new locale
  2485. // Set abbr so it will have a name (getters return
  2486. // undefined otherwise).
  2487. config.abbr = name;
  2488. }
  2489. locale = new Locale(config);
  2490. locale.parentLocale = locales[name];
  2491. locales[name] = locale;
  2492. }
  2493. // backwards compat for now: also set the locale
  2494. getSetGlobalLocale(name);
  2495. } else {
  2496. // pass null for config to unupdate, useful for tests
  2497. if (locales[name] != null) {
  2498. if (locales[name].parentLocale != null) {
  2499. locales[name] = locales[name].parentLocale;
  2500. if (name === getSetGlobalLocale()) {
  2501. getSetGlobalLocale(name);
  2502. }
  2503. } else if (locales[name] != null) {
  2504. delete locales[name];
  2505. }
  2506. }
  2507. }
  2508. return locales[name];
  2509. }
  2510. // returns locale data
  2511. function getLocale(key) {
  2512. var locale;
  2513. if (key && key._locale && key._locale._abbr) {
  2514. key = key._locale._abbr;
  2515. }
  2516. if (!key) {
  2517. return globalLocale;
  2518. }
  2519. if (!isArray(key)) {
  2520. //short-circuit everything else
  2521. locale = loadLocale(key);
  2522. if (locale) {
  2523. return locale;
  2524. }
  2525. key = [key];
  2526. }
  2527. return chooseLocale(key);
  2528. }
  2529. function listLocales() {
  2530. return keys(locales);
  2531. }
  2532. function checkOverflow(m) {
  2533. var overflow,
  2534. a = m._a;
  2535. if (a && getParsingFlags(m).overflow === -2) {
  2536. overflow =
  2537. a[MONTH] < 0 || a[MONTH] > 11
  2538. ? MONTH
  2539. : a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH])
  2540. ? DATE
  2541. : a[HOUR] < 0 ||
  2542. a[HOUR] > 24 ||
  2543. (a[HOUR] === 24 &&
  2544. (a[MINUTE] !== 0 ||
  2545. a[SECOND] !== 0 ||
  2546. a[MILLISECOND] !== 0))
  2547. ? HOUR
  2548. : a[MINUTE] < 0 || a[MINUTE] > 59
  2549. ? MINUTE
  2550. : a[SECOND] < 0 || a[SECOND] > 59
  2551. ? SECOND
  2552. : a[MILLISECOND] < 0 || a[MILLISECOND] > 999
  2553. ? MILLISECOND
  2554. : -1;
  2555. if (
  2556. getParsingFlags(m)._overflowDayOfYear &&
  2557. (overflow < YEAR || overflow > DATE)
  2558. ) {
  2559. overflow = DATE;
  2560. }
  2561. if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
  2562. overflow = WEEK;
  2563. }
  2564. if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
  2565. overflow = WEEKDAY;
  2566. }
  2567. getParsingFlags(m).overflow = overflow;
  2568. }
  2569. return m;
  2570. }
  2571. // iso 8601 regex
  2572. // 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)
  2573. var extendedIsoRegex =
  2574. /^\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)?)?$/,
  2575. basicIsoRegex =
  2576. /^\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)?)?$/,
  2577. tzRegex = /Z|[+-]\d\d(?::?\d\d)?/,
  2578. isoDates = [
  2579. ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/],
  2580. ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/],
  2581. ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/],
  2582. ['GGGG-[W]WW', /\d{4}-W\d\d/, false],
  2583. ['YYYY-DDD', /\d{4}-\d{3}/],
  2584. ['YYYY-MM', /\d{4}-\d\d/, false],
  2585. ['YYYYYYMMDD', /[+-]\d{10}/],
  2586. ['YYYYMMDD', /\d{8}/],
  2587. ['GGGG[W]WWE', /\d{4}W\d{3}/],
  2588. ['GGGG[W]WW', /\d{4}W\d{2}/, false],
  2589. ['YYYYDDD', /\d{7}/],
  2590. ['YYYYMM', /\d{6}/, false],
  2591. ['YYYY', /\d{4}/, false],
  2592. ],
  2593. // iso time formats and regexes
  2594. isoTimes = [
  2595. ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/],
  2596. ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/],
  2597. ['HH:mm:ss', /\d\d:\d\d:\d\d/],
  2598. ['HH:mm', /\d\d:\d\d/],
  2599. ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/],
  2600. ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/],
  2601. ['HHmmss', /\d\d\d\d\d\d/],
  2602. ['HHmm', /\d\d\d\d/],
  2603. ['HH', /\d\d/],
  2604. ],
  2605. aspNetJsonRegex = /^\/?Date\((-?\d+)/i,
  2606. // RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3
  2607. rfc2822 =
  2608. /^(?:(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}))$/,
  2609. obsOffsets = {
  2610. UT: 0,
  2611. GMT: 0,
  2612. EDT: -4 * 60,
  2613. EST: -5 * 60,
  2614. CDT: -5 * 60,
  2615. CST: -6 * 60,
  2616. MDT: -6 * 60,
  2617. MST: -7 * 60,
  2618. PDT: -7 * 60,
  2619. PST: -8 * 60,
  2620. };
  2621. // date from iso format
  2622. function configFromISO(config) {
  2623. var i,
  2624. l,
  2625. string = config._i,
  2626. match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
  2627. allowTime,
  2628. dateFormat,
  2629. timeFormat,
  2630. tzFormat,
  2631. isoDatesLen = isoDates.length,
  2632. isoTimesLen = isoTimes.length;
  2633. if (match) {
  2634. getParsingFlags(config).iso = true;
  2635. for (i = 0, l = isoDatesLen; i < l; i++) {
  2636. if (isoDates[i][1].exec(match[1])) {
  2637. dateFormat = isoDates[i][0];
  2638. allowTime = isoDates[i][2] !== false;
  2639. break;
  2640. }
  2641. }
  2642. if (dateFormat == null) {
  2643. config._isValid = false;
  2644. return;
  2645. }
  2646. if (match[3]) {
  2647. for (i = 0, l = isoTimesLen; i < l; i++) {
  2648. if (isoTimes[i][1].exec(match[3])) {
  2649. // match[2] should be 'T' or space
  2650. timeFormat = (match[2] || ' ') + isoTimes[i][0];
  2651. break;
  2652. }
  2653. }
  2654. if (timeFormat == null) {
  2655. config._isValid = false;
  2656. return;
  2657. }
  2658. }
  2659. if (!allowTime && timeFormat != null) {
  2660. config._isValid = false;
  2661. return;
  2662. }
  2663. if (match[4]) {
  2664. if (tzRegex.exec(match[4])) {
  2665. tzFormat = 'Z';
  2666. } else {
  2667. config._isValid = false;
  2668. return;
  2669. }
  2670. }
  2671. config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
  2672. configFromStringAndFormat(config);
  2673. } else {
  2674. config._isValid = false;
  2675. }
  2676. }
  2677. function extractFromRFC2822Strings(
  2678. yearStr,
  2679. monthStr,
  2680. dayStr,
  2681. hourStr,
  2682. minuteStr,
  2683. secondStr
  2684. ) {
  2685. var result = [
  2686. untruncateYear(yearStr),
  2687. defaultLocaleMonthsShort.indexOf(monthStr),
  2688. parseInt(dayStr, 10),
  2689. parseInt(hourStr, 10),
  2690. parseInt(minuteStr, 10),
  2691. ];
  2692. if (secondStr) {
  2693. result.push(parseInt(secondStr, 10));
  2694. }
  2695. return result;
  2696. }
  2697. function untruncateYear(yearStr) {
  2698. var year = parseInt(yearStr, 10);
  2699. if (year <= 49) {
  2700. return 2000 + year;
  2701. } else if (year <= 999) {
  2702. return 1900 + year;
  2703. }
  2704. return year;
  2705. }
  2706. function preprocessRFC2822(s) {
  2707. // Remove comments and folding whitespace and replace multiple-spaces with a single space
  2708. return s
  2709. .replace(/\([^()]*\)|[\n\t]/g, ' ')
  2710. .replace(/(\s\s+)/g, ' ')
  2711. .replace(/^\s\s*/, '')
  2712. .replace(/\s\s*$/, '');
  2713. }
  2714. function checkWeekday(weekdayStr, parsedInput, config) {
  2715. if (weekdayStr) {
  2716. // TODO: Replace the vanilla JS Date object with an independent day-of-week check.
  2717. var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr),
  2718. weekdayActual = new Date(
  2719. parsedInput[0],
  2720. parsedInput[1],
  2721. parsedInput[2]
  2722. ).getDay();
  2723. if (weekdayProvided !== weekdayActual) {
  2724. getParsingFlags(config).weekdayMismatch = true;
  2725. config._isValid = false;
  2726. return false;
  2727. }
  2728. }
  2729. return true;
  2730. }
  2731. function calculateOffset(obsOffset, militaryOffset, numOffset) {
  2732. if (obsOffset) {
  2733. return obsOffsets[obsOffset];
  2734. } else if (militaryOffset) {
  2735. // the only allowed military tz is Z
  2736. return 0;
  2737. } else {
  2738. var hm = parseInt(numOffset, 10),
  2739. m = hm % 100,
  2740. h = (hm - m) / 100;
  2741. return h * 60 + m;
  2742. }
  2743. }
  2744. // date and time from ref 2822 format
  2745. function configFromRFC2822(config) {
  2746. var match = rfc2822.exec(preprocessRFC2822(config._i)),
  2747. parsedArray;
  2748. if (match) {
  2749. parsedArray = extractFromRFC2822Strings(
  2750. match[4],
  2751. match[3],
  2752. match[2],
  2753. match[5],
  2754. match[6],
  2755. match[7]
  2756. );
  2757. if (!checkWeekday(match[1], parsedArray, config)) {
  2758. return;
  2759. }
  2760. config._a = parsedArray;
  2761. config._tzm = calculateOffset(match[8], match[9], match[10]);
  2762. config._d = createUTCDate.apply(null, config._a);
  2763. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  2764. getParsingFlags(config).rfc2822 = true;
  2765. } else {
  2766. config._isValid = false;
  2767. }
  2768. }
  2769. // date from 1) ASP.NET, 2) ISO, 3) RFC 2822 formats, or 4) optional fallback if parsing isn't strict
  2770. function configFromString(config) {
  2771. var matched = aspNetJsonRegex.exec(config._i);
  2772. if (matched !== null) {
  2773. config._d = new Date(+matched[1]);
  2774. return;
  2775. }
  2776. configFromISO(config);
  2777. if (config._isValid === false) {
  2778. delete config._isValid;
  2779. } else {
  2780. return;
  2781. }
  2782. configFromRFC2822(config);
  2783. if (config._isValid === false) {
  2784. delete config._isValid;
  2785. } else {
  2786. return;
  2787. }
  2788. if (config._strict) {
  2789. config._isValid = false;
  2790. } else {
  2791. // Final attempt, use Input Fallback
  2792. hooks.createFromInputFallback(config);
  2793. }
  2794. }
  2795. hooks.createFromInputFallback = deprecate(
  2796. 'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' +
  2797. 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' +
  2798. 'discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.',
  2799. function (config) {
  2800. config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
  2801. }
  2802. );
  2803. // Pick the first defined of two or three arguments.
  2804. function defaults(a, b, c) {
  2805. if (a != null) {
  2806. return a;
  2807. }
  2808. if (b != null) {
  2809. return b;
  2810. }
  2811. return c;
  2812. }
  2813. function currentDateArray(config) {
  2814. // hooks is actually the exported moment object
  2815. var nowValue = new Date(hooks.now());
  2816. if (config._useUTC) {
  2817. return [
  2818. nowValue.getUTCFullYear(),
  2819. nowValue.getUTCMonth(),
  2820. nowValue.getUTCDate(),
  2821. ];
  2822. }
  2823. return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
  2824. }
  2825. // convert an array to a date.
  2826. // the array should mirror the parameters below
  2827. // note: all values past the year are optional and will default to the lowest possible value.
  2828. // [year, month, day , hour, minute, second, millisecond]
  2829. function configFromArray(config) {
  2830. var i,
  2831. date,
  2832. input = [],
  2833. currentDate,
  2834. expectedWeekday,
  2835. yearToUse;
  2836. if (config._d) {
  2837. return;
  2838. }
  2839. currentDate = currentDateArray(config);
  2840. //compute day of the year from weeks and weekdays
  2841. if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
  2842. dayOfYearFromWeekInfo(config);
  2843. }
  2844. //if the day of the year is set, figure out what it is
  2845. if (config._dayOfYear != null) {
  2846. yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
  2847. if (
  2848. config._dayOfYear > daysInYear(yearToUse) ||
  2849. config._dayOfYear === 0
  2850. ) {
  2851. getParsingFlags(config)._overflowDayOfYear = true;
  2852. }
  2853. date = createUTCDate(yearToUse, 0, config._dayOfYear);
  2854. config._a[MONTH] = date.getUTCMonth();
  2855. config._a[DATE] = date.getUTCDate();
  2856. }
  2857. // Default to current date.
  2858. // * if no year, month, day of month are given, default to today
  2859. // * if day of month is given, default month and year
  2860. // * if month is given, default only year
  2861. // * if year is given, don't default anything
  2862. for (i = 0; i < 3 && config._a[i] == null; ++i) {
  2863. config._a[i] = input[i] = currentDate[i];
  2864. }
  2865. // Zero out whatever was not defaulted, including time
  2866. for (; i < 7; i++) {
  2867. config._a[i] = input[i] =
  2868. config._a[i] == null ? (i === 2 ? 1 : 0) : config._a[i];
  2869. }
  2870. // Check for 24:00:00.000
  2871. if (
  2872. config._a[HOUR] === 24 &&
  2873. config._a[MINUTE] === 0 &&
  2874. config._a[SECOND] === 0 &&
  2875. config._a[MILLISECOND] === 0
  2876. ) {
  2877. config._nextDay = true;
  2878. config._a[HOUR] = 0;
  2879. }
  2880. config._d = (config._useUTC ? createUTCDate : createDate).apply(
  2881. null,
  2882. input
  2883. );
  2884. expectedWeekday = config._useUTC
  2885. ? config._d.getUTCDay()
  2886. : config._d.getDay();
  2887. // Apply timezone offset from input. The actual utcOffset can be changed
  2888. // with parseZone.
  2889. if (config._tzm != null) {
  2890. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  2891. }
  2892. if (config._nextDay) {
  2893. config._a[HOUR] = 24;
  2894. }
  2895. // check for mismatching day of week
  2896. if (
  2897. config._w &&
  2898. typeof config._w.d !== 'undefined' &&
  2899. config._w.d !== expectedWeekday
  2900. ) {
  2901. getParsingFlags(config).weekdayMismatch = true;
  2902. }
  2903. }
  2904. function dayOfYearFromWeekInfo(config) {
  2905. var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow, curWeek;
  2906. w = config._w;
  2907. if (w.GG != null || w.W != null || w.E != null) {
  2908. dow = 1;
  2909. doy = 4;
  2910. // TODO: We need to take the current isoWeekYear, but that depends on
  2911. // how we interpret now (local, utc, fixed offset). So create
  2912. // a now version of current config (take local/utc/offset flags, and
  2913. // create now).
  2914. weekYear = defaults(
  2915. w.GG,
  2916. config._a[YEAR],
  2917. weekOfYear(createLocal(), 1, 4).year
  2918. );
  2919. week = defaults(w.W, 1);
  2920. weekday = defaults(w.E, 1);
  2921. if (weekday < 1 || weekday > 7) {
  2922. weekdayOverflow = true;
  2923. }
  2924. } else {
  2925. dow = config._locale._week.dow;
  2926. doy = config._locale._week.doy;
  2927. curWeek = weekOfYear(createLocal(), dow, doy);
  2928. weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
  2929. // Default to current week.
  2930. week = defaults(w.w, curWeek.week);
  2931. if (w.d != null) {
  2932. // weekday -- low day numbers are considered next week
  2933. weekday = w.d;
  2934. if (weekday < 0 || weekday > 6) {
  2935. weekdayOverflow = true;
  2936. }
  2937. } else if (w.e != null) {
  2938. // local weekday -- counting starts from beginning of week
  2939. weekday = w.e + dow;
  2940. if (w.e < 0 || w.e > 6) {
  2941. weekdayOverflow = true;
  2942. }
  2943. } else {
  2944. // default to beginning of week
  2945. weekday = dow;
  2946. }
  2947. }
  2948. if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
  2949. getParsingFlags(config)._overflowWeeks = true;
  2950. } else if (weekdayOverflow != null) {
  2951. getParsingFlags(config)._overflowWeekday = true;
  2952. } else {
  2953. temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
  2954. config._a[YEAR] = temp.year;
  2955. config._dayOfYear = temp.dayOfYear;
  2956. }
  2957. }
  2958. // constant that refers to the ISO standard
  2959. hooks.ISO_8601 = function () {};
  2960. // constant that refers to the RFC 2822 form
  2961. hooks.RFC_2822 = function () {};
  2962. // date from string and format string
  2963. function configFromStringAndFormat(config) {
  2964. // TODO: Move this to another part of the creation flow to prevent circular deps
  2965. if (config._f === hooks.ISO_8601) {
  2966. configFromISO(config);
  2967. return;
  2968. }
  2969. if (config._f === hooks.RFC_2822) {
  2970. configFromRFC2822(config);
  2971. return;
  2972. }
  2973. config._a = [];
  2974. getParsingFlags(config).empty = true;
  2975. // This array is used to make a Date, either with `new Date` or `Date.UTC`
  2976. var string = '' + config._i,
  2977. i,
  2978. parsedInput,
  2979. tokens,
  2980. token,
  2981. skipped,
  2982. stringLength = string.length,
  2983. totalParsedInputLength = 0,
  2984. era,
  2985. tokenLen;
  2986. tokens =
  2987. expandFormat(config._f, config._locale).match(formattingTokens) || [];
  2988. tokenLen = tokens.length;
  2989. for (i = 0; i < tokenLen; i++) {
  2990. token = tokens[i];
  2991. parsedInput = (string.match(getParseRegexForToken(token, config)) ||
  2992. [])[0];
  2993. if (parsedInput) {
  2994. skipped = string.substr(0, string.indexOf(parsedInput));
  2995. if (skipped.length > 0) {
  2996. getParsingFlags(config).unusedInput.push(skipped);
  2997. }
  2998. string = string.slice(
  2999. string.indexOf(parsedInput) + parsedInput.length
  3000. );
  3001. totalParsedInputLength += parsedInput.length;
  3002. }
  3003. // don't parse if it's not a known token
  3004. if (formatTokenFunctions[token]) {
  3005. if (parsedInput) {
  3006. getParsingFlags(config).empty = false;
  3007. } else {
  3008. getParsingFlags(config).unusedTokens.push(token);
  3009. }
  3010. addTimeToArrayFromToken(token, parsedInput, config);
  3011. } else if (config._strict && !parsedInput) {
  3012. getParsingFlags(config).unusedTokens.push(token);
  3013. }
  3014. }
  3015. // add remaining unparsed input length to the string
  3016. getParsingFlags(config).charsLeftOver =
  3017. stringLength - totalParsedInputLength;
  3018. if (string.length > 0) {
  3019. getParsingFlags(config).unusedInput.push(string);
  3020. }
  3021. // clear _12h flag if hour is <= 12
  3022. if (
  3023. config._a[HOUR] <= 12 &&
  3024. getParsingFlags(config).bigHour === true &&
  3025. config._a[HOUR] > 0
  3026. ) {
  3027. getParsingFlags(config).bigHour = undefined;
  3028. }
  3029. getParsingFlags(config).parsedDateParts = config._a.slice(0);
  3030. getParsingFlags(config).meridiem = config._meridiem;
  3031. // handle meridiem
  3032. config._a[HOUR] = meridiemFixWrap(
  3033. config._locale,
  3034. config._a[HOUR],
  3035. config._meridiem
  3036. );
  3037. // handle era
  3038. era = getParsingFlags(config).era;
  3039. if (era !== null) {
  3040. config._a[YEAR] = config._locale.erasConvertYear(era, config._a[YEAR]);
  3041. }
  3042. configFromArray(config);
  3043. checkOverflow(config);
  3044. }
  3045. function meridiemFixWrap(locale, hour, meridiem) {
  3046. var isPm;
  3047. if (meridiem == null) {
  3048. // nothing to do
  3049. return hour;
  3050. }
  3051. if (locale.meridiemHour != null) {
  3052. return locale.meridiemHour(hour, meridiem);
  3053. } else if (locale.isPM != null) {
  3054. // Fallback
  3055. isPm = locale.isPM(meridiem);
  3056. if (isPm && hour < 12) {
  3057. hour += 12;
  3058. }
  3059. if (!isPm && hour === 12) {
  3060. hour = 0;
  3061. }
  3062. return hour;
  3063. } else {
  3064. // this is not supposed to happen
  3065. return hour;
  3066. }
  3067. }
  3068. // date from string and array of format strings
  3069. function configFromStringAndArray(config) {
  3070. var tempConfig,
  3071. bestMoment,
  3072. scoreToBeat,
  3073. i,
  3074. currentScore,
  3075. validFormatFound,
  3076. bestFormatIsValid = false,
  3077. configfLen = config._f.length;
  3078. if (configfLen === 0) {
  3079. getParsingFlags(config).invalidFormat = true;
  3080. config._d = new Date(NaN);
  3081. return;
  3082. }
  3083. for (i = 0; i < configfLen; i++) {
  3084. currentScore = 0;
  3085. validFormatFound = false;
  3086. tempConfig = copyConfig({}, config);
  3087. if (config._useUTC != null) {
  3088. tempConfig._useUTC = config._useUTC;
  3089. }
  3090. tempConfig._f = config._f[i];
  3091. configFromStringAndFormat(tempConfig);
  3092. if (isValid(tempConfig)) {
  3093. validFormatFound = true;
  3094. }
  3095. // if there is any input that was not parsed add a penalty for that format
  3096. currentScore += getParsingFlags(tempConfig).charsLeftOver;
  3097. //or tokens
  3098. currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
  3099. getParsingFlags(tempConfig).score = currentScore;
  3100. if (!bestFormatIsValid) {
  3101. if (
  3102. scoreToBeat == null ||
  3103. currentScore < scoreToBeat ||
  3104. validFormatFound
  3105. ) {
  3106. scoreToBeat = currentScore;
  3107. bestMoment = tempConfig;
  3108. if (validFormatFound) {
  3109. bestFormatIsValid = true;
  3110. }
  3111. }
  3112. } else {
  3113. if (currentScore < scoreToBeat) {
  3114. scoreToBeat = currentScore;
  3115. bestMoment = tempConfig;
  3116. }
  3117. }
  3118. }
  3119. extend(config, bestMoment || tempConfig);
  3120. }
  3121. function configFromObject(config) {
  3122. if (config._d) {
  3123. return;
  3124. }
  3125. var i = normalizeObjectUnits(config._i),
  3126. dayOrDate = i.day === undefined ? i.date : i.day;
  3127. config._a = map(
  3128. [i.year, i.month, dayOrDate, i.hour, i.minute, i.second, i.millisecond],
  3129. function (obj) {
  3130. return obj && parseInt(obj, 10);
  3131. }
  3132. );
  3133. configFromArray(config);
  3134. }
  3135. function createFromConfig(config) {
  3136. var res = new Moment(checkOverflow(prepareConfig(config)));
  3137. if (res._nextDay) {
  3138. // Adding is smart enough around DST
  3139. res.add(1, 'd');
  3140. res._nextDay = undefined;
  3141. }
  3142. return res;
  3143. }
  3144. function prepareConfig(config) {
  3145. var input = config._i,
  3146. format = config._f;
  3147. config._locale = config._locale || getLocale(config._l);
  3148. if (input === null || (format === undefined && input === '')) {
  3149. return createInvalid({ nullInput: true });
  3150. }
  3151. if (typeof input === 'string') {
  3152. config._i = input = config._locale.preparse(input);
  3153. }
  3154. if (isMoment(input)) {
  3155. return new Moment(checkOverflow(input));
  3156. } else if (isDate(input)) {
  3157. config._d = input;
  3158. } else if (isArray(format)) {
  3159. configFromStringAndArray(config);
  3160. } else if (format) {
  3161. configFromStringAndFormat(config);
  3162. } else {
  3163. configFromInput(config);
  3164. }
  3165. if (!isValid(config)) {
  3166. config._d = null;
  3167. }
  3168. return config;
  3169. }
  3170. function configFromInput(config) {
  3171. var input = config._i;
  3172. if (isUndefined(input)) {
  3173. config._d = new Date(hooks.now());
  3174. } else if (isDate(input)) {
  3175. config._d = new Date(input.valueOf());
  3176. } else if (typeof input === 'string') {
  3177. configFromString(config);
  3178. } else if (isArray(input)) {
  3179. config._a = map(input.slice(0), function (obj) {
  3180. return parseInt(obj, 10);
  3181. });
  3182. configFromArray(config);
  3183. } else if (isObject(input)) {
  3184. configFromObject(config);
  3185. } else if (isNumber(input)) {
  3186. // from milliseconds
  3187. config._d = new Date(input);
  3188. } else {
  3189. hooks.createFromInputFallback(config);
  3190. }
  3191. }
  3192. function createLocalOrUTC(input, format, locale, strict, isUTC) {
  3193. var c = {};
  3194. if (format === true || format === false) {
  3195. strict = format;
  3196. format = undefined;
  3197. }
  3198. if (locale === true || locale === false) {
  3199. strict = locale;
  3200. locale = undefined;
  3201. }
  3202. if (
  3203. (isObject(input) && isObjectEmpty(input)) ||
  3204. (isArray(input) && input.length === 0)
  3205. ) {
  3206. input = undefined;
  3207. }
  3208. // object construction must be done this way.
  3209. // https://github.com/moment/moment/issues/1423
  3210. c._isAMomentObject = true;
  3211. c._useUTC = c._isUTC = isUTC;
  3212. c._l = locale;
  3213. c._i = input;
  3214. c._f = format;
  3215. c._strict = strict;
  3216. return createFromConfig(c);
  3217. }
  3218. function createLocal(input, format, locale, strict) {
  3219. return createLocalOrUTC(input, format, locale, strict, false);
  3220. }
  3221. var prototypeMin = deprecate(
  3222. 'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',
  3223. function () {
  3224. var other = createLocal.apply(null, arguments);
  3225. if (this.isValid() && other.isValid()) {
  3226. return other < this ? this : other;
  3227. } else {
  3228. return createInvalid();
  3229. }
  3230. }
  3231. ),
  3232. prototypeMax = deprecate(
  3233. 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',
  3234. function () {
  3235. var other = createLocal.apply(null, arguments);
  3236. if (this.isValid() && other.isValid()) {
  3237. return other > this ? this : other;
  3238. } else {
  3239. return createInvalid();
  3240. }
  3241. }
  3242. );
  3243. // Pick a moment m from moments so that m[fn](other) is true for all
  3244. // other. This relies on the function fn to be transitive.
  3245. //
  3246. // moments should either be an array of moment objects or an array, whose
  3247. // first element is an array of moment objects.
  3248. function pickBy(fn, moments) {
  3249. var res, i;
  3250. if (moments.length === 1 && isArray(moments[0])) {
  3251. moments = moments[0];
  3252. }
  3253. if (!moments.length) {
  3254. return createLocal();
  3255. }
  3256. res = moments[0];
  3257. for (i = 1; i < moments.length; ++i) {
  3258. if (!moments[i].isValid() || moments[i][fn](res)) {
  3259. res = moments[i];
  3260. }
  3261. }
  3262. return res;
  3263. }
  3264. // TODO: Use [].sort instead?
  3265. function min() {
  3266. var args = [].slice.call(arguments, 0);
  3267. return pickBy('isBefore', args);
  3268. }
  3269. function max() {
  3270. var args = [].slice.call(arguments, 0);
  3271. return pickBy('isAfter', args);
  3272. }
  3273. var now = function () {
  3274. return Date.now ? Date.now() : +new Date();
  3275. };
  3276. var ordering = [
  3277. 'year',
  3278. 'quarter',
  3279. 'month',
  3280. 'week',
  3281. 'day',
  3282. 'hour',
  3283. 'minute',
  3284. 'second',
  3285. 'millisecond',
  3286. ];
  3287. function isDurationValid(m) {
  3288. var key,
  3289. unitHasDecimal = false,
  3290. i,
  3291. orderLen = ordering.length;
  3292. for (key in m) {
  3293. if (
  3294. hasOwnProp(m, key) &&
  3295. !(
  3296. indexOf.call(ordering, key) !== -1 &&
  3297. (m[key] == null || !isNaN(m[key]))
  3298. )
  3299. ) {
  3300. return false;
  3301. }
  3302. }
  3303. for (i = 0; i < orderLen; ++i) {
  3304. if (m[ordering[i]]) {
  3305. if (unitHasDecimal) {
  3306. return false; // only allow non-integers for smallest unit
  3307. }
  3308. if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
  3309. unitHasDecimal = true;
  3310. }
  3311. }
  3312. }
  3313. return true;
  3314. }
  3315. function isValid$1() {
  3316. return this._isValid;
  3317. }
  3318. function createInvalid$1() {
  3319. return createDuration(NaN);
  3320. }
  3321. function Duration(duration) {
  3322. var normalizedInput = normalizeObjectUnits(duration),
  3323. years = normalizedInput.year || 0,
  3324. quarters = normalizedInput.quarter || 0,
  3325. months = normalizedInput.month || 0,
  3326. weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
  3327. days = normalizedInput.day || 0,
  3328. hours = normalizedInput.hour || 0,
  3329. minutes = normalizedInput.minute || 0,
  3330. seconds = normalizedInput.second || 0,
  3331. milliseconds = normalizedInput.millisecond || 0;
  3332. this._isValid = isDurationValid(normalizedInput);
  3333. // representation for dateAddRemove
  3334. this._milliseconds =
  3335. +milliseconds +
  3336. seconds * 1e3 + // 1000
  3337. minutes * 6e4 + // 1000 * 60
  3338. hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
  3339. // Because of dateAddRemove treats 24 hours as different from a
  3340. // day when working around DST, we need to store them separately
  3341. this._days = +days + weeks * 7;
  3342. // It is impossible to translate months into days without knowing
  3343. // which months you are are talking about, so we have to store
  3344. // it separately.
  3345. this._months = +months + quarters * 3 + years * 12;
  3346. this._data = {};
  3347. this._locale = getLocale();
  3348. this._bubble();
  3349. }
  3350. function isDuration(obj) {
  3351. return obj instanceof Duration;
  3352. }
  3353. function absRound(number) {
  3354. if (number < 0) {
  3355. return Math.round(-1 * number) * -1;
  3356. } else {
  3357. return Math.round(number);
  3358. }
  3359. }
  3360. // compare two arrays, return the number of differences
  3361. function compareArrays(array1, array2, dontConvert) {
  3362. var len = Math.min(array1.length, array2.length),
  3363. lengthDiff = Math.abs(array1.length - array2.length),
  3364. diffs = 0,
  3365. i;
  3366. for (i = 0; i < len; i++) {
  3367. if (
  3368. (dontConvert && array1[i] !== array2[i]) ||
  3369. (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))
  3370. ) {
  3371. diffs++;
  3372. }
  3373. }
  3374. return diffs + lengthDiff;
  3375. }
  3376. // FORMATTING
  3377. function offset(token, separator) {
  3378. addFormatToken(token, 0, 0, function () {
  3379. var offset = this.utcOffset(),
  3380. sign = '+';
  3381. if (offset < 0) {
  3382. offset = -offset;
  3383. sign = '-';
  3384. }
  3385. return (
  3386. sign +
  3387. zeroFill(~~(offset / 60), 2) +
  3388. separator +
  3389. zeroFill(~~offset % 60, 2)
  3390. );
  3391. });
  3392. }
  3393. offset('Z', ':');
  3394. offset('ZZ', '');
  3395. // PARSING
  3396. addRegexToken('Z', matchShortOffset);
  3397. addRegexToken('ZZ', matchShortOffset);
  3398. addParseToken(['Z', 'ZZ'], function (input, array, config) {
  3399. config._useUTC = true;
  3400. config._tzm = offsetFromString(matchShortOffset, input);
  3401. });
  3402. // HELPERS
  3403. // timezone chunker
  3404. // '+10:00' > ['10', '00']
  3405. // '-1530' > ['-15', '30']
  3406. var chunkOffset = /([\+\-]|\d\d)/gi;
  3407. function offsetFromString(matcher, string) {
  3408. var matches = (string || '').match(matcher),
  3409. chunk,
  3410. parts,
  3411. minutes;
  3412. if (matches === null) {
  3413. return null;
  3414. }
  3415. chunk = matches[matches.length - 1] || [];
  3416. parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
  3417. minutes = +(parts[1] * 60) + toInt(parts[2]);
  3418. return minutes === 0 ? 0 : parts[0] === '+' ? minutes : -minutes;
  3419. }
  3420. // Return a moment from input, that is local/utc/zone equivalent to model.
  3421. function cloneWithOffset(input, model) {
  3422. var res, diff;
  3423. if (model._isUTC) {
  3424. res = model.clone();
  3425. diff =
  3426. (isMoment(input) || isDate(input)
  3427. ? input.valueOf()
  3428. : createLocal(input).valueOf()) - res.valueOf();
  3429. // Use low-level api, because this fn is low-level api.
  3430. res._d.setTime(res._d.valueOf() + diff);
  3431. hooks.updateOffset(res, false);
  3432. return res;
  3433. } else {
  3434. return createLocal(input).local();
  3435. }
  3436. }
  3437. function getDateOffset(m) {
  3438. // On Firefox.24 Date#getTimezoneOffset returns a floating point.
  3439. // https://github.com/moment/moment/pull/1871
  3440. return -Math.round(m._d.getTimezoneOffset());
  3441. }
  3442. // HOOKS
  3443. // This function will be called whenever a moment is mutated.
  3444. // It is intended to keep the offset in sync with the timezone.
  3445. hooks.updateOffset = function () {};
  3446. // MOMENTS
  3447. // keepLocalTime = true means only change the timezone, without
  3448. // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
  3449. // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
  3450. // +0200, so we adjust the time as needed, to be valid.
  3451. //
  3452. // Keeping the time actually adds/subtracts (one hour)
  3453. // from the actual represented time. That is why we call updateOffset
  3454. // a second time. In case it wants us to change the offset again
  3455. // _changeInProgress == true case, then we have to adjust, because
  3456. // there is no such time in the given timezone.
  3457. function getSetOffset(input, keepLocalTime, keepMinutes) {
  3458. var offset = this._offset || 0,
  3459. localAdjust;
  3460. if (!this.isValid()) {
  3461. return input != null ? this : NaN;
  3462. }
  3463. if (input != null) {
  3464. if (typeof input === 'string') {
  3465. input = offsetFromString(matchShortOffset, input);
  3466. if (input === null) {
  3467. return this;
  3468. }
  3469. } else if (Math.abs(input) < 16 && !keepMinutes) {
  3470. input = input * 60;
  3471. }
  3472. if (!this._isUTC && keepLocalTime) {
  3473. localAdjust = getDateOffset(this);
  3474. }
  3475. this._offset = input;
  3476. this._isUTC = true;
  3477. if (localAdjust != null) {
  3478. this.add(localAdjust, 'm');
  3479. }
  3480. if (offset !== input) {
  3481. if (!keepLocalTime || this._changeInProgress) {
  3482. addSubtract(
  3483. this,
  3484. createDuration(input - offset, 'm'),
  3485. 1,
  3486. false
  3487. );
  3488. } else if (!this._changeInProgress) {
  3489. this._changeInProgress = true;
  3490. hooks.updateOffset(this, true);
  3491. this._changeInProgress = null;
  3492. }
  3493. }
  3494. return this;
  3495. } else {
  3496. return this._isUTC ? offset : getDateOffset(this);
  3497. }
  3498. }
  3499. function getSetZone(input, keepLocalTime) {
  3500. if (input != null) {
  3501. if (typeof input !== 'string') {
  3502. input = -input;
  3503. }
  3504. this.utcOffset(input, keepLocalTime);
  3505. return this;
  3506. } else {
  3507. return -this.utcOffset();
  3508. }
  3509. }
  3510. function setOffsetToUTC(keepLocalTime) {
  3511. return this.utcOffset(0, keepLocalTime);
  3512. }
  3513. function setOffsetToLocal(keepLocalTime) {
  3514. if (this._isUTC) {
  3515. this.utcOffset(0, keepLocalTime);
  3516. this._isUTC = false;
  3517. if (keepLocalTime) {
  3518. this.subtract(getDateOffset(this), 'm');
  3519. }
  3520. }
  3521. return this;
  3522. }
  3523. function setOffsetToParsedOffset() {
  3524. if (this._tzm != null) {
  3525. this.utcOffset(this._tzm, false, true);
  3526. } else if (typeof this._i === 'string') {
  3527. var tZone = offsetFromString(matchOffset, this._i);
  3528. if (tZone != null) {
  3529. this.utcOffset(tZone);
  3530. } else {
  3531. this.utcOffset(0, true);
  3532. }
  3533. }
  3534. return this;
  3535. }
  3536. function hasAlignedHourOffset(input) {
  3537. if (!this.isValid()) {
  3538. return false;
  3539. }
  3540. input = input ? createLocal(input).utcOffset() : 0;
  3541. return (this.utcOffset() - input) % 60 === 0;
  3542. }
  3543. function isDaylightSavingTime() {
  3544. return (
  3545. this.utcOffset() > this.clone().month(0).utcOffset() ||
  3546. this.utcOffset() > this.clone().month(5).utcOffset()
  3547. );
  3548. }
  3549. function isDaylightSavingTimeShifted() {
  3550. if (!isUndefined(this._isDSTShifted)) {
  3551. return this._isDSTShifted;
  3552. }
  3553. var c = {},
  3554. other;
  3555. copyConfig(c, this);
  3556. c = prepareConfig(c);
  3557. if (c._a) {
  3558. other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
  3559. this._isDSTShifted =
  3560. this.isValid() && compareArrays(c._a, other.toArray()) > 0;
  3561. } else {
  3562. this._isDSTShifted = false;
  3563. }
  3564. return this._isDSTShifted;
  3565. }
  3566. function isLocal() {
  3567. return this.isValid() ? !this._isUTC : false;
  3568. }
  3569. function isUtcOffset() {
  3570. return this.isValid() ? this._isUTC : false;
  3571. }
  3572. function isUtc() {
  3573. return this.isValid() ? this._isUTC && this._offset === 0 : false;
  3574. }
  3575. // ASP.NET json date format regex
  3576. var aspNetRegex = /^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,
  3577. // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
  3578. // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
  3579. // and further modified to allow for strings containing both week and day
  3580. isoRegex =
  3581. /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
  3582. function createDuration(input, key) {
  3583. var duration = input,
  3584. // matching against regexp is expensive, do it on demand
  3585. match = null,
  3586. sign,
  3587. ret,
  3588. diffRes;
  3589. if (isDuration(input)) {
  3590. duration = {
  3591. ms: input._milliseconds,
  3592. d: input._days,
  3593. M: input._months,
  3594. };
  3595. } else if (isNumber(input) || !isNaN(+input)) {
  3596. duration = {};
  3597. if (key) {
  3598. duration[key] = +input;
  3599. } else {
  3600. duration.milliseconds = +input;
  3601. }
  3602. } else if ((match = aspNetRegex.exec(input))) {
  3603. sign = match[1] === '-' ? -1 : 1;
  3604. duration = {
  3605. y: 0,
  3606. d: toInt(match[DATE]) * sign,
  3607. h: toInt(match[HOUR]) * sign,
  3608. m: toInt(match[MINUTE]) * sign,
  3609. s: toInt(match[SECOND]) * sign,
  3610. ms: toInt(absRound(match[MILLISECOND] * 1000)) * sign, // the millisecond decimal point is included in the match
  3611. };
  3612. } else if ((match = isoRegex.exec(input))) {
  3613. sign = match[1] === '-' ? -1 : 1;
  3614. duration = {
  3615. y: parseIso(match[2], sign),
  3616. M: parseIso(match[3], sign),
  3617. w: parseIso(match[4], sign),
  3618. d: parseIso(match[5], sign),
  3619. h: parseIso(match[6], sign),
  3620. m: parseIso(match[7], sign),
  3621. s: parseIso(match[8], sign),
  3622. };
  3623. } else if (duration == null) {
  3624. // checks for null or undefined
  3625. duration = {};
  3626. } else if (
  3627. typeof duration === 'object' &&
  3628. ('from' in duration || 'to' in duration)
  3629. ) {
  3630. diffRes = momentsDifference(
  3631. createLocal(duration.from),
  3632. createLocal(duration.to)
  3633. );
  3634. duration = {};
  3635. duration.ms = diffRes.milliseconds;
  3636. duration.M = diffRes.months;
  3637. }
  3638. ret = new Duration(duration);
  3639. if (isDuration(input) && hasOwnProp(input, '_locale')) {
  3640. ret._locale = input._locale;
  3641. }
  3642. if (isDuration(input) && hasOwnProp(input, '_isValid')) {
  3643. ret._isValid = input._isValid;
  3644. }
  3645. return ret;
  3646. }
  3647. createDuration.fn = Duration.prototype;
  3648. createDuration.invalid = createInvalid$1;
  3649. function parseIso(inp, sign) {
  3650. // We'd normally use ~~inp for this, but unfortunately it also
  3651. // converts floats to ints.
  3652. // inp may be undefined, so careful calling replace on it.
  3653. var res = inp && parseFloat(inp.replace(',', '.'));
  3654. // apply sign while we're at it
  3655. return (isNaN(res) ? 0 : res) * sign;
  3656. }
  3657. function positiveMomentsDifference(base, other) {
  3658. var res = {};
  3659. res.months =
  3660. other.month() - base.month() + (other.year() - base.year()) * 12;
  3661. if (base.clone().add(res.months, 'M').isAfter(other)) {
  3662. --res.months;
  3663. }
  3664. res.milliseconds = +other - +base.clone().add(res.months, 'M');
  3665. return res;
  3666. }
  3667. function momentsDifference(base, other) {
  3668. var res;
  3669. if (!(base.isValid() && other.isValid())) {
  3670. return { milliseconds: 0, months: 0 };
  3671. }
  3672. other = cloneWithOffset(other, base);
  3673. if (base.isBefore(other)) {
  3674. res = positiveMomentsDifference(base, other);
  3675. } else {
  3676. res = positiveMomentsDifference(other, base);
  3677. res.milliseconds = -res.milliseconds;
  3678. res.months = -res.months;
  3679. }
  3680. return res;
  3681. }
  3682. // TODO: remove 'name' arg after deprecation is removed
  3683. function createAdder(direction, name) {
  3684. return function (val, period) {
  3685. var dur, tmp;
  3686. //invert the arguments, but complain about it
  3687. if (period !== null && !isNaN(+period)) {
  3688. deprecateSimple(
  3689. name,
  3690. 'moment().' +
  3691. name +
  3692. '(period, number) is deprecated. Please use moment().' +
  3693. name +
  3694. '(number, period). ' +
  3695. 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.'
  3696. );
  3697. tmp = val;
  3698. val = period;
  3699. period = tmp;
  3700. }
  3701. dur = createDuration(val, period);
  3702. addSubtract(this, dur, direction);
  3703. return this;
  3704. };
  3705. }
  3706. function addSubtract(mom, duration, isAdding, updateOffset) {
  3707. var milliseconds = duration._milliseconds,
  3708. days = absRound(duration._days),
  3709. months = absRound(duration._months);
  3710. if (!mom.isValid()) {
  3711. // No op
  3712. return;
  3713. }
  3714. updateOffset = updateOffset == null ? true : updateOffset;
  3715. if (months) {
  3716. setMonth(mom, get(mom, 'Month') + months * isAdding);
  3717. }
  3718. if (days) {
  3719. set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
  3720. }
  3721. if (milliseconds) {
  3722. mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
  3723. }
  3724. if (updateOffset) {
  3725. hooks.updateOffset(mom, days || months);
  3726. }
  3727. }
  3728. var add = createAdder(1, 'add'),
  3729. subtract = createAdder(-1, 'subtract');
  3730. function isString(input) {
  3731. return typeof input === 'string' || input instanceof String;
  3732. }
  3733. // type MomentInput = Moment | Date | string | number | (number | string)[] | MomentInputObject | void; // null | undefined
  3734. function isMomentInput(input) {
  3735. return (
  3736. isMoment(input) ||
  3737. isDate(input) ||
  3738. isString(input) ||
  3739. isNumber(input) ||
  3740. isNumberOrStringArray(input) ||
  3741. isMomentInputObject(input) ||
  3742. input === null ||
  3743. input === undefined
  3744. );
  3745. }
  3746. function isMomentInputObject(input) {
  3747. var objectTest = isObject(input) && !isObjectEmpty(input),
  3748. propertyTest = false,
  3749. properties = [
  3750. 'years',
  3751. 'year',
  3752. 'y',
  3753. 'months',
  3754. 'month',
  3755. 'M',
  3756. 'days',
  3757. 'day',
  3758. 'd',
  3759. 'dates',
  3760. 'date',
  3761. 'D',
  3762. 'hours',
  3763. 'hour',
  3764. 'h',
  3765. 'minutes',
  3766. 'minute',
  3767. 'm',
  3768. 'seconds',
  3769. 'second',
  3770. 's',
  3771. 'milliseconds',
  3772. 'millisecond',
  3773. 'ms',
  3774. ],
  3775. i,
  3776. property,
  3777. propertyLen = properties.length;
  3778. for (i = 0; i < propertyLen; i += 1) {
  3779. property = properties[i];
  3780. propertyTest = propertyTest || hasOwnProp(input, property);
  3781. }
  3782. return objectTest && propertyTest;
  3783. }
  3784. function isNumberOrStringArray(input) {
  3785. var arrayTest = isArray(input),
  3786. dataTypeTest = false;
  3787. if (arrayTest) {
  3788. dataTypeTest =
  3789. input.filter(function (item) {
  3790. return !isNumber(item) && isString(input);
  3791. }).length === 0;
  3792. }
  3793. return arrayTest && dataTypeTest;
  3794. }
  3795. function isCalendarSpec(input) {
  3796. var objectTest = isObject(input) && !isObjectEmpty(input),
  3797. propertyTest = false,
  3798. properties = [
  3799. 'sameDay',
  3800. 'nextDay',
  3801. 'lastDay',
  3802. 'nextWeek',
  3803. 'lastWeek',
  3804. 'sameElse',
  3805. ],
  3806. i,
  3807. property;
  3808. for (i = 0; i < properties.length; i += 1) {
  3809. property = properties[i];
  3810. propertyTest = propertyTest || hasOwnProp(input, property);
  3811. }
  3812. return objectTest && propertyTest;
  3813. }
  3814. function getCalendarFormat(myMoment, now) {
  3815. var diff = myMoment.diff(now, 'days', true);
  3816. return diff < -6
  3817. ? 'sameElse'
  3818. : diff < -1
  3819. ? 'lastWeek'
  3820. : diff < 0
  3821. ? 'lastDay'
  3822. : diff < 1
  3823. ? 'sameDay'
  3824. : diff < 2
  3825. ? 'nextDay'
  3826. : diff < 7
  3827. ? 'nextWeek'
  3828. : 'sameElse';
  3829. }
  3830. function calendar$1(time, formats) {
  3831. // Support for single parameter, formats only overload to the calendar function
  3832. if (arguments.length === 1) {
  3833. if (!arguments[0]) {
  3834. time = undefined;
  3835. formats = undefined;
  3836. } else if (isMomentInput(arguments[0])) {
  3837. time = arguments[0];
  3838. formats = undefined;
  3839. } else if (isCalendarSpec(arguments[0])) {
  3840. formats = arguments[0];
  3841. time = undefined;
  3842. }
  3843. }
  3844. // We want to compare the start of today, vs this.
  3845. // Getting start-of-today depends on whether we're local/utc/offset or not.
  3846. var now = time || createLocal(),
  3847. sod = cloneWithOffset(now, this).startOf('day'),
  3848. format = hooks.calendarFormat(this, sod) || 'sameElse',
  3849. output =
  3850. formats &&
  3851. (isFunction(formats[format])
  3852. ? formats[format].call(this, now)
  3853. : formats[format]);
  3854. return this.format(
  3855. output || this.localeData().calendar(format, this, createLocal(now))
  3856. );
  3857. }
  3858. function clone() {
  3859. return new Moment(this);
  3860. }
  3861. function isAfter(input, units) {
  3862. var localInput = isMoment(input) ? input : createLocal(input);
  3863. if (!(this.isValid() && localInput.isValid())) {
  3864. return false;
  3865. }
  3866. units = normalizeUnits(units) || 'millisecond';
  3867. if (units === 'millisecond') {
  3868. return this.valueOf() > localInput.valueOf();
  3869. } else {
  3870. return localInput.valueOf() < this.clone().startOf(units).valueOf();
  3871. }
  3872. }
  3873. function isBefore(input, units) {
  3874. var localInput = isMoment(input) ? input : createLocal(input);
  3875. if (!(this.isValid() && localInput.isValid())) {
  3876. return false;
  3877. }
  3878. units = normalizeUnits(units) || 'millisecond';
  3879. if (units === 'millisecond') {
  3880. return this.valueOf() < localInput.valueOf();
  3881. } else {
  3882. return this.clone().endOf(units).valueOf() < localInput.valueOf();
  3883. }
  3884. }
  3885. function isBetween(from, to, units, inclusivity) {
  3886. var localFrom = isMoment(from) ? from : createLocal(from),
  3887. localTo = isMoment(to) ? to : createLocal(to);
  3888. if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
  3889. return false;
  3890. }
  3891. inclusivity = inclusivity || '()';
  3892. return (
  3893. (inclusivity[0] === '('
  3894. ? this.isAfter(localFrom, units)
  3895. : !this.isBefore(localFrom, units)) &&
  3896. (inclusivity[1] === ')'
  3897. ? this.isBefore(localTo, units)
  3898. : !this.isAfter(localTo, units))
  3899. );
  3900. }
  3901. function isSame(input, units) {
  3902. var localInput = isMoment(input) ? input : createLocal(input),
  3903. inputMs;
  3904. if (!(this.isValid() && localInput.isValid())) {
  3905. return false;
  3906. }
  3907. units = normalizeUnits(units) || 'millisecond';
  3908. if (units === 'millisecond') {
  3909. return this.valueOf() === localInput.valueOf();
  3910. } else {
  3911. inputMs = localInput.valueOf();
  3912. return (
  3913. this.clone().startOf(units).valueOf() <= inputMs &&
  3914. inputMs <= this.clone().endOf(units).valueOf()
  3915. );
  3916. }
  3917. }
  3918. function isSameOrAfter(input, units) {
  3919. return this.isSame(input, units) || this.isAfter(input, units);
  3920. }
  3921. function isSameOrBefore(input, units) {
  3922. return this.isSame(input, units) || this.isBefore(input, units);
  3923. }
  3924. function diff(input, units, asFloat) {
  3925. var that, zoneDelta, output;
  3926. if (!this.isValid()) {
  3927. return NaN;
  3928. }
  3929. that = cloneWithOffset(input, this);
  3930. if (!that.isValid()) {
  3931. return NaN;
  3932. }
  3933. zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
  3934. units = normalizeUnits(units);
  3935. switch (units) {
  3936. case 'year':
  3937. output = monthDiff(this, that) / 12;
  3938. break;
  3939. case 'month':
  3940. output = monthDiff(this, that);
  3941. break;
  3942. case 'quarter':
  3943. output = monthDiff(this, that) / 3;
  3944. break;
  3945. case 'second':
  3946. output = (this - that) / 1e3;
  3947. break; // 1000
  3948. case 'minute':
  3949. output = (this - that) / 6e4;
  3950. break; // 1000 * 60
  3951. case 'hour':
  3952. output = (this - that) / 36e5;
  3953. break; // 1000 * 60 * 60
  3954. case 'day':
  3955. output = (this - that - zoneDelta) / 864e5;
  3956. break; // 1000 * 60 * 60 * 24, negate dst
  3957. case 'week':
  3958. output = (this - that - zoneDelta) / 6048e5;
  3959. break; // 1000 * 60 * 60 * 24 * 7, negate dst
  3960. default:
  3961. output = this - that;
  3962. }
  3963. return asFloat ? output : absFloor(output);
  3964. }
  3965. function monthDiff(a, b) {
  3966. if (a.date() < b.date()) {
  3967. // end-of-month calculations work correct when the start month has more
  3968. // days than the end month.
  3969. return -monthDiff(b, a);
  3970. }
  3971. // difference in months
  3972. var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month()),
  3973. // b is in (anchor - 1 month, anchor + 1 month)
  3974. anchor = a.clone().add(wholeMonthDiff, 'months'),
  3975. anchor2,
  3976. adjust;
  3977. if (b - anchor < 0) {
  3978. anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
  3979. // linear across the month
  3980. adjust = (b - anchor) / (anchor - anchor2);
  3981. } else {
  3982. anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
  3983. // linear across the month
  3984. adjust = (b - anchor) / (anchor2 - anchor);
  3985. }
  3986. //check for negative zero, return zero if negative zero
  3987. return -(wholeMonthDiff + adjust) || 0;
  3988. }
  3989. hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
  3990. hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
  3991. function toString() {
  3992. return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
  3993. }
  3994. function toISOString(keepOffset) {
  3995. if (!this.isValid()) {
  3996. return null;
  3997. }
  3998. var utc = keepOffset !== true,
  3999. m = utc ? this.clone().utc() : this;
  4000. if (m.year() < 0 || m.year() > 9999) {
  4001. return formatMoment(
  4002. m,
  4003. utc
  4004. ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]'
  4005. : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ'
  4006. );
  4007. }
  4008. if (isFunction(Date.prototype.toISOString)) {
  4009. // native implementation is ~50x faster, use it when we can
  4010. if (utc) {
  4011. return this.toDate().toISOString();
  4012. } else {
  4013. return new Date(this.valueOf() + this.utcOffset() * 60 * 1000)
  4014. .toISOString()
  4015. .replace('Z', formatMoment(m, 'Z'));
  4016. }
  4017. }
  4018. return formatMoment(
  4019. m,
  4020. utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ'
  4021. );
  4022. }
  4023. /**
  4024. * Return a human readable representation of a moment that can
  4025. * also be evaluated to get a new moment which is the same
  4026. *
  4027. * @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects
  4028. */
  4029. function inspect() {
  4030. if (!this.isValid()) {
  4031. return 'moment.invalid(/* ' + this._i + ' */)';
  4032. }
  4033. var func = 'moment',
  4034. zone = '',
  4035. prefix,
  4036. year,
  4037. datetime,
  4038. suffix;
  4039. if (!this.isLocal()) {
  4040. func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
  4041. zone = 'Z';
  4042. }
  4043. prefix = '[' + func + '("]';
  4044. year = 0 <= this.year() && this.year() <= 9999 ? 'YYYY' : 'YYYYYY';
  4045. datetime = '-MM-DD[T]HH:mm:ss.SSS';
  4046. suffix = zone + '[")]';
  4047. return this.format(prefix + year + datetime + suffix);
  4048. }
  4049. function format(inputString) {
  4050. if (!inputString) {
  4051. inputString = this.isUtc()
  4052. ? hooks.defaultFormatUtc
  4053. : hooks.defaultFormat;
  4054. }
  4055. var output = formatMoment(this, inputString);
  4056. return this.localeData().postformat(output);
  4057. }
  4058. function from(time, withoutSuffix) {
  4059. if (
  4060. this.isValid() &&
  4061. ((isMoment(time) && time.isValid()) || createLocal(time).isValid())
  4062. ) {
  4063. return createDuration({ to: this, from: time })
  4064. .locale(this.locale())
  4065. .humanize(!withoutSuffix);
  4066. } else {
  4067. return this.localeData().invalidDate();
  4068. }
  4069. }
  4070. function fromNow(withoutSuffix) {
  4071. return this.from(createLocal(), withoutSuffix);
  4072. }
  4073. function to(time, withoutSuffix) {
  4074. if (
  4075. this.isValid() &&
  4076. ((isMoment(time) && time.isValid()) || createLocal(time).isValid())
  4077. ) {
  4078. return createDuration({ from: this, to: time })
  4079. .locale(this.locale())
  4080. .humanize(!withoutSuffix);
  4081. } else {
  4082. return this.localeData().invalidDate();
  4083. }
  4084. }
  4085. function toNow(withoutSuffix) {
  4086. return this.to(createLocal(), withoutSuffix);
  4087. }
  4088. // If passed a locale key, it will set the locale for this
  4089. // instance. Otherwise, it will return the locale configuration
  4090. // variables for this instance.
  4091. function locale(key) {
  4092. var newLocaleData;
  4093. if (key === undefined) {
  4094. return this._locale._abbr;
  4095. } else {
  4096. newLocaleData = getLocale(key);
  4097. if (newLocaleData != null) {
  4098. this._locale = newLocaleData;
  4099. }
  4100. return this;
  4101. }
  4102. }
  4103. var lang = deprecate(
  4104. 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
  4105. function (key) {
  4106. if (key === undefined) {
  4107. return this.localeData();
  4108. } else {
  4109. return this.locale(key);
  4110. }
  4111. }
  4112. );
  4113. function localeData() {
  4114. return this._locale;
  4115. }
  4116. var MS_PER_SECOND = 1000,
  4117. MS_PER_MINUTE = 60 * MS_PER_SECOND,
  4118. MS_PER_HOUR = 60 * MS_PER_MINUTE,
  4119. MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
  4120. // actual modulo - handles negative numbers (for dates before 1970):
  4121. function mod$1(dividend, divisor) {
  4122. return ((dividend % divisor) + divisor) % divisor;
  4123. }
  4124. function localStartOfDate(y, m, d) {
  4125. // the date constructor remaps years 0-99 to 1900-1999
  4126. if (y < 100 && y >= 0) {
  4127. // preserve leap years using a full 400 year cycle, then reset
  4128. return new Date(y + 400, m, d) - MS_PER_400_YEARS;
  4129. } else {
  4130. return new Date(y, m, d).valueOf();
  4131. }
  4132. }
  4133. function utcStartOfDate(y, m, d) {
  4134. // Date.UTC remaps years 0-99 to 1900-1999
  4135. if (y < 100 && y >= 0) {
  4136. // preserve leap years using a full 400 year cycle, then reset
  4137. return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
  4138. } else {
  4139. return Date.UTC(y, m, d);
  4140. }
  4141. }
  4142. function startOf(units) {
  4143. var time, startOfDate;
  4144. units = normalizeUnits(units);
  4145. if (units === undefined || units === 'millisecond' || !this.isValid()) {
  4146. return this;
  4147. }
  4148. startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
  4149. switch (units) {
  4150. case 'year':
  4151. time = startOfDate(this.year(), 0, 1);
  4152. break;
  4153. case 'quarter':
  4154. time = startOfDate(
  4155. this.year(),
  4156. this.month() - (this.month() % 3),
  4157. 1
  4158. );
  4159. break;
  4160. case 'month':
  4161. time = startOfDate(this.year(), this.month(), 1);
  4162. break;
  4163. case 'week':
  4164. time = startOfDate(
  4165. this.year(),
  4166. this.month(),
  4167. this.date() - this.weekday()
  4168. );
  4169. break;
  4170. case 'isoWeek':
  4171. time = startOfDate(
  4172. this.year(),
  4173. this.month(),
  4174. this.date() - (this.isoWeekday() - 1)
  4175. );
  4176. break;
  4177. case 'day':
  4178. case 'date':
  4179. time = startOfDate(this.year(), this.month(), this.date());
  4180. break;
  4181. case 'hour':
  4182. time = this._d.valueOf();
  4183. time -= mod$1(
  4184. time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
  4185. MS_PER_HOUR
  4186. );
  4187. break;
  4188. case 'minute':
  4189. time = this._d.valueOf();
  4190. time -= mod$1(time, MS_PER_MINUTE);
  4191. break;
  4192. case 'second':
  4193. time = this._d.valueOf();
  4194. time -= mod$1(time, MS_PER_SECOND);
  4195. break;
  4196. }
  4197. this._d.setTime(time);
  4198. hooks.updateOffset(this, true);
  4199. return this;
  4200. }
  4201. function endOf(units) {
  4202. var time, startOfDate;
  4203. units = normalizeUnits(units);
  4204. if (units === undefined || units === 'millisecond' || !this.isValid()) {
  4205. return this;
  4206. }
  4207. startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
  4208. switch (units) {
  4209. case 'year':
  4210. time = startOfDate(this.year() + 1, 0, 1) - 1;
  4211. break;
  4212. case 'quarter':
  4213. time =
  4214. startOfDate(
  4215. this.year(),
  4216. this.month() - (this.month() % 3) + 3,
  4217. 1
  4218. ) - 1;
  4219. break;
  4220. case 'month':
  4221. time = startOfDate(this.year(), this.month() + 1, 1) - 1;
  4222. break;
  4223. case 'week':
  4224. time =
  4225. startOfDate(
  4226. this.year(),
  4227. this.month(),
  4228. this.date() - this.weekday() + 7
  4229. ) - 1;
  4230. break;
  4231. case 'isoWeek':
  4232. time =
  4233. startOfDate(
  4234. this.year(),
  4235. this.month(),
  4236. this.date() - (this.isoWeekday() - 1) + 7
  4237. ) - 1;
  4238. break;
  4239. case 'day':
  4240. case 'date':
  4241. time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
  4242. break;
  4243. case 'hour':
  4244. time = this._d.valueOf();
  4245. time +=
  4246. MS_PER_HOUR -
  4247. mod$1(
  4248. time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
  4249. MS_PER_HOUR
  4250. ) -
  4251. 1;
  4252. break;
  4253. case 'minute':
  4254. time = this._d.valueOf();
  4255. time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
  4256. break;
  4257. case 'second':
  4258. time = this._d.valueOf();
  4259. time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
  4260. break;
  4261. }
  4262. this._d.setTime(time);
  4263. hooks.updateOffset(this, true);
  4264. return this;
  4265. }
  4266. function valueOf() {
  4267. return this._d.valueOf() - (this._offset || 0) * 60000;
  4268. }
  4269. function unix() {
  4270. return Math.floor(this.valueOf() / 1000);
  4271. }
  4272. function toDate() {
  4273. return new Date(this.valueOf());
  4274. }
  4275. function toArray() {
  4276. var m = this;
  4277. return [
  4278. m.year(),
  4279. m.month(),
  4280. m.date(),
  4281. m.hour(),
  4282. m.minute(),
  4283. m.second(),
  4284. m.millisecond(),
  4285. ];
  4286. }
  4287. function toObject() {
  4288. var m = this;
  4289. return {
  4290. years: m.year(),
  4291. months: m.month(),
  4292. date: m.date(),
  4293. hours: m.hours(),
  4294. minutes: m.minutes(),
  4295. seconds: m.seconds(),
  4296. milliseconds: m.milliseconds(),
  4297. };
  4298. }
  4299. function toJSON() {
  4300. // new Date(NaN).toJSON() === null
  4301. return this.isValid() ? this.toISOString() : null;
  4302. }
  4303. function isValid$2() {
  4304. return isValid(this);
  4305. }
  4306. function parsingFlags() {
  4307. return extend({}, getParsingFlags(this));
  4308. }
  4309. function invalidAt() {
  4310. return getParsingFlags(this).overflow;
  4311. }
  4312. function creationData() {
  4313. return {
  4314. input: this._i,
  4315. format: this._f,
  4316. locale: this._locale,
  4317. isUTC: this._isUTC,
  4318. strict: this._strict,
  4319. };
  4320. }
  4321. addFormatToken('N', 0, 0, 'eraAbbr');
  4322. addFormatToken('NN', 0, 0, 'eraAbbr');
  4323. addFormatToken('NNN', 0, 0, 'eraAbbr');
  4324. addFormatToken('NNNN', 0, 0, 'eraName');
  4325. addFormatToken('NNNNN', 0, 0, 'eraNarrow');
  4326. addFormatToken('y', ['y', 1], 'yo', 'eraYear');
  4327. addFormatToken('y', ['yy', 2], 0, 'eraYear');
  4328. addFormatToken('y', ['yyy', 3], 0, 'eraYear');
  4329. addFormatToken('y', ['yyyy', 4], 0, 'eraYear');
  4330. addRegexToken('N', matchEraAbbr);
  4331. addRegexToken('NN', matchEraAbbr);
  4332. addRegexToken('NNN', matchEraAbbr);
  4333. addRegexToken('NNNN', matchEraName);
  4334. addRegexToken('NNNNN', matchEraNarrow);
  4335. addParseToken(
  4336. ['N', 'NN', 'NNN', 'NNNN', 'NNNNN'],
  4337. function (input, array, config, token) {
  4338. var era = config._locale.erasParse(input, token, config._strict);
  4339. if (era) {
  4340. getParsingFlags(config).era = era;
  4341. } else {
  4342. getParsingFlags(config).invalidEra = input;
  4343. }
  4344. }
  4345. );
  4346. addRegexToken('y', matchUnsigned);
  4347. addRegexToken('yy', matchUnsigned);
  4348. addRegexToken('yyy', matchUnsigned);
  4349. addRegexToken('yyyy', matchUnsigned);
  4350. addRegexToken('yo', matchEraYearOrdinal);
  4351. addParseToken(['y', 'yy', 'yyy', 'yyyy'], YEAR);
  4352. addParseToken(['yo'], function (input, array, config, token) {
  4353. var match;
  4354. if (config._locale._eraYearOrdinalRegex) {
  4355. match = input.match(config._locale._eraYearOrdinalRegex);
  4356. }
  4357. if (config._locale.eraYearOrdinalParse) {
  4358. array[YEAR] = config._locale.eraYearOrdinalParse(input, match);
  4359. } else {
  4360. array[YEAR] = parseInt(input, 10);
  4361. }
  4362. });
  4363. function localeEras(m, format) {
  4364. var i,
  4365. l,
  4366. date,
  4367. eras = this._eras || getLocale('en')._eras;
  4368. for (i = 0, l = eras.length; i < l; ++i) {
  4369. switch (typeof eras[i].since) {
  4370. case 'string':
  4371. // truncate time
  4372. date = hooks(eras[i].since).startOf('day');
  4373. eras[i].since = date.valueOf();
  4374. break;
  4375. }
  4376. switch (typeof eras[i].until) {
  4377. case 'undefined':
  4378. eras[i].until = +Infinity;
  4379. break;
  4380. case 'string':
  4381. // truncate time
  4382. date = hooks(eras[i].until).startOf('day').valueOf();
  4383. eras[i].until = date.valueOf();
  4384. break;
  4385. }
  4386. }
  4387. return eras;
  4388. }
  4389. function localeErasParse(eraName, format, strict) {
  4390. var i,
  4391. l,
  4392. eras = this.eras(),
  4393. name,
  4394. abbr,
  4395. narrow;
  4396. eraName = eraName.toUpperCase();
  4397. for (i = 0, l = eras.length; i < l; ++i) {
  4398. name = eras[i].name.toUpperCase();
  4399. abbr = eras[i].abbr.toUpperCase();
  4400. narrow = eras[i].narrow.toUpperCase();
  4401. if (strict) {
  4402. switch (format) {
  4403. case 'N':
  4404. case 'NN':
  4405. case 'NNN':
  4406. if (abbr === eraName) {
  4407. return eras[i];
  4408. }
  4409. break;
  4410. case 'NNNN':
  4411. if (name === eraName) {
  4412. return eras[i];
  4413. }
  4414. break;
  4415. case 'NNNNN':
  4416. if (narrow === eraName) {
  4417. return eras[i];
  4418. }
  4419. break;
  4420. }
  4421. } else if ([name, abbr, narrow].indexOf(eraName) >= 0) {
  4422. return eras[i];
  4423. }
  4424. }
  4425. }
  4426. function localeErasConvertYear(era, year) {
  4427. var dir = era.since <= era.until ? +1 : -1;
  4428. if (year === undefined) {
  4429. return hooks(era.since).year();
  4430. } else {
  4431. return hooks(era.since).year() + (year - era.offset) * dir;
  4432. }
  4433. }
  4434. function getEraName() {
  4435. var i,
  4436. l,
  4437. val,
  4438. eras = this.localeData().eras();
  4439. for (i = 0, l = eras.length; i < l; ++i) {
  4440. // truncate time
  4441. val = this.clone().startOf('day').valueOf();
  4442. if (eras[i].since <= val && val <= eras[i].until) {
  4443. return eras[i].name;
  4444. }
  4445. if (eras[i].until <= val && val <= eras[i].since) {
  4446. return eras[i].name;
  4447. }
  4448. }
  4449. return '';
  4450. }
  4451. function getEraNarrow() {
  4452. var i,
  4453. l,
  4454. val,
  4455. eras = this.localeData().eras();
  4456. for (i = 0, l = eras.length; i < l; ++i) {
  4457. // truncate time
  4458. val = this.clone().startOf('day').valueOf();
  4459. if (eras[i].since <= val && val <= eras[i].until) {
  4460. return eras[i].narrow;
  4461. }
  4462. if (eras[i].until <= val && val <= eras[i].since) {
  4463. return eras[i].narrow;
  4464. }
  4465. }
  4466. return '';
  4467. }
  4468. function getEraAbbr() {
  4469. var i,
  4470. l,
  4471. val,
  4472. eras = this.localeData().eras();
  4473. for (i = 0, l = eras.length; i < l; ++i) {
  4474. // truncate time
  4475. val = this.clone().startOf('day').valueOf();
  4476. if (eras[i].since <= val && val <= eras[i].until) {
  4477. return eras[i].abbr;
  4478. }
  4479. if (eras[i].until <= val && val <= eras[i].since) {
  4480. return eras[i].abbr;
  4481. }
  4482. }
  4483. return '';
  4484. }
  4485. function getEraYear() {
  4486. var i,
  4487. l,
  4488. dir,
  4489. val,
  4490. eras = this.localeData().eras();
  4491. for (i = 0, l = eras.length; i < l; ++i) {
  4492. dir = eras[i].since <= eras[i].until ? +1 : -1;
  4493. // truncate time
  4494. val = this.clone().startOf('day').valueOf();
  4495. if (
  4496. (eras[i].since <= val && val <= eras[i].until) ||
  4497. (eras[i].until <= val && val <= eras[i].since)
  4498. ) {
  4499. return (
  4500. (this.year() - hooks(eras[i].since).year()) * dir +
  4501. eras[i].offset
  4502. );
  4503. }
  4504. }
  4505. return this.year();
  4506. }
  4507. function erasNameRegex(isStrict) {
  4508. if (!hasOwnProp(this, '_erasNameRegex')) {
  4509. computeErasParse.call(this);
  4510. }
  4511. return isStrict ? this._erasNameRegex : this._erasRegex;
  4512. }
  4513. function erasAbbrRegex(isStrict) {
  4514. if (!hasOwnProp(this, '_erasAbbrRegex')) {
  4515. computeErasParse.call(this);
  4516. }
  4517. return isStrict ? this._erasAbbrRegex : this._erasRegex;
  4518. }
  4519. function erasNarrowRegex(isStrict) {
  4520. if (!hasOwnProp(this, '_erasNarrowRegex')) {
  4521. computeErasParse.call(this);
  4522. }
  4523. return isStrict ? this._erasNarrowRegex : this._erasRegex;
  4524. }
  4525. function matchEraAbbr(isStrict, locale) {
  4526. return locale.erasAbbrRegex(isStrict);
  4527. }
  4528. function matchEraName(isStrict, locale) {
  4529. return locale.erasNameRegex(isStrict);
  4530. }
  4531. function matchEraNarrow(isStrict, locale) {
  4532. return locale.erasNarrowRegex(isStrict);
  4533. }
  4534. function matchEraYearOrdinal(isStrict, locale) {
  4535. return locale._eraYearOrdinalRegex || matchUnsigned;
  4536. }
  4537. function computeErasParse() {
  4538. var abbrPieces = [],
  4539. namePieces = [],
  4540. narrowPieces = [],
  4541. mixedPieces = [],
  4542. i,
  4543. l,
  4544. eras = this.eras();
  4545. for (i = 0, l = eras.length; i < l; ++i) {
  4546. namePieces.push(regexEscape(eras[i].name));
  4547. abbrPieces.push(regexEscape(eras[i].abbr));
  4548. narrowPieces.push(regexEscape(eras[i].narrow));
  4549. mixedPieces.push(regexEscape(eras[i].name));
  4550. mixedPieces.push(regexEscape(eras[i].abbr));
  4551. mixedPieces.push(regexEscape(eras[i].narrow));
  4552. }
  4553. this._erasRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  4554. this._erasNameRegex = new RegExp('^(' + namePieces.join('|') + ')', 'i');
  4555. this._erasAbbrRegex = new RegExp('^(' + abbrPieces.join('|') + ')', 'i');
  4556. this._erasNarrowRegex = new RegExp(
  4557. '^(' + narrowPieces.join('|') + ')',
  4558. 'i'
  4559. );
  4560. }
  4561. // FORMATTING
  4562. addFormatToken(0, ['gg', 2], 0, function () {
  4563. return this.weekYear() % 100;
  4564. });
  4565. addFormatToken(0, ['GG', 2], 0, function () {
  4566. return this.isoWeekYear() % 100;
  4567. });
  4568. function addWeekYearFormatToken(token, getter) {
  4569. addFormatToken(0, [token, token.length], 0, getter);
  4570. }
  4571. addWeekYearFormatToken('gggg', 'weekYear');
  4572. addWeekYearFormatToken('ggggg', 'weekYear');
  4573. addWeekYearFormatToken('GGGG', 'isoWeekYear');
  4574. addWeekYearFormatToken('GGGGG', 'isoWeekYear');
  4575. // ALIASES
  4576. addUnitAlias('weekYear', 'gg');
  4577. addUnitAlias('isoWeekYear', 'GG');
  4578. // PRIORITY
  4579. addUnitPriority('weekYear', 1);
  4580. addUnitPriority('isoWeekYear', 1);
  4581. // PARSING
  4582. addRegexToken('G', matchSigned);
  4583. addRegexToken('g', matchSigned);
  4584. addRegexToken('GG', match1to2, match2);
  4585. addRegexToken('gg', match1to2, match2);
  4586. addRegexToken('GGGG', match1to4, match4);
  4587. addRegexToken('gggg', match1to4, match4);
  4588. addRegexToken('GGGGG', match1to6, match6);
  4589. addRegexToken('ggggg', match1to6, match6);
  4590. addWeekParseToken(
  4591. ['gggg', 'ggggg', 'GGGG', 'GGGGG'],
  4592. function (input, week, config, token) {
  4593. week[token.substr(0, 2)] = toInt(input);
  4594. }
  4595. );
  4596. addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
  4597. week[token] = hooks.parseTwoDigitYear(input);
  4598. });
  4599. // MOMENTS
  4600. function getSetWeekYear(input) {
  4601. return getSetWeekYearHelper.call(
  4602. this,
  4603. input,
  4604. this.week(),
  4605. this.weekday(),
  4606. this.localeData()._week.dow,
  4607. this.localeData()._week.doy
  4608. );
  4609. }
  4610. function getSetISOWeekYear(input) {
  4611. return getSetWeekYearHelper.call(
  4612. this,
  4613. input,
  4614. this.isoWeek(),
  4615. this.isoWeekday(),
  4616. 1,
  4617. 4
  4618. );
  4619. }
  4620. function getISOWeeksInYear() {
  4621. return weeksInYear(this.year(), 1, 4);
  4622. }
  4623. function getISOWeeksInISOWeekYear() {
  4624. return weeksInYear(this.isoWeekYear(), 1, 4);
  4625. }
  4626. function getWeeksInYear() {
  4627. var weekInfo = this.localeData()._week;
  4628. return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
  4629. }
  4630. function getWeeksInWeekYear() {
  4631. var weekInfo = this.localeData()._week;
  4632. return weeksInYear(this.weekYear(), weekInfo.dow, weekInfo.doy);
  4633. }
  4634. function getSetWeekYearHelper(input, week, weekday, dow, doy) {
  4635. var weeksTarget;
  4636. if (input == null) {
  4637. return weekOfYear(this, dow, doy).year;
  4638. } else {
  4639. weeksTarget = weeksInYear(input, dow, doy);
  4640. if (week > weeksTarget) {
  4641. week = weeksTarget;
  4642. }
  4643. return setWeekAll.call(this, input, week, weekday, dow, doy);
  4644. }
  4645. }
  4646. function setWeekAll(weekYear, week, weekday, dow, doy) {
  4647. var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
  4648. date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
  4649. this.year(date.getUTCFullYear());
  4650. this.month(date.getUTCMonth());
  4651. this.date(date.getUTCDate());
  4652. return this;
  4653. }
  4654. // FORMATTING
  4655. addFormatToken('Q', 0, 'Qo', 'quarter');
  4656. // ALIASES
  4657. addUnitAlias('quarter', 'Q');
  4658. // PRIORITY
  4659. addUnitPriority('quarter', 7);
  4660. // PARSING
  4661. addRegexToken('Q', match1);
  4662. addParseToken('Q', function (input, array) {
  4663. array[MONTH] = (toInt(input) - 1) * 3;
  4664. });
  4665. // MOMENTS
  4666. function getSetQuarter(input) {
  4667. return input == null
  4668. ? Math.ceil((this.month() + 1) / 3)
  4669. : this.month((input - 1) * 3 + (this.month() % 3));
  4670. }
  4671. // FORMATTING
  4672. addFormatToken('D', ['DD', 2], 'Do', 'date');
  4673. // ALIASES
  4674. addUnitAlias('date', 'D');
  4675. // PRIORITY
  4676. addUnitPriority('date', 9);
  4677. // PARSING
  4678. addRegexToken('D', match1to2);
  4679. addRegexToken('DD', match1to2, match2);
  4680. addRegexToken('Do', function (isStrict, locale) {
  4681. // TODO: Remove "ordinalParse" fallback in next major release.
  4682. return isStrict
  4683. ? locale._dayOfMonthOrdinalParse || locale._ordinalParse
  4684. : locale._dayOfMonthOrdinalParseLenient;
  4685. });
  4686. addParseToken(['D', 'DD'], DATE);
  4687. addParseToken('Do', function (input, array) {
  4688. array[DATE] = toInt(input.match(match1to2)[0]);
  4689. });
  4690. // MOMENTS
  4691. var getSetDayOfMonth = makeGetSet('Date', true);
  4692. // FORMATTING
  4693. addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
  4694. // ALIASES
  4695. addUnitAlias('dayOfYear', 'DDD');
  4696. // PRIORITY
  4697. addUnitPriority('dayOfYear', 4);
  4698. // PARSING
  4699. addRegexToken('DDD', match1to3);
  4700. addRegexToken('DDDD', match3);
  4701. addParseToken(['DDD', 'DDDD'], function (input, array, config) {
  4702. config._dayOfYear = toInt(input);
  4703. });
  4704. // HELPERS
  4705. // MOMENTS
  4706. function getSetDayOfYear(input) {
  4707. var dayOfYear =
  4708. Math.round(
  4709. (this.clone().startOf('day') - this.clone().startOf('year')) / 864e5
  4710. ) + 1;
  4711. return input == null ? dayOfYear : this.add(input - dayOfYear, 'd');
  4712. }
  4713. // FORMATTING
  4714. addFormatToken('m', ['mm', 2], 0, 'minute');
  4715. // ALIASES
  4716. addUnitAlias('minute', 'm');
  4717. // PRIORITY
  4718. addUnitPriority('minute', 14);
  4719. // PARSING
  4720. addRegexToken('m', match1to2);
  4721. addRegexToken('mm', match1to2, match2);
  4722. addParseToken(['m', 'mm'], MINUTE);
  4723. // MOMENTS
  4724. var getSetMinute = makeGetSet('Minutes', false);
  4725. // FORMATTING
  4726. addFormatToken('s', ['ss', 2], 0, 'second');
  4727. // ALIASES
  4728. addUnitAlias('second', 's');
  4729. // PRIORITY
  4730. addUnitPriority('second', 15);
  4731. // PARSING
  4732. addRegexToken('s', match1to2);
  4733. addRegexToken('ss', match1to2, match2);
  4734. addParseToken(['s', 'ss'], SECOND);
  4735. // MOMENTS
  4736. var getSetSecond = makeGetSet('Seconds', false);
  4737. // FORMATTING
  4738. addFormatToken('S', 0, 0, function () {
  4739. return ~~(this.millisecond() / 100);
  4740. });
  4741. addFormatToken(0, ['SS', 2], 0, function () {
  4742. return ~~(this.millisecond() / 10);
  4743. });
  4744. addFormatToken(0, ['SSS', 3], 0, 'millisecond');
  4745. addFormatToken(0, ['SSSS', 4], 0, function () {
  4746. return this.millisecond() * 10;
  4747. });
  4748. addFormatToken(0, ['SSSSS', 5], 0, function () {
  4749. return this.millisecond() * 100;
  4750. });
  4751. addFormatToken(0, ['SSSSSS', 6], 0, function () {
  4752. return this.millisecond() * 1000;
  4753. });
  4754. addFormatToken(0, ['SSSSSSS', 7], 0, function () {
  4755. return this.millisecond() * 10000;
  4756. });
  4757. addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
  4758. return this.millisecond() * 100000;
  4759. });
  4760. addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
  4761. return this.millisecond() * 1000000;
  4762. });
  4763. // ALIASES
  4764. addUnitAlias('millisecond', 'ms');
  4765. // PRIORITY
  4766. addUnitPriority('millisecond', 16);
  4767. // PARSING
  4768. addRegexToken('S', match1to3, match1);
  4769. addRegexToken('SS', match1to3, match2);
  4770. addRegexToken('SSS', match1to3, match3);
  4771. var token, getSetMillisecond;
  4772. for (token = 'SSSS'; token.length <= 9; token += 'S') {
  4773. addRegexToken(token, matchUnsigned);
  4774. }
  4775. function parseMs(input, array) {
  4776. array[MILLISECOND] = toInt(('0.' + input) * 1000);
  4777. }
  4778. for (token = 'S'; token.length <= 9; token += 'S') {
  4779. addParseToken(token, parseMs);
  4780. }
  4781. getSetMillisecond = makeGetSet('Milliseconds', false);
  4782. // FORMATTING
  4783. addFormatToken('z', 0, 0, 'zoneAbbr');
  4784. addFormatToken('zz', 0, 0, 'zoneName');
  4785. // MOMENTS
  4786. function getZoneAbbr() {
  4787. return this._isUTC ? 'UTC' : '';
  4788. }
  4789. function getZoneName() {
  4790. return this._isUTC ? 'Coordinated Universal Time' : '';
  4791. }
  4792. var proto = Moment.prototype;
  4793. proto.add = add;
  4794. proto.calendar = calendar$1;
  4795. proto.clone = clone;
  4796. proto.diff = diff;
  4797. proto.endOf = endOf;
  4798. proto.format = format;
  4799. proto.from = from;
  4800. proto.fromNow = fromNow;
  4801. proto.to = to;
  4802. proto.toNow = toNow;
  4803. proto.get = stringGet;
  4804. proto.invalidAt = invalidAt;
  4805. proto.isAfter = isAfter;
  4806. proto.isBefore = isBefore;
  4807. proto.isBetween = isBetween;
  4808. proto.isSame = isSame;
  4809. proto.isSameOrAfter = isSameOrAfter;
  4810. proto.isSameOrBefore = isSameOrBefore;
  4811. proto.isValid = isValid$2;
  4812. proto.lang = lang;
  4813. proto.locale = locale;
  4814. proto.localeData = localeData;
  4815. proto.max = prototypeMax;
  4816. proto.min = prototypeMin;
  4817. proto.parsingFlags = parsingFlags;
  4818. proto.set = stringSet;
  4819. proto.startOf = startOf;
  4820. proto.subtract = subtract;
  4821. proto.toArray = toArray;
  4822. proto.toObject = toObject;
  4823. proto.toDate = toDate;
  4824. proto.toISOString = toISOString;
  4825. proto.inspect = inspect;
  4826. if (typeof Symbol !== 'undefined' && Symbol.for != null) {
  4827. proto[Symbol.for('nodejs.util.inspect.custom')] = function () {
  4828. return 'Moment<' + this.format() + '>';
  4829. };
  4830. }
  4831. proto.toJSON = toJSON;
  4832. proto.toString = toString;
  4833. proto.unix = unix;
  4834. proto.valueOf = valueOf;
  4835. proto.creationData = creationData;
  4836. proto.eraName = getEraName;
  4837. proto.eraNarrow = getEraNarrow;
  4838. proto.eraAbbr = getEraAbbr;
  4839. proto.eraYear = getEraYear;
  4840. proto.year = getSetYear;
  4841. proto.isLeapYear = getIsLeapYear;
  4842. proto.weekYear = getSetWeekYear;
  4843. proto.isoWeekYear = getSetISOWeekYear;
  4844. proto.quarter = proto.quarters = getSetQuarter;
  4845. proto.month = getSetMonth;
  4846. proto.daysInMonth = getDaysInMonth;
  4847. proto.week = proto.weeks = getSetWeek;
  4848. proto.isoWeek = proto.isoWeeks = getSetISOWeek;
  4849. proto.weeksInYear = getWeeksInYear;
  4850. proto.weeksInWeekYear = getWeeksInWeekYear;
  4851. proto.isoWeeksInYear = getISOWeeksInYear;
  4852. proto.isoWeeksInISOWeekYear = getISOWeeksInISOWeekYear;
  4853. proto.date = getSetDayOfMonth;
  4854. proto.day = proto.days = getSetDayOfWeek;
  4855. proto.weekday = getSetLocaleDayOfWeek;
  4856. proto.isoWeekday = getSetISODayOfWeek;
  4857. proto.dayOfYear = getSetDayOfYear;
  4858. proto.hour = proto.hours = getSetHour;
  4859. proto.minute = proto.minutes = getSetMinute;
  4860. proto.second = proto.seconds = getSetSecond;
  4861. proto.millisecond = proto.milliseconds = getSetMillisecond;
  4862. proto.utcOffset = getSetOffset;
  4863. proto.utc = setOffsetToUTC;
  4864. proto.local = setOffsetToLocal;
  4865. proto.parseZone = setOffsetToParsedOffset;
  4866. proto.hasAlignedHourOffset = hasAlignedHourOffset;
  4867. proto.isDST = isDaylightSavingTime;
  4868. proto.isLocal = isLocal;
  4869. proto.isUtcOffset = isUtcOffset;
  4870. proto.isUtc = isUtc;
  4871. proto.isUTC = isUtc;
  4872. proto.zoneAbbr = getZoneAbbr;
  4873. proto.zoneName = getZoneName;
  4874. proto.dates = deprecate(
  4875. 'dates accessor is deprecated. Use date instead.',
  4876. getSetDayOfMonth
  4877. );
  4878. proto.months = deprecate(
  4879. 'months accessor is deprecated. Use month instead',
  4880. getSetMonth
  4881. );
  4882. proto.years = deprecate(
  4883. 'years accessor is deprecated. Use year instead',
  4884. getSetYear
  4885. );
  4886. proto.zone = deprecate(
  4887. 'moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/',
  4888. getSetZone
  4889. );
  4890. proto.isDSTShifted = deprecate(
  4891. 'isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information',
  4892. isDaylightSavingTimeShifted
  4893. );
  4894. function createUnix(input) {
  4895. return createLocal(input * 1000);
  4896. }
  4897. function createInZone() {
  4898. return createLocal.apply(null, arguments).parseZone();
  4899. }
  4900. function preParsePostFormat(string) {
  4901. return string;
  4902. }
  4903. var proto$1 = Locale.prototype;
  4904. proto$1.calendar = calendar;
  4905. proto$1.longDateFormat = longDateFormat;
  4906. proto$1.invalidDate = invalidDate;
  4907. proto$1.ordinal = ordinal;
  4908. proto$1.preparse = preParsePostFormat;
  4909. proto$1.postformat = preParsePostFormat;
  4910. proto$1.relativeTime = relativeTime;
  4911. proto$1.pastFuture = pastFuture;
  4912. proto$1.set = set;
  4913. proto$1.eras = localeEras;
  4914. proto$1.erasParse = localeErasParse;
  4915. proto$1.erasConvertYear = localeErasConvertYear;
  4916. proto$1.erasAbbrRegex = erasAbbrRegex;
  4917. proto$1.erasNameRegex = erasNameRegex;
  4918. proto$1.erasNarrowRegex = erasNarrowRegex;
  4919. proto$1.months = localeMonths;
  4920. proto$1.monthsShort = localeMonthsShort;
  4921. proto$1.monthsParse = localeMonthsParse;
  4922. proto$1.monthsRegex = monthsRegex;
  4923. proto$1.monthsShortRegex = monthsShortRegex;
  4924. proto$1.week = localeWeek;
  4925. proto$1.firstDayOfYear = localeFirstDayOfYear;
  4926. proto$1.firstDayOfWeek = localeFirstDayOfWeek;
  4927. proto$1.weekdays = localeWeekdays;
  4928. proto$1.weekdaysMin = localeWeekdaysMin;
  4929. proto$1.weekdaysShort = localeWeekdaysShort;
  4930. proto$1.weekdaysParse = localeWeekdaysParse;
  4931. proto$1.weekdaysRegex = weekdaysRegex;
  4932. proto$1.weekdaysShortRegex = weekdaysShortRegex;
  4933. proto$1.weekdaysMinRegex = weekdaysMinRegex;
  4934. proto$1.isPM = localeIsPM;
  4935. proto$1.meridiem = localeMeridiem;
  4936. function get$1(format, index, field, setter) {
  4937. var locale = getLocale(),
  4938. utc = createUTC().set(setter, index);
  4939. return locale[field](utc, format);
  4940. }
  4941. function listMonthsImpl(format, index, field) {
  4942. if (isNumber(format)) {
  4943. index = format;
  4944. format = undefined;
  4945. }
  4946. format = format || '';
  4947. if (index != null) {
  4948. return get$1(format, index, field, 'month');
  4949. }
  4950. var i,
  4951. out = [];
  4952. for (i = 0; i < 12; i++) {
  4953. out[i] = get$1(format, i, field, 'month');
  4954. }
  4955. return out;
  4956. }
  4957. // ()
  4958. // (5)
  4959. // (fmt, 5)
  4960. // (fmt)
  4961. // (true)
  4962. // (true, 5)
  4963. // (true, fmt, 5)
  4964. // (true, fmt)
  4965. function listWeekdaysImpl(localeSorted, format, index, field) {
  4966. if (typeof localeSorted === 'boolean') {
  4967. if (isNumber(format)) {
  4968. index = format;
  4969. format = undefined;
  4970. }
  4971. format = format || '';
  4972. } else {
  4973. format = localeSorted;
  4974. index = format;
  4975. localeSorted = false;
  4976. if (isNumber(format)) {
  4977. index = format;
  4978. format = undefined;
  4979. }
  4980. format = format || '';
  4981. }
  4982. var locale = getLocale(),
  4983. shift = localeSorted ? locale._week.dow : 0,
  4984. i,
  4985. out = [];
  4986. if (index != null) {
  4987. return get$1(format, (index + shift) % 7, field, 'day');
  4988. }
  4989. for (i = 0; i < 7; i++) {
  4990. out[i] = get$1(format, (i + shift) % 7, field, 'day');
  4991. }
  4992. return out;
  4993. }
  4994. function listMonths(format, index) {
  4995. return listMonthsImpl(format, index, 'months');
  4996. }
  4997. function listMonthsShort(format, index) {
  4998. return listMonthsImpl(format, index, 'monthsShort');
  4999. }
  5000. function listWeekdays(localeSorted, format, index) {
  5001. return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
  5002. }
  5003. function listWeekdaysShort(localeSorted, format, index) {
  5004. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
  5005. }
  5006. function listWeekdaysMin(localeSorted, format, index) {
  5007. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
  5008. }
  5009. getSetGlobalLocale('en', {
  5010. eras: [
  5011. {
  5012. since: '0001-01-01',
  5013. until: +Infinity,
  5014. offset: 1,
  5015. name: 'Anno Domini',
  5016. narrow: 'AD',
  5017. abbr: 'AD',
  5018. },
  5019. {
  5020. since: '0000-12-31',
  5021. until: -Infinity,
  5022. offset: 1,
  5023. name: 'Before Christ',
  5024. narrow: 'BC',
  5025. abbr: 'BC',
  5026. },
  5027. ],
  5028. dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
  5029. ordinal: function (number) {
  5030. var b = number % 10,
  5031. output =
  5032. toInt((number % 100) / 10) === 1
  5033. ? 'th'
  5034. : b === 1
  5035. ? 'st'
  5036. : b === 2
  5037. ? 'nd'
  5038. : b === 3
  5039. ? 'rd'
  5040. : 'th';
  5041. return number + output;
  5042. },
  5043. });
  5044. // Side effect imports
  5045. hooks.lang = deprecate(
  5046. 'moment.lang is deprecated. Use moment.locale instead.',
  5047. getSetGlobalLocale
  5048. );
  5049. hooks.langData = deprecate(
  5050. 'moment.langData is deprecated. Use moment.localeData instead.',
  5051. getLocale
  5052. );
  5053. var mathAbs = Math.abs;
  5054. function abs() {
  5055. var data = this._data;
  5056. this._milliseconds = mathAbs(this._milliseconds);
  5057. this._days = mathAbs(this._days);
  5058. this._months = mathAbs(this._months);
  5059. data.milliseconds = mathAbs(data.milliseconds);
  5060. data.seconds = mathAbs(data.seconds);
  5061. data.minutes = mathAbs(data.minutes);
  5062. data.hours = mathAbs(data.hours);
  5063. data.months = mathAbs(data.months);
  5064. data.years = mathAbs(data.years);
  5065. return this;
  5066. }
  5067. function addSubtract$1(duration, input, value, direction) {
  5068. var other = createDuration(input, value);
  5069. duration._milliseconds += direction * other._milliseconds;
  5070. duration._days += direction * other._days;
  5071. duration._months += direction * other._months;
  5072. return duration._bubble();
  5073. }
  5074. // supports only 2.0-style add(1, 's') or add(duration)
  5075. function add$1(input, value) {
  5076. return addSubtract$1(this, input, value, 1);
  5077. }
  5078. // supports only 2.0-style subtract(1, 's') or subtract(duration)
  5079. function subtract$1(input, value) {
  5080. return addSubtract$1(this, input, value, -1);
  5081. }
  5082. function absCeil(number) {
  5083. if (number < 0) {
  5084. return Math.floor(number);
  5085. } else {
  5086. return Math.ceil(number);
  5087. }
  5088. }
  5089. function bubble() {
  5090. var milliseconds = this._milliseconds,
  5091. days = this._days,
  5092. months = this._months,
  5093. data = this._data,
  5094. seconds,
  5095. minutes,
  5096. hours,
  5097. years,
  5098. monthsFromDays;
  5099. // if we have a mix of positive and negative values, bubble down first
  5100. // check: https://github.com/moment/moment/issues/2166
  5101. if (
  5102. !(
  5103. (milliseconds >= 0 && days >= 0 && months >= 0) ||
  5104. (milliseconds <= 0 && days <= 0 && months <= 0)
  5105. )
  5106. ) {
  5107. milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
  5108. days = 0;
  5109. months = 0;
  5110. }
  5111. // The following code bubbles up values, see the tests for
  5112. // examples of what that means.
  5113. data.milliseconds = milliseconds % 1000;
  5114. seconds = absFloor(milliseconds / 1000);
  5115. data.seconds = seconds % 60;
  5116. minutes = absFloor(seconds / 60);
  5117. data.minutes = minutes % 60;
  5118. hours = absFloor(minutes / 60);
  5119. data.hours = hours % 24;
  5120. days += absFloor(hours / 24);
  5121. // convert days to months
  5122. monthsFromDays = absFloor(daysToMonths(days));
  5123. months += monthsFromDays;
  5124. days -= absCeil(monthsToDays(monthsFromDays));
  5125. // 12 months -> 1 year
  5126. years = absFloor(months / 12);
  5127. months %= 12;
  5128. data.days = days;
  5129. data.months = months;
  5130. data.years = years;
  5131. return this;
  5132. }
  5133. function daysToMonths(days) {
  5134. // 400 years have 146097 days (taking into account leap year rules)
  5135. // 400 years have 12 months === 4800
  5136. return (days * 4800) / 146097;
  5137. }
  5138. function monthsToDays(months) {
  5139. // the reverse of daysToMonths
  5140. return (months * 146097) / 4800;
  5141. }
  5142. function as(units) {
  5143. if (!this.isValid()) {
  5144. return NaN;
  5145. }
  5146. var days,
  5147. months,
  5148. milliseconds = this._milliseconds;
  5149. units = normalizeUnits(units);
  5150. if (units === 'month' || units === 'quarter' || units === 'year') {
  5151. days = this._days + milliseconds / 864e5;
  5152. months = this._months + daysToMonths(days);
  5153. switch (units) {
  5154. case 'month':
  5155. return months;
  5156. case 'quarter':
  5157. return months / 3;
  5158. case 'year':
  5159. return months / 12;
  5160. }
  5161. } else {
  5162. // handle milliseconds separately because of floating point math errors (issue #1867)
  5163. days = this._days + Math.round(monthsToDays(this._months));
  5164. switch (units) {
  5165. case 'week':
  5166. return days / 7 + milliseconds / 6048e5;
  5167. case 'day':
  5168. return days + milliseconds / 864e5;
  5169. case 'hour':
  5170. return days * 24 + milliseconds / 36e5;
  5171. case 'minute':
  5172. return days * 1440 + milliseconds / 6e4;
  5173. case 'second':
  5174. return days * 86400 + milliseconds / 1000;
  5175. // Math.floor prevents floating point math errors here
  5176. case 'millisecond':
  5177. return Math.floor(days * 864e5) + milliseconds;
  5178. default:
  5179. throw new Error('Unknown unit ' + units);
  5180. }
  5181. }
  5182. }
  5183. // TODO: Use this.as('ms')?
  5184. function valueOf$1() {
  5185. if (!this.isValid()) {
  5186. return NaN;
  5187. }
  5188. return (
  5189. this._milliseconds +
  5190. this._days * 864e5 +
  5191. (this._months % 12) * 2592e6 +
  5192. toInt(this._months / 12) * 31536e6
  5193. );
  5194. }
  5195. function makeAs(alias) {
  5196. return function () {
  5197. return this.as(alias);
  5198. };
  5199. }
  5200. var asMilliseconds = makeAs('ms'),
  5201. asSeconds = makeAs('s'),
  5202. asMinutes = makeAs('m'),
  5203. asHours = makeAs('h'),
  5204. asDays = makeAs('d'),
  5205. asWeeks = makeAs('w'),
  5206. asMonths = makeAs('M'),
  5207. asQuarters = makeAs('Q'),
  5208. asYears = makeAs('y');
  5209. function clone$1() {
  5210. return createDuration(this);
  5211. }
  5212. function get$2(units) {
  5213. units = normalizeUnits(units);
  5214. return this.isValid() ? this[units + 's']() : NaN;
  5215. }
  5216. function makeGetter(name) {
  5217. return function () {
  5218. return this.isValid() ? this._data[name] : NaN;
  5219. };
  5220. }
  5221. var milliseconds = makeGetter('milliseconds'),
  5222. seconds = makeGetter('seconds'),
  5223. minutes = makeGetter('minutes'),
  5224. hours = makeGetter('hours'),
  5225. days = makeGetter('days'),
  5226. months = makeGetter('months'),
  5227. years = makeGetter('years');
  5228. function weeks() {
  5229. return absFloor(this.days() / 7);
  5230. }
  5231. var round = Math.round,
  5232. thresholds = {
  5233. ss: 44, // a few seconds to seconds
  5234. s: 45, // seconds to minute
  5235. m: 45, // minutes to hour
  5236. h: 22, // hours to day
  5237. d: 26, // days to month/week
  5238. w: null, // weeks to month
  5239. M: 11, // months to year
  5240. };
  5241. // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
  5242. function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
  5243. return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
  5244. }
  5245. function relativeTime$1(posNegDuration, withoutSuffix, thresholds, locale) {
  5246. var duration = createDuration(posNegDuration).abs(),
  5247. seconds = round(duration.as('s')),
  5248. minutes = round(duration.as('m')),
  5249. hours = round(duration.as('h')),
  5250. days = round(duration.as('d')),
  5251. months = round(duration.as('M')),
  5252. weeks = round(duration.as('w')),
  5253. years = round(duration.as('y')),
  5254. a =
  5255. (seconds <= thresholds.ss && ['s', seconds]) ||
  5256. (seconds < thresholds.s && ['ss', seconds]) ||
  5257. (minutes <= 1 && ['m']) ||
  5258. (minutes < thresholds.m && ['mm', minutes]) ||
  5259. (hours <= 1 && ['h']) ||
  5260. (hours < thresholds.h && ['hh', hours]) ||
  5261. (days <= 1 && ['d']) ||
  5262. (days < thresholds.d && ['dd', days]);
  5263. if (thresholds.w != null) {
  5264. a =
  5265. a ||
  5266. (weeks <= 1 && ['w']) ||
  5267. (weeks < thresholds.w && ['ww', weeks]);
  5268. }
  5269. a = a ||
  5270. (months <= 1 && ['M']) ||
  5271. (months < thresholds.M && ['MM', months]) ||
  5272. (years <= 1 && ['y']) || ['yy', years];
  5273. a[2] = withoutSuffix;
  5274. a[3] = +posNegDuration > 0;
  5275. a[4] = locale;
  5276. return substituteTimeAgo.apply(null, a);
  5277. }
  5278. // This function allows you to set the rounding function for relative time strings
  5279. function getSetRelativeTimeRounding(roundingFunction) {
  5280. if (roundingFunction === undefined) {
  5281. return round;
  5282. }
  5283. if (typeof roundingFunction === 'function') {
  5284. round = roundingFunction;
  5285. return true;
  5286. }
  5287. return false;
  5288. }
  5289. // This function allows you to set a threshold for relative time strings
  5290. function getSetRelativeTimeThreshold(threshold, limit) {
  5291. if (thresholds[threshold] === undefined) {
  5292. return false;
  5293. }
  5294. if (limit === undefined) {
  5295. return thresholds[threshold];
  5296. }
  5297. thresholds[threshold] = limit;
  5298. if (threshold === 's') {
  5299. thresholds.ss = limit - 1;
  5300. }
  5301. return true;
  5302. }
  5303. function humanize(argWithSuffix, argThresholds) {
  5304. if (!this.isValid()) {
  5305. return this.localeData().invalidDate();
  5306. }
  5307. var withSuffix = false,
  5308. th = thresholds,
  5309. locale,
  5310. output;
  5311. if (typeof argWithSuffix === 'object') {
  5312. argThresholds = argWithSuffix;
  5313. argWithSuffix = false;
  5314. }
  5315. if (typeof argWithSuffix === 'boolean') {
  5316. withSuffix = argWithSuffix;
  5317. }
  5318. if (typeof argThresholds === 'object') {
  5319. th = Object.assign({}, thresholds, argThresholds);
  5320. if (argThresholds.s != null && argThresholds.ss == null) {
  5321. th.ss = argThresholds.s - 1;
  5322. }
  5323. }
  5324. locale = this.localeData();
  5325. output = relativeTime$1(this, !withSuffix, th, locale);
  5326. if (withSuffix) {
  5327. output = locale.pastFuture(+this, output);
  5328. }
  5329. return locale.postformat(output);
  5330. }
  5331. var abs$1 = Math.abs;
  5332. function sign(x) {
  5333. return (x > 0) - (x < 0) || +x;
  5334. }
  5335. function toISOString$1() {
  5336. // for ISO strings we do not use the normal bubbling rules:
  5337. // * milliseconds bubble up until they become hours
  5338. // * days do not bubble at all
  5339. // * months bubble up until they become years
  5340. // This is because there is no context-free conversion between hours and days
  5341. // (think of clock changes)
  5342. // and also not between days and months (28-31 days per month)
  5343. if (!this.isValid()) {
  5344. return this.localeData().invalidDate();
  5345. }
  5346. var seconds = abs$1(this._milliseconds) / 1000,
  5347. days = abs$1(this._days),
  5348. months = abs$1(this._months),
  5349. minutes,
  5350. hours,
  5351. years,
  5352. s,
  5353. total = this.asSeconds(),
  5354. totalSign,
  5355. ymSign,
  5356. daysSign,
  5357. hmsSign;
  5358. if (!total) {
  5359. // this is the same as C#'s (Noda) and python (isodate)...
  5360. // but not other JS (goog.date)
  5361. return 'P0D';
  5362. }
  5363. // 3600 seconds -> 60 minutes -> 1 hour
  5364. minutes = absFloor(seconds / 60);
  5365. hours = absFloor(minutes / 60);
  5366. seconds %= 60;
  5367. minutes %= 60;
  5368. // 12 months -> 1 year
  5369. years = absFloor(months / 12);
  5370. months %= 12;
  5371. // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
  5372. s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : '';
  5373. totalSign = total < 0 ? '-' : '';
  5374. ymSign = sign(this._months) !== sign(total) ? '-' : '';
  5375. daysSign = sign(this._days) !== sign(total) ? '-' : '';
  5376. hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : '';
  5377. return (
  5378. totalSign +
  5379. 'P' +
  5380. (years ? ymSign + years + 'Y' : '') +
  5381. (months ? ymSign + months + 'M' : '') +
  5382. (days ? daysSign + days + 'D' : '') +
  5383. (hours || minutes || seconds ? 'T' : '') +
  5384. (hours ? hmsSign + hours + 'H' : '') +
  5385. (minutes ? hmsSign + minutes + 'M' : '') +
  5386. (seconds ? hmsSign + s + 'S' : '')
  5387. );
  5388. }
  5389. var proto$2 = Duration.prototype;
  5390. proto$2.isValid = isValid$1;
  5391. proto$2.abs = abs;
  5392. proto$2.add = add$1;
  5393. proto$2.subtract = subtract$1;
  5394. proto$2.as = as;
  5395. proto$2.asMilliseconds = asMilliseconds;
  5396. proto$2.asSeconds = asSeconds;
  5397. proto$2.asMinutes = asMinutes;
  5398. proto$2.asHours = asHours;
  5399. proto$2.asDays = asDays;
  5400. proto$2.asWeeks = asWeeks;
  5401. proto$2.asMonths = asMonths;
  5402. proto$2.asQuarters = asQuarters;
  5403. proto$2.asYears = asYears;
  5404. proto$2.valueOf = valueOf$1;
  5405. proto$2._bubble = bubble;
  5406. proto$2.clone = clone$1;
  5407. proto$2.get = get$2;
  5408. proto$2.milliseconds = milliseconds;
  5409. proto$2.seconds = seconds;
  5410. proto$2.minutes = minutes;
  5411. proto$2.hours = hours;
  5412. proto$2.days = days;
  5413. proto$2.weeks = weeks;
  5414. proto$2.months = months;
  5415. proto$2.years = years;
  5416. proto$2.humanize = humanize;
  5417. proto$2.toISOString = toISOString$1;
  5418. proto$2.toString = toISOString$1;
  5419. proto$2.toJSON = toISOString$1;
  5420. proto$2.locale = locale;
  5421. proto$2.localeData = localeData;
  5422. proto$2.toIsoString = deprecate(
  5423. 'toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)',
  5424. toISOString$1
  5425. );
  5426. proto$2.lang = lang;
  5427. // FORMATTING
  5428. addFormatToken('X', 0, 0, 'unix');
  5429. addFormatToken('x', 0, 0, 'valueOf');
  5430. // PARSING
  5431. addRegexToken('x', matchSigned);
  5432. addRegexToken('X', matchTimestamp);
  5433. addParseToken('X', function (input, array, config) {
  5434. config._d = new Date(parseFloat(input) * 1000);
  5435. });
  5436. addParseToken('x', function (input, array, config) {
  5437. config._d = new Date(toInt(input));
  5438. });
  5439. //! moment.js
  5440. hooks.version = '2.29.4';
  5441. setHookCallback(createLocal);
  5442. hooks.fn = proto;
  5443. hooks.min = min;
  5444. hooks.max = max;
  5445. hooks.now = now;
  5446. hooks.utc = createUTC;
  5447. hooks.unix = createUnix;
  5448. hooks.months = listMonths;
  5449. hooks.isDate = isDate;
  5450. hooks.locale = getSetGlobalLocale;
  5451. hooks.invalid = createInvalid;
  5452. hooks.duration = createDuration;
  5453. hooks.isMoment = isMoment;
  5454. hooks.weekdays = listWeekdays;
  5455. hooks.parseZone = createInZone;
  5456. hooks.localeData = getLocale;
  5457. hooks.isDuration = isDuration;
  5458. hooks.monthsShort = listMonthsShort;
  5459. hooks.weekdaysMin = listWeekdaysMin;
  5460. hooks.defineLocale = defineLocale;
  5461. hooks.updateLocale = updateLocale;
  5462. hooks.locales = listLocales;
  5463. hooks.weekdaysShort = listWeekdaysShort;
  5464. hooks.normalizeUnits = normalizeUnits;
  5465. hooks.relativeTimeRounding = getSetRelativeTimeRounding;
  5466. hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
  5467. hooks.calendarFormat = getCalendarFormat;
  5468. hooks.prototype = proto;
  5469. // currently HTML5 input type only supports 24-hour formats
  5470. hooks.HTML5_FMT = {
  5471. DATETIME_LOCAL: 'YYYY-MM-DDTHH:mm', // <input type="datetime-local" />
  5472. DATETIME_LOCAL_SECONDS: 'YYYY-MM-DDTHH:mm:ss', // <input type="datetime-local" step="1" />
  5473. DATETIME_LOCAL_MS: 'YYYY-MM-DDTHH:mm:ss.SSS', // <input type="datetime-local" step="0.001" />
  5474. DATE: 'YYYY-MM-DD', // <input type="date" />
  5475. TIME: 'HH:mm', // <input type="time" />
  5476. TIME_SECONDS: 'HH:mm:ss', // <input type="time" step="1" />
  5477. TIME_MS: 'HH:mm:ss.SSS', // <input type="time" step="0.001" />
  5478. WEEK: 'GGGG-[W]WW', // <input type="week" />
  5479. MONTH: 'YYYY-MM', // <input type="month" />
  5480. };
  5481. return hooks;
  5482. })));
  5483. define('moment', ['moment/moment'], function (main) { return main; });
  5484. define('frontend',['fast', 'template', 'moment'], function (Fast, Template, Moment) {
  5485. var Frontend = {
  5486. api: {
  5487. //发送验证码
  5488. sendcaptcha: function (btn, type, data, callback) {
  5489. $(btn).addClass("disabled", true).text("发送中...");
  5490. var si = {};
  5491. Frontend.api.ajax({url: $(btn).data("url"), data: data}, function (data, ret) {
  5492. clearInterval(si[type]);
  5493. var seconds = 60;
  5494. si[type] = setInterval(function () {
  5495. seconds--;
  5496. if (seconds <= 0) {
  5497. clearInterval(si);
  5498. $(btn).removeClass("disabled").text("发送验证码");
  5499. } else {
  5500. $(btn).addClass("disabled").text(seconds + "秒后可再次发送");
  5501. }
  5502. }, 1000);
  5503. if (typeof callback == 'function') {
  5504. callback.call(this, data, ret);
  5505. }
  5506. }, function () {
  5507. $(btn).removeClass("disabled").text('发送验证码');
  5508. });
  5509. },
  5510. //准备验证码
  5511. preparecaptcha: function (btn, type, data) {
  5512. require(['form'], function (Form) {
  5513. Layer.open({
  5514. title: '请完成验证',
  5515. type: 1,
  5516. content: Template("captchatpl", {}),
  5517. btnAlign: 'c',
  5518. success: function (layero, index) {
  5519. var form = $("form", layero);
  5520. form.data("validator-options", {
  5521. valid: function (ret) {
  5522. data.captcha = $("input[name=captcha]", form).val();
  5523. Frontend.api.sendcaptcha(btn, type, data, function (data, ret) {
  5524. Layer.close(index);
  5525. });
  5526. return true;
  5527. }
  5528. })
  5529. Form.api.bindevent(form);
  5530. }
  5531. });
  5532. });
  5533. }
  5534. },
  5535. init: function () {
  5536. //点击发送验证码
  5537. $(document).on("click", ".btn-captcha", function (e) {
  5538. var type = $(this).data("type") ? $(this).data("type") : 'mobile';
  5539. var btn = this;
  5540. if (['mobile', 'email'].indexOf(type) > -1) {
  5541. var element = $(this).data("input-id") ? $("#" + $(this).data("input-id")) : $("input[name='" + type + "']", $(this).closest("form"));
  5542. var text = type === 'email' ? '邮箱' : '手机号码';
  5543. if (element.val() === "") {
  5544. Layer.msg(text + "不能为空!");
  5545. element.focus();
  5546. return false;
  5547. } else if (type === 'mobile' && !element.val().match(/^1[3-9]\d{9}$/)) {
  5548. Layer.msg("请输入正确的" + text + "!");
  5549. element.focus();
  5550. return false;
  5551. } else if (type === 'email' && !element.val().match(/^[\w\+\-]+(\.[\w\+\-]+)*@[a-z\d\-]+(\.[a-z\d\-]+)*\.([a-z]{2,4})$/)) {
  5552. Layer.msg("请输入正确的" + text + "!");
  5553. element.focus();
  5554. return false;
  5555. }
  5556. element.isValid(function (v) {
  5557. if (v) {
  5558. var data = {event: $(btn).data("event"), id: $(btn).data("id")};
  5559. data[type] = element.val();
  5560. if ($("#captchatpl").length === 0) {
  5561. Frontend.api.sendcaptcha(btn, type, data);
  5562. } else {
  5563. Frontend.api.preparecaptcha(btn, type, data);
  5564. }
  5565. } else {
  5566. Layer.msg("请确认已经输入了正确的" + text + "!");
  5567. }
  5568. });
  5569. } else {
  5570. var data = {event: $(btn).data("event")};
  5571. Frontend.api.sendcaptcha(btn, type, data, function (data, ret) {
  5572. Layer.open({
  5573. title: false,
  5574. area: [Math.min($(window).width(), 400) + "px", "430px"],
  5575. content: "<img src='" + data.image + "' width='400' height='400' /><div class='text-center panel-title'>扫一扫关注公众号获取验证码</div>",
  5576. type: 1
  5577. });
  5578. });
  5579. }
  5580. return false;
  5581. });
  5582. //tooltip和popover
  5583. if (!('ontouchstart' in document.documentElement)) {
  5584. $('body').tooltip({selector: '[data-toggle="tooltip"]'});
  5585. }
  5586. $('body').popover({selector: '[data-toggle="popover"]'});
  5587. // 手机端左右滑动切换菜单栏
  5588. if ('ontouchstart' in document.documentElement) {
  5589. var startX, startY, moveEndX, moveEndY, relativeX, relativeY, element;
  5590. element = $('body', document);
  5591. element.on("touchstart", function (e) {
  5592. startX = e.originalEvent.changedTouches[0].pageX;
  5593. startY = e.originalEvent.changedTouches[0].pageY;
  5594. });
  5595. element.on("touchend", function (e) {
  5596. moveEndX = e.originalEvent.changedTouches[0].pageX;
  5597. moveEndY = e.originalEvent.changedTouches[0].pageY;
  5598. relativeX = moveEndX - startX;
  5599. relativeY = moveEndY - startY;
  5600. // 判断标准
  5601. //右滑
  5602. if (relativeX > 45) {
  5603. if ((Math.abs(relativeX) - Math.abs(relativeY)) > 50) {
  5604. element.addClass("sidebar-open");
  5605. }
  5606. }
  5607. //左滑
  5608. else if (relativeX < -45) {
  5609. if ((Math.abs(relativeX) - Math.abs(relativeY)) > 50) {
  5610. element.removeClass("sidebar-open");
  5611. }
  5612. }
  5613. });
  5614. }
  5615. $(document).on("click", ".sidebar-toggle", function () {
  5616. $("body").toggleClass("sidebar-open");
  5617. });
  5618. }
  5619. };
  5620. Frontend.api = $.extend(Fast.api, Frontend.api);
  5621. //将Template渲染至全局,以便于在子框架中调用
  5622. window.Template = Template;
  5623. //将Moment渲染至全局,以便于在子框架中调用
  5624. window.Moment = Moment;
  5625. //将Frontend渲染至全局,以便于在子框架中调用
  5626. window.Frontend = Frontend;
  5627. Frontend.init();
  5628. return Frontend;
  5629. });
  5630. define('frontend-init',['frontend'], function (Frontend) {
  5631. });
  5632. //! moment.js locale configuration
  5633. //! locale : Chinese (China) [zh-cn]
  5634. //! author : suupic : https://github.com/suupic
  5635. //! author : Zeno Zeng : https://github.com/zenozeng
  5636. //! author : uu109 : https://github.com/uu109
  5637. ;(function (global, factory) {
  5638. typeof exports === 'object' && typeof module !== 'undefined'
  5639. && typeof require === 'function' ? factory(require('../moment')) :
  5640. typeof define === 'function' && define.amd ? define('moment/locale/zh-cn',['../moment'], factory) :
  5641. factory(global.moment)
  5642. }(this, (function (moment) { 'use strict';
  5643. //! moment.js locale configuration
  5644. var zhCn = moment.defineLocale('zh-cn', {
  5645. months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split(
  5646. '_'
  5647. ),
  5648. monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split(
  5649. '_'
  5650. ),
  5651. weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
  5652. weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'),
  5653. weekdaysMin: '日_一_二_三_四_五_六'.split('_'),
  5654. longDateFormat: {
  5655. LT: 'HH:mm',
  5656. LTS: 'HH:mm:ss',
  5657. L: 'YYYY/MM/DD',
  5658. LL: 'YYYY年M月D日',
  5659. LLL: 'YYYY年M月D日Ah点mm分',
  5660. LLLL: 'YYYY年M月D日ddddAh点mm分',
  5661. l: 'YYYY/M/D',
  5662. ll: 'YYYY年M月D日',
  5663. lll: 'YYYY年M月D日 HH:mm',
  5664. llll: 'YYYY年M月D日dddd HH:mm',
  5665. },
  5666. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  5667. meridiemHour: function (hour, meridiem) {
  5668. if (hour === 12) {
  5669. hour = 0;
  5670. }
  5671. if (meridiem === '凌晨' || meridiem === '早上' || meridiem === '上午') {
  5672. return hour;
  5673. } else if (meridiem === '下午' || meridiem === '晚上') {
  5674. return hour + 12;
  5675. } else {
  5676. // '中午'
  5677. return hour >= 11 ? hour : hour + 12;
  5678. }
  5679. },
  5680. meridiem: function (hour, minute, isLower) {
  5681. var hm = hour * 100 + minute;
  5682. if (hm < 600) {
  5683. return '凌晨';
  5684. } else if (hm < 900) {
  5685. return '早上';
  5686. } else if (hm < 1130) {
  5687. return '上午';
  5688. } else if (hm < 1230) {
  5689. return '中午';
  5690. } else if (hm < 1800) {
  5691. return '下午';
  5692. } else {
  5693. return '晚上';
  5694. }
  5695. },
  5696. calendar: {
  5697. sameDay: '[今天]LT',
  5698. nextDay: '[明天]LT',
  5699. nextWeek: function (now) {
  5700. if (now.week() !== this.week()) {
  5701. return '[下]dddLT';
  5702. } else {
  5703. return '[本]dddLT';
  5704. }
  5705. },
  5706. lastDay: '[昨天]LT',
  5707. lastWeek: function (now) {
  5708. if (this.week() !== now.week()) {
  5709. return '[上]dddLT';
  5710. } else {
  5711. return '[本]dddLT';
  5712. }
  5713. },
  5714. sameElse: 'L',
  5715. },
  5716. dayOfMonthOrdinalParse: /\d{1,2}(日|月|周)/,
  5717. ordinal: function (number, period) {
  5718. switch (period) {
  5719. case 'd':
  5720. case 'D':
  5721. case 'DDD':
  5722. return number + '日';
  5723. case 'M':
  5724. return number + '月';
  5725. case 'w':
  5726. case 'W':
  5727. return number + '周';
  5728. default:
  5729. return number;
  5730. }
  5731. },
  5732. relativeTime: {
  5733. future: '%s后',
  5734. past: '%s前',
  5735. s: '几秒',
  5736. ss: '%d 秒',
  5737. m: '1 分钟',
  5738. mm: '%d 分钟',
  5739. h: '1 小时',
  5740. hh: '%d 小时',
  5741. d: '1 天',
  5742. dd: '%d 天',
  5743. w: '1 周',
  5744. ww: '%d 周',
  5745. M: '1 个月',
  5746. MM: '%d 个月',
  5747. y: '1 年',
  5748. yy: '%d 年',
  5749. },
  5750. week: {
  5751. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  5752. dow: 1, // Monday is the first day of the week.
  5753. doy: 4, // The week that contains Jan 4th is the first week of the year.
  5754. },
  5755. });
  5756. return zhCn;
  5757. })));
  5758. /*
  5759. * bootstrap-table - v1.11.9 - 2022-10-27
  5760. https://github.com/wenzhixin/bootstrap-table
  5761. * Copyright (c) 2017 zhixin wen
  5762. * Licensed MIT License
  5763. */
  5764. !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);
  5765. define("bootstrap-table", ["bootstrap"], (function (global) {
  5766. return function () {
  5767. var ret, fn;
  5768. return ret || global.$.fn.bootstrapTable;
  5769. };
  5770. }(this)));
  5771. /**
  5772. * Bootstrap Table Chinese translation
  5773. * Author: Zhixin Wen<wenzhixin2010@gmail.com>
  5774. */
  5775. (function ($) {
  5776. 'use strict';
  5777. $.fn.bootstrapTable.locales['zh-CN'] = {
  5778. formatLoadingMessage: function () {
  5779. return '正在努力地加载数据中,请稍候……';
  5780. },
  5781. formatRecordsPerPage: function (pageNumber) {
  5782. return '每页显示 ' + pageNumber + ' 条记录';
  5783. },
  5784. formatShowingRows: function (pageFrom, pageTo, totalRows) {
  5785. return '显示第 ' + pageFrom + ' 到第 ' + pageTo + ' 条记录,总共 ' + totalRows + ' 条记录';
  5786. },
  5787. formatSearch: function () {
  5788. return '搜索';
  5789. },
  5790. formatNoMatches: function () {
  5791. return '没有找到匹配的记录';
  5792. },
  5793. formatPaginationSwitch: function () {
  5794. return '隐藏/显示分页';
  5795. },
  5796. formatRefresh: function () {
  5797. return '刷新';
  5798. },
  5799. formatToggle: function () {
  5800. return '切换';
  5801. },
  5802. formatColumns: function () {
  5803. return '列';
  5804. },
  5805. formatExport: function () {
  5806. return '导出数据';
  5807. },
  5808. formatClearFilters: function () {
  5809. return '清空过滤';
  5810. }
  5811. };
  5812. $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['zh-CN']);
  5813. })(jQuery);
  5814. define("bootstrap-table-lang", ["bootstrap-table"], (function (global) {
  5815. return function () {
  5816. var ret, fn;
  5817. return ret || global.$.fn.bootstrapTable.defaults;
  5818. };
  5819. }(this)));
  5820. /*
  5821. * bootstrap-table - v1.11.9 - 2022-10-27
  5822. https://github.com/wenzhixin/bootstrap-table
  5823. * Copyright (c) 2017 zhixin wen
  5824. * Licensed MIT License
  5825. */
  5826. !function(p){"use strict";var o=p.fn.bootstrapTable.utils.sprintf,i={json:"JSON",xml:"XML",png:"PNG",csv:"CSV",txt:"TXT",sql:"SQL",doc:"MS-Word",excel:"MS-Excel",xlsx:"MS-Excel (OpenXML)",powerpoint:"MS-Powerpoint",pdf:"PDF"},t=(p.extend(p.fn.bootstrapTable.defaults,{showExport:!1,exportDataType:"basic",exportTypes:["json","xml","csv","txt","sql","excel"],exportOptions:{}}),p.extend(p.fn.bootstrapTable.defaults.icons,{export:"glyphicon-export icon-share"}),p.extend(p.fn.bootstrapTable.locales,{formatExport:function(){return"Export data"}}),p.extend(p.fn.bootstrapTable.defaults,p.fn.bootstrapTable.locales),p.fn.bootstrapTable.Constructor),a=t.prototype.initToolbar;t.prototype.initToolbar=function(){var s,e,t,n;this.showToolbar=this.options.showExport,a.apply(this,Array.prototype.slice.apply(arguments)),this.options.showExport&&!(t=(s=this).$toolbar.find(">.btn-group")).find("div.export").length&&(e=p(['<div class="export btn-group">','<button class="btn'+o(" btn-%s",this.options.buttonsClass)+o(" btn-%s",this.options.iconSize)+' dropdown-toggle" aria-label="export type" title="'+this.options.formatExport()+'" data-toggle="dropdown" type="button">',o('<i class="%s %s"></i> ',this.options.iconsPrefix,this.options.icons.export),'<span class="caret"></span>',"</button>",'<ul class="dropdown-menu" role="menu">',"</ul>","</div>"].join("")).appendTo(t).find(".dropdown-menu"),n=this.options.exportTypes,"string"==typeof this.options.exportTypes&&(t=this.options.exportTypes.slice(1,-1).replace(/ /g,"").split(","),n=[],p.each(t,function(t,o){n.push(o.slice(1,-1))})),p.each(n,function(t,o){i.hasOwnProperty(o)&&e.append(['<li role="menuitem" data-type="'+o+'">','<a href="javascript:void(0)">',i[o],"</a>","</li>"].join(""))}),e.find("li").click(function(){function t(){if("function"!=typeof require)throw new Error("RequireJS not found");require(["tableexport"],function(){s.$el.tableExport(p.extend({},s.options.exportOptions,{type:i,escape:!1}))})}var o,e,n,i=p(this).data("type");"all"===s.options.exportDataType&&s.options.pagination?(s.$el.one("server"===s.options.sidePagination?"post-body.bs.table":"page-change.bs.table",function(){t(),s.togglePagination()}),s.togglePagination()):"selected"===s.options.exportDataType?(o=s.getData(),n=s.getAllSelections(),"server"===s.options.sidePagination&&((o={total:s.options.totalRows})[s.options.dataField]=s.getData(),e="function"==typeof require?require("table"):null,(n={total:s.options.totalRows})[s.options.dataField]=e&&s.options.maintainSelected?e.api.selecteddata(s.$el):s.getAllSelections()),s.load(n),t(),s.load(o)):t()}))}}(jQuery);
  5827. define("bootstrap-table-export", ["bootstrap-table"], (function (global) {
  5828. return function () {
  5829. var ret, fn;
  5830. return ret || global.$.fn.bootstrapTable.defaults;
  5831. };
  5832. }(this)));
  5833. (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});
  5834. define('upload',['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined, Dropzone, Template) {
  5835. var Upload = {
  5836. list: {},
  5837. options: {},
  5838. config: {
  5839. container: document.body,
  5840. classname: '.plupload:not([initialized]),.faupload:not([initialized])',
  5841. 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>',
  5842. },
  5843. events: {
  5844. //初始化
  5845. onInit: function () {
  5846. },
  5847. //上传成功的回调
  5848. onUploadSuccess: function (up, ret, file) {
  5849. var button = up.element;
  5850. var onUploadSuccess = up.options.onUploadSuccess;
  5851. var data = typeof ret.data !== 'undefined' ? ret.data : null;
  5852. //上传成功后回调
  5853. if (button) {
  5854. //如果有文本框则填充
  5855. var input_id = $(button).data("input-id") ? $(button).data("input-id") : "";
  5856. if (input_id) {
  5857. var urlArr = [];
  5858. var inputObj = $("#" + input_id);
  5859. if ($(button).data("multiple") && inputObj.val() !== "") {
  5860. urlArr.push(inputObj.val());
  5861. }
  5862. var url = Config.upload.fullmode ? (data.fullurl ? data.fullurl : Fast.api.cdnurl(data.url)) : data.url;
  5863. urlArr.push(url);
  5864. inputObj.val(urlArr.join(",")).trigger("change").trigger("validate");
  5865. }
  5866. //如果有回调函数
  5867. var onDomUploadSuccess = $(button).data("upload-success");
  5868. if (onDomUploadSuccess) {
  5869. if (typeof onDomUploadSuccess !== 'function' && typeof Upload.api.custom[onDomUploadSuccess] === 'function') {
  5870. onDomUploadSuccess = Upload.api.custom[onDomUploadSuccess];
  5871. }
  5872. if (typeof onDomUploadSuccess === 'function') {
  5873. var result = onDomUploadSuccess.call(button, data, ret);
  5874. if (result === false)
  5875. return;
  5876. }
  5877. }
  5878. }
  5879. if (typeof onUploadSuccess === 'function') {
  5880. var result = onUploadSuccess.call(button, data, ret);
  5881. if (result === false)
  5882. return;
  5883. }
  5884. },
  5885. //上传错误的回调
  5886. onUploadError: function (up, ret, file) {
  5887. var button = up.element;
  5888. var onUploadError = up.options.onUploadError;
  5889. var data = typeof ret.data !== 'undefined' ? ret.data : null;
  5890. if (button) {
  5891. var onDomUploadError = $(button).data("upload-error");
  5892. if (onDomUploadError) {
  5893. if (typeof onDomUploadError !== 'function' && typeof Upload.api.custom[onDomUploadError] === 'function') {
  5894. onDomUploadError = Upload.api.custom[onDomUploadError];
  5895. }
  5896. if (typeof onDomUploadError === 'function') {
  5897. var result = onDomUploadError.call(button, data, ret);
  5898. if (result === false)
  5899. return;
  5900. }
  5901. }
  5902. }
  5903. if (typeof onUploadError === 'function') {
  5904. var result = onUploadError.call(button, data, ret);
  5905. if (result === false) {
  5906. return;
  5907. }
  5908. }
  5909. Toastr.error(ret.msg.toString().replace(/(<([^>]+)>)/gi, "") + "(code:" + ret.code + ")");
  5910. },
  5911. //服务器响应数据后
  5912. onUploadResponse: function (response, up, file) {
  5913. try {
  5914. var ret = typeof response === 'object' ? response : JSON.parse(response);
  5915. if (!ret.hasOwnProperty('code')) {
  5916. $.extend(ret, {code: -2, msg: response, data: null});
  5917. }
  5918. } catch (e) {
  5919. var ret = {code: -1, msg: e.message, data: null};
  5920. }
  5921. return ret;
  5922. },
  5923. //上传全部结束后
  5924. onUploadComplete: function (up, files) {
  5925. var button = up.element;
  5926. var onUploadComplete = up.options.onUploadComplete;
  5927. if (button) {
  5928. var onDomUploadComplete = $(button).data("upload-complete");
  5929. if (onDomUploadComplete) {
  5930. if (typeof onDomUploadComplete !== 'function' && typeof Upload.api.custom[onDomUploadComplete] === 'function') {
  5931. onDomUploadComplete = Upload.api.custom[onDomUploadComplete];
  5932. }
  5933. if (typeof onDomUploadComplete === 'function') {
  5934. var result = onDomUploadComplete.call(button, files);
  5935. if (result === false)
  5936. return;
  5937. }
  5938. }
  5939. }
  5940. if (typeof onUploadComplete === 'function') {
  5941. var result = onUploadComplete.call(button, files);
  5942. if (result === false) {
  5943. return;
  5944. }
  5945. }
  5946. }
  5947. },
  5948. api: {
  5949. //上传接口
  5950. upload: function (element, onUploadSuccess, onUploadError, onUploadComplete) {
  5951. element = typeof element === 'undefined' ? Upload.config.classname : element;
  5952. $(element, Upload.config.container).each(function () {
  5953. if ($(this).attr("initialized")) {
  5954. return true;
  5955. }
  5956. $(this).attr("initialized", true);
  5957. var that = this;
  5958. var id = $(this).prop("id") || $(this).prop("name") || Dropzone.uuidv4();
  5959. var url = $(this).data("url");
  5960. var maxsize = $(this).data("maxsize");
  5961. var maxcount = $(this).data("maxcount");
  5962. var mimetype = $(this).data("mimetype");
  5963. var multipart = $(this).data("multipart");
  5964. var multiple = $(this).data("multiple");
  5965. //填充ID
  5966. var input_id = $(that).data("input-id") ? $(that).data("input-id") : "";
  5967. //预览ID
  5968. var preview_id = $(that).data("preview-id") ? $(that).data("preview-id") : "";
  5969. //上传URL
  5970. url = url ? url : Config.upload.uploadurl;
  5971. url = Fast.api.fixurl(url);
  5972. var chunking = false, chunkSize = Config.upload.chunksize || 2097152, timeout = Config.upload.timeout || 600000;
  5973. //最大可上传文件大小
  5974. maxsize = typeof maxsize !== "undefined" ? maxsize : Config.upload.maxsize;
  5975. //文件类型
  5976. mimetype = typeof mimetype !== "undefined" ? mimetype : Config.upload.mimetype;
  5977. //请求的表单参数
  5978. multipart = typeof multipart !== "undefined" ? multipart : Config.upload.multipart;
  5979. //是否支持批量上传
  5980. multiple = typeof multiple !== "undefined" ? multiple : Config.upload.multiple;
  5981. //后缀特殊处理
  5982. mimetype = mimetype.split(",").map(function (k) {
  5983. return k.indexOf("/") > -1 ? k : (!k || k === "*" || k.charAt(0) === "." ? k : "." + k);
  5984. }).join(",");
  5985. mimetype = mimetype === '*' ? null : mimetype;
  5986. //最大文件限制转换成mb
  5987. var maxFilesize = (function (maxsize) {
  5988. var matches = maxsize.toString().match(/^([0-9\.]+)(\w+)$/);
  5989. var size = matches ? parseFloat(matches[1]) : parseFloat(maxsize),
  5990. unit = matches ? matches[2].toLowerCase() : 'b';
  5991. var unitDict = {'b': 0, 'k': 1, 'kb': 1, 'm': 2, 'mb': 2, 'gb': 3, 'g': 3, 'tb': 4, 't': 4};
  5992. var y = typeof unitDict[unit] !== 'undefined' ? unitDict[unit] : 0;
  5993. var bytes = size * Math.pow(1024, y);
  5994. return bytes / Math.pow(1024, 2);
  5995. }(maxsize));
  5996. var options = $(this).data() || {};
  5997. options = $.extend(true, {}, options, $(this).data("upload-options") || {});
  5998. delete options.success;
  5999. delete options.url;
  6000. // delete options.params;
  6001. multipart = $.isArray(multipart) ? {} : multipart;
  6002. Upload.list[id] = new Dropzone(this, $.extend({
  6003. url: url,
  6004. params: function (files, xhr, chunk) {
  6005. var params = multipart;
  6006. if (chunk) {
  6007. return $.extend({}, params, {
  6008. filesize: chunk.file.size,
  6009. filename: chunk.file.name,
  6010. chunkid: chunk.file.upload.uuid,
  6011. chunkindex: chunk.index,
  6012. chunkcount: chunk.file.upload.totalChunkCount,
  6013. chunksize: this.options.chunkSize,
  6014. chunkfilesize: chunk.dataBlock.data.size,
  6015. width: chunk.file.width || 0,
  6016. height: chunk.file.height || 0,
  6017. type: chunk.file.type,
  6018. });
  6019. }
  6020. return params;
  6021. },
  6022. chunking: chunking,
  6023. chunkSize: chunkSize,
  6024. maxFilesize: maxFilesize,
  6025. acceptedFiles: mimetype,
  6026. maxFiles: (maxcount && parseInt(maxcount) > 1 ? maxcount : (multiple ? null : 1)),
  6027. timeout: timeout,
  6028. parallelUploads: 1,
  6029. previewsContainer: false,
  6030. dictDefaultMessage: __("Drop files here to upload"),
  6031. dictFallbackMessage: __("Your browser does not support drag'n'drop file uploads"),
  6032. dictFallbackText: __("Please use the fallback form below to upload your files like in the olden days"),
  6033. dictFileTooBig: __("File is too big (%sMiB), Max filesize: %sMiB", "{{filesize}}", "{{maxFilesize}}"),
  6034. dictInvalidFileType: __("You can't upload files of this type"),
  6035. dictResponseError: __("Server responded with %s code.", "{{statusCode}}"),
  6036. dictCancelUpload: __("Cancel upload"),
  6037. dictUploadCanceled: __("Upload canceled"),
  6038. dictCancelUploadConfirmation: __("Are you sure you want to cancel this upload?"),
  6039. dictRemoveFile: __("Remove file"),
  6040. dictMaxFilesExceeded: __("You can only upload a maximum of %s files", "{{maxFiles}}"),
  6041. init: function () {
  6042. Upload.events.onInit.call(this);
  6043. //必须添加dz-message,否则点击icon无法唤起上传窗口
  6044. $(">i", this.element).addClass("dz-message");
  6045. this.options.elementHtml = $(this.element).html();
  6046. },
  6047. sending: function (file, xhr, formData) {
  6048. if (typeof file.category !== 'undefined') {
  6049. formData.append('category', file.category);
  6050. }
  6051. },
  6052. addedfile: function (file) {
  6053. var params = $(this.element).data("params") || {};
  6054. params = typeof params === 'function' ? params.call(this, file) : params;
  6055. var category = typeof params.category !== 'undefined' ? params.category : ($(this.element).data("category") || '');
  6056. file.category = typeof category === 'function' ? category.call(this, file) : category;
  6057. },
  6058. addedfiles: function (files) {
  6059. if (this.options.maxFiles && (!this.options.maxFiles || this.options.maxFiles > 1) && this.options.inputId) {
  6060. var inputObj = $("#" + this.options.inputId);
  6061. if (inputObj.length > 0) {
  6062. var value = $.trim(inputObj.val());
  6063. var nums = value === '' ? 0 : value.split(/\,/).length;
  6064. var remain = this.options.maxFiles - nums;
  6065. if (remain === 0 || files.length > remain) {
  6066. files = Array.prototype.slice.call(files, remain);
  6067. for (var i = 0; i < files.length; i++) {
  6068. this.removeFile(files[i]);
  6069. }
  6070. Toastr.error(__("You can only upload a maximum of %s files", this.options.maxFiles));
  6071. }
  6072. }
  6073. }
  6074. },
  6075. success: function (file, response) {
  6076. var ret = Upload.events.onUploadResponse(response, this, file);
  6077. file.ret = ret;
  6078. if (ret.code === 1) {
  6079. Upload.events.onUploadSuccess(this, ret, file);
  6080. } else {
  6081. Upload.events.onUploadError(this, ret, file);
  6082. }
  6083. },
  6084. error: function (file, response, xhr) {
  6085. var responseObj = $("<div>" + (xhr && typeof xhr.responseText !== 'undefined' ? xhr.responseText : response) + "</div>");
  6086. responseObj.find("style, title, script").remove();
  6087. var msg = responseObj.text() || __('Network error');
  6088. var ret = {code: 0, data: null, msg: msg};
  6089. Upload.events.onUploadError(this, ret, file);
  6090. },
  6091. uploadprogress: function (file, progress, bytesSent) {
  6092. if (file.upload.chunked) {
  6093. $(this.element).prop("disabled", true).html("<i class='fa fa-upload'></i> " + __('Upload') + Math.floor((file.upload.bytesSent / file.size) * 100) + "%");
  6094. }
  6095. },
  6096. totaluploadprogress: function (progress, bytesSent) {
  6097. if (this.getActiveFiles().length > 0 && !this.options.chunking) {
  6098. $(this.element).prop("disabled", true).html("<i class='fa fa-upload'></i> " + __('Upload') + Math.floor(progress) + "%");
  6099. }
  6100. },
  6101. queuecomplete: function () {
  6102. Upload.events.onUploadComplete(this, this.files);
  6103. this.removeAllFiles(true);
  6104. $(this.element).prop("disabled", false).html(this.options.elementHtml);
  6105. },
  6106. chunkSuccess: function (chunk, file, response) {
  6107. },
  6108. chunksUploaded: function (file, done) {
  6109. var that = this;
  6110. Fast.api.ajax({
  6111. url: this.options.url,
  6112. data: $.extend({}, multipart, {
  6113. action: 'merge',
  6114. filesize: file.size,
  6115. filename: file.name,
  6116. chunkid: file.upload.uuid,
  6117. chunkcount: file.upload.totalChunkCount,
  6118. })
  6119. }, function (data, ret) {
  6120. done(JSON.stringify(ret));
  6121. return false;
  6122. }, function (data, ret) {
  6123. file.accepted = false;
  6124. that._errorProcessing([file], ret.msg);
  6125. });
  6126. },
  6127. onUploadSuccess: onUploadSuccess,
  6128. onUploadError: onUploadError,
  6129. onUploadComplete: onUploadComplete,
  6130. }, Upload.options, options));
  6131. //拖动排序
  6132. if (preview_id && multiple) {
  6133. require(['dragsort'], function () {
  6134. $("#" + preview_id).dragsort({
  6135. dragSelector: "li a:not(.btn-trash)",
  6136. dragEnd: function () {
  6137. $("#" + preview_id).trigger("fa.preview.change");
  6138. },
  6139. placeHolderTemplate: '<li class="col-xs-3"></li>'
  6140. });
  6141. });
  6142. }
  6143. //刷新隐藏textarea的值
  6144. var refresh = function (name) {
  6145. var data = {};
  6146. var textarea = $("textarea[name='" + name + "']");
  6147. var container = textarea.prev("ul");
  6148. $.each($("input,select,textarea", container).serializeArray(), function (i, j) {
  6149. var reg = /\[?(\w+)\]?\[(\w+)\]$/g;
  6150. var match = reg.exec(j.name);
  6151. if (!match)
  6152. return true;
  6153. if (!isNaN(match[2])) {
  6154. data[i] = j.value;
  6155. } else {
  6156. match[1] = "x" + parseInt(match[1]);
  6157. if (typeof data[match[1]] === 'undefined') {
  6158. data[match[1]] = {};
  6159. }
  6160. data[match[1]][match[2]] = j.value;
  6161. }
  6162. });
  6163. var result = [];
  6164. $.each(data, function (i, j) {
  6165. result.push(j);
  6166. });
  6167. textarea.val(JSON.stringify(result));
  6168. };
  6169. if (preview_id && input_id) {
  6170. $(document.body).on("keyup change", "#" + input_id, function (e) {
  6171. var inputStr = $("#" + input_id).val();
  6172. var inputArr = inputStr.split(/\,/);
  6173. var previewObj = $("#" + preview_id);
  6174. previewObj.empty();
  6175. var tpl = previewObj.data("template") ? previewObj.data("template") : "";
  6176. var extend = previewObj.next().is("textarea") ? previewObj.next("textarea").val() : "{}";
  6177. var json = {};
  6178. try {
  6179. json = JSON.parse(extend);
  6180. } catch (e) {
  6181. }
  6182. $.each(inputArr, function (i, j) {
  6183. if (!j) {
  6184. return true;
  6185. }
  6186. var suffix = /[\.]?([a-zA-Z0-9]+)$/.exec(j);
  6187. suffix = suffix ? suffix[1] : 'file';
  6188. var btnData = $(that).data();
  6189. var fullurl = typeof btnData.cdnurl!=='undefined' ? Fast.api.cdnurl(j, btnData.cdnurl) : Fast.api.cdnurl(j);
  6190. j = Config.upload.fullmode ? fullurl : j;
  6191. var value = (json && typeof json[i] !== 'undefined' ? json[i] : null);
  6192. var data = {url: j, fullurl: fullurl, data: btnData, key: i, index: i, value: value, row: value, suffix: suffix};
  6193. var html = tpl ? Template(tpl, data) : Template.render(Upload.config.previewtpl, data);
  6194. previewObj.append(html);
  6195. });
  6196. refresh(previewObj.data("name"));
  6197. });
  6198. $("#" + input_id).trigger("change");
  6199. }
  6200. if (preview_id) {
  6201. //监听文本框改变事件
  6202. $("#" + preview_id).on('change keyup', "input,textarea,select", function () {
  6203. refresh($(this).closest("ul").data("name"));
  6204. });
  6205. // 监听事件
  6206. $(document.body).on("fa.preview.change", "#" + preview_id, function () {
  6207. var urlArr = [];
  6208. $("#" + preview_id + " [data-url]").each(function (i, j) {
  6209. urlArr.push($(this).data("url"));
  6210. });
  6211. if (input_id) {
  6212. $("#" + input_id).val(urlArr.join(","));
  6213. }
  6214. refresh($("#" + preview_id).data("name"));
  6215. });
  6216. // 移除按钮事件
  6217. $(document.body).on("click", "#" + preview_id + " .btn-trash", function () {
  6218. $(this).closest("li").remove();
  6219. $("#" + preview_id).trigger("fa.preview.change");
  6220. });
  6221. }
  6222. if (input_id) {
  6223. //粘贴上传、拖拽上传
  6224. $("body").on('paste drop', "#" + input_id, function (event) {
  6225. var originEvent = event.originalEvent;
  6226. var button = $(".plupload[data-input-id='" + $(this).attr("id") + "'],.faupload[data-input-id='" + $(this).attr("id") + "']");
  6227. if (event.type === 'paste' && originEvent.clipboardData && originEvent.clipboardData.items) {
  6228. var items = originEvent.clipboardData.items;
  6229. if ((items.length === 1 && items[0].type.indexOf("text") > -1) || (items.length === 2 && items[1].type.indexOf("text") > -1)) {
  6230. } else {
  6231. Upload.list[button.attr("id")].paste(originEvent);
  6232. return false;
  6233. }
  6234. }
  6235. if (event.type === 'drop' && originEvent.dataTransfer && originEvent.dataTransfer.files) {
  6236. Upload.list[button.attr("id")].drop(originEvent);
  6237. return false;
  6238. }
  6239. });
  6240. }
  6241. });
  6242. },
  6243. /**
  6244. * @deprecated Use upload instead.
  6245. */
  6246. plupload: function (element, onUploadSuccess, onUploadError, onUploadComplete) {
  6247. return Upload.api.upload(element, onUploadSuccess, onUploadError, onUploadComplete);
  6248. },
  6249. /**
  6250. * @deprecated Use upload instead.
  6251. */
  6252. faupload: function (element, onUploadSuccess, onUploadError, onUploadComplete) {
  6253. return Upload.api.upload(element, onUploadSuccess, onUploadError, onUploadComplete);
  6254. },
  6255. // AJAX异步上传
  6256. send: function (file, onUploadSuccess, onUploadError, onUploadComplete) {
  6257. var index = Layer.msg(__('Uploading'), {offset: 't', time: 0});
  6258. var id = "dropzone-" + Dropzone.uuidv4();
  6259. $('<button type="button" id="' + id + '" class="btn btn-danger hidden faupload" />').appendTo("body");
  6260. $("#" + id).data("upload-complete", function (files) {
  6261. Layer.close(index);
  6262. Upload.list[id].removeAllFiles(true);
  6263. });
  6264. Upload.api.upload("#" + id, onUploadSuccess, onUploadError, onUploadComplete);
  6265. setTimeout(function () {
  6266. Upload.list[id].addFile(file);
  6267. }, 1);
  6268. },
  6269. custom: {
  6270. //自定义上传完成回调
  6271. afteruploadcallback: function (response) {
  6272. console.log(this, response);
  6273. alert("Custom Callback,Response URL:" + response.url);
  6274. },
  6275. }
  6276. }
  6277. }
  6278. ;
  6279. return Upload;
  6280. });
  6281. /*! nice-validator 1.1.5
  6282. * (c) 2012-2020 Jony Zhang <niceue@live.com>, MIT Licensed
  6283. * https://github.com/niceue/nice-validator
  6284. */
  6285. ;(function(factory) {
  6286. typeof module === 'object' && module.exports ? module.exports = factory( require( 'jquery' ) ) :
  6287. typeof define === 'function' && define.amd ? define('validator',['jquery'], factory) :
  6288. factory(jQuery);
  6289. }(function($, undefined) {
  6290. 'use strict';
  6291. var NS = 'validator',
  6292. CLS_NS = '.' + NS,
  6293. CLS_NS_RULE = '.rule',
  6294. CLS_NS_FIELD = '.field',
  6295. CLS_NS_FORM = '.form',
  6296. CLS_WRAPPER = 'nice-' + NS,
  6297. CLS_MSG_BOX = 'msg-box',
  6298. ARIA_INVALID = 'aria-invalid',
  6299. DATA_RULE = 'data-rule',
  6300. DATA_MSG = 'data-msg',
  6301. DATA_TIP = 'data-tip',
  6302. DATA_OK = 'data-ok',
  6303. DATA_TIMELY = 'data-timely',
  6304. DATA_TARGET = 'data-target',
  6305. DATA_DISPLAY = 'data-display',
  6306. DATA_MUST = 'data-must',
  6307. NOVALIDATE = 'novalidate',
  6308. INPUT_SELECTOR = ':verifiable',
  6309. rRules = /(&)?(!)?\b(\w+)(?:\[\s*(.*?\]?)\s*\]|\(\s*(.*?\)?)\s*\))?\s*(;|\|)?/g,
  6310. rRule = /(\w+)(?:\[\s*(.*?\]?)\s*\]|\(\s*(.*?\)?)\s*\))?/,
  6311. rDisplay = /(?:([^:;\(\[]*):)?(.*)/,
  6312. rDoubleBytes = /[^\x00-\xff]/g,
  6313. rPos = /top|right|bottom|left/,
  6314. rAjaxType = /(?:(cors|jsonp):)?(?:(post|get):)?(.+)/i,
  6315. rUnsafe = /[<>'"`\\]|&#x?\d+[A-F]?;?|%3[A-F]/gmi,
  6316. noop = $.noop,
  6317. proxy = $.proxy,
  6318. trim = $.trim,
  6319. isFunction = $.isFunction,
  6320. isString = function(s) {
  6321. return typeof s === 'string';
  6322. },
  6323. isObject = function(o) {
  6324. return o && Object.prototype.toString.call(o) === '[object Object]';
  6325. },
  6326. isIE = document.documentMode || +(navigator.userAgent.match(/MSIE (\d+)/) && RegExp.$1),
  6327. attr = function(el, key, value) {
  6328. if (!el || !el.tagName) return null;
  6329. if (value !== undefined) {
  6330. if (value === null) el.removeAttribute(key);
  6331. else el.setAttribute(key, '' + value);
  6332. } else {
  6333. return el.getAttribute(key);
  6334. }
  6335. },
  6336. novalidateonce,
  6337. preinitialized = {},
  6338. defaults = {
  6339. debug: 0,
  6340. theme: 'default',
  6341. ignore: '',
  6342. focusInvalid: true,
  6343. focusCleanup: false,
  6344. stopOnError: false,
  6345. beforeSubmit: null,
  6346. valid: null,
  6347. invalid: null,
  6348. validation: null,
  6349. formClass: 'n-default',
  6350. validClass: 'n-valid',
  6351. invalidClass: 'n-invalid',
  6352. bindClassTo: null
  6353. },
  6354. fieldDefaults = {
  6355. timely: 1,
  6356. display: null,
  6357. target: null,
  6358. ignoreBlank: false,
  6359. showOk: true,
  6360. // Translate ajax response to validation result
  6361. dataFilter: function (data) {
  6362. if ( isString(data) || ( isObject(data) && ('error' in data || 'ok' in data) ) ) {
  6363. return data;
  6364. }
  6365. },
  6366. msgMaker: function(opt) {
  6367. var html;
  6368. html = '<span role="alert" class="msg-wrap n-'+ opt.type + '">' + opt.arrow;
  6369. if (opt.result) {
  6370. $.each(opt.result, function(i, obj){
  6371. html += '<span class="n-'+ obj.type +'">' + opt.icon + '<span class="n-msg">' + obj.msg + '</span></span>';
  6372. });
  6373. } else {
  6374. html += opt.icon + '<span class="n-msg">' + opt.msg + '</span>';
  6375. }
  6376. html += '</span>';
  6377. return html;
  6378. },
  6379. msgWrapper: 'span',
  6380. msgArrow: '',
  6381. msgIcon: '<span class="n-icon"></span>',
  6382. msgClass: 'n-right',
  6383. msgStyle: '',
  6384. msgShow: null,
  6385. msgHide: null
  6386. },
  6387. themes = {};
  6388. /** jQuery Plugin
  6389. * @param {Object} options
  6390. debug {Boolean} 0 Whether to enable debug mode
  6391. timely {Number} 1 Whether to enable timely validation
  6392. theme {String} 'default' Theme name
  6393. stopOnError {Boolean} false Whether to stop validate when found an error input
  6394. focusCleanup {Boolean} false Whether to clean up the field message when focus the field
  6395. focusInvalid {Boolean} true Whether to focus the field that is invalid
  6396. ignoreBlank {Boolean} false When the field has no value, whether to ignore validation
  6397. ignore {jqSelector} '' Ignored fields (Using jQuery selector)
  6398. beforeSubmit {Function} Do something before submit form
  6399. dataFilter {Function} Convert ajax results
  6400. valid {Function} Triggered when the form is valid
  6401. invalid {Function} Triggered when the form is invalid
  6402. validClass {String} 'n-valid' Add this class name to a valid field
  6403. invalidClass {String} 'n-invalid' Add this class name to a invalid field
  6404. bindClassTo {jqSelector} ':verifiable' Which element should the className binding to
  6405. display {Function} Callback function to get dynamic display
  6406. target {Function} Callback function to get dynamic target
  6407. msgShow {Function} Trigger this callback when show message
  6408. msgHide {Function} Trigger this callback when hide message
  6409. msgWrapper {String} 'span' Message wrapper tag name
  6410. msgMaker {Function} Callback function to make message HTML
  6411. msgArrow {String} Message arrow template
  6412. msgIcon {String} Message icon template
  6413. msgStyle {String} Custom message css style
  6414. msgClass {String} Additional added to the message class names
  6415. formClass {String} Additional added to the form class names
  6416. messages {Object} Custom messages for the current instance
  6417. rules {Object} Custom rules for the current instance
  6418. fields {Object} Field validation configuration
  6419. {String} key name|#id
  6420. {String|Object} value Rule string or an object which can pass more arguments
  6421. fields[key][rule] {String} Rule string
  6422. fields[key][display] {String|Function}
  6423. fields[key][tip] {String} Custom tip message
  6424. fields[key][ok] {String} Custom success message
  6425. fields[key][msg] {Object} Custom error message
  6426. fields[key][msgStyle] {String} Custom message style
  6427. fields[key][msgClass] {String} A className which added to message placeholder element
  6428. fields[key][msgWrapper] {String} Tag name of the message placeholder element
  6429. fields[key][msgMaker] {Function} A function to custom message HTML
  6430. fields[key][dataFilter] {Function} A function to convert ajax results
  6431. fields[key][valid] {Function} A function triggered when field is valid
  6432. fields[key][invalid] {Function} A function triggered when field is invalid
  6433. fields[key][must] {Boolean} If set true, we always check the field even has remote checking
  6434. fields[key][timely] {Boolean} Whether to enable timely validation
  6435. fields[key][target] {jqSelector} Define placement of a message
  6436. */
  6437. $.fn.validator = function(options) {
  6438. var that = this,
  6439. args = arguments;
  6440. if (that.is(INPUT_SELECTOR)) return that;
  6441. if (!that.is('form')) that = this.find('form');
  6442. if (!that.length) that = this;
  6443. that.each(function() {
  6444. var instance = $(this).data(NS);
  6445. if (instance) {
  6446. if ( isString(options) ) {
  6447. if ( options.charAt(0) === '_' ) return;
  6448. instance[options].apply(instance, [].slice.call(args, 1));
  6449. }
  6450. else if (options) {
  6451. instance._reset(true);
  6452. instance._init(this, options);
  6453. }
  6454. } else {
  6455. new Validator(this, options);
  6456. }
  6457. });
  6458. return this;
  6459. };
  6460. // Validate a field, or an area
  6461. $.fn.isValid = function(callback, hideMsg) {
  6462. var me = _getInstance(this[0]),
  6463. hasCallback = isFunction(callback),
  6464. ret, opt;
  6465. if (!me) return true;
  6466. if (!hasCallback && hideMsg === undefined) hideMsg = callback;
  6467. me.checkOnly = !!hideMsg;
  6468. opt = me.options;
  6469. ret = me._multiValidate(
  6470. this.is(INPUT_SELECTOR) ? this : this.find(INPUT_SELECTOR),
  6471. function(isValid){
  6472. if (!isValid && opt.focusInvalid && !me.checkOnly) {
  6473. // navigate to the error element
  6474. me.$el.find('[' + ARIA_INVALID + ']:first').focus();
  6475. }
  6476. if (hasCallback) {
  6477. if (callback.length) {
  6478. callback(isValid);
  6479. } else if (isValid) {
  6480. callback();
  6481. }
  6482. }
  6483. me.checkOnly = false;
  6484. }
  6485. );
  6486. // If you pass a callback, we maintain the jQuery object chain
  6487. return hasCallback ? this : ret;
  6488. };
  6489. $.extend($.expr.pseudos || $.expr[':'], {
  6490. // A faster selector than ":input:not(:submit,:button,:reset,:image,:disabled,[contenteditable])"
  6491. verifiable: function(elem) {
  6492. var name = elem.nodeName.toLowerCase();
  6493. return ( name === 'input' && !({submit: 1, button: 1, reset: 1, image: 1})[elem.type] ||
  6494. name === 'select' ||
  6495. name === 'textarea' ||
  6496. elem.contentEditable === 'true'
  6497. ) && !elem.disabled;
  6498. },
  6499. // any value, but not only whitespace
  6500. filled: function(elem) {
  6501. return !!trim($(elem).val());
  6502. }
  6503. });
  6504. /**
  6505. * Creates a new Validator
  6506. *
  6507. * @class
  6508. * @param {Element} element - form element
  6509. * @param {Object} options - options for validator
  6510. */
  6511. function Validator(element, options) {
  6512. var me = this;
  6513. if ( !(me instanceof Validator) ) {
  6514. return new Validator(element, options);
  6515. }
  6516. if (Validator.pending) {
  6517. $(window).on('validatorready', init);
  6518. } else {
  6519. init();
  6520. }
  6521. function init() {
  6522. me.$el = $(element);
  6523. if (me.$el.length) {
  6524. me._init(me.$el[0], options);
  6525. }
  6526. else if (isString(element)) {
  6527. preinitialized[element] = options;
  6528. }
  6529. }
  6530. }
  6531. Validator.prototype = {
  6532. _init: function(element, options) {
  6533. var me = this,
  6534. opt, themeOpt, dataOpt;
  6535. // Initialization options
  6536. if ( isFunction(options) ) {
  6537. options = {
  6538. valid: options
  6539. };
  6540. }
  6541. options = me._opt = options || {};
  6542. dataOpt = attr(element, 'data-'+ NS +'-option');
  6543. dataOpt = me._dataOpt = dataOpt && dataOpt.charAt(0) === '{' ? (new Function('return ' + dataOpt))() : {};
  6544. themeOpt = me._themeOpt = themes[ options.theme || dataOpt.theme || defaults.theme ];
  6545. opt = me.options = $.extend({}, defaults, fieldDefaults, themeOpt, me.options, options, dataOpt);
  6546. me.rules = new Rules(opt.rules, true);
  6547. me.messages = new Messages(opt.messages, true);
  6548. me.Field = _createFieldFactory(me);
  6549. me.elements = me.elements || {};
  6550. me.deferred = {};
  6551. me.errors = {};
  6552. me.fields = {};
  6553. // Initialization fields
  6554. me._initFields(opt.fields);
  6555. // Initialization events and make a cache
  6556. if ( !me.$el.data(NS) ) {
  6557. me.$el.data(NS, me).addClass(CLS_WRAPPER +' '+ opt.formClass)
  6558. .on('form-submit-validate', function(e, a, $form, opts, veto) {
  6559. me.vetoed = veto.veto = !me.isValid;
  6560. me.ajaxFormOptions = opts;
  6561. })
  6562. .on('submit'+ CLS_NS +' validate'+ CLS_NS, proxy(me, '_submit'))
  6563. .on('reset'+ CLS_NS, proxy(me, '_reset'))
  6564. .on('showmsg'+ CLS_NS, proxy(me, '_showmsg'))
  6565. .on('hidemsg'+ CLS_NS, proxy(me, '_hidemsg'))
  6566. .on('focusin'+ CLS_NS + ' click'+ CLS_NS, INPUT_SELECTOR, proxy(me, '_focusin'))
  6567. .on('focusout'+ CLS_NS +' validate'+ CLS_NS, INPUT_SELECTOR, proxy(me, '_focusout'))
  6568. .on('keyup'+ CLS_NS +' input'+ CLS_NS + ' compositionstart compositionend', INPUT_SELECTOR, proxy(me, '_focusout'))
  6569. .on('click'+ CLS_NS, ':radio,:checkbox', 'click', proxy(me, '_focusout'))
  6570. .on('change'+ CLS_NS, 'select,input[type="file"]', 'change', proxy(me, '_focusout'));
  6571. // cache the novalidate attribute value
  6572. me._NOVALIDATE = attr(element, NOVALIDATE);
  6573. // Initialization is complete, stop off default HTML5 form validation
  6574. // If use "jQuery.attr('novalidate')" in IE7 will complain: "SCRIPT3: Member not found."
  6575. attr(element, NOVALIDATE, NOVALIDATE);
  6576. }
  6577. // Display all messages in target container
  6578. if ( isString(opt.target) ) {
  6579. me.$el.find(opt.target).addClass('msg-container');
  6580. }
  6581. },
  6582. // Guess whether the form use ajax submit
  6583. _guessAjax: function(form) {
  6584. var me = this;
  6585. if ( !(me.isAjaxSubmit = !!me.options.valid) ) {
  6586. // if there is a "valid.form" event
  6587. var events = ($._data || $.data)(form, 'events');
  6588. me.isAjaxSubmit = issetEvent(events, 'valid', 'form') || issetEvent(events, 'submit', 'form-plugin');
  6589. }
  6590. function issetEvent(events, name, namespace) {
  6591. return !!(
  6592. events && events[name]
  6593. && $.map(events[name], function(e){
  6594. return ~e.namespace.indexOf(namespace) ? 1 : null;
  6595. }).length )
  6596. }
  6597. },
  6598. _initFields: function(fields) {
  6599. var me = this, k, arr, i,
  6600. clear = fields === null;
  6601. // Processing field information
  6602. if (clear) fields = me.fields;
  6603. if ( isObject(fields) ) {
  6604. for (k in fields) {
  6605. if (~k.indexOf(',')) {
  6606. arr = k.split(',');
  6607. i = arr.length;
  6608. while (i--) {
  6609. initField(trim(arr[i]), fields[k]);
  6610. }
  6611. } else {
  6612. initField(k, fields[k]);
  6613. }
  6614. }
  6615. }
  6616. // Parsing DOM rules
  6617. me.$el.find(INPUT_SELECTOR).each(function() {
  6618. me._parse(this);
  6619. });
  6620. function initField(k, v) {
  6621. // delete a field from settings
  6622. if ( v === null || clear ) {
  6623. var el = me.elements[k];
  6624. if (el) me._resetElement(el, true);
  6625. delete me.fields[k];
  6626. } else {
  6627. me.fields[k] = new me.Field(k, isString(v) ? {rule: v} : v, me.fields[k]);
  6628. }
  6629. }
  6630. },
  6631. // Parsing a field
  6632. _parse: function(el) {
  6633. var me = this,
  6634. field,
  6635. key = el.name,
  6636. display,
  6637. timely,
  6638. dataRule = attr(el, DATA_RULE);
  6639. dataRule && attr(el, DATA_RULE, null);
  6640. // If the field has passed the key as id mode, or it doesn't has a name
  6641. if ( el.id && (
  6642. ('#' + el.id in me.fields) ||
  6643. !key ||
  6644. // If dataRule and element are diffrent from old's, we use ID mode.
  6645. (dataRule !== null && (field = me.fields[key]) && dataRule !== field.rule && el.id !== field.key)
  6646. )
  6647. ) {
  6648. key = '#' + el.id;
  6649. }
  6650. // Generate id
  6651. if (!key) {
  6652. key = '#' + (el.id = 'N' + String(Math.random()).slice(-12));
  6653. }
  6654. field = me.getField(key, true);
  6655. // The priority of passing parameter by DOM is higher than by JS.
  6656. field.rule = dataRule || field.rule;
  6657. if (display = attr(el, DATA_DISPLAY)) {
  6658. field.display = display;
  6659. }
  6660. if (field.rule) {
  6661. if ( attr(el, DATA_MUST) !== null || /\b(?:match|checked)\b/.test(field.rule) ) {
  6662. field.must = true;
  6663. }
  6664. if ( /\brequired\b/.test(field.rule) ) {
  6665. field.required = true;
  6666. }
  6667. if (timely = attr(el, DATA_TIMELY)) {
  6668. field.timely = +timely;
  6669. } else if (field.timely > 3) {
  6670. attr(el, DATA_TIMELY, field.timely);
  6671. }
  6672. me._parseRule(field);
  6673. field.old = {};
  6674. }
  6675. if ( isString(field.target) ) {
  6676. attr(el, DATA_TARGET, field.target);
  6677. }
  6678. if ( isString(field.tip) ) {
  6679. attr(el, DATA_TIP, field.tip);
  6680. }
  6681. return me.fields[key] = field;
  6682. },
  6683. // Parsing field rules
  6684. _parseRule: function(field) {
  6685. var arr = rDisplay.exec(field.rule);
  6686. if (!arr) return;
  6687. // current rule index
  6688. field._i = 0;
  6689. if (arr[1]) {
  6690. field.display = arr[1];
  6691. }
  6692. if (arr[2]) {
  6693. field._rules = [];
  6694. arr[2].replace(rRules, function(){
  6695. var args = arguments;
  6696. args[4] = args[4] || args[5];
  6697. field._rules.push({
  6698. and: args[1] === '&',
  6699. not: args[2] === '!',
  6700. or: args[6] === '|',
  6701. method: args[3],
  6702. params: args[4] ? $.map( args[4].split(', '), trim ) : undefined
  6703. });
  6704. });
  6705. }
  6706. },
  6707. // Verify a zone
  6708. _multiValidate: function($inputs, doneCallback){
  6709. var me = this,
  6710. opt = me.options;
  6711. me.hasError = false;
  6712. if (opt.ignore) {
  6713. $inputs = $inputs.not(opt.ignore);
  6714. }
  6715. $inputs.each(function() {
  6716. me._validate(this);
  6717. if (me.hasError && opt.stopOnError) {
  6718. // stop the validation
  6719. return false;
  6720. }
  6721. });
  6722. // Need to wait for all fields validation complete, especially asynchronous validation
  6723. if (doneCallback) {
  6724. me.validating = true;
  6725. $.when.apply(
  6726. null,
  6727. $.map(me.deferred, function(v){return v;})
  6728. ).done(function(){
  6729. doneCallback.call(me, !me.hasError);
  6730. me.validating = false;
  6731. });
  6732. }
  6733. // If the form does not contain asynchronous validation, the return value is correct.
  6734. // Otherwise, you should detect form validation result through "doneCallback".
  6735. return !$.isEmptyObject(me.deferred) ? undefined : !me.hasError;
  6736. },
  6737. // Validate the whole form
  6738. _submit: function(e) {
  6739. var me = this,
  6740. opt = me.options,
  6741. form = e.target,
  6742. canSubmit = e.type === 'submit' && form.tagName === 'FORM' && !e.isDefaultPrevented();
  6743. e.preventDefault();
  6744. if (
  6745. novalidateonce && ~(novalidateonce = false) ||
  6746. // Prevent duplicate submission
  6747. me.submiting ||
  6748. // Receive the "validate" event only from the form.
  6749. e.type === 'validate' && me.$el[0] !== form ||
  6750. // trigger the beforeSubmit callback.
  6751. isFunction(opt.beforeSubmit) && opt.beforeSubmit.call(me, form) === false
  6752. ) {
  6753. return;
  6754. }
  6755. if (me.isAjaxSubmit === undefined) {
  6756. me._guessAjax(form);
  6757. }
  6758. me._debug('log', '\n<<< event: ' + e.type);
  6759. me._reset();
  6760. me.submiting = true;
  6761. me._multiValidate(
  6762. me.$el.find(INPUT_SELECTOR),
  6763. function(isValid){
  6764. var ret = (isValid || opt.debug === 2) ? 'valid' : 'invalid',
  6765. errors;
  6766. if (!isValid) {
  6767. if (opt.focusInvalid) {
  6768. // navigate to the error element
  6769. me.$el.find('[' + ARIA_INVALID + ']:first').focus();
  6770. }
  6771. errors = $.map(me.errors, function(err){return err;});
  6772. }
  6773. // releasing submit
  6774. me.submiting = false;
  6775. me.isValid = isValid;
  6776. // trigger callback and event
  6777. isFunction(opt[ret]) && opt[ret].call(me, form, errors);
  6778. me.$el.trigger(ret + CLS_NS_FORM, [form, errors]);
  6779. me._debug('log', '>>> ' + ret);
  6780. if (!isValid) return;
  6781. // For jquery.form plugin
  6782. if (me.vetoed) {
  6783. $(form).ajaxSubmit(me.ajaxFormOptions);
  6784. }
  6785. else if (canSubmit && !me.isAjaxSubmit) {
  6786. document.createElement('form').submit.call(form);
  6787. }
  6788. }
  6789. );
  6790. },
  6791. _reset: function(e) {
  6792. var me = this;
  6793. me.errors = {};
  6794. if (e) {
  6795. me.reseting = true;
  6796. me.$el.find(INPUT_SELECTOR).each( function(){
  6797. me._resetElement(this);
  6798. });
  6799. delete me.reseting;
  6800. }
  6801. },
  6802. _resetElement: function(el, all) {
  6803. this._setClass(el, null);
  6804. this.hideMsg(el);
  6805. },
  6806. // Handle events: "focusin/click"
  6807. _focusin: function(e) {
  6808. var me = this,
  6809. opt = me.options,
  6810. el = e.target,
  6811. timely,
  6812. msg;
  6813. if ( me.validating || ( e.type==='click' && document.activeElement === el ) ) {
  6814. return;
  6815. }
  6816. if (opt.focusCleanup) {
  6817. if ( attr(el, ARIA_INVALID) === 'true' ) {
  6818. me._setClass(el, null);
  6819. me.hideMsg(el);
  6820. }
  6821. }
  6822. msg = attr(el, DATA_TIP);
  6823. if (msg) {
  6824. me.showMsg(el, {
  6825. type: 'tip',
  6826. msg: msg
  6827. });
  6828. } else {
  6829. if (attr(el, DATA_RULE)) {
  6830. me._parse(el);
  6831. }
  6832. if (timely = attr(el, DATA_TIMELY)) {
  6833. if ( timely === 8 || timely === 9 ) {
  6834. me._focusout(e);
  6835. }
  6836. }
  6837. }
  6838. },
  6839. // Handle events: "focusout/validate/keyup/click/change/input/compositionstart/compositionend"
  6840. _focusout: function(e) {
  6841. var me = this,
  6842. opt = me.options,
  6843. el = e.target,
  6844. etype = e.type,
  6845. etype0,
  6846. focusin = etype === 'focusin',
  6847. special = etype === 'validate',
  6848. elem,
  6849. field,
  6850. old,
  6851. value,
  6852. timestamp,
  6853. key, specialKey,
  6854. timely,
  6855. timer = 0;
  6856. if (etype === 'compositionstart') {
  6857. me.pauseValidate = true;
  6858. }
  6859. if (etype === 'compositionend') {
  6860. me.pauseValidate = false;
  6861. }
  6862. if (me.pauseValidate) {
  6863. return;
  6864. }
  6865. // For checkbox and radio
  6866. elem = el.name && _checkable(el) ? me.$el.find('input[name="'+ el.name +'"]').get(0) : el;
  6867. // Get field
  6868. if (!(field = me.getField(elem)) || !field.rule) {
  6869. return;
  6870. }
  6871. // Cache event type
  6872. etype0 = field._e;
  6873. field._e = etype;
  6874. timely = field.timely;
  6875. if (!special) {
  6876. if (!timely || (_checkable(el) && etype !== 'click')) {
  6877. return;
  6878. }
  6879. value = field.getValue();
  6880. // not validate field unless fill a value
  6881. if ( field.ignoreBlank && !value && !focusin ) {
  6882. me.hideMsg(el);
  6883. return;
  6884. }
  6885. if ( etype === 'focusout' ) {
  6886. if (etype0 === 'change') {
  6887. return;
  6888. }
  6889. if ( timely === 2 || timely === 8 ) {
  6890. old = field.old;
  6891. if (value && old) {
  6892. if (field.isValid && !old.showOk) {
  6893. me.hideMsg(el);
  6894. } else {
  6895. me._makeMsg(el, field, old);
  6896. }
  6897. } else {
  6898. return;
  6899. }
  6900. }
  6901. }
  6902. else {
  6903. if ( timely < 2 && !e.data ) {
  6904. return;
  6905. }
  6906. // mark timestamp to reduce the frequency of the received event
  6907. timestamp = +new Date();
  6908. if ( timestamp - (el._ts || 0) < 100 ) {
  6909. return;
  6910. }
  6911. el._ts = timestamp;
  6912. // handle keyup
  6913. if ( etype === 'keyup' ) {
  6914. if (etype0 === 'input') {
  6915. return;
  6916. }
  6917. key = e.keyCode;
  6918. specialKey = {
  6919. 8: 1, // Backspace
  6920. 9: 1, // Tab
  6921. 16: 1, // Shift
  6922. 32: 1, // Space
  6923. 46: 1 // Delete
  6924. };
  6925. // only gets focus, no validation
  6926. if ( key === 9 && !value ) {
  6927. return;
  6928. }
  6929. // do not validate, if triggered by these keys
  6930. if ( key < 48 && !specialKey[key] ) {
  6931. return;
  6932. }
  6933. }
  6934. if ( !focusin ) {
  6935. // keyboard events, reducing the frequency of validation
  6936. timer = timely <100 ? (etype === 'click' || el.tagName === 'SELECT') ? 0 : 400 : timely;
  6937. }
  6938. }
  6939. }
  6940. // if the current field is ignored
  6941. if ( opt.ignore && $(el).is(opt.ignore) ) {
  6942. return;
  6943. }
  6944. clearTimeout(field._t);
  6945. if (timer) {
  6946. field._t = setTimeout(function() {
  6947. me._validate(el, field);
  6948. }, timer);
  6949. } else {
  6950. if (special) field.old = {};
  6951. me._validate(el, field);
  6952. }
  6953. },
  6954. _setClass: function(el, isValid) {
  6955. var $el = $(el), opt = this.options;
  6956. if (opt.bindClassTo) {
  6957. $el = $el.closest(opt.bindClassTo);
  6958. }
  6959. $el.removeClass( opt.invalidClass + ' ' + opt.validClass );
  6960. if (isValid !== null) {
  6961. $el.addClass( isValid ? opt.validClass : opt.invalidClass );
  6962. }
  6963. },
  6964. _showmsg: function(e, type, msg) {
  6965. var me = this,
  6966. el = e.target;
  6967. if ( me.$el.is(el) ) {
  6968. if (isObject(type)) {
  6969. me.showMsg(type)
  6970. }
  6971. else if ( type === 'tip' ) {
  6972. me.$el.find(INPUT_SELECTOR +'['+ DATA_TIP +']', el).each(function(){
  6973. me.showMsg(this, {type: type, msg: msg});
  6974. });
  6975. }
  6976. }
  6977. else {
  6978. me.showMsg(el, {type: type, msg: msg});
  6979. }
  6980. },
  6981. _hidemsg: function(e) {
  6982. var $el = $(e.target);
  6983. if ( $el.is(INPUT_SELECTOR) ) {
  6984. this.hideMsg($el);
  6985. }
  6986. },
  6987. // Validated a field
  6988. _validatedField: function(el, field, ret) {
  6989. var me = this,
  6990. opt = me.options,
  6991. isValid = field.isValid = ret.isValid = !!ret.isValid,
  6992. callback = isValid ? 'valid' : 'invalid';
  6993. ret.key = field.key;
  6994. ret.ruleName = field._r;
  6995. ret.id = el.id;
  6996. ret.value = field.value;
  6997. me.elements[field.key] = ret.element = el;
  6998. me.isValid = me.$el[0].isValid = isValid ? me.isFormValid() : isValid;
  6999. if (isValid) {
  7000. ret.type = 'ok';
  7001. } else {
  7002. if (me.submiting) {
  7003. me.errors[field.key] = ret.msg;
  7004. }
  7005. me.hasError = true;
  7006. }
  7007. // cache result
  7008. field.old = ret;
  7009. // trigger callback
  7010. isFunction(field[callback]) && field[callback].call(me, el, ret);
  7011. isFunction(opt.validation) && opt.validation.call(me, el, ret);
  7012. // trigger event
  7013. $(el).attr( ARIA_INVALID, isValid ? null : true )
  7014. .trigger( callback + CLS_NS_FIELD, [ret, me] );
  7015. me.$el.triggerHandler('validation', [ret, me]);
  7016. if (me.checkOnly) return;
  7017. // set className
  7018. me._setClass(el, ret.skip || ret.type === 'tip' ? null : isValid);
  7019. me._makeMsg.apply(me, arguments);
  7020. },
  7021. _makeMsg: function(el, field, ret) {
  7022. // show or hide the message
  7023. if (field.msgMaker) {
  7024. ret = $.extend({}, ret);
  7025. if (field._e === 'focusin') {
  7026. ret.type = 'tip';
  7027. }
  7028. this[ ret.showOk || ret.msg || ret.type === 'tip' ? 'showMsg' : 'hideMsg' ](el, ret, field);
  7029. }
  7030. },
  7031. // Validated a rule
  7032. _validatedRule: function(el, field, ret, msgOpt) {
  7033. field = field || me.getField(el);
  7034. msgOpt = msgOpt || {};
  7035. var me = this,
  7036. msg,
  7037. rule,
  7038. method = field._r,
  7039. timely = field.timely,
  7040. special = timely === 9 || timely === 8,
  7041. transfer,
  7042. temp,
  7043. isValid = false;
  7044. // use null to break validation from a field
  7045. if (ret === null) {
  7046. me._validatedField(el, field, {isValid: true, skip: true});
  7047. field._i = 0;
  7048. return;
  7049. }
  7050. else if (ret === undefined) {
  7051. transfer = true;
  7052. }
  7053. else if (ret === true || ret === '') {
  7054. isValid = true;
  7055. }
  7056. else if (isString(ret)) {
  7057. msg = ret;
  7058. }
  7059. else if (isObject(ret)) {
  7060. if (ret.error) {
  7061. msg = ret.error;
  7062. } else {
  7063. msg = ret.ok;
  7064. isValid = true;
  7065. }
  7066. }
  7067. else {
  7068. isValid = !!ret
  7069. }
  7070. rule = field._rules[field._i];
  7071. if (rule.not) {
  7072. msg = undefined;
  7073. isValid = method === 'required' || !isValid;
  7074. }
  7075. if (rule.or) {
  7076. if (isValid) {
  7077. while ( field._i < field._rules.length && field._rules[field._i].or ) {
  7078. field._i++;
  7079. }
  7080. } else {
  7081. transfer = true;
  7082. }
  7083. }
  7084. else if (rule.and) {
  7085. if (!field.isValid) transfer = true;
  7086. }
  7087. if (transfer) {
  7088. isValid = true;
  7089. }
  7090. // message analysis, and throw rule level event
  7091. else {
  7092. if (isValid) {
  7093. if (field.showOk !== false) {
  7094. temp = attr(el, DATA_OK);
  7095. msg = temp === null ? isString(field.ok) ? field.ok : msg : temp;
  7096. if (!isString(msg) && isString(field.showOk)) {
  7097. msg = field.showOk;
  7098. }
  7099. if (isString(msg)) {
  7100. msgOpt.showOk = isValid;
  7101. }
  7102. }
  7103. }
  7104. if (!isValid || special) {
  7105. /* rule message priority:
  7106. 1. custom DOM message
  7107. 2. custom field message;
  7108. 3. global defined message;
  7109. 4. rule returned message;
  7110. 5. default message;
  7111. */
  7112. msg = (_getDataMsg(el, field, msg || rule.msg || me.messages[method]) || me.messages.fallback).replace(/\{0\|?([^\}]*)\}/, function(m, defaultDisplay){
  7113. return me._getDisplay(el, field.display) || defaultDisplay || me.messages[0];
  7114. });
  7115. }
  7116. if (!isValid) field.isValid = isValid;
  7117. msgOpt.msg = msg;
  7118. $(el).trigger( (isValid ? 'valid' : 'invalid') + CLS_NS_RULE, [method, msg]);
  7119. }
  7120. if (special && (!transfer || rule.and)) {
  7121. if (!isValid && !field._m) field._m = msg;
  7122. field._v = field._v || [];
  7123. field._v.push({
  7124. type: isValid ? !transfer ? 'ok' : 'tip' : 'error',
  7125. msg: msg || rule.msg
  7126. });
  7127. }
  7128. me._debug('log', ' ' + field._i + ': ' + method + ' => ' + (isValid || msg));
  7129. // the current rule has passed, continue to validate
  7130. if ( (isValid || special) && field._i < field._rules.length - 1) {
  7131. field._i++;
  7132. me._checkRule(el, field);
  7133. }
  7134. // field was invalid, or all fields was valid
  7135. else {
  7136. field._i = 0;
  7137. if (special) {
  7138. msgOpt.isValid = field.isValid;
  7139. msgOpt.result = field._v;
  7140. msgOpt.msg = field._m || '';
  7141. if (!field.value && (field._e === 'focusin')) {
  7142. msgOpt.type = 'tip';
  7143. }
  7144. } else {
  7145. msgOpt.isValid = isValid;
  7146. }
  7147. me._validatedField(el, field, msgOpt);
  7148. delete field._m;
  7149. delete field._v;
  7150. }
  7151. },
  7152. // Verify a rule form a field
  7153. _checkRule: function(el, field) {
  7154. var me = this,
  7155. ret,
  7156. fn,
  7157. old,
  7158. key = field.key,
  7159. rule = field._rules[field._i],
  7160. method = rule.method,
  7161. params = rule.params;
  7162. // request has been sent, wait it
  7163. if (me.submiting && me.deferred[key]) {
  7164. return;
  7165. }
  7166. old = field.old;
  7167. field._r = method;
  7168. if (old && !field.must && !rule.must && rule.result !== undefined &&
  7169. old.ruleName === method && old.id === el.id &&
  7170. field.value && old.value === field.value )
  7171. {
  7172. // get result from cache
  7173. ret = rule.result;
  7174. }
  7175. else {
  7176. // get result from current rule
  7177. fn = _getDataRule(el, method) || me.rules[method] || noop;
  7178. ret = fn.call(field, el, params, field);
  7179. if (fn.msg) rule.msg = fn.msg;
  7180. }
  7181. // asynchronous validation
  7182. if (isObject(ret) && isFunction(ret.then)) {
  7183. me.deferred[key] = ret;
  7184. // whether the field valid is unknown
  7185. field.isValid = undefined;
  7186. // show loading message
  7187. !me.checkOnly && me.showMsg(el, {
  7188. type: 'loading',
  7189. msg: me.messages.loading
  7190. }, field);
  7191. // waiting to parse the response data
  7192. ret.then(
  7193. function(d, textStatus, jqXHR) {
  7194. var data = trim(jqXHR.responseText),
  7195. result,
  7196. dataFilter = field.dataFilter;
  7197. // detect if data is json or jsonp format
  7198. if (/jsonp?/.test(this.dataType)) {
  7199. data = d;
  7200. } else if (data.charAt(0) === '{') {
  7201. data = $.parseJSON(data);
  7202. }
  7203. // filter data
  7204. result = dataFilter.call(this, data, field);
  7205. if (result === undefined) result = dataFilter.call(this, data.data, field);
  7206. rule.data = this.data;
  7207. rule.result = field.old ? result : undefined;
  7208. me._validatedRule(el, field, result);
  7209. },
  7210. function(jqXHR, textStatus){
  7211. me._validatedRule(el, field, me.messages[textStatus] || textStatus);
  7212. }
  7213. ).always(function(){
  7214. delete me.deferred[key];
  7215. });
  7216. }
  7217. // other result
  7218. else {
  7219. me._validatedRule(el, field, ret);
  7220. }
  7221. },
  7222. // Processing the validation
  7223. _validate: function(el, field) {
  7224. var me = this;
  7225. // doesn't validate the element that has "disabled" or "novalidate" attribute
  7226. if ( el.disabled || attr(el, NOVALIDATE) !== null ) {
  7227. return;
  7228. }
  7229. field = field || me.getField(el);
  7230. if (!field) return;
  7231. if (!field._rules) me._parse(el);
  7232. if (!field._rules) return;
  7233. me._debug('info', field.key);
  7234. field.isValid = true;
  7235. field.element = el;
  7236. // Cache the value
  7237. field.value = field.getValue();
  7238. // if the field is not required, and that has a blank value
  7239. if (!field.required && !field.must && !field.value) {
  7240. if (!_checkable(el)) {
  7241. me._validatedField(el, field, {isValid: true});
  7242. return true;
  7243. }
  7244. }
  7245. me._checkRule(el, field);
  7246. return field.isValid;
  7247. },
  7248. _debug: function(type, messages) {
  7249. if (window.console && this.options.debug) {
  7250. console[type](messages);
  7251. }
  7252. },
  7253. /**
  7254. * Detecting whether the value of an element that matches a rule
  7255. *
  7256. * @method test
  7257. * @param {Element} el - input element
  7258. * @param {String} rule - rule name
  7259. */
  7260. test: function(el, rule) {
  7261. var me = this,
  7262. ret,
  7263. parts = rRule.exec(rule),
  7264. field,
  7265. method,
  7266. params;
  7267. if (parts) {
  7268. method = parts[1];
  7269. if (method in me.rules) {
  7270. params = parts[2] || parts[3];
  7271. params = params ? params.split(', ') : undefined;
  7272. field = me.getField(el, true);
  7273. field._r = method;
  7274. field.value = field.getValue();
  7275. ret = me.rules[method].call(field, el, params);
  7276. }
  7277. }
  7278. return ret === true || ret === undefined || ret === null;
  7279. },
  7280. _getDisplay: function(el, str) {
  7281. return !isString(str) ? isFunction(str) ? str.call(this, el) : '' : str;
  7282. },
  7283. _getMsgOpt: function(obj, field) {
  7284. var opt = field ? field : this.options;
  7285. return $.extend({
  7286. type: 'error',
  7287. pos: _getPos(opt.msgClass),
  7288. target: opt.target,
  7289. wrapper: opt.msgWrapper,
  7290. style: opt.msgStyle,
  7291. cls: opt.msgClass,
  7292. arrow: opt.msgArrow,
  7293. icon: opt.msgIcon
  7294. }, isString(obj) ? {msg: obj} : obj);
  7295. },
  7296. _getMsgDOM: function(el, msgOpt) {
  7297. var $el = $(el), $msgbox, datafor, tgt, container;
  7298. if ( $el.is(INPUT_SELECTOR) ) {
  7299. tgt = msgOpt.target || attr(el, DATA_TARGET);
  7300. if (tgt) {
  7301. tgt = !isFunction(tgt) ? tgt.charAt(0) === '#' ? $(tgt) : this.$el.find(tgt) : tgt.call(this, el);
  7302. if (tgt.length) {
  7303. if ( tgt.is(INPUT_SELECTOR) ) {
  7304. $el = tgt
  7305. el = tgt.get(0);
  7306. } else if ( tgt.hasClass(CLS_MSG_BOX) ) {
  7307. $msgbox = tgt;
  7308. } else {
  7309. container = tgt;
  7310. }
  7311. }
  7312. }
  7313. if (!$msgbox) {
  7314. datafor = (!_checkable(el) || !el.name) && el.id ? el.id : el.name;
  7315. $msgbox = (container || this.$el).find(msgOpt.wrapper + '.' + CLS_MSG_BOX + '[for="' + datafor + '"]');
  7316. }
  7317. } else {
  7318. $msgbox = $el;
  7319. }
  7320. // Create new message box
  7321. if (!msgOpt.hide && !$msgbox.length) {
  7322. $msgbox = $('<'+ msgOpt.wrapper + '>').attr({
  7323. 'class': CLS_MSG_BOX + (msgOpt.cls ? ' ' + msgOpt.cls : ''),
  7324. 'style': msgOpt.style || undefined,
  7325. 'for': datafor
  7326. });
  7327. if (container) {
  7328. $msgbox.appendTo(container);
  7329. } else {
  7330. if ( _checkable(el) ) {
  7331. var $parent = $el.parent();
  7332. $msgbox.appendTo( $parent.is('label') ? $parent.parent() : $parent );
  7333. } else {
  7334. $msgbox[!msgOpt.pos || msgOpt.pos === 'right' ? 'insertAfter' : 'insertBefore']($el);
  7335. }
  7336. }
  7337. }
  7338. return $msgbox;
  7339. },
  7340. /**
  7341. * Show validation message
  7342. *
  7343. * @method showMsg
  7344. * @param {Element} el - input element
  7345. * @param {Object} msgOpt
  7346. */
  7347. showMsg: function(el, msgOpt, /*INTERNAL*/ field) {
  7348. if (!el) return;
  7349. var me = this,
  7350. opt = me.options,
  7351. msgShow,
  7352. msgMaker,
  7353. temp,
  7354. $msgbox;
  7355. if (isObject(el) && !el.jquery && !msgOpt) {
  7356. $.each(el, function(key, msg) {
  7357. var el = me.elements[key] || me.$el.find(_key2selector(key))[0];
  7358. me.showMsg(el, msg);
  7359. });
  7360. return;
  7361. }
  7362. if ($(el).is(INPUT_SELECTOR)) {
  7363. field = field || me.getField(el);
  7364. }
  7365. if (!(msgMaker = (field || opt).msgMaker)) {
  7366. return;
  7367. }
  7368. msgOpt = me._getMsgOpt(msgOpt, field);
  7369. el = (el.name && _checkable(el) ? me.$el.find('input[name="'+ el.name +'"]') : $(el)).get(0);
  7370. // ok or tip
  7371. if (!msgOpt.msg && msgOpt.type !== 'error') {
  7372. temp = attr(el, 'data-' + msgOpt.type);
  7373. if (temp !== null) msgOpt.msg = temp;
  7374. }
  7375. if ( !isString(msgOpt.msg) ) {
  7376. return;
  7377. }
  7378. $msgbox = me._getMsgDOM(el, msgOpt);
  7379. !rPos.test($msgbox[0].className) && $msgbox.addClass(msgOpt.cls);
  7380. if ( isIE === 6 && msgOpt.pos === 'bottom' ) {
  7381. $msgbox[0].style.marginTop = $(el).outerHeight() + 'px';
  7382. }
  7383. $msgbox.html( msgMaker.call(me, msgOpt) )[0].style.display = '';
  7384. if (isFunction(msgShow = field && field.msgShow || opt.msgShow)) {
  7385. msgShow.call(me, $msgbox, msgOpt.type);
  7386. }
  7387. },
  7388. /**
  7389. * Hide validation message
  7390. *
  7391. * @method hideMsg
  7392. * @param {Element} el - input element
  7393. * @param {Object} msgOpt optional
  7394. */
  7395. hideMsg: function(el, msgOpt, /*INTERNAL*/ field) {
  7396. var me = this,
  7397. opt = me.options,
  7398. msgHide,
  7399. $msgbox;
  7400. el = $(el).get(0);
  7401. if ($(el).is(INPUT_SELECTOR)) {
  7402. field = field || me.getField(el);
  7403. if (field) {
  7404. if (field.isValid || me.reseting) attr(el, ARIA_INVALID, null);
  7405. }
  7406. }
  7407. msgOpt = me._getMsgOpt(msgOpt, field);
  7408. msgOpt.hide = true;
  7409. $msgbox = me._getMsgDOM(el, msgOpt);
  7410. if (!$msgbox.length) return;
  7411. if ( isFunction(msgHide = field && field.msgHide || opt.msgHide) ) {
  7412. msgHide.call(me, $msgbox, msgOpt.type);
  7413. } else {
  7414. $msgbox[0].style.display = 'none';
  7415. $msgbox[0].innerHTML = '';
  7416. }
  7417. },
  7418. /**
  7419. * Get field information
  7420. *
  7421. * @method getField
  7422. * @param {Element} - input element
  7423. * @return {Object} field
  7424. */
  7425. getField: function(el, must) {
  7426. var me = this,
  7427. key,
  7428. field;
  7429. if (isString(el)) {
  7430. key = el;
  7431. el = undefined;
  7432. } else {
  7433. if (attr(el, DATA_RULE)) {
  7434. return me._parse(el);
  7435. }
  7436. if (el.id && '#' + el.id in me.fields || !el.name) {
  7437. key = '#' + el.id;
  7438. } else {
  7439. key = el.name;
  7440. }
  7441. }
  7442. if ( (field = me.fields[key]) || must && (field = new me.Field(key)) ) {
  7443. field.element = el;
  7444. }
  7445. return field;
  7446. },
  7447. /**
  7448. * Config a field
  7449. *
  7450. * @method: setField
  7451. * @param {String} key
  7452. * @param {Object} obj
  7453. */
  7454. setField: function(key, obj) {
  7455. var fields = {};
  7456. if (!key) return;
  7457. // update this field
  7458. if (isString(key)) {
  7459. fields[key] = obj;
  7460. }
  7461. // update fields
  7462. else {
  7463. fields = key;
  7464. }
  7465. this._initFields(fields);
  7466. },
  7467. /**
  7468. * Detecting whether the form is valid
  7469. *
  7470. * @method isFormValid
  7471. * @return {Boolean}
  7472. */
  7473. isFormValid: function() {
  7474. var fields = this.fields, k, field;
  7475. for (k in fields) {
  7476. field = fields[k];
  7477. if (!field._rules || !field.required && !field.must && !field.value) continue;
  7478. if (!field.isValid) return false;
  7479. }
  7480. return true;
  7481. },
  7482. /**
  7483. * Prevent submission form
  7484. *
  7485. * @method holdSubmit
  7486. * @param {Boolean} hold - If set to false, will release the hold
  7487. */
  7488. holdSubmit: function(hold) {
  7489. this.submiting = hold === undefined || hold;
  7490. },
  7491. /**
  7492. * Clean validation messages
  7493. *
  7494. * @method cleanUp
  7495. */
  7496. cleanUp: function() {
  7497. this._reset(1);
  7498. },
  7499. /**
  7500. * Destroy the validation
  7501. *
  7502. * @method destroy
  7503. */
  7504. destroy: function() {
  7505. this._reset(1);
  7506. this.$el.off(CLS_NS).removeData(NS);
  7507. attr(this.$el[0], NOVALIDATE, this._NOVALIDATE);
  7508. }
  7509. };
  7510. /**
  7511. * Create Field Factory
  7512. *
  7513. * @class
  7514. * @param {Object} context
  7515. * @return {Function} Factory
  7516. */
  7517. function _createFieldFactory(context) {
  7518. function FieldFactory() {
  7519. var options = this.options;
  7520. for (var i in options) {
  7521. if (i in fieldDefaults) this[i] = options[i];
  7522. }
  7523. $.extend(this, {
  7524. _valHook: function() {
  7525. return this.element.contentEditable === 'true' ? 'text' : 'val';
  7526. },
  7527. getValue: function() {
  7528. var elem = this.element;
  7529. if (elem.type === 'number' && elem.validity && elem.validity.badInput) {
  7530. return 'NaN';
  7531. }
  7532. return $(elem)[this._valHook()]();
  7533. },
  7534. setValue: function(value) {
  7535. $(this.element)[this._valHook()](this.value = value);
  7536. },
  7537. // Get a range of validation messages
  7538. getRangeMsg: function(value, params, suffix) {
  7539. if (!params) return;
  7540. var me = this,
  7541. msg = me.messages[me._r] || '',
  7542. result,
  7543. p = params[0].split('~'),
  7544. e = params[1] === 'false',
  7545. a = p[0],
  7546. b = p[1],
  7547. c = 'rg',
  7548. args = [''],
  7549. isNumber = trim(value) && +value === +value;
  7550. function compare(large, small) {
  7551. return !e ? large >= small : large > small;
  7552. }
  7553. if (p.length === 2) {
  7554. if (a && b) {
  7555. if (isNumber && compare(value, +a) && compare(+b, value)) {
  7556. result = true;
  7557. }
  7558. args = args.concat(p);
  7559. c = e ? 'gtlt' : 'rg';
  7560. }
  7561. else if (a && !b) {
  7562. if (isNumber && compare(value, +a)) {
  7563. result = true;
  7564. }
  7565. args.push(a);
  7566. c = e ? 'gt' : 'gte';
  7567. }
  7568. else if (!a && b) {
  7569. if (isNumber && compare(+b, value)) {
  7570. result = true;
  7571. }
  7572. args.push(b);
  7573. c = e ? 'lt' : 'lte';
  7574. }
  7575. }
  7576. else {
  7577. if (value === +a) {
  7578. result = true;
  7579. }
  7580. args.push(a);
  7581. c = 'eq';
  7582. }
  7583. if (msg) {
  7584. if (suffix && msg[c + suffix]) {
  7585. c += suffix;
  7586. }
  7587. args[0] = msg[c];
  7588. }
  7589. return result || me._rules && ( me._rules[me._i].msg = me.renderMsg.apply(null, args) );
  7590. },
  7591. // Render message template
  7592. renderMsg: function() {
  7593. var args = arguments,
  7594. tpl = args[0],
  7595. i = args.length;
  7596. if (!tpl) return;
  7597. while (--i) {
  7598. tpl = tpl.replace('{' + i + '}', args[i]);
  7599. }
  7600. return tpl;
  7601. }
  7602. });
  7603. }
  7604. function Field(key, obj, oldField) {
  7605. this.key = key;
  7606. this.validator = context;
  7607. $.extend(this, oldField, obj);
  7608. }
  7609. FieldFactory.prototype = context;
  7610. Field.prototype = new FieldFactory();
  7611. return Field;
  7612. }
  7613. /**
  7614. * Create Rules
  7615. *
  7616. * @class
  7617. * @param {Object} obj rules
  7618. * @param {Object} context context
  7619. */
  7620. function Rules(obj, context) {
  7621. if (!isObject(obj)) return;
  7622. var k, that = context ? context === true ? this : context : Rules.prototype;
  7623. for (k in obj) {
  7624. if (_checkRuleName(k)) {
  7625. that[k] = _getRule(obj[k]);
  7626. }
  7627. }
  7628. }
  7629. /**
  7630. * Create Messages
  7631. *
  7632. * @class
  7633. * @param {Object} obj rules
  7634. * @param {Object} context context
  7635. */
  7636. function Messages(obj, context) {
  7637. if (!isObject(obj)) return;
  7638. var k, that = context ? context === true ? this : context : Messages.prototype;
  7639. for (k in obj) {
  7640. that[k] = obj[k];
  7641. }
  7642. }
  7643. // Rule converted factory
  7644. function _getRule(fn) {
  7645. switch ($.type(fn)) {
  7646. case 'function':
  7647. return fn;
  7648. case 'array':
  7649. var f = function() {
  7650. return fn[0].test(this.value) || fn[1] || false;
  7651. };
  7652. f.msg = fn[1];
  7653. return f;
  7654. case 'regexp':
  7655. return function() {
  7656. return fn.test(this.value);
  7657. };
  7658. }
  7659. }
  7660. // Get instance by an element
  7661. function _getInstance(el) {
  7662. var wrap, k, options;
  7663. if (!el || !el.tagName) return;
  7664. switch (el.tagName) {
  7665. case 'INPUT':
  7666. case 'SELECT':
  7667. case 'TEXTAREA':
  7668. case 'BUTTON':
  7669. case 'FIELDSET':
  7670. wrap = el.form || $(el).closest('.' + CLS_WRAPPER);
  7671. break;
  7672. case 'FORM':
  7673. wrap = el;
  7674. break;
  7675. default:
  7676. wrap = $(el).closest('.' + CLS_WRAPPER);
  7677. }
  7678. for (k in preinitialized) {
  7679. if ($(wrap).is(k)) {
  7680. options = preinitialized[k];
  7681. break;
  7682. }
  7683. }
  7684. return $(wrap).data(NS) || $(wrap)[NS](options).data(NS);
  7685. }
  7686. // Get custom rules on the node
  7687. function _getDataRule(el, method) {
  7688. var fn = trim(attr(el, DATA_RULE + '-' + method));
  7689. if ( fn && (fn = new Function('return ' + fn)()) ) {
  7690. return _getRule(fn);
  7691. }
  7692. }
  7693. // Get custom messages on the node
  7694. function _getDataMsg(el, field, m) {
  7695. var msg = field.msg,
  7696. item = field._r;
  7697. if ( isObject(msg) ) msg = msg[item];
  7698. if ( !isString(msg) ) {
  7699. msg = attr(el, DATA_MSG + '-' + item) || attr(el, DATA_MSG) || ( m ? isString(m) ? m : m[item] : '');
  7700. }
  7701. return msg;
  7702. }
  7703. // Get message position
  7704. function _getPos(str) {
  7705. var pos;
  7706. if (str) pos = rPos.exec(str);
  7707. return pos && pos[0];
  7708. }
  7709. // Check whether the element is checkbox or radio
  7710. function _checkable(el) {
  7711. return el.tagName === 'INPUT' && el.type === 'checkbox' || el.type === 'radio';
  7712. }
  7713. // Parse date string to timestamp
  7714. function _parseDate(str) {
  7715. return Date.parse(str.replace(/\.|\-/g, '/'));
  7716. }
  7717. // Rule name only allows alphanumeric characters and underscores
  7718. function _checkRuleName(name) {
  7719. return /^\w+$/.test(name);
  7720. }
  7721. // Translate field key to jQuery selector.
  7722. function _key2selector(key) {
  7723. var isID = key.charAt(0) === '#';
  7724. key = key.replace(/([:.{(|)}/\[\]])/g, '\\$1');
  7725. return isID ? key : '[name="'+ key +'"]:first';
  7726. }
  7727. // Fixed a issue cause by refresh page in IE.
  7728. $(window).on('beforeunload', function(){
  7729. this.focus();
  7730. });
  7731. $(document)
  7732. .on('click', ':submit', function(){
  7733. var input = this, attrNode;
  7734. if (!input.form) return;
  7735. // Shim for "formnovalidate"
  7736. attrNode = input.getAttributeNode('formnovalidate');
  7737. if (attrNode && attrNode.nodeValue !== null || attr(input, NOVALIDATE)!== null) {
  7738. novalidateonce = true;
  7739. }
  7740. })
  7741. // Automatic initializing form validation
  7742. .on('focusin submit validate', 'form,.'+CLS_WRAPPER, function(e) {
  7743. if ( attr(this, NOVALIDATE) !== null ) return;
  7744. var $form = $(this), me;
  7745. if ( !$form.data(NS) && (me = _getInstance(this)) ) {
  7746. if ( !$.isEmptyObject(me.fields) ) {
  7747. // Execute event handler
  7748. if (e.type === 'focusin') {
  7749. me._focusin(e);
  7750. } else {
  7751. me._submit(e);
  7752. }
  7753. } else {
  7754. attr(this, NOVALIDATE, NOVALIDATE);
  7755. $form.off(CLS_NS).removeData(NS);
  7756. }
  7757. }
  7758. });
  7759. new Messages({
  7760. fallback: 'This field is not valid.',
  7761. loading: 'Validating...'
  7762. });
  7763. // Built-in rules (global)
  7764. new Rules({
  7765. /**
  7766. * required
  7767. *
  7768. * @example:
  7769. required
  7770. required(jqSelector)
  7771. required(anotherRule)
  7772. required(not, -1)
  7773. required(from, .contact)
  7774. */
  7775. required: function(element, params) {
  7776. var me = this,
  7777. val = trim(me.value),
  7778. isValid = true;
  7779. if (params) {
  7780. if ( params.length === 1 ) {
  7781. if ( !_checkRuleName(params[0]) ) {
  7782. if (!val && !$(params[0], me.$el).length ) {
  7783. return null;
  7784. }
  7785. }
  7786. else if ( me.rules[params[0]] ) {
  7787. if ( !val && !me.test(element, params[0]) ) {
  7788. return null;
  7789. }
  7790. me._r = 'required'
  7791. }
  7792. }
  7793. else if ( params[0] === 'not' ) {
  7794. $.each(params.slice(1), function() {
  7795. return (isValid = val !== trim(this));
  7796. });
  7797. }
  7798. else if ( params[0] === 'from' ) {
  7799. var $elements = me.$el.find(params[1]),
  7800. VALIDATED = '_validated_',
  7801. ret;
  7802. isValid = $elements.filter(function(){
  7803. var field = me.getField(this);
  7804. return field && !!trim(field.getValue());
  7805. }).length >= (params[2] || 1);
  7806. if (isValid) {
  7807. if (!val) ret = null;
  7808. } else {
  7809. ret = _getDataMsg($elements[0], me) || false;
  7810. }
  7811. if ( !$(element).data(VALIDATED) ) {
  7812. $elements.data(VALIDATED, 1).each(function(){
  7813. if (element !== this) {
  7814. me._validate(this);
  7815. }
  7816. }).removeData(VALIDATED);
  7817. }
  7818. return ret;
  7819. }
  7820. }
  7821. return isValid && !!val;
  7822. },
  7823. /**
  7824. * integer
  7825. *
  7826. * @example:
  7827. integer
  7828. integer[+]
  7829. integer[+0]
  7830. integer[-]
  7831. integer[-0]
  7832. */
  7833. integer: function(element, params) {
  7834. var re, z = '0|',
  7835. p = '[1-9]\\d*',
  7836. key = params ? params[0] : '*';
  7837. switch (key) {
  7838. case '+':
  7839. re = p;
  7840. break;
  7841. case '-':
  7842. re = '-' + p;
  7843. break;
  7844. case '+0':
  7845. re = z + p;
  7846. break;
  7847. case '-0':
  7848. re = z + '-' + p;
  7849. break;
  7850. default:
  7851. re = z + '-?' + p;
  7852. }
  7853. re = '^(?:' + re + ')$';
  7854. return new RegExp(re).test(this.value) || (this.messages.integer && this.messages.integer[key]);
  7855. },
  7856. /**
  7857. * match another field
  7858. *
  7859. * @example:
  7860. match[password] Match the password field (two values ​​must be the same)
  7861. match[eq, password] Ditto
  7862. match[neq, count] The value must be not equal to the value of the count field
  7863. match[lt, count] The value must be less than the value of the count field
  7864. match[lte, count] The value must be less than or equal to the value of the count field
  7865. match[gt, count] The value must be greater than the value of the count field
  7866. match[gte, count] The value must be greater than or equal to the value of the count field
  7867. match[gte, startDate, date]
  7868. match[gte, startTime, time]
  7869. **/
  7870. match: function(element, params) {
  7871. if (!params) return;
  7872. var me = this,
  7873. isValid = true,
  7874. a, b,
  7875. key, msg, type = 'eq', parser,
  7876. selector2, elem2, field2;
  7877. if (params.length === 1) {
  7878. key = params[0];
  7879. } else {
  7880. type = params[0];
  7881. key = params[1];
  7882. }
  7883. selector2 = _key2selector(key);
  7884. elem2 = me.$el.find(selector2)[0];
  7885. // If the compared field is not exist
  7886. if (!elem2) return;
  7887. field2 = me.getField(elem2);
  7888. a = me.value;
  7889. b = field2.getValue();
  7890. if (!me._match) {
  7891. me.$el.on('valid'+CLS_NS_FIELD+CLS_NS, selector2, function(){
  7892. $(element).trigger('validate');
  7893. });
  7894. me._match = field2._match = 1;
  7895. }
  7896. // If both fields are blank
  7897. if (!me.required && a === '' && b === '') {
  7898. return null;
  7899. }
  7900. parser = params[2];
  7901. if (parser) {
  7902. if (/^date(time)?$/i.test(parser)) {
  7903. a = _parseDate(a);
  7904. b = _parseDate(b);
  7905. } else if (parser === 'time') {
  7906. a = +a.replace(/:/g, '');
  7907. b = +b.replace(/:/g, '');
  7908. }
  7909. }
  7910. // If the compared field is incorrect, we only ensure that this field is correct.
  7911. if (type !== 'eq' && !isNaN(+a) && isNaN(+b)) {
  7912. return true;
  7913. }
  7914. switch (type) {
  7915. case 'lt':
  7916. isValid = +a < +b; break;
  7917. case 'lte':
  7918. isValid = +a <= +b; break;
  7919. case 'gte':
  7920. isValid = +a >= +b; break;
  7921. case 'gt':
  7922. isValid = +a > +b; break;
  7923. case 'neq':
  7924. isValid = a !== b; break;
  7925. default:
  7926. isValid = a === b;
  7927. }
  7928. return isValid || (
  7929. isObject(me.messages.match)
  7930. && me.messages.match[type].replace( '{1}', me._getDisplay( elem2, field2.display || key ) )
  7931. );
  7932. },
  7933. /**
  7934. * range numbers
  7935. *
  7936. * @example:
  7937. range[0~99] Number 0-99
  7938. range[0~] Number greater than or equal to 0
  7939. range[~100] Number less than or equal to 100
  7940. **/
  7941. range: function(element, params) {
  7942. return this.getRangeMsg(this.value, params);
  7943. },
  7944. /**
  7945. * how many checkbox or radio inputs that checked
  7946. *
  7947. * @example:
  7948. checked; no empty, same to required
  7949. checked[1~3] 1-3 items
  7950. checked[1~] greater than 1 item
  7951. checked[~3] less than 3 items
  7952. checked[3] 3 items
  7953. **/
  7954. checked: function(element, params) {
  7955. if ( !_checkable(element) ) return;
  7956. var me = this,
  7957. elem, count;
  7958. if (element.name) {
  7959. count = me.$el.find('input[name="' + element.name + '"]').filter(function() {
  7960. var el = this;
  7961. if (!elem && _checkable(el)) elem = el;
  7962. return !el.disabled && el.checked;
  7963. }).length;
  7964. } else {
  7965. elem = element;
  7966. count = elem.checked;
  7967. }
  7968. if (params) {
  7969. return me.getRangeMsg(count, params);
  7970. } else {
  7971. return !!count || _getDataMsg(elem, me, '') || me.messages.required || false;
  7972. }
  7973. },
  7974. /**
  7975. * length of a characters (You can pass the second parameter "true", will calculate the length in bytes)
  7976. *
  7977. * @example:
  7978. length[6~16] 6-16 characters
  7979. length[6~] Greater than 6 characters
  7980. length[~16] Less than 16 characters
  7981. length[~16, true] Less than 16 characters, non-ASCII characters calculating two-character
  7982. **/
  7983. length: function(element, params) {
  7984. var value = this.value,
  7985. len = (params[1] === 'true' ? value.replace(rDoubleBytes, 'xx') : value).length;
  7986. return this.getRangeMsg(len, params, (params[1] ? '_2' : ''));
  7987. },
  7988. /**
  7989. * remote validation
  7990. *
  7991. * @description
  7992. * remote([get:]url [, name1, [name2 ...]]);
  7993. * Adaptation three kinds of results (Front for the successful, followed by a failure):
  7994. 1. text:
  7995. '' 'Error Message'
  7996. 2. json:
  7997. {"ok": ""} {"error": "Error Message"}
  7998. 3. json wrapper:
  7999. {"status": 1, "data": {"ok": ""}} {"status": 1, "data": {"error": "Error Message"}}
  8000. * @example
  8001. The simplest: remote(path/to/server);
  8002. With parameters: remote(path/to/server, name1, name2, ...);
  8003. By GET: remote(get:path/to/server, name1, name2, ...);
  8004. Name proxy: remote(path/to/server, name1, proxyname2:name2, proxyname3:#id3, ...)
  8005. Query String remote(path/to/server, foo=1&bar=2, name1, name2, ...)
  8006. CORS remote(cors:path/to/server)
  8007. JSONP remote(jsonp:path/to/server)
  8008. */
  8009. remote: function(element, params) {
  8010. if (!params) return;
  8011. var me = this,
  8012. arr = rAjaxType.exec(params[0]),
  8013. rule = me._rules[me._i],
  8014. data = {},
  8015. queryString = '',
  8016. url = arr[3],
  8017. type = arr[2] || 'POST', // GET / POST
  8018. rType = (arr[1]||'').toLowerCase(), // CORS / JSONP
  8019. dataType;
  8020. rule.must = true;
  8021. data[element.name] = me.value;
  8022. // There are extra fields
  8023. if (params[1]) {
  8024. $.map(params.slice(1), function(name) {
  8025. var arr, key;
  8026. if (~name.indexOf('=')) {
  8027. queryString += '&' + name;
  8028. } else {
  8029. arr = name.split(':');
  8030. name = trim(arr[0]);
  8031. key = trim(arr[1]) || name;
  8032. data[ name ] = me.$el.find( _key2selector(key) ).val();
  8033. }
  8034. });
  8035. }
  8036. data = $.param(data) + queryString;
  8037. if (!me.must && rule.data && rule.data === data) {
  8038. return rule.result;
  8039. }
  8040. // Cross-domain request, force jsonp dataType
  8041. if (rType !== 'cors' && /^https?:/.test(url) && !~url.indexOf(location.host)) {
  8042. dataType = 'jsonp';
  8043. }
  8044. // Asynchronous validation need return jqXHR objects
  8045. return $.ajax({
  8046. url: url,
  8047. type: type,
  8048. data: data,
  8049. dataType: dataType
  8050. });
  8051. },
  8052. /**
  8053. * filter characters, direct filtration without prompting error (support custom regular expressions)
  8054. *
  8055. * @example
  8056. * filter filtering unsafe characters
  8057. * filter(regexp) filtering the "regexp" matched characters
  8058. */
  8059. filter: function(element, params) {
  8060. var value = this.value,
  8061. temp = value.replace( params ? (new RegExp('[' + params[0] + ']', 'gm')) : rUnsafe, '' );
  8062. if (temp !== value) this.setValue(temp);
  8063. }
  8064. });
  8065. /**
  8066. * Config global options
  8067. *
  8068. * @static config
  8069. * @param {Object} options
  8070. */
  8071. Validator.config = function(key, value) {
  8072. if (isObject(key)) {
  8073. $.each(key, _config);
  8074. }
  8075. else if (isString(key)) {
  8076. _config(key, value);
  8077. }
  8078. function _config(k, o) {
  8079. if (k === 'rules') {
  8080. new Rules(o);
  8081. }
  8082. else if (k === 'messages') {
  8083. new Messages(o);
  8084. }
  8085. else if (k in fieldDefaults) {
  8086. fieldDefaults[k] = o;
  8087. }
  8088. else {
  8089. defaults[k] = o;
  8090. }
  8091. }
  8092. };
  8093. /**
  8094. * Config themes
  8095. *
  8096. * @static setTheme
  8097. * @param {String|Object} name
  8098. * @param {Object} obj
  8099. * @example
  8100. .setTheme( themeName, themeOptions )
  8101. .setTheme( multiThemes )
  8102. */
  8103. Validator.setTheme = function(name, obj) {
  8104. if ( isObject(name) ) {
  8105. $.extend(true, themes, name);
  8106. }
  8107. else if ( isString(name) && isObject(obj) ) {
  8108. themes[name] = $.extend(themes[name], obj);
  8109. }
  8110. };
  8111. /**
  8112. * Resource loader
  8113. *
  8114. * @static load
  8115. * @param {String} str
  8116. * @example
  8117. .load('local=zh-CN') // load: local/zh-CN.js and jquery.validator.css
  8118. .load('local=zh-CN&css=') // load: local/zh-CN.js
  8119. .load('local&css') // load: local/en.js (set <html lang="en">) and jquery.validator.css
  8120. .load('local') // dito
  8121. */
  8122. Validator.load = function(str) {
  8123. if (!str) return;
  8124. var doc = document,
  8125. params = {},
  8126. node = doc.scripts[0],
  8127. dir, el, ONLOAD;
  8128. str.replace(/([^?=&]+)=([^&#]*)/g, function(m, key, value){
  8129. params[key] = value;
  8130. });
  8131. dir = params.dir || Validator.dir;
  8132. if (!Validator.css && params.css !== '') {
  8133. el = doc.createElement('link');
  8134. el.rel = 'stylesheet';
  8135. el.href = Validator.css = dir + 'jquery.validator.css';
  8136. node.parentNode.insertBefore(el, node);
  8137. }
  8138. if (!Validator.local && ~str.indexOf('local') && params.local !== '') {
  8139. Validator.local = (params.local || doc.documentElement.lang || 'en').replace('_','-');
  8140. Validator.pending = 1;
  8141. el = doc.createElement('script');
  8142. el.src = dir + 'local/' + Validator.local + '.js';
  8143. ONLOAD = 'onload' in el ? 'onload' : 'onreadystatechange';
  8144. el[ONLOAD] = function() {
  8145. if (!el.readyState || /loaded|complete/.test(el.readyState)) {
  8146. el = el[ONLOAD] = null;
  8147. delete Validator.pending;
  8148. $(window).triggerHandler('validatorready');
  8149. }
  8150. };
  8151. node.parentNode.insertBefore(el, node);
  8152. }
  8153. };
  8154. // Auto loading resources
  8155. (function(){
  8156. var scripts = document.scripts,
  8157. i = scripts.length, node, arr,
  8158. re = /(.*validator(?:\.min)?.js)(\?.*(?:local|css|dir)(?:=[\w\-]*)?)?/;
  8159. while (i-- && !arr) {
  8160. node = scripts[i];
  8161. arr = (node.hasAttribute ? node.src : node.getAttribute('src',4)||'').match(re);
  8162. }
  8163. if (!arr) return;
  8164. Validator.dir = arr[1].split('/').slice(0, -1).join('/')+'/';
  8165. Validator.load(arr[2]);
  8166. })();
  8167. return $[NS] = Validator;
  8168. }));
  8169. /*********************************
  8170. * Themes, rules, and i18n support
  8171. * Locale: Chinese; 中文
  8172. *********************************/
  8173. (function(factory) {
  8174. typeof module === "object" && module.exports ? module.exports = factory( require( "jquery" ) ) :
  8175. typeof define === 'function' && define.amd ? define('validator-lang',['jquery'], factory) :
  8176. factory(jQuery);
  8177. }(function($) {
  8178. /* Global configuration
  8179. */
  8180. $.validator.config({
  8181. //stopOnError: true,
  8182. //focusCleanup: true,
  8183. //theme: 'yellow_right',
  8184. //timely: 2,
  8185. // Custom rules
  8186. rules: {
  8187. digits: [/^\d+$/, "请填写数字"]
  8188. ,letters: [/^[a-z]+$/i, "请填写字母"]
  8189. ,date: [/^\d{4}-\d{2}-\d{2}$/, "请填写有效的日期,格式:yyyy-mm-dd"]
  8190. ,time: [/^([01]\d|2[0-3])(:[0-5]\d){1,2}$/, "请填写有效的时间,00:00到23:59之间"]
  8191. ,email: [/^[\w\+\-]+(\.[\w\+\-]+)*@[a-z\d\-]+(\.[a-z\d\-]+)*\.([a-z]{2,4})$/i, "请填写有效的邮箱"]
  8192. ,url: [/^(https?|s?ftp):\/\/\S+$/i, "请填写有效的网址"]
  8193. ,qq: [/^[1-9]\d{4,}$/, "请填写有效的QQ号"]
  8194. ,IDcard: [/^\d{6}(19|2\d)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)?$/, "请填写正确的身份证号码"]
  8195. ,tel: [/^(?:(?:0\d{2,3}[\- ]?[1-9]\d{6,7})|(?:[48]00[\- ]?[1-9]\d{6}))$/, "请填写有效的电话号码"]
  8196. ,mobile: [/^1[3-9]\d{9}$/, "请填写有效的手机号"]
  8197. ,zipcode: [/^\d{6}$/, "请检查邮政编码格式"]
  8198. ,chinese: [/^[\u0391-\uFFE5]+$/, "请填写中文字符"]
  8199. ,username: [/^\w{3,12}$/, "请填写3-12位数字、字母、下划线"]
  8200. ,password: [/^[\S]{6,16}$/, "请填写6-16位字符,不能包含空格"]
  8201. ,accept: function (element, params){
  8202. if (!params) return true;
  8203. var ext = params[0],
  8204. value = $(element).val();
  8205. return (ext === '*') ||
  8206. (new RegExp(".(?:" + ext + ")$", "i")).test(value) ||
  8207. this.renderMsg("只接受{1}后缀的文件", ext.replace(/\|/g, ','));
  8208. }
  8209. },
  8210. // Default error messages
  8211. messages: {
  8212. 0: "此处",
  8213. fallback: "{0}格式不正确",
  8214. loading: "正在验证...",
  8215. error: "网络异常",
  8216. timeout: "请求超时",
  8217. required: "{0}不能为空",
  8218. remote: "{0}已被使用",
  8219. integer: {
  8220. '*': "请填写整数",
  8221. '+': "请填写正整数",
  8222. '+0': "请填写正整数或0",
  8223. '-': "请填写负整数",
  8224. '-0': "请填写负整数或0"
  8225. },
  8226. match: {
  8227. eq: "{0}与{1}不一致",
  8228. neq: "{0}与{1}不能相同",
  8229. lt: "{0}必须小于{1}",
  8230. gt: "{0}必须大于{1}",
  8231. lte: "{0}不能大于{1}",
  8232. gte: "{0}不能小于{1}"
  8233. },
  8234. range: {
  8235. rg: "请填写{1}到{2}的数",
  8236. gte: "请填写不小于{1}的数",
  8237. lte: "请填写最大{1}的数",
  8238. gtlt: "请填写{1}到{2}之间的数",
  8239. gt: "请填写大于{1}的数",
  8240. lt: "请填写小于{1}的数"
  8241. },
  8242. checked: {
  8243. eq: "请选择{1}项",
  8244. rg: "请选择{1}到{2}项",
  8245. gte: "请至少选择{1}项",
  8246. lte: "请最多选择{1}项"
  8247. },
  8248. length: {
  8249. eq: "请填写{1}个字符",
  8250. rg: "请填写{1}到{2}个字符",
  8251. gte: "请至少填写{1}个字符",
  8252. lte: "请最多填写{1}个字符",
  8253. eq_2: "",
  8254. rg_2: "",
  8255. gte_2: "",
  8256. lte_2: ""
  8257. }
  8258. }
  8259. });
  8260. /* Themes
  8261. */
  8262. var TPL_ARROW = '<span class="n-arrow"><b>◆</b><i>◆</i></span>';
  8263. $.validator.setTheme({
  8264. 'simple_right': {
  8265. formClass: 'n-simple',
  8266. msgClass: 'n-right'
  8267. },
  8268. 'simple_bottom': {
  8269. formClass: 'n-simple',
  8270. msgClass: 'n-bottom'
  8271. },
  8272. 'yellow_top': {
  8273. formClass: 'n-yellow',
  8274. msgClass: 'n-top',
  8275. msgArrow: TPL_ARROW
  8276. },
  8277. 'yellow_right': {
  8278. formClass: 'n-yellow',
  8279. msgClass: 'n-right',
  8280. msgArrow: TPL_ARROW
  8281. },
  8282. 'yellow_right_effect': {
  8283. formClass: 'n-yellow',
  8284. msgClass: 'n-right',
  8285. msgArrow: TPL_ARROW,
  8286. msgShow: function($msgbox, type){
  8287. var $el = $msgbox.children();
  8288. if ($el.is(':animated')) return;
  8289. if (type === 'error') {
  8290. $el.css({left: '20px', opacity: 0})
  8291. .delay(100).show().stop()
  8292. .animate({left: '-4px', opacity: 1}, 150)
  8293. .animate({left: '3px'}, 80)
  8294. .animate({left: 0}, 80);
  8295. } else {
  8296. $el.css({left: 0, opacity: 1}).fadeIn(200);
  8297. }
  8298. },
  8299. msgHide: function($msgbox, type){
  8300. var $el = $msgbox.children();
  8301. $el.stop().delay(100).show()
  8302. .animate({left: '20px', opacity: 0}, 300, function(){
  8303. $msgbox.hide();
  8304. });
  8305. }
  8306. }
  8307. });
  8308. }));
  8309. define('form',['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], function ($, undefined, Upload, Validator, undefined) {
  8310. var Form = {
  8311. config: {
  8312. 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>'
  8313. },
  8314. events: {
  8315. validator: function (form, success, error, submit) {
  8316. if (!form.is("form"))
  8317. return;
  8318. //绑定表单事件
  8319. form.validator($.extend({
  8320. rules: {
  8321. username: [/^\w{3,30}$/, __('Username must be 3 to 30 characters')],
  8322. password: [/^[\S]{6,30}$/, __('Password must be 6 to 30 characters')]
  8323. },
  8324. validClass: 'has-success',
  8325. invalidClass: 'has-error',
  8326. bindClassTo: '.form-group',
  8327. formClass: 'n-default n-bootstrap',
  8328. msgClass: 'n-right',
  8329. stopOnError: true,
  8330. display: function (elem) {
  8331. return $(elem).closest('.form-group').find(".control-label").text().replace(/\:/, '');
  8332. },
  8333. dataFilter: function (data) {
  8334. if (data.code === 1) {
  8335. return data.msg ? {"ok": data.msg} : '';
  8336. } else {
  8337. return data.msg;
  8338. }
  8339. },
  8340. target: function (input) {
  8341. var target = $(input).data("target");
  8342. if (target && $(target).length > 0) {
  8343. return $(target);
  8344. }
  8345. var $formitem = $(input).closest('.form-group'),
  8346. $msgbox = $formitem.find('span.msg-box');
  8347. if (!$msgbox.length) {
  8348. return [];
  8349. }
  8350. return $msgbox;
  8351. },
  8352. valid: function (ret) {
  8353. var that = this, submitBtn = $(".layer-footer [type=submit]", form);
  8354. that.holdSubmit(true);
  8355. submitBtn.addClass("disabled");
  8356. //验证通过提交表单
  8357. var submitResult = Form.api.submit($(ret), function (data, ret) {
  8358. that.holdSubmit(false);
  8359. submitBtn.removeClass("disabled");
  8360. if (false === $(this).triggerHandler("success.form", [data, ret])) {
  8361. return false;
  8362. }
  8363. if (typeof success === 'function') {
  8364. if (false === success.call($(this), data, ret)) {
  8365. return false;
  8366. }
  8367. }
  8368. //提示及关闭当前窗口
  8369. var msg = ret.hasOwnProperty("msg") && ret.msg !== "" ? ret.msg : __('Operation completed');
  8370. parent.Toastr.success(msg);
  8371. parent.$(".btn-refresh").trigger("click");
  8372. if (window.name) {
  8373. var index = parent.Layer.getFrameIndex(window.name);
  8374. parent.Layer.close(index);
  8375. }
  8376. return false;
  8377. }, function (data, ret) {
  8378. that.holdSubmit(false);
  8379. if (false === $(this).triggerHandler("error.form", [data, ret])) {
  8380. return false;
  8381. }
  8382. submitBtn.removeClass("disabled");
  8383. if (typeof error === 'function') {
  8384. if (false === error.call($(this), data, ret)) {
  8385. return false;
  8386. }
  8387. }
  8388. }, submit);
  8389. //如果提交失败则释放锁定
  8390. if (!submitResult) {
  8391. that.holdSubmit(false);
  8392. submitBtn.removeClass("disabled");
  8393. }
  8394. return false;
  8395. }
  8396. }, form.data("validator-options") || {}));
  8397. //移除提交按钮的disabled类
  8398. $(".layer-footer [type=submit],.fixed-footer [type=submit],.normal-footer [type=submit]", form).removeClass("disabled");
  8399. //自定义关闭按钮事件
  8400. form.on("click", ".layer-close", function () {
  8401. if (window.name) {
  8402. var index = parent.Layer.getFrameIndex(window.name);
  8403. parent.Layer.close(index);
  8404. }
  8405. return false;
  8406. });
  8407. },
  8408. selectpicker: function (form) {
  8409. //绑定select元素事件
  8410. if ($(".selectpicker", form).length > 0) {
  8411. require(['bootstrap-select', 'bootstrap-select-lang'], function () {
  8412. $.fn.selectpicker.Constructor.BootstrapVersion = '3';
  8413. $('.selectpicker', form).selectpicker();
  8414. $(form).on("reset", function () {
  8415. setTimeout(function () {
  8416. $('.selectpicker').selectpicker('refresh').trigger("change");
  8417. }, 1);
  8418. });
  8419. });
  8420. }
  8421. },
  8422. selectpage: function (form) {
  8423. //绑定selectpage元素事件
  8424. if ($(".selectpage", form).length > 0) {
  8425. require(['selectpage'], function () {
  8426. $('.selectpage', form).selectPage({
  8427. eAjaxSuccess: function (data) {
  8428. data.list = typeof data.rows !== 'undefined' ? data.rows : (typeof data.list !== 'undefined' ? data.list : []);
  8429. data.totalRow = typeof data.total !== 'undefined' ? data.total : (typeof data.totalRow !== 'undefined' ? data.totalRow : data.list.length);
  8430. return data;
  8431. }
  8432. });
  8433. });
  8434. //给隐藏的元素添加上validate验证触发事件
  8435. $(document).on("change", ".sp_hidden", function () {
  8436. $(this).trigger("validate");
  8437. });
  8438. $(document).on("change", ".sp_input", function () {
  8439. $(this).closest(".sp_container").find(".sp_hidden").trigger("change");
  8440. });
  8441. $(form).on("reset", function () {
  8442. setTimeout(function () {
  8443. $('.selectpage', form).selectPageClear();
  8444. }, 1);
  8445. });
  8446. }
  8447. },
  8448. cxselect: function (form) {
  8449. //绑定cxselect元素事件
  8450. if ($("[data-toggle='cxselect']", form).length > 0) {
  8451. require(['cxselect'], function () {
  8452. $.cxSelect.defaults.jsonName = 'name';
  8453. $.cxSelect.defaults.jsonValue = 'value';
  8454. $.cxSelect.defaults.jsonSpace = 'data';
  8455. $("[data-toggle='cxselect']", form).cxSelect();
  8456. });
  8457. }
  8458. },
  8459. citypicker: function (form) {
  8460. //绑定城市远程插件
  8461. if ($("[data-toggle='city-picker']", form).length > 0) {
  8462. require(['citypicker'], function () {
  8463. $(form).on("reset", function () {
  8464. setTimeout(function () {
  8465. $("[data-toggle='city-picker']").citypicker('refresh');
  8466. }, 1);
  8467. });
  8468. });
  8469. }
  8470. },
  8471. datetimepicker: function (form) {
  8472. //绑定日期时间元素事件
  8473. if ($(".datetimepicker", form).length > 0) {
  8474. require(['bootstrap-datetimepicker'], function () {
  8475. var options = {
  8476. format: 'YYYY-MM-DD HH:mm:ss',
  8477. icons: {
  8478. time: 'fa fa-clock-o',
  8479. date: 'fa fa-calendar',
  8480. up: 'fa fa-chevron-up',
  8481. down: 'fa fa-chevron-down',
  8482. previous: 'fa fa-chevron-left',
  8483. next: 'fa fa-chevron-right',
  8484. today: 'fa fa-history',
  8485. clear: 'fa fa-trash',
  8486. close: 'fa fa-remove'
  8487. },
  8488. showTodayButton: true,
  8489. showClose: true
  8490. };
  8491. $('.datetimepicker', form).parent().css('position', 'relative');
  8492. $('.datetimepicker', form).datetimepicker(options).on('dp.change', function (e) {
  8493. $(this, document).trigger("changed");
  8494. });
  8495. });
  8496. }
  8497. },
  8498. daterangepicker: function (form) {
  8499. //绑定日期时间元素事件
  8500. if ($(".datetimerange", form).length > 0) {
  8501. require(['bootstrap-daterangepicker'], function () {
  8502. var ranges = {};
  8503. ranges[__('Today')] = [Moment().startOf('day'), Moment().endOf('day')];
  8504. ranges[__('Yesterday')] = [Moment().subtract(1, 'days').startOf('day'), Moment().subtract(1, 'days').endOf('day')];
  8505. ranges[__('Last 7 Days')] = [Moment().subtract(6, 'days').startOf('day'), Moment().endOf('day')];
  8506. ranges[__('Last 30 Days')] = [Moment().subtract(29, 'days').startOf('day'), Moment().endOf('day')];
  8507. ranges[__('This Month')] = [Moment().startOf('month'), Moment().endOf('month')];
  8508. ranges[__('Last Month')] = [Moment().subtract(1, 'month').startOf('month'), Moment().subtract(1, 'month').endOf('month')];
  8509. var options = {
  8510. timePicker: false,
  8511. autoUpdateInput: false,
  8512. timePickerSeconds: true,
  8513. timePicker24Hour: true,
  8514. autoApply: true,
  8515. locale: {
  8516. format: 'YYYY-MM-DD HH:mm:ss',
  8517. customRangeLabel: __("Custom Range"),
  8518. applyLabel: __("Apply"),
  8519. cancelLabel: __("Clear"),
  8520. },
  8521. ranges: ranges,
  8522. };
  8523. var origincallback = function (start, end) {
  8524. $(this.element).val(start.format(this.locale.format) + " - " + end.format(this.locale.format));
  8525. $(this.element).trigger('change');
  8526. };
  8527. $(".datetimerange", form).each(function () {
  8528. var callback = typeof $(this).data('callback') == 'function' ? $(this).data('callback') : origincallback;
  8529. $(this).on('apply.daterangepicker', function (ev, picker) {
  8530. callback.call(picker, picker.startDate, picker.endDate);
  8531. });
  8532. $(this).on('cancel.daterangepicker', function (ev, picker) {
  8533. $(this).val('').trigger('change');
  8534. });
  8535. $(this).daterangepicker($.extend(true, options, $(this).data() || {}, $(this).data("daterangepicker-options") || {}));
  8536. });
  8537. });
  8538. }
  8539. },
  8540. /**
  8541. * 绑定上传事件
  8542. * @param form
  8543. * @deprecated Use faupload instead.
  8544. */
  8545. plupload: function (form) {
  8546. Form.events.faupload(form);
  8547. },
  8548. /**
  8549. * 绑定上传事件
  8550. * @param form
  8551. */
  8552. faupload: function (form) {
  8553. //绑定上传元素事件
  8554. if ($(".plupload,.faupload", form).length > 0) {
  8555. Upload.api.upload($(".plupload,.faupload", form));
  8556. }
  8557. },
  8558. faselect: function (form) {
  8559. //绑定fachoose选择附件事件
  8560. if ($(".faselect,.fachoose", form).length > 0) {
  8561. $(".faselect,.fachoose", form).off('click').on('click', function () {
  8562. var that = this;
  8563. var multiple = $(this).data("multiple") ? $(this).data("multiple") : false;
  8564. var mimetype = $(this).data("mimetype") ? $(this).data("mimetype") : '';
  8565. var admin_id = $(this).data("admin-id") ? $(this).data("admin-id") : '';
  8566. var user_id = $(this).data("user-id") ? $(this).data("user-id") : '';
  8567. mimetype = mimetype.replace(/\/\*/ig, '/');
  8568. var url = $(this).data("url") ? $(this).data("url") : (typeof Backend !== 'undefined' ? "general/attachment/select" : "user/attachment");
  8569. parent.Fast.api.open(url + "?element_id=" + $(this).attr("id") + "&multiple=" + multiple + "&mimetype=" + mimetype + "&admin_id=" + admin_id + "&user_id=" + user_id, __('Choose'), {
  8570. callback: function (data) {
  8571. var button = $("#" + $(that).attr("id"));
  8572. var maxcount = $(button).data("maxcount");
  8573. var input_id = $(button).data("input-id") ? $(button).data("input-id") : "";
  8574. maxcount = typeof maxcount !== "undefined" ? maxcount : 0;
  8575. if (input_id && data.multiple) {
  8576. var urlArr = [];
  8577. var inputObj = $("#" + input_id);
  8578. var value = $.trim(inputObj.val());
  8579. if (value !== "") {
  8580. urlArr.push(inputObj.val());
  8581. }
  8582. var nums = value === '' ? 0 : value.split(/\,/).length;
  8583. var files = data.url !== "" ? data.url.split(/\,/) : [];
  8584. $.each(files, function (i, j) {
  8585. var url = Config.upload.fullmode ? Fast.api.cdnurl(j) : j;
  8586. urlArr.push(url);
  8587. });
  8588. if (maxcount > 0) {
  8589. var remains = maxcount - nums;
  8590. if (files.length > remains) {
  8591. Toastr.error(__('You can choose up to %d file%s', remains));
  8592. return false;
  8593. }
  8594. }
  8595. var result = urlArr.join(",");
  8596. inputObj.val(result).trigger("change").trigger("validate");
  8597. } else if (input_id) {
  8598. var url = Config.upload.fullmode ? Fast.api.cdnurl(data.url) : data.url;
  8599. $("#" + input_id).val(url).trigger("change").trigger("validate");
  8600. }
  8601. }
  8602. });
  8603. return false;
  8604. });
  8605. }
  8606. },
  8607. fieldlist: function (form) {
  8608. //绑定fieldlist
  8609. if ($(".fieldlist", form).length > 0) {
  8610. require(['dragsort', 'template'], function (undefined, Template) {
  8611. //刷新隐藏textarea的值
  8612. var refresh = function (container) {
  8613. var data = {};
  8614. var name = container.data("name");
  8615. var textarea = $("textarea[name='" + name + "']", form);
  8616. var template = container.data("template");
  8617. $.each($("input,select,textarea", container).serializeArray(), function (i, j) {
  8618. var reg = /\[(\w+)\]\[(\w+)\]$/g;
  8619. var match = reg.exec(j.name);
  8620. if (!match)
  8621. return true;
  8622. match[1] = "x" + parseInt(match[1]);
  8623. if (typeof data[match[1]] == 'undefined') {
  8624. data[match[1]] = {};
  8625. }
  8626. data[match[1]][match[2]] = j.value;
  8627. });
  8628. var result = template ? [] : {};
  8629. $.each(data, function (i, j) {
  8630. if (j) {
  8631. if (!template) {
  8632. if (j.key !== '') {
  8633. result['__PLACEHOLDKEY__' + j.key] = j.value;
  8634. }
  8635. } else {
  8636. result.push(j);
  8637. }
  8638. }
  8639. });
  8640. textarea.val(JSON.stringify(result).replace(/__PLACEHOLDKEY__/g, ''));
  8641. };
  8642. //追加一行数据
  8643. var append = function (container, row, initial) {
  8644. var tagName = container.data("tag") || (container.is("table") ? "tr" : "dd");
  8645. var index = container.data("index");
  8646. var name = container.data("name");
  8647. var template = container.data("template");
  8648. var data = container.data();
  8649. index = index ? parseInt(index) : 0;
  8650. container.data("index", index + 1);
  8651. row = row ? row : {};
  8652. row = typeof row.key === 'undefined' || typeof row.value === 'undefined' ? {key: '', value: row} : row;
  8653. var options = container.data("fieldlist-options") || {};
  8654. var vars = {index: index, name: name, data: data, options: options, key: row.key, value: row.value, row: row.value};
  8655. var html = template ? Template(template, vars) : Template.render(Form.config.fieldlisttpl, vars);
  8656. var obj = $(html);
  8657. if ((options.deleteBtn === false || options.removeBtn === false) && initial)
  8658. obj.find(".btn-remove").remove();
  8659. if (options.dragsortBtn === false && initial)
  8660. obj.find(".btn-dragsort").remove();
  8661. if ((options.readonlyKey === true || options.disableKey === true) && initial) {
  8662. obj.find("input[name$='[key]']").prop("readonly", true);
  8663. }
  8664. obj.attr("fieldlist-item", true);
  8665. obj.insertAfter($(tagName + "[fieldlist-item]", container).length > 0 ? $(tagName + "[fieldlist-item]:last", container) : $(tagName + ":first", container));
  8666. if ($(".btn-append,.append", container).length > 0) {
  8667. //兼容旧版本事件
  8668. $(".btn-append,.append", container).trigger("fa.event.appendfieldlist", obj);
  8669. } else {
  8670. //新版本事件
  8671. container.trigger("fa.event.appendfieldlist", obj);
  8672. }
  8673. return obj;
  8674. };
  8675. var fieldlist = $(".fieldlist", form);
  8676. //监听文本框改变事件
  8677. $(document).on('change keyup changed', ".fieldlist input,.fieldlist textarea,.fieldlist select", function () {
  8678. var container = $(this).closest(".fieldlist");
  8679. refresh(container);
  8680. });
  8681. //追加控制(点击按钮)
  8682. fieldlist.on("click", ".btn-append,.append", function (e, row) {
  8683. var container = $(this).closest(".fieldlist");
  8684. append(container, row);
  8685. // refresh(container);
  8686. });
  8687. //移除控制(点击按钮)
  8688. fieldlist.on("click", ".btn-remove", function () {
  8689. var container = $(this).closest(".fieldlist");
  8690. var tagName = container.data("tag") || (container.is("table") ? "tr" : "dd");
  8691. $(this).closest(tagName).remove();
  8692. refresh(container);
  8693. });
  8694. //追加控制(通过事件)
  8695. fieldlist.on("fa.event.appendtofieldlist", function (e, row) {
  8696. var container = $(this);
  8697. append(container, row);
  8698. refresh(container);
  8699. });
  8700. //根据textarea内容重新渲染
  8701. fieldlist.on("fa.event.refreshfieldlist", function () {
  8702. var container = $(this);
  8703. var textarea = $("textarea[name='" + container.data("name") + "']", form);
  8704. //先清空已有的数据
  8705. $("[fieldlist-item]", container).remove();
  8706. var json = {};
  8707. try {
  8708. var val = textarea.val().replace(/"(\d+)"\:/g, "\"__PLACEHOLDERKEY__$1\":");
  8709. json = JSON.parse(val);
  8710. } catch (e) {
  8711. }
  8712. $.each(json, function (i, j) {
  8713. append(container, {key: i.toString().replace("__PLACEHOLDERKEY__", ""), value: j}, true);
  8714. });
  8715. });
  8716. //拖拽排序
  8717. fieldlist.each(function () {
  8718. var container = $(this);
  8719. var tagName = container.data("tag") || (container.is("table") ? "tr" : "dd");
  8720. container.dragsort({
  8721. itemSelector: tagName,
  8722. dragSelector: ".btn-dragsort",
  8723. dragEnd: function () {
  8724. refresh(container);
  8725. },
  8726. placeHolderTemplate: $("<" + tagName + "/>")
  8727. });
  8728. if (typeof container.data("options") === 'object' && container.data("options").appendBtn === false) {
  8729. $(".btn-append,.append", container).hide();
  8730. }
  8731. $("textarea[name='" + container.data("name") + "']", form).on("fa.event.refreshfieldlist", function () {
  8732. //兼容旧版本事件
  8733. $(this).closest(".fieldlist").trigger("fa.event.refreshfieldlist");
  8734. });
  8735. });
  8736. fieldlist.trigger("fa.event.refreshfieldlist");
  8737. });
  8738. }
  8739. },
  8740. switcher: function (form) {
  8741. form.on("click", "[data-toggle='switcher']", function () {
  8742. if ($(this).hasClass("disabled")) {
  8743. return false;
  8744. }
  8745. var switcher = $.proxy(function () {
  8746. var input = $(this).prev("input");
  8747. input = $(this).data("input-id") ? $("#" + $(this).data("input-id")) : input;
  8748. if (input.length > 0) {
  8749. var yes = $(this).data("yes");
  8750. var no = $(this).data("no");
  8751. if (input.val() == yes) {
  8752. input.val(no);
  8753. $("i", this).addClass("fa-flip-horizontal text-gray");
  8754. } else {
  8755. input.val(yes);
  8756. $("i", this).removeClass("fa-flip-horizontal text-gray");
  8757. }
  8758. input.trigger('change');
  8759. }
  8760. }, this);
  8761. if (typeof $(this).data("confirm") !== 'undefined') {
  8762. Layer.confirm($(this).data("confirm"), function (index) {
  8763. switcher();
  8764. Layer.close(index);
  8765. });
  8766. } else {
  8767. switcher();
  8768. }
  8769. return false;
  8770. });
  8771. },
  8772. bindevent: function (form) {
  8773. },
  8774. slider: function (form) {
  8775. if ($(".slider", form).length > 0) {
  8776. require(['bootstrap-slider'], function () {
  8777. $('.slider').removeClass('hidden').css('width', function (index, value) {
  8778. return $(this).parents('.form-control').width();
  8779. }).slider().on('slide', function (ev) {
  8780. var data = $(this).data();
  8781. if (typeof data.unit !== 'undefined') {
  8782. $(this).parents('.form-control').siblings('.value').text(ev.value + data.unit);
  8783. }
  8784. });
  8785. });
  8786. }
  8787. },
  8788. tagsinput: function (form) {
  8789. if ($("[data-role='tagsinput']", form).length > 0) {
  8790. require(['tagsinput', 'autocomplete'], function () {
  8791. $("[data-role='tagsinput']").tagsinput();
  8792. });
  8793. }
  8794. },
  8795. autocomplete: function (form) {
  8796. if ($("[data-role='autocomplete']", form).length > 0) {
  8797. require(['autocomplete'], function () {
  8798. $("[data-role='autocomplete']").autocomplete();
  8799. });
  8800. }
  8801. },
  8802. favisible: function (form) {
  8803. if ($("[data-favisible]", form).length == 0) {
  8804. return;
  8805. }
  8806. var checkCondition = function (condition) {
  8807. var conditionArr = condition.split(/&&/);
  8808. var success = 0;
  8809. var baseregex = /^([a-z0-9\_]+)([>|<|=|\!]=?)(.*)$/i, strregex = /^('|")(.*)('|")$/, regregex = /^regex:(.*)$/;
  8810. // @formatter:off
  8811. var operator_result = {
  8812. '>': function(a, b) { return a > b; },
  8813. '>=': function(a, b) { return a >= b; },
  8814. '<': function(a, b) { return a < b; },
  8815. '<=': function(a, b) { return a <= b; },
  8816. '==': function(a, b) { return a == b; },
  8817. '!=': function(a, b) { return a != b; },
  8818. 'in': function(a, b) { return b.split(/\,/).indexOf(a) > -1; },
  8819. 'regex': function (a, b) {
  8820. var regParts = b.match(/^\/(.*?)\/([gim]*)$/);
  8821. var regexp = regParts ? new RegExp(regParts[1], regParts[2]) : new RegExp(b);
  8822. return regexp.test(a);
  8823. }
  8824. };
  8825. // @formatter:on
  8826. var dataArr = form.serializeArray(), dataObj = {}, fieldName, fieldValue;
  8827. $(dataArr).each(function (i, field) {
  8828. fieldName = field.name;
  8829. fieldValue = field.value;
  8830. fieldName = fieldName.substr(-2) === '[]' ? fieldName.substr(0, fieldName.length - 2) : fieldName;
  8831. dataObj[fieldName] = typeof dataObj[fieldName] !== 'undefined' ? [dataObj[fieldName], fieldValue].join(',') : fieldValue;
  8832. });
  8833. $.each(conditionArr, function (i, item) {
  8834. var basematches = baseregex.exec(item);
  8835. if (basematches) {
  8836. var name = basematches[1], operator = basematches[2], value = basematches[3].toString();
  8837. if (operator === '=') {
  8838. var strmatches = strregex.exec(value);
  8839. operator = strmatches ? '==' : 'in';
  8840. value = strmatches ? strmatches[2] : value;
  8841. }
  8842. var regmatches = regregex.exec(value);
  8843. if (regmatches) {
  8844. operator = 'regex';
  8845. value = regmatches[1];
  8846. }
  8847. var chkname = "row[" + name + "]";
  8848. if (typeof dataObj[chkname] === 'undefined') {
  8849. return false;
  8850. }
  8851. var objvalue = dataObj[chkname];
  8852. if ($.isArray(objvalue)) {
  8853. objvalue = dataObj[chkname].join(",");
  8854. }
  8855. if (['>', '>=', '<', '<='].indexOf(operator) > -1) {
  8856. objvalue = parseFloat(objvalue);
  8857. value = parseFloat(value);
  8858. }
  8859. var result = operator_result[operator](objvalue, value);
  8860. success += (result ? 1 : 0);
  8861. }
  8862. });
  8863. return success === conditionArr.length;
  8864. };
  8865. form.on("keyup change click configchange", "input,select", function () {
  8866. $("[data-favisible][data-favisible!='']", form).each(function () {
  8867. var visible = $(this).data("favisible");
  8868. var groupArr = visible.split(/\|\|/);
  8869. var success = 0;
  8870. $.each(groupArr, function (i, j) {
  8871. if (checkCondition(j)) {
  8872. success++;
  8873. }
  8874. });
  8875. if (success > 0) {
  8876. $(this).removeClass("hidden");
  8877. } else {
  8878. $(this).addClass("hidden");
  8879. }
  8880. });
  8881. });
  8882. //追加上忽略元素
  8883. setTimeout(function () {
  8884. form.data('validator').options.ignore += ((form.data('validator').options.ignore ? ',' : '') + '[data-favisible] :hidden,[data-favisible]:hidden');
  8885. }, 0);
  8886. $("input,select", form).trigger("configchange");
  8887. }
  8888. },
  8889. api: {
  8890. submit: function (form, success, error, submit) {
  8891. if (form.length === 0) {
  8892. Toastr.error("表单未初始化完成,无法提交");
  8893. return false;
  8894. }
  8895. if (typeof submit === 'function') {
  8896. if (false === submit.call(form, success, error)) {
  8897. return false;
  8898. }
  8899. }
  8900. var type = form.attr("method") ? form.attr("method").toUpperCase() : 'GET';
  8901. type = type && (type === 'GET' || type === 'POST') ? type : 'GET';
  8902. url = form.attr("action");
  8903. url = url ? url : location.href;
  8904. //修复当存在多选项元素时提交的BUG
  8905. var params = {};
  8906. var multipleList = $("[name$='[]']", form);
  8907. if (multipleList.length > 0) {
  8908. var postFields = form.serializeArray().map(function (obj) {
  8909. return $(obj).prop("name");
  8910. });
  8911. $.each(multipleList, function (i, j) {
  8912. if (postFields.indexOf($(this).prop("name")) < 0) {
  8913. params[$(this).prop("name")] = '';
  8914. }
  8915. });
  8916. }
  8917. //调用Ajax请求方法
  8918. Fast.api.ajax({
  8919. type: type,
  8920. url: url,
  8921. data: form.serialize() + (Object.keys(params).length > 0 ? '&' + $.param(params) : ''),
  8922. dataType: 'json',
  8923. complete: function (xhr) {
  8924. var token = xhr.getResponseHeader('__token__');
  8925. if (token) {
  8926. $("input[name='__token__']").val(token);
  8927. }
  8928. }
  8929. }, function (data, ret) {
  8930. $('.form-group', form).removeClass('has-feedback has-success has-error');
  8931. if (data && typeof data === 'object') {
  8932. //刷新客户端token
  8933. if (typeof data.token !== 'undefined') {
  8934. $("input[name='__token__']").val(data.token);
  8935. }
  8936. //调用客户端事件
  8937. if (typeof data.callback !== 'undefined' && typeof data.callback === 'function') {
  8938. data.callback.call(form, data);
  8939. }
  8940. }
  8941. if (typeof success === 'function') {
  8942. if (false === success.call(form, data, ret)) {
  8943. return false;
  8944. }
  8945. }
  8946. }, function (data, ret) {
  8947. if (data && typeof data === 'object' && typeof data.token !== 'undefined') {
  8948. $("input[name='__token__']").val(data.token);
  8949. }
  8950. if (typeof error === 'function') {
  8951. if (false === error.call(form, data, ret)) {
  8952. return false;
  8953. }
  8954. }
  8955. });
  8956. return true;
  8957. },
  8958. bindevent: function (form, success, error, submit) {
  8959. form = typeof form === 'object' ? form : $(form);
  8960. var events = Form.events;
  8961. events.bindevent(form);
  8962. events.validator(form, success, error, submit);
  8963. events.selectpicker(form);
  8964. events.daterangepicker(form);
  8965. events.selectpage(form);
  8966. events.cxselect(form);
  8967. events.citypicker(form);
  8968. events.datetimepicker(form);
  8969. events.faupload(form);
  8970. events.faselect(form);
  8971. events.fieldlist(form);
  8972. events.slider(form);
  8973. events.switcher(form);
  8974. events.tagsinput(form);
  8975. events.autocomplete(form);
  8976. events.favisible(form);
  8977. },
  8978. custom: {}
  8979. },
  8980. };
  8981. return Form;
  8982. });
  8983. /**
  8984. * FastAdmin通用搜索
  8985. *
  8986. * @author: pppscn <35696959@qq.com>
  8987. * @update 2017-05-07 <https://gitee.com/pp/fastadmin>
  8988. *
  8989. * @author: Karson <karson@fastadmin.net>
  8990. * @update 2018-04-05 <https://gitee.com/karson/fastadmin>
  8991. */
  8992. !function ($) {
  8993. 'use strict';
  8994. var ColumnsForSearch = [];
  8995. var sprintf = $.fn.bootstrapTable.utils.sprintf;
  8996. var initCommonSearch = function (pColumns, that) {
  8997. var vFormCommon = createFormCommon(pColumns, that);
  8998. var vModal = sprintf("<div class=\"commonsearch-table %s\">", that.options.searchFormVisible ? "" : "hidden");
  8999. vModal += vFormCommon;
  9000. vModal += "</div>";
  9001. that.$container.prepend($(vModal));
  9002. that.$commonsearch = $(".commonsearch-table", that.$container);
  9003. var form = $("form.form-commonsearch", that.$commonsearch);
  9004. require(['form'], function (Form) {
  9005. Form.api.bindevent(form);
  9006. form.validator("destroy");
  9007. });
  9008. // 表单提交
  9009. form.on("submit", function (event) {
  9010. event.preventDefault();
  9011. that.onCommonSearch();
  9012. return false;
  9013. });
  9014. // 重置搜索
  9015. form.on("click", "button[type=reset]", function (event) {
  9016. form[0].reset();
  9017. setTimeout(function () {
  9018. that.onCommonSearch();
  9019. }, 10);
  9020. });
  9021. };
  9022. var createFormCommon = function (pColumns, that) {
  9023. // 如果有使用模板则直接返回模板的内容
  9024. if (that.options.searchFormTemplate) {
  9025. return Template(that.options.searchFormTemplate, {columns: pColumns, table: that});
  9026. }
  9027. var htmlForm = [];
  9028. htmlForm.push(sprintf('<form class="form-horizontal form-commonsearch" novalidate method="post" action="%s" >', that.options.actionForm));
  9029. htmlForm.push('<fieldset>');
  9030. if (that.options.titleForm.length > 0)
  9031. htmlForm.push(sprintf("<legend>%s</legend>", that.options.titleForm));
  9032. htmlForm.push('<div class="row">');
  9033. for (var i in pColumns) {
  9034. var vObjCol = pColumns[i];
  9035. if (!vObjCol.checkbox && vObjCol.field !== 'operate' && vObjCol.searchable && vObjCol.operate !== false) {
  9036. var query = Fast.api.query(vObjCol.field);
  9037. var operate = Fast.api.query(vObjCol.field + "-operate");
  9038. var renderDefault = that.options.renderDefault && (typeof vObjCol.renderDefault == 'undefined' || vObjCol.renderDefault);
  9039. vObjCol.defaultValue = renderDefault && query ? query : (typeof vObjCol.defaultValue === 'undefined' ? '' : vObjCol.defaultValue);
  9040. vObjCol.operate = renderDefault && operate ? operate : (typeof vObjCol.operate === 'undefined' ? '=' : vObjCol.operate);
  9041. ColumnsForSearch.push(vObjCol);
  9042. htmlForm.push('<div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">');
  9043. htmlForm.push(sprintf('<label for="%s" class="control-label col-xs-4">%s</label>', vObjCol.field, vObjCol.title));
  9044. htmlForm.push('<div class="col-xs-8">');
  9045. vObjCol.operate = vObjCol.operate ? vObjCol.operate.toUpperCase() : '=';
  9046. 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));
  9047. var addClass = typeof vObjCol.addClass === 'undefined' ? (typeof vObjCol.addclass === 'undefined' ? 'form-control' : 'form-control ' + vObjCol.addclass) : 'form-control ' + vObjCol.addClass;
  9048. var extend = typeof vObjCol.extend === 'undefined' ? '' : vObjCol.extend;
  9049. var style = typeof vObjCol.style === 'undefined' ? '' : sprintf('style="%s"', vObjCol.style);
  9050. extend = typeof vObjCol.data !== 'undefined' && extend == '' ? vObjCol.data : extend;
  9051. extend = typeof vObjCol.autocomplete !== 'undefined' ? extend + ' autocomplete="' + (vObjCol.autocomplete === false || vObjCol.autocomplete === 'off' ? 'off' : 'on') + '"' : extend;
  9052. if (vObjCol.searchList) {
  9053. if (typeof vObjCol.searchList === 'function') {
  9054. htmlForm.push(vObjCol.searchList.call(this, vObjCol));
  9055. } else {
  9056. var optionList = [sprintf('<option value="">%s</option>', that.options.formatCommonChoose())];
  9057. if (typeof vObjCol.searchList === 'object' && typeof vObjCol.searchList.then === 'function') {
  9058. (function (vObjCol, that) {
  9059. $.when(vObjCol.searchList).done(function (ret) {
  9060. var searchList = [];
  9061. if (ret.data && ret.data.searchlist && $.isArray(ret.data.searchlist)) {
  9062. searchList = ret.data.searchlist;
  9063. } else if (ret.constructor === Array || ret.constructor === Object) {
  9064. searchList = ret;
  9065. }
  9066. var optionList = createOptionList(searchList, vObjCol, that);
  9067. $("form.form-commonsearch select[name='" + vObjCol.field + "']", that.$container).html(optionList.join('')).trigger("change");
  9068. });
  9069. })(vObjCol, that);
  9070. } else {
  9071. optionList = createOptionList(vObjCol.searchList, vObjCol, that);
  9072. }
  9073. htmlForm.push(sprintf('<select class="%s" name="%s" %s %s>%s</select>', addClass, vObjCol.field, style, extend, optionList.join('')));
  9074. }
  9075. } else {
  9076. var placeholder = typeof vObjCol.placeholder === 'undefined' ? vObjCol.title : vObjCol.placeholder;
  9077. var type = typeof vObjCol.type === 'undefined' ? 'text' : vObjCol.type;
  9078. var defaultValue = typeof vObjCol.defaultValue === 'undefined' ? '' : vObjCol.defaultValue;
  9079. if (/BETWEEN$/.test(vObjCol.operate)) {
  9080. var defaultValueArr = defaultValue.toString().match(/\|/) ? defaultValue.split('|') : ['', ''];
  9081. var placeholderArr = placeholder.toString().match(/\|/) ? placeholder.split('|') : [placeholder, placeholder];
  9082. htmlForm.push('<div class="row row-between">');
  9083. 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));
  9084. 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));
  9085. htmlForm.push('</div>');
  9086. } else {
  9087. 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));
  9088. }
  9089. }
  9090. htmlForm.push('</div>');
  9091. htmlForm.push('</div>');
  9092. }
  9093. }
  9094. htmlForm.push('<div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">');
  9095. htmlForm.push(createFormBtn(that).join(''));
  9096. htmlForm.push('</div>');
  9097. htmlForm.push('</div>');
  9098. htmlForm.push('</fieldset>');
  9099. htmlForm.push('</form>');
  9100. return htmlForm.join('');
  9101. };
  9102. var createFormBtn = function (that) {
  9103. var htmlBtn = [];
  9104. var searchSubmit = that.options.formatCommonSubmitButton();
  9105. var searchReset = that.options.formatCommonResetButton();
  9106. htmlBtn.push('<div class="col-sm-8 col-xs-offset-4">');
  9107. htmlBtn.push(sprintf('<button type="submit" class="btn btn-success" formnovalidate>%s</button> ', searchSubmit));
  9108. htmlBtn.push(sprintf('<button type="reset" class="btn btn-default" >%s</button> ', searchReset));
  9109. htmlBtn.push('</div>');
  9110. return htmlBtn;
  9111. };
  9112. var createOptionList = function (searchList, vObjCol, that) {
  9113. var isArray = searchList.constructor === Array;
  9114. var optionList = [];
  9115. optionList.push(sprintf('<option value="">%s</option>', that.options.formatCommonChoose()));
  9116. $.each(searchList, function (key, value) {
  9117. if (value.constructor === Object) {
  9118. key = value.id;
  9119. value = value.name;
  9120. } else {
  9121. key = isArray ? value : key;
  9122. }
  9123. optionList.push(sprintf("<option value='" + key + "' %s>" + value + "</option>", key == vObjCol.defaultValue ? 'selected' : ''));
  9124. });
  9125. return optionList;
  9126. };
  9127. var isSearchAvailble = function (that) {
  9128. //只支持服务端搜索
  9129. if (!that.options.commonSearch || that.options.sidePagination != 'server' || !that.options.url) {
  9130. return false;
  9131. }
  9132. return true;
  9133. };
  9134. var getSearchQuery = function (that, removeempty) {
  9135. var op = {};
  9136. var filter = {};
  9137. var value = '';
  9138. $("form.form-commonsearch .operate", that.$commonsearch).each(function (i) {
  9139. var name = $(this).data("name");
  9140. var sym = $(this).is("select") ? $("option:selected", this).val() : $(this).val().toUpperCase();
  9141. var obj = $("[name='" + name + "']", that.$commonsearch);
  9142. if (obj.length == 0)
  9143. return true;
  9144. var vObjCol = ColumnsForSearch[i];
  9145. var process = !that.options.searchFormTemplate && vObjCol && typeof vObjCol.process == 'function' ? vObjCol.process : null;
  9146. if (obj.length > 1) {
  9147. if (/BETWEEN$/.test(sym)) {
  9148. var value_begin = $.trim($("[name='" + name + "']:first", that.$commonsearch).val()),
  9149. value_end = $.trim($("[name='" + name + "']:last", that.$commonsearch).val());
  9150. if (value_begin.length || value_end.length) {
  9151. if (process) {
  9152. value_begin = process(value_begin, 'begin');
  9153. value_end = process(value_end, 'end');
  9154. }
  9155. value = value_begin + ',' + value_end;
  9156. } else {
  9157. value = '';
  9158. }
  9159. //如果是时间筛选,将operate置为RANGE
  9160. if ($("[name='" + name + "']:first", that.$commonsearch).hasClass("datetimepicker")) {
  9161. sym = 'RANGE';
  9162. }
  9163. } else {
  9164. value = $("[name='" + name + "']:checked", that.$commonsearch).val();
  9165. value = process ? process(value) : value;
  9166. }
  9167. } else {
  9168. value = process ? process(obj.val()) : obj.val();
  9169. }
  9170. if (removeempty && (value === '' || value == null || ($.isArray(value) && value.length === 0)) && !sym.match(/null/i)) {
  9171. return true;
  9172. }
  9173. op[name] = sym;
  9174. filter[name] = value;
  9175. });
  9176. if (that.options.searchCountTips) {
  9177. var count = 0;
  9178. $.each(filter, function (key, value) {
  9179. if ((value === '' || value == null || ($.isArray(value) && value.length === 0))) {
  9180. return true;
  9181. }
  9182. count++;
  9183. });
  9184. that.$toolbar.find(".btn-commonsearch > span").text(count).toggleClass("hidden", count === 0);
  9185. }
  9186. return {op: op, filter: filter};
  9187. };
  9188. var getQueryParams = function (params, searchQuery, removeempty) {
  9189. params.filter = typeof params.filter === 'Object' ? params.filter : (params.filter ? JSON.parse(params.filter) : {});
  9190. params.op = typeof params.op === 'Object' ? params.op : (params.op ? JSON.parse(params.op) : {});
  9191. params.filter = $.extend({}, params.filter, searchQuery.filter);
  9192. params.op = $.extend({}, params.op, searchQuery.op);
  9193. //移除empty的值
  9194. if (removeempty) {
  9195. $.each(params.filter, function (i, j) {
  9196. if ((j == '' || j == null || ($.isArray(j) && j.length == 0)) && !params.op[i].match(/null/i)) {
  9197. delete params.filter[i];
  9198. delete params.op[i];
  9199. }
  9200. });
  9201. }
  9202. params.filter = JSON.stringify(params.filter);
  9203. params.op = JSON.stringify(params.op);
  9204. return params;
  9205. };
  9206. $.extend($.fn.bootstrapTable.defaults, {
  9207. commonSearch: false,
  9208. titleForm: "Common search",
  9209. actionForm: "",
  9210. searchFormTemplate: "",
  9211. searchFormVisible: true,
  9212. searchCountTips: true,
  9213. searchClass: 'searchit',
  9214. showSearch: true,
  9215. renderDefault: true,
  9216. onCommonSearch: function (field, text) {
  9217. return false;
  9218. },
  9219. onPostCommonSearch: function (table) {
  9220. return false;
  9221. }
  9222. });
  9223. $.extend($.fn.bootstrapTable.defaults.icons, {
  9224. commonSearchIcon: 'glyphicon-search'
  9225. });
  9226. $.extend($.fn.bootstrapTable.Constructor.EVENTS, {
  9227. 'common-search.bs.table': 'onCommonSearch',
  9228. 'post-common-search.bs.table': 'onPostCommonSearch'
  9229. });
  9230. $.extend($.fn.bootstrapTable.locales[$.fn.bootstrapTable.defaults.locale], {
  9231. formatCommonSearch: function () {
  9232. return "Common search";
  9233. },
  9234. formatCommonSubmitButton: function () {
  9235. return "Search";
  9236. },
  9237. formatCommonResetButton: function () {
  9238. return "Reset";
  9239. },
  9240. formatCommonCloseButton: function () {
  9241. return "Close";
  9242. },
  9243. formatCommonChoose: function () {
  9244. return "Choose";
  9245. }
  9246. });
  9247. $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);
  9248. var BootstrapTable = $.fn.bootstrapTable.Constructor,
  9249. _initHeader = BootstrapTable.prototype.initHeader,
  9250. _initToolbar = BootstrapTable.prototype.initToolbar,
  9251. _load = BootstrapTable.prototype.load,
  9252. _initSearch = BootstrapTable.prototype.initSearch;
  9253. BootstrapTable.prototype.initHeader = function () {
  9254. _initHeader.apply(this, Array.prototype.slice.apply(arguments));
  9255. this.$header.find('th[data-field]').each(function (i) {
  9256. var column = $(this).data();
  9257. if (typeof column['width'] !== 'undefined' && column['width'].toString().indexOf("%") === -1) {
  9258. $(".th-inner", this).outerWidth(column['width']);
  9259. $(this).css("max-width", column['width']);
  9260. }
  9261. });
  9262. this.options.stateField = this.header.stateField;
  9263. };
  9264. BootstrapTable.prototype.initToolbar = function () {
  9265. _initToolbar.apply(this, Array.prototype.slice.apply(arguments));
  9266. if (!isSearchAvailble(this)) {
  9267. return;
  9268. }
  9269. var that = this,
  9270. html = [];
  9271. if (that.options.showSearch) {
  9272. html.push(sprintf('<div class="columns-%s pull-%s" style="margin-top:10px;margin-bottom:10px;">', this.options.buttonsAlign, this.options.buttonsAlign));
  9273. 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()));
  9274. if (that.options.searchCountTips) {
  9275. html.push(sprintf('<span class="label label-danger hidden">0</span>'));
  9276. }
  9277. html.push(sprintf('<i class="%s %s"></i>', that.options.iconsPrefix, that.options.icons.commonSearchIcon));
  9278. html.push('</button></div>');
  9279. }
  9280. if (that.$toolbar.find(".pull-right").length > 0) {
  9281. $(html.join('')).insertBefore(that.$toolbar.find(".pull-right:first"));
  9282. } else {
  9283. that.$toolbar.append(html.join(''));
  9284. }
  9285. initCommonSearch(that.columns, that);
  9286. that.$toolbar.find('button[name="commonSearch"]')
  9287. .off('click').on('click', function () {
  9288. that.$commonsearch.toggleClass("hidden");
  9289. return;
  9290. });
  9291. that.$container.on("click", "." + that.options.searchClass, function () {
  9292. var value = $(this).data("value");
  9293. var field = $(this).data("field");
  9294. var ul = that.$container.closest(".panel-intro").find("ul[data-field='" + field + "']");
  9295. if (ul.length > 0) {
  9296. $('li a[data-value="' + value + '"][data-toggle="tab"]', ul).trigger('click');
  9297. return;
  9298. }
  9299. var obj = $("form [name='" + field + "']", that.$commonsearch);
  9300. if (obj.length > 0) {
  9301. if (obj.is("select")) {
  9302. $("option[value='" + value + "']", obj).prop("selected", true);
  9303. } else if (obj.length > 1) {
  9304. $("form [name='" + field + "'][value='" + value + "']", that.$commonsearch).prop("checked", true);
  9305. } else {
  9306. obj.val(value + "");
  9307. }
  9308. obj.trigger("change");
  9309. $("form", that.$commonsearch).trigger("submit");
  9310. }
  9311. });
  9312. var queryParams = that.options.queryParams;
  9313. //匹配默认搜索值
  9314. this.options.queryParams = function (params) {
  9315. return queryParams(getQueryParams(params, getSearchQuery(that, true)));
  9316. };
  9317. this.trigger('post-common-search', that);
  9318. };
  9319. BootstrapTable.prototype.onCommonSearch = function () {
  9320. var searchQuery = getSearchQuery(this);
  9321. this.trigger('common-search', this, searchQuery);
  9322. this.options.pageNumber = 1;
  9323. //this.options.pageSize = $.fn.bootstrapTable.defaults.pageSize;
  9324. this.refresh({});
  9325. };
  9326. BootstrapTable.prototype.load = function (data) {
  9327. _load.apply(this, Array.prototype.slice.apply(arguments));
  9328. if (!isSearchAvailble(this)) {
  9329. return;
  9330. }
  9331. };
  9332. BootstrapTable.prototype.initSearch = function () {
  9333. _initSearch.apply(this, Array.prototype.slice.apply(arguments));
  9334. if (!isSearchAvailble(this)) {
  9335. return;
  9336. }
  9337. var that = this;
  9338. var fp = $.isEmptyObject(this.filterColumnsPartial) ? null : this.filterColumnsPartial;
  9339. this.data = fp ? $.grep(this.data, function (item, i) {
  9340. for (var key in fp) {
  9341. var fval = fp[key].toLowerCase();
  9342. var value = item[key];
  9343. value = $.fn.bootstrapTable.utils.calculateObjectValue(that.header,
  9344. that.header.formatters[$.inArray(key, that.header.fields)],
  9345. [value, item, i], value);
  9346. if (!($.inArray(key, that.header.fields) !== -1 &&
  9347. (typeof value === 'string' || typeof value === 'number') &&
  9348. (value + '').toLowerCase().indexOf(fval) !== -1)) {
  9349. return false;
  9350. }
  9351. }
  9352. return true;
  9353. }) : this.data;
  9354. };
  9355. }(jQuery);
  9356. define("bootstrap-table-commonsearch", ["bootstrap-table"], (function (global) {
  9357. return function () {
  9358. var ret, fn;
  9359. return ret || global.$.fn.bootstrapTable.defaults;
  9360. };
  9361. }(this)));
  9362. /**
  9363. * 将BootstrapTable的行使用自定义的模板来渲染
  9364. *
  9365. * @author: karson
  9366. * @version: v0.0.1
  9367. *
  9368. * @update 2017-06-24 <http://github.com/karsonzhang/fastadmin>
  9369. */
  9370. !function ($) {
  9371. 'use strict';
  9372. $.extend($.fn.bootstrapTable.defaults, {
  9373. //是否启用模板渲染
  9374. templateView: false,
  9375. //数据格式化的模板ID或格式函数
  9376. templateFormatter: "itemtpl",
  9377. //添加的父类的class
  9378. templateParentClass: "row row-flex",
  9379. //向table添加的class
  9380. templateTableClass: "table-template",
  9381. });
  9382. var BootstrapTable = $.fn.bootstrapTable.Constructor,
  9383. _initContainer = BootstrapTable.prototype.initContainer,
  9384. _initBody = BootstrapTable.prototype.initBody,
  9385. _initRow = BootstrapTable.prototype.initRow;
  9386. BootstrapTable.prototype.initContainer = function () {
  9387. _initContainer.apply(this, Array.prototype.slice.apply(arguments));
  9388. var that = this;
  9389. if (!that.options.templateView) {
  9390. return;
  9391. }
  9392. that.options.cardView = true;
  9393. };
  9394. BootstrapTable.prototype.initBody = function () {
  9395. var that = this;
  9396. $.extend(that.options, {
  9397. showHeader: !that.options.templateView ? $.fn.bootstrapTable.defaults.showHeader : false,
  9398. showFooter: !that.options.templateView ? $.fn.bootstrapTable.defaults.showFooter : false,
  9399. });
  9400. $(that.$el).toggleClass(that.options.templateTableClass, that.options.templateView);
  9401. _initBody.apply(this, Array.prototype.slice.apply(arguments));
  9402. if (!that.options.templateView) {
  9403. return;
  9404. } else {
  9405. //由于Bootstrap是基于Table的,添加一个父类容器
  9406. $("> *:not(.no-records-found)", that.$body).wrapAll($("<div />").addClass(that.options.templateParentClass));
  9407. }
  9408. };
  9409. BootstrapTable.prototype.initRow = function (item, i, data, parentDom) {
  9410. var that = this;
  9411. //如果未启用则使用原生的initRow方法
  9412. if (!that.options.templateView) {
  9413. return _initRow.apply(that, Array.prototype.slice.apply(arguments));
  9414. }
  9415. var $content = '';
  9416. if (typeof that.options.templateFormatter === 'function') {
  9417. $content = that.options.templateFormatter.call(that, item, i, data);
  9418. } else {
  9419. var Template = require('template');
  9420. $content = Template(that.options.templateFormatter, {item: item, i: i, data: data});
  9421. }
  9422. return $content;
  9423. };
  9424. }(jQuery);
  9425. define("bootstrap-table-template", ["bootstrap-table","template"], (function (global) {
  9426. return function () {
  9427. var ret, fn;
  9428. return ret || global.$.fn.bootstrapTable.defaults;
  9429. };
  9430. }(this)));
  9431. /**
  9432. * @author Jay <jwang@dizsoft.com>
  9433. */
  9434. (function ($) {
  9435. 'use strict';
  9436. var sprintf = $.fn.bootstrapTable.utils.sprintf;
  9437. $.extend($.fn.bootstrapTable.defaults, {
  9438. showJumpto: false,
  9439. exportOptions: {}
  9440. });
  9441. $.extend($.fn.bootstrapTable.locales, {
  9442. formatJumpto: function () {
  9443. return 'GO';
  9444. }
  9445. });
  9446. $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);
  9447. var BootstrapTable = $.fn.bootstrapTable.Constructor,
  9448. _initPagination = BootstrapTable.prototype.initPagination;
  9449. BootstrapTable.prototype.initPagination = function () {
  9450. this.showToolbar = this.options.showExport;
  9451. _initPagination.apply(this, Array.prototype.slice.apply(arguments));
  9452. if (this.options.showJumpto) {
  9453. var that = this,
  9454. $pageGroup = this.$pagination.find('ul.pagination'),
  9455. $jumpto = $pageGroup.find('li.jumpto');
  9456. if (!$jumpto.length) {
  9457. $jumpto = $([
  9458. '<li class="jumpto">',
  9459. '<input type="text" class="form-control">',
  9460. '<button class="btn' +
  9461. sprintf(' btn-%s', this.options.buttonsClass) +
  9462. sprintf(' btn-%s', this.options.iconSize) +
  9463. '" title="' + this.options.formatJumpto() + '" ' +
  9464. ' type="button">'+this.options.formatJumpto(),
  9465. '</button>',
  9466. '</li>'].join('')).appendTo($pageGroup);
  9467. $jumpto.find('button').click(function () {
  9468. that.selectPage(parseInt($jumpto.find('input').val()));
  9469. });
  9470. }
  9471. }
  9472. };
  9473. })(jQuery);
  9474. define("bootstrap-table-jumpto", ["bootstrap-table"], (function (global) {
  9475. return function () {
  9476. var ret, fn;
  9477. return ret || global.$.fn.bootstrapTable.defaults;
  9478. };
  9479. }(this)));
  9480. (function ($) {
  9481. 'use strict';
  9482. // Reasonable defaults
  9483. var PIXEL_STEP = 10;
  9484. var LINE_HEIGHT = 40;
  9485. var PAGE_HEIGHT = 800;
  9486. function normalizeWheel(event) {
  9487. var sX = 0; // spinX
  9488. var sY = 0; // spinY
  9489. var pX = 0; // pixelX
  9490. var pY = 0; // pixelY
  9491. // Legacy
  9492. if ('detail' in event) {
  9493. sY = event.detail;
  9494. }
  9495. if ('wheelDelta' in event) {
  9496. sY = -event.wheelDelta / 120;
  9497. }
  9498. if ('wheelDeltaY' in event) {
  9499. sY = -event.wheelDeltaY / 120;
  9500. }
  9501. if ('wheelDeltaX' in event) {
  9502. sX = -event.wheelDeltaX / 120;
  9503. }
  9504. // side scrolling on FF with DOMMouseScroll
  9505. if ('axis' in event && event.axis === event.HORIZONTAL_AXIS) {
  9506. sX = sY;
  9507. sY = 0;
  9508. }
  9509. pX = sX * PIXEL_STEP;
  9510. pY = sY * PIXEL_STEP;
  9511. if ('deltaY' in event) {
  9512. pY = event.deltaY;
  9513. }
  9514. if ('deltaX' in event) {
  9515. pX = event.deltaX;
  9516. }
  9517. if ((pX || pY) && event.deltaMode) {
  9518. if (event.deltaMode === 1) {
  9519. // delta in LINE units
  9520. pX *= LINE_HEIGHT;
  9521. pY *= LINE_HEIGHT;
  9522. } else {
  9523. // delta in PAGE units
  9524. pX *= PAGE_HEIGHT;
  9525. pY *= PAGE_HEIGHT;
  9526. }
  9527. }
  9528. // Fall-back if spin cannot be determined
  9529. if (pX && !sX) {
  9530. sX = pX < 1 ? -1 : 1;
  9531. }
  9532. if (pY && !sY) {
  9533. sY = pY < 1 ? -1 : 1;
  9534. }
  9535. return {
  9536. spinX: sX,
  9537. spinY: sY,
  9538. pixelX: pX,
  9539. pixelY: pY
  9540. };
  9541. }
  9542. var cachedWidth = null;
  9543. var getScrollBarWidth = function getScrollBarWidth() {
  9544. if (cachedWidth === null) {
  9545. var inner = $('<p/>').addClass('fixed-table-scroll-inner'),
  9546. outer = $('<div/>').addClass('fixed-table-scroll-outer'),
  9547. w1 = void 0,
  9548. w2 = void 0;
  9549. outer.append(inner);
  9550. $('body').append(outer);
  9551. w1 = inner[0].offsetWidth;
  9552. outer.css('overflow', 'scroll');
  9553. w2 = inner[0].offsetWidth;
  9554. if (w1 === w2) {
  9555. w2 = outer[0].clientWidth;
  9556. }
  9557. outer.remove();
  9558. cachedWidth = w1 - w2;
  9559. }
  9560. return cachedWidth;
  9561. };
  9562. //获取原本表格体的滑块宽度
  9563. var getTableBodyScrollBarWidth = function getTableBodyScrollBarWidth(tableBody) {
  9564. return tableBody[0].scrollHeight > tableBody[0].clientHeight ? 15 : 0;
  9565. };
  9566. $.extend($.fn.bootstrapTable.defaults, {
  9567. fixedColumns: false,
  9568. fixedNumber: 0,
  9569. fixedRightNumber: 0
  9570. });
  9571. var BootstrapTable = $.fn.bootstrapTable.Constructor,
  9572. _initBody = BootstrapTable.prototype.initBody,
  9573. _initContainer = BootstrapTable.prototype.initContainer,
  9574. _trigger = BootstrapTable.prototype.trigger,
  9575. _hideLoading = BootstrapTable.prototype.hideLoading,
  9576. _updateSelected = BootstrapTable.prototype.updateSelected;
  9577. BootstrapTable.prototype.fixedColumnsSupported = function () {
  9578. var that = this;
  9579. return that.options.fixedColumns && !that.options.detailView && !that.options.cardView;
  9580. };
  9581. BootstrapTable.prototype.initFixedContainer = function () {
  9582. if (!this.fixedColumnsSupported()) {
  9583. return;
  9584. }
  9585. if (this.options.fixedNumber) {
  9586. this.$tableContainer.find('.fixed-columns').length == 0 && this.$tableContainer.append('<div class="fixed-columns"></div>');
  9587. this.$fixedColumns = this.$tableContainer.find('.fixed-columns');
  9588. }
  9589. if (this.options.fixedRightNumber) {
  9590. this.$tableContainer.find('.fixed-columns-right').length == 0 && this.$tableContainer.append('<div class="fixed-columns-right"></div>');
  9591. this.$fixedColumnsRight = this.$tableContainer.find('.fixed-columns-right');
  9592. }
  9593. };
  9594. BootstrapTable.prototype.initContainer = function () {
  9595. _initContainer.apply(this, Array.prototype.slice.apply(arguments));
  9596. this.initFixedContainer();
  9597. };
  9598. BootstrapTable.prototype.initBody = function () {
  9599. _initBody.apply(this, Array.prototype.slice.apply(arguments));
  9600. if (!this.fixedColumnsSupported()) {
  9601. return;
  9602. }
  9603. if (this.options.showHeader && this.options.height) {
  9604. return;
  9605. }
  9606. this.initFixedColumnsBody();
  9607. this.initFixedColumnsEvents();
  9608. };
  9609. BootstrapTable.prototype.trigger = function () {
  9610. var that = this;
  9611. _trigger.apply(this, Array.prototype.slice.apply(arguments));
  9612. if (arguments[0] === 'pre-body') {
  9613. //如果上来就是cardView 设置表格高度为auto
  9614. if (this.options.cardView) {
  9615. this.$tableBody.css("height", "auto");
  9616. }
  9617. }
  9618. //监听cardView 显示/隐藏fixed部分
  9619. if (arguments[0] === 'toggle') {
  9620. if (arguments[1]) {
  9621. this.$tableBody.css("height", "auto");
  9622. this.$fixedColumns && this.$fixedColumns.hide();
  9623. this.$fixedColumnsRight && this.$fixedColumnsRight.hide();
  9624. } else {
  9625. this.$tableBody.css("height", "100%");
  9626. this.$fixedColumns && this.$fixedColumns.show();
  9627. this.$fixedColumnsRight && this.$fixedColumnsRight.show();
  9628. this.$fixedHeaderRight && this.$fixedHeaderRight.scrollLeft(this.$tableBody.find('table').width());
  9629. this.$fixedBodyRight && this.$fixedBodyRight.scrollLeft(this.$tableBody.find('table').width());
  9630. }
  9631. }
  9632. if (!that.fixedColumnsSupported()) {
  9633. return;
  9634. }
  9635. if (arguments[0] === 'post-header') {
  9636. this.initFixedColumnsHeader();
  9637. } else if (arguments[0] === 'scroll-body') {
  9638. if (this.needFixedColumns && this.options.fixedNumber) {
  9639. this.$fixedBody && this.$fixedBody.scrollTop(this.$tableBody.scrollTop());
  9640. }
  9641. if (this.needFixedColumns && this.options.fixedRightNumber) {
  9642. this.$fixedBodyRight && this.$fixedBodyRight.scrollTop(this.$tableBody.scrollTop());
  9643. }
  9644. } else if (arguments[0] === 'load-success') {
  9645. this.hideLoading();
  9646. }
  9647. };
  9648. BootstrapTable.prototype.updateSelected = function () {
  9649. var that = this;
  9650. _updateSelected.apply(this, Array.prototype.slice.apply(arguments));
  9651. if (!this.fixedColumnsSupported()) {
  9652. return;
  9653. }
  9654. this.$tableBody.find('tr').each(function (i, el) {
  9655. var $el = $(el);
  9656. var index = $el.data('index');
  9657. var classes = $el.attr('class');
  9658. var inputSelector = '[name="' + that.options.selectItemName + '"]';
  9659. var $input = $el.find(inputSelector);
  9660. if (typeof index === 'undefined') {
  9661. return;
  9662. }
  9663. var updateFixedBody = function updateFixedBody($fixedHeader, $fixedBody) {
  9664. var $tr = $fixedBody.find('tr[data-index="' + index + '"]');
  9665. $tr.attr('class', classes);
  9666. if ($input.length) {
  9667. $tr.find(inputSelector).prop('checked', $input.prop('checked'));
  9668. }
  9669. if (that.$selectAll.length) {
  9670. $fixedHeader.add($fixedBody).find('[name="btSelectAll"]').prop('checked', that.$selectAll.prop('checked'));
  9671. }
  9672. };
  9673. if (that.$fixedBody && that.options.fixedNumber) {
  9674. updateFixedBody(that.$fixedHeader, that.$fixedBody);
  9675. }
  9676. if (that.$fixedBodyRight && that.options.fixedRightNumber) {
  9677. updateFixedBody(that.$fixedHeaderRight, that.$fixedBodyRight);
  9678. }
  9679. });
  9680. };
  9681. BootstrapTable.prototype.hideLoading = function () {
  9682. _hideLoading.apply(this, Array.prototype.slice.apply(arguments));
  9683. if (this.needFixedColumns && this.options.fixedNumber) {
  9684. this.$fixedColumns.find('.fixed-table-loading').hide();
  9685. }
  9686. if (this.needFixedColumns && this.options.fixedRightNumber) {
  9687. this.$fixedColumnsRight.find('.fixed-table-loading').hide();
  9688. }
  9689. };
  9690. BootstrapTable.prototype.initFixedColumnsHeader = function () {
  9691. var that = this;
  9692. if (this.options.height) {
  9693. this.needFixedColumns = this.$tableHeader.outerWidth(true) < this.$tableHeader.find('table').outerWidth(true);
  9694. } else {
  9695. this.needFixedColumns = this.$tableBody.outerWidth(true) < this.$tableBody.find('table').outerWidth(true);
  9696. }
  9697. var initFixedHeader = function initFixedHeader($fixedColumns, isRight) {
  9698. $fixedColumns.find('.fixed-table-header').remove();
  9699. $fixedColumns.append(that.$tableHeader.clone(true));
  9700. $fixedColumns.find('.fixed-table-header').css('margin-right', "");
  9701. $fixedColumns.css({
  9702. width: that.getFixedColumnsWidth(isRight)
  9703. });
  9704. return $fixedColumns.find('.fixed-table-header');
  9705. };
  9706. if (this.needFixedColumns && this.options.fixedNumber) {
  9707. this.$fixedHeader = initFixedHeader(this.$fixedColumns);
  9708. this.$fixedHeader.css('margin-right', '');
  9709. } else if (this.$fixedColumns) {
  9710. this.$fixedColumns.html('').css('width', '');
  9711. }
  9712. if (this.needFixedColumns && this.options.fixedRightNumber) {
  9713. this.$fixedHeaderRight = initFixedHeader(this.$fixedColumnsRight, true);
  9714. this.$fixedHeaderRight.scrollLeft(this.$fixedHeaderRight.find('table').width());
  9715. } else if (this.$fixedColumnsRight) {
  9716. this.$fixedColumnsRight.html('').css('width', '');
  9717. }
  9718. this.initFixedColumnsBody();
  9719. this.initFixedColumnsEvents();
  9720. };
  9721. BootstrapTable.prototype.initFixedColumnsBody = function () {
  9722. var that = this;
  9723. var initFixedBody = function initFixedBody($fixedColumns, $fixedHeader) {
  9724. $fixedColumns.find('.fixed-table-body').remove();
  9725. $fixedColumns.append(that.$tableBody.clone(true));
  9726. var $fixedBody = $fixedColumns.find('.fixed-table-body');
  9727. var tableBody = that.$tableBody.get(0);
  9728. var scrollHeight = tableBody.scrollWidth > tableBody.clientWidth ? getScrollBarWidth() : 0;
  9729. var paginationHeight = $(".fixed-table-pagination", that.$tableContainer).height();
  9730. if (typeof that.options.height !== 'undefined') paginationHeight = 0;
  9731. var height = that.$tableContainer.outerHeight(true) - scrollHeight - paginationHeight + 1;
  9732. $fixedColumns.css({
  9733. height: height,
  9734. "min-height": "calc(100% - " + (paginationHeight + scrollHeight) + "px)"
  9735. });
  9736. $fixedBody.css({
  9737. height: height - $fixedHeader.height(),
  9738. "min-height": "calc(100% - " + $fixedHeader.height() + "px)",
  9739. overflow: "hidden"
  9740. });
  9741. return $fixedBody;
  9742. };
  9743. if (this.needFixedColumns && this.options.fixedNumber) {
  9744. this.$fixedBody = initFixedBody(this.$fixedColumns, this.$fixedHeader);
  9745. }
  9746. if (this.needFixedColumns && this.options.fixedRightNumber) {
  9747. this.$fixedBodyRight = initFixedBody(this.$fixedColumnsRight, this.$fixedHeaderRight);
  9748. this.$fixedBodyRight.scrollLeft(this.$fixedBodyRight.find('table').width());
  9749. this.$fixedBodyRight.css('overflow-y', 'hidden');
  9750. }
  9751. };
  9752. BootstrapTable.prototype.getFixedColumnsWidth = function (isRight) {
  9753. var visibleFields = this.getVisibleFields();
  9754. var width = 0;
  9755. var fixedNumber = this.options.fixedNumber;
  9756. var marginRight = 0;
  9757. if (isRight) {
  9758. visibleFields = visibleFields.reverse();
  9759. fixedNumber = this.options.fixedRightNumber;
  9760. //右侧固定列距离
  9761. this.$fixedColumnsRight.css('right', getTableBodyScrollBarWidth(this.$tableBody));
  9762. }
  9763. for (var i = 0; i < fixedNumber; i++) {
  9764. width += this.$header.find('th[data-field="' + visibleFields[i] + '"]').outerWidth();
  9765. }
  9766. return width + 1;
  9767. };
  9768. BootstrapTable.prototype.initFixedColumnsEvents = function () {
  9769. var that = this;
  9770. var toggleHover = function toggleHover(e, toggle) {
  9771. var tr = 'tr[data-index="' + $(e.currentTarget).data('index') + '"]';
  9772. var $trs = that.$tableBody.find(tr);
  9773. if (that.$fixedBody) {
  9774. $trs = $trs.add(that.$fixedBody.find(tr));
  9775. }
  9776. if (that.$fixedBodyRight) {
  9777. $trs = $trs.add(that.$fixedBodyRight.find(tr));
  9778. }
  9779. $trs.css('background-color', toggle ? $(e.currentTarget).css('background-color') : '');
  9780. };
  9781. this.$tableBody.find('tr').hover(function (e) {
  9782. toggleHover(e, true);
  9783. }, function (e) {
  9784. toggleHover(e, false);
  9785. });
  9786. var isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
  9787. var mousewheel = isFirefox ? 'DOMMouseScroll' : 'mousewheel';
  9788. var updateScroll = function updateScroll(e, fixedBody) {
  9789. var normalized = normalizeWheel(e);
  9790. var deltaY = Math.ceil(normalized.pixelY);
  9791. var top = that.$tableBody.scrollTop() + deltaY;
  9792. if (deltaY < 0 && top > 0 || deltaY > 0 && top < fixedBody.scrollHeight - fixedBody.clientHeight) {
  9793. e.preventDefault();
  9794. }
  9795. that.$tableBody.scrollTop(top);
  9796. if (that.$fixedBody) {
  9797. that.$fixedBody.scrollTop(top);
  9798. }
  9799. if (that.$fixedBodyRight) {
  9800. that.$fixedBodyRight.scrollTop(top);
  9801. }
  9802. };
  9803. if (this.needFixedColumns && this.options.fixedNumber) {
  9804. this.$fixedBody.find('tr').hover(function (e) {
  9805. toggleHover(e, true);
  9806. }, function (e) {
  9807. toggleHover(e, false);
  9808. });
  9809. this.$fixedBody[0].addEventListener(mousewheel, function (e) {
  9810. //给鼠标滑轮绑定事件
  9811. updateScroll(e, that.$fixedBody[0]);
  9812. });
  9813. //给固定表格的checkbox绑定事件
  9814. this.$fixedBody.find('input[name="' + this.options.selectItemName + '"]').off("click").on('click', function (e) {
  9815. e.stopImmediatePropagation();
  9816. var index = $(e.target).data("index");
  9817. $(that.$selectItem[index]).trigger("click");
  9818. });
  9819. //绑定TD点击事件
  9820. this.$fixedBody.find('> table > tbody > tr[data-index] > td').off('click dblclick').on('click dblclick', function (e) {
  9821. var index = $(this).closest("tr[data-index]").data("index");
  9822. $(that.$selectItem[index]).closest("tr[data-index]").find(">td:eq(" + $(this).index() + ")").trigger("click");
  9823. });
  9824. }
  9825. //给原本表格绑定scroll事件
  9826. $('div.fixed-table-body').off('scroll'); //给所有的body解绑 scroll
  9827. this.$tableBody.off('scroll').on('scroll', function (e) {
  9828. that.$tableHeader.scrollLeft(0);
  9829. if (that.$tableBody.scrollLeft() > 0) {
  9830. that.$tableHeader.scrollLeft(that.$tableBody.scrollLeft());
  9831. if (that.options.showFooter && !that.options.cardView) {
  9832. that.$tableFooter.scrollLeft(that.$tableBody.scrollLeft());
  9833. }
  9834. }
  9835. var top = that.$tableBody.scrollTop();
  9836. if (that.$fixedBody) {
  9837. that.$fixedBody.scrollTop(top);
  9838. }
  9839. if (that.$fixedBodyRight) {
  9840. that.$fixedBodyRight.scrollTop(top);
  9841. }
  9842. });
  9843. if (this.needFixedColumns && this.options.fixedRightNumber) {
  9844. this.$fixedBodyRight.find('tr').hover(function (e) {
  9845. toggleHover(e, true);
  9846. }, function (e) {
  9847. toggleHover(e, false);
  9848. });
  9849. this.$fixedBodyRight[0].addEventListener(mousewheel, function (e) {
  9850. //给鼠标滑轮绑定事件
  9851. updateScroll(e, that.$fixedBodyRight[0]);
  9852. });
  9853. //给固定表格的checkbox绑定事件
  9854. this.$fixedBodyRight.find('input[name="' + this.options.selectItemName + '"]').off("click").on('click', function (e) {
  9855. e.stopImmediatePropagation();
  9856. var index = $(e.target).data("index");
  9857. $(that.$selectItem[index]).trigger("click");
  9858. });
  9859. //绑定TD点击事件
  9860. this.$fixedBodyRight.find('> table > tbody > tr[data-index] > td').off('click dblclick').on('click dblclick', function (e) {
  9861. var index = $(this).closest("tr[data-index]").data("index");
  9862. $(that.$selectItem[index]).closest("tr[data-index]").find(">td:eq(" + $(this).index() + ")").trigger("click");
  9863. });
  9864. }
  9865. if (this.options.filterControl) {
  9866. $(this.$fixedColumns).off('keyup change').on('keyup change', function (e) {
  9867. var $target = $(e.target);
  9868. var value = $target.val();
  9869. var field = $target.parents('th').data('field');
  9870. var $coreTh = that.$header.find('th[data-field="' + field + '"]');
  9871. if ($target.is('input')) {
  9872. $coreTh.find('input').val(value);
  9873. } else if ($target.is('select')) {
  9874. var $select = $coreTh.find('select');
  9875. $select.find('option[selected]').removeAttr('selected');
  9876. $select.find('option[value="' + value + '"]').attr('selected', true);
  9877. }
  9878. that.triggerSearch();
  9879. });
  9880. }
  9881. };
  9882. })(jQuery);
  9883. define("bootstrap-table-fixed-columns", ["bootstrap-table"], (function (global) {
  9884. return function () {
  9885. var ret, fn;
  9886. return ret || global.$.fn.bootstrapTable.defaults;
  9887. };
  9888. }(this)));
  9889. define('table',['jquery', 'bootstrap'], function ($, undefined) {
  9890. var Table = {
  9891. list: {},
  9892. // Bootstrap-table 基础配置
  9893. defaults: {
  9894. url: '',
  9895. sidePagination: 'server',
  9896. method: 'get', //请求方法
  9897. toolbar: ".toolbar", //工具栏
  9898. search: true, //是否启用快速搜索
  9899. cache: false,
  9900. commonSearch: true, //是否启用通用搜索
  9901. searchFormVisible: false, //是否始终显示搜索表单
  9902. titleForm: '', //为空则不显示标题,不定义默认显示:普通搜索
  9903. idTable: 'commonTable',
  9904. showExport: true,
  9905. exportDataType: "auto",
  9906. exportTypes: ['json', 'xml', 'csv', 'txt', 'doc', 'excel'],
  9907. exportOptions: {
  9908. fileName: 'export_' + Moment().format("YYYY-MM-DD"),
  9909. preventInjection: false,
  9910. mso: {
  9911. onMsoNumberFormat: function (cell, row, col) {
  9912. return !isNaN($(cell).text()) ? '\\@' : '';
  9913. },
  9914. },
  9915. ignoreColumn: [0, 'operate'] //默认不导出第一列(checkbox)与操作(operate)列
  9916. },
  9917. pageSize: Config.pagesize || localStorage.getItem("pagesize") || 10,
  9918. pageList: [10, 15, 20, 25, 50, 'All'],
  9919. pagination: true,
  9920. clickToSelect: true, //是否启用点击选中
  9921. dblClickToEdit: true, //是否启用双击编辑
  9922. singleSelect: false, //是否启用单选
  9923. showRefresh: false,
  9924. showJumpto: true,
  9925. locale: Config.language === 'en' ? 'en-US' : Config.language.replace(/\-(\w+)$/, function (value) {
  9926. return value.toUpperCase();
  9927. }),
  9928. showToggle: true,
  9929. showColumns: true,
  9930. pk: 'id',
  9931. sortName: 'id',
  9932. sortOrder: 'desc',
  9933. paginationFirstText: __("First"),
  9934. paginationPreText: __("Previous"),
  9935. paginationNextText: __("Next"),
  9936. paginationLastText: __("Last"),
  9937. cardView: false, //卡片视图
  9938. iosCardView: true, //ios卡片视图
  9939. checkOnInit: true, //是否在初始化时判断
  9940. escape: true, //是否对内容进行转义
  9941. fixDropdownPosition: true, //是否修复下拉的定位
  9942. selectedIds: [],
  9943. selectedData: [],
  9944. extend: {
  9945. index_url: '',
  9946. add_url: '',
  9947. edit_url: '',
  9948. del_url: '',
  9949. import_url: '',
  9950. multi_url: '',
  9951. dragsort_url: 'ajax/weigh',
  9952. }
  9953. },
  9954. // Bootstrap-table 列配置
  9955. columnDefaults: {
  9956. align: 'center',
  9957. valign: 'middle',
  9958. },
  9959. config: {
  9960. checkboxtd: 'tbody>tr>td.bs-checkbox',
  9961. toolbar: '.toolbar',
  9962. refreshbtn: '.btn-refresh',
  9963. addbtn: '.btn-add',
  9964. editbtn: '.btn-edit',
  9965. delbtn: '.btn-del',
  9966. importbtn: '.btn-import',
  9967. multibtn: '.btn-multi',
  9968. disabledbtn: '.btn-disabled',
  9969. editonebtn: '.btn-editone',
  9970. restoreonebtn: '.btn-restoreone',
  9971. destroyonebtn: '.btn-destroyone',
  9972. restoreallbtn: '.btn-restoreall',
  9973. destroyallbtn: '.btn-destroyall',
  9974. dragsortfield: 'weigh',
  9975. },
  9976. button: {
  9977. edit: {
  9978. name: 'edit',
  9979. icon: 'fa fa-pencil',
  9980. title: __('Edit'),
  9981. extend: 'data-toggle="tooltip"',
  9982. classname: 'btn btn-xs btn-success btn-editone'
  9983. },
  9984. del: {
  9985. name: 'del',
  9986. icon: 'fa fa-trash',
  9987. title: __('Del'),
  9988. extend: 'data-toggle="tooltip"',
  9989. classname: 'btn btn-xs btn-danger btn-delone'
  9990. },
  9991. dragsort: {
  9992. name: 'dragsort',
  9993. icon: 'fa fa-arrows',
  9994. title: __('Drag to sort'),
  9995. extend: 'data-toggle="tooltip"',
  9996. classname: 'btn btn-xs btn-primary btn-dragsort'
  9997. }
  9998. },
  9999. api: {
  10000. init: function (defaults, columnDefaults, locales) {
  10001. defaults = defaults ? defaults : {};
  10002. columnDefaults = columnDefaults ? columnDefaults : {};
  10003. locales = locales ? locales : {};
  10004. $.fn.bootstrapTable.Constructor.prototype.getSelectItem = function () {
  10005. return this.$selectItem;
  10006. };
  10007. var _onPageListChange = $.fn.bootstrapTable.Constructor.prototype.onPageListChange;
  10008. $.fn.bootstrapTable.Constructor.prototype.onPageListChange = function () {
  10009. _onPageListChange.apply(this, Array.prototype.slice.apply(arguments));
  10010. localStorage.setItem('pagesize', this.options.pageSize);
  10011. return false;
  10012. };
  10013. // 写入bootstrap-table默认配置
  10014. $.extend(true, $.fn.bootstrapTable.defaults, Table.defaults, defaults);
  10015. // 写入bootstrap-table column配置
  10016. $.extend($.fn.bootstrapTable.columnDefaults, Table.columnDefaults, columnDefaults);
  10017. // 写入bootstrap-table locale配置
  10018. $.extend($.fn.bootstrapTable.locales[Table.defaults.locale], {
  10019. formatCommonSearch: function () {
  10020. return __('Common search');
  10021. },
  10022. formatCommonSubmitButton: function () {
  10023. return __('Search');
  10024. },
  10025. formatCommonResetButton: function () {
  10026. return __('Reset');
  10027. },
  10028. formatCommonCloseButton: function () {
  10029. return __('Close');
  10030. },
  10031. formatCommonChoose: function () {
  10032. return __('Choose');
  10033. },
  10034. formatJumpto: function () {
  10035. return __('Go');
  10036. }
  10037. }, locales);
  10038. // 如果是iOS设备则判断是否启用卡片视图
  10039. if ($.fn.bootstrapTable.defaults.iosCardView && navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
  10040. Table.defaults.cardView = true;
  10041. $.fn.bootstrapTable.defaults.cardView = true;
  10042. }
  10043. if (typeof defaults.exportTypes != 'undefined') {
  10044. $.fn.bootstrapTable.defaults.exportTypes = defaults.exportTypes;
  10045. }
  10046. },
  10047. // 绑定事件
  10048. bindevent: function (table) {
  10049. //Bootstrap-table的父元素,包含table,toolbar,pagnation
  10050. var parenttable = table.closest('.bootstrap-table');
  10051. //Bootstrap-table配置
  10052. var options = table.bootstrapTable('getOptions');
  10053. //Bootstrap操作区
  10054. var toolbar = $(options.toolbar, parenttable);
  10055. //跨页提示按钮
  10056. var tipsBtn = $(".btn-selected-tips", parenttable);
  10057. if (tipsBtn.length === 0) {
  10058. 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);
  10059. }
  10060. //点击提示按钮
  10061. tipsBtn.off("click").on("click", function (e) {
  10062. table.trigger("uncheckbox");
  10063. table.bootstrapTable("refresh");
  10064. });
  10065. //当刷新表格时
  10066. table.on('uncheckbox', function (status, res, e) {
  10067. options.selectedIds = [];
  10068. options.selectedData = [];
  10069. tipsBtn.tooltip('hide');
  10070. tipsBtn.addClass('hide');
  10071. });
  10072. //表格加载出错时
  10073. table.on('load-error.bs.table', function (status, res, e) {
  10074. if (e.status === 0) {
  10075. return;
  10076. }
  10077. Toastr.error(__('Unknown data format'));
  10078. });
  10079. //当加载数据成功时
  10080. table.on('load-success.bs.table', function (e, data) {
  10081. if (typeof data.rows === 'undefined' && typeof data.code != 'undefined') {
  10082. Toastr.error(data.msg);
  10083. }
  10084. });
  10085. //当刷新表格时
  10086. table.on('refresh.bs.table', function (e, settings, data) {
  10087. $(Table.config.refreshbtn, toolbar).find(".fa").addClass("fa-spin");
  10088. });
  10089. //当执行搜索时
  10090. table.on('search.bs.table common-search.bs.table', function (e, settings, data) {
  10091. table.trigger("uncheckbox");
  10092. });
  10093. if (options.dblClickToEdit) {
  10094. //当双击单元格时
  10095. table.on('dbl-click-row.bs.table', function (e, row, element, field) {
  10096. $(Table.config.editonebtn, element).trigger("click");
  10097. });
  10098. }
  10099. //渲染内容前
  10100. table.on('pre-body.bs.table', function (e, data) {
  10101. if (options.maintainSelected) {
  10102. $.each(data, function (i, row) {
  10103. row[options.stateField] = $.inArray(row[options.pk], options.selectedIds) > -1;
  10104. });
  10105. }
  10106. });
  10107. //当内容渲染完成后
  10108. table.on('post-body.bs.table', function (e, data) {
  10109. $(Table.config.refreshbtn, toolbar).find(".fa").removeClass("fa-spin");
  10110. if ($(Table.config.checkboxtd + ":first", table).find("input[type='checkbox'][data-index]").length > 0) {
  10111. // 拖拽选择,需要重新绑定事件
  10112. require(['drag', 'drop'], function () {
  10113. var checkboxtd = $(Table.config.checkboxtd, table);
  10114. checkboxtd.drag("start", function (ev, dd) {
  10115. return $('<div class="selection" />').css('opacity', .65).appendTo(document.body);
  10116. }).drag(function (ev, dd) {
  10117. setTimeout(function () {
  10118. $(dd.proxy).css({
  10119. top: Math.min(ev.pageY, dd.startY),
  10120. left: Math.min(ev.pageX, dd.startX),
  10121. height: Math.abs(ev.pageY - dd.startY),
  10122. width: Math.abs(ev.pageX - dd.startX)
  10123. });
  10124. }, 0);
  10125. }).drag("end", function (ev, dd) {
  10126. $(dd.proxy).remove();
  10127. });
  10128. checkboxtd.drop("start", function () {
  10129. Table.api.toggleattr(this);
  10130. }).drop(function () {
  10131. // Table.api.toggleattr(this);
  10132. }).drop("end", function (e) {
  10133. var that = this;
  10134. setTimeout(function () {
  10135. if (e.type === 'mousemove') {
  10136. Table.api.toggleattr(that);
  10137. }
  10138. }, 0);
  10139. });
  10140. $.drop({
  10141. multi: true
  10142. });
  10143. });
  10144. }
  10145. });
  10146. var exportDataType = options.exportDataType;
  10147. // 处理选中筛选框后按钮的状态统一变更
  10148. table.on('check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table post-body.bs.table', function (e) {
  10149. var allIds = [];
  10150. $.each(table.bootstrapTable("getData"), function (i, item) {
  10151. allIds.push(typeof item[options.pk] != 'undefined' ? item[options.pk] : '');
  10152. });
  10153. var selectedIds = Table.api.selectedids(table, true),
  10154. selectedData = Table.api.selecteddata(table, true);
  10155. //开启分页checkbox分页记忆
  10156. if (options.maintainSelected) {
  10157. options.selectedIds = options.selectedIds.filter(function (element, index, self) {
  10158. return $.inArray(element, allIds) === -1;
  10159. }).concat(selectedIds);
  10160. options.selectedData = options.selectedData.filter(function (element, index, self) {
  10161. return $.inArray(element[options.pk], allIds) === -1;
  10162. }).concat(selectedData);
  10163. if (options.selectedIds.length > selectedIds.length) {
  10164. $("b", tipsBtn).text(options.selectedIds.length);
  10165. tipsBtn.removeClass('hide');
  10166. } else {
  10167. tipsBtn.addClass('hide');
  10168. }
  10169. } else {
  10170. options.selectedIds = selectedIds;
  10171. options.selectedData = selectedData;
  10172. }
  10173. //如果导出类型为auto时则自动判断
  10174. if (exportDataType === 'auto') {
  10175. options.exportDataType = selectedIds.length > 0 ? 'selected' : 'all';
  10176. }
  10177. $(Table.config.disabledbtn, toolbar).toggleClass('disabled', !options.selectedIds.length);
  10178. });
  10179. // 绑定TAB事件
  10180. $('.panel-heading [data-field] a[data-toggle="tab"]', table.closest(".panel-intro")).on('shown.bs.tab', function (e) {
  10181. var field = $(this).closest("[data-field]").data("field");
  10182. var value = $(this).data("value");
  10183. var object = $("[name='" + field + "']", table.closest(".bootstrap-table").find(".commonsearch-table"));
  10184. if (object.prop('tagName') == "SELECT") {
  10185. $("option[value='" + value + "']", object).prop("selected", true);
  10186. } else {
  10187. object.val(value);
  10188. }
  10189. table.trigger("uncheckbox");
  10190. table.bootstrapTable('refresh', {pageNumber: 1});
  10191. return false;
  10192. });
  10193. // 修复重置事件
  10194. $("form", table.closest(".bootstrap-table").find(".commonsearch-table")).on('reset', function () {
  10195. setTimeout(function () {
  10196. // $('.panel-heading [data-field] li.active a[data-toggle="tab"]').trigger('shown.bs.tab');
  10197. }, 0);
  10198. $('.panel-heading [data-field] li', table.closest(".panel-intro")).removeClass('active');
  10199. $('.panel-heading [data-field] li:first', table.closest(".panel-intro")).addClass('active');
  10200. });
  10201. // 刷新按钮事件
  10202. toolbar.on('click', Table.config.refreshbtn, function () {
  10203. table.bootstrapTable('refresh');
  10204. });
  10205. // 添加按钮事件
  10206. toolbar.on('click', Table.config.addbtn, function () {
  10207. var ids = Table.api.selectedids(table);
  10208. var url = options.extend.add_url;
  10209. if (url.indexOf("{ids}") !== -1) {
  10210. url = Table.api.replaceurl(url, {ids: ids.length > 0 ? ids.join(",") : 0}, table);
  10211. }
  10212. Fast.api.open(url, $(this).data("original-title") || $(this).attr("title") || __('Add'), $(this).data() || {});
  10213. });
  10214. // 导入按钮事件
  10215. if ($(Table.config.importbtn, toolbar).length > 0) {
  10216. require(['upload'], function (Upload) {
  10217. Upload.api.upload($(Table.config.importbtn, toolbar), function (data, ret) {
  10218. Fast.api.ajax({
  10219. url: options.extend.import_url,
  10220. data: {file: data.url},
  10221. }, function (data, ret) {
  10222. table.trigger("uncheckbox");
  10223. table.bootstrapTable('refresh');
  10224. });
  10225. });
  10226. });
  10227. }
  10228. // 批量编辑按钮事件
  10229. toolbar.on('click', Table.config.editbtn, function () {
  10230. var that = this;
  10231. var ids = Table.api.selectedids(table);
  10232. if (ids.length > 10) {
  10233. return;
  10234. }
  10235. var title = $(that).data('title') || $(that).attr("title") || __('Edit');
  10236. var data = $(that).data() || {};
  10237. delete data.title;
  10238. //循环弹出多个编辑框
  10239. $.each(Table.api.selecteddata(table), function (index, row) {
  10240. var url = options.extend.edit_url;
  10241. row = $.extend({}, row ? row : {}, {ids: row[options.pk]});
  10242. url = Table.api.replaceurl(url, row, table);
  10243. Fast.api.open(url, typeof title === 'function' ? title.call(table, row) : title, data);
  10244. });
  10245. });
  10246. //清空回收站
  10247. $(document).on('click', Table.config.destroyallbtn, function () {
  10248. var that = this;
  10249. Layer.confirm(__('Are you sure you want to truncate?'), function () {
  10250. var url = $(that).data("url") ? $(that).data("url") : $(that).attr("href");
  10251. Fast.api.ajax(url, function () {
  10252. Layer.closeAll();
  10253. table.trigger("uncheckbox");
  10254. table.bootstrapTable('refresh');
  10255. }, function () {
  10256. Layer.closeAll();
  10257. });
  10258. });
  10259. return false;
  10260. });
  10261. //全部还原
  10262. $(document).on('click', Table.config.restoreallbtn, function () {
  10263. var that = this;
  10264. var url = $(that).data("url") ? $(that).data("url") : $(that).attr("href");
  10265. Fast.api.ajax(url, function () {
  10266. Layer.closeAll();
  10267. table.trigger("uncheckbox");
  10268. table.bootstrapTable('refresh');
  10269. }, function () {
  10270. Layer.closeAll();
  10271. });
  10272. return false;
  10273. });
  10274. //销毁或删除
  10275. $(document).on('click', Table.config.restoreonebtn + ',' + Table.config.destroyonebtn, function () {
  10276. var that = this;
  10277. var url = $(that).data("url") ? $(that).data("url") : $(that).attr("href");
  10278. var row = Table.api.getrowbyindex(table, $(that).data("row-index"));
  10279. Fast.api.ajax({
  10280. url: url,
  10281. data: {ids: row[options.pk]}
  10282. }, function () {
  10283. table.trigger("uncheckbox");
  10284. table.bootstrapTable('refresh');
  10285. });
  10286. return false;
  10287. });
  10288. // 批量操作按钮事件
  10289. toolbar.on('click', Table.config.multibtn, function () {
  10290. var ids = Table.api.selectedids(table);
  10291. Table.api.multi($(this).data("action"), ids, table, this);
  10292. });
  10293. // 批量删除按钮事件
  10294. toolbar.on('click', Table.config.delbtn, function () {
  10295. var that = this;
  10296. var ids = Table.api.selectedids(table);
  10297. Layer.confirm(
  10298. __('Are you sure you want to delete the %s selected item?', ids.length),
  10299. {icon: 3, title: __('Warning'), offset: 0, shadeClose: true, btn: [__('OK'), __('Cancel')]},
  10300. function (index) {
  10301. Table.api.multi("del", ids, table, that);
  10302. Layer.close(index);
  10303. }
  10304. );
  10305. });
  10306. // 拖拽排序
  10307. require(['dragsort'], function () {
  10308. //绑定拖动排序
  10309. $("tbody", table).dragsort({
  10310. itemSelector: 'tr:visible',
  10311. dragSelector: "a.btn-dragsort",
  10312. dragEnd: function (a, b) {
  10313. var element = $("a.btn-dragsort", this);
  10314. var data = table.bootstrapTable('getData');
  10315. var current = data[parseInt($(this).data("index"))];
  10316. var options = table.bootstrapTable('getOptions');
  10317. //改变的值和改变的ID集合
  10318. var ids = $.map($("tbody tr:visible", table), function (tr) {
  10319. return data[parseInt($(tr).data("index"))][options.pk];
  10320. });
  10321. var changeid = current[options.pk];
  10322. var pid = typeof current.pid != 'undefined' ? current.pid : '';
  10323. var params = {
  10324. url: table.bootstrapTable('getOptions').extend.dragsort_url,
  10325. data: {
  10326. ids: ids.join(','),
  10327. changeid: changeid,
  10328. pid: pid,
  10329. field: Table.config.dragsortfield,
  10330. orderway: options.sortOrder,
  10331. table: options.extend.table,
  10332. pk: options.pk
  10333. }
  10334. };
  10335. Fast.api.ajax(params, function (data, ret) {
  10336. var success = $(element).data("success") || $.noop;
  10337. if (typeof success === 'function') {
  10338. if (false === success.call(element, data, ret)) {
  10339. return false;
  10340. }
  10341. }
  10342. table.bootstrapTable('refresh');
  10343. }, function (data, ret) {
  10344. var error = $(element).data("error") || $.noop;
  10345. if (typeof error === 'function') {
  10346. if (false === error.call(element, data, ret)) {
  10347. return false;
  10348. }
  10349. }
  10350. table.bootstrapTable('refresh');
  10351. });
  10352. },
  10353. placeHolderTemplate: ""
  10354. });
  10355. });
  10356. table.on("click", "input[data-id][name='checkbox']", function (e) {
  10357. var ids = $(this).data("id");
  10358. table.bootstrapTable($(this).prop("checked") ? 'checkBy' : 'uncheckBy', {field: options.pk, values: [ids]});
  10359. });
  10360. table.on("click", "[data-id].btn-change", function (e) {
  10361. e.preventDefault();
  10362. var changer = $.proxy(function () {
  10363. Table.api.multi($(this).data("action") ? $(this).data("action") : '', [$(this).data("id")], table, this);
  10364. }, this);
  10365. if (typeof $(this).data("confirm") !== 'undefined') {
  10366. Layer.confirm($(this).data("confirm"), function (index) {
  10367. changer();
  10368. Layer.close(index);
  10369. });
  10370. } else {
  10371. changer();
  10372. }
  10373. });
  10374. table.on("click", "[data-id].btn-edit", function (e) {
  10375. e.preventDefault();
  10376. var ids = $(this).data("id");
  10377. var row = Table.api.getrowbyid(table, ids);
  10378. row.ids = ids;
  10379. var url = Table.api.replaceurl(options.extend.edit_url, row, table);
  10380. Fast.api.open(url, $(this).data("original-title") || $(this).attr("title") || __('Edit'), $(this).data() || {});
  10381. });
  10382. table.on("click", "[data-id].btn-del", function (e) {
  10383. e.preventDefault();
  10384. var id = $(this).data("id");
  10385. var that = this;
  10386. Layer.confirm(
  10387. __('Are you sure you want to delete this item?'),
  10388. {icon: 3, title: __('Warning'), shadeClose: true, btn: [__('OK'), __('Cancel')]},
  10389. function (index) {
  10390. Table.api.multi("del", id, table, that);
  10391. Layer.close(index);
  10392. }
  10393. );
  10394. });
  10395. //修复dropdown定位溢出的情况
  10396. if (options.fixDropdownPosition) {
  10397. var tableBody = table.closest(".fixed-table-body");
  10398. table.on('show.bs.dropdown fa.event.refreshdropdown', ".btn-group", function (e) {
  10399. var dropdownMenu = $(".dropdown-menu", this);
  10400. var btnGroup = $(this);
  10401. var isPullRight = dropdownMenu.hasClass("pull-right") || dropdownMenu.hasClass("dropdown-menu-right");
  10402. var left, top, position;
  10403. if (true || dropdownMenu.outerHeight() + btnGroup.outerHeight() > tableBody.outerHeight() - 41) {
  10404. position = 'fixed';
  10405. top = btnGroup.offset().top - $(window).scrollTop() + btnGroup.outerHeight();
  10406. if ((top + dropdownMenu.outerHeight()) > $(window).height()) {
  10407. top = btnGroup.offset().top - dropdownMenu.outerHeight() - 5;
  10408. }
  10409. left = isPullRight ? btnGroup.offset().left + btnGroup.outerWidth() - dropdownMenu.outerWidth() : btnGroup.offset().left;
  10410. }
  10411. if (left || top) {
  10412. dropdownMenu.css({
  10413. position: position, left: left, top: top, right: 'inherit'
  10414. });
  10415. }
  10416. });
  10417. var checkdropdown = function () {
  10418. if ($(".btn-group.open", table).length > 0 && $(".btn-group.open .dropdown-menu", table).css("position") == 'fixed') {
  10419. $(".btn-group.open", table).trigger("fa.event.refreshdropdown");
  10420. }
  10421. };
  10422. $(window).on("scroll", function () {
  10423. checkdropdown();
  10424. });
  10425. tableBody.on("scroll", function () {
  10426. checkdropdown();
  10427. });
  10428. }
  10429. var id = table.attr("id");
  10430. Table.list[id] = table;
  10431. return table;
  10432. },
  10433. // 批量操作请求
  10434. multi: function (action, ids, table, element) {
  10435. var options = table.bootstrapTable('getOptions');
  10436. var data = element ? $(element).data() : {};
  10437. ids = ($.isArray(ids) ? ids.join(",") : ids);
  10438. var url = typeof data.url !== "undefined" ? data.url : (action == "del" ? options.extend.del_url : options.extend.multi_url);
  10439. var params = typeof data.params !== "undefined" ? (typeof data.params == 'object' ? $.param(data.params) : data.params) : '';
  10440. options = {url: url, data: {action: action, ids: ids, params: params}};
  10441. Fast.api.ajax(options, function (data, ret) {
  10442. table.trigger("uncheckbox");
  10443. var success = $(element).data("success") || $.noop;
  10444. if (typeof success === 'function') {
  10445. if (false === success.call(element, data, ret)) {
  10446. return false;
  10447. }
  10448. }
  10449. table.bootstrapTable('refresh');
  10450. }, function (data, ret) {
  10451. var error = $(element).data("error") || $.noop;
  10452. if (typeof error === 'function') {
  10453. if (false === error.call(element, data, ret)) {
  10454. return false;
  10455. }
  10456. }
  10457. });
  10458. },
  10459. // 单元格元素事件
  10460. events: {
  10461. operate: {
  10462. 'click .btn-editone': function (e, value, row, index) {
  10463. e.stopPropagation();
  10464. e.preventDefault();
  10465. var table = $(this).closest('table');
  10466. var options = table.bootstrapTable('getOptions');
  10467. var ids = row[options.pk];
  10468. row = $.extend({}, row ? row : {}, {ids: ids});
  10469. var url = options.extend.edit_url;
  10470. Fast.api.open(Table.api.replaceurl(url, row, table), $(this).data("original-title") || $(this).attr("title") || __('Edit'), $(this).data() || {});
  10471. },
  10472. 'click .btn-delone': function (e, value, row, index) {
  10473. e.stopPropagation();
  10474. e.preventDefault();
  10475. var that = this;
  10476. var top = $(that).offset().top - $(window).scrollTop();
  10477. var left = $(that).offset().left - $(window).scrollLeft() - 260;
  10478. if (top + 154 > $(window).height()) {
  10479. top = top - 154;
  10480. }
  10481. if ($(window).width() < 480) {
  10482. top = left = undefined;
  10483. }
  10484. Layer.confirm(
  10485. __('Are you sure you want to delete this item?'),
  10486. {icon: 3, title: __('Warning'), offset: [top, left], shadeClose: true, btn: [__('OK'), __('Cancel')]},
  10487. function (index) {
  10488. var table = $(that).closest('table');
  10489. var options = table.bootstrapTable('getOptions');
  10490. Table.api.multi("del", row[options.pk], table, that);
  10491. Layer.close(index);
  10492. }
  10493. );
  10494. }
  10495. },//单元格图片预览
  10496. image: {
  10497. 'click .img-center': function (e, value, row, index) {
  10498. var data = [];
  10499. value = value === null ? '' : value.toString();
  10500. var arr = value != '' ? value.split(",") : [];
  10501. var url;
  10502. $.each(arr, function (index, value) {
  10503. url = Fast.api.cdnurl(value);
  10504. data.push({
  10505. src: url,
  10506. thumb: url.match(/^(\/|data:image\\)/) ? url : url + Config.upload.thumbstyle
  10507. });
  10508. });
  10509. Layer.photos({
  10510. photos: {
  10511. "start": $(this).parent().index(),
  10512. "data": data
  10513. },
  10514. anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)
  10515. });
  10516. },
  10517. }
  10518. },
  10519. // 单元格数据格式化
  10520. formatter: {
  10521. icon: function (value, row, index) {
  10522. value = value === null ? '' : value.toString();
  10523. value = value.indexOf(" ") > -1 ? value : "fa fa-" + value;
  10524. //渲染fontawesome图标
  10525. return '<i class="' + value + '"></i> ' + value;
  10526. },
  10527. image: function (value, row, index) {
  10528. return Table.api.formatter.images.call(this, value, row, index);
  10529. },
  10530. images: function (value, row, index) {
  10531. value = value == null || value.length === 0 ? '' : value.toString();
  10532. var classname = typeof this.classname !== 'undefined' ? this.classname : 'img-sm img-center';
  10533. var arr = value !== '' ? value.split(',') : [];
  10534. var html = [];
  10535. var url;
  10536. $.each(arr, function (i, value) {
  10537. value = value ? value : '/assets/img/blank.gif';
  10538. url = Fast.api.cdnurl(value, true);
  10539. url = url.match(/^(\/|data:image\\)/) ? url : url + Config.upload.thumbstyle;
  10540. html.push('<a href="javascript:"><img class="' + classname + '" src="' + url + '" width="30" height="30" /></a>');
  10541. });
  10542. return html.join(' ');
  10543. },
  10544. file: function (value, row, index) {
  10545. return Table.api.formatter.files.call(this, value, row, index);
  10546. },
  10547. files: function (value, row, index) {
  10548. value = value == null || value.length === 0 ? '' : value.toString();
  10549. var classname = typeof this.classname !== 'undefined' ? this.classname : 'img-sm img-center';
  10550. var arr = value !== '' ? value.split(',') : [];
  10551. var html = [];
  10552. var suffix, url;
  10553. $.each(arr, function (i, value) {
  10554. value = Fast.api.cdnurl(value, true);
  10555. suffix = /[\.]?([a-zA-Z0-9]+)$/.exec(value);
  10556. suffix = suffix ? suffix[1] : 'file';
  10557. url = Fast.api.fixurl("ajax/icon?suffix=" + suffix);
  10558. html.push('<a href="' + value + '" target="_blank"><img src="' + url + '" class="' + classname + '" width="30" height="30"></a>');
  10559. });
  10560. return html.join(' ');
  10561. },
  10562. content: function (value, row, index) {
  10563. var width = this.width != undefined ? (this.width.match(/^\d+$/) ? this.width + "px" : this.width) : "250px";
  10564. return "<div style='white-space: nowrap; text-overflow:ellipsis; overflow: hidden; max-width:" + width + ";'>" + value + "</div>";
  10565. },
  10566. status: function (value, row, index) {
  10567. var custom = {normal: 'success', hidden: 'gray', deleted: 'danger', locked: 'info'};
  10568. if (typeof this.custom !== 'undefined') {
  10569. custom = $.extend(custom, this.custom);
  10570. }
  10571. this.custom = custom;
  10572. this.icon = 'fa fa-circle';
  10573. return Table.api.formatter.normal.call(this, value, row, index);
  10574. },
  10575. normal: function (value, row, index) {
  10576. var colorArr = ["primary", "success", "danger", "warning", "info", "gray", "red", "yellow", "aqua", "blue", "navy", "teal", "olive", "lime", "fuchsia", "purple", "maroon"];
  10577. var custom = {};
  10578. if (typeof this.custom !== 'undefined') {
  10579. custom = $.extend(custom, this.custom);
  10580. }
  10581. value = value == null || value.length === 0 ? '' : value.toString();
  10582. var keys = typeof this.searchList === 'object' ? Object.keys(this.searchList) : [];
  10583. var index = keys.indexOf(value);
  10584. var color = value && typeof custom[value] !== 'undefined' ? custom[value] : null;
  10585. var display = index > -1 ? this.searchList[value] : null;
  10586. var icon = typeof this.icon !== 'undefined' ? this.icon : null;
  10587. if (!color) {
  10588. color = index > -1 && typeof colorArr[index] !== 'undefined' ? colorArr[index] : 'primary';
  10589. }
  10590. if (!display) {
  10591. display = __(value.charAt(0).toUpperCase() + value.slice(1));
  10592. }
  10593. var html = '<span class="text-' + color + '">' + (icon ? '<i class="' + icon + '"></i> ' : '') + display + '</span>';
  10594. if (this.operate != false) {
  10595. html = '<a href="javascript:;" class="searchit" data-toggle="tooltip" title="' + __('Click to search %s', display) + '" data-field="' + this.field + '" data-value="' + value + '">' + html + '</a>';
  10596. }
  10597. return html;
  10598. },
  10599. toggle: function (value, row, index) {
  10600. var table = this.table;
  10601. var options = table ? table.bootstrapTable('getOptions') : {};
  10602. var pk = options.pk || "id";
  10603. var color = typeof this.color !== 'undefined' ? this.color : 'success';
  10604. var yes = typeof this.yes !== 'undefined' ? this.yes : 1;
  10605. var no = typeof this.no !== 'undefined' ? this.no : 0;
  10606. var url = typeof this.url !== 'undefined' ? this.url : '';
  10607. var confirm = '';
  10608. var disable = false;
  10609. if (typeof this.confirm !== "undefined") {
  10610. confirm = typeof this.confirm === "function" ? this.confirm.call(this, value, row, index) : this.confirm;
  10611. }
  10612. if (typeof this.disable !== "undefined") {
  10613. disable = typeof this.disable === "function" ? this.disable.call(this, value, row, index) : this.disable;
  10614. }
  10615. return "<a href='javascript:;' data-toggle='tooltip' title='" + __('Click to toggle') + "' class='btn-change " + (disable ? 'btn disabled no-padding' : '') + "' data-index='" + index + "' data-id='"
  10616. + 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>";
  10617. },
  10618. url: function (value, row, index) {
  10619. value = value == null || value.length === 0 ? '' : value.toString();
  10620. 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>';
  10621. },
  10622. search: function (value, row, index) {
  10623. var field = this.field;
  10624. if (typeof this.customField !== 'undefined' && typeof row[this.customField] !== 'undefined') {
  10625. value = row[this.customField];
  10626. field = this.customField;
  10627. }
  10628. return '<a href="javascript:;" class="searchit" data-toggle="tooltip" title="' + __('Click to search %s', value) + '" data-field="' + field + '" data-value="' + value + '">' + value + '</a>';
  10629. },
  10630. addtabs: function (value, row, index) {
  10631. var url = Table.api.replaceurl(this.url || '', row, this.table);
  10632. var title = this.atitle ? this.atitle : __("Search %s", value);
  10633. return '<a href="' + Fast.api.fixurl(url) + '" class="addtabsit" data-value="' + value + '" title="' + title + '">' + value + '</a>';
  10634. },
  10635. dialog: function (value, row, index) {
  10636. var url = Table.api.replaceurl(this.url || '', row, this.table);
  10637. var title = this.atitle ? this.atitle : __("View %s", value);
  10638. return '<a href="' + Fast.api.fixurl(url) + '" class="dialogit" data-value="' + value + '" title="' + title + '">' + value + '</a>';
  10639. },
  10640. flag: function (value, row, index) {
  10641. var that = this;
  10642. value = value == null || value.length === 0 ? '' : value.toString();
  10643. var colorArr = {index: 'success', hot: 'warning', recommend: 'danger', 'new': 'info'};
  10644. //如果字段列有定义custom
  10645. if (typeof this.custom !== 'undefined') {
  10646. colorArr = $.extend(colorArr, this.custom);
  10647. }
  10648. var field = this.field;
  10649. if (typeof this.customField !== 'undefined' && typeof row[this.customField] !== 'undefined') {
  10650. value = row[this.customField];
  10651. field = this.customField;
  10652. }
  10653. if (typeof that.searchList === 'object' && typeof that.custom === 'undefined') {
  10654. var i = 0;
  10655. var searchValues = Object.keys(colorArr).map(function (e) {
  10656. return colorArr[e];
  10657. });
  10658. $.each(that.searchList, function (key, val) {
  10659. if (typeof colorArr[key] == 'undefined') {
  10660. colorArr[key] = searchValues[i];
  10661. i = typeof searchValues[i + 1] === 'undefined' ? 0 : i + 1;
  10662. }
  10663. });
  10664. }
  10665. //渲染Flag
  10666. var html = [];
  10667. var arr = value !== '' ? value.split(',') : [];
  10668. var color, display, label;
  10669. $.each(arr, function (i, value) {
  10670. value = value == null || value.length === 0 ? '' : value.toString();
  10671. if (value === '')
  10672. return true;
  10673. color = value && typeof colorArr[value] !== 'undefined' ? colorArr[value] : 'primary';
  10674. display = typeof that.searchList !== 'undefined' && typeof that.searchList[value] !== 'undefined' ? that.searchList[value] : __(value.charAt(0).toUpperCase() + value.slice(1));
  10675. label = '<span class="label label-' + color + '">' + display + '</span>';
  10676. if (that.operate) {
  10677. html.push('<a href="javascript:;" class="searchit" data-toggle="tooltip" title="' + __('Click to search %s', display) + '" data-field="' + field + '" data-value="' + value + '">' + label + '</a>');
  10678. } else {
  10679. html.push(label);
  10680. }
  10681. });
  10682. return html.join(' ');
  10683. },
  10684. label: function (value, row, index) {
  10685. return Table.api.formatter.flag.call(this, value, row, index);
  10686. },
  10687. datetime: function (value, row, index) {
  10688. var datetimeFormat = typeof this.datetimeFormat === 'undefined' ? 'YYYY-MM-DD HH:mm:ss' : this.datetimeFormat;
  10689. if (isNaN(value)) {
  10690. return value ? Moment(value).format(datetimeFormat) : __('None');
  10691. } else {
  10692. return value ? Moment(parseInt(value) * 1000).format(datetimeFormat) : __('None');
  10693. }
  10694. },
  10695. operate: function (value, row, index) {
  10696. var table = this.table;
  10697. // 操作配置
  10698. var options = table ? table.bootstrapTable('getOptions') : {};
  10699. // 默认按钮组
  10700. var buttons = $.extend([], this.buttons || []);
  10701. // 所有按钮名称
  10702. var names = [];
  10703. buttons.forEach(function (item) {
  10704. names.push(item.name);
  10705. });
  10706. if (options.extend.dragsort_url !== '' && names.indexOf('dragsort') === -1) {
  10707. buttons.push(Table.button.dragsort);
  10708. }
  10709. if (options.extend.edit_url !== '' && names.indexOf('edit') === -1) {
  10710. Table.button.edit.url = options.extend.edit_url;
  10711. buttons.push(Table.button.edit);
  10712. }
  10713. if (options.extend.del_url !== '' && names.indexOf('del') === -1) {
  10714. buttons.push(Table.button.del);
  10715. }
  10716. return Table.api.buttonlink(this, buttons, value, row, index, 'operate');
  10717. }
  10718. ,
  10719. buttons: function (value, row, index) {
  10720. // 默认按钮组
  10721. var buttons = $.extend([], this.buttons || []);
  10722. return Table.api.buttonlink(this, buttons, value, row, index, 'buttons');
  10723. }
  10724. },
  10725. buttonlink: function (column, buttons, value, row, index, type) {
  10726. var table = column.table;
  10727. column.clickToSelect = false;
  10728. type = typeof type === 'undefined' ? 'buttons' : type;
  10729. var options = table ? table.bootstrapTable('getOptions') : {};
  10730. var html = [];
  10731. var hidden, visible, disable, url, classname, icon, text, title, refresh, confirm, extend,
  10732. dropdown, link;
  10733. var fieldIndex = column.fieldIndex;
  10734. var dropdowns = {};
  10735. $.each(buttons, function (i, j) {
  10736. if (type === 'operate') {
  10737. if (j.name === 'dragsort' && typeof row[Table.config.dragsortfield] === 'undefined') {
  10738. return true;
  10739. }
  10740. if (['add', 'edit', 'del', 'multi', 'dragsort'].indexOf(j.name) > -1 && !options.extend[j.name + "_url"]) {
  10741. return true;
  10742. }
  10743. }
  10744. var attr = table.data(type + "-" + j.name);
  10745. if (typeof attr === 'undefined' || attr) {
  10746. hidden = typeof j.hidden === 'function' ? j.hidden.call(table, row, j) : (typeof j.hidden !== 'undefined' ? j.hidden : false);
  10747. if (hidden) {
  10748. return true;
  10749. }
  10750. visible = typeof j.visible === 'function' ? j.visible.call(table, row, j) : (typeof j.visible !== 'undefined' ? j.visible : true);
  10751. if (!visible) {
  10752. return true;
  10753. }
  10754. dropdown = j.dropdown ? j.dropdown : '';
  10755. url = j.url ? j.url : '';
  10756. url = typeof url === 'function' ? url.call(table, row, j) : (url ? Fast.api.fixurl(Table.api.replaceurl(url, row, table)) : 'javascript:;');
  10757. classname = j.classname ? j.classname : (dropdown ? 'btn-' + name + 'one' : 'btn-primary btn-' + name + 'one');
  10758. icon = j.icon ? j.icon : '';
  10759. text = typeof j.text === 'function' ? j.text.call(table, row, j) : j.text ? j.text : '';
  10760. title = typeof j.title === 'function' ? j.title.call(table, row, j) : j.title ? j.title : text;
  10761. refresh = j.refresh ? 'data-refresh="' + j.refresh + '"' : '';
  10762. confirm = typeof j.confirm === 'function' ? j.confirm.call(table, row, j) : (typeof j.confirm !== 'undefined' ? j.confirm : false);
  10763. confirm = confirm ? 'data-confirm="' + confirm + '"' : '';
  10764. extend = j.extend ? j.extend : '';
  10765. disable = typeof j.disable === 'function' ? j.disable.call(table, row, j) : (typeof j.disable !== 'undefined' ? j.disable : false);
  10766. if (disable) {
  10767. classname = classname + ' disabled';
  10768. }
  10769. 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>';
  10770. if (dropdown) {
  10771. if (typeof dropdowns[dropdown] == 'undefined') {
  10772. dropdowns[dropdown] = [];
  10773. }
  10774. dropdowns[dropdown].push(link);
  10775. } else {
  10776. html.push(link);
  10777. }
  10778. }
  10779. });
  10780. if (!$.isEmptyObject(dropdowns)) {
  10781. var dropdownHtml = [];
  10782. $.each(dropdowns, function (i, j) {
  10783. 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>');
  10784. });
  10785. html.unshift(dropdownHtml);
  10786. }
  10787. return html.join(' ');
  10788. },
  10789. //替换URL中的数据
  10790. replaceurl: function (url, row, table) {
  10791. var options = table ? table.bootstrapTable('getOptions') : null;
  10792. var ids = options ? row[options.pk] : 0;
  10793. row.ids = ids ? ids : (typeof row.ids !== 'undefined' ? row.ids : 0);
  10794. url = url == null || url.length === 0 ? '' : url.toString();
  10795. //自动添加ids参数
  10796. url = !url.match(/\{ids\}/i) ? url + (url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + '{ids}' : url;
  10797. url = url.replace(/\{(.*?)\}/gi, function (matched) {
  10798. matched = matched.substring(1, matched.length - 1);
  10799. if (matched.indexOf(".") !== -1) {
  10800. var temp = row;
  10801. var arr = matched.split(/\./);
  10802. for (var i = 0; i < arr.length; i++) {
  10803. if (typeof temp[arr[i]] !== 'undefined') {
  10804. temp = temp[arr[i]];
  10805. }
  10806. }
  10807. return typeof temp === 'object' ? '' : temp;
  10808. }
  10809. return row[matched];
  10810. });
  10811. return url;
  10812. },
  10813. // 获取选中的条目ID集合
  10814. selectedids: function (table, current) {
  10815. var options = table.bootstrapTable('getOptions');
  10816. //如果有设置翻页记忆模式
  10817. if (!current && options.maintainSelected) {
  10818. return options.selectedIds;
  10819. }
  10820. return $.map(table.bootstrapTable('getSelections'), function (row) {
  10821. return row[options.pk];
  10822. });
  10823. },
  10824. //获取选中的数据
  10825. selecteddata: function (table, current) {
  10826. var options = table.bootstrapTable('getOptions');
  10827. //如果有设置翻页记忆模式
  10828. if (!current && options.maintainSelected) {
  10829. return options.selectedData;
  10830. }
  10831. return table.bootstrapTable('getSelections');
  10832. },
  10833. // 切换复选框状态
  10834. toggleattr: function (table) {
  10835. $("input[type='checkbox']", table).trigger('click');
  10836. },
  10837. // 根据行索引获取行数据
  10838. getrowdata: function (table, index) {
  10839. index = parseInt(index);
  10840. var data = table.bootstrapTable('getData');
  10841. return typeof data[index] !== 'undefined' ? data[index] : null;
  10842. },
  10843. // 根据行索引获取行数据
  10844. getrowbyindex: function (table, index) {
  10845. return Table.api.getrowdata(table, index);
  10846. },
  10847. // 根据主键ID获取行数据
  10848. getrowbyid: function (table, id) {
  10849. var row = {};
  10850. var options = table.bootstrapTable("getOptions");
  10851. $.each(Table.api.selecteddata(table), function (i, j) {
  10852. if (j[options.pk] == id) {
  10853. row = j;
  10854. return false;
  10855. }
  10856. });
  10857. return row;
  10858. }
  10859. },
  10860. };
  10861. return Table;
  10862. });
  10863. // jQuery List DragSort v0.5.2
  10864. // Website: http://dragsort.codeplex.com/
  10865. // License: http://dragsort.codeplex.com/license
  10866. (function($) {
  10867. $.fn.dragsort = function(options) {
  10868. if (options == "destroy") {
  10869. $(this.selector).trigger("dragsort-uninit");
  10870. return;
  10871. }
  10872. var opts = $.extend({}, $.fn.dragsort.defaults, options);
  10873. var lists = [];
  10874. var list = null, lastPos = null;
  10875. this.each(function(i, cont) {
  10876. //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
  10877. if ($(cont).is("table") && $(cont).children().length == 1 && $(cont).children().is("tbody"))
  10878. cont = $(cont).children().get(0);
  10879. var newList = {
  10880. draggedItem: null,
  10881. placeHolderItem: null,
  10882. pos: null,
  10883. offset: null,
  10884. offsetLimit: null,
  10885. scroll: null,
  10886. container: cont,
  10887. init: function() {
  10888. //set options to default values if not set
  10889. opts.tagName = opts.tagName == "" ? ($(this.container).children().length == 0 ? "li" : $(this.container).children().get(0).tagName.toLowerCase()) : opts.tagName;
  10890. if (opts.itemSelector == "")
  10891. opts.itemSelector = opts.tagName;
  10892. if (opts.dragSelector == "")
  10893. opts.dragSelector = opts.tagName;
  10894. if (opts.placeHolderTemplate == "")
  10895. opts.placeHolderTemplate = "<" + opts.tagName + ">&nbsp;</" + opts.tagName + ">";
  10896. //listidx allows reference back to correct list variable instance
  10897. $(this.container).attr("data-listidx", i).mousedown(this.grabItem).bind("dragsort-uninit", this.uninit);
  10898. this.styleDragHandlers(true);
  10899. },
  10900. uninit: function() {
  10901. var list = lists[$(this).attr("data-listidx")];
  10902. $(list.container).unbind("mousedown", list.grabItem).unbind("dragsort-uninit");
  10903. list.styleDragHandlers(false);
  10904. },
  10905. getItems: function() {
  10906. return $(this.container).children(opts.itemSelector);
  10907. },
  10908. styleDragHandlers: function(cursor) {
  10909. this.getItems().map(function() { return $(this).is(opts.dragSelector) ? this : $(this).find(opts.dragSelector).get(); }).css("cursor", cursor ? "pointer" : "");
  10910. },
  10911. grabItem: function(e) {
  10912. var list = lists[$(this).attr("data-listidx")];
  10913. var item = $(e.target).closest("[data-listidx] > " + opts.tagName).get(0);
  10914. var insideMoveableItem = list.getItems().filter(function() { return this == item; }).length > 0;
  10915. //if not left click or if clicked on excluded element (e.g. text box) or not a moveable list item return
  10916. if (e.which != 1 || $(e.target).is(opts.dragSelectorExclude) || $(e.target).closest(opts.dragSelectorExclude).length > 0 || !insideMoveableItem)
  10917. return;
  10918. //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,
  10919. //does also stop being able to click text boxes hence dragging on text boxes by default is disabled in dragSelectorExclude
  10920. //e.preventDefault();
  10921. //change cursor to move while dragging
  10922. var dragHandle = e.target;
  10923. while (!$(dragHandle).is(opts.dragSelector)) {
  10924. if (dragHandle == this) return;
  10925. dragHandle = dragHandle.parentNode;
  10926. }
  10927. $(dragHandle).attr("data-cursor", $(dragHandle).css("cursor"));
  10928. $(dragHandle).css("cursor", "move");
  10929. //on mousedown wait for movement of mouse before triggering dragsort script (dragStart) to allow clicking of hyperlinks to work
  10930. var listElem = this;
  10931. var trigger = function() {
  10932. list.dragStart.call(listElem, e);
  10933. $(list.container).unbind("mousemove", trigger);
  10934. };
  10935. $(list.container).mousemove(trigger).mouseup(function() { $(list.container).unbind("mousemove", trigger); $(dragHandle).css("cursor", $(dragHandle).attr("data-cursor")); });
  10936. },
  10937. dragStart: function(e) {
  10938. if (list != null && list.draggedItem != null)
  10939. list.dropItem();
  10940. list = lists[$(this).attr("data-listidx")];
  10941. list.draggedItem = $(e.target).closest("[data-listidx] > " + opts.tagName)
  10942. //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
  10943. list.draggedItem.attr("data-origpos", $(this).attr("data-listidx") + "-" + $(list.container).children().index(list.draggedItem));
  10944. //calculate mouse offset relative to draggedItem
  10945. var mt = parseInt(list.draggedItem.css("marginTop"));
  10946. var ml = parseInt(list.draggedItem.css("marginLeft"));
  10947. list.offset = list.draggedItem.offset();
  10948. list.offset.top = e.pageY - list.offset.top + (isNaN(mt) ? 0 : mt) - 1;
  10949. list.offset.left = e.pageX - list.offset.left + (isNaN(ml) ? 0 : ml) - 1;
  10950. //calculate box the dragged item can't be dragged outside of
  10951. if (!opts.dragBetween) {
  10952. 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();
  10953. list.offsetLimit = $(list.container).offset();
  10954. list.offsetLimit.right = list.offsetLimit.left + $(list.container).outerWidth() - list.draggedItem.outerWidth();
  10955. list.offsetLimit.bottom = list.offsetLimit.top + containerHeight - list.draggedItem.outerHeight();
  10956. }
  10957. //create placeholder item
  10958. var h = list.draggedItem.height();
  10959. var w = list.draggedItem.width();
  10960. if (opts.tagName == "tr") {
  10961. list.draggedItem.children().each(function() { $(this).width($(this).width()); });
  10962. list.placeHolderItem = list.draggedItem.clone().attr("data-placeholder", true);
  10963. list.draggedItem.after(list.placeHolderItem);
  10964. //list.placeHolderItem.children().each(function() { $(this).css({ borderWidth:0, width: $(this).width() + 1, height: $(this).height() + 1 }).html("&nbsp;"); });
  10965. list.placeHolderItem.children().each(function() { $(this).html("&nbsp;"); });
  10966. } else {
  10967. list.draggedItem.after(opts.placeHolderTemplate);
  10968. list.placeHolderItem = list.draggedItem.next().css({ height: h, width: w }).attr("data-placeholder", true);
  10969. }
  10970. if (opts.tagName == "td") {
  10971. var listTable = list.draggedItem.closest("table").get(0);
  10972. $("<table id='" + listTable.id + "' style='border-width: 0px;' class='dragSortItem " + listTable.className + "'><tr></tr></table>").appendTo("body").children().append(list.draggedItem);
  10973. }
  10974. //style draggedItem while dragging
  10975. var orig = list.draggedItem.attr("style");
  10976. list.draggedItem.attr("data-origstyle", orig ? orig : "");
  10977. list.draggedItem.css({ position: "absolute", opacity: 0.8, "z-index": 999, height: h, width: w });
  10978. //auto-scroll setup
  10979. list.scroll = { moveX: 0, moveY: 0, maxX: $(document).width() - $(window).width(), maxY: $(document).height() - $(window).height() };
  10980. list.scroll.scrollY = window.setInterval(function() {
  10981. if (opts.scrollContainer != window) {
  10982. $(opts.scrollContainer).scrollTop($(opts.scrollContainer).scrollTop() + list.scroll.moveY);
  10983. return;
  10984. }
  10985. var t = $(opts.scrollContainer).scrollTop();
  10986. if (list.scroll.moveY > 0 && t < list.scroll.maxY || list.scroll.moveY < 0 && t > 0) {
  10987. $(opts.scrollContainer).scrollTop(t + list.scroll.moveY);
  10988. list.draggedItem.css("top", list.draggedItem.offset().top + list.scroll.moveY + 1);
  10989. }
  10990. }, 10);
  10991. list.scroll.scrollX = window.setInterval(function() {
  10992. if (opts.scrollContainer != window) {
  10993. $(opts.scrollContainer).scrollLeft($(opts.scrollContainer).scrollLeft() + list.scroll.moveX);
  10994. return;
  10995. }
  10996. var l = $(opts.scrollContainer).scrollLeft();
  10997. if (list.scroll.moveX > 0 && l < list.scroll.maxX || list.scroll.moveX < 0 && l > 0) {
  10998. $(opts.scrollContainer).scrollLeft(l + list.scroll.moveX);
  10999. list.draggedItem.css("left", list.draggedItem.offset().left + list.scroll.moveX + 1);
  11000. }
  11001. }, 10);
  11002. //misc
  11003. $(lists).each(function(i, l) { l.createDropTargets(); l.buildPositionTable(); });
  11004. list.setPos(e.pageX, e.pageY);
  11005. $(document).bind("mousemove", list.swapItems);
  11006. $(document).bind("mouseup", list.dropItem);
  11007. if (opts.scrollContainer != window)
  11008. $(window).bind("wheel", list.wheel);
  11009. },
  11010. //set position of draggedItem
  11011. setPos: function(x, y) {
  11012. //remove mouse offset so mouse cursor remains in same place on draggedItem instead of top left corner
  11013. var top = y - this.offset.top;
  11014. var left = x - this.offset.left;
  11015. //limit top, left to within box draggedItem can't be dragged outside of
  11016. if (!opts.dragBetween) {
  11017. top = Math.min(this.offsetLimit.bottom, Math.max(top, this.offsetLimit.top));
  11018. left = Math.min(this.offsetLimit.right, Math.max(left, this.offsetLimit.left));
  11019. }
  11020. //adjust top & left calculations to parent offset
  11021. var parent = this.draggedItem.offsetParent().not("body").offset(); //offsetParent returns body even when it's static, if not static offset is only factoring margin
  11022. if (parent != null) {
  11023. top -= parent.top;
  11024. left -= parent.left;
  11025. }
  11026. //set x or y auto-scroll amount
  11027. if (opts.scrollContainer == window) {
  11028. y -= $(window).scrollTop();
  11029. x -= $(window).scrollLeft();
  11030. y = Math.max(0, y - $(window).height() + 5) + Math.min(0, y - 5);
  11031. x = Math.max(0, x - $(window).width() + 5) + Math.min(0, x - 5);
  11032. } else {
  11033. var cont = $(opts.scrollContainer);
  11034. var offset = cont.offset();
  11035. y = Math.max(0, y - cont.height() - offset.top) + Math.min(0, y - offset.top);
  11036. x = Math.max(0, x - cont.width() - offset.left) + Math.min(0, x - offset.left);
  11037. }
  11038. list.scroll.moveX = x == 0 ? 0 : x * opts.scrollSpeed / Math.abs(x);
  11039. list.scroll.moveY = y == 0 ? 0 : y * opts.scrollSpeed / Math.abs(y);
  11040. //move draggedItem to new mouse cursor location
  11041. this.draggedItem.css({ top: top, left: left });
  11042. },
  11043. //if scroll container is a div allow mouse wheel to scroll div instead of window when mouse is hovering over
  11044. wheel: function(e) {
  11045. if (list && opts.scrollContainer != window) {
  11046. var cont = $(opts.scrollContainer);
  11047. var offset = cont.offset();
  11048. e = e.originalEvent;
  11049. if (e.clientX > offset.left && e.clientX < offset.left + cont.width() && e.clientY > offset.top && e.clientY < offset.top + cont.height()) {
  11050. var deltaY = (e.deltaMode == 0 ? 1 : 10) * e.deltaY;
  11051. cont.scrollTop(cont.scrollTop() + deltaY);
  11052. e.preventDefault();
  11053. }
  11054. }
  11055. },
  11056. //build a table recording all the positions of the moveable list items
  11057. buildPositionTable: function() {
  11058. var pos = [];
  11059. this.getItems().not([list.draggedItem[0], list.placeHolderItem[0]]).each(function(i) {
  11060. var loc = $(this).offset();
  11061. loc.right = loc.left + $(this).outerWidth();
  11062. loc.bottom = loc.top + $(this).outerHeight();
  11063. loc.elm = this;
  11064. pos[i] = loc;
  11065. });
  11066. this.pos = pos;
  11067. },
  11068. dropItem: function() {
  11069. if (list.draggedItem == null)
  11070. return;
  11071. //list.draggedItem.attr("style", "") doesn't work on IE8 and jQuery 1.5 or lower
  11072. //list.draggedItem.removeAttr("style") doesn't work on chrome and jQuery 1.6 (works jQuery 1.5 or lower)
  11073. var orig = list.draggedItem.attr("data-origstyle");
  11074. list.draggedItem.attr("style", orig);
  11075. if (orig == "")
  11076. list.draggedItem.removeAttr("style");
  11077. list.draggedItem.removeAttr("data-origstyle");
  11078. list.styleDragHandlers(true);
  11079. list.placeHolderItem.before(list.draggedItem);
  11080. list.placeHolderItem.remove();
  11081. $("[data-droptarget], .dragSortItem").remove();
  11082. window.clearInterval(list.scroll.scrollY);
  11083. window.clearInterval(list.scroll.scrollX);
  11084. //if position changed call dragEnd
  11085. if (list.draggedItem.attr("data-origpos") != $(lists).index(list) + "-" + $(list.container).children().index(list.draggedItem))
  11086. if (opts.dragEnd.apply(list.draggedItem) == false) { //if dragEnd returns false revert order
  11087. var pos = list.draggedItem.attr("data-origpos").split('-');
  11088. var nextItem = $(lists[pos[0]].container).children().not(list.draggedItem).eq(pos[1]);
  11089. if (nextItem.length > 0)
  11090. nextItem.before(list.draggedItem);
  11091. else if (pos[1] == 0) //was the only item in list
  11092. $(lists[pos[0]].container).prepend(list.draggedItem);
  11093. else //was the last item in list
  11094. $(lists[pos[0]].container).append(list.draggedItem);
  11095. }
  11096. list.draggedItem.removeAttr("data-origpos");
  11097. list.draggedItem = null;
  11098. $(document).unbind("mousemove", list.swapItems);
  11099. $(document).unbind("mouseup", list.dropItem);
  11100. if (opts.scrollContainer != window)
  11101. $(window).unbind("wheel", list.wheel);
  11102. return false;
  11103. },
  11104. //swap the draggedItem (represented visually by placeholder) with the list item the it has been dragged on top of
  11105. swapItems: function(e) {
  11106. if (list.draggedItem == null)
  11107. return false;
  11108. //move draggedItem to mouse location
  11109. list.setPos(e.pageX, e.pageY);
  11110. //retrieve list and item position mouse cursor is over
  11111. var ei = list.findPos(e.pageX, e.pageY);
  11112. var nlist = list;
  11113. for (var i = 0; ei == -1 && opts.dragBetween && i < lists.length; i++) {
  11114. ei = lists[i].findPos(e.pageX, e.pageY);
  11115. nlist = lists[i];
  11116. }
  11117. //if not over another moveable list item return
  11118. if (ei == -1)
  11119. return false;
  11120. //save fixed items locations
  11121. var children = function() { return $(nlist.container).children().not(nlist.draggedItem); };
  11122. var fixed = children().not(opts.itemSelector).each(function(i) { this.idx = children().index(this); });
  11123. //if moving draggedItem up or left place placeHolder before list item the dragged item is hovering over otherwise place it after
  11124. if (lastPos == null || lastPos.top > list.draggedItem.offset().top || lastPos.left > list.draggedItem.offset().left)
  11125. $(nlist.pos[ei].elm).before(list.placeHolderItem);
  11126. else
  11127. $(nlist.pos[ei].elm).after(list.placeHolderItem);
  11128. //restore fixed items location
  11129. fixed.each(function() {
  11130. var elm = children().eq(this.idx).get(0);
  11131. if (this != elm && children().index(this) < this.idx)
  11132. $(this).insertAfter(elm);
  11133. else if (this != elm)
  11134. $(this).insertBefore(elm);
  11135. });
  11136. //misc
  11137. $(lists).each(function(i, l) { l.createDropTargets(); l.buildPositionTable(); });
  11138. lastPos = list.draggedItem.offset();
  11139. return false;
  11140. },
  11141. //returns the index of the list item the mouse is over
  11142. findPos: function(x, y) {
  11143. for (var i = 0; i < this.pos.length; i++) {
  11144. if (this.pos[i].left < x && this.pos[i].right > x && this.pos[i].top < y && this.pos[i].bottom > y)
  11145. return i;
  11146. }
  11147. return -1;
  11148. },
  11149. //create drop targets which are placeholders at the end of other lists to allow dragging straight to the last position
  11150. createDropTargets: function() {
  11151. if (!opts.dragBetween)
  11152. return;
  11153. $(lists).each(function() {
  11154. var ph = $(this.container).find("[data-placeholder]");
  11155. var dt = $(this.container).find("[data-droptarget]");
  11156. if (ph.length > 0 && dt.length > 0)
  11157. dt.remove();
  11158. else if (ph.length == 0 && dt.length == 0) {
  11159. if (opts.tagName == "td")
  11160. $(opts.placeHolderTemplate).attr("data-droptarget", true).appendTo(this.container);
  11161. else
  11162. //list.placeHolderItem.clone().removeAttr("data-placeholder") crashes in IE7 and jquery 1.5.1 (doesn't in jquery 1.4.2 or IE8)
  11163. $(this.container).append(list.placeHolderItem.removeAttr("data-placeholder").clone().attr("data-droptarget", true));
  11164. list.placeHolderItem.attr("data-placeholder", true);
  11165. }
  11166. });
  11167. }
  11168. };
  11169. newList.init();
  11170. lists.push(newList);
  11171. });
  11172. return this;
  11173. };
  11174. $.fn.dragsort.defaults = {
  11175. tagName:"",
  11176. itemSelector: "",
  11177. dragSelector: "",
  11178. dragSelectorExclude: "input, textarea",
  11179. dragEnd: function() { },
  11180. dragBetween: false,
  11181. placeHolderTemplate: "",
  11182. scrollContainer: window,
  11183. scrollSpeed: 5
  11184. };
  11185. })(jQuery);
  11186. define("dragsort", function(){});
  11187. /*!
  11188. * jquery.event.drag - v 2.2
  11189. * Copyright (c) 2010 Three Dub Media - http://threedubmedia.com
  11190. * Open Source MIT License - http://threedubmedia.com/code/license
  11191. */
  11192. ;(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);
  11193. define("drag", function(){});
  11194. /*!
  11195. * jquery.event.drop - v 2.2
  11196. * Copyright (c) 2010 Three Dub Media - http://threedubmedia.com
  11197. * Open Source MIT License - http://threedubmedia.com/code/license
  11198. */
  11199. ;(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);
  11200. define("drop", function(){});
  11201. /**
  11202. * @summary SelectPage
  11203. * @desc Simple and powerful selection plugin
  11204. * @file selectpage.js
  11205. * @version 2.20
  11206. * @author TerryZeng
  11207. * @contact https://terryz.github.io/
  11208. * @license MIT License
  11209. *
  11210. */
  11211. ;(function ($) {
  11212. "use strict";
  11213. /**
  11214. * Default options
  11215. */
  11216. var defaults = {
  11217. /**
  11218. * Data source
  11219. * @type {string|Object}
  11220. *
  11221. * string:server side request url address
  11222. * Object:JSON array,format:[{a:1,b:2,c:3},{...}]
  11223. */
  11224. data: undefined,
  11225. /**
  11226. * Language ('cn', 'en')
  11227. * @type string
  11228. * @default 'cn'
  11229. */
  11230. lang: 'cn',
  11231. /**
  11232. * Multiple select mode(tags)
  11233. * @type boolean
  11234. * @default false
  11235. */
  11236. multiple: false,
  11237. /**
  11238. * pagination or not
  11239. * @type boolean
  11240. * @default true
  11241. */
  11242. pagination: true,
  11243. /**
  11244. * Show up menu button
  11245. * @type boolean
  11246. * @default true
  11247. */
  11248. dropButton: true,
  11249. /**
  11250. * Result list visible size in pagination bar close
  11251. * @type number
  11252. * @default 10
  11253. */
  11254. listSize: 10,
  11255. /**
  11256. * Show control bar in multiple select mode
  11257. * @type boolean
  11258. * @default true
  11259. */
  11260. multipleControlbar: true,
  11261. /**
  11262. * Max selected item limited in multiple select mode
  11263. * @type number
  11264. * @default 0(unlimited)
  11265. */
  11266. maxSelectLimit: 0,
  11267. /**
  11268. * Select result item to close list, work on multiple select mode
  11269. * @type boolean
  11270. * @default false
  11271. */
  11272. selectToCloseList: false,
  11273. /**
  11274. * Init selected item key, the result will match to option.keyField option
  11275. * @type string
  11276. */
  11277. initRecord: undefined,
  11278. /**
  11279. * The table parameter in server side mode
  11280. * @type string
  11281. */
  11282. dbTable: 'tbl',
  11283. /**
  11284. * The value field, the value will fill to hidden element
  11285. * @type string
  11286. * @default 'id'
  11287. */
  11288. keyField: 'id',
  11289. /**
  11290. * The show text field, the text will show to input element or tags(multiple mode)
  11291. * @type string
  11292. * @default 'name'
  11293. */
  11294. showField: 'name',
  11295. /**
  11296. * Actually used to search field
  11297. * @type string
  11298. */
  11299. searchField: undefined,
  11300. /**
  11301. * Search type ('AND' or 'OR')
  11302. * @type string
  11303. * @default 'AND'
  11304. */
  11305. andOr: 'OR',
  11306. /**
  11307. * Used to separate search content
  11308. * @see SelectPage.prototype.suggest()
  11309. */
  11310. separator: ',',
  11311. /**
  11312. * Result sort type
  11313. * @type array|boolean - if not set, will default used showField field
  11314. * @example
  11315. * orderBy : ['id desc']
  11316. */
  11317. orderBy: undefined,
  11318. /**
  11319. * Page size
  11320. * @type number
  11321. * @default 10
  11322. */
  11323. pageSize: 10,
  11324. /**
  11325. * Server side request parameters
  11326. * @type function
  11327. * @return object
  11328. * @example params : function(){return {'name':'aa','sex':1};}
  11329. */
  11330. params: undefined,
  11331. /**
  11332. * Custom result list item show text
  11333. * @type function
  11334. * @param data {object} row data
  11335. * @return string
  11336. */
  11337. formatItem: undefined,
  11338. /**
  11339. * Have some highlight item and lost focus, auto select the highlight item
  11340. * @type boolean
  11341. * @default false
  11342. */
  11343. autoFillResult: false,
  11344. /**
  11345. * Auto select first item in show up result list or search result
  11346. * depend on `autoFillResult` option set to true
  11347. * @type boolean
  11348. * @default false
  11349. */
  11350. autoSelectFirst: false,
  11351. /**
  11352. * Whether clear input element text when enter some keywords to search and no result return
  11353. * @type boolean
  11354. * @default true
  11355. */
  11356. noResultClean: true,
  11357. /**
  11358. * Select only mode
  11359. * @type boolean
  11360. */
  11361. selectOnly: false,
  11362. /**
  11363. * Input to search delay time, work on ajax data source
  11364. * @type number
  11365. * @default 0.5
  11366. */
  11367. inputDelay: 0.5,
  11368. /**
  11369. * -----------------------------------------Callback--------------------------------------------
  11370. */
  11371. /**
  11372. * Result list item selected callback
  11373. * @type function
  11374. * @param object - selected item json data
  11375. * @param self - plugin object
  11376. */
  11377. eSelect: undefined,
  11378. /**
  11379. * Before result list show up callback, you can do anything prepared
  11380. * @param self - plugin object
  11381. */
  11382. eOpen: undefined,
  11383. /**
  11384. * Server side return data convert callback
  11385. * @type function
  11386. * @param data {object} server side return data
  11387. * @param self {object} plugin object
  11388. * @return {object} return data format:
  11389. * @example
  11390. * {
  11391. * list : [{name:'aa',sex:1},{name:'bb',sex:1}...],
  11392. * totalRow : 100
  11393. * }
  11394. */
  11395. eAjaxSuccess: undefined,
  11396. /**
  11397. * Close selected item tag callback (multiple mode)
  11398. * @type function
  11399. * @param removeCount {number} remove item count
  11400. * @param self {object} plugin object
  11401. */
  11402. eTagRemove: undefined,
  11403. /**
  11404. * Clear selected item callback(single select mode)
  11405. * @type function
  11406. * @param self {object} plugin object
  11407. */
  11408. eClear: undefined
  11409. };
  11410. /**
  11411. * SelectPage class definition
  11412. * @constructor
  11413. * @param {Object} input - input element
  11414. * @param {Object} option
  11415. */
  11416. var SelectPage = function (input, option) {
  11417. //特殊字段处理
  11418. $.each({data: 'source', keyField: 'primaryKey', showField: 'field', pageSize: 'perPage'}, function (i, j) {
  11419. if (typeof option[j] !== 'undefined') {
  11420. option[i] = option[j];
  11421. delete option[j];
  11422. }
  11423. });
  11424. this.setOption(option);
  11425. this.setLanguage();
  11426. this.setCssClass();
  11427. this.setProp();
  11428. this.setElem(input);
  11429. this.setButtonAttrDefault();
  11430. this.setInitRecord();
  11431. this.eDropdownButton();
  11432. this.eInput();
  11433. this.eWhole();
  11434. };
  11435. /**
  11436. * Plugin version number
  11437. */
  11438. SelectPage.version = '2.19';
  11439. /**
  11440. * Plugin object cache key
  11441. */
  11442. SelectPage.dataKey = 'selectPageObject';
  11443. /**
  11444. * Options set
  11445. * @param {Object} option
  11446. */
  11447. SelectPage.prototype.setOption = function (option) {
  11448. //use showField to default
  11449. option.searchField = option.searchField || option.showField;
  11450. option.andOr = option.andOr.toUpperCase();
  11451. if (option.andOr !== 'AND' && option.andOr !== 'OR') option.andOr = 'AND';
  11452. //support multiple field set
  11453. var arr = ['searchField'];
  11454. for (var i = 0; i < arr.length; i++) {
  11455. option[arr[i]] = this.strToArray(option[arr[i]]);
  11456. }
  11457. //set default order field
  11458. option.orderBy = option.orderBy || option.showField;
  11459. //set multiple order field
  11460. //example: [ ['id', 'ASC'], ['name', 'DESC'] ]
  11461. if (option.orderBy !== false) option.orderBy = this.setOrderbyOption(option.orderBy, option.showField);
  11462. //close auto fill result and auto select first in multiple mode and select item not close list
  11463. if (option.multiple && !option.selectToCloseList) {
  11464. option.autoFillResult = false;
  11465. option.autoSelectFirst = false;
  11466. }
  11467. //show all item when pagination bar close, limited 200
  11468. if (!option.pagination) option.pageSize = 200;
  11469. if ($.type(option.listSize) !== 'number' || option.listSize < 0) option.listSize = 10;
  11470. if (typeof option.formatItem === 'string') {
  11471. var _formatItem = option.formatItem;
  11472. option.formatItem = function (row) {
  11473. if (typeof Template === 'function' && _formatItem.match(/\#([a-zA-Z0-9_\-]+)$/)) {
  11474. return Template(_formatItem.substring(1), row);
  11475. } else {
  11476. return _formatItem.replace(/\{(.*?)\}/gi, function (matched) {
  11477. matched = matched.substring(1, matched.length - 1);
  11478. return typeof row[matched] !== 'undefined' ? row[matched] : '';
  11479. });
  11480. }
  11481. };
  11482. }
  11483. this.option = option;
  11484. };
  11485. /**
  11486. * String convert to array
  11487. * @param str {string}
  11488. * @return {Array}
  11489. */
  11490. SelectPage.prototype.strToArray = function (str) {
  11491. return str ? str.replace(/[\s ]+/g, '').split(',') : '';
  11492. };
  11493. /**
  11494. * Set order field
  11495. * @param {Array} arg_order
  11496. * @param {string} arg_field - default sort field
  11497. * @return {Array}
  11498. */
  11499. SelectPage.prototype.setOrderbyOption = function (arg_order, arg_field) {
  11500. var arr = [], orders = [];
  11501. if (typeof arg_order === 'object') {
  11502. for (var i = 0; i < arg_order.length; i++) {
  11503. orders = $.trim(arg_order[i]).split(' ');
  11504. if (orders.length)
  11505. arr.push((orders.length === 2) ? orders.concat() : [orders[0], 'ASC']);
  11506. }
  11507. } else {
  11508. orders = $.trim(arg_order).split(' ');
  11509. arr[0] = (orders.length === 2) ? orders.concat() : (orders[0].toUpperCase().match(/^(ASC|DESC)$/i)) ? [arg_field, orders[0].toUpperCase()] : [orders[0], 'ASC'];
  11510. }
  11511. return arr;
  11512. };
  11513. /**
  11514. * i18n
  11515. */
  11516. SelectPage.prototype.setLanguage = function () {
  11517. var message, p = this.option;
  11518. switch (p.lang) {
  11519. // English
  11520. case 'en':
  11521. message = {
  11522. add_btn: 'Add button',
  11523. add_title: 'add a box',
  11524. del_btn: 'Del button',
  11525. del_title: 'delete a box',
  11526. next: 'Next',
  11527. next_title: 'Next' + p.pageSize + ' (Right key)',
  11528. prev: 'Prev',
  11529. prev_title: 'Prev' + p.pageSize + ' (Left key)',
  11530. first_title: 'First (Shift + Left key)',
  11531. last_title: 'Last (Shift + Right key)',
  11532. get_all_btn: 'Get All (Down key)',
  11533. get_all_alt: '(button)',
  11534. close_btn: 'Close (Tab key)',
  11535. close_alt: '(button)',
  11536. loading: 'loading...',
  11537. loading_alt: '(loading)',
  11538. page_info: 'page_num of page_count',
  11539. select_ng: 'Attention : Please choose from among the list.',
  11540. select_ok: 'OK : Correctly selected.',
  11541. not_found: 'not found',
  11542. ajax_error: 'An error occurred while loading data.',
  11543. clear: 'Clear content',
  11544. select_all: 'Select current page',
  11545. unselect_all: 'Clear current page',
  11546. clear_all: 'Clear all selected',
  11547. max_selected: 'You can only select up to max_selected_limit items'
  11548. };
  11549. break;
  11550. // 中文
  11551. case 'cn':
  11552. default:
  11553. message = {
  11554. add_btn: '添加按钮',
  11555. add_title: '添加区域',
  11556. del_btn: '删除按钮',
  11557. del_title: '删除区域',
  11558. next: '下一页',
  11559. next_title: '下' + p.pageSize + ' (→)',
  11560. prev: '上一页',
  11561. prev_title: '上' + p.pageSize + ' (←)',
  11562. first_title: '首页 (Shift + ←)',
  11563. last_title: '尾页 (Shift + →)',
  11564. get_all_btn: '获得全部 (↓)',
  11565. get_all_alt: '(按钮)',
  11566. close_btn: '关闭 (Tab键)',
  11567. close_alt: '(按钮)',
  11568. loading: '读取中...',
  11569. loading_alt: '(读取中)',
  11570. page_info: '第 page_num 页(共page_count页)',
  11571. select_ng: '请注意:请从列表中选择.',
  11572. select_ok: 'OK : 已经选择.',
  11573. not_found: '无查询结果',
  11574. ajax_error: '加载数据时发生了错误!',
  11575. clear: '清除内容',
  11576. select_all: '选择当前页项目',
  11577. unselect_all: '取消选择当前页项目',
  11578. clear_all: '清除全部已选择项目',
  11579. max_selected: '最多只能选择 max_selected_limit 个项目'
  11580. };
  11581. break;
  11582. }
  11583. this.message = message;
  11584. };
  11585. /**
  11586. * Css classname defined
  11587. */
  11588. SelectPage.prototype.setCssClass = function () {
  11589. var css_class = {
  11590. container: 'sp_container',
  11591. container_open: 'sp_container_open',
  11592. re_area: 'sp_result_area',
  11593. result_open: 'sp_result_area_open',
  11594. control_box: 'sp_control_box',
  11595. //multiple select mode
  11596. element_box: 'sp_element_box',
  11597. navi: 'sp_navi',
  11598. //result list
  11599. results: 'sp_results',
  11600. re_off: 'sp_results_off',
  11601. select: 'sp_over',
  11602. select_ok: 'sp_select_ok',
  11603. select_ng: 'sp_select_ng',
  11604. selected: 'sp_selected',
  11605. input_off: 'sp_input_off',
  11606. message_box: 'sp_message_box',
  11607. disabled: 'sp_disabled',
  11608. button: 'sp_button',
  11609. caret_open: 'sp_caret_open',
  11610. btn_on: 'sp_btn_on',
  11611. btn_out: 'sp_btn_out',
  11612. input: 'sp_input',
  11613. clear_btn: 'sp_clear_btn',
  11614. align_right: 'sp_align_right'
  11615. };
  11616. this.css_class = css_class;
  11617. };
  11618. /**
  11619. * Plugin inner properties
  11620. */
  11621. SelectPage.prototype.setProp = function () {
  11622. this.prop = {
  11623. //input disabled status
  11624. disabled: false,
  11625. current_page: 1,
  11626. //total page
  11627. max_page: 1,
  11628. //ajax data loading status
  11629. is_loading: false,
  11630. xhr: false,
  11631. key_paging: false,
  11632. key_select: false,
  11633. //last selected item value
  11634. prev_value: '',
  11635. //last selected item text
  11636. selected_text: '',
  11637. last_input_time: undefined,
  11638. init_set: false
  11639. };
  11640. this.template = {
  11641. tag: {
  11642. content: '<li class="selected_tag" itemvalue="#item_value#">#item_text#<span class="tag_close"><i class="spfont sp-close"></i></span></li>',
  11643. textKey: '#item_text#',
  11644. valueKey: '#item_value#'
  11645. },
  11646. page: {
  11647. current: 'page_num',
  11648. total: 'page_count'
  11649. },
  11650. msg: {
  11651. maxSelectLimit: 'max_selected_limit'
  11652. }
  11653. };
  11654. };
  11655. /**
  11656. * Get the actual width/height of invisible DOM elements with jQuery.
  11657. * Source code come from dreamerslab/jquery.actual
  11658. * @param element
  11659. * @param method
  11660. * @returns {*}
  11661. */
  11662. SelectPage.prototype.elementRealSize = function (element, method) {
  11663. var defaults = {
  11664. absolute: false,
  11665. clone: false,
  11666. includeMargin: false,
  11667. display: 'block'
  11668. };
  11669. var configs = defaults, $target = element.eq(0), fix, restore, tmp = [], style = '', $hidden;
  11670. fix = function () {
  11671. // get all hidden parents
  11672. $hidden = $target.parents().addBack().filter(':hidden');
  11673. style += 'visibility: hidden !important; display: ' + configs.display + ' !important; ';
  11674. if (configs.absolute === true) style += 'position: absolute !important;';
  11675. // save the origin style props
  11676. // set the hidden el css to be got the actual value later
  11677. $hidden.each(function () {
  11678. // Save original style. If no style was set, attr() returns undefined
  11679. var $this = $(this), thisStyle = $this.attr('style');
  11680. tmp.push(thisStyle);
  11681. // Retain as much of the original style as possible, if there is one
  11682. $this.attr('style', thisStyle ? thisStyle + ';' + style : style);
  11683. });
  11684. };
  11685. restore = function () {
  11686. // restore origin style values
  11687. $hidden.each(function (i) {
  11688. var $this = $(this), _tmp = tmp[i];
  11689. if (_tmp === undefined) $this.removeAttr('style');
  11690. else $this.attr('style', _tmp);
  11691. });
  11692. };
  11693. fix();
  11694. // get the actual value with user specific methed
  11695. // it can be 'width', 'height', 'outerWidth', 'innerWidth'... etc
  11696. // configs.includeMargin only works for 'outerWidth' and 'outerHeight'
  11697. var actual = /(outer)/.test(method) ?
  11698. $target[method](configs.includeMargin) :
  11699. $target[method]();
  11700. restore();
  11701. // IMPORTANT, this plugin only return the value of the first element
  11702. return actual;
  11703. };
  11704. /**
  11705. * Dom building
  11706. * @param {Object} combo_input - original input element
  11707. */
  11708. SelectPage.prototype.setElem = function (combo_input) {
  11709. // 1. build Dom object
  11710. var elem = {}, p = this.option, css = this.css_class, msg = this.message, input = $(combo_input);
  11711. var cssWidth = input.css("width");
  11712. var orgWidth = input.outerWidth();
  11713. if (cssWidth.indexOf("%") > -1 || input.parent().length > 0 && input.parent().width() == orgWidth) {
  11714. orgWidth = "100%";
  11715. } else {
  11716. // fix input width in hidden situation
  11717. if (orgWidth <= 0) orgWidth = this.elementRealSize(input, 'outerWidth');
  11718. if (orgWidth < 150) orgWidth = 150;
  11719. }
  11720. elem.combo_input = input.attr({'autocomplete': 'off'}).addClass(css.input).wrap('<div>');
  11721. if (p.selectOnly) elem.combo_input.prop('readonly', true);
  11722. elem.container = elem.combo_input.parent().addClass(css.container);
  11723. if (elem.combo_input.prop('disabled')) {
  11724. if (p.multiple) elem.container.addClass(css.disabled);
  11725. else elem.combo_input.addClass(css.input_off);
  11726. }
  11727. // set outer box width
  11728. elem.container.width(orgWidth);
  11729. elem.button = $('<div>').addClass(css.button);
  11730. //drop down button
  11731. elem.dropdown = $('<span class="sp_caret"></span>');
  11732. //clear button 'X' in single mode
  11733. elem.clear_btn = $('<div>').html($('<i>').addClass('spfont sp-close')).addClass(css.clear_btn).attr('title', msg.clear);
  11734. if (!p.dropButton) elem.clear_btn.addClass(css.align_right);
  11735. //main box in multiple mode
  11736. elem.element_box = $('<ul>').addClass(css.element_box);
  11737. if (p.multiple && p.multipleControlbar)
  11738. elem.control = $('<div>').addClass(css.control_box);
  11739. //result list box
  11740. elem.result_area = $('<div>').addClass(css.re_area);
  11741. //pagination bar
  11742. if (p.pagination) elem.navi = $('<div>').addClass('sp_pagination').append('<ul>');
  11743. elem.results = $('<ul>').addClass(css.results);
  11744. var namePrefix = '_text',
  11745. input_id = elem.combo_input.attr('id') || elem.combo_input.attr('name'),
  11746. input_name = elem.combo_input.attr('name') || 'selectPage',
  11747. hidden_name = input_name,
  11748. hidden_id = input_id;
  11749. //switch the id and name attributes of input/hidden element
  11750. elem.hidden = elem.combo_input.clone().attr({
  11751. name: hidden_name,
  11752. id: hidden_id,
  11753. type: 'hidden',
  11754. class: 'sp_hidden'
  11755. }).val('');
  11756. elem.combo_input.attr({
  11757. name: typeof input.data('name') !== 'undefined' ? input.data('name') : input_name + namePrefix,
  11758. id: input_id + namePrefix
  11759. });
  11760. elem.hidden.attr("data-rule", elem.combo_input.data("rule") || '');
  11761. elem.combo_input.attr("novalidate", "novalidate");
  11762. // 2. DOM element put
  11763. elem.container.append(elem.hidden);
  11764. if (p.dropButton) {
  11765. elem.container.append(elem.button)
  11766. elem.button.append(elem.dropdown);
  11767. }
  11768. $(document.body).append(elem.result_area);
  11769. elem.result_area.append(elem.results);
  11770. if (p.pagination) elem.result_area.append(elem.navi);
  11771. //Multiple select mode
  11772. if (p.multiple) {
  11773. if (p.multipleControlbar) {
  11774. elem.control.append('<button type="button" class="btn btn-default sp_clear_all" ><i class="spfont sp-clear"></i></button>');
  11775. elem.control.append('<button type="button" class="btn btn-default sp_unselect_all" ><i class="spfont sp-unselect-all"></i></button>');
  11776. elem.control.append('<button type="button" class="btn btn-default sp_select_all" ><i class="spfont sp-select-all"></i></button>');
  11777. elem.control_text = $('<p>');
  11778. elem.control.append(elem.control_text);
  11779. elem.result_area.prepend(elem.control);
  11780. }
  11781. elem.container.addClass('sp_container_combo');
  11782. elem.combo_input.addClass('sp_combo_input').before(elem.element_box);
  11783. var li = $('<li>').addClass('input_box');
  11784. li.append(elem.combo_input);
  11785. elem.element_box.append(li);
  11786. if (elem.combo_input.attr('placeholder')) elem.combo_input.attr('placeholder_bak', elem.combo_input.attr('placeholder'));
  11787. }
  11788. this.elem = elem;
  11789. };
  11790. /**
  11791. * Drop down button set to default
  11792. */
  11793. SelectPage.prototype.setButtonAttrDefault = function () {
  11794. /*
  11795. if (this.option.selectOnly) {
  11796. if ($(this.elem.combo_input).val() !== '') {
  11797. if ($(this.elem.hidden).val() !== '') {
  11798. //选择条件
  11799. $(this.elem.combo_input).attr('title', this.message.select_ok).removeClass(this.css_class.select_ng).addClass(this.css_class.select_ok);
  11800. } else {
  11801. //输入方式
  11802. $(this.elem.combo_input).attr('title', this.message.select_ng).removeClass(this.css_class.select_ok).addClass(this.css_class.select_ng);
  11803. }
  11804. } else {
  11805. $(this.elem.hidden).val('');
  11806. $(this.elem.combo_input).removeAttr('title').removeClass(this.css_class.select_ng);
  11807. }
  11808. }
  11809. */
  11810. //this.elem.button.attr('title', this.message.get_all_btn);
  11811. if (this.option.dropButton)
  11812. this.elem.button.attr('title', this.message.close_btn);
  11813. };
  11814. /**
  11815. * Set item need selected after init
  11816. * set selected item ways:
  11817. * <input value="key">
  11818. * <input data-init="key">
  11819. */
  11820. SelectPage.prototype.setInitRecord = function (refresh) {
  11821. var self = this, p = self.option, el = self.elem, key = '';
  11822. if ($.type(el.combo_input.data('init')) != 'undefined')
  11823. p.initRecord = String(el.combo_input.data('init'));
  11824. //data-init and value attribute can be init plugin selected item
  11825. //but, if set data-init and value attribute in the same time, plugin will choose data-init attribute first
  11826. if (!refresh && !p.initRecord && el.combo_input.val())
  11827. p.initRecord = el.combo_input.val();
  11828. el.combo_input.val('');
  11829. if (!refresh) el.hidden.val(p.initRecord);
  11830. key = refresh && el.hidden.val() ? el.hidden.val() : p.initRecord;
  11831. if (key) {
  11832. if (typeof p.data === 'object') {
  11833. var data = new Array();
  11834. var keyarr = key.split(',');
  11835. $.each(keyarr, function (index, row) {
  11836. for (var i = 0; i < p.data.length; i++) {
  11837. if (p.data[i][p.keyField] == row) {
  11838. data.push(p.data[i]);
  11839. break;
  11840. }
  11841. }
  11842. });
  11843. if (!p.multiple && data.length > 1) data = [data[0]];
  11844. self.afterInit(self, data);
  11845. } else {//ajax data source mode to init selected item
  11846. var _paramsFunc = p.params, _params = {}, searchKey = p.searchField;
  11847. var _orgParams = {
  11848. searchTable: p.dbTable,
  11849. searchKey: p.keyField,
  11850. searchValue: key,
  11851. orderBy: p.orderBy,
  11852. showField: p.showField,
  11853. keyField: p.keyField,
  11854. keyValue: key,
  11855. searchField: p.searchField
  11856. };
  11857. if (_paramsFunc) {
  11858. var result = $.isFunction(_paramsFunc) ? _paramsFunc(self) : _paramsFunc;
  11859. if (result && $.isPlainObject(result)) {
  11860. _params = $.extend({}, _orgParams, result);
  11861. } else {
  11862. _params = _orgParams;
  11863. }
  11864. } else {
  11865. _params = _orgParams;
  11866. }
  11867. $.ajax({
  11868. dataType: 'json',
  11869. type: 'POST',
  11870. url: p.data,
  11871. data: _params,
  11872. success: function (json) {
  11873. var d = null;
  11874. if (p.eAjaxSuccess && $.isFunction(p.eAjaxSuccess))
  11875. d = p.eAjaxSuccess(json);
  11876. self.afterInit(self, d.list);
  11877. },
  11878. error: function (jqXHR, textStatus, errorThrown) {
  11879. self.ajaxErrorNotify(self, errorThrown);
  11880. }
  11881. });
  11882. }
  11883. }
  11884. };
  11885. /**
  11886. * Selected item set to plugin
  11887. * @param {Object} self
  11888. * @param {Object} data - selected item data
  11889. */
  11890. SelectPage.prototype.afterInit = function (self, data) {
  11891. if (!data || ($.isArray(data) && data.length === 0)) return;
  11892. if (!$.isArray(data)) data = [data];
  11893. var p = self.option, css = self.css_class;
  11894. self.data = data;
  11895. if (p.multiple) {
  11896. self.prop.init_set = true;
  11897. self.clearAll(self);
  11898. $.each(data, function (i, row) {
  11899. var value = row[p.keyField];
  11900. var text = row[p.showField];
  11901. var item = {text: text, value: value};
  11902. if (!self.isAlreadySelected(self, item)) self.addNewTag(self, row, item);
  11903. });
  11904. self.tagValuesSet(self);
  11905. self.inputResize(self);
  11906. self.elem.hidden.blur();
  11907. self.prop.init_set = false;
  11908. } else {
  11909. var row = data[0];
  11910. var value = row[p.keyField];
  11911. var text = row[p.showField];
  11912. self.elem.combo_input.val(text);
  11913. self.elem.hidden.val(value);
  11914. self.prop.prev_value = text;
  11915. self.prop.selected_text = text;
  11916. if (p.selectOnly) {
  11917. self.elem.combo_input.attr('title', self.message.select_ok).removeClass(css.select_ng).addClass(css.select_ok);
  11918. }
  11919. self.putClearButton();
  11920. }
  11921. };
  11922. /**
  11923. * Drop down button event bind
  11924. */
  11925. SelectPage.prototype.eDropdownButton = function () {
  11926. var self = this;
  11927. if (self.option.dropButton) {
  11928. self.elem.button.mouseup(function (ev) {
  11929. ev.stopPropagation();
  11930. if (self.elem.result_area.is(':hidden') && !self.elem.combo_input.prop('disabled')) {
  11931. self.elem.combo_input.focus();
  11932. } else self.hideResults(self);
  11933. });
  11934. }
  11935. };
  11936. /**
  11937. * Events bind
  11938. */
  11939. SelectPage.prototype.eInput = function () {
  11940. var self = this, p = self.option, el = self.elem, msg = self.message;
  11941. var showList = function () {
  11942. self.prop.page_move = false;
  11943. self.suggest(self);
  11944. self.setCssFocusedInput(self);
  11945. };
  11946. el.combo_input.keyup(function (e) {
  11947. self.processKey(self, e);
  11948. }).keydown(function (e) {
  11949. self.processControl(self, e);
  11950. }).focus(function (e) {
  11951. //When focus on input, show the result list
  11952. if (el.result_area.is(':hidden')) {
  11953. e.stopPropagation();
  11954. self.prop.first_show = true;
  11955. showList();
  11956. }
  11957. });
  11958. el.container.on('click.SelectPage', 'div.' + self.css_class.clear_btn, function (e) {
  11959. e.stopPropagation();
  11960. if (!self.disabled(self)) {
  11961. self.clearAll(self, true);
  11962. self.elem.hidden.change();
  11963. if (p.eClear && $.isFunction(p.eClear)) p.eClear(self);
  11964. }
  11965. });
  11966. el.result_area.on('mousedown.SelectPage', function (e) {
  11967. e.stopPropagation();
  11968. });
  11969. if (p.multiple) {
  11970. if (p.multipleControlbar) {
  11971. //Select all item of current page
  11972. el.control.find('.sp_select_all').on('click.SelectPage', function (e) {
  11973. self.selectAllLine(self);
  11974. }).hover(function () {
  11975. el.control_text.html(msg.select_all);
  11976. }, function () {
  11977. el.control_text.html('');
  11978. });
  11979. //Cancel select all item of current page
  11980. el.control.find('.sp_unselect_all').on('click.SelectPage', function (e) {
  11981. self.unSelectAllLine(self);
  11982. }).hover(function () {
  11983. el.control_text.html(msg.unselect_all);
  11984. }, function () {
  11985. el.control_text.html('');
  11986. });
  11987. //Clear all selected item
  11988. el.control.find('.sp_clear_all').on('click.SelectPage', function (e) {
  11989. self.clearAll(self, true);
  11990. }).hover(function () {
  11991. el.control_text.html(msg.clear_all);
  11992. }, function () {
  11993. el.control_text.html('');
  11994. });
  11995. }
  11996. el.element_box.on('click.SelectPage', function (e) {
  11997. var srcEl = e.target || e.srcElement;
  11998. if ($(srcEl).is('ul')) el.combo_input.focus();
  11999. });
  12000. //Tag close
  12001. el.element_box.on('click.SelectPage', 'span.tag_close', function () {
  12002. var li = $(this).closest('li'), data = li.data('dataObj');
  12003. self.removeTag(self, li);
  12004. showList();
  12005. if (p.eTagRemove && $.isFunction(p.eTagRemove)) p.eTagRemove([data]);
  12006. });
  12007. self.inputResize(self);
  12008. }
  12009. };
  12010. /**
  12011. * Out of plugin area click event handler
  12012. */
  12013. SelectPage.prototype.eWhole = function () {
  12014. var self = this, css = self.css_class;
  12015. var cleanContent = function (obj) {
  12016. obj.elem.combo_input.val('');
  12017. if (!obj.option.multiple) obj.elem.hidden.val('');
  12018. obj.prop.selected_text = '';
  12019. };
  12020. //Out of plugin area
  12021. $(document.body).off('mousedown.selectPage').on('mousedown.selectPage', function (e) {
  12022. var ele = e.target || e.srcElement;
  12023. var sp = $(ele).closest('div.' + css.container);
  12024. //Open status result list
  12025. $('div.' + css.container + '.' + css.container_open).each(function () {
  12026. if (this == sp[0]) return;
  12027. var $this = $(this), d = $this.find('input.' + css.input).data(SelectPage.dataKey);
  12028. if (!d.elem.combo_input.val() && d.elem.hidden.val() && !d.option.multiple) {
  12029. d.prop.current_page = 1;//reset page to 1
  12030. cleanContent(d);
  12031. d.hideResults(d);
  12032. return true;
  12033. }
  12034. if (d.elem.results.find('li').not('.' + css.message_box).length) {
  12035. if (d.option.autoFillResult) {
  12036. //have selected item, then hide result list
  12037. if (d.elem.hidden.val()) d.hideResults(d);
  12038. else if (d.elem.results.find('li.sp_over').length) {
  12039. //no one selected and have highlight item, select the highlight item
  12040. d.selectCurrentLine(d, true);
  12041. } else if (d.option.autoSelectFirst) {
  12042. //no one selected, no one highlight, select the first item
  12043. d.nextLine(d);
  12044. d.selectCurrentLine(d, true);
  12045. } else d.hideResults(d);
  12046. } else d.hideResults(d);
  12047. } else {
  12048. //when no one item match, clear search keywords
  12049. if (d.option.noResultClean) cleanContent(d);
  12050. else {
  12051. if (!d.option.multiple) d.elem.hidden.val('');
  12052. }
  12053. d.hideResults(d);
  12054. }
  12055. });
  12056. });
  12057. };
  12058. /**
  12059. * Result list event bind
  12060. */
  12061. SelectPage.prototype.eResultList = function () {
  12062. var self = this, css = this.css_class;
  12063. self.elem.results.children('li').hover(function () {
  12064. if (self.prop.key_select) {
  12065. self.prop.key_select = false;
  12066. return;
  12067. }
  12068. if (!$(this).hasClass(css.selected) && !$(this).hasClass(css.message_box)) {
  12069. $(this).addClass(css.select);
  12070. self.setCssFocusedResults(self);
  12071. }
  12072. }, function () {
  12073. $(this).removeClass(css.select);
  12074. }).click(function (e) {
  12075. if (self.prop.key_select) {
  12076. self.prop.key_select = false;
  12077. return;
  12078. }
  12079. e.preventDefault();
  12080. e.stopPropagation();
  12081. if (!$(this).hasClass(css.selected)) self.selectCurrentLine(self, false);
  12082. });
  12083. };
  12084. /**
  12085. * Reposition result list when list beyond the visible area
  12086. */
  12087. SelectPage.prototype.eScroll = function () {
  12088. var self = this, css = this.css_class;
  12089. $(window).on('scroll.SelectPage', function (e) {
  12090. $('div.' + css.container + '.' + css.container_open).each(function () {
  12091. var $this = $(this), d = $this.find('input.' + css.input).data(SelectPage.dataKey),
  12092. offset = d.elem.result_area.offset(),
  12093. screenScrollTop = $(window).scrollTop(),
  12094. docHeight = $(document).height(),
  12095. viewHeight = $(window).height(),
  12096. listHeight = d.elem.result_area.outerHeight(),
  12097. listBottom = offset.top + listHeight,
  12098. hasOverflow = docHeight > viewHeight,
  12099. down = d.elem.result_area.hasClass('shadowDown');
  12100. if (hasOverflow) {
  12101. if (down) {//open down
  12102. if (listBottom > (viewHeight + screenScrollTop)) d.calcResultsSize(d);
  12103. } else {//open up
  12104. if (offset.top < screenScrollTop) d.calcResultsSize(d);
  12105. }
  12106. }
  12107. });
  12108. });
  12109. };
  12110. /**
  12111. * Page bar button event bind
  12112. */
  12113. SelectPage.prototype.ePaging = function () {
  12114. var self = this;
  12115. if (!self.option.pagination) return;
  12116. self.elem.navi.find('li.csFirstPage').off('click').on('click', function (ev) {
  12117. //$(self.elem.combo_input).focus();
  12118. ev.preventDefault();
  12119. self.firstPage(self);
  12120. });
  12121. self.elem.navi.find('li.csPreviousPage').off('click').on('click', function (ev) {
  12122. //$(self.elem.combo_input).focus();
  12123. ev.preventDefault();
  12124. self.prevPage(self);
  12125. });
  12126. self.elem.navi.find('li.csNextPage').off('click').on('click', function (ev) {
  12127. //$(self.elem.combo_input).focus();
  12128. ev.preventDefault();
  12129. self.nextPage(self);
  12130. });
  12131. self.elem.navi.find('li.csLastPage').off('click').on('click', function (ev) {
  12132. //$(self.elem.combo_input).focus();
  12133. ev.preventDefault();
  12134. self.lastPage(self);
  12135. });
  12136. };
  12137. /**
  12138. * Ajax request fail
  12139. * @param {Object} self
  12140. * @param {string} errorThrown
  12141. */
  12142. SelectPage.prototype.ajaxErrorNotify = function (self, errorThrown) {
  12143. self.showMessage(self, self.message.ajax_error);
  12144. };
  12145. /**
  12146. * Message box
  12147. * @param {Object} self
  12148. * @param msg {string} the text need to show
  12149. */
  12150. SelectPage.prototype.showMessage = function (self, msg) {
  12151. if (!msg) return;
  12152. var msgLi = '<li class="' + self.css_class.message_box + '"><i class="spfont sp-warning"></i> ' + msg + '</li>';
  12153. self.elem.results.empty().append(msgLi).show();
  12154. self.calcResultsSize(self);
  12155. self.setOpenStatus(self, true);
  12156. if (self.elem.control) self.elem.control.hide();
  12157. if (self.option.pagination) self.elem.navi.hide();
  12158. };
  12159. /**
  12160. * @desc Scroll
  12161. * @param {Object} self
  12162. * @param {boolean} enforce
  12163. */
  12164. SelectPage.prototype.scrollWindow = function (self, enforce) {
  12165. var current_result = self.getCurrentLine(self),
  12166. target_top = (current_result && !enforce) ? current_result.offset().top : self.elem.container.offset().top,
  12167. target_size;
  12168. self.prop.size_li = self.elem.results.children('li:first').outerHeight();
  12169. target_size = self.prop.size_li;
  12170. var gap, client_height = $(window).height(),
  12171. scroll_top = $(window).scrollTop(),
  12172. scroll_bottom = scroll_top + client_height - target_size;
  12173. if (current_result.length) {
  12174. if (target_top < scroll_top || target_size > client_height) {
  12175. //scroll to top
  12176. gap = target_top - scroll_top;
  12177. } else if (target_top > scroll_bottom) {
  12178. //scroll down
  12179. gap = target_top - scroll_bottom;
  12180. } else return; //do not scroll
  12181. } else if (target_top < scroll_top) gap = target_top - scroll_top;
  12182. window.scrollBy(0, gap);
  12183. };
  12184. /**
  12185. * change css class by status
  12186. * @param self
  12187. * @param status {boolean} true: open, false: close
  12188. */
  12189. SelectPage.prototype.setOpenStatus = function (self, status) {
  12190. var el = self.elem, css = self.css_class;
  12191. if (status) {
  12192. el.container.addClass(css.container_open);
  12193. el.result_area.addClass(css.result_open);
  12194. } else {
  12195. el.container.removeClass(css.container_open);
  12196. el.result_area.removeClass(css.result_open);
  12197. }
  12198. };
  12199. /**
  12200. * input element in focus css class set
  12201. * @param {Object} self
  12202. */
  12203. SelectPage.prototype.setCssFocusedInput = function (self) {
  12204. //$(self.elem.results).addClass(self.css_class.re_off);
  12205. //$(self.elem.combo_input).removeClass(self.css_class.input_off);
  12206. };
  12207. /**
  12208. * set result list get focus and input element lost focus
  12209. * @param {Object} self
  12210. */
  12211. SelectPage.prototype.setCssFocusedResults = function (self) {
  12212. //$(self.elem.results).removeClass(self.css_class.re_off);
  12213. //$(self.elem.combo_input).addClass(self.css_class.input_off);
  12214. };
  12215. /**
  12216. * Quick search input keywords listener
  12217. * @param {Object} self
  12218. */
  12219. SelectPage.prototype.checkValue = function (self) {
  12220. var now_value = self.elem.combo_input.val();
  12221. if (now_value != self.prop.prev_value) {
  12222. self.prop.prev_value = now_value;
  12223. self.prop.first_show = false;
  12224. if (self.option.selectOnly) self.setButtonAttrDefault();
  12225. if (!self.option.multiple && !now_value) {
  12226. self.elem.combo_input.val('');
  12227. self.elem.hidden.val('');
  12228. self.elem.clear_btn.remove();
  12229. }
  12230. self.suggest(self);
  12231. }
  12232. };
  12233. /**
  12234. * Input handle(regular input)
  12235. * @param {Object} self
  12236. * @param {Object} e - event object
  12237. */
  12238. SelectPage.prototype.processKey = function (self, e) {
  12239. if ($.inArray(e.keyCode, [37, 38, 39, 40, 27, 9, 13]) === -1) {
  12240. if (e.keyCode != 16) self.setCssFocusedInput(self); // except Shift(16)
  12241. self.inputResize(self);
  12242. if ($.type(self.option.data) === 'string') {
  12243. self.prop.last_input_time = e.timeStamp;
  12244. setTimeout(function () {
  12245. if ((e.timeStamp - self.prop.last_input_time) === 0)
  12246. self.checkValue(self);
  12247. }, self.option.inputDelay * 1000);
  12248. } else {
  12249. self.checkValue(self);
  12250. }
  12251. }
  12252. }
  12253. /**
  12254. * Input handle(control key)
  12255. * @param {Object} self
  12256. * @param {Object} e - event object
  12257. */
  12258. SelectPage.prototype.processControl = function (self, e) {
  12259. if (($.inArray(e.keyCode, [37, 38, 39, 40, 27, 9]) > -1 && self.elem.result_area.is(':visible')) ||
  12260. ($.inArray(e.keyCode, [13, 9]) > -1 && self.getCurrentLine(self))) {
  12261. e.preventDefault();
  12262. e.stopPropagation();
  12263. e.cancelBubble = true;
  12264. e.returnValue = false;
  12265. switch (e.keyCode) {
  12266. case 37:// left
  12267. if (e.shiftKey) self.firstPage(self);
  12268. else self.prevPage(self);
  12269. break;
  12270. case 38:// up
  12271. self.prop.key_select = true;
  12272. self.prevLine(self);
  12273. break;
  12274. case 39:// right
  12275. if (e.shiftKey) self.lastPage(self);
  12276. else self.nextPage(self);
  12277. break;
  12278. case 40:// down
  12279. if (self.elem.results.children('li').length) {
  12280. self.prop.key_select = true;
  12281. self.nextLine(self);
  12282. } else self.suggest(self);
  12283. break;
  12284. case 9:// tab
  12285. self.prop.key_paging = true;
  12286. self.selectCurrentLine(self, true);
  12287. //self.hideResults(self);
  12288. break;
  12289. case 13:// return
  12290. self.selectCurrentLine(self, true);
  12291. break;
  12292. case 27:// escape
  12293. self.prop.key_paging = true;
  12294. self.hideResults(self);
  12295. break;
  12296. }
  12297. }
  12298. };
  12299. /**
  12300. * Abort Ajax request
  12301. * @param {Object} self
  12302. */
  12303. SelectPage.prototype.abortAjax = function (self) {
  12304. if (self.prop.xhr) {
  12305. self.prop.xhr.abort();
  12306. self.prop.xhr = false;
  12307. }
  12308. };
  12309. /**
  12310. * Suggest result of search keywords
  12311. * @param {Object} self
  12312. */
  12313. SelectPage.prototype.suggest = function (self) {
  12314. var q_word, val = $.trim(self.elem.combo_input.val());
  12315. if (self.option.multiple) q_word = val;
  12316. else {
  12317. if (val && val === self.prop.selected_text) q_word = '';
  12318. else q_word = val;
  12319. }
  12320. q_word = q_word.split(self.option.separator);
  12321. //Before show up result list callback
  12322. if (self.option.eOpen && $.isFunction(self.option.eOpen))
  12323. self.option.eOpen.call(self);
  12324. self.abortAjax(self);
  12325. //self.setLoading(self);
  12326. var which_page_num = self.prop.current_page || 1;
  12327. if (typeof self.option.data == 'object') self.searchForJson(self, q_word, which_page_num);
  12328. else self.searchForDb(self, q_word, which_page_num);
  12329. };
  12330. /**
  12331. * Loading
  12332. * @param {Object} self
  12333. */
  12334. SelectPage.prototype.setLoading = function (self) {
  12335. if (self.elem.results.html() === '') {
  12336. //self.calcResultsSize(self);
  12337. self.setOpenStatus(self, true);
  12338. }
  12339. };
  12340. /**
  12341. * Search for ajax
  12342. * @param {Object} self
  12343. * @param {Array} q_word - query keyword
  12344. * @param {number} which_page_num - target page number
  12345. */
  12346. SelectPage.prototype.searchForDb = function (self, q_word, which_page_num) {
  12347. var p = self.option;
  12348. if (!p.eAjaxSuccess || !$.isFunction(p.eAjaxSuccess)) self.hideResults(self);
  12349. var _paramsFunc = p.params, _params = {}, searchKey = p.searchField;
  12350. //when have new query keyword, then reset page number to 1.
  12351. if (q_word.length && q_word[0] && q_word.join(self.option.separator) !== self.prop.prev_value) which_page_num = 1;
  12352. var _orgParams = {
  12353. q_word: q_word,
  12354. pageNumber: which_page_num,
  12355. pageSize: p.pageSize,
  12356. andOr: p.andOr,
  12357. orderBy: p.orderBy,
  12358. searchTable: p.dbTable,
  12359. showField: self.option.showField,
  12360. keyField: self.option.keyField,
  12361. searchField: self.option.searchField
  12362. };
  12363. if (p.orderBy !== false) _orgParams.orderBy = p.orderBy;
  12364. // 这个应该是历史遗留了,没仔细追逻辑,先留着。
  12365. _orgParams[searchKey] = q_word[0];
  12366. if (_paramsFunc) {
  12367. var result = $.isFunction(_paramsFunc) ? _paramsFunc(self) : _paramsFunc;
  12368. if (result && $.isPlainObject(result)) {
  12369. _params = $.extend({}, _orgParams, result);
  12370. } else {
  12371. _params = _orgParams;
  12372. }
  12373. } else {
  12374. _params = _orgParams;
  12375. }
  12376. self.prop.xhr = $.ajax({
  12377. dataType: 'json',
  12378. url: p.data,
  12379. type: 'POST',
  12380. data: _params,
  12381. success: function (returnData) {
  12382. if (!returnData || !$.isPlainObject(returnData)) {
  12383. self.hideResults(self);
  12384. self.ajaxErrorNotify(self, errorThrown);
  12385. return;
  12386. }
  12387. var data = {}, json = {};
  12388. try {
  12389. data = p.eAjaxSuccess(returnData);
  12390. json.originalResult = data.list;
  12391. json.cnt_whole = data.totalRow;
  12392. } catch (e) {
  12393. self.showMessage(self, self.message.ajax_error);
  12394. return;
  12395. }
  12396. if (self.elem.navi) {
  12397. $(self.elem.navi).toggleClass("hide", json.cnt_whole <= json.originalResult.length);
  12398. }
  12399. json.candidate = [];
  12400. json.keyField = [];
  12401. if (typeof json.originalResult != 'object') {
  12402. self.prop.xhr = null;
  12403. self.notFoundSearch(self);
  12404. return;
  12405. }
  12406. json.cnt_page = json.originalResult.length;
  12407. for (var i = 0; i < json.cnt_page; i++) {
  12408. for (var key in json.originalResult[i]) {
  12409. if (key == p.keyField) {
  12410. json.keyField.push(json.originalResult[i][key]);
  12411. }
  12412. if (key == p.showField) {
  12413. json.candidate.push(json.originalResult[i][key]);
  12414. }
  12415. }
  12416. }
  12417. self.prepareResults(self, json, q_word, which_page_num);
  12418. },
  12419. error: function (jqXHR, textStatus, errorThrown) {
  12420. if (textStatus != 'abort') {
  12421. self.hideResults(self);
  12422. self.ajaxErrorNotify(self, errorThrown);
  12423. }
  12424. },
  12425. complete: function () {
  12426. self.prop.xhr = null;
  12427. }
  12428. });
  12429. };
  12430. /**
  12431. * Search for json data source
  12432. * @param {Object} self
  12433. * @param {Array} q_word
  12434. * @param {number} which_page_num
  12435. */
  12436. SelectPage.prototype.searchForJson = function (self, q_word, which_page_num) {
  12437. var p = self.option, matched = [], esc_q = [], sorted = [], json = {}, i = 0, arr_reg = [];
  12438. //query keyword filter
  12439. do {
  12440. //'/\W/g'正则代表全部不是字母,数字,下划线,汉字的字符
  12441. //将非法字符进行转义
  12442. esc_q[i] = q_word[i].replace(/\W/g, '\\$&').toString();
  12443. arr_reg[i] = new RegExp(esc_q[i], 'gi');
  12444. i++;
  12445. } while (i < q_word.length);
  12446. // SELECT * FROM data WHERE field LIKE q_word;
  12447. for (var i = 0; i < p.data.length; i++) {
  12448. var flag = false, row = p.data[i], itemText;
  12449. for (var j = 0; j < arr_reg.length; j++) {
  12450. itemText = row[p.searchField];
  12451. if (p.formatItem && $.isFunction(p.formatItem))
  12452. itemText = p.formatItem(row);
  12453. if (itemText.match(arr_reg[j])) {
  12454. flag = true;
  12455. if (p.andOr == 'OR') break;
  12456. } else {
  12457. flag = false;
  12458. if (p.andOr == 'AND') break;
  12459. }
  12460. }
  12461. if (flag) matched.push(row);
  12462. }
  12463. // (CASE WHEN ...) then く order some column
  12464. if (p.orderBy === false) sorted = matched.concat();
  12465. else {
  12466. var reg1 = new RegExp('^' + esc_q[0] + '$', 'gi'),
  12467. reg2 = new RegExp('^' + esc_q[0], 'gi'),
  12468. matched1 = [], matched2 = [], matched3 = [];
  12469. for (var i = 0; i < matched.length; i++) {
  12470. var orderField = p.orderBy[0][0];
  12471. var orderValue = String(matched[i][orderField]);
  12472. if (orderValue.match(reg1)) {
  12473. matched1.push(matched[i]);
  12474. } else if (orderValue.match(reg2)) {
  12475. matched2.push(matched[i]);
  12476. } else {
  12477. matched3.push(matched[i]);
  12478. }
  12479. }
  12480. if (p.orderBy[0][1].match(/^asc$/i)) {
  12481. matched1 = self.sortAsc(self, matched1);
  12482. matched2 = self.sortAsc(self, matched2);
  12483. matched3 = self.sortAsc(self, matched3);
  12484. } else {
  12485. matched1 = self.sortDesc(self, matched1);
  12486. matched2 = self.sortDesc(self, matched2);
  12487. matched3 = self.sortDesc(self, matched3);
  12488. }
  12489. sorted = sorted.concat(matched1).concat(matched2).concat(matched3);
  12490. }
  12491. /*
  12492. if (sorted.length === undefined || sorted.length === 0 ) {
  12493. self.notFoundSearch(self);
  12494. return;
  12495. }
  12496. */
  12497. json.cnt_whole = sorted.length;
  12498. //page_move used to distinguish between init plugin or page moving
  12499. if (!self.prop.page_move) {
  12500. //only single mode can be used page number relocation
  12501. if (!p.multiple) {
  12502. //get selected item belong page number
  12503. var currentValue = self.elem.hidden.val();
  12504. if ($.type(currentValue) !== 'undefined' && $.trim(currentValue) !== '') {
  12505. var index = 0;
  12506. $.each(sorted, function (i, row) {
  12507. if (row[p.keyField] == currentValue) {
  12508. index = i + 1;
  12509. return false;
  12510. }
  12511. });
  12512. which_page_num = Math.ceil(index / p.pageSize);
  12513. if (which_page_num < 1) which_page_num = 1;
  12514. self.prop.current_page = which_page_num;
  12515. }
  12516. }
  12517. } else {
  12518. //set page number to 1 when result number less then page size
  12519. if (sorted.length <= ((which_page_num - 1) * p.pageSize)) {
  12520. which_page_num = 1;
  12521. self.prop.current_page = 1;
  12522. }
  12523. }
  12524. //LIMIT xx OFFSET xx
  12525. var start = (which_page_num - 1) * p.pageSize, end = start + p.pageSize;
  12526. //save original data
  12527. json.originalResult = [];
  12528. //after data filter handle
  12529. for (var i = start; i < end; i++) {
  12530. if (sorted[i] === undefined) break;
  12531. json.originalResult.push(sorted[i]);
  12532. for (var key in sorted[i]) {
  12533. if (key == p.keyField) {
  12534. if (json.keyField === undefined) json.keyField = [];
  12535. json.keyField.push(sorted[i][key]);
  12536. }
  12537. if (key == p.showField) {
  12538. if (json.candidate === undefined) json.candidate = [];
  12539. json.candidate.push(sorted[i][key]);
  12540. }
  12541. }
  12542. }
  12543. if (json.candidate === undefined) json.candidate = [];
  12544. json.cnt_page = json.candidate.length;
  12545. self.prepareResults(self, json, q_word, which_page_num);
  12546. };
  12547. /**
  12548. * Set order asc
  12549. * @param {Object} self
  12550. * @param {Array} arr - result array
  12551. */
  12552. SelectPage.prototype.sortAsc = function (self, arr) {
  12553. arr.sort(function (a, b) {
  12554. var valA = a[self.option.orderBy[0][0]], valB = b[self.option.orderBy[0][0]];
  12555. return $.type(valA) === 'number' ? valA - valB : String(valA).localeCompare(String(valB));
  12556. });
  12557. return arr;
  12558. };
  12559. /**
  12560. * Set order desc
  12561. * @param {Object} self
  12562. * @param {Array} arr - result array
  12563. */
  12564. SelectPage.prototype.sortDesc = function (self, arr) {
  12565. arr.sort(function (a, b) {
  12566. var valA = a[self.option.orderBy[0][0]], valB = b[self.option.orderBy[0][0]];
  12567. return $.type(valA) === 'number' ? valB - valA : String(valB).localeCompare(String(valA));
  12568. });
  12569. return arr;
  12570. };
  12571. /**
  12572. * Not result found handle
  12573. * @param {Object} self
  12574. */
  12575. SelectPage.prototype.notFoundSearch = function (self) {
  12576. self.elem.results.empty();
  12577. self.calcResultsSize(self);
  12578. self.setOpenStatus(self, true);
  12579. self.setCssFocusedInput(self);
  12580. };
  12581. /**
  12582. * Prepare data to show
  12583. * @param {Object} self
  12584. * @param {Object} json - data result
  12585. * @param {Array} q_word - query keyword
  12586. * @param {number} which_page_num - target page number
  12587. */
  12588. SelectPage.prototype.prepareResults = function (self, json, q_word, which_page_num) {
  12589. self.data = json.originalResult;
  12590. if (self.option.pagination) self.setNavi(self, json.cnt_whole, json.cnt_page, which_page_num);
  12591. if (!json.keyField) json.keyField = false;
  12592. if (self.option.selectOnly && json.candidate.length === 1 && json.candidate[0] == q_word[0]) {
  12593. self.elem.hidden.val(json.keyField[0]);
  12594. this.setButtonAttrDefault();
  12595. }
  12596. var is_query = false;
  12597. if (q_word && q_word.length && q_word[0]) is_query = true;
  12598. self.displayResults(self, json, is_query);
  12599. };
  12600. /**
  12601. * Build page bar
  12602. * @param {Object} self
  12603. * @param {number} cnt_whole - total record count
  12604. * @param {number} cnt_page
  12605. * @param {number} page_num - current page number
  12606. */
  12607. SelectPage.prototype.setNavi = function (self, cnt_whole, cnt_page, page_num) {
  12608. var msg = self.message;
  12609. /**
  12610. * build pagination bar
  12611. */
  12612. var buildPageNav = function (self, pagebar, page_num, last_page) {
  12613. var updatePageInfo = function () {
  12614. var pageInfo = msg.page_info;
  12615. return pageInfo.replace(self.template.page.current, page_num).replace(self.template.page.total, last_page);
  12616. };
  12617. if (pagebar.find('li').length === 0) {
  12618. pagebar.hide().empty();
  12619. var iconFist = 'spfont sp-first',
  12620. iconPrev = 'spfont sp-previous',
  12621. iconNext = 'spfont sp-next',
  12622. iconLast = 'spfont sp-last';
  12623. pagebar.append('<li class="csFirstPage" title="' + msg.first_title + '" ><a href="javascript:void(0);"> <i class="' + iconFist + '"></i> </a></li>');
  12624. pagebar.append('<li class="csPreviousPage" title="' + msg.prev_title + '" ><a href="javascript:void(0);"><i class="' + iconPrev + '"></i></a></li>');
  12625. //pagination information
  12626. pagebar.append('<li class="pageInfoBox"><a href="javascript:void(0);"> ' + updatePageInfo() + ' </a></li>');
  12627. pagebar.append('<li class="csNextPage" title="' + msg.next_title + '" ><a href="javascript:void(0);"><i class="' + iconNext + '"></i></a></li>');
  12628. pagebar.append('<li class="csLastPage" title="' + msg.last_title + '" ><a href="javascript:void(0);"> <i class="' + iconLast + '"></i> </a></li>');
  12629. pagebar.show();
  12630. } else {
  12631. pagebar.find('li.pageInfoBox a').html(updatePageInfo());
  12632. }
  12633. };
  12634. var pagebar = self.elem.navi.find('ul'),
  12635. last_page = Math.ceil(cnt_whole / self.option.pageSize); //calculate total page
  12636. if (last_page === 0) page_num = 0;
  12637. else {
  12638. if (last_page < page_num) page_num = last_page;
  12639. else if (page_num === 0) page_num = 1;
  12640. }
  12641. self.prop.current_page = page_num;//update current page number
  12642. self.prop.max_page = last_page;//update page count
  12643. buildPageNav(self, pagebar, page_num, last_page);
  12644. //update paging status
  12645. var dClass = 'disabled',
  12646. first = pagebar.find('li.csFirstPage'),
  12647. previous = pagebar.find('li.csPreviousPage'),
  12648. next = pagebar.find('li.csNextPage'),
  12649. last = pagebar.find('li.csLastPage');
  12650. //first and previous
  12651. if (page_num === 1 || page_num === 0) {
  12652. if (!first.hasClass(dClass)) first.addClass(dClass);
  12653. if (!previous.hasClass(dClass)) previous.addClass(dClass);
  12654. } else {
  12655. if (first.hasClass(dClass)) first.removeClass(dClass);
  12656. if (previous.hasClass(dClass)) previous.removeClass(dClass);
  12657. }
  12658. //next and last
  12659. if (page_num === last_page || last_page === 0) {
  12660. if (!next.hasClass(dClass)) next.addClass(dClass);
  12661. if (!last.hasClass(dClass)) last.addClass(dClass);
  12662. } else {
  12663. if (next.hasClass(dClass)) next.removeClass(dClass);
  12664. if (last.hasClass(dClass)) last.removeClass(dClass);
  12665. }
  12666. if (last_page > 1) self.ePaging(); //pagination event bind
  12667. };
  12668. /**
  12669. * Render result list
  12670. * @param {Object} self
  12671. * @param {Object} json - result data
  12672. * @param {boolean} is_query - used to different from search to open and just click to open
  12673. */
  12674. SelectPage.prototype.displayResults = function (self, json, is_query) {
  12675. var p = self.option, el = self.elem;
  12676. el.results.hide().empty();
  12677. if (p.multiple && $.type(p.maxSelectLimit) === 'number' && p.maxSelectLimit > 0) {
  12678. var selectedSize = el.element_box.find('li.selected_tag').length;
  12679. if (selectedSize > 0 && selectedSize >= p.maxSelectLimit) {
  12680. var msg = self.message.max_selected;
  12681. self.showMessage(self, msg.replace(self.template.msg.maxSelectLimit, p.maxSelectLimit));
  12682. return;
  12683. }
  12684. }
  12685. if (json.candidate.length) {
  12686. var arr_candidate = json.candidate,
  12687. arr_primary_key = json.keyField,
  12688. keystr = el.hidden.val(),
  12689. keyArr = keystr ? keystr.split(',') : new Array(),
  12690. itemText = '';
  12691. for (var i = 0; i < arr_candidate.length; i++) {
  12692. if (p.formatItem && $.isFunction(p.formatItem)) {
  12693. try {
  12694. itemText = p.formatItem(json.originalResult[i]);
  12695. } catch (e) {
  12696. console.error('formatItem内容格式化函数内容设置不正确!');
  12697. itemText = arr_candidate[i];
  12698. }
  12699. } else itemText = arr_candidate[i];
  12700. var list = $('<li>').html(itemText).attr({
  12701. pkey: arr_primary_key[i],
  12702. index: i
  12703. });
  12704. if (!p.formatItem) list.attr('title', itemText);
  12705. //Set selected item highlight
  12706. if ($.inArray(arr_primary_key[i].toString(), keyArr) !== -1) {
  12707. list.addClass(self.css_class.selected);
  12708. }
  12709. //cache item data
  12710. list.data('dataObj', json.originalResult[i]);
  12711. el.results.append(list);
  12712. }
  12713. } else {
  12714. var li = '<li class="' + self.css_class.message_box + '"><i class="spfont sp-warning"></i> ' +
  12715. self.message.not_found + '</li>';
  12716. el.results.append(li);
  12717. }
  12718. el.results.show();
  12719. if (p.multiple && p.multipleControlbar) el.control.show();
  12720. if (p.pagination) el.navi.show();
  12721. self.calcResultsSize(self);
  12722. self.setOpenStatus(self, true);
  12723. //Result item event bind
  12724. self.eResultList();
  12725. //scrolling listen
  12726. self.eScroll();
  12727. //auto highlight first item in search, have result and set autoSelectFirst to true situation
  12728. if (is_query && json.candidate.length && p.autoSelectFirst) self.nextLine(self);
  12729. };
  12730. /**
  12731. * Calculate result list size and position
  12732. * @param {Object} self
  12733. */
  12734. SelectPage.prototype.calcResultsSize = function (self) {
  12735. var p = self.option, el = self.elem;
  12736. var rePosition = function () {
  12737. if (el.container.css('position') === 'static') {
  12738. // position: static
  12739. var offset = el.combo_input.offset();
  12740. el.result_area.css({
  12741. top: offset.top + el.combo_input.outerHeight() + 'px',
  12742. left: offset.left + 'px'
  12743. });
  12744. } else {
  12745. if (!p.pagination) {
  12746. var itemHeight = el.results.find('li:first').outerHeight(true),
  12747. listHeight = itemHeight * p.listSize;
  12748. el.results.css({
  12749. 'max-height': listHeight,
  12750. 'overflow-y': 'auto'
  12751. });
  12752. }
  12753. //handle result list show up side(left, right, up or down)
  12754. var docWidth = $(document).width(),
  12755. docHeight = $(document).height(), //the document full height
  12756. viewHeight = $(window).height(), //browser visible area height
  12757. offset = el.container.offset(),
  12758. screenScrollTop = $(window).scrollTop(),
  12759. listWidth = el.result_area.outerWidth(),
  12760. //result list height
  12761. listHeight = el.result_area.outerHeight(),
  12762. //default left used input element left
  12763. defaultLeft = offset.left, //p.multiple ? -1 : 0;
  12764. //input element height
  12765. inputHeight = el.container.outerHeight(),
  12766. left = (offset.left + listWidth) > docWidth ?
  12767. defaultLeft - (listWidth - el.container.outerWidth()) :
  12768. defaultLeft,
  12769. //the actual top coordinate of input element(outer div)
  12770. screenTop = offset.top, //$(el.container).scrollTop();//offset.top - screenScrollTop;
  12771. top = 0, dist = 5, //set distance between input element and result list
  12772. //the actual top coordinate of result list
  12773. listBottom = screenTop + inputHeight + listHeight + dist,
  12774. listTop = screenTop + listHeight + dist,
  12775. hasOverflow = docHeight > viewHeight;
  12776. if ((screenTop - screenScrollTop - dist > listHeight) &&
  12777. (hasOverflow && listBottom > (viewHeight + screenScrollTop)) ||
  12778. (!hasOverflow && listBottom > viewHeight && screenTop >= listTop)) {
  12779. //open up
  12780. top = offset.top - listHeight - dist;
  12781. el.result_area.removeClass('shadowUp shadowDown').addClass('shadowUp');
  12782. } else {
  12783. //open down
  12784. top = offset.top + (p.multiple ? el.container.outerHeight() : inputHeight);
  12785. el.result_area.removeClass('shadowUp shadowDown').addClass('shadowDown');
  12786. top += dist;
  12787. }
  12788. return {
  12789. top: top + 'px', left: left + 'px'
  12790. };
  12791. }
  12792. };
  12793. if (el.result_area.is(':visible')) {
  12794. el.result_area.css(rePosition());
  12795. } else {
  12796. var pss = rePosition();
  12797. el.result_area.css(pss).show(1, function () {
  12798. var repss = rePosition();
  12799. if (pss.top !== repss.top || pss.left !== repss.left) el.result_area.css(repss);
  12800. });
  12801. }
  12802. };
  12803. /**
  12804. * hide result list
  12805. * @param {Object} self
  12806. */
  12807. SelectPage.prototype.hideResults = function (self) {
  12808. if (self.prop.key_paging) {
  12809. self.scrollWindow(self, true);
  12810. self.prop.key_paging = false;
  12811. }
  12812. self.setCssFocusedInput(self);
  12813. if (self.option.autoFillResult) {
  12814. //self.selectCurrentLine(self, true);
  12815. }
  12816. self.elem.results.empty();
  12817. self.elem.result_area.hide();
  12818. self.setOpenStatus(self, false);
  12819. //unbind window scroll listen
  12820. $(window).off('scroll.SelectPage');
  12821. self.abortAjax(self);
  12822. self.setButtonAttrDefault();
  12823. };
  12824. /**
  12825. * set plugin to disabled / enabled
  12826. * @param self
  12827. * @param disabled
  12828. */
  12829. SelectPage.prototype.disabled = function (self, disabled) {
  12830. var p = self.option, el = self.elem;
  12831. if ($.type(disabled) === 'undefined') return el.combo_input.prop('disabled');
  12832. if ($.type(disabled) === 'boolean') {
  12833. el.combo_input.prop('disabled', disabled);
  12834. if (disabled) el.container.addClass(self.css_class.disabled);
  12835. else el.container.removeClass(self.css_class.disabled);
  12836. }
  12837. };
  12838. /**
  12839. * Go fist page
  12840. * @param {Object} self
  12841. */
  12842. SelectPage.prototype.firstPage = function (self) {
  12843. if (self.prop.current_page > 1) {
  12844. self.prop.current_page = 1;
  12845. self.prop.page_move = true;
  12846. self.suggest(self);
  12847. }
  12848. };
  12849. /**
  12850. * Go previous page
  12851. * @param {Object} self
  12852. */
  12853. SelectPage.prototype.prevPage = function (self) {
  12854. if (self.prop.current_page > 1) {
  12855. self.prop.current_page--;
  12856. self.prop.page_move = true;
  12857. self.suggest(self);
  12858. }
  12859. };
  12860. /**
  12861. * Go next page
  12862. * @param {Object} self
  12863. */
  12864. SelectPage.prototype.nextPage = function (self) {
  12865. if (self.prop.current_page < self.prop.max_page) {
  12866. self.prop.current_page++;
  12867. self.prop.page_move = true;
  12868. self.suggest(self);
  12869. }
  12870. };
  12871. /**
  12872. * Go last page
  12873. * @param {Object} self
  12874. */
  12875. SelectPage.prototype.lastPage = function (self) {
  12876. if (self.prop.current_page < self.prop.max_page) {
  12877. self.prop.current_page = self.prop.max_page;
  12878. self.prop.page_move = true;
  12879. self.suggest(self);
  12880. }
  12881. };
  12882. /**
  12883. * do something after select/unSelect action
  12884. * @param {Object} self
  12885. * @param {boolean} reOpen
  12886. */
  12887. SelectPage.prototype.afterAction = function (self, reOpen) {
  12888. self.inputResize(self);
  12889. self.elem.combo_input.change();
  12890. self.setCssFocusedInput(self);
  12891. if (self.prop.init_set) return;
  12892. if (self.option.multiple) {
  12893. if (self.option.selectToCloseList) {
  12894. self.hideResults(self);
  12895. self.elem.combo_input.blur();
  12896. }
  12897. if (!self.option.selectToCloseList && reOpen) {
  12898. self.suggest(self);
  12899. self.elem.combo_input.focus();
  12900. }
  12901. } else {
  12902. self.hideResults(self);
  12903. self.elem.combo_input.blur();
  12904. }
  12905. };
  12906. /**
  12907. * Select current list item
  12908. * @param {Object} self
  12909. * @param {boolean} is_enter_key
  12910. */
  12911. SelectPage.prototype.selectCurrentLine = function (self, is_enter_key) {
  12912. self.scrollWindow(self, true);
  12913. var p = self.option, current = self.getCurrentLine(self);
  12914. if (current) {
  12915. var data = current.data('dataObj');
  12916. var text = data[p.showField] || current.text();
  12917. var value = current.attr('pkey');
  12918. if (!p.multiple) {
  12919. self.elem.combo_input.val(text);
  12920. self.elem.hidden.val(value);
  12921. } else {
  12922. //build tags in multiple selection mode
  12923. self.elem.combo_input.val('');
  12924. var item = {text: text, value: value};
  12925. if (!self.isAlreadySelected(self, item)) {
  12926. self.addNewTag(self, data, item);
  12927. self.tagValuesSet(self);
  12928. }
  12929. }
  12930. if (p.selectOnly) self.setButtonAttrDefault();
  12931. //Select item callback
  12932. if (p.eSelect && $.isFunction(p.eSelect)) p.eSelect(data, self);
  12933. self.prop.prev_value = self.elem.combo_input.val();
  12934. self.prop.selected_text = self.elem.combo_input.val();
  12935. self.putClearButton();
  12936. }
  12937. self.afterAction(self, true);
  12938. };
  12939. /**
  12940. * Show clear button when item selected in single selection mode
  12941. */
  12942. SelectPage.prototype.putClearButton = function () {
  12943. if (!this.option.multiple && !this.elem.combo_input.prop('disabled')) this.elem.container.append(this.elem.clear_btn);
  12944. };
  12945. /**
  12946. * Select all list item
  12947. * @param {Object} self
  12948. */
  12949. SelectPage.prototype.selectAllLine = function (self) {
  12950. var p = self.option, jsonarr = new Array();
  12951. self.elem.results.find('li').each(function (i, row) {
  12952. var $row = $(row), data = $row.data('dataObj');
  12953. var text = data[p.showField] || $row.text();
  12954. var value = $row.attr('pkey');
  12955. var item = {text: text, value: value};
  12956. if (!self.isAlreadySelected(self, item)) {
  12957. self.addNewTag(self, data, item);
  12958. self.tagValuesSet(self);
  12959. }
  12960. jsonarr.push(data);
  12961. //limited max selected items
  12962. if ($.type(p.maxSelectLimit) === 'number' &&
  12963. p.maxSelectLimit > 0 &&
  12964. p.maxSelectLimit === self.elem.element_box.find('li.selected_tag').length) {
  12965. return false;
  12966. }
  12967. });
  12968. if (p.eSelect && $.isFunction(p.eSelect)) p.eSelect(jsonarr, self);
  12969. self.afterAction(self, true);
  12970. };
  12971. /**
  12972. * Cancel select all item in current page
  12973. * @param {Object} self
  12974. */
  12975. SelectPage.prototype.unSelectAllLine = function (self) {
  12976. var p = self.option, size = self.elem.results.find('li').length, ds = [];
  12977. self.elem.results.find('li').each(function (i, row) {
  12978. var key = $(row).attr('pkey');
  12979. var tag = self.elem.element_box.find('li.selected_tag[itemvalue="' + key + '"]');
  12980. if (tag.length) ds.push(tag.data('dataObj'));
  12981. self.removeTag(self, tag);
  12982. });
  12983. self.afterAction(self, true);
  12984. if (p.eTagRemove && $.isFunction(p.eTagRemove)) p.eTagRemove(ds);
  12985. };
  12986. /**
  12987. * Clear all selected items
  12988. * @param {Object} self
  12989. * @param {boolean} open - open list after clear selected item
  12990. */
  12991. SelectPage.prototype.clearAll = function (self, open) {
  12992. var p = self.option, ds = [];
  12993. if (p.multiple) {
  12994. self.elem.element_box.find('li.selected_tag').each(function (i, row) {
  12995. ds.push($(row).data('dataObj'));
  12996. row.remove();
  12997. });
  12998. self.elem.element_box.find('li.selected_tag').remove();
  12999. }
  13000. self.reset(self);
  13001. self.afterAction(self, open);
  13002. if (p.multiple) {
  13003. if (p.eTagRemove && $.isFunction(p.eTagRemove)) p.eTagRemove(ds);
  13004. } else self.elem.clear_btn.remove();
  13005. };
  13006. /**
  13007. * reset
  13008. */
  13009. SelectPage.prototype.reset = function (self) {
  13010. self.elem.combo_input.val('');
  13011. self.elem.hidden.val('');
  13012. self.prop.prev_value = '';
  13013. self.prop.selected_text = '';
  13014. self.prop.current_page = 1;
  13015. };
  13016. /**
  13017. * Get current highlight item
  13018. * @param {Object} self
  13019. */
  13020. SelectPage.prototype.getCurrentLine = function (self) {
  13021. if (self.elem.result_area.is(':hidden')) return false;
  13022. var obj = self.elem.results.find('li.' + self.css_class.select);
  13023. if (obj.length) return obj;
  13024. else return false;
  13025. };
  13026. /**
  13027. * Check the result item is already selected or not
  13028. * @param {Object} self
  13029. * @param {Object} item - item info
  13030. */
  13031. SelectPage.prototype.isAlreadySelected = function (self, item) {
  13032. var isExist = false;
  13033. if (item.value) {
  13034. var keys = self.elem.hidden.val();
  13035. if (keys) {
  13036. var karr = keys.split(',');
  13037. if (karr && karr.length && $.inArray(item.value, karr) != -1) isExist = true;
  13038. }
  13039. }
  13040. return isExist;
  13041. };
  13042. /**
  13043. * Add a new tag in multiple selection mode
  13044. * @param {Object} self
  13045. * @param {object} data - raw row data
  13046. * @param {Object} item
  13047. */
  13048. SelectPage.prototype.addNewTag = function (self, data, item) {
  13049. if (!self.option.multiple || !data || !item) return;
  13050. var tmp = self.template.tag.content, tag;
  13051. tmp = tmp.replace(self.template.tag.textKey, item.text);
  13052. tmp = tmp.replace(self.template.tag.valueKey, item.value);
  13053. tag = $(tmp);
  13054. tag.data('dataObj', data);
  13055. if (self.elem.combo_input.prop('disabled')) tag.find('span.tag_close').hide();
  13056. self.elem.combo_input.closest('li').before(tag);
  13057. };
  13058. /**
  13059. * Remove a tag in multiple selection mode
  13060. * @param {Object} self
  13061. * @param {Object} item
  13062. */
  13063. SelectPage.prototype.removeTag = function (self, item) {
  13064. var key = $(item).attr('itemvalue');
  13065. var keys = self.elem.hidden.val();
  13066. if ($.type(key) != 'undefined' && keys) {
  13067. var keyarr = keys.split(','),
  13068. index = $.inArray(key.toString(), keyarr);
  13069. if (index != -1) {
  13070. keyarr.splice(index, 1);
  13071. self.elem.hidden.val(keyarr.toString()).trigger("change");
  13072. }
  13073. }
  13074. $(item).remove();
  13075. self.inputResize(self);
  13076. };
  13077. /**
  13078. * Selected item value(keyField) put in to hidden element
  13079. * @param {Object} self
  13080. */
  13081. SelectPage.prototype.tagValuesSet = function (self) {
  13082. if (!self.option.multiple) return;
  13083. var tags = self.elem.element_box.find('li.selected_tag');
  13084. if (tags && tags.length) {
  13085. var result = new Array();
  13086. $.each(tags, function (i, li) {
  13087. var v = $(li).attr('itemvalue');
  13088. if ($.type(v) !== 'undefined') result.push(v);
  13089. });
  13090. if (result.length) {
  13091. self.elem.hidden.val(result.join(',')).trigger("change");
  13092. }
  13093. }
  13094. };
  13095. /**
  13096. * auto resize input element width in multiple select mode
  13097. * @param {Object} self
  13098. */
  13099. SelectPage.prototype.inputResize = function (self) {
  13100. if (!self.option.multiple) return;
  13101. var width = '',
  13102. inputLi = self.elem.combo_input.closest('li');
  13103. var setDefaultSize = function (self, inputLi) {
  13104. inputLi.removeClass('full_width');
  13105. var minimumWidth = self.elem.combo_input.val().length + 1,
  13106. width = (minimumWidth * 0.75) + 'em';
  13107. self.elem.combo_input.css('width', width).removeAttr('placeholder');
  13108. };
  13109. if (self.elem.element_box.find('li.selected_tag').length === 0) {
  13110. if (!inputLi.hasClass('full_width')) inputLi.addClass('full_width');
  13111. if (self.elem.combo_input.attr('placeholder_bak')) {
  13112. self.elem.combo_input.attr('placeholder', self.elem.combo_input.attr('placeholder_bak')).removeAttr('style');
  13113. }
  13114. } else setDefaultSize(self, inputLi);
  13115. };
  13116. /**
  13117. * Move to next line
  13118. * @param {Object} self
  13119. */
  13120. SelectPage.prototype.nextLine = function (self) {
  13121. var obj = self.getCurrentLine(self), idx;
  13122. if (!obj) idx = -1;
  13123. else {
  13124. idx = self.elem.results.children('li').index(obj);
  13125. obj.removeClass(self.css_class.select);
  13126. }
  13127. idx++;
  13128. if (idx < self.elem.results.children('li').length) {
  13129. var next = self.elem.results.children('li').eq(idx);
  13130. next.addClass(self.css_class.select);
  13131. self.setCssFocusedResults(self);
  13132. } else self.setCssFocusedInput(self);
  13133. self.scrollWindow(self, false);
  13134. };
  13135. /**
  13136. * Move to previous line
  13137. * @param {Object} self
  13138. */
  13139. SelectPage.prototype.prevLine = function (self) {
  13140. var obj = self.getCurrentLine(self), idx;
  13141. if (!obj) idx = self.elem.results.children('li').length;
  13142. else {
  13143. idx = self.elem.results.children('li').index(obj);
  13144. obj.removeClass(self.css_class.select);
  13145. }
  13146. idx--;
  13147. if (idx > -1) {
  13148. var prev = self.elem.results.children('li').eq(idx);
  13149. prev.addClass(self.css_class.select);
  13150. self.setCssFocusedResults(self);
  13151. } else self.setCssFocusedInput(self);
  13152. self.scrollWindow(self, false);
  13153. };
  13154. /**
  13155. * SelectPage plugin definition
  13156. * @global
  13157. * @param option {Object} init plugin option
  13158. */
  13159. function Plugin(option) {
  13160. return this.each(function () {
  13161. var $this = $(this),
  13162. data = $this.data(SelectPage.dataKey),
  13163. params = $.extend({}, defaults, $this.data(), data && data.option, typeof option === 'object' && option);
  13164. if (!data) $this.data(SelectPage.dataKey, (data = new SelectPage(this, params)));
  13165. });
  13166. }
  13167. /**
  13168. * Get plugin object
  13169. * @param {object} obj
  13170. * @returns
  13171. */
  13172. function getPlugin(obj) {
  13173. return $(obj).closest('div.sp_container').find('input.sp_input');
  13174. }
  13175. /**
  13176. * Clear all selected item
  13177. */
  13178. function ClearSelected() {
  13179. return this.each(function () {
  13180. var $this = getPlugin(this),
  13181. data = $this.data(SelectPage.dataKey);
  13182. if (data) {
  13183. data.prop.init_set = true;
  13184. data.clearAll(data);
  13185. data.prop.init_set = false;
  13186. }
  13187. });
  13188. }
  13189. /**
  13190. * Refresh result list
  13191. * use case:
  13192. * 1.use $(obj).val('xxx') to modify selectpage selected item key
  13193. * 2.refresh selected item show content/tag text
  13194. */
  13195. function SelectedRefresh() {
  13196. return this.each(function () {
  13197. var $this = getPlugin(this),
  13198. data = $this.data(SelectPage.dataKey);
  13199. if (data && data.elem.hidden.val())
  13200. data.setInitRecord(true);
  13201. });
  13202. }
  13203. /**
  13204. * Modify plugin datasource, only work on json datasource mode
  13205. * @param {array} data - new datasource
  13206. * @example
  13207. * [{name:'aa',sex:1},{name:'bb',sex:0},{...}]
  13208. */
  13209. function ModifyDataSource(data) {
  13210. return this.each(function () {
  13211. if (data && $.isArray(data)) {
  13212. var $this = getPlugin(this),
  13213. plugin = $this.data(SelectPage.dataKey);
  13214. if (plugin) {
  13215. plugin.clearAll(plugin);
  13216. plugin.option.data = data;
  13217. }
  13218. }
  13219. });
  13220. }
  13221. /**
  13222. * Get plugin disabled status or Modify plugin disabled status
  13223. * @param disabled {boolean} set disabled status
  13224. */
  13225. function PluginDisabled(disabled) {
  13226. var status = false;
  13227. this.each(function () {
  13228. var $this = getPlugin(this),
  13229. plugin = $this.data(SelectPage.dataKey);
  13230. if (plugin) {
  13231. if ($.type(disabled) !== 'undefined')
  13232. plugin.disabled(plugin, disabled);
  13233. else
  13234. status = plugin.disabled(plugin);
  13235. }
  13236. });
  13237. return status;
  13238. }
  13239. /**
  13240. * Get selected item text
  13241. * @returns {string}
  13242. */
  13243. function GetInputText() {
  13244. var str = '';
  13245. this.each(function () {
  13246. var $this = getPlugin(this), data = $this.data(SelectPage.dataKey);
  13247. if (data) {
  13248. if (data.option.multiple) {
  13249. var tags = [];
  13250. data.elem.element_box.find('li.selected_tag').each(function (i, tag) {
  13251. tags.push($(tag).text());
  13252. });
  13253. str += tags.toString();
  13254. } else {
  13255. str += data.elem.combo_input.val();
  13256. }
  13257. }
  13258. });
  13259. return str;
  13260. }
  13261. /**
  13262. * Get selected item raw data
  13263. * @returns {any[]}
  13264. */
  13265. function GetSelectedData() {
  13266. var results = [];
  13267. this.each(function () {
  13268. var $this = getPlugin(this), data = $this.data(SelectPage.dataKey);
  13269. if (data) {
  13270. if (data.option.multiple) {
  13271. data.elem.element_box.find('li.selected_tag').each(function (i, tag) {
  13272. results.push($(tag).data('dataObj'));
  13273. });
  13274. } else {
  13275. var selected = data.elem.combo_input.data('dataObj');
  13276. if (selected) results.push(selected);
  13277. }
  13278. }
  13279. });
  13280. return results;
  13281. }
  13282. var old = $.fn.selectPage;
  13283. $.fn.selectPage = Plugin;
  13284. $.fn.selectPage.Constructor = SelectPage;
  13285. $.fn.selectPageClear = ClearSelected;
  13286. $.fn.selectPageRefresh = SelectedRefresh;
  13287. $.fn.selectPageData = ModifyDataSource;
  13288. $.fn.selectPageDisabled = PluginDisabled;
  13289. $.fn.selectPageText = GetInputText;
  13290. $.fn.selectPageSelectedData = GetSelectedData;
  13291. // SelectPage no conflict
  13292. // =================
  13293. $.fn.selectPage.noConflict = function () {
  13294. $.fn.selectPage = old;
  13295. return this;
  13296. };
  13297. })(window.jQuery);
  13298. define("selectpage", ["jquery"], (function (global) {
  13299. return function () {
  13300. var ret, fn;
  13301. return ret || global.$.fn.extend;
  13302. };
  13303. }(this)));