require-backend.min.js 1.1 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273
  1. /*! jQuery v2.2.4 | (c) jQuery Foundation | jquery.org/license */
  2. !function (a, b) {
  3. "object" == typeof module && "object" == typeof module.exports ? module.exports = a.document ? b(a, !0) : function (a) {
  4. if (!a.document) throw new Error("jQuery requires a window with a document");
  5. return b(a)
  6. } : b(a)
  7. }("undefined" != typeof window ? window : this, function (a, b) {
  8. var c = [], d = a.document, e = c.slice, f = c.concat, g = c.push, h = c.indexOf, i = {}, j = i.toString,
  9. k = i.hasOwnProperty, l = {}, m = "2.2.4", n = function (a, b) {
  10. return new n.fn.init(a, b)
  11. }, o = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, p = /^-ms-/, q = /-([\da-z])/gi, r = function (a, b) {
  12. return b.toUpperCase()
  13. };
  14. n.fn = n.prototype = {
  15. jquery: m, constructor: n, selector: "", length: 0, toArray: function () {
  16. return e.call(this)
  17. }, get: function (a) {
  18. return null != a ? 0 > a ? this[a + this.length] : this[a] : e.call(this)
  19. }, pushStack: function (a) {
  20. var b = n.merge(this.constructor(), a);
  21. return b.prevObject = this, b.context = this.context, b
  22. }, each: function (a) {
  23. return n.each(this, a)
  24. }, map: function (a) {
  25. return this.pushStack(n.map(this, function (b, c) {
  26. return a.call(b, c, b)
  27. }))
  28. }, slice: function () {
  29. return this.pushStack(e.apply(this, arguments))
  30. }, first: function () {
  31. return this.eq(0)
  32. }, last: function () {
  33. return this.eq(-1)
  34. }, eq: function (a) {
  35. var b = this.length, c = +a + (0 > a ? b : 0);
  36. return this.pushStack(c >= 0 && b > c ? [this[c]] : [])
  37. }, end: function () {
  38. return this.prevObject || this.constructor()
  39. }, push: g, sort: c.sort, splice: c.splice
  40. }, n.extend = n.fn.extend = function () {
  41. var a, b, c, d, e, f, g = arguments[0] || {}, h = 1, i = arguments.length, j = !1;
  42. for ("boolean" == typeof g && (j = g, g = arguments[h] || {}, h++), "object" == typeof g || n.isFunction(g) || (g = {}), h === i && (g = this, h--); i > h; h++) if (null != (a = arguments[h])) for (b in a) c = g[b], d = a[b], g !== d && (j && d && (n.isPlainObject(d) || (e = n.isArray(d))) ? (e ? (e = !1, f = c && n.isArray(c) ? c : []) : f = c && n.isPlainObject(c) ? c : {}, g[b] = n.extend(j, f, d)) : void 0 !== d && (g[b] = d));
  43. return g
  44. }, n.extend({
  45. expando: "jQuery" + (m + Math.random()).replace(/\D/g, ""), isReady: !0, error: function (a) {
  46. throw new Error(a)
  47. }, noop: function () {
  48. }, isFunction: function (a) {
  49. return "function" === n.type(a)
  50. }, isArray: Array.isArray, isWindow: function (a) {
  51. return null != a && a === a.window
  52. }, isNumeric: function (a) {
  53. var b = a && a.toString();
  54. return !n.isArray(a) && b - parseFloat(b) + 1 >= 0
  55. }, isPlainObject: function (a) {
  56. var b;
  57. if ("object" !== n.type(a) || a.nodeType || n.isWindow(a)) return !1;
  58. if (a.constructor && !k.call(a, "constructor") && !k.call(a.constructor.prototype || {}, "isPrototypeOf")) return !1;
  59. for (b in a) ;
  60. return void 0 === b || k.call(a, b)
  61. }, isEmptyObject: function (a) {
  62. var b;
  63. for (b in a) return !1;
  64. return !0
  65. }, type: function (a) {
  66. return null == a ? a + "" : "object" == typeof a || "function" == typeof a ? i[j.call(a)] || "object" : typeof a
  67. }, globalEval: function (a) {
  68. var b, c = eval;
  69. a = n.trim(a), a && (1 === a.indexOf("use strict") ? (b = d.createElement("script"), b.text = a, d.head.appendChild(b).parentNode.removeChild(b)) : c(a))
  70. }, camelCase: function (a) {
  71. return a.replace(p, "ms-").replace(q, r)
  72. }, nodeName: function (a, b) {
  73. return a.nodeName && a.nodeName.toLowerCase() === b.toLowerCase()
  74. }, each: function (a, b) {
  75. var c, d = 0;
  76. if (s(a)) {
  77. for (c = a.length; c > d; d++) if (b.call(a[d], d, a[d]) === !1) break
  78. } else for (d in a) if (b.call(a[d], d, a[d]) === !1) break;
  79. return a
  80. }, trim: function (a) {
  81. return null == a ? "" : (a + "").replace(o, "")
  82. }, makeArray: function (a, b) {
  83. var c = b || [];
  84. return null != a && (s(Object(a)) ? n.merge(c, "string" == typeof a ? [a] : a) : g.call(c, a)), c
  85. }, inArray: function (a, b, c) {
  86. return null == b ? -1 : h.call(b, a, c)
  87. }, merge: function (a, b) {
  88. for (var c = +b.length, d = 0, e = a.length; c > d; d++) a[e++] = b[d];
  89. return a.length = e, a
  90. }, grep: function (a, b, c) {
  91. for (var d, e = [], f = 0, g = a.length, h = !c; g > f; f++) d = !b(a[f], f), d !== h && e.push(a[f]);
  92. return e
  93. }, map: function (a, b, c) {
  94. var d, e, g = 0, h = [];
  95. if (s(a)) for (d = a.length; d > g; g++) e = b(a[g], g, c), null != e && h.push(e); else for (g in a) e = b(a[g], g, c), null != e && h.push(e);
  96. return f.apply([], h)
  97. }, guid: 1, proxy: function (a, b) {
  98. var c, d, f;
  99. return "string" == typeof b && (c = a[b], b = a, a = c), n.isFunction(a) ? (d = e.call(arguments, 2), f = function () {
  100. return a.apply(b || this, d.concat(e.call(arguments)))
  101. }, f.guid = a.guid = a.guid || n.guid++, f) : void 0
  102. }, now: Date.now, support: l
  103. }), "function" == typeof Symbol && (n.fn[Symbol.iterator] = c[Symbol.iterator]), n.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "), function (a, b) {
  104. i["[object " + b + "]"] = b.toLowerCase()
  105. });
  106. function s(a) {
  107. var b = !!a && "length" in a && a.length, c = n.type(a);
  108. return "function" === c || n.isWindow(a) ? !1 : "array" === c || 0 === b || "number" == typeof b && b > 0 && b - 1 in a
  109. }
  110. var t = function (a) {
  111. var b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u = "sizzle" + 1 * new Date, v = a.document, w = 0,
  112. x = 0, y = ga(), z = ga(), A = ga(), B = function (a, b) {
  113. return a === b && (l = !0), 0
  114. }, C = 1 << 31, D = {}.hasOwnProperty, E = [], F = E.pop, G = E.push, H = E.push, I = E.slice,
  115. J = function (a, b) {
  116. for (var c = 0, d = a.length; d > c; c++) if (a[c] === b) return c;
  117. return -1
  118. },
  119. K = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  120. L = "[\\x20\\t\\r\\n\\f]", M = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
  121. N = "\\[" + L + "*(" + M + ")(?:" + L + "*([*^$|!~]?=)" + L + "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + M + "))|)" + L + "*\\]",
  122. O = ":(" + M + ")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|" + N + ")*)|.*)\\)|)",
  123. P = new RegExp(L + "+", "g"), Q = new RegExp("^" + L + "+|((?:^|[^\\\\])(?:\\\\.)*)" + L + "+$", "g"),
  124. R = new RegExp("^" + L + "*," + L + "*"), S = new RegExp("^" + L + "*([>+~]|" + L + ")" + L + "*"),
  125. T = new RegExp("=" + L + "*([^\\]'\"]*?)" + L + "*\\]", "g"), U = new RegExp(O),
  126. V = new RegExp("^" + M + "$"), W = {
  127. ID: new RegExp("^#(" + M + ")"),
  128. CLASS: new RegExp("^\\.(" + M + ")"),
  129. TAG: new RegExp("^(" + M + "|[*])"),
  130. ATTR: new RegExp("^" + N),
  131. PSEUDO: new RegExp("^" + O),
  132. CHILD: new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + L + "*(even|odd|(([+-]|)(\\d*)n|)" + L + "*(?:([+-]|)" + L + "*(\\d+)|))" + L + "*\\)|)", "i"),
  133. bool: new RegExp("^(?:" + K + ")$", "i"),
  134. needsContext: new RegExp("^" + L + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + L + "*((?:-\\d)?\\d*)" + L + "*\\)|)(?=[^-]|$)", "i")
  135. }, X = /^(?:input|select|textarea|button)$/i, Y = /^h\d$/i, Z = /^[^{]+\{\s*\[native \w/,
  136. $ = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, _ = /[+~]/, aa = /'|\\/g,
  137. ba = new RegExp("\\\\([\\da-f]{1,6}" + L + "?|(" + L + ")|.)", "ig"), ca = function (a, b, c) {
  138. var d = "0x" + b - 65536;
  139. return d !== d || c ? b : 0 > d ? String.fromCharCode(d + 65536) : String.fromCharCode(d >> 10 | 55296, 1023 & d | 56320)
  140. }, da = function () {
  141. m()
  142. };
  143. try {
  144. H.apply(E = I.call(v.childNodes), v.childNodes), E[v.childNodes.length].nodeType
  145. } catch (ea) {
  146. H = {
  147. apply: E.length ? function (a, b) {
  148. G.apply(a, I.call(b))
  149. } : function (a, b) {
  150. var c = a.length, d = 0;
  151. while (a[c++] = b[d++]) ;
  152. a.length = c - 1
  153. }
  154. }
  155. }
  156. function fa(a, b, d, e) {
  157. var f, h, j, k, l, o, r, s, w = b && b.ownerDocument, x = b ? b.nodeType : 9;
  158. if (d = d || [], "string" != typeof a || !a || 1 !== x && 9 !== x && 11 !== x) return d;
  159. if (!e && ((b ? b.ownerDocument || b : v) !== n && m(b), b = b || n, p)) {
  160. if (11 !== x && (o = $.exec(a))) if (f = o[1]) {
  161. if (9 === x) {
  162. if (!(j = b.getElementById(f))) return d;
  163. if (j.id === f) return d.push(j), d
  164. } else if (w && (j = w.getElementById(f)) && t(b, j) && j.id === f) return d.push(j), d
  165. } else {
  166. if (o[2]) return H.apply(d, b.getElementsByTagName(a)), d;
  167. if ((f = o[3]) && c.getElementsByClassName && b.getElementsByClassName) return H.apply(d, b.getElementsByClassName(f)), d
  168. }
  169. if (c.qsa && !A[a + " "] && (!q || !q.test(a))) {
  170. if (1 !== x) w = b, s = a; else if ("object" !== b.nodeName.toLowerCase()) {
  171. (k = b.getAttribute("id")) ? k = k.replace(aa, "\\$&") : b.setAttribute("id", k = u), r = g(a), h = r.length, l = V.test(k) ? "#" + k : "[id='" + k + "']";
  172. while (h--) r[h] = l + " " + qa(r[h]);
  173. s = r.join(","), w = _.test(a) && oa(b.parentNode) || b
  174. }
  175. if (s) try {
  176. return H.apply(d, w.querySelectorAll(s)), d
  177. } catch (y) {
  178. } finally {
  179. k === u && b.removeAttribute("id")
  180. }
  181. }
  182. }
  183. return i(a.replace(Q, "$1"), b, d, e)
  184. }
  185. function ga() {
  186. var a = [];
  187. function b(c, e) {
  188. return a.push(c + " ") > d.cacheLength && delete b[a.shift()], b[c + " "] = e
  189. }
  190. return b
  191. }
  192. function ha(a) {
  193. return a[u] = !0, a
  194. }
  195. function ia(a) {
  196. var b = n.createElement("div");
  197. try {
  198. return !!a(b)
  199. } catch (c) {
  200. return !1
  201. } finally {
  202. b.parentNode && b.parentNode.removeChild(b), b = null
  203. }
  204. }
  205. function ja(a, b) {
  206. var c = a.split("|"), e = c.length;
  207. while (e--) d.attrHandle[c[e]] = b
  208. }
  209. function ka(a, b) {
  210. var c = b && a,
  211. d = c && 1 === a.nodeType && 1 === b.nodeType && (~b.sourceIndex || C) - (~a.sourceIndex || C);
  212. if (d) return d;
  213. if (c) while (c = c.nextSibling) if (c === b) return -1;
  214. return a ? 1 : -1
  215. }
  216. function la(a) {
  217. return function (b) {
  218. var c = b.nodeName.toLowerCase();
  219. return "input" === c && b.type === a
  220. }
  221. }
  222. function ma(a) {
  223. return function (b) {
  224. var c = b.nodeName.toLowerCase();
  225. return ("input" === c || "button" === c) && b.type === a
  226. }
  227. }
  228. function na(a) {
  229. return ha(function (b) {
  230. return b = +b, ha(function (c, d) {
  231. var e, f = a([], c.length, b), g = f.length;
  232. while (g--) c[e = f[g]] && (c[e] = !(d[e] = c[e]))
  233. })
  234. })
  235. }
  236. function oa(a) {
  237. return a && "undefined" != typeof a.getElementsByTagName && a
  238. }
  239. c = fa.support = {}, f = fa.isXML = function (a) {
  240. var b = a && (a.ownerDocument || a).documentElement;
  241. return b ? "HTML" !== b.nodeName : !1
  242. }, m = fa.setDocument = function (a) {
  243. var b, e, g = a ? a.ownerDocument || a : v;
  244. return g !== n && 9 === g.nodeType && g.documentElement ? (n = g, o = n.documentElement, p = !f(n), (e = n.defaultView) && e.top !== e && (e.addEventListener ? e.addEventListener("unload", da, !1) : e.attachEvent && e.attachEvent("onunload", da)), c.attributes = ia(function (a) {
  245. return a.className = "i", !a.getAttribute("className")
  246. }), c.getElementsByTagName = ia(function (a) {
  247. return a.appendChild(n.createComment("")), !a.getElementsByTagName("*").length
  248. }), c.getElementsByClassName = Z.test(n.getElementsByClassName), c.getById = ia(function (a) {
  249. return o.appendChild(a).id = u, !n.getElementsByName || !n.getElementsByName(u).length
  250. }), c.getById ? (d.find.ID = function (a, b) {
  251. if ("undefined" != typeof b.getElementById && p) {
  252. var c = b.getElementById(a);
  253. return c ? [c] : []
  254. }
  255. }, d.filter.ID = function (a) {
  256. var b = a.replace(ba, ca);
  257. return function (a) {
  258. return a.getAttribute("id") === b
  259. }
  260. }) : (delete d.find.ID, d.filter.ID = function (a) {
  261. var b = a.replace(ba, ca);
  262. return function (a) {
  263. var c = "undefined" != typeof a.getAttributeNode && a.getAttributeNode("id");
  264. return c && c.value === b
  265. }
  266. }), d.find.TAG = c.getElementsByTagName ? function (a, b) {
  267. return "undefined" != typeof b.getElementsByTagName ? b.getElementsByTagName(a) : c.qsa ? b.querySelectorAll(a) : void 0
  268. } : function (a, b) {
  269. var c, d = [], e = 0, f = b.getElementsByTagName(a);
  270. if ("*" === a) {
  271. while (c = f[e++]) 1 === c.nodeType && d.push(c);
  272. return d
  273. }
  274. return f
  275. }, d.find.CLASS = c.getElementsByClassName && function (a, b) {
  276. return "undefined" != typeof b.getElementsByClassName && p ? b.getElementsByClassName(a) : void 0
  277. }, r = [], q = [], (c.qsa = Z.test(n.querySelectorAll)) && (ia(function (a) {
  278. o.appendChild(a).innerHTML = "<a id='" + u + "'></a><select id='" + u + "-\r\\' msallowcapture=''><option selected=''></option></select>", a.querySelectorAll("[msallowcapture^='']").length && q.push("[*^$]=" + L + "*(?:''|\"\")"), a.querySelectorAll("[selected]").length || q.push("\\[" + L + "*(?:value|" + K + ")"), a.querySelectorAll("[id~=" + u + "-]").length || q.push("~="), a.querySelectorAll(":checked").length || q.push(":checked"), a.querySelectorAll("a#" + u + "+*").length || q.push(".#.+[+~]")
  279. }), ia(function (a) {
  280. var b = n.createElement("input");
  281. b.setAttribute("type", "hidden"), a.appendChild(b).setAttribute("name", "D"), a.querySelectorAll("[name=d]").length && q.push("name" + L + "*[*^$|!~]?="), a.querySelectorAll(":enabled").length || q.push(":enabled", ":disabled"), a.querySelectorAll("*,:x"), q.push(",.*:")
  282. })), (c.matchesSelector = Z.test(s = o.matches || o.webkitMatchesSelector || o.mozMatchesSelector || o.oMatchesSelector || o.msMatchesSelector)) && ia(function (a) {
  283. c.disconnectedMatch = s.call(a, "div"), s.call(a, "[s!='']:x"), r.push("!=", O)
  284. }), q = q.length && new RegExp(q.join("|")), r = r.length && new RegExp(r.join("|")), b = Z.test(o.compareDocumentPosition), t = b || Z.test(o.contains) ? function (a, b) {
  285. var c = 9 === a.nodeType ? a.documentElement : a, d = b && b.parentNode;
  286. return a === d || !(!d || 1 !== d.nodeType || !(c.contains ? c.contains(d) : a.compareDocumentPosition && 16 & a.compareDocumentPosition(d)))
  287. } : function (a, b) {
  288. if (b) while (b = b.parentNode) if (b === a) return !0;
  289. return !1
  290. }, B = b ? function (a, b) {
  291. if (a === b) return l = !0, 0;
  292. var d = !a.compareDocumentPosition - !b.compareDocumentPosition;
  293. return d ? d : (d = (a.ownerDocument || a) === (b.ownerDocument || b) ? a.compareDocumentPosition(b) : 1, 1 & d || !c.sortDetached && b.compareDocumentPosition(a) === d ? a === n || a.ownerDocument === v && t(v, a) ? -1 : b === n || b.ownerDocument === v && t(v, b) ? 1 : k ? J(k, a) - J(k, b) : 0 : 4 & d ? -1 : 1)
  294. } : function (a, b) {
  295. if (a === b) return l = !0, 0;
  296. var c, d = 0, e = a.parentNode, f = b.parentNode, g = [a], h = [b];
  297. if (!e || !f) return a === n ? -1 : b === n ? 1 : e ? -1 : f ? 1 : k ? J(k, a) - J(k, b) : 0;
  298. if (e === f) return ka(a, b);
  299. c = a;
  300. while (c = c.parentNode) g.unshift(c);
  301. c = b;
  302. while (c = c.parentNode) h.unshift(c);
  303. while (g[d] === h[d]) d++;
  304. return d ? ka(g[d], h[d]) : g[d] === v ? -1 : h[d] === v ? 1 : 0
  305. }, n) : n
  306. }, fa.matches = function (a, b) {
  307. return fa(a, null, null, b)
  308. }, fa.matchesSelector = function (a, b) {
  309. if ((a.ownerDocument || a) !== n && m(a), b = b.replace(T, "='$1']"), c.matchesSelector && p && !A[b + " "] && (!r || !r.test(b)) && (!q || !q.test(b))) try {
  310. var d = s.call(a, b);
  311. if (d || c.disconnectedMatch || a.document && 11 !== a.document.nodeType) return d
  312. } catch (e) {
  313. }
  314. return fa(b, n, null, [a]).length > 0
  315. }, fa.contains = function (a, b) {
  316. return (a.ownerDocument || a) !== n && m(a), t(a, b)
  317. }, fa.attr = function (a, b) {
  318. (a.ownerDocument || a) !== n && m(a);
  319. var e = d.attrHandle[b.toLowerCase()],
  320. f = e && D.call(d.attrHandle, b.toLowerCase()) ? e(a, b, !p) : void 0;
  321. return void 0 !== f ? f : c.attributes || !p ? a.getAttribute(b) : (f = a.getAttributeNode(b)) && f.specified ? f.value : null
  322. }, fa.error = function (a) {
  323. throw new Error("Syntax error, unrecognized expression: " + a)
  324. }, fa.uniqueSort = function (a) {
  325. var b, d = [], e = 0, f = 0;
  326. if (l = !c.detectDuplicates, k = !c.sortStable && a.slice(0), a.sort(B), l) {
  327. while (b = a[f++]) b === a[f] && (e = d.push(f));
  328. while (e--) a.splice(d[e], 1)
  329. }
  330. return k = null, a
  331. }, e = fa.getText = function (a) {
  332. var b, c = "", d = 0, f = a.nodeType;
  333. if (f) {
  334. if (1 === f || 9 === f || 11 === f) {
  335. if ("string" == typeof a.textContent) return a.textContent;
  336. for (a = a.firstChild; a; a = a.nextSibling) c += e(a)
  337. } else if (3 === f || 4 === f) return a.nodeValue
  338. } else while (b = a[d++]) c += e(b);
  339. return c
  340. }, d = fa.selectors = {
  341. cacheLength: 50,
  342. createPseudo: ha,
  343. match: W,
  344. attrHandle: {},
  345. find: {},
  346. relative: {
  347. ">": {dir: "parentNode", first: !0},
  348. " ": {dir: "parentNode"},
  349. "+": {dir: "previousSibling", first: !0},
  350. "~": {dir: "previousSibling"}
  351. },
  352. preFilter: {
  353. ATTR: function (a) {
  354. return a[1] = a[1].replace(ba, ca), a[3] = (a[3] || a[4] || a[5] || "").replace(ba, ca), "~=" === a[2] && (a[3] = " " + a[3] + " "), a.slice(0, 4)
  355. }, CHILD: function (a) {
  356. return a[1] = a[1].toLowerCase(), "nth" === a[1].slice(0, 3) ? (a[3] || fa.error(a[0]), a[4] = +(a[4] ? a[5] + (a[6] || 1) : 2 * ("even" === a[3] || "odd" === a[3])), a[5] = +(a[7] + a[8] || "odd" === a[3])) : a[3] && fa.error(a[0]), a
  357. }, PSEUDO: function (a) {
  358. var b, c = !a[6] && a[2];
  359. return W.CHILD.test(a[0]) ? null : (a[3] ? a[2] = a[4] || a[5] || "" : c && U.test(c) && (b = g(c, !0)) && (b = c.indexOf(")", c.length - b) - c.length) && (a[0] = a[0].slice(0, b), a[2] = c.slice(0, b)), a.slice(0, 3))
  360. }
  361. },
  362. filter: {
  363. TAG: function (a) {
  364. var b = a.replace(ba, ca).toLowerCase();
  365. return "*" === a ? function () {
  366. return !0
  367. } : function (a) {
  368. return a.nodeName && a.nodeName.toLowerCase() === b
  369. }
  370. }, CLASS: function (a) {
  371. var b = y[a + " "];
  372. return b || (b = new RegExp("(^|" + L + ")" + a + "(" + L + "|$)")) && y(a, function (a) {
  373. return b.test("string" == typeof a.className && a.className || "undefined" != typeof a.getAttribute && a.getAttribute("class") || "")
  374. })
  375. }, ATTR: function (a, b, c) {
  376. return function (d) {
  377. var e = fa.attr(d, a);
  378. return null == e ? "!=" === b : b ? (e += "", "=" === b ? e === c : "!=" === b ? e !== c : "^=" === b ? c && 0 === e.indexOf(c) : "*=" === b ? c && e.indexOf(c) > -1 : "$=" === b ? c && e.slice(-c.length) === c : "~=" === b ? (" " + e.replace(P, " ") + " ").indexOf(c) > -1 : "|=" === b ? e === c || e.slice(0, c.length + 1) === c + "-" : !1) : !0
  379. }
  380. }, CHILD: function (a, b, c, d, e) {
  381. var f = "nth" !== a.slice(0, 3), g = "last" !== a.slice(-4), h = "of-type" === b;
  382. return 1 === d && 0 === e ? function (a) {
  383. return !!a.parentNode
  384. } : function (b, c, i) {
  385. var j, k, l, m, n, o, p = f !== g ? "nextSibling" : "previousSibling", q = b.parentNode,
  386. r = h && b.nodeName.toLowerCase(), s = !i && !h, t = !1;
  387. if (q) {
  388. if (f) {
  389. while (p) {
  390. m = b;
  391. while (m = m[p]) if (h ? m.nodeName.toLowerCase() === r : 1 === m.nodeType) return !1;
  392. o = p = "only" === a && !o && "nextSibling"
  393. }
  394. return !0
  395. }
  396. if (o = [g ? q.firstChild : q.lastChild], g && s) {
  397. m = q, l = m[u] || (m[u] = {}), k = l[m.uniqueID] || (l[m.uniqueID] = {}), j = k[a] || [], n = j[0] === w && j[1], t = n && j[2], m = n && q.childNodes[n];
  398. while (m = ++n && m && m[p] || (t = n = 0) || o.pop()) if (1 === m.nodeType && ++t && m === b) {
  399. k[a] = [w, n, t];
  400. break
  401. }
  402. } else if (s && (m = b, l = m[u] || (m[u] = {}), k = l[m.uniqueID] || (l[m.uniqueID] = {}), j = k[a] || [], n = j[0] === w && j[1], t = n), t === !1) while (m = ++n && m && m[p] || (t = n = 0) || o.pop()) if ((h ? m.nodeName.toLowerCase() === r : 1 === m.nodeType) && ++t && (s && (l = m[u] || (m[u] = {}), k = l[m.uniqueID] || (l[m.uniqueID] = {}), k[a] = [w, t]), m === b)) break;
  403. return t -= e, t === d || t % d === 0 && t / d >= 0
  404. }
  405. }
  406. }, PSEUDO: function (a, b) {
  407. var c, e = d.pseudos[a] || d.setFilters[a.toLowerCase()] || fa.error("unsupported pseudo: " + a);
  408. return e[u] ? e(b) : e.length > 1 ? (c = [a, a, "", b], d.setFilters.hasOwnProperty(a.toLowerCase()) ? ha(function (a, c) {
  409. var d, f = e(a, b), g = f.length;
  410. while (g--) d = J(a, f[g]), a[d] = !(c[d] = f[g])
  411. }) : function (a) {
  412. return e(a, 0, c)
  413. }) : e
  414. }
  415. },
  416. pseudos: {
  417. not: ha(function (a) {
  418. var b = [], c = [], d = h(a.replace(Q, "$1"));
  419. return d[u] ? ha(function (a, b, c, e) {
  420. var f, g = d(a, null, e, []), h = a.length;
  421. while (h--) (f = g[h]) && (a[h] = !(b[h] = f))
  422. }) : function (a, e, f) {
  423. return b[0] = a, d(b, null, f, c), b[0] = null, !c.pop()
  424. }
  425. }), has: ha(function (a) {
  426. return function (b) {
  427. return fa(a, b).length > 0
  428. }
  429. }), contains: ha(function (a) {
  430. return a = a.replace(ba, ca), function (b) {
  431. return (b.textContent || b.innerText || e(b)).indexOf(a) > -1
  432. }
  433. }), lang: ha(function (a) {
  434. return V.test(a || "") || fa.error("unsupported lang: " + a), a = a.replace(ba, ca).toLowerCase(), function (b) {
  435. var c;
  436. do if (c = p ? b.lang : b.getAttribute("xml:lang") || b.getAttribute("lang")) return c = c.toLowerCase(), c === a || 0 === c.indexOf(a + "-"); while ((b = b.parentNode) && 1 === b.nodeType);
  437. return !1
  438. }
  439. }), target: function (b) {
  440. var c = a.location && a.location.hash;
  441. return c && c.slice(1) === b.id
  442. }, root: function (a) {
  443. return a === o
  444. }, focus: function (a) {
  445. return a === n.activeElement && (!n.hasFocus || n.hasFocus()) && !!(a.type || a.href || ~a.tabIndex)
  446. }, enabled: function (a) {
  447. return a.disabled === !1
  448. }, disabled: function (a) {
  449. return a.disabled === !0
  450. }, checked: function (a) {
  451. var b = a.nodeName.toLowerCase();
  452. return "input" === b && !!a.checked || "option" === b && !!a.selected
  453. }, selected: function (a) {
  454. return a.parentNode && a.parentNode.selectedIndex, a.selected === !0
  455. }, empty: function (a) {
  456. for (a = a.firstChild; a; a = a.nextSibling) if (a.nodeType < 6) return !1;
  457. return !0
  458. }, parent: function (a) {
  459. return !d.pseudos.empty(a)
  460. }, header: function (a) {
  461. return Y.test(a.nodeName)
  462. }, input: function (a) {
  463. return X.test(a.nodeName)
  464. }, button: function (a) {
  465. var b = a.nodeName.toLowerCase();
  466. return "input" === b && "button" === a.type || "button" === b
  467. }, text: function (a) {
  468. var b;
  469. return "input" === a.nodeName.toLowerCase() && "text" === a.type && (null == (b = a.getAttribute("type")) || "text" === b.toLowerCase())
  470. }, first: na(function () {
  471. return [0]
  472. }), last: na(function (a, b) {
  473. return [b - 1]
  474. }), eq: na(function (a, b, c) {
  475. return [0 > c ? c + b : c]
  476. }), even: na(function (a, b) {
  477. for (var c = 0; b > c; c += 2) a.push(c);
  478. return a
  479. }), odd: na(function (a, b) {
  480. for (var c = 1; b > c; c += 2) a.push(c);
  481. return a
  482. }), lt: na(function (a, b, c) {
  483. for (var d = 0 > c ? c + b : c; --d >= 0;) a.push(d);
  484. return a
  485. }), gt: na(function (a, b, c) {
  486. for (var d = 0 > c ? c + b : c; ++d < b;) a.push(d);
  487. return a
  488. })
  489. }
  490. }, d.pseudos.nth = d.pseudos.eq;
  491. for (b in {radio: !0, checkbox: !0, file: !0, password: !0, image: !0}) d.pseudos[b] = la(b);
  492. for (b in {submit: !0, reset: !0}) d.pseudos[b] = ma(b);
  493. function pa() {
  494. }
  495. pa.prototype = d.filters = d.pseudos, d.setFilters = new pa, g = fa.tokenize = function (a, b) {
  496. var c, e, f, g, h, i, j, k = z[a + " "];
  497. if (k) return b ? 0 : k.slice(0);
  498. h = a, i = [], j = d.preFilter;
  499. while (h) {
  500. c && !(e = R.exec(h)) || (e && (h = h.slice(e[0].length) || h), i.push(f = [])), c = !1, (e = S.exec(h)) && (c = e.shift(), f.push({
  501. value: c,
  502. type: e[0].replace(Q, " ")
  503. }), h = h.slice(c.length));
  504. for (g in d.filter) !(e = W[g].exec(h)) || j[g] && !(e = j[g](e)) || (c = e.shift(), f.push({
  505. value: c,
  506. type: g,
  507. matches: e
  508. }), h = h.slice(c.length));
  509. if (!c) break
  510. }
  511. return b ? h.length : h ? fa.error(a) : z(a, i).slice(0)
  512. };
  513. function qa(a) {
  514. for (var b = 0, c = a.length, d = ""; c > b; b++) d += a[b].value;
  515. return d
  516. }
  517. function ra(a, b, c) {
  518. var d = b.dir, e = c && "parentNode" === d, f = x++;
  519. return b.first ? function (b, c, f) {
  520. while (b = b[d]) if (1 === b.nodeType || e) return a(b, c, f)
  521. } : function (b, c, g) {
  522. var h, i, j, k = [w, f];
  523. if (g) {
  524. while (b = b[d]) if ((1 === b.nodeType || e) && a(b, c, g)) return !0
  525. } else while (b = b[d]) if (1 === b.nodeType || e) {
  526. if (j = b[u] || (b[u] = {}), i = j[b.uniqueID] || (j[b.uniqueID] = {}), (h = i[d]) && h[0] === w && h[1] === f) return k[2] = h[2];
  527. if (i[d] = k, k[2] = a(b, c, g)) return !0
  528. }
  529. }
  530. }
  531. function sa(a) {
  532. return a.length > 1 ? function (b, c, d) {
  533. var e = a.length;
  534. while (e--) if (!a[e](b, c, d)) return !1;
  535. return !0
  536. } : a[0]
  537. }
  538. function ta(a, b, c) {
  539. for (var d = 0, e = b.length; e > d; d++) fa(a, b[d], c);
  540. return c
  541. }
  542. function ua(a, b, c, d, e) {
  543. for (var f, g = [], h = 0, i = a.length, j = null != b; i > h; h++) (f = a[h]) && (c && !c(f, d, e) || (g.push(f), j && b.push(h)));
  544. return g
  545. }
  546. function va(a, b, c, d, e, f) {
  547. return d && !d[u] && (d = va(d)), e && !e[u] && (e = va(e, f)), ha(function (f, g, h, i) {
  548. var j, k, l, m = [], n = [], o = g.length, p = f || ta(b || "*", h.nodeType ? [h] : h, []),
  549. q = !a || !f && b ? p : ua(p, m, a, h, i), r = c ? e || (f ? a : o || d) ? [] : g : q;
  550. if (c && c(q, r, h, i), d) {
  551. j = ua(r, n), d(j, [], h, i), k = j.length;
  552. while (k--) (l = j[k]) && (r[n[k]] = !(q[n[k]] = l))
  553. }
  554. if (f) {
  555. if (e || a) {
  556. if (e) {
  557. j = [], k = r.length;
  558. while (k--) (l = r[k]) && j.push(q[k] = l);
  559. e(null, r = [], j, i)
  560. }
  561. k = r.length;
  562. while (k--) (l = r[k]) && (j = e ? J(f, l) : m[k]) > -1 && (f[j] = !(g[j] = l))
  563. }
  564. } else r = ua(r === g ? r.splice(o, r.length) : r), e ? e(null, g, r, i) : H.apply(g, r)
  565. })
  566. }
  567. function wa(a) {
  568. for (var b, c, e, f = a.length, g = d.relative[a[0].type], h = g || d.relative[" "], i = g ? 1 : 0, k = ra(function (a) {
  569. return a === b
  570. }, h, !0), l = ra(function (a) {
  571. return J(b, a) > -1
  572. }, h, !0), m = [function (a, c, d) {
  573. var e = !g && (d || c !== j) || ((b = c).nodeType ? k(a, c, d) : l(a, c, d));
  574. return b = null, e
  575. }]; f > i; i++) if (c = d.relative[a[i].type]) m = [ra(sa(m), c)]; else {
  576. if (c = d.filter[a[i].type].apply(null, a[i].matches), c[u]) {
  577. for (e = ++i; f > e; e++) if (d.relative[a[e].type]) break;
  578. return va(i > 1 && sa(m), i > 1 && qa(a.slice(0, i - 1).concat({value: " " === a[i - 2].type ? "*" : ""})).replace(Q, "$1"), c, e > i && wa(a.slice(i, e)), f > e && wa(a = a.slice(e)), f > e && qa(a))
  579. }
  580. m.push(c)
  581. }
  582. return sa(m)
  583. }
  584. function xa(a, b) {
  585. var c = b.length > 0, e = a.length > 0, f = function (f, g, h, i, k) {
  586. var l, o, q, r = 0, s = "0", t = f && [], u = [], v = j, x = f || e && d.find.TAG("*", k),
  587. y = w += null == v ? 1 : Math.random() || .1, z = x.length;
  588. for (k && (j = g === n || g || k); s !== z && null != (l = x[s]); s++) {
  589. if (e && l) {
  590. o = 0, g || l.ownerDocument === n || (m(l), h = !p);
  591. while (q = a[o++]) if (q(l, g || n, h)) {
  592. i.push(l);
  593. break
  594. }
  595. k && (w = y)
  596. }
  597. c && ((l = !q && l) && r--, f && t.push(l))
  598. }
  599. if (r += s, c && s !== r) {
  600. o = 0;
  601. while (q = b[o++]) q(t, u, g, h);
  602. if (f) {
  603. if (r > 0) while (s--) t[s] || u[s] || (u[s] = F.call(i));
  604. u = ua(u)
  605. }
  606. H.apply(i, u), k && !f && u.length > 0 && r + b.length > 1 && fa.uniqueSort(i)
  607. }
  608. return k && (w = y, j = v), t
  609. };
  610. return c ? ha(f) : f
  611. }
  612. return h = fa.compile = function (a, b) {
  613. var c, d = [], e = [], f = A[a + " "];
  614. if (!f) {
  615. b || (b = g(a)), c = b.length;
  616. while (c--) f = wa(b[c]), f[u] ? d.push(f) : e.push(f);
  617. f = A(a, xa(e, d)), f.selector = a
  618. }
  619. return f
  620. }, i = fa.select = function (a, b, e, f) {
  621. var i, j, k, l, m, n = "function" == typeof a && a, o = !f && g(a = n.selector || a);
  622. if (e = e || [], 1 === o.length) {
  623. if (j = o[0] = o[0].slice(0), j.length > 2 && "ID" === (k = j[0]).type && c.getById && 9 === b.nodeType && p && d.relative[j[1].type]) {
  624. if (b = (d.find.ID(k.matches[0].replace(ba, ca), b) || [])[0], !b) return e;
  625. n && (b = b.parentNode), a = a.slice(j.shift().value.length)
  626. }
  627. i = W.needsContext.test(a) ? 0 : j.length;
  628. while (i--) {
  629. if (k = j[i], d.relative[l = k.type]) break;
  630. if ((m = d.find[l]) && (f = m(k.matches[0].replace(ba, ca), _.test(j[0].type) && oa(b.parentNode) || b))) {
  631. if (j.splice(i, 1), a = f.length && qa(j), !a) return H.apply(e, f), e;
  632. break
  633. }
  634. }
  635. }
  636. return (n || h(a, o))(f, b, !p, e, !b || _.test(a) && oa(b.parentNode) || b), e
  637. }, c.sortStable = u.split("").sort(B).join("") === u, c.detectDuplicates = !!l, m(), c.sortDetached = ia(function (a) {
  638. return 1 & a.compareDocumentPosition(n.createElement("div"))
  639. }), ia(function (a) {
  640. return a.innerHTML = "<a href='#'></a>", "#" === a.firstChild.getAttribute("href")
  641. }) || ja("type|href|height|width", function (a, b, c) {
  642. return c ? void 0 : a.getAttribute(b, "type" === b.toLowerCase() ? 1 : 2)
  643. }), c.attributes && ia(function (a) {
  644. return a.innerHTML = "<input/>", a.firstChild.setAttribute("value", ""), "" === a.firstChild.getAttribute("value")
  645. }) || ja("value", function (a, b, c) {
  646. return c || "input" !== a.nodeName.toLowerCase() ? void 0 : a.defaultValue
  647. }), ia(function (a) {
  648. return null == a.getAttribute("disabled")
  649. }) || ja(K, function (a, b, c) {
  650. var d;
  651. return c ? void 0 : a[b] === !0 ? b.toLowerCase() : (d = a.getAttributeNode(b)) && d.specified ? d.value : null
  652. }), fa
  653. }(a);
  654. n.find = t, n.expr = t.selectors, n.expr[":"] = n.expr.pseudos, n.uniqueSort = n.unique = t.uniqueSort, n.text = t.getText, n.isXMLDoc = t.isXML, n.contains = t.contains;
  655. var u = function (a, b, c) {
  656. var d = [], e = void 0 !== c;
  657. while ((a = a[b]) && 9 !== a.nodeType) if (1 === a.nodeType) {
  658. if (e && n(a).is(c)) break;
  659. d.push(a)
  660. }
  661. return d
  662. }, v = function (a, b) {
  663. for (var c = []; a; a = a.nextSibling) 1 === a.nodeType && a !== b && c.push(a);
  664. return c
  665. }, w = n.expr.match.needsContext, x = /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/, y = /^.[^:#\[\.,]*$/;
  666. function z(a, b, c) {
  667. if (n.isFunction(b)) return n.grep(a, function (a, d) {
  668. return !!b.call(a, d, a) !== c
  669. });
  670. if (b.nodeType) return n.grep(a, function (a) {
  671. return a === b !== c
  672. });
  673. if ("string" == typeof b) {
  674. if (y.test(b)) return n.filter(b, a, c);
  675. b = n.filter(b, a)
  676. }
  677. return n.grep(a, function (a) {
  678. return h.call(b, a) > -1 !== c
  679. })
  680. }
  681. n.filter = function (a, b, c) {
  682. var d = b[0];
  683. return c && (a = ":not(" + a + ")"), 1 === b.length && 1 === d.nodeType ? n.find.matchesSelector(d, a) ? [d] : [] : n.find.matches(a, n.grep(b, function (a) {
  684. return 1 === a.nodeType
  685. }))
  686. }, n.fn.extend({
  687. find: function (a) {
  688. var b, c = this.length, d = [], e = this;
  689. if ("string" != typeof a) return this.pushStack(n(a).filter(function () {
  690. for (b = 0; c > b; b++) if (n.contains(e[b], this)) return !0
  691. }));
  692. for (b = 0; c > b; b++) n.find(a, e[b], d);
  693. return d = this.pushStack(c > 1 ? n.unique(d) : d), d.selector = this.selector ? this.selector + " " + a : a, d
  694. }, filter: function (a) {
  695. return this.pushStack(z(this, a || [], !1))
  696. }, not: function (a) {
  697. return this.pushStack(z(this, a || [], !0))
  698. }, is: function (a) {
  699. return !!z(this, "string" == typeof a && w.test(a) ? n(a) : a || [], !1).length
  700. }
  701. });
  702. var A, B = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, C = n.fn.init = function (a, b, c) {
  703. var e, f;
  704. if (!a) return this;
  705. if (c = c || A, "string" == typeof a) {
  706. if (e = "<" === a[0] && ">" === a[a.length - 1] && a.length >= 3 ? [null, a, null] : B.exec(a), !e || !e[1] && b) return !b || b.jquery ? (b || c).find(a) : this.constructor(b).find(a);
  707. if (e[1]) {
  708. if (b = b instanceof n ? b[0] : b, n.merge(this, n.parseHTML(e[1], b && b.nodeType ? b.ownerDocument || b : d, !0)), x.test(e[1]) && n.isPlainObject(b)) for (e in b) n.isFunction(this[e]) ? this[e](b[e]) : this.attr(e, b[e]);
  709. return this
  710. }
  711. return f = d.getElementById(e[2]), f && f.parentNode && (this.length = 1, this[0] = f), this.context = d, this.selector = a, this
  712. }
  713. return a.nodeType ? (this.context = this[0] = a, this.length = 1, this) : n.isFunction(a) ? void 0 !== c.ready ? c.ready(a) : a(n) : (void 0 !== a.selector && (this.selector = a.selector, this.context = a.context), n.makeArray(a, this))
  714. };
  715. C.prototype = n.fn, A = n(d);
  716. var D = /^(?:parents|prev(?:Until|All))/, E = {children: !0, contents: !0, next: !0, prev: !0};
  717. n.fn.extend({
  718. has: function (a) {
  719. var b = n(a, this), c = b.length;
  720. return this.filter(function () {
  721. for (var a = 0; c > a; a++) if (n.contains(this, b[a])) return !0
  722. })
  723. }, closest: function (a, b) {
  724. for (var c, d = 0, e = this.length, f = [], g = w.test(a) || "string" != typeof a ? n(a, b || this.context) : 0; e > d; d++) for (c = this[d]; c && c !== b; c = c.parentNode) if (c.nodeType < 11 && (g ? g.index(c) > -1 : 1 === c.nodeType && n.find.matchesSelector(c, a))) {
  725. f.push(c);
  726. break
  727. }
  728. return this.pushStack(f.length > 1 ? n.uniqueSort(f) : f)
  729. }, index: function (a) {
  730. return a ? "string" == typeof a ? h.call(n(a), this[0]) : h.call(this, a.jquery ? a[0] : a) : this[0] && this[0].parentNode ? this.first().prevAll().length : -1
  731. }, add: function (a, b) {
  732. return this.pushStack(n.uniqueSort(n.merge(this.get(), n(a, b))))
  733. }, addBack: function (a) {
  734. return this.add(null == a ? this.prevObject : this.prevObject.filter(a))
  735. }
  736. });
  737. function F(a, b) {
  738. while ((a = a[b]) && 1 !== a.nodeType) ;
  739. return a
  740. }
  741. n.each({
  742. parent: function (a) {
  743. var b = a.parentNode;
  744. return b && 11 !== b.nodeType ? b : null
  745. }, parents: function (a) {
  746. return u(a, "parentNode")
  747. }, parentsUntil: function (a, b, c) {
  748. return u(a, "parentNode", c)
  749. }, next: function (a) {
  750. return F(a, "nextSibling")
  751. }, prev: function (a) {
  752. return F(a, "previousSibling")
  753. }, nextAll: function (a) {
  754. return u(a, "nextSibling")
  755. }, prevAll: function (a) {
  756. return u(a, "previousSibling")
  757. }, nextUntil: function (a, b, c) {
  758. return u(a, "nextSibling", c)
  759. }, prevUntil: function (a, b, c) {
  760. return u(a, "previousSibling", c)
  761. }, siblings: function (a) {
  762. return v((a.parentNode || {}).firstChild, a)
  763. }, children: function (a) {
  764. return v(a.firstChild)
  765. }, contents: function (a) {
  766. return a.contentDocument || n.merge([], a.childNodes)
  767. }
  768. }, function (a, b) {
  769. n.fn[a] = function (c, d) {
  770. var e = n.map(this, b, c);
  771. return "Until" !== a.slice(-5) && (d = c), d && "string" == typeof d && (e = n.filter(d, e)), this.length > 1 && (E[a] || n.uniqueSort(e), D.test(a) && e.reverse()), this.pushStack(e)
  772. }
  773. });
  774. var G = /\S+/g;
  775. function H(a) {
  776. var b = {};
  777. return n.each(a.match(G) || [], function (a, c) {
  778. b[c] = !0
  779. }), b
  780. }
  781. n.Callbacks = function (a) {
  782. a = "string" == typeof a ? H(a) : n.extend({}, a);
  783. var b, c, d, e, f = [], g = [], h = -1, i = function () {
  784. for (e = a.once, d = b = !0; g.length; h = -1) {
  785. c = g.shift();
  786. while (++h < f.length) f[h].apply(c[0], c[1]) === !1 && a.stopOnFalse && (h = f.length, c = !1)
  787. }
  788. a.memory || (c = !1), b = !1, e && (f = c ? [] : "")
  789. }, j = {
  790. add: function () {
  791. return f && (c && !b && (h = f.length - 1, g.push(c)), function d(b) {
  792. n.each(b, function (b, c) {
  793. n.isFunction(c) ? a.unique && j.has(c) || f.push(c) : c && c.length && "string" !== n.type(c) && d(c)
  794. })
  795. }(arguments), c && !b && i()), this
  796. }, remove: function () {
  797. return n.each(arguments, function (a, b) {
  798. var c;
  799. while ((c = n.inArray(b, f, c)) > -1) f.splice(c, 1), h >= c && h--
  800. }), this
  801. }, has: function (a) {
  802. return a ? n.inArray(a, f) > -1 : f.length > 0
  803. }, empty: function () {
  804. return f && (f = []), this
  805. }, disable: function () {
  806. return e = g = [], f = c = "", this
  807. }, disabled: function () {
  808. return !f
  809. }, lock: function () {
  810. return e = g = [], c || (f = c = ""), this
  811. }, locked: function () {
  812. return !!e
  813. }, fireWith: function (a, c) {
  814. return e || (c = c || [], c = [a, c.slice ? c.slice() : c], g.push(c), b || i()), this
  815. }, fire: function () {
  816. return j.fireWith(this, arguments), this
  817. }, fired: function () {
  818. return !!d
  819. }
  820. };
  821. return j
  822. }, n.extend({
  823. Deferred: function (a) {
  824. var b = [["resolve", "done", n.Callbacks("once memory"), "resolved"], ["reject", "fail", n.Callbacks("once memory"), "rejected"], ["notify", "progress", n.Callbacks("memory")]],
  825. c = "pending", d = {
  826. state: function () {
  827. return c
  828. }, always: function () {
  829. return e.done(arguments).fail(arguments), this
  830. }, then: function () {
  831. var a = arguments;
  832. return n.Deferred(function (c) {
  833. n.each(b, function (b, f) {
  834. var g = n.isFunction(a[b]) && a[b];
  835. e[f[1]](function () {
  836. var a = g && g.apply(this, arguments);
  837. a && n.isFunction(a.promise) ? a.promise().progress(c.notify).done(c.resolve).fail(c.reject) : c[f[0] + "With"](this === d ? c.promise() : this, g ? [a] : arguments)
  838. })
  839. }), a = null
  840. }).promise()
  841. }, promise: function (a) {
  842. return null != a ? n.extend(a, d) : d
  843. }
  844. }, e = {};
  845. return d.pipe = d.then, n.each(b, function (a, f) {
  846. var g = f[2], h = f[3];
  847. d[f[1]] = g.add, h && g.add(function () {
  848. c = h
  849. }, b[1 ^ a][2].disable, b[2][2].lock), e[f[0]] = function () {
  850. return e[f[0] + "With"](this === e ? d : this, arguments), this
  851. }, e[f[0] + "With"] = g.fireWith
  852. }), d.promise(e), a && a.call(e, e), e
  853. }, when: function (a) {
  854. var b = 0, c = e.call(arguments), d = c.length, f = 1 !== d || a && n.isFunction(a.promise) ? d : 0,
  855. g = 1 === f ? a : n.Deferred(), h = function (a, b, c) {
  856. return function (d) {
  857. b[a] = this, c[a] = arguments.length > 1 ? e.call(arguments) : d, c === i ? g.notifyWith(b, c) : --f || g.resolveWith(b, c)
  858. }
  859. }, i, j, k;
  860. if (d > 1) for (i = new Array(d), j = new Array(d), k = new Array(d); d > b; b++) c[b] && n.isFunction(c[b].promise) ? c[b].promise().progress(h(b, j, i)).done(h(b, k, c)).fail(g.reject) : --f;
  861. return f || g.resolveWith(k, c), g.promise()
  862. }
  863. });
  864. var I;
  865. n.fn.ready = function (a) {
  866. return n.ready.promise().done(a), this
  867. }, n.extend({
  868. isReady: !1, readyWait: 1, holdReady: function (a) {
  869. a ? n.readyWait++ : n.ready(!0)
  870. }, ready: function (a) {
  871. (a === !0 ? --n.readyWait : n.isReady) || (n.isReady = !0, a !== !0 && --n.readyWait > 0 || (I.resolveWith(d, [n]), n.fn.triggerHandler && (n(d).triggerHandler("ready"), n(d).off("ready"))))
  872. }
  873. });
  874. function J() {
  875. d.removeEventListener("DOMContentLoaded", J), a.removeEventListener("load", J), n.ready()
  876. }
  877. n.ready.promise = function (b) {
  878. return I || (I = n.Deferred(), "complete" === d.readyState || "loading" !== d.readyState && !d.documentElement.doScroll ? a.setTimeout(n.ready) : (d.addEventListener("DOMContentLoaded", J), a.addEventListener("load", J))), I.promise(b)
  879. }, n.ready.promise();
  880. var K = function (a, b, c, d, e, f, g) {
  881. var h = 0, i = a.length, j = null == c;
  882. if ("object" === n.type(c)) {
  883. e = !0;
  884. for (h in c) K(a, b, h, c[h], !0, f, g)
  885. } else if (void 0 !== d && (e = !0, n.isFunction(d) || (g = !0), j && (g ? (b.call(a, d), b = null) : (j = b, b = function (a, b, c) {
  886. return j.call(n(a), c)
  887. })), b)) for (; i > h; h++) b(a[h], c, g ? d : d.call(a[h], h, b(a[h], c)));
  888. return e ? a : j ? b.call(a) : i ? b(a[0], c) : f
  889. }, L = function (a) {
  890. return 1 === a.nodeType || 9 === a.nodeType || !+a.nodeType
  891. };
  892. function M() {
  893. this.expando = n.expando + M.uid++
  894. }
  895. M.uid = 1, M.prototype = {
  896. register: function (a, b) {
  897. var c = b || {};
  898. return a.nodeType ? a[this.expando] = c : Object.defineProperty(a, this.expando, {
  899. value: c,
  900. writable: !0,
  901. configurable: !0
  902. }), a[this.expando]
  903. }, cache: function (a) {
  904. if (!L(a)) return {};
  905. var b = a[this.expando];
  906. return b || (b = {}, L(a) && (a.nodeType ? a[this.expando] = b : Object.defineProperty(a, this.expando, {
  907. value: b,
  908. configurable: !0
  909. }))), b
  910. }, set: function (a, b, c) {
  911. var d, e = this.cache(a);
  912. if ("string" == typeof b) e[b] = c; else for (d in b) e[d] = b[d];
  913. return e
  914. }, get: function (a, b) {
  915. return void 0 === b ? this.cache(a) : a[this.expando] && a[this.expando][b]
  916. }, access: function (a, b, c) {
  917. var d;
  918. return void 0 === b || b && "string" == typeof b && void 0 === c ? (d = this.get(a, b), void 0 !== d ? d : this.get(a, n.camelCase(b))) : (this.set(a, b, c), void 0 !== c ? c : b)
  919. }, remove: function (a, b) {
  920. var c, d, e, f = a[this.expando];
  921. if (void 0 !== f) {
  922. if (void 0 === b) this.register(a); else {
  923. n.isArray(b) ? d = b.concat(b.map(n.camelCase)) : (e = n.camelCase(b), b in f ? d = [b, e] : (d = e, d = d in f ? [d] : d.match(G) || [])), c = d.length;
  924. while (c--) delete f[d[c]]
  925. }
  926. (void 0 === b || n.isEmptyObject(f)) && (a.nodeType ? a[this.expando] = void 0 : delete a[this.expando])
  927. }
  928. }, hasData: function (a) {
  929. var b = a[this.expando];
  930. return void 0 !== b && !n.isEmptyObject(b)
  931. }
  932. };
  933. var N = new M, O = new M, P = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, Q = /[A-Z]/g;
  934. function R(a, b, c) {
  935. var d;
  936. if (void 0 === c && 1 === a.nodeType) if (d = "data-" + b.replace(Q, "-$&").toLowerCase(), c = a.getAttribute(d), "string" == typeof c) {
  937. try {
  938. c = "true" === c ? !0 : "false" === c ? !1 : "null" === c ? null : +c + "" === c ? +c : P.test(c) ? n.parseJSON(c) : c;
  939. } catch (e) {
  940. }
  941. O.set(a, b, c)
  942. } else c = void 0;
  943. return c
  944. }
  945. n.extend({
  946. hasData: function (a) {
  947. return O.hasData(a) || N.hasData(a)
  948. }, data: function (a, b, c) {
  949. return O.access(a, b, c)
  950. }, removeData: function (a, b) {
  951. O.remove(a, b)
  952. }, _data: function (a, b, c) {
  953. return N.access(a, b, c)
  954. }, _removeData: function (a, b) {
  955. N.remove(a, b)
  956. }
  957. }), n.fn.extend({
  958. data: function (a, b) {
  959. var c, d, e, f = this[0], g = f && f.attributes;
  960. if (void 0 === a) {
  961. if (this.length && (e = O.get(f), 1 === f.nodeType && !N.get(f, "hasDataAttrs"))) {
  962. c = g.length;
  963. while (c--) g[c] && (d = g[c].name, 0 === d.indexOf("data-") && (d = n.camelCase(d.slice(5)), R(f, d, e[d])));
  964. N.set(f, "hasDataAttrs", !0)
  965. }
  966. return e
  967. }
  968. return "object" == typeof a ? this.each(function () {
  969. O.set(this, a)
  970. }) : K(this, function (b) {
  971. var c, d;
  972. if (f && void 0 === b) {
  973. if (c = O.get(f, a) || O.get(f, a.replace(Q, "-$&").toLowerCase()), void 0 !== c) return c;
  974. if (d = n.camelCase(a), c = O.get(f, d), void 0 !== c) return c;
  975. if (c = R(f, d, void 0), void 0 !== c) return c
  976. } else d = n.camelCase(a), this.each(function () {
  977. var c = O.get(this, d);
  978. O.set(this, d, b), a.indexOf("-") > -1 && void 0 !== c && O.set(this, a, b)
  979. })
  980. }, null, b, arguments.length > 1, null, !0)
  981. }, removeData: function (a) {
  982. return this.each(function () {
  983. O.remove(this, a)
  984. })
  985. }
  986. }), n.extend({
  987. queue: function (a, b, c) {
  988. var d;
  989. return a ? (b = (b || "fx") + "queue", d = N.get(a, b), c && (!d || n.isArray(c) ? d = N.access(a, b, n.makeArray(c)) : d.push(c)), d || []) : void 0
  990. }, dequeue: function (a, b) {
  991. b = b || "fx";
  992. var c = n.queue(a, b), d = c.length, e = c.shift(), f = n._queueHooks(a, b), g = function () {
  993. n.dequeue(a, b)
  994. };
  995. "inprogress" === e && (e = c.shift(), d--), e && ("fx" === b && c.unshift("inprogress"), delete f.stop, e.call(a, g, f)), !d && f && f.empty.fire()
  996. }, _queueHooks: function (a, b) {
  997. var c = b + "queueHooks";
  998. return N.get(a, c) || N.access(a, c, {
  999. empty: n.Callbacks("once memory").add(function () {
  1000. N.remove(a, [b + "queue", c])
  1001. })
  1002. })
  1003. }
  1004. }), n.fn.extend({
  1005. queue: function (a, b) {
  1006. var c = 2;
  1007. return "string" != typeof a && (b = a, a = "fx", c--), arguments.length < c ? n.queue(this[0], a) : void 0 === b ? this : this.each(function () {
  1008. var c = n.queue(this, a, b);
  1009. n._queueHooks(this, a), "fx" === a && "inprogress" !== c[0] && n.dequeue(this, a)
  1010. })
  1011. }, dequeue: function (a) {
  1012. return this.each(function () {
  1013. n.dequeue(this, a)
  1014. })
  1015. }, clearQueue: function (a) {
  1016. return this.queue(a || "fx", [])
  1017. }, promise: function (a, b) {
  1018. var c, d = 1, e = n.Deferred(), f = this, g = this.length, h = function () {
  1019. --d || e.resolveWith(f, [f])
  1020. };
  1021. "string" != typeof a && (b = a, a = void 0), a = a || "fx";
  1022. while (g--) c = N.get(f[g], a + "queueHooks"), c && c.empty && (d++, c.empty.add(h));
  1023. return h(), e.promise(b)
  1024. }
  1025. });
  1026. var S = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source, T = new RegExp("^(?:([+-])=|)(" + S + ")([a-z%]*)$", "i"),
  1027. U = ["Top", "Right", "Bottom", "Left"], V = function (a, b) {
  1028. return a = b || a, "none" === n.css(a, "display") || !n.contains(a.ownerDocument, a)
  1029. };
  1030. function W(a, b, c, d) {
  1031. var e, f = 1, g = 20, h = d ? function () {
  1032. return d.cur()
  1033. } : function () {
  1034. return n.css(a, b, "")
  1035. }, i = h(), j = c && c[3] || (n.cssNumber[b] ? "" : "px"),
  1036. k = (n.cssNumber[b] || "px" !== j && +i) && T.exec(n.css(a, b));
  1037. if (k && k[3] !== j) {
  1038. j = j || k[3], c = c || [], k = +i || 1;
  1039. do f = f || ".5", k /= f, n.style(a, b, k + j); while (f !== (f = h() / i) && 1 !== f && --g)
  1040. }
  1041. return c && (k = +k || +i || 0, e = c[1] ? k + (c[1] + 1) * c[2] : +c[2], d && (d.unit = j, d.start = k, d.end = e)), e
  1042. }
  1043. var X = /^(?:checkbox|radio)$/i, Y = /<([\w:-]+)/, Z = /^$|\/(?:java|ecma)script/i, $ = {
  1044. option: [1, "<select multiple='multiple'>", "</select>"],
  1045. thead: [1, "<table>", "</table>"],
  1046. col: [2, "<table><colgroup>", "</colgroup></table>"],
  1047. tr: [2, "<table><tbody>", "</tbody></table>"],
  1048. td: [3, "<table><tbody><tr>", "</tr></tbody></table>"],
  1049. _default: [0, "", ""]
  1050. };
  1051. $.optgroup = $.option, $.tbody = $.tfoot = $.colgroup = $.caption = $.thead, $.th = $.td;
  1052. function _(a, b) {
  1053. var c = "undefined" != typeof a.getElementsByTagName ? a.getElementsByTagName(b || "*") : "undefined" != typeof a.querySelectorAll ? a.querySelectorAll(b || "*") : [];
  1054. return void 0 === b || b && n.nodeName(a, b) ? n.merge([a], c) : c
  1055. }
  1056. function aa(a, b) {
  1057. for (var c = 0, d = a.length; d > c; c++) N.set(a[c], "globalEval", !b || N.get(b[c], "globalEval"))
  1058. }
  1059. var ba = /<|&#?\w+;/;
  1060. function ca(a, b, c, d, e) {
  1061. for (var f, g, h, i, j, k, l = b.createDocumentFragment(), m = [], o = 0, p = a.length; p > o; o++) if (f = a[o], f || 0 === f) if ("object" === n.type(f)) n.merge(m, f.nodeType ? [f] : f); else if (ba.test(f)) {
  1062. g = g || l.appendChild(b.createElement("div")), h = (Y.exec(f) || ["", ""])[1].toLowerCase(), i = $[h] || $._default, g.innerHTML = i[1] + n.htmlPrefilter(f) + i[2], k = i[0];
  1063. while (k--) g = g.lastChild;
  1064. n.merge(m, g.childNodes), g = l.firstChild, g.textContent = ""
  1065. } else m.push(b.createTextNode(f));
  1066. l.textContent = "", o = 0;
  1067. while (f = m[o++]) if (d && n.inArray(f, d) > -1) e && e.push(f); else if (j = n.contains(f.ownerDocument, f), g = _(l.appendChild(f), "script"), j && aa(g), c) {
  1068. k = 0;
  1069. while (f = g[k++]) Z.test(f.type || "") && c.push(f)
  1070. }
  1071. return l
  1072. }
  1073. !function () {
  1074. var a = d.createDocumentFragment(), b = a.appendChild(d.createElement("div")), c = d.createElement("input");
  1075. c.setAttribute("type", "radio"), c.setAttribute("checked", "checked"), c.setAttribute("name", "t"), b.appendChild(c), l.checkClone = b.cloneNode(!0).cloneNode(!0).lastChild.checked, b.innerHTML = "<textarea>x</textarea>", l.noCloneChecked = !!b.cloneNode(!0).lastChild.defaultValue
  1076. }();
  1077. var da = /^key/, ea = /^(?:mouse|pointer|contextmenu|drag|drop)|click/, fa = /^([^.]*)(?:\.(.+)|)/;
  1078. function ga() {
  1079. return !0
  1080. }
  1081. function ha() {
  1082. return !1
  1083. }
  1084. function ia() {
  1085. try {
  1086. return d.activeElement
  1087. } catch (a) {
  1088. }
  1089. }
  1090. function ja(a, b, c, d, e, f) {
  1091. var g, h;
  1092. if ("object" == typeof b) {
  1093. "string" != typeof c && (d = d || c, c = void 0);
  1094. for (h in b) ja(a, h, c, d, b[h], f);
  1095. return a
  1096. }
  1097. if (null == d && null == e ? (e = c, d = c = void 0) : null == e && ("string" == typeof c ? (e = d, d = void 0) : (e = d, d = c, c = void 0)), e === !1) e = ha; else if (!e) return a;
  1098. return 1 === f && (g = e, e = function (a) {
  1099. return n().off(a), g.apply(this, arguments)
  1100. }, e.guid = g.guid || (g.guid = n.guid++)), a.each(function () {
  1101. n.event.add(this, b, e, d, c)
  1102. })
  1103. }
  1104. n.event = {
  1105. global: {},
  1106. add: function (a, b, c, d, e) {
  1107. var f, g, h, i, j, k, l, m, o, p, q, r = N.get(a);
  1108. if (r) {
  1109. c.handler && (f = c, c = f.handler, e = f.selector), c.guid || (c.guid = n.guid++), (i = r.events) || (i = r.events = {}), (g = r.handle) || (g = r.handle = function (b) {
  1110. return "undefined" != typeof n && n.event.triggered !== b.type ? n.event.dispatch.apply(a, arguments) : void 0
  1111. }), b = (b || "").match(G) || [""], j = b.length;
  1112. while (j--) h = fa.exec(b[j]) || [], o = q = h[1], p = (h[2] || "").split(".").sort(), o && (l = n.event.special[o] || {}, o = (e ? l.delegateType : l.bindType) || o, l = n.event.special[o] || {}, k = n.extend({
  1113. type: o,
  1114. origType: q,
  1115. data: d,
  1116. handler: c,
  1117. guid: c.guid,
  1118. selector: e,
  1119. needsContext: e && n.expr.match.needsContext.test(e),
  1120. namespace: p.join(".")
  1121. }, f), (m = i[o]) || (m = i[o] = [], m.delegateCount = 0, l.setup && l.setup.call(a, d, p, g) !== !1 || a.addEventListener && a.addEventListener(o, g)), l.add && (l.add.call(a, k), k.handler.guid || (k.handler.guid = c.guid)), e ? m.splice(m.delegateCount++, 0, k) : m.push(k), n.event.global[o] = !0)
  1122. }
  1123. },
  1124. remove: function (a, b, c, d, e) {
  1125. var f, g, h, i, j, k, l, m, o, p, q, r = N.hasData(a) && N.get(a);
  1126. if (r && (i = r.events)) {
  1127. b = (b || "").match(G) || [""], j = b.length;
  1128. while (j--) if (h = fa.exec(b[j]) || [], o = q = h[1], p = (h[2] || "").split(".").sort(), o) {
  1129. l = n.event.special[o] || {}, o = (d ? l.delegateType : l.bindType) || o, m = i[o] || [], h = h[2] && new RegExp("(^|\\.)" + p.join("\\.(?:.*\\.|)") + "(\\.|$)"), g = f = m.length;
  1130. while (f--) k = m[f], !e && q !== k.origType || c && c.guid !== k.guid || h && !h.test(k.namespace) || d && d !== k.selector && ("**" !== d || !k.selector) || (m.splice(f, 1), k.selector && m.delegateCount--, l.remove && l.remove.call(a, k));
  1131. g && !m.length && (l.teardown && l.teardown.call(a, p, r.handle) !== !1 || n.removeEvent(a, o, r.handle), delete i[o])
  1132. } else for (o in i) n.event.remove(a, o + b[j], c, d, !0);
  1133. n.isEmptyObject(i) && N.remove(a, "handle events")
  1134. }
  1135. },
  1136. dispatch: function (a) {
  1137. a = n.event.fix(a);
  1138. var b, c, d, f, g, h = [], i = e.call(arguments), j = (N.get(this, "events") || {})[a.type] || [],
  1139. k = n.event.special[a.type] || {};
  1140. if (i[0] = a, a.delegateTarget = this, !k.preDispatch || k.preDispatch.call(this, a) !== !1) {
  1141. h = n.event.handlers.call(this, a, j), b = 0;
  1142. while ((f = h[b++]) && !a.isPropagationStopped()) {
  1143. a.currentTarget = f.elem, c = 0;
  1144. while ((g = f.handlers[c++]) && !a.isImmediatePropagationStopped()) a.rnamespace && !a.rnamespace.test(g.namespace) || (a.handleObj = g, a.data = g.data, d = ((n.event.special[g.origType] || {}).handle || g.handler).apply(f.elem, i), void 0 !== d && (a.result = d) === !1 && (a.preventDefault(), a.stopPropagation()))
  1145. }
  1146. return k.postDispatch && k.postDispatch.call(this, a), a.result
  1147. }
  1148. },
  1149. handlers: function (a, b) {
  1150. var c, d, e, f, g = [], h = b.delegateCount, i = a.target;
  1151. if (h && i.nodeType && ("click" !== a.type || isNaN(a.button) || a.button < 1)) for (; i !== this; i = i.parentNode || this) if (1 === i.nodeType && (i.disabled !== !0 || "click" !== a.type)) {
  1152. for (d = [], c = 0; h > c; c++) f = b[c], e = f.selector + " ", void 0 === d[e] && (d[e] = f.needsContext ? n(e, this).index(i) > -1 : n.find(e, this, null, [i]).length), d[e] && d.push(f);
  1153. d.length && g.push({elem: i, handlers: d})
  1154. }
  1155. return h < b.length && g.push({elem: this, handlers: b.slice(h)}), g
  1156. },
  1157. props: "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
  1158. fixHooks: {},
  1159. keyHooks: {
  1160. props: "char charCode key keyCode".split(" "), filter: function (a, b) {
  1161. return null == a.which && (a.which = null != b.charCode ? b.charCode : b.keyCode), a
  1162. }
  1163. },
  1164. mouseHooks: {
  1165. props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
  1166. filter: function (a, b) {
  1167. var c, e, f, g = b.button;
  1168. return null == a.pageX && null != b.clientX && (c = a.target.ownerDocument || d, e = c.documentElement, f = c.body, a.pageX = b.clientX + (e && e.scrollLeft || f && f.scrollLeft || 0) - (e && e.clientLeft || f && f.clientLeft || 0), a.pageY = b.clientY + (e && e.scrollTop || f && f.scrollTop || 0) - (e && e.clientTop || f && f.clientTop || 0)), a.which || void 0 === g || (a.which = 1 & g ? 1 : 2 & g ? 3 : 4 & g ? 2 : 0), a
  1169. }
  1170. },
  1171. fix: function (a) {
  1172. if (a[n.expando]) return a;
  1173. var b, c, e, f = a.type, g = a, h = this.fixHooks[f];
  1174. h || (this.fixHooks[f] = h = ea.test(f) ? this.mouseHooks : da.test(f) ? this.keyHooks : {}), e = h.props ? this.props.concat(h.props) : this.props, a = new n.Event(g), b = e.length;
  1175. while (b--) c = e[b], a[c] = g[c];
  1176. return a.target || (a.target = d), 3 === a.target.nodeType && (a.target = a.target.parentNode), h.filter ? h.filter(a, g) : a
  1177. },
  1178. special: {
  1179. load: {noBubble: !0}, focus: {
  1180. trigger: function () {
  1181. return this !== ia() && this.focus ? (this.focus(), !1) : void 0
  1182. }, delegateType: "focusin"
  1183. }, blur: {
  1184. trigger: function () {
  1185. return this === ia() && this.blur ? (this.blur(), !1) : void 0
  1186. }, delegateType: "focusout"
  1187. }, click: {
  1188. trigger: function () {
  1189. return "checkbox" === this.type && this.click && n.nodeName(this, "input") ? (this.click(), !1) : void 0
  1190. }, _default: function (a) {
  1191. return n.nodeName(a.target, "a")
  1192. }
  1193. }, beforeunload: {
  1194. postDispatch: function (a) {
  1195. void 0 !== a.result && a.originalEvent && (a.originalEvent.returnValue = a.result)
  1196. }
  1197. }
  1198. }
  1199. }, n.removeEvent = function (a, b, c) {
  1200. a.removeEventListener && a.removeEventListener(b, c)
  1201. }, n.Event = function (a, b) {
  1202. return this instanceof n.Event ? (a && a.type ? (this.originalEvent = a, this.type = a.type, this.isDefaultPrevented = a.defaultPrevented || void 0 === a.defaultPrevented && a.returnValue === !1 ? ga : ha) : this.type = a, b && n.extend(this, b), this.timeStamp = a && a.timeStamp || n.now(), void (this[n.expando] = !0)) : new n.Event(a, b)
  1203. }, n.Event.prototype = {
  1204. constructor: n.Event,
  1205. isDefaultPrevented: ha,
  1206. isPropagationStopped: ha,
  1207. isImmediatePropagationStopped: ha,
  1208. isSimulated: !1,
  1209. preventDefault: function () {
  1210. var a = this.originalEvent;
  1211. this.isDefaultPrevented = ga, a && !this.isSimulated && a.preventDefault()
  1212. },
  1213. stopPropagation: function () {
  1214. var a = this.originalEvent;
  1215. this.isPropagationStopped = ga, a && !this.isSimulated && a.stopPropagation()
  1216. },
  1217. stopImmediatePropagation: function () {
  1218. var a = this.originalEvent;
  1219. this.isImmediatePropagationStopped = ga, a && !this.isSimulated && a.stopImmediatePropagation(), this.stopPropagation()
  1220. }
  1221. }, n.each({
  1222. mouseenter: "mouseover",
  1223. mouseleave: "mouseout",
  1224. pointerenter: "pointerover",
  1225. pointerleave: "pointerout"
  1226. }, function (a, b) {
  1227. n.event.special[a] = {
  1228. delegateType: b, bindType: b, handle: function (a) {
  1229. var c, d = this, e = a.relatedTarget, f = a.handleObj;
  1230. return e && (e === d || n.contains(d, e)) || (a.type = f.origType, c = f.handler.apply(this, arguments), a.type = b), c
  1231. }
  1232. }
  1233. }), n.fn.extend({
  1234. on: function (a, b, c, d) {
  1235. return ja(this, a, b, c, d)
  1236. }, one: function (a, b, c, d) {
  1237. return ja(this, a, b, c, d, 1)
  1238. }, off: function (a, b, c) {
  1239. var d, e;
  1240. if (a && a.preventDefault && a.handleObj) return d = a.handleObj, n(a.delegateTarget).off(d.namespace ? d.origType + "." + d.namespace : d.origType, d.selector, d.handler), this;
  1241. if ("object" == typeof a) {
  1242. for (e in a) this.off(e, b, a[e]);
  1243. return this
  1244. }
  1245. return b !== !1 && "function" != typeof b || (c = b, b = void 0), c === !1 && (c = ha), this.each(function () {
  1246. n.event.remove(this, a, c, b)
  1247. })
  1248. }
  1249. });
  1250. var ka = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi, la = /<script|<style|<link/i,
  1251. ma = /checked\s*(?:[^=]|=\s*.checked.)/i, na = /^true\/(.*)/, oa = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  1252. function pa(a, b) {
  1253. return n.nodeName(a, "table") && n.nodeName(11 !== b.nodeType ? b : b.firstChild, "tr") ? a.getElementsByTagName("tbody")[0] || a.appendChild(a.ownerDocument.createElement("tbody")) : a
  1254. }
  1255. function qa(a) {
  1256. return a.type = (null !== a.getAttribute("type")) + "/" + a.type, a
  1257. }
  1258. function ra(a) {
  1259. var b = na.exec(a.type);
  1260. return b ? a.type = b[1] : a.removeAttribute("type"), a
  1261. }
  1262. function sa(a, b) {
  1263. var c, d, e, f, g, h, i, j;
  1264. if (1 === b.nodeType) {
  1265. if (N.hasData(a) && (f = N.access(a), g = N.set(b, f), j = f.events)) {
  1266. delete g.handle, g.events = {};
  1267. for (e in j) for (c = 0, d = j[e].length; d > c; c++) n.event.add(b, e, j[e][c])
  1268. }
  1269. O.hasData(a) && (h = O.access(a), i = n.extend({}, h), O.set(b, i))
  1270. }
  1271. }
  1272. function ta(a, b) {
  1273. var c = b.nodeName.toLowerCase();
  1274. "input" === c && X.test(a.type) ? b.checked = a.checked : "input" !== c && "textarea" !== c || (b.defaultValue = a.defaultValue)
  1275. }
  1276. function ua(a, b, c, d) {
  1277. b = f.apply([], b);
  1278. var e, g, h, i, j, k, m = 0, o = a.length, p = o - 1, q = b[0], r = n.isFunction(q);
  1279. if (r || o > 1 && "string" == typeof q && !l.checkClone && ma.test(q)) return a.each(function (e) {
  1280. var f = a.eq(e);
  1281. r && (b[0] = q.call(this, e, f.html())), ua(f, b, c, d)
  1282. });
  1283. if (o && (e = ca(b, a[0].ownerDocument, !1, a, d), g = e.firstChild, 1 === e.childNodes.length && (e = g), g || d)) {
  1284. for (h = n.map(_(e, "script"), qa), i = h.length; o > m; m++) j = e, m !== p && (j = n.clone(j, !0, !0), i && n.merge(h, _(j, "script"))), c.call(a[m], j, m);
  1285. if (i) for (k = h[h.length - 1].ownerDocument, n.map(h, ra), m = 0; i > m; m++) j = h[m], Z.test(j.type || "") && !N.access(j, "globalEval") && n.contains(k, j) && (j.src ? n._evalUrl && n._evalUrl(j.src) : n.globalEval(j.textContent.replace(oa, "")))
  1286. }
  1287. return a
  1288. }
  1289. function va(a, b, c) {
  1290. for (var d, e = b ? n.filter(b, a) : a, f = 0; null != (d = e[f]); f++) c || 1 !== d.nodeType || n.cleanData(_(d)), d.parentNode && (c && n.contains(d.ownerDocument, d) && aa(_(d, "script")), d.parentNode.removeChild(d));
  1291. return a
  1292. }
  1293. n.extend({
  1294. htmlPrefilter: function (a) {
  1295. return a.replace(ka, "<$1></$2>")
  1296. }, clone: function (a, b, c) {
  1297. var d, e, f, g, h = a.cloneNode(!0), i = n.contains(a.ownerDocument, a);
  1298. if (!(l.noCloneChecked || 1 !== a.nodeType && 11 !== a.nodeType || n.isXMLDoc(a))) for (g = _(h), f = _(a), d = 0, e = f.length; e > d; d++) ta(f[d], g[d]);
  1299. if (b) if (c) for (f = f || _(a), g = g || _(h), d = 0, e = f.length; e > d; d++) sa(f[d], g[d]); else sa(a, h);
  1300. return g = _(h, "script"), g.length > 0 && aa(g, !i && _(a, "script")), h
  1301. }, cleanData: function (a) {
  1302. for (var b, c, d, e = n.event.special, f = 0; void 0 !== (c = a[f]); f++) if (L(c)) {
  1303. if (b = c[N.expando]) {
  1304. if (b.events) for (d in b.events) e[d] ? n.event.remove(c, d) : n.removeEvent(c, d, b.handle);
  1305. c[N.expando] = void 0
  1306. }
  1307. c[O.expando] && (c[O.expando] = void 0)
  1308. }
  1309. }
  1310. }), n.fn.extend({
  1311. domManip: ua, detach: function (a) {
  1312. return va(this, a, !0)
  1313. }, remove: function (a) {
  1314. return va(this, a)
  1315. }, text: function (a) {
  1316. return K(this, function (a) {
  1317. return void 0 === a ? n.text(this) : this.empty().each(function () {
  1318. 1 !== this.nodeType && 11 !== this.nodeType && 9 !== this.nodeType || (this.textContent = a)
  1319. })
  1320. }, null, a, arguments.length)
  1321. }, append: function () {
  1322. return ua(this, arguments, function (a) {
  1323. if (1 === this.nodeType || 11 === this.nodeType || 9 === this.nodeType) {
  1324. var b = pa(this, a);
  1325. b.appendChild(a)
  1326. }
  1327. })
  1328. }, prepend: function () {
  1329. return ua(this, arguments, function (a) {
  1330. if (1 === this.nodeType || 11 === this.nodeType || 9 === this.nodeType) {
  1331. var b = pa(this, a);
  1332. b.insertBefore(a, b.firstChild)
  1333. }
  1334. })
  1335. }, before: function () {
  1336. return ua(this, arguments, function (a) {
  1337. this.parentNode && this.parentNode.insertBefore(a, this)
  1338. })
  1339. }, after: function () {
  1340. return ua(this, arguments, function (a) {
  1341. this.parentNode && this.parentNode.insertBefore(a, this.nextSibling)
  1342. })
  1343. }, empty: function () {
  1344. for (var a, b = 0; null != (a = this[b]); b++) 1 === a.nodeType && (n.cleanData(_(a, !1)), a.textContent = "");
  1345. return this
  1346. }, clone: function (a, b) {
  1347. return a = null == a ? !1 : a, b = null == b ? a : b, this.map(function () {
  1348. return n.clone(this, a, b)
  1349. })
  1350. }, html: function (a) {
  1351. return K(this, function (a) {
  1352. var b = this[0] || {}, c = 0, d = this.length;
  1353. if (void 0 === a && 1 === b.nodeType) return b.innerHTML;
  1354. if ("string" == typeof a && !la.test(a) && !$[(Y.exec(a) || ["", ""])[1].toLowerCase()]) {
  1355. a = n.htmlPrefilter(a);
  1356. try {
  1357. for (; d > c; c++) b = this[c] || {}, 1 === b.nodeType && (n.cleanData(_(b, !1)), b.innerHTML = a);
  1358. b = 0
  1359. } catch (e) {
  1360. }
  1361. }
  1362. b && this.empty().append(a)
  1363. }, null, a, arguments.length)
  1364. }, replaceWith: function () {
  1365. var a = [];
  1366. return ua(this, arguments, function (b) {
  1367. var c = this.parentNode;
  1368. n.inArray(this, a) < 0 && (n.cleanData(_(this)), c && c.replaceChild(b, this))
  1369. }, a)
  1370. }
  1371. }), n.each({
  1372. appendTo: "append",
  1373. prependTo: "prepend",
  1374. insertBefore: "before",
  1375. insertAfter: "after",
  1376. replaceAll: "replaceWith"
  1377. }, function (a, b) {
  1378. n.fn[a] = function (a) {
  1379. for (var c, d = [], e = n(a), f = e.length - 1, h = 0; f >= h; h++) c = h === f ? this : this.clone(!0), n(e[h])[b](c), g.apply(d, c.get());
  1380. return this.pushStack(d)
  1381. }
  1382. });
  1383. var wa, xa = {HTML: "block", BODY: "block"};
  1384. function ya(a, b) {
  1385. var c = n(b.createElement(a)).appendTo(b.body), d = n.css(c[0], "display");
  1386. return c.detach(), d
  1387. }
  1388. function za(a) {
  1389. var b = d, c = xa[a];
  1390. return c || (c = ya(a, b), "none" !== c && c || (wa = (wa || n("<iframe frameborder='0' width='0' height='0'/>")).appendTo(b.documentElement), b = wa[0].contentDocument, b.write(), b.close(), c = ya(a, b), wa.detach()), xa[a] = c), c
  1391. }
  1392. var Aa = /^margin/, Ba = new RegExp("^(" + S + ")(?!px)[a-z%]+$", "i"), Ca = function (b) {
  1393. var c = b.ownerDocument.defaultView;
  1394. return c && c.opener || (c = a), c.getComputedStyle(b)
  1395. }, Da = function (a, b, c, d) {
  1396. var e, f, g = {};
  1397. for (f in b) g[f] = a.style[f], a.style[f] = b[f];
  1398. e = c.apply(a, d || []);
  1399. for (f in b) a.style[f] = g[f];
  1400. return e
  1401. }, Ea = d.documentElement;
  1402. !function () {
  1403. var b, c, e, f, g = d.createElement("div"), h = d.createElement("div");
  1404. if (h.style) {
  1405. h.style.backgroundClip = "content-box", h.cloneNode(!0).style.backgroundClip = "", l.clearCloneStyle = "content-box" === h.style.backgroundClip, g.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;padding:0;margin-top:1px;position:absolute", g.appendChild(h);
  1406. function i() {
  1407. h.style.cssText = "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:relative;display:block;margin:auto;border:1px;padding:1px;top:1%;width:50%", h.innerHTML = "", Ea.appendChild(g);
  1408. var d = a.getComputedStyle(h);
  1409. b = "1%" !== d.top, f = "2px" === d.marginLeft, c = "4px" === d.width, h.style.marginRight = "50%", e = "4px" === d.marginRight, Ea.removeChild(g)
  1410. }
  1411. n.extend(l, {
  1412. pixelPosition: function () {
  1413. return i(), b
  1414. }, boxSizingReliable: function () {
  1415. return null == c && i(), c
  1416. }, pixelMarginRight: function () {
  1417. return null == c && i(), e
  1418. }, reliableMarginLeft: function () {
  1419. return null == c && i(), f
  1420. }, reliableMarginRight: function () {
  1421. var b, c = h.appendChild(d.createElement("div"));
  1422. return c.style.cssText = h.style.cssText = "-webkit-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0", c.style.marginRight = c.style.width = "0", h.style.width = "1px", Ea.appendChild(g), b = !parseFloat(a.getComputedStyle(c).marginRight), Ea.removeChild(g), h.removeChild(c), b
  1423. }
  1424. })
  1425. }
  1426. }();
  1427. function Fa(a, b, c) {
  1428. var d, e, f, g, h = a.style;
  1429. return c = c || Ca(a), g = c ? c.getPropertyValue(b) || c[b] : void 0, "" !== g && void 0 !== g || n.contains(a.ownerDocument, a) || (g = n.style(a, b)), c && !l.pixelMarginRight() && Ba.test(g) && Aa.test(b) && (d = h.width, e = h.minWidth, f = h.maxWidth, h.minWidth = h.maxWidth = h.width = g, g = c.width, h.width = d, h.minWidth = e, h.maxWidth = f), void 0 !== g ? g + "" : g
  1430. }
  1431. function Ga(a, b) {
  1432. return {
  1433. get: function () {
  1434. return a() ? void delete this.get : (this.get = b).apply(this, arguments)
  1435. }
  1436. }
  1437. }
  1438. var Ha = /^(none|table(?!-c[ea]).+)/, Ia = {position: "absolute", visibility: "hidden", display: "block"},
  1439. Ja = {letterSpacing: "0", fontWeight: "400"}, Ka = ["Webkit", "O", "Moz", "ms"],
  1440. La = d.createElement("div").style;
  1441. function Ma(a) {
  1442. if (a in La) return a;
  1443. var b = a[0].toUpperCase() + a.slice(1), c = Ka.length;
  1444. while (c--) if (a = Ka[c] + b, a in La) return a
  1445. }
  1446. function Na(a, b, c) {
  1447. var d = T.exec(b);
  1448. return d ? Math.max(0, d[2] - (c || 0)) + (d[3] || "px") : b
  1449. }
  1450. function Oa(a, b, c, d, e) {
  1451. for (var f = c === (d ? "border" : "content") ? 4 : "width" === b ? 1 : 0, g = 0; 4 > f; f += 2) "margin" === c && (g += n.css(a, c + U[f], !0, e)), d ? ("content" === c && (g -= n.css(a, "padding" + U[f], !0, e)), "margin" !== c && (g -= n.css(a, "border" + U[f] + "Width", !0, e))) : (g += n.css(a, "padding" + U[f], !0, e), "padding" !== c && (g += n.css(a, "border" + U[f] + "Width", !0, e)));
  1452. return g
  1453. }
  1454. function Pa(a, b, c) {
  1455. var d = !0, e = "width" === b ? a.offsetWidth : a.offsetHeight, f = Ca(a),
  1456. g = "border-box" === n.css(a, "boxSizing", !1, f);
  1457. if (0 >= e || null == e) {
  1458. if (e = Fa(a, b, f), (0 > e || null == e) && (e = a.style[b]), Ba.test(e)) return e;
  1459. d = g && (l.boxSizingReliable() || e === a.style[b]), e = parseFloat(e) || 0
  1460. }
  1461. return e + Oa(a, b, c || (g ? "border" : "content"), d, f) + "px"
  1462. }
  1463. function Qa(a, b) {
  1464. for (var c, d, e, f = [], g = 0, h = a.length; h > g; g++) d = a[g], d.style && (f[g] = N.get(d, "olddisplay"), c = d.style.display, b ? (f[g] || "none" !== c || (d.style.display = ""), "" === d.style.display && V(d) && (f[g] = N.access(d, "olddisplay", za(d.nodeName)))) : (e = V(d), "none" === c && e || N.set(d, "olddisplay", e ? c : n.css(d, "display"))));
  1465. for (g = 0; h > g; g++) d = a[g], d.style && (b && "none" !== d.style.display && "" !== d.style.display || (d.style.display = b ? f[g] || "" : "none"));
  1466. return a
  1467. }
  1468. n.extend({
  1469. cssHooks: {
  1470. opacity: {
  1471. get: function (a, b) {
  1472. if (b) {
  1473. var c = Fa(a, "opacity");
  1474. return "" === c ? "1" : c
  1475. }
  1476. }
  1477. }
  1478. },
  1479. cssNumber: {
  1480. animationIterationCount: !0,
  1481. columnCount: !0,
  1482. fillOpacity: !0,
  1483. flexGrow: !0,
  1484. flexShrink: !0,
  1485. fontWeight: !0,
  1486. lineHeight: !0,
  1487. opacity: !0,
  1488. order: !0,
  1489. orphans: !0,
  1490. widows: !0,
  1491. zIndex: !0,
  1492. zoom: !0
  1493. },
  1494. cssProps: {"float": "cssFloat"},
  1495. style: function (a, b, c, d) {
  1496. if (a && 3 !== a.nodeType && 8 !== a.nodeType && a.style) {
  1497. var e, f, g, h = n.camelCase(b), i = a.style;
  1498. return b = n.cssProps[h] || (n.cssProps[h] = Ma(h) || h), g = n.cssHooks[b] || n.cssHooks[h], void 0 === c ? g && "get" in g && void 0 !== (e = g.get(a, !1, d)) ? e : i[b] : (f = typeof c, "string" === f && (e = T.exec(c)) && e[1] && (c = W(a, b, e), f = "number"), null != c && c === c && ("number" === f && (c += e && e[3] || (n.cssNumber[h] ? "" : "px")), l.clearCloneStyle || "" !== c || 0 !== b.indexOf("background") || (i[b] = "inherit"), g && "set" in g && void 0 === (c = g.set(a, c, d)) || (i[b] = c)), void 0)
  1499. }
  1500. },
  1501. css: function (a, b, c, d) {
  1502. var e, f, g, h = n.camelCase(b);
  1503. return b = n.cssProps[h] || (n.cssProps[h] = Ma(h) || h), g = n.cssHooks[b] || n.cssHooks[h], g && "get" in g && (e = g.get(a, !0, c)), void 0 === e && (e = Fa(a, b, d)), "normal" === e && b in Ja && (e = Ja[b]), "" === c || c ? (f = parseFloat(e), c === !0 || isFinite(f) ? f || 0 : e) : e
  1504. }
  1505. }), n.each(["height", "width"], function (a, b) {
  1506. n.cssHooks[b] = {
  1507. get: function (a, c, d) {
  1508. return c ? Ha.test(n.css(a, "display")) && 0 === a.offsetWidth ? Da(a, Ia, function () {
  1509. return Pa(a, b, d)
  1510. }) : Pa(a, b, d) : void 0
  1511. }, set: function (a, c, d) {
  1512. var e, f = d && Ca(a), g = d && Oa(a, b, d, "border-box" === n.css(a, "boxSizing", !1, f), f);
  1513. return g && (e = T.exec(c)) && "px" !== (e[3] || "px") && (a.style[b] = c, c = n.css(a, b)), Na(a, c, g)
  1514. }
  1515. }
  1516. }), n.cssHooks.marginLeft = Ga(l.reliableMarginLeft, function (a, b) {
  1517. return b ? (parseFloat(Fa(a, "marginLeft")) || a.getBoundingClientRect().left - Da(a, {marginLeft: 0}, function () {
  1518. return a.getBoundingClientRect().left
  1519. })) + "px" : void 0
  1520. }), n.cssHooks.marginRight = Ga(l.reliableMarginRight, function (a, b) {
  1521. return b ? Da(a, {display: "inline-block"}, Fa, [a, "marginRight"]) : void 0
  1522. }), n.each({margin: "", padding: "", border: "Width"}, function (a, b) {
  1523. n.cssHooks[a + b] = {
  1524. expand: function (c) {
  1525. for (var d = 0, e = {}, f = "string" == typeof c ? c.split(" ") : [c]; 4 > d; d++) e[a + U[d] + b] = f[d] || f[d - 2] || f[0];
  1526. return e
  1527. }
  1528. }, Aa.test(a) || (n.cssHooks[a + b].set = Na)
  1529. }), n.fn.extend({
  1530. css: function (a, b) {
  1531. return K(this, function (a, b, c) {
  1532. var d, e, f = {}, g = 0;
  1533. if (n.isArray(b)) {
  1534. for (d = Ca(a), e = b.length; e > g; g++) f[b[g]] = n.css(a, b[g], !1, d);
  1535. return f
  1536. }
  1537. return void 0 !== c ? n.style(a, b, c) : n.css(a, b)
  1538. }, a, b, arguments.length > 1)
  1539. }, show: function () {
  1540. return Qa(this, !0)
  1541. }, hide: function () {
  1542. return Qa(this)
  1543. }, toggle: function (a) {
  1544. return "boolean" == typeof a ? a ? this.show() : this.hide() : this.each(function () {
  1545. V(this) ? n(this).show() : n(this).hide()
  1546. })
  1547. }
  1548. });
  1549. function Ra(a, b, c, d, e) {
  1550. return new Ra.prototype.init(a, b, c, d, e)
  1551. }
  1552. n.Tween = Ra, Ra.prototype = {
  1553. constructor: Ra, init: function (a, b, c, d, e, f) {
  1554. this.elem = a, this.prop = c, this.easing = e || n.easing._default, this.options = b, this.start = this.now = this.cur(), this.end = d, this.unit = f || (n.cssNumber[c] ? "" : "px")
  1555. }, cur: function () {
  1556. var a = Ra.propHooks[this.prop];
  1557. return a && a.get ? a.get(this) : Ra.propHooks._default.get(this)
  1558. }, run: function (a) {
  1559. var b, c = Ra.propHooks[this.prop];
  1560. return this.options.duration ? this.pos = b = n.easing[this.easing](a, this.options.duration * a, 0, 1, this.options.duration) : this.pos = b = a, this.now = (this.end - this.start) * b + this.start, this.options.step && this.options.step.call(this.elem, this.now, this), c && c.set ? c.set(this) : Ra.propHooks._default.set(this), this
  1561. }
  1562. }, Ra.prototype.init.prototype = Ra.prototype, Ra.propHooks = {
  1563. _default: {
  1564. get: function (a) {
  1565. var b;
  1566. return 1 !== a.elem.nodeType || null != a.elem[a.prop] && null == a.elem.style[a.prop] ? a.elem[a.prop] : (b = n.css(a.elem, a.prop, ""), b && "auto" !== b ? b : 0)
  1567. }, set: function (a) {
  1568. n.fx.step[a.prop] ? n.fx.step[a.prop](a) : 1 !== a.elem.nodeType || null == a.elem.style[n.cssProps[a.prop]] && !n.cssHooks[a.prop] ? a.elem[a.prop] = a.now : n.style(a.elem, a.prop, a.now + a.unit)
  1569. }
  1570. }
  1571. }, Ra.propHooks.scrollTop = Ra.propHooks.scrollLeft = {
  1572. set: function (a) {
  1573. a.elem.nodeType && a.elem.parentNode && (a.elem[a.prop] = a.now)
  1574. }
  1575. }, n.easing = {
  1576. linear: function (a) {
  1577. return a
  1578. }, swing: function (a) {
  1579. return .5 - Math.cos(a * Math.PI) / 2
  1580. }, _default: "swing"
  1581. }, n.fx = Ra.prototype.init, n.fx.step = {};
  1582. var Sa, Ta, Ua = /^(?:toggle|show|hide)$/, Va = /queueHooks$/;
  1583. function Wa() {
  1584. return a.setTimeout(function () {
  1585. Sa = void 0
  1586. }), Sa = n.now()
  1587. }
  1588. function Xa(a, b) {
  1589. var c, d = 0, e = {height: a};
  1590. for (b = b ? 1 : 0; 4 > d; d += 2 - b) c = U[d], e["margin" + c] = e["padding" + c] = a;
  1591. return b && (e.opacity = e.width = a), e
  1592. }
  1593. function Ya(a, b, c) {
  1594. for (var d, e = (_a.tweeners[b] || []).concat(_a.tweeners["*"]), f = 0, g = e.length; g > f; f++) if (d = e[f].call(c, b, a)) return d
  1595. }
  1596. function Za(a, b, c) {
  1597. var d, e, f, g, h, i, j, k, l = this, m = {}, o = a.style, p = a.nodeType && V(a), q = N.get(a, "fxshow");
  1598. c.queue || (h = n._queueHooks(a, "fx"), null == h.unqueued && (h.unqueued = 0, i = h.empty.fire, h.empty.fire = function () {
  1599. h.unqueued || i()
  1600. }), h.unqueued++, l.always(function () {
  1601. l.always(function () {
  1602. h.unqueued--, n.queue(a, "fx").length || h.empty.fire()
  1603. })
  1604. })), 1 === a.nodeType && ("height" in b || "width" in b) && (c.overflow = [o.overflow, o.overflowX, o.overflowY], j = n.css(a, "display"), k = "none" === j ? N.get(a, "olddisplay") || za(a.nodeName) : j, "inline" === k && "none" === n.css(a, "float") && (o.display = "inline-block")), c.overflow && (o.overflow = "hidden", l.always(function () {
  1605. o.overflow = c.overflow[0], o.overflowX = c.overflow[1], o.overflowY = c.overflow[2]
  1606. }));
  1607. for (d in b) if (e = b[d], Ua.exec(e)) {
  1608. if (delete b[d], f = f || "toggle" === e, e === (p ? "hide" : "show")) {
  1609. if ("show" !== e || !q || void 0 === q[d]) continue;
  1610. p = !0
  1611. }
  1612. m[d] = q && q[d] || n.style(a, d)
  1613. } else j = void 0;
  1614. if (n.isEmptyObject(m)) "inline" === ("none" === j ? za(a.nodeName) : j) && (o.display = j); else {
  1615. q ? "hidden" in q && (p = q.hidden) : q = N.access(a, "fxshow", {}), f && (q.hidden = !p), p ? n(a).show() : l.done(function () {
  1616. n(a).hide()
  1617. }), l.done(function () {
  1618. var b;
  1619. N.remove(a, "fxshow");
  1620. for (b in m) n.style(a, b, m[b])
  1621. });
  1622. for (d in m) g = Ya(p ? q[d] : 0, d, l), d in q || (q[d] = g.start, p && (g.end = g.start, g.start = "width" === d || "height" === d ? 1 : 0))
  1623. }
  1624. }
  1625. function $a(a, b) {
  1626. var c, d, e, f, g;
  1627. for (c in a) if (d = n.camelCase(c), e = b[d], f = a[c], n.isArray(f) && (e = f[1], f = a[c] = f[0]), c !== d && (a[d] = f, delete a[c]), g = n.cssHooks[d], g && "expand" in g) {
  1628. f = g.expand(f), delete a[d];
  1629. for (c in f) c in a || (a[c] = f[c], b[c] = e)
  1630. } else b[d] = e
  1631. }
  1632. function _a(a, b, c) {
  1633. var d, e, f = 0, g = _a.prefilters.length, h = n.Deferred().always(function () {
  1634. delete i.elem
  1635. }), i = function () {
  1636. if (e) return !1;
  1637. for (var b = Sa || Wa(), c = Math.max(0, j.startTime + j.duration - b), d = c / j.duration || 0, f = 1 - d, g = 0, i = j.tweens.length; i > g; g++) j.tweens[g].run(f);
  1638. return h.notifyWith(a, [j, f, c]), 1 > f && i ? c : (h.resolveWith(a, [j]), !1)
  1639. }, j = h.promise({
  1640. elem: a,
  1641. props: n.extend({}, b),
  1642. opts: n.extend(!0, {specialEasing: {}, easing: n.easing._default}, c),
  1643. originalProperties: b,
  1644. originalOptions: c,
  1645. startTime: Sa || Wa(),
  1646. duration: c.duration,
  1647. tweens: [],
  1648. createTween: function (b, c) {
  1649. var d = n.Tween(a, j.opts, b, c, j.opts.specialEasing[b] || j.opts.easing);
  1650. return j.tweens.push(d), d
  1651. },
  1652. stop: function (b) {
  1653. var c = 0, d = b ? j.tweens.length : 0;
  1654. if (e) return this;
  1655. for (e = !0; d > c; c++) j.tweens[c].run(1);
  1656. return b ? (h.notifyWith(a, [j, 1, 0]), h.resolveWith(a, [j, b])) : h.rejectWith(a, [j, b]), this
  1657. }
  1658. }), k = j.props;
  1659. for ($a(k, j.opts.specialEasing); g > f; f++) if (d = _a.prefilters[f].call(j, a, k, j.opts)) return n.isFunction(d.stop) && (n._queueHooks(j.elem, j.opts.queue).stop = n.proxy(d.stop, d)), d;
  1660. return n.map(k, Ya, j), n.isFunction(j.opts.start) && j.opts.start.call(a, j), n.fx.timer(n.extend(i, {
  1661. elem: a,
  1662. anim: j,
  1663. queue: j.opts.queue
  1664. })), j.progress(j.opts.progress).done(j.opts.done, j.opts.complete).fail(j.opts.fail).always(j.opts.always)
  1665. }
  1666. n.Animation = n.extend(_a, {
  1667. tweeners: {
  1668. "*": [function (a, b) {
  1669. var c = this.createTween(a, b);
  1670. return W(c.elem, a, T.exec(b), c), c
  1671. }]
  1672. }, tweener: function (a, b) {
  1673. n.isFunction(a) ? (b = a, a = ["*"]) : a = a.match(G);
  1674. for (var c, d = 0, e = a.length; e > d; d++) c = a[d], _a.tweeners[c] = _a.tweeners[c] || [], _a.tweeners[c].unshift(b)
  1675. }, prefilters: [Za], prefilter: function (a, b) {
  1676. b ? _a.prefilters.unshift(a) : _a.prefilters.push(a)
  1677. }
  1678. }), n.speed = function (a, b, c) {
  1679. var d = a && "object" == typeof a ? n.extend({}, a) : {
  1680. complete: c || !c && b || n.isFunction(a) && a,
  1681. duration: a,
  1682. easing: c && b || b && !n.isFunction(b) && b
  1683. };
  1684. return d.duration = n.fx.off ? 0 : "number" == typeof d.duration ? d.duration : d.duration in n.fx.speeds ? n.fx.speeds[d.duration] : n.fx.speeds._default, null != d.queue && d.queue !== !0 || (d.queue = "fx"), d.old = d.complete, d.complete = function () {
  1685. n.isFunction(d.old) && d.old.call(this), d.queue && n.dequeue(this, d.queue)
  1686. }, d
  1687. }, n.fn.extend({
  1688. fadeTo: function (a, b, c, d) {
  1689. return this.filter(V).css("opacity", 0).show().end().animate({opacity: b}, a, c, d)
  1690. }, animate: function (a, b, c, d) {
  1691. var e = n.isEmptyObject(a), f = n.speed(b, c, d), g = function () {
  1692. var b = _a(this, n.extend({}, a), f);
  1693. (e || N.get(this, "finish")) && b.stop(!0)
  1694. };
  1695. return g.finish = g, e || f.queue === !1 ? this.each(g) : this.queue(f.queue, g)
  1696. }, stop: function (a, b, c) {
  1697. var d = function (a) {
  1698. var b = a.stop;
  1699. delete a.stop, b(c)
  1700. };
  1701. return "string" != typeof a && (c = b, b = a, a = void 0), b && a !== !1 && this.queue(a || "fx", []), this.each(function () {
  1702. var b = !0, e = null != a && a + "queueHooks", f = n.timers, g = N.get(this);
  1703. if (e) g[e] && g[e].stop && d(g[e]); else for (e in g) g[e] && g[e].stop && Va.test(e) && d(g[e]);
  1704. for (e = f.length; e--;) f[e].elem !== this || null != a && f[e].queue !== a || (f[e].anim.stop(c), b = !1, f.splice(e, 1));
  1705. !b && c || n.dequeue(this, a)
  1706. })
  1707. }, finish: function (a) {
  1708. return a !== !1 && (a = a || "fx"), this.each(function () {
  1709. var b, c = N.get(this), d = c[a + "queue"], e = c[a + "queueHooks"], f = n.timers, g = d ? d.length : 0;
  1710. for (c.finish = !0, n.queue(this, a, []), e && e.stop && e.stop.call(this, !0), b = f.length; b--;) f[b].elem === this && f[b].queue === a && (f[b].anim.stop(!0), f.splice(b, 1));
  1711. for (b = 0; g > b; b++) d[b] && d[b].finish && d[b].finish.call(this);
  1712. delete c.finish
  1713. })
  1714. }
  1715. }), n.each(["toggle", "show", "hide"], function (a, b) {
  1716. var c = n.fn[b];
  1717. n.fn[b] = function (a, d, e) {
  1718. return null == a || "boolean" == typeof a ? c.apply(this, arguments) : this.animate(Xa(b, !0), a, d, e)
  1719. }
  1720. }), n.each({
  1721. slideDown: Xa("show"),
  1722. slideUp: Xa("hide"),
  1723. slideToggle: Xa("toggle"),
  1724. fadeIn: {opacity: "show"},
  1725. fadeOut: {opacity: "hide"},
  1726. fadeToggle: {opacity: "toggle"}
  1727. }, function (a, b) {
  1728. n.fn[a] = function (a, c, d) {
  1729. return this.animate(b, a, c, d)
  1730. }
  1731. }), n.timers = [], n.fx.tick = function () {
  1732. var a, b = 0, c = n.timers;
  1733. for (Sa = n.now(); b < c.length; b++) a = c[b], a() || c[b] !== a || c.splice(b--, 1);
  1734. c.length || n.fx.stop(), Sa = void 0
  1735. }, n.fx.timer = function (a) {
  1736. n.timers.push(a), a() ? n.fx.start() : n.timers.pop()
  1737. }, n.fx.interval = 13, n.fx.start = function () {
  1738. Ta || (Ta = a.setInterval(n.fx.tick, n.fx.interval))
  1739. }, n.fx.stop = function () {
  1740. a.clearInterval(Ta), Ta = null
  1741. }, n.fx.speeds = {slow: 600, fast: 200, _default: 400}, n.fn.delay = function (b, c) {
  1742. return b = n.fx ? n.fx.speeds[b] || b : b, c = c || "fx", this.queue(c, function (c, d) {
  1743. var e = a.setTimeout(c, b);
  1744. d.stop = function () {
  1745. a.clearTimeout(e)
  1746. }
  1747. })
  1748. }, function () {
  1749. var a = d.createElement("input"), b = d.createElement("select"), c = b.appendChild(d.createElement("option"));
  1750. a.type = "checkbox", l.checkOn = "" !== a.value, l.optSelected = c.selected, b.disabled = !0, l.optDisabled = !c.disabled, a = d.createElement("input"), a.value = "t", a.type = "radio", l.radioValue = "t" === a.value
  1751. }();
  1752. var ab, bb = n.expr.attrHandle;
  1753. n.fn.extend({
  1754. attr: function (a, b) {
  1755. return K(this, n.attr, a, b, arguments.length > 1)
  1756. }, removeAttr: function (a) {
  1757. return this.each(function () {
  1758. n.removeAttr(this, a)
  1759. })
  1760. }
  1761. }), n.extend({
  1762. attr: function (a, b, c) {
  1763. var d, e, f = a.nodeType;
  1764. if (3 !== f && 8 !== f && 2 !== f) return "undefined" == typeof a.getAttribute ? n.prop(a, b, c) : (1 === f && n.isXMLDoc(a) || (b = b.toLowerCase(), e = n.attrHooks[b] || (n.expr.match.bool.test(b) ? ab : void 0)), void 0 !== c ? null === c ? void n.removeAttr(a, b) : e && "set" in e && void 0 !== (d = e.set(a, c, b)) ? d : (a.setAttribute(b, c + ""), c) : e && "get" in e && null !== (d = e.get(a, b)) ? d : (d = n.find.attr(a, b), null == d ? void 0 : d))
  1765. }, attrHooks: {
  1766. type: {
  1767. set: function (a, b) {
  1768. if (!l.radioValue && "radio" === b && n.nodeName(a, "input")) {
  1769. var c = a.value;
  1770. return a.setAttribute("type", b), c && (a.value = c), b
  1771. }
  1772. }
  1773. }
  1774. }, removeAttr: function (a, b) {
  1775. var c, d, e = 0, f = b && b.match(G);
  1776. if (f && 1 === a.nodeType) while (c = f[e++]) d = n.propFix[c] || c, n.expr.match.bool.test(c) && (a[d] = !1), a.removeAttribute(c)
  1777. }
  1778. }), ab = {
  1779. set: function (a, b, c) {
  1780. return b === !1 ? n.removeAttr(a, c) : a.setAttribute(c, c), c
  1781. }
  1782. }, n.each(n.expr.match.bool.source.match(/\w+/g), function (a, b) {
  1783. var c = bb[b] || n.find.attr;
  1784. bb[b] = function (a, b, d) {
  1785. var e, f;
  1786. return d || (f = bb[b], bb[b] = e, e = null != c(a, b, d) ? b.toLowerCase() : null, bb[b] = f), e
  1787. }
  1788. });
  1789. var cb = /^(?:input|select|textarea|button)$/i, db = /^(?:a|area)$/i;
  1790. n.fn.extend({
  1791. prop: function (a, b) {
  1792. return K(this, n.prop, a, b, arguments.length > 1)
  1793. }, removeProp: function (a) {
  1794. return this.each(function () {
  1795. delete this[n.propFix[a] || a]
  1796. })
  1797. }
  1798. }), n.extend({
  1799. prop: function (a, b, c) {
  1800. var d, e, f = a.nodeType;
  1801. if (3 !== f && 8 !== f && 2 !== f) return 1 === f && n.isXMLDoc(a) || (b = n.propFix[b] || b, e = n.propHooks[b]),
  1802. void 0 !== c ? e && "set" in e && void 0 !== (d = e.set(a, c, b)) ? d : a[b] = c : e && "get" in e && null !== (d = e.get(a, b)) ? d : a[b]
  1803. }, propHooks: {
  1804. tabIndex: {
  1805. get: function (a) {
  1806. var b = n.find.attr(a, "tabindex");
  1807. return b ? parseInt(b, 10) : cb.test(a.nodeName) || db.test(a.nodeName) && a.href ? 0 : -1
  1808. }
  1809. }
  1810. }, propFix: {"for": "htmlFor", "class": "className"}
  1811. }), l.optSelected || (n.propHooks.selected = {
  1812. get: function (a) {
  1813. var b = a.parentNode;
  1814. return b && b.parentNode && b.parentNode.selectedIndex, null
  1815. }, set: function (a) {
  1816. var b = a.parentNode;
  1817. b && (b.selectedIndex, b.parentNode && b.parentNode.selectedIndex)
  1818. }
  1819. }), n.each(["tabIndex", "readOnly", "maxLength", "cellSpacing", "cellPadding", "rowSpan", "colSpan", "useMap", "frameBorder", "contentEditable"], function () {
  1820. n.propFix[this.toLowerCase()] = this
  1821. });
  1822. var eb = /[\t\r\n\f]/g;
  1823. function fb(a) {
  1824. return a.getAttribute && a.getAttribute("class") || ""
  1825. }
  1826. n.fn.extend({
  1827. addClass: function (a) {
  1828. var b, c, d, e, f, g, h, i = 0;
  1829. if (n.isFunction(a)) return this.each(function (b) {
  1830. n(this).addClass(a.call(this, b, fb(this)))
  1831. });
  1832. if ("string" == typeof a && a) {
  1833. b = a.match(G) || [];
  1834. while (c = this[i++]) if (e = fb(c), d = 1 === c.nodeType && (" " + e + " ").replace(eb, " ")) {
  1835. g = 0;
  1836. while (f = b[g++]) d.indexOf(" " + f + " ") < 0 && (d += f + " ");
  1837. h = n.trim(d), e !== h && c.setAttribute("class", h)
  1838. }
  1839. }
  1840. return this
  1841. }, removeClass: function (a) {
  1842. var b, c, d, e, f, g, h, i = 0;
  1843. if (n.isFunction(a)) return this.each(function (b) {
  1844. n(this).removeClass(a.call(this, b, fb(this)))
  1845. });
  1846. if (!arguments.length) return this.attr("class", "");
  1847. if ("string" == typeof a && a) {
  1848. b = a.match(G) || [];
  1849. while (c = this[i++]) if (e = fb(c), d = 1 === c.nodeType && (" " + e + " ").replace(eb, " ")) {
  1850. g = 0;
  1851. while (f = b[g++]) while (d.indexOf(" " + f + " ") > -1) d = d.replace(" " + f + " ", " ");
  1852. h = n.trim(d), e !== h && c.setAttribute("class", h)
  1853. }
  1854. }
  1855. return this
  1856. }, toggleClass: function (a, b) {
  1857. var c = typeof a;
  1858. return "boolean" == typeof b && "string" === c ? b ? this.addClass(a) : this.removeClass(a) : n.isFunction(a) ? this.each(function (c) {
  1859. n(this).toggleClass(a.call(this, c, fb(this), b), b)
  1860. }) : this.each(function () {
  1861. var b, d, e, f;
  1862. if ("string" === c) {
  1863. d = 0, e = n(this), f = a.match(G) || [];
  1864. while (b = f[d++]) e.hasClass(b) ? e.removeClass(b) : e.addClass(b)
  1865. } else void 0 !== a && "boolean" !== c || (b = fb(this), b && N.set(this, "__className__", b), this.setAttribute && this.setAttribute("class", b || a === !1 ? "" : N.get(this, "__className__") || ""))
  1866. })
  1867. }, hasClass: function (a) {
  1868. var b, c, d = 0;
  1869. b = " " + a + " ";
  1870. while (c = this[d++]) if (1 === c.nodeType && (" " + fb(c) + " ").replace(eb, " ").indexOf(b) > -1) return !0;
  1871. return !1
  1872. }
  1873. });
  1874. var gb = /\r/g, hb = /[\x20\t\r\n\f]+/g;
  1875. n.fn.extend({
  1876. val: function (a) {
  1877. var b, c, d, e = this[0];
  1878. {
  1879. if (arguments.length) return d = n.isFunction(a), this.each(function (c) {
  1880. var e;
  1881. 1 === this.nodeType && (e = d ? a.call(this, c, n(this).val()) : a, null == e ? e = "" : "number" == typeof e ? e += "" : n.isArray(e) && (e = n.map(e, function (a) {
  1882. return null == a ? "" : a + ""
  1883. })), b = n.valHooks[this.type] || n.valHooks[this.nodeName.toLowerCase()], b && "set" in b && void 0 !== b.set(this, e, "value") || (this.value = e))
  1884. });
  1885. if (e) return b = n.valHooks[e.type] || n.valHooks[e.nodeName.toLowerCase()], b && "get" in b && void 0 !== (c = b.get(e, "value")) ? c : (c = e.value, "string" == typeof c ? c.replace(gb, "") : null == c ? "" : c)
  1886. }
  1887. }
  1888. }), n.extend({
  1889. valHooks: {
  1890. option: {
  1891. get: function (a) {
  1892. var b = n.find.attr(a, "value");
  1893. return null != b ? b : n.trim(n.text(a)).replace(hb, " ")
  1894. }
  1895. }, select: {
  1896. get: function (a) {
  1897. for (var b, c, d = a.options, e = a.selectedIndex, f = "select-one" === a.type || 0 > e, g = f ? null : [], h = f ? e + 1 : d.length, i = 0 > e ? h : f ? e : 0; h > i; i++) if (c = d[i], (c.selected || i === e) && (l.optDisabled ? !c.disabled : null === c.getAttribute("disabled")) && (!c.parentNode.disabled || !n.nodeName(c.parentNode, "optgroup"))) {
  1898. if (b = n(c).val(), f) return b;
  1899. g.push(b)
  1900. }
  1901. return g
  1902. }, set: function (a, b) {
  1903. var c, d, e = a.options, f = n.makeArray(b), g = e.length;
  1904. while (g--) d = e[g], (d.selected = n.inArray(n.valHooks.option.get(d), f) > -1) && (c = !0);
  1905. return c || (a.selectedIndex = -1), f
  1906. }
  1907. }
  1908. }
  1909. }), n.each(["radio", "checkbox"], function () {
  1910. n.valHooks[this] = {
  1911. set: function (a, b) {
  1912. return n.isArray(b) ? a.checked = n.inArray(n(a).val(), b) > -1 : void 0
  1913. }
  1914. }, l.checkOn || (n.valHooks[this].get = function (a) {
  1915. return null === a.getAttribute("value") ? "on" : a.value
  1916. })
  1917. });
  1918. var ib = /^(?:focusinfocus|focusoutblur)$/;
  1919. n.extend(n.event, {
  1920. trigger: function (b, c, e, f) {
  1921. var g, h, i, j, l, m, o, p = [e || d], q = k.call(b, "type") ? b.type : b,
  1922. r = k.call(b, "namespace") ? b.namespace.split(".") : [];
  1923. if (h = i = e = e || d, 3 !== e.nodeType && 8 !== e.nodeType && !ib.test(q + n.event.triggered) && (q.indexOf(".") > -1 && (r = q.split("."), q = r.shift(), r.sort()), l = q.indexOf(":") < 0 && "on" + q, b = b[n.expando] ? b : new n.Event(q, "object" == typeof b && b), b.isTrigger = f ? 2 : 3, b.namespace = r.join("."), b.rnamespace = b.namespace ? new RegExp("(^|\\.)" + r.join("\\.(?:.*\\.|)") + "(\\.|$)") : null, b.result = void 0, b.target || (b.target = e), c = null == c ? [b] : n.makeArray(c, [b]), o = n.event.special[q] || {}, f || !o.trigger || o.trigger.apply(e, c) !== !1)) {
  1924. if (!f && !o.noBubble && !n.isWindow(e)) {
  1925. for (j = o.delegateType || q, ib.test(j + q) || (h = h.parentNode); h; h = h.parentNode) p.push(h), i = h;
  1926. i === (e.ownerDocument || d) && p.push(i.defaultView || i.parentWindow || a)
  1927. }
  1928. g = 0;
  1929. while ((h = p[g++]) && !b.isPropagationStopped()) b.type = g > 1 ? j : o.bindType || q, m = (N.get(h, "events") || {})[b.type] && N.get(h, "handle"), m && m.apply(h, c), m = l && h[l], m && m.apply && L(h) && (b.result = m.apply(h, c), b.result === !1 && b.preventDefault());
  1930. return b.type = q, f || b.isDefaultPrevented() || o._default && o._default.apply(p.pop(), c) !== !1 || !L(e) || l && n.isFunction(e[q]) && !n.isWindow(e) && (i = e[l], i && (e[l] = null), n.event.triggered = q, e[q](), n.event.triggered = void 0, i && (e[l] = i)), b.result
  1931. }
  1932. }, simulate: function (a, b, c) {
  1933. var d = n.extend(new n.Event, c, {type: a, isSimulated: !0});
  1934. n.event.trigger(d, null, b)
  1935. }
  1936. }), n.fn.extend({
  1937. trigger: function (a, b) {
  1938. return this.each(function () {
  1939. n.event.trigger(a, b, this)
  1940. })
  1941. }, triggerHandler: function (a, b) {
  1942. var c = this[0];
  1943. return c ? n.event.trigger(a, b, c, !0) : void 0
  1944. }
  1945. }), n.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "), function (a, b) {
  1946. n.fn[b] = function (a, c) {
  1947. return arguments.length > 0 ? this.on(b, null, a, c) : this.trigger(b)
  1948. }
  1949. }), n.fn.extend({
  1950. hover: function (a, b) {
  1951. return this.mouseenter(a).mouseleave(b || a)
  1952. }
  1953. }), l.focusin = "onfocusin" in a, l.focusin || n.each({focus: "focusin", blur: "focusout"}, function (a, b) {
  1954. var c = function (a) {
  1955. n.event.simulate(b, a.target, n.event.fix(a))
  1956. };
  1957. n.event.special[b] = {
  1958. setup: function () {
  1959. var d = this.ownerDocument || this, e = N.access(d, b);
  1960. e || d.addEventListener(a, c, !0), N.access(d, b, (e || 0) + 1)
  1961. }, teardown: function () {
  1962. var d = this.ownerDocument || this, e = N.access(d, b) - 1;
  1963. e ? N.access(d, b, e) : (d.removeEventListener(a, c, !0), N.remove(d, b))
  1964. }
  1965. }
  1966. });
  1967. var jb = a.location, kb = n.now(), lb = /\?/;
  1968. n.parseJSON = function (a) {
  1969. return JSON.parse(a + "")
  1970. }, n.parseXML = function (b) {
  1971. var c;
  1972. if (!b || "string" != typeof b) return null;
  1973. try {
  1974. c = (new a.DOMParser).parseFromString(b, "text/xml")
  1975. } catch (d) {
  1976. c = void 0
  1977. }
  1978. return c && !c.getElementsByTagName("parsererror").length || n.error("Invalid XML: " + b), c
  1979. };
  1980. var mb = /#.*$/, nb = /([?&])_=[^&]*/, ob = /^(.*?):[ \t]*([^\r\n]*)$/gm,
  1981. pb = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, qb = /^(?:GET|HEAD)$/, rb = /^\/\//, sb = {},
  1982. tb = {}, ub = "*/".concat("*"), vb = d.createElement("a");
  1983. vb.href = jb.href;
  1984. function wb(a) {
  1985. return function (b, c) {
  1986. "string" != typeof b && (c = b, b = "*");
  1987. var d, e = 0, f = b.toLowerCase().match(G) || [];
  1988. if (n.isFunction(c)) while (d = f[e++]) "+" === d[0] ? (d = d.slice(1) || "*", (a[d] = a[d] || []).unshift(c)) : (a[d] = a[d] || []).push(c)
  1989. }
  1990. }
  1991. function xb(a, b, c, d) {
  1992. var e = {}, f = a === tb;
  1993. function g(h) {
  1994. var i;
  1995. return e[h] = !0, n.each(a[h] || [], function (a, h) {
  1996. var j = h(b, c, d);
  1997. return "string" != typeof j || f || e[j] ? f ? !(i = j) : void 0 : (b.dataTypes.unshift(j), g(j), !1)
  1998. }), i
  1999. }
  2000. return g(b.dataTypes[0]) || !e["*"] && g("*")
  2001. }
  2002. function yb(a, b) {
  2003. var c, d, e = n.ajaxSettings.flatOptions || {};
  2004. for (c in b) void 0 !== b[c] && ((e[c] ? a : d || (d = {}))[c] = b[c]);
  2005. return d && n.extend(!0, a, d), a
  2006. }
  2007. function zb(a, b, c) {
  2008. var d, e, f, g, h = a.contents, i = a.dataTypes;
  2009. while ("*" === i[0]) i.shift(), void 0 === d && (d = a.mimeType || b.getResponseHeader("Content-Type"));
  2010. if (d) for (e in h) if (h[e] && h[e].test(d)) {
  2011. i.unshift(e);
  2012. break
  2013. }
  2014. if (i[0] in c) f = i[0]; else {
  2015. for (e in c) {
  2016. if (!i[0] || a.converters[e + " " + i[0]]) {
  2017. f = e;
  2018. break
  2019. }
  2020. g || (g = e)
  2021. }
  2022. f = f || g
  2023. }
  2024. return f ? (f !== i[0] && i.unshift(f), c[f]) : void 0
  2025. }
  2026. function Ab(a, b, c, d) {
  2027. var e, f, g, h, i, j = {}, k = a.dataTypes.slice();
  2028. if (k[1]) for (g in a.converters) j[g.toLowerCase()] = a.converters[g];
  2029. f = k.shift();
  2030. while (f) if (a.responseFields[f] && (c[a.responseFields[f]] = b), !i && d && a.dataFilter && (b = a.dataFilter(b, a.dataType)), i = f, f = k.shift()) if ("*" === f) f = i; else if ("*" !== i && i !== f) {
  2031. if (g = j[i + " " + f] || j["* " + f], !g) for (e in j) if (h = e.split(" "), h[1] === f && (g = j[i + " " + h[0]] || j["* " + h[0]])) {
  2032. g === !0 ? g = j[e] : j[e] !== !0 && (f = h[0], k.unshift(h[1]));
  2033. break
  2034. }
  2035. if (g !== !0) if (g && a["throws"]) b = g(b); else try {
  2036. b = g(b)
  2037. } catch (l) {
  2038. return {state: "parsererror", error: g ? l : "No conversion from " + i + " to " + f}
  2039. }
  2040. }
  2041. return {state: "success", data: b}
  2042. }
  2043. n.extend({
  2044. active: 0,
  2045. lastModified: {},
  2046. etag: {},
  2047. ajaxSettings: {
  2048. url: jb.href,
  2049. type: "GET",
  2050. isLocal: pb.test(jb.protocol),
  2051. global: !0,
  2052. processData: !0,
  2053. async: !0,
  2054. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  2055. accepts: {
  2056. "*": ub,
  2057. text: "text/plain",
  2058. html: "text/html",
  2059. xml: "application/xml, text/xml",
  2060. json: "application/json, text/javascript"
  2061. },
  2062. contents: {xml: /\bxml\b/, html: /\bhtml/, json: /\bjson\b/},
  2063. responseFields: {xml: "responseXML", text: "responseText", json: "responseJSON"},
  2064. converters: {"* text": String, "text html": !0, "text json": n.parseJSON, "text xml": n.parseXML},
  2065. flatOptions: {url: !0, context: !0}
  2066. },
  2067. ajaxSetup: function (a, b) {
  2068. return b ? yb(yb(a, n.ajaxSettings), b) : yb(n.ajaxSettings, a)
  2069. },
  2070. ajaxPrefilter: wb(sb),
  2071. ajaxTransport: wb(tb),
  2072. ajax: function (b, c) {
  2073. "object" == typeof b && (c = b, b = void 0), c = c || {};
  2074. var e, f, g, h, i, j, k, l, m = n.ajaxSetup({}, c), o = m.context || m,
  2075. p = m.context && (o.nodeType || o.jquery) ? n(o) : n.event, q = n.Deferred(),
  2076. r = n.Callbacks("once memory"), s = m.statusCode || {}, t = {}, u = {}, v = 0, w = "canceled", x = {
  2077. readyState: 0, getResponseHeader: function (a) {
  2078. var b;
  2079. if (2 === v) {
  2080. if (!h) {
  2081. h = {};
  2082. while (b = ob.exec(g)) h[b[1].toLowerCase()] = b[2]
  2083. }
  2084. b = h[a.toLowerCase()]
  2085. }
  2086. return null == b ? null : b
  2087. }, getAllResponseHeaders: function () {
  2088. return 2 === v ? g : null
  2089. }, setRequestHeader: function (a, b) {
  2090. var c = a.toLowerCase();
  2091. return v || (a = u[c] = u[c] || a, t[a] = b), this
  2092. }, overrideMimeType: function (a) {
  2093. return v || (m.mimeType = a), this
  2094. }, statusCode: function (a) {
  2095. var b;
  2096. if (a) if (2 > v) for (b in a) s[b] = [s[b], a[b]]; else x.always(a[x.status]);
  2097. return this
  2098. }, abort: function (a) {
  2099. var b = a || w;
  2100. return e && e.abort(b), z(0, b), this
  2101. }
  2102. };
  2103. if (q.promise(x).complete = r.add, x.success = x.done, x.error = x.fail, m.url = ((b || m.url || jb.href) + "").replace(mb, "").replace(rb, jb.protocol + "//"), m.type = c.method || c.type || m.method || m.type, m.dataTypes = n.trim(m.dataType || "*").toLowerCase().match(G) || [""], null == m.crossDomain) {
  2104. j = d.createElement("a");
  2105. try {
  2106. j.href = m.url, j.href = j.href, m.crossDomain = vb.protocol + "//" + vb.host != j.protocol + "//" + j.host
  2107. } catch (y) {
  2108. m.crossDomain = !0
  2109. }
  2110. }
  2111. if (m.data && m.processData && "string" != typeof m.data && (m.data = n.param(m.data, m.traditional)), xb(sb, m, c, x), 2 === v) return x;
  2112. k = n.event && m.global, k && 0 === n.active++ && n.event.trigger("ajaxStart"), m.type = m.type.toUpperCase(), m.hasContent = !qb.test(m.type), f = m.url, m.hasContent || (m.data && (f = m.url += (lb.test(f) ? "&" : "?") + m.data, delete m.data), m.cache === !1 && (m.url = nb.test(f) ? f.replace(nb, "$1_=" + kb++) : f + (lb.test(f) ? "&" : "?") + "_=" + kb++)), m.ifModified && (n.lastModified[f] && x.setRequestHeader("If-Modified-Since", n.lastModified[f]), n.etag[f] && x.setRequestHeader("If-None-Match", n.etag[f])), (m.data && m.hasContent && m.contentType !== !1 || c.contentType) && x.setRequestHeader("Content-Type", m.contentType), x.setRequestHeader("Accept", m.dataTypes[0] && m.accepts[m.dataTypes[0]] ? m.accepts[m.dataTypes[0]] + ("*" !== m.dataTypes[0] ? ", " + ub + "; q=0.01" : "") : m.accepts["*"]);
  2113. for (l in m.headers) x.setRequestHeader(l, m.headers[l]);
  2114. if (m.beforeSend && (m.beforeSend.call(o, x, m) === !1 || 2 === v)) return x.abort();
  2115. w = "abort";
  2116. for (l in {success: 1, error: 1, complete: 1}) x[l](m[l]);
  2117. if (e = xb(tb, m, c, x)) {
  2118. if (x.readyState = 1, k && p.trigger("ajaxSend", [x, m]), 2 === v) return x;
  2119. m.async && m.timeout > 0 && (i = a.setTimeout(function () {
  2120. x.abort("timeout")
  2121. }, m.timeout));
  2122. try {
  2123. v = 1, e.send(t, z)
  2124. } catch (y) {
  2125. if (!(2 > v)) throw y;
  2126. z(-1, y)
  2127. }
  2128. } else z(-1, "No Transport");
  2129. function z(b, c, d, h) {
  2130. var j, l, t, u, w, y = c;
  2131. 2 !== v && (v = 2, i && a.clearTimeout(i), e = void 0, g = h || "", x.readyState = b > 0 ? 4 : 0, j = b >= 200 && 300 > b || 304 === b, d && (u = zb(m, x, d)), u = Ab(m, u, x, j), j ? (m.ifModified && (w = x.getResponseHeader("Last-Modified"), w && (n.lastModified[f] = w), w = x.getResponseHeader("etag"), w && (n.etag[f] = w)), 204 === b || "HEAD" === m.type ? y = "nocontent" : 304 === b ? y = "notmodified" : (y = u.state, l = u.data, t = u.error, j = !t)) : (t = y, !b && y || (y = "error", 0 > b && (b = 0))), x.status = b, x.statusText = (c || y) + "", j ? q.resolveWith(o, [l, y, x]) : q.rejectWith(o, [x, y, t]), x.statusCode(s), s = void 0, k && p.trigger(j ? "ajaxSuccess" : "ajaxError", [x, m, j ? l : t]), r.fireWith(o, [x, y]), k && (p.trigger("ajaxComplete", [x, m]), --n.active || n.event.trigger("ajaxStop")))
  2132. }
  2133. return x
  2134. },
  2135. getJSON: function (a, b, c) {
  2136. return n.get(a, b, c, "json")
  2137. },
  2138. getScript: function (a, b) {
  2139. return n.get(a, void 0, b, "script")
  2140. }
  2141. }), n.each(["get", "post"], function (a, b) {
  2142. n[b] = function (a, c, d, e) {
  2143. return n.isFunction(c) && (e = e || d, d = c, c = void 0), n.ajax(n.extend({
  2144. url: a,
  2145. type: b,
  2146. dataType: e,
  2147. data: c,
  2148. success: d
  2149. }, n.isPlainObject(a) && a))
  2150. }
  2151. }), n._evalUrl = function (a) {
  2152. return n.ajax({url: a, type: "GET", dataType: "script", async: !1, global: !1, "throws": !0})
  2153. }, n.fn.extend({
  2154. wrapAll: function (a) {
  2155. var b;
  2156. return n.isFunction(a) ? this.each(function (b) {
  2157. n(this).wrapAll(a.call(this, b))
  2158. }) : (this[0] && (b = n(a, this[0].ownerDocument).eq(0).clone(!0), this[0].parentNode && b.insertBefore(this[0]), b.map(function () {
  2159. var a = this;
  2160. while (a.firstElementChild) a = a.firstElementChild;
  2161. return a
  2162. }).append(this)), this)
  2163. }, wrapInner: function (a) {
  2164. return n.isFunction(a) ? this.each(function (b) {
  2165. n(this).wrapInner(a.call(this, b))
  2166. }) : this.each(function () {
  2167. var b = n(this), c = b.contents();
  2168. c.length ? c.wrapAll(a) : b.append(a)
  2169. })
  2170. }, wrap: function (a) {
  2171. var b = n.isFunction(a);
  2172. return this.each(function (c) {
  2173. n(this).wrapAll(b ? a.call(this, c) : a)
  2174. })
  2175. }, unwrap: function () {
  2176. return this.parent().each(function () {
  2177. n.nodeName(this, "body") || n(this).replaceWith(this.childNodes)
  2178. }).end()
  2179. }
  2180. }), n.expr.filters.hidden = function (a) {
  2181. return !n.expr.filters.visible(a)
  2182. }, n.expr.filters.visible = function (a) {
  2183. return a.offsetWidth > 0 || a.offsetHeight > 0 || a.getClientRects().length > 0
  2184. };
  2185. var Bb = /%20/g, Cb = /\[\]$/, Db = /\r?\n/g, Eb = /^(?:submit|button|image|reset|file)$/i,
  2186. Fb = /^(?:input|select|textarea|keygen)/i;
  2187. function Gb(a, b, c, d) {
  2188. var e;
  2189. if (n.isArray(b)) n.each(b, function (b, e) {
  2190. c || Cb.test(a) ? d(a, e) : Gb(a + "[" + ("object" == typeof e && null != e ? b : "") + "]", e, c, d)
  2191. }); else if (c || "object" !== n.type(b)) d(a, b); else for (e in b) Gb(a + "[" + e + "]", b[e], c, d)
  2192. }
  2193. n.param = function (a, b) {
  2194. var c, d = [], e = function (a, b) {
  2195. b = n.isFunction(b) ? b() : null == b ? "" : b, d[d.length] = encodeURIComponent(a) + "=" + encodeURIComponent(b)
  2196. };
  2197. if (void 0 === b && (b = n.ajaxSettings && n.ajaxSettings.traditional), n.isArray(a) || a.jquery && !n.isPlainObject(a)) n.each(a, function () {
  2198. e(this.name, this.value)
  2199. }); else for (c in a) Gb(c, a[c], b, e);
  2200. return d.join("&").replace(Bb, "+")
  2201. }, n.fn.extend({
  2202. serialize: function () {
  2203. return n.param(this.serializeArray())
  2204. }, serializeArray: function () {
  2205. return this.map(function () {
  2206. var a = n.prop(this, "elements");
  2207. return a ? n.makeArray(a) : this
  2208. }).filter(function () {
  2209. var a = this.type;
  2210. return this.name && !n(this).is(":disabled") && Fb.test(this.nodeName) && !Eb.test(a) && (this.checked || !X.test(a))
  2211. }).map(function (a, b) {
  2212. var c = n(this).val();
  2213. return null == c ? null : n.isArray(c) ? n.map(c, function (a) {
  2214. return {name: b.name, value: a.replace(Db, "\r\n")}
  2215. }) : {name: b.name, value: c.replace(Db, "\r\n")}
  2216. }).get()
  2217. }
  2218. }), n.ajaxSettings.xhr = function () {
  2219. try {
  2220. return new a.XMLHttpRequest
  2221. } catch (b) {
  2222. }
  2223. };
  2224. var Hb = {0: 200, 1223: 204}, Ib = n.ajaxSettings.xhr();
  2225. l.cors = !!Ib && "withCredentials" in Ib, l.ajax = Ib = !!Ib, n.ajaxTransport(function (b) {
  2226. var c, d;
  2227. return l.cors || Ib && !b.crossDomain ? {
  2228. send: function (e, f) {
  2229. var g, h = b.xhr();
  2230. if (h.open(b.type, b.url, b.async, b.username, b.password), b.xhrFields) for (g in b.xhrFields) h[g] = b.xhrFields[g];
  2231. b.mimeType && h.overrideMimeType && h.overrideMimeType(b.mimeType), b.crossDomain || e["X-Requested-With"] || (e["X-Requested-With"] = "XMLHttpRequest");
  2232. for (g in e) h.setRequestHeader(g, e[g]);
  2233. c = function (a) {
  2234. return function () {
  2235. c && (c = d = h.onload = h.onerror = h.onabort = h.onreadystatechange = null, "abort" === a ? h.abort() : "error" === a ? "number" != typeof h.status ? f(0, "error") : f(h.status, h.statusText) : f(Hb[h.status] || h.status, h.statusText, "text" !== (h.responseType || "text") || "string" != typeof h.responseText ? {binary: h.response} : {text: h.responseText}, h.getAllResponseHeaders()))
  2236. }
  2237. }, h.onload = c(), d = h.onerror = c("error"), void 0 !== h.onabort ? h.onabort = d : h.onreadystatechange = function () {
  2238. 4 === h.readyState && a.setTimeout(function () {
  2239. c && d()
  2240. })
  2241. }, c = c("abort");
  2242. try {
  2243. h.send(b.hasContent && b.data || null)
  2244. } catch (i) {
  2245. if (c) throw i
  2246. }
  2247. }, abort: function () {
  2248. c && c()
  2249. }
  2250. } : void 0
  2251. }), n.ajaxSetup({
  2252. accepts: {script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},
  2253. contents: {script: /\b(?:java|ecma)script\b/},
  2254. converters: {
  2255. "text script": function (a) {
  2256. return n.globalEval(a), a
  2257. }
  2258. }
  2259. }), n.ajaxPrefilter("script", function (a) {
  2260. void 0 === a.cache && (a.cache = !1), a.crossDomain && (a.type = "GET")
  2261. }), n.ajaxTransport("script", function (a) {
  2262. if (a.crossDomain) {
  2263. var b, c;
  2264. return {
  2265. send: function (e, f) {
  2266. b = n("<script>").prop({charset: a.scriptCharset, src: a.url}).on("load error", c = function (a) {
  2267. b.remove(), c = null, a && f("error" === a.type ? 404 : 200, a.type)
  2268. }), d.head.appendChild(b[0])
  2269. }, abort: function () {
  2270. c && c()
  2271. }
  2272. }
  2273. }
  2274. });
  2275. var Jb = [], Kb = /(=)\?(?=&|$)|\?\?/;
  2276. n.ajaxSetup({
  2277. jsonp: "callback", jsonpCallback: function () {
  2278. var a = Jb.pop() || n.expando + "_" + kb++;
  2279. return this[a] = !0, a
  2280. }
  2281. }), n.ajaxPrefilter("json jsonp", function (b, c, d) {
  2282. var e, f, g,
  2283. h = b.jsonp !== !1 && (Kb.test(b.url) ? "url" : "string" == typeof b.data && 0 === (b.contentType || "").indexOf("application/x-www-form-urlencoded") && Kb.test(b.data) && "data");
  2284. return h || "jsonp" === b.dataTypes[0] ? (e = b.jsonpCallback = n.isFunction(b.jsonpCallback) ? b.jsonpCallback() : b.jsonpCallback, h ? b[h] = b[h].replace(Kb, "$1" + e) : b.jsonp !== !1 && (b.url += (lb.test(b.url) ? "&" : "?") + b.jsonp + "=" + e), b.converters["script json"] = function () {
  2285. return g || n.error(e + " was not called"), g[0]
  2286. }, b.dataTypes[0] = "json", f = a[e], a[e] = function () {
  2287. g = arguments
  2288. }, d.always(function () {
  2289. void 0 === f ? n(a).removeProp(e) : a[e] = f, b[e] && (b.jsonpCallback = c.jsonpCallback, Jb.push(e)), g && n.isFunction(f) && f(g[0]), g = f = void 0
  2290. }), "script") : void 0
  2291. }), n.parseHTML = function (a, b, c) {
  2292. if (!a || "string" != typeof a) return null;
  2293. "boolean" == typeof b && (c = b, b = !1), b = b || d;
  2294. var e = x.exec(a), f = !c && [];
  2295. return e ? [b.createElement(e[1])] : (e = ca([a], b, f), f && f.length && n(f).remove(), n.merge([], e.childNodes))
  2296. };
  2297. var Lb = n.fn.load;
  2298. n.fn.load = function (a, b, c) {
  2299. if ("string" != typeof a && Lb) return Lb.apply(this, arguments);
  2300. var d, e, f, g = this, h = a.indexOf(" ");
  2301. return h > -1 && (d = n.trim(a.slice(h)), a = a.slice(0, h)), n.isFunction(b) ? (c = b, b = void 0) : b && "object" == typeof b && (e = "POST"), g.length > 0 && n.ajax({
  2302. url: a,
  2303. type: e || "GET",
  2304. dataType: "html",
  2305. data: b
  2306. }).done(function (a) {
  2307. f = arguments, g.html(d ? n("<div>").append(n.parseHTML(a)).find(d) : a)
  2308. }).always(c && function (a, b) {
  2309. g.each(function () {
  2310. c.apply(this, f || [a.responseText, b, a])
  2311. })
  2312. }), this
  2313. }, n.each(["ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend"], function (a, b) {
  2314. n.fn[b] = function (a) {
  2315. return this.on(b, a)
  2316. }
  2317. }), n.expr.filters.animated = function (a) {
  2318. return n.grep(n.timers, function (b) {
  2319. return a === b.elem
  2320. }).length
  2321. };
  2322. function Mb(a) {
  2323. return n.isWindow(a) ? a : 9 === a.nodeType && a.defaultView
  2324. }
  2325. n.offset = {
  2326. setOffset: function (a, b, c) {
  2327. var d, e, f, g, h, i, j, k = n.css(a, "position"), l = n(a), m = {};
  2328. "static" === k && (a.style.position = "relative"), h = l.offset(), f = n.css(a, "top"), i = n.css(a, "left"), j = ("absolute" === k || "fixed" === k) && (f + i).indexOf("auto") > -1, j ? (d = l.position(), g = d.top, e = d.left) : (g = parseFloat(f) || 0, e = parseFloat(i) || 0), n.isFunction(b) && (b = b.call(a, c, n.extend({}, h))), null != b.top && (m.top = b.top - h.top + g), null != b.left && (m.left = b.left - h.left + e), "using" in b ? b.using.call(a, m) : l.css(m)
  2329. }
  2330. }, n.fn.extend({
  2331. offset: function (a) {
  2332. if (arguments.length) return void 0 === a ? this : this.each(function (b) {
  2333. n.offset.setOffset(this, a, b)
  2334. });
  2335. var b, c, d = this[0], e = {top: 0, left: 0}, f = d && d.ownerDocument;
  2336. if (f) return b = f.documentElement, n.contains(b, d) ? (e = d.getBoundingClientRect(), c = Mb(f), {
  2337. top: e.top + c.pageYOffset - b.clientTop,
  2338. left: e.left + c.pageXOffset - b.clientLeft
  2339. }) : e
  2340. }, position: function () {
  2341. if (this[0]) {
  2342. var a, b, c = this[0], d = {top: 0, left: 0};
  2343. return "fixed" === n.css(c, "position") ? b = c.getBoundingClientRect() : (a = this.offsetParent(), b = this.offset(), n.nodeName(a[0], "html") || (d = a.offset()), d.top += n.css(a[0], "borderTopWidth", !0), d.left += n.css(a[0], "borderLeftWidth", !0)), {
  2344. top: b.top - d.top - n.css(c, "marginTop", !0),
  2345. left: b.left - d.left - n.css(c, "marginLeft", !0)
  2346. }
  2347. }
  2348. }, offsetParent: function () {
  2349. return this.map(function () {
  2350. var a = this.offsetParent;
  2351. while (a && "static" === n.css(a, "position")) a = a.offsetParent;
  2352. return a || Ea
  2353. })
  2354. }
  2355. }), n.each({scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function (a, b) {
  2356. var c = "pageYOffset" === b;
  2357. n.fn[a] = function (d) {
  2358. return K(this, function (a, d, e) {
  2359. var f = Mb(a);
  2360. return void 0 === e ? f ? f[b] : a[d] : void (f ? f.scrollTo(c ? f.pageXOffset : e, c ? e : f.pageYOffset) : a[d] = e)
  2361. }, a, d, arguments.length)
  2362. }
  2363. }), n.each(["top", "left"], function (a, b) {
  2364. n.cssHooks[b] = Ga(l.pixelPosition, function (a, c) {
  2365. return c ? (c = Fa(a, b), Ba.test(c) ? n(a).position()[b] + "px" : c) : void 0
  2366. })
  2367. }), n.each({Height: "height", Width: "width"}, function (a, b) {
  2368. n.each({padding: "inner" + a, content: b, "": "outer" + a}, function (c, d) {
  2369. n.fn[d] = function (d, e) {
  2370. var f = arguments.length && (c || "boolean" != typeof d),
  2371. g = c || (d === !0 || e === !0 ? "margin" : "border");
  2372. return K(this, function (b, c, d) {
  2373. var e;
  2374. return n.isWindow(b) ? b.document.documentElement["client" + a] : 9 === b.nodeType ? (e = b.documentElement, Math.max(b.body["scroll" + a], e["scroll" + a], b.body["offset" + a], e["offset" + a], e["client" + a])) : void 0 === d ? n.css(b, c, g) : n.style(b, c, d, g)
  2375. }, b, f ? d : void 0, f, null)
  2376. }
  2377. })
  2378. }), n.fn.extend({
  2379. bind: function (a, b, c) {
  2380. return this.on(a, null, b, c)
  2381. }, unbind: function (a, b) {
  2382. return this.off(a, null, b)
  2383. }, delegate: function (a, b, c, d) {
  2384. return this.on(b, a, c, d)
  2385. }, undelegate: function (a, b, c) {
  2386. return 1 === arguments.length ? this.off(a, "**") : this.off(b, a || "**", c)
  2387. }, size: function () {
  2388. return this.length
  2389. }
  2390. }), n.fn.andSelf = n.fn.addBack, "function" == typeof define && define.amd && define("jquery", [], function () {
  2391. return n
  2392. });
  2393. var Nb = a.jQuery, Ob = a.$;
  2394. return n.noConflict = function (b) {
  2395. return a.$ === n && (a.$ = Ob), b && a.jQuery === n && (a.jQuery = Nb), n
  2396. }, b || (a.jQuery = a.$ = n), n
  2397. });
  2398. /*!
  2399. * Bootstrap v3.4.1 (https://getbootstrap.com/)
  2400. * Copyright 2011-2019 Twitter, Inc.
  2401. * Licensed under the MIT license
  2402. */
  2403. if ("undefined" == typeof jQuery) throw new Error("Bootstrap's JavaScript requires jQuery");
  2404. !function (t) {
  2405. "use strict";
  2406. var e = jQuery.fn.jquery.split(" ")[0].split(".");
  2407. 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")
  2408. }(), function (n) {
  2409. "use strict";
  2410. n.fn.emulateTransitionEnd = function (t) {
  2411. var e = !1, i = this;
  2412. n(this).one("bsTransitionEnd", function () {
  2413. e = !0
  2414. });
  2415. return setTimeout(function () {
  2416. e || n(i).trigger(n.support.transition.end)
  2417. }, t), this
  2418. }, n(function () {
  2419. n.support.transition = function o() {
  2420. var t = document.createElement("bootstrap"), e = {
  2421. WebkitTransition: "webkitTransitionEnd",
  2422. MozTransition: "transitionend",
  2423. OTransition: "oTransitionEnd otransitionend",
  2424. transition: "transitionend"
  2425. };
  2426. for (var i in e) if (t.style[i] !== undefined) return {end: e[i]};
  2427. return !1
  2428. }(), n.support.transition && (n.event.special.bsTransitionEnd = {
  2429. bindType: n.support.transition.end,
  2430. delegateType: n.support.transition.end,
  2431. handle: function (t) {
  2432. if (n(t.target).is(this)) return t.handleObj.handler.apply(this, arguments)
  2433. }
  2434. })
  2435. })
  2436. }(jQuery), function (s) {
  2437. "use strict";
  2438. var e = '[data-dismiss="alert"]', a = function (t) {
  2439. s(t).on("click", e, this.close)
  2440. };
  2441. a.VERSION = "3.4.1", a.TRANSITION_DURATION = 150, a.prototype.close = function (t) {
  2442. var e = s(this), i = e.attr("data-target");
  2443. i || (i = (i = e.attr("href")) && i.replace(/.*(?=#[^\s]*$)/, "")), i = "#" === i ? [] : i;
  2444. var o = s(document).find(i);
  2445. function n() {
  2446. o.detach().trigger("closed.bs.alert").remove()
  2447. }
  2448. 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())
  2449. };
  2450. var t = s.fn.alert;
  2451. s.fn.alert = function o(i) {
  2452. return this.each(function () {
  2453. var t = s(this), e = t.data("bs.alert");
  2454. e || t.data("bs.alert", e = new a(this)), "string" == typeof i && e[i].call(t)
  2455. })
  2456. }, s.fn.alert.Constructor = a, s.fn.alert.noConflict = function () {
  2457. return s.fn.alert = t, this
  2458. }, s(document).on("click.bs.alert.data-api", e, a.prototype.close)
  2459. }(jQuery), function (s) {
  2460. "use strict";
  2461. var n = function (t, e) {
  2462. this.$element = s(t), this.options = s.extend({}, n.DEFAULTS, e), this.isLoading = !1
  2463. };
  2464. function i(o) {
  2465. return this.each(function () {
  2466. var t = s(this), e = t.data("bs.button"), i = "object" == typeof o && o;
  2467. e || t.data("bs.button", e = new n(this, i)), "toggle" == o ? e.toggle() : o && e.setState(o)
  2468. })
  2469. }
  2470. n.VERSION = "3.4.1", n.DEFAULTS = {loadingText: "loading..."}, n.prototype.setState = function (t) {
  2471. var e = "disabled", i = this.$element, o = i.is("input") ? "val" : "html", n = i.data();
  2472. t += "Text", null == n.resetText && i.data("resetText", i[o]()), setTimeout(s.proxy(function () {
  2473. 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))
  2474. }, this), 0)
  2475. }, n.prototype.toggle = function () {
  2476. var t = !0, e = this.$element.closest('[data-toggle="buttons"]');
  2477. if (e.length) {
  2478. var i = this.$element.find("input");
  2479. "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")
  2480. } else this.$element.attr("aria-pressed", !this.$element.hasClass("active")), this.$element.toggleClass("active")
  2481. };
  2482. var t = s.fn.button;
  2483. s.fn.button = i, s.fn.button.Constructor = n, s.fn.button.noConflict = function () {
  2484. return s.fn.button = t, this
  2485. }, s(document).on("click.bs.button.data-api", '[data-toggle^="button"]', function (t) {
  2486. var e = s(t.target).closest(".btn");
  2487. 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"))
  2488. }).on("focus.bs.button.data-api blur.bs.button.data-api", '[data-toggle^="button"]', function (t) {
  2489. s(t.target).closest(".btn").toggleClass("focus", /^focus(in)?$/.test(t.type))
  2490. })
  2491. }(jQuery), function (p) {
  2492. "use strict";
  2493. var c = function (t, e) {
  2494. 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))
  2495. };
  2496. function r(n) {
  2497. return this.each(function () {
  2498. var t = p(this), e = t.data("bs.carousel"),
  2499. i = p.extend({}, c.DEFAULTS, t.data(), "object" == typeof n && n),
  2500. o = "string" == typeof n ? n : i.slide;
  2501. e || t.data("bs.carousel", e = new c(this, i)), "number" == typeof n ? e.to(n) : o ? e[o]() : i.interval && e.pause().cycle()
  2502. })
  2503. }
  2504. c.VERSION = "3.4.1", c.TRANSITION_DURATION = 600, c.DEFAULTS = {
  2505. interval: 5e3,
  2506. pause: "hover",
  2507. wrap: !0,
  2508. keyboard: !0
  2509. }, c.prototype.keydown = function (t) {
  2510. if (!/input|textarea/i.test(t.target.tagName)) {
  2511. switch (t.which) {
  2512. case 37:
  2513. this.prev();
  2514. break;
  2515. case 39:
  2516. this.next();
  2517. break;
  2518. default:
  2519. return
  2520. }
  2521. t.preventDefault()
  2522. }
  2523. }, c.prototype.cycle = function (t) {
  2524. 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
  2525. }, c.prototype.getItemIndex = function (t) {
  2526. return this.$items = t.parent().children(".item"), this.$items.index(t || this.$active)
  2527. }, c.prototype.getItemForDirection = function (t, e) {
  2528. var i = this.getItemIndex(e);
  2529. if (("prev" == t && 0 === i || "next" == t && i == this.$items.length - 1) && !this.options.wrap) return e;
  2530. var o = (i + ("prev" == t ? -1 : 1)) % this.$items.length;
  2531. return this.$items.eq(o)
  2532. }, c.prototype.to = function (t) {
  2533. var e = this, i = this.getItemIndex(this.$active = this.$element.find(".item.active"));
  2534. if (!(t > this.$items.length - 1 || t < 0)) return this.sliding ? this.$element.one("slid.bs.carousel", function () {
  2535. e.to(t)
  2536. }) : i == t ? this.pause().cycle() : this.slide(i < t ? "next" : "prev", this.$items.eq(t))
  2537. }, c.prototype.pause = function (t) {
  2538. 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
  2539. }, c.prototype.next = function () {
  2540. if (!this.sliding) return this.slide("next")
  2541. }, c.prototype.prev = function () {
  2542. if (!this.sliding) return this.slide("prev")
  2543. }, c.prototype.slide = function (t, e) {
  2544. var i = this.$element.find(".item.active"), o = e || this.getItemForDirection(t, i), n = this.interval,
  2545. s = "next" == t ? "left" : "right", a = this;
  2546. if (o.hasClass("active")) return this.sliding = !1;
  2547. var r = o[0], l = p.Event("slide.bs.carousel", {relatedTarget: r, direction: s});
  2548. if (this.$element.trigger(l), !l.isDefaultPrevented()) {
  2549. if (this.sliding = !0, n && this.pause(), this.$indicators.length) {
  2550. this.$indicators.find(".active").removeClass("active");
  2551. var h = p(this.$indicators.children()[this.getItemIndex(o)]);
  2552. h && h.addClass("active")
  2553. }
  2554. var d = p.Event("slid.bs.carousel", {relatedTarget: r, direction: s});
  2555. 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 () {
  2556. o.removeClass([t, s].join(" ")).addClass("active"), i.removeClass(["active", s].join(" ")), a.sliding = !1, setTimeout(function () {
  2557. a.$element.trigger(d)
  2558. }, 0)
  2559. }).emulateTransitionEnd(c.TRANSITION_DURATION)) : (i.removeClass("active"), o.addClass("active"), this.sliding = !1, this.$element.trigger(d)), n && this.cycle(), this
  2560. }
  2561. };
  2562. var t = p.fn.carousel;
  2563. p.fn.carousel = r, p.fn.carousel.Constructor = c, p.fn.carousel.noConflict = function () {
  2564. return p.fn.carousel = t, this
  2565. };
  2566. var e = function (t) {
  2567. var e = p(this), i = e.attr("href");
  2568. i && (i = i.replace(/.*(?=#[^\s]+$)/, ""));
  2569. var o = e.attr("data-target") || i, n = p(document).find(o);
  2570. if (n.hasClass("carousel")) {
  2571. var s = p.extend({}, n.data(), e.data()), a = e.attr("data-slide-to");
  2572. a && (s.interval = !1), r.call(n, s), a && n.data("bs.carousel").to(a), t.preventDefault()
  2573. }
  2574. };
  2575. 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 () {
  2576. p('[data-ride="carousel"]').each(function () {
  2577. var t = p(this);
  2578. r.call(t, t.data())
  2579. })
  2580. })
  2581. }(jQuery), function (a) {
  2582. "use strict";
  2583. var r = function (t, e) {
  2584. 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()
  2585. };
  2586. function n(t) {
  2587. var e, i = t.attr("data-target") || (e = t.attr("href")) && e.replace(/.*(?=#[^\s]+$)/, "");
  2588. return a(document).find(i)
  2589. }
  2590. function l(o) {
  2591. return this.each(function () {
  2592. var t = a(this), e = t.data("bs.collapse"),
  2593. i = a.extend({}, r.DEFAULTS, t.data(), "object" == typeof o && o);
  2594. !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]()
  2595. })
  2596. }
  2597. r.VERSION = "3.4.1", r.TRANSITION_DURATION = 350, r.DEFAULTS = {toggle: !0}, r.prototype.dimension = function () {
  2598. return this.$element.hasClass("width") ? "width" : "height"
  2599. }, r.prototype.show = function () {
  2600. if (!this.transitioning && !this.$element.hasClass("in")) {
  2601. var t, e = this.$parent && this.$parent.children(".panel").children(".in, .collapsing");
  2602. if (!(e && e.length && (t = e.data("bs.collapse")) && t.transitioning)) {
  2603. var i = a.Event("show.bs.collapse");
  2604. if (this.$element.trigger(i), !i.isDefaultPrevented()) {
  2605. e && e.length && (l.call(e, "hide"), t || e.data("bs.collapse", null));
  2606. var o = this.dimension();
  2607. this.$element.removeClass("collapse").addClass("collapsing")[o](0).attr("aria-expanded", !0), this.$trigger.removeClass("collapsed").attr("aria-expanded", !0), this.transitioning = 1;
  2608. var n = function () {
  2609. this.$element.removeClass("collapsing").addClass("collapse in")[o](""), this.transitioning = 0, this.$element.trigger("shown.bs.collapse")
  2610. };
  2611. if (!a.support.transition) return n.call(this);
  2612. var s = a.camelCase(["scroll", o].join("-"));
  2613. this.$element.one("bsTransitionEnd", a.proxy(n, this)).emulateTransitionEnd(r.TRANSITION_DURATION)[o](this.$element[0][s])
  2614. }
  2615. }
  2616. }
  2617. }, r.prototype.hide = function () {
  2618. if (!this.transitioning && this.$element.hasClass("in")) {
  2619. var t = a.Event("hide.bs.collapse");
  2620. if (this.$element.trigger(t), !t.isDefaultPrevented()) {
  2621. var e = this.dimension();
  2622. 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;
  2623. var i = function () {
  2624. this.transitioning = 0, this.$element.removeClass("collapsing").addClass("collapse").trigger("hidden.bs.collapse")
  2625. };
  2626. if (!a.support.transition) return i.call(this);
  2627. this.$element[e](0).one("bsTransitionEnd", a.proxy(i, this)).emulateTransitionEnd(r.TRANSITION_DURATION)
  2628. }
  2629. }
  2630. }, r.prototype.toggle = function () {
  2631. this[this.$element.hasClass("in") ? "hide" : "show"]()
  2632. }, r.prototype.getParent = function () {
  2633. return a(document).find(this.options.parent).find('[data-toggle="collapse"][data-parent="' + this.options.parent + '"]').each(a.proxy(function (t, e) {
  2634. var i = a(e);
  2635. this.addAriaAndCollapsedClass(n(i), i)
  2636. }, this)).end()
  2637. }, r.prototype.addAriaAndCollapsedClass = function (t, e) {
  2638. var i = t.hasClass("in");
  2639. t.attr("aria-expanded", i), e.toggleClass("collapsed", !i).attr("aria-expanded", i)
  2640. };
  2641. var t = a.fn.collapse;
  2642. a.fn.collapse = l, a.fn.collapse.Constructor = r, a.fn.collapse.noConflict = function () {
  2643. return a.fn.collapse = t, this
  2644. }, a(document).on("click.bs.collapse.data-api", '[data-toggle="collapse"]', function (t) {
  2645. var e = a(this);
  2646. e.attr("data-target") || t.preventDefault();
  2647. var i = n(e), o = i.data("bs.collapse") ? "toggle" : e.data();
  2648. l.call(i, o)
  2649. })
  2650. }(jQuery), function (a) {
  2651. "use strict";
  2652. var r = '[data-toggle="dropdown"]', o = function (t) {
  2653. a(t).on("click.bs.dropdown", this.toggle)
  2654. };
  2655. function l(t) {
  2656. var e = t.attr("data-target");
  2657. e || (e = (e = t.attr("href")) && /#[A-Za-z]/.test(e) && e.replace(/.*(?=#[^\s]*$)/, ""));
  2658. var i = "#" !== e ? a(document).find(e) : null;
  2659. return i && i.length ? i : t.parent()
  2660. }
  2661. function s(o) {
  2662. o && 3 === o.which || (a(".dropdown-backdrop").remove(), a(r).each(function () {
  2663. var t = a(this), e = l(t), i = {relatedTarget: this};
  2664. 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)))))
  2665. }))
  2666. }
  2667. o.VERSION = "3.4.1", o.prototype.toggle = function (t) {
  2668. var e = a(this);
  2669. if (!e.is(".disabled, :disabled")) {
  2670. var i = l(e), o = i.hasClass("open");
  2671. if (s(), !o) {
  2672. "ontouchstart" in document.documentElement && !i.closest(".navbar-nav").length && a(document.createElement("div")).addClass("dropdown-backdrop").insertAfter(a(this)).on("click", s);
  2673. var n = {relatedTarget: this};
  2674. if (i.trigger(t = a.Event("show.bs.dropdown", n)), t.isDefaultPrevented()) return;
  2675. e.trigger("focus").attr("aria-expanded", "true"), i.toggleClass("open").trigger(a.Event("shown.bs.dropdown", n))
  2676. }
  2677. return !1
  2678. }
  2679. }, o.prototype.keydown = function (t) {
  2680. if (/(38|40|27|32)/.test(t.which) && !/input|textarea/i.test(t.target.tagName)) {
  2681. var e = a(this);
  2682. if (t.preventDefault(), t.stopPropagation(), !e.is(".disabled, :disabled")) {
  2683. var i = l(e), o = i.hasClass("open");
  2684. if (!o && 27 != t.which || o && 27 == t.which) return 27 == t.which && i.find(r).trigger("focus"), e.trigger("click");
  2685. var n = i.find(".dropdown-menu li:not(.disabled):visible a");
  2686. if (n.length) {
  2687. var s = n.index(t.target);
  2688. 38 == t.which && 0 < s && s--, 40 == t.which && s < n.length - 1 && s++, ~s || (s = 0), n.eq(s).trigger("focus")
  2689. }
  2690. }
  2691. }
  2692. };
  2693. var t = a.fn.dropdown;
  2694. a.fn.dropdown = function e(i) {
  2695. return this.each(function () {
  2696. var t = a(this), e = t.data("bs.dropdown");
  2697. e || t.data("bs.dropdown", e = new o(this)), "string" == typeof i && e[i].call(t)
  2698. })
  2699. }, a.fn.dropdown.Constructor = o, a.fn.dropdown.noConflict = function () {
  2700. return a.fn.dropdown = t, this
  2701. }, a(document).on("click.bs.dropdown.data-api", s).on("click.bs.dropdown.data-api", ".dropdown form", function (t) {
  2702. t.stopPropagation()
  2703. }).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)
  2704. }(jQuery), function (a) {
  2705. "use strict";
  2706. var s = function (t, e) {
  2707. 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 () {
  2708. this.$element.trigger("loaded.bs.modal")
  2709. }, this))
  2710. };
  2711. function r(o, n) {
  2712. return this.each(function () {
  2713. var t = a(this), e = t.data("bs.modal"), i = a.extend({}, s.DEFAULTS, t.data(), "object" == typeof o && o);
  2714. e || t.data("bs.modal", e = new s(this, i)), "string" == typeof o ? e[o](n) : i.show && e.show(n)
  2715. })
  2716. }
  2717. s.VERSION = "3.4.1", s.TRANSITION_DURATION = 300, s.BACKDROP_TRANSITION_DURATION = 150, s.DEFAULTS = {
  2718. backdrop: !0,
  2719. keyboard: !0,
  2720. show: !0
  2721. }, s.prototype.toggle = function (t) {
  2722. return this.isShown ? this.hide() : this.show(t)
  2723. }, s.prototype.show = function (i) {
  2724. var o = this, t = a.Event("show.bs.modal", {relatedTarget: i});
  2725. 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 () {
  2726. o.$element.one("mouseup.dismiss.bs.modal", function (t) {
  2727. a(t.target).is(o.$element) && (o.ignoreBackdropClick = !0)
  2728. })
  2729. }), this.backdrop(function () {
  2730. var t = a.support.transition && o.$element.hasClass("fade");
  2731. 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();
  2732. var e = a.Event("shown.bs.modal", {relatedTarget: i});
  2733. t ? o.$dialog.one("bsTransitionEnd", function () {
  2734. o.$element.trigger("focus").trigger(e)
  2735. }).emulateTransitionEnd(s.TRANSITION_DURATION) : o.$element.trigger("focus").trigger(e)
  2736. }))
  2737. }, s.prototype.hide = function (t) {
  2738. 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())
  2739. }, s.prototype.enforceFocus = function () {
  2740. a(document).off("focusin.bs.modal").on("focusin.bs.modal", a.proxy(function (t) {
  2741. document === t.target || this.$element[0] === t.target || this.$element.has(t.target).length || this.$element.trigger("focus")
  2742. }, this))
  2743. }, s.prototype.escape = function () {
  2744. this.isShown && this.options.keyboard ? this.$element.on("keydown.dismiss.bs.modal", a.proxy(function (t) {
  2745. 27 == t.which && this.hide()
  2746. }, this)) : this.isShown || this.$element.off("keydown.dismiss.bs.modal")
  2747. }, s.prototype.resize = function () {
  2748. this.isShown ? a(window).on("resize.bs.modal", a.proxy(this.handleUpdate, this)) : a(window).off("resize.bs.modal")
  2749. }, s.prototype.hideModal = function () {
  2750. var t = this;
  2751. this.$element.hide(), this.backdrop(function () {
  2752. t.$body.removeClass("modal-open"), t.resetAdjustments(), t.resetScrollbar(), t.$element.trigger("hidden.bs.modal")
  2753. })
  2754. }, s.prototype.removeBackdrop = function () {
  2755. this.$backdrop && this.$backdrop.remove(), this.$backdrop = null
  2756. }, s.prototype.backdrop = function (t) {
  2757. var e = this, i = this.$element.hasClass("fade") ? "fade" : "";
  2758. if (this.isShown && this.options.backdrop) {
  2759. var o = a.support.transition && i;
  2760. 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) {
  2761. this.ignoreBackdropClick ? this.ignoreBackdropClick = !1 : t.target === t.currentTarget && ("static" == this.options.backdrop ? this.$element[0].focus() : this.hide())
  2762. }, this)), o && this.$backdrop[0].offsetWidth, this.$backdrop.addClass("in"), !t) return;
  2763. o ? this.$backdrop.one("bsTransitionEnd", t).emulateTransitionEnd(s.BACKDROP_TRANSITION_DURATION) : t()
  2764. } else if (!this.isShown && this.$backdrop) {
  2765. this.$backdrop.removeClass("in");
  2766. var n = function () {
  2767. e.removeBackdrop(), t && t()
  2768. };
  2769. a.support.transition && this.$element.hasClass("fade") ? this.$backdrop.one("bsTransitionEnd", n).emulateTransitionEnd(s.BACKDROP_TRANSITION_DURATION) : n()
  2770. } else t && t()
  2771. }, s.prototype.handleUpdate = function () {
  2772. this.adjustDialog()
  2773. }, s.prototype.adjustDialog = function () {
  2774. var t = this.$element[0].scrollHeight > document.documentElement.clientHeight;
  2775. this.$element.css({
  2776. paddingLeft: !this.bodyIsOverflowing && t ? this.scrollbarWidth : "",
  2777. paddingRight: this.bodyIsOverflowing && !t ? this.scrollbarWidth : ""
  2778. })
  2779. }, s.prototype.resetAdjustments = function () {
  2780. this.$element.css({paddingLeft: "", paddingRight: ""})
  2781. }, s.prototype.checkScrollbar = function () {
  2782. var t = window.innerWidth;
  2783. if (!t) {
  2784. var e = document.documentElement.getBoundingClientRect();
  2785. t = e.right - Math.abs(e.left)
  2786. }
  2787. this.bodyIsOverflowing = document.body.clientWidth < t, this.scrollbarWidth = this.measureScrollbar()
  2788. }, s.prototype.setScrollbar = function () {
  2789. var t = parseInt(this.$body.css("padding-right") || 0, 10);
  2790. this.originalBodyPad = document.body.style.paddingRight || "";
  2791. var n = this.scrollbarWidth;
  2792. this.bodyIsOverflowing && (this.$body.css("padding-right", t + n), a(this.fixedContent).each(function (t, e) {
  2793. var i = e.style.paddingRight, o = a(e).css("padding-right");
  2794. a(e).data("padding-right", i).css("padding-right", parseFloat(o) + n + "px")
  2795. }))
  2796. }, s.prototype.resetScrollbar = function () {
  2797. this.$body.css("padding-right", this.originalBodyPad), a(this.fixedContent).each(function (t, e) {
  2798. var i = a(e).data("padding-right");
  2799. a(e).removeData("padding-right"), e.style.paddingRight = i || ""
  2800. })
  2801. }, s.prototype.measureScrollbar = function () {
  2802. var t = document.createElement("div");
  2803. t.className = "modal-scrollbar-measure", this.$body.append(t);
  2804. var e = t.offsetWidth - t.clientWidth;
  2805. return this.$body[0].removeChild(t), e
  2806. };
  2807. var t = a.fn.modal;
  2808. a.fn.modal = r, a.fn.modal.Constructor = s, a.fn.modal.noConflict = function () {
  2809. return a.fn.modal = t, this
  2810. }, a(document).on("click.bs.modal.data-api", '[data-toggle="modal"]', function (t) {
  2811. var e = a(this), i = e.attr("href"), o = e.attr("data-target") || i && i.replace(/.*(?=#[^\s]+$)/, ""),
  2812. n = a(document).find(o),
  2813. s = n.data("bs.modal") ? "toggle" : a.extend({remote: !/#/.test(i) && i}, n.data(), e.data());
  2814. e.is("a") && t.preventDefault(), n.one("show.bs.modal", function (t) {
  2815. t.isDefaultPrevented() || n.one("hidden.bs.modal", function () {
  2816. e.is(":visible") && e.trigger("focus")
  2817. })
  2818. }), r.call(n, s, this)
  2819. })
  2820. }(jQuery), function (g) {
  2821. "use strict";
  2822. var o = ["sanitize", "whiteList", "sanitizeFn"],
  2823. a = ["background", "cite", "href", "itemtype", "longdesc", "poster", "src", "xlink:href"], t = {
  2824. "*": ["class", "dir", "id", "lang", "role", /^aria-[\w-]*$/i],
  2825. a: ["target", "href", "title", "rel"],
  2826. area: [],
  2827. b: [],
  2828. br: [],
  2829. col: [],
  2830. code: [],
  2831. div: [],
  2832. em: [],
  2833. hr: [],
  2834. h1: [],
  2835. h2: [],
  2836. h3: [],
  2837. h4: [],
  2838. h5: [],
  2839. h6: [],
  2840. i: [],
  2841. img: ["src", "alt", "title", "width", "height"],
  2842. li: [],
  2843. ol: [],
  2844. p: [],
  2845. pre: [],
  2846. s: [],
  2847. small: [],
  2848. span: [],
  2849. sub: [],
  2850. sup: [],
  2851. strong: [],
  2852. u: [],
  2853. ul: []
  2854. }, r = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi,
  2855. 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;
  2856. function u(t, e) {
  2857. var i = t.nodeName.toLowerCase();
  2858. if (-1 !== g.inArray(i, e)) return -1 === g.inArray(i, a) || Boolean(t.nodeValue.match(r) || t.nodeValue.match(l));
  2859. for (var o = g(e).filter(function (t, e) {
  2860. return e instanceof RegExp
  2861. }), n = 0, s = o.length; n < s; n++) if (i.match(o[n])) return !0;
  2862. return !1
  2863. }
  2864. function n(t, e, i) {
  2865. if (0 === t.length) return t;
  2866. if (i && "function" == typeof i) return i(t);
  2867. if (!document.implementation || !document.implementation.createHTMLDocument) return t;
  2868. var o = document.implementation.createHTMLDocument("sanitization");
  2869. o.body.innerHTML = t;
  2870. for (var n = g.map(e, function (t, e) {
  2871. return e
  2872. }), s = g(o.body).find("*"), a = 0, r = s.length; a < r; a++) {
  2873. var l = s[a], h = l.nodeName.toLowerCase();
  2874. if (-1 !== g.inArray(h, n)) for (var d = g.map(l.attributes, function (t) {
  2875. return t
  2876. }), 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)
  2877. }
  2878. return o.body.innerHTML
  2879. }
  2880. var m = function (t, e) {
  2881. 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)
  2882. };
  2883. m.VERSION = "3.4.1", m.TRANSITION_DURATION = 150, m.DEFAULTS = {
  2884. animation: !0,
  2885. placement: "top",
  2886. selector: !1,
  2887. template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
  2888. trigger: "hover focus",
  2889. title: "",
  2890. delay: 0,
  2891. html: !1,
  2892. container: !1,
  2893. viewport: {selector: "body", padding: 0},
  2894. sanitize: !0,
  2895. sanitizeFn: null,
  2896. whiteList: t
  2897. }, m.prototype.init = function (t, e, i) {
  2898. 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 = {
  2899. click: !1,
  2900. hover: !1,
  2901. focus: !1
  2902. }, 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!");
  2903. for (var o = this.options.trigger.split(" "), n = o.length; n--;) {
  2904. var s = o[n];
  2905. if ("click" == s) this.$element.on("click." + this.type, this.options.selector, g.proxy(this.toggle, this)); else if ("manual" != s) {
  2906. var a = "hover" == s ? "mouseenter" : "focusin", r = "hover" == s ? "mouseleave" : "focusout";
  2907. 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))
  2908. }
  2909. }
  2910. this.options.selector ? this._options = g.extend({}, this.options, {
  2911. trigger: "manual",
  2912. selector: ""
  2913. }) : this.fixTitle()
  2914. }, m.prototype.getDefaults = function () {
  2915. return m.DEFAULTS
  2916. }, m.prototype.getOptions = function (t) {
  2917. var e = this.$element.data();
  2918. for (var i in e) e.hasOwnProperty(i) && -1 !== g.inArray(i, o) && delete e[i];
  2919. return (t = g.extend({}, this.getDefaults(), e, t)).delay && "number" == typeof t.delay && (t.delay = {
  2920. show: t.delay,
  2921. hide: t.delay
  2922. }), t.sanitize && (t.template = n(t.template, t.whiteList, t.sanitizeFn)), t
  2923. }, m.prototype.getDelegateOptions = function () {
  2924. var i = {}, o = this.getDefaults();
  2925. return this._options && g.each(this._options, function (t, e) {
  2926. o[t] != e && (i[t] = e)
  2927. }), i
  2928. }, m.prototype.enter = function (t) {
  2929. var e = t instanceof this.constructor ? t : g(t.currentTarget).data("bs." + this.type);
  2930. 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 {
  2931. if (clearTimeout(e.timeout), e.hoverState = "in", !e.options.delay || !e.options.delay.show) return e.show();
  2932. e.timeout = setTimeout(function () {
  2933. "in" == e.hoverState && e.show()
  2934. }, e.options.delay.show)
  2935. }
  2936. }, m.prototype.isInStateTrue = function () {
  2937. for (var t in this.inState) if (this.inState[t]) return !0;
  2938. return !1
  2939. }, m.prototype.leave = function (t) {
  2940. var e = t instanceof this.constructor ? t : g(t.currentTarget).data("bs." + this.type);
  2941. 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()) {
  2942. if (clearTimeout(e.timeout), e.hoverState = "out", !e.options.delay || !e.options.delay.hide) return e.hide();
  2943. e.timeout = setTimeout(function () {
  2944. "out" == e.hoverState && e.hide()
  2945. }, e.options.delay.hide)
  2946. }
  2947. }, m.prototype.show = function () {
  2948. var t = g.Event("show.bs." + this.type);
  2949. if (this.hasContent() && this.enabled) {
  2950. this.$element.trigger(t);
  2951. var e = g.contains(this.$element[0].ownerDocument.documentElement, this.$element[0]);
  2952. if (t.isDefaultPrevented() || !e) return;
  2953. var i = this, o = this.tip(), n = this.getUID(this.type);
  2954. this.setContent(), o.attr("id", n), this.$element.attr("aria-describedby", n), this.options.animation && o.addClass("fade");
  2955. var s = "function" == typeof this.options.placement ? this.options.placement.call(this, o[0], this.$element[0]) : this.options.placement,
  2956. a = /\s?auto?\s?/i, r = a.test(s);
  2957. r && (s = s.replace(a, "") || "top"), o.detach().css({
  2958. top: 0,
  2959. left: 0,
  2960. display: "block"
  2961. }).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);
  2962. var l = this.getPosition(), h = o[0].offsetWidth, d = o[0].offsetHeight;
  2963. if (r) {
  2964. var p = s, c = this.getPosition(this.$viewport);
  2965. 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)
  2966. }
  2967. var f = this.getCalculatedOffset(s, l, h, d);
  2968. this.applyPlacement(f, s);
  2969. var u = function () {
  2970. var t = i.hoverState;
  2971. i.$element.trigger("shown.bs." + i.type), i.hoverState = null, "out" == t && i.leave(i)
  2972. };
  2973. g.support.transition && this.$tip.hasClass("fade") ? o.one("bsTransitionEnd", u).emulateTransitionEnd(m.TRANSITION_DURATION) : u()
  2974. }
  2975. }, m.prototype.applyPlacement = function (t, e) {
  2976. var i = this.tip(), o = i[0].offsetWidth, n = i[0].offsetHeight, s = parseInt(i.css("margin-top"), 10),
  2977. a = parseInt(i.css("margin-left"), 10);
  2978. isNaN(s) && (s = 0), isNaN(a) && (a = 0), t.top += s, t.left += a, g.offset.setOffset(i[0], g.extend({
  2979. using: function (t) {
  2980. i.css({top: Math.round(t.top), left: Math.round(t.left)})
  2981. }
  2982. }, t), 0), i.addClass("in");
  2983. var r = i[0].offsetWidth, l = i[0].offsetHeight;
  2984. "top" == e && l != n && (t.top = t.top + n - l);
  2985. var h = this.getViewportAdjustedDelta(e, t, r, l);
  2986. h.left ? t.left += h.left : t.top += h.top;
  2987. var d = /top|bottom/.test(e), p = d ? 2 * h.left - o + r : 2 * h.top - n + l,
  2988. c = d ? "offsetWidth" : "offsetHeight";
  2989. i.offset(t), this.replaceArrow(p, i[0][c], d)
  2990. }, m.prototype.replaceArrow = function (t, e, i) {
  2991. this.arrow().css(i ? "left" : "top", 50 * (1 - t / e) + "%").css(i ? "top" : "left", "")
  2992. }, m.prototype.setContent = function () {
  2993. var t = this.tip(), e = this.getTitle();
  2994. 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")
  2995. }, m.prototype.hide = function (t) {
  2996. var e = this, i = g(this.$tip), o = g.Event("hide.bs." + this.type);
  2997. function n() {
  2998. "in" != e.hoverState && i.detach(), e.$element && e.$element.removeAttr("aria-describedby").trigger("hidden.bs." + e.type), t && t()
  2999. }
  3000. 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
  3001. }, m.prototype.fixTitle = function () {
  3002. var t = this.$element;
  3003. (t.attr("title") || "string" != typeof t.attr("data-original-title")) && t.attr("data-original-title", t.attr("title") || "").attr("title", "")
  3004. }, m.prototype.hasContent = function () {
  3005. return this.getTitle()
  3006. }, m.prototype.getPosition = function (t) {
  3007. var e = (t = t || this.$element)[0], i = "BODY" == e.tagName, o = e.getBoundingClientRect();
  3008. null == o.width && (o = g.extend({}, o, {width: o.right - o.left, height: o.bottom - o.top}));
  3009. var n = window.SVGElement && e instanceof window.SVGElement, s = i ? {top: 0, left: 0} : n ? null : t.offset(),
  3010. a = {scroll: i ? document.documentElement.scrollTop || document.body.scrollTop : t.scrollTop()},
  3011. r = i ? {width: g(window).width(), height: g(window).height()} : null;
  3012. return g.extend({}, o, a, r, s)
  3013. }, m.prototype.getCalculatedOffset = function (t, e, i, o) {
  3014. return "bottom" == t ? {
  3015. top: e.top + e.height,
  3016. left: e.left + e.width / 2 - i / 2
  3017. } : "top" == t ? {
  3018. top: e.top - o,
  3019. left: e.left + e.width / 2 - i / 2
  3020. } : "left" == t ? {top: e.top + e.height / 2 - o / 2, left: e.left - i} : {
  3021. top: e.top + e.height / 2 - o / 2,
  3022. left: e.left + e.width
  3023. }
  3024. }, m.prototype.getViewportAdjustedDelta = function (t, e, i, o) {
  3025. var n = {top: 0, left: 0};
  3026. if (!this.$viewport) return n;
  3027. var s = this.options.viewport && this.options.viewport.padding || 0, a = this.getPosition(this.$viewport);
  3028. if (/right|left/.test(t)) {
  3029. var r = e.top - s - a.scroll, l = e.top + s - a.scroll + o;
  3030. r < a.top ? n.top = a.top - r : l > a.top + a.height && (n.top = a.top + a.height - l)
  3031. } else {
  3032. var h = e.left - s, d = e.left + s + i;
  3033. h < a.left ? n.left = a.left - h : d > a.right && (n.left = a.left + a.width - d)
  3034. }
  3035. return n
  3036. }, m.prototype.getTitle = function () {
  3037. var t = this.$element, e = this.options;
  3038. return t.attr("data-original-title") || ("function" == typeof e.title ? e.title.call(t[0]) : e.title)
  3039. }, m.prototype.getUID = function (t) {
  3040. for (; t += ~~(1e6 * Math.random()), document.getElementById(t);) ;
  3041. return t
  3042. }, m.prototype.tip = function () {
  3043. 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!");
  3044. return this.$tip
  3045. }, m.prototype.arrow = function () {
  3046. return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow")
  3047. }, m.prototype.enable = function () {
  3048. this.enabled = !0
  3049. }, m.prototype.disable = function () {
  3050. this.enabled = !1
  3051. }, m.prototype.toggleEnabled = function () {
  3052. this.enabled = !this.enabled
  3053. }, m.prototype.toggle = function (t) {
  3054. var e = this;
  3055. 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)
  3056. }, m.prototype.destroy = function () {
  3057. var t = this;
  3058. clearTimeout(this.timeout), this.hide(function () {
  3059. 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
  3060. })
  3061. }, m.prototype.sanitizeHtml = function (t) {
  3062. return n(t, this.options.whiteList, this.options.sanitizeFn)
  3063. };
  3064. var e = g.fn.tooltip;
  3065. g.fn.tooltip = function i(o) {
  3066. return this.each(function () {
  3067. var t = g(this), e = t.data("bs.tooltip"), i = "object" == typeof o && o;
  3068. !e && /destroy|hide/.test(o) || (e || t.data("bs.tooltip", e = new m(this, i)), "string" == typeof o && e[o]())
  3069. })
  3070. }, g.fn.tooltip.Constructor = m, g.fn.tooltip.noConflict = function () {
  3071. return g.fn.tooltip = e, this
  3072. }
  3073. }(jQuery), function (n) {
  3074. "use strict";
  3075. var s = function (t, e) {
  3076. this.init("popover", t, e)
  3077. };
  3078. if (!n.fn.tooltip) throw new Error("Popover requires tooltip.js");
  3079. s.VERSION = "3.4.1", s.DEFAULTS = n.extend({}, n.fn.tooltip.Constructor.DEFAULTS, {
  3080. placement: "right",
  3081. trigger: "click",
  3082. content: "",
  3083. template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
  3084. }), ((s.prototype = n.extend({}, n.fn.tooltip.Constructor.prototype)).constructor = s).prototype.getDefaults = function () {
  3085. return s.DEFAULTS
  3086. }, s.prototype.setContent = function () {
  3087. var t = this.tip(), e = this.getTitle(), i = this.getContent();
  3088. if (this.options.html) {
  3089. var o = typeof i;
  3090. 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)
  3091. } else t.find(".popover-title").text(e), t.find(".popover-content").children().detach().end().text(i);
  3092. t.removeClass("fade top bottom left right in"), t.find(".popover-title").html() || t.find(".popover-title").hide()
  3093. }, s.prototype.hasContent = function () {
  3094. return this.getTitle() || this.getContent()
  3095. }, s.prototype.getContent = function () {
  3096. var t = this.$element, e = this.options;
  3097. return t.attr("data-content") || ("function" == typeof e.content ? e.content.call(t[0]) : e.content)
  3098. }, s.prototype.arrow = function () {
  3099. return this.$arrow = this.$arrow || this.tip().find(".arrow")
  3100. };
  3101. var t = n.fn.popover;
  3102. n.fn.popover = function e(o) {
  3103. return this.each(function () {
  3104. var t = n(this), e = t.data("bs.popover"), i = "object" == typeof o && o;
  3105. !e && /destroy|hide/.test(o) || (e || t.data("bs.popover", e = new s(this, i)), "string" == typeof o && e[o]())
  3106. })
  3107. }, n.fn.popover.Constructor = s, n.fn.popover.noConflict = function () {
  3108. return n.fn.popover = t, this
  3109. }
  3110. }(jQuery), function (s) {
  3111. "use strict";
  3112. function n(t, e) {
  3113. 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()
  3114. }
  3115. function e(o) {
  3116. return this.each(function () {
  3117. var t = s(this), e = t.data("bs.scrollspy"), i = "object" == typeof o && o;
  3118. e || t.data("bs.scrollspy", e = new n(this, i)), "string" == typeof o && e[o]()
  3119. })
  3120. }
  3121. n.VERSION = "3.4.1", n.DEFAULTS = {offset: 10}, n.prototype.getScrollHeight = function () {
  3122. return this.$scrollElement[0].scrollHeight || Math.max(this.$body[0].scrollHeight, document.documentElement.scrollHeight)
  3123. }, n.prototype.refresh = function () {
  3124. var t = this, o = "offset", n = 0;
  3125. 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 () {
  3126. var t = s(this), e = t.data("target") || t.attr("href"), i = /^#./.test(e) && s(e);
  3127. return i && i.length && i.is(":visible") && [[i[o]().top + n, e]] || null
  3128. }).sort(function (t, e) {
  3129. return t[0] - e[0]
  3130. }).each(function () {
  3131. t.offsets.push(this[0]), t.targets.push(this[1])
  3132. })
  3133. }, n.prototype.process = function () {
  3134. var t, e = this.$scrollElement.scrollTop() + this.options.offset, i = this.getScrollHeight(),
  3135. o = this.options.offset + i - this.$scrollElement.height(), n = this.offsets, s = this.targets,
  3136. a = this.activeTarget;
  3137. if (this.scrollHeight != i && this.refresh(), o <= e) return a != (t = s[s.length - 1]) && this.activate(t);
  3138. if (a && e < n[0]) return this.activeTarget = null, this.clear();
  3139. for (t = n.length; t--;) a != s[t] && e >= n[t] && (n[t + 1] === undefined || e < n[t + 1]) && this.activate(s[t])
  3140. }, n.prototype.activate = function (t) {
  3141. this.activeTarget = t, this.clear();
  3142. var e = this.selector + '[data-target="' + t + '"],' + this.selector + '[href="' + t + '"]',
  3143. i = s(e).parents("li").addClass("active");
  3144. i.parent(".dropdown-menu").length && (i = i.closest("li.dropdown").addClass("active")), i.trigger("activate.bs.scrollspy")
  3145. }, n.prototype.clear = function () {
  3146. s(this.selector).parentsUntil(this.options.target, ".active").removeClass("active")
  3147. };
  3148. var t = s.fn.scrollspy;
  3149. s.fn.scrollspy = e, s.fn.scrollspy.Constructor = n, s.fn.scrollspy.noConflict = function () {
  3150. return s.fn.scrollspy = t, this
  3151. }, s(window).on("load.bs.scrollspy.data-api", function () {
  3152. s('[data-spy="scroll"]').each(function () {
  3153. var t = s(this);
  3154. e.call(t, t.data())
  3155. })
  3156. })
  3157. }(jQuery), function (r) {
  3158. "use strict";
  3159. var a = function (t) {
  3160. this.element = r(t)
  3161. };
  3162. function e(i) {
  3163. return this.each(function () {
  3164. var t = r(this), e = t.data("bs.tab");
  3165. e || t.data("bs.tab", e = new a(this)), "string" == typeof i && e[i]()
  3166. })
  3167. }
  3168. a.VERSION = "3.4.1", a.TRANSITION_DURATION = 150, a.prototype.show = function () {
  3169. var t = this.element, e = t.closest("ul:not(.dropdown-menu)"), i = t.data("target");
  3170. if (i || (i = (i = t.attr("href")) && i.replace(/.*(?=#[^\s]*$)/, "")), !t.parent("li").hasClass("active")) {
  3171. var o = e.find(".active:last a"), n = r.Event("hide.bs.tab", {relatedTarget: t[0]}),
  3172. s = r.Event("show.bs.tab", {relatedTarget: o[0]});
  3173. if (o.trigger(n), t.trigger(s), !s.isDefaultPrevented() && !n.isDefaultPrevented()) {
  3174. var a = r(document).find(i);
  3175. this.activate(t.closest("li"), e), this.activate(a, a.parent(), function () {
  3176. o.trigger({type: "hidden.bs.tab", relatedTarget: t[0]}), t.trigger({
  3177. type: "shown.bs.tab",
  3178. relatedTarget: o[0]
  3179. })
  3180. })
  3181. }
  3182. }
  3183. }, a.prototype.activate = function (t, e, i) {
  3184. var o = e.find("> .active"),
  3185. n = i && r.support.transition && (o.length && o.hasClass("fade") || !!e.find("> .fade").length);
  3186. function s() {
  3187. 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()
  3188. }
  3189. o.length && n ? o.one("bsTransitionEnd", s).emulateTransitionEnd(a.TRANSITION_DURATION) : s(), o.removeClass("in")
  3190. };
  3191. var t = r.fn.tab;
  3192. r.fn.tab = e, r.fn.tab.Constructor = a, r.fn.tab.noConflict = function () {
  3193. return r.fn.tab = t, this
  3194. };
  3195. var i = function (t) {
  3196. t.preventDefault(), e.call(r(this), "show")
  3197. };
  3198. r(document).on("click.bs.tab.data-api", '[data-toggle="tab"]', i).on("click.bs.tab.data-api", '[data-toggle="pill"]', i)
  3199. }(jQuery), function (l) {
  3200. "use strict";
  3201. var h = function (t, e) {
  3202. this.options = l.extend({}, h.DEFAULTS, e);
  3203. var i = this.options.target === h.DEFAULTS.target ? l(this.options.target) : l(document).find(this.options.target);
  3204. 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()
  3205. };
  3206. function i(o) {
  3207. return this.each(function () {
  3208. var t = l(this), e = t.data("bs.affix"), i = "object" == typeof o && o;
  3209. e || t.data("bs.affix", e = new h(this, i)), "string" == typeof o && e[o]()
  3210. })
  3211. }
  3212. h.VERSION = "3.4.1", h.RESET = "affix affix-top affix-bottom", h.DEFAULTS = {
  3213. offset: 0,
  3214. target: window
  3215. }, h.prototype.getState = function (t, e, i, o) {
  3216. var n = this.$target.scrollTop(), s = this.$element.offset(), a = this.$target.height();
  3217. if (null != i && "top" == this.affixed) return n < i && "top";
  3218. if ("bottom" == this.affixed) return null != i ? !(n + this.unpin <= s.top) && "bottom" : !(n + a <= t - o) && "bottom";
  3219. var r = null == this.affixed, l = r ? n : s.top;
  3220. return null != i && n <= i ? "top" : null != o && t - o <= l + (r ? a : e) && "bottom"
  3221. }, h.prototype.getPinnedOffset = function () {
  3222. if (this.pinnedOffset) return this.pinnedOffset;
  3223. this.$element.removeClass(h.RESET).addClass("affix");
  3224. var t = this.$target.scrollTop(), e = this.$element.offset();
  3225. return this.pinnedOffset = e.top - t
  3226. }, h.prototype.checkPositionWithEventLoop = function () {
  3227. setTimeout(l.proxy(this.checkPosition, this), 1)
  3228. }, h.prototype.checkPosition = function () {
  3229. if (this.$element.is(":visible")) {
  3230. var t = this.$element.height(), e = this.options.offset, i = e.top, o = e.bottom,
  3231. n = Math.max(l(document).height(), l(document.body).height());
  3232. "object" != typeof e && (o = i = e), "function" == typeof i && (i = e.top(this.$element)), "function" == typeof o && (o = e.bottom(this.$element));
  3233. var s = this.getState(n, t, i, o);
  3234. if (this.affixed != s) {
  3235. null != this.unpin && this.$element.css("top", "");
  3236. var a = "affix" + (s ? "-" + s : ""), r = l.Event(a + ".bs.affix");
  3237. if (this.$element.trigger(r), r.isDefaultPrevented()) return;
  3238. this.affixed = s, this.unpin = "bottom" == s ? this.getPinnedOffset() : null, this.$element.removeClass(h.RESET).addClass(a).trigger(a.replace("affix", "affixed") + ".bs.affix")
  3239. }
  3240. "bottom" == s && this.$element.offset({top: n - t - o})
  3241. }
  3242. };
  3243. var t = l.fn.affix;
  3244. l.fn.affix = i, l.fn.affix.Constructor = h, l.fn.affix.noConflict = function () {
  3245. return l.fn.affix = t, this
  3246. }, l(window).on("load", function () {
  3247. l('[data-spy="affix"]').each(function () {
  3248. var t = l(this), e = t.data();
  3249. e.offset = e.offset || {}, null != e.offsetBottom && (e.offset.bottom = e.offsetBottom), null != e.offsetTop && (e.offset.top = e.offsetTop), i.call(t, e)
  3250. })
  3251. })
  3252. }(jQuery);
  3253. define("bootstrap", ["jquery"], function () {
  3254. });
  3255. require.config({
  3256. urlArgs: "v=" + requirejs.s.contexts._.config.config.site.version,
  3257. packages: [{
  3258. name: 'moment',
  3259. location: '../libs/moment',
  3260. main: 'moment'
  3261. }],
  3262. //在打包压缩时将会把include中的模块合并到主文件中
  3263. include: ['css', 'layer', 'toastr', 'fast', 'backend', 'backend-init', 'table', 'form', 'dragsort', 'drag', 'drop', 'addtabs', 'selectpage'],
  3264. paths: {
  3265. 'lang': "empty:",
  3266. 'form': 'require-form',
  3267. 'table': 'require-table',
  3268. 'upload': 'require-upload',
  3269. 'drag': 'jquery.drag.min',
  3270. 'drop': 'jquery.drop.min',
  3271. 'dropzone': 'dropzone.min',
  3272. 'echarts': 'echarts.min',
  3273. 'echarts-theme': 'echarts-theme',
  3274. 'adminlte': 'adminlte',
  3275. 'bootstrap-table-commonsearch': 'bootstrap-table-commonsearch',
  3276. 'bootstrap-table-template': 'bootstrap-table-template',
  3277. //
  3278. // 以下的包从bower的libs目录加载
  3279. 'jquery': '../libs/jquery/dist/jquery.min',
  3280. 'bootstrap': '../libs/bootstrap/dist/js/bootstrap.min',
  3281. 'bootstrap-datetimepicker': '../libs/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min',
  3282. 'bootstrap-daterangepicker': '../libs/bootstrap-daterangepicker/daterangepicker',
  3283. 'bootstrap-select': '../libs/bootstrap-select/dist/js/bootstrap-select.min',
  3284. 'bootstrap-select-lang': '../libs/bootstrap-select/dist/js/i18n/defaults-zh_CN',
  3285. 'bootstrap-table': '../libs/bootstrap-table/dist/bootstrap-table.min',
  3286. 'bootstrap-table-export': '../libs/bootstrap-table/dist/extensions/export/bootstrap-table-export.min',
  3287. 'bootstrap-table-fixed-columns': '../libs/bootstrap-table/dist/extensions/fixed-columns/bootstrap-table-fixed-columns',
  3288. 'bootstrap-table-mobile': '../libs/bootstrap-table/dist/extensions/mobile/bootstrap-table-mobile',
  3289. 'bootstrap-table-lang': '../libs/bootstrap-table/dist/locale/bootstrap-table-zh-CN',
  3290. 'bootstrap-table-jumpto': '../libs/bootstrap-table/dist/extensions/page-jumpto/bootstrap-table-jumpto',
  3291. 'bootstrap-slider': '../libs/bootstrap-slider/bootstrap-slider',
  3292. 'tableexport': '../libs/tableExport.jquery.plugin/tableExport.min',
  3293. 'dragsort': '../libs/fastadmin-dragsort/jquery.dragsort',
  3294. 'sortable': '../libs/Sortable/Sortable.min',
  3295. 'addtabs': '../libs/fastadmin-addtabs/jquery.addtabs',
  3296. 'slimscroll': '../libs/jquery-slimscroll/jquery.slimscroll',
  3297. 'validator': '../libs/nice-validator/dist/jquery.validator',
  3298. 'validator-lang': '../libs/nice-validator/dist/local/zh-CN',
  3299. 'toastr': '../libs/toastr/toastr',
  3300. 'jstree': '../libs/jstree/dist/jstree.min',
  3301. 'layer': '../libs/fastadmin-layer/dist/layer',
  3302. 'cookie': '../libs/jquery.cookie/jquery.cookie',
  3303. 'cxselect': '../libs/fastadmin-cxselect/js/jquery.cxselect',
  3304. 'template': '../libs/art-template/dist/template-native',
  3305. 'selectpage': '../libs/fastadmin-selectpage/selectpage',
  3306. 'citypicker': '../libs/fastadmin-citypicker/dist/js/city-picker.min',
  3307. 'citypicker-data': '../libs/fastadmin-citypicker/dist/js/city-picker.data',
  3308. },
  3309. // shim依赖配置
  3310. shim: {
  3311. 'addons': ['backend'],
  3312. 'bootstrap': ['jquery'],
  3313. 'bootstrap-table': {
  3314. deps: ['bootstrap'],
  3315. exports: '$.fn.bootstrapTable'
  3316. },
  3317. 'bootstrap-table-lang': {
  3318. deps: ['bootstrap-table'],
  3319. exports: '$.fn.bootstrapTable.defaults'
  3320. },
  3321. 'bootstrap-table-export': {
  3322. deps: ['bootstrap-table', 'tableexport'],
  3323. exports: '$.fn.bootstrapTable.defaults'
  3324. },
  3325. 'bootstrap-table-fixed-columns': {
  3326. deps: ['bootstrap-table'],
  3327. exports: '$.fn.bootstrapTable.defaults'
  3328. },
  3329. 'bootstrap-table-mobile': {
  3330. deps: ['bootstrap-table'],
  3331. exports: '$.fn.bootstrapTable.defaults'
  3332. },
  3333. 'bootstrap-table-advancedsearch': {
  3334. deps: ['bootstrap-table'],
  3335. exports: '$.fn.bootstrapTable.defaults'
  3336. },
  3337. 'bootstrap-table-commonsearch': {
  3338. deps: ['bootstrap-table'],
  3339. exports: '$.fn.bootstrapTable.defaults'
  3340. },
  3341. 'bootstrap-table-template': {
  3342. deps: ['bootstrap-table', 'template'],
  3343. exports: '$.fn.bootstrapTable.defaults'
  3344. },
  3345. 'bootstrap-table-jumpto': {
  3346. deps: ['bootstrap-table'],
  3347. exports: '$.fn.bootstrapTable.defaults'
  3348. },
  3349. 'tableexport': {
  3350. deps: ['jquery'],
  3351. exports: '$.fn.extend'
  3352. },
  3353. 'slimscroll': {
  3354. deps: ['jquery'],
  3355. exports: '$.fn.extend'
  3356. },
  3357. 'adminlte': {
  3358. deps: ['bootstrap', 'slimscroll'],
  3359. exports: '$.AdminLTE'
  3360. },
  3361. 'bootstrap-daterangepicker': [
  3362. 'moment/locale/zh-cn'
  3363. ],
  3364. 'bootstrap-datetimepicker': [
  3365. 'moment/locale/zh-cn',
  3366. ],
  3367. 'bootstrap-select-lang': ['bootstrap-select'],
  3368. 'jstree': ['css!../libs/jstree/dist/themes/default/style.css'],
  3369. 'validator-lang': ['validator'],
  3370. 'citypicker': ['citypicker-data', 'css!../libs/fastadmin-citypicker/dist/css/city-picker.css']
  3371. },
  3372. baseUrl: requirejs.s.contexts._.config.config.site.cdnurl + '/assets/js/', //资源基础路径
  3373. map: {
  3374. '*': {
  3375. 'css': '../libs/require-css/css.min'
  3376. }
  3377. },
  3378. waitSeconds: 60,
  3379. charset: 'utf-8' // 文件编码
  3380. });
  3381. require(['jquery', 'bootstrap'], function ($, undefined) {
  3382. //初始配置
  3383. var Config = requirejs.s.contexts._.config.config;
  3384. //将Config渲染到全局
  3385. window.Config = Config;
  3386. // 配置语言包的路径
  3387. var paths = {};
  3388. paths['lang'] = Config.moduleurl + '/ajax/lang?callback=define&controllername=' + Config.controllername + '&lang=' + Config.language + '&v=' + Config.site.version;
  3389. // 避免目录冲突
  3390. paths['backend/'] = 'backend/';
  3391. require.config({paths: paths});
  3392. // 初始化
  3393. $(function () {
  3394. require(['fast'], function (Fast) {
  3395. require(['backend', 'backend-init', 'addons'], function (Backend, undefined, Addons) {
  3396. //加载相应模块
  3397. if (Config.jsname) {
  3398. require([Config.jsname], function (Controller) {
  3399. if (Controller.hasOwnProperty(Config.actionname)) {
  3400. Controller[Config.actionname]();
  3401. } else {
  3402. if (Controller.hasOwnProperty("_empty")) {
  3403. Controller._empty();
  3404. }
  3405. }
  3406. }, function (e) {
  3407. console.error(e);
  3408. // 这里可捕获模块加载的错误
  3409. });
  3410. }
  3411. });
  3412. });
  3413. });
  3414. });
  3415. define("require-backend", function () {
  3416. });
  3417. define('../libs/require-css/css.min', [], function () {
  3418. if ("undefined" == typeof window) return {
  3419. load: function (a, b, c) {
  3420. c()
  3421. }
  3422. };
  3423. var a = document.getElementsByTagName("head")[0],
  3424. b = window.navigator.userAgent.match(/Trident\/([^ ;]*)|AppleWebKit\/([^ ;]*)|Opera\/([^ ;]*)|rv\:([^ ;]*)(.*?)Gecko\/([^ ;]*)|MSIE\s([^ ;]*)|AndroidWebKit\/([^ ;]*)/) || 0,
  3425. c = !1, d = !0;
  3426. 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);
  3427. var e = {};
  3428. e.pluginBuilder = "./css-builder";
  3429. var f, g, h, i = function () {
  3430. f = document.createElement("style"), a.appendChild(f), g = f.styleSheet || f.sheet
  3431. }, j = 0, k = [], l = function (a) {
  3432. g.addImport(a), f.onload = function () {
  3433. m()
  3434. }, j++, 31 == j && (i(), j = 0)
  3435. }, m = function () {
  3436. h();
  3437. var a = k.shift();
  3438. return a ? (h = a[1], void l(a[0])) : void (h = null)
  3439. }, n = function (a, b) {
  3440. if (g && g.addImport || i(), g && g.addImport) h ? k.push([a, b]) : (l(a), h = b); else {
  3441. f.textContent = '@import "' + a + '";';
  3442. var c = setInterval(function () {
  3443. try {
  3444. f.sheet.cssRules, clearInterval(c), b()
  3445. } catch (a) {
  3446. }
  3447. }, 10)
  3448. }
  3449. }, o = function (b, c) {
  3450. var e = document.createElement("link");
  3451. if (e.type = "text/css", e.rel = "stylesheet", d) e.onload = function () {
  3452. e.onload = function () {
  3453. }, setTimeout(c, 7)
  3454. }; else var f = setInterval(function () {
  3455. for (var a = 0; a < document.styleSheets.length; a++) {
  3456. var b = document.styleSheets[a];
  3457. if (b.href == e.href) return clearInterval(f), c()
  3458. }
  3459. }, 10);
  3460. e.href = b, a.appendChild(e)
  3461. };
  3462. return e.normalize = function (a, b) {
  3463. return ".css" == a.substr(a.length - 4, 4) && (a = a.substr(0, a.length - 4)), b(a)
  3464. }, e.load = function (a, b, d, e) {
  3465. (c ? n : o)(b.toUrl(a + ".css"), d)
  3466. }, e
  3467. });
  3468. /*! layer-v3.5.1 Web 通用弹出层组件 MIT License http://layer.layui.com/ By 贤心 */
  3469. ;!function (e, t) {
  3470. "use strict";
  3471. var i, n, a = e.layui && layui.define, o = {
  3472. getPath: function () {
  3473. var t = document.currentScript ? document.currentScript.src : function () {
  3474. for (var e, t = document.scripts, i = t.length - 1, n = i; n > 0; n--) if ("interactive" === t[n].readyState) {
  3475. e = t[n].src;
  3476. break
  3477. }
  3478. return e || t[i].src
  3479. }(), i = e.LAYUI_GLOBAL || {};
  3480. return i.layer_dir || t.substring(0, t.lastIndexOf("/") + 1)
  3481. }(),
  3482. config: {},
  3483. end: {},
  3484. minIndex: 0,
  3485. minLeft: [],
  3486. btn: ["&#x786E;&#x5B9A;", "&#x53D6;&#x6D88;"],
  3487. type: ["dialog", "page", "iframe", "loading", "tips"],
  3488. getStyle: function (t, i) {
  3489. var n = t.currentStyle ? t.currentStyle : e.getComputedStyle(t, null);
  3490. return n[n.getPropertyValue ? "getPropertyValue" : "getAttribute"](i)
  3491. },
  3492. link: function (t, i, n) {
  3493. if (r.path) {
  3494. var a = document.getElementsByTagName("head")[0], s = document.createElement("link");
  3495. "string" == typeof i && (n = i);
  3496. var l = (n || t).replace(/\.|\//g, ""), f = "layuicss-" + l, c = "creating", u = 0;
  3497. s.rel = "stylesheet", s.href = r.path + t, s.id = f, document.getElementById(f) || a.appendChild(s), "function" == typeof i && !function d(t) {
  3498. var n = 100, a = document.getElementById(f);
  3499. 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 () {
  3500. d(c)
  3501. }, n)))
  3502. }()
  3503. }
  3504. }
  3505. }, r = {
  3506. v: "3.5.1", ie: function () {
  3507. var t = navigator.userAgent.toLowerCase();
  3508. return !!(e.ActiveXObject || "ActiveXObject" in e) && ((t.match(/msie\s(\d+)/) || [])[1] || "11")
  3509. }(), index: e.layer && e.layer.v ? 1e5 : 0, path: o.getPath, config: function (e, t) {
  3510. 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
  3511. }, ready: function (e) {
  3512. var t = "layer", i = "", n = (a ? "modules/layer/" : "theme/") + "default/layer.css?v=" + r.v + i;
  3513. return a ? layui.addcss(n, e, t) : o.link(n, e, t), this
  3514. }, alert: function (e, t, n) {
  3515. var a = "function" == typeof t;
  3516. return a && (n = t), r.open(i.extend({content: e, yes: n}, a ? {} : t))
  3517. }, confirm: function (e, t, n, a) {
  3518. var s = "function" == typeof t;
  3519. return s && (a = n, n = t), r.open(i.extend({content: e, btn: o.btn, yes: n, btn2: a}, s ? {} : t))
  3520. }, msg: function (e, n, a) {
  3521. var s = "function" == typeof n, f = o.config.skin, c = (f ? f + " " + f + "-msg" : "") || "layui-layer-msg",
  3522. u = l.anim.length - 1;
  3523. return s && (a = n), r.open(i.extend({
  3524. content: e,
  3525. time: 3e3,
  3526. shade: !1,
  3527. skin: c,
  3528. title: !1,
  3529. closeBtn: !1,
  3530. btn: !1,
  3531. resize: !1,
  3532. end: a
  3533. }, s && !o.config.skin ? {skin: c + " layui-layer-hui", anim: u} : function () {
  3534. return n = n || {}, n.icon !== -1 && n.icon !== t || (n.skin = c + " " + (n.skin || "layui-layer-hui")), n
  3535. }()))
  3536. }, load: function (e, t) {
  3537. return r.open(i.extend({type: 3, icon: e || 0, resize: !1, shade: .01}, t))
  3538. }, tips: function (e, t, n) {
  3539. return r.open(i.extend({
  3540. type: 4,
  3541. content: [e, t],
  3542. closeBtn: !1,
  3543. time: 3e3,
  3544. shade: !1,
  3545. resize: !1,
  3546. fixed: !1,
  3547. maxWidth: 260
  3548. }, n))
  3549. }
  3550. }, s = function (e) {
  3551. var t = this, n = function () {
  3552. t.creat()
  3553. };
  3554. t.index = ++r.index, t.config = i.extend({}, t.config, o.config, e), document.body ? n() : setTimeout(function () {
  3555. n()
  3556. }, 30)
  3557. };
  3558. s.pt = s.prototype;
  3559. 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"];
  3560. 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 = {
  3561. type: 0,
  3562. shade: .3,
  3563. fixed: !0,
  3564. move: l[1],
  3565. title: "&#x4FE1;&#x606F;",
  3566. offset: "auto",
  3567. area: "auto",
  3568. closeBtn: 1,
  3569. time: 0,
  3570. zIndex: 19891014,
  3571. maxWidth: 360,
  3572. anim: 0,
  3573. isOutAnim: !0,
  3574. minStack: !0,
  3575. focusBtn: 0,
  3576. icon: -1,
  3577. moveType: 1,
  3578. resize: !0,
  3579. scrollbar: !0,
  3580. tips: 2
  3581. }, s.pt.vessel = function (e, t) {
  3582. var n = this, a = n.index, r = n.config, s = r.zIndex + a, f = "object" == typeof r.title,
  3583. c = r.maxmin && (1 === r.type || 2 === r.type),
  3584. u = r.title ? '<div class="layui-layer-title" style="' + (f ? r.title[1] : "") + '">' + (f ? r.title[0] : r.title) + "</div>" : "";
  3585. 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 () {
  3586. var e = c ? '<a class="layui-layer-min" href="javascript:;"><cite></cite></a><a class="layui-layer-ico layui-layer-max" href="javascript:;"></a>' : "";
  3587. 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
  3588. }() + "</span>" + (r.btn ? function () {
  3589. var e = "";
  3590. "string" == typeof r.btn && (r.btn = [r.btn]);
  3591. for (var t = 0, i = r.btn.length; t < i; t++) e += '<a class="' + l[6] + t + '" href="javascript:">' + r.btn[t] + "</a>";
  3592. return '<div class="' + l[6] + " layui-layer-btn-" + (r.btnAlign || "") + '">' + e + "</div>"
  3593. }() : "") + (r.resize ? '<span class="layui-layer-resize"></span>' : "") + "</div>"], u, i('<div class="' + l.MOVE + '" id="' + l.MOVE + '"></div>')), n
  3594. }, s.pt.creat = function () {
  3595. var e = this, t = e.config, a = e.index, s = t.content, f = "object" == typeof s, c = i("body");
  3596. if (!t.id || !i("#" + t.id)[0]) {
  3597. 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) {
  3598. case 0:
  3599. t.btn = "btn" in t ? t.btn : o.btn[0], r.closeAll("dialog");
  3600. break;
  3601. case 2:
  3602. var s = t.content = f ? t.content : [t.content || "", "auto"];
  3603. 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>';
  3604. break;
  3605. case 3:
  3606. delete t.title, delete t.closeBtn, t.icon === -1 && 0 === t.icon, r.closeAll("loading");
  3607. break;
  3608. case 4:
  3609. 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")
  3610. }
  3611. if (e.vessel(f, function (n, r, u) {
  3612. c.append(n[0]), f ? function () {
  3613. 2 == t.type || 4 == t.type ? function () {
  3614. i("body").append(n[1])
  3615. }() : function () {
  3616. 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))
  3617. }()
  3618. }() : 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)
  3619. }).auto(a), e.shadeo.css({
  3620. "background-color": t.shade[1] || "#000",
  3621. opacity: t.shade[0] || t.shade
  3622. }), 2 == t.type && 6 == r.ie && e.layero.find("iframe").attr("src", s[0]), 4 == t.type ? e.tips() : function () {
  3623. e.offset(), parseInt(o.getStyle(document.getElementById(l.MOVE), "z-index")) || function () {
  3624. e.layero.css("visibility", "hidden"), r.ready(function () {
  3625. e.offset(), e.layero.css("visibility", "visible")
  3626. })
  3627. }()
  3628. }(), t.fixed && n.on("resize", function () {
  3629. e.offset(), (/^\d+%$/.test(t.area[0]) || /^\d+%$/.test(t.area[1])) && e.auto(a), 4 == t.type && e.tips()
  3630. }), t.time <= 0 || setTimeout(function () {
  3631. r.close(e.index)
  3632. }, t.time), e.move().callback(), l.anim[t.anim]) {
  3633. var u = "layer-anim " + l.anim[t.anim];
  3634. e.layero.addClass(u).one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", function () {
  3635. i(this).removeClass(u)
  3636. })
  3637. }
  3638. t.isOutAnim && e.layero.data("isOutAnim", !0)
  3639. }
  3640. }, s.pt.auto = function (e) {
  3641. var t = this, a = t.config, o = i("#" + l[0] + e);
  3642. "" === 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));
  3643. var s = [o.innerWidth(), o.innerHeight()], f = o.find(l[1]).outerHeight() || 0,
  3644. c = o.find("." + l[6]).outerHeight() || 0, u = function (e) {
  3645. e = o.find(e), e.height(s[1] - f - c - 2 * (0 | parseFloat(e.css("padding-top"))))
  3646. };
  3647. switch (a.type) {
  3648. case 2:
  3649. u("iframe");
  3650. break;
  3651. default:
  3652. "" === 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])
  3653. }
  3654. return t
  3655. }, s.pt.offset = function () {
  3656. var e = this, t = e.config, i = e.layero, a = [i.outerWidth(), i.outerHeight()],
  3657. o = "object" == typeof t.offset;
  3658. 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({
  3659. top: e.offsetTop,
  3660. left: e.offsetLeft
  3661. })
  3662. }, s.pt.tips = function () {
  3663. var e = this, t = e.config, a = e.layero, o = [a.outerWidth(), a.outerHeight()], r = i(t.follow);
  3664. r[0] || (r = i("body"));
  3665. var s = {width: r.outerWidth(), height: r.outerHeight(), top: r.offset().top, left: r.offset().left},
  3666. f = a.find(".layui-layer-TipsG"), c = t.tips[0];
  3667. t.tips[1] || f.remove(), s.autoLeft = function () {
  3668. s.left + o[0] - n.width() > 0 ? (s.tipLeft = s.left + s.width - o[0], f.css({
  3669. right: 12,
  3670. left: "auto"
  3671. })) : s.tipLeft = s.left
  3672. }, s.where = [function () {
  3673. 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])
  3674. }, function () {
  3675. 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])
  3676. }, function () {
  3677. 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])
  3678. }, function () {
  3679. 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])
  3680. }], 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({
  3681. "background-color": t.tips[1],
  3682. "padding-right": t.closeBtn ? "30px" : ""
  3683. }), a.css({left: s.tipLeft - (t.fixed ? n.scrollLeft() : 0), top: s.tipTop - (t.fixed ? n.scrollTop() : 0)})
  3684. }, s.pt.move = function () {
  3685. var e = this, t = e.config, a = i(document), s = e.layero, l = s.find(t.move),
  3686. f = s.find(".layui-layer-resize"), c = {};
  3687. return t.move && l.css("cursor", "move"), l.on("mousedown", function (e) {
  3688. 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())
  3689. }), f.on("mousedown", function (e) {
  3690. e.preventDefault(), c.resizeStart = !0, c.offset = [e.clientX, e.clientY], c.area = [s.outerWidth(), s.outerHeight()], o.moveElem.css("cursor", "se-resize").show()
  3691. }), a.on("mousemove", function (i) {
  3692. if (c.moveStart) {
  3693. var a = i.clientX - c.offset[0], o = i.clientY - c.offset[1], l = "fixed" === s.css("position");
  3694. if (i.preventDefault(), c.stX = l ? 0 : n.scrollLeft(), c.stY = l ? 0 : n.scrollTop(), !t.moveOut) {
  3695. var f = n.width() - s.outerWidth() + c.stX, u = n.height() - s.outerHeight() + c.stY;
  3696. a < c.stX && (a = c.stX), a > f && (a = f), o < c.stY && (o = c.stY), o > u && (o = u)
  3697. }
  3698. s.css({left: a, top: o})
  3699. }
  3700. if (t.resize && c.resizeStart) {
  3701. var a = i.clientX - c.offset[0], o = i.clientY - c.offset[1];
  3702. i.preventDefault(), r.style(e.index, {
  3703. width: c.area[0] + a,
  3704. height: c.area[1] + o
  3705. }), c.isResize = !0, t.resizing && t.resizing(s)
  3706. }
  3707. }).on("mouseup", function (e) {
  3708. c.moveStart && (delete c.moveStart, o.moveElem.hide(), t.moveEnd && t.moveEnd(s)), c.resizeStart && (delete c.resizeStart, o.moveElem.hide())
  3709. }), e
  3710. }, s.pt.callback = function () {
  3711. function e() {
  3712. var e = a.cancel && a.cancel(t.index, n);
  3713. e === !1 || r.close(t.index)
  3714. }
  3715. var t = this, n = t.layero, a = t.config;
  3716. if (t.openLayer(), a.success && (2 == a.type ? n.find("iframe").on("load", function () {
  3717. a.success(n, t.index)
  3718. }) : a.success(n, t.index)), 6 == r.ie && t.IE6(n), n.find("." + l[6]).children("a").on("click", function () {
  3719. var e = i(this).index();
  3720. if (0 === e) a.yes ? a.yes(t.index, n) : a.btn1 ? a.btn1(t.index, n) : r.close(t.index); else {
  3721. var o = a["btn" + (e + 1)] && a["btn" + (e + 1)](t.index, n);
  3722. o === !1 || r.close(t.index)
  3723. }
  3724. }), "number" == typeof a.focusBtn) {
  3725. var s = n.find("." + l[6]).children("a").eq(a.focusBtn);
  3726. if (s.size() > 0) {
  3727. n.find("." + l[6]).css("position", "relative");
  3728. var f = s.position(), c = {
  3729. width: s.outerWidth(),
  3730. height: s.outerHeight(),
  3731. left: f.left,
  3732. top: f.top,
  3733. marginTop: s.css("marginTop"),
  3734. marginLeft: s.css("marginLeft")
  3735. }, u = i("<button class='layui-layer-confirm'></button>").css(c);
  3736. if (a.resize) {
  3737. var d = a.resizing;
  3738. a.resizing = function (e) {
  3739. d && d(e);
  3740. var t = s.position();
  3741. u.size() > 0 && u.css({left: t.left, top: t.top})
  3742. }
  3743. }
  3744. n.find("." + l[6]).append(u), u.focus().click(function () {
  3745. return s.trigger("click"), !1
  3746. }).on("focus blur", function (e) {
  3747. s.toggleClass("focus", "focus" === e.type), "blur" === e.type && u.remove()
  3748. })
  3749. }
  3750. }
  3751. n.find("." + l[7]).on("click", e), a.shadeClose && t.shadeo.on("click", function () {
  3752. r.close(t.index)
  3753. }), n.find(".layui-layer-min").on("click", function () {
  3754. var e = a.min && a.min(n, t.index);
  3755. e === !1 || r.min(t.index, a)
  3756. }), n.find(".layui-layer-max").on("click", function () {
  3757. i(this).hasClass("layui-layer-maxmin") ? (r.restore(t.index), a.restore && a.restore(n, t.index)) : (r.full(t.index, a), setTimeout(function () {
  3758. a.full && a.full(n, t.index)
  3759. }, 100))
  3760. }), a.end && (o.end[t.index] = a.end)
  3761. }, o.reselect = function () {
  3762. i.each(i("select"), function (e, t) {
  3763. var n = i(this);
  3764. n.parents("." + l[0])[0] || 1 == n.attr("layer") && i("." + l[0]).length < 1 && n.removeAttr("layer").show(), n = null
  3765. })
  3766. }, s.pt.IE6 = function (e) {
  3767. i("select").each(function (e, t) {
  3768. var n = i(this);
  3769. n.parents("." + l[0])[0] || "none" === n.css("display") || n.attr({layer: "1"}).hide(), n = null
  3770. })
  3771. }, s.pt.openLayer = function () {
  3772. var e = this;
  3773. r.zIndex = e.config.zIndex, r.setTop = function (e) {
  3774. var t = function () {
  3775. r.zIndex++, e.css("z-index", r.zIndex + 1)
  3776. };
  3777. return r.zIndex = parseInt(e[0].style.zIndex), e.on("mousedown", t), r.zIndex
  3778. }
  3779. }, o.record = function (e) {
  3780. var t = [e.width(), e.height(), e.position().top, e.position().left + parseFloat(e.css("margin-left"))];
  3781. e.find(".layui-layer-max").addClass("layui-layer-maxmin"), e.attr({area: t})
  3782. }, o.rescollbar = function (e) {
  3783. 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"))
  3784. }, e.layer = r, r.getChildFrame = function (e, t) {
  3785. return t = t || i("." + l[4]).attr("times"), i("#" + l[0] + t).find("iframe").contents().find(e)
  3786. }, r.getFrameIndex = function (e) {
  3787. return i("#" + e).parents("." + l[4]).attr("times")
  3788. }, r.iframeAuto = function (e) {
  3789. if (e) {
  3790. var t = r.getChildFrame("html", e).outerHeight(), n = i("#" + l[0] + e),
  3791. a = n.find(l[1]).outerHeight() || 0, o = n.find("." + l[6]).outerHeight() || 0;
  3792. n.css({height: t + a + o}), n.find("iframe").css({height: t})
  3793. }
  3794. }, r.iframeSrc = function (e, t) {
  3795. i("#" + l[0] + e).find("iframe").attr("src", t)
  3796. }, r.style = function (e, t, n) {
  3797. var a = i("#" + l[0] + e), r = a.find(".layui-layer-content"), s = a.attr("type"),
  3798. f = a.find(l[1]).outerHeight() || 0, c = a.find("." + l[6]).outerHeight() || 0;
  3799. a.attr("minLeft");
  3800. s !== o.type[3] && s !== o.type[4] && (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}) : r.css({height: parseFloat(t.height) - f - c - parseFloat(r.css("padding-top")) - parseFloat(r.css("padding-bottom"))}))
  3801. }, r.min = function (e, t) {
  3802. t = t || {};
  3803. var a = i("#" + l[0] + e), s = i("#" + l.SHADE + e), f = a.find(l[1]).outerHeight() || 0,
  3804. c = a.attr("minLeft") || 181 * o.minIndex + "px", u = a.css("position"),
  3805. d = {width: 180, height: f, position: "fixed", overflow: "hidden"};
  3806. 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()
  3807. }, r.restore = function (e) {
  3808. var t = i("#" + l[0] + e), n = i("#" + l.SHADE + e), a = t.attr("area").split(",");
  3809. t.attr("type");
  3810. r.style(e, {
  3811. width: parseFloat(a[0]),
  3812. height: parseFloat(a[1]),
  3813. top: parseFloat(a[2]),
  3814. left: parseFloat(a[3]),
  3815. position: t.attr("position"),
  3816. overflow: "visible"
  3817. }, !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()
  3818. }, r.full = function (e) {
  3819. var t, a = i("#" + l[0] + e);
  3820. o.record(a), l.html.attr("layer-full") || l.html.css("overflow", "hidden").attr("layer-full", e), clearTimeout(t), t = setTimeout(function () {
  3821. var t = "fixed" === a.css("position");
  3822. r.style(e, {
  3823. top: t ? 0 : n.scrollTop(),
  3824. left: t ? 0 : n.scrollLeft(),
  3825. width: n.width(),
  3826. height: n.height()
  3827. }, !0), a.find(".layui-layer-min").hide()
  3828. }, 100)
  3829. }, r.title = function (e, t) {
  3830. var n = i("#" + l[0] + (t || r.index)).find(l[1]);
  3831. n.html(e)
  3832. }, r.close = function (e, t) {
  3833. var n = i("#" + l[0] + e), a = n.attr("type"), s = "layer-anim-close";
  3834. if (n[0]) {
  3835. var f = "layui-layer-wrap", c = function () {
  3836. if (a === o.type[1] && "object" === n.attr("conType")) {
  3837. n.children(":not(." + l[5] + ")").remove();
  3838. for (var r = n.find("." + f), s = 0; s < 2; s++) r.unwrap();
  3839. r.css("display", r.data("display")).removeClass(f)
  3840. } else {
  3841. if (a === o.type[2]) try {
  3842. var c = i("#" + l[4] + e)[0];
  3843. c.contentWindow.document.write(""), c.contentWindow.close(), n.find("." + l[5])[0].removeChild(c)
  3844. } catch (u) {
  3845. }
  3846. n[0].innerHTML = "", n.remove()
  3847. }
  3848. "function" == typeof o.end[e] && o.end[e](), delete o.end[e], "function" == typeof t && t()
  3849. };
  3850. 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 () {
  3851. c()
  3852. }, 200)
  3853. }
  3854. }, r.closeAll = function (e, t) {
  3855. "function" == typeof e && (t = e, e = null);
  3856. var n = i("." + l[0]);
  3857. i.each(n, function (a) {
  3858. var o = i(this), s = e ? o.attr("type") === e : 1;
  3859. s && r.close(o.attr("times"), a === n.length - 1 ? t : null), s = null
  3860. }), 0 === n.length && "function" == typeof t && t()
  3861. };
  3862. var f = r.cache || {}, c = function (e) {
  3863. return f.skin ? " " + f.skin + " " + f.skin + "-" + e : ""
  3864. };
  3865. r.prompt = function (e, t) {
  3866. var a = "";
  3867. if (e = e || {}, "function" == typeof e && (t = e), e.area) {
  3868. var o = e.area;
  3869. a = 'style="width: ' + o[0] + "; height: " + o[1] + ';"', delete e.area
  3870. }
  3871. var s, l = 2 == e.formType ? '<textarea class="layui-layer-input"' + a + "></textarea>" : function () {
  3872. return '<input type="' + (1 == e.formType ? "password" : "text") + '" class="layui-layer-input">'
  3873. }(), f = e.success;
  3874. return delete e.success, r.open(i.extend({
  3875. type: 1,
  3876. btn: ["&#x786E;&#x5B9A;", "&#x53D6;&#x6D88;"],
  3877. content: l,
  3878. skin: "layui-layer-prompt" + c("prompt"),
  3879. maxWidth: n.width(),
  3880. success: function (t) {
  3881. s = t.find(".layui-layer-input"), s.val(e.value || "").focus(), "function" == typeof f && f(t)
  3882. },
  3883. resize: !1,
  3884. yes: function (i) {
  3885. var n = s.val();
  3886. "" === 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)
  3887. }
  3888. }, e))
  3889. }, r.tab = function (e) {
  3890. e = e || {};
  3891. var t = e.tab || {}, n = "layui-this", a = e.success;
  3892. return delete e.success, r.open(i.extend({
  3893. type: 1,
  3894. skin: "layui-layer-tab" + c("tab"),
  3895. resize: !1,
  3896. title: function () {
  3897. var e = t.length, i = 1, a = "";
  3898. if (e > 0) for (a = '<span class="' + n + '">' + t[0].title + "</span>"; i < e; i++) a += "<span>" + t[i].title + "</span>";
  3899. return a
  3900. }(),
  3901. content: '<ul class="layui-layer-tabmain">' + function () {
  3902. var e = t.length, i = 1, a = "";
  3903. 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>";
  3904. return a
  3905. }() + "</ul>",
  3906. success: function (t) {
  3907. var o = t.find(".layui-layer-title").children(), r = t.find(".layui-layer-tabmain").children();
  3908. o.on("mousedown", function (t) {
  3909. t.stopPropagation ? t.stopPropagation() : t.cancelBubble = !0;
  3910. var a = i(this), o = a.index();
  3911. a.addClass(n).siblings().removeClass(n), r.eq(o).show().siblings().hide(), "function" == typeof e.change && e.change(o)
  3912. }), "function" == typeof a && a(t)
  3913. }
  3914. }, e))
  3915. }, r.photos = function (t, n, a) {
  3916. function o(e, t, i) {
  3917. var n = new Image;
  3918. return n.src = e, n.complete ? t(n) : (n.onload = function () {
  3919. n.onload = null, t(n)
  3920. }, void (n.onerror = function (e) {
  3921. n.onerror = null, i(e)
  3922. }))
  3923. }
  3924. var s = {};
  3925. if (t = t || {}, t.photos) {
  3926. var l = !("string" == typeof t.photos || t.photos instanceof i), f = l ? t.photos : {}, u = f.data || [],
  3927. d = f.start || 0;
  3928. s.imgIndex = (0 | d) + 1, t.img = t.img || "img";
  3929. var y = t.success;
  3930. if (delete t.success, l) {
  3931. if (0 === u.length) return r.msg("&#x6CA1;&#x6709;&#x56FE;&#x7247;")
  3932. } else {
  3933. var p = i(t.photos), h = function () {
  3934. u = [], p.find(t.img).each(function (e) {
  3935. var t = i(this);
  3936. t.attr("layer-index", e), u.push({
  3937. alt: t.attr("alt"),
  3938. pid: t.attr("layer-pid"),
  3939. src: t.attr("layer-src") || t.attr("src"),
  3940. thumb: t.attr("src")
  3941. })
  3942. })
  3943. };
  3944. if (h(), 0 === u.length) return;
  3945. if (n || p.on("click", t.img, function () {
  3946. h();
  3947. var e = i(this), n = e.attr("layer-index");
  3948. r.photos(i.extend(t, {photos: {start: n, data: u, tab: t.tab}, full: t.full}), !0)
  3949. }), !n) return
  3950. }
  3951. s.imgprev = function (e) {
  3952. s.imgIndex--, s.imgIndex < 1 && (s.imgIndex = u.length), s.tabimg(e)
  3953. }, s.imgnext = function (e, t) {
  3954. s.imgIndex++, s.imgIndex > u.length && (s.imgIndex = 1, t) || s.tabimg(e)
  3955. }, s.keyup = function (e) {
  3956. if (!s.end) {
  3957. var t = e.keyCode;
  3958. e.preventDefault(), 37 === t ? s.imgprev(!0) : 39 === t ? s.imgnext(!0) : 27 === t && r.close(s.index)
  3959. }
  3960. }, s.tabimg = function (e) {
  3961. if (!(u.length <= 1)) return f.start = s.imgIndex - 1, r.close(s.index), r.photos(t, !0, e)
  3962. }, s.event = function () {
  3963. s.bigimg.find(".layui-layer-imgprev").on("click", function (e) {
  3964. e.preventDefault(), s.imgprev(!0)
  3965. }), s.bigimg.find(".layui-layer-imgnext").on("click", function (e) {
  3966. e.preventDefault(), s.imgnext(!0)
  3967. }), i(document).on("keyup", s.keyup)
  3968. }, s.loadi = r.load(1, {shade: !("shade" in t) && .9, scrollbar: !1}), o(u[d].src, function (n) {
  3969. r.close(s.loadi), a && (t.anim = -1), s.index = r.open(i.extend({
  3970. type: 1,
  3971. id: "layui-layer-photos",
  3972. area: function () {
  3973. var a = [n.width, n.height], o = [i(e).width() - 100, i(e).height() - 100];
  3974. if (!t.full && (a[0] > o[0] || a[1] > o[1])) {
  3975. var r = [a[0] / o[0], a[1] / o[1]];
  3976. 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])
  3977. }
  3978. return [a[0] + "px", a[1] + "px"]
  3979. }(),
  3980. title: !1,
  3981. shade: .9,
  3982. shadeClose: !0,
  3983. closeBtn: !1,
  3984. move: ".layui-layer-phimg img",
  3985. moveType: 1,
  3986. scrollbar: !1,
  3987. moveOut: !0,
  3988. anim: 5,
  3989. isOutAnim: !1,
  3990. skin: "layui-layer-photos" + c("photos"),
  3991. content: '<div class="layui-layer-phimg"><img src="' + u[d].src + '" alt="' + (u[d].alt || "") + '" layer-pid="' + u[d].pid + '">' + function () {
  3992. 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>" : ""
  3993. }() + "</div>",
  3994. success: function (e, i) {
  3995. 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)
  3996. },
  3997. end: function () {
  3998. s.end = !0, i(document).off("keyup", s.keyup)
  3999. }
  4000. }, t))
  4001. }, function () {
  4002. 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;", {
  4003. time: 3e4,
  4004. btn: ["&#x4E0B;&#x4E00;&#x5F20;", "&#x4E0D;&#x770B;&#x4E86;"],
  4005. yes: function () {
  4006. u.length > 1 && s.imgnext(!0, !0)
  4007. }
  4008. })
  4009. })
  4010. }
  4011. }, o.run = function (t) {
  4012. i = t, n = i(e), l.html = i("html"), r.open = function (e) {
  4013. var t = new s(e);
  4014. return t.index
  4015. }
  4016. }, e.layui && layui.define ? (r.ready(), layui.define("jquery", function (t) {
  4017. r.path = layui.cache.dir, o.run(layui.$), e.layer = r, t("layer", r)
  4018. })) : "function" == typeof define && define.amd ? define('layer', ["jquery"], function () {
  4019. return o.run(e.jQuery), r
  4020. }) : function () {
  4021. r.ready(), o.run(e.jQuery)
  4022. }()
  4023. }(window);
  4024. /*
  4025. * Toastr
  4026. * Copyright 2012-2015
  4027. * Authors: John Papa, Hans Fjällemark, and Tim Ferrell.
  4028. * All Rights Reserved.
  4029. * Use, reproduction, distribution, and modification of this code is subject to the terms and
  4030. * conditions of the MIT license, available at http://www.opensource.org/licenses/mit-license.php
  4031. *
  4032. * ARIA Support: Greta Krafsig
  4033. *
  4034. * Project: https://github.com/CodeSeven/toastr
  4035. */
  4036. /* global define */
  4037. (function (define) {
  4038. define('toastr', ['jquery'], function ($) {
  4039. return (function () {
  4040. var $container;
  4041. var listener;
  4042. var toastId = 0;
  4043. var toastType = {
  4044. error: 'error',
  4045. info: 'info',
  4046. success: 'success',
  4047. warning: 'warning'
  4048. };
  4049. var toastr = {
  4050. clear: clear,
  4051. remove: remove,
  4052. error: error,
  4053. getContainer: getContainer,
  4054. info: info,
  4055. options: {},
  4056. subscribe: subscribe,
  4057. success: success,
  4058. version: '2.1.3',
  4059. warning: warning
  4060. };
  4061. var previousToast;
  4062. return toastr;
  4063. ////////////////
  4064. function error(message, title, optionsOverride) {
  4065. return notify({
  4066. type: toastType.error,
  4067. iconClass: getOptions().iconClasses.error,
  4068. message: message,
  4069. optionsOverride: optionsOverride,
  4070. title: title
  4071. });
  4072. }
  4073. function getContainer(options, create) {
  4074. if (!options) {
  4075. options = getOptions();
  4076. }
  4077. $container = $('#' + options.containerId);
  4078. if ($container.length) {
  4079. return $container;
  4080. }
  4081. if (create) {
  4082. $container = createContainer(options);
  4083. }
  4084. return $container;
  4085. }
  4086. function info(message, title, optionsOverride) {
  4087. return notify({
  4088. type: toastType.info,
  4089. iconClass: getOptions().iconClasses.info,
  4090. message: message,
  4091. optionsOverride: optionsOverride,
  4092. title: title
  4093. });
  4094. }
  4095. function subscribe(callback) {
  4096. listener = callback;
  4097. }
  4098. function success(message, title, optionsOverride) {
  4099. return notify({
  4100. type: toastType.success,
  4101. iconClass: getOptions().iconClasses.success,
  4102. message: message,
  4103. optionsOverride: optionsOverride,
  4104. title: title
  4105. });
  4106. }
  4107. function warning(message, title, optionsOverride) {
  4108. return notify({
  4109. type: toastType.warning,
  4110. iconClass: getOptions().iconClasses.warning,
  4111. message: message,
  4112. optionsOverride: optionsOverride,
  4113. title: title
  4114. });
  4115. }
  4116. function clear($toastElement, clearOptions) {
  4117. var options = getOptions();
  4118. if (!$container) {
  4119. getContainer(options);
  4120. }
  4121. if (!clearToast($toastElement, options, clearOptions)) {
  4122. clearContainer(options);
  4123. }
  4124. }
  4125. function remove($toastElement) {
  4126. var options = getOptions();
  4127. if (!$container) {
  4128. getContainer(options);
  4129. }
  4130. if ($toastElement && $(':focus', $toastElement).length === 0) {
  4131. removeToast($toastElement);
  4132. return;
  4133. }
  4134. if ($container.children().length) {
  4135. $container.remove();
  4136. }
  4137. }
  4138. // internal functions
  4139. function clearContainer(options) {
  4140. var toastsToClear = $container.children();
  4141. for (var i = toastsToClear.length - 1; i >= 0; i--) {
  4142. clearToast($(toastsToClear[i]), options);
  4143. }
  4144. }
  4145. function clearToast($toastElement, options, clearOptions) {
  4146. var force = clearOptions && clearOptions.force ? clearOptions.force : false;
  4147. if ($toastElement && (force || $(':focus', $toastElement).length === 0)) {
  4148. $toastElement[options.hideMethod]({
  4149. duration: options.hideDuration,
  4150. easing: options.hideEasing,
  4151. complete: function () {
  4152. removeToast($toastElement);
  4153. }
  4154. });
  4155. return true;
  4156. }
  4157. return false;
  4158. }
  4159. function createContainer(options) {
  4160. $container = $('<div/>')
  4161. .attr('id', options.containerId)
  4162. .addClass(options.positionClass);
  4163. $container.appendTo($(options.target));
  4164. return $container;
  4165. }
  4166. function getDefaults() {
  4167. return {
  4168. tapToDismiss: true,
  4169. toastClass: 'toast',
  4170. containerId: 'toast-container',
  4171. debug: false,
  4172. showMethod: 'fadeIn', //fadeIn, slideDown, and show are built into jQuery
  4173. showDuration: 300,
  4174. showEasing: 'swing', //swing and linear are built into jQuery
  4175. onShown: undefined,
  4176. hideMethod: 'fadeOut',
  4177. hideDuration: 1000,
  4178. hideEasing: 'swing',
  4179. onHidden: undefined,
  4180. closeMethod: false,
  4181. closeDuration: false,
  4182. closeEasing: false,
  4183. closeOnHover: true,
  4184. extendedTimeOut: 1000,
  4185. iconClasses: {
  4186. error: 'toast-error',
  4187. info: 'toast-info',
  4188. success: 'toast-success',
  4189. warning: 'toast-warning'
  4190. },
  4191. iconClass: 'toast-info',
  4192. positionClass: 'toast-top-right',
  4193. timeOut: 5000, // Set timeOut and extendedTimeOut to 0 to make it sticky
  4194. titleClass: 'toast-title',
  4195. messageClass: 'toast-message',
  4196. escapeHtml: false,
  4197. target: 'body',
  4198. closeHtml: '<button type="button">&times;</button>',
  4199. closeClass: 'toast-close-button',
  4200. newestOnTop: true,
  4201. preventDuplicates: false,
  4202. progressBar: false,
  4203. progressClass: 'toast-progress',
  4204. rtl: false
  4205. };
  4206. }
  4207. function publish(args) {
  4208. if (!listener) {
  4209. return;
  4210. }
  4211. listener(args);
  4212. }
  4213. function notify(map) {
  4214. var options = getOptions();
  4215. var iconClass = map.iconClass || options.iconClass;
  4216. if (typeof (map.optionsOverride) !== 'undefined') {
  4217. options = $.extend(options, map.optionsOverride);
  4218. iconClass = map.optionsOverride.iconClass || iconClass;
  4219. }
  4220. if (shouldExit(options, map)) {
  4221. return;
  4222. }
  4223. toastId++;
  4224. $container = getContainer(options, true);
  4225. var intervalId = null;
  4226. var $toastElement = $('<div/>');
  4227. var $titleElement = $('<div/>');
  4228. var $messageElement = $('<div/>');
  4229. var $progressElement = $('<div/>');
  4230. var $closeElement = $(options.closeHtml);
  4231. var progressBar = {
  4232. intervalId: null,
  4233. hideEta: null,
  4234. maxHideTime: null
  4235. };
  4236. var response = {
  4237. toastId: toastId,
  4238. state: 'visible',
  4239. startTime: new Date(),
  4240. options: options,
  4241. map: map
  4242. };
  4243. personalizeToast();
  4244. displayToast();
  4245. handleEvents();
  4246. publish(response);
  4247. if (options.debug && console) {
  4248. console.log(response);
  4249. }
  4250. return $toastElement;
  4251. function escapeHtml(source) {
  4252. if (source == null) {
  4253. source = '';
  4254. }
  4255. return source
  4256. .replace(/&/g, '&amp;')
  4257. .replace(/"/g, '&quot;')
  4258. .replace(/'/g, '&#39;')
  4259. .replace(/</g, '&lt;')
  4260. .replace(/>/g, '&gt;');
  4261. }
  4262. function personalizeToast() {
  4263. setIcon();
  4264. setTitle();
  4265. setMessage();
  4266. setCloseButton();
  4267. setProgressBar();
  4268. setRTL();
  4269. setSequence();
  4270. setAria();
  4271. }
  4272. function setAria() {
  4273. var ariaValue = '';
  4274. switch (map.iconClass) {
  4275. case 'toast-success':
  4276. case 'toast-info':
  4277. ariaValue = 'polite';
  4278. break;
  4279. default:
  4280. ariaValue = 'assertive';
  4281. }
  4282. $toastElement.attr('aria-live', ariaValue);
  4283. }
  4284. function handleEvents() {
  4285. if (options.closeOnHover) {
  4286. $toastElement.hover(stickAround, delayedHideToast);
  4287. }
  4288. if (!options.onclick && options.tapToDismiss) {
  4289. $toastElement.click(hideToast);
  4290. }
  4291. if (options.closeButton && $closeElement) {
  4292. $closeElement.click(function (event) {
  4293. if (event.stopPropagation) {
  4294. event.stopPropagation();
  4295. } else if (event.cancelBubble !== undefined && event.cancelBubble !== true) {
  4296. event.cancelBubble = true;
  4297. }
  4298. if (options.onCloseClick) {
  4299. options.onCloseClick(event);
  4300. }
  4301. hideToast(true);
  4302. });
  4303. }
  4304. if (options.onclick) {
  4305. $toastElement.click(function (event) {
  4306. options.onclick(event);
  4307. hideToast();
  4308. });
  4309. }
  4310. }
  4311. function displayToast() {
  4312. $toastElement.hide();
  4313. $toastElement[options.showMethod](
  4314. {duration: options.showDuration, easing: options.showEasing, complete: options.onShown}
  4315. );
  4316. if (options.timeOut > 0) {
  4317. intervalId = setTimeout(hideToast, options.timeOut);
  4318. progressBar.maxHideTime = parseFloat(options.timeOut);
  4319. progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime;
  4320. if (options.progressBar) {
  4321. progressBar.intervalId = setInterval(updateProgress, 10);
  4322. }
  4323. }
  4324. }
  4325. function setIcon() {
  4326. if (map.iconClass) {
  4327. $toastElement.addClass(options.toastClass).addClass(iconClass);
  4328. }
  4329. }
  4330. function setSequence() {
  4331. if (options.newestOnTop) {
  4332. $container.prepend($toastElement);
  4333. } else {
  4334. $container.append($toastElement);
  4335. }
  4336. }
  4337. function setTitle() {
  4338. if (map.title) {
  4339. var suffix = map.title;
  4340. if (options.escapeHtml) {
  4341. suffix = escapeHtml(map.title);
  4342. }
  4343. $titleElement.append(suffix).addClass(options.titleClass);
  4344. $toastElement.append($titleElement);
  4345. }
  4346. }
  4347. function setMessage() {
  4348. if (map.message) {
  4349. var suffix = map.message;
  4350. if (options.escapeHtml) {
  4351. suffix = escapeHtml(map.message);
  4352. }
  4353. $messageElement.append(suffix).addClass(options.messageClass);
  4354. $toastElement.append($messageElement);
  4355. }
  4356. }
  4357. function setCloseButton() {
  4358. if (options.closeButton) {
  4359. $closeElement.addClass(options.closeClass).attr('role', 'button');
  4360. $toastElement.prepend($closeElement);
  4361. }
  4362. }
  4363. function setProgressBar() {
  4364. if (options.progressBar) {
  4365. $progressElement.addClass(options.progressClass);
  4366. $toastElement.prepend($progressElement);
  4367. }
  4368. }
  4369. function setRTL() {
  4370. if (options.rtl) {
  4371. $toastElement.addClass('rtl');
  4372. }
  4373. }
  4374. function shouldExit(options, map) {
  4375. if (options.preventDuplicates) {
  4376. if (map.message === previousToast) {
  4377. return true;
  4378. } else {
  4379. previousToast = map.message;
  4380. }
  4381. }
  4382. return false;
  4383. }
  4384. function hideToast(override) {
  4385. var method = override && options.closeMethod !== false ? options.closeMethod : options.hideMethod;
  4386. var duration = override && options.closeDuration !== false ?
  4387. options.closeDuration : options.hideDuration;
  4388. var easing = override && options.closeEasing !== false ? options.closeEasing : options.hideEasing;
  4389. if ($(':focus', $toastElement).length && !override) {
  4390. return;
  4391. }
  4392. clearTimeout(progressBar.intervalId);
  4393. return $toastElement[method]({
  4394. duration: duration,
  4395. easing: easing,
  4396. complete: function () {
  4397. removeToast($toastElement);
  4398. clearTimeout(intervalId);
  4399. if (options.onHidden && response.state !== 'hidden') {
  4400. options.onHidden();
  4401. }
  4402. response.state = 'hidden';
  4403. response.endTime = new Date();
  4404. publish(response);
  4405. }
  4406. });
  4407. }
  4408. function delayedHideToast() {
  4409. if (options.timeOut > 0 || options.extendedTimeOut > 0) {
  4410. intervalId = setTimeout(hideToast, options.extendedTimeOut);
  4411. progressBar.maxHideTime = parseFloat(options.extendedTimeOut);
  4412. progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime;
  4413. }
  4414. }
  4415. function stickAround() {
  4416. clearTimeout(intervalId);
  4417. progressBar.hideEta = 0;
  4418. $toastElement.stop(true, true)[options.showMethod](
  4419. {duration: options.showDuration, easing: options.showEasing}
  4420. );
  4421. }
  4422. function updateProgress() {
  4423. var percentage = ((progressBar.hideEta - (new Date().getTime())) / progressBar.maxHideTime) * 100;
  4424. $progressElement.width(percentage + '%');
  4425. }
  4426. }
  4427. function getOptions() {
  4428. return $.extend({}, getDefaults(), toastr.options);
  4429. }
  4430. function removeToast($toastElement) {
  4431. if (!$container) {
  4432. $container = getContainer();
  4433. }
  4434. if ($toastElement.is(':visible')) {
  4435. return;
  4436. }
  4437. $toastElement.remove();
  4438. $toastElement = null;
  4439. if ($container.children().length === 0) {
  4440. $container.remove();
  4441. previousToast = undefined;
  4442. }
  4443. }
  4444. })();
  4445. });
  4446. }(typeof define === 'function' && define.amd ? define : function (deps, factory) {
  4447. if (typeof module !== 'undefined' && module.exports) { //Node
  4448. module.exports = factory(require('jquery'));
  4449. } else {
  4450. window.toastr = factory(window.jQuery);
  4451. }
  4452. }));
  4453. define('fast', ['jquery', 'bootstrap', 'toastr', 'layer', 'lang'], function ($, undefined, Toastr, Layer, Lang) {
  4454. var Fast = {
  4455. config: {
  4456. //toastr默认配置
  4457. toastr: {
  4458. "closeButton": true,
  4459. "debug": false,
  4460. "newestOnTop": false,
  4461. "progressBar": false,
  4462. "positionClass": "toast-top-center",
  4463. "preventDuplicates": false,
  4464. "onclick": null,
  4465. "showDuration": "300",
  4466. "hideDuration": "1000",
  4467. "timeOut": "5000",
  4468. "extendedTimeOut": "1000",
  4469. "showEasing": "swing",
  4470. "hideEasing": "linear",
  4471. "showMethod": "fadeIn",
  4472. "hideMethod": "fadeOut"
  4473. }
  4474. },
  4475. events: {
  4476. //请求成功的回调
  4477. onAjaxSuccess: function (ret, onAjaxSuccess) {
  4478. var data = typeof ret.data !== 'undefined' ? ret.data : null;
  4479. var msg = typeof ret.msg !== 'undefined' && ret.msg ? ret.msg : __('Operation completed');
  4480. if (typeof onAjaxSuccess === 'function') {
  4481. var result = onAjaxSuccess.call(this, data, ret);
  4482. if (result === false)
  4483. return;
  4484. }
  4485. Toastr.success(msg);
  4486. },
  4487. //请求错误的回调
  4488. onAjaxError: function (ret, onAjaxError) {
  4489. var data = typeof ret.data !== 'undefined' ? ret.data : null;
  4490. if (typeof onAjaxError === 'function') {
  4491. var result = onAjaxError.call(this, data, ret);
  4492. if (result === false) {
  4493. return;
  4494. }
  4495. }
  4496. Toastr.error(ret.msg);
  4497. },
  4498. //服务器响应数据后
  4499. onAjaxResponse: function (response) {
  4500. try {
  4501. var ret = typeof response === 'object' ? response : JSON.parse(response);
  4502. if (!ret.hasOwnProperty('code')) {
  4503. $.extend(ret, {code: -2, msg: response, data: null});
  4504. }
  4505. } catch (e) {
  4506. var ret = {code: -1, msg: e.message, data: null};
  4507. }
  4508. return ret;
  4509. }
  4510. },
  4511. api: {
  4512. //发送Ajax请求
  4513. ajax: function (options, success, error) {
  4514. options = typeof options === 'string' ? {url: options} : options;
  4515. var index;
  4516. if (typeof options.loading === 'undefined' || options.loading) {
  4517. index = Layer.load(options.loading || 0);
  4518. }
  4519. options = $.extend({
  4520. type: "POST",
  4521. dataType: "json",
  4522. xhrFields: {
  4523. withCredentials: true
  4524. },
  4525. success: function (ret) {
  4526. index && Layer.close(index);
  4527. ret = Fast.events.onAjaxResponse(ret);
  4528. if (ret.code === 1) {
  4529. Fast.events.onAjaxSuccess(ret, success);
  4530. } else {
  4531. Fast.events.onAjaxError(ret, error);
  4532. }
  4533. },
  4534. error: function (xhr) {
  4535. index && Layer.close(index);
  4536. var ret = {code: xhr.status, msg: xhr.statusText, data: null};
  4537. Fast.events.onAjaxError(ret, error);
  4538. }
  4539. }, options);
  4540. return $.ajax(options);
  4541. },
  4542. //修复URL
  4543. fixurl: function (url) {
  4544. if (url.substr(0, 1) !== "/") {
  4545. var r = new RegExp('^(?:[a-z]+:)?//', 'i');
  4546. if (!r.test(url)) {
  4547. url = Config.moduleurl + "/" + url;
  4548. }
  4549. } else if (url.substr(0, 8) === "/addons/") {
  4550. url = Config.__PUBLIC__.replace(/(\/*$)/g, "") + url;
  4551. }
  4552. return url;
  4553. },
  4554. //获取修复后可访问的cdn链接
  4555. cdnurl: function (url, domain) {
  4556. var rule = new RegExp("^((?:[a-z]+:)?\\/\\/|data:image\\/)", "i");
  4557. var cdnurl = Config.upload.cdnurl;
  4558. url = rule.test(url) || (cdnurl && url.indexOf(cdnurl) === 0) ? url : cdnurl + url;
  4559. if (domain && !rule.test(url)) {
  4560. domain = typeof domain === 'string' ? domain : location.origin;
  4561. url = domain + url;
  4562. }
  4563. return url;
  4564. },
  4565. //查询Url参数
  4566. query: function (name, url) {
  4567. if (!url) {
  4568. url = window.location.href;
  4569. }
  4570. name = name.replace(/[\[\]]/g, "\\$&");
  4571. var regex = new RegExp("[?&/]" + name + "([=/]([^&#/?]*)|&|#|$)"),
  4572. results = regex.exec(url);
  4573. if (!results)
  4574. return null;
  4575. if (!results[2])
  4576. return '';
  4577. return decodeURIComponent(results[2].replace(/\+/g, " "));
  4578. },
  4579. //打开一个弹出窗口
  4580. open: function (url, title, options) {
  4581. title = options && options.title ? options.title : (title ? title : "");
  4582. url = Fast.api.fixurl(url);
  4583. url = url + (url.indexOf("?") > -1 ? "&" : "?") + "dialog=1";
  4584. var area = Fast.config.openArea != undefined ? Fast.config.openArea : [$(window).width() > 800 ? '800px' : '95%', $(window).height() > 600 ? '600px' : '95%'];
  4585. options = $.extend({
  4586. type: 2,
  4587. title: title,
  4588. shadeClose: true,
  4589. shade: false,
  4590. maxmin: true,
  4591. moveOut: true,
  4592. area: area,
  4593. content: url,
  4594. zIndex: Layer.zIndex,
  4595. success: function (layero, index) {
  4596. var that = this;
  4597. //存储callback事件
  4598. $(layero).data("callback", that.callback);
  4599. //$(layero).removeClass("layui-layer-border");
  4600. Layer.setTop(layero);
  4601. try {
  4602. var frame = Layer.getChildFrame('html', index);
  4603. var layerfooter = frame.find(".layer-footer");
  4604. Fast.api.layerfooter(layero, index, that);
  4605. //绑定事件
  4606. if (layerfooter.size() > 0) {
  4607. // 监听窗口内的元素及属性变化
  4608. // Firefox和Chrome早期版本中带有前缀
  4609. var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
  4610. if (MutationObserver) {
  4611. // 选择目标节点
  4612. var target = layerfooter[0];
  4613. // 创建观察者对象
  4614. var observer = new MutationObserver(function (mutations) {
  4615. Fast.api.layerfooter(layero, index, that);
  4616. mutations.forEach(function (mutation) {
  4617. });
  4618. });
  4619. // 配置观察选项:
  4620. var config = {attributes: true, childList: true, characterData: true, subtree: true}
  4621. // 传入目标节点和观察选项
  4622. observer.observe(target, config);
  4623. // 随后,你还可以停止观察
  4624. // observer.disconnect();
  4625. }
  4626. }
  4627. } catch (e) {
  4628. }
  4629. if ($(layero).height() > $(window).height()) {
  4630. //当弹出窗口大于浏览器可视高度时,重定位
  4631. Layer.style(index, {
  4632. top: 0,
  4633. height: $(window).height()
  4634. });
  4635. }
  4636. }
  4637. }, options ? options : {});
  4638. if ($(window).width() < 480 || (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream && top.$(".tab-pane.active").size() > 0)) {
  4639. options.area = [top.$(".tab-pane.active").width() + "px", top.$(".tab-pane.active").height() + "px"];
  4640. options.offset = [top.$(".tab-pane.active").scrollTop() + "px", "0px"];
  4641. }
  4642. return Layer.open(options);
  4643. },
  4644. //关闭窗口并回传数据
  4645. close: function (data) {
  4646. var index = parent.Layer.getFrameIndex(window.name);
  4647. var callback = parent.$("#layui-layer" + index).data("callback");
  4648. //再执行关闭
  4649. parent.Layer.close(index);
  4650. //再调用回传函数
  4651. if (typeof callback === 'function') {
  4652. callback.call(undefined, data);
  4653. }
  4654. },
  4655. layerfooter: function (layero, index, that) {
  4656. var frame = Layer.getChildFrame('html', index);
  4657. var layerfooter = frame.find(".layer-footer");
  4658. if (layerfooter.size() > 0) {
  4659. $(".layui-layer-footer", layero).remove();
  4660. var footer = $("<div />").addClass('layui-layer-btn layui-layer-footer');
  4661. footer.html(layerfooter.html());
  4662. if ($(".row", footer).size() === 0) {
  4663. $(">", footer).wrapAll("<div class='row'></div>");
  4664. }
  4665. footer.insertAfter(layero.find('.layui-layer-content'));
  4666. //绑定事件
  4667. footer.on("click", ".btn", function () {
  4668. if ($(this).hasClass("disabled") || $(this).parent().hasClass("disabled")) {
  4669. return;
  4670. }
  4671. var index = footer.find('.btn').index(this);
  4672. $(".btn:eq(" + index + ")", layerfooter).trigger("click");
  4673. });
  4674. var titHeight = layero.find('.layui-layer-title').outerHeight() || 0;
  4675. var btnHeight = layero.find('.layui-layer-btn').outerHeight() || 0;
  4676. //重设iframe高度
  4677. $("iframe", layero).height(layero.height() - titHeight - btnHeight);
  4678. }
  4679. //修复iOS下弹出窗口的高度和iOS下iframe无法滚动的BUG
  4680. if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
  4681. var titHeight = layero.find('.layui-layer-title').outerHeight() || 0;
  4682. var btnHeight = layero.find('.layui-layer-btn').outerHeight() || 0;
  4683. $("iframe", layero).parent().css("height", layero.height() - titHeight - btnHeight);
  4684. $("iframe", layero).css("height", "100%");
  4685. }
  4686. },
  4687. success: function (options, callback) {
  4688. var type = typeof options === 'function';
  4689. if (type) {
  4690. callback = options;
  4691. }
  4692. return Layer.msg(__('Operation completed'), $.extend({
  4693. offset: 0, icon: 1
  4694. }, type ? {} : options), callback);
  4695. },
  4696. error: function (options, callback) {
  4697. var type = typeof options === 'function';
  4698. if (type) {
  4699. callback = options;
  4700. }
  4701. return Layer.msg(__('Operation failed'), $.extend({
  4702. offset: 0, icon: 2
  4703. }, type ? {} : options), callback);
  4704. },
  4705. msg: function (message, url) {
  4706. var callback = typeof url === 'function' ? url : function () {
  4707. if (typeof url !== 'undefined' && url) {
  4708. location.href = url;
  4709. }
  4710. };
  4711. Layer.msg(message, {
  4712. time: 2000
  4713. }, callback);
  4714. },
  4715. toastr: Toastr,
  4716. layer: Layer
  4717. },
  4718. lang: function () {
  4719. var args = arguments,
  4720. string = args[0],
  4721. i = 1;
  4722. string = string.toLowerCase();
  4723. //string = typeof Lang[string] != 'undefined' ? Lang[string] : string;
  4724. if (typeof Lang !== 'undefined' && typeof Lang[string] !== 'undefined') {
  4725. if (typeof Lang[string] == 'object')
  4726. return Lang[string];
  4727. string = Lang[string];
  4728. } else if (string.indexOf('.') !== -1 && false) {
  4729. var arr = string.split('.');
  4730. var current = Lang[arr[0]];
  4731. for (var i = 1; i < arr.length; i++) {
  4732. current = typeof current[arr[i]] != 'undefined' ? current[arr[i]] : '';
  4733. if (typeof current != 'object')
  4734. break;
  4735. }
  4736. if (typeof current == 'object')
  4737. return current;
  4738. string = current;
  4739. } else {
  4740. string = args[0];
  4741. }
  4742. return string.replace(/%((%)|s|d)/g, function (m) {
  4743. // m is the matched format, e.g. %s, %d
  4744. var val = null;
  4745. if (m[2]) {
  4746. val = m[2];
  4747. } else {
  4748. val = args[i];
  4749. // A switch statement so that the formatter can be extended. Default is %s
  4750. switch (m) {
  4751. case '%d':
  4752. val = parseFloat(val);
  4753. if (isNaN(val)) {
  4754. val = 0;
  4755. }
  4756. break;
  4757. }
  4758. i++;
  4759. }
  4760. return val;
  4761. });
  4762. },
  4763. init: function () {
  4764. // 对相对地址进行处理
  4765. $.ajaxSetup({
  4766. beforeSend: function (xhr, setting) {
  4767. setting.url = Fast.api.fixurl(setting.url);
  4768. }
  4769. });
  4770. Layer.config({
  4771. skin: 'layui-layer-fast'
  4772. });
  4773. // 绑定ESC关闭窗口事件
  4774. $(window).keyup(function (e) {
  4775. if (e.keyCode == 27) {
  4776. if ($(".layui-layer").size() > 0) {
  4777. var index = 0;
  4778. $(".layui-layer").each(function () {
  4779. index = Math.max(index, parseInt($(this).attr("times")));
  4780. });
  4781. if (index) {
  4782. Layer.close(index);
  4783. }
  4784. }
  4785. }
  4786. });
  4787. //公共代码
  4788. //配置Toastr的参数
  4789. Toastr.options = Fast.config.toastr;
  4790. }
  4791. };
  4792. //将Layer暴露到全局中去
  4793. window.Layer = Layer;
  4794. //将Toastr暴露到全局中去
  4795. window.Toastr = Toastr;
  4796. //将语言方法暴露到全局中去
  4797. window.__ = Fast.lang;
  4798. //将Fast渲染至全局
  4799. window.Fast = Fast;
  4800. //默认初始化执行的代码
  4801. Fast.init();
  4802. return Fast;
  4803. });
  4804. /*!art-template - Template Engine | http://aui.github.com/artTemplate/*/
  4805. !function () {
  4806. function a(a) {
  4807. return a.replace(t, "").replace(u, ",").replace(v, "").replace(w, "").replace(x, "").split(y)
  4808. }
  4809. function b(a) {
  4810. return "'" + a.replace(/('|\\)/g, "\\$1").replace(/\r/g, "\\r").replace(/\n/g, "\\n") + "'"
  4811. }
  4812. function c(c, d) {
  4813. function e(a) {
  4814. 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
  4815. }
  4816. function f(b) {
  4817. var c = m;
  4818. if (j ? b = j(b, d) : g && (b = b.replace(/\n/g, function () {
  4819. return m++, "$line=" + m + ";"
  4820. })), 0 === b.indexOf("=")) {
  4821. var e = l && !/^=[=#]/.test(b);
  4822. if (b = b.replace(/^=[=#]?|[\s;]*$/g, ""), e) {
  4823. var f = b.replace(/\s*\([^\)]+\)/, "");
  4824. n[f] || /^(include|print)$/.test(f) || (b = "$escape(" + b + ")")
  4825. } else b = "$string(" + b + ")";
  4826. b = s[1] + b + s[2]
  4827. }
  4828. return g && (b = "$line=" + c + ";" + b), r(a(b), function (a) {
  4829. if (a && !p[a]) {
  4830. var b;
  4831. b = "print" === a ? u : "include" === a ? v : n[a] ? "$utils." + a : o[a] ? "$helpers." + a : "$data." + a, w += a + "=" + b + ",", p[a] = !0
  4832. }
  4833. }), b + "\n"
  4834. }
  4835. var g = d.debug, h = d.openTag, i = d.closeTag, j = d.parser, k = d.compress, l = d.escape, m = 1,
  4836. p = {$data: 1, $filename: 1, $utils: 1, $helpers: 1, $out: 1, $line: 1}, q = "".trim,
  4837. s = q ? ["$out='';", "$out+=", ";", "$out"] : ["$out=[];", "$out.push(", ");", "$out.join('')"],
  4838. t = q ? "$out+=text;return $out;" : "$out.push(text);",
  4839. u = "function(){var text=''.concat.apply('',arguments);" + t + "}",
  4840. v = "function(filename,data){data=data||$data;var text=$utils.$include(filename,data,$filename);" + t + "}",
  4841. w = "'use strict';var $utils=this,$helpers=$utils.$helpers," + (g ? "$line=0," : ""), x = s[0],
  4842. y = "return new String(" + s[3] + ");";
  4843. r(c.split(h), function (a) {
  4844. a = a.split(i);
  4845. var b = a[0], c = a[1];
  4846. 1 === a.length ? x += e(b) : (x += f(b), c && (x += e(c)))
  4847. });
  4848. var z = w + x + y;
  4849. 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+/,'')};}");
  4850. try {
  4851. var A = new Function("$data", "$filename", z);
  4852. return A.prototype = n, A
  4853. } catch (a) {
  4854. throw a.temp = "function anonymous($data,$filename) {" + z + "}", a
  4855. }
  4856. }
  4857. var d = function (a, b) {
  4858. return "string" == typeof b ? q(b, {filename: a}) : g(a, b)
  4859. };
  4860. d.version = "3.0.0", d.config = function (a, b) {
  4861. e[a] = b
  4862. };
  4863. var e = d.defaults = {openTag: "<%", closeTag: "%>", escape: !0, cache: !0, compress: !1, parser: null},
  4864. f = d.cache = {};
  4865. d.render = function (a, b) {
  4866. return q(a)(b)
  4867. };
  4868. var g = d.renderFile = function (a, b) {
  4869. var c = d.get(a) || p({filename: a, name: "Render Error", message: "Template not found"});
  4870. return b ? c(b) : c
  4871. };
  4872. d.get = function (a) {
  4873. var b;
  4874. if (f[a]) b = f[a]; else if ("object" == typeof document) {
  4875. var c = document.getElementById(a);
  4876. if (c) {
  4877. var d = (c.value || c.innerHTML).replace(/^\s*|\s*$/g, "");
  4878. b = q(d, {filename: a})
  4879. }
  4880. }
  4881. return b
  4882. };
  4883. var h = function (a, b) {
  4884. return "string" != typeof a && (b = typeof a, "number" === b ? a += "" : a = "function" === b ? h(a.call(a)) : ""), a
  4885. }, i = {"<": "&#60;", ">": "&#62;", '"': "&#34;", "'": "&#39;", "&": "&#38;"}, j = function (a) {
  4886. return i[a]
  4887. }, k = function (a) {
  4888. return h(a).replace(/&(?![\w#]+;)|[<>"']/g, j)
  4889. }, l = Array.isArray || function (a) {
  4890. return "[object Array]" === {}.toString.call(a)
  4891. }, m = function (a, b) {
  4892. var c, d;
  4893. 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)
  4894. }, n = d.utils = {$helpers: {}, $include: g, $string: h, $escape: k, $each: m};
  4895. d.helper = function (a, b) {
  4896. o[a] = b
  4897. };
  4898. var o = d.helpers = n.$helpers;
  4899. d.onerror = function (a) {
  4900. var b = "Template Error\n\n";
  4901. for (var c in a) b += "<" + c + ">\n" + a[c] + "\n\n";
  4902. "object" == typeof console && console.error(b)
  4903. };
  4904. var p = function (a) {
  4905. return d.onerror(a), function () {
  4906. return "{Template Error}"
  4907. }
  4908. }, q = d.compile = function (a, b) {
  4909. function d(c) {
  4910. try {
  4911. return new i(c, h) + ""
  4912. } catch (d) {
  4913. return b.debug ? p(d)() : (b.debug = !0, q(a, b)(c))
  4914. }
  4915. }
  4916. b = b || {};
  4917. for (var g in e) void 0 === b[g] && (b[g] = e[g]);
  4918. var h = b.filename;
  4919. try {
  4920. var i = c(a, b)
  4921. } catch (a) {
  4922. return a.filename = h || "anonymous", a.name = "Syntax Error", p(a)
  4923. }
  4924. return d.prototype = i.prototype, d.toString = function () {
  4925. return i.toString()
  4926. }, h && b.cache && (f[h] = d), d
  4927. }, r = n.$each,
  4928. 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",
  4929. t = /\/\*[\w\W]*?\*\/|\/\/[^\n]*\n|\/\/[^\n]*$|"(?:[^"\\]|\\[\w\W])*"|'(?:[^'\\]|\\[\w\W])*'|\s*\.\s*[$\w\.]+/g,
  4930. u = /[^\w$]+/g, v = new RegExp(["\\b" + s.replace(/,/g, "\\b|\\b") + "\\b"].join("|"), "g"),
  4931. w = /^\d[^,]*|,\d[^,]*/g, x = /^,+|,+$/g, y = /^$|,+/;
  4932. "object" == typeof exports && "undefined" != typeof module ? module.exports = d : "function" == typeof define ? define('template', [], function () {
  4933. return d
  4934. }) : this.template = d
  4935. }();
  4936. //! moment.js
  4937. //! version : 2.29.1
  4938. //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
  4939. //! license : MIT
  4940. //! momentjs.com
  4941. ;(function (global, factory) {
  4942. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  4943. typeof define === 'function' && define.amd ? define('moment/moment', factory) :
  4944. global.moment = factory()
  4945. }(this, (function () {
  4946. 'use strict';
  4947. var hookCallback;
  4948. function hooks() {
  4949. return hookCallback.apply(null, arguments);
  4950. }
  4951. // This is done to register the method called with moment()
  4952. // without creating circular dependencies.
  4953. function setHookCallback(callback) {
  4954. hookCallback = callback;
  4955. }
  4956. function isArray(input) {
  4957. return (
  4958. input instanceof Array ||
  4959. Object.prototype.toString.call(input) === '[object Array]'
  4960. );
  4961. }
  4962. function isObject(input) {
  4963. // IE8 will treat undefined and null as object if it wasn't for
  4964. // input != null
  4965. return (
  4966. input != null &&
  4967. Object.prototype.toString.call(input) === '[object Object]'
  4968. );
  4969. }
  4970. function hasOwnProp(a, b) {
  4971. return Object.prototype.hasOwnProperty.call(a, b);
  4972. }
  4973. function isObjectEmpty(obj) {
  4974. if (Object.getOwnPropertyNames) {
  4975. return Object.getOwnPropertyNames(obj).length === 0;
  4976. } else {
  4977. var k;
  4978. for (k in obj) {
  4979. if (hasOwnProp(obj, k)) {
  4980. return false;
  4981. }
  4982. }
  4983. return true;
  4984. }
  4985. }
  4986. function isUndefined(input) {
  4987. return input === void 0;
  4988. }
  4989. function isNumber(input) {
  4990. return (
  4991. typeof input === 'number' ||
  4992. Object.prototype.toString.call(input) === '[object Number]'
  4993. );
  4994. }
  4995. function isDate(input) {
  4996. return (
  4997. input instanceof Date ||
  4998. Object.prototype.toString.call(input) === '[object Date]'
  4999. );
  5000. }
  5001. function map(arr, fn) {
  5002. var res = [],
  5003. i;
  5004. for (i = 0; i < arr.length; ++i) {
  5005. res.push(fn(arr[i], i));
  5006. }
  5007. return res;
  5008. }
  5009. function extend(a, b) {
  5010. for (var i in b) {
  5011. if (hasOwnProp(b, i)) {
  5012. a[i] = b[i];
  5013. }
  5014. }
  5015. if (hasOwnProp(b, 'toString')) {
  5016. a.toString = b.toString;
  5017. }
  5018. if (hasOwnProp(b, 'valueOf')) {
  5019. a.valueOf = b.valueOf;
  5020. }
  5021. return a;
  5022. }
  5023. function createUTC(input, format, locale, strict) {
  5024. return createLocalOrUTC(input, format, locale, strict, true).utc();
  5025. }
  5026. function defaultParsingFlags() {
  5027. // We need to deep clone this object.
  5028. return {
  5029. empty: false,
  5030. unusedTokens: [],
  5031. unusedInput: [],
  5032. overflow: -2,
  5033. charsLeftOver: 0,
  5034. nullInput: false,
  5035. invalidEra: null,
  5036. invalidMonth: null,
  5037. invalidFormat: false,
  5038. userInvalidated: false,
  5039. iso: false,
  5040. parsedDateParts: [],
  5041. era: null,
  5042. meridiem: null,
  5043. rfc2822: false,
  5044. weekdayMismatch: false,
  5045. };
  5046. }
  5047. function getParsingFlags(m) {
  5048. if (m._pf == null) {
  5049. m._pf = defaultParsingFlags();
  5050. }
  5051. return m._pf;
  5052. }
  5053. var some;
  5054. if (Array.prototype.some) {
  5055. some = Array.prototype.some;
  5056. } else {
  5057. some = function (fun) {
  5058. var t = Object(this),
  5059. len = t.length >>> 0,
  5060. i;
  5061. for (i = 0; i < len; i++) {
  5062. if (i in t && fun.call(this, t[i], i, t)) {
  5063. return true;
  5064. }
  5065. }
  5066. return false;
  5067. };
  5068. }
  5069. function isValid(m) {
  5070. if (m._isValid == null) {
  5071. var flags = getParsingFlags(m),
  5072. parsedParts = some.call(flags.parsedDateParts, function (i) {
  5073. return i != null;
  5074. }),
  5075. isNowValid =
  5076. !isNaN(m._d.getTime()) &&
  5077. flags.overflow < 0 &&
  5078. !flags.empty &&
  5079. !flags.invalidEra &&
  5080. !flags.invalidMonth &&
  5081. !flags.invalidWeekday &&
  5082. !flags.weekdayMismatch &&
  5083. !flags.nullInput &&
  5084. !flags.invalidFormat &&
  5085. !flags.userInvalidated &&
  5086. (!flags.meridiem || (flags.meridiem && parsedParts));
  5087. if (m._strict) {
  5088. isNowValid =
  5089. isNowValid &&
  5090. flags.charsLeftOver === 0 &&
  5091. flags.unusedTokens.length === 0 &&
  5092. flags.bigHour === undefined;
  5093. }
  5094. if (Object.isFrozen == null || !Object.isFrozen(m)) {
  5095. m._isValid = isNowValid;
  5096. } else {
  5097. return isNowValid;
  5098. }
  5099. }
  5100. return m._isValid;
  5101. }
  5102. function createInvalid(flags) {
  5103. var m = createUTC(NaN);
  5104. if (flags != null) {
  5105. extend(getParsingFlags(m), flags);
  5106. } else {
  5107. getParsingFlags(m).userInvalidated = true;
  5108. }
  5109. return m;
  5110. }
  5111. // Plugins that add properties should also add the key here (null value),
  5112. // so we can properly clone ourselves.
  5113. var momentProperties = (hooks.momentProperties = []),
  5114. updateInProgress = false;
  5115. function copyConfig(to, from) {
  5116. var i, prop, val;
  5117. if (!isUndefined(from._isAMomentObject)) {
  5118. to._isAMomentObject = from._isAMomentObject;
  5119. }
  5120. if (!isUndefined(from._i)) {
  5121. to._i = from._i;
  5122. }
  5123. if (!isUndefined(from._f)) {
  5124. to._f = from._f;
  5125. }
  5126. if (!isUndefined(from._l)) {
  5127. to._l = from._l;
  5128. }
  5129. if (!isUndefined(from._strict)) {
  5130. to._strict = from._strict;
  5131. }
  5132. if (!isUndefined(from._tzm)) {
  5133. to._tzm = from._tzm;
  5134. }
  5135. if (!isUndefined(from._isUTC)) {
  5136. to._isUTC = from._isUTC;
  5137. }
  5138. if (!isUndefined(from._offset)) {
  5139. to._offset = from._offset;
  5140. }
  5141. if (!isUndefined(from._pf)) {
  5142. to._pf = getParsingFlags(from);
  5143. }
  5144. if (!isUndefined(from._locale)) {
  5145. to._locale = from._locale;
  5146. }
  5147. if (momentProperties.length > 0) {
  5148. for (i = 0; i < momentProperties.length; i++) {
  5149. prop = momentProperties[i];
  5150. val = from[prop];
  5151. if (!isUndefined(val)) {
  5152. to[prop] = val;
  5153. }
  5154. }
  5155. }
  5156. return to;
  5157. }
  5158. // Moment prototype object
  5159. function Moment(config) {
  5160. copyConfig(this, config);
  5161. this._d = new Date(config._d != null ? config._d.getTime() : NaN);
  5162. if (!this.isValid()) {
  5163. this._d = new Date(NaN);
  5164. }
  5165. // Prevent infinite loop in case updateOffset creates new moment
  5166. // objects.
  5167. if (updateInProgress === false) {
  5168. updateInProgress = true;
  5169. hooks.updateOffset(this);
  5170. updateInProgress = false;
  5171. }
  5172. }
  5173. function isMoment(obj) {
  5174. return (
  5175. obj instanceof Moment || (obj != null && obj._isAMomentObject != null)
  5176. );
  5177. }
  5178. function warn(msg) {
  5179. if (
  5180. hooks.suppressDeprecationWarnings === false &&
  5181. typeof console !== 'undefined' &&
  5182. console.warn
  5183. ) {
  5184. console.warn('Deprecation warning: ' + msg);
  5185. }
  5186. }
  5187. function deprecate(msg, fn) {
  5188. var firstTime = true;
  5189. return extend(function () {
  5190. if (hooks.deprecationHandler != null) {
  5191. hooks.deprecationHandler(null, msg);
  5192. }
  5193. if (firstTime) {
  5194. var args = [],
  5195. arg,
  5196. i,
  5197. key;
  5198. for (i = 0; i < arguments.length; i++) {
  5199. arg = '';
  5200. if (typeof arguments[i] === 'object') {
  5201. arg += '\n[' + i + '] ';
  5202. for (key in arguments[0]) {
  5203. if (hasOwnProp(arguments[0], key)) {
  5204. arg += key + ': ' + arguments[0][key] + ', ';
  5205. }
  5206. }
  5207. arg = arg.slice(0, -2); // Remove trailing comma and space
  5208. } else {
  5209. arg = arguments[i];
  5210. }
  5211. args.push(arg);
  5212. }
  5213. warn(
  5214. msg +
  5215. '\nArguments: ' +
  5216. Array.prototype.slice.call(args).join('') +
  5217. '\n' +
  5218. new Error().stack
  5219. );
  5220. firstTime = false;
  5221. }
  5222. return fn.apply(this, arguments);
  5223. }, fn);
  5224. }
  5225. var deprecations = {};
  5226. function deprecateSimple(name, msg) {
  5227. if (hooks.deprecationHandler != null) {
  5228. hooks.deprecationHandler(name, msg);
  5229. }
  5230. if (!deprecations[name]) {
  5231. warn(msg);
  5232. deprecations[name] = true;
  5233. }
  5234. }
  5235. hooks.suppressDeprecationWarnings = false;
  5236. hooks.deprecationHandler = null;
  5237. function isFunction(input) {
  5238. return (
  5239. (typeof Function !== 'undefined' && input instanceof Function) ||
  5240. Object.prototype.toString.call(input) === '[object Function]'
  5241. );
  5242. }
  5243. function set(config) {
  5244. var prop, i;
  5245. for (i in config) {
  5246. if (hasOwnProp(config, i)) {
  5247. prop = config[i];
  5248. if (isFunction(prop)) {
  5249. this[i] = prop;
  5250. } else {
  5251. this['_' + i] = prop;
  5252. }
  5253. }
  5254. }
  5255. this._config = config;
  5256. // Lenient ordinal parsing accepts just a number in addition to
  5257. // number + (possibly) stuff coming from _dayOfMonthOrdinalParse.
  5258. // TODO: Remove "ordinalParse" fallback in next major release.
  5259. this._dayOfMonthOrdinalParseLenient = new RegExp(
  5260. (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
  5261. '|' +
  5262. /\d{1,2}/.source
  5263. );
  5264. }
  5265. function mergeConfigs(parentConfig, childConfig) {
  5266. var res = extend({}, parentConfig),
  5267. prop;
  5268. for (prop in childConfig) {
  5269. if (hasOwnProp(childConfig, prop)) {
  5270. if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
  5271. res[prop] = {};
  5272. extend(res[prop], parentConfig[prop]);
  5273. extend(res[prop], childConfig[prop]);
  5274. } else if (childConfig[prop] != null) {
  5275. res[prop] = childConfig[prop];
  5276. } else {
  5277. delete res[prop];
  5278. }
  5279. }
  5280. }
  5281. for (prop in parentConfig) {
  5282. if (
  5283. hasOwnProp(parentConfig, prop) &&
  5284. !hasOwnProp(childConfig, prop) &&
  5285. isObject(parentConfig[prop])
  5286. ) {
  5287. // make sure changes to properties don't modify parent config
  5288. res[prop] = extend({}, res[prop]);
  5289. }
  5290. }
  5291. return res;
  5292. }
  5293. function Locale(config) {
  5294. if (config != null) {
  5295. this.set(config);
  5296. }
  5297. }
  5298. var keys;
  5299. if (Object.keys) {
  5300. keys = Object.keys;
  5301. } else {
  5302. keys = function (obj) {
  5303. var i,
  5304. res = [];
  5305. for (i in obj) {
  5306. if (hasOwnProp(obj, i)) {
  5307. res.push(i);
  5308. }
  5309. }
  5310. return res;
  5311. };
  5312. }
  5313. var defaultCalendar = {
  5314. sameDay: '[Today at] LT',
  5315. nextDay: '[Tomorrow at] LT',
  5316. nextWeek: 'dddd [at] LT',
  5317. lastDay: '[Yesterday at] LT',
  5318. lastWeek: '[Last] dddd [at] LT',
  5319. sameElse: 'L',
  5320. };
  5321. function calendar(key, mom, now) {
  5322. var output = this._calendar[key] || this._calendar['sameElse'];
  5323. return isFunction(output) ? output.call(mom, now) : output;
  5324. }
  5325. function zeroFill(number, targetLength, forceSign) {
  5326. var absNumber = '' + Math.abs(number),
  5327. zerosToFill = targetLength - absNumber.length,
  5328. sign = number >= 0;
  5329. return (
  5330. (sign ? (forceSign ? '+' : '') : '-') +
  5331. Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) +
  5332. absNumber
  5333. );
  5334. }
  5335. var formattingTokens = /(\[[^\[]*\])|(\\)?([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,
  5336. localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,
  5337. formatFunctions = {},
  5338. formatTokenFunctions = {};
  5339. // token: 'M'
  5340. // padded: ['MM', 2]
  5341. // ordinal: 'Mo'
  5342. // callback: function () { this.month() + 1 }
  5343. function addFormatToken(token, padded, ordinal, callback) {
  5344. var func = callback;
  5345. if (typeof callback === 'string') {
  5346. func = function () {
  5347. return this[callback]();
  5348. };
  5349. }
  5350. if (token) {
  5351. formatTokenFunctions[token] = func;
  5352. }
  5353. if (padded) {
  5354. formatTokenFunctions[padded[0]] = function () {
  5355. return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
  5356. };
  5357. }
  5358. if (ordinal) {
  5359. formatTokenFunctions[ordinal] = function () {
  5360. return this.localeData().ordinal(
  5361. func.apply(this, arguments),
  5362. token
  5363. );
  5364. };
  5365. }
  5366. }
  5367. function removeFormattingTokens(input) {
  5368. if (input.match(/\[[\s\S]/)) {
  5369. return input.replace(/^\[|\]$/g, '');
  5370. }
  5371. return input.replace(/\\/g, '');
  5372. }
  5373. function makeFormatFunction(format) {
  5374. var array = format.match(formattingTokens),
  5375. i,
  5376. length;
  5377. for (i = 0, length = array.length; i < length; i++) {
  5378. if (formatTokenFunctions[array[i]]) {
  5379. array[i] = formatTokenFunctions[array[i]];
  5380. } else {
  5381. array[i] = removeFormattingTokens(array[i]);
  5382. }
  5383. }
  5384. return function (mom) {
  5385. var output = '',
  5386. i;
  5387. for (i = 0; i < length; i++) {
  5388. output += isFunction(array[i])
  5389. ? array[i].call(mom, format)
  5390. : array[i];
  5391. }
  5392. return output;
  5393. };
  5394. }
  5395. // format date using native date object
  5396. function formatMoment(m, format) {
  5397. if (!m.isValid()) {
  5398. return m.localeData().invalidDate();
  5399. }
  5400. format = expandFormat(format, m.localeData());
  5401. formatFunctions[format] =
  5402. formatFunctions[format] || makeFormatFunction(format);
  5403. return formatFunctions[format](m);
  5404. }
  5405. function expandFormat(format, locale) {
  5406. var i = 5;
  5407. function replaceLongDateFormatTokens(input) {
  5408. return locale.longDateFormat(input) || input;
  5409. }
  5410. localFormattingTokens.lastIndex = 0;
  5411. while (i >= 0 && localFormattingTokens.test(format)) {
  5412. format = format.replace(
  5413. localFormattingTokens,
  5414. replaceLongDateFormatTokens
  5415. );
  5416. localFormattingTokens.lastIndex = 0;
  5417. i -= 1;
  5418. }
  5419. return format;
  5420. }
  5421. var defaultLongDateFormat = {
  5422. LTS: 'h:mm:ss A',
  5423. LT: 'h:mm A',
  5424. L: 'MM/DD/YYYY',
  5425. LL: 'MMMM D, YYYY',
  5426. LLL: 'MMMM D, YYYY h:mm A',
  5427. LLLL: 'dddd, MMMM D, YYYY h:mm A',
  5428. };
  5429. function longDateFormat(key) {
  5430. var format = this._longDateFormat[key],
  5431. formatUpper = this._longDateFormat[key.toUpperCase()];
  5432. if (format || !formatUpper) {
  5433. return format;
  5434. }
  5435. this._longDateFormat[key] = formatUpper
  5436. .match(formattingTokens)
  5437. .map(function (tok) {
  5438. if (
  5439. tok === 'MMMM' ||
  5440. tok === 'MM' ||
  5441. tok === 'DD' ||
  5442. tok === 'dddd'
  5443. ) {
  5444. return tok.slice(1);
  5445. }
  5446. return tok;
  5447. })
  5448. .join('');
  5449. return this._longDateFormat[key];
  5450. }
  5451. var defaultInvalidDate = 'Invalid date';
  5452. function invalidDate() {
  5453. return this._invalidDate;
  5454. }
  5455. var defaultOrdinal = '%d',
  5456. defaultDayOfMonthOrdinalParse = /\d{1,2}/;
  5457. function ordinal(number) {
  5458. return this._ordinal.replace('%d', number);
  5459. }
  5460. var defaultRelativeTime = {
  5461. future: 'in %s',
  5462. past: '%s ago',
  5463. s: 'a few seconds',
  5464. ss: '%d seconds',
  5465. m: 'a minute',
  5466. mm: '%d minutes',
  5467. h: 'an hour',
  5468. hh: '%d hours',
  5469. d: 'a day',
  5470. dd: '%d days',
  5471. w: 'a week',
  5472. ww: '%d weeks',
  5473. M: 'a month',
  5474. MM: '%d months',
  5475. y: 'a year',
  5476. yy: '%d years',
  5477. };
  5478. function relativeTime(number, withoutSuffix, string, isFuture) {
  5479. var output = this._relativeTime[string];
  5480. return isFunction(output)
  5481. ? output(number, withoutSuffix, string, isFuture)
  5482. : output.replace(/%d/i, number);
  5483. }
  5484. function pastFuture(diff, output) {
  5485. var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
  5486. return isFunction(format) ? format(output) : format.replace(/%s/i, output);
  5487. }
  5488. var aliases = {};
  5489. function addUnitAlias(unit, shorthand) {
  5490. var lowerCase = unit.toLowerCase();
  5491. aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
  5492. }
  5493. function normalizeUnits(units) {
  5494. return typeof units === 'string'
  5495. ? aliases[units] || aliases[units.toLowerCase()]
  5496. : undefined;
  5497. }
  5498. function normalizeObjectUnits(inputObject) {
  5499. var normalizedInput = {},
  5500. normalizedProp,
  5501. prop;
  5502. for (prop in inputObject) {
  5503. if (hasOwnProp(inputObject, prop)) {
  5504. normalizedProp = normalizeUnits(prop);
  5505. if (normalizedProp) {
  5506. normalizedInput[normalizedProp] = inputObject[prop];
  5507. }
  5508. }
  5509. }
  5510. return normalizedInput;
  5511. }
  5512. var priorities = {};
  5513. function addUnitPriority(unit, priority) {
  5514. priorities[unit] = priority;
  5515. }
  5516. function getPrioritizedUnits(unitsObj) {
  5517. var units = [],
  5518. u;
  5519. for (u in unitsObj) {
  5520. if (hasOwnProp(unitsObj, u)) {
  5521. units.push({unit: u, priority: priorities[u]});
  5522. }
  5523. }
  5524. units.sort(function (a, b) {
  5525. return a.priority - b.priority;
  5526. });
  5527. return units;
  5528. }
  5529. function isLeapYear(year) {
  5530. return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
  5531. }
  5532. function absFloor(number) {
  5533. if (number < 0) {
  5534. // -0 -> 0
  5535. return Math.ceil(number) || 0;
  5536. } else {
  5537. return Math.floor(number);
  5538. }
  5539. }
  5540. function toInt(argumentForCoercion) {
  5541. var coercedNumber = +argumentForCoercion,
  5542. value = 0;
  5543. if (coercedNumber !== 0 && isFinite(coercedNumber)) {
  5544. value = absFloor(coercedNumber);
  5545. }
  5546. return value;
  5547. }
  5548. function makeGetSet(unit, keepTime) {
  5549. return function (value) {
  5550. if (value != null) {
  5551. set$1(this, unit, value);
  5552. hooks.updateOffset(this, keepTime);
  5553. return this;
  5554. } else {
  5555. return get(this, unit);
  5556. }
  5557. };
  5558. }
  5559. function get(mom, unit) {
  5560. return mom.isValid()
  5561. ? mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]()
  5562. : NaN;
  5563. }
  5564. function set$1(mom, unit, value) {
  5565. if (mom.isValid() && !isNaN(value)) {
  5566. if (
  5567. unit === 'FullYear' &&
  5568. isLeapYear(mom.year()) &&
  5569. mom.month() === 1 &&
  5570. mom.date() === 29
  5571. ) {
  5572. value = toInt(value);
  5573. mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](
  5574. value,
  5575. mom.month(),
  5576. daysInMonth(value, mom.month())
  5577. );
  5578. } else {
  5579. mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
  5580. }
  5581. }
  5582. }
  5583. // MOMENTS
  5584. function stringGet(units) {
  5585. units = normalizeUnits(units);
  5586. if (isFunction(this[units])) {
  5587. return this[units]();
  5588. }
  5589. return this;
  5590. }
  5591. function stringSet(units, value) {
  5592. if (typeof units === 'object') {
  5593. units = normalizeObjectUnits(units);
  5594. var prioritized = getPrioritizedUnits(units),
  5595. i;
  5596. for (i = 0; i < prioritized.length; i++) {
  5597. this[prioritized[i].unit](units[prioritized[i].unit]);
  5598. }
  5599. } else {
  5600. units = normalizeUnits(units);
  5601. if (isFunction(this[units])) {
  5602. return this[units](value);
  5603. }
  5604. }
  5605. return this;
  5606. }
  5607. var match1 = /\d/, // 0 - 9
  5608. match2 = /\d\d/, // 00 - 99
  5609. match3 = /\d{3}/, // 000 - 999
  5610. match4 = /\d{4}/, // 0000 - 9999
  5611. match6 = /[+-]?\d{6}/, // -999999 - 999999
  5612. match1to2 = /\d\d?/, // 0 - 99
  5613. match3to4 = /\d\d\d\d?/, // 999 - 9999
  5614. match5to6 = /\d\d\d\d\d\d?/, // 99999 - 999999
  5615. match1to3 = /\d{1,3}/, // 0 - 999
  5616. match1to4 = /\d{1,4}/, // 0 - 9999
  5617. match1to6 = /[+-]?\d{1,6}/, // -999999 - 999999
  5618. matchUnsigned = /\d+/, // 0 - inf
  5619. matchSigned = /[+-]?\d+/, // -inf - inf
  5620. matchOffset = /Z|[+-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z
  5621. matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi, // +00 -00 +00:00 -00:00 +0000 -0000 or Z
  5622. matchTimestamp = /[+-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123
  5623. // any word (or two) characters or numbers including two/three word month in arabic.
  5624. // includes scottish gaelic two word and hyphenated months
  5625. matchWord = /[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,
  5626. regexes;
  5627. regexes = {};
  5628. function addRegexToken(token, regex, strictRegex) {
  5629. regexes[token] = isFunction(regex)
  5630. ? regex
  5631. : function (isStrict, localeData) {
  5632. return isStrict && strictRegex ? strictRegex : regex;
  5633. };
  5634. }
  5635. function getParseRegexForToken(token, config) {
  5636. if (!hasOwnProp(regexes, token)) {
  5637. return new RegExp(unescapeFormat(token));
  5638. }
  5639. return regexes[token](config._strict, config._locale);
  5640. }
  5641. // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
  5642. function unescapeFormat(s) {
  5643. return regexEscape(
  5644. s
  5645. .replace('\\', '')
  5646. .replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (
  5647. matched,
  5648. p1,
  5649. p2,
  5650. p3,
  5651. p4
  5652. ) {
  5653. return p1 || p2 || p3 || p4;
  5654. })
  5655. );
  5656. }
  5657. function regexEscape(s) {
  5658. return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
  5659. }
  5660. var tokens = {};
  5661. function addParseToken(token, callback) {
  5662. var i,
  5663. func = callback;
  5664. if (typeof token === 'string') {
  5665. token = [token];
  5666. }
  5667. if (isNumber(callback)) {
  5668. func = function (input, array) {
  5669. array[callback] = toInt(input);
  5670. };
  5671. }
  5672. for (i = 0; i < token.length; i++) {
  5673. tokens[token[i]] = func;
  5674. }
  5675. }
  5676. function addWeekParseToken(token, callback) {
  5677. addParseToken(token, function (input, array, config, token) {
  5678. config._w = config._w || {};
  5679. callback(input, config._w, config, token);
  5680. });
  5681. }
  5682. function addTimeToArrayFromToken(token, input, config) {
  5683. if (input != null && hasOwnProp(tokens, token)) {
  5684. tokens[token](input, config._a, config, token);
  5685. }
  5686. }
  5687. var YEAR = 0,
  5688. MONTH = 1,
  5689. DATE = 2,
  5690. HOUR = 3,
  5691. MINUTE = 4,
  5692. SECOND = 5,
  5693. MILLISECOND = 6,
  5694. WEEK = 7,
  5695. WEEKDAY = 8;
  5696. function mod(n, x) {
  5697. return ((n % x) + x) % x;
  5698. }
  5699. var indexOf;
  5700. if (Array.prototype.indexOf) {
  5701. indexOf = Array.prototype.indexOf;
  5702. } else {
  5703. indexOf = function (o) {
  5704. // I know
  5705. var i;
  5706. for (i = 0; i < this.length; ++i) {
  5707. if (this[i] === o) {
  5708. return i;
  5709. }
  5710. }
  5711. return -1;
  5712. };
  5713. }
  5714. function daysInMonth(year, month) {
  5715. if (isNaN(year) || isNaN(month)) {
  5716. return NaN;
  5717. }
  5718. var modMonth = mod(month, 12);
  5719. year += (month - modMonth) / 12;
  5720. return modMonth === 1
  5721. ? isLeapYear(year)
  5722. ? 29
  5723. : 28
  5724. : 31 - ((modMonth % 7) % 2);
  5725. }
  5726. // FORMATTING
  5727. addFormatToken('M', ['MM', 2], 'Mo', function () {
  5728. return this.month() + 1;
  5729. });
  5730. addFormatToken('MMM', 0, 0, function (format) {
  5731. return this.localeData().monthsShort(this, format);
  5732. });
  5733. addFormatToken('MMMM', 0, 0, function (format) {
  5734. return this.localeData().months(this, format);
  5735. });
  5736. // ALIASES
  5737. addUnitAlias('month', 'M');
  5738. // PRIORITY
  5739. addUnitPriority('month', 8);
  5740. // PARSING
  5741. addRegexToken('M', match1to2);
  5742. addRegexToken('MM', match1to2, match2);
  5743. addRegexToken('MMM', function (isStrict, locale) {
  5744. return locale.monthsShortRegex(isStrict);
  5745. });
  5746. addRegexToken('MMMM', function (isStrict, locale) {
  5747. return locale.monthsRegex(isStrict);
  5748. });
  5749. addParseToken(['M', 'MM'], function (input, array) {
  5750. array[MONTH] = toInt(input) - 1;
  5751. });
  5752. addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
  5753. var month = config._locale.monthsParse(input, token, config._strict);
  5754. // if we didn't find a month name, mark the date as invalid.
  5755. if (month != null) {
  5756. array[MONTH] = month;
  5757. } else {
  5758. getParsingFlags(config).invalidMonth = input;
  5759. }
  5760. });
  5761. // LOCALES
  5762. var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split(
  5763. '_'
  5764. ),
  5765. defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split(
  5766. '_'
  5767. ),
  5768. MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,
  5769. defaultMonthsShortRegex = matchWord,
  5770. defaultMonthsRegex = matchWord;
  5771. function localeMonths(m, format) {
  5772. if (!m) {
  5773. return isArray(this._months)
  5774. ? this._months
  5775. : this._months['standalone'];
  5776. }
  5777. return isArray(this._months)
  5778. ? this._months[m.month()]
  5779. : this._months[
  5780. (this._months.isFormat || MONTHS_IN_FORMAT).test(format)
  5781. ? 'format'
  5782. : 'standalone'
  5783. ][m.month()];
  5784. }
  5785. function localeMonthsShort(m, format) {
  5786. if (!m) {
  5787. return isArray(this._monthsShort)
  5788. ? this._monthsShort
  5789. : this._monthsShort['standalone'];
  5790. }
  5791. return isArray(this._monthsShort)
  5792. ? this._monthsShort[m.month()]
  5793. : this._monthsShort[
  5794. MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'
  5795. ][m.month()];
  5796. }
  5797. function handleStrictParse(monthName, format, strict) {
  5798. var i,
  5799. ii,
  5800. mom,
  5801. llc = monthName.toLocaleLowerCase();
  5802. if (!this._monthsParse) {
  5803. // this is not used
  5804. this._monthsParse = [];
  5805. this._longMonthsParse = [];
  5806. this._shortMonthsParse = [];
  5807. for (i = 0; i < 12; ++i) {
  5808. mom = createUTC([2000, i]);
  5809. this._shortMonthsParse[i] = this.monthsShort(
  5810. mom,
  5811. ''
  5812. ).toLocaleLowerCase();
  5813. this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
  5814. }
  5815. }
  5816. if (strict) {
  5817. if (format === 'MMM') {
  5818. ii = indexOf.call(this._shortMonthsParse, llc);
  5819. return ii !== -1 ? ii : null;
  5820. } else {
  5821. ii = indexOf.call(this._longMonthsParse, llc);
  5822. return ii !== -1 ? ii : null;
  5823. }
  5824. } else {
  5825. if (format === 'MMM') {
  5826. ii = indexOf.call(this._shortMonthsParse, llc);
  5827. if (ii !== -1) {
  5828. return ii;
  5829. }
  5830. ii = indexOf.call(this._longMonthsParse, llc);
  5831. return ii !== -1 ? ii : null;
  5832. } else {
  5833. ii = indexOf.call(this._longMonthsParse, llc);
  5834. if (ii !== -1) {
  5835. return ii;
  5836. }
  5837. ii = indexOf.call(this._shortMonthsParse, llc);
  5838. return ii !== -1 ? ii : null;
  5839. }
  5840. }
  5841. }
  5842. function localeMonthsParse(monthName, format, strict) {
  5843. var i, mom, regex;
  5844. if (this._monthsParseExact) {
  5845. return handleStrictParse.call(this, monthName, format, strict);
  5846. }
  5847. if (!this._monthsParse) {
  5848. this._monthsParse = [];
  5849. this._longMonthsParse = [];
  5850. this._shortMonthsParse = [];
  5851. }
  5852. // TODO: add sorting
  5853. // Sorting makes sure if one month (or abbr) is a prefix of another
  5854. // see sorting in computeMonthsParse
  5855. for (i = 0; i < 12; i++) {
  5856. // make the regex if we don't have it already
  5857. mom = createUTC([2000, i]);
  5858. if (strict && !this._longMonthsParse[i]) {
  5859. this._longMonthsParse[i] = new RegExp(
  5860. '^' + this.months(mom, '').replace('.', '') + '$',
  5861. 'i'
  5862. );
  5863. this._shortMonthsParse[i] = new RegExp(
  5864. '^' + this.monthsShort(mom, '').replace('.', '') + '$',
  5865. 'i'
  5866. );
  5867. }
  5868. if (!strict && !this._monthsParse[i]) {
  5869. regex =
  5870. '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
  5871. this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
  5872. }
  5873. // test the regex
  5874. if (
  5875. strict &&
  5876. format === 'MMMM' &&
  5877. this._longMonthsParse[i].test(monthName)
  5878. ) {
  5879. return i;
  5880. } else if (
  5881. strict &&
  5882. format === 'MMM' &&
  5883. this._shortMonthsParse[i].test(monthName)
  5884. ) {
  5885. return i;
  5886. } else if (!strict && this._monthsParse[i].test(monthName)) {
  5887. return i;
  5888. }
  5889. }
  5890. }
  5891. // MOMENTS
  5892. function setMonth(mom, value) {
  5893. var dayOfMonth;
  5894. if (!mom.isValid()) {
  5895. // No op
  5896. return mom;
  5897. }
  5898. if (typeof value === 'string') {
  5899. if (/^\d+$/.test(value)) {
  5900. value = toInt(value);
  5901. } else {
  5902. value = mom.localeData().monthsParse(value);
  5903. // TODO: Another silent failure?
  5904. if (!isNumber(value)) {
  5905. return mom;
  5906. }
  5907. }
  5908. }
  5909. dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
  5910. mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
  5911. return mom;
  5912. }
  5913. function getSetMonth(value) {
  5914. if (value != null) {
  5915. setMonth(this, value);
  5916. hooks.updateOffset(this, true);
  5917. return this;
  5918. } else {
  5919. return get(this, 'Month');
  5920. }
  5921. }
  5922. function getDaysInMonth() {
  5923. return daysInMonth(this.year(), this.month());
  5924. }
  5925. function monthsShortRegex(isStrict) {
  5926. if (this._monthsParseExact) {
  5927. if (!hasOwnProp(this, '_monthsRegex')) {
  5928. computeMonthsParse.call(this);
  5929. }
  5930. if (isStrict) {
  5931. return this._monthsShortStrictRegex;
  5932. } else {
  5933. return this._monthsShortRegex;
  5934. }
  5935. } else {
  5936. if (!hasOwnProp(this, '_monthsShortRegex')) {
  5937. this._monthsShortRegex = defaultMonthsShortRegex;
  5938. }
  5939. return this._monthsShortStrictRegex && isStrict
  5940. ? this._monthsShortStrictRegex
  5941. : this._monthsShortRegex;
  5942. }
  5943. }
  5944. function monthsRegex(isStrict) {
  5945. if (this._monthsParseExact) {
  5946. if (!hasOwnProp(this, '_monthsRegex')) {
  5947. computeMonthsParse.call(this);
  5948. }
  5949. if (isStrict) {
  5950. return this._monthsStrictRegex;
  5951. } else {
  5952. return this._monthsRegex;
  5953. }
  5954. } else {
  5955. if (!hasOwnProp(this, '_monthsRegex')) {
  5956. this._monthsRegex = defaultMonthsRegex;
  5957. }
  5958. return this._monthsStrictRegex && isStrict
  5959. ? this._monthsStrictRegex
  5960. : this._monthsRegex;
  5961. }
  5962. }
  5963. function computeMonthsParse() {
  5964. function cmpLenRev(a, b) {
  5965. return b.length - a.length;
  5966. }
  5967. var shortPieces = [],
  5968. longPieces = [],
  5969. mixedPieces = [],
  5970. i,
  5971. mom;
  5972. for (i = 0; i < 12; i++) {
  5973. // make the regex if we don't have it already
  5974. mom = createUTC([2000, i]);
  5975. shortPieces.push(this.monthsShort(mom, ''));
  5976. longPieces.push(this.months(mom, ''));
  5977. mixedPieces.push(this.months(mom, ''));
  5978. mixedPieces.push(this.monthsShort(mom, ''));
  5979. }
  5980. // Sorting makes sure if one month (or abbr) is a prefix of another it
  5981. // will match the longer piece.
  5982. shortPieces.sort(cmpLenRev);
  5983. longPieces.sort(cmpLenRev);
  5984. mixedPieces.sort(cmpLenRev);
  5985. for (i = 0; i < 12; i++) {
  5986. shortPieces[i] = regexEscape(shortPieces[i]);
  5987. longPieces[i] = regexEscape(longPieces[i]);
  5988. }
  5989. for (i = 0; i < 24; i++) {
  5990. mixedPieces[i] = regexEscape(mixedPieces[i]);
  5991. }
  5992. this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  5993. this._monthsShortRegex = this._monthsRegex;
  5994. this._monthsStrictRegex = new RegExp(
  5995. '^(' + longPieces.join('|') + ')',
  5996. 'i'
  5997. );
  5998. this._monthsShortStrictRegex = new RegExp(
  5999. '^(' + shortPieces.join('|') + ')',
  6000. 'i'
  6001. );
  6002. }
  6003. // FORMATTING
  6004. addFormatToken('Y', 0, 0, function () {
  6005. var y = this.year();
  6006. return y <= 9999 ? zeroFill(y, 4) : '+' + y;
  6007. });
  6008. addFormatToken(0, ['YY', 2], 0, function () {
  6009. return this.year() % 100;
  6010. });
  6011. addFormatToken(0, ['YYYY', 4], 0, 'year');
  6012. addFormatToken(0, ['YYYYY', 5], 0, 'year');
  6013. addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
  6014. // ALIASES
  6015. addUnitAlias('year', 'y');
  6016. // PRIORITIES
  6017. addUnitPriority('year', 1);
  6018. // PARSING
  6019. addRegexToken('Y', matchSigned);
  6020. addRegexToken('YY', match1to2, match2);
  6021. addRegexToken('YYYY', match1to4, match4);
  6022. addRegexToken('YYYYY', match1to6, match6);
  6023. addRegexToken('YYYYYY', match1to6, match6);
  6024. addParseToken(['YYYYY', 'YYYYYY'], YEAR);
  6025. addParseToken('YYYY', function (input, array) {
  6026. array[YEAR] =
  6027. input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
  6028. });
  6029. addParseToken('YY', function (input, array) {
  6030. array[YEAR] = hooks.parseTwoDigitYear(input);
  6031. });
  6032. addParseToken('Y', function (input, array) {
  6033. array[YEAR] = parseInt(input, 10);
  6034. });
  6035. // HELPERS
  6036. function daysInYear(year) {
  6037. return isLeapYear(year) ? 366 : 365;
  6038. }
  6039. // HOOKS
  6040. hooks.parseTwoDigitYear = function (input) {
  6041. return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
  6042. };
  6043. // MOMENTS
  6044. var getSetYear = makeGetSet('FullYear', true);
  6045. function getIsLeapYear() {
  6046. return isLeapYear(this.year());
  6047. }
  6048. function createDate(y, m, d, h, M, s, ms) {
  6049. // can't just apply() to create a date:
  6050. // https://stackoverflow.com/q/181348
  6051. var date;
  6052. // the date constructor remaps years 0-99 to 1900-1999
  6053. if (y < 100 && y >= 0) {
  6054. // preserve leap years using a full 400 year cycle, then reset
  6055. date = new Date(y + 400, m, d, h, M, s, ms);
  6056. if (isFinite(date.getFullYear())) {
  6057. date.setFullYear(y);
  6058. }
  6059. } else {
  6060. date = new Date(y, m, d, h, M, s, ms);
  6061. }
  6062. return date;
  6063. }
  6064. function createUTCDate(y) {
  6065. var date, args;
  6066. // the Date.UTC function remaps years 0-99 to 1900-1999
  6067. if (y < 100 && y >= 0) {
  6068. args = Array.prototype.slice.call(arguments);
  6069. // preserve leap years using a full 400 year cycle, then reset
  6070. args[0] = y + 400;
  6071. date = new Date(Date.UTC.apply(null, args));
  6072. if (isFinite(date.getUTCFullYear())) {
  6073. date.setUTCFullYear(y);
  6074. }
  6075. } else {
  6076. date = new Date(Date.UTC.apply(null, arguments));
  6077. }
  6078. return date;
  6079. }
  6080. // start-of-first-week - start-of-year
  6081. function firstWeekOffset(year, dow, doy) {
  6082. var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
  6083. fwd = 7 + dow - doy,
  6084. // first-week day local weekday -- which local weekday is fwd
  6085. fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
  6086. return -fwdlw + fwd - 1;
  6087. }
  6088. // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
  6089. function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
  6090. var localWeekday = (7 + weekday - dow) % 7,
  6091. weekOffset = firstWeekOffset(year, dow, doy),
  6092. dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
  6093. resYear,
  6094. resDayOfYear;
  6095. if (dayOfYear <= 0) {
  6096. resYear = year - 1;
  6097. resDayOfYear = daysInYear(resYear) + dayOfYear;
  6098. } else if (dayOfYear > daysInYear(year)) {
  6099. resYear = year + 1;
  6100. resDayOfYear = dayOfYear - daysInYear(year);
  6101. } else {
  6102. resYear = year;
  6103. resDayOfYear = dayOfYear;
  6104. }
  6105. return {
  6106. year: resYear,
  6107. dayOfYear: resDayOfYear,
  6108. };
  6109. }
  6110. function weekOfYear(mom, dow, doy) {
  6111. var weekOffset = firstWeekOffset(mom.year(), dow, doy),
  6112. week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
  6113. resWeek,
  6114. resYear;
  6115. if (week < 1) {
  6116. resYear = mom.year() - 1;
  6117. resWeek = week + weeksInYear(resYear, dow, doy);
  6118. } else if (week > weeksInYear(mom.year(), dow, doy)) {
  6119. resWeek = week - weeksInYear(mom.year(), dow, doy);
  6120. resYear = mom.year() + 1;
  6121. } else {
  6122. resYear = mom.year();
  6123. resWeek = week;
  6124. }
  6125. return {
  6126. week: resWeek,
  6127. year: resYear,
  6128. };
  6129. }
  6130. function weeksInYear(year, dow, doy) {
  6131. var weekOffset = firstWeekOffset(year, dow, doy),
  6132. weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
  6133. return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
  6134. }
  6135. // FORMATTING
  6136. addFormatToken('w', ['ww', 2], 'wo', 'week');
  6137. addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
  6138. // ALIASES
  6139. addUnitAlias('week', 'w');
  6140. addUnitAlias('isoWeek', 'W');
  6141. // PRIORITIES
  6142. addUnitPriority('week', 5);
  6143. addUnitPriority('isoWeek', 5);
  6144. // PARSING
  6145. addRegexToken('w', match1to2);
  6146. addRegexToken('ww', match1to2, match2);
  6147. addRegexToken('W', match1to2);
  6148. addRegexToken('WW', match1to2, match2);
  6149. addWeekParseToken(['w', 'ww', 'W', 'WW'], function (
  6150. input,
  6151. week,
  6152. config,
  6153. token
  6154. ) {
  6155. week[token.substr(0, 1)] = toInt(input);
  6156. });
  6157. // HELPERS
  6158. // LOCALES
  6159. function localeWeek(mom) {
  6160. return weekOfYear(mom, this._week.dow, this._week.doy).week;
  6161. }
  6162. var defaultLocaleWeek = {
  6163. dow: 0, // Sunday is the first day of the week.
  6164. doy: 6, // The week that contains Jan 6th is the first week of the year.
  6165. };
  6166. function localeFirstDayOfWeek() {
  6167. return this._week.dow;
  6168. }
  6169. function localeFirstDayOfYear() {
  6170. return this._week.doy;
  6171. }
  6172. // MOMENTS
  6173. function getSetWeek(input) {
  6174. var week = this.localeData().week(this);
  6175. return input == null ? week : this.add((input - week) * 7, 'd');
  6176. }
  6177. function getSetISOWeek(input) {
  6178. var week = weekOfYear(this, 1, 4).week;
  6179. return input == null ? week : this.add((input - week) * 7, 'd');
  6180. }
  6181. // FORMATTING
  6182. addFormatToken('d', 0, 'do', 'day');
  6183. addFormatToken('dd', 0, 0, function (format) {
  6184. return this.localeData().weekdaysMin(this, format);
  6185. });
  6186. addFormatToken('ddd', 0, 0, function (format) {
  6187. return this.localeData().weekdaysShort(this, format);
  6188. });
  6189. addFormatToken('dddd', 0, 0, function (format) {
  6190. return this.localeData().weekdays(this, format);
  6191. });
  6192. addFormatToken('e', 0, 0, 'weekday');
  6193. addFormatToken('E', 0, 0, 'isoWeekday');
  6194. // ALIASES
  6195. addUnitAlias('day', 'd');
  6196. addUnitAlias('weekday', 'e');
  6197. addUnitAlias('isoWeekday', 'E');
  6198. // PRIORITY
  6199. addUnitPriority('day', 11);
  6200. addUnitPriority('weekday', 11);
  6201. addUnitPriority('isoWeekday', 11);
  6202. // PARSING
  6203. addRegexToken('d', match1to2);
  6204. addRegexToken('e', match1to2);
  6205. addRegexToken('E', match1to2);
  6206. addRegexToken('dd', function (isStrict, locale) {
  6207. return locale.weekdaysMinRegex(isStrict);
  6208. });
  6209. addRegexToken('ddd', function (isStrict, locale) {
  6210. return locale.weekdaysShortRegex(isStrict);
  6211. });
  6212. addRegexToken('dddd', function (isStrict, locale) {
  6213. return locale.weekdaysRegex(isStrict);
  6214. });
  6215. addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
  6216. var weekday = config._locale.weekdaysParse(input, token, config._strict);
  6217. // if we didn't get a weekday name, mark the date as invalid
  6218. if (weekday != null) {
  6219. week.d = weekday;
  6220. } else {
  6221. getParsingFlags(config).invalidWeekday = input;
  6222. }
  6223. });
  6224. addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
  6225. week[token] = toInt(input);
  6226. });
  6227. // HELPERS
  6228. function parseWeekday(input, locale) {
  6229. if (typeof input !== 'string') {
  6230. return input;
  6231. }
  6232. if (!isNaN(input)) {
  6233. return parseInt(input, 10);
  6234. }
  6235. input = locale.weekdaysParse(input);
  6236. if (typeof input === 'number') {
  6237. return input;
  6238. }
  6239. return null;
  6240. }
  6241. function parseIsoWeekday(input, locale) {
  6242. if (typeof input === 'string') {
  6243. return locale.weekdaysParse(input) % 7 || 7;
  6244. }
  6245. return isNaN(input) ? null : input;
  6246. }
  6247. // LOCALES
  6248. function shiftWeekdays(ws, n) {
  6249. return ws.slice(n, 7).concat(ws.slice(0, n));
  6250. }
  6251. var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split(
  6252. '_'
  6253. ),
  6254. defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
  6255. defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
  6256. defaultWeekdaysRegex = matchWord,
  6257. defaultWeekdaysShortRegex = matchWord,
  6258. defaultWeekdaysMinRegex = matchWord;
  6259. function localeWeekdays(m, format) {
  6260. var weekdays = isArray(this._weekdays)
  6261. ? this._weekdays
  6262. : this._weekdays[
  6263. m && m !== true && this._weekdays.isFormat.test(format)
  6264. ? 'format'
  6265. : 'standalone'
  6266. ];
  6267. return m === true
  6268. ? shiftWeekdays(weekdays, this._week.dow)
  6269. : m
  6270. ? weekdays[m.day()]
  6271. : weekdays;
  6272. }
  6273. function localeWeekdaysShort(m) {
  6274. return m === true
  6275. ? shiftWeekdays(this._weekdaysShort, this._week.dow)
  6276. : m
  6277. ? this._weekdaysShort[m.day()]
  6278. : this._weekdaysShort;
  6279. }
  6280. function localeWeekdaysMin(m) {
  6281. return m === true
  6282. ? shiftWeekdays(this._weekdaysMin, this._week.dow)
  6283. : m
  6284. ? this._weekdaysMin[m.day()]
  6285. : this._weekdaysMin;
  6286. }
  6287. function handleStrictParse$1(weekdayName, format, strict) {
  6288. var i,
  6289. ii,
  6290. mom,
  6291. llc = weekdayName.toLocaleLowerCase();
  6292. if (!this._weekdaysParse) {
  6293. this._weekdaysParse = [];
  6294. this._shortWeekdaysParse = [];
  6295. this._minWeekdaysParse = [];
  6296. for (i = 0; i < 7; ++i) {
  6297. mom = createUTC([2000, 1]).day(i);
  6298. this._minWeekdaysParse[i] = this.weekdaysMin(
  6299. mom,
  6300. ''
  6301. ).toLocaleLowerCase();
  6302. this._shortWeekdaysParse[i] = this.weekdaysShort(
  6303. mom,
  6304. ''
  6305. ).toLocaleLowerCase();
  6306. this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
  6307. }
  6308. }
  6309. if (strict) {
  6310. if (format === 'dddd') {
  6311. ii = indexOf.call(this._weekdaysParse, llc);
  6312. return ii !== -1 ? ii : null;
  6313. } else if (format === 'ddd') {
  6314. ii = indexOf.call(this._shortWeekdaysParse, llc);
  6315. return ii !== -1 ? ii : null;
  6316. } else {
  6317. ii = indexOf.call(this._minWeekdaysParse, llc);
  6318. return ii !== -1 ? ii : null;
  6319. }
  6320. } else {
  6321. if (format === 'dddd') {
  6322. ii = indexOf.call(this._weekdaysParse, llc);
  6323. if (ii !== -1) {
  6324. return ii;
  6325. }
  6326. ii = indexOf.call(this._shortWeekdaysParse, llc);
  6327. if (ii !== -1) {
  6328. return ii;
  6329. }
  6330. ii = indexOf.call(this._minWeekdaysParse, llc);
  6331. return ii !== -1 ? ii : null;
  6332. } else if (format === 'ddd') {
  6333. ii = indexOf.call(this._shortWeekdaysParse, llc);
  6334. if (ii !== -1) {
  6335. return ii;
  6336. }
  6337. ii = indexOf.call(this._weekdaysParse, llc);
  6338. if (ii !== -1) {
  6339. return ii;
  6340. }
  6341. ii = indexOf.call(this._minWeekdaysParse, llc);
  6342. return ii !== -1 ? ii : null;
  6343. } else {
  6344. ii = indexOf.call(this._minWeekdaysParse, llc);
  6345. if (ii !== -1) {
  6346. return ii;
  6347. }
  6348. ii = indexOf.call(this._weekdaysParse, llc);
  6349. if (ii !== -1) {
  6350. return ii;
  6351. }
  6352. ii = indexOf.call(this._shortWeekdaysParse, llc);
  6353. return ii !== -1 ? ii : null;
  6354. }
  6355. }
  6356. }
  6357. function localeWeekdaysParse(weekdayName, format, strict) {
  6358. var i, mom, regex;
  6359. if (this._weekdaysParseExact) {
  6360. return handleStrictParse$1.call(this, weekdayName, format, strict);
  6361. }
  6362. if (!this._weekdaysParse) {
  6363. this._weekdaysParse = [];
  6364. this._minWeekdaysParse = [];
  6365. this._shortWeekdaysParse = [];
  6366. this._fullWeekdaysParse = [];
  6367. }
  6368. for (i = 0; i < 7; i++) {
  6369. // make the regex if we don't have it already
  6370. mom = createUTC([2000, 1]).day(i);
  6371. if (strict && !this._fullWeekdaysParse[i]) {
  6372. this._fullWeekdaysParse[i] = new RegExp(
  6373. '^' + this.weekdays(mom, '').replace('.', '\\.?') + '$',
  6374. 'i'
  6375. );
  6376. this._shortWeekdaysParse[i] = new RegExp(
  6377. '^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$',
  6378. 'i'
  6379. );
  6380. this._minWeekdaysParse[i] = new RegExp(
  6381. '^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$',
  6382. 'i'
  6383. );
  6384. }
  6385. if (!this._weekdaysParse[i]) {
  6386. regex =
  6387. '^' +
  6388. this.weekdays(mom, '') +
  6389. '|^' +
  6390. this.weekdaysShort(mom, '') +
  6391. '|^' +
  6392. this.weekdaysMin(mom, '');
  6393. this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
  6394. }
  6395. // test the regex
  6396. if (
  6397. strict &&
  6398. format === 'dddd' &&
  6399. this._fullWeekdaysParse[i].test(weekdayName)
  6400. ) {
  6401. return i;
  6402. } else if (
  6403. strict &&
  6404. format === 'ddd' &&
  6405. this._shortWeekdaysParse[i].test(weekdayName)
  6406. ) {
  6407. return i;
  6408. } else if (
  6409. strict &&
  6410. format === 'dd' &&
  6411. this._minWeekdaysParse[i].test(weekdayName)
  6412. ) {
  6413. return i;
  6414. } else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
  6415. return i;
  6416. }
  6417. }
  6418. }
  6419. // MOMENTS
  6420. function getSetDayOfWeek(input) {
  6421. if (!this.isValid()) {
  6422. return input != null ? this : NaN;
  6423. }
  6424. var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
  6425. if (input != null) {
  6426. input = parseWeekday(input, this.localeData());
  6427. return this.add(input - day, 'd');
  6428. } else {
  6429. return day;
  6430. }
  6431. }
  6432. function getSetLocaleDayOfWeek(input) {
  6433. if (!this.isValid()) {
  6434. return input != null ? this : NaN;
  6435. }
  6436. var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
  6437. return input == null ? weekday : this.add(input - weekday, 'd');
  6438. }
  6439. function getSetISODayOfWeek(input) {
  6440. if (!this.isValid()) {
  6441. return input != null ? this : NaN;
  6442. }
  6443. // behaves the same as moment#day except
  6444. // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
  6445. // as a setter, sunday should belong to the previous week.
  6446. if (input != null) {
  6447. var weekday = parseIsoWeekday(input, this.localeData());
  6448. return this.day(this.day() % 7 ? weekday : weekday - 7);
  6449. } else {
  6450. return this.day() || 7;
  6451. }
  6452. }
  6453. function weekdaysRegex(isStrict) {
  6454. if (this._weekdaysParseExact) {
  6455. if (!hasOwnProp(this, '_weekdaysRegex')) {
  6456. computeWeekdaysParse.call(this);
  6457. }
  6458. if (isStrict) {
  6459. return this._weekdaysStrictRegex;
  6460. } else {
  6461. return this._weekdaysRegex;
  6462. }
  6463. } else {
  6464. if (!hasOwnProp(this, '_weekdaysRegex')) {
  6465. this._weekdaysRegex = defaultWeekdaysRegex;
  6466. }
  6467. return this._weekdaysStrictRegex && isStrict
  6468. ? this._weekdaysStrictRegex
  6469. : this._weekdaysRegex;
  6470. }
  6471. }
  6472. function weekdaysShortRegex(isStrict) {
  6473. if (this._weekdaysParseExact) {
  6474. if (!hasOwnProp(this, '_weekdaysRegex')) {
  6475. computeWeekdaysParse.call(this);
  6476. }
  6477. if (isStrict) {
  6478. return this._weekdaysShortStrictRegex;
  6479. } else {
  6480. return this._weekdaysShortRegex;
  6481. }
  6482. } else {
  6483. if (!hasOwnProp(this, '_weekdaysShortRegex')) {
  6484. this._weekdaysShortRegex = defaultWeekdaysShortRegex;
  6485. }
  6486. return this._weekdaysShortStrictRegex && isStrict
  6487. ? this._weekdaysShortStrictRegex
  6488. : this._weekdaysShortRegex;
  6489. }
  6490. }
  6491. function weekdaysMinRegex(isStrict) {
  6492. if (this._weekdaysParseExact) {
  6493. if (!hasOwnProp(this, '_weekdaysRegex')) {
  6494. computeWeekdaysParse.call(this);
  6495. }
  6496. if (isStrict) {
  6497. return this._weekdaysMinStrictRegex;
  6498. } else {
  6499. return this._weekdaysMinRegex;
  6500. }
  6501. } else {
  6502. if (!hasOwnProp(this, '_weekdaysMinRegex')) {
  6503. this._weekdaysMinRegex = defaultWeekdaysMinRegex;
  6504. }
  6505. return this._weekdaysMinStrictRegex && isStrict
  6506. ? this._weekdaysMinStrictRegex
  6507. : this._weekdaysMinRegex;
  6508. }
  6509. }
  6510. function computeWeekdaysParse() {
  6511. function cmpLenRev(a, b) {
  6512. return b.length - a.length;
  6513. }
  6514. var minPieces = [],
  6515. shortPieces = [],
  6516. longPieces = [],
  6517. mixedPieces = [],
  6518. i,
  6519. mom,
  6520. minp,
  6521. shortp,
  6522. longp;
  6523. for (i = 0; i < 7; i++) {
  6524. // make the regex if we don't have it already
  6525. mom = createUTC([2000, 1]).day(i);
  6526. minp = regexEscape(this.weekdaysMin(mom, ''));
  6527. shortp = regexEscape(this.weekdaysShort(mom, ''));
  6528. longp = regexEscape(this.weekdays(mom, ''));
  6529. minPieces.push(minp);
  6530. shortPieces.push(shortp);
  6531. longPieces.push(longp);
  6532. mixedPieces.push(minp);
  6533. mixedPieces.push(shortp);
  6534. mixedPieces.push(longp);
  6535. }
  6536. // Sorting makes sure if one weekday (or abbr) is a prefix of another it
  6537. // will match the longer piece.
  6538. minPieces.sort(cmpLenRev);
  6539. shortPieces.sort(cmpLenRev);
  6540. longPieces.sort(cmpLenRev);
  6541. mixedPieces.sort(cmpLenRev);
  6542. this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  6543. this._weekdaysShortRegex = this._weekdaysRegex;
  6544. this._weekdaysMinRegex = this._weekdaysRegex;
  6545. this._weekdaysStrictRegex = new RegExp(
  6546. '^(' + longPieces.join('|') + ')',
  6547. 'i'
  6548. );
  6549. this._weekdaysShortStrictRegex = new RegExp(
  6550. '^(' + shortPieces.join('|') + ')',
  6551. 'i'
  6552. );
  6553. this._weekdaysMinStrictRegex = new RegExp(
  6554. '^(' + minPieces.join('|') + ')',
  6555. 'i'
  6556. );
  6557. }
  6558. // FORMATTING
  6559. function hFormat() {
  6560. return this.hours() % 12 || 12;
  6561. }
  6562. function kFormat() {
  6563. return this.hours() || 24;
  6564. }
  6565. addFormatToken('H', ['HH', 2], 0, 'hour');
  6566. addFormatToken('h', ['hh', 2], 0, hFormat);
  6567. addFormatToken('k', ['kk', 2], 0, kFormat);
  6568. addFormatToken('hmm', 0, 0, function () {
  6569. return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
  6570. });
  6571. addFormatToken('hmmss', 0, 0, function () {
  6572. return (
  6573. '' +
  6574. hFormat.apply(this) +
  6575. zeroFill(this.minutes(), 2) +
  6576. zeroFill(this.seconds(), 2)
  6577. );
  6578. });
  6579. addFormatToken('Hmm', 0, 0, function () {
  6580. return '' + this.hours() + zeroFill(this.minutes(), 2);
  6581. });
  6582. addFormatToken('Hmmss', 0, 0, function () {
  6583. return (
  6584. '' +
  6585. this.hours() +
  6586. zeroFill(this.minutes(), 2) +
  6587. zeroFill(this.seconds(), 2)
  6588. );
  6589. });
  6590. function meridiem(token, lowercase) {
  6591. addFormatToken(token, 0, 0, function () {
  6592. return this.localeData().meridiem(
  6593. this.hours(),
  6594. this.minutes(),
  6595. lowercase
  6596. );
  6597. });
  6598. }
  6599. meridiem('a', true);
  6600. meridiem('A', false);
  6601. // ALIASES
  6602. addUnitAlias('hour', 'h');
  6603. // PRIORITY
  6604. addUnitPriority('hour', 13);
  6605. // PARSING
  6606. function matchMeridiem(isStrict, locale) {
  6607. return locale._meridiemParse;
  6608. }
  6609. addRegexToken('a', matchMeridiem);
  6610. addRegexToken('A', matchMeridiem);
  6611. addRegexToken('H', match1to2);
  6612. addRegexToken('h', match1to2);
  6613. addRegexToken('k', match1to2);
  6614. addRegexToken('HH', match1to2, match2);
  6615. addRegexToken('hh', match1to2, match2);
  6616. addRegexToken('kk', match1to2, match2);
  6617. addRegexToken('hmm', match3to4);
  6618. addRegexToken('hmmss', match5to6);
  6619. addRegexToken('Hmm', match3to4);
  6620. addRegexToken('Hmmss', match5to6);
  6621. addParseToken(['H', 'HH'], HOUR);
  6622. addParseToken(['k', 'kk'], function (input, array, config) {
  6623. var kInput = toInt(input);
  6624. array[HOUR] = kInput === 24 ? 0 : kInput;
  6625. });
  6626. addParseToken(['a', 'A'], function (input, array, config) {
  6627. config._isPm = config._locale.isPM(input);
  6628. config._meridiem = input;
  6629. });
  6630. addParseToken(['h', 'hh'], function (input, array, config) {
  6631. array[HOUR] = toInt(input);
  6632. getParsingFlags(config).bigHour = true;
  6633. });
  6634. addParseToken('hmm', function (input, array, config) {
  6635. var pos = input.length - 2;
  6636. array[HOUR] = toInt(input.substr(0, pos));
  6637. array[MINUTE] = toInt(input.substr(pos));
  6638. getParsingFlags(config).bigHour = true;
  6639. });
  6640. addParseToken('hmmss', function (input, array, config) {
  6641. var pos1 = input.length - 4,
  6642. pos2 = input.length - 2;
  6643. array[HOUR] = toInt(input.substr(0, pos1));
  6644. array[MINUTE] = toInt(input.substr(pos1, 2));
  6645. array[SECOND] = toInt(input.substr(pos2));
  6646. getParsingFlags(config).bigHour = true;
  6647. });
  6648. addParseToken('Hmm', function (input, array, config) {
  6649. var pos = input.length - 2;
  6650. array[HOUR] = toInt(input.substr(0, pos));
  6651. array[MINUTE] = toInt(input.substr(pos));
  6652. });
  6653. addParseToken('Hmmss', function (input, array, config) {
  6654. var pos1 = input.length - 4,
  6655. pos2 = input.length - 2;
  6656. array[HOUR] = toInt(input.substr(0, pos1));
  6657. array[MINUTE] = toInt(input.substr(pos1, 2));
  6658. array[SECOND] = toInt(input.substr(pos2));
  6659. });
  6660. // LOCALES
  6661. function localeIsPM(input) {
  6662. // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
  6663. // Using charAt should be more compatible.
  6664. return (input + '').toLowerCase().charAt(0) === 'p';
  6665. }
  6666. var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i,
  6667. // Setting the hour should keep the time, because the user explicitly
  6668. // specified which hour they want. So trying to maintain the same hour (in
  6669. // a new timezone) makes sense. Adding/subtracting hours does not follow
  6670. // this rule.
  6671. getSetHour = makeGetSet('Hours', true);
  6672. function localeMeridiem(hours, minutes, isLower) {
  6673. if (hours > 11) {
  6674. return isLower ? 'pm' : 'PM';
  6675. } else {
  6676. return isLower ? 'am' : 'AM';
  6677. }
  6678. }
  6679. var baseConfig = {
  6680. calendar: defaultCalendar,
  6681. longDateFormat: defaultLongDateFormat,
  6682. invalidDate: defaultInvalidDate,
  6683. ordinal: defaultOrdinal,
  6684. dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
  6685. relativeTime: defaultRelativeTime,
  6686. months: defaultLocaleMonths,
  6687. monthsShort: defaultLocaleMonthsShort,
  6688. week: defaultLocaleWeek,
  6689. weekdays: defaultLocaleWeekdays,
  6690. weekdaysMin: defaultLocaleWeekdaysMin,
  6691. weekdaysShort: defaultLocaleWeekdaysShort,
  6692. meridiemParse: defaultLocaleMeridiemParse,
  6693. };
  6694. // internal storage for locale config files
  6695. var locales = {},
  6696. localeFamilies = {},
  6697. globalLocale;
  6698. function commonPrefix(arr1, arr2) {
  6699. var i,
  6700. minl = Math.min(arr1.length, arr2.length);
  6701. for (i = 0; i < minl; i += 1) {
  6702. if (arr1[i] !== arr2[i]) {
  6703. return i;
  6704. }
  6705. }
  6706. return minl;
  6707. }
  6708. function normalizeLocale(key) {
  6709. return key ? key.toLowerCase().replace('_', '-') : key;
  6710. }
  6711. // pick the locale from the array
  6712. // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
  6713. // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
  6714. function chooseLocale(names) {
  6715. var i = 0,
  6716. j,
  6717. next,
  6718. locale,
  6719. split;
  6720. while (i < names.length) {
  6721. split = normalizeLocale(names[i]).split('-');
  6722. j = split.length;
  6723. next = normalizeLocale(names[i + 1]);
  6724. next = next ? next.split('-') : null;
  6725. while (j > 0) {
  6726. locale = loadLocale(split.slice(0, j).join('-'));
  6727. if (locale) {
  6728. return locale;
  6729. }
  6730. if (
  6731. next &&
  6732. next.length >= j &&
  6733. commonPrefix(split, next) >= j - 1
  6734. ) {
  6735. //the next array item is better than a shallower substring of this one
  6736. break;
  6737. }
  6738. j--;
  6739. }
  6740. i++;
  6741. }
  6742. return globalLocale;
  6743. }
  6744. function loadLocale(name) {
  6745. var oldLocale = null,
  6746. aliasedRequire;
  6747. // TODO: Find a better way to register and load all the locales in Node
  6748. if (
  6749. locales[name] === undefined &&
  6750. typeof module !== 'undefined' &&
  6751. module &&
  6752. module.exports
  6753. ) {
  6754. try {
  6755. oldLocale = globalLocale._abbr;
  6756. aliasedRequire = require;
  6757. aliasedRequire('./locale/' + name);
  6758. getSetGlobalLocale(oldLocale);
  6759. } catch (e) {
  6760. // mark as not found to avoid repeating expensive file require call causing high CPU
  6761. // when trying to find en-US, en_US, en-us for every format call
  6762. locales[name] = null; // null means not found
  6763. }
  6764. }
  6765. return locales[name];
  6766. }
  6767. // This function will load locale and then set the global locale. If
  6768. // no arguments are passed in, it will simply return the current global
  6769. // locale key.
  6770. function getSetGlobalLocale(key, values) {
  6771. var data;
  6772. if (key) {
  6773. if (isUndefined(values)) {
  6774. data = getLocale(key);
  6775. } else {
  6776. data = defineLocale(key, values);
  6777. }
  6778. if (data) {
  6779. // moment.duration._locale = moment._locale = data;
  6780. globalLocale = data;
  6781. } else {
  6782. if (typeof console !== 'undefined' && console.warn) {
  6783. //warn user if arguments are passed but the locale could not be set
  6784. console.warn(
  6785. 'Locale ' + key + ' not found. Did you forget to load it?'
  6786. );
  6787. }
  6788. }
  6789. }
  6790. return globalLocale._abbr;
  6791. }
  6792. function defineLocale(name, config) {
  6793. if (config !== null) {
  6794. var locale,
  6795. parentConfig = baseConfig;
  6796. config.abbr = name;
  6797. if (locales[name] != null) {
  6798. deprecateSimple(
  6799. 'defineLocaleOverride',
  6800. 'use moment.updateLocale(localeName, config) to change ' +
  6801. 'an existing locale. moment.defineLocale(localeName, ' +
  6802. 'config) should only be used for creating a new locale ' +
  6803. 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.'
  6804. );
  6805. parentConfig = locales[name]._config;
  6806. } else if (config.parentLocale != null) {
  6807. if (locales[config.parentLocale] != null) {
  6808. parentConfig = locales[config.parentLocale]._config;
  6809. } else {
  6810. locale = loadLocale(config.parentLocale);
  6811. if (locale != null) {
  6812. parentConfig = locale._config;
  6813. } else {
  6814. if (!localeFamilies[config.parentLocale]) {
  6815. localeFamilies[config.parentLocale] = [];
  6816. }
  6817. localeFamilies[config.parentLocale].push({
  6818. name: name,
  6819. config: config,
  6820. });
  6821. return null;
  6822. }
  6823. }
  6824. }
  6825. locales[name] = new Locale(mergeConfigs(parentConfig, config));
  6826. if (localeFamilies[name]) {
  6827. localeFamilies[name].forEach(function (x) {
  6828. defineLocale(x.name, x.config);
  6829. });
  6830. }
  6831. // backwards compat for now: also set the locale
  6832. // make sure we set the locale AFTER all child locales have been
  6833. // created, so we won't end up with the child locale set.
  6834. getSetGlobalLocale(name);
  6835. return locales[name];
  6836. } else {
  6837. // useful for testing
  6838. delete locales[name];
  6839. return null;
  6840. }
  6841. }
  6842. function updateLocale(name, config) {
  6843. if (config != null) {
  6844. var locale,
  6845. tmpLocale,
  6846. parentConfig = baseConfig;
  6847. if (locales[name] != null && locales[name].parentLocale != null) {
  6848. // Update existing child locale in-place to avoid memory-leaks
  6849. locales[name].set(mergeConfigs(locales[name]._config, config));
  6850. } else {
  6851. // MERGE
  6852. tmpLocale = loadLocale(name);
  6853. if (tmpLocale != null) {
  6854. parentConfig = tmpLocale._config;
  6855. }
  6856. config = mergeConfigs(parentConfig, config);
  6857. if (tmpLocale == null) {
  6858. // updateLocale is called for creating a new locale
  6859. // Set abbr so it will have a name (getters return
  6860. // undefined otherwise).
  6861. config.abbr = name;
  6862. }
  6863. locale = new Locale(config);
  6864. locale.parentLocale = locales[name];
  6865. locales[name] = locale;
  6866. }
  6867. // backwards compat for now: also set the locale
  6868. getSetGlobalLocale(name);
  6869. } else {
  6870. // pass null for config to unupdate, useful for tests
  6871. if (locales[name] != null) {
  6872. if (locales[name].parentLocale != null) {
  6873. locales[name] = locales[name].parentLocale;
  6874. if (name === getSetGlobalLocale()) {
  6875. getSetGlobalLocale(name);
  6876. }
  6877. } else if (locales[name] != null) {
  6878. delete locales[name];
  6879. }
  6880. }
  6881. }
  6882. return locales[name];
  6883. }
  6884. // returns locale data
  6885. function getLocale(key) {
  6886. var locale;
  6887. if (key && key._locale && key._locale._abbr) {
  6888. key = key._locale._abbr;
  6889. }
  6890. if (!key) {
  6891. return globalLocale;
  6892. }
  6893. if (!isArray(key)) {
  6894. //short-circuit everything else
  6895. locale = loadLocale(key);
  6896. if (locale) {
  6897. return locale;
  6898. }
  6899. key = [key];
  6900. }
  6901. return chooseLocale(key);
  6902. }
  6903. function listLocales() {
  6904. return keys(locales);
  6905. }
  6906. function checkOverflow(m) {
  6907. var overflow,
  6908. a = m._a;
  6909. if (a && getParsingFlags(m).overflow === -2) {
  6910. overflow =
  6911. a[MONTH] < 0 || a[MONTH] > 11
  6912. ? MONTH
  6913. : a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH])
  6914. ? DATE
  6915. : a[HOUR] < 0 ||
  6916. a[HOUR] > 24 ||
  6917. (a[HOUR] === 24 &&
  6918. (a[MINUTE] !== 0 ||
  6919. a[SECOND] !== 0 ||
  6920. a[MILLISECOND] !== 0))
  6921. ? HOUR
  6922. : a[MINUTE] < 0 || a[MINUTE] > 59
  6923. ? MINUTE
  6924. : a[SECOND] < 0 || a[SECOND] > 59
  6925. ? SECOND
  6926. : a[MILLISECOND] < 0 || a[MILLISECOND] > 999
  6927. ? MILLISECOND
  6928. : -1;
  6929. if (
  6930. getParsingFlags(m)._overflowDayOfYear &&
  6931. (overflow < YEAR || overflow > DATE)
  6932. ) {
  6933. overflow = DATE;
  6934. }
  6935. if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
  6936. overflow = WEEK;
  6937. }
  6938. if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
  6939. overflow = WEEKDAY;
  6940. }
  6941. getParsingFlags(m).overflow = overflow;
  6942. }
  6943. return m;
  6944. }
  6945. // iso 8601 regex
  6946. // 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)
  6947. var extendedIsoRegex = /^\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)?)?$/,
  6948. basicIsoRegex = /^\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)?)?$/,
  6949. tzRegex = /Z|[+-]\d\d(?::?\d\d)?/,
  6950. isoDates = [
  6951. ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/],
  6952. ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/],
  6953. ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/],
  6954. ['GGGG-[W]WW', /\d{4}-W\d\d/, false],
  6955. ['YYYY-DDD', /\d{4}-\d{3}/],
  6956. ['YYYY-MM', /\d{4}-\d\d/, false],
  6957. ['YYYYYYMMDD', /[+-]\d{10}/],
  6958. ['YYYYMMDD', /\d{8}/],
  6959. ['GGGG[W]WWE', /\d{4}W\d{3}/],
  6960. ['GGGG[W]WW', /\d{4}W\d{2}/, false],
  6961. ['YYYYDDD', /\d{7}/],
  6962. ['YYYYMM', /\d{6}/, false],
  6963. ['YYYY', /\d{4}/, false],
  6964. ],
  6965. // iso time formats and regexes
  6966. isoTimes = [
  6967. ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/],
  6968. ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/],
  6969. ['HH:mm:ss', /\d\d:\d\d:\d\d/],
  6970. ['HH:mm', /\d\d:\d\d/],
  6971. ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/],
  6972. ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/],
  6973. ['HHmmss', /\d\d\d\d\d\d/],
  6974. ['HHmm', /\d\d\d\d/],
  6975. ['HH', /\d\d/],
  6976. ],
  6977. aspNetJsonRegex = /^\/?Date\((-?\d+)/i,
  6978. // RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3
  6979. rfc2822 = /^(?:(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}))$/,
  6980. obsOffsets = {
  6981. UT: 0,
  6982. GMT: 0,
  6983. EDT: -4 * 60,
  6984. EST: -5 * 60,
  6985. CDT: -5 * 60,
  6986. CST: -6 * 60,
  6987. MDT: -6 * 60,
  6988. MST: -7 * 60,
  6989. PDT: -7 * 60,
  6990. PST: -8 * 60,
  6991. };
  6992. // date from iso format
  6993. function configFromISO(config) {
  6994. var i,
  6995. l,
  6996. string = config._i,
  6997. match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
  6998. allowTime,
  6999. dateFormat,
  7000. timeFormat,
  7001. tzFormat;
  7002. if (match) {
  7003. getParsingFlags(config).iso = true;
  7004. for (i = 0, l = isoDates.length; i < l; i++) {
  7005. if (isoDates[i][1].exec(match[1])) {
  7006. dateFormat = isoDates[i][0];
  7007. allowTime = isoDates[i][2] !== false;
  7008. break;
  7009. }
  7010. }
  7011. if (dateFormat == null) {
  7012. config._isValid = false;
  7013. return;
  7014. }
  7015. if (match[3]) {
  7016. for (i = 0, l = isoTimes.length; i < l; i++) {
  7017. if (isoTimes[i][1].exec(match[3])) {
  7018. // match[2] should be 'T' or space
  7019. timeFormat = (match[2] || ' ') + isoTimes[i][0];
  7020. break;
  7021. }
  7022. }
  7023. if (timeFormat == null) {
  7024. config._isValid = false;
  7025. return;
  7026. }
  7027. }
  7028. if (!allowTime && timeFormat != null) {
  7029. config._isValid = false;
  7030. return;
  7031. }
  7032. if (match[4]) {
  7033. if (tzRegex.exec(match[4])) {
  7034. tzFormat = 'Z';
  7035. } else {
  7036. config._isValid = false;
  7037. return;
  7038. }
  7039. }
  7040. config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
  7041. configFromStringAndFormat(config);
  7042. } else {
  7043. config._isValid = false;
  7044. }
  7045. }
  7046. function extractFromRFC2822Strings(
  7047. yearStr,
  7048. monthStr,
  7049. dayStr,
  7050. hourStr,
  7051. minuteStr,
  7052. secondStr
  7053. ) {
  7054. var result = [
  7055. untruncateYear(yearStr),
  7056. defaultLocaleMonthsShort.indexOf(monthStr),
  7057. parseInt(dayStr, 10),
  7058. parseInt(hourStr, 10),
  7059. parseInt(minuteStr, 10),
  7060. ];
  7061. if (secondStr) {
  7062. result.push(parseInt(secondStr, 10));
  7063. }
  7064. return result;
  7065. }
  7066. function untruncateYear(yearStr) {
  7067. var year = parseInt(yearStr, 10);
  7068. if (year <= 49) {
  7069. return 2000 + year;
  7070. } else if (year <= 999) {
  7071. return 1900 + year;
  7072. }
  7073. return year;
  7074. }
  7075. function preprocessRFC2822(s) {
  7076. // Remove comments and folding whitespace and replace multiple-spaces with a single space
  7077. return s
  7078. .replace(/\([^)]*\)|[\n\t]/g, ' ')
  7079. .replace(/(\s\s+)/g, ' ')
  7080. .replace(/^\s\s*/, '')
  7081. .replace(/\s\s*$/, '');
  7082. }
  7083. function checkWeekday(weekdayStr, parsedInput, config) {
  7084. if (weekdayStr) {
  7085. // TODO: Replace the vanilla JS Date object with an independent day-of-week check.
  7086. var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr),
  7087. weekdayActual = new Date(
  7088. parsedInput[0],
  7089. parsedInput[1],
  7090. parsedInput[2]
  7091. ).getDay();
  7092. if (weekdayProvided !== weekdayActual) {
  7093. getParsingFlags(config).weekdayMismatch = true;
  7094. config._isValid = false;
  7095. return false;
  7096. }
  7097. }
  7098. return true;
  7099. }
  7100. function calculateOffset(obsOffset, militaryOffset, numOffset) {
  7101. if (obsOffset) {
  7102. return obsOffsets[obsOffset];
  7103. } else if (militaryOffset) {
  7104. // the only allowed military tz is Z
  7105. return 0;
  7106. } else {
  7107. var hm = parseInt(numOffset, 10),
  7108. m = hm % 100,
  7109. h = (hm - m) / 100;
  7110. return h * 60 + m;
  7111. }
  7112. }
  7113. // date and time from ref 2822 format
  7114. function configFromRFC2822(config) {
  7115. var match = rfc2822.exec(preprocessRFC2822(config._i)),
  7116. parsedArray;
  7117. if (match) {
  7118. parsedArray = extractFromRFC2822Strings(
  7119. match[4],
  7120. match[3],
  7121. match[2],
  7122. match[5],
  7123. match[6],
  7124. match[7]
  7125. );
  7126. if (!checkWeekday(match[1], parsedArray, config)) {
  7127. return;
  7128. }
  7129. config._a = parsedArray;
  7130. config._tzm = calculateOffset(match[8], match[9], match[10]);
  7131. config._d = createUTCDate.apply(null, config._a);
  7132. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  7133. getParsingFlags(config).rfc2822 = true;
  7134. } else {
  7135. config._isValid = false;
  7136. }
  7137. }
  7138. // date from 1) ASP.NET, 2) ISO, 3) RFC 2822 formats, or 4) optional fallback if parsing isn't strict
  7139. function configFromString(config) {
  7140. var matched = aspNetJsonRegex.exec(config._i);
  7141. if (matched !== null) {
  7142. config._d = new Date(+matched[1]);
  7143. return;
  7144. }
  7145. configFromISO(config);
  7146. if (config._isValid === false) {
  7147. delete config._isValid;
  7148. } else {
  7149. return;
  7150. }
  7151. configFromRFC2822(config);
  7152. if (config._isValid === false) {
  7153. delete config._isValid;
  7154. } else {
  7155. return;
  7156. }
  7157. if (config._strict) {
  7158. config._isValid = false;
  7159. } else {
  7160. // Final attempt, use Input Fallback
  7161. hooks.createFromInputFallback(config);
  7162. }
  7163. }
  7164. hooks.createFromInputFallback = deprecate(
  7165. 'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' +
  7166. 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' +
  7167. 'discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.',
  7168. function (config) {
  7169. config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
  7170. }
  7171. );
  7172. // Pick the first defined of two or three arguments.
  7173. function defaults(a, b, c) {
  7174. if (a != null) {
  7175. return a;
  7176. }
  7177. if (b != null) {
  7178. return b;
  7179. }
  7180. return c;
  7181. }
  7182. function currentDateArray(config) {
  7183. // hooks is actually the exported moment object
  7184. var nowValue = new Date(hooks.now());
  7185. if (config._useUTC) {
  7186. return [
  7187. nowValue.getUTCFullYear(),
  7188. nowValue.getUTCMonth(),
  7189. nowValue.getUTCDate(),
  7190. ];
  7191. }
  7192. return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
  7193. }
  7194. // convert an array to a date.
  7195. // the array should mirror the parameters below
  7196. // note: all values past the year are optional and will default to the lowest possible value.
  7197. // [year, month, day , hour, minute, second, millisecond]
  7198. function configFromArray(config) {
  7199. var i,
  7200. date,
  7201. input = [],
  7202. currentDate,
  7203. expectedWeekday,
  7204. yearToUse;
  7205. if (config._d) {
  7206. return;
  7207. }
  7208. currentDate = currentDateArray(config);
  7209. //compute day of the year from weeks and weekdays
  7210. if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
  7211. dayOfYearFromWeekInfo(config);
  7212. }
  7213. //if the day of the year is set, figure out what it is
  7214. if (config._dayOfYear != null) {
  7215. yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
  7216. if (
  7217. config._dayOfYear > daysInYear(yearToUse) ||
  7218. config._dayOfYear === 0
  7219. ) {
  7220. getParsingFlags(config)._overflowDayOfYear = true;
  7221. }
  7222. date = createUTCDate(yearToUse, 0, config._dayOfYear);
  7223. config._a[MONTH] = date.getUTCMonth();
  7224. config._a[DATE] = date.getUTCDate();
  7225. }
  7226. // Default to current date.
  7227. // * if no year, month, day of month are given, default to today
  7228. // * if day of month is given, default month and year
  7229. // * if month is given, default only year
  7230. // * if year is given, don't default anything
  7231. for (i = 0; i < 3 && config._a[i] == null; ++i) {
  7232. config._a[i] = input[i] = currentDate[i];
  7233. }
  7234. // Zero out whatever was not defaulted, including time
  7235. for (; i < 7; i++) {
  7236. config._a[i] = input[i] =
  7237. config._a[i] == null ? (i === 2 ? 1 : 0) : config._a[i];
  7238. }
  7239. // Check for 24:00:00.000
  7240. if (
  7241. config._a[HOUR] === 24 &&
  7242. config._a[MINUTE] === 0 &&
  7243. config._a[SECOND] === 0 &&
  7244. config._a[MILLISECOND] === 0
  7245. ) {
  7246. config._nextDay = true;
  7247. config._a[HOUR] = 0;
  7248. }
  7249. config._d = (config._useUTC ? createUTCDate : createDate).apply(
  7250. null,
  7251. input
  7252. );
  7253. expectedWeekday = config._useUTC
  7254. ? config._d.getUTCDay()
  7255. : config._d.getDay();
  7256. // Apply timezone offset from input. The actual utcOffset can be changed
  7257. // with parseZone.
  7258. if (config._tzm != null) {
  7259. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  7260. }
  7261. if (config._nextDay) {
  7262. config._a[HOUR] = 24;
  7263. }
  7264. // check for mismatching day of week
  7265. if (
  7266. config._w &&
  7267. typeof config._w.d !== 'undefined' &&
  7268. config._w.d !== expectedWeekday
  7269. ) {
  7270. getParsingFlags(config).weekdayMismatch = true;
  7271. }
  7272. }
  7273. function dayOfYearFromWeekInfo(config) {
  7274. var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow, curWeek;
  7275. w = config._w;
  7276. if (w.GG != null || w.W != null || w.E != null) {
  7277. dow = 1;
  7278. doy = 4;
  7279. // TODO: We need to take the current isoWeekYear, but that depends on
  7280. // how we interpret now (local, utc, fixed offset). So create
  7281. // a now version of current config (take local/utc/offset flags, and
  7282. // create now).
  7283. weekYear = defaults(
  7284. w.GG,
  7285. config._a[YEAR],
  7286. weekOfYear(createLocal(), 1, 4).year
  7287. );
  7288. week = defaults(w.W, 1);
  7289. weekday = defaults(w.E, 1);
  7290. if (weekday < 1 || weekday > 7) {
  7291. weekdayOverflow = true;
  7292. }
  7293. } else {
  7294. dow = config._locale._week.dow;
  7295. doy = config._locale._week.doy;
  7296. curWeek = weekOfYear(createLocal(), dow, doy);
  7297. weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
  7298. // Default to current week.
  7299. week = defaults(w.w, curWeek.week);
  7300. if (w.d != null) {
  7301. // weekday -- low day numbers are considered next week
  7302. weekday = w.d;
  7303. if (weekday < 0 || weekday > 6) {
  7304. weekdayOverflow = true;
  7305. }
  7306. } else if (w.e != null) {
  7307. // local weekday -- counting starts from beginning of week
  7308. weekday = w.e + dow;
  7309. if (w.e < 0 || w.e > 6) {
  7310. weekdayOverflow = true;
  7311. }
  7312. } else {
  7313. // default to beginning of week
  7314. weekday = dow;
  7315. }
  7316. }
  7317. if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
  7318. getParsingFlags(config)._overflowWeeks = true;
  7319. } else if (weekdayOverflow != null) {
  7320. getParsingFlags(config)._overflowWeekday = true;
  7321. } else {
  7322. temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
  7323. config._a[YEAR] = temp.year;
  7324. config._dayOfYear = temp.dayOfYear;
  7325. }
  7326. }
  7327. // constant that refers to the ISO standard
  7328. hooks.ISO_8601 = function () {
  7329. };
  7330. // constant that refers to the RFC 2822 form
  7331. hooks.RFC_2822 = function () {
  7332. };
  7333. // date from string and format string
  7334. function configFromStringAndFormat(config) {
  7335. // TODO: Move this to another part of the creation flow to prevent circular deps
  7336. if (config._f === hooks.ISO_8601) {
  7337. configFromISO(config);
  7338. return;
  7339. }
  7340. if (config._f === hooks.RFC_2822) {
  7341. configFromRFC2822(config);
  7342. return;
  7343. }
  7344. config._a = [];
  7345. getParsingFlags(config).empty = true;
  7346. // This array is used to make a Date, either with `new Date` or `Date.UTC`
  7347. var string = '' + config._i,
  7348. i,
  7349. parsedInput,
  7350. tokens,
  7351. token,
  7352. skipped,
  7353. stringLength = string.length,
  7354. totalParsedInputLength = 0,
  7355. era;
  7356. tokens =
  7357. expandFormat(config._f, config._locale).match(formattingTokens) || [];
  7358. for (i = 0; i < tokens.length; i++) {
  7359. token = tokens[i];
  7360. parsedInput = (string.match(getParseRegexForToken(token, config)) ||
  7361. [])[0];
  7362. if (parsedInput) {
  7363. skipped = string.substr(0, string.indexOf(parsedInput));
  7364. if (skipped.length > 0) {
  7365. getParsingFlags(config).unusedInput.push(skipped);
  7366. }
  7367. string = string.slice(
  7368. string.indexOf(parsedInput) + parsedInput.length
  7369. );
  7370. totalParsedInputLength += parsedInput.length;
  7371. }
  7372. // don't parse if it's not a known token
  7373. if (formatTokenFunctions[token]) {
  7374. if (parsedInput) {
  7375. getParsingFlags(config).empty = false;
  7376. } else {
  7377. getParsingFlags(config).unusedTokens.push(token);
  7378. }
  7379. addTimeToArrayFromToken(token, parsedInput, config);
  7380. } else if (config._strict && !parsedInput) {
  7381. getParsingFlags(config).unusedTokens.push(token);
  7382. }
  7383. }
  7384. // add remaining unparsed input length to the string
  7385. getParsingFlags(config).charsLeftOver =
  7386. stringLength - totalParsedInputLength;
  7387. if (string.length > 0) {
  7388. getParsingFlags(config).unusedInput.push(string);
  7389. }
  7390. // clear _12h flag if hour is <= 12
  7391. if (
  7392. config._a[HOUR] <= 12 &&
  7393. getParsingFlags(config).bigHour === true &&
  7394. config._a[HOUR] > 0
  7395. ) {
  7396. getParsingFlags(config).bigHour = undefined;
  7397. }
  7398. getParsingFlags(config).parsedDateParts = config._a.slice(0);
  7399. getParsingFlags(config).meridiem = config._meridiem;
  7400. // handle meridiem
  7401. config._a[HOUR] = meridiemFixWrap(
  7402. config._locale,
  7403. config._a[HOUR],
  7404. config._meridiem
  7405. );
  7406. // handle era
  7407. era = getParsingFlags(config).era;
  7408. if (era !== null) {
  7409. config._a[YEAR] = config._locale.erasConvertYear(era, config._a[YEAR]);
  7410. }
  7411. configFromArray(config);
  7412. checkOverflow(config);
  7413. }
  7414. function meridiemFixWrap(locale, hour, meridiem) {
  7415. var isPm;
  7416. if (meridiem == null) {
  7417. // nothing to do
  7418. return hour;
  7419. }
  7420. if (locale.meridiemHour != null) {
  7421. return locale.meridiemHour(hour, meridiem);
  7422. } else if (locale.isPM != null) {
  7423. // Fallback
  7424. isPm = locale.isPM(meridiem);
  7425. if (isPm && hour < 12) {
  7426. hour += 12;
  7427. }
  7428. if (!isPm && hour === 12) {
  7429. hour = 0;
  7430. }
  7431. return hour;
  7432. } else {
  7433. // this is not supposed to happen
  7434. return hour;
  7435. }
  7436. }
  7437. // date from string and array of format strings
  7438. function configFromStringAndArray(config) {
  7439. var tempConfig,
  7440. bestMoment,
  7441. scoreToBeat,
  7442. i,
  7443. currentScore,
  7444. validFormatFound,
  7445. bestFormatIsValid = false;
  7446. if (config._f.length === 0) {
  7447. getParsingFlags(config).invalidFormat = true;
  7448. config._d = new Date(NaN);
  7449. return;
  7450. }
  7451. for (i = 0; i < config._f.length; i++) {
  7452. currentScore = 0;
  7453. validFormatFound = false;
  7454. tempConfig = copyConfig({}, config);
  7455. if (config._useUTC != null) {
  7456. tempConfig._useUTC = config._useUTC;
  7457. }
  7458. tempConfig._f = config._f[i];
  7459. configFromStringAndFormat(tempConfig);
  7460. if (isValid(tempConfig)) {
  7461. validFormatFound = true;
  7462. }
  7463. // if there is any input that was not parsed add a penalty for that format
  7464. currentScore += getParsingFlags(tempConfig).charsLeftOver;
  7465. //or tokens
  7466. currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
  7467. getParsingFlags(tempConfig).score = currentScore;
  7468. if (!bestFormatIsValid) {
  7469. if (
  7470. scoreToBeat == null ||
  7471. currentScore < scoreToBeat ||
  7472. validFormatFound
  7473. ) {
  7474. scoreToBeat = currentScore;
  7475. bestMoment = tempConfig;
  7476. if (validFormatFound) {
  7477. bestFormatIsValid = true;
  7478. }
  7479. }
  7480. } else {
  7481. if (currentScore < scoreToBeat) {
  7482. scoreToBeat = currentScore;
  7483. bestMoment = tempConfig;
  7484. }
  7485. }
  7486. }
  7487. extend(config, bestMoment || tempConfig);
  7488. }
  7489. function configFromObject(config) {
  7490. if (config._d) {
  7491. return;
  7492. }
  7493. var i = normalizeObjectUnits(config._i),
  7494. dayOrDate = i.day === undefined ? i.date : i.day;
  7495. config._a = map(
  7496. [i.year, i.month, dayOrDate, i.hour, i.minute, i.second, i.millisecond],
  7497. function (obj) {
  7498. return obj && parseInt(obj, 10);
  7499. }
  7500. );
  7501. configFromArray(config);
  7502. }
  7503. function createFromConfig(config) {
  7504. var res = new Moment(checkOverflow(prepareConfig(config)));
  7505. if (res._nextDay) {
  7506. // Adding is smart enough around DST
  7507. res.add(1, 'd');
  7508. res._nextDay = undefined;
  7509. }
  7510. return res;
  7511. }
  7512. function prepareConfig(config) {
  7513. var input = config._i,
  7514. format = config._f;
  7515. config._locale = config._locale || getLocale(config._l);
  7516. if (input === null || (format === undefined && input === '')) {
  7517. return createInvalid({nullInput: true});
  7518. }
  7519. if (typeof input === 'string') {
  7520. config._i = input = config._locale.preparse(input);
  7521. }
  7522. if (isMoment(input)) {
  7523. return new Moment(checkOverflow(input));
  7524. } else if (isDate(input)) {
  7525. config._d = input;
  7526. } else if (isArray(format)) {
  7527. configFromStringAndArray(config);
  7528. } else if (format) {
  7529. configFromStringAndFormat(config);
  7530. } else {
  7531. configFromInput(config);
  7532. }
  7533. if (!isValid(config)) {
  7534. config._d = null;
  7535. }
  7536. return config;
  7537. }
  7538. function configFromInput(config) {
  7539. var input = config._i;
  7540. if (isUndefined(input)) {
  7541. config._d = new Date(hooks.now());
  7542. } else if (isDate(input)) {
  7543. config._d = new Date(input.valueOf());
  7544. } else if (typeof input === 'string') {
  7545. configFromString(config);
  7546. } else if (isArray(input)) {
  7547. config._a = map(input.slice(0), function (obj) {
  7548. return parseInt(obj, 10);
  7549. });
  7550. configFromArray(config);
  7551. } else if (isObject(input)) {
  7552. configFromObject(config);
  7553. } else if (isNumber(input)) {
  7554. // from milliseconds
  7555. config._d = new Date(input);
  7556. } else {
  7557. hooks.createFromInputFallback(config);
  7558. }
  7559. }
  7560. function createLocalOrUTC(input, format, locale, strict, isUTC) {
  7561. var c = {};
  7562. if (format === true || format === false) {
  7563. strict = format;
  7564. format = undefined;
  7565. }
  7566. if (locale === true || locale === false) {
  7567. strict = locale;
  7568. locale = undefined;
  7569. }
  7570. if (
  7571. (isObject(input) && isObjectEmpty(input)) ||
  7572. (isArray(input) && input.length === 0)
  7573. ) {
  7574. input = undefined;
  7575. }
  7576. // object construction must be done this way.
  7577. // https://github.com/moment/moment/issues/1423
  7578. c._isAMomentObject = true;
  7579. c._useUTC = c._isUTC = isUTC;
  7580. c._l = locale;
  7581. c._i = input;
  7582. c._f = format;
  7583. c._strict = strict;
  7584. return createFromConfig(c);
  7585. }
  7586. function createLocal(input, format, locale, strict) {
  7587. return createLocalOrUTC(input, format, locale, strict, false);
  7588. }
  7589. var prototypeMin = deprecate(
  7590. 'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',
  7591. function () {
  7592. var other = createLocal.apply(null, arguments);
  7593. if (this.isValid() && other.isValid()) {
  7594. return other < this ? this : other;
  7595. } else {
  7596. return createInvalid();
  7597. }
  7598. }
  7599. ),
  7600. prototypeMax = deprecate(
  7601. 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',
  7602. function () {
  7603. var other = createLocal.apply(null, arguments);
  7604. if (this.isValid() && other.isValid()) {
  7605. return other > this ? this : other;
  7606. } else {
  7607. return createInvalid();
  7608. }
  7609. }
  7610. );
  7611. // Pick a moment m from moments so that m[fn](other) is true for all
  7612. // other. This relies on the function fn to be transitive.
  7613. //
  7614. // moments should either be an array of moment objects or an array, whose
  7615. // first element is an array of moment objects.
  7616. function pickBy(fn, moments) {
  7617. var res, i;
  7618. if (moments.length === 1 && isArray(moments[0])) {
  7619. moments = moments[0];
  7620. }
  7621. if (!moments.length) {
  7622. return createLocal();
  7623. }
  7624. res = moments[0];
  7625. for (i = 1; i < moments.length; ++i) {
  7626. if (!moments[i].isValid() || moments[i][fn](res)) {
  7627. res = moments[i];
  7628. }
  7629. }
  7630. return res;
  7631. }
  7632. // TODO: Use [].sort instead?
  7633. function min() {
  7634. var args = [].slice.call(arguments, 0);
  7635. return pickBy('isBefore', args);
  7636. }
  7637. function max() {
  7638. var args = [].slice.call(arguments, 0);
  7639. return pickBy('isAfter', args);
  7640. }
  7641. var now = function () {
  7642. return Date.now ? Date.now() : +new Date();
  7643. };
  7644. var ordering = [
  7645. 'year',
  7646. 'quarter',
  7647. 'month',
  7648. 'week',
  7649. 'day',
  7650. 'hour',
  7651. 'minute',
  7652. 'second',
  7653. 'millisecond',
  7654. ];
  7655. function isDurationValid(m) {
  7656. var key,
  7657. unitHasDecimal = false,
  7658. i;
  7659. for (key in m) {
  7660. if (
  7661. hasOwnProp(m, key) &&
  7662. !(
  7663. indexOf.call(ordering, key) !== -1 &&
  7664. (m[key] == null || !isNaN(m[key]))
  7665. )
  7666. ) {
  7667. return false;
  7668. }
  7669. }
  7670. for (i = 0; i < ordering.length; ++i) {
  7671. if (m[ordering[i]]) {
  7672. if (unitHasDecimal) {
  7673. return false; // only allow non-integers for smallest unit
  7674. }
  7675. if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
  7676. unitHasDecimal = true;
  7677. }
  7678. }
  7679. }
  7680. return true;
  7681. }
  7682. function isValid$1() {
  7683. return this._isValid;
  7684. }
  7685. function createInvalid$1() {
  7686. return createDuration(NaN);
  7687. }
  7688. function Duration(duration) {
  7689. var normalizedInput = normalizeObjectUnits(duration),
  7690. years = normalizedInput.year || 0,
  7691. quarters = normalizedInput.quarter || 0,
  7692. months = normalizedInput.month || 0,
  7693. weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
  7694. days = normalizedInput.day || 0,
  7695. hours = normalizedInput.hour || 0,
  7696. minutes = normalizedInput.minute || 0,
  7697. seconds = normalizedInput.second || 0,
  7698. milliseconds = normalizedInput.millisecond || 0;
  7699. this._isValid = isDurationValid(normalizedInput);
  7700. // representation for dateAddRemove
  7701. this._milliseconds =
  7702. +milliseconds +
  7703. seconds * 1e3 + // 1000
  7704. minutes * 6e4 + // 1000 * 60
  7705. hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
  7706. // Because of dateAddRemove treats 24 hours as different from a
  7707. // day when working around DST, we need to store them separately
  7708. this._days = +days + weeks * 7;
  7709. // It is impossible to translate months into days without knowing
  7710. // which months you are are talking about, so we have to store
  7711. // it separately.
  7712. this._months = +months + quarters * 3 + years * 12;
  7713. this._data = {};
  7714. this._locale = getLocale();
  7715. this._bubble();
  7716. }
  7717. function isDuration(obj) {
  7718. return obj instanceof Duration;
  7719. }
  7720. function absRound(number) {
  7721. if (number < 0) {
  7722. return Math.round(-1 * number) * -1;
  7723. } else {
  7724. return Math.round(number);
  7725. }
  7726. }
  7727. // compare two arrays, return the number of differences
  7728. function compareArrays(array1, array2, dontConvert) {
  7729. var len = Math.min(array1.length, array2.length),
  7730. lengthDiff = Math.abs(array1.length - array2.length),
  7731. diffs = 0,
  7732. i;
  7733. for (i = 0; i < len; i++) {
  7734. if (
  7735. (dontConvert && array1[i] !== array2[i]) ||
  7736. (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))
  7737. ) {
  7738. diffs++;
  7739. }
  7740. }
  7741. return diffs + lengthDiff;
  7742. }
  7743. // FORMATTING
  7744. function offset(token, separator) {
  7745. addFormatToken(token, 0, 0, function () {
  7746. var offset = this.utcOffset(),
  7747. sign = '+';
  7748. if (offset < 0) {
  7749. offset = -offset;
  7750. sign = '-';
  7751. }
  7752. return (
  7753. sign +
  7754. zeroFill(~~(offset / 60), 2) +
  7755. separator +
  7756. zeroFill(~~offset % 60, 2)
  7757. );
  7758. });
  7759. }
  7760. offset('Z', ':');
  7761. offset('ZZ', '');
  7762. // PARSING
  7763. addRegexToken('Z', matchShortOffset);
  7764. addRegexToken('ZZ', matchShortOffset);
  7765. addParseToken(['Z', 'ZZ'], function (input, array, config) {
  7766. config._useUTC = true;
  7767. config._tzm = offsetFromString(matchShortOffset, input);
  7768. });
  7769. // HELPERS
  7770. // timezone chunker
  7771. // '+10:00' > ['10', '00']
  7772. // '-1530' > ['-15', '30']
  7773. var chunkOffset = /([\+\-]|\d\d)/gi;
  7774. function offsetFromString(matcher, string) {
  7775. var matches = (string || '').match(matcher),
  7776. chunk,
  7777. parts,
  7778. minutes;
  7779. if (matches === null) {
  7780. return null;
  7781. }
  7782. chunk = matches[matches.length - 1] || [];
  7783. parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
  7784. minutes = +(parts[1] * 60) + toInt(parts[2]);
  7785. return minutes === 0 ? 0 : parts[0] === '+' ? minutes : -minutes;
  7786. }
  7787. // Return a moment from input, that is local/utc/zone equivalent to model.
  7788. function cloneWithOffset(input, model) {
  7789. var res, diff;
  7790. if (model._isUTC) {
  7791. res = model.clone();
  7792. diff =
  7793. (isMoment(input) || isDate(input)
  7794. ? input.valueOf()
  7795. : createLocal(input).valueOf()) - res.valueOf();
  7796. // Use low-level api, because this fn is low-level api.
  7797. res._d.setTime(res._d.valueOf() + diff);
  7798. hooks.updateOffset(res, false);
  7799. return res;
  7800. } else {
  7801. return createLocal(input).local();
  7802. }
  7803. }
  7804. function getDateOffset(m) {
  7805. // On Firefox.24 Date#getTimezoneOffset returns a floating point.
  7806. // https://github.com/moment/moment/pull/1871
  7807. return -Math.round(m._d.getTimezoneOffset());
  7808. }
  7809. // HOOKS
  7810. // This function will be called whenever a moment is mutated.
  7811. // It is intended to keep the offset in sync with the timezone.
  7812. hooks.updateOffset = function () {
  7813. };
  7814. // MOMENTS
  7815. // keepLocalTime = true means only change the timezone, without
  7816. // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
  7817. // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
  7818. // +0200, so we adjust the time as needed, to be valid.
  7819. //
  7820. // Keeping the time actually adds/subtracts (one hour)
  7821. // from the actual represented time. That is why we call updateOffset
  7822. // a second time. In case it wants us to change the offset again
  7823. // _changeInProgress == true case, then we have to adjust, because
  7824. // there is no such time in the given timezone.
  7825. function getSetOffset(input, keepLocalTime, keepMinutes) {
  7826. var offset = this._offset || 0,
  7827. localAdjust;
  7828. if (!this.isValid()) {
  7829. return input != null ? this : NaN;
  7830. }
  7831. if (input != null) {
  7832. if (typeof input === 'string') {
  7833. input = offsetFromString(matchShortOffset, input);
  7834. if (input === null) {
  7835. return this;
  7836. }
  7837. } else if (Math.abs(input) < 16 && !keepMinutes) {
  7838. input = input * 60;
  7839. }
  7840. if (!this._isUTC && keepLocalTime) {
  7841. localAdjust = getDateOffset(this);
  7842. }
  7843. this._offset = input;
  7844. this._isUTC = true;
  7845. if (localAdjust != null) {
  7846. this.add(localAdjust, 'm');
  7847. }
  7848. if (offset !== input) {
  7849. if (!keepLocalTime || this._changeInProgress) {
  7850. addSubtract(
  7851. this,
  7852. createDuration(input - offset, 'm'),
  7853. 1,
  7854. false
  7855. );
  7856. } else if (!this._changeInProgress) {
  7857. this._changeInProgress = true;
  7858. hooks.updateOffset(this, true);
  7859. this._changeInProgress = null;
  7860. }
  7861. }
  7862. return this;
  7863. } else {
  7864. return this._isUTC ? offset : getDateOffset(this);
  7865. }
  7866. }
  7867. function getSetZone(input, keepLocalTime) {
  7868. if (input != null) {
  7869. if (typeof input !== 'string') {
  7870. input = -input;
  7871. }
  7872. this.utcOffset(input, keepLocalTime);
  7873. return this;
  7874. } else {
  7875. return -this.utcOffset();
  7876. }
  7877. }
  7878. function setOffsetToUTC(keepLocalTime) {
  7879. return this.utcOffset(0, keepLocalTime);
  7880. }
  7881. function setOffsetToLocal(keepLocalTime) {
  7882. if (this._isUTC) {
  7883. this.utcOffset(0, keepLocalTime);
  7884. this._isUTC = false;
  7885. if (keepLocalTime) {
  7886. this.subtract(getDateOffset(this), 'm');
  7887. }
  7888. }
  7889. return this;
  7890. }
  7891. function setOffsetToParsedOffset() {
  7892. if (this._tzm != null) {
  7893. this.utcOffset(this._tzm, false, true);
  7894. } else if (typeof this._i === 'string') {
  7895. var tZone = offsetFromString(matchOffset, this._i);
  7896. if (tZone != null) {
  7897. this.utcOffset(tZone);
  7898. } else {
  7899. this.utcOffset(0, true);
  7900. }
  7901. }
  7902. return this;
  7903. }
  7904. function hasAlignedHourOffset(input) {
  7905. if (!this.isValid()) {
  7906. return false;
  7907. }
  7908. input = input ? createLocal(input).utcOffset() : 0;
  7909. return (this.utcOffset() - input) % 60 === 0;
  7910. }
  7911. function isDaylightSavingTime() {
  7912. return (
  7913. this.utcOffset() > this.clone().month(0).utcOffset() ||
  7914. this.utcOffset() > this.clone().month(5).utcOffset()
  7915. );
  7916. }
  7917. function isDaylightSavingTimeShifted() {
  7918. if (!isUndefined(this._isDSTShifted)) {
  7919. return this._isDSTShifted;
  7920. }
  7921. var c = {},
  7922. other;
  7923. copyConfig(c, this);
  7924. c = prepareConfig(c);
  7925. if (c._a) {
  7926. other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
  7927. this._isDSTShifted =
  7928. this.isValid() && compareArrays(c._a, other.toArray()) > 0;
  7929. } else {
  7930. this._isDSTShifted = false;
  7931. }
  7932. return this._isDSTShifted;
  7933. }
  7934. function isLocal() {
  7935. return this.isValid() ? !this._isUTC : false;
  7936. }
  7937. function isUtcOffset() {
  7938. return this.isValid() ? this._isUTC : false;
  7939. }
  7940. function isUtc() {
  7941. return this.isValid() ? this._isUTC && this._offset === 0 : false;
  7942. }
  7943. // ASP.NET json date format regex
  7944. var aspNetRegex = /^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,
  7945. // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
  7946. // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
  7947. // and further modified to allow for strings containing both week and day
  7948. isoRegex = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
  7949. function createDuration(input, key) {
  7950. var duration = input,
  7951. // matching against regexp is expensive, do it on demand
  7952. match = null,
  7953. sign,
  7954. ret,
  7955. diffRes;
  7956. if (isDuration(input)) {
  7957. duration = {
  7958. ms: input._milliseconds,
  7959. d: input._days,
  7960. M: input._months,
  7961. };
  7962. } else if (isNumber(input) || !isNaN(+input)) {
  7963. duration = {};
  7964. if (key) {
  7965. duration[key] = +input;
  7966. } else {
  7967. duration.milliseconds = +input;
  7968. }
  7969. } else if ((match = aspNetRegex.exec(input))) {
  7970. sign = match[1] === '-' ? -1 : 1;
  7971. duration = {
  7972. y: 0,
  7973. d: toInt(match[DATE]) * sign,
  7974. h: toInt(match[HOUR]) * sign,
  7975. m: toInt(match[MINUTE]) * sign,
  7976. s: toInt(match[SECOND]) * sign,
  7977. ms: toInt(absRound(match[MILLISECOND] * 1000)) * sign, // the millisecond decimal point is included in the match
  7978. };
  7979. } else if ((match = isoRegex.exec(input))) {
  7980. sign = match[1] === '-' ? -1 : 1;
  7981. duration = {
  7982. y: parseIso(match[2], sign),
  7983. M: parseIso(match[3], sign),
  7984. w: parseIso(match[4], sign),
  7985. d: parseIso(match[5], sign),
  7986. h: parseIso(match[6], sign),
  7987. m: parseIso(match[7], sign),
  7988. s: parseIso(match[8], sign),
  7989. };
  7990. } else if (duration == null) {
  7991. // checks for null or undefined
  7992. duration = {};
  7993. } else if (
  7994. typeof duration === 'object' &&
  7995. ('from' in duration || 'to' in duration)
  7996. ) {
  7997. diffRes = momentsDifference(
  7998. createLocal(duration.from),
  7999. createLocal(duration.to)
  8000. );
  8001. duration = {};
  8002. duration.ms = diffRes.milliseconds;
  8003. duration.M = diffRes.months;
  8004. }
  8005. ret = new Duration(duration);
  8006. if (isDuration(input) && hasOwnProp(input, '_locale')) {
  8007. ret._locale = input._locale;
  8008. }
  8009. if (isDuration(input) && hasOwnProp(input, '_isValid')) {
  8010. ret._isValid = input._isValid;
  8011. }
  8012. return ret;
  8013. }
  8014. createDuration.fn = Duration.prototype;
  8015. createDuration.invalid = createInvalid$1;
  8016. function parseIso(inp, sign) {
  8017. // We'd normally use ~~inp for this, but unfortunately it also
  8018. // converts floats to ints.
  8019. // inp may be undefined, so careful calling replace on it.
  8020. var res = inp && parseFloat(inp.replace(',', '.'));
  8021. // apply sign while we're at it
  8022. return (isNaN(res) ? 0 : res) * sign;
  8023. }
  8024. function positiveMomentsDifference(base, other) {
  8025. var res = {};
  8026. res.months =
  8027. other.month() - base.month() + (other.year() - base.year()) * 12;
  8028. if (base.clone().add(res.months, 'M').isAfter(other)) {
  8029. --res.months;
  8030. }
  8031. res.milliseconds = +other - +base.clone().add(res.months, 'M');
  8032. return res;
  8033. }
  8034. function momentsDifference(base, other) {
  8035. var res;
  8036. if (!(base.isValid() && other.isValid())) {
  8037. return {milliseconds: 0, months: 0};
  8038. }
  8039. other = cloneWithOffset(other, base);
  8040. if (base.isBefore(other)) {
  8041. res = positiveMomentsDifference(base, other);
  8042. } else {
  8043. res = positiveMomentsDifference(other, base);
  8044. res.milliseconds = -res.milliseconds;
  8045. res.months = -res.months;
  8046. }
  8047. return res;
  8048. }
  8049. // TODO: remove 'name' arg after deprecation is removed
  8050. function createAdder(direction, name) {
  8051. return function (val, period) {
  8052. var dur, tmp;
  8053. //invert the arguments, but complain about it
  8054. if (period !== null && !isNaN(+period)) {
  8055. deprecateSimple(
  8056. name,
  8057. 'moment().' +
  8058. name +
  8059. '(period, number) is deprecated. Please use moment().' +
  8060. name +
  8061. '(number, period). ' +
  8062. 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.'
  8063. );
  8064. tmp = val;
  8065. val = period;
  8066. period = tmp;
  8067. }
  8068. dur = createDuration(val, period);
  8069. addSubtract(this, dur, direction);
  8070. return this;
  8071. };
  8072. }
  8073. function addSubtract(mom, duration, isAdding, updateOffset) {
  8074. var milliseconds = duration._milliseconds,
  8075. days = absRound(duration._days),
  8076. months = absRound(duration._months);
  8077. if (!mom.isValid()) {
  8078. // No op
  8079. return;
  8080. }
  8081. updateOffset = updateOffset == null ? true : updateOffset;
  8082. if (months) {
  8083. setMonth(mom, get(mom, 'Month') + months * isAdding);
  8084. }
  8085. if (days) {
  8086. set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
  8087. }
  8088. if (milliseconds) {
  8089. mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
  8090. }
  8091. if (updateOffset) {
  8092. hooks.updateOffset(mom, days || months);
  8093. }
  8094. }
  8095. var add = createAdder(1, 'add'),
  8096. subtract = createAdder(-1, 'subtract');
  8097. function isString(input) {
  8098. return typeof input === 'string' || input instanceof String;
  8099. }
  8100. // type MomentInput = Moment | Date | string | number | (number | string)[] | MomentInputObject | void; // null | undefined
  8101. function isMomentInput(input) {
  8102. return (
  8103. isMoment(input) ||
  8104. isDate(input) ||
  8105. isString(input) ||
  8106. isNumber(input) ||
  8107. isNumberOrStringArray(input) ||
  8108. isMomentInputObject(input) ||
  8109. input === null ||
  8110. input === undefined
  8111. );
  8112. }
  8113. function isMomentInputObject(input) {
  8114. var objectTest = isObject(input) && !isObjectEmpty(input),
  8115. propertyTest = false,
  8116. properties = [
  8117. 'years',
  8118. 'year',
  8119. 'y',
  8120. 'months',
  8121. 'month',
  8122. 'M',
  8123. 'days',
  8124. 'day',
  8125. 'd',
  8126. 'dates',
  8127. 'date',
  8128. 'D',
  8129. 'hours',
  8130. 'hour',
  8131. 'h',
  8132. 'minutes',
  8133. 'minute',
  8134. 'm',
  8135. 'seconds',
  8136. 'second',
  8137. 's',
  8138. 'milliseconds',
  8139. 'millisecond',
  8140. 'ms',
  8141. ],
  8142. i,
  8143. property;
  8144. for (i = 0; i < properties.length; i += 1) {
  8145. property = properties[i];
  8146. propertyTest = propertyTest || hasOwnProp(input, property);
  8147. }
  8148. return objectTest && propertyTest;
  8149. }
  8150. function isNumberOrStringArray(input) {
  8151. var arrayTest = isArray(input),
  8152. dataTypeTest = false;
  8153. if (arrayTest) {
  8154. dataTypeTest =
  8155. input.filter(function (item) {
  8156. return !isNumber(item) && isString(input);
  8157. }).length === 0;
  8158. }
  8159. return arrayTest && dataTypeTest;
  8160. }
  8161. function isCalendarSpec(input) {
  8162. var objectTest = isObject(input) && !isObjectEmpty(input),
  8163. propertyTest = false,
  8164. properties = [
  8165. 'sameDay',
  8166. 'nextDay',
  8167. 'lastDay',
  8168. 'nextWeek',
  8169. 'lastWeek',
  8170. 'sameElse',
  8171. ],
  8172. i,
  8173. property;
  8174. for (i = 0; i < properties.length; i += 1) {
  8175. property = properties[i];
  8176. propertyTest = propertyTest || hasOwnProp(input, property);
  8177. }
  8178. return objectTest && propertyTest;
  8179. }
  8180. function getCalendarFormat(myMoment, now) {
  8181. var diff = myMoment.diff(now, 'days', true);
  8182. return diff < -6
  8183. ? 'sameElse'
  8184. : diff < -1
  8185. ? 'lastWeek'
  8186. : diff < 0
  8187. ? 'lastDay'
  8188. : diff < 1
  8189. ? 'sameDay'
  8190. : diff < 2
  8191. ? 'nextDay'
  8192. : diff < 7
  8193. ? 'nextWeek'
  8194. : 'sameElse';
  8195. }
  8196. function calendar$1(time, formats) {
  8197. // Support for single parameter, formats only overload to the calendar function
  8198. if (arguments.length === 1) {
  8199. if (!arguments[0]) {
  8200. time = undefined;
  8201. formats = undefined;
  8202. } else if (isMomentInput(arguments[0])) {
  8203. time = arguments[0];
  8204. formats = undefined;
  8205. } else if (isCalendarSpec(arguments[0])) {
  8206. formats = arguments[0];
  8207. time = undefined;
  8208. }
  8209. }
  8210. // We want to compare the start of today, vs this.
  8211. // Getting start-of-today depends on whether we're local/utc/offset or not.
  8212. var now = time || createLocal(),
  8213. sod = cloneWithOffset(now, this).startOf('day'),
  8214. format = hooks.calendarFormat(this, sod) || 'sameElse',
  8215. output =
  8216. formats &&
  8217. (isFunction(formats[format])
  8218. ? formats[format].call(this, now)
  8219. : formats[format]);
  8220. return this.format(
  8221. output || this.localeData().calendar(format, this, createLocal(now))
  8222. );
  8223. }
  8224. function clone() {
  8225. return new Moment(this);
  8226. }
  8227. function isAfter(input, units) {
  8228. var localInput = isMoment(input) ? input : createLocal(input);
  8229. if (!(this.isValid() && localInput.isValid())) {
  8230. return false;
  8231. }
  8232. units = normalizeUnits(units) || 'millisecond';
  8233. if (units === 'millisecond') {
  8234. return this.valueOf() > localInput.valueOf();
  8235. } else {
  8236. return localInput.valueOf() < this.clone().startOf(units).valueOf();
  8237. }
  8238. }
  8239. function isBefore(input, units) {
  8240. var localInput = isMoment(input) ? input : createLocal(input);
  8241. if (!(this.isValid() && localInput.isValid())) {
  8242. return false;
  8243. }
  8244. units = normalizeUnits(units) || 'millisecond';
  8245. if (units === 'millisecond') {
  8246. return this.valueOf() < localInput.valueOf();
  8247. } else {
  8248. return this.clone().endOf(units).valueOf() < localInput.valueOf();
  8249. }
  8250. }
  8251. function isBetween(from, to, units, inclusivity) {
  8252. var localFrom = isMoment(from) ? from : createLocal(from),
  8253. localTo = isMoment(to) ? to : createLocal(to);
  8254. if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
  8255. return false;
  8256. }
  8257. inclusivity = inclusivity || '()';
  8258. return (
  8259. (inclusivity[0] === '('
  8260. ? this.isAfter(localFrom, units)
  8261. : !this.isBefore(localFrom, units)) &&
  8262. (inclusivity[1] === ')'
  8263. ? this.isBefore(localTo, units)
  8264. : !this.isAfter(localTo, units))
  8265. );
  8266. }
  8267. function isSame(input, units) {
  8268. var localInput = isMoment(input) ? input : createLocal(input),
  8269. inputMs;
  8270. if (!(this.isValid() && localInput.isValid())) {
  8271. return false;
  8272. }
  8273. units = normalizeUnits(units) || 'millisecond';
  8274. if (units === 'millisecond') {
  8275. return this.valueOf() === localInput.valueOf();
  8276. } else {
  8277. inputMs = localInput.valueOf();
  8278. return (
  8279. this.clone().startOf(units).valueOf() <= inputMs &&
  8280. inputMs <= this.clone().endOf(units).valueOf()
  8281. );
  8282. }
  8283. }
  8284. function isSameOrAfter(input, units) {
  8285. return this.isSame(input, units) || this.isAfter(input, units);
  8286. }
  8287. function isSameOrBefore(input, units) {
  8288. return this.isSame(input, units) || this.isBefore(input, units);
  8289. }
  8290. function diff(input, units, asFloat) {
  8291. var that, zoneDelta, output;
  8292. if (!this.isValid()) {
  8293. return NaN;
  8294. }
  8295. that = cloneWithOffset(input, this);
  8296. if (!that.isValid()) {
  8297. return NaN;
  8298. }
  8299. zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
  8300. units = normalizeUnits(units);
  8301. switch (units) {
  8302. case 'year':
  8303. output = monthDiff(this, that) / 12;
  8304. break;
  8305. case 'month':
  8306. output = monthDiff(this, that);
  8307. break;
  8308. case 'quarter':
  8309. output = monthDiff(this, that) / 3;
  8310. break;
  8311. case 'second':
  8312. output = (this - that) / 1e3;
  8313. break; // 1000
  8314. case 'minute':
  8315. output = (this - that) / 6e4;
  8316. break; // 1000 * 60
  8317. case 'hour':
  8318. output = (this - that) / 36e5;
  8319. break; // 1000 * 60 * 60
  8320. case 'day':
  8321. output = (this - that - zoneDelta) / 864e5;
  8322. break; // 1000 * 60 * 60 * 24, negate dst
  8323. case 'week':
  8324. output = (this - that - zoneDelta) / 6048e5;
  8325. break; // 1000 * 60 * 60 * 24 * 7, negate dst
  8326. default:
  8327. output = this - that;
  8328. }
  8329. return asFloat ? output : absFloor(output);
  8330. }
  8331. function monthDiff(a, b) {
  8332. if (a.date() < b.date()) {
  8333. // end-of-month calculations work correct when the start month has more
  8334. // days than the end month.
  8335. return -monthDiff(b, a);
  8336. }
  8337. // difference in months
  8338. var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month()),
  8339. // b is in (anchor - 1 month, anchor + 1 month)
  8340. anchor = a.clone().add(wholeMonthDiff, 'months'),
  8341. anchor2,
  8342. adjust;
  8343. if (b - anchor < 0) {
  8344. anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
  8345. // linear across the month
  8346. adjust = (b - anchor) / (anchor - anchor2);
  8347. } else {
  8348. anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
  8349. // linear across the month
  8350. adjust = (b - anchor) / (anchor2 - anchor);
  8351. }
  8352. //check for negative zero, return zero if negative zero
  8353. return -(wholeMonthDiff + adjust) || 0;
  8354. }
  8355. hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
  8356. hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
  8357. function toString() {
  8358. return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
  8359. }
  8360. function toISOString(keepOffset) {
  8361. if (!this.isValid()) {
  8362. return null;
  8363. }
  8364. var utc = keepOffset !== true,
  8365. m = utc ? this.clone().utc() : this;
  8366. if (m.year() < 0 || m.year() > 9999) {
  8367. return formatMoment(
  8368. m,
  8369. utc
  8370. ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]'
  8371. : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ'
  8372. );
  8373. }
  8374. if (isFunction(Date.prototype.toISOString)) {
  8375. // native implementation is ~50x faster, use it when we can
  8376. if (utc) {
  8377. return this.toDate().toISOString();
  8378. } else {
  8379. return new Date(this.valueOf() + this.utcOffset() * 60 * 1000)
  8380. .toISOString()
  8381. .replace('Z', formatMoment(m, 'Z'));
  8382. }
  8383. }
  8384. return formatMoment(
  8385. m,
  8386. utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ'
  8387. );
  8388. }
  8389. /**
  8390. * Return a human readable representation of a moment that can
  8391. * also be evaluated to get a new moment which is the same
  8392. *
  8393. * @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects
  8394. */
  8395. function inspect() {
  8396. if (!this.isValid()) {
  8397. return 'moment.invalid(/* ' + this._i + ' */)';
  8398. }
  8399. var func = 'moment',
  8400. zone = '',
  8401. prefix,
  8402. year,
  8403. datetime,
  8404. suffix;
  8405. if (!this.isLocal()) {
  8406. func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
  8407. zone = 'Z';
  8408. }
  8409. prefix = '[' + func + '("]';
  8410. year = 0 <= this.year() && this.year() <= 9999 ? 'YYYY' : 'YYYYYY';
  8411. datetime = '-MM-DD[T]HH:mm:ss.SSS';
  8412. suffix = zone + '[")]';
  8413. return this.format(prefix + year + datetime + suffix);
  8414. }
  8415. function format(inputString) {
  8416. if (!inputString) {
  8417. inputString = this.isUtc()
  8418. ? hooks.defaultFormatUtc
  8419. : hooks.defaultFormat;
  8420. }
  8421. var output = formatMoment(this, inputString);
  8422. return this.localeData().postformat(output);
  8423. }
  8424. function from(time, withoutSuffix) {
  8425. if (
  8426. this.isValid() &&
  8427. ((isMoment(time) && time.isValid()) || createLocal(time).isValid())
  8428. ) {
  8429. return createDuration({to: this, from: time})
  8430. .locale(this.locale())
  8431. .humanize(!withoutSuffix);
  8432. } else {
  8433. return this.localeData().invalidDate();
  8434. }
  8435. }
  8436. function fromNow(withoutSuffix) {
  8437. return this.from(createLocal(), withoutSuffix);
  8438. }
  8439. function to(time, withoutSuffix) {
  8440. if (
  8441. this.isValid() &&
  8442. ((isMoment(time) && time.isValid()) || createLocal(time).isValid())
  8443. ) {
  8444. return createDuration({from: this, to: time})
  8445. .locale(this.locale())
  8446. .humanize(!withoutSuffix);
  8447. } else {
  8448. return this.localeData().invalidDate();
  8449. }
  8450. }
  8451. function toNow(withoutSuffix) {
  8452. return this.to(createLocal(), withoutSuffix);
  8453. }
  8454. // If passed a locale key, it will set the locale for this
  8455. // instance. Otherwise, it will return the locale configuration
  8456. // variables for this instance.
  8457. function locale(key) {
  8458. var newLocaleData;
  8459. if (key === undefined) {
  8460. return this._locale._abbr;
  8461. } else {
  8462. newLocaleData = getLocale(key);
  8463. if (newLocaleData != null) {
  8464. this._locale = newLocaleData;
  8465. }
  8466. return this;
  8467. }
  8468. }
  8469. var lang = deprecate(
  8470. 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
  8471. function (key) {
  8472. if (key === undefined) {
  8473. return this.localeData();
  8474. } else {
  8475. return this.locale(key);
  8476. }
  8477. }
  8478. );
  8479. function localeData() {
  8480. return this._locale;
  8481. }
  8482. var MS_PER_SECOND = 1000,
  8483. MS_PER_MINUTE = 60 * MS_PER_SECOND,
  8484. MS_PER_HOUR = 60 * MS_PER_MINUTE,
  8485. MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
  8486. // actual modulo - handles negative numbers (for dates before 1970):
  8487. function mod$1(dividend, divisor) {
  8488. return ((dividend % divisor) + divisor) % divisor;
  8489. }
  8490. function localStartOfDate(y, m, d) {
  8491. // the date constructor remaps years 0-99 to 1900-1999
  8492. if (y < 100 && y >= 0) {
  8493. // preserve leap years using a full 400 year cycle, then reset
  8494. return new Date(y + 400, m, d) - MS_PER_400_YEARS;
  8495. } else {
  8496. return new Date(y, m, d).valueOf();
  8497. }
  8498. }
  8499. function utcStartOfDate(y, m, d) {
  8500. // Date.UTC remaps years 0-99 to 1900-1999
  8501. if (y < 100 && y >= 0) {
  8502. // preserve leap years using a full 400 year cycle, then reset
  8503. return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
  8504. } else {
  8505. return Date.UTC(y, m, d);
  8506. }
  8507. }
  8508. function startOf(units) {
  8509. var time, startOfDate;
  8510. units = normalizeUnits(units);
  8511. if (units === undefined || units === 'millisecond' || !this.isValid()) {
  8512. return this;
  8513. }
  8514. startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
  8515. switch (units) {
  8516. case 'year':
  8517. time = startOfDate(this.year(), 0, 1);
  8518. break;
  8519. case 'quarter':
  8520. time = startOfDate(
  8521. this.year(),
  8522. this.month() - (this.month() % 3),
  8523. 1
  8524. );
  8525. break;
  8526. case 'month':
  8527. time = startOfDate(this.year(), this.month(), 1);
  8528. break;
  8529. case 'week':
  8530. time = startOfDate(
  8531. this.year(),
  8532. this.month(),
  8533. this.date() - this.weekday()
  8534. );
  8535. break;
  8536. case 'isoWeek':
  8537. time = startOfDate(
  8538. this.year(),
  8539. this.month(),
  8540. this.date() - (this.isoWeekday() - 1)
  8541. );
  8542. break;
  8543. case 'day':
  8544. case 'date':
  8545. time = startOfDate(this.year(), this.month(), this.date());
  8546. break;
  8547. case 'hour':
  8548. time = this._d.valueOf();
  8549. time -= mod$1(
  8550. time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
  8551. MS_PER_HOUR
  8552. );
  8553. break;
  8554. case 'minute':
  8555. time = this._d.valueOf();
  8556. time -= mod$1(time, MS_PER_MINUTE);
  8557. break;
  8558. case 'second':
  8559. time = this._d.valueOf();
  8560. time -= mod$1(time, MS_PER_SECOND);
  8561. break;
  8562. }
  8563. this._d.setTime(time);
  8564. hooks.updateOffset(this, true);
  8565. return this;
  8566. }
  8567. function endOf(units) {
  8568. var time, startOfDate;
  8569. units = normalizeUnits(units);
  8570. if (units === undefined || units === 'millisecond' || !this.isValid()) {
  8571. return this;
  8572. }
  8573. startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
  8574. switch (units) {
  8575. case 'year':
  8576. time = startOfDate(this.year() + 1, 0, 1) - 1;
  8577. break;
  8578. case 'quarter':
  8579. time =
  8580. startOfDate(
  8581. this.year(),
  8582. this.month() - (this.month() % 3) + 3,
  8583. 1
  8584. ) - 1;
  8585. break;
  8586. case 'month':
  8587. time = startOfDate(this.year(), this.month() + 1, 1) - 1;
  8588. break;
  8589. case 'week':
  8590. time =
  8591. startOfDate(
  8592. this.year(),
  8593. this.month(),
  8594. this.date() - this.weekday() + 7
  8595. ) - 1;
  8596. break;
  8597. case 'isoWeek':
  8598. time =
  8599. startOfDate(
  8600. this.year(),
  8601. this.month(),
  8602. this.date() - (this.isoWeekday() - 1) + 7
  8603. ) - 1;
  8604. break;
  8605. case 'day':
  8606. case 'date':
  8607. time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
  8608. break;
  8609. case 'hour':
  8610. time = this._d.valueOf();
  8611. time +=
  8612. MS_PER_HOUR -
  8613. mod$1(
  8614. time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
  8615. MS_PER_HOUR
  8616. ) -
  8617. 1;
  8618. break;
  8619. case 'minute':
  8620. time = this._d.valueOf();
  8621. time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
  8622. break;
  8623. case 'second':
  8624. time = this._d.valueOf();
  8625. time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
  8626. break;
  8627. }
  8628. this._d.setTime(time);
  8629. hooks.updateOffset(this, true);
  8630. return this;
  8631. }
  8632. function valueOf() {
  8633. return this._d.valueOf() - (this._offset || 0) * 60000;
  8634. }
  8635. function unix() {
  8636. return Math.floor(this.valueOf() / 1000);
  8637. }
  8638. function toDate() {
  8639. return new Date(this.valueOf());
  8640. }
  8641. function toArray() {
  8642. var m = this;
  8643. return [
  8644. m.year(),
  8645. m.month(),
  8646. m.date(),
  8647. m.hour(),
  8648. m.minute(),
  8649. m.second(),
  8650. m.millisecond(),
  8651. ];
  8652. }
  8653. function toObject() {
  8654. var m = this;
  8655. return {
  8656. years: m.year(),
  8657. months: m.month(),
  8658. date: m.date(),
  8659. hours: m.hours(),
  8660. minutes: m.minutes(),
  8661. seconds: m.seconds(),
  8662. milliseconds: m.milliseconds(),
  8663. };
  8664. }
  8665. function toJSON() {
  8666. // new Date(NaN).toJSON() === null
  8667. return this.isValid() ? this.toISOString() : null;
  8668. }
  8669. function isValid$2() {
  8670. return isValid(this);
  8671. }
  8672. function parsingFlags() {
  8673. return extend({}, getParsingFlags(this));
  8674. }
  8675. function invalidAt() {
  8676. return getParsingFlags(this).overflow;
  8677. }
  8678. function creationData() {
  8679. return {
  8680. input: this._i,
  8681. format: this._f,
  8682. locale: this._locale,
  8683. isUTC: this._isUTC,
  8684. strict: this._strict,
  8685. };
  8686. }
  8687. addFormatToken('N', 0, 0, 'eraAbbr');
  8688. addFormatToken('NN', 0, 0, 'eraAbbr');
  8689. addFormatToken('NNN', 0, 0, 'eraAbbr');
  8690. addFormatToken('NNNN', 0, 0, 'eraName');
  8691. addFormatToken('NNNNN', 0, 0, 'eraNarrow');
  8692. addFormatToken('y', ['y', 1], 'yo', 'eraYear');
  8693. addFormatToken('y', ['yy', 2], 0, 'eraYear');
  8694. addFormatToken('y', ['yyy', 3], 0, 'eraYear');
  8695. addFormatToken('y', ['yyyy', 4], 0, 'eraYear');
  8696. addRegexToken('N', matchEraAbbr);
  8697. addRegexToken('NN', matchEraAbbr);
  8698. addRegexToken('NNN', matchEraAbbr);
  8699. addRegexToken('NNNN', matchEraName);
  8700. addRegexToken('NNNNN', matchEraNarrow);
  8701. addParseToken(['N', 'NN', 'NNN', 'NNNN', 'NNNNN'], function (
  8702. input,
  8703. array,
  8704. config,
  8705. token
  8706. ) {
  8707. var era = config._locale.erasParse(input, token, config._strict);
  8708. if (era) {
  8709. getParsingFlags(config).era = era;
  8710. } else {
  8711. getParsingFlags(config).invalidEra = input;
  8712. }
  8713. });
  8714. addRegexToken('y', matchUnsigned);
  8715. addRegexToken('yy', matchUnsigned);
  8716. addRegexToken('yyy', matchUnsigned);
  8717. addRegexToken('yyyy', matchUnsigned);
  8718. addRegexToken('yo', matchEraYearOrdinal);
  8719. addParseToken(['y', 'yy', 'yyy', 'yyyy'], YEAR);
  8720. addParseToken(['yo'], function (input, array, config, token) {
  8721. var match;
  8722. if (config._locale._eraYearOrdinalRegex) {
  8723. match = input.match(config._locale._eraYearOrdinalRegex);
  8724. }
  8725. if (config._locale.eraYearOrdinalParse) {
  8726. array[YEAR] = config._locale.eraYearOrdinalParse(input, match);
  8727. } else {
  8728. array[YEAR] = parseInt(input, 10);
  8729. }
  8730. });
  8731. function localeEras(m, format) {
  8732. var i,
  8733. l,
  8734. date,
  8735. eras = this._eras || getLocale('en')._eras;
  8736. for (i = 0, l = eras.length; i < l; ++i) {
  8737. switch (typeof eras[i].since) {
  8738. case 'string':
  8739. // truncate time
  8740. date = hooks(eras[i].since).startOf('day');
  8741. eras[i].since = date.valueOf();
  8742. break;
  8743. }
  8744. switch (typeof eras[i].until) {
  8745. case 'undefined':
  8746. eras[i].until = +Infinity;
  8747. break;
  8748. case 'string':
  8749. // truncate time
  8750. date = hooks(eras[i].until).startOf('day').valueOf();
  8751. eras[i].until = date.valueOf();
  8752. break;
  8753. }
  8754. }
  8755. return eras;
  8756. }
  8757. function localeErasParse(eraName, format, strict) {
  8758. var i,
  8759. l,
  8760. eras = this.eras(),
  8761. name,
  8762. abbr,
  8763. narrow;
  8764. eraName = eraName.toUpperCase();
  8765. for (i = 0, l = eras.length; i < l; ++i) {
  8766. name = eras[i].name.toUpperCase();
  8767. abbr = eras[i].abbr.toUpperCase();
  8768. narrow = eras[i].narrow.toUpperCase();
  8769. if (strict) {
  8770. switch (format) {
  8771. case 'N':
  8772. case 'NN':
  8773. case 'NNN':
  8774. if (abbr === eraName) {
  8775. return eras[i];
  8776. }
  8777. break;
  8778. case 'NNNN':
  8779. if (name === eraName) {
  8780. return eras[i];
  8781. }
  8782. break;
  8783. case 'NNNNN':
  8784. if (narrow === eraName) {
  8785. return eras[i];
  8786. }
  8787. break;
  8788. }
  8789. } else if ([name, abbr, narrow].indexOf(eraName) >= 0) {
  8790. return eras[i];
  8791. }
  8792. }
  8793. }
  8794. function localeErasConvertYear(era, year) {
  8795. var dir = era.since <= era.until ? +1 : -1;
  8796. if (year === undefined) {
  8797. return hooks(era.since).year();
  8798. } else {
  8799. return hooks(era.since).year() + (year - era.offset) * dir;
  8800. }
  8801. }
  8802. function getEraName() {
  8803. var i,
  8804. l,
  8805. val,
  8806. eras = this.localeData().eras();
  8807. for (i = 0, l = eras.length; i < l; ++i) {
  8808. // truncate time
  8809. val = this.clone().startOf('day').valueOf();
  8810. if (eras[i].since <= val && val <= eras[i].until) {
  8811. return eras[i].name;
  8812. }
  8813. if (eras[i].until <= val && val <= eras[i].since) {
  8814. return eras[i].name;
  8815. }
  8816. }
  8817. return '';
  8818. }
  8819. function getEraNarrow() {
  8820. var i,
  8821. l,
  8822. val,
  8823. eras = this.localeData().eras();
  8824. for (i = 0, l = eras.length; i < l; ++i) {
  8825. // truncate time
  8826. val = this.clone().startOf('day').valueOf();
  8827. if (eras[i].since <= val && val <= eras[i].until) {
  8828. return eras[i].narrow;
  8829. }
  8830. if (eras[i].until <= val && val <= eras[i].since) {
  8831. return eras[i].narrow;
  8832. }
  8833. }
  8834. return '';
  8835. }
  8836. function getEraAbbr() {
  8837. var i,
  8838. l,
  8839. val,
  8840. eras = this.localeData().eras();
  8841. for (i = 0, l = eras.length; i < l; ++i) {
  8842. // truncate time
  8843. val = this.clone().startOf('day').valueOf();
  8844. if (eras[i].since <= val && val <= eras[i].until) {
  8845. return eras[i].abbr;
  8846. }
  8847. if (eras[i].until <= val && val <= eras[i].since) {
  8848. return eras[i].abbr;
  8849. }
  8850. }
  8851. return '';
  8852. }
  8853. function getEraYear() {
  8854. var i,
  8855. l,
  8856. dir,
  8857. val,
  8858. eras = this.localeData().eras();
  8859. for (i = 0, l = eras.length; i < l; ++i) {
  8860. dir = eras[i].since <= eras[i].until ? +1 : -1;
  8861. // truncate time
  8862. val = this.clone().startOf('day').valueOf();
  8863. if (
  8864. (eras[i].since <= val && val <= eras[i].until) ||
  8865. (eras[i].until <= val && val <= eras[i].since)
  8866. ) {
  8867. return (
  8868. (this.year() - hooks(eras[i].since).year()) * dir +
  8869. eras[i].offset
  8870. );
  8871. }
  8872. }
  8873. return this.year();
  8874. }
  8875. function erasNameRegex(isStrict) {
  8876. if (!hasOwnProp(this, '_erasNameRegex')) {
  8877. computeErasParse.call(this);
  8878. }
  8879. return isStrict ? this._erasNameRegex : this._erasRegex;
  8880. }
  8881. function erasAbbrRegex(isStrict) {
  8882. if (!hasOwnProp(this, '_erasAbbrRegex')) {
  8883. computeErasParse.call(this);
  8884. }
  8885. return isStrict ? this._erasAbbrRegex : this._erasRegex;
  8886. }
  8887. function erasNarrowRegex(isStrict) {
  8888. if (!hasOwnProp(this, '_erasNarrowRegex')) {
  8889. computeErasParse.call(this);
  8890. }
  8891. return isStrict ? this._erasNarrowRegex : this._erasRegex;
  8892. }
  8893. function matchEraAbbr(isStrict, locale) {
  8894. return locale.erasAbbrRegex(isStrict);
  8895. }
  8896. function matchEraName(isStrict, locale) {
  8897. return locale.erasNameRegex(isStrict);
  8898. }
  8899. function matchEraNarrow(isStrict, locale) {
  8900. return locale.erasNarrowRegex(isStrict);
  8901. }
  8902. function matchEraYearOrdinal(isStrict, locale) {
  8903. return locale._eraYearOrdinalRegex || matchUnsigned;
  8904. }
  8905. function computeErasParse() {
  8906. var abbrPieces = [],
  8907. namePieces = [],
  8908. narrowPieces = [],
  8909. mixedPieces = [],
  8910. i,
  8911. l,
  8912. eras = this.eras();
  8913. for (i = 0, l = eras.length; i < l; ++i) {
  8914. namePieces.push(regexEscape(eras[i].name));
  8915. abbrPieces.push(regexEscape(eras[i].abbr));
  8916. narrowPieces.push(regexEscape(eras[i].narrow));
  8917. mixedPieces.push(regexEscape(eras[i].name));
  8918. mixedPieces.push(regexEscape(eras[i].abbr));
  8919. mixedPieces.push(regexEscape(eras[i].narrow));
  8920. }
  8921. this._erasRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  8922. this._erasNameRegex = new RegExp('^(' + namePieces.join('|') + ')', 'i');
  8923. this._erasAbbrRegex = new RegExp('^(' + abbrPieces.join('|') + ')', 'i');
  8924. this._erasNarrowRegex = new RegExp(
  8925. '^(' + narrowPieces.join('|') + ')',
  8926. 'i'
  8927. );
  8928. }
  8929. // FORMATTING
  8930. addFormatToken(0, ['gg', 2], 0, function () {
  8931. return this.weekYear() % 100;
  8932. });
  8933. addFormatToken(0, ['GG', 2], 0, function () {
  8934. return this.isoWeekYear() % 100;
  8935. });
  8936. function addWeekYearFormatToken(token, getter) {
  8937. addFormatToken(0, [token, token.length], 0, getter);
  8938. }
  8939. addWeekYearFormatToken('gggg', 'weekYear');
  8940. addWeekYearFormatToken('ggggg', 'weekYear');
  8941. addWeekYearFormatToken('GGGG', 'isoWeekYear');
  8942. addWeekYearFormatToken('GGGGG', 'isoWeekYear');
  8943. // ALIASES
  8944. addUnitAlias('weekYear', 'gg');
  8945. addUnitAlias('isoWeekYear', 'GG');
  8946. // PRIORITY
  8947. addUnitPriority('weekYear', 1);
  8948. addUnitPriority('isoWeekYear', 1);
  8949. // PARSING
  8950. addRegexToken('G', matchSigned);
  8951. addRegexToken('g', matchSigned);
  8952. addRegexToken('GG', match1to2, match2);
  8953. addRegexToken('gg', match1to2, match2);
  8954. addRegexToken('GGGG', match1to4, match4);
  8955. addRegexToken('gggg', match1to4, match4);
  8956. addRegexToken('GGGGG', match1to6, match6);
  8957. addRegexToken('ggggg', match1to6, match6);
  8958. addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (
  8959. input,
  8960. week,
  8961. config,
  8962. token
  8963. ) {
  8964. week[token.substr(0, 2)] = toInt(input);
  8965. });
  8966. addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
  8967. week[token] = hooks.parseTwoDigitYear(input);
  8968. });
  8969. // MOMENTS
  8970. function getSetWeekYear(input) {
  8971. return getSetWeekYearHelper.call(
  8972. this,
  8973. input,
  8974. this.week(),
  8975. this.weekday(),
  8976. this.localeData()._week.dow,
  8977. this.localeData()._week.doy
  8978. );
  8979. }
  8980. function getSetISOWeekYear(input) {
  8981. return getSetWeekYearHelper.call(
  8982. this,
  8983. input,
  8984. this.isoWeek(),
  8985. this.isoWeekday(),
  8986. 1,
  8987. 4
  8988. );
  8989. }
  8990. function getISOWeeksInYear() {
  8991. return weeksInYear(this.year(), 1, 4);
  8992. }
  8993. function getISOWeeksInISOWeekYear() {
  8994. return weeksInYear(this.isoWeekYear(), 1, 4);
  8995. }
  8996. function getWeeksInYear() {
  8997. var weekInfo = this.localeData()._week;
  8998. return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
  8999. }
  9000. function getWeeksInWeekYear() {
  9001. var weekInfo = this.localeData()._week;
  9002. return weeksInYear(this.weekYear(), weekInfo.dow, weekInfo.doy);
  9003. }
  9004. function getSetWeekYearHelper(input, week, weekday, dow, doy) {
  9005. var weeksTarget;
  9006. if (input == null) {
  9007. return weekOfYear(this, dow, doy).year;
  9008. } else {
  9009. weeksTarget = weeksInYear(input, dow, doy);
  9010. if (week > weeksTarget) {
  9011. week = weeksTarget;
  9012. }
  9013. return setWeekAll.call(this, input, week, weekday, dow, doy);
  9014. }
  9015. }
  9016. function setWeekAll(weekYear, week, weekday, dow, doy) {
  9017. var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
  9018. date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
  9019. this.year(date.getUTCFullYear());
  9020. this.month(date.getUTCMonth());
  9021. this.date(date.getUTCDate());
  9022. return this;
  9023. }
  9024. // FORMATTING
  9025. addFormatToken('Q', 0, 'Qo', 'quarter');
  9026. // ALIASES
  9027. addUnitAlias('quarter', 'Q');
  9028. // PRIORITY
  9029. addUnitPriority('quarter', 7);
  9030. // PARSING
  9031. addRegexToken('Q', match1);
  9032. addParseToken('Q', function (input, array) {
  9033. array[MONTH] = (toInt(input) - 1) * 3;
  9034. });
  9035. // MOMENTS
  9036. function getSetQuarter(input) {
  9037. return input == null
  9038. ? Math.ceil((this.month() + 1) / 3)
  9039. : this.month((input - 1) * 3 + (this.month() % 3));
  9040. }
  9041. // FORMATTING
  9042. addFormatToken('D', ['DD', 2], 'Do', 'date');
  9043. // ALIASES
  9044. addUnitAlias('date', 'D');
  9045. // PRIORITY
  9046. addUnitPriority('date', 9);
  9047. // PARSING
  9048. addRegexToken('D', match1to2);
  9049. addRegexToken('DD', match1to2, match2);
  9050. addRegexToken('Do', function (isStrict, locale) {
  9051. // TODO: Remove "ordinalParse" fallback in next major release.
  9052. return isStrict
  9053. ? locale._dayOfMonthOrdinalParse || locale._ordinalParse
  9054. : locale._dayOfMonthOrdinalParseLenient;
  9055. });
  9056. addParseToken(['D', 'DD'], DATE);
  9057. addParseToken('Do', function (input, array) {
  9058. array[DATE] = toInt(input.match(match1to2)[0]);
  9059. });
  9060. // MOMENTS
  9061. var getSetDayOfMonth = makeGetSet('Date', true);
  9062. // FORMATTING
  9063. addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
  9064. // ALIASES
  9065. addUnitAlias('dayOfYear', 'DDD');
  9066. // PRIORITY
  9067. addUnitPriority('dayOfYear', 4);
  9068. // PARSING
  9069. addRegexToken('DDD', match1to3);
  9070. addRegexToken('DDDD', match3);
  9071. addParseToken(['DDD', 'DDDD'], function (input, array, config) {
  9072. config._dayOfYear = toInt(input);
  9073. });
  9074. // HELPERS
  9075. // MOMENTS
  9076. function getSetDayOfYear(input) {
  9077. var dayOfYear =
  9078. Math.round(
  9079. (this.clone().startOf('day') - this.clone().startOf('year')) / 864e5
  9080. ) + 1;
  9081. return input == null ? dayOfYear : this.add(input - dayOfYear, 'd');
  9082. }
  9083. // FORMATTING
  9084. addFormatToken('m', ['mm', 2], 0, 'minute');
  9085. // ALIASES
  9086. addUnitAlias('minute', 'm');
  9087. // PRIORITY
  9088. addUnitPriority('minute', 14);
  9089. // PARSING
  9090. addRegexToken('m', match1to2);
  9091. addRegexToken('mm', match1to2, match2);
  9092. addParseToken(['m', 'mm'], MINUTE);
  9093. // MOMENTS
  9094. var getSetMinute = makeGetSet('Minutes', false);
  9095. // FORMATTING
  9096. addFormatToken('s', ['ss', 2], 0, 'second');
  9097. // ALIASES
  9098. addUnitAlias('second', 's');
  9099. // PRIORITY
  9100. addUnitPriority('second', 15);
  9101. // PARSING
  9102. addRegexToken('s', match1to2);
  9103. addRegexToken('ss', match1to2, match2);
  9104. addParseToken(['s', 'ss'], SECOND);
  9105. // MOMENTS
  9106. var getSetSecond = makeGetSet('Seconds', false);
  9107. // FORMATTING
  9108. addFormatToken('S', 0, 0, function () {
  9109. return ~~(this.millisecond() / 100);
  9110. });
  9111. addFormatToken(0, ['SS', 2], 0, function () {
  9112. return ~~(this.millisecond() / 10);
  9113. });
  9114. addFormatToken(0, ['SSS', 3], 0, 'millisecond');
  9115. addFormatToken(0, ['SSSS', 4], 0, function () {
  9116. return this.millisecond() * 10;
  9117. });
  9118. addFormatToken(0, ['SSSSS', 5], 0, function () {
  9119. return this.millisecond() * 100;
  9120. });
  9121. addFormatToken(0, ['SSSSSS', 6], 0, function () {
  9122. return this.millisecond() * 1000;
  9123. });
  9124. addFormatToken(0, ['SSSSSSS', 7], 0, function () {
  9125. return this.millisecond() * 10000;
  9126. });
  9127. addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
  9128. return this.millisecond() * 100000;
  9129. });
  9130. addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
  9131. return this.millisecond() * 1000000;
  9132. });
  9133. // ALIASES
  9134. addUnitAlias('millisecond', 'ms');
  9135. // PRIORITY
  9136. addUnitPriority('millisecond', 16);
  9137. // PARSING
  9138. addRegexToken('S', match1to3, match1);
  9139. addRegexToken('SS', match1to3, match2);
  9140. addRegexToken('SSS', match1to3, match3);
  9141. var token, getSetMillisecond;
  9142. for (token = 'SSSS'; token.length <= 9; token += 'S') {
  9143. addRegexToken(token, matchUnsigned);
  9144. }
  9145. function parseMs(input, array) {
  9146. array[MILLISECOND] = toInt(('0.' + input) * 1000);
  9147. }
  9148. for (token = 'S'; token.length <= 9; token += 'S') {
  9149. addParseToken(token, parseMs);
  9150. }
  9151. getSetMillisecond = makeGetSet('Milliseconds', false);
  9152. // FORMATTING
  9153. addFormatToken('z', 0, 0, 'zoneAbbr');
  9154. addFormatToken('zz', 0, 0, 'zoneName');
  9155. // MOMENTS
  9156. function getZoneAbbr() {
  9157. return this._isUTC ? 'UTC' : '';
  9158. }
  9159. function getZoneName() {
  9160. return this._isUTC ? 'Coordinated Universal Time' : '';
  9161. }
  9162. var proto = Moment.prototype;
  9163. proto.add = add;
  9164. proto.calendar = calendar$1;
  9165. proto.clone = clone;
  9166. proto.diff = diff;
  9167. proto.endOf = endOf;
  9168. proto.format = format;
  9169. proto.from = from;
  9170. proto.fromNow = fromNow;
  9171. proto.to = to;
  9172. proto.toNow = toNow;
  9173. proto.get = stringGet;
  9174. proto.invalidAt = invalidAt;
  9175. proto.isAfter = isAfter;
  9176. proto.isBefore = isBefore;
  9177. proto.isBetween = isBetween;
  9178. proto.isSame = isSame;
  9179. proto.isSameOrAfter = isSameOrAfter;
  9180. proto.isSameOrBefore = isSameOrBefore;
  9181. proto.isValid = isValid$2;
  9182. proto.lang = lang;
  9183. proto.locale = locale;
  9184. proto.localeData = localeData;
  9185. proto.max = prototypeMax;
  9186. proto.min = prototypeMin;
  9187. proto.parsingFlags = parsingFlags;
  9188. proto.set = stringSet;
  9189. proto.startOf = startOf;
  9190. proto.subtract = subtract;
  9191. proto.toArray = toArray;
  9192. proto.toObject = toObject;
  9193. proto.toDate = toDate;
  9194. proto.toISOString = toISOString;
  9195. proto.inspect = inspect;
  9196. if (typeof Symbol !== 'undefined' && Symbol.for != null) {
  9197. proto[Symbol.for('nodejs.util.inspect.custom')] = function () {
  9198. return 'Moment<' + this.format() + '>';
  9199. };
  9200. }
  9201. proto.toJSON = toJSON;
  9202. proto.toString = toString;
  9203. proto.unix = unix;
  9204. proto.valueOf = valueOf;
  9205. proto.creationData = creationData;
  9206. proto.eraName = getEraName;
  9207. proto.eraNarrow = getEraNarrow;
  9208. proto.eraAbbr = getEraAbbr;
  9209. proto.eraYear = getEraYear;
  9210. proto.year = getSetYear;
  9211. proto.isLeapYear = getIsLeapYear;
  9212. proto.weekYear = getSetWeekYear;
  9213. proto.isoWeekYear = getSetISOWeekYear;
  9214. proto.quarter = proto.quarters = getSetQuarter;
  9215. proto.month = getSetMonth;
  9216. proto.daysInMonth = getDaysInMonth;
  9217. proto.week = proto.weeks = getSetWeek;
  9218. proto.isoWeek = proto.isoWeeks = getSetISOWeek;
  9219. proto.weeksInYear = getWeeksInYear;
  9220. proto.weeksInWeekYear = getWeeksInWeekYear;
  9221. proto.isoWeeksInYear = getISOWeeksInYear;
  9222. proto.isoWeeksInISOWeekYear = getISOWeeksInISOWeekYear;
  9223. proto.date = getSetDayOfMonth;
  9224. proto.day = proto.days = getSetDayOfWeek;
  9225. proto.weekday = getSetLocaleDayOfWeek;
  9226. proto.isoWeekday = getSetISODayOfWeek;
  9227. proto.dayOfYear = getSetDayOfYear;
  9228. proto.hour = proto.hours = getSetHour;
  9229. proto.minute = proto.minutes = getSetMinute;
  9230. proto.second = proto.seconds = getSetSecond;
  9231. proto.millisecond = proto.milliseconds = getSetMillisecond;
  9232. proto.utcOffset = getSetOffset;
  9233. proto.utc = setOffsetToUTC;
  9234. proto.local = setOffsetToLocal;
  9235. proto.parseZone = setOffsetToParsedOffset;
  9236. proto.hasAlignedHourOffset = hasAlignedHourOffset;
  9237. proto.isDST = isDaylightSavingTime;
  9238. proto.isLocal = isLocal;
  9239. proto.isUtcOffset = isUtcOffset;
  9240. proto.isUtc = isUtc;
  9241. proto.isUTC = isUtc;
  9242. proto.zoneAbbr = getZoneAbbr;
  9243. proto.zoneName = getZoneName;
  9244. proto.dates = deprecate(
  9245. 'dates accessor is deprecated. Use date instead.',
  9246. getSetDayOfMonth
  9247. );
  9248. proto.months = deprecate(
  9249. 'months accessor is deprecated. Use month instead',
  9250. getSetMonth
  9251. );
  9252. proto.years = deprecate(
  9253. 'years accessor is deprecated. Use year instead',
  9254. getSetYear
  9255. );
  9256. proto.zone = deprecate(
  9257. 'moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/',
  9258. getSetZone
  9259. );
  9260. proto.isDSTShifted = deprecate(
  9261. 'isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information',
  9262. isDaylightSavingTimeShifted
  9263. );
  9264. function createUnix(input) {
  9265. return createLocal(input * 1000);
  9266. }
  9267. function createInZone() {
  9268. return createLocal.apply(null, arguments).parseZone();
  9269. }
  9270. function preParsePostFormat(string) {
  9271. return string;
  9272. }
  9273. var proto$1 = Locale.prototype;
  9274. proto$1.calendar = calendar;
  9275. proto$1.longDateFormat = longDateFormat;
  9276. proto$1.invalidDate = invalidDate;
  9277. proto$1.ordinal = ordinal;
  9278. proto$1.preparse = preParsePostFormat;
  9279. proto$1.postformat = preParsePostFormat;
  9280. proto$1.relativeTime = relativeTime;
  9281. proto$1.pastFuture = pastFuture;
  9282. proto$1.set = set;
  9283. proto$1.eras = localeEras;
  9284. proto$1.erasParse = localeErasParse;
  9285. proto$1.erasConvertYear = localeErasConvertYear;
  9286. proto$1.erasAbbrRegex = erasAbbrRegex;
  9287. proto$1.erasNameRegex = erasNameRegex;
  9288. proto$1.erasNarrowRegex = erasNarrowRegex;
  9289. proto$1.months = localeMonths;
  9290. proto$1.monthsShort = localeMonthsShort;
  9291. proto$1.monthsParse = localeMonthsParse;
  9292. proto$1.monthsRegex = monthsRegex;
  9293. proto$1.monthsShortRegex = monthsShortRegex;
  9294. proto$1.week = localeWeek;
  9295. proto$1.firstDayOfYear = localeFirstDayOfYear;
  9296. proto$1.firstDayOfWeek = localeFirstDayOfWeek;
  9297. proto$1.weekdays = localeWeekdays;
  9298. proto$1.weekdaysMin = localeWeekdaysMin;
  9299. proto$1.weekdaysShort = localeWeekdaysShort;
  9300. proto$1.weekdaysParse = localeWeekdaysParse;
  9301. proto$1.weekdaysRegex = weekdaysRegex;
  9302. proto$1.weekdaysShortRegex = weekdaysShortRegex;
  9303. proto$1.weekdaysMinRegex = weekdaysMinRegex;
  9304. proto$1.isPM = localeIsPM;
  9305. proto$1.meridiem = localeMeridiem;
  9306. function get$1(format, index, field, setter) {
  9307. var locale = getLocale(),
  9308. utc = createUTC().set(setter, index);
  9309. return locale[field](utc, format);
  9310. }
  9311. function listMonthsImpl(format, index, field) {
  9312. if (isNumber(format)) {
  9313. index = format;
  9314. format = undefined;
  9315. }
  9316. format = format || '';
  9317. if (index != null) {
  9318. return get$1(format, index, field, 'month');
  9319. }
  9320. var i,
  9321. out = [];
  9322. for (i = 0; i < 12; i++) {
  9323. out[i] = get$1(format, i, field, 'month');
  9324. }
  9325. return out;
  9326. }
  9327. // ()
  9328. // (5)
  9329. // (fmt, 5)
  9330. // (fmt)
  9331. // (true)
  9332. // (true, 5)
  9333. // (true, fmt, 5)
  9334. // (true, fmt)
  9335. function listWeekdaysImpl(localeSorted, format, index, field) {
  9336. if (typeof localeSorted === 'boolean') {
  9337. if (isNumber(format)) {
  9338. index = format;
  9339. format = undefined;
  9340. }
  9341. format = format || '';
  9342. } else {
  9343. format = localeSorted;
  9344. index = format;
  9345. localeSorted = false;
  9346. if (isNumber(format)) {
  9347. index = format;
  9348. format = undefined;
  9349. }
  9350. format = format || '';
  9351. }
  9352. var locale = getLocale(),
  9353. shift = localeSorted ? locale._week.dow : 0,
  9354. i,
  9355. out = [];
  9356. if (index != null) {
  9357. return get$1(format, (index + shift) % 7, field, 'day');
  9358. }
  9359. for (i = 0; i < 7; i++) {
  9360. out[i] = get$1(format, (i + shift) % 7, field, 'day');
  9361. }
  9362. return out;
  9363. }
  9364. function listMonths(format, index) {
  9365. return listMonthsImpl(format, index, 'months');
  9366. }
  9367. function listMonthsShort(format, index) {
  9368. return listMonthsImpl(format, index, 'monthsShort');
  9369. }
  9370. function listWeekdays(localeSorted, format, index) {
  9371. return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
  9372. }
  9373. function listWeekdaysShort(localeSorted, format, index) {
  9374. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
  9375. }
  9376. function listWeekdaysMin(localeSorted, format, index) {
  9377. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
  9378. }
  9379. getSetGlobalLocale('en', {
  9380. eras: [
  9381. {
  9382. since: '0001-01-01',
  9383. until: +Infinity,
  9384. offset: 1,
  9385. name: 'Anno Domini',
  9386. narrow: 'AD',
  9387. abbr: 'AD',
  9388. },
  9389. {
  9390. since: '0000-12-31',
  9391. until: -Infinity,
  9392. offset: 1,
  9393. name: 'Before Christ',
  9394. narrow: 'BC',
  9395. abbr: 'BC',
  9396. },
  9397. ],
  9398. dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
  9399. ordinal: function (number) {
  9400. var b = number % 10,
  9401. output =
  9402. toInt((number % 100) / 10) === 1
  9403. ? 'th'
  9404. : b === 1
  9405. ? 'st'
  9406. : b === 2
  9407. ? 'nd'
  9408. : b === 3
  9409. ? 'rd'
  9410. : 'th';
  9411. return number + output;
  9412. },
  9413. });
  9414. // Side effect imports
  9415. hooks.lang = deprecate(
  9416. 'moment.lang is deprecated. Use moment.locale instead.',
  9417. getSetGlobalLocale
  9418. );
  9419. hooks.langData = deprecate(
  9420. 'moment.langData is deprecated. Use moment.localeData instead.',
  9421. getLocale
  9422. );
  9423. var mathAbs = Math.abs;
  9424. function abs() {
  9425. var data = this._data;
  9426. this._milliseconds = mathAbs(this._milliseconds);
  9427. this._days = mathAbs(this._days);
  9428. this._months = mathAbs(this._months);
  9429. data.milliseconds = mathAbs(data.milliseconds);
  9430. data.seconds = mathAbs(data.seconds);
  9431. data.minutes = mathAbs(data.minutes);
  9432. data.hours = mathAbs(data.hours);
  9433. data.months = mathAbs(data.months);
  9434. data.years = mathAbs(data.years);
  9435. return this;
  9436. }
  9437. function addSubtract$1(duration, input, value, direction) {
  9438. var other = createDuration(input, value);
  9439. duration._milliseconds += direction * other._milliseconds;
  9440. duration._days += direction * other._days;
  9441. duration._months += direction * other._months;
  9442. return duration._bubble();
  9443. }
  9444. // supports only 2.0-style add(1, 's') or add(duration)
  9445. function add$1(input, value) {
  9446. return addSubtract$1(this, input, value, 1);
  9447. }
  9448. // supports only 2.0-style subtract(1, 's') or subtract(duration)
  9449. function subtract$1(input, value) {
  9450. return addSubtract$1(this, input, value, -1);
  9451. }
  9452. function absCeil(number) {
  9453. if (number < 0) {
  9454. return Math.floor(number);
  9455. } else {
  9456. return Math.ceil(number);
  9457. }
  9458. }
  9459. function bubble() {
  9460. var milliseconds = this._milliseconds,
  9461. days = this._days,
  9462. months = this._months,
  9463. data = this._data,
  9464. seconds,
  9465. minutes,
  9466. hours,
  9467. years,
  9468. monthsFromDays;
  9469. // if we have a mix of positive and negative values, bubble down first
  9470. // check: https://github.com/moment/moment/issues/2166
  9471. if (
  9472. !(
  9473. (milliseconds >= 0 && days >= 0 && months >= 0) ||
  9474. (milliseconds <= 0 && days <= 0 && months <= 0)
  9475. )
  9476. ) {
  9477. milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
  9478. days = 0;
  9479. months = 0;
  9480. }
  9481. // The following code bubbles up values, see the tests for
  9482. // examples of what that means.
  9483. data.milliseconds = milliseconds % 1000;
  9484. seconds = absFloor(milliseconds / 1000);
  9485. data.seconds = seconds % 60;
  9486. minutes = absFloor(seconds / 60);
  9487. data.minutes = minutes % 60;
  9488. hours = absFloor(minutes / 60);
  9489. data.hours = hours % 24;
  9490. days += absFloor(hours / 24);
  9491. // convert days to months
  9492. monthsFromDays = absFloor(daysToMonths(days));
  9493. months += monthsFromDays;
  9494. days -= absCeil(monthsToDays(monthsFromDays));
  9495. // 12 months -> 1 year
  9496. years = absFloor(months / 12);
  9497. months %= 12;
  9498. data.days = days;
  9499. data.months = months;
  9500. data.years = years;
  9501. return this;
  9502. }
  9503. function daysToMonths(days) {
  9504. // 400 years have 146097 days (taking into account leap year rules)
  9505. // 400 years have 12 months === 4800
  9506. return (days * 4800) / 146097;
  9507. }
  9508. function monthsToDays(months) {
  9509. // the reverse of daysToMonths
  9510. return (months * 146097) / 4800;
  9511. }
  9512. function as(units) {
  9513. if (!this.isValid()) {
  9514. return NaN;
  9515. }
  9516. var days,
  9517. months,
  9518. milliseconds = this._milliseconds;
  9519. units = normalizeUnits(units);
  9520. if (units === 'month' || units === 'quarter' || units === 'year') {
  9521. days = this._days + milliseconds / 864e5;
  9522. months = this._months + daysToMonths(days);
  9523. switch (units) {
  9524. case 'month':
  9525. return months;
  9526. case 'quarter':
  9527. return months / 3;
  9528. case 'year':
  9529. return months / 12;
  9530. }
  9531. } else {
  9532. // handle milliseconds separately because of floating point math errors (issue #1867)
  9533. days = this._days + Math.round(monthsToDays(this._months));
  9534. switch (units) {
  9535. case 'week':
  9536. return days / 7 + milliseconds / 6048e5;
  9537. case 'day':
  9538. return days + milliseconds / 864e5;
  9539. case 'hour':
  9540. return days * 24 + milliseconds / 36e5;
  9541. case 'minute':
  9542. return days * 1440 + milliseconds / 6e4;
  9543. case 'second':
  9544. return days * 86400 + milliseconds / 1000;
  9545. // Math.floor prevents floating point math errors here
  9546. case 'millisecond':
  9547. return Math.floor(days * 864e5) + milliseconds;
  9548. default:
  9549. throw new Error('Unknown unit ' + units);
  9550. }
  9551. }
  9552. }
  9553. // TODO: Use this.as('ms')?
  9554. function valueOf$1() {
  9555. if (!this.isValid()) {
  9556. return NaN;
  9557. }
  9558. return (
  9559. this._milliseconds +
  9560. this._days * 864e5 +
  9561. (this._months % 12) * 2592e6 +
  9562. toInt(this._months / 12) * 31536e6
  9563. );
  9564. }
  9565. function makeAs(alias) {
  9566. return function () {
  9567. return this.as(alias);
  9568. };
  9569. }
  9570. var asMilliseconds = makeAs('ms'),
  9571. asSeconds = makeAs('s'),
  9572. asMinutes = makeAs('m'),
  9573. asHours = makeAs('h'),
  9574. asDays = makeAs('d'),
  9575. asWeeks = makeAs('w'),
  9576. asMonths = makeAs('M'),
  9577. asQuarters = makeAs('Q'),
  9578. asYears = makeAs('y');
  9579. function clone$1() {
  9580. return createDuration(this);
  9581. }
  9582. function get$2(units) {
  9583. units = normalizeUnits(units);
  9584. return this.isValid() ? this[units + 's']() : NaN;
  9585. }
  9586. function makeGetter(name) {
  9587. return function () {
  9588. return this.isValid() ? this._data[name] : NaN;
  9589. };
  9590. }
  9591. var milliseconds = makeGetter('milliseconds'),
  9592. seconds = makeGetter('seconds'),
  9593. minutes = makeGetter('minutes'),
  9594. hours = makeGetter('hours'),
  9595. days = makeGetter('days'),
  9596. months = makeGetter('months'),
  9597. years = makeGetter('years');
  9598. function weeks() {
  9599. return absFloor(this.days() / 7);
  9600. }
  9601. var round = Math.round,
  9602. thresholds = {
  9603. ss: 44, // a few seconds to seconds
  9604. s: 45, // seconds to minute
  9605. m: 45, // minutes to hour
  9606. h: 22, // hours to day
  9607. d: 26, // days to month/week
  9608. w: null, // weeks to month
  9609. M: 11, // months to year
  9610. };
  9611. // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
  9612. function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
  9613. return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
  9614. }
  9615. function relativeTime$1(posNegDuration, withoutSuffix, thresholds, locale) {
  9616. var duration = createDuration(posNegDuration).abs(),
  9617. seconds = round(duration.as('s')),
  9618. minutes = round(duration.as('m')),
  9619. hours = round(duration.as('h')),
  9620. days = round(duration.as('d')),
  9621. months = round(duration.as('M')),
  9622. weeks = round(duration.as('w')),
  9623. years = round(duration.as('y')),
  9624. a =
  9625. (seconds <= thresholds.ss && ['s', seconds]) ||
  9626. (seconds < thresholds.s && ['ss', seconds]) ||
  9627. (minutes <= 1 && ['m']) ||
  9628. (minutes < thresholds.m && ['mm', minutes]) ||
  9629. (hours <= 1 && ['h']) ||
  9630. (hours < thresholds.h && ['hh', hours]) ||
  9631. (days <= 1 && ['d']) ||
  9632. (days < thresholds.d && ['dd', days]);
  9633. if (thresholds.w != null) {
  9634. a =
  9635. a ||
  9636. (weeks <= 1 && ['w']) ||
  9637. (weeks < thresholds.w && ['ww', weeks]);
  9638. }
  9639. a = a ||
  9640. (months <= 1 && ['M']) ||
  9641. (months < thresholds.M && ['MM', months]) ||
  9642. (years <= 1 && ['y']) || ['yy', years];
  9643. a[2] = withoutSuffix;
  9644. a[3] = +posNegDuration > 0;
  9645. a[4] = locale;
  9646. return substituteTimeAgo.apply(null, a);
  9647. }
  9648. // This function allows you to set the rounding function for relative time strings
  9649. function getSetRelativeTimeRounding(roundingFunction) {
  9650. if (roundingFunction === undefined) {
  9651. return round;
  9652. }
  9653. if (typeof roundingFunction === 'function') {
  9654. round = roundingFunction;
  9655. return true;
  9656. }
  9657. return false;
  9658. }
  9659. // This function allows you to set a threshold for relative time strings
  9660. function getSetRelativeTimeThreshold(threshold, limit) {
  9661. if (thresholds[threshold] === undefined) {
  9662. return false;
  9663. }
  9664. if (limit === undefined) {
  9665. return thresholds[threshold];
  9666. }
  9667. thresholds[threshold] = limit;
  9668. if (threshold === 's') {
  9669. thresholds.ss = limit - 1;
  9670. }
  9671. return true;
  9672. }
  9673. function humanize(argWithSuffix, argThresholds) {
  9674. if (!this.isValid()) {
  9675. return this.localeData().invalidDate();
  9676. }
  9677. var withSuffix = false,
  9678. th = thresholds,
  9679. locale,
  9680. output;
  9681. if (typeof argWithSuffix === 'object') {
  9682. argThresholds = argWithSuffix;
  9683. argWithSuffix = false;
  9684. }
  9685. if (typeof argWithSuffix === 'boolean') {
  9686. withSuffix = argWithSuffix;
  9687. }
  9688. if (typeof argThresholds === 'object') {
  9689. th = Object.assign({}, thresholds, argThresholds);
  9690. if (argThresholds.s != null && argThresholds.ss == null) {
  9691. th.ss = argThresholds.s - 1;
  9692. }
  9693. }
  9694. locale = this.localeData();
  9695. output = relativeTime$1(this, !withSuffix, th, locale);
  9696. if (withSuffix) {
  9697. output = locale.pastFuture(+this, output);
  9698. }
  9699. return locale.postformat(output);
  9700. }
  9701. var abs$1 = Math.abs;
  9702. function sign(x) {
  9703. return (x > 0) - (x < 0) || +x;
  9704. }
  9705. function toISOString$1() {
  9706. // for ISO strings we do not use the normal bubbling rules:
  9707. // * milliseconds bubble up until they become hours
  9708. // * days do not bubble at all
  9709. // * months bubble up until they become years
  9710. // This is because there is no context-free conversion between hours and days
  9711. // (think of clock changes)
  9712. // and also not between days and months (28-31 days per month)
  9713. if (!this.isValid()) {
  9714. return this.localeData().invalidDate();
  9715. }
  9716. var seconds = abs$1(this._milliseconds) / 1000,
  9717. days = abs$1(this._days),
  9718. months = abs$1(this._months),
  9719. minutes,
  9720. hours,
  9721. years,
  9722. s,
  9723. total = this.asSeconds(),
  9724. totalSign,
  9725. ymSign,
  9726. daysSign,
  9727. hmsSign;
  9728. if (!total) {
  9729. // this is the same as C#'s (Noda) and python (isodate)...
  9730. // but not other JS (goog.date)
  9731. return 'P0D';
  9732. }
  9733. // 3600 seconds -> 60 minutes -> 1 hour
  9734. minutes = absFloor(seconds / 60);
  9735. hours = absFloor(minutes / 60);
  9736. seconds %= 60;
  9737. minutes %= 60;
  9738. // 12 months -> 1 year
  9739. years = absFloor(months / 12);
  9740. months %= 12;
  9741. // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
  9742. s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : '';
  9743. totalSign = total < 0 ? '-' : '';
  9744. ymSign = sign(this._months) !== sign(total) ? '-' : '';
  9745. daysSign = sign(this._days) !== sign(total) ? '-' : '';
  9746. hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : '';
  9747. return (
  9748. totalSign +
  9749. 'P' +
  9750. (years ? ymSign + years + 'Y' : '') +
  9751. (months ? ymSign + months + 'M' : '') +
  9752. (days ? daysSign + days + 'D' : '') +
  9753. (hours || minutes || seconds ? 'T' : '') +
  9754. (hours ? hmsSign + hours + 'H' : '') +
  9755. (minutes ? hmsSign + minutes + 'M' : '') +
  9756. (seconds ? hmsSign + s + 'S' : '')
  9757. );
  9758. }
  9759. var proto$2 = Duration.prototype;
  9760. proto$2.isValid = isValid$1;
  9761. proto$2.abs = abs;
  9762. proto$2.add = add$1;
  9763. proto$2.subtract = subtract$1;
  9764. proto$2.as = as;
  9765. proto$2.asMilliseconds = asMilliseconds;
  9766. proto$2.asSeconds = asSeconds;
  9767. proto$2.asMinutes = asMinutes;
  9768. proto$2.asHours = asHours;
  9769. proto$2.asDays = asDays;
  9770. proto$2.asWeeks = asWeeks;
  9771. proto$2.asMonths = asMonths;
  9772. proto$2.asQuarters = asQuarters;
  9773. proto$2.asYears = asYears;
  9774. proto$2.valueOf = valueOf$1;
  9775. proto$2._bubble = bubble;
  9776. proto$2.clone = clone$1;
  9777. proto$2.get = get$2;
  9778. proto$2.milliseconds = milliseconds;
  9779. proto$2.seconds = seconds;
  9780. proto$2.minutes = minutes;
  9781. proto$2.hours = hours;
  9782. proto$2.days = days;
  9783. proto$2.weeks = weeks;
  9784. proto$2.months = months;
  9785. proto$2.years = years;
  9786. proto$2.humanize = humanize;
  9787. proto$2.toISOString = toISOString$1;
  9788. proto$2.toString = toISOString$1;
  9789. proto$2.toJSON = toISOString$1;
  9790. proto$2.locale = locale;
  9791. proto$2.localeData = localeData;
  9792. proto$2.toIsoString = deprecate(
  9793. 'toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)',
  9794. toISOString$1
  9795. );
  9796. proto$2.lang = lang;
  9797. // FORMATTING
  9798. addFormatToken('X', 0, 0, 'unix');
  9799. addFormatToken('x', 0, 0, 'valueOf');
  9800. // PARSING
  9801. addRegexToken('x', matchSigned);
  9802. addRegexToken('X', matchTimestamp);
  9803. addParseToken('X', function (input, array, config) {
  9804. config._d = new Date(parseFloat(input) * 1000);
  9805. });
  9806. addParseToken('x', function (input, array, config) {
  9807. config._d = new Date(toInt(input));
  9808. });
  9809. //! moment.js
  9810. hooks.version = '2.29.1';
  9811. setHookCallback(createLocal);
  9812. hooks.fn = proto;
  9813. hooks.min = min;
  9814. hooks.max = max;
  9815. hooks.now = now;
  9816. hooks.utc = createUTC;
  9817. hooks.unix = createUnix;
  9818. hooks.months = listMonths;
  9819. hooks.isDate = isDate;
  9820. hooks.locale = getSetGlobalLocale;
  9821. hooks.invalid = createInvalid;
  9822. hooks.duration = createDuration;
  9823. hooks.isMoment = isMoment;
  9824. hooks.weekdays = listWeekdays;
  9825. hooks.parseZone = createInZone;
  9826. hooks.localeData = getLocale;
  9827. hooks.isDuration = isDuration;
  9828. hooks.monthsShort = listMonthsShort;
  9829. hooks.weekdaysMin = listWeekdaysMin;
  9830. hooks.defineLocale = defineLocale;
  9831. hooks.updateLocale = updateLocale;
  9832. hooks.locales = listLocales;
  9833. hooks.weekdaysShort = listWeekdaysShort;
  9834. hooks.normalizeUnits = normalizeUnits;
  9835. hooks.relativeTimeRounding = getSetRelativeTimeRounding;
  9836. hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
  9837. hooks.calendarFormat = getCalendarFormat;
  9838. hooks.prototype = proto;
  9839. // currently HTML5 input type only supports 24-hour formats
  9840. hooks.HTML5_FMT = {
  9841. DATETIME_LOCAL: 'YYYY-MM-DDTHH:mm', // <input type="datetime-local" />
  9842. DATETIME_LOCAL_SECONDS: 'YYYY-MM-DDTHH:mm:ss', // <input type="datetime-local" step="1" />
  9843. DATETIME_LOCAL_MS: 'YYYY-MM-DDTHH:mm:ss.SSS', // <input type="datetime-local" step="0.001" />
  9844. DATE: 'YYYY-MM-DD', // <input type="date" />
  9845. TIME: 'HH:mm', // <input type="time" />
  9846. TIME_SECONDS: 'HH:mm:ss', // <input type="time" step="1" />
  9847. TIME_MS: 'HH:mm:ss.SSS', // <input type="time" step="0.001" />
  9848. WEEK: 'GGGG-[W]WW', // <input type="week" />
  9849. MONTH: 'YYYY-MM', // <input type="month" />
  9850. };
  9851. return hooks;
  9852. })));
  9853. define('moment', ['moment/moment'], function (main) {
  9854. return main;
  9855. });
  9856. define('backend', ['fast', 'template', 'moment'], function (Fast, Template, Moment) {
  9857. var Backend = {
  9858. api: {
  9859. sidebar: function (params) {
  9860. colorArr = ['red', 'green', 'yellow', 'blue', 'teal', 'orange', 'purple'];
  9861. $colorNums = colorArr.length;
  9862. badgeList = {};
  9863. $.each(params, function (k, v) {
  9864. $url = Fast.api.fixurl(k);
  9865. if ($.isArray(v)) {
  9866. $nums = typeof v[0] !== 'undefined' ? v[0] : 0;
  9867. $color = typeof v[1] !== 'undefined' ? v[1] : colorArr[(!isNaN($nums) ? $nums : $nums.length) % $colorNums];
  9868. $class = typeof v[2] !== 'undefined' ? v[2] : 'label';
  9869. } else {
  9870. $nums = v;
  9871. $color = colorArr[(!isNaN($nums) ? $nums : $nums.length) % $colorNums];
  9872. $class = 'label';
  9873. }
  9874. //必须nums大于0才显示
  9875. badgeList[$url] = $nums > 0 ? '<small class="' + $class + ' pull-right bg-' + $color + '">' + $nums + '</small>' : '';
  9876. });
  9877. $.each(badgeList, function (k, v) {
  9878. var anchor = top.window.$("li a[addtabs][url='" + k + "']");
  9879. if (anchor) {
  9880. top.window.$(".pull-right-container", anchor).html(v);
  9881. top.window.$(".nav-addtabs li a[node-id='" + anchor.attr("addtabs") + "'] .pull-right-container").html(v);
  9882. }
  9883. });
  9884. },
  9885. addtabs: function (url, title, icon) {
  9886. var dom = "a[url='{url}']"
  9887. var leftlink = top.window.$(dom.replace(/\{url\}/, url));
  9888. if (leftlink.size() > 0) {
  9889. leftlink.trigger("click");
  9890. } else {
  9891. url = Fast.api.fixurl(url);
  9892. leftlink = top.window.$(dom.replace(/\{url\}/, url));
  9893. if (leftlink.size() > 0) {
  9894. var event = leftlink.parent().hasClass("active") ? "dblclick" : "click";
  9895. leftlink.trigger(event);
  9896. } else {
  9897. var baseurl = url.substr(0, url.indexOf("?") > -1 ? url.indexOf("?") : url.length);
  9898. leftlink = top.window.$(dom.replace(/\{url\}/, baseurl));
  9899. //能找到相对地址
  9900. if (leftlink.size() > 0) {
  9901. icon = typeof icon !== 'undefined' ? icon : leftlink.find("i").attr("class");
  9902. title = typeof title !== 'undefined' ? title : leftlink.find("span:first").text();
  9903. leftlink.trigger("fa.event.toggleitem");
  9904. }
  9905. var navnode = top.window.$(".nav-tabs ul li a[node-url='" + url + "']");
  9906. if (navnode.size() > 0) {
  9907. navnode.trigger("click");
  9908. } else {
  9909. //追加新的tab
  9910. var id = Math.floor(new Date().valueOf() * Math.random());
  9911. icon = typeof icon !== 'undefined' ? icon : 'fa fa-circle-o';
  9912. title = typeof title !== 'undefined' ? title : '';
  9913. top.window.$("<a />").append('<i class="' + icon + '"></i> <span>' + title + '</span>').prop("href", url).attr({
  9914. url: url,
  9915. addtabs: id
  9916. }).addClass("hide").appendTo(top.window.document.body).trigger("click");
  9917. }
  9918. }
  9919. }
  9920. },
  9921. closetabs: function (url) {
  9922. if (typeof url === 'undefined') {
  9923. top.window.$("ul.nav-addtabs li.active .close-tab").trigger("click");
  9924. } else {
  9925. var dom = "a[url='{url}']"
  9926. var navlink = top.window.$(dom.replace(/\{url\}/, url));
  9927. if (navlink.size() === 0) {
  9928. url = Fast.api.fixurl(url);
  9929. navlink = top.window.$(dom.replace(/\{url\}/, url));
  9930. if (navlink.size() === 0) {
  9931. } else {
  9932. var baseurl = url.substr(0, url.indexOf("?") > -1 ? url.indexOf("?") : url.length);
  9933. navlink = top.window.$(dom.replace(/\{url\}/, baseurl));
  9934. //能找到相对地址
  9935. if (navlink.size() === 0) {
  9936. navlink = top.window.$(".nav-tabs ul li a[node-url='" + url + "']");
  9937. }
  9938. }
  9939. }
  9940. if (navlink.size() > 0 && navlink.attr('addtabs')) {
  9941. top.window.$("ul.nav-addtabs li#tab_" + navlink.attr('addtabs') + " .close-tab").trigger("click");
  9942. }
  9943. }
  9944. },
  9945. replaceids: function (elem, url) {
  9946. //如果有需要替换ids的
  9947. if (url.indexOf("{ids}") > -1) {
  9948. var ids = 0;
  9949. var tableId = $(elem).data("table-id");
  9950. if (tableId && $("#" + tableId).size() > 0 && $("#" + tableId).data("bootstrap.table")) {
  9951. var Table = require("table");
  9952. ids = Table.api.selectedids($("#" + tableId)).join(",");
  9953. }
  9954. url = url.replace(/\{ids\}/g, ids);
  9955. }
  9956. return url;
  9957. },
  9958. refreshmenu: function () {
  9959. top.window.$(".sidebar-menu").trigger("refresh");
  9960. },
  9961. gettablecolumnbutton: function (options) {
  9962. if (typeof options.tableId !== 'undefined' && typeof options.fieldIndex !== 'undefined' && typeof options.buttonIndex !== 'undefined') {
  9963. var tableOptions = $("#" + options.tableId).bootstrapTable('getOptions');
  9964. if (tableOptions) {
  9965. var columnObj = null;
  9966. $.each(tableOptions.columns, function (i, columns) {
  9967. $.each(columns, function (j, column) {
  9968. if (typeof column.fieldIndex !== 'undefined' && column.fieldIndex === options.fieldIndex) {
  9969. columnObj = column;
  9970. return false;
  9971. }
  9972. });
  9973. if (columnObj) {
  9974. return false;
  9975. }
  9976. });
  9977. if (columnObj) {
  9978. return columnObj['buttons'][options.buttonIndex];
  9979. }
  9980. }
  9981. }
  9982. return null;
  9983. },
  9984. },
  9985. init: function () {
  9986. //公共代码
  9987. //添加ios-fix兼容iOS下的iframe
  9988. if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
  9989. $("html").addClass("ios-fix");
  9990. }
  9991. //配置Toastr的参数
  9992. Toastr.options.positionClass = Config.controllername === 'index' ? "toast-top-right-index" : "toast-top-right";
  9993. //点击包含.btn-dialog的元素时弹出dialog
  9994. $(document).on('click', '.btn-dialog,.dialogit', function (e) {
  9995. var that = this;
  9996. var options = $.extend({}, $(that).data() || {});
  9997. var url = Backend.api.replaceids(that, $(that).data("url") || $(that).attr('href'));
  9998. var title = $(that).attr("title") || $(that).data("title") || $(that).data('original-title');
  9999. var button = Backend.api.gettablecolumnbutton(options);
  10000. if (button && typeof button.callback === 'function') {
  10001. options.callback = button.callback;
  10002. }
  10003. if (typeof options.confirm !== 'undefined') {
  10004. Layer.confirm(options.confirm, function (index) {
  10005. Backend.api.open(url, title, options);
  10006. Layer.close(index);
  10007. });
  10008. } else {
  10009. window[$(that).data("window") || 'self'].Backend.api.open(url, title, options);
  10010. }
  10011. return false;
  10012. });
  10013. //点击包含.btn-addtabs的元素时新增选项卡
  10014. $(document).on('click', '.btn-addtabs,.addtabsit', function (e) {
  10015. var that = this;
  10016. var options = $.extend({}, $(that).data() || {});
  10017. var url = Backend.api.replaceids(that, $(that).data("url") || $(that).attr('href'));
  10018. var title = $(that).attr("title") || $(that).data("title") || $(that).data('original-title');
  10019. var icon = $(that).attr("icon") || $(that).data("icon");
  10020. if (typeof options.confirm !== 'undefined') {
  10021. Layer.confirm(options.confirm, function (index) {
  10022. Backend.api.addtabs(url, title, icon);
  10023. Layer.close(index);
  10024. });
  10025. } else {
  10026. Backend.api.addtabs(url, title, icon);
  10027. }
  10028. return false;
  10029. });
  10030. //点击包含.btn-ajax的元素时发送Ajax请求
  10031. $(document).on('click', '.btn-ajax,.ajaxit', function (e) {
  10032. var that = this;
  10033. var options = $.extend({}, $(that).data() || {});
  10034. if (typeof options.url === 'undefined' && $(that).attr("href")) {
  10035. options.url = $(that).attr("href");
  10036. }
  10037. options.url = Backend.api.replaceids(this, options.url);
  10038. var success = typeof options.success === 'function' ? options.success : null;
  10039. var error = typeof options.error === 'function' ? options.error : null;
  10040. delete options.success;
  10041. delete options.error;
  10042. var button = Backend.api.gettablecolumnbutton(options);
  10043. if (button) {
  10044. if (typeof button.success === 'function') {
  10045. success = button.success;
  10046. }
  10047. if (typeof button.error === 'function') {
  10048. error = button.error;
  10049. }
  10050. }
  10051. //如果未设备成功的回调,设定了自动刷新的情况下自动进行刷新
  10052. if (!success && typeof options.tableId !== 'undefined' && typeof options.refresh !== 'undefined' && options.refresh) {
  10053. success = function () {
  10054. $("#" + options.tableId).bootstrapTable('refresh');
  10055. }
  10056. }
  10057. if (typeof options.confirm !== 'undefined') {
  10058. Layer.confirm(options.confirm, function (index) {
  10059. Backend.api.ajax(options, success, error);
  10060. Layer.close(index);
  10061. });
  10062. } else {
  10063. Backend.api.ajax(options, success, error);
  10064. }
  10065. return false;
  10066. });
  10067. $(document).on('click', '.btn-click,.clickit', function (e) {
  10068. var that = this;
  10069. var options = $.extend({}, $(that).data() || {});
  10070. var row = {};
  10071. if (typeof options.tableId !== 'undefined') {
  10072. var index = parseInt(options.rowIndex);
  10073. var data = $("#" + options.tableId).bootstrapTable('getData');
  10074. row = typeof data[index] !== 'undefined' ? data[index] : {};
  10075. }
  10076. var button = Backend.api.gettablecolumnbutton(options);
  10077. var click = typeof button.click === 'function' ? button.click : $.noop;
  10078. if (typeof options.confirm !== 'undefined') {
  10079. Layer.confirm(options.confirm, function (index) {
  10080. click.apply(that, [options, row, button]);
  10081. Layer.close(index);
  10082. });
  10083. } else {
  10084. click.apply(that, [options, row, button]);
  10085. }
  10086. return false;
  10087. });
  10088. //修复含有fixed-footer类的body边距
  10089. if ($(".fixed-footer").size() > 0) {
  10090. $(document.body).css("padding-bottom", $(".fixed-footer").outerHeight());
  10091. }
  10092. //修复不在iframe时layer-footer隐藏的问题
  10093. if ($(".layer-footer").size() > 0 && self === top) {
  10094. $(".layer-footer").show();
  10095. }
  10096. //tooltip和popover
  10097. if (!('ontouchstart' in document.documentElement)) {
  10098. $('body').tooltip({selector: '[data-toggle="tooltip"]'});
  10099. }
  10100. $('body').popover({selector: '[data-toggle="popover"]'});
  10101. }
  10102. };
  10103. Backend.api = $.extend(Fast.api, Backend.api);
  10104. //将Template渲染至全局,以便于在子框架中调用
  10105. window.Template = Template;
  10106. //将Moment渲染至全局,以便于在子框架中调用
  10107. window.Moment = Moment;
  10108. //将Backend渲染至全局,以便于在子框架中调用
  10109. window.Backend = Backend;
  10110. Backend.init();
  10111. return Backend;
  10112. });
  10113. define('backend-init', ['backend'], function (Backend) {
  10114. // Layer.config({focusBtn: false});
  10115. // Fast.config.openArea = ["100%", "100%"];
  10116. });
  10117. //! moment.js locale configuration
  10118. //! locale : Chinese (China) [zh-cn]
  10119. //! author : suupic : https://github.com/suupic
  10120. //! author : Zeno Zeng : https://github.com/zenozeng
  10121. //! author : uu109 : https://github.com/uu109
  10122. ;(function (global, factory) {
  10123. typeof exports === 'object' && typeof module !== 'undefined'
  10124. && typeof require === 'function' ? factory(require('../moment')) :
  10125. typeof define === 'function' && define.amd ? define('moment/locale/zh-cn', ['../moment'], factory) :
  10126. factory(global.moment)
  10127. }(this, (function (moment) {
  10128. 'use strict';
  10129. //! moment.js locale configuration
  10130. var zhCn = moment.defineLocale('zh-cn', {
  10131. months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split(
  10132. '_'
  10133. ),
  10134. monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split(
  10135. '_'
  10136. ),
  10137. weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
  10138. weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'),
  10139. weekdaysMin: '日_一_二_三_四_五_六'.split('_'),
  10140. longDateFormat: {
  10141. LT: 'HH:mm',
  10142. LTS: 'HH:mm:ss',
  10143. L: 'YYYY/MM/DD',
  10144. LL: 'YYYY年M月D日',
  10145. LLL: 'YYYY年M月D日Ah点mm分',
  10146. LLLL: 'YYYY年M月D日ddddAh点mm分',
  10147. l: 'YYYY/M/D',
  10148. ll: 'YYYY年M月D日',
  10149. lll: 'YYYY年M月D日 HH:mm',
  10150. llll: 'YYYY年M月D日dddd HH:mm',
  10151. },
  10152. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  10153. meridiemHour: function (hour, meridiem) {
  10154. if (hour === 12) {
  10155. hour = 0;
  10156. }
  10157. if (meridiem === '凌晨' || meridiem === '早上' || meridiem === '上午') {
  10158. return hour;
  10159. } else if (meridiem === '下午' || meridiem === '晚上') {
  10160. return hour + 12;
  10161. } else {
  10162. // '中午'
  10163. return hour >= 11 ? hour : hour + 12;
  10164. }
  10165. },
  10166. meridiem: function (hour, minute, isLower) {
  10167. var hm = hour * 100 + minute;
  10168. if (hm < 600) {
  10169. return '凌晨';
  10170. } else if (hm < 900) {
  10171. return '早上';
  10172. } else if (hm < 1130) {
  10173. return '上午';
  10174. } else if (hm < 1230) {
  10175. return '中午';
  10176. } else if (hm < 1800) {
  10177. return '下午';
  10178. } else {
  10179. return '晚上';
  10180. }
  10181. },
  10182. calendar: {
  10183. sameDay: '[今天]LT',
  10184. nextDay: '[明天]LT',
  10185. nextWeek: function (now) {
  10186. if (now.week() !== this.week()) {
  10187. return '[下]dddLT';
  10188. } else {
  10189. return '[本]dddLT';
  10190. }
  10191. },
  10192. lastDay: '[昨天]LT',
  10193. lastWeek: function (now) {
  10194. if (this.week() !== now.week()) {
  10195. return '[上]dddLT';
  10196. } else {
  10197. return '[本]dddLT';
  10198. }
  10199. },
  10200. sameElse: 'L',
  10201. },
  10202. dayOfMonthOrdinalParse: /\d{1,2}(日|月|周)/,
  10203. ordinal: function (number, period) {
  10204. switch (period) {
  10205. case 'd':
  10206. case 'D':
  10207. case 'DDD':
  10208. return number + '日';
  10209. case 'M':
  10210. return number + '月';
  10211. case 'w':
  10212. case 'W':
  10213. return number + '周';
  10214. default:
  10215. return number;
  10216. }
  10217. },
  10218. relativeTime: {
  10219. future: '%s后',
  10220. past: '%s前',
  10221. s: '几秒',
  10222. ss: '%d 秒',
  10223. m: '1 分钟',
  10224. mm: '%d 分钟',
  10225. h: '1 小时',
  10226. hh: '%d 小时',
  10227. d: '1 天',
  10228. dd: '%d 天',
  10229. w: '1 周',
  10230. ww: '%d 周',
  10231. M: '1 个月',
  10232. MM: '%d 个月',
  10233. y: '1 年',
  10234. yy: '%d 年',
  10235. },
  10236. week: {
  10237. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  10238. dow: 1, // Monday is the first day of the week.
  10239. doy: 4, // The week that contains Jan 4th is the first week of the year.
  10240. },
  10241. });
  10242. return zhCn;
  10243. })));
  10244. (function ($) {
  10245. "use strict";
  10246. var cachedWidth = null;
  10247. var sprintf = function (str) {
  10248. var args = arguments, flag = true, i = 1;
  10249. str = str.replace(/%s/g, function () {
  10250. var arg = args[i++];
  10251. if (typeof arg === "undefined") {
  10252. flag = false;
  10253. return ""
  10254. }
  10255. return arg
  10256. });
  10257. return flag ? str : ""
  10258. };
  10259. var getPropertyFromOther = function (list, from, to, value) {
  10260. var result = "";
  10261. $.each(list, function (i, item) {
  10262. if (item[from] === value) {
  10263. result = item[to];
  10264. return false
  10265. }
  10266. return true
  10267. });
  10268. return result
  10269. };
  10270. var getFieldIndex = function (columns, field) {
  10271. var index = -1;
  10272. $.each(columns, function (i, column) {
  10273. if (column.field === field) {
  10274. index = i;
  10275. return false
  10276. }
  10277. return true
  10278. });
  10279. return index
  10280. };
  10281. var setFieldIndex = function (columns) {
  10282. var i, j, k, totalCol = 0, flag = [];
  10283. for (i = 0; i < columns[0].length; i++) {
  10284. totalCol += columns[0][i].colspan || 1
  10285. }
  10286. for (i = 0; i < columns.length; i++) {
  10287. flag[i] = [];
  10288. for (j = 0; j < totalCol; j++) {
  10289. flag[i][j] = false
  10290. }
  10291. }
  10292. for (i = 0; i < columns.length; i++) {
  10293. for (j = 0; j < columns[i].length; j++) {
  10294. var r = columns[i][j], rowspan = r.rowspan || 1, colspan = r.colspan || 1,
  10295. index = $.inArray(false, flag[i]);
  10296. if (colspan === 1) {
  10297. r.fieldIndex = index;
  10298. if (typeof r.field === "undefined") {
  10299. r.field = index
  10300. }
  10301. }
  10302. for (k = 0; k < rowspan; k++) {
  10303. flag[i + k][index] = true
  10304. }
  10305. for (k = 0; k < colspan; k++) {
  10306. flag[i][index + k] = true
  10307. }
  10308. }
  10309. }
  10310. };
  10311. var getScrollBarWidth = function () {
  10312. if (cachedWidth === null) {
  10313. var inner = $("<p/>").addClass("fixed-table-scroll-inner"),
  10314. outer = $("<div/>").addClass("fixed-table-scroll-outer"), w1, w2;
  10315. outer.append(inner);
  10316. $("body").append(outer);
  10317. w1 = inner[0].offsetWidth;
  10318. outer.css("overflow", "scroll");
  10319. w2 = inner[0].offsetWidth;
  10320. if (w1 === w2) {
  10321. w2 = outer[0].clientWidth
  10322. }
  10323. outer.remove();
  10324. cachedWidth = w1 - w2
  10325. }
  10326. return cachedWidth
  10327. };
  10328. var calculateObjectValue = function (self, name, args, defaultValue) {
  10329. var func = name;
  10330. if (typeof name === "string") {
  10331. var names = name.split(".");
  10332. if (names.length > 1) {
  10333. func = window;
  10334. $.each(names, function (i, f) {
  10335. func = func[f]
  10336. })
  10337. } else {
  10338. func = window[name]
  10339. }
  10340. }
  10341. if (typeof func === "object") {
  10342. return func
  10343. }
  10344. if (typeof func === "function") {
  10345. return func.apply(self, args || [])
  10346. }
  10347. if (!func && typeof name === "string" && sprintf.apply(this, [name].concat(args))) {
  10348. return sprintf.apply(this, [name].concat(args))
  10349. }
  10350. return defaultValue
  10351. };
  10352. var compareObjects = function (objectA, objectB, compareLength) {
  10353. var objectAProperties = Object.getOwnPropertyNames(objectA),
  10354. objectBProperties = Object.getOwnPropertyNames(objectB), propName = "";
  10355. if (compareLength) {
  10356. if (objectAProperties.length !== objectBProperties.length) {
  10357. return false
  10358. }
  10359. }
  10360. for (var i = 0; i < objectAProperties.length; i++) {
  10361. propName = objectAProperties[i];
  10362. if ($.inArray(propName, objectBProperties) > -1) {
  10363. if (objectA[propName] !== objectB[propName]) {
  10364. return false
  10365. }
  10366. }
  10367. }
  10368. return true
  10369. };
  10370. var escapeHTML = function (text) {
  10371. if (typeof text === "string") {
  10372. return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;").replace(/`/g, "&#x60;")
  10373. }
  10374. return text
  10375. };
  10376. var getRealDataAttr = function (dataAttr) {
  10377. for (var attr in dataAttr) {
  10378. var auxAttr = attr.split(/(?=[A-Z])/).join("-").toLowerCase();
  10379. if (auxAttr !== attr) {
  10380. dataAttr[auxAttr] = dataAttr[attr];
  10381. delete dataAttr[attr]
  10382. }
  10383. }
  10384. return dataAttr
  10385. };
  10386. var getItemField = function (item, field, escape) {
  10387. var value = item;
  10388. if (typeof field !== "string" || item.hasOwnProperty(field)) {
  10389. return escape ? escapeHTML(item[field]) : item[field]
  10390. }
  10391. var props = field.split(".");
  10392. for (var p in props) {
  10393. if (props.hasOwnProperty(p)) {
  10394. value = value && value[props[p]]
  10395. }
  10396. }
  10397. return escape ? escapeHTML(value) : value
  10398. };
  10399. var isIEBrowser = function () {
  10400. return !!(navigator.userAgent.indexOf("MSIE ") > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))
  10401. };
  10402. var objectKeys = function () {
  10403. if (!Object.keys) {
  10404. Object.keys = function () {
  10405. var hasOwnProperty = Object.prototype.hasOwnProperty,
  10406. hasDontEnumBug = !{toString: null}.propertyIsEnumerable("toString"),
  10407. dontEnums = ["toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "constructor"],
  10408. dontEnumsLength = dontEnums.length;
  10409. return function (obj) {
  10410. if (typeof obj !== "object" && (typeof obj !== "function" || obj === null)) {
  10411. throw new TypeError("Object.keys called on non-object")
  10412. }
  10413. var result = [], prop, i;
  10414. for (prop in obj) {
  10415. if (hasOwnProperty.call(obj, prop)) {
  10416. result.push(prop)
  10417. }
  10418. }
  10419. if (hasDontEnumBug) {
  10420. for (i = 0; i < dontEnumsLength; i++) {
  10421. if (hasOwnProperty.call(obj, dontEnums[i])) {
  10422. result.push(dontEnums[i])
  10423. }
  10424. }
  10425. }
  10426. return result
  10427. }
  10428. }()
  10429. }
  10430. };
  10431. var BootstrapTable = function (el, options) {
  10432. this.options = options;
  10433. this.$el = $(el);
  10434. this.$el_ = this.$el.clone();
  10435. this.timeoutId_ = 0;
  10436. this.timeoutFooter_ = 0;
  10437. this.init()
  10438. };
  10439. BootstrapTable.DEFAULTS = {
  10440. classes: "table table-hover",
  10441. sortClass: undefined,
  10442. locale: undefined,
  10443. height: undefined,
  10444. undefinedText: "-",
  10445. sortName: undefined,
  10446. sortOrder: "asc",
  10447. sortStable: false,
  10448. striped: false,
  10449. columns: [[]],
  10450. data: [],
  10451. totalField: "total",
  10452. dataField: "rows",
  10453. method: "get",
  10454. url: undefined,
  10455. ajax: undefined,
  10456. cache: true,
  10457. contentType: "application/json",
  10458. dataType: "json",
  10459. ajaxOptions: {},
  10460. queryParams: function (params) {
  10461. return params
  10462. },
  10463. queryParamsType: "limit",
  10464. responseHandler: function (res) {
  10465. return res
  10466. },
  10467. pagination: false,
  10468. onlyInfoPagination: false,
  10469. paginationLoop: true,
  10470. sidePagination: "client",
  10471. totalRows: 0,
  10472. pageNumber: 1,
  10473. pageSize: 10,
  10474. pageList: [10, 25, 50, 100],
  10475. paginationHAlign: "right",
  10476. paginationVAlign: "bottom",
  10477. paginationDetailHAlign: "left",
  10478. paginationPreText: "&lsaquo;",
  10479. paginationNextText: "&rsaquo;",
  10480. search: false,
  10481. searchOnEnterKey: false,
  10482. strictSearch: false,
  10483. searchAlign: "right",
  10484. selectItemName: "btSelectItem",
  10485. showHeader: true,
  10486. showFooter: false,
  10487. showColumns: false,
  10488. showPaginationSwitch: false,
  10489. showRefresh: false,
  10490. showToggle: false,
  10491. buttonsAlign: "right",
  10492. smartDisplay: true,
  10493. escape: false,
  10494. minimumCountColumns: 1,
  10495. idField: undefined,
  10496. uniqueId: undefined,
  10497. cardView: false,
  10498. detailView: false,
  10499. detailFormatter: function (index, row) {
  10500. return ""
  10501. },
  10502. trimOnSearch: true,
  10503. clickToSelect: false,
  10504. singleSelect: false,
  10505. toolbar: undefined,
  10506. toolbarAlign: "left",
  10507. checkboxHeader: true,
  10508. sortable: true,
  10509. silentSort: true,
  10510. maintainSelected: false,
  10511. searchTimeOut: 500,
  10512. searchText: "",
  10513. iconSize: undefined,
  10514. buttonsClass: "default",
  10515. iconsPrefix: "glyphicon",
  10516. icons: {
  10517. paginationSwitchDown: "glyphicon-collapse-down icon-chevron-down",
  10518. paginationSwitchUp: "glyphicon-collapse-up icon-chevron-up",
  10519. refresh: "glyphicon-refresh icon-refresh",
  10520. toggle: "glyphicon-list-alt icon-list-alt",
  10521. columns: "glyphicon-th icon-th",
  10522. detailOpen: "glyphicon-plus icon-plus",
  10523. detailClose: "glyphicon-minus icon-minus"
  10524. },
  10525. customSearch: $.noop,
  10526. customSort: $.noop,
  10527. rowStyle: function (row, index) {
  10528. return {}
  10529. },
  10530. rowAttributes: function (row, index) {
  10531. return {}
  10532. },
  10533. footerStyle: function (row, index) {
  10534. return {}
  10535. },
  10536. onAll: function (name, args) {
  10537. return false
  10538. },
  10539. onClickCell: function (field, value, row, $element) {
  10540. return false
  10541. },
  10542. onDblClickCell: function (field, value, row, $element) {
  10543. return false
  10544. },
  10545. onClickRow: function (item, $element) {
  10546. return false
  10547. },
  10548. onDblClickRow: function (item, $element) {
  10549. return false
  10550. },
  10551. onSort: function (name, order) {
  10552. return false
  10553. },
  10554. onCheck: function (row) {
  10555. return false
  10556. },
  10557. onUncheck: function (row) {
  10558. return false
  10559. },
  10560. onCheckAll: function (rows) {
  10561. return false
  10562. },
  10563. onUncheckAll: function (rows) {
  10564. return false
  10565. },
  10566. onCheckSome: function (rows) {
  10567. return false
  10568. },
  10569. onUncheckSome: function (rows) {
  10570. return false
  10571. },
  10572. onLoadSuccess: function (data) {
  10573. return false
  10574. },
  10575. onLoadError: function (status) {
  10576. return false
  10577. },
  10578. onColumnSwitch: function (field, checked) {
  10579. return false
  10580. },
  10581. onPageChange: function (number, size) {
  10582. return false
  10583. },
  10584. onSearch: function (text) {
  10585. return false
  10586. },
  10587. onToggle: function (cardView) {
  10588. return false
  10589. },
  10590. onPreBody: function (data) {
  10591. return false
  10592. },
  10593. onPostBody: function () {
  10594. return false
  10595. },
  10596. onPostHeader: function () {
  10597. return false
  10598. },
  10599. onExpandRow: function (index, row, $detail) {
  10600. return false
  10601. },
  10602. onCollapseRow: function (index, row) {
  10603. return false
  10604. },
  10605. onRefreshOptions: function (options) {
  10606. return false
  10607. },
  10608. onRefresh: function (params) {
  10609. return false
  10610. },
  10611. onResetView: function () {
  10612. return false
  10613. }
  10614. };
  10615. BootstrapTable.LOCALES = {};
  10616. BootstrapTable.LOCALES["en-US"] = BootstrapTable.LOCALES.en = {
  10617. formatLoadingMessage: function () {
  10618. return "Loading, please wait..."
  10619. }, formatRecordsPerPage: function (pageNumber) {
  10620. return sprintf("%s rows per page", pageNumber)
  10621. }, formatShowingRows: function (pageFrom, pageTo, totalRows) {
  10622. return sprintf("Showing %s to %s of %s rows", pageFrom, pageTo, totalRows)
  10623. }, formatDetailPagination: function (totalRows) {
  10624. return sprintf("Showing %s rows", totalRows)
  10625. }, formatSearch: function () {
  10626. return "Search"
  10627. }, formatNoMatches: function () {
  10628. return "No matching records found"
  10629. }, formatPaginationSwitch: function () {
  10630. return "Hide/Show pagination"
  10631. }, formatRefresh: function () {
  10632. return "Refresh"
  10633. }, formatToggle: function () {
  10634. return "Toggle"
  10635. }, formatColumns: function () {
  10636. return "Columns"
  10637. }, formatAllRows: function () {
  10638. return "All"
  10639. }
  10640. };
  10641. $.extend(BootstrapTable.DEFAULTS, BootstrapTable.LOCALES["en-US"]);
  10642. BootstrapTable.COLUMN_DEFAULTS = {
  10643. radio: false,
  10644. checkbox: false,
  10645. checkboxEnabled: true,
  10646. field: undefined,
  10647. title: undefined,
  10648. titleTooltip: undefined,
  10649. class: undefined,
  10650. align: undefined,
  10651. halign: undefined,
  10652. falign: undefined,
  10653. valign: undefined,
  10654. width: undefined,
  10655. sortable: false,
  10656. order: "asc",
  10657. visible: true,
  10658. switchable: true,
  10659. clickToSelect: true,
  10660. formatter: undefined,
  10661. footerFormatter: undefined,
  10662. events: undefined,
  10663. sorter: undefined,
  10664. sortName: undefined,
  10665. cellStyle: undefined,
  10666. searchable: true,
  10667. searchFormatter: true,
  10668. cardVisible: true,
  10669. escape: false
  10670. };
  10671. BootstrapTable.EVENTS = {
  10672. "all.bs.table": "onAll",
  10673. "click-cell.bs.table": "onClickCell",
  10674. "dbl-click-cell.bs.table": "onDblClickCell",
  10675. "click-row.bs.table": "onClickRow",
  10676. "dbl-click-row.bs.table": "onDblClickRow",
  10677. "sort.bs.table": "onSort",
  10678. "check.bs.table": "onCheck",
  10679. "uncheck.bs.table": "onUncheck",
  10680. "check-all.bs.table": "onCheckAll",
  10681. "uncheck-all.bs.table": "onUncheckAll",
  10682. "check-some.bs.table": "onCheckSome",
  10683. "uncheck-some.bs.table": "onUncheckSome",
  10684. "load-success.bs.table": "onLoadSuccess",
  10685. "load-error.bs.table": "onLoadError",
  10686. "column-switch.bs.table": "onColumnSwitch",
  10687. "page-change.bs.table": "onPageChange",
  10688. "search.bs.table": "onSearch",
  10689. "toggle.bs.table": "onToggle",
  10690. "pre-body.bs.table": "onPreBody",
  10691. "post-body.bs.table": "onPostBody",
  10692. "post-header.bs.table": "onPostHeader",
  10693. "expand-row.bs.table": "onExpandRow",
  10694. "collapse-row.bs.table": "onCollapseRow",
  10695. "refresh-options.bs.table": "onRefreshOptions",
  10696. "reset-view.bs.table": "onResetView",
  10697. "refresh.bs.table": "onRefresh"
  10698. };
  10699. BootstrapTable.prototype.init = function () {
  10700. this.initLocale();
  10701. this.initContainer();
  10702. this.initTable();
  10703. this.initHeader();
  10704. this.initData();
  10705. this.initHiddenRows();
  10706. this.initFooter();
  10707. this.initToolbar();
  10708. this.initPagination();
  10709. this.initBody();
  10710. this.initSearchText();
  10711. this.initServer()
  10712. };
  10713. BootstrapTable.prototype.initLocale = function () {
  10714. if (this.options.locale) {
  10715. var parts = this.options.locale.split(/-|_/);
  10716. parts[0].toLowerCase();
  10717. if (parts[1]) parts[1].toUpperCase();
  10718. if ($.fn.bootstrapTable.locales[this.options.locale]) {
  10719. $.extend(this.options, $.fn.bootstrapTable.locales[this.options.locale])
  10720. } else if ($.fn.bootstrapTable.locales[parts.join("-")]) {
  10721. $.extend(this.options, $.fn.bootstrapTable.locales[parts.join("-")])
  10722. } else if ($.fn.bootstrapTable.locales[parts[0]]) {
  10723. $.extend(this.options, $.fn.bootstrapTable.locales[parts[0]])
  10724. }
  10725. }
  10726. };
  10727. BootstrapTable.prototype.initContainer = function () {
  10728. this.$container = $(['<div class="bootstrap-table">', '<div class="fixed-table-toolbar"></div>', this.options.paginationVAlign === "top" || this.options.paginationVAlign === "both" ? '<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>', this.options.paginationVAlign === "bottom" || this.options.paginationVAlign === "both" ? '<div class="fixed-table-pagination"></div>' : "", "</div>", "</div>"].join(""));
  10729. this.$container.insertAfter(this.$el);
  10730. this.$tableContainer = this.$container.find(".fixed-table-container");
  10731. this.$tableHeader = this.$container.find(".fixed-table-header");
  10732. this.$tableBody = this.$container.find(".fixed-table-body");
  10733. this.$tableLoading = this.$container.find(".fixed-table-loading");
  10734. this.$tableFooter = this.$container.find(".fixed-table-footer");
  10735. this.$toolbar = this.$container.find(".fixed-table-toolbar");
  10736. this.$pagination = this.$container.find(".fixed-table-pagination");
  10737. this.$tableBody.append(this.$el);
  10738. this.$container.after('<div class="clearfix"></div>');
  10739. this.$el.addClass(this.options.classes);
  10740. if (this.options.striped) {
  10741. this.$el.addClass("table-striped")
  10742. }
  10743. if ($.inArray("table-no-bordered", this.options.classes.split(" ")) !== -1) {
  10744. this.$tableContainer.addClass("table-no-bordered")
  10745. }
  10746. };
  10747. BootstrapTable.prototype.initTable = function () {
  10748. var that = this, columns = [], data = [];
  10749. this.$header = this.$el.find(">thead");
  10750. if (!this.$header.length) {
  10751. this.$header = $("<thead></thead>").appendTo(this.$el)
  10752. }
  10753. this.$header.find("tr").each(function () {
  10754. var column = [];
  10755. $(this).find("th").each(function () {
  10756. if (typeof $(this).data("field") !== "undefined") {
  10757. $(this).data("field", $(this).data("field") + "")
  10758. }
  10759. column.push($.extend({}, {
  10760. title: $(this).html(),
  10761. class: $(this).attr("class"),
  10762. titleTooltip: $(this).attr("title"),
  10763. rowspan: $(this).attr("rowspan") ? +$(this).attr("rowspan") : undefined,
  10764. colspan: $(this).attr("colspan") ? +$(this).attr("colspan") : undefined
  10765. }, $(this).data()))
  10766. });
  10767. columns.push(column)
  10768. });
  10769. if (!$.isArray(this.options.columns[0])) {
  10770. this.options.columns = [this.options.columns]
  10771. }
  10772. this.options.columns = $.extend(true, [], columns, this.options.columns);
  10773. this.columns = [];
  10774. setFieldIndex(this.options.columns);
  10775. $.each(this.options.columns, function (i, columns) {
  10776. $.each(columns, function (j, column) {
  10777. column = $.extend({}, BootstrapTable.COLUMN_DEFAULTS, column);
  10778. if (typeof column.fieldIndex !== "undefined") {
  10779. that.columns[column.fieldIndex] = column
  10780. }
  10781. that.options.columns[i][j] = column
  10782. })
  10783. });
  10784. if (this.options.data.length) {
  10785. return
  10786. }
  10787. var m = [];
  10788. this.$el.find(">tbody>tr").each(function (y) {
  10789. var row = {};
  10790. row._id = $(this).attr("id");
  10791. row._class = $(this).attr("class");
  10792. row._data = getRealDataAttr($(this).data());
  10793. $(this).find(">td").each(function (x) {
  10794. var $this = $(this), cspan = +$this.attr("colspan") || 1, rspan = +$this.attr("rowspan") || 1, tx, ty;
  10795. for (; m[y] && m[y][x]; x++) ;
  10796. for (tx = x; tx < x + cspan; tx++) {
  10797. for (ty = y; ty < y + rspan; ty++) {
  10798. if (!m[ty]) {
  10799. m[ty] = []
  10800. }
  10801. m[ty][tx] = true
  10802. }
  10803. }
  10804. var field = that.columns[x].field;
  10805. row[field] = $(this).html();
  10806. row["_" + field + "_id"] = $(this).attr("id");
  10807. row["_" + field + "_class"] = $(this).attr("class");
  10808. row["_" + field + "_rowspan"] = $(this).attr("rowspan");
  10809. row["_" + field + "_colspan"] = $(this).attr("colspan");
  10810. row["_" + field + "_title"] = $(this).attr("title");
  10811. row["_" + field + "_data"] = getRealDataAttr($(this).data())
  10812. });
  10813. data.push(row)
  10814. });
  10815. this.options.data = data;
  10816. if (data.length) this.fromHtml = true
  10817. };
  10818. BootstrapTable.prototype.initHeader = function () {
  10819. var that = this, visibleColumns = {}, html = [];
  10820. this.header = {
  10821. fields: [],
  10822. styles: [],
  10823. classes: [],
  10824. formatters: [],
  10825. events: [],
  10826. sorters: [],
  10827. sortNames: [],
  10828. cellStyles: [],
  10829. searchables: []
  10830. };
  10831. $.each(this.options.columns, function (i, columns) {
  10832. html.push("<tr>");
  10833. if (i === 0 && !that.options.cardView && that.options.detailView) {
  10834. html.push(sprintf('<th class="detail" rowspan="%s"><div class="fht-cell"></div></th>', that.options.columns.length))
  10835. }
  10836. $.each(columns, function (j, column) {
  10837. var text = "", halign = "", align = "", style = "", class_ = sprintf(' class="%s"', column["class"]),
  10838. order = that.options.sortOrder || column.order, unitWidth = "px", width = column.width;
  10839. if (column.width !== undefined && !that.options.cardView) {
  10840. if (typeof column.width === "string") {
  10841. if (column.width.indexOf("%") !== -1) {
  10842. unitWidth = "%"
  10843. }
  10844. }
  10845. }
  10846. if (column.width && typeof column.width === "string") {
  10847. width = column.width.replace("%", "").replace("px", "")
  10848. }
  10849. halign = sprintf("text-align: %s; ", column.halign ? column.halign : column.align);
  10850. align = sprintf("text-align: %s; ", column.align);
  10851. style = sprintf("vertical-align: %s; ", column.valign);
  10852. style += sprintf("width: %s; ", (column.checkbox || column.radio) && !width ? "36px" : width ? width + unitWidth : undefined);
  10853. if (typeof column.fieldIndex !== "undefined") {
  10854. that.header.fields[column.fieldIndex] = column.field;
  10855. that.header.styles[column.fieldIndex] = align + style;
  10856. that.header.classes[column.fieldIndex] = class_;
  10857. that.header.formatters[column.fieldIndex] = column.formatter;
  10858. that.header.events[column.fieldIndex] = column.events;
  10859. that.header.sorters[column.fieldIndex] = column.sorter;
  10860. that.header.sortNames[column.fieldIndex] = column.sortName;
  10861. that.header.cellStyles[column.fieldIndex] = column.cellStyle;
  10862. that.header.searchables[column.fieldIndex] = column.searchable;
  10863. if (!column.visible) {
  10864. return
  10865. }
  10866. if (that.options.cardView && !column.cardVisible) {
  10867. return
  10868. }
  10869. visibleColumns[column.field] = column
  10870. }
  10871. html.push("<th" + sprintf(' title="%s"', column.titleTooltip), column.checkbox || column.radio ? sprintf(' class="bs-checkbox %s"', column["class"] || "") : class_, sprintf(' style="%s"', halign + style), sprintf(' rowspan="%s"', column.rowspan), sprintf(' colspan="%s"', column.colspan), sprintf(' data-field="%s"', column.field), ">");
  10872. html.push(sprintf('<div class="th-inner %s">', that.options.sortable && column.sortable ? "sortable both" : ""));
  10873. text = that.options.escape ? escapeHTML(column.title) : column.title;
  10874. if (column.checkbox) {
  10875. if (!that.options.singleSelect && that.options.checkboxHeader) {
  10876. text = '<input name="btSelectAll" type="checkbox" />'
  10877. }
  10878. that.header.stateField = column.field
  10879. }
  10880. if (column.radio) {
  10881. text = "";
  10882. that.header.stateField = column.field;
  10883. that.options.singleSelect = true
  10884. }
  10885. html.push(text);
  10886. html.push("</div>");
  10887. html.push('<div class="fht-cell"></div>');
  10888. html.push("</div>");
  10889. html.push("</th>")
  10890. });
  10891. html.push("</tr>")
  10892. });
  10893. this.$header.html(html.join(""));
  10894. this.$header.find("th[data-field]").each(function (i) {
  10895. $(this).data(visibleColumns[$(this).data("field")])
  10896. });
  10897. this.$container.off("click", ".th-inner").on("click", ".th-inner", function (event) {
  10898. var target = $(this);
  10899. if (that.options.detailView) {
  10900. if (target.closest(".bootstrap-table")[0] !== that.$container[0]) return false
  10901. }
  10902. if (that.options.sortable && target.parent().data().sortable) {
  10903. that.onSort(event)
  10904. }
  10905. });
  10906. this.$header.children().children().off("keypress").on("keypress", function (event) {
  10907. if (that.options.sortable && $(this).data().sortable) {
  10908. var code = event.keyCode || event.which;
  10909. if (code == 13) {
  10910. that.onSort(event)
  10911. }
  10912. }
  10913. });
  10914. $(window).off("resize.bootstrap-table");
  10915. if (!this.options.showHeader || this.options.cardView) {
  10916. this.$header.hide();
  10917. this.$tableHeader.hide();
  10918. this.$tableLoading.css("top", 0)
  10919. } else {
  10920. this.$header.show();
  10921. this.$tableHeader.show();
  10922. this.$tableLoading.css("top", this.$header.outerHeight() + 1);
  10923. this.getCaret();
  10924. $(window).on("resize.bootstrap-table", $.proxy(this.resetWidth, this))
  10925. }
  10926. this.$selectAll = this.$header.find('[name="btSelectAll"]');
  10927. this.$selectAll.off("click").on("click", function () {
  10928. var checked = $(this).prop("checked");
  10929. that[checked ? "checkAll" : "uncheckAll"]();
  10930. that.updateSelected()
  10931. })
  10932. };
  10933. BootstrapTable.prototype.initFooter = function () {
  10934. if (!this.options.showFooter || this.options.cardView) {
  10935. this.$tableFooter.hide()
  10936. } else {
  10937. this.$tableFooter.show()
  10938. }
  10939. };
  10940. BootstrapTable.prototype.initData = function (data, type) {
  10941. if (type === "append") {
  10942. this.data = this.data.concat(data)
  10943. } else if (type === "prepend") {
  10944. this.data = [].concat(data).concat(this.data)
  10945. } else {
  10946. this.data = data || this.options.data
  10947. }
  10948. if (type === "append") {
  10949. this.options.data = this.options.data.concat(data)
  10950. } else if (type === "prepend") {
  10951. this.options.data = [].concat(data).concat(this.options.data)
  10952. } else {
  10953. this.options.data = this.data
  10954. }
  10955. if (this.options.sidePagination === "server") {
  10956. return
  10957. }
  10958. this.initSort()
  10959. };
  10960. BootstrapTable.prototype.initSort = function () {
  10961. var that = this, name = this.options.sortName, order = this.options.sortOrder === "desc" ? -1 : 1,
  10962. index = $.inArray(this.options.sortName, this.header.fields), timeoutId = 0;
  10963. if (this.options.customSort !== $.noop) {
  10964. this.options.customSort.apply(this, [this.options.sortName, this.options.sortOrder]);
  10965. return
  10966. }
  10967. if (index !== -1) {
  10968. if (this.options.sortStable) {
  10969. $.each(this.data, function (i, row) {
  10970. if (!row.hasOwnProperty("_position")) row._position = i
  10971. })
  10972. }
  10973. this.data.sort(function (a, b) {
  10974. if (that.header.sortNames[index]) {
  10975. name = that.header.sortNames[index]
  10976. }
  10977. var aa = getItemField(a, name, that.options.escape), bb = getItemField(b, name, that.options.escape),
  10978. value = calculateObjectValue(that.header, that.header.sorters[index], [aa, bb]);
  10979. if (value !== undefined) {
  10980. return order * value
  10981. }
  10982. if (aa === undefined || aa === null) {
  10983. aa = ""
  10984. }
  10985. if (bb === undefined || bb === null) {
  10986. bb = ""
  10987. }
  10988. if (that.options.sortStable && aa === bb) {
  10989. aa = a._position;
  10990. bb = b._position
  10991. }
  10992. if ($.isNumeric(aa) && $.isNumeric(bb)) {
  10993. aa = parseFloat(aa);
  10994. bb = parseFloat(bb);
  10995. if (aa < bb) {
  10996. return order * -1
  10997. }
  10998. return order
  10999. }
  11000. if (aa === bb) {
  11001. return 0
  11002. }
  11003. if (typeof aa !== "string") {
  11004. aa = aa.toString()
  11005. }
  11006. if (aa.localeCompare(bb) === -1) {
  11007. return order * -1
  11008. }
  11009. return order
  11010. });
  11011. if (this.options.sortClass !== undefined) {
  11012. clearTimeout(timeoutId);
  11013. timeoutId = setTimeout(function () {
  11014. that.$el.removeClass(that.options.sortClass);
  11015. var index = that.$header.find(sprintf('[data-field="%s"]', that.options.sortName).index() + 1);
  11016. that.$el.find(sprintf("tr td:nth-child(%s)", index)).addClass(that.options.sortClass)
  11017. }, 250)
  11018. }
  11019. }
  11020. };
  11021. BootstrapTable.prototype.onSort = function (event) {
  11022. var $this = event.type === "keypress" ? $(event.currentTarget) : $(event.currentTarget).parent(),
  11023. $this_ = this.$header.find("th").eq($this.index());
  11024. this.$header.add(this.$header_).find("span.order").remove();
  11025. if (this.options.sortName === $this.data("field")) {
  11026. this.options.sortOrder = this.options.sortOrder === "asc" ? "desc" : "asc"
  11027. } else {
  11028. this.options.sortName = $this.data("field");
  11029. this.options.sortOrder = $this.data("order") === "asc" ? "desc" : "asc"
  11030. }
  11031. this.trigger("sort", this.options.sortName, this.options.sortOrder);
  11032. $this.add($this_).data("order", this.options.sortOrder);
  11033. this.getCaret();
  11034. if (this.options.sidePagination === "server") {
  11035. this.initServer(this.options.silentSort);
  11036. return
  11037. }
  11038. this.initSort();
  11039. this.initBody()
  11040. };
  11041. BootstrapTable.prototype.initToolbar = function () {
  11042. var that = this, html = [], timeoutId = 0, $keepOpen, $search, switchableCount = 0;
  11043. if (this.$toolbar.find(".bs-bars").children().length) {
  11044. $("body").append($(this.options.toolbar))
  11045. }
  11046. this.$toolbar.html("");
  11047. if (typeof this.options.toolbar === "string" || typeof this.options.toolbar === "object") {
  11048. $(sprintf('<div class="bs-bars pull-%s"></div>', this.options.toolbarAlign)).appendTo(this.$toolbar).append($(this.options.toolbar))
  11049. }
  11050. html = [sprintf('<div class="columns columns-%s btn-group pull-%s">', this.options.buttonsAlign, this.options.buttonsAlign)];
  11051. if (typeof this.options.icons === "string") {
  11052. this.options.icons = calculateObjectValue(null, this.options.icons)
  11053. }
  11054. if (this.options.showPaginationSwitch) {
  11055. html.push(sprintf('<button class="btn' + sprintf(" btn-%s", this.options.buttonsClass) + sprintf(" btn-%s", this.options.iconSize) + '" type="button" name="paginationSwitch" aria-label="pagination Switch" title="%s">', this.options.formatPaginationSwitch()), sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.paginationSwitchDown), "</button>")
  11056. }
  11057. if (this.options.showRefresh) {
  11058. html.push(sprintf('<button class="btn' + sprintf(" btn-%s", this.options.buttonsClass) + sprintf(" btn-%s", this.options.iconSize) + '" type="button" name="refresh" aria-label="refresh" title="%s">', this.options.formatRefresh()), sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.refresh), "</button>")
  11059. }
  11060. if (this.options.showToggle) {
  11061. html.push(sprintf('<button class="btn' + sprintf(" btn-%s", this.options.buttonsClass) + sprintf(" btn-%s", this.options.iconSize) + '" type="button" name="toggle" aria-label="toggle" title="%s">', this.options.formatToggle()), sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.toggle), "</button>")
  11062. }
  11063. if (this.options.showColumns) {
  11064. html.push(sprintf('<div class="keep-open btn-group" title="%s">', this.options.formatColumns()), '<button type="button" aria-label="columns" class="btn' + sprintf(" btn-%s", this.options.buttonsClass) + sprintf(" btn-%s", this.options.iconSize) + ' dropdown-toggle" data-toggle="dropdown">', sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.columns), ' <span class="caret"></span>', "</button>", '<ul class="dropdown-menu" role="menu">');
  11065. $.each(this.columns, function (i, column) {
  11066. if (column.radio || column.checkbox) {
  11067. return
  11068. }
  11069. if (that.options.cardView && !column.cardVisible) {
  11070. return
  11071. }
  11072. var checked = column.visible ? ' checked="checked"' : "";
  11073. if (column.switchable) {
  11074. html.push(sprintf('<li role="menuitem">' + '<label><input type="checkbox" data-field="%s" value="%s"%s> %s</label>' + "</li>", column.field, i, checked, column.title));
  11075. switchableCount++
  11076. }
  11077. });
  11078. html.push("</ul>", "</div>")
  11079. }
  11080. html.push("</div>");
  11081. if (this.showToolbar || html.length > 2) {
  11082. this.$toolbar.append(html.join(""))
  11083. }
  11084. if (this.options.showPaginationSwitch) {
  11085. this.$toolbar.find('button[name="paginationSwitch"]').off("click").on("click", $.proxy(this.togglePagination, this))
  11086. }
  11087. if (this.options.showRefresh) {
  11088. this.$toolbar.find('button[name="refresh"]').off("click").on("click", $.proxy(this.refresh, this))
  11089. }
  11090. if (this.options.showToggle) {
  11091. this.$toolbar.find('button[name="toggle"]').off("click").on("click", function () {
  11092. that.toggleView()
  11093. })
  11094. }
  11095. if (this.options.showColumns) {
  11096. $keepOpen = this.$toolbar.find(".keep-open");
  11097. if (switchableCount <= this.options.minimumCountColumns) {
  11098. $keepOpen.find("input").prop("disabled", true)
  11099. }
  11100. $keepOpen.find("li").off("click").on("click", function (event) {
  11101. event.stopImmediatePropagation()
  11102. });
  11103. $keepOpen.find("input").off("click").on("click", function () {
  11104. var $this = $(this);
  11105. that.toggleColumn($(this).val(), $this.prop("checked"), false);
  11106. that.trigger("column-switch", $(this).data("field"), $this.prop("checked"))
  11107. })
  11108. }
  11109. if (this.options.search) {
  11110. html = [];
  11111. html.push('<div class="pull-' + this.options.searchAlign + ' search">', sprintf('<input class="form-control' + sprintf(" input-%s", this.options.iconSize) + '" type="text" placeholder="%s">', this.options.formatSearch()), "</div>");
  11112. this.$toolbar.append(html.join(""));
  11113. $search = this.$toolbar.find(".search input");
  11114. $search.off("keyup drop blur").on("keyup drop blur", function (event) {
  11115. if (that.options.searchOnEnterKey && event.keyCode !== 13) {
  11116. return
  11117. }
  11118. if ($.inArray(event.keyCode, [37, 38, 39, 40]) > -1) {
  11119. return
  11120. }
  11121. clearTimeout(timeoutId);
  11122. timeoutId = setTimeout(function () {
  11123. that.onSearch(event)
  11124. }, that.options.searchTimeOut)
  11125. });
  11126. if (isIEBrowser()) {
  11127. $search.off("mouseup").on("mouseup", function (event) {
  11128. clearTimeout(timeoutId);
  11129. timeoutId = setTimeout(function () {
  11130. that.onSearch(event)
  11131. }, that.options.searchTimeOut)
  11132. })
  11133. }
  11134. }
  11135. };
  11136. BootstrapTable.prototype.onSearch = function (event) {
  11137. var text = $.trim($(event.currentTarget).val());
  11138. if (this.options.trimOnSearch && $(event.currentTarget).val() !== text) {
  11139. $(event.currentTarget).val(text)
  11140. }
  11141. if (text === this.searchText) {
  11142. return
  11143. }
  11144. this.searchText = text;
  11145. this.options.searchText = text;
  11146. this.options.pageNumber = 1;
  11147. this.initSearch();
  11148. this.updatePagination();
  11149. this.trigger("search", text)
  11150. };
  11151. BootstrapTable.prototype.initSearch = function () {
  11152. var that = this;
  11153. if (this.options.sidePagination !== "server") {
  11154. if (this.options.customSearch !== $.noop) {
  11155. this.options.customSearch.apply(this, [this.searchText]);
  11156. return
  11157. }
  11158. var s = this.searchText && (this.options.escape ? escapeHTML(this.searchText) : this.searchText).toLowerCase();
  11159. var f = $.isEmptyObject(this.filterColumns) ? null : this.filterColumns;
  11160. this.data = f ? $.grep(this.options.data, function (item, i) {
  11161. for (var key in f) {
  11162. if ($.isArray(f[key]) && $.inArray(item[key], f[key]) === -1 || !$.isArray(f[key]) && item[key] !== f[key]) {
  11163. return false
  11164. }
  11165. }
  11166. return true
  11167. }) : this.options.data;
  11168. this.data = s ? $.grep(this.data, function (item, i) {
  11169. for (var j = 0; j < that.header.fields.length; j++) {
  11170. if (!that.header.searchables[j]) {
  11171. continue
  11172. }
  11173. var key = $.isNumeric(that.header.fields[j]) ? parseInt(that.header.fields[j], 10) : that.header.fields[j];
  11174. var column = that.columns[getFieldIndex(that.columns, key)];
  11175. var value;
  11176. if (typeof key === "string") {
  11177. value = item;
  11178. var props = key.split(".");
  11179. for (var prop_index = 0; prop_index < props.length; prop_index++) {
  11180. value = value[props[prop_index]]
  11181. }
  11182. if (column && column.searchFormatter) {
  11183. value = calculateObjectValue(column, that.header.formatters[j], [value, item, i], value)
  11184. }
  11185. } else {
  11186. value = item[key]
  11187. }
  11188. if (typeof value === "string" || typeof value === "number") {
  11189. if (that.options.strictSearch) {
  11190. if ((value + "").toLowerCase() === s) {
  11191. return true
  11192. }
  11193. } else {
  11194. if ((value + "").toLowerCase().indexOf(s) !== -1) {
  11195. return true
  11196. }
  11197. }
  11198. }
  11199. }
  11200. return false
  11201. }) : this.data
  11202. }
  11203. };
  11204. BootstrapTable.prototype.initPagination = function () {
  11205. if (!this.options.pagination) {
  11206. this.$pagination.hide();
  11207. return
  11208. } else {
  11209. this.$pagination.show()
  11210. }
  11211. var that = this, html = [], $allSelected = false, i, from, to, $pageList, $first, $pre, $next, $last, $number,
  11212. data = this.getData(), pageList = this.options.pageList;
  11213. if (this.options.sidePagination !== "server") {
  11214. this.options.totalRows = data.length
  11215. }
  11216. this.totalPages = 0;
  11217. if (this.options.totalRows) {
  11218. if (this.options.pageSize === this.options.formatAllRows()) {
  11219. this.options.pageSize = this.options.totalRows;
  11220. $allSelected = true
  11221. } else if (this.options.pageSize === this.options.totalRows) {
  11222. var pageLst = typeof this.options.pageList === "string" ? this.options.pageList.replace("[", "").replace("]", "").replace(/ /g, "").toLowerCase().split(",") : this.options.pageList;
  11223. if ($.inArray(this.options.formatAllRows().toLowerCase(), pageLst) > -1) {
  11224. $allSelected = true
  11225. }
  11226. }
  11227. this.totalPages = ~~((this.options.totalRows - 1) / this.options.pageSize) + 1;
  11228. this.options.totalPages = this.totalPages
  11229. }
  11230. if (this.totalPages > 0 && this.options.pageNumber > this.totalPages) {
  11231. this.options.pageNumber = this.totalPages
  11232. }
  11233. this.pageFrom = (this.options.pageNumber - 1) * this.options.pageSize + 1;
  11234. this.pageTo = this.options.pageNumber * this.options.pageSize;
  11235. if (this.pageTo > this.options.totalRows) {
  11236. this.pageTo = this.options.totalRows
  11237. }
  11238. html.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>");
  11239. if (!this.options.onlyInfoPagination) {
  11240. html.push('<span class="page-list">');
  11241. var pageNumber = [sprintf('<span class="btn-group %s">', this.options.paginationVAlign === "top" || this.options.paginationVAlign === "both" ? "dropdown" : "dropup"), '<button type="button" class="btn' + sprintf(" btn-%s", this.options.buttonsClass) + sprintf(" btn-%s", this.options.iconSize) + ' dropdown-toggle" data-toggle="dropdown">', '<span class="page-size">', $allSelected ? this.options.formatAllRows() : this.options.pageSize, "</span>", ' <span class="caret"></span>', "</button>", '<ul class="dropdown-menu" role="menu">'];
  11242. if (typeof this.options.pageList === "string") {
  11243. var list = this.options.pageList.replace("[", "").replace("]", "").replace(/ /g, "").split(",");
  11244. pageList = [];
  11245. $.each(list, function (i, value) {
  11246. pageList.push(value.toUpperCase() === that.options.formatAllRows().toUpperCase() ? that.options.formatAllRows() : +value)
  11247. })
  11248. }
  11249. $.each(pageList, function (i, page) {
  11250. if (!that.options.smartDisplay || i === 0 || pageList[i - 1] < that.options.totalRows) {
  11251. var active;
  11252. if ($allSelected) {
  11253. active = page === that.options.formatAllRows() ? ' class="active"' : ""
  11254. } else {
  11255. active = page === that.options.pageSize ? ' class="active"' : ""
  11256. }
  11257. pageNumber.push(sprintf('<li role="menuitem"%s><a href="#">%s</a></li>', active, page))
  11258. }
  11259. });
  11260. pageNumber.push("</ul></span>");
  11261. html.push(this.options.formatRecordsPerPage(pageNumber.join("")));
  11262. html.push("</span>");
  11263. html.push("</div>", '<div class="pull-' + this.options.paginationHAlign + ' pagination">', '<ul class="pagination' + sprintf(" pagination-%s", this.options.iconSize) + '">', '<li class="page-pre"><a href="#">' + this.options.paginationPreText + "</a></li>");
  11264. if (this.totalPages < 5) {
  11265. from = 1;
  11266. to = this.totalPages
  11267. } else {
  11268. from = this.options.pageNumber - 2;
  11269. to = from + 4;
  11270. if (from < 1) {
  11271. from = 1;
  11272. to = 5
  11273. }
  11274. if (to > this.totalPages) {
  11275. to = this.totalPages;
  11276. from = to - 4
  11277. }
  11278. }
  11279. if (this.totalPages >= 6) {
  11280. if (this.options.pageNumber >= 3) {
  11281. html.push('<li class="page-first' + (1 === this.options.pageNumber ? " active" : "") + '">', '<a href="#">', 1, "</a>", "</li>");
  11282. from++
  11283. }
  11284. if (this.options.pageNumber >= 4) {
  11285. if (this.options.pageNumber == 4 || this.totalPages == 6 || this.totalPages == 7) {
  11286. from--
  11287. } else {
  11288. html.push('<li class="page-first-separator disabled">', '<a href="#">...</a>', "</li>")
  11289. }
  11290. to--
  11291. }
  11292. }
  11293. if (this.totalPages >= 7) {
  11294. if (this.options.pageNumber >= this.totalPages - 2) {
  11295. from--
  11296. }
  11297. }
  11298. if (this.totalPages == 6) {
  11299. if (this.options.pageNumber >= this.totalPages - 2) {
  11300. to++
  11301. }
  11302. } else if (this.totalPages >= 7) {
  11303. if (this.totalPages == 7 || this.options.pageNumber >= this.totalPages - 3) {
  11304. to++
  11305. }
  11306. }
  11307. for (i = from; i <= to; i++) {
  11308. html.push('<li class="page-number' + (i === this.options.pageNumber ? " active" : "") + '">', '<a href="#">', i, "</a>", "</li>")
  11309. }
  11310. if (this.totalPages >= 8) {
  11311. if (this.options.pageNumber <= this.totalPages - 4) {
  11312. html.push('<li class="page-last-separator disabled">', '<a href="#">...</a>', "</li>")
  11313. }
  11314. }
  11315. if (this.totalPages >= 6) {
  11316. if (this.options.pageNumber <= this.totalPages - 3) {
  11317. html.push('<li class="page-last' + (this.totalPages === this.options.pageNumber ? " active" : "") + '">', '<a href="#">', this.totalPages, "</a>", "</li>")
  11318. }
  11319. }
  11320. html.push('<li class="page-next"><a href="#">' + this.options.paginationNextText + "</a></li>", "</ul>", "</div>")
  11321. }
  11322. this.$pagination.html(html.join(""));
  11323. if (!this.options.onlyInfoPagination) {
  11324. $pageList = this.$pagination.find(".page-list a");
  11325. $first = this.$pagination.find(".page-first");
  11326. $pre = this.$pagination.find(".page-pre");
  11327. $next = this.$pagination.find(".page-next");
  11328. $last = this.$pagination.find(".page-last");
  11329. $number = this.$pagination.find(".page-number");
  11330. if (this.options.smartDisplay) {
  11331. if (this.totalPages <= 1) {
  11332. this.$pagination.find("div.pagination").hide()
  11333. }
  11334. if (pageList.length < 2 || this.options.totalRows <= pageList[0]) {
  11335. this.$pagination.find("span.page-list").hide()
  11336. }
  11337. this.$pagination[this.getData().length ? "show" : "hide"]()
  11338. }
  11339. if (!this.options.paginationLoop) {
  11340. if (this.options.pageNumber === 1) {
  11341. $pre.addClass("disabled")
  11342. }
  11343. if (this.options.pageNumber === this.totalPages) {
  11344. $next.addClass("disabled")
  11345. }
  11346. }
  11347. if ($allSelected) {
  11348. this.options.pageSize = this.options.formatAllRows()
  11349. }
  11350. $pageList.off("click").on("click", $.proxy(this.onPageListChange, this));
  11351. $first.off("click").on("click", $.proxy(this.onPageFirst, this));
  11352. $pre.off("click").on("click", $.proxy(this.onPagePre, this));
  11353. $next.off("click").on("click", $.proxy(this.onPageNext, this));
  11354. $last.off("click").on("click", $.proxy(this.onPageLast, this));
  11355. $number.off("click").on("click", $.proxy(this.onPageNumber, this))
  11356. }
  11357. };
  11358. BootstrapTable.prototype.updatePagination = function (event) {
  11359. if (event && $(event.currentTarget).hasClass("disabled")) {
  11360. return
  11361. }
  11362. if (!this.options.maintainSelected) {
  11363. this.resetRows()
  11364. }
  11365. this.initPagination();
  11366. if (this.options.sidePagination === "server") {
  11367. this.initServer()
  11368. } else {
  11369. this.initBody()
  11370. }
  11371. this.trigger("page-change", this.options.pageNumber, this.options.pageSize)
  11372. };
  11373. BootstrapTable.prototype.onPageListChange = function (event) {
  11374. var $this = $(event.currentTarget);
  11375. $this.parent().addClass("active").siblings().removeClass("active");
  11376. this.options.pageSize = $this.text().toUpperCase() === this.options.formatAllRows().toUpperCase() ? this.options.formatAllRows() : +$this.text();
  11377. this.$toolbar.find(".page-size").text(this.options.pageSize);
  11378. this.updatePagination(event);
  11379. return false
  11380. };
  11381. BootstrapTable.prototype.onPageFirst = function (event) {
  11382. this.options.pageNumber = 1;
  11383. this.updatePagination(event);
  11384. return false
  11385. };
  11386. BootstrapTable.prototype.onPagePre = function (event) {
  11387. if (this.options.pageNumber - 1 === 0) {
  11388. this.options.pageNumber = this.options.totalPages
  11389. } else {
  11390. this.options.pageNumber--
  11391. }
  11392. this.updatePagination(event);
  11393. return false
  11394. };
  11395. BootstrapTable.prototype.onPageNext = function (event) {
  11396. if (this.options.pageNumber + 1 > this.options.totalPages) {
  11397. this.options.pageNumber = 1
  11398. } else {
  11399. this.options.pageNumber++
  11400. }
  11401. this.updatePagination(event);
  11402. return false
  11403. };
  11404. BootstrapTable.prototype.onPageLast = function (event) {
  11405. this.options.pageNumber = this.totalPages;
  11406. this.updatePagination(event);
  11407. return false
  11408. };
  11409. BootstrapTable.prototype.onPageNumber = function (event) {
  11410. if (this.options.pageNumber === +$(event.currentTarget).text()) {
  11411. return
  11412. }
  11413. this.options.pageNumber = +$(event.currentTarget).text();
  11414. this.updatePagination(event);
  11415. return false
  11416. };
  11417. BootstrapTable.prototype.initRow = function (item, i, data, parentDom) {
  11418. var that = this, key, html = [], style = {}, csses = [], data_ = "", attributes = {}, htmlAttributes = [];
  11419. if ($.inArray(item, this.hiddenRows) > -1) {
  11420. return
  11421. }
  11422. style = calculateObjectValue(this.options, this.options.rowStyle, [item, i], style);
  11423. if (style && style.css) {
  11424. for (key in style.css) {
  11425. csses.push(key + ": " + style.css[key])
  11426. }
  11427. }
  11428. attributes = calculateObjectValue(this.options, this.options.rowAttributes, [item, i], attributes);
  11429. if (attributes) {
  11430. for (key in attributes) {
  11431. htmlAttributes.push(sprintf('%s="%s"', key, escapeHTML(attributes[key])))
  11432. }
  11433. }
  11434. if (item._data && !$.isEmptyObject(item._data)) {
  11435. $.each(item._data, function (k, v) {
  11436. if (k === "index") {
  11437. return
  11438. }
  11439. data_ += sprintf(' data-%s="%s"', k, v)
  11440. })
  11441. }
  11442. html.push("<tr", sprintf(" %s", htmlAttributes.join(" ")), sprintf(' id="%s"', $.isArray(item) ? undefined : item._id), sprintf(' class="%s"', style.classes || ($.isArray(item) ? undefined : item._class)), sprintf(' data-index="%s"', i), sprintf(' data-uniqueid="%s"', item[this.options.uniqueId]), sprintf("%s", data_), ">");
  11443. if (this.options.cardView) {
  11444. html.push(sprintf('<td colspan="%s"><div class="card-views">', this.header.fields.length))
  11445. }
  11446. if (!this.options.cardView && this.options.detailView) {
  11447. html.push("<td>", '<a class="detail-icon" href="#">', sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.detailOpen), "</a>", "</td>")
  11448. }
  11449. $.each(this.header.fields, function (j, field) {
  11450. var text = "", value_ = getItemField(item, field, that.options.escape), value = "", type = "",
  11451. cellStyle = {}, id_ = "", class_ = that.header.classes[j], data_ = "", rowspan_ = "", colspan_ = "",
  11452. title_ = "", column = that.columns[j];
  11453. if (that.fromHtml && typeof value_ === "undefined") {
  11454. return
  11455. }
  11456. if (!column.visible) {
  11457. return
  11458. }
  11459. if (that.options.cardView && !column.cardVisible) {
  11460. return
  11461. }
  11462. if (column.escape) {
  11463. value_ = escapeHTML(value_)
  11464. }
  11465. style = sprintf('style="%s"', csses.concat(that.header.styles[j]).join("; "));
  11466. if (item["_" + field + "_id"]) {
  11467. id_ = sprintf(' id="%s"', item["_" + field + "_id"])
  11468. }
  11469. if (item["_" + field + "_class"]) {
  11470. class_ = sprintf(' class="%s"', item["_" + field + "_class"])
  11471. }
  11472. if (item["_" + field + "_rowspan"]) {
  11473. rowspan_ = sprintf(' rowspan="%s"', item["_" + field + "_rowspan"])
  11474. }
  11475. if (item["_" + field + "_colspan"]) {
  11476. colspan_ = sprintf(' colspan="%s"', item["_" + field + "_colspan"])
  11477. }
  11478. if (item["_" + field + "_title"]) {
  11479. title_ = sprintf(' title="%s"', item["_" + field + "_title"])
  11480. }
  11481. cellStyle = calculateObjectValue(that.header, that.header.cellStyles[j], [value_, item, i, field], cellStyle);
  11482. if (cellStyle.classes) {
  11483. class_ = sprintf(' class="%s"', cellStyle.classes)
  11484. }
  11485. if (cellStyle.css) {
  11486. var csses_ = [];
  11487. for (var key in cellStyle.css) {
  11488. csses_.push(key + ": " + cellStyle.css[key])
  11489. }
  11490. style = sprintf('style="%s"', csses_.concat(that.header.styles[j]).join("; "))
  11491. }
  11492. value = calculateObjectValue(column, that.header.formatters[j], [value_, item, i], value_);
  11493. if (item["_" + field + "_data"] && !$.isEmptyObject(item["_" + field + "_data"])) {
  11494. $.each(item["_" + field + "_data"], function (k, v) {
  11495. if (k === "index") {
  11496. return
  11497. }
  11498. data_ += sprintf(' data-%s="%s"', k, v)
  11499. })
  11500. }
  11501. if (column.checkbox || column.radio) {
  11502. type = column.checkbox ? "checkbox" : type;
  11503. type = column.radio ? "radio" : type;
  11504. text = [sprintf(that.options.cardView ? '<div class="card-view %s">' : '<td class="bs-checkbox %s">', column["class"] || ""), "<input" + sprintf(' data-index="%s"', i) + sprintf(' name="%s"', that.options.selectItemName) + sprintf(' type="%s"', type) + sprintf(' value="%s"', item[that.options.idField]) + sprintf(' checked="%s"', value === true || (value_ || value && value.checked) ? "checked" : undefined) + sprintf(' disabled="%s"', !column.checkboxEnabled || value && value.disabled ? "disabled" : undefined) + " />", that.header.formatters[j] && typeof value === "string" ? value : "", that.options.cardView ? "</div>" : "</td>"].join("");
  11505. item[that.header.stateField] = value === true || value && value.checked
  11506. } else {
  11507. value = typeof value === "undefined" || value === null ? that.options.undefinedText : value;
  11508. text = that.options.cardView ? ['<div class="card-view">', that.options.showHeader ? sprintf('<span class="title" %s>%s</span>', style, getPropertyFromOther(that.columns, "field", "title", field)) : "", sprintf('<span class="value">%s</span>', value), "</div>"].join("") : [sprintf("<td%s %s %s %s %s %s %s>", id_, class_, style, data_, rowspan_, colspan_, title_), value, "</td>"].join("");
  11509. if (that.options.cardView && that.options.smartDisplay && value === "") {
  11510. text = '<div class="card-view"></div>'
  11511. }
  11512. }
  11513. html.push(text)
  11514. });
  11515. if (this.options.cardView) {
  11516. html.push("</div></td>")
  11517. }
  11518. html.push("</tr>");
  11519. return html.join(" ")
  11520. };
  11521. BootstrapTable.prototype.initBody = function (fixedScroll) {
  11522. var that = this, html = [], data = this.getData();
  11523. this.trigger("pre-body", data);
  11524. this.$body = this.$el.find(">tbody");
  11525. if (!this.$body.length) {
  11526. this.$body = $("<tbody></tbody>").appendTo(this.$el)
  11527. }
  11528. if (!this.options.pagination || this.options.sidePagination === "server") {
  11529. this.pageFrom = 1;
  11530. this.pageTo = data.length
  11531. }
  11532. var trFragments = $(document.createDocumentFragment());
  11533. var hasTr;
  11534. for (var i = this.pageFrom - 1; i < this.pageTo; i++) {
  11535. var item = data[i];
  11536. var tr = this.initRow(item, i, data, trFragments);
  11537. hasTr = hasTr || !!tr;
  11538. if (tr && tr !== true) {
  11539. trFragments.append(tr)
  11540. }
  11541. }
  11542. if (!hasTr) {
  11543. trFragments.append('<tr class="no-records-found">' + sprintf('<td colspan="%s">%s</td>', this.$header.find("th").length, this.options.formatNoMatches()) + "</tr>")
  11544. }
  11545. this.$body.html(trFragments);
  11546. if (!fixedScroll) {
  11547. this.scrollTo(0)
  11548. }
  11549. this.$body.find("> tr[data-index] > td").off("click dblclick").on("click dblclick", function (e) {
  11550. var $td = $(this), $tr = $td.parent(), item = that.data[$tr.data("index")], index = $td[0].cellIndex,
  11551. fields = that.getVisibleFields(),
  11552. field = fields[that.options.detailView && !that.options.cardView ? index - 1 : index],
  11553. column = that.columns[getFieldIndex(that.columns, field)],
  11554. value = getItemField(item, field, that.options.escape);
  11555. if ($td.find(".detail-icon").length) {
  11556. return
  11557. }
  11558. that.trigger(e.type === "click" ? "click-cell" : "dbl-click-cell", field, value, item, $td);
  11559. that.trigger(e.type === "click" ? "click-row" : "dbl-click-row", item, $tr, field);
  11560. if (e.type === "click" && that.options.clickToSelect && column.clickToSelect) {
  11561. var $selectItem = $tr.find(sprintf('[name="%s"]', that.options.selectItemName));
  11562. if ($selectItem.length) {
  11563. $selectItem[0].click()
  11564. }
  11565. }
  11566. });
  11567. this.$body.find("> tr[data-index] > td > .detail-icon").off("click").on("click", function () {
  11568. var $this = $(this), $tr = $this.parent().parent(), index = $tr.data("index"), row = data[index];
  11569. if ($tr.next().is("tr.detail-view")) {
  11570. $this.find("i").attr("class", sprintf("%s %s", that.options.iconsPrefix, that.options.icons.detailOpen));
  11571. that.trigger("collapse-row", index, row);
  11572. $tr.next().remove()
  11573. } else {
  11574. $this.find("i").attr("class", sprintf("%s %s", that.options.iconsPrefix, that.options.icons.detailClose));
  11575. $tr.after(sprintf('<tr class="detail-view"><td colspan="%s"></td></tr>', $tr.find("td").length));
  11576. var $element = $tr.next().find("td");
  11577. var content = calculateObjectValue(that.options, that.options.detailFormatter, [index, row, $element], "");
  11578. if ($element.length === 1) {
  11579. $element.append(content)
  11580. }
  11581. that.trigger("expand-row", index, row, $element)
  11582. }
  11583. that.resetView();
  11584. return false
  11585. });
  11586. this.$selectItem = this.$body.find(sprintf('[name="%s"]', this.options.selectItemName));
  11587. this.$selectItem.off("click").on("click", function (event) {
  11588. event.stopImmediatePropagation();
  11589. var $this = $(this), checked = $this.prop("checked"), row = that.data[$this.data("index")];
  11590. if (that.options.maintainSelected && $(this).is(":radio")) {
  11591. $.each(that.options.data, function (i, row) {
  11592. row[that.header.stateField] = false
  11593. })
  11594. }
  11595. row[that.header.stateField] = checked;
  11596. if (that.options.singleSelect) {
  11597. that.$selectItem.not(this).each(function () {
  11598. that.data[$(this).data("index")][that.header.stateField] = false
  11599. });
  11600. that.$selectItem.filter(":checked").not(this).prop("checked", false)
  11601. }
  11602. that.updateSelected();
  11603. that.trigger(checked ? "check" : "uncheck", row, $this)
  11604. });
  11605. $.each(this.header.events, function (i, events) {
  11606. if (!events) {
  11607. return
  11608. }
  11609. if (typeof events === "string") {
  11610. events = calculateObjectValue(null, events)
  11611. }
  11612. var field = that.header.fields[i], fieldIndex = $.inArray(field, that.getVisibleFields());
  11613. if (that.options.detailView && !that.options.cardView) {
  11614. fieldIndex += 1
  11615. }
  11616. for (var key in events) {
  11617. that.$body.find(">tr:not(.no-records-found)").each(function () {
  11618. var $tr = $(this), $td = $tr.find(that.options.cardView ? ".card-view" : "td").eq(fieldIndex),
  11619. index = key.indexOf(" "), name = key.substring(0, index), el = key.substring(index + 1),
  11620. func = events[key];
  11621. $td.find(el).off(name).on(name, function (e) {
  11622. var index = $tr.data("index"), row = that.data[index], value = row[field];
  11623. var props = field.split(".");
  11624. if (props.length > 1) {
  11625. value = row;
  11626. for (var prop_index = 0; prop_index < props.length; prop_index++) {
  11627. value = value[props[prop_index]]
  11628. }
  11629. }
  11630. func.apply(this, [e, value, row, index])
  11631. })
  11632. })
  11633. }
  11634. });
  11635. this.updateSelected();
  11636. this.resetView();
  11637. this.trigger("post-body", data)
  11638. };
  11639. BootstrapTable.prototype.initServer = function (silent, query, url) {
  11640. var that = this, data = {},
  11641. params = {searchText: this.searchText, sortName: this.options.sortName, sortOrder: this.options.sortOrder},
  11642. request;
  11643. if (this.options.pagination) {
  11644. params.pageSize = this.options.pageSize === this.options.formatAllRows() ? this.options.totalRows : this.options.pageSize;
  11645. params.pageNumber = this.options.pageNumber
  11646. }
  11647. if (!(url || this.options.url) && !this.options.ajax) {
  11648. return
  11649. }
  11650. if (this.options.queryParamsType === "limit") {
  11651. params = {search: params.searchText, sort: params.sortName, order: params.sortOrder};
  11652. if (this.options.pagination) {
  11653. params.offset = this.options.pageSize === this.options.formatAllRows() ? 0 : this.options.pageSize * (this.options.pageNumber - 1);
  11654. params.limit = this.options.pageSize === this.options.formatAllRows() ? this.options.totalRows : this.options.pageSize
  11655. }
  11656. }
  11657. if (!$.isEmptyObject(this.filterColumnsPartial)) {
  11658. params.filter = JSON.stringify(this.filterColumnsPartial, null)
  11659. }
  11660. data = calculateObjectValue(this.options, this.options.queryParams, [params], data);
  11661. $.extend(data, query || {});
  11662. if (data === false) {
  11663. return
  11664. }
  11665. if (!silent) {
  11666. this.$tableLoading.show()
  11667. }
  11668. request = $.extend({}, calculateObjectValue(null, this.options.ajaxOptions), {
  11669. type: this.options.method,
  11670. url: url || this.options.url,
  11671. data: this.options.contentType === "application/json" && this.options.method === "post" ? JSON.stringify(data) : data,
  11672. cache: this.options.cache,
  11673. contentType: this.options.contentType,
  11674. dataType: this.options.dataType,
  11675. success: function (res) {
  11676. res = calculateObjectValue(that.options, that.options.responseHandler, [res], res);
  11677. that.load(res);
  11678. that.trigger("load-success", res);
  11679. if (!silent) that.$tableLoading.hide()
  11680. },
  11681. error: function (res) {
  11682. that.trigger("load-error", res.status, res);
  11683. if (!silent) that.$tableLoading.hide()
  11684. }
  11685. });
  11686. if (this.options.ajax) {
  11687. calculateObjectValue(this, this.options.ajax, [request], null)
  11688. } else {
  11689. if (this._xhr && this._xhr.readyState !== 4) {
  11690. this._xhr.abort()
  11691. }
  11692. this._xhr = $.ajax(request)
  11693. }
  11694. };
  11695. BootstrapTable.prototype.initSearchText = function () {
  11696. if (this.options.search) {
  11697. if (this.options.searchText !== "") {
  11698. var $search = this.$toolbar.find(".search input");
  11699. $search.val(this.options.searchText);
  11700. this.onSearch({currentTarget: $search})
  11701. }
  11702. }
  11703. };
  11704. BootstrapTable.prototype.getCaret = function () {
  11705. var that = this;
  11706. $.each(this.$header.find("th"), function (i, th) {
  11707. $(th).find(".sortable").removeClass("desc asc").addClass($(th).data("field") === that.options.sortName ? that.options.sortOrder : "both")
  11708. })
  11709. };
  11710. BootstrapTable.prototype.updateSelected = function () {
  11711. var checkAll = this.$selectItem.filter(":enabled").length && this.$selectItem.filter(":enabled").length === this.$selectItem.filter(":enabled").filter(":checked").length;
  11712. this.$selectAll.add(this.$selectAll_).prop("checked", checkAll);
  11713. this.$selectItem.each(function () {
  11714. $(this).closest("tr")[$(this).prop("checked") ? "addClass" : "removeClass"]("selected")
  11715. })
  11716. };
  11717. BootstrapTable.prototype.updateRows = function () {
  11718. var that = this;
  11719. this.$selectItem.each(function () {
  11720. that.data[$(this).data("index")][that.header.stateField] = $(this).prop("checked")
  11721. })
  11722. };
  11723. BootstrapTable.prototype.resetRows = function () {
  11724. var that = this;
  11725. $.each(this.data, function (i, row) {
  11726. that.$selectAll.prop("checked", false);
  11727. that.$selectItem.prop("checked", false);
  11728. if (that.header.stateField) {
  11729. row[that.header.stateField] = false
  11730. }
  11731. });
  11732. this.initHiddenRows()
  11733. };
  11734. BootstrapTable.prototype.trigger = function (name) {
  11735. var args = Array.prototype.slice.call(arguments, 1);
  11736. name += ".bs.table";
  11737. this.options[BootstrapTable.EVENTS[name]].apply(this.options, args);
  11738. this.$el.trigger($.Event(name), args);
  11739. this.options.onAll(name, args);
  11740. this.$el.trigger($.Event("all.bs.table"), [name, args])
  11741. };
  11742. BootstrapTable.prototype.resetHeader = function () {
  11743. clearTimeout(this.timeoutId_);
  11744. this.timeoutId_ = setTimeout($.proxy(this.fitHeader, this), this.$el.is(":hidden") ? 100 : 0)
  11745. };
  11746. BootstrapTable.prototype.fitHeader = function () {
  11747. var that = this, fixedBody, scrollWidth, focused, focusedTemp;
  11748. if (that.$el.is(":hidden")) {
  11749. that.timeoutId_ = setTimeout($.proxy(that.fitHeader, that), 100);
  11750. return
  11751. }
  11752. fixedBody = this.$tableBody.get(0);
  11753. scrollWidth = fixedBody.scrollWidth > fixedBody.clientWidth && fixedBody.scrollHeight > fixedBody.clientHeight + this.$header.outerHeight() ? getScrollBarWidth() : 0;
  11754. this.$el.css("margin-top", -this.$header.outerHeight());
  11755. focused = $(":focus");
  11756. if (focused.length > 0) {
  11757. var $th = focused.parents("th");
  11758. if ($th.length > 0) {
  11759. var dataField = $th.attr("data-field");
  11760. if (dataField !== undefined) {
  11761. var $headerTh = this.$header.find("[data-field='" + dataField + "']");
  11762. if ($headerTh.length > 0) {
  11763. $headerTh.find(":input").addClass("focus-temp")
  11764. }
  11765. }
  11766. }
  11767. }
  11768. this.$header_ = this.$header.clone(true, true);
  11769. this.$selectAll_ = this.$header_.find('[name="btSelectAll"]');
  11770. this.$tableHeader.css({"margin-right": scrollWidth}).find("table").css("width", this.$el.outerWidth()).html("").attr("class", this.$el.attr("class")).append(this.$header_);
  11771. focusedTemp = $(".focus-temp:visible:eq(0)");
  11772. if (focusedTemp.length > 0) {
  11773. focusedTemp.focus();
  11774. this.$header.find(".focus-temp").removeClass("focus-temp")
  11775. }
  11776. this.$header.find("th[data-field]").each(function (i) {
  11777. that.$header_.find(sprintf('th[data-field="%s"]', $(this).data("field"))).data($(this).data())
  11778. });
  11779. var visibleFields = this.getVisibleFields(), $ths = this.$header_.find("th");
  11780. this.$body.find(">tr:first-child:not(.no-records-found) > *").each(function (i) {
  11781. var $this = $(this), index = i;
  11782. if (that.options.detailView && !that.options.cardView) {
  11783. if (i === 0) {
  11784. that.$header_.find("th.detail").find(".fht-cell").width($this.innerWidth())
  11785. }
  11786. index = i - 1
  11787. }
  11788. var $th = that.$header_.find(sprintf('th[data-field="%s"]', visibleFields[index]));
  11789. if ($th.length > 1) {
  11790. $th = $($ths[$this[0].cellIndex])
  11791. }
  11792. $th.find(".fht-cell").width($this.innerWidth())
  11793. });
  11794. this.$tableBody.off("scroll").on("scroll", function () {
  11795. that.$tableHeader.scrollLeft($(this).scrollLeft());
  11796. if (that.options.showFooter && !that.options.cardView) {
  11797. that.$tableFooter.scrollLeft($(this).scrollLeft())
  11798. }
  11799. });
  11800. that.trigger("post-header")
  11801. };
  11802. BootstrapTable.prototype.resetFooter = function () {
  11803. var that = this, data = that.getData(), html = [];
  11804. if (!this.options.showFooter || this.options.cardView) {
  11805. return
  11806. }
  11807. if (!this.options.cardView && this.options.detailView) {
  11808. html.push('<td><div class="th-inner">&nbsp;</div><div class="fht-cell"></div></td>')
  11809. }
  11810. $.each(this.columns, function (i, column) {
  11811. var key, falign = "", valign = "", csses = [], style = {}, class_ = sprintf(' class="%s"', column["class"]);
  11812. if (!column.visible) {
  11813. return
  11814. }
  11815. if (that.options.cardView && !column.cardVisible) {
  11816. return
  11817. }
  11818. falign = sprintf("text-align: %s; ", column.falign ? column.falign : column.align);
  11819. valign = sprintf("vertical-align: %s; ", column.valign);
  11820. style = calculateObjectValue(null, that.options.footerStyle);
  11821. if (style && style.css) {
  11822. for (key in style.css) {
  11823. csses.push(key + ": " + style.css[key])
  11824. }
  11825. }
  11826. html.push("<td", class_, sprintf(' style="%s"', falign + valign + csses.concat().join("; ")), ">");
  11827. html.push('<div class="th-inner">');
  11828. html.push(calculateObjectValue(column, column.footerFormatter, [data], "&nbsp;") || "&nbsp;");
  11829. html.push("</div>");
  11830. html.push('<div class="fht-cell"></div>');
  11831. html.push("</div>");
  11832. html.push("</td>")
  11833. });
  11834. this.$tableFooter.find("tr").html(html.join(""));
  11835. this.$tableFooter.show();
  11836. clearTimeout(this.timeoutFooter_);
  11837. this.timeoutFooter_ = setTimeout($.proxy(this.fitFooter, this), this.$el.is(":hidden") ? 100 : 0)
  11838. };
  11839. BootstrapTable.prototype.fitFooter = function () {
  11840. var that = this, $footerTd, elWidth, scrollWidth;
  11841. clearTimeout(this.timeoutFooter_);
  11842. if (this.$el.is(":hidden")) {
  11843. this.timeoutFooter_ = setTimeout($.proxy(this.fitFooter, this), 100);
  11844. return
  11845. }
  11846. elWidth = this.$el.css("width");
  11847. scrollWidth = elWidth > this.$tableBody.width() ? getScrollBarWidth() : 0;
  11848. this.$tableFooter.css({"margin-right": scrollWidth}).find("table").css("width", elWidth).attr("class", this.$el.attr("class"));
  11849. $footerTd = this.$tableFooter.find("td");
  11850. this.$body.find(">tr:first-child:not(.no-records-found) > *").each(function (i) {
  11851. var $this = $(this);
  11852. $footerTd.eq(i).find(".fht-cell").width($this.innerWidth())
  11853. })
  11854. };
  11855. BootstrapTable.prototype.toggleColumn = function (index, checked, needUpdate) {
  11856. if (index === -1) {
  11857. return
  11858. }
  11859. this.columns[index].visible = checked;
  11860. this.initHeader();
  11861. this.initSearch();
  11862. this.initPagination();
  11863. this.initBody();
  11864. if (this.options.showColumns) {
  11865. var $items = this.$toolbar.find(".keep-open input").prop("disabled", false);
  11866. if (needUpdate) {
  11867. $items.filter(sprintf('[value="%s"]', index)).prop("checked", checked)
  11868. }
  11869. if ($items.filter(":checked").length <= this.options.minimumCountColumns) {
  11870. $items.filter(":checked").prop("disabled", true)
  11871. }
  11872. }
  11873. };
  11874. BootstrapTable.prototype.getVisibleFields = function () {
  11875. var that = this, visibleFields = [];
  11876. $.each(this.header.fields, function (j, field) {
  11877. var column = that.columns[getFieldIndex(that.columns, field)];
  11878. if (!column.visible) {
  11879. return
  11880. }
  11881. visibleFields.push(field)
  11882. });
  11883. return visibleFields
  11884. };
  11885. BootstrapTable.prototype.resetView = function (params) {
  11886. var padding = 0;
  11887. if (params && params.height) {
  11888. this.options.height = params.height
  11889. }
  11890. this.$selectAll.prop("checked", this.$selectItem.length > 0 && this.$selectItem.length === this.$selectItem.filter(":checked").length);
  11891. if (this.options.height) {
  11892. var toolbarHeight = this.$toolbar.outerHeight(true), paginationHeight = this.$pagination.outerHeight(true),
  11893. height = this.options.height - toolbarHeight - paginationHeight;
  11894. this.$tableContainer.css("height", height + "px")
  11895. }
  11896. if (this.options.cardView) {
  11897. this.$el.css("margin-top", "0");
  11898. this.$tableContainer.css("padding-bottom", "0");
  11899. this.$tableFooter.hide();
  11900. return
  11901. }
  11902. if (this.options.showHeader && this.options.height) {
  11903. this.$tableHeader.show();
  11904. this.resetHeader();
  11905. padding += this.$header.outerHeight()
  11906. } else {
  11907. this.$tableHeader.hide();
  11908. this.trigger("post-header")
  11909. }
  11910. if (this.options.showFooter) {
  11911. this.resetFooter();
  11912. if (this.options.height) {
  11913. padding += this.$tableFooter.outerHeight() + 1
  11914. }
  11915. }
  11916. this.getCaret();
  11917. this.$tableContainer.css("padding-bottom", padding + "px");
  11918. this.trigger("reset-view")
  11919. };
  11920. BootstrapTable.prototype.getData = function (useCurrentPage) {
  11921. return this.searchText || !$.isEmptyObject(this.filterColumns) || !$.isEmptyObject(this.filterColumnsPartial) ? useCurrentPage ? this.data.slice(this.pageFrom - 1, this.pageTo) : this.data : useCurrentPage ? this.options.data.slice(this.pageFrom - 1, this.pageTo) : this.options.data
  11922. };
  11923. BootstrapTable.prototype.load = function (data) {
  11924. var fixedScroll = false;
  11925. if (this.options.sidePagination === "server") {
  11926. this.options.totalRows = data[this.options.totalField];
  11927. fixedScroll = data.fixedScroll;
  11928. data = data[this.options.dataField]
  11929. } else if (!$.isArray(data)) {
  11930. fixedScroll = data.fixedScroll;
  11931. data = data.data
  11932. }
  11933. this.initData(data);
  11934. this.initSearch();
  11935. this.initPagination();
  11936. this.initBody(fixedScroll)
  11937. };
  11938. BootstrapTable.prototype.append = function (data) {
  11939. this.initData(data, "append");
  11940. this.initSearch();
  11941. this.initPagination();
  11942. this.initSort();
  11943. this.initBody(true)
  11944. };
  11945. BootstrapTable.prototype.prepend = function (data) {
  11946. this.initData(data, "prepend");
  11947. this.initSearch();
  11948. this.initPagination();
  11949. this.initSort();
  11950. this.initBody(true)
  11951. };
  11952. BootstrapTable.prototype.remove = function (params) {
  11953. var len = this.options.data.length, i, row;
  11954. if (!params.hasOwnProperty("field") || !params.hasOwnProperty("values")) {
  11955. return
  11956. }
  11957. for (i = len - 1; i >= 0; i--) {
  11958. row = this.options.data[i];
  11959. if (!row.hasOwnProperty(params.field)) {
  11960. continue
  11961. }
  11962. if ($.inArray(row[params.field], params.values) !== -1) {
  11963. this.options.data.splice(i, 1);
  11964. if (this.options.sidePagination === "server") {
  11965. this.options.totalRows -= 1
  11966. }
  11967. }
  11968. }
  11969. if (len === this.options.data.length) {
  11970. return
  11971. }
  11972. this.initSearch();
  11973. this.initPagination();
  11974. this.initSort();
  11975. this.initBody(true)
  11976. };
  11977. BootstrapTable.prototype.removeAll = function () {
  11978. if (this.options.data.length > 0) {
  11979. this.options.data.splice(0, this.options.data.length);
  11980. this.initSearch();
  11981. this.initPagination();
  11982. this.initBody(true)
  11983. }
  11984. };
  11985. BootstrapTable.prototype.getRowByUniqueId = function (id) {
  11986. var uniqueId = this.options.uniqueId, len = this.options.data.length, dataRow = null, i, row, rowUniqueId;
  11987. for (i = len - 1; i >= 0; i--) {
  11988. row = this.options.data[i];
  11989. if (row.hasOwnProperty(uniqueId)) {
  11990. rowUniqueId = row[uniqueId]
  11991. } else if (row._data.hasOwnProperty(uniqueId)) {
  11992. rowUniqueId = row._data[uniqueId]
  11993. } else {
  11994. continue
  11995. }
  11996. if (typeof rowUniqueId === "string") {
  11997. id = id.toString()
  11998. } else if (typeof rowUniqueId === "number") {
  11999. if (Number(rowUniqueId) === rowUniqueId && rowUniqueId % 1 === 0) {
  12000. id = parseInt(id)
  12001. } else if (rowUniqueId === Number(rowUniqueId) && rowUniqueId !== 0) {
  12002. id = parseFloat(id)
  12003. }
  12004. }
  12005. if (rowUniqueId === id) {
  12006. dataRow = row;
  12007. break
  12008. }
  12009. }
  12010. return dataRow
  12011. };
  12012. BootstrapTable.prototype.removeByUniqueId = function (id) {
  12013. var len = this.options.data.length, row = this.getRowByUniqueId(id);
  12014. if (row) {
  12015. this.options.data.splice(this.options.data.indexOf(row), 1)
  12016. }
  12017. if (len === this.options.data.length) {
  12018. return
  12019. }
  12020. this.initSearch();
  12021. this.initPagination();
  12022. this.initBody(true)
  12023. };
  12024. BootstrapTable.prototype.updateByUniqueId = function (params) {
  12025. var that = this;
  12026. var allParams = $.isArray(params) ? params : [params];
  12027. $.each(allParams, function (i, params) {
  12028. var rowId;
  12029. if (!params.hasOwnProperty("id") || !params.hasOwnProperty("row")) {
  12030. return
  12031. }
  12032. rowId = $.inArray(that.getRowByUniqueId(params.id), that.options.data);
  12033. if (rowId === -1) {
  12034. return
  12035. }
  12036. $.extend(that.options.data[rowId], params.row)
  12037. });
  12038. this.initSearch();
  12039. this.initPagination();
  12040. this.initSort();
  12041. this.initBody(true)
  12042. };
  12043. BootstrapTable.prototype.insertRow = function (params) {
  12044. if (!params.hasOwnProperty("index") || !params.hasOwnProperty("row")) {
  12045. return
  12046. }
  12047. this.data.splice(params.index, 0, params.row);
  12048. this.initSearch();
  12049. this.initPagination();
  12050. this.initSort();
  12051. this.initBody(true)
  12052. };
  12053. BootstrapTable.prototype.updateRow = function (params) {
  12054. var that = this;
  12055. var allParams = $.isArray(params) ? params : [params];
  12056. $.each(allParams, function (i, params) {
  12057. if (!params.hasOwnProperty("index") || !params.hasOwnProperty("row")) {
  12058. return
  12059. }
  12060. $.extend(that.options.data[params.index], params.row)
  12061. });
  12062. this.initSearch();
  12063. this.initPagination();
  12064. this.initSort();
  12065. this.initBody(true)
  12066. };
  12067. BootstrapTable.prototype.initHiddenRows = function () {
  12068. this.hiddenRows = []
  12069. };
  12070. BootstrapTable.prototype.showRow = function (params) {
  12071. this.toggleRow(params, true)
  12072. };
  12073. BootstrapTable.prototype.hideRow = function (params) {
  12074. this.toggleRow(params, false)
  12075. };
  12076. BootstrapTable.prototype.toggleRow = function (params, visible) {
  12077. var row, index;
  12078. if (params.hasOwnProperty("index")) {
  12079. row = this.getData()[params.index]
  12080. } else if (params.hasOwnProperty("uniqueId")) {
  12081. row = this.getRowByUniqueId(params.uniqueId)
  12082. }
  12083. if (!row) {
  12084. return
  12085. }
  12086. index = $.inArray(row, this.hiddenRows);
  12087. if (!visible && index === -1) {
  12088. this.hiddenRows.push(row)
  12089. } else if (visible && index > -1) {
  12090. this.hiddenRows.splice(index, 1)
  12091. }
  12092. this.initBody(true)
  12093. };
  12094. BootstrapTable.prototype.getHiddenRows = function (show) {
  12095. var that = this, data = this.getData(), rows = [];
  12096. $.each(data, function (i, row) {
  12097. if ($.inArray(row, that.hiddenRows) > -1) {
  12098. rows.push(row)
  12099. }
  12100. });
  12101. this.hiddenRows = rows;
  12102. return rows
  12103. };
  12104. BootstrapTable.prototype.mergeCells = function (options) {
  12105. var row = options.index, col = $.inArray(options.field, this.getVisibleFields()),
  12106. rowspan = options.rowspan || 1, colspan = options.colspan || 1, i, j, $tr = this.$body.find(">tr"), $td;
  12107. if (this.options.detailView && !this.options.cardView) {
  12108. col += 1
  12109. }
  12110. $td = $tr.eq(row).find(">td").eq(col);
  12111. if (row < 0 || col < 0 || row >= this.data.length) {
  12112. return
  12113. }
  12114. for (i = row; i < row + rowspan; i++) {
  12115. for (j = col; j < col + colspan; j++) {
  12116. $tr.eq(i).find(">td").eq(j).hide()
  12117. }
  12118. }
  12119. $td.attr("rowspan", rowspan).attr("colspan", colspan).show()
  12120. };
  12121. BootstrapTable.prototype.updateCell = function (params) {
  12122. if (!params.hasOwnProperty("index") || !params.hasOwnProperty("field") || !params.hasOwnProperty("value")) {
  12123. return
  12124. }
  12125. this.data[params.index][params.field] = params.value;
  12126. if (params.reinit === false) {
  12127. return
  12128. }
  12129. this.initSort();
  12130. this.initBody(true)
  12131. };
  12132. BootstrapTable.prototype.getOptions = function () {
  12133. return this.options
  12134. };
  12135. BootstrapTable.prototype.getSelections = function () {
  12136. var that = this;
  12137. return $.grep(this.options.data, function (row) {
  12138. return row[that.header.stateField] === true
  12139. })
  12140. };
  12141. BootstrapTable.prototype.getAllSelections = function () {
  12142. var that = this;
  12143. return $.grep(this.options.data, function (row) {
  12144. return row[that.header.stateField]
  12145. })
  12146. };
  12147. BootstrapTable.prototype.checkAll = function () {
  12148. this.checkAll_(true)
  12149. };
  12150. BootstrapTable.prototype.uncheckAll = function () {
  12151. this.checkAll_(false)
  12152. };
  12153. BootstrapTable.prototype.checkInvert = function () {
  12154. var that = this;
  12155. var rows = that.$selectItem.filter(":enabled");
  12156. var checked = rows.filter(":checked");
  12157. rows.each(function () {
  12158. $(this).prop("checked", !$(this).prop("checked"))
  12159. });
  12160. that.updateRows();
  12161. that.updateSelected();
  12162. that.trigger("uncheck-some", checked);
  12163. checked = that.getSelections();
  12164. that.trigger("check-some", checked)
  12165. };
  12166. BootstrapTable.prototype.checkAll_ = function (checked) {
  12167. var rows;
  12168. if (!checked) {
  12169. rows = this.getSelections()
  12170. }
  12171. this.$selectAll.add(this.$selectAll_).prop("checked", checked);
  12172. this.$selectItem.filter(":enabled").prop("checked", checked);
  12173. this.updateRows();
  12174. if (checked) {
  12175. rows = this.getSelections()
  12176. }
  12177. this.trigger(checked ? "check-all" : "uncheck-all", rows)
  12178. };
  12179. BootstrapTable.prototype.check = function (index) {
  12180. this.check_(true, index)
  12181. };
  12182. BootstrapTable.prototype.uncheck = function (index) {
  12183. this.check_(false, index)
  12184. };
  12185. BootstrapTable.prototype.check_ = function (checked, index) {
  12186. var $el = this.$selectItem.filter(sprintf('[data-index="%s"]', index)).prop("checked", checked);
  12187. this.data[index][this.header.stateField] = checked;
  12188. this.updateSelected();
  12189. this.trigger(checked ? "check" : "uncheck", this.data[index], $el)
  12190. };
  12191. BootstrapTable.prototype.checkBy = function (obj) {
  12192. this.checkBy_(true, obj)
  12193. };
  12194. BootstrapTable.prototype.uncheckBy = function (obj) {
  12195. this.checkBy_(false, obj)
  12196. };
  12197. BootstrapTable.prototype.checkBy_ = function (checked, obj) {
  12198. if (!obj.hasOwnProperty("field") || !obj.hasOwnProperty("values")) {
  12199. return
  12200. }
  12201. var that = this, rows = [];
  12202. $.each(this.options.data, function (index, row) {
  12203. if (!row.hasOwnProperty(obj.field)) {
  12204. return false
  12205. }
  12206. if ($.inArray(row[obj.field], obj.values) !== -1) {
  12207. var $el = that.$selectItem.filter(":enabled").filter(sprintf('[data-index="%s"]', index)).prop("checked", checked);
  12208. row[that.header.stateField] = checked;
  12209. rows.push(row);
  12210. that.trigger(checked ? "check" : "uncheck", row, $el)
  12211. }
  12212. });
  12213. this.updateSelected();
  12214. this.trigger(checked ? "check-some" : "uncheck-some", rows)
  12215. };
  12216. BootstrapTable.prototype.destroy = function () {
  12217. this.$el.insertBefore(this.$container);
  12218. $(this.options.toolbar).insertBefore(this.$el);
  12219. this.$container.next().remove();
  12220. this.$container.remove();
  12221. this.$el.html(this.$el_.html()).css("margin-top", "0").attr("class", this.$el_.attr("class") || "")
  12222. };
  12223. BootstrapTable.prototype.showLoading = function () {
  12224. this.$tableLoading.show()
  12225. };
  12226. BootstrapTable.prototype.hideLoading = function () {
  12227. this.$tableLoading.hide()
  12228. };
  12229. BootstrapTable.prototype.togglePagination = function () {
  12230. this.options.pagination = !this.options.pagination;
  12231. var button = this.$toolbar.find('button[name="paginationSwitch"] i');
  12232. if (this.options.pagination) {
  12233. button.attr("class", this.options.iconsPrefix + " " + this.options.icons.paginationSwitchDown)
  12234. } else {
  12235. button.attr("class", this.options.iconsPrefix + " " + this.options.icons.paginationSwitchUp)
  12236. }
  12237. this.updatePagination()
  12238. };
  12239. BootstrapTable.prototype.refresh = function (params) {
  12240. if (params && params.url) {
  12241. this.options.url = params.url
  12242. }
  12243. if (params && params.pageNumber) {
  12244. this.options.pageNumber = params.pageNumber
  12245. }
  12246. if (params && params.pageSize) {
  12247. this.options.pageSize = params.pageSize
  12248. }
  12249. this.initServer(params && params.silent, params && params.query, params && params.url);
  12250. this.trigger("refresh", params)
  12251. };
  12252. BootstrapTable.prototype.resetWidth = function () {
  12253. if (this.options.showHeader && this.options.height) {
  12254. this.fitHeader()
  12255. }
  12256. if (this.options.showFooter) {
  12257. this.fitFooter()
  12258. }
  12259. };
  12260. BootstrapTable.prototype.showColumn = function (field) {
  12261. this.toggleColumn(getFieldIndex(this.columns, field), true, true)
  12262. };
  12263. BootstrapTable.prototype.hideColumn = function (field) {
  12264. this.toggleColumn(getFieldIndex(this.columns, field), false, true)
  12265. };
  12266. BootstrapTable.prototype.getHiddenColumns = function () {
  12267. return $.grep(this.columns, function (column) {
  12268. return !column.visible
  12269. })
  12270. };
  12271. BootstrapTable.prototype.getVisibleColumns = function () {
  12272. return $.grep(this.columns, function (column) {
  12273. return column.visible
  12274. })
  12275. };
  12276. BootstrapTable.prototype.toggleAllColumns = function (visible) {
  12277. $.each(this.columns, function (i, column) {
  12278. this.columns[i].visible = visible
  12279. });
  12280. this.initHeader();
  12281. this.initSearch();
  12282. this.initPagination();
  12283. this.initBody();
  12284. if (this.options.showColumns) {
  12285. var $items = this.$toolbar.find(".keep-open input").prop("disabled", false);
  12286. if ($items.filter(":checked").length <= this.options.minimumCountColumns) {
  12287. $items.filter(":checked").prop("disabled", true)
  12288. }
  12289. }
  12290. };
  12291. BootstrapTable.prototype.showAllColumns = function () {
  12292. this.toggleAllColumns(true)
  12293. };
  12294. BootstrapTable.prototype.hideAllColumns = function () {
  12295. this.toggleAllColumns(false)
  12296. };
  12297. BootstrapTable.prototype.filterBy = function (columns) {
  12298. this.filterColumns = $.isEmptyObject(columns) ? {} : columns;
  12299. this.options.pageNumber = 1;
  12300. this.initSearch();
  12301. this.updatePagination()
  12302. };
  12303. BootstrapTable.prototype.scrollTo = function (value) {
  12304. if (typeof value === "string") {
  12305. value = value === "bottom" ? this.$tableBody[0].scrollHeight : 0
  12306. }
  12307. if (typeof value === "number") {
  12308. this.$tableBody.scrollTop(value)
  12309. }
  12310. if (typeof value === "undefined") {
  12311. return this.$tableBody.scrollTop()
  12312. }
  12313. };
  12314. BootstrapTable.prototype.getScrollPosition = function () {
  12315. return this.scrollTo()
  12316. };
  12317. BootstrapTable.prototype.selectPage = function (page) {
  12318. if (page > 0 && page <= this.options.totalPages) {
  12319. this.options.pageNumber = page;
  12320. this.updatePagination()
  12321. }
  12322. };
  12323. BootstrapTable.prototype.prevPage = function () {
  12324. if (this.options.pageNumber > 1) {
  12325. this.options.pageNumber--;
  12326. this.updatePagination()
  12327. }
  12328. };
  12329. BootstrapTable.prototype.nextPage = function () {
  12330. if (this.options.pageNumber < this.options.totalPages) {
  12331. this.options.pageNumber++;
  12332. this.updatePagination()
  12333. }
  12334. };
  12335. BootstrapTable.prototype.toggleView = function () {
  12336. this.options.cardView = !this.options.cardView;
  12337. this.initHeader();
  12338. this.initBody();
  12339. this.trigger("toggle", this.options.cardView)
  12340. };
  12341. BootstrapTable.prototype.refreshOptions = function (options) {
  12342. if (compareObjects(this.options, options, true)) {
  12343. return
  12344. }
  12345. this.options = $.extend(this.options, options);
  12346. this.trigger("refresh-options", this.options);
  12347. this.destroy();
  12348. this.init()
  12349. };
  12350. BootstrapTable.prototype.resetSearch = function (text) {
  12351. var $search = this.$toolbar.find(".search input");
  12352. $search.val(text || "");
  12353. this.onSearch({currentTarget: $search})
  12354. };
  12355. BootstrapTable.prototype.expandRow_ = function (expand, index) {
  12356. var $tr = this.$body.find(sprintf('> tr[data-index="%s"]', index));
  12357. if ($tr.next().is("tr.detail-view") === (expand ? false : true)) {
  12358. $tr.find("> td > .detail-icon").click()
  12359. }
  12360. };
  12361. BootstrapTable.prototype.expandRow = function (index) {
  12362. this.expandRow_(true, index)
  12363. };
  12364. BootstrapTable.prototype.collapseRow = function (index) {
  12365. this.expandRow_(false, index)
  12366. };
  12367. BootstrapTable.prototype.expandAllRows = function (isSubTable) {
  12368. if (isSubTable) {
  12369. var $tr = this.$body.find(sprintf('> tr[data-index="%s"]', 0)), that = this, detailIcon = null,
  12370. executeInterval = false, idInterval = -1;
  12371. if (!$tr.next().is("tr.detail-view")) {
  12372. $tr.find("> td > .detail-icon").click();
  12373. executeInterval = true
  12374. } else if (!$tr.next().next().is("tr.detail-view")) {
  12375. $tr.next().find(".detail-icon").click();
  12376. executeInterval = true
  12377. }
  12378. if (executeInterval) {
  12379. try {
  12380. idInterval = setInterval(function () {
  12381. detailIcon = that.$body.find("tr.detail-view").last().find(".detail-icon");
  12382. if (detailIcon.length > 0) {
  12383. detailIcon.click()
  12384. } else {
  12385. clearInterval(idInterval)
  12386. }
  12387. }, 1)
  12388. } catch (ex) {
  12389. clearInterval(idInterval)
  12390. }
  12391. }
  12392. } else {
  12393. var trs = this.$body.children();
  12394. for (var i = 0; i < trs.length; i++) {
  12395. this.expandRow_(true, $(trs[i]).data("index"))
  12396. }
  12397. }
  12398. };
  12399. BootstrapTable.prototype.collapseAllRows = function (isSubTable) {
  12400. if (isSubTable) {
  12401. this.expandRow_(false, 0)
  12402. } else {
  12403. var trs = this.$body.children();
  12404. for (var i = 0; i < trs.length; i++) {
  12405. this.expandRow_(false, $(trs[i]).data("index"))
  12406. }
  12407. }
  12408. };
  12409. BootstrapTable.prototype.updateFormatText = function (name, text) {
  12410. if (this.options[sprintf("format%s", name)]) {
  12411. if (typeof text === "string") {
  12412. this.options[sprintf("format%s", name)] = function () {
  12413. return text
  12414. }
  12415. } else if (typeof text === "function") {
  12416. this.options[sprintf("format%s", name)] = text
  12417. }
  12418. }
  12419. this.initToolbar();
  12420. this.initPagination();
  12421. this.initBody()
  12422. };
  12423. var allowedMethods = ["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"];
  12424. $.fn.bootstrapTable = function (option) {
  12425. var value, args = Array.prototype.slice.call(arguments, 1);
  12426. this.each(function () {
  12427. var $this = $(this), data = $this.data("bootstrap.table"),
  12428. options = $.extend({}, BootstrapTable.DEFAULTS, $this.data(), typeof option === "object" && option);
  12429. if (typeof option === "string") {
  12430. if ($.inArray(option, allowedMethods) < 0) {
  12431. throw new Error("Unknown method: " + option)
  12432. }
  12433. if (!data) {
  12434. return
  12435. }
  12436. value = data[option].apply(data, args);
  12437. if (option === "destroy") {
  12438. $this.removeData("bootstrap.table")
  12439. }
  12440. }
  12441. if (!data) {
  12442. $this.data("bootstrap.table", data = new BootstrapTable(this, options))
  12443. }
  12444. });
  12445. return typeof value === "undefined" ? this : value
  12446. };
  12447. $.fn.bootstrapTable.Constructor = BootstrapTable;
  12448. $.fn.bootstrapTable.defaults = BootstrapTable.DEFAULTS;
  12449. $.fn.bootstrapTable.columnDefaults = BootstrapTable.COLUMN_DEFAULTS;
  12450. $.fn.bootstrapTable.locales = BootstrapTable.LOCALES;
  12451. $.fn.bootstrapTable.methods = allowedMethods;
  12452. $.fn.bootstrapTable.utils = {
  12453. sprintf: sprintf,
  12454. getFieldIndex: getFieldIndex,
  12455. compareObjects: compareObjects,
  12456. calculateObjectValue: calculateObjectValue,
  12457. getItemField: getItemField,
  12458. objectKeys: objectKeys,
  12459. isIEBrowser: isIEBrowser
  12460. };
  12461. $(function () {
  12462. $('[data-toggle="table"]').bootstrapTable()
  12463. })
  12464. })(jQuery);
  12465. define("bootstrap-table", ["bootstrap"], (function (global) {
  12466. return function () {
  12467. var ret, fn;
  12468. return ret || global.$.fn.bootstrapTable;
  12469. };
  12470. }(this)));
  12471. /**
  12472. * Bootstrap Table Chinese translation
  12473. * Author: Zhixin Wen<wenzhixin2010@gmail.com>
  12474. */
  12475. (function ($) {
  12476. 'use strict';
  12477. $.fn.bootstrapTable.locales['zh-CN'] = {
  12478. formatLoadingMessage: function () {
  12479. return '正在努力地加载数据中,请稍候……';
  12480. },
  12481. formatRecordsPerPage: function (pageNumber) {
  12482. return '每页显示 ' + pageNumber + ' 条记录';
  12483. },
  12484. formatShowingRows: function (pageFrom, pageTo, totalRows) {
  12485. return '显示第 ' + pageFrom + ' 到第 ' + pageTo + ' 条记录,总共 ' + totalRows + ' 条记录';
  12486. },
  12487. formatSearch: function () {
  12488. return '搜索';
  12489. },
  12490. formatNoMatches: function () {
  12491. return '没有找到匹配的记录';
  12492. },
  12493. formatPaginationSwitch: function () {
  12494. return '隐藏/显示分页';
  12495. },
  12496. formatRefresh: function () {
  12497. return '刷新';
  12498. },
  12499. formatToggle: function () {
  12500. return '切换';
  12501. },
  12502. formatColumns: function () {
  12503. return '列';
  12504. },
  12505. formatExport: function () {
  12506. return '导出数据';
  12507. },
  12508. formatClearFilters: function () {
  12509. return '清空过滤';
  12510. }
  12511. };
  12512. $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['zh-CN']);
  12513. })(jQuery);
  12514. define("bootstrap-table-lang", ["bootstrap-table"], (function (global) {
  12515. return function () {
  12516. var ret, fn;
  12517. return ret || global.$.fn.bootstrapTable.defaults;
  12518. };
  12519. }(this)));
  12520. /*
  12521. tableExport.jquery.plugin
  12522. Version 1.10.22
  12523. Copyright (c) 2015-2021 hhurz, https://github.com/hhurz/tableExport.jquery.plugin
  12524. Based on https://github.com/kayalshri/tableExport.jquery.plugin
  12525. Licensed under the MIT License
  12526. */
  12527. var $jscomp = $jscomp || {};
  12528. $jscomp.scope = {};
  12529. $jscomp.findInternal = function (d, k, y) {
  12530. d instanceof String && (d = String(d));
  12531. for (var C = d.length, v = 0; v < C; v++) {
  12532. var R = d[v];
  12533. if (k.call(y, R, v, d)) return {i: v, v: R}
  12534. }
  12535. return {i: -1, v: void 0}
  12536. };
  12537. $jscomp.ASSUME_ES5 = !1;
  12538. $jscomp.ASSUME_NO_NATIVE_MAP = !1;
  12539. $jscomp.ASSUME_NO_NATIVE_SET = !1;
  12540. $jscomp.defineProperty = $jscomp.ASSUME_ES5 || "function" == typeof Object.defineProperties ? Object.defineProperty : function (d, k, y) {
  12541. d != Array.prototype && d != Object.prototype && (d[k] = y.value)
  12542. };
  12543. $jscomp.getGlobal = function (d) {
  12544. return "undefined" != typeof window && window === d ? d : "undefined" != typeof global && null != global ? global : d
  12545. };
  12546. $jscomp.global = $jscomp.getGlobal(this);
  12547. $jscomp.polyfill = function (d, k, y, C) {
  12548. if (k) {
  12549. y = $jscomp.global;
  12550. d = d.split(".");
  12551. for (C = 0; C < d.length - 1; C++) {
  12552. var v = d[C];
  12553. v in y || (y[v] = {});
  12554. y = y[v]
  12555. }
  12556. d = d[d.length - 1];
  12557. C = y[d];
  12558. k = k(C);
  12559. k != C && null != k && $jscomp.defineProperty(y, d, {configurable: !0, writable: !0, value: k})
  12560. }
  12561. };
  12562. $jscomp.polyfill("Array.prototype.find", function (d) {
  12563. return d ? d : function (d, y) {
  12564. return $jscomp.findInternal(this, d, y).v
  12565. }
  12566. }, "es6", "es3");
  12567. (function (d) {
  12568. d.fn.tableExport = function (k) {
  12569. function y(b) {
  12570. var c = [];
  12571. v(b, "thead").each(function () {
  12572. c.push.apply(c, v(d(this), a.theadSelector).toArray())
  12573. });
  12574. return c
  12575. }
  12576. function C(b) {
  12577. var c = [];
  12578. v(b, "tbody").each(function () {
  12579. c.push.apply(c, v(d(this), a.tbodySelector).toArray())
  12580. });
  12581. a.tfootSelector.length && v(b, "tfoot").each(function () {
  12582. c.push.apply(c, v(d(this), a.tfootSelector).toArray())
  12583. });
  12584. return c
  12585. }
  12586. function v(b, a) {
  12587. var c = b[0].tagName, q = b.parents(c).length;
  12588. return b.find(a).filter(function () {
  12589. return q === d(this).closest(c).parents(c).length
  12590. })
  12591. }
  12592. function R(b) {
  12593. var a = [], e = 0, q = 0, f = 0;
  12594. d(b).find("thead").first().find("th").each(function (b, c) {
  12595. b = void 0 !== d(c).attr("data-field");
  12596. "undefined" !== typeof c.parentNode.rowIndex && q !== c.parentNode.rowIndex && (q = c.parentNode.rowIndex, e = f = 0);
  12597. var h = J(c);
  12598. for (e += h ? h : 1; f < e;) a[f] = b ? d(c).attr("data-field") : f.toString(), f++
  12599. });
  12600. return a
  12601. }
  12602. function I(b) {
  12603. var a = "undefined" !== typeof b[0].rowIndex, e = !1 === a && "undefined" !== typeof b[0].cellIndex,
  12604. q = e || a ? Ja(b) : b.is(":visible"), f = b.attr("data-tableexport-display");
  12605. e && "none" !== f &&
  12606. "always" !== f && (b = d(b[0].parentNode), a = "undefined" !== typeof b[0].rowIndex, f = b.attr("data-tableexport-display"));
  12607. a && "none" !== f && "always" !== f && (f = b.closest("table").attr("data-tableexport-display"));
  12608. return "none" !== f && (!0 === q || "always" === f)
  12609. }
  12610. function Ja(b) {
  12611. var a = [];
  12612. V && (a = K.filter(function () {
  12613. var a = !1;
  12614. this.nodeType === b[0].nodeType && ("undefined" !== typeof this.rowIndex && this.rowIndex === b[0].rowIndex ? a = !0 : "undefined" !== typeof this.cellIndex && this.cellIndex === b[0].cellIndex && "undefined" !== typeof this.parentNode.rowIndex &&
  12615. "undefined" !== typeof b[0].parentNode.rowIndex && this.parentNode.rowIndex === b[0].parentNode.rowIndex && (a = !0));
  12616. return a
  12617. }));
  12618. return !1 === V || 0 === a.length
  12619. }
  12620. function ta(b, c, e) {
  12621. var q = !1;
  12622. I(b) ? 0 < a.ignoreColumn.length && (-1 !== d.inArray(e, a.ignoreColumn) || -1 !== d.inArray(e - c, a.ignoreColumn) || S.length > e && "undefined" !== typeof S[e] && -1 !== d.inArray(S[e], a.ignoreColumn)) && (q = !0) : q = !0;
  12623. return q
  12624. }
  12625. function E(b, c, e, q, f) {
  12626. if ("function" === typeof f) {
  12627. var h = !1;
  12628. "function" === typeof a.onIgnoreRow && (h = a.onIgnoreRow(d(b), e));
  12629. if (!1 === h &&
  12630. (0 === a.ignoreRow.length || -1 === d.inArray(e, a.ignoreRow) && -1 === d.inArray(e - q, a.ignoreRow)) && I(d(b))) {
  12631. b = v(d(b), c);
  12632. var n = b.length, l = 0, u = 0;
  12633. b.each(function () {
  12634. var b = d(this), a = J(this), c = T(this), h;
  12635. d.each(G, function () {
  12636. if (e > this.s.r && e <= this.e.r && l >= this.s.c && l <= this.e.c) for (h = 0; h <= this.e.c - this.s.c; ++h) n++, u++, f(null, e, l++)
  12637. });
  12638. if (c || a) a = a || 1, G.push({s: {r: e, c: l}, e: {r: e + (c || 1) - 1, c: l + a - 1}});
  12639. !1 === ta(b, n, u++) && f(this, e, l++);
  12640. if (1 < a) for (h = 0; h < a - 1; ++h) u++, f(null, e, l++)
  12641. });
  12642. d.each(G, function () {
  12643. if (e >= this.s.r && e <= this.e.r &&
  12644. l >= this.s.c && l <= this.e.c) for (ea = 0; ea <= this.e.c - this.s.c; ++ea) f(null, e, l++)
  12645. })
  12646. }
  12647. }
  12648. }
  12649. function ua(b, a, e, d) {
  12650. if ("undefined" !== typeof d.images && (e = d.images[e], "undefined" !== typeof e)) {
  12651. a = a.getBoundingClientRect();
  12652. var c = b.width / b.height, h = a.width / a.height, q = b.width, l = b.height, u = 19.049976 / 25.4,
  12653. g = 0;
  12654. h <= c ? (l = Math.min(b.height, a.height), q = a.width * l / a.height) : h > c && (q = Math.min(b.width, a.width), l = a.height * q / a.width);
  12655. q *= u;
  12656. l *= u;
  12657. l < b.height && (g = (b.height - l) / 2);
  12658. try {
  12659. d.doc.addImage(e.src, b.textPos.x, b.y + g, q, l)
  12660. } catch (Pa) {
  12661. }
  12662. b.textPos.x +=
  12663. q
  12664. }
  12665. }
  12666. function va(b, c) {
  12667. if ("string" === a.outputMode) return b.output();
  12668. if ("base64" === a.outputMode) return L(b.output());
  12669. if ("window" === a.outputMode) window.URL = window.URL || window.webkitURL, window.open(window.URL.createObjectURL(b.output("blob"))); else try {
  12670. var e = b.output("blob");
  12671. saveAs(e, a.fileName + ".pdf")
  12672. } catch (q) {
  12673. ka(a.fileName + ".pdf", "data:application/pdf" + (c ? "" : ";base64") + ",", c ? b.output("blob") : b.output())
  12674. }
  12675. }
  12676. function wa(b, a, e) {
  12677. var c = 0;
  12678. "undefined" !== typeof e && (c = e.colspan);
  12679. if (0 <= c) {
  12680. for (var f = b.width, d = b.textPos.x,
  12681. n = a.table.columns.indexOf(a.column), l = 1; l < c; l++) f += a.table.columns[n + l].width;
  12682. 1 < c && ("right" === b.styles.halign ? d = b.textPos.x + f - b.width : "center" === b.styles.halign && (d = b.textPos.x + (f - b.width) / 2));
  12683. b.width = f;
  12684. b.textPos.x = d;
  12685. "undefined" !== typeof e && 1 < e.rowspan && (b.height *= e.rowspan);
  12686. if ("middle" === b.styles.valign || "bottom" === b.styles.valign) e = ("string" === typeof b.text ? b.text.split(/\r\n|\r|\n/g) : b.text).length || 1, 2 < e && (b.textPos.y -= (2 - 1.15) / 2 * a.row.styles.fontSize * (e - 2) / 3);
  12687. return !0
  12688. }
  12689. return !1
  12690. }
  12691. function xa(b,
  12692. a, e) {
  12693. "undefined" !== typeof b && null !== b && (b.hasAttribute("data-tableexport-canvas") ? (a = (new Date).getTime(), d(b).attr("data-tableexport-canvas", a), e.images[a] = {
  12694. url: '[data-tableexport-canvas="' + a + '"]',
  12695. src: null
  12696. }) : "undefined" !== a && null != a && a.each(function () {
  12697. if (d(this).is("img")) {
  12698. var a = ya(this.src);
  12699. e.images[a] = {url: this.src, src: this.src}
  12700. }
  12701. xa(b, d(this).children(), e)
  12702. }))
  12703. }
  12704. function Ka(b, a) {
  12705. function c(b) {
  12706. if (b.url) if (b.src) {
  12707. var c = new Image;
  12708. q = ++f;
  12709. c.crossOrigin = "Anonymous";
  12710. c.onerror = c.onload = function () {
  12711. if (c.complete &&
  12712. (0 === c.src.indexOf("data:image/") && (c.width = b.width || c.width || 0, c.height = b.height || c.height || 0), c.width + c.height)) {
  12713. var e = document.createElement("canvas"), d = e.getContext("2d");
  12714. e.width = c.width;
  12715. e.height = c.height;
  12716. d.drawImage(c, 0, 0);
  12717. b.src = e.toDataURL("image/png")
  12718. }
  12719. --f || a(q)
  12720. };
  12721. c.src = b.url
  12722. } else {
  12723. var e = d(b.url);
  12724. e.length && (q = ++f, html2canvas(e[0]).then(function (c) {
  12725. b.src = c.toDataURL("image/png");
  12726. --f || a(q)
  12727. }))
  12728. }
  12729. }
  12730. var q = 0, f = 0;
  12731. if ("undefined" !== typeof b.images) for (var h in b.images) b.images.hasOwnProperty(h) && c(b.images[h]);
  12732. (b = f) || (a(q), b = void 0);
  12733. return b
  12734. }
  12735. function za(b, c, e) {
  12736. c.each(function () {
  12737. if (d(this).is("div")) {
  12738. var c = fa(M(this, "background-color"), [255, 255, 255]),
  12739. f = fa(M(this, "border-top-color"), [0, 0, 0]), h = ha(this, "border-top-width", a.jspdf.unit),
  12740. n = this.getBoundingClientRect(), l = this.offsetLeft * e.wScaleFactor,
  12741. u = this.offsetTop * e.hScaleFactor, g = n.width * e.wScaleFactor;
  12742. n = n.height * e.hScaleFactor;
  12743. e.doc.setDrawColor.apply(void 0, f);
  12744. e.doc.setFillColor.apply(void 0, c);
  12745. e.doc.setLineWidth(h);
  12746. e.doc.rect(b.x + l, b.y + u, g, n, h ? "FD" : "F")
  12747. } else d(this).is("img") &&
  12748. (c = ya(this.src), ua(b, this, c, e));
  12749. za(b, d(this).children(), e)
  12750. })
  12751. }
  12752. function Aa(b, c, e) {
  12753. if ("function" === typeof e.onAutotableText) e.onAutotableText(e.doc, b, c); else {
  12754. var q = b.textPos.x, f = b.textPos.y, h = {halign: b.styles.halign, valign: b.styles.valign};
  12755. if (c.length) {
  12756. for (c = c[0]; c.previousSibling;) c = c.previousSibling;
  12757. for (var n = !1, l = !1; c;) {
  12758. var u = c.innerText || c.textContent || "", g = u.length && " " === u[0] ? " " : "",
  12759. k = 1 < u.length && " " === u[u.length - 1] ? " " : "";
  12760. !0 !== a.preserve.leadingWS && (u = g + la(u));
  12761. !0 !== a.preserve.trailingWS && (u = ma(u) +
  12762. k);
  12763. d(c).is("br") && (q = b.textPos.x, f += e.doc.internal.getFontSize());
  12764. d(c).is("b") ? n = !0 : d(c).is("i") && (l = !0);
  12765. (n || l) && e.doc.setFontType(n && l ? "bolditalic" : n ? "bold" : "italic");
  12766. if (g = e.doc.getStringUnitWidth(u) * e.doc.internal.getFontSize()) {
  12767. "linebreak" === b.styles.overflow && q > b.textPos.x && q + g > b.textPos.x + b.width && (0 <= ".,!%*;:=-".indexOf(u.charAt(0)) && (k = u.charAt(0), g = e.doc.getStringUnitWidth(k) * e.doc.internal.getFontSize(), q + g <= b.textPos.x + b.width && (e.doc.autoTableText(k, q, f, h), u = u.substring(1, u.length)), g =
  12768. e.doc.getStringUnitWidth(u) * e.doc.internal.getFontSize()), q = b.textPos.x, f += e.doc.internal.getFontSize());
  12769. if ("visible" !== b.styles.overflow) for (; u.length && q + g > b.textPos.x + b.width;) u = u.substring(0, u.length - 1), g = e.doc.getStringUnitWidth(u) * e.doc.internal.getFontSize();
  12770. e.doc.autoTableText(u, q, f, h);
  12771. q += g
  12772. }
  12773. if (n || l) d(c).is("b") ? n = !1 : d(c).is("i") && (l = !1), e.doc.setFontType(n || l ? n ? "bold" : "italic" : "normal");
  12774. c = c.nextSibling
  12775. }
  12776. b.textPos.x = q;
  12777. b.textPos.y = f
  12778. } else e.doc.autoTableText(b.text, b.textPos.x, b.textPos.y, h)
  12779. }
  12780. }
  12781. function W(b, a, e) {
  12782. return null == b ? "" : b.toString().replace(new RegExp(null == a ? "" : a.toString().replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"), "g"), e)
  12783. }
  12784. function la(b) {
  12785. return null == b ? "" : b.toString().replace(/^\s+/, "")
  12786. }
  12787. function ma(b) {
  12788. return null == b ? "" : b.toString().replace(/\s+$/, "")
  12789. }
  12790. function La(b) {
  12791. if (0 === a.date.html.length) return !1;
  12792. a.date.pattern.lastIndex = 0;
  12793. var c = a.date.pattern.exec(b);
  12794. if (null == c) return !1;
  12795. b = +c[a.date.match_y];
  12796. if (0 > b || 8099 < b) return !1;
  12797. var e = 1 * c[a.date.match_m];
  12798. c = 1 * c[a.date.match_d];
  12799. if (!isFinite(c)) return !1;
  12800. var d = new Date(b, e - 1, c, 0, 0, 0);
  12801. return d.getFullYear() === b && d.getMonth() === e - 1 && d.getDate() === c ? new Date(Date.UTC(b, e - 1, c, 0, 0, 0)) : !1
  12802. }
  12803. function na(b) {
  12804. b = b || "0";
  12805. "" !== a.numbers.html.thousandsSeparator && (b = W(b, a.numbers.html.thousandsSeparator, ""));
  12806. "." !== a.numbers.html.decimalMark && (b = W(b, a.numbers.html.decimalMark, "."));
  12807. return "number" === typeof b || !1 !== jQuery.isNumeric(b) ? b : !1
  12808. }
  12809. function Ma(b) {
  12810. -1 < b.indexOf("%") ? (b = na(b.replace(/%/g, "")), !1 !== b && (b /= 100)) : b = !1;
  12811. return b
  12812. }
  12813. function D(b, c, e, q) {
  12814. var f = "", h = "text";
  12815. if (null !== b) {
  12816. var n = d(b);
  12817. n.removeData("teUserDefText");
  12818. if (n[0].hasAttribute("data-tableexport-canvas")) var l = ""; else if (n[0].hasAttribute("data-tableexport-value")) l = (l = n.attr("data-tableexport-value")) ? l + "" : "", n.data("teUserDefText", 1); else if (l = n.html(), "function" === typeof a.onCellHtmlData) l = a.onCellHtmlData(n, c, e, l), n.data("teUserDefText", 1); else if ("" !== l) {
  12819. b = d.parseHTML(l);
  12820. var g = 0, k = 0;
  12821. l = "";
  12822. d.each(b, function () {
  12823. if (d(this).is("input")) l += n.find("input").eq(g++).val(); else if (d(this).is("select")) l +=
  12824. n.find("select option:selected").eq(k++).text(); else if (d(this).is("br")) l += "<br>"; else {
  12825. if ("undefined" === typeof d(this).html()) l += d(this).text(); else if (void 0 === jQuery().bootstrapTable || !1 === d(this).hasClass("fht-cell") && !1 === d(this).hasClass("filterControl") && 0 === n.parents(".detail-view").length) l += d(this).html();
  12826. if (d(this).is("a")) {
  12827. var b = n.find("a").attr("href") || "";
  12828. f = "function" === typeof a.onCellHtmlHyperlink ? f + a.onCellHtmlHyperlink(n, c, e, b, l) : "href" === a.htmlHyperlink ? f + b : f + l;
  12829. l = ""
  12830. }
  12831. }
  12832. })
  12833. }
  12834. if (l && "" !==
  12835. l && !0 === a.htmlContent) f = d.trim(l); else if (l && "" !== l) if ("" !== n.attr("data-tableexport-cellformat")) {
  12836. var m = l.replace(/\n/g, "\u2028").replace(/(<\s*br([^>]*)>)/gi, "\u2060"),
  12837. p = d("<div/>").html(m).contents();
  12838. b = !1;
  12839. m = "";
  12840. d.each(p.text().split("\u2028"), function (b, c) {
  12841. 0 < b && (m += " ");
  12842. !0 !== a.preserve.leadingWS && (c = la(c));
  12843. m += !0 !== a.preserve.trailingWS ? ma(c) : c
  12844. });
  12845. d.each(m.split("\u2060"), function (b, c) {
  12846. 0 < b && (f += "\n");
  12847. !0 !== a.preserve.leadingWS && (c = la(c));
  12848. !0 !== a.preserve.trailingWS && (c = ma(c));
  12849. f += c.replace(/\u00AD/g,
  12850. "")
  12851. });
  12852. f = f.replace(/\u00A0/g, " ");
  12853. if ("json" === a.type || "excel" === a.type && "xmlss" === a.mso.fileFormat || !1 === a.numbers.output) b = na(f), !1 !== b && (h = "number", f = Number(b)); else if (a.numbers.html.decimalMark !== a.numbers.output.decimalMark || a.numbers.html.thousandsSeparator !== a.numbers.output.thousandsSeparator) if (b = na(f), !1 !== b) {
  12854. p = ("" + b.substr(0 > b ? 1 : 0)).split(".");
  12855. 1 === p.length && (p[1] = "");
  12856. var t = 3 < p[0].length ? p[0].length % 3 : 0;
  12857. h = "number";
  12858. f = (0 > b ? "-" : "") + (a.numbers.output.thousandsSeparator ? (t ? p[0].substr(0, t) + a.numbers.output.thousandsSeparator :
  12859. "") + p[0].substr(t).replace(/(\d{3})(?=\d)/g, "$1" + a.numbers.output.thousandsSeparator) : p[0]) + (p[1].length ? a.numbers.output.decimalMark + p[1] : "")
  12860. }
  12861. } else f = l;
  12862. !0 === a.escape && (f = escape(f));
  12863. "function" === typeof a.onCellData && (f = a.onCellData(n, c, e, f, h), n.data("teUserDefText", 1))
  12864. }
  12865. void 0 !== q && (q.type = h);
  12866. return f
  12867. }
  12868. function Ba(b) {
  12869. return 0 < b.length && !0 === a.preventInjection && 0 <= "=+-@".indexOf(b.charAt(0)) ? "'" + b : b
  12870. }
  12871. function Na(b, a, e) {
  12872. return a + "-" + e.toLowerCase()
  12873. }
  12874. function fa(b, a) {
  12875. (b = /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(b)) &&
  12876. (a = [parseInt(b[1]), parseInt(b[2]), parseInt(b[3])]);
  12877. return a
  12878. }
  12879. function Ca(b) {
  12880. var a = M(b, "text-align"), e = M(b, "font-weight"), d = M(b, "font-style"), f = "";
  12881. "start" === a && (a = "rtl" === M(b, "direction") ? "right" : "left");
  12882. 700 <= e && (f = "bold");
  12883. "italic" === d && (f += d);
  12884. "" === f && (f = "normal");
  12885. a = {
  12886. style: {
  12887. align: a,
  12888. bcolor: fa(M(b, "background-color"), [255, 255, 255]),
  12889. color: fa(M(b, "color"), [0, 0, 0]),
  12890. fstyle: f
  12891. }, colspan: J(b), rowspan: T(b)
  12892. };
  12893. null !== b && (b = b.getBoundingClientRect(), a.rect = {width: b.width, height: b.height});
  12894. return a
  12895. }
  12896. function J(b) {
  12897. var a =
  12898. d(b).attr("data-tableexport-colspan");
  12899. "undefined" === typeof a && d(b).is("[colspan]") && (a = d(b).attr("colspan"));
  12900. return parseInt(a) || 0
  12901. }
  12902. function T(b) {
  12903. var a = d(b).attr("data-tableexport-rowspan");
  12904. "undefined" === typeof a && d(b).is("[rowspan]") && (a = d(b).attr("rowspan"));
  12905. return parseInt(a) || 0
  12906. }
  12907. function M(a, c) {
  12908. try {
  12909. return window.getComputedStyle ? (c = c.replace(/([a-z])([A-Z])/, Na), window.getComputedStyle(a, null).getPropertyValue(c)) : a.currentStyle ? a.currentStyle[c] : a.style[c]
  12910. } catch (e) {
  12911. }
  12912. return ""
  12913. }
  12914. function ha(a, c, e) {
  12915. c =
  12916. M(a, c).match(/\d+/);
  12917. if (null !== c) {
  12918. c = c[0];
  12919. a = a.parentElement;
  12920. var b = document.createElement("div");
  12921. b.style.overflow = "hidden";
  12922. b.style.visibility = "hidden";
  12923. a.appendChild(b);
  12924. b.style.width = 100 + e;
  12925. e = 100 / b.offsetWidth;
  12926. a.removeChild(b);
  12927. return c * e
  12928. }
  12929. return 0
  12930. }
  12931. function Oa(a) {
  12932. for (var b = new ArrayBuffer(a.length), e = new Uint8Array(b), d = 0; d !== a.length; ++d) e[d] = a.charCodeAt(d) & 255;
  12933. return b
  12934. }
  12935. function oa(a) {
  12936. var b = a.c, e = "";
  12937. for (++b; b; b = Math.floor((b - 1) / 26)) e = String.fromCharCode((b - 1) % 26 + 65) + e;
  12938. return e + ("" + (a.r + 1))
  12939. }
  12940. function pa(a,
  12941. c) {
  12942. if ("undefined" === typeof c || "number" === typeof c) return pa(a.s, a.e);
  12943. "string" !== typeof a && (a = oa(a));
  12944. "string" !== typeof c && (c = oa(c));
  12945. return a === c ? a : a + ":" + c
  12946. }
  12947. function Da(a, c) {
  12948. var b = Number(a);
  12949. if (isFinite(b)) return b;
  12950. var d = 1;
  12951. "" !== c.thousandsSeparator && (a = a.replace(new RegExp("([\\d])" + c.thousandsSeparator + "([\\d])", "g"), "$1$2"));
  12952. "." !== c.decimalMark && (a = a.replace(new RegExp("([\\d])" + c.decimalMark + "([\\d])", "g"), "$1.$2"));
  12953. a = a.replace(/[$]/g, "").replace(/[%]/g, function () {
  12954. d *= 100;
  12955. return ""
  12956. });
  12957. if (isFinite(b = Number(a))) return b /
  12958. d;
  12959. a = a.replace(/[(](.*)[)]/, function (a, b) {
  12960. d = -d;
  12961. return b
  12962. });
  12963. return isFinite(b = Number(a)) ? b / d : b
  12964. }
  12965. function ya(a) {
  12966. var b = 0, d;
  12967. if (0 === a.length) return b;
  12968. var q = 0;
  12969. for (d = a.length; q < d; q++) {
  12970. var f = a.charCodeAt(q);
  12971. b = (b << 5) - b + f;
  12972. b |= 0
  12973. }
  12974. return b
  12975. }
  12976. function N(b, c, d, q, f, h) {
  12977. var e = !0;
  12978. "function" === typeof a.onBeforeSaveToFile && (e = a.onBeforeSaveToFile(b, c, d, q, f), "boolean" !== typeof e && (e = !0));
  12979. if (e) try {
  12980. if (Ea = new Blob([b], {type: d + ";charset=" + q}), saveAs(Ea, c, !1 === h), "function" === typeof a.onAfterSaveToFile) a.onAfterSaveToFile(b, c)
  12981. } catch (l) {
  12982. ka(c,
  12983. "data:" + d + (q.length ? ";charset=" + q : "") + (f.length ? ";" + f : "") + ",", h ? "\ufeff" + b : b)
  12984. }
  12985. }
  12986. function ka(b, c, d) {
  12987. var e = window.navigator.userAgent;
  12988. if (!1 !== b && window.navigator.msSaveOrOpenBlob) window.navigator.msSaveOrOpenBlob(new Blob([d]), b); else if (!1 !== b && (0 < e.indexOf("MSIE ") || e.match(/Trident.*rv\:11\./))) {
  12989. if (c = document.createElement("iframe")) {
  12990. document.body.appendChild(c);
  12991. c.setAttribute("style", "display:none");
  12992. c.contentDocument.open("txt/plain", "replace");
  12993. c.contentDocument.write(d);
  12994. c.contentDocument.close();
  12995. c.contentWindow.focus();
  12996. switch (b.substr(b.lastIndexOf(".") + 1)) {
  12997. case "doc":
  12998. case "json":
  12999. case "png":
  13000. case "pdf":
  13001. case "xls":
  13002. case "xlsx":
  13003. b += ".txt"
  13004. }
  13005. c.contentDocument.execCommand("SaveAs", !0, b);
  13006. document.body.removeChild(c)
  13007. }
  13008. } else {
  13009. var f = document.createElement("a");
  13010. if (f) {
  13011. var h = null;
  13012. f.style.display = "none";
  13013. !1 !== b ? f.download = b : f.target = "_blank";
  13014. "object" === typeof d ? (window.URL = window.URL || window.webkitURL, e = [], e.push(d), h = window.URL.createObjectURL(new Blob(e, {type: c})), f.href = h) : 0 <= c.toLowerCase().indexOf("base64,") ?
  13015. f.href = c + L(d) : f.href = c + encodeURIComponent(d);
  13016. document.body.appendChild(f);
  13017. if (document.createEvent) null === ia && (ia = document.createEvent("MouseEvents")), ia.initEvent("click", !0, !1), f.dispatchEvent(ia); else if (document.createEventObject) f.fireEvent("onclick"); else if ("function" === typeof f.onclick) f.onclick();
  13018. setTimeout(function () {
  13019. h && window.URL.revokeObjectURL(h);
  13020. document.body.removeChild(f);
  13021. if ("function" === typeof a.onAfterSaveToFile) a.onAfterSaveToFile(d, b)
  13022. }, 100)
  13023. }
  13024. }
  13025. }
  13026. function L(a) {
  13027. var b, d = "", q = 0;
  13028. if ("string" ===
  13029. typeof a) {
  13030. a = a.replace(/\x0d\x0a/g, "\n");
  13031. var f = "";
  13032. for (b = 0; b < a.length; b++) {
  13033. var h = a.charCodeAt(b);
  13034. 128 > h ? f += String.fromCharCode(h) : (127 < h && 2048 > h ? f += String.fromCharCode(h >> 6 | 192) : (f += String.fromCharCode(h >> 12 | 224), f += String.fromCharCode(h >> 6 & 63 | 128)), f += String.fromCharCode(h & 63 | 128))
  13035. }
  13036. a = f
  13037. }
  13038. for (; q < a.length;) {
  13039. var n = a.charCodeAt(q++);
  13040. f = a.charCodeAt(q++);
  13041. b = a.charCodeAt(q++);
  13042. h = n >> 2;
  13043. n = (n & 3) << 4 | f >> 4;
  13044. var l = (f & 15) << 2 | b >> 6;
  13045. var g = b & 63;
  13046. isNaN(f) ? l = g = 64 : isNaN(b) && (g = 64);
  13047. d = d + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(h) +
  13048. "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(n) + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(l) + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(g)
  13049. }
  13050. return d
  13051. }
  13052. var a = {
  13053. csvEnclosure: '"',
  13054. csvSeparator: ",",
  13055. csvUseBOM: !0,
  13056. date: {html: "dd/mm/yyyy"},
  13057. displayTableName: !1,
  13058. escape: !1,
  13059. exportHiddenCells: !1,
  13060. fileName: "tableExport",
  13061. htmlContent: !1,
  13062. htmlHyperlink: "content",
  13063. ignoreColumn: [],
  13064. ignoreRow: [],
  13065. jsonScope: "all",
  13066. jspdf: {
  13067. orientation: "p",
  13068. unit: "pt",
  13069. format: "a4",
  13070. margins: {left: 20, right: 10, top: 10, bottom: 10},
  13071. onDocCreated: null,
  13072. autotable: {
  13073. styles: {
  13074. cellPadding: 2,
  13075. rowHeight: 12,
  13076. fontSize: 8,
  13077. fillColor: 255,
  13078. textColor: 50,
  13079. fontStyle: "normal",
  13080. overflow: "ellipsize",
  13081. halign: "inherit",
  13082. valign: "middle"
  13083. },
  13084. headerStyles: {
  13085. fillColor: [52, 73, 94],
  13086. textColor: 255,
  13087. fontStyle: "bold",
  13088. halign: "inherit",
  13089. valign: "middle"
  13090. },
  13091. alternateRowStyles: {fillColor: 245},
  13092. tableExport: {
  13093. doc: null,
  13094. onAfterAutotable: null,
  13095. onBeforeAutotable: null,
  13096. onAutotableText: null,
  13097. onTable: null,
  13098. outputImages: !0
  13099. }
  13100. }
  13101. },
  13102. mso: {
  13103. fileFormat: "xlshtml",
  13104. onMsoNumberFormat: null,
  13105. pageFormat: "a4",
  13106. pageOrientation: "portrait",
  13107. rtl: !1,
  13108. styles: [],
  13109. worksheetName: "",
  13110. xslx: {formatId: {date: 14, numbers: 2}}
  13111. },
  13112. numbers: {
  13113. html: {decimalMark: ".", thousandsSeparator: ","},
  13114. output: {decimalMark: ".", thousandsSeparator: ","}
  13115. },
  13116. onAfterSaveToFile: null,
  13117. onBeforeSaveToFile: null,
  13118. onCellData: null,
  13119. onCellHtmlData: null,
  13120. onCellHtmlHyperlink: null,
  13121. onIgnoreRow: null,
  13122. onTableExportBegin: null,
  13123. onTableExportEnd: null,
  13124. outputMode: "file",
  13125. pdfmake: {
  13126. enabled: !1, docDefinition: {
  13127. pageSize: "A4", pageOrientation: "portrait",
  13128. styles: {
  13129. header: {
  13130. background: "#34495E",
  13131. color: "#FFFFFF",
  13132. bold: !0,
  13133. alignment: "center",
  13134. fillColor: "#34495E"
  13135. }, alternateRow: {fillColor: "#f5f5f5"}
  13136. }, defaultStyle: {color: "#000000", fontSize: 8, font: "Roboto"}
  13137. }, fonts: {}
  13138. },
  13139. preserve: {leadingWS: !1, trailingWS: !1},
  13140. preventInjection: !0,
  13141. sql: {tableEnclosure: "`", columnEnclosure: "`"},
  13142. tbodySelector: "tr",
  13143. tfootSelector: "tr",
  13144. theadSelector: "tr",
  13145. tableName: "Table",
  13146. type: "csv"
  13147. }, O = {
  13148. a0: [2383.94, 3370.39],
  13149. a1: [1683.78, 2383.94],
  13150. a2: [1190.55, 1683.78],
  13151. a3: [841.89, 1190.55],
  13152. a4: [595.28, 841.89],
  13153. a5: [419.53,
  13154. 595.28],
  13155. a6: [297.64, 419.53],
  13156. a7: [209.76, 297.64],
  13157. a8: [147.4, 209.76],
  13158. a9: [104.88, 147.4],
  13159. a10: [73.7, 104.88],
  13160. b0: [2834.65, 4008.19],
  13161. b1: [2004.09, 2834.65],
  13162. b2: [1417.32, 2004.09],
  13163. b3: [1000.63, 1417.32],
  13164. b4: [708.66, 1000.63],
  13165. b5: [498.9, 708.66],
  13166. b6: [354.33, 498.9],
  13167. b7: [249.45, 354.33],
  13168. b8: [175.75, 249.45],
  13169. b9: [124.72, 175.75],
  13170. b10: [87.87, 124.72],
  13171. c0: [2599.37, 3676.54],
  13172. c1: [1836.85, 2599.37],
  13173. c2: [1298.27, 1836.85],
  13174. c3: [918.43, 1298.27],
  13175. c4: [649.13, 918.43],
  13176. c5: [459.21, 649.13],
  13177. c6: [323.15, 459.21],
  13178. c7: [229.61, 323.15],
  13179. c8: [161.57, 229.61],
  13180. c9: [113.39,
  13181. 161.57],
  13182. c10: [79.37, 113.39],
  13183. dl: [311.81, 623.62],
  13184. letter: [612, 792],
  13185. "government-letter": [576, 756],
  13186. legal: [612, 1008],
  13187. "junior-legal": [576, 360],
  13188. ledger: [1224, 792],
  13189. tabloid: [792, 1224],
  13190. "credit-card": [153, 243]
  13191. }, B = this, ia = null, r = [], w = [], p = 0, t = "", S = [], G = [], Ea, K = [], V = !1;
  13192. d.extend(!0, a, k);
  13193. "xlsx" === a.type && (a.mso.fileFormat = a.type, a.type = "excel");
  13194. "undefined" !== typeof a.excelFileFormat && "undefined" === a.mso.fileFormat && (a.mso.fileFormat = a.excelFileFormat);
  13195. "undefined" !== typeof a.excelPageFormat && "undefined" === a.mso.pageFormat &&
  13196. (a.mso.pageFormat = a.excelPageFormat);
  13197. "undefined" !== typeof a.excelPageOrientation && "undefined" === a.mso.pageOrientation && (a.mso.pageOrientation = a.excelPageOrientation);
  13198. "undefined" !== typeof a.excelRTL && "undefined" === a.mso.rtl && (a.mso.rtl = a.excelRTL);
  13199. "undefined" !== typeof a.excelstyles && "undefined" === a.mso.styles && (a.mso.styles = a.excelstyles);
  13200. "undefined" !== typeof a.onMsoNumberFormat && "undefined" === a.mso.onMsoNumberFormat && (a.mso.onMsoNumberFormat = a.onMsoNumberFormat);
  13201. "undefined" !== typeof a.worksheetName &&
  13202. "undefined" === a.mso.worksheetName && (a.mso.worksheetName = a.worksheetName);
  13203. a.mso.pageOrientation = "l" === a.mso.pageOrientation.substr(0, 1) ? "landscape" : "portrait";
  13204. a.date.html = a.date.html || "";
  13205. if (a.date.html.length) {
  13206. k = [];
  13207. k.dd = "(3[01]|[12][0-9]|0?[1-9])";
  13208. k.mm = "(1[012]|0?[1-9])";
  13209. k.yyyy = "((?:1[6-9]|2[0-2])\\d{2})";
  13210. k.yy = "(\\d{2})";
  13211. var z = a.date.html.match(/[^a-zA-Z0-9]/)[0];
  13212. z = a.date.html.toLowerCase().split(z);
  13213. a.date.regex = "^\\s*";
  13214. a.date.regex += k[z[0]];
  13215. a.date.regex += "(.)";
  13216. a.date.regex += k[z[1]];
  13217. a.date.regex +=
  13218. "\\2";
  13219. a.date.regex += k[z[2]];
  13220. a.date.regex += "\\s*$";
  13221. a.date.pattern = new RegExp(a.date.regex, "g");
  13222. k = z.indexOf("dd") + 1;
  13223. a.date.match_d = k + (1 < k ? 1 : 0);
  13224. k = z.indexOf("mm") + 1;
  13225. a.date.match_m = k + (1 < k ? 1 : 0);
  13226. k = (0 <= z.indexOf("yyyy") ? z.indexOf("yyyy") : z.indexOf("yy")) + 1;
  13227. a.date.match_y = k + (1 < k ? 1 : 0)
  13228. }
  13229. S = R(B);
  13230. if ("function" === typeof a.onTableExportBegin) a.onTableExportBegin();
  13231. if ("csv" === a.type || "tsv" === a.type || "txt" === a.type) {
  13232. var P = "", Z = 0;
  13233. G = [];
  13234. p = 0;
  13235. var qa = function (b, c, e) {
  13236. b.each(function () {
  13237. t = "";
  13238. E(this, c, p, e + b.length, function (b,
  13239. c, d) {
  13240. var e = t, f = "";
  13241. if (null !== b) if (b = D(b, c, d), c = null === b || "" === b ? "" : b.toString(), "tsv" === a.type) b instanceof Date && b.toLocaleString(), f = W(c, "\t", " "); else if (b instanceof Date) f = a.csvEnclosure + b.toLocaleString() + a.csvEnclosure; else if (f = Ba(c), f = W(f, a.csvEnclosure, a.csvEnclosure + a.csvEnclosure), 0 <= f.indexOf(a.csvSeparator) || /[\r\n ]/g.test(f)) f = a.csvEnclosure + f + a.csvEnclosure;
  13242. t = e + (f + ("tsv" === a.type ? "\t" : a.csvSeparator))
  13243. });
  13244. t = d.trim(t).substring(0, t.length - 1);
  13245. 0 < t.length && (0 < P.length && (P += "\n"), P += t);
  13246. p++
  13247. });
  13248. return b.length
  13249. };
  13250. Z += qa(d(B).find("thead").first().find(a.theadSelector), "th,td", Z);
  13251. v(d(B), "tbody").each(function () {
  13252. Z += qa(v(d(this), a.tbodySelector), "td,th", Z)
  13253. });
  13254. a.tfootSelector.length && qa(d(B).find("tfoot").first().find(a.tfootSelector), "td,th", Z);
  13255. P += "\n";
  13256. if ("string" === a.outputMode) return P;
  13257. if ("base64" === a.outputMode) return L(P);
  13258. if ("window" === a.outputMode) {
  13259. ka(!1, "data:text/" + ("csv" === a.type ? "csv" : "plain") + ";charset=utf-8,", P);
  13260. return
  13261. }
  13262. N(P, a.fileName + "." + a.type, "text/" + ("csv" === a.type ? "csv" : "plain"),
  13263. "utf-8", "", "csv" === a.type && a.csvUseBOM)
  13264. } else if ("sql" === a.type) {
  13265. p = 0;
  13266. G = [];
  13267. var A = "INSERT INTO " + a.sql.tableEnclosure + a.tableName + a.sql.tableEnclosure + " (";
  13268. r = y(d(B));
  13269. d(r).each(function () {
  13270. E(this, "th,td", p, r.length, function (b, c, d) {
  13271. b = D(b, c, d) || "";
  13272. -1 < b.indexOf(a.sql.columnEnclosure) && (b = W(b.toString(), a.sql.columnEnclosure, a.sql.columnEnclosure + a.sql.columnEnclosure));
  13273. A += a.sql.columnEnclosure + b + a.sql.columnEnclosure + ","
  13274. });
  13275. p++;
  13276. A = d.trim(A).substring(0, A.length - 1)
  13277. });
  13278. A += ") VALUES ";
  13279. w = C(d(B));
  13280. d(w).each(function () {
  13281. t =
  13282. "";
  13283. E(this, "td,th", p, r.length + w.length, function (a, c, d) {
  13284. a = D(a, c, d) || "";
  13285. -1 < a.indexOf("'") && (a = W(a.toString(), "'", "''"));
  13286. t += "'" + a + "',"
  13287. });
  13288. 3 < t.length && (A += "(" + t, A = d.trim(A).substring(0, A.length - 1), A += "),");
  13289. p++
  13290. });
  13291. A = d.trim(A).substring(0, A.length - 1);
  13292. A += ";";
  13293. if ("string" === a.outputMode) return A;
  13294. if ("base64" === a.outputMode) return L(A);
  13295. N(A, a.fileName + ".sql", "application/sql", "utf-8", "", !1)
  13296. } else if ("json" === a.type) {
  13297. var X = [];
  13298. G = [];
  13299. r = y(d(B));
  13300. d(r).each(function () {
  13301. var a = [];
  13302. E(this, "th,td", p, r.length, function (b, d, g) {
  13303. a.push(D(b,
  13304. d, g))
  13305. });
  13306. X.push(a)
  13307. });
  13308. var ra = [];
  13309. w = C(d(B));
  13310. d(w).each(function () {
  13311. var a = {}, c = 0;
  13312. E(this, "td,th", p, r.length + w.length, function (b, d, f) {
  13313. X.length ? a[X[X.length - 1][c]] = D(b, d, f) : a[c] = D(b, d, f);
  13314. c++
  13315. });
  13316. !1 === d.isEmptyObject(a) && ra.push(a);
  13317. p++
  13318. });
  13319. k = "head" === a.jsonScope ? JSON.stringify(X) : "data" === a.jsonScope ? JSON.stringify(ra) : JSON.stringify({
  13320. header: X,
  13321. data: ra
  13322. });
  13323. if ("string" === a.outputMode) return k;
  13324. if ("base64" === a.outputMode) return L(k);
  13325. N(k, a.fileName + ".json", "application/json", "utf-8", "base64", !1)
  13326. } else if ("xml" === a.type) {
  13327. p =
  13328. 0;
  13329. G = [];
  13330. var Q = '<?xml version="1.0" encoding="utf-8"?>';
  13331. Q += "<tabledata><fields>";
  13332. r = y(d(B));
  13333. d(r).each(function () {
  13334. E(this, "th,td", p, r.length, function (a, d, e) {
  13335. Q += "<field>" + D(a, d, e) + "</field>"
  13336. });
  13337. p++
  13338. });
  13339. Q += "</fields><data>";
  13340. var Fa = 1;
  13341. w = C(d(B));
  13342. d(w).each(function () {
  13343. var a = 1;
  13344. t = "";
  13345. E(this, "td,th", p, r.length + w.length, function (b, d, g) {
  13346. t += "<column-" + a + ">" + D(b, d, g) + "</column-" + a + ">";
  13347. a++
  13348. });
  13349. 0 < t.length && "<column-1></column-1>" !== t && (Q += '<row id="' + Fa + '">' + t + "</row>", Fa++);
  13350. p++
  13351. });
  13352. Q += "</data></tabledata>";
  13353. if ("string" === a.outputMode) return Q;
  13354. if ("base64" === a.outputMode) return L(Q);
  13355. N(Q, a.fileName + ".xml", "application/xml", "utf-8", "base64", !1)
  13356. } else if ("excel" === a.type && "xmlss" === a.mso.fileFormat) {
  13357. var sa = [], F = [];
  13358. d(B).filter(function () {
  13359. return I(d(this))
  13360. }).each(function () {
  13361. function b(a, b, c) {
  13362. var f = [];
  13363. d(a).each(function () {
  13364. var b = 0, e = 0;
  13365. t = "";
  13366. E(this, "td,th", p, c + a.length, function (a, c, h) {
  13367. if (null !== a) {
  13368. var l = "";
  13369. c = D(a, c, h);
  13370. h = "String";
  13371. if (!1 !== jQuery.isNumeric(c)) h = "Number"; else {
  13372. var n = Ma(c);
  13373. !1 !== n && (c = n, h = "Number", l += ' ss:StyleID="pct1"')
  13374. }
  13375. "Number" !== h && (c =
  13376. c.replace(/\n/g, "<br>"));
  13377. n = J(a);
  13378. a = T(a);
  13379. d.each(f, function () {
  13380. if (p >= this.s.r && p <= this.e.r && e >= this.s.c && e <= this.e.c) for (var a = 0; a <= this.e.c - this.s.c; ++a) e++, b++
  13381. });
  13382. if (a || n) a = a || 1, n = n || 1, f.push({
  13383. s: {r: p, c: e},
  13384. e: {r: p + a - 1, c: e + n - 1}
  13385. });
  13386. 1 < n && (l += ' ss:MergeAcross="' + (n - 1) + '"', e += n - 1);
  13387. 1 < a && (l += ' ss:MergeDown="' + (a - 1) + '" ss:StyleID="rsp1"');
  13388. 0 < b && (l += ' ss:Index="' + (e + 1) + '"', b = 0);
  13389. t += "<Cell" + l + '><Data ss:Type="' + h + '">' + d("<div />").text(c).html() + "</Data></Cell>\r";
  13390. e++
  13391. }
  13392. });
  13393. 0 < t.length && (H += '<Row ss:AutoFitHeight="0">\r' +
  13394. t + "</Row>\r");
  13395. p++
  13396. });
  13397. return a.length
  13398. }
  13399. var c = d(this), e = "";
  13400. "string" === typeof a.mso.worksheetName && a.mso.worksheetName.length ? e = a.mso.worksheetName + " " + (F.length + 1) : "undefined" !== typeof a.mso.worksheetName[F.length] && (e = a.mso.worksheetName[F.length]);
  13401. e.length || (e = c.find("caption").text() || "");
  13402. e.length || (e = "Table " + (F.length + 1));
  13403. e = d.trim(e.replace(/[\\\/[\]*:?'"]/g, "").substring(0, 31));
  13404. F.push(d("<div />").text(e).html());
  13405. !1 === a.exportHiddenCells && (K = c.find("tr, th, td").filter(":hidden"), V = 0 < K.length);
  13406. p = 0;
  13407. S = R(this);
  13408. H = "<Table>\r";
  13409. e = b(y(c), "th,td", 0);
  13410. b(C(c), "td,th", e);
  13411. H += "</Table>\r";
  13412. sa.push(H)
  13413. });
  13414. k = {};
  13415. z = {};
  13416. for (var m, aa, Y = 0, ea = F.length; Y < ea; Y++) m = F[Y], aa = k[m], aa = k[m] = null == aa ? 1 : aa + 1, 2 === aa && (F[z[m]] = F[z[m]].substring(0, 29) + "-1"), 1 < k[m] ? F[Y] = F[Y].substring(0, 29) + "-" + k[m] : z[m] = Y;
  13417. k = '<?xml version="1.0" encoding="UTF-8"?>\r<?mso-application progid="Excel.Sheet"?>\r<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"\r xmlns:o="urn:schemas-microsoft-com:office:office"\r xmlns:x="urn:schemas-microsoft-com:office:excel"\r xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"\r xmlns:html="http://www.w3.org/TR/REC-html40">\r<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">\r <Created>' +
  13418. (new Date).toISOString() + '</Created>\r</DocumentProperties>\r<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">\r <AllowPNG/>\r</OfficeDocumentSettings>\r<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">\r <WindowHeight>9000</WindowHeight>\r <WindowWidth>13860</WindowWidth>\r <WindowTopX>0</WindowTopX>\r <WindowTopY>0</WindowTopY>\r <ProtectStructure>False</ProtectStructure>\r <ProtectWindows>False</ProtectWindows>\r</ExcelWorkbook>\r<Styles>\r <Style ss:ID="Default" ss:Name="Normal">\r <Alignment ss:Vertical="Bottom"/>\r <Borders/>\r <Font/>\r <Interior/>\r <NumberFormat/>\r <Protection/>\r </Style>\r <Style ss:ID="rsp1">\r <Alignment ss:Vertical="Center"/>\r </Style>\r <Style ss:ID="pct1">\r <NumberFormat ss:Format="Percent"/>\r </Style>\r</Styles>\r';
  13419. for (z = 0; z < sa.length; z++) k += '<Worksheet ss:Name="' + F[z] + '" ss:RightToLeft="' + (a.mso.rtl ? "1" : "0") + '">\r' + sa[z], k = a.mso.rtl ? k + '<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">\r<DisplayRightToLeft/>\r</WorksheetOptions>\r' : k + '<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"/>\r', k += "</Worksheet>\r";
  13420. k += "</Workbook>\r";
  13421. if ("string" === a.outputMode) return k;
  13422. if ("base64" === a.outputMode) return L(k);
  13423. N(k, a.fileName + ".xml", "application/xml", "utf-8", "base64", !1)
  13424. } else if ("excel" ===
  13425. a.type && "xlsx" === a.mso.fileFormat) {
  13426. var ba = [], Ga = XLSX.utils.book_new();
  13427. d(B).filter(function () {
  13428. return I(d(this))
  13429. }).each(function () {
  13430. for (var b = d(this), c = {}, e = this.getElementsByTagName("tr"), g = {
  13431. s: {r: 0, c: 0},
  13432. e: {r: 0, c: 0}
  13433. }, f = [], h, n = [], l = 0, u = 0, k, m, p, t, r, w = XLSX.SSF.get_table(); l < e.length && 1E7 > u; ++l) if (k = e[l], m = !1, "function" === typeof a.onIgnoreRow && (m = a.onIgnoreRow(d(k), l)), !0 !== m && (0 === a.ignoreRow.length || -1 === d.inArray(l, a.ignoreRow) && -1 === d.inArray(l - e.length, a.ignoreRow)) && !1 !== I(d(k))) {
  13434. var y = k.children,
  13435. B = 0;
  13436. for (k = 0; k < y.length; ++k) r = y[k], t = +J(r) || 1, B += t;
  13437. var z = 0;
  13438. for (k = m = 0; k < y.length; ++k) if (r = y[k], t = +J(r) || 1, h = k + z, !ta(d(r), B, h + (h < m ? m - h : 0))) {
  13439. z += t - 1;
  13440. for (h = 0; h < f.length; ++h) {
  13441. var v = f[h];
  13442. v.s.c == m && v.s.r <= u && u <= v.e.r && (m = v.e.c + 1, h = -1)
  13443. }
  13444. (0 < (p = +T(r)) || 1 < t) && f.push({s: {r: u, c: m}, e: {r: u + (p || 1) - 1, c: m + t - 1}});
  13445. var C = {type: ""};
  13446. h = D(r, l, k + z, C);
  13447. v = {t: "s", v: h};
  13448. var A = "";
  13449. if ("" !== (d(r).attr("data-tableexport-cellformat") || "")) {
  13450. var x = parseInt(d(r).attr("data-tableexport-xlsxformatid") || 0);
  13451. 0 === x && "function" === typeof a.mso.xslx.formatId.numbers &&
  13452. (x = a.mso.xslx.formatId.numbers(d(r), l, k + z));
  13453. 0 === x && "function" === typeof a.mso.xslx.formatId.date && (x = a.mso.xslx.formatId.date(d(r), l, k + z));
  13454. if (49 === x || "@" === x) A = "s"; else if ("number" === C.type || 0 < x && 14 > x || 36 < x && 41 > x || 48 === x) A = "n"; else if ("date" === C.type || 13 < x && 37 > x || 44 < x && 48 > x || 56 === x) A = "d"
  13455. } else A = "s";
  13456. if (null != h) if (0 === h.length) v.t = "z"; else if (0 !== h.trim().length) if ("s" === A) d(r).find("a").length && (h = "href" !== a.htmlHyperlink ? h : "", v = {f: '=HYPERLINK("' + d(r).find("a").attr("href") + (h.length ? '","' + h : "") + '")'});
  13457. else if ("function" === C.type) v = {f: h}; else if ("TRUE" === h) v = {
  13458. t: "b",
  13459. v: !0
  13460. }; else if ("FALSE" === h) v = {
  13461. t: "b",
  13462. v: !1
  13463. }; else if ("n" === A || isFinite(Da(h, a.numbers.output))) {
  13464. if (r = Da(h, a.numbers.output), 0 === x && "function" !== typeof a.mso.xslx.formatId.numbers && (x = a.mso.xslx.formatId.numbers), isFinite(r) || isFinite(h)) v = {
  13465. t: "n",
  13466. v: isFinite(r) ? r : h,
  13467. z: "string" === typeof x ? x : x in w ? w[x] : "0.00"
  13468. }
  13469. } else if (!1 !== (r = La(h)) || "d" === A) 0 === x && "function" !== typeof a.mso.xslx.formatId.date && (x = a.mso.xslx.formatId.date), v = {
  13470. t: "d", v: !1 !== r ? r :
  13471. h, z: "string" === typeof x ? x : x in w ? w[x] : "m/d/yy"
  13472. };
  13473. c[oa({c: m, r: u})] = v;
  13474. g.e.c < m && (g.e.c = m);
  13475. m += t
  13476. }
  13477. ++u
  13478. }
  13479. f.length && (c["!merges"] = f);
  13480. n.length && (c["!rows"] = n);
  13481. g.e.r = u - 1;
  13482. c["!ref"] = pa(g);
  13483. 1E7 <= u && (c["!fullref"] = pa((g.e.r = e.length - l + u - 1, g)));
  13484. e = "";
  13485. "string" === typeof a.mso.worksheetName && a.mso.worksheetName.length ? e = a.mso.worksheetName + " " + (ba.length + 1) : "undefined" !== typeof a.mso.worksheetName[ba.length] && (e = a.mso.worksheetName[ba.length]);
  13486. e.length || (e = b.find("caption").text() || "");
  13487. e.length || (e = "Table " + (ba.length +
  13488. 1));
  13489. e = d.trim(e.replace(/[\\\/[\]*:?'"]/g, "").substring(0, 31));
  13490. ba.push(e);
  13491. XLSX.utils.book_append_sheet(Ga, c, e)
  13492. });
  13493. k = XLSX.write(Ga, {type: "binary", bookType: a.mso.fileFormat, bookSST: !1});
  13494. N(Oa(k), a.fileName + "." + a.mso.fileFormat, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "UTF-8", "", !1)
  13495. } else if ("excel" === a.type || "xls" === a.type || "word" === a.type || "doc" === a.type) {
  13496. k = "excel" === a.type || "xls" === a.type ? "excel" : "word";
  13497. z = "excel" === k ? "xls" : "doc";
  13498. m = 'xmlns:x="urn:schemas-microsoft-com:office:' +
  13499. k + '"';
  13500. var H = "", ca = "";
  13501. d(B).filter(function () {
  13502. return I(d(this))
  13503. }).each(function () {
  13504. var b = d(this);
  13505. "" === ca && (ca = a.mso.worksheetName || b.find("caption").text() || "Table", ca = d.trim(ca.replace(/[\\\/[\]*:?'"]/g, "").substring(0, 31)));
  13506. !1 === a.exportHiddenCells && (K = b.find("tr, th, td").filter(":hidden"), V = 0 < K.length);
  13507. p = 0;
  13508. G = [];
  13509. S = R(this);
  13510. H += "<table><thead>";
  13511. r = y(b);
  13512. d(r).each(function () {
  13513. var b = d(this);
  13514. t = "";
  13515. E(this, "th,td", p, r.length, function (d, c, f) {
  13516. if (null !== d) {
  13517. var e = "";
  13518. t += "<th";
  13519. if (a.mso.styles.length) {
  13520. var n = document.defaultView.getComputedStyle(d,
  13521. null), l = document.defaultView.getComputedStyle(b[0], null), g;
  13522. for (g in a.mso.styles) {
  13523. var k = n[a.mso.styles[g]];
  13524. "" === k && (k = l[a.mso.styles[g]]);
  13525. "" !== k && "0px none rgb(0, 0, 0)" !== k && "rgba(0, 0, 0, 0)" !== k && (e += "" === e ? 'style="' : ";", e += a.mso.styles[g] + ":" + k)
  13526. }
  13527. }
  13528. "" !== e && (t += " " + e + '"');
  13529. e = J(d);
  13530. 0 < e && (t += ' colspan="' + e + '"');
  13531. e = T(d);
  13532. 0 < e && (t += ' rowspan="' + e + '"');
  13533. t += ">" + D(d, c, f) + "</th>"
  13534. }
  13535. });
  13536. 0 < t.length && (H += "<tr>" + t + "</tr>");
  13537. p++
  13538. });
  13539. H += "</thead><tbody>";
  13540. w = C(b);
  13541. d(w).each(function () {
  13542. var b = d(this);
  13543. t = "";
  13544. E(this, "td,th", p, r.length +
  13545. w.length, function (c, g, f) {
  13546. if (null !== c) {
  13547. var e = D(c, g, f), n = "", l = d(c).attr("data-tableexport-msonumberformat");
  13548. "undefined" === typeof l && "function" === typeof a.mso.onMsoNumberFormat && (l = a.mso.onMsoNumberFormat(c, g, f));
  13549. "undefined" !== typeof l && "" !== l && (n = "style=\"mso-number-format:'" + l + "'");
  13550. if (a.mso.styles.length) {
  13551. g = document.defaultView.getComputedStyle(c, null);
  13552. f = document.defaultView.getComputedStyle(b[0], null);
  13553. for (var k in a.mso.styles) l = g[a.mso.styles[k]], "" === l && (l = f[a.mso.styles[k]]), "" !== l && "0px none rgb(0, 0, 0)" !==
  13554. l && "rgba(0, 0, 0, 0)" !== l && (n += "" === n ? 'style="' : ";", n += a.mso.styles[k] + ":" + l)
  13555. }
  13556. t += "<td";
  13557. "" !== n && (t += " " + n + '"');
  13558. n = J(c);
  13559. 0 < n && (t += ' colspan="' + n + '"');
  13560. c = T(c);
  13561. 0 < c && (t += ' rowspan="' + c + '"');
  13562. "string" === typeof e && "" !== e && (e = Ba(e), e = e.replace(/\n/g, "<br>"));
  13563. t += ">" + e + "</td>"
  13564. }
  13565. });
  13566. 0 < t.length && (H += "<tr>" + t + "</tr>");
  13567. p++
  13568. });
  13569. a.displayTableName && (H += "<tr><td></td></tr><tr><td></td></tr><tr><td>" + D(d("<p>" + a.tableName + "</p>")) + "</td></tr>");
  13570. H += "</tbody></table>"
  13571. });
  13572. m = '<html xmlns:o="urn:schemas-microsoft-com:office:office" ' +
  13573. m + ' xmlns="http://www.w3.org/TR/REC-html40">' + ('<meta http-equiv="content-type" content="application/vnd.ms-' + k + '; charset=UTF-8">') + "<head>";
  13574. "excel" === k && (m += "\x3c!--[if gte mso 9]>", m += "<xml>", m += "<x:ExcelWorkbook>", m += "<x:ExcelWorksheets>", m += "<x:ExcelWorksheet>", m += "<x:Name>", m += ca, m += "</x:Name>", m += "<x:WorksheetOptions>", m += "<x:DisplayGridlines/>", a.mso.rtl && (m += "<x:DisplayRightToLeft/>"), m += "</x:WorksheetOptions>", m += "</x:ExcelWorksheet>", m += "</x:ExcelWorksheets>", m += "</x:ExcelWorkbook>", m +=
  13575. "</xml>", m += "<![endif]--\x3e");
  13576. m += "<style>";
  13577. m += "@page { size:" + a.mso.pageOrientation + "; mso-page-orientation:" + a.mso.pageOrientation + "; }";
  13578. m += "@page Section1 {size:" + O[a.mso.pageFormat][0] + "pt " + O[a.mso.pageFormat][1] + "pt";
  13579. m += "; margin:1.0in 1.25in 1.0in 1.25in;mso-header-margin:.5in;mso-footer-margin:.5in;mso-paper-source:0;}";
  13580. m += "div.Section1 {page:Section1;}";
  13581. m += "@page Section2 {size:" + O[a.mso.pageFormat][1] + "pt " + O[a.mso.pageFormat][0] + "pt";
  13582. m += ";mso-page-orientation:" + a.mso.pageOrientation + ";margin:1.25in 1.0in 1.25in 1.0in;mso-header-margin:.5in;mso-footer-margin:.5in;mso-paper-source:0;}";
  13583. m += "div.Section2 {page:Section2;}";
  13584. m += "br {mso-data-placement:same-cell;}";
  13585. m += "</style>";
  13586. m += "</head>";
  13587. m += "<body>";
  13588. m += '<div class="Section' + ("landscape" === a.mso.pageOrientation ? "2" : "1") + '">';
  13589. m += H;
  13590. m += "</div>";
  13591. m += "</body>";
  13592. m += "</html>";
  13593. if ("string" === a.outputMode) return m;
  13594. if ("base64" === a.outputMode) return L(m);
  13595. N(m, a.fileName + "." + z, "application/vnd.ms-" + k, "", "base64", !1)
  13596. } else if ("png" === a.type) html2canvas(d(B)[0]).then(function (b) {
  13597. b = b.toDataURL();
  13598. for (var c = atob(b.substring(22)), d = new ArrayBuffer(c.length),
  13599. g = new Uint8Array(d), f = 0; f < c.length; f++) g[f] = c.charCodeAt(f);
  13600. if ("string" === a.outputMode) return c;
  13601. if ("base64" === a.outputMode) return L(b);
  13602. "window" === a.outputMode ? window.open(b) : N(d, a.fileName + ".png", "image/png", "", "", !1)
  13603. }); else if ("pdf" === a.type) if (!0 === a.pdfmake.enabled) {
  13604. var U = {content: []};
  13605. d.extend(!0, U, a.pdfmake.docDefinition);
  13606. G = [];
  13607. d(B).filter(function () {
  13608. return I(d(this))
  13609. }).each(function () {
  13610. var b = d(this), c = [], e = [];
  13611. p = 0;
  13612. var g = function (a, b, c) {
  13613. var f = 0;
  13614. d(a).each(function () {
  13615. var a = [];
  13616. E(this, b, p, c, function (c,
  13617. d, f) {
  13618. if ("undefined" !== typeof c && null !== c) {
  13619. var e = J(c), h = T(c);
  13620. c = {text: D(c, d, f) || " "};
  13621. if (1 < e || 1 < h) c.colSpan = e || 1, c.rowSpan = h || 1
  13622. } else c = {text: " "};
  13623. 0 <= b.indexOf("th") && (c.style = "header");
  13624. a.push(c)
  13625. });
  13626. for (var d = a.length; d < c; d++) a.push("");
  13627. a.length && e.push(a);
  13628. f < a.length && (f = a.length);
  13629. p++
  13630. });
  13631. return f
  13632. };
  13633. r = y(b);
  13634. for (var f = g(r, "th,td", r.length), h = c.length; h < f; h++) c.push("*");
  13635. w = C(b);
  13636. f = g(w, "td", r.length + w.length);
  13637. for (h = c.length; h < f; h++) c.push("*");
  13638. U.content.push({
  13639. table: {
  13640. headerRows: r.length ? r.length : null, widths: c,
  13641. body: e
  13642. }, layout: {
  13643. layout: "noBorders", hLineStyle: function (a, b) {
  13644. return 0
  13645. }, vLineWidth: function (a, b) {
  13646. return 0
  13647. }, hLineColor: function (b, c) {
  13648. return b < c.table.headerRows ? a.pdfmake.docDefinition.styles.header.background : a.pdfmake.docDefinition.styles.alternateRow.fillColor
  13649. }, vLineColor: function (b, c) {
  13650. return b < c.table.headerRows ? a.pdfmake.docDefinition.styles.header.background : a.pdfmake.docDefinition.styles.alternateRow.fillColor
  13651. }, fillColor: function (b, c, d) {
  13652. return 0 === b % 2 ? a.pdfmake.docDefinition.styles.alternateRow.fillColor :
  13653. null
  13654. }
  13655. }, pageBreak: U.content.length ? "before" : void 0
  13656. })
  13657. });
  13658. "undefined" !== typeof pdfMake && "undefined" !== typeof pdfMake.createPdf && (pdfMake.fonts = {
  13659. Roboto: {
  13660. normal: "Roboto-Regular.ttf",
  13661. bold: "Roboto-Medium.ttf",
  13662. italics: "Roboto-Italic.ttf",
  13663. bolditalics: "Roboto-MediumItalic.ttf"
  13664. }
  13665. }, pdfMake.vfs.hasOwnProperty("Mirza-Regular.ttf") ? (U.defaultStyle.font = "Mirza", d.extend(!0, pdfMake.fonts, {
  13666. Mirza: {
  13667. normal: "Mirza-Regular.ttf",
  13668. bold: "Mirza-Bold.ttf",
  13669. italics: "Mirza-Medium.ttf",
  13670. bolditalics: "Mirza-SemiBold.ttf"
  13671. }
  13672. })) : pdfMake.vfs.hasOwnProperty("gbsn00lp.ttf") ?
  13673. (U.defaultStyle.font = "gbsn00lp", d.extend(!0, pdfMake.fonts, {
  13674. gbsn00lp: {
  13675. normal: "gbsn00lp.ttf",
  13676. bold: "gbsn00lp.ttf",
  13677. italics: "gbsn00lp.ttf",
  13678. bolditalics: "gbsn00lp.ttf"
  13679. }
  13680. })) : pdfMake.vfs.hasOwnProperty("ZCOOLXiaoWei-Regular.ttf") && (U.defaultStyle.font = "ZCOOLXiaoWei", d.extend(!0, pdfMake.fonts, {
  13681. ZCOOLXiaoWei: {
  13682. normal: "ZCOOLXiaoWei-Regular.ttf",
  13683. bold: "ZCOOLXiaoWei-Regular.ttf",
  13684. italics: "ZCOOLXiaoWei-Regular.ttf",
  13685. bolditalics: "ZCOOLXiaoWei-Regular.ttf"
  13686. }
  13687. })), d.extend(!0, pdfMake.fonts, a.pdfmake.fonts), pdfMake.createPdf(U).getBuffer(function (b) {
  13688. N(b,
  13689. a.fileName + ".pdf", "application/pdf", "", "", !1)
  13690. }))
  13691. } else if (!1 === a.jspdf.autotable) {
  13692. k = {
  13693. dim: {w: ha(d(B).first().get(0), "width", "mm"), h: ha(d(B).first().get(0), "height", "mm")},
  13694. pagesplit: !1
  13695. };
  13696. var Ha = new jsPDF(a.jspdf.orientation, a.jspdf.unit, a.jspdf.format);
  13697. Ha.addHTML(d(B).first(), a.jspdf.margins.left, a.jspdf.margins.top, k, function () {
  13698. va(Ha, !1)
  13699. })
  13700. } else {
  13701. var g = a.jspdf.autotable.tableExport;
  13702. if ("string" === typeof a.jspdf.format && "bestfit" === a.jspdf.format.toLowerCase()) {
  13703. var ja = "", da = "", Ia = 0;
  13704. d(B).each(function () {
  13705. if (I(d(this))) {
  13706. var a =
  13707. ha(d(this).get(0), "width", "pt");
  13708. if (a > Ia) {
  13709. a > O.a0[0] && (ja = "a0", da = "l");
  13710. for (var c in O) O.hasOwnProperty(c) && O[c][1] > a && (ja = c, da = "l", O[c][0] > a && (da = "p"));
  13711. Ia = a
  13712. }
  13713. }
  13714. });
  13715. a.jspdf.format = "" === ja ? "a4" : ja;
  13716. a.jspdf.orientation = "" === da ? "w" : da
  13717. }
  13718. if (null == g.doc && (g.doc = new jsPDF(a.jspdf.orientation, a.jspdf.unit, a.jspdf.format), g.wScaleFactor = 1, g.hScaleFactor = 1, "function" === typeof a.jspdf.onDocCreated)) a.jspdf.onDocCreated(g.doc);
  13719. !0 === g.outputImages && (g.images = {});
  13720. "undefined" !== typeof g.images && (d(B).filter(function () {
  13721. return I(d(this))
  13722. }).each(function () {
  13723. var b =
  13724. 0;
  13725. G = [];
  13726. !1 === a.exportHiddenCells && (K = d(this).find("tr, th, td").filter(":hidden"), V = 0 < K.length);
  13727. r = y(d(this));
  13728. w = C(d(this));
  13729. d(w).each(function () {
  13730. E(this, "td,th", r.length + b, r.length + w.length, function (a) {
  13731. xa(a, d(a).children(), g)
  13732. });
  13733. b++
  13734. })
  13735. }), r = [], w = []);
  13736. Ka(g, function () {
  13737. d(B).filter(function () {
  13738. return I(d(this))
  13739. }).each(function () {
  13740. var b;
  13741. p = 0;
  13742. G = [];
  13743. !1 === a.exportHiddenCells && (K = d(this).find("tr, th, td").filter(":hidden"), V = 0 < K.length);
  13744. S = R(this);
  13745. g.columns = [];
  13746. g.rows = [];
  13747. g.teCells = {};
  13748. if ("function" === typeof g.onTable &&
  13749. !1 === g.onTable(d(this), a)) return !0;
  13750. a.jspdf.autotable.tableExport = null;
  13751. var c = d.extend(!0, {}, a.jspdf.autotable);
  13752. a.jspdf.autotable.tableExport = g;
  13753. c.margin = {};
  13754. d.extend(!0, c.margin, a.jspdf.margins);
  13755. c.tableExport = g;
  13756. "function" !== typeof c.beforePageContent && (c.beforePageContent = function (a) {
  13757. if (1 === a.pageCount) {
  13758. var b = a.table.rows.concat(a.table.headerRow);
  13759. d.each(b, function () {
  13760. 0 < this.height && (this.height += (2 - 1.15) / 2 * this.styles.fontSize, a.table.height += (2 - 1.15) / 2 * this.styles.fontSize)
  13761. })
  13762. }
  13763. });
  13764. "function" !== typeof c.createdHeaderCell &&
  13765. (c.createdHeaderCell = function (a, b) {
  13766. a.styles = d.extend({}, b.row.styles);
  13767. if ("undefined" !== typeof g.columns[b.column.dataKey]) {
  13768. var e = g.columns[b.column.dataKey];
  13769. if ("undefined" !== typeof e.rect) {
  13770. a.contentWidth = e.rect.width;
  13771. if ("undefined" === typeof g.heightRatio || 0 === g.heightRatio) {
  13772. var f = b.row.raw[b.column.dataKey].rowspan ? b.row.raw[b.column.dataKey].rect.height / b.row.raw[b.column.dataKey].rowspan : b.row.raw[b.column.dataKey].rect.height;
  13773. g.heightRatio = a.styles.rowHeight / f
  13774. }
  13775. f = b.row.raw[b.column.dataKey].rect.height *
  13776. g.heightRatio;
  13777. f > a.styles.rowHeight && (a.styles.rowHeight = f)
  13778. }
  13779. a.styles.halign = "inherit" === c.headerStyles.halign ? "center" : c.headerStyles.halign;
  13780. a.styles.valign = c.headerStyles.valign;
  13781. "undefined" !== typeof e.style && !0 !== e.style.hidden && ("inherit" === c.headerStyles.halign && (a.styles.halign = e.style.align), "inherit" === c.styles.fillColor && (a.styles.fillColor = e.style.bcolor), "inherit" === c.styles.textColor && (a.styles.textColor = e.style.color), "inherit" === c.styles.fontStyle && (a.styles.fontStyle = e.style.fstyle))
  13782. }
  13783. });
  13784. "function" !== typeof c.createdCell && (c.createdCell = function (a, b) {
  13785. b = g.teCells[b.row.index + ":" + b.column.dataKey];
  13786. a.styles.halign = "inherit" === c.styles.halign ? "center" : c.styles.halign;
  13787. a.styles.valign = c.styles.valign;
  13788. "undefined" !== typeof b && "undefined" !== typeof b.style && !0 !== b.style.hidden && ("inherit" === c.styles.halign && (a.styles.halign = b.style.align), "inherit" === c.styles.fillColor && (a.styles.fillColor = b.style.bcolor), "inherit" === c.styles.textColor && (a.styles.textColor = b.style.color), "inherit" === c.styles.fontStyle &&
  13789. (a.styles.fontStyle = b.style.fstyle))
  13790. });
  13791. "function" !== typeof c.drawHeaderCell && (c.drawHeaderCell = function (a, b) {
  13792. var c = g.columns[b.column.dataKey];
  13793. return (!0 !== c.style.hasOwnProperty("hidden") || !0 !== c.style.hidden) && 0 <= c.rowIndex ? wa(a, b, c) : !1
  13794. });
  13795. "function" !== typeof c.drawCell && (c.drawCell = function (a, b) {
  13796. var c = g.teCells[b.row.index + ":" + b.column.dataKey];
  13797. if (!0 !== ("undefined" !== typeof c && c.isCanvas)) wa(a, b, c) && (g.doc.rect(a.x, a.y, a.width, a.height, a.styles.fillStyle), "undefined" === typeof c || "undefined" !== typeof c.hasUserDefText &&
  13798. !0 === c.hasUserDefText || "undefined" === typeof c.elements || !c.elements.length ? Aa(a, {}, g) : (b = a.height / c.rect.height, b > g.hScaleFactor && (g.hScaleFactor = b), g.wScaleFactor = a.width / c.rect.width, b = a.textPos.y, za(a, c.elements, g), a.textPos.y = b, Aa(a, c.elements, g))); else {
  13799. c = c.elements[0];
  13800. var e = d(c).attr("data-tableexport-canvas"), f = c.getBoundingClientRect();
  13801. a.width = f.width * g.wScaleFactor;
  13802. a.height = f.height * g.hScaleFactor;
  13803. b.row.height = a.height;
  13804. ua(a, c, e, g)
  13805. }
  13806. return !1
  13807. });
  13808. g.headerrows = [];
  13809. r = y(d(this));
  13810. d(r).each(function () {
  13811. b =
  13812. 0;
  13813. g.headerrows[p] = [];
  13814. E(this, "th,td", p, r.length, function (a, c, d) {
  13815. var e = Ca(a);
  13816. e.title = D(a, c, d);
  13817. e.key = b++;
  13818. e.rowIndex = p;
  13819. g.headerrows[p].push(e)
  13820. });
  13821. p++
  13822. });
  13823. if (0 < p) for (var e = p - 1; 0 <= e;) d.each(g.headerrows[e], function () {
  13824. var a = this;
  13825. 0 < e && null === this.rect && (a = g.headerrows[e - 1][this.key]);
  13826. null !== a && 0 <= a.rowIndex && (!0 !== a.style.hasOwnProperty("hidden") || !0 !== a.style.hidden) && g.columns.push(a)
  13827. }), e = 0 < g.columns.length ? -1 : e - 1;
  13828. var k = 0;
  13829. w = [];
  13830. w = C(d(this));
  13831. d(w).each(function () {
  13832. var a = [];
  13833. b = 0;
  13834. E(this, "td,th", p, r.length + w.length,
  13835. function (c, e, f) {
  13836. if ("undefined" === typeof g.columns[b]) {
  13837. var h = {title: "", key: b, style: {hidden: !0}};
  13838. g.columns.push(h)
  13839. }
  13840. a.push(D(c, e, f));
  13841. "undefined" !== typeof c && null !== c ? (h = Ca(c), h.isCanvas = c.hasAttribute("data-tableexport-canvas"), h.elements = h.isCanvas ? d(c) : d(c).children(), "undefined" !== typeof d(c).data("teUserDefText") && (h.hasUserDefText = !0)) : (h = d.extend(!0, {}, g.teCells[k + ":" + (b - 1)]), h.colspan = -1);
  13842. g.teCells[k + ":" + b++] = h
  13843. });
  13844. a.length && (g.rows.push(a), k++);
  13845. p++
  13846. });
  13847. if ("function" === typeof g.onBeforeAutotable) g.onBeforeAutotable(d(this),
  13848. g.columns, g.rows, c);
  13849. g.doc.autoTable(g.columns, g.rows, c);
  13850. if ("function" === typeof g.onAfterAutotable) g.onAfterAutotable(d(this), c);
  13851. a.jspdf.autotable.startY = g.doc.autoTableEndPosY() + c.margin.top
  13852. });
  13853. va(g.doc, "undefined" !== typeof g.images && !1 === jQuery.isEmptyObject(g.images));
  13854. "undefined" !== typeof g.headerrows && (g.headerrows.length = 0);
  13855. "undefined" !== typeof g.columns && (g.columns.length = 0);
  13856. "undefined" !== typeof g.rows && (g.rows.length = 0);
  13857. delete g.doc;
  13858. g.doc = null
  13859. })
  13860. }
  13861. if ("function" === typeof a.onTableExportEnd) a.onTableExportEnd();
  13862. return this
  13863. }
  13864. })(jQuery);
  13865. define("tableexport", ["jquery"], (function (global) {
  13866. return function () {
  13867. var ret, fn;
  13868. return ret || global.$.fn.extend;
  13869. };
  13870. }(this)));
  13871. !function (t) {
  13872. "use strict";
  13873. var o = t.fn.bootstrapTable.utils.sprintf, e = {
  13874. json: "JSON",
  13875. xml: "XML",
  13876. png: "PNG",
  13877. csv: "CSV",
  13878. txt: "TXT",
  13879. sql: "SQL",
  13880. doc: "MS-Word",
  13881. excel: "MS-Excel",
  13882. xlsx: "MS-Excel (OpenXML)",
  13883. powerpoint: "MS-Powerpoint",
  13884. pdf: "PDF"
  13885. };
  13886. t.extend(t.fn.bootstrapTable.defaults, {
  13887. showExport: !1,
  13888. exportDataType: "basic",
  13889. exportTypes: ["json", "xml", "csv", "txt", "sql", "excel"],
  13890. exportOptions: {}
  13891. }), t.extend(t.fn.bootstrapTable.defaults.icons, {export: "glyphicon-export icon-share"}), t.extend(t.fn.bootstrapTable.locales, {
  13892. formatExport: function () {
  13893. return "Export data"
  13894. }
  13895. }), t.extend(t.fn.bootstrapTable.defaults, t.fn.bootstrapTable.locales);
  13896. var s = t.fn.bootstrapTable.Constructor, i = s.prototype.initToolbar;
  13897. s.prototype.initToolbar = function () {
  13898. if (this.showToolbar = this.options.showExport, i.apply(this, Array.prototype.slice.apply(arguments)), this.options.showExport) {
  13899. var s = this, n = this.$toolbar.find(">.btn-group"), a = n.find("div.export");
  13900. if (!a.length) {
  13901. var p = (a = t(['<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(n)).find(".dropdown-menu"),
  13902. l = this.options.exportTypes;
  13903. if ("string" == typeof this.options.exportTypes) {
  13904. var r = this.options.exportTypes.slice(1, -1).replace(/ /g, "").split(",");
  13905. l = [], t.each(r, function (t, o) {
  13906. l.push(o.slice(1, -1))
  13907. })
  13908. }
  13909. t.each(l, function (t, o) {
  13910. e.hasOwnProperty(o) && p.append(['<li role="menuitem" data-type="' + o + '">', '<a href="javascript:void(0)">', e[o], "</a>", "</li>"].join(""))
  13911. }), p.find("li").click(function () {
  13912. var o = t(this).data("type"), e = function () {
  13913. s.$el.tableExport(t.extend({}, s.options.exportOptions, {type: o, escape: !1}))
  13914. };
  13915. if ("all" === s.options.exportDataType && s.options.pagination) s.$el.one("server" === s.options.sidePagination ? "post-body.bs.table" : "page-change.bs.table", function () {
  13916. e(), s.togglePagination()
  13917. }), s.togglePagination(); else if ("selected" === s.options.exportDataType) {
  13918. var i = s.getData(), n = s.getAllSelections();
  13919. if ("server" === s.options.sidePagination) {
  13920. (i = {total: s.options.totalRows})[s.options.dataField] = s.getData();
  13921. var a = "function" == typeof require ? require("table") : null;
  13922. (n = {total: s.options.totalRows})[s.options.dataField] = a && s.options.maintainSelected ? a.api.selecteddata(s.$el) : s.getAllSelections()
  13923. }
  13924. s.load(n), e(), s.load(i)
  13925. } else e()
  13926. })
  13927. }
  13928. }
  13929. }
  13930. }(jQuery);
  13931. define("bootstrap-table-export", ["bootstrap-table", "tableexport"], (function (global) {
  13932. return function () {
  13933. var ret, fn;
  13934. return ret || global.$.fn.bootstrapTable.defaults;
  13935. };
  13936. }(this)));
  13937. (function (factory) {
  13938. if (typeof define === "function" && define.amd) {
  13939. define('dropzone', ["jquery"], factory)
  13940. } else {
  13941. factory(jQuery)
  13942. }
  13943. })(function (jQuery) {
  13944. var module = {exports: {}};
  13945. "use strict";
  13946. function _typeof(obj) {
  13947. "@babel/helpers - typeof";
  13948. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  13949. _typeof = function _typeof(obj) {
  13950. return typeof obj
  13951. }
  13952. } else {
  13953. _typeof = function _typeof(obj) {
  13954. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj
  13955. }
  13956. }
  13957. return _typeof(obj)
  13958. }
  13959. function _possibleConstructorReturn(self, call) {
  13960. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  13961. return call
  13962. }
  13963. return _assertThisInitialized(self)
  13964. }
  13965. function _getPrototypeOf(o) {
  13966. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  13967. return o.__proto__ || Object.getPrototypeOf(o)
  13968. };
  13969. return _getPrototypeOf(o)
  13970. }
  13971. function _assertThisInitialized(self) {
  13972. if (self === void 0) {
  13973. throw new ReferenceError("this hasn't been initialised - super() hasn't been called")
  13974. }
  13975. return self
  13976. }
  13977. function _inherits(subClass, superClass) {
  13978. if (typeof superClass !== "function" && superClass !== null) {
  13979. throw new TypeError("Super expression must either be null or a function")
  13980. }
  13981. subClass.prototype = Object.create(superClass && superClass.prototype, {
  13982. constructor: {
  13983. value: subClass,
  13984. writable: true,
  13985. configurable: true
  13986. }
  13987. });
  13988. if (superClass) _setPrototypeOf(subClass, superClass)
  13989. }
  13990. function _setPrototypeOf(o, p) {
  13991. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  13992. o.__proto__ = p;
  13993. return o
  13994. };
  13995. return _setPrototypeOf(o, p)
  13996. }
  13997. function _classCallCheck(instance, Constructor) {
  13998. if (!(instance instanceof Constructor)) {
  13999. throw new TypeError("Cannot call a class as a function")
  14000. }
  14001. }
  14002. function _defineProperties(target, props) {
  14003. for (var i = 0; i < props.length; i++) {
  14004. var descriptor = props[i];
  14005. descriptor.enumerable = descriptor.enumerable || false;
  14006. descriptor.configurable = true;
  14007. if ("value" in descriptor) descriptor.writable = true;
  14008. Object.defineProperty(target, descriptor.key, descriptor)
  14009. }
  14010. }
  14011. function _createClass(Constructor, protoProps, staticProps) {
  14012. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  14013. if (staticProps) _defineProperties(Constructor, staticProps);
  14014. return Constructor
  14015. }
  14016. var Emitter = function () {
  14017. function Emitter() {
  14018. _classCallCheck(this, Emitter)
  14019. }
  14020. _createClass(Emitter, [{
  14021. key: "on", value: function on(event, fn) {
  14022. this._callbacks = this._callbacks || {};
  14023. if (!this._callbacks[event]) {
  14024. this._callbacks[event] = []
  14025. }
  14026. this._callbacks[event].push(fn);
  14027. return this
  14028. }
  14029. }, {
  14030. key: "emit", value: function emit(event) {
  14031. this._callbacks = this._callbacks || {};
  14032. var callbacks = this._callbacks[event];
  14033. if (callbacks) {
  14034. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  14035. args[_key - 1] = arguments[_key]
  14036. }
  14037. var _iteratorNormalCompletion = true;
  14038. var _didIteratorError = false;
  14039. var _iteratorError = undefined;
  14040. try {
  14041. for (var _iterator = callbacks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  14042. var callback = _step.value;
  14043. callback.apply(this, args)
  14044. }
  14045. } catch (err) {
  14046. _didIteratorError = true;
  14047. _iteratorError = err
  14048. } finally {
  14049. try {
  14050. if (!_iteratorNormalCompletion && _iterator["return"] != null) {
  14051. _iterator["return"]()
  14052. }
  14053. } finally {
  14054. if (_didIteratorError) {
  14055. throw _iteratorError
  14056. }
  14057. }
  14058. }
  14059. }
  14060. return this
  14061. }
  14062. }, {
  14063. key: "off", value: function off(event, fn) {
  14064. if (!this._callbacks || arguments.length === 0) {
  14065. this._callbacks = {};
  14066. return this
  14067. }
  14068. var callbacks = this._callbacks[event];
  14069. if (!callbacks) {
  14070. return this
  14071. }
  14072. if (arguments.length === 1) {
  14073. delete this._callbacks[event];
  14074. return this
  14075. }
  14076. for (var i = 0; i < callbacks.length; i++) {
  14077. var callback = callbacks[i];
  14078. if (callback === fn) {
  14079. callbacks.splice(i, 1);
  14080. break
  14081. }
  14082. }
  14083. return this
  14084. }
  14085. }]);
  14086. return Emitter
  14087. }();
  14088. var Dropzone = function (_Emitter) {
  14089. _inherits(Dropzone, _Emitter);
  14090. _createClass(Dropzone, null, [{
  14091. key: "initClass", value: function initClass() {
  14092. this.prototype.Emitter = Emitter;
  14093. 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"];
  14094. this.prototype.defaultOptions = {
  14095. url: null,
  14096. method: "post",
  14097. withCredentials: false,
  14098. timeout: 3e4,
  14099. parallelUploads: 2,
  14100. uploadMultiple: false,
  14101. chunking: false,
  14102. forceChunking: false,
  14103. chunkSize: 2e6,
  14104. parallelChunkUploads: false,
  14105. retryChunks: false,
  14106. retryChunksLimit: 3,
  14107. maxFilesize: 256,
  14108. paramName: "file",
  14109. createImageThumbnails: true,
  14110. maxThumbnailFilesize: 10,
  14111. thumbnailWidth: 120,
  14112. thumbnailHeight: 120,
  14113. thumbnailMethod: "crop",
  14114. resizeWidth: null,
  14115. resizeHeight: null,
  14116. resizeMimeType: null,
  14117. resizeQuality: .8,
  14118. resizeMethod: "contain",
  14119. filesizeBase: 1e3,
  14120. maxFiles: null,
  14121. headers: null,
  14122. clickable: true,
  14123. ignoreHiddenFiles: true,
  14124. acceptedFiles: null,
  14125. acceptedMimeTypes: null,
  14126. autoProcessQueue: true,
  14127. autoQueue: true,
  14128. addRemoveLinks: false,
  14129. previewsContainer: null,
  14130. hiddenInputContainer: "body",
  14131. capture: null,
  14132. renameFilename: null,
  14133. renameFile: null,
  14134. forceFallback: false,
  14135. dictDefaultMessage: "Drop files here to upload",
  14136. dictFallbackMessage: "Your browser does not support drag'n'drop file uploads.",
  14137. dictFallbackText: "Please use the fallback form below to upload your files like in the olden days.",
  14138. dictFileTooBig: "File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB.",
  14139. dictInvalidFileType: "You can't upload files of this type.",
  14140. dictResponseError: "Server responded with {{statusCode}} code.",
  14141. dictCancelUpload: "Cancel upload",
  14142. dictUploadCanceled: "Upload canceled.",
  14143. dictCancelUploadConfirmation: "Are you sure you want to cancel this upload?",
  14144. dictRemoveFile: "Remove file",
  14145. dictRemoveFileConfirmation: null,
  14146. dictMaxFilesExceeded: "You can not upload any more files.",
  14147. dictFileSizeUnits: {tb: "TB", gb: "GB", mb: "MB", kb: "KB", b: "b"},
  14148. init: function init() {
  14149. },
  14150. params: function params(files, xhr, chunk) {
  14151. if (chunk) {
  14152. return {
  14153. dzuuid: chunk.file.upload.uuid,
  14154. dzchunkindex: chunk.index,
  14155. dztotalfilesize: chunk.file.size,
  14156. dzchunksize: this.options.chunkSize,
  14157. dztotalchunkcount: chunk.file.upload.totalChunkCount,
  14158. dzchunkbyteoffset: chunk.index * this.options.chunkSize
  14159. }
  14160. }
  14161. },
  14162. accept: function accept(file, done) {
  14163. return done()
  14164. },
  14165. chunkSuccess: function (chunk, file, response) {
  14166. },
  14167. chunksUploaded: function chunksUploaded(file, done) {
  14168. done()
  14169. },
  14170. fallback: function fallback() {
  14171. var messageElement;
  14172. this.element.className = "".concat(this.element.className, " dz-browser-not-supported");
  14173. var _iteratorNormalCompletion2 = true;
  14174. var _didIteratorError2 = false;
  14175. var _iteratorError2 = undefined;
  14176. try {
  14177. for (var _iterator2 = this.element.getElementsByTagName("div")[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  14178. var child = _step2.value;
  14179. if (/(^| )dz-message($| )/.test(child.className)) {
  14180. messageElement = child;
  14181. child.className = "dz-message";
  14182. break
  14183. }
  14184. }
  14185. } catch (err) {
  14186. _didIteratorError2 = true;
  14187. _iteratorError2 = err
  14188. } finally {
  14189. try {
  14190. if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
  14191. _iterator2["return"]()
  14192. }
  14193. } finally {
  14194. if (_didIteratorError2) {
  14195. throw _iteratorError2
  14196. }
  14197. }
  14198. }
  14199. if (!messageElement) {
  14200. messageElement = Dropzone.createElement('<div class="dz-message"><span></span></div>');
  14201. this.element.appendChild(messageElement)
  14202. }
  14203. var span = messageElement.getElementsByTagName("span")[0];
  14204. if (span) {
  14205. if (span.textContent != null) {
  14206. span.textContent = this.options.dictFallbackMessage
  14207. } else if (span.innerText != null) {
  14208. span.innerText = this.options.dictFallbackMessage
  14209. }
  14210. }
  14211. return this.element.appendChild(this.getFallbackForm())
  14212. },
  14213. resize: function resize(file, width, height, resizeMethod) {
  14214. var info = {srcX: 0, srcY: 0, srcWidth: file.width, srcHeight: file.height};
  14215. var srcRatio = file.width / file.height;
  14216. if (width == null && height == null) {
  14217. width = info.srcWidth;
  14218. height = info.srcHeight
  14219. } else if (width == null) {
  14220. width = height * srcRatio
  14221. } else if (height == null) {
  14222. height = width / srcRatio
  14223. }
  14224. width = Math.min(width, info.srcWidth);
  14225. height = Math.min(height, info.srcHeight);
  14226. var trgRatio = width / height;
  14227. if (info.srcWidth > width || info.srcHeight > height) {
  14228. if (resizeMethod === "crop") {
  14229. if (srcRatio > trgRatio) {
  14230. info.srcHeight = file.height;
  14231. info.srcWidth = info.srcHeight * trgRatio
  14232. } else {
  14233. info.srcWidth = file.width;
  14234. info.srcHeight = info.srcWidth / trgRatio
  14235. }
  14236. } else if (resizeMethod === "contain") {
  14237. if (srcRatio > trgRatio) {
  14238. height = width / srcRatio
  14239. } else {
  14240. width = height * srcRatio
  14241. }
  14242. } else {
  14243. throw new Error("Unknown resizeMethod '".concat(resizeMethod, "'"))
  14244. }
  14245. }
  14246. info.srcX = (file.width - info.srcWidth) / 2;
  14247. info.srcY = (file.height - info.srcHeight) / 2;
  14248. info.trgWidth = width;
  14249. info.trgHeight = height;
  14250. return info
  14251. },
  14252. transformFile: function transformFile(file, done) {
  14253. if ((this.options.resizeWidth || this.options.resizeHeight) && file.type.match(/image.*/)) {
  14254. return this.resizeImage(file, this.options.resizeWidth, this.options.resizeHeight, this.options.resizeMethod, done)
  14255. } else {
  14256. return done(file)
  14257. }
  14258. },
  14259. 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>',
  14260. drop: function drop(e) {
  14261. return this.element.classList.remove("dz-drag-hover")
  14262. },
  14263. dragstart: function dragstart(e) {
  14264. },
  14265. dragend: function dragend(e) {
  14266. return this.element.classList.remove("dz-drag-hover")
  14267. },
  14268. dragenter: function dragenter(e) {
  14269. return this.element.classList.add("dz-drag-hover")
  14270. },
  14271. dragover: function dragover(e) {
  14272. return this.element.classList.add("dz-drag-hover")
  14273. },
  14274. dragleave: function dragleave(e) {
  14275. return this.element.classList.remove("dz-drag-hover")
  14276. },
  14277. paste: function paste(e) {
  14278. },
  14279. reset: function reset() {
  14280. return this.element.classList.remove("dz-started")
  14281. },
  14282. addedfile: function addedfile(file) {
  14283. var _this2 = this;
  14284. if (this.element === this.previewsContainer) {
  14285. this.element.classList.add("dz-started")
  14286. }
  14287. if (this.previewsContainer) {
  14288. file.previewElement = Dropzone.createElement(this.options.previewTemplate.trim());
  14289. file.previewTemplate = file.previewElement;
  14290. this.previewsContainer.appendChild(file.previewElement);
  14291. var _iteratorNormalCompletion3 = true;
  14292. var _didIteratorError3 = false;
  14293. var _iteratorError3 = undefined;
  14294. try {
  14295. for (var _iterator3 = file.previewElement.querySelectorAll("[data-dz-name]")[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  14296. var node = _step3.value;
  14297. node.textContent = file.name
  14298. }
  14299. } catch (err) {
  14300. _didIteratorError3 = true;
  14301. _iteratorError3 = err
  14302. } finally {
  14303. try {
  14304. if (!_iteratorNormalCompletion3 && _iterator3["return"] != null) {
  14305. _iterator3["return"]()
  14306. }
  14307. } finally {
  14308. if (_didIteratorError3) {
  14309. throw _iteratorError3
  14310. }
  14311. }
  14312. }
  14313. var _iteratorNormalCompletion4 = true;
  14314. var _didIteratorError4 = false;
  14315. var _iteratorError4 = undefined;
  14316. try {
  14317. for (var _iterator4 = file.previewElement.querySelectorAll("[data-dz-size]")[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  14318. node = _step4.value;
  14319. node.innerHTML = this.filesize(file.size)
  14320. }
  14321. } catch (err) {
  14322. _didIteratorError4 = true;
  14323. _iteratorError4 = err
  14324. } finally {
  14325. try {
  14326. if (!_iteratorNormalCompletion4 && _iterator4["return"] != null) {
  14327. _iterator4["return"]()
  14328. }
  14329. } finally {
  14330. if (_didIteratorError4) {
  14331. throw _iteratorError4
  14332. }
  14333. }
  14334. }
  14335. if (this.options.addRemoveLinks) {
  14336. file._removeLink = Dropzone.createElement('<a class="dz-remove" href="javascript:undefined;" data-dz-remove>'.concat(this.options.dictRemoveFile, "</a>"));
  14337. file.previewElement.appendChild(file._removeLink)
  14338. }
  14339. var removeFileEvent = function removeFileEvent(e) {
  14340. e.preventDefault();
  14341. e.stopPropagation();
  14342. if (file.status === Dropzone.UPLOADING) {
  14343. return Dropzone.confirm(_this2.options.dictCancelUploadConfirmation, function () {
  14344. return _this2.removeFile(file)
  14345. })
  14346. } else {
  14347. if (_this2.options.dictRemoveFileConfirmation) {
  14348. return Dropzone.confirm(_this2.options.dictRemoveFileConfirmation, function () {
  14349. return _this2.removeFile(file)
  14350. })
  14351. } else {
  14352. return _this2.removeFile(file)
  14353. }
  14354. }
  14355. };
  14356. var _iteratorNormalCompletion5 = true;
  14357. var _didIteratorError5 = false;
  14358. var _iteratorError5 = undefined;
  14359. try {
  14360. for (var _iterator5 = file.previewElement.querySelectorAll("[data-dz-remove]")[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
  14361. var removeLink = _step5.value;
  14362. removeLink.addEventListener("click", removeFileEvent)
  14363. }
  14364. } catch (err) {
  14365. _didIteratorError5 = true;
  14366. _iteratorError5 = err
  14367. } finally {
  14368. try {
  14369. if (!_iteratorNormalCompletion5 && _iterator5["return"] != null) {
  14370. _iterator5["return"]()
  14371. }
  14372. } finally {
  14373. if (_didIteratorError5) {
  14374. throw _iteratorError5
  14375. }
  14376. }
  14377. }
  14378. }
  14379. },
  14380. removedfile: function removedfile(file) {
  14381. if (file.previewElement != null && file.previewElement.parentNode != null) {
  14382. file.previewElement.parentNode.removeChild(file.previewElement)
  14383. }
  14384. return this._updateMaxFilesReachedClass()
  14385. },
  14386. thumbnail: function thumbnail(file, dataUrl) {
  14387. if (file.previewElement) {
  14388. file.previewElement.classList.remove("dz-file-preview");
  14389. var _iteratorNormalCompletion6 = true;
  14390. var _didIteratorError6 = false;
  14391. var _iteratorError6 = undefined;
  14392. try {
  14393. for (var _iterator6 = file.previewElement.querySelectorAll("[data-dz-thumbnail]")[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
  14394. var thumbnailElement = _step6.value;
  14395. thumbnailElement.alt = file.name;
  14396. thumbnailElement.src = dataUrl
  14397. }
  14398. } catch (err) {
  14399. _didIteratorError6 = true;
  14400. _iteratorError6 = err
  14401. } finally {
  14402. try {
  14403. if (!_iteratorNormalCompletion6 && _iterator6["return"] != null) {
  14404. _iterator6["return"]()
  14405. }
  14406. } finally {
  14407. if (_didIteratorError6) {
  14408. throw _iteratorError6
  14409. }
  14410. }
  14411. }
  14412. return setTimeout(function () {
  14413. return file.previewElement.classList.add("dz-image-preview")
  14414. }, 1)
  14415. }
  14416. },
  14417. error: function error(file, message) {
  14418. if (file.previewElement) {
  14419. file.previewElement.classList.add("dz-error");
  14420. if (typeof message !== "String" && message.error) {
  14421. message = message.error
  14422. }
  14423. var _iteratorNormalCompletion7 = true;
  14424. var _didIteratorError7 = false;
  14425. var _iteratorError7 = undefined;
  14426. try {
  14427. for (var _iterator7 = file.previewElement.querySelectorAll("[data-dz-errormessage]")[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
  14428. var node = _step7.value;
  14429. node.textContent = message
  14430. }
  14431. } catch (err) {
  14432. _didIteratorError7 = true;
  14433. _iteratorError7 = err
  14434. } finally {
  14435. try {
  14436. if (!_iteratorNormalCompletion7 && _iterator7["return"] != null) {
  14437. _iterator7["return"]()
  14438. }
  14439. } finally {
  14440. if (_didIteratorError7) {
  14441. throw _iteratorError7
  14442. }
  14443. }
  14444. }
  14445. }
  14446. },
  14447. errormultiple: function errormultiple() {
  14448. },
  14449. processing: function processing(file) {
  14450. if (file.previewElement) {
  14451. file.previewElement.classList.add("dz-processing");
  14452. if (file._removeLink) {
  14453. return file._removeLink.innerHTML = this.options.dictCancelUpload
  14454. }
  14455. }
  14456. },
  14457. processingmultiple: function processingmultiple() {
  14458. },
  14459. uploadprogress: function uploadprogress(file, progress, bytesSent) {
  14460. if (file.previewElement) {
  14461. var _iteratorNormalCompletion8 = true;
  14462. var _didIteratorError8 = false;
  14463. var _iteratorError8 = undefined;
  14464. try {
  14465. for (var _iterator8 = file.previewElement.querySelectorAll("[data-dz-uploadprogress]")[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {
  14466. var node = _step8.value;
  14467. node.nodeName === "PROGRESS" ? node.value = progress : node.style.width = "".concat(progress, "%")
  14468. }
  14469. } catch (err) {
  14470. _didIteratorError8 = true;
  14471. _iteratorError8 = err
  14472. } finally {
  14473. try {
  14474. if (!_iteratorNormalCompletion8 && _iterator8["return"] != null) {
  14475. _iterator8["return"]()
  14476. }
  14477. } finally {
  14478. if (_didIteratorError8) {
  14479. throw _iteratorError8
  14480. }
  14481. }
  14482. }
  14483. }
  14484. },
  14485. totaluploadprogress: function totaluploadprogress() {
  14486. },
  14487. sending: function sending() {
  14488. },
  14489. sendingmultiple: function sendingmultiple() {
  14490. },
  14491. success: function success(file) {
  14492. if (file.previewElement) {
  14493. return file.previewElement.classList.add("dz-success")
  14494. }
  14495. },
  14496. successmultiple: function successmultiple() {
  14497. },
  14498. canceled: function canceled(file) {
  14499. return this.emit("error", file, this.options.dictUploadCanceled)
  14500. },
  14501. canceledmultiple: function canceledmultiple() {
  14502. },
  14503. complete: function complete(file) {
  14504. if (file._removeLink) {
  14505. file._removeLink.innerHTML = this.options.dictRemoveFile
  14506. }
  14507. if (file.previewElement) {
  14508. return file.previewElement.classList.add("dz-complete")
  14509. }
  14510. },
  14511. completemultiple: function completemultiple() {
  14512. },
  14513. maxfilesexceeded: function maxfilesexceeded() {
  14514. },
  14515. maxfilesreached: function maxfilesreached() {
  14516. },
  14517. queuecomplete: function queuecomplete() {
  14518. },
  14519. addedfiles: function addedfiles() {
  14520. }
  14521. };
  14522. this.prototype._thumbnailQueue = [];
  14523. this.prototype._processingThumbnail = false
  14524. }
  14525. }, {
  14526. key: "extend", value: function extend(target) {
  14527. for (var _len2 = arguments.length, objects = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  14528. objects[_key2 - 1] = arguments[_key2]
  14529. }
  14530. for (var _i = 0, _objects = objects; _i < _objects.length; _i++) {
  14531. var object = _objects[_i];
  14532. for (var key in object) {
  14533. var val = object[key];
  14534. target[key] = val
  14535. }
  14536. }
  14537. return target
  14538. }
  14539. }]);
  14540. function Dropzone(el, options) {
  14541. var _this;
  14542. _classCallCheck(this, Dropzone);
  14543. _this = _possibleConstructorReturn(this, _getPrototypeOf(Dropzone).call(this));
  14544. var fallback, left;
  14545. _this.element = el;
  14546. _this.version = Dropzone.version;
  14547. _this.defaultOptions.previewTemplate = _this.defaultOptions.previewTemplate.replace(/\n*/g, "");
  14548. _this.clickableElements = [];
  14549. _this.listeners = [];
  14550. _this.files = [];
  14551. if (typeof _this.element === "string") {
  14552. _this.element = document.querySelector(_this.element)
  14553. }
  14554. if (!_this.element || _this.element.nodeType == null) {
  14555. throw new Error("Invalid dropzone element.")
  14556. }
  14557. if (_this.element.dropzone) {
  14558. throw new Error("Dropzone already attached.")
  14559. }
  14560. Dropzone.instances.push(_assertThisInitialized(_this));
  14561. _this.element.dropzone = _assertThisInitialized(_this);
  14562. var elementOptions = (left = Dropzone.optionsForElement(_this.element)) != null ? left : {};
  14563. _this.options = Dropzone.extend({}, _this.defaultOptions, elementOptions, options != null ? options : {});
  14564. if (_this.options.forceFallback || !Dropzone.isBrowserSupported()) {
  14565. return _possibleConstructorReturn(_this, _this.options.fallback.call(_assertThisInitialized(_this)))
  14566. }
  14567. if (_this.options.url == null) {
  14568. _this.options.url = _this.element.getAttribute("action")
  14569. }
  14570. if (!_this.options.url) {
  14571. throw new Error("No URL provided.")
  14572. }
  14573. if (_this.options.acceptedFiles && _this.options.acceptedMimeTypes) {
  14574. throw new Error("You can't provide both 'acceptedFiles' and 'acceptedMimeTypes'. 'acceptedMimeTypes' is deprecated.")
  14575. }
  14576. if (_this.options.uploadMultiple && _this.options.chunking) {
  14577. throw new Error("You cannot set both: uploadMultiple and chunking.")
  14578. }
  14579. if (_this.options.acceptedMimeTypes) {
  14580. _this.options.acceptedFiles = _this.options.acceptedMimeTypes;
  14581. delete _this.options.acceptedMimeTypes
  14582. }
  14583. if (_this.options.renameFilename != null) {
  14584. _this.options.renameFile = function (file) {
  14585. return _this.options.renameFilename.call(_assertThisInitialized(_this), file.name, file)
  14586. }
  14587. }
  14588. _this.options.method = typeof _this.options.method !== "function" ? _this.options.method.toUpperCase() : _this.options.method;
  14589. if ((fallback = _this.getExistingFallback()) && fallback.parentNode) {
  14590. fallback.parentNode.removeChild(fallback)
  14591. }
  14592. if (_this.options.previewsContainer !== false) {
  14593. if (_this.options.previewsContainer) {
  14594. _this.previewsContainer = Dropzone.getElement(_this.options.previewsContainer, "previewsContainer")
  14595. } else {
  14596. _this.previewsContainer = _this.element
  14597. }
  14598. }
  14599. if (_this.options.clickable) {
  14600. if (_this.options.clickable === true) {
  14601. _this.clickableElements = [_this.element]
  14602. } else {
  14603. _this.clickableElements = Dropzone.getElements(_this.options.clickable, "clickable")
  14604. }
  14605. }
  14606. _this.init();
  14607. return _this
  14608. }
  14609. _createClass(Dropzone, [{
  14610. key: "getAcceptedFiles", value: function getAcceptedFiles() {
  14611. return this.files.filter(function (file) {
  14612. return file.accepted
  14613. }).map(function (file) {
  14614. return file
  14615. })
  14616. }
  14617. }, {
  14618. key: "getRejectedFiles", value: function getRejectedFiles() {
  14619. return this.files.filter(function (file) {
  14620. return !file.accepted
  14621. }).map(function (file) {
  14622. return file
  14623. })
  14624. }
  14625. }, {
  14626. key: "getFilesWithStatus", value: function getFilesWithStatus(status) {
  14627. return this.files.filter(function (file) {
  14628. return file.status === status
  14629. }).map(function (file) {
  14630. return file
  14631. })
  14632. }
  14633. }, {
  14634. key: "getQueuedFiles", value: function getQueuedFiles() {
  14635. return this.getFilesWithStatus(Dropzone.QUEUED)
  14636. }
  14637. }, {
  14638. key: "getUploadingFiles", value: function getUploadingFiles() {
  14639. return this.getFilesWithStatus(Dropzone.UPLOADING)
  14640. }
  14641. }, {
  14642. key: "getAddedFiles", value: function getAddedFiles() {
  14643. return this.getFilesWithStatus(Dropzone.ADDED)
  14644. }
  14645. }, {
  14646. key: "getActiveFiles", value: function getActiveFiles() {
  14647. return this.files.filter(function (file) {
  14648. return file.status === Dropzone.UPLOADING || file.status === Dropzone.QUEUED
  14649. }).map(function (file) {
  14650. return file
  14651. })
  14652. }
  14653. }, {
  14654. key: "init", value: function init() {
  14655. var _this3 = this;
  14656. if (this.element.tagName === "form") {
  14657. this.element.setAttribute("enctype", "multipart/form-data")
  14658. }
  14659. if (this.element.classList.contains("dropzone") && !this.element.querySelector(".dz-message")) {
  14660. this.element.appendChild(Dropzone.createElement('<div class="dz-default dz-message"><button class="dz-button" type="button">'.concat(this.options.dictDefaultMessage, "</button></div>")))
  14661. }
  14662. if (this.clickableElements.length) {
  14663. var setupHiddenFileInput = function setupHiddenFileInput() {
  14664. if (_this3.hiddenFileInput) {
  14665. _this3.hiddenFileInput.parentNode.removeChild(_this3.hiddenFileInput)
  14666. }
  14667. _this3.hiddenFileInput = document.createElement("input");
  14668. _this3.hiddenFileInput.setAttribute("type", "file");
  14669. if (_this3.options.maxFiles === null || _this3.options.maxFiles > 1) {
  14670. _this3.hiddenFileInput.setAttribute("multiple", "multiple")
  14671. }
  14672. _this3.hiddenFileInput.className = "dz-hidden-input";
  14673. if (_this3.options.acceptedFiles !== null) {
  14674. _this3.hiddenFileInput.setAttribute("accept", _this3.options.acceptedFiles)
  14675. }
  14676. if (_this3.options.capture !== null) {
  14677. _this3.hiddenFileInput.setAttribute("capture", _this3.options.capture)
  14678. }
  14679. _this3.hiddenFileInput.style.visibility = "hidden";
  14680. _this3.hiddenFileInput.style.position = "absolute";
  14681. _this3.hiddenFileInput.style.top = "0";
  14682. _this3.hiddenFileInput.style.left = "0";
  14683. _this3.hiddenFileInput.style.height = "0";
  14684. _this3.hiddenFileInput.style.width = "0";
  14685. Dropzone.getElement(_this3.options.hiddenInputContainer, "hiddenInputContainer").appendChild(_this3.hiddenFileInput);
  14686. return _this3.hiddenFileInput.addEventListener("change", function () {
  14687. var files = _this3.hiddenFileInput.files;
  14688. if (files.length) {
  14689. var _iteratorNormalCompletion9 = true;
  14690. var _didIteratorError9 = false;
  14691. var _iteratorError9 = undefined;
  14692. try {
  14693. for (var _iterator9 = files[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
  14694. var file = _step9.value;
  14695. _this3.addFile(file)
  14696. }
  14697. } catch (err) {
  14698. _didIteratorError9 = true;
  14699. _iteratorError9 = err
  14700. } finally {
  14701. try {
  14702. if (!_iteratorNormalCompletion9 && _iterator9["return"] != null) {
  14703. _iterator9["return"]()
  14704. }
  14705. } finally {
  14706. if (_didIteratorError9) {
  14707. throw _iteratorError9
  14708. }
  14709. }
  14710. }
  14711. }
  14712. _this3.emit("addedfiles", files);
  14713. return setupHiddenFileInput()
  14714. })
  14715. };
  14716. setupHiddenFileInput()
  14717. }
  14718. this.URL = window.URL !== null ? window.URL : window.webkitURL;
  14719. var _iteratorNormalCompletion10 = true;
  14720. var _didIteratorError10 = false;
  14721. var _iteratorError10 = undefined;
  14722. try {
  14723. for (var _iterator10 = this.events[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {
  14724. var eventName = _step10.value;
  14725. this.on(eventName, this.options[eventName])
  14726. }
  14727. } catch (err) {
  14728. _didIteratorError10 = true;
  14729. _iteratorError10 = err
  14730. } finally {
  14731. try {
  14732. if (!_iteratorNormalCompletion10 && _iterator10["return"] != null) {
  14733. _iterator10["return"]()
  14734. }
  14735. } finally {
  14736. if (_didIteratorError10) {
  14737. throw _iteratorError10
  14738. }
  14739. }
  14740. }
  14741. this.on("uploadprogress", function () {
  14742. return _this3.updateTotalUploadProgress()
  14743. });
  14744. this.on("removedfile", function () {
  14745. return _this3.updateTotalUploadProgress()
  14746. });
  14747. this.on("canceled", function (file) {
  14748. return _this3.emit("complete", file)
  14749. });
  14750. this.on("complete", function (file) {
  14751. if (_this3.getAddedFiles().length === 0 && _this3.getUploadingFiles().length === 0 && _this3.getQueuedFiles().length === 0) {
  14752. return setTimeout(function () {
  14753. return _this3.emit("queuecomplete")
  14754. }, 0)
  14755. }
  14756. });
  14757. var containsFiles = function containsFiles(e) {
  14758. return e.dataTransfer.types && e.dataTransfer.types.some(function (type) {
  14759. return type == "Files"
  14760. })
  14761. };
  14762. var noPropagation = function noPropagation(e) {
  14763. if (!containsFiles(e)) return;
  14764. e.stopPropagation();
  14765. if (e.preventDefault) {
  14766. return e.preventDefault()
  14767. } else {
  14768. return e.returnValue = false
  14769. }
  14770. };
  14771. this.listeners = [{
  14772. element: this.element, events: {
  14773. dragstart: function dragstart(e) {
  14774. return _this3.emit("dragstart", e)
  14775. }, dragenter: function dragenter(e) {
  14776. noPropagation(e);
  14777. return _this3.emit("dragenter", e)
  14778. }, dragover: function dragover(e) {
  14779. var efct;
  14780. try {
  14781. efct = e.dataTransfer.effectAllowed
  14782. } catch (error) {
  14783. }
  14784. e.dataTransfer.dropEffect = "move" === efct || "linkMove" === efct ? "move" : "copy";
  14785. noPropagation(e);
  14786. return _this3.emit("dragover", e)
  14787. }, dragleave: function dragleave(e) {
  14788. return _this3.emit("dragleave", e)
  14789. }, drop: function drop(e) {
  14790. noPropagation(e);
  14791. return _this3.drop(e)
  14792. }, dragend: function dragend(e) {
  14793. return _this3.emit("dragend", e)
  14794. }
  14795. }
  14796. }];
  14797. this.clickableElements.forEach(function (clickableElement) {
  14798. return _this3.listeners.push({
  14799. element: clickableElement, events: {
  14800. click: function click(evt) {
  14801. if (clickableElement !== _this3.element || evt.target === _this3.element || Dropzone.elementInside(evt.target, _this3.element.querySelector(".dz-message"))) {
  14802. _this3.hiddenFileInput.click()
  14803. }
  14804. return true
  14805. }
  14806. }
  14807. })
  14808. });
  14809. this.enable();
  14810. return this.options.init.call(this)
  14811. }
  14812. }, {
  14813. key: "destroy", value: function destroy() {
  14814. this.disable();
  14815. this.removeAllFiles(true);
  14816. if (this.hiddenFileInput != null ? this.hiddenFileInput.parentNode : undefined) {
  14817. this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput);
  14818. this.hiddenFileInput = null
  14819. }
  14820. delete this.element.dropzone;
  14821. return Dropzone.instances.splice(Dropzone.instances.indexOf(this), 1)
  14822. }
  14823. }, {
  14824. key: "updateTotalUploadProgress", value: function updateTotalUploadProgress() {
  14825. var totalUploadProgress;
  14826. var totalBytesSent = 0;
  14827. var totalBytes = 0;
  14828. var activeFiles = this.getActiveFiles();
  14829. if (activeFiles.length) {
  14830. var _iteratorNormalCompletion11 = true;
  14831. var _didIteratorError11 = false;
  14832. var _iteratorError11 = undefined;
  14833. try {
  14834. for (var _iterator11 = this.getActiveFiles()[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) {
  14835. var file = _step11.value;
  14836. totalBytesSent += file.upload.bytesSent;
  14837. totalBytes += file.upload.total
  14838. }
  14839. } catch (err) {
  14840. _didIteratorError11 = true;
  14841. _iteratorError11 = err
  14842. } finally {
  14843. try {
  14844. if (!_iteratorNormalCompletion11 && _iterator11["return"] != null) {
  14845. _iterator11["return"]()
  14846. }
  14847. } finally {
  14848. if (_didIteratorError11) {
  14849. throw _iteratorError11
  14850. }
  14851. }
  14852. }
  14853. totalUploadProgress = 100 * totalBytesSent / totalBytes
  14854. } else {
  14855. totalUploadProgress = 100
  14856. }
  14857. return this.emit("totaluploadprogress", totalUploadProgress, totalBytes, totalBytesSent)
  14858. }
  14859. }, {
  14860. key: "_getParamName", value: function _getParamName(n) {
  14861. if (typeof this.options.paramName === "function") {
  14862. return this.options.paramName(n)
  14863. } else {
  14864. return "".concat(this.options.paramName).concat(this.options.uploadMultiple ? "[".concat(n, "]") : "")
  14865. }
  14866. }
  14867. }, {
  14868. key: "_renameFile", value: function _renameFile(file) {
  14869. if (typeof this.options.renameFile !== "function") {
  14870. return file.name
  14871. }
  14872. return this.options.renameFile(file)
  14873. }
  14874. }, {
  14875. key: "getFallbackForm", value: function getFallbackForm() {
  14876. var existingFallback, form;
  14877. if (existingFallback = this.getExistingFallback()) {
  14878. return existingFallback
  14879. }
  14880. var fieldsString = '<div class="dz-fallback">';
  14881. if (this.options.dictFallbackText) {
  14882. fieldsString += "<p>".concat(this.options.dictFallbackText, "</p>")
  14883. }
  14884. fieldsString += '<input type="file" name="'.concat(this._getParamName(0), '" ').concat(this.options.uploadMultiple ? 'multiple="multiple"' : undefined, ' /><input type="submit" value="Upload!"></div>');
  14885. var fields = Dropzone.createElement(fieldsString);
  14886. if (this.element.tagName !== "FORM") {
  14887. form = Dropzone.createElement('<form action="'.concat(this.options.url, '" enctype="multipart/form-data" method="').concat(this.options.method, '"></form>'));
  14888. form.appendChild(fields)
  14889. } else {
  14890. this.element.setAttribute("enctype", "multipart/form-data");
  14891. this.element.setAttribute("method", this.options.method)
  14892. }
  14893. return form != null ? form : fields
  14894. }
  14895. }, {
  14896. key: "getExistingFallback", value: function getExistingFallback() {
  14897. var getFallback = function getFallback(elements) {
  14898. var _iteratorNormalCompletion12 = true;
  14899. var _didIteratorError12 = false;
  14900. var _iteratorError12 = undefined;
  14901. try {
  14902. for (var _iterator12 = elements[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {
  14903. var el = _step12.value;
  14904. if (/(^| )fallback($| )/.test(el.className)) {
  14905. return el
  14906. }
  14907. }
  14908. } catch (err) {
  14909. _didIteratorError12 = true;
  14910. _iteratorError12 = err
  14911. } finally {
  14912. try {
  14913. if (!_iteratorNormalCompletion12 && _iterator12["return"] != null) {
  14914. _iterator12["return"]()
  14915. }
  14916. } finally {
  14917. if (_didIteratorError12) {
  14918. throw _iteratorError12
  14919. }
  14920. }
  14921. }
  14922. };
  14923. for (var _i2 = 0, _arr = ["div", "form"]; _i2 < _arr.length; _i2++) {
  14924. var tagName = _arr[_i2];
  14925. var fallback;
  14926. if (fallback = getFallback(this.element.getElementsByTagName(tagName))) {
  14927. return fallback
  14928. }
  14929. }
  14930. }
  14931. }, {
  14932. key: "setupEventListeners", value: function setupEventListeners() {
  14933. return this.listeners.map(function (elementListeners) {
  14934. return function () {
  14935. var result = [];
  14936. for (var event in elementListeners.events) {
  14937. var listener = elementListeners.events[event];
  14938. result.push(elementListeners.element.addEventListener(event, listener, false))
  14939. }
  14940. return result
  14941. }()
  14942. })
  14943. }
  14944. }, {
  14945. key: "removeEventListeners", value: function removeEventListeners() {
  14946. return this.listeners.map(function (elementListeners) {
  14947. return function () {
  14948. var result = [];
  14949. for (var event in elementListeners.events) {
  14950. var listener = elementListeners.events[event];
  14951. result.push(elementListeners.element.removeEventListener(event, listener, false))
  14952. }
  14953. return result
  14954. }()
  14955. })
  14956. }
  14957. }, {
  14958. key: "disable", value: function disable() {
  14959. var _this4 = this;
  14960. this.clickableElements.forEach(function (element) {
  14961. return element.classList.remove("dz-clickable")
  14962. });
  14963. this.removeEventListeners();
  14964. this.disabled = true;
  14965. return this.files.map(function (file) {
  14966. return _this4.cancelUpload(file)
  14967. })
  14968. }
  14969. }, {
  14970. key: "enable", value: function enable() {
  14971. delete this.disabled;
  14972. this.clickableElements.forEach(function (element) {
  14973. return element.classList.add("dz-clickable")
  14974. });
  14975. return this.setupEventListeners()
  14976. }
  14977. }, {
  14978. key: "filesize", value: function filesize(size) {
  14979. var selectedSize = 0;
  14980. var selectedUnit = "b";
  14981. if (size > 0) {
  14982. var units = ["tb", "gb", "mb", "kb", "b"];
  14983. for (var i = 0; i < units.length; i++) {
  14984. var unit = units[i];
  14985. var cutoff = Math.pow(this.options.filesizeBase, 4 - i) / 10;
  14986. if (size >= cutoff) {
  14987. selectedSize = size / Math.pow(this.options.filesizeBase, 4 - i);
  14988. selectedUnit = unit;
  14989. break
  14990. }
  14991. }
  14992. selectedSize = Math.round(10 * selectedSize) / 10
  14993. }
  14994. return "<strong>".concat(selectedSize, "</strong> ").concat(this.options.dictFileSizeUnits[selectedUnit])
  14995. }
  14996. }, {
  14997. key: "_updateMaxFilesReachedClass", value: function _updateMaxFilesReachedClass() {
  14998. if (this.options.maxFiles != null && this.getAcceptedFiles().length >= this.options.maxFiles) {
  14999. if (this.getAcceptedFiles().length === this.options.maxFiles) {
  15000. this.emit("maxfilesreached", this.files)
  15001. }
  15002. return this.element.classList.add("dz-max-files-reached")
  15003. } else {
  15004. return this.element.classList.remove("dz-max-files-reached")
  15005. }
  15006. }
  15007. }, {
  15008. key: "drop", value: function drop(e) {
  15009. if (!e.dataTransfer) {
  15010. return
  15011. }
  15012. this.emit("drop", e);
  15013. var files = [];
  15014. for (var i = 0; i < e.dataTransfer.files.length; i++) {
  15015. files[i] = e.dataTransfer.files[i]
  15016. }
  15017. if (files.length) {
  15018. var items = e.dataTransfer.items;
  15019. if (items && items.length && items[0].webkitGetAsEntry != null) {
  15020. this._addFilesFromItems(items)
  15021. } else {
  15022. this.handleFiles(files)
  15023. }
  15024. }
  15025. this.emit("addedfiles", files)
  15026. }
  15027. }, {
  15028. key: "paste", value: function paste(e) {
  15029. if (__guard__(e != null ? e.clipboardData : undefined, function (x) {
  15030. return x.items
  15031. }) == null) {
  15032. return
  15033. }
  15034. this.emit("paste", e);
  15035. var items = e.clipboardData.items;
  15036. if (items.length) {
  15037. return this._addFilesFromItems(items)
  15038. }
  15039. }
  15040. }, {
  15041. key: "handleFiles", value: function handleFiles(files) {
  15042. var _iteratorNormalCompletion13 = true;
  15043. var _didIteratorError13 = false;
  15044. var _iteratorError13 = undefined;
  15045. try {
  15046. for (var _iterator13 = files[Symbol.iterator](), _step13; !(_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done); _iteratorNormalCompletion13 = true) {
  15047. var file = _step13.value;
  15048. this.addFile(file)
  15049. }
  15050. } catch (err) {
  15051. _didIteratorError13 = true;
  15052. _iteratorError13 = err
  15053. } finally {
  15054. try {
  15055. if (!_iteratorNormalCompletion13 && _iterator13["return"] != null) {
  15056. _iterator13["return"]()
  15057. }
  15058. } finally {
  15059. if (_didIteratorError13) {
  15060. throw _iteratorError13
  15061. }
  15062. }
  15063. }
  15064. }
  15065. }, {
  15066. key: "_addFilesFromItems", value: function _addFilesFromItems(items) {
  15067. var _this5 = this;
  15068. return function () {
  15069. var result = [];
  15070. var _iteratorNormalCompletion14 = true;
  15071. var _didIteratorError14 = false;
  15072. var _iteratorError14 = undefined;
  15073. try {
  15074. for (var _iterator14 = items[Symbol.iterator](), _step14; !(_iteratorNormalCompletion14 = (_step14 = _iterator14.next()).done); _iteratorNormalCompletion14 = true) {
  15075. var item = _step14.value;
  15076. var entry;
  15077. if (item.webkitGetAsEntry != null && (entry = item.webkitGetAsEntry())) {
  15078. if (entry.isFile) {
  15079. result.push(_this5.addFile(item.getAsFile()))
  15080. } else if (entry.isDirectory) {
  15081. result.push(_this5._addFilesFromDirectory(entry, entry.name))
  15082. } else {
  15083. result.push(undefined)
  15084. }
  15085. } else if (item.getAsFile != null) {
  15086. if (item.kind == null || item.kind === "file") {
  15087. result.push(_this5.addFile(item.getAsFile()))
  15088. } else {
  15089. result.push(undefined)
  15090. }
  15091. } else {
  15092. result.push(undefined)
  15093. }
  15094. }
  15095. } catch (err) {
  15096. _didIteratorError14 = true;
  15097. _iteratorError14 = err
  15098. } finally {
  15099. try {
  15100. if (!_iteratorNormalCompletion14 && _iterator14["return"] != null) {
  15101. _iterator14["return"]()
  15102. }
  15103. } finally {
  15104. if (_didIteratorError14) {
  15105. throw _iteratorError14
  15106. }
  15107. }
  15108. }
  15109. return result
  15110. }()
  15111. }
  15112. }, {
  15113. key: "_addFilesFromDirectory", value: function _addFilesFromDirectory(directory, path) {
  15114. var _this6 = this;
  15115. var dirReader = directory.createReader();
  15116. var errorHandler = function errorHandler(error) {
  15117. return __guardMethod__(console, "log", function (o) {
  15118. return o.log(error)
  15119. })
  15120. };
  15121. var readEntries = function readEntries() {
  15122. return dirReader.readEntries(function (entries) {
  15123. if (entries.length > 0) {
  15124. var _iteratorNormalCompletion15 = true;
  15125. var _didIteratorError15 = false;
  15126. var _iteratorError15 = undefined;
  15127. try {
  15128. for (var _iterator15 = entries[Symbol.iterator](), _step15; !(_iteratorNormalCompletion15 = (_step15 = _iterator15.next()).done); _iteratorNormalCompletion15 = true) {
  15129. var entry = _step15.value;
  15130. if (entry.isFile) {
  15131. entry.file(function (file) {
  15132. if (_this6.options.ignoreHiddenFiles && file.name.substring(0, 1) === ".") {
  15133. return
  15134. }
  15135. file.fullPath = "".concat(path, "/").concat(file.name);
  15136. return _this6.addFile(file)
  15137. })
  15138. } else if (entry.isDirectory) {
  15139. _this6._addFilesFromDirectory(entry, "".concat(path, "/").concat(entry.name))
  15140. }
  15141. }
  15142. } catch (err) {
  15143. _didIteratorError15 = true;
  15144. _iteratorError15 = err
  15145. } finally {
  15146. try {
  15147. if (!_iteratorNormalCompletion15 && _iterator15["return"] != null) {
  15148. _iterator15["return"]()
  15149. }
  15150. } finally {
  15151. if (_didIteratorError15) {
  15152. throw _iteratorError15
  15153. }
  15154. }
  15155. }
  15156. readEntries()
  15157. }
  15158. return null
  15159. }, errorHandler)
  15160. };
  15161. return readEntries()
  15162. }
  15163. }, {
  15164. key: "accept", value: function accept(file, done) {
  15165. if (this.options.maxFilesize && file.size > this.options.maxFilesize * 1024 * 1024) {
  15166. done(this.options.dictFileTooBig.replace("{{filesize}}", Math.round(file.size / 1024 / 10.24) / 100).replace("{{maxFilesize}}", this.options.maxFilesize))
  15167. } else if (!Dropzone.isValidFile(file, this.options.acceptedFiles)) {
  15168. done(this.options.dictInvalidFileType)
  15169. } else if (this.options.maxFiles != null && this.getAcceptedFiles().length >= this.options.maxFiles) {
  15170. done(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}", this.options.maxFiles));
  15171. this.emit("maxfilesexceeded", file)
  15172. } else {
  15173. this.options.accept.call(this, file, done)
  15174. }
  15175. }
  15176. }, {
  15177. key: "addFile", value: function addFile(file) {
  15178. var _this7 = this;
  15179. file.upload = {
  15180. uuid: Dropzone.uuidv4(),
  15181. progress: 0,
  15182. total: file.size,
  15183. bytesSent: 0,
  15184. filename: this._renameFile(file)
  15185. };
  15186. this.files.push(file);
  15187. file.status = Dropzone.ADDED;
  15188. this.emit("addedfile", file);
  15189. this._enqueueThumbnail(file);
  15190. this.accept(file, function (error) {
  15191. if (error) {
  15192. file.accepted = false;
  15193. _this7._errorProcessing([file], error)
  15194. } else {
  15195. file.accepted = true;
  15196. if (_this7.options.autoQueue) {
  15197. _this7.enqueueFile(file)
  15198. }
  15199. }
  15200. _this7._updateMaxFilesReachedClass()
  15201. })
  15202. }
  15203. }, {
  15204. key: "enqueueFiles", value: function enqueueFiles(files) {
  15205. var _iteratorNormalCompletion16 = true;
  15206. var _didIteratorError16 = false;
  15207. var _iteratorError16 = undefined;
  15208. try {
  15209. for (var _iterator16 = files[Symbol.iterator](), _step16; !(_iteratorNormalCompletion16 = (_step16 = _iterator16.next()).done); _iteratorNormalCompletion16 = true) {
  15210. var file = _step16.value;
  15211. this.enqueueFile(file)
  15212. }
  15213. } catch (err) {
  15214. _didIteratorError16 = true;
  15215. _iteratorError16 = err
  15216. } finally {
  15217. try {
  15218. if (!_iteratorNormalCompletion16 && _iterator16["return"] != null) {
  15219. _iterator16["return"]()
  15220. }
  15221. } finally {
  15222. if (_didIteratorError16) {
  15223. throw _iteratorError16
  15224. }
  15225. }
  15226. }
  15227. return null
  15228. }
  15229. }, {
  15230. key: "enqueueFile", value: function enqueueFile(file) {
  15231. var _this8 = this;
  15232. if (file.status === Dropzone.ADDED && file.accepted === true) {
  15233. file.status = Dropzone.QUEUED;
  15234. if (this.options.autoProcessQueue) {
  15235. return setTimeout(function () {
  15236. return _this8.processQueue()
  15237. }, 0)
  15238. }
  15239. } else {
  15240. throw new Error("This file can't be queued because it has already been processed or was rejected.")
  15241. }
  15242. }
  15243. }, {
  15244. key: "_enqueueThumbnail", value: function _enqueueThumbnail(file) {
  15245. var _this9 = this;
  15246. if (this.options.createImageThumbnails && file.type.match(/image.*/) && file.size <= this.options.maxThumbnailFilesize * 1024 * 1024) {
  15247. this._thumbnailQueue.push(file);
  15248. return setTimeout(function () {
  15249. return _this9._processThumbnailQueue()
  15250. }, 0)
  15251. }
  15252. }
  15253. }, {
  15254. key: "_processThumbnailQueue", value: function _processThumbnailQueue() {
  15255. var _this10 = this;
  15256. if (this._processingThumbnail || this._thumbnailQueue.length === 0) {
  15257. return
  15258. }
  15259. this._processingThumbnail = true;
  15260. var file = this._thumbnailQueue.shift();
  15261. return this.createThumbnail(file, this.options.thumbnailWidth, this.options.thumbnailHeight, this.options.thumbnailMethod, true, function (dataUrl) {
  15262. _this10.emit("thumbnail", file, dataUrl);
  15263. _this10._processingThumbnail = false;
  15264. return _this10._processThumbnailQueue()
  15265. })
  15266. }
  15267. }, {
  15268. key: "removeFile", value: function removeFile(file) {
  15269. if (file.status === Dropzone.UPLOADING) {
  15270. this.cancelUpload(file)
  15271. }
  15272. this.files = without(this.files, file);
  15273. this.emit("removedfile", file);
  15274. if (this.files.length === 0) {
  15275. return this.emit("reset")
  15276. }
  15277. }
  15278. }, {
  15279. key: "removeAllFiles", value: function removeAllFiles(cancelIfNecessary) {
  15280. if (cancelIfNecessary == null) {
  15281. cancelIfNecessary = false
  15282. }
  15283. var _iteratorNormalCompletion17 = true;
  15284. var _didIteratorError17 = false;
  15285. var _iteratorError17 = undefined;
  15286. try {
  15287. for (var _iterator17 = this.files.slice()[Symbol.iterator](), _step17; !(_iteratorNormalCompletion17 = (_step17 = _iterator17.next()).done); _iteratorNormalCompletion17 = true) {
  15288. var file = _step17.value;
  15289. if (file.status !== Dropzone.UPLOADING || cancelIfNecessary) {
  15290. this.removeFile(file)
  15291. }
  15292. }
  15293. } catch (err) {
  15294. _didIteratorError17 = true;
  15295. _iteratorError17 = err
  15296. } finally {
  15297. try {
  15298. if (!_iteratorNormalCompletion17 && _iterator17["return"] != null) {
  15299. _iterator17["return"]()
  15300. }
  15301. } finally {
  15302. if (_didIteratorError17) {
  15303. throw _iteratorError17
  15304. }
  15305. }
  15306. }
  15307. return null
  15308. }
  15309. }, {
  15310. key: "resizeImage", value: function resizeImage(file, width, height, resizeMethod, callback) {
  15311. var _this11 = this;
  15312. return this.createThumbnail(file, width, height, resizeMethod, true, function (dataUrl, canvas) {
  15313. if (canvas == null) {
  15314. return callback(file)
  15315. } else {
  15316. var resizeMimeType = _this11.options.resizeMimeType;
  15317. if (resizeMimeType == null) {
  15318. resizeMimeType = file.type
  15319. }
  15320. var resizedDataURL = canvas.toDataURL(resizeMimeType, _this11.options.resizeQuality);
  15321. if (resizeMimeType === "image/jpeg" || resizeMimeType === "image/jpg") {
  15322. resizedDataURL = ExifRestore.restore(file.dataURL, resizedDataURL)
  15323. }
  15324. return callback(Dropzone.dataURItoBlob(resizedDataURL))
  15325. }
  15326. })
  15327. }
  15328. }, {
  15329. key: "createThumbnail",
  15330. value: function createThumbnail(file, width, height, resizeMethod, fixOrientation, callback) {
  15331. var _this12 = this;
  15332. var fileReader = new FileReader;
  15333. fileReader.onload = function () {
  15334. file.dataURL = fileReader.result;
  15335. if (file.type === "image/svg+xml") {
  15336. if (callback != null) {
  15337. callback(fileReader.result)
  15338. }
  15339. return
  15340. }
  15341. _this12.createThumbnailFromUrl(file, width, height, resizeMethod, fixOrientation, callback)
  15342. };
  15343. fileReader.readAsDataURL(file)
  15344. }
  15345. }, {
  15346. key: "displayExistingFile", value: function displayExistingFile(mockFile, imageUrl, callback, crossOrigin) {
  15347. var _this13 = this;
  15348. var resizeThumbnail = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  15349. this.emit("addedfile", mockFile);
  15350. this.emit("complete", mockFile);
  15351. if (!resizeThumbnail) {
  15352. this.emit("thumbnail", mockFile, imageUrl);
  15353. if (callback) callback()
  15354. } else {
  15355. var onDone = function onDone(thumbnail) {
  15356. _this13.emit("thumbnail", mockFile, thumbnail);
  15357. if (callback) callback()
  15358. };
  15359. mockFile.dataURL = imageUrl;
  15360. this.createThumbnailFromUrl(mockFile, this.options.thumbnailWidth, this.options.thumbnailHeight, this.options.resizeMethod, this.options.fixOrientation, onDone, crossOrigin)
  15361. }
  15362. }
  15363. }, {
  15364. key: "createThumbnailFromUrl",
  15365. value: function createThumbnailFromUrl(file, width, height, resizeMethod, fixOrientation, callback, crossOrigin) {
  15366. var _this14 = this;
  15367. var img = document.createElement("img");
  15368. if (crossOrigin) {
  15369. img.crossOrigin = crossOrigin
  15370. }
  15371. img.onload = function () {
  15372. var loadExif = function loadExif(callback) {
  15373. return callback(1)
  15374. };
  15375. if (typeof EXIF !== "undefined" && EXIF !== null && fixOrientation) {
  15376. loadExif = function loadExif(callback) {
  15377. return EXIF.getData(img, function () {
  15378. return callback(EXIF.getTag(this, "Orientation"))
  15379. })
  15380. }
  15381. }
  15382. return loadExif(function (orientation) {
  15383. file.width = img.width;
  15384. file.height = img.height;
  15385. var resizeInfo = _this14.options.resize.call(_this14, file, width, height, resizeMethod);
  15386. var canvas = document.createElement("canvas");
  15387. var ctx = canvas.getContext("2d");
  15388. canvas.width = resizeInfo.trgWidth;
  15389. canvas.height = resizeInfo.trgHeight;
  15390. if (orientation > 4) {
  15391. canvas.width = resizeInfo.trgHeight;
  15392. canvas.height = resizeInfo.trgWidth
  15393. }
  15394. switch (orientation) {
  15395. case 2:
  15396. ctx.translate(canvas.width, 0);
  15397. ctx.scale(-1, 1);
  15398. break;
  15399. case 3:
  15400. ctx.translate(canvas.width, canvas.height);
  15401. ctx.rotate(Math.PI);
  15402. break;
  15403. case 4:
  15404. ctx.translate(0, canvas.height);
  15405. ctx.scale(1, -1);
  15406. break;
  15407. case 5:
  15408. ctx.rotate(.5 * Math.PI);
  15409. ctx.scale(1, -1);
  15410. break;
  15411. case 6:
  15412. ctx.rotate(.5 * Math.PI);
  15413. ctx.translate(0, -canvas.width);
  15414. break;
  15415. case 7:
  15416. ctx.rotate(.5 * Math.PI);
  15417. ctx.translate(canvas.height, -canvas.width);
  15418. ctx.scale(-1, 1);
  15419. break;
  15420. case 8:
  15421. ctx.rotate(-.5 * Math.PI);
  15422. ctx.translate(-canvas.height, 0);
  15423. break
  15424. }
  15425. 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);
  15426. var thumbnail = canvas.toDataURL("image/png");
  15427. if (callback != null) {
  15428. return callback(thumbnail, canvas)
  15429. }
  15430. })
  15431. };
  15432. if (callback != null) {
  15433. img.onerror = callback
  15434. }
  15435. return img.src = file.dataURL
  15436. }
  15437. }, {
  15438. key: "processQueue", value: function processQueue() {
  15439. var parallelUploads = this.options.parallelUploads;
  15440. var processingLength = this.getUploadingFiles().length;
  15441. var i = processingLength;
  15442. if (processingLength >= parallelUploads) {
  15443. return
  15444. }
  15445. var queuedFiles = this.getQueuedFiles();
  15446. if (!(queuedFiles.length > 0)) {
  15447. return
  15448. }
  15449. if (this.options.uploadMultiple) {
  15450. return this.processFiles(queuedFiles.slice(0, parallelUploads - processingLength))
  15451. } else {
  15452. while (i < parallelUploads) {
  15453. if (!queuedFiles.length) {
  15454. return
  15455. }
  15456. this.processFile(queuedFiles.shift());
  15457. i++
  15458. }
  15459. }
  15460. }
  15461. }, {
  15462. key: "processFile", value: function processFile(file) {
  15463. return this.processFiles([file])
  15464. }
  15465. }, {
  15466. key: "processFiles", value: function processFiles(files) {
  15467. var _iteratorNormalCompletion18 = true;
  15468. var _didIteratorError18 = false;
  15469. var _iteratorError18 = undefined;
  15470. try {
  15471. for (var _iterator18 = files[Symbol.iterator](), _step18; !(_iteratorNormalCompletion18 = (_step18 = _iterator18.next()).done); _iteratorNormalCompletion18 = true) {
  15472. var file = _step18.value;
  15473. file.processing = true;
  15474. file.status = Dropzone.UPLOADING;
  15475. this.emit("processing", file)
  15476. }
  15477. } catch (err) {
  15478. _didIteratorError18 = true;
  15479. _iteratorError18 = err
  15480. } finally {
  15481. try {
  15482. if (!_iteratorNormalCompletion18 && _iterator18["return"] != null) {
  15483. _iterator18["return"]()
  15484. }
  15485. } finally {
  15486. if (_didIteratorError18) {
  15487. throw _iteratorError18
  15488. }
  15489. }
  15490. }
  15491. if (this.options.uploadMultiple) {
  15492. this.emit("processingmultiple", files)
  15493. }
  15494. return this.uploadFiles(files)
  15495. }
  15496. }, {
  15497. key: "_getFilesWithXhr", value: function _getFilesWithXhr(xhr) {
  15498. var files;
  15499. return files = this.files.filter(function (file) {
  15500. return file.xhr === xhr
  15501. }).map(function (file) {
  15502. return file
  15503. })
  15504. }
  15505. }, {
  15506. key: "cancelUpload", value: function cancelUpload(file) {
  15507. if (file.status === Dropzone.UPLOADING) {
  15508. var groupedFiles = this._getFilesWithXhr(file.xhr);
  15509. var _iteratorNormalCompletion19 = true;
  15510. var _didIteratorError19 = false;
  15511. var _iteratorError19 = undefined;
  15512. try {
  15513. for (var _iterator19 = groupedFiles[Symbol.iterator](), _step19; !(_iteratorNormalCompletion19 = (_step19 = _iterator19.next()).done); _iteratorNormalCompletion19 = true) {
  15514. var groupedFile = _step19.value;
  15515. groupedFile.status = Dropzone.CANCELED
  15516. }
  15517. } catch (err) {
  15518. _didIteratorError19 = true;
  15519. _iteratorError19 = err
  15520. } finally {
  15521. try {
  15522. if (!_iteratorNormalCompletion19 && _iterator19["return"] != null) {
  15523. _iterator19["return"]()
  15524. }
  15525. } finally {
  15526. if (_didIteratorError19) {
  15527. throw _iteratorError19
  15528. }
  15529. }
  15530. }
  15531. if (typeof file.xhr !== "undefined") {
  15532. file.xhr.abort()
  15533. }
  15534. var _iteratorNormalCompletion20 = true;
  15535. var _didIteratorError20 = false;
  15536. var _iteratorError20 = undefined;
  15537. try {
  15538. for (var _iterator20 = groupedFiles[Symbol.iterator](), _step20; !(_iteratorNormalCompletion20 = (_step20 = _iterator20.next()).done); _iteratorNormalCompletion20 = true) {
  15539. var _groupedFile = _step20.value;
  15540. this.emit("canceled", _groupedFile)
  15541. }
  15542. } catch (err) {
  15543. _didIteratorError20 = true;
  15544. _iteratorError20 = err
  15545. } finally {
  15546. try {
  15547. if (!_iteratorNormalCompletion20 && _iterator20["return"] != null) {
  15548. _iterator20["return"]()
  15549. }
  15550. } finally {
  15551. if (_didIteratorError20) {
  15552. throw _iteratorError20
  15553. }
  15554. }
  15555. }
  15556. if (this.options.uploadMultiple) {
  15557. this.emit("canceledmultiple", groupedFiles)
  15558. }
  15559. } else if (file.status === Dropzone.ADDED || file.status === Dropzone.QUEUED) {
  15560. file.status = Dropzone.CANCELED;
  15561. this.emit("canceled", file);
  15562. if (this.options.uploadMultiple) {
  15563. this.emit("canceledmultiple", [file])
  15564. }
  15565. }
  15566. if (this.options.autoProcessQueue) {
  15567. return this.processQueue()
  15568. }
  15569. }
  15570. }, {
  15571. key: "resolveOption", value: function resolveOption(option) {
  15572. if (typeof option === "function") {
  15573. for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
  15574. args[_key3 - 1] = arguments[_key3]
  15575. }
  15576. return option.apply(this, args)
  15577. }
  15578. return option
  15579. }
  15580. }, {
  15581. key: "uploadFile", value: function uploadFile(file) {
  15582. return this.uploadFiles([file])
  15583. }
  15584. }, {
  15585. key: "uploadFiles", value: function uploadFiles(files) {
  15586. var _this15 = this;
  15587. this._transformFiles(files, function (transformedFiles) {
  15588. if (_this15.options.chunking) {
  15589. var transformedFile = transformedFiles[0];
  15590. files[0].upload.chunked = _this15.options.chunking && (_this15.options.forceChunking || transformedFile.size > _this15.options.chunkSize);
  15591. files[0].upload.totalChunkCount = Math.ceil(transformedFile.size / _this15.options.chunkSize)
  15592. }
  15593. if (files[0].upload.chunked) {
  15594. var file = files[0];
  15595. var _transformedFile = transformedFiles[0];
  15596. var startedChunkCount = 0;
  15597. file.upload.chunks = [];
  15598. var handleNextChunk = function handleNextChunk() {
  15599. var chunkIndex = 0;
  15600. while (file.upload.chunks[chunkIndex] !== undefined) {
  15601. chunkIndex++
  15602. }
  15603. if (chunkIndex >= file.upload.totalChunkCount) return;
  15604. startedChunkCount++;
  15605. var start = chunkIndex * _this15.options.chunkSize;
  15606. var end = Math.min(start + _this15.options.chunkSize, file.size);
  15607. var dataBlock = {
  15608. name: _this15._getParamName(0),
  15609. data: _transformedFile.webkitSlice ? _transformedFile.webkitSlice(start, end) : _transformedFile.slice(start, end),
  15610. filename: file.upload.filename,
  15611. chunkIndex: chunkIndex
  15612. };
  15613. file.upload.chunks[chunkIndex] = {
  15614. file: file,
  15615. index: chunkIndex,
  15616. dataBlock: dataBlock,
  15617. status: Dropzone.UPLOADING,
  15618. progress: 0,
  15619. retries: 0
  15620. };
  15621. _this15._uploadData(files, [dataBlock])
  15622. };
  15623. file.upload.finishedChunkUpload = function (chunk, response) {
  15624. var allFinished = true;
  15625. chunk.status = Dropzone.SUCCESS;
  15626. _this15.options.chunkSuccess.call(_this15, chunk, file, response);
  15627. chunk.dataBlock = null;
  15628. chunk.xhr = null;
  15629. for (var i = 0; i < file.upload.totalChunkCount; i++) {
  15630. if (file.upload.chunks[i] === undefined) {
  15631. return handleNextChunk()
  15632. }
  15633. if (file.upload.chunks[i].status !== Dropzone.SUCCESS) {
  15634. allFinished = false
  15635. }
  15636. }
  15637. if (allFinished) {
  15638. _this15.options.chunksUploaded.call(_this15, file, function (response) {
  15639. _this15._finished(files, response || "", null)
  15640. })
  15641. }
  15642. };
  15643. if (_this15.options.parallelChunkUploads) {
  15644. for (var i = 0; i < file.upload.totalChunkCount; i++) {
  15645. handleNextChunk()
  15646. }
  15647. } else {
  15648. handleNextChunk()
  15649. }
  15650. } else {
  15651. var dataBlocks = [];
  15652. for (var _i3 = 0; _i3 < files.length; _i3++) {
  15653. dataBlocks[_i3] = {
  15654. name: _this15._getParamName(_i3),
  15655. data: transformedFiles[_i3],
  15656. filename: files[_i3].upload.filename
  15657. }
  15658. }
  15659. _this15._uploadData(files, dataBlocks)
  15660. }
  15661. })
  15662. }
  15663. }, {
  15664. key: "_getChunk", value: function _getChunk(file, xhr) {
  15665. for (var i = 0; i < file.upload.totalChunkCount; i++) {
  15666. if (file.upload.chunks[i] !== undefined && file.upload.chunks[i].xhr === xhr) {
  15667. return file.upload.chunks[i]
  15668. }
  15669. }
  15670. }
  15671. }, {
  15672. key: "_uploadData", value: function _uploadData(files, dataBlocks) {
  15673. var _this16 = this;
  15674. var xhr = new XMLHttpRequest;
  15675. var _iteratorNormalCompletion21 = true;
  15676. var _didIteratorError21 = false;
  15677. var _iteratorError21 = undefined;
  15678. try {
  15679. for (var _iterator21 = files[Symbol.iterator](), _step21; !(_iteratorNormalCompletion21 = (_step21 = _iterator21.next()).done); _iteratorNormalCompletion21 = true) {
  15680. var file = _step21.value;
  15681. file.xhr = xhr
  15682. }
  15683. } catch (err) {
  15684. _didIteratorError21 = true;
  15685. _iteratorError21 = err
  15686. } finally {
  15687. try {
  15688. if (!_iteratorNormalCompletion21 && _iterator21["return"] != null) {
  15689. _iterator21["return"]()
  15690. }
  15691. } finally {
  15692. if (_didIteratorError21) {
  15693. throw _iteratorError21
  15694. }
  15695. }
  15696. }
  15697. if (files[0].upload.chunked) {
  15698. files[0].upload.chunks[dataBlocks[0].chunkIndex].xhr = xhr
  15699. }
  15700. var method = this.resolveOption(this.options.method, files);
  15701. var url = this.resolveOption(this.options.url, files);
  15702. xhr.open(method, url, true);
  15703. xhr.timeout = this.resolveOption(this.options.timeout, files);
  15704. xhr.withCredentials = !!this.options.withCredentials;
  15705. xhr.onload = function (e) {
  15706. _this16._finishedUploading(files, xhr, e)
  15707. };
  15708. xhr.ontimeout = function () {
  15709. _this16._handleUploadError(files, xhr, "Request timedout after ".concat(_this16.options.timeout, " seconds"))
  15710. };
  15711. xhr.onerror = function () {
  15712. _this16._handleUploadError(files, xhr)
  15713. };
  15714. var progressObj = xhr.upload != null ? xhr.upload : xhr;
  15715. progressObj.onprogress = function (e) {
  15716. return _this16._updateFilesUploadProgress(files, xhr, e)
  15717. };
  15718. var headers = {
  15719. Accept: "application/json",
  15720. "Cache-Control": "no-cache",
  15721. "X-Requested-With": "XMLHttpRequest"
  15722. };
  15723. if (this.options.headers) {
  15724. Dropzone.extend(headers, this.options.headers)
  15725. }
  15726. for (var headerName in headers) {
  15727. var headerValue = headers[headerName];
  15728. if (headerValue) {
  15729. xhr.setRequestHeader(headerName, headerValue)
  15730. }
  15731. }
  15732. var formData = new FormData;
  15733. if (this.options.params) {
  15734. var additionalParams = this.options.params;
  15735. if (typeof additionalParams === "function") {
  15736. additionalParams = additionalParams.call(this, files, xhr, files[0].upload.chunked ? this._getChunk(files[0], xhr) : null)
  15737. }
  15738. for (var key in additionalParams) {
  15739. var value = additionalParams[key];
  15740. formData.append(key, value)
  15741. }
  15742. }
  15743. var _iteratorNormalCompletion22 = true;
  15744. var _didIteratorError22 = false;
  15745. var _iteratorError22 = undefined;
  15746. try {
  15747. for (var _iterator22 = files[Symbol.iterator](), _step22; !(_iteratorNormalCompletion22 = (_step22 = _iterator22.next()).done); _iteratorNormalCompletion22 = true) {
  15748. var _file = _step22.value;
  15749. this.emit("sending", _file, xhr, formData)
  15750. }
  15751. } catch (err) {
  15752. _didIteratorError22 = true;
  15753. _iteratorError22 = err
  15754. } finally {
  15755. try {
  15756. if (!_iteratorNormalCompletion22 && _iterator22["return"] != null) {
  15757. _iterator22["return"]()
  15758. }
  15759. } finally {
  15760. if (_didIteratorError22) {
  15761. throw _iteratorError22
  15762. }
  15763. }
  15764. }
  15765. if (this.options.uploadMultiple) {
  15766. this.emit("sendingmultiple", files, xhr, formData)
  15767. }
  15768. this._addFormElementData(formData);
  15769. for (var i = 0; i < dataBlocks.length; i++) {
  15770. var dataBlock = dataBlocks[i];
  15771. formData.append(dataBlock.name, dataBlock.data, dataBlock.filename)
  15772. }
  15773. this.submitRequest(xhr, formData, files)
  15774. }
  15775. }, {
  15776. key: "_transformFiles", value: function _transformFiles(files, done) {
  15777. var _this17 = this;
  15778. var transformedFiles = [];
  15779. var doneCounter = 0;
  15780. var _loop = function _loop(i) {
  15781. _this17.options.transformFile.call(_this17, files[i], function (transformedFile) {
  15782. transformedFiles[i] = transformedFile;
  15783. if (++doneCounter === files.length) {
  15784. done(transformedFiles)
  15785. }
  15786. })
  15787. };
  15788. for (var i = 0; i < files.length; i++) {
  15789. _loop(i)
  15790. }
  15791. }
  15792. }, {
  15793. key: "_addFormElementData", value: function _addFormElementData(formData) {
  15794. if (this.element.tagName === "FORM") {
  15795. var _iteratorNormalCompletion23 = true;
  15796. var _didIteratorError23 = false;
  15797. var _iteratorError23 = undefined;
  15798. try {
  15799. for (var _iterator23 = this.element.querySelectorAll("input, textarea, select, button")[Symbol.iterator](), _step23; !(_iteratorNormalCompletion23 = (_step23 = _iterator23.next()).done); _iteratorNormalCompletion23 = true) {
  15800. var input = _step23.value;
  15801. var inputName = input.getAttribute("name");
  15802. var inputType = input.getAttribute("type");
  15803. if (inputType) inputType = inputType.toLowerCase();
  15804. if (typeof inputName === "undefined" || inputName === null) continue;
  15805. if (input.tagName === "SELECT" && input.hasAttribute("multiple")) {
  15806. var _iteratorNormalCompletion24 = true;
  15807. var _didIteratorError24 = false;
  15808. var _iteratorError24 = undefined;
  15809. try {
  15810. for (var _iterator24 = input.options[Symbol.iterator](), _step24; !(_iteratorNormalCompletion24 = (_step24 = _iterator24.next()).done); _iteratorNormalCompletion24 = true) {
  15811. var option = _step24.value;
  15812. if (option.selected) {
  15813. formData.append(inputName, option.value)
  15814. }
  15815. }
  15816. } catch (err) {
  15817. _didIteratorError24 = true;
  15818. _iteratorError24 = err
  15819. } finally {
  15820. try {
  15821. if (!_iteratorNormalCompletion24 && _iterator24["return"] != null) {
  15822. _iterator24["return"]()
  15823. }
  15824. } finally {
  15825. if (_didIteratorError24) {
  15826. throw _iteratorError24
  15827. }
  15828. }
  15829. }
  15830. } else if (!inputType || inputType !== "checkbox" && inputType !== "radio" || input.checked) {
  15831. formData.append(inputName, input.value)
  15832. }
  15833. }
  15834. } catch (err) {
  15835. _didIteratorError23 = true;
  15836. _iteratorError23 = err
  15837. } finally {
  15838. try {
  15839. if (!_iteratorNormalCompletion23 && _iterator23["return"] != null) {
  15840. _iterator23["return"]()
  15841. }
  15842. } finally {
  15843. if (_didIteratorError23) {
  15844. throw _iteratorError23
  15845. }
  15846. }
  15847. }
  15848. }
  15849. }
  15850. }, {
  15851. key: "_updateFilesUploadProgress", value: function _updateFilesUploadProgress(files, xhr, e) {
  15852. var progress;
  15853. if (typeof e !== "undefined") {
  15854. progress = 100 * e.loaded / e.total;
  15855. if (files[0].upload.chunked) {
  15856. var file = files[0];
  15857. var chunk = this._getChunk(file, xhr);
  15858. chunk.progress = progress;
  15859. chunk.total = e.total;
  15860. chunk.bytesSent = e.loaded;
  15861. var fileProgress = 0, fileTotal, fileBytesSent;
  15862. file.upload.progress = 0;
  15863. file.upload.total = 0;
  15864. file.upload.bytesSent = 0;
  15865. for (var i = 0; i < file.upload.totalChunkCount; i++) {
  15866. if (file.upload.chunks[i] !== undefined && file.upload.chunks[i].progress !== undefined) {
  15867. file.upload.progress += file.upload.chunks[i].progress;
  15868. file.upload.total += file.upload.chunks[i].total;
  15869. file.upload.bytesSent += file.upload.chunks[i].bytesSent
  15870. }
  15871. }
  15872. file.upload.progress = file.upload.progress / file.upload.totalChunkCount
  15873. } else {
  15874. var _iteratorNormalCompletion25 = true;
  15875. var _didIteratorError25 = false;
  15876. var _iteratorError25 = undefined;
  15877. try {
  15878. for (var _iterator25 = files[Symbol.iterator](), _step25; !(_iteratorNormalCompletion25 = (_step25 = _iterator25.next()).done); _iteratorNormalCompletion25 = true) {
  15879. var _file2 = _step25.value;
  15880. _file2.upload.progress = progress;
  15881. _file2.upload.total = e.total;
  15882. _file2.upload.bytesSent = e.loaded
  15883. }
  15884. } catch (err) {
  15885. _didIteratorError25 = true;
  15886. _iteratorError25 = err
  15887. } finally {
  15888. try {
  15889. if (!_iteratorNormalCompletion25 && _iterator25["return"] != null) {
  15890. _iterator25["return"]()
  15891. }
  15892. } finally {
  15893. if (_didIteratorError25) {
  15894. throw _iteratorError25
  15895. }
  15896. }
  15897. }
  15898. }
  15899. var _iteratorNormalCompletion26 = true;
  15900. var _didIteratorError26 = false;
  15901. var _iteratorError26 = undefined;
  15902. try {
  15903. for (var _iterator26 = files[Symbol.iterator](), _step26; !(_iteratorNormalCompletion26 = (_step26 = _iterator26.next()).done); _iteratorNormalCompletion26 = true) {
  15904. var _file3 = _step26.value;
  15905. this.emit("uploadprogress", _file3, _file3.upload.progress, _file3.upload.bytesSent)
  15906. }
  15907. } catch (err) {
  15908. _didIteratorError26 = true;
  15909. _iteratorError26 = err
  15910. } finally {
  15911. try {
  15912. if (!_iteratorNormalCompletion26 && _iterator26["return"] != null) {
  15913. _iterator26["return"]()
  15914. }
  15915. } finally {
  15916. if (_didIteratorError26) {
  15917. throw _iteratorError26
  15918. }
  15919. }
  15920. }
  15921. } else {
  15922. var allFilesFinished = true;
  15923. progress = 100;
  15924. var _iteratorNormalCompletion27 = true;
  15925. var _didIteratorError27 = false;
  15926. var _iteratorError27 = undefined;
  15927. try {
  15928. for (var _iterator27 = files[Symbol.iterator](), _step27; !(_iteratorNormalCompletion27 = (_step27 = _iterator27.next()).done); _iteratorNormalCompletion27 = true) {
  15929. var _file4 = _step27.value;
  15930. if (_file4.upload.progress !== 100 || _file4.upload.bytesSent !== _file4.upload.total) {
  15931. allFilesFinished = false
  15932. }
  15933. _file4.upload.progress = progress;
  15934. _file4.upload.bytesSent = _file4.upload.total
  15935. }
  15936. } catch (err) {
  15937. _didIteratorError27 = true;
  15938. _iteratorError27 = err
  15939. } finally {
  15940. try {
  15941. if (!_iteratorNormalCompletion27 && _iterator27["return"] != null) {
  15942. _iterator27["return"]()
  15943. }
  15944. } finally {
  15945. if (_didIteratorError27) {
  15946. throw _iteratorError27
  15947. }
  15948. }
  15949. }
  15950. if (allFilesFinished) {
  15951. return
  15952. }
  15953. var _iteratorNormalCompletion28 = true;
  15954. var _didIteratorError28 = false;
  15955. var _iteratorError28 = undefined;
  15956. try {
  15957. for (var _iterator28 = files[Symbol.iterator](), _step28; !(_iteratorNormalCompletion28 = (_step28 = _iterator28.next()).done); _iteratorNormalCompletion28 = true) {
  15958. var _file5 = _step28.value;
  15959. this.emit("uploadprogress", _file5, progress, _file5.upload.bytesSent)
  15960. }
  15961. } catch (err) {
  15962. _didIteratorError28 = true;
  15963. _iteratorError28 = err
  15964. } finally {
  15965. try {
  15966. if (!_iteratorNormalCompletion28 && _iterator28["return"] != null) {
  15967. _iterator28["return"]()
  15968. }
  15969. } finally {
  15970. if (_didIteratorError28) {
  15971. throw _iteratorError28
  15972. }
  15973. }
  15974. }
  15975. }
  15976. }
  15977. }, {
  15978. key: "_finishedUploading", value: function _finishedUploading(files, xhr, e) {
  15979. var response;
  15980. if (files[0].status === Dropzone.CANCELED) {
  15981. return
  15982. }
  15983. if (xhr.readyState !== 4) {
  15984. return
  15985. }
  15986. if (xhr.responseType !== "arraybuffer" && xhr.responseType !== "blob") {
  15987. response = xhr.responseText;
  15988. if (xhr.getResponseHeader("content-type") && ~xhr.getResponseHeader("content-type").indexOf("application/json")) {
  15989. try {
  15990. response = JSON.parse(response)
  15991. } catch (error) {
  15992. e = error;
  15993. response = "Invalid JSON response from server."
  15994. }
  15995. }
  15996. }
  15997. this._updateFilesUploadProgress(files);
  15998. if (!(200 <= xhr.status && xhr.status < 300)) {
  15999. this._handleUploadError(files, xhr, response)
  16000. } else {
  16001. if (files[0].upload.chunked) {
  16002. files[0].upload.finishedChunkUpload(this._getChunk(files[0], xhr), response)
  16003. } else {
  16004. this._finished(files, response, e)
  16005. }
  16006. }
  16007. }
  16008. }, {
  16009. key: "_handleUploadError", value: function _handleUploadError(files, xhr, response) {
  16010. if (files[0].status === Dropzone.CANCELED) {
  16011. return
  16012. }
  16013. if (files[0].upload.chunked && this.options.retryChunks) {
  16014. var chunk = this._getChunk(files[0], xhr);
  16015. if (chunk.retries++ < this.options.retryChunksLimit) {
  16016. this._uploadData(files, [chunk.dataBlock]);
  16017. return
  16018. } else {
  16019. console.warn("Retried this chunk too often. Giving up.")
  16020. }
  16021. }
  16022. this._errorProcessing(files, response || this.options.dictResponseError.replace("{{statusCode}}", xhr.status), xhr)
  16023. }
  16024. }, {
  16025. key: "submitRequest", value: function submitRequest(xhr, formData, files) {
  16026. xhr.send(formData)
  16027. }
  16028. }, {
  16029. key: "_finished", value: function _finished(files, responseText, e) {
  16030. var _iteratorNormalCompletion29 = true;
  16031. var _didIteratorError29 = false;
  16032. var _iteratorError29 = undefined;
  16033. try {
  16034. for (var _iterator29 = files[Symbol.iterator](), _step29; !(_iteratorNormalCompletion29 = (_step29 = _iterator29.next()).done); _iteratorNormalCompletion29 = true) {
  16035. var file = _step29.value;
  16036. file.status = Dropzone.SUCCESS;
  16037. this.emit("success", file, responseText, e);
  16038. this.emit("complete", file)
  16039. }
  16040. } catch (err) {
  16041. _didIteratorError29 = true;
  16042. _iteratorError29 = err
  16043. } finally {
  16044. try {
  16045. if (!_iteratorNormalCompletion29 && _iterator29["return"] != null) {
  16046. _iterator29["return"]()
  16047. }
  16048. } finally {
  16049. if (_didIteratorError29) {
  16050. throw _iteratorError29
  16051. }
  16052. }
  16053. }
  16054. if (this.options.uploadMultiple) {
  16055. this.emit("successmultiple", files, responseText, e);
  16056. this.emit("completemultiple", files)
  16057. }
  16058. if (this.options.autoProcessQueue) {
  16059. return this.processQueue()
  16060. }
  16061. }
  16062. }, {
  16063. key: "_errorProcessing", value: function _errorProcessing(files, message, xhr) {
  16064. var _iteratorNormalCompletion30 = true;
  16065. var _didIteratorError30 = false;
  16066. var _iteratorError30 = undefined;
  16067. try {
  16068. for (var _iterator30 = files[Symbol.iterator](), _step30; !(_iteratorNormalCompletion30 = (_step30 = _iterator30.next()).done); _iteratorNormalCompletion30 = true) {
  16069. var file = _step30.value;
  16070. file.status = Dropzone.ERROR;
  16071. this.emit("error", file, message, xhr);
  16072. this.emit("complete", file)
  16073. }
  16074. } catch (err) {
  16075. _didIteratorError30 = true;
  16076. _iteratorError30 = err
  16077. } finally {
  16078. try {
  16079. if (!_iteratorNormalCompletion30 && _iterator30["return"] != null) {
  16080. _iterator30["return"]()
  16081. }
  16082. } finally {
  16083. if (_didIteratorError30) {
  16084. throw _iteratorError30
  16085. }
  16086. }
  16087. }
  16088. if (this.options.uploadMultiple) {
  16089. this.emit("errormultiple", files, message, xhr);
  16090. this.emit("completemultiple", files)
  16091. }
  16092. if (this.options.autoProcessQueue) {
  16093. return this.processQueue()
  16094. }
  16095. }
  16096. }], [{
  16097. key: "uuidv4", value: function uuidv4() {
  16098. return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
  16099. var r = Math.random() * 16 | 0, v = c === "x" ? r : r & 3 | 8;
  16100. return v.toString(16)
  16101. })
  16102. }
  16103. }]);
  16104. return Dropzone
  16105. }(Emitter);
  16106. Dropzone.initClass();
  16107. Dropzone.version = "5.7.0";
  16108. Dropzone.options = {};
  16109. Dropzone.optionsForElement = function (element) {
  16110. if (element.getAttribute("id")) {
  16111. return Dropzone.options[camelize(element.getAttribute("id"))]
  16112. } else {
  16113. return undefined
  16114. }
  16115. };
  16116. Dropzone.instances = [];
  16117. Dropzone.forElement = function (element) {
  16118. if (typeof element === "string") {
  16119. element = document.querySelector(element)
  16120. }
  16121. if ((element != null ? element.dropzone : undefined) == null) {
  16122. 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.")
  16123. }
  16124. return element.dropzone
  16125. };
  16126. Dropzone.autoDiscover = true;
  16127. Dropzone.discover = function () {
  16128. var dropzones;
  16129. if (document.querySelectorAll) {
  16130. dropzones = document.querySelectorAll(".dropzone")
  16131. } else {
  16132. dropzones = [];
  16133. var checkElements = function checkElements(elements) {
  16134. return function () {
  16135. var result = [];
  16136. var _iteratorNormalCompletion31 = true;
  16137. var _didIteratorError31 = false;
  16138. var _iteratorError31 = undefined;
  16139. try {
  16140. for (var _iterator31 = elements[Symbol.iterator](), _step31; !(_iteratorNormalCompletion31 = (_step31 = _iterator31.next()).done); _iteratorNormalCompletion31 = true) {
  16141. var el = _step31.value;
  16142. if (/(^| )dropzone($| )/.test(el.className)) {
  16143. result.push(dropzones.push(el))
  16144. } else {
  16145. result.push(undefined)
  16146. }
  16147. }
  16148. } catch (err) {
  16149. _didIteratorError31 = true;
  16150. _iteratorError31 = err
  16151. } finally {
  16152. try {
  16153. if (!_iteratorNormalCompletion31 && _iterator31["return"] != null) {
  16154. _iterator31["return"]()
  16155. }
  16156. } finally {
  16157. if (_didIteratorError31) {
  16158. throw _iteratorError31
  16159. }
  16160. }
  16161. }
  16162. return result
  16163. }()
  16164. };
  16165. checkElements(document.getElementsByTagName("div"));
  16166. checkElements(document.getElementsByTagName("form"))
  16167. }
  16168. return function () {
  16169. var result = [];
  16170. var _iteratorNormalCompletion32 = true;
  16171. var _didIteratorError32 = false;
  16172. var _iteratorError32 = undefined;
  16173. try {
  16174. for (var _iterator32 = dropzones[Symbol.iterator](), _step32; !(_iteratorNormalCompletion32 = (_step32 = _iterator32.next()).done); _iteratorNormalCompletion32 = true) {
  16175. var dropzone = _step32.value;
  16176. if (Dropzone.optionsForElement(dropzone) !== false) {
  16177. result.push(new Dropzone(dropzone))
  16178. } else {
  16179. result.push(undefined)
  16180. }
  16181. }
  16182. } catch (err) {
  16183. _didIteratorError32 = true;
  16184. _iteratorError32 = err
  16185. } finally {
  16186. try {
  16187. if (!_iteratorNormalCompletion32 && _iterator32["return"] != null) {
  16188. _iterator32["return"]()
  16189. }
  16190. } finally {
  16191. if (_didIteratorError32) {
  16192. throw _iteratorError32
  16193. }
  16194. }
  16195. }
  16196. return result
  16197. }()
  16198. };
  16199. Dropzone.blacklistedBrowsers = [/opera.*(Macintosh|Windows Phone).*version\/12/i];
  16200. Dropzone.isBrowserSupported = function () {
  16201. var capableBrowser = true;
  16202. if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData && document.querySelector) {
  16203. if (!("classList" in document.createElement("a"))) {
  16204. capableBrowser = false
  16205. } else {
  16206. var _iteratorNormalCompletion33 = true;
  16207. var _didIteratorError33 = false;
  16208. var _iteratorError33 = undefined;
  16209. try {
  16210. for (var _iterator33 = Dropzone.blacklistedBrowsers[Symbol.iterator](), _step33; !(_iteratorNormalCompletion33 = (_step33 = _iterator33.next()).done); _iteratorNormalCompletion33 = true) {
  16211. var regex = _step33.value;
  16212. if (regex.test(navigator.userAgent)) {
  16213. capableBrowser = false;
  16214. continue
  16215. }
  16216. }
  16217. } catch (err) {
  16218. _didIteratorError33 = true;
  16219. _iteratorError33 = err
  16220. } finally {
  16221. try {
  16222. if (!_iteratorNormalCompletion33 && _iterator33["return"] != null) {
  16223. _iterator33["return"]()
  16224. }
  16225. } finally {
  16226. if (_didIteratorError33) {
  16227. throw _iteratorError33
  16228. }
  16229. }
  16230. }
  16231. }
  16232. } else {
  16233. capableBrowser = false
  16234. }
  16235. return capableBrowser
  16236. };
  16237. Dropzone.dataURItoBlob = function (dataURI) {
  16238. var byteString = atob(dataURI.split(",")[1]);
  16239. var mimeString = dataURI.split(",")[0].split(":")[1].split(";")[0];
  16240. var ab = new ArrayBuffer(byteString.length);
  16241. var ia = new Uint8Array(ab);
  16242. for (var i = 0, end = byteString.length, asc = 0 <= end; asc ? i <= end : i >= end; asc ? i++ : i--) {
  16243. ia[i] = byteString.charCodeAt(i)
  16244. }
  16245. return new Blob([ab], {type: mimeString})
  16246. };
  16247. var without = function without(list, rejectedItem) {
  16248. return list.filter(function (item) {
  16249. return item !== rejectedItem
  16250. }).map(function (item) {
  16251. return item
  16252. })
  16253. };
  16254. var camelize = function camelize(str) {
  16255. return str.replace(/[\-_](\w)/g, function (match) {
  16256. return match.charAt(1).toUpperCase()
  16257. })
  16258. };
  16259. Dropzone.createElement = function (string) {
  16260. var div = document.createElement("div");
  16261. div.innerHTML = string;
  16262. return div.childNodes[0]
  16263. };
  16264. Dropzone.elementInside = function (element, container) {
  16265. if (element === container) {
  16266. return true
  16267. }
  16268. while (element = element.parentNode) {
  16269. if (element === container) {
  16270. return true
  16271. }
  16272. }
  16273. return false
  16274. };
  16275. Dropzone.getElement = function (el, name) {
  16276. var element;
  16277. if (typeof el === "string") {
  16278. element = document.querySelector(el)
  16279. } else if (el.nodeType != null) {
  16280. element = el
  16281. }
  16282. if (element == null) {
  16283. throw new Error("Invalid `".concat(name, "` option provided. Please provide a CSS selector or a plain HTML element."))
  16284. }
  16285. return element
  16286. };
  16287. Dropzone.getElements = function (els, name) {
  16288. var el, elements;
  16289. if (els instanceof Array) {
  16290. elements = [];
  16291. try {
  16292. var _iteratorNormalCompletion34 = true;
  16293. var _didIteratorError34 = false;
  16294. var _iteratorError34 = undefined;
  16295. try {
  16296. for (var _iterator34 = els[Symbol.iterator](), _step34; !(_iteratorNormalCompletion34 = (_step34 = _iterator34.next()).done); _iteratorNormalCompletion34 = true) {
  16297. el = _step34.value;
  16298. elements.push(this.getElement(el, name))
  16299. }
  16300. } catch (err) {
  16301. _didIteratorError34 = true;
  16302. _iteratorError34 = err
  16303. } finally {
  16304. try {
  16305. if (!_iteratorNormalCompletion34 && _iterator34["return"] != null) {
  16306. _iterator34["return"]()
  16307. }
  16308. } finally {
  16309. if (_didIteratorError34) {
  16310. throw _iteratorError34
  16311. }
  16312. }
  16313. }
  16314. } catch (e) {
  16315. elements = null
  16316. }
  16317. } else if (typeof els === "string") {
  16318. elements = [];
  16319. var _iteratorNormalCompletion35 = true;
  16320. var _didIteratorError35 = false;
  16321. var _iteratorError35 = undefined;
  16322. try {
  16323. for (var _iterator35 = document.querySelectorAll(els)[Symbol.iterator](), _step35; !(_iteratorNormalCompletion35 = (_step35 = _iterator35.next()).done); _iteratorNormalCompletion35 = true) {
  16324. el = _step35.value;
  16325. elements.push(el)
  16326. }
  16327. } catch (err) {
  16328. _didIteratorError35 = true;
  16329. _iteratorError35 = err
  16330. } finally {
  16331. try {
  16332. if (!_iteratorNormalCompletion35 && _iterator35["return"] != null) {
  16333. _iterator35["return"]()
  16334. }
  16335. } finally {
  16336. if (_didIteratorError35) {
  16337. throw _iteratorError35
  16338. }
  16339. }
  16340. }
  16341. } else if (els.nodeType != null) {
  16342. elements = [els]
  16343. }
  16344. if (elements == null || !elements.length) {
  16345. throw new Error("Invalid `".concat(name, "` option provided. Please provide a CSS selector, a plain HTML element or a list of those."))
  16346. }
  16347. return elements
  16348. };
  16349. Dropzone.confirm = function (question, accepted, rejected) {
  16350. if (window.confirm(question)) {
  16351. return accepted()
  16352. } else if (rejected != null) {
  16353. return rejected()
  16354. }
  16355. };
  16356. Dropzone.isValidFile = function (file, acceptedFiles) {
  16357. if (!acceptedFiles) {
  16358. return true
  16359. }
  16360. acceptedFiles = acceptedFiles.split(",");
  16361. var mimeType = file.type;
  16362. var baseMimeType = mimeType.replace(/\/.*$/, "");
  16363. var _iteratorNormalCompletion36 = true;
  16364. var _didIteratorError36 = false;
  16365. var _iteratorError36 = undefined;
  16366. try {
  16367. for (var _iterator36 = acceptedFiles[Symbol.iterator](), _step36; !(_iteratorNormalCompletion36 = (_step36 = _iterator36.next()).done); _iteratorNormalCompletion36 = true) {
  16368. var validType = _step36.value;
  16369. validType = validType.trim();
  16370. if (validType.charAt(0) === ".") {
  16371. if (file.name.toLowerCase().indexOf(validType.toLowerCase(), file.name.length - validType.length) !== -1) {
  16372. return true
  16373. }
  16374. } else if (/\/\*$/.test(validType)) {
  16375. if (baseMimeType === validType.replace(/\/.*$/, "")) {
  16376. return true
  16377. }
  16378. } else {
  16379. if (mimeType === validType) {
  16380. return true
  16381. }
  16382. }
  16383. }
  16384. } catch (err) {
  16385. _didIteratorError36 = true;
  16386. _iteratorError36 = err
  16387. } finally {
  16388. try {
  16389. if (!_iteratorNormalCompletion36 && _iterator36["return"] != null) {
  16390. _iterator36["return"]()
  16391. }
  16392. } finally {
  16393. if (_didIteratorError36) {
  16394. throw _iteratorError36
  16395. }
  16396. }
  16397. }
  16398. return false
  16399. };
  16400. if (typeof jQuery !== "undefined" && jQuery !== null) {
  16401. jQuery.fn.dropzone = function (options) {
  16402. return this.each(function () {
  16403. return new Dropzone(this, options)
  16404. })
  16405. }
  16406. }
  16407. if (typeof module !== "undefined" && module !== null) {
  16408. module.exports = Dropzone
  16409. } else {
  16410. window.Dropzone = Dropzone
  16411. }
  16412. Dropzone.ADDED = "added";
  16413. Dropzone.QUEUED = "queued";
  16414. Dropzone.ACCEPTED = Dropzone.QUEUED;
  16415. Dropzone.UPLOADING = "uploading";
  16416. Dropzone.PROCESSING = Dropzone.UPLOADING;
  16417. Dropzone.CANCELED = "canceled";
  16418. Dropzone.ERROR = "error";
  16419. Dropzone.SUCCESS = "success";
  16420. var detectVerticalSquash = function detectVerticalSquash(img) {
  16421. var iw = img.naturalWidth;
  16422. var ih = img.naturalHeight;
  16423. var canvas = document.createElement("canvas");
  16424. canvas.width = 1;
  16425. canvas.height = ih;
  16426. var ctx = canvas.getContext("2d");
  16427. ctx.drawImage(img, 0, 0);
  16428. var _ctx$getImageData = ctx.getImageData(1, 0, 1, ih), data = _ctx$getImageData.data;
  16429. var sy = 0;
  16430. var ey = ih;
  16431. var py = ih;
  16432. while (py > sy) {
  16433. var alpha = data[(py - 1) * 4 + 3];
  16434. if (alpha === 0) {
  16435. ey = py
  16436. } else {
  16437. sy = py
  16438. }
  16439. py = ey + sy >> 1
  16440. }
  16441. var ratio = py / ih;
  16442. if (ratio === 0) {
  16443. return 1
  16444. } else {
  16445. return ratio
  16446. }
  16447. };
  16448. var drawImageIOSFix = function drawImageIOSFix(ctx, img, sx, sy, sw, sh, dx, dy, dw, dh) {
  16449. var vertSquashRatio = detectVerticalSquash(img);
  16450. return ctx.drawImage(img, sx, sy, sw, sh, dx, dy, dw, dh / vertSquashRatio)
  16451. };
  16452. var ExifRestore = function () {
  16453. function ExifRestore() {
  16454. _classCallCheck(this, ExifRestore)
  16455. }
  16456. _createClass(ExifRestore, null, [{
  16457. key: "initClass", value: function initClass() {
  16458. this.KEY_STR = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
  16459. }
  16460. }, {
  16461. key: "encode64", value: function encode64(input) {
  16462. var output = "";
  16463. var chr1 = undefined;
  16464. var chr2 = undefined;
  16465. var chr3 = "";
  16466. var enc1 = undefined;
  16467. var enc2 = undefined;
  16468. var enc3 = undefined;
  16469. var enc4 = "";
  16470. var i = 0;
  16471. while (true) {
  16472. chr1 = input[i++];
  16473. chr2 = input[i++];
  16474. chr3 = input[i++];
  16475. enc1 = chr1 >> 2;
  16476. enc2 = (chr1 & 3) << 4 | chr2 >> 4;
  16477. enc3 = (chr2 & 15) << 2 | chr3 >> 6;
  16478. enc4 = chr3 & 63;
  16479. if (isNaN(chr2)) {
  16480. enc3 = enc4 = 64
  16481. } else if (isNaN(chr3)) {
  16482. enc4 = 64
  16483. }
  16484. output = output + this.KEY_STR.charAt(enc1) + this.KEY_STR.charAt(enc2) + this.KEY_STR.charAt(enc3) + this.KEY_STR.charAt(enc4);
  16485. chr1 = chr2 = chr3 = "";
  16486. enc1 = enc2 = enc3 = enc4 = "";
  16487. if (!(i < input.length)) {
  16488. break
  16489. }
  16490. }
  16491. return output
  16492. }
  16493. }, {
  16494. key: "restore", value: function restore(origFileBase64, resizedFileBase64) {
  16495. if (!origFileBase64.match("data:image/jpeg;base64,")) {
  16496. return resizedFileBase64
  16497. }
  16498. var rawImage = this.decode64(origFileBase64.replace("data:image/jpeg;base64,", ""));
  16499. var segments = this.slice2Segments(rawImage);
  16500. var image = this.exifManipulation(resizedFileBase64, segments);
  16501. return "data:image/jpeg;base64,".concat(this.encode64(image))
  16502. }
  16503. }, {
  16504. key: "exifManipulation", value: function exifManipulation(resizedFileBase64, segments) {
  16505. var exifArray = this.getExifArray(segments);
  16506. var newImageArray = this.insertExif(resizedFileBase64, exifArray);
  16507. var aBuffer = new Uint8Array(newImageArray);
  16508. return aBuffer
  16509. }
  16510. }, {
  16511. key: "getExifArray", value: function getExifArray(segments) {
  16512. var seg = undefined;
  16513. var x = 0;
  16514. while (x < segments.length) {
  16515. seg = segments[x];
  16516. if (seg[0] === 255 & seg[1] === 225) {
  16517. return seg
  16518. }
  16519. x++
  16520. }
  16521. return []
  16522. }
  16523. }, {
  16524. key: "insertExif", value: function insertExif(resizedFileBase64, exifArray) {
  16525. var imageData = resizedFileBase64.replace("data:image/jpeg;base64,", "");
  16526. var buf = this.decode64(imageData);
  16527. var separatePoint = buf.indexOf(255, 3);
  16528. var mae = buf.slice(0, separatePoint);
  16529. var ato = buf.slice(separatePoint);
  16530. var array = mae;
  16531. array = array.concat(exifArray);
  16532. array = array.concat(ato);
  16533. return array
  16534. }
  16535. }, {
  16536. key: "slice2Segments", value: function slice2Segments(rawImageArray) {
  16537. var head = 0;
  16538. var segments = [];
  16539. while (true) {
  16540. var length;
  16541. if (rawImageArray[head] === 255 & rawImageArray[head + 1] === 218) {
  16542. break
  16543. }
  16544. if (rawImageArray[head] === 255 & rawImageArray[head + 1] === 216) {
  16545. head += 2
  16546. } else {
  16547. length = rawImageArray[head + 2] * 256 + rawImageArray[head + 3];
  16548. var endPoint = head + length + 2;
  16549. var seg = rawImageArray.slice(head, endPoint);
  16550. segments.push(seg);
  16551. head = endPoint
  16552. }
  16553. if (head > rawImageArray.length) {
  16554. break
  16555. }
  16556. }
  16557. return segments
  16558. }
  16559. }, {
  16560. key: "decode64", value: function decode64(input) {
  16561. var output = "";
  16562. var chr1 = undefined;
  16563. var chr2 = undefined;
  16564. var chr3 = "";
  16565. var enc1 = undefined;
  16566. var enc2 = undefined;
  16567. var enc3 = undefined;
  16568. var enc4 = "";
  16569. var i = 0;
  16570. var buf = [];
  16571. var base64test = /[^A-Za-z0-9\+\/\=]/g;
  16572. if (base64test.exec(input)) {
  16573. 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.")
  16574. }
  16575. input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
  16576. while (true) {
  16577. enc1 = this.KEY_STR.indexOf(input.charAt(i++));
  16578. enc2 = this.KEY_STR.indexOf(input.charAt(i++));
  16579. enc3 = this.KEY_STR.indexOf(input.charAt(i++));
  16580. enc4 = this.KEY_STR.indexOf(input.charAt(i++));
  16581. chr1 = enc1 << 2 | enc2 >> 4;
  16582. chr2 = (enc2 & 15) << 4 | enc3 >> 2;
  16583. chr3 = (enc3 & 3) << 6 | enc4;
  16584. buf.push(chr1);
  16585. if (enc3 !== 64) {
  16586. buf.push(chr2)
  16587. }
  16588. if (enc4 !== 64) {
  16589. buf.push(chr3)
  16590. }
  16591. chr1 = chr2 = chr3 = "";
  16592. enc1 = enc2 = enc3 = enc4 = "";
  16593. if (!(i < input.length)) {
  16594. break
  16595. }
  16596. }
  16597. return buf
  16598. }
  16599. }]);
  16600. return ExifRestore
  16601. }();
  16602. ExifRestore.initClass();
  16603. var contentLoaded = function contentLoaded(win, fn) {
  16604. var done = false;
  16605. var top = true;
  16606. var doc = win.document;
  16607. var root = doc.documentElement;
  16608. var add = doc.addEventListener ? "addEventListener" : "attachEvent";
  16609. var rem = doc.addEventListener ? "removeEventListener" : "detachEvent";
  16610. var pre = doc.addEventListener ? "" : "on";
  16611. var init = function init(e) {
  16612. if (e.type === "readystatechange" && doc.readyState !== "complete") {
  16613. return
  16614. }
  16615. (e.type === "load" ? win : doc)[rem](pre + e.type, init, false);
  16616. if (!done && (done = true)) {
  16617. return fn.call(win, e.type || e)
  16618. }
  16619. };
  16620. var poll = function poll() {
  16621. try {
  16622. root.doScroll("left")
  16623. } catch (e) {
  16624. setTimeout(poll, 50);
  16625. return
  16626. }
  16627. return init("poll")
  16628. };
  16629. if (doc.readyState !== "complete") {
  16630. if (doc.createEventObject && root.doScroll) {
  16631. try {
  16632. top = !win.frameElement
  16633. } catch (error) {
  16634. }
  16635. if (top) {
  16636. poll()
  16637. }
  16638. }
  16639. doc[add](pre + "DOMContentLoaded", init, false);
  16640. doc[add](pre + "readystatechange", init, false);
  16641. return win[add](pre + "load", init, false)
  16642. }
  16643. };
  16644. Dropzone._autoDiscoverFunction = function () {
  16645. if (Dropzone.autoDiscover) {
  16646. return Dropzone.discover()
  16647. }
  16648. };
  16649. contentLoaded(window, Dropzone._autoDiscoverFunction);
  16650. function __guard__(value, transform) {
  16651. return typeof value !== "undefined" && value !== null ? transform(value) : undefined
  16652. }
  16653. function __guardMethod__(obj, methodName, transform) {
  16654. if (typeof obj !== "undefined" && obj !== null && typeof obj[methodName] === "function") {
  16655. return transform(obj, methodName)
  16656. } else {
  16657. return undefined
  16658. }
  16659. }
  16660. return module.exports
  16661. });
  16662. define('upload', ['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined, Dropzone, Template) {
  16663. var Upload = {
  16664. list: {},
  16665. options: {},
  16666. config: {
  16667. container: document.body,
  16668. classname: '.plupload:not([initialized]),.faupload:not([initialized])',
  16669. 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>',
  16670. },
  16671. events: {
  16672. //初始化
  16673. onInit: function () {
  16674. },
  16675. //上传成功的回调
  16676. onUploadSuccess: function (up, ret, file) {
  16677. var button = up.element;
  16678. var onUploadSuccess = up.options.onUploadSuccess;
  16679. var data = typeof ret.data !== 'undefined' ? ret.data : null;
  16680. //上传成功后回调
  16681. if (button) {
  16682. //如果有文本框则填充
  16683. var input_id = $(button).data("input-id") ? $(button).data("input-id") : "";
  16684. if (input_id) {
  16685. var urlArr = [];
  16686. var inputObj = $("#" + input_id);
  16687. if ($(button).data("multiple") && inputObj.val() !== "") {
  16688. urlArr.push(inputObj.val());
  16689. }
  16690. urlArr.push(data.url);
  16691. inputObj.val(urlArr.join(",")).trigger("change").trigger("validate");
  16692. }
  16693. //如果有回调函数
  16694. var onDomUploadSuccess = $(button).data("upload-success");
  16695. if (onDomUploadSuccess) {
  16696. if (typeof onDomUploadSuccess !== 'function' && typeof Upload.api.custom[onDomUploadSuccess] === 'function') {
  16697. onDomUploadSuccess = Upload.api.custom[onDomUploadSuccess];
  16698. }
  16699. if (typeof onDomUploadSuccess === 'function') {
  16700. var result = onDomUploadSuccess.call(button, data, ret);
  16701. if (result === false)
  16702. return;
  16703. }
  16704. }
  16705. }
  16706. if (typeof onUploadSuccess === 'function') {
  16707. var result = onUploadSuccess.call(button, data, ret);
  16708. if (result === false)
  16709. return;
  16710. }
  16711. },
  16712. //上传错误的回调
  16713. onUploadError: function (up, ret, file) {
  16714. var button = up.element;
  16715. var onUploadError = up.options.onUploadError;
  16716. var data = typeof ret.data !== 'undefined' ? ret.data : null;
  16717. if (button) {
  16718. var onDomUploadError = $(button).data("upload-error");
  16719. if (onDomUploadError) {
  16720. if (typeof onDomUploadError !== 'function' && typeof Upload.api.custom[onDomUploadError] === 'function') {
  16721. onDomUploadError = Upload.api.custom[onDomUploadError];
  16722. }
  16723. if (typeof onDomUploadError === 'function') {
  16724. var result = onDomUploadError.call(button, data, ret);
  16725. if (result === false)
  16726. return;
  16727. }
  16728. }
  16729. }
  16730. if (typeof onUploadError === 'function') {
  16731. var result = onUploadError.call(button, data, ret);
  16732. if (result === false) {
  16733. return;
  16734. }
  16735. }
  16736. Toastr.error(ret.msg.toString().replace(/(<([^>]+)>)/gi, "") + "(code:" + ret.code + ")");
  16737. },
  16738. //服务器响应数据后
  16739. onUploadResponse: function (response, up, file) {
  16740. try {
  16741. var ret = typeof response === 'object' ? response : JSON.parse(response);
  16742. if (!ret.hasOwnProperty('code')) {
  16743. $.extend(ret, {code: -2, msg: response, data: null});
  16744. }
  16745. } catch (e) {
  16746. var ret = {code: -1, msg: e.message, data: null};
  16747. }
  16748. return ret;
  16749. },
  16750. //上传全部结束后
  16751. onUploadComplete: function (up, files) {
  16752. var button = up.element;
  16753. var onUploadComplete = up.options.onUploadComplete;
  16754. if (button) {
  16755. var onDomUploadComplete = $(button).data("upload-complete");
  16756. if (onDomUploadComplete) {
  16757. if (typeof onDomUploadComplete !== 'function' && typeof Upload.api.custom[onDomUploadComplete] === 'function') {
  16758. onDomUploadComplete = Upload.api.custom[onDomUploadComplete];
  16759. }
  16760. if (typeof onDomUploadComplete === 'function') {
  16761. var result = onDomUploadComplete.call(button, files);
  16762. if (result === false)
  16763. return;
  16764. }
  16765. }
  16766. }
  16767. if (typeof onUploadComplete === 'function') {
  16768. var result = onUploadComplete.call(button, files);
  16769. if (result === false) {
  16770. return;
  16771. }
  16772. }
  16773. }
  16774. },
  16775. api: {
  16776. //上传接口
  16777. upload: function (element, onUploadSuccess, onUploadError, onUploadComplete) {
  16778. element = typeof element === 'undefined' ? Upload.config.classname : element;
  16779. $(element, Upload.config.container).each(function () {
  16780. if ($(this).attr("initialized")) {
  16781. return true;
  16782. }
  16783. $(this).attr("initialized", true);
  16784. var that = this;
  16785. var id = $(this).prop("id") || $(this).prop("name") || Dropzone.uuidv4();
  16786. var url = $(this).data("url");
  16787. var maxsize = $(this).data("maxsize");
  16788. var maxcount = $(this).data("maxcount");
  16789. var mimetype = $(this).data("mimetype");
  16790. var multipart = $(this).data("multipart");
  16791. var multiple = $(this).data("multiple");
  16792. //填充ID
  16793. var input_id = $(that).data("input-id") ? $(that).data("input-id") : "";
  16794. //预览ID
  16795. var preview_id = $(that).data("preview-id") ? $(that).data("preview-id") : "";
  16796. //上传URL
  16797. url = url ? url : Config.upload.uploadurl;
  16798. url = Fast.api.fixurl(url);
  16799. var chunking = false, chunkSize = Config.upload.chunksize || 2097152,
  16800. timeout = Config.upload.timeout || 600000;
  16801. //最大可上传文件大小
  16802. maxsize = typeof maxsize !== "undefined" ? maxsize : Config.upload.maxsize;
  16803. //文件类型
  16804. mimetype = typeof mimetype !== "undefined" ? mimetype : Config.upload.mimetype;
  16805. //请求的表单参数
  16806. multipart = typeof multipart !== "undefined" ? multipart : Config.upload.multipart;
  16807. //是否支持批量上传
  16808. multiple = typeof multiple !== "undefined" ? multiple : Config.upload.multiple;
  16809. //后缀特殊处理
  16810. mimetype = mimetype.split(",").map(function (k) {
  16811. return k.indexOf("/") > -1 ? k : (!k || k === "*" || k.charAt(0) === "." ? k : "." + k);
  16812. }).join(",");
  16813. mimetype = mimetype === '*' ? null : mimetype;
  16814. //最大文件限制转换成mb
  16815. var maxFilesize = (function (maxsize) {
  16816. var matches = maxsize.toString().match(/^([0-9\.]+)(\w+)$/);
  16817. var size = matches ? parseFloat(matches[1]) : parseFloat(maxsize),
  16818. unit = matches ? matches[2].toLowerCase() : 'b';
  16819. var unitDict = {'b': 0, 'k': 1, 'kb': 1, 'm': 2, 'mb': 2, 'gb': 3, 'g': 3, 'tb': 4, 't': 4};
  16820. var y = typeof unitDict[unit] !== 'undefined' ? unitDict[unit] : 0;
  16821. var bytes = size * Math.pow(1024, y);
  16822. return bytes / Math.pow(1024, 2);
  16823. }(maxsize));
  16824. var options = $(this).data() || {};
  16825. delete options.success;
  16826. delete options.url;
  16827. multipart = $.isArray(multipart) ? {} : multipart;
  16828. Upload.list[id] = new Dropzone(this, $.extend({
  16829. url: url,
  16830. params: function (files, xhr, chunk) {
  16831. var params = multipart;
  16832. if (chunk) {
  16833. return $.extend({}, params, {
  16834. filesize: chunk.file.size,
  16835. filename: chunk.file.name,
  16836. chunkid: chunk.file.upload.uuid,
  16837. chunkindex: chunk.index,
  16838. chunkcount: chunk.file.upload.totalChunkCount,
  16839. chunksize: this.options.chunkSize,
  16840. chunkfilesize: chunk.dataBlock.data.size,
  16841. width: chunk.file.width || 0,
  16842. height: chunk.file.height || 0,
  16843. type: chunk.file.type,
  16844. });
  16845. }
  16846. return params;
  16847. },
  16848. chunking: chunking,
  16849. chunkSize: chunkSize,
  16850. maxFilesize: maxFilesize,
  16851. acceptedFiles: mimetype,
  16852. maxFiles: (maxcount && parseInt(maxcount) > 1 ? maxcount : (multiple ? null : 1)),
  16853. timeout: timeout,
  16854. parallelUploads: 1,
  16855. previewsContainer: false,
  16856. dictDefaultMessage: __("Drop files here to upload"),
  16857. dictFallbackMessage: __("Your browser does not support drag'n'drop file uploads"),
  16858. dictFallbackText: __("Please use the fallback form below to upload your files like in the olden days"),
  16859. dictFileTooBig: __("File is too big (%sMiB), Max filesize: %sMiB", "{{filesize}}", "{{maxFilesize}}"),
  16860. dictInvalidFileType: __("You can't upload files of this type"),
  16861. dictResponseError: __("Server responded with %s code.", "{{statusCode}}"),
  16862. dictCancelUpload: __("Cancel upload"),
  16863. dictUploadCanceled: __("Upload canceled"),
  16864. dictCancelUploadConfirmation: __("Are you sure you want to cancel this upload?"),
  16865. dictRemoveFile: __("Remove file"),
  16866. dictMaxFilesExceeded: __("You can only upload a maximum of %s files", "{{maxFiles}}"),
  16867. init: function () {
  16868. Upload.events.onInit.call(this);
  16869. //必须添加dz-message,否则点击icon无法唤起上传窗口
  16870. $(">i", this.element).addClass("dz-message");
  16871. this.options.elementHtml = $(this.element).html();
  16872. },
  16873. addedfiles: function (files) {
  16874. if (this.options.maxFiles && (!this.options.maxFiles || this.options.maxFiles > 1) && this.options.inputId) {
  16875. var inputObj = $("#" + this.options.inputId);
  16876. if (inputObj.size() > 0) {
  16877. var value = $.trim(inputObj.val());
  16878. var nums = value === '' ? 0 : value.split(/\,/).length;
  16879. var remain = this.options.maxFiles - nums;
  16880. if (remain === 0 || files.length > remain) {
  16881. files = Array.prototype.slice.call(files, remain);
  16882. for (var i = 0; i < files.length; i++) {
  16883. this.removeFile(files[i]);
  16884. }
  16885. Toastr.error(__("You can only upload a maximum of %s files", this.options.maxFiles));
  16886. }
  16887. }
  16888. }
  16889. },
  16890. success: function (file, response) {
  16891. var ret = Upload.events.onUploadResponse(response, this, file);
  16892. file.ret = ret;
  16893. if (ret.code === 1) {
  16894. Upload.events.onUploadSuccess(this, ret, file);
  16895. } else {
  16896. Upload.events.onUploadError(this, ret, file);
  16897. }
  16898. },
  16899. error: function (file, response, xhr) {
  16900. var responseObj = $("<div>" + (xhr && typeof xhr.responseText !== 'undefined' ? xhr.responseText : response) + "</div>");
  16901. responseObj.find("style, title, script").remove();
  16902. var ret = {code: 0, data: null, msg: responseObj.text()};
  16903. Upload.events.onUploadError(this, ret, file);
  16904. },
  16905. uploadprogress: function (file, progress, bytesSent) {
  16906. if (file.upload.chunked) {
  16907. $(this.element).prop("disabled", true).html("<i class='fa fa-upload'></i> " + __('Upload') + Math.floor((file.upload.bytesSent / file.size) * 100) + "%");
  16908. }
  16909. },
  16910. totaluploadprogress: function (progress, bytesSent) {
  16911. if (this.getActiveFiles().length > 0 && !this.options.chunking) {
  16912. $(this.element).prop("disabled", true).html("<i class='fa fa-upload'></i> " + __('Upload') + Math.floor(progress) + "%");
  16913. }
  16914. },
  16915. queuecomplete: function () {
  16916. Upload.events.onUploadComplete(this, this.files);
  16917. this.removeAllFiles(true);
  16918. $(this.element).prop("disabled", false).html(this.options.elementHtml);
  16919. },
  16920. chunkSuccess: function (chunk, file, response) {
  16921. },
  16922. chunksUploaded: function (file, done) {
  16923. var that = this;
  16924. Fast.api.ajax({
  16925. url: this.options.url,
  16926. data: $.extend({}, multipart, {
  16927. action: 'merge',
  16928. filesize: file.size,
  16929. filename: file.name,
  16930. chunkid: file.upload.uuid,
  16931. chunkcount: file.upload.totalChunkCount,
  16932. })
  16933. }, function (data, ret) {
  16934. done(JSON.stringify(ret));
  16935. return false;
  16936. }, function (data, ret) {
  16937. file.accepted = false;
  16938. that._errorProcessing([file], ret.msg);
  16939. });
  16940. },
  16941. onUploadSuccess: onUploadSuccess,
  16942. onUploadError: onUploadError,
  16943. onUploadComplete: onUploadComplete,
  16944. }, Upload.options, options));
  16945. //拖动排序
  16946. if (preview_id && multiple) {
  16947. require(['dragsort'], function () {
  16948. $("#" + preview_id).dragsort({
  16949. dragSelector: "li a:not(.btn-trash)",
  16950. dragEnd: function () {
  16951. $("#" + preview_id).trigger("fa.preview.change");
  16952. },
  16953. placeHolderTemplate: '<li class="col-xs-3"></li>'
  16954. });
  16955. });
  16956. }
  16957. //刷新隐藏textarea的值
  16958. var refresh = function (name) {
  16959. var data = {};
  16960. var textarea = $("textarea[name='" + name + "']");
  16961. var container = textarea.prev("ul");
  16962. $.each($("input,select,textarea", container).serializeArray(), function (i, j) {
  16963. var reg = /\[?(\w+)\]?\[(\w+)\]$/g;
  16964. var match = reg.exec(j.name);
  16965. if (!match)
  16966. return true;
  16967. if (!isNaN(match[2])) {
  16968. data[i] = j.value;
  16969. } else {
  16970. match[1] = "x" + parseInt(match[1]);
  16971. if (typeof data[match[1]] === 'undefined') {
  16972. data[match[1]] = {};
  16973. }
  16974. data[match[1]][match[2]] = j.value;
  16975. }
  16976. });
  16977. var result = [];
  16978. $.each(data, function (i, j) {
  16979. result.push(j);
  16980. });
  16981. textarea.val(JSON.stringify(result));
  16982. };
  16983. if (preview_id && input_id) {
  16984. $(document.body).on("keyup change", "#" + input_id, function (e) {
  16985. var inputStr = $("#" + input_id).val();
  16986. var inputArr = inputStr.split(/\,/);
  16987. $("#" + preview_id).empty();
  16988. var tpl = $("#" + preview_id).data("template") ? $("#" + preview_id).data("template") : "";
  16989. var extend = $("#" + preview_id).next().is("textarea") ? $("#" + preview_id).next("textarea").val() : "{}";
  16990. var json = {};
  16991. try {
  16992. json = JSON.parse(extend);
  16993. } catch (e) {
  16994. }
  16995. $.each(inputArr, function (i, j) {
  16996. if (!j) {
  16997. return true;
  16998. }
  16999. var suffix = /[\.]?([a-zA-Z0-9]+)$/.exec(j);
  17000. suffix = suffix ? suffix[1] : 'file';
  17001. var value = (json && typeof json[i] !== 'undefined' ? json[i] : null);
  17002. var data = {
  17003. url: j,
  17004. fullurl: Fast.api.cdnurl(j),
  17005. data: $(that).data(),
  17006. key: i,
  17007. index: i,
  17008. value: value,
  17009. row: value,
  17010. suffix: suffix
  17011. };
  17012. var html = tpl ? Template(tpl, data) : Template.render(Upload.config.previewtpl, data);
  17013. $("#" + preview_id).append(html);
  17014. });
  17015. refresh($("#" + preview_id).data("name"));
  17016. });
  17017. $("#" + input_id).trigger("change");
  17018. }
  17019. if (preview_id) {
  17020. //监听文本框改变事件
  17021. $("#" + preview_id).on('change keyup', "input,textarea,select", function () {
  17022. refresh($(this).closest("ul").data("name"));
  17023. });
  17024. // 监听事件
  17025. $(document.body).on("fa.preview.change", "#" + preview_id, function () {
  17026. var urlArr = [];
  17027. $("#" + preview_id + " [data-url]").each(function (i, j) {
  17028. urlArr.push($(this).data("url"));
  17029. });
  17030. if (input_id) {
  17031. $("#" + input_id).val(urlArr.join(","));
  17032. }
  17033. refresh($("#" + preview_id).data("name"));
  17034. });
  17035. // 移除按钮事件
  17036. $(document.body).on("click", "#" + preview_id + " .btn-trash", function () {
  17037. $(this).closest("li").remove();
  17038. $("#" + preview_id).trigger("fa.preview.change");
  17039. });
  17040. }
  17041. if (input_id) {
  17042. //粘贴上传、拖拽上传
  17043. $("body").on('paste drop', "#" + input_id, function (event) {
  17044. var originEvent = event.originalEvent;
  17045. var button = $(".plupload[data-input-id='" + $(this).attr("id") + "'],.faupload[data-input-id='" + $(this).attr("id") + "']");
  17046. if (event.type === 'paste' && originEvent.clipboardData && originEvent.clipboardData.items) {
  17047. var items = originEvent.clipboardData.items;
  17048. if ((items.length === 1 && items[0].type.indexOf("text") > -1) || (items.length === 2 && items[1].type.indexOf("text") > -1)) {
  17049. } else {
  17050. Upload.list[button.attr("id")].paste(originEvent);
  17051. return false;
  17052. }
  17053. }
  17054. if (event.type === 'drop' && originEvent.dataTransfer && originEvent.dataTransfer.files) {
  17055. Upload.list[button.attr("id")].drop(originEvent);
  17056. return false;
  17057. }
  17058. });
  17059. }
  17060. });
  17061. },
  17062. /**
  17063. * @deprecated Use upload instead.
  17064. */
  17065. plupload: function (element, onUploadSuccess, onUploadError, onUploadComplete) {
  17066. return Upload.api.upload(element, onUploadSuccess, onUploadError, onUploadComplete);
  17067. },
  17068. /**
  17069. * @deprecated Use upload instead.
  17070. */
  17071. faupload: function (element, onUploadSuccess, onUploadError, onUploadComplete) {
  17072. return Upload.api.upload(element, onUploadSuccess, onUploadError, onUploadComplete);
  17073. },
  17074. // AJAX异步上传
  17075. send: function (file, onUploadSuccess, onUploadError, onUploadComplete) {
  17076. var index = Layer.msg(__('Uploading'), {offset: 't', time: 0});
  17077. var id = "dropzone-" + Dropzone.uuidv4();
  17078. $('<button type="button" id="' + id + '" class="btn btn-danger hidden faupload" />').appendTo("body");
  17079. $("#" + id).data("upload-complete", function (files) {
  17080. Layer.close(index);
  17081. Upload.list[id].removeAllFiles(true);
  17082. });
  17083. Upload.api.upload("#" + id, onUploadSuccess, onUploadError, onUploadComplete);
  17084. setTimeout(function () {
  17085. Upload.list[id].addFile(file);
  17086. }, 1);
  17087. },
  17088. custom: {
  17089. //自定义上传完成回调
  17090. afteruploadcallback: function (response) {
  17091. console.log(this, response);
  17092. alert("Custom Callback,Response URL:" + response.url);
  17093. },
  17094. }
  17095. }
  17096. }
  17097. ;
  17098. return Upload;
  17099. });
  17100. /*! nice-validator 1.1.5
  17101. * (c) 2012-2020 Jony Zhang <niceue@live.com>, MIT Licensed
  17102. * https://github.com/niceue/nice-validator
  17103. */
  17104. ;(function (factory) {
  17105. typeof module === 'object' && module.exports ? module.exports = factory(require('jquery')) :
  17106. typeof define === 'function' && define.amd ? define('validator', ['jquery'], factory) :
  17107. factory(jQuery);
  17108. }(function ($, undefined) {
  17109. 'use strict';
  17110. var NS = 'validator',
  17111. CLS_NS = '.' + NS,
  17112. CLS_NS_RULE = '.rule',
  17113. CLS_NS_FIELD = '.field',
  17114. CLS_NS_FORM = '.form',
  17115. CLS_WRAPPER = 'nice-' + NS,
  17116. CLS_MSG_BOX = 'msg-box',
  17117. ARIA_INVALID = 'aria-invalid',
  17118. DATA_RULE = 'data-rule',
  17119. DATA_MSG = 'data-msg',
  17120. DATA_TIP = 'data-tip',
  17121. DATA_OK = 'data-ok',
  17122. DATA_TIMELY = 'data-timely',
  17123. DATA_TARGET = 'data-target',
  17124. DATA_DISPLAY = 'data-display',
  17125. DATA_MUST = 'data-must',
  17126. NOVALIDATE = 'novalidate',
  17127. INPUT_SELECTOR = ':verifiable',
  17128. rRules = /(&)?(!)?\b(\w+)(?:\[\s*(.*?\]?)\s*\]|\(\s*(.*?\)?)\s*\))?\s*(;|\|)?/g,
  17129. rRule = /(\w+)(?:\[\s*(.*?\]?)\s*\]|\(\s*(.*?\)?)\s*\))?/,
  17130. rDisplay = /(?:([^:;\(\[]*):)?(.*)/,
  17131. rDoubleBytes = /[^\x00-\xff]/g,
  17132. rPos = /top|right|bottom|left/,
  17133. rAjaxType = /(?:(cors|jsonp):)?(?:(post|get):)?(.+)/i,
  17134. rUnsafe = /[<>'"`\\]|&#x?\d+[A-F]?;?|%3[A-F]/gmi,
  17135. noop = $.noop,
  17136. proxy = $.proxy,
  17137. trim = $.trim,
  17138. isFunction = $.isFunction,
  17139. isString = function (s) {
  17140. return typeof s === 'string';
  17141. },
  17142. isObject = function (o) {
  17143. return o && Object.prototype.toString.call(o) === '[object Object]';
  17144. },
  17145. isIE = document.documentMode || +(navigator.userAgent.match(/MSIE (\d+)/) && RegExp.$1),
  17146. attr = function (el, key, value) {
  17147. if (!el || !el.tagName) return null;
  17148. if (value !== undefined) {
  17149. if (value === null) el.removeAttribute(key);
  17150. else el.setAttribute(key, '' + value);
  17151. } else {
  17152. return el.getAttribute(key);
  17153. }
  17154. },
  17155. novalidateonce,
  17156. preinitialized = {},
  17157. defaults = {
  17158. debug: 0,
  17159. theme: 'default',
  17160. ignore: '',
  17161. focusInvalid: true,
  17162. focusCleanup: false,
  17163. stopOnError: false,
  17164. beforeSubmit: null,
  17165. valid: null,
  17166. invalid: null,
  17167. validation: null,
  17168. formClass: 'n-default',
  17169. validClass: 'n-valid',
  17170. invalidClass: 'n-invalid',
  17171. bindClassTo: null
  17172. },
  17173. fieldDefaults = {
  17174. timely: 1,
  17175. display: null,
  17176. target: null,
  17177. ignoreBlank: false,
  17178. showOk: true,
  17179. // Translate ajax response to validation result
  17180. dataFilter: function (data) {
  17181. if (isString(data) || (isObject(data) && ('error' in data || 'ok' in data))) {
  17182. return data;
  17183. }
  17184. },
  17185. msgMaker: function (opt) {
  17186. var html;
  17187. html = '<span role="alert" class="msg-wrap n-' + opt.type + '">' + opt.arrow;
  17188. if (opt.result) {
  17189. $.each(opt.result, function (i, obj) {
  17190. html += '<span class="n-' + obj.type + '">' + opt.icon + '<span class="n-msg">' + obj.msg + '</span></span>';
  17191. });
  17192. } else {
  17193. html += opt.icon + '<span class="n-msg">' + opt.msg + '</span>';
  17194. }
  17195. html += '</span>';
  17196. return html;
  17197. },
  17198. msgWrapper: 'span',
  17199. msgArrow: '',
  17200. msgIcon: '<span class="n-icon"></span>',
  17201. msgClass: 'n-right',
  17202. msgStyle: '',
  17203. msgShow: null,
  17204. msgHide: null
  17205. },
  17206. themes = {};
  17207. /** jQuery Plugin
  17208. * @param {Object} options
  17209. debug {Boolean} 0 Whether to enable debug mode
  17210. timely {Number} 1 Whether to enable timely validation
  17211. theme {String} 'default' Theme name
  17212. stopOnError {Boolean} false Whether to stop validate when found an error input
  17213. focusCleanup {Boolean} false Whether to clean up the field message when focus the field
  17214. focusInvalid {Boolean} true Whether to focus the field that is invalid
  17215. ignoreBlank {Boolean} false When the field has no value, whether to ignore validation
  17216. ignore {jqSelector} '' Ignored fields (Using jQuery selector)
  17217. beforeSubmit {Function} Do something before submit form
  17218. dataFilter {Function} Convert ajax results
  17219. valid {Function} Triggered when the form is valid
  17220. invalid {Function} Triggered when the form is invalid
  17221. validClass {String} 'n-valid' Add this class name to a valid field
  17222. invalidClass {String} 'n-invalid' Add this class name to a invalid field
  17223. bindClassTo {jqSelector} ':verifiable' Which element should the className binding to
  17224. display {Function} Callback function to get dynamic display
  17225. target {Function} Callback function to get dynamic target
  17226. msgShow {Function} Trigger this callback when show message
  17227. msgHide {Function} Trigger this callback when hide message
  17228. msgWrapper {String} 'span' Message wrapper tag name
  17229. msgMaker {Function} Callback function to make message HTML
  17230. msgArrow {String} Message arrow template
  17231. msgIcon {String} Message icon template
  17232. msgStyle {String} Custom message css style
  17233. msgClass {String} Additional added to the message class names
  17234. formClass {String} Additional added to the form class names
  17235. messages {Object} Custom messages for the current instance
  17236. rules {Object} Custom rules for the current instance
  17237. fields {Object} Field validation configuration
  17238. {String} key name|#id
  17239. {String|Object} value Rule string or an object which can pass more arguments
  17240. fields[key][rule] {String} Rule string
  17241. fields[key][display] {String|Function}
  17242. fields[key][tip] {String} Custom tip message
  17243. fields[key][ok] {String} Custom success message
  17244. fields[key][msg] {Object} Custom error message
  17245. fields[key][msgStyle] {String} Custom message style
  17246. fields[key][msgClass] {String} A className which added to message placeholder element
  17247. fields[key][msgWrapper] {String} Tag name of the message placeholder element
  17248. fields[key][msgMaker] {Function} A function to custom message HTML
  17249. fields[key][dataFilter] {Function} A function to convert ajax results
  17250. fields[key][valid] {Function} A function triggered when field is valid
  17251. fields[key][invalid] {Function} A function triggered when field is invalid
  17252. fields[key][must] {Boolean} If set true, we always check the field even has remote checking
  17253. fields[key][timely] {Boolean} Whether to enable timely validation
  17254. fields[key][target] {jqSelector} Define placement of a message
  17255. */
  17256. $.fn.validator = function (options) {
  17257. var that = this,
  17258. args = arguments;
  17259. if (that.is(INPUT_SELECTOR)) return that;
  17260. if (!that.is('form')) that = this.find('form');
  17261. if (!that.length) that = this;
  17262. that.each(function () {
  17263. var instance = $(this).data(NS);
  17264. if (instance) {
  17265. if (isString(options)) {
  17266. if (options.charAt(0) === '_') return;
  17267. instance[options].apply(instance, [].slice.call(args, 1));
  17268. } else if (options) {
  17269. instance._reset(true);
  17270. instance._init(this, options);
  17271. }
  17272. } else {
  17273. new Validator(this, options);
  17274. }
  17275. });
  17276. return this;
  17277. };
  17278. // Validate a field, or an area
  17279. $.fn.isValid = function (callback, hideMsg) {
  17280. var me = _getInstance(this[0]),
  17281. hasCallback = isFunction(callback),
  17282. ret, opt;
  17283. if (!me) return true;
  17284. if (!hasCallback && hideMsg === undefined) hideMsg = callback;
  17285. me.checkOnly = !!hideMsg;
  17286. opt = me.options;
  17287. ret = me._multiValidate(
  17288. this.is(INPUT_SELECTOR) ? this : this.find(INPUT_SELECTOR),
  17289. function (isValid) {
  17290. if (!isValid && opt.focusInvalid && !me.checkOnly) {
  17291. // navigate to the error element
  17292. me.$el.find('[' + ARIA_INVALID + ']:first').focus();
  17293. }
  17294. if (hasCallback) {
  17295. if (callback.length) {
  17296. callback(isValid);
  17297. } else if (isValid) {
  17298. callback();
  17299. }
  17300. }
  17301. me.checkOnly = false;
  17302. }
  17303. );
  17304. // If you pass a callback, we maintain the jQuery object chain
  17305. return hasCallback ? this : ret;
  17306. };
  17307. $.extend($.expr.pseudos || $.expr[':'], {
  17308. // A faster selector than ":input:not(:submit,:button,:reset,:image,:disabled,[contenteditable])"
  17309. verifiable: function (elem) {
  17310. var name = elem.nodeName.toLowerCase();
  17311. return (name === 'input' && !({submit: 1, button: 1, reset: 1, image: 1})[elem.type] ||
  17312. name === 'select' ||
  17313. name === 'textarea' ||
  17314. elem.contentEditable === 'true'
  17315. ) && !elem.disabled;
  17316. },
  17317. // any value, but not only whitespace
  17318. filled: function (elem) {
  17319. return !!trim($(elem).val());
  17320. }
  17321. });
  17322. /**
  17323. * Creates a new Validator
  17324. *
  17325. * @class
  17326. * @param {Element} element - form element
  17327. * @param {Object} options - options for validator
  17328. */
  17329. function Validator(element, options) {
  17330. var me = this;
  17331. if (!(me instanceof Validator)) {
  17332. return new Validator(element, options);
  17333. }
  17334. if (Validator.pending) {
  17335. $(window).on('validatorready', init);
  17336. } else {
  17337. init();
  17338. }
  17339. function init() {
  17340. me.$el = $(element);
  17341. if (me.$el.length) {
  17342. me._init(me.$el[0], options);
  17343. } else if (isString(element)) {
  17344. preinitialized[element] = options;
  17345. }
  17346. }
  17347. }
  17348. Validator.prototype = {
  17349. _init: function (element, options) {
  17350. var me = this,
  17351. opt, themeOpt, dataOpt;
  17352. // Initialization options
  17353. if (isFunction(options)) {
  17354. options = {
  17355. valid: options
  17356. };
  17357. }
  17358. options = me._opt = options || {};
  17359. dataOpt = attr(element, 'data-' + NS + '-option');
  17360. dataOpt = me._dataOpt = dataOpt && dataOpt.charAt(0) === '{' ? (new Function('return ' + dataOpt))() : {};
  17361. themeOpt = me._themeOpt = themes[options.theme || dataOpt.theme || defaults.theme];
  17362. opt = me.options = $.extend({}, defaults, fieldDefaults, themeOpt, me.options, options, dataOpt);
  17363. me.rules = new Rules(opt.rules, true);
  17364. me.messages = new Messages(opt.messages, true);
  17365. me.Field = _createFieldFactory(me);
  17366. me.elements = me.elements || {};
  17367. me.deferred = {};
  17368. me.errors = {};
  17369. me.fields = {};
  17370. // Initialization fields
  17371. me._initFields(opt.fields);
  17372. // Initialization events and make a cache
  17373. if (!me.$el.data(NS)) {
  17374. me.$el.data(NS, me).addClass(CLS_WRAPPER + ' ' + opt.formClass)
  17375. .on('form-submit-validate', function (e, a, $form, opts, veto) {
  17376. me.vetoed = veto.veto = !me.isValid;
  17377. me.ajaxFormOptions = opts;
  17378. })
  17379. .on('submit' + CLS_NS + ' validate' + CLS_NS, proxy(me, '_submit'))
  17380. .on('reset' + CLS_NS, proxy(me, '_reset'))
  17381. .on('showmsg' + CLS_NS, proxy(me, '_showmsg'))
  17382. .on('hidemsg' + CLS_NS, proxy(me, '_hidemsg'))
  17383. .on('focusin' + CLS_NS + ' click' + CLS_NS, INPUT_SELECTOR, proxy(me, '_focusin'))
  17384. .on('focusout' + CLS_NS + ' validate' + CLS_NS, INPUT_SELECTOR, proxy(me, '_focusout'))
  17385. .on('keyup' + CLS_NS + ' input' + CLS_NS + ' compositionstart compositionend', INPUT_SELECTOR, proxy(me, '_focusout'))
  17386. .on('click' + CLS_NS, ':radio,:checkbox', 'click', proxy(me, '_focusout'))
  17387. .on('change' + CLS_NS, 'select,input[type="file"]', 'change', proxy(me, '_focusout'));
  17388. // cache the novalidate attribute value
  17389. me._NOVALIDATE = attr(element, NOVALIDATE);
  17390. // Initialization is complete, stop off default HTML5 form validation
  17391. // If use "jQuery.attr('novalidate')" in IE7 will complain: "SCRIPT3: Member not found."
  17392. attr(element, NOVALIDATE, NOVALIDATE);
  17393. }
  17394. // Display all messages in target container
  17395. if (isString(opt.target)) {
  17396. me.$el.find(opt.target).addClass('msg-container');
  17397. }
  17398. },
  17399. // Guess whether the form use ajax submit
  17400. _guessAjax: function (form) {
  17401. var me = this;
  17402. if (!(me.isAjaxSubmit = !!me.options.valid)) {
  17403. // if there is a "valid.form" event
  17404. var events = ($._data || $.data)(form, 'events');
  17405. me.isAjaxSubmit = issetEvent(events, 'valid', 'form') || issetEvent(events, 'submit', 'form-plugin');
  17406. }
  17407. function issetEvent(events, name, namespace) {
  17408. return !!(
  17409. events && events[name]
  17410. && $.map(events[name], function (e) {
  17411. return ~e.namespace.indexOf(namespace) ? 1 : null;
  17412. }).length)
  17413. }
  17414. },
  17415. _initFields: function (fields) {
  17416. var me = this, k, arr, i,
  17417. clear = fields === null;
  17418. // Processing field information
  17419. if (clear) fields = me.fields;
  17420. if (isObject(fields)) {
  17421. for (k in fields) {
  17422. if (~k.indexOf(',')) {
  17423. arr = k.split(',');
  17424. i = arr.length;
  17425. while (i--) {
  17426. initField(trim(arr[i]), fields[k]);
  17427. }
  17428. } else {
  17429. initField(k, fields[k]);
  17430. }
  17431. }
  17432. }
  17433. // Parsing DOM rules
  17434. me.$el.find(INPUT_SELECTOR).each(function () {
  17435. me._parse(this);
  17436. });
  17437. function initField(k, v) {
  17438. // delete a field from settings
  17439. if (v === null || clear) {
  17440. var el = me.elements[k];
  17441. if (el) me._resetElement(el, true);
  17442. delete me.fields[k];
  17443. } else {
  17444. me.fields[k] = new me.Field(k, isString(v) ? {rule: v} : v, me.fields[k]);
  17445. }
  17446. }
  17447. },
  17448. // Parsing a field
  17449. _parse: function (el) {
  17450. var me = this,
  17451. field,
  17452. key = el.name,
  17453. display,
  17454. timely,
  17455. dataRule = attr(el, DATA_RULE);
  17456. dataRule && attr(el, DATA_RULE, null);
  17457. // If the field has passed the key as id mode, or it doesn't has a name
  17458. if (el.id && (
  17459. ('#' + el.id in me.fields) ||
  17460. !key ||
  17461. // If dataRule and element are diffrent from old's, we use ID mode.
  17462. (dataRule !== null && (field = me.fields[key]) && dataRule !== field.rule && el.id !== field.key)
  17463. )
  17464. ) {
  17465. key = '#' + el.id;
  17466. }
  17467. // Generate id
  17468. if (!key) {
  17469. key = '#' + (el.id = 'N' + String(Math.random()).slice(-12));
  17470. }
  17471. field = me.getField(key, true);
  17472. // The priority of passing parameter by DOM is higher than by JS.
  17473. field.rule = dataRule || field.rule;
  17474. if (display = attr(el, DATA_DISPLAY)) {
  17475. field.display = display;
  17476. }
  17477. if (field.rule) {
  17478. if (attr(el, DATA_MUST) !== null || /\b(?:match|checked)\b/.test(field.rule)) {
  17479. field.must = true;
  17480. }
  17481. if (/\brequired\b/.test(field.rule)) {
  17482. field.required = true;
  17483. }
  17484. if (timely = attr(el, DATA_TIMELY)) {
  17485. field.timely = +timely;
  17486. } else if (field.timely > 3) {
  17487. attr(el, DATA_TIMELY, field.timely);
  17488. }
  17489. me._parseRule(field);
  17490. field.old = {};
  17491. }
  17492. if (isString(field.target)) {
  17493. attr(el, DATA_TARGET, field.target);
  17494. }
  17495. if (isString(field.tip)) {
  17496. attr(el, DATA_TIP, field.tip);
  17497. }
  17498. return me.fields[key] = field;
  17499. },
  17500. // Parsing field rules
  17501. _parseRule: function (field) {
  17502. var arr = rDisplay.exec(field.rule);
  17503. if (!arr) return;
  17504. // current rule index
  17505. field._i = 0;
  17506. if (arr[1]) {
  17507. field.display = arr[1];
  17508. }
  17509. if (arr[2]) {
  17510. field._rules = [];
  17511. arr[2].replace(rRules, function () {
  17512. var args = arguments;
  17513. args[4] = args[4] || args[5];
  17514. field._rules.push({
  17515. and: args[1] === '&',
  17516. not: args[2] === '!',
  17517. or: args[6] === '|',
  17518. method: args[3],
  17519. params: args[4] ? $.map(args[4].split(', '), trim) : undefined
  17520. });
  17521. });
  17522. }
  17523. },
  17524. // Verify a zone
  17525. _multiValidate: function ($inputs, doneCallback) {
  17526. var me = this,
  17527. opt = me.options;
  17528. me.hasError = false;
  17529. if (opt.ignore) {
  17530. $inputs = $inputs.not(opt.ignore);
  17531. }
  17532. $inputs.each(function () {
  17533. me._validate(this);
  17534. if (me.hasError && opt.stopOnError) {
  17535. // stop the validation
  17536. return false;
  17537. }
  17538. });
  17539. // Need to wait for all fields validation complete, especially asynchronous validation
  17540. if (doneCallback) {
  17541. me.validating = true;
  17542. $.when.apply(
  17543. null,
  17544. $.map(me.deferred, function (v) {
  17545. return v;
  17546. })
  17547. ).done(function () {
  17548. doneCallback.call(me, !me.hasError);
  17549. me.validating = false;
  17550. });
  17551. }
  17552. // If the form does not contain asynchronous validation, the return value is correct.
  17553. // Otherwise, you should detect form validation result through "doneCallback".
  17554. return !$.isEmptyObject(me.deferred) ? undefined : !me.hasError;
  17555. },
  17556. // Validate the whole form
  17557. _submit: function (e) {
  17558. var me = this,
  17559. opt = me.options,
  17560. form = e.target,
  17561. canSubmit = e.type === 'submit' && form.tagName === 'FORM' && !e.isDefaultPrevented();
  17562. e.preventDefault();
  17563. if (
  17564. novalidateonce && ~(novalidateonce = false) ||
  17565. // Prevent duplicate submission
  17566. me.submiting ||
  17567. // Receive the "validate" event only from the form.
  17568. e.type === 'validate' && me.$el[0] !== form ||
  17569. // trigger the beforeSubmit callback.
  17570. isFunction(opt.beforeSubmit) && opt.beforeSubmit.call(me, form) === false
  17571. ) {
  17572. return;
  17573. }
  17574. if (me.isAjaxSubmit === undefined) {
  17575. me._guessAjax(form);
  17576. }
  17577. me._debug('log', '\n<<< event: ' + e.type);
  17578. me._reset();
  17579. me.submiting = true;
  17580. me._multiValidate(
  17581. me.$el.find(INPUT_SELECTOR),
  17582. function (isValid) {
  17583. var ret = (isValid || opt.debug === 2) ? 'valid' : 'invalid',
  17584. errors;
  17585. if (!isValid) {
  17586. if (opt.focusInvalid) {
  17587. // navigate to the error element
  17588. me.$el.find('[' + ARIA_INVALID + ']:first').focus();
  17589. }
  17590. errors = $.map(me.errors, function (err) {
  17591. return err;
  17592. });
  17593. }
  17594. // releasing submit
  17595. me.submiting = false;
  17596. me.isValid = isValid;
  17597. // trigger callback and event
  17598. isFunction(opt[ret]) && opt[ret].call(me, form, errors);
  17599. me.$el.trigger(ret + CLS_NS_FORM, [form, errors]);
  17600. me._debug('log', '>>> ' + ret);
  17601. if (!isValid) return;
  17602. // For jquery.form plugin
  17603. if (me.vetoed) {
  17604. $(form).ajaxSubmit(me.ajaxFormOptions);
  17605. } else if (canSubmit && !me.isAjaxSubmit) {
  17606. document.createElement('form').submit.call(form);
  17607. }
  17608. }
  17609. );
  17610. },
  17611. _reset: function (e) {
  17612. var me = this;
  17613. me.errors = {};
  17614. if (e) {
  17615. me.reseting = true;
  17616. me.$el.find(INPUT_SELECTOR).each(function () {
  17617. me._resetElement(this);
  17618. });
  17619. delete me.reseting;
  17620. }
  17621. },
  17622. _resetElement: function (el, all) {
  17623. this._setClass(el, null);
  17624. this.hideMsg(el);
  17625. },
  17626. // Handle events: "focusin/click"
  17627. _focusin: function (e) {
  17628. var me = this,
  17629. opt = me.options,
  17630. el = e.target,
  17631. timely,
  17632. msg;
  17633. if (me.validating || (e.type === 'click' && document.activeElement === el)) {
  17634. return;
  17635. }
  17636. if (opt.focusCleanup) {
  17637. if (attr(el, ARIA_INVALID) === 'true') {
  17638. me._setClass(el, null);
  17639. me.hideMsg(el);
  17640. }
  17641. }
  17642. msg = attr(el, DATA_TIP);
  17643. if (msg) {
  17644. me.showMsg(el, {
  17645. type: 'tip',
  17646. msg: msg
  17647. });
  17648. } else {
  17649. if (attr(el, DATA_RULE)) {
  17650. me._parse(el);
  17651. }
  17652. if (timely = attr(el, DATA_TIMELY)) {
  17653. if (timely === 8 || timely === 9) {
  17654. me._focusout(e);
  17655. }
  17656. }
  17657. }
  17658. },
  17659. // Handle events: "focusout/validate/keyup/click/change/input/compositionstart/compositionend"
  17660. _focusout: function (e) {
  17661. var me = this,
  17662. opt = me.options,
  17663. el = e.target,
  17664. etype = e.type,
  17665. etype0,
  17666. focusin = etype === 'focusin',
  17667. special = etype === 'validate',
  17668. elem,
  17669. field,
  17670. old,
  17671. value,
  17672. timestamp,
  17673. key, specialKey,
  17674. timely,
  17675. timer = 0;
  17676. if (etype === 'compositionstart') {
  17677. me.pauseValidate = true;
  17678. }
  17679. if (etype === 'compositionend') {
  17680. me.pauseValidate = false;
  17681. }
  17682. if (me.pauseValidate) {
  17683. return;
  17684. }
  17685. // For checkbox and radio
  17686. elem = el.name && _checkable(el) ? me.$el.find('input[name="' + el.name + '"]').get(0) : el;
  17687. // Get field
  17688. if (!(field = me.getField(elem)) || !field.rule) {
  17689. return;
  17690. }
  17691. // Cache event type
  17692. etype0 = field._e;
  17693. field._e = etype;
  17694. timely = field.timely;
  17695. if (!special) {
  17696. if (!timely || (_checkable(el) && etype !== 'click')) {
  17697. return;
  17698. }
  17699. value = field.getValue();
  17700. // not validate field unless fill a value
  17701. if (field.ignoreBlank && !value && !focusin) {
  17702. me.hideMsg(el);
  17703. return;
  17704. }
  17705. if (etype === 'focusout') {
  17706. if (etype0 === 'change') {
  17707. return;
  17708. }
  17709. if (timely === 2 || timely === 8) {
  17710. old = field.old;
  17711. if (value && old) {
  17712. if (field.isValid && !old.showOk) {
  17713. me.hideMsg(el);
  17714. } else {
  17715. me._makeMsg(el, field, old);
  17716. }
  17717. } else {
  17718. return;
  17719. }
  17720. }
  17721. } else {
  17722. if (timely < 2 && !e.data) {
  17723. return;
  17724. }
  17725. // mark timestamp to reduce the frequency of the received event
  17726. timestamp = +new Date();
  17727. if (timestamp - (el._ts || 0) < 100) {
  17728. return;
  17729. }
  17730. el._ts = timestamp;
  17731. // handle keyup
  17732. if (etype === 'keyup') {
  17733. if (etype0 === 'input') {
  17734. return;
  17735. }
  17736. key = e.keyCode;
  17737. specialKey = {
  17738. 8: 1, // Backspace
  17739. 9: 1, // Tab
  17740. 16: 1, // Shift
  17741. 32: 1, // Space
  17742. 46: 1 // Delete
  17743. };
  17744. // only gets focus, no validation
  17745. if (key === 9 && !value) {
  17746. return;
  17747. }
  17748. // do not validate, if triggered by these keys
  17749. if (key < 48 && !specialKey[key]) {
  17750. return;
  17751. }
  17752. }
  17753. if (!focusin) {
  17754. // keyboard events, reducing the frequency of validation
  17755. timer = timely < 100 ? (etype === 'click' || el.tagName === 'SELECT') ? 0 : 400 : timely;
  17756. }
  17757. }
  17758. }
  17759. // if the current field is ignored
  17760. if (opt.ignore && $(el).is(opt.ignore)) {
  17761. return;
  17762. }
  17763. clearTimeout(field._t);
  17764. if (timer) {
  17765. field._t = setTimeout(function () {
  17766. me._validate(el, field);
  17767. }, timer);
  17768. } else {
  17769. if (special) field.old = {};
  17770. me._validate(el, field);
  17771. }
  17772. },
  17773. _setClass: function (el, isValid) {
  17774. var $el = $(el), opt = this.options;
  17775. if (opt.bindClassTo) {
  17776. $el = $el.closest(opt.bindClassTo);
  17777. }
  17778. $el.removeClass(opt.invalidClass + ' ' + opt.validClass);
  17779. if (isValid !== null) {
  17780. $el.addClass(isValid ? opt.validClass : opt.invalidClass);
  17781. }
  17782. },
  17783. _showmsg: function (e, type, msg) {
  17784. var me = this,
  17785. el = e.target;
  17786. if (me.$el.is(el)) {
  17787. if (isObject(type)) {
  17788. me.showMsg(type)
  17789. } else if (type === 'tip') {
  17790. me.$el.find(INPUT_SELECTOR + '[' + DATA_TIP + ']', el).each(function () {
  17791. me.showMsg(this, {type: type, msg: msg});
  17792. });
  17793. }
  17794. } else {
  17795. me.showMsg(el, {type: type, msg: msg});
  17796. }
  17797. },
  17798. _hidemsg: function (e) {
  17799. var $el = $(e.target);
  17800. if ($el.is(INPUT_SELECTOR)) {
  17801. this.hideMsg($el);
  17802. }
  17803. },
  17804. // Validated a field
  17805. _validatedField: function (el, field, ret) {
  17806. var me = this,
  17807. opt = me.options,
  17808. isValid = field.isValid = ret.isValid = !!ret.isValid,
  17809. callback = isValid ? 'valid' : 'invalid';
  17810. ret.key = field.key;
  17811. ret.ruleName = field._r;
  17812. ret.id = el.id;
  17813. ret.value = field.value;
  17814. me.elements[field.key] = ret.element = el;
  17815. me.isValid = me.$el[0].isValid = isValid ? me.isFormValid() : isValid;
  17816. if (isValid) {
  17817. ret.type = 'ok';
  17818. } else {
  17819. if (me.submiting) {
  17820. me.errors[field.key] = ret.msg;
  17821. }
  17822. me.hasError = true;
  17823. }
  17824. // cache result
  17825. field.old = ret;
  17826. // trigger callback
  17827. isFunction(field[callback]) && field[callback].call(me, el, ret);
  17828. isFunction(opt.validation) && opt.validation.call(me, el, ret);
  17829. // trigger event
  17830. $(el).attr(ARIA_INVALID, isValid ? null : true)
  17831. .trigger(callback + CLS_NS_FIELD, [ret, me]);
  17832. me.$el.triggerHandler('validation', [ret, me]);
  17833. if (me.checkOnly) return;
  17834. // set className
  17835. me._setClass(el, ret.skip || ret.type === 'tip' ? null : isValid);
  17836. me._makeMsg.apply(me, arguments);
  17837. },
  17838. _makeMsg: function (el, field, ret) {
  17839. // show or hide the message
  17840. if (field.msgMaker) {
  17841. ret = $.extend({}, ret);
  17842. if (field._e === 'focusin') {
  17843. ret.type = 'tip';
  17844. }
  17845. this[ret.showOk || ret.msg || ret.type === 'tip' ? 'showMsg' : 'hideMsg'](el, ret, field);
  17846. }
  17847. },
  17848. // Validated a rule
  17849. _validatedRule: function (el, field, ret, msgOpt) {
  17850. field = field || me.getField(el);
  17851. msgOpt = msgOpt || {};
  17852. var me = this,
  17853. msg,
  17854. rule,
  17855. method = field._r,
  17856. timely = field.timely,
  17857. special = timely === 9 || timely === 8,
  17858. transfer,
  17859. temp,
  17860. isValid = false;
  17861. // use null to break validation from a field
  17862. if (ret === null) {
  17863. me._validatedField(el, field, {isValid: true, skip: true});
  17864. field._i = 0;
  17865. return;
  17866. } else if (ret === undefined) {
  17867. transfer = true;
  17868. } else if (ret === true || ret === '') {
  17869. isValid = true;
  17870. } else if (isString(ret)) {
  17871. msg = ret;
  17872. } else if (isObject(ret)) {
  17873. if (ret.error) {
  17874. msg = ret.error;
  17875. } else {
  17876. msg = ret.ok;
  17877. isValid = true;
  17878. }
  17879. } else {
  17880. isValid = !!ret
  17881. }
  17882. rule = field._rules[field._i];
  17883. if (rule.not) {
  17884. msg = undefined;
  17885. isValid = method === 'required' || !isValid;
  17886. }
  17887. if (rule.or) {
  17888. if (isValid) {
  17889. while (field._i < field._rules.length && field._rules[field._i].or) {
  17890. field._i++;
  17891. }
  17892. } else {
  17893. transfer = true;
  17894. }
  17895. } else if (rule.and) {
  17896. if (!field.isValid) transfer = true;
  17897. }
  17898. if (transfer) {
  17899. isValid = true;
  17900. }
  17901. // message analysis, and throw rule level event
  17902. else {
  17903. if (isValid) {
  17904. if (field.showOk !== false) {
  17905. temp = attr(el, DATA_OK);
  17906. msg = temp === null ? isString(field.ok) ? field.ok : msg : temp;
  17907. if (!isString(msg) && isString(field.showOk)) {
  17908. msg = field.showOk;
  17909. }
  17910. if (isString(msg)) {
  17911. msgOpt.showOk = isValid;
  17912. }
  17913. }
  17914. }
  17915. if (!isValid || special) {
  17916. /* rule message priority:
  17917. 1. custom DOM message
  17918. 2. custom field message;
  17919. 3. global defined message;
  17920. 4. rule returned message;
  17921. 5. default message;
  17922. */
  17923. msg = (_getDataMsg(el, field, msg || rule.msg || me.messages[method]) || me.messages.fallback).replace(/\{0\|?([^\}]*)\}/, function (m, defaultDisplay) {
  17924. return me._getDisplay(el, field.display) || defaultDisplay || me.messages[0];
  17925. });
  17926. }
  17927. if (!isValid) field.isValid = isValid;
  17928. msgOpt.msg = msg;
  17929. $(el).trigger((isValid ? 'valid' : 'invalid') + CLS_NS_RULE, [method, msg]);
  17930. }
  17931. if (special && (!transfer || rule.and)) {
  17932. if (!isValid && !field._m) field._m = msg;
  17933. field._v = field._v || [];
  17934. field._v.push({
  17935. type: isValid ? !transfer ? 'ok' : 'tip' : 'error',
  17936. msg: msg || rule.msg
  17937. });
  17938. }
  17939. me._debug('log', ' ' + field._i + ': ' + method + ' => ' + (isValid || msg));
  17940. // the current rule has passed, continue to validate
  17941. if ((isValid || special) && field._i < field._rules.length - 1) {
  17942. field._i++;
  17943. me._checkRule(el, field);
  17944. }
  17945. // field was invalid, or all fields was valid
  17946. else {
  17947. field._i = 0;
  17948. if (special) {
  17949. msgOpt.isValid = field.isValid;
  17950. msgOpt.result = field._v;
  17951. msgOpt.msg = field._m || '';
  17952. if (!field.value && (field._e === 'focusin')) {
  17953. msgOpt.type = 'tip';
  17954. }
  17955. } else {
  17956. msgOpt.isValid = isValid;
  17957. }
  17958. me._validatedField(el, field, msgOpt);
  17959. delete field._m;
  17960. delete field._v;
  17961. }
  17962. },
  17963. // Verify a rule form a field
  17964. _checkRule: function (el, field) {
  17965. var me = this,
  17966. ret,
  17967. fn,
  17968. old,
  17969. key = field.key,
  17970. rule = field._rules[field._i],
  17971. method = rule.method,
  17972. params = rule.params;
  17973. // request has been sent, wait it
  17974. if (me.submiting && me.deferred[key]) {
  17975. return;
  17976. }
  17977. old = field.old;
  17978. field._r = method;
  17979. if (old && !field.must && !rule.must && rule.result !== undefined &&
  17980. old.ruleName === method && old.id === el.id &&
  17981. field.value && old.value === field.value) {
  17982. // get result from cache
  17983. ret = rule.result;
  17984. } else {
  17985. // get result from current rule
  17986. fn = _getDataRule(el, method) || me.rules[method] || noop;
  17987. ret = fn.call(field, el, params, field);
  17988. if (fn.msg) rule.msg = fn.msg;
  17989. }
  17990. // asynchronous validation
  17991. if (isObject(ret) && isFunction(ret.then)) {
  17992. me.deferred[key] = ret;
  17993. // whether the field valid is unknown
  17994. field.isValid = undefined;
  17995. // show loading message
  17996. !me.checkOnly && me.showMsg(el, {
  17997. type: 'loading',
  17998. msg: me.messages.loading
  17999. }, field);
  18000. // waiting to parse the response data
  18001. ret.then(
  18002. function (d, textStatus, jqXHR) {
  18003. var data = trim(jqXHR.responseText),
  18004. result,
  18005. dataFilter = field.dataFilter;
  18006. // detect if data is json or jsonp format
  18007. if (/jsonp?/.test(this.dataType)) {
  18008. data = d;
  18009. } else if (data.charAt(0) === '{') {
  18010. data = $.parseJSON(data);
  18011. }
  18012. // filter data
  18013. result = dataFilter.call(this, data, field);
  18014. if (result === undefined) result = dataFilter.call(this, data.data, field);
  18015. rule.data = this.data;
  18016. rule.result = field.old ? result : undefined;
  18017. me._validatedRule(el, field, result);
  18018. },
  18019. function (jqXHR, textStatus) {
  18020. me._validatedRule(el, field, me.messages[textStatus] || textStatus);
  18021. }
  18022. ).always(function () {
  18023. delete me.deferred[key];
  18024. });
  18025. }
  18026. // other result
  18027. else {
  18028. me._validatedRule(el, field, ret);
  18029. }
  18030. },
  18031. // Processing the validation
  18032. _validate: function (el, field) {
  18033. var me = this;
  18034. // doesn't validate the element that has "disabled" or "novalidate" attribute
  18035. if (el.disabled || attr(el, NOVALIDATE) !== null) {
  18036. return;
  18037. }
  18038. field = field || me.getField(el);
  18039. if (!field) return;
  18040. if (!field._rules) me._parse(el);
  18041. if (!field._rules) return;
  18042. me._debug('info', field.key);
  18043. field.isValid = true;
  18044. field.element = el;
  18045. // Cache the value
  18046. field.value = field.getValue();
  18047. // if the field is not required, and that has a blank value
  18048. if (!field.required && !field.must && !field.value) {
  18049. if (!_checkable(el)) {
  18050. me._validatedField(el, field, {isValid: true});
  18051. return true;
  18052. }
  18053. }
  18054. me._checkRule(el, field);
  18055. return field.isValid;
  18056. },
  18057. _debug: function (type, messages) {
  18058. if (window.console && this.options.debug) {
  18059. console[type](messages);
  18060. }
  18061. },
  18062. /**
  18063. * Detecting whether the value of an element that matches a rule
  18064. *
  18065. * @method test
  18066. * @param {Element} el - input element
  18067. * @param {String} rule - rule name
  18068. */
  18069. test: function (el, rule) {
  18070. var me = this,
  18071. ret,
  18072. parts = rRule.exec(rule),
  18073. field,
  18074. method,
  18075. params;
  18076. if (parts) {
  18077. method = parts[1];
  18078. if (method in me.rules) {
  18079. params = parts[2] || parts[3];
  18080. params = params ? params.split(', ') : undefined;
  18081. field = me.getField(el, true);
  18082. field._r = method;
  18083. field.value = field.getValue();
  18084. ret = me.rules[method].call(field, el, params);
  18085. }
  18086. }
  18087. return ret === true || ret === undefined || ret === null;
  18088. },
  18089. _getDisplay: function (el, str) {
  18090. return !isString(str) ? isFunction(str) ? str.call(this, el) : '' : str;
  18091. },
  18092. _getMsgOpt: function (obj, field) {
  18093. var opt = field ? field : this.options;
  18094. return $.extend({
  18095. type: 'error',
  18096. pos: _getPos(opt.msgClass),
  18097. target: opt.target,
  18098. wrapper: opt.msgWrapper,
  18099. style: opt.msgStyle,
  18100. cls: opt.msgClass,
  18101. arrow: opt.msgArrow,
  18102. icon: opt.msgIcon
  18103. }, isString(obj) ? {msg: obj} : obj);
  18104. },
  18105. _getMsgDOM: function (el, msgOpt) {
  18106. var $el = $(el), $msgbox, datafor, tgt, container;
  18107. if ($el.is(INPUT_SELECTOR)) {
  18108. tgt = msgOpt.target || attr(el, DATA_TARGET);
  18109. if (tgt) {
  18110. tgt = !isFunction(tgt) ? tgt.charAt(0) === '#' ? $(tgt) : this.$el.find(tgt) : tgt.call(this, el);
  18111. if (tgt.length) {
  18112. if (tgt.is(INPUT_SELECTOR)) {
  18113. $el = tgt
  18114. el = tgt.get(0);
  18115. } else if (tgt.hasClass(CLS_MSG_BOX)) {
  18116. $msgbox = tgt;
  18117. } else {
  18118. container = tgt;
  18119. }
  18120. }
  18121. }
  18122. if (!$msgbox) {
  18123. datafor = (!_checkable(el) || !el.name) && el.id ? el.id : el.name;
  18124. $msgbox = (container || this.$el).find(msgOpt.wrapper + '.' + CLS_MSG_BOX + '[for="' + datafor + '"]');
  18125. }
  18126. } else {
  18127. $msgbox = $el;
  18128. }
  18129. // Create new message box
  18130. if (!msgOpt.hide && !$msgbox.length) {
  18131. $msgbox = $('<' + msgOpt.wrapper + '>').attr({
  18132. 'class': CLS_MSG_BOX + (msgOpt.cls ? ' ' + msgOpt.cls : ''),
  18133. 'style': msgOpt.style || undefined,
  18134. 'for': datafor
  18135. });
  18136. if (container) {
  18137. $msgbox.appendTo(container);
  18138. } else {
  18139. if (_checkable(el)) {
  18140. var $parent = $el.parent();
  18141. $msgbox.appendTo($parent.is('label') ? $parent.parent() : $parent);
  18142. } else {
  18143. $msgbox[!msgOpt.pos || msgOpt.pos === 'right' ? 'insertAfter' : 'insertBefore']($el);
  18144. }
  18145. }
  18146. }
  18147. return $msgbox;
  18148. },
  18149. /**
  18150. * Show validation message
  18151. *
  18152. * @method showMsg
  18153. * @param {Element} el - input element
  18154. * @param {Object} msgOpt
  18155. */
  18156. showMsg: function (el, msgOpt, /*INTERNAL*/ field) {
  18157. if (!el) return;
  18158. var me = this,
  18159. opt = me.options,
  18160. msgShow,
  18161. msgMaker,
  18162. temp,
  18163. $msgbox;
  18164. if (isObject(el) && !el.jquery && !msgOpt) {
  18165. $.each(el, function (key, msg) {
  18166. var el = me.elements[key] || me.$el.find(_key2selector(key))[0];
  18167. me.showMsg(el, msg);
  18168. });
  18169. return;
  18170. }
  18171. if ($(el).is(INPUT_SELECTOR)) {
  18172. field = field || me.getField(el);
  18173. }
  18174. if (!(msgMaker = (field || opt).msgMaker)) {
  18175. return;
  18176. }
  18177. msgOpt = me._getMsgOpt(msgOpt, field);
  18178. el = (el.name && _checkable(el) ? me.$el.find('input[name="' + el.name + '"]') : $(el)).get(0);
  18179. // ok or tip
  18180. if (!msgOpt.msg && msgOpt.type !== 'error') {
  18181. temp = attr(el, 'data-' + msgOpt.type);
  18182. if (temp !== null) msgOpt.msg = temp;
  18183. }
  18184. if (!isString(msgOpt.msg)) {
  18185. return;
  18186. }
  18187. $msgbox = me._getMsgDOM(el, msgOpt);
  18188. !rPos.test($msgbox[0].className) && $msgbox.addClass(msgOpt.cls);
  18189. if (isIE === 6 && msgOpt.pos === 'bottom') {
  18190. $msgbox[0].style.marginTop = $(el).outerHeight() + 'px';
  18191. }
  18192. $msgbox.html(msgMaker.call(me, msgOpt))[0].style.display = '';
  18193. if (isFunction(msgShow = field && field.msgShow || opt.msgShow)) {
  18194. msgShow.call(me, $msgbox, msgOpt.type);
  18195. }
  18196. },
  18197. /**
  18198. * Hide validation message
  18199. *
  18200. * @method hideMsg
  18201. * @param {Element} el - input element
  18202. * @param {Object} msgOpt optional
  18203. */
  18204. hideMsg: function (el, msgOpt, /*INTERNAL*/ field) {
  18205. var me = this,
  18206. opt = me.options,
  18207. msgHide,
  18208. $msgbox;
  18209. el = $(el).get(0);
  18210. if ($(el).is(INPUT_SELECTOR)) {
  18211. field = field || me.getField(el);
  18212. if (field) {
  18213. if (field.isValid || me.reseting) attr(el, ARIA_INVALID, null);
  18214. }
  18215. }
  18216. msgOpt = me._getMsgOpt(msgOpt, field);
  18217. msgOpt.hide = true;
  18218. $msgbox = me._getMsgDOM(el, msgOpt);
  18219. if (!$msgbox.length) return;
  18220. if (isFunction(msgHide = field && field.msgHide || opt.msgHide)) {
  18221. msgHide.call(me, $msgbox, msgOpt.type);
  18222. } else {
  18223. $msgbox[0].style.display = 'none';
  18224. $msgbox[0].innerHTML = '';
  18225. }
  18226. },
  18227. /**
  18228. * Get field information
  18229. *
  18230. * @method getField
  18231. * @param {Element} - input element
  18232. * @return {Object} field
  18233. */
  18234. getField: function (el, must) {
  18235. var me = this,
  18236. key,
  18237. field;
  18238. if (isString(el)) {
  18239. key = el;
  18240. el = undefined;
  18241. } else {
  18242. if (attr(el, DATA_RULE)) {
  18243. return me._parse(el);
  18244. }
  18245. if (el.id && '#' + el.id in me.fields || !el.name) {
  18246. key = '#' + el.id;
  18247. } else {
  18248. key = el.name;
  18249. }
  18250. }
  18251. if ((field = me.fields[key]) || must && (field = new me.Field(key))) {
  18252. field.element = el;
  18253. }
  18254. return field;
  18255. },
  18256. /**
  18257. * Config a field
  18258. *
  18259. * @method: setField
  18260. * @param {String} key
  18261. * @param {Object} obj
  18262. */
  18263. setField: function (key, obj) {
  18264. var fields = {};
  18265. if (!key) return;
  18266. // update this field
  18267. if (isString(key)) {
  18268. fields[key] = obj;
  18269. }
  18270. // update fields
  18271. else {
  18272. fields = key;
  18273. }
  18274. this._initFields(fields);
  18275. },
  18276. /**
  18277. * Detecting whether the form is valid
  18278. *
  18279. * @method isFormValid
  18280. * @return {Boolean}
  18281. */
  18282. isFormValid: function () {
  18283. var fields = this.fields, k, field;
  18284. for (k in fields) {
  18285. field = fields[k];
  18286. if (!field._rules || !field.required && !field.must && !field.value) continue;
  18287. if (!field.isValid) return false;
  18288. }
  18289. return true;
  18290. },
  18291. /**
  18292. * Prevent submission form
  18293. *
  18294. * @method holdSubmit
  18295. * @param {Boolean} hold - If set to false, will release the hold
  18296. */
  18297. holdSubmit: function (hold) {
  18298. this.submiting = hold === undefined || hold;
  18299. },
  18300. /**
  18301. * Clean validation messages
  18302. *
  18303. * @method cleanUp
  18304. */
  18305. cleanUp: function () {
  18306. this._reset(1);
  18307. },
  18308. /**
  18309. * Destroy the validation
  18310. *
  18311. * @method destroy
  18312. */
  18313. destroy: function () {
  18314. this._reset(1);
  18315. this.$el.off(CLS_NS).removeData(NS);
  18316. attr(this.$el[0], NOVALIDATE, this._NOVALIDATE);
  18317. }
  18318. };
  18319. /**
  18320. * Create Field Factory
  18321. *
  18322. * @class
  18323. * @param {Object} context
  18324. * @return {Function} Factory
  18325. */
  18326. function _createFieldFactory(context) {
  18327. function FieldFactory() {
  18328. var options = this.options;
  18329. for (var i in options) {
  18330. if (i in fieldDefaults) this[i] = options[i];
  18331. }
  18332. $.extend(this, {
  18333. _valHook: function () {
  18334. return this.element.contentEditable === 'true' ? 'text' : 'val';
  18335. },
  18336. getValue: function () {
  18337. var elem = this.element;
  18338. if (elem.type === 'number' && elem.validity && elem.validity.badInput) {
  18339. return 'NaN';
  18340. }
  18341. return $(elem)[this._valHook()]();
  18342. },
  18343. setValue: function (value) {
  18344. $(this.element)[this._valHook()](this.value = value);
  18345. },
  18346. // Get a range of validation messages
  18347. getRangeMsg: function (value, params, suffix) {
  18348. if (!params) return;
  18349. var me = this,
  18350. msg = me.messages[me._r] || '',
  18351. result,
  18352. p = params[0].split('~'),
  18353. e = params[1] === 'false',
  18354. a = p[0],
  18355. b = p[1],
  18356. c = 'rg',
  18357. args = [''],
  18358. isNumber = trim(value) && +value === +value;
  18359. function compare(large, small) {
  18360. return !e ? large >= small : large > small;
  18361. }
  18362. if (p.length === 2) {
  18363. if (a && b) {
  18364. if (isNumber && compare(value, +a) && compare(+b, value)) {
  18365. result = true;
  18366. }
  18367. args = args.concat(p);
  18368. c = e ? 'gtlt' : 'rg';
  18369. } else if (a && !b) {
  18370. if (isNumber && compare(value, +a)) {
  18371. result = true;
  18372. }
  18373. args.push(a);
  18374. c = e ? 'gt' : 'gte';
  18375. } else if (!a && b) {
  18376. if (isNumber && compare(+b, value)) {
  18377. result = true;
  18378. }
  18379. args.push(b);
  18380. c = e ? 'lt' : 'lte';
  18381. }
  18382. } else {
  18383. if (value === +a) {
  18384. result = true;
  18385. }
  18386. args.push(a);
  18387. c = 'eq';
  18388. }
  18389. if (msg) {
  18390. if (suffix && msg[c + suffix]) {
  18391. c += suffix;
  18392. }
  18393. args[0] = msg[c];
  18394. }
  18395. return result || me._rules && (me._rules[me._i].msg = me.renderMsg.apply(null, args));
  18396. },
  18397. // Render message template
  18398. renderMsg: function () {
  18399. var args = arguments,
  18400. tpl = args[0],
  18401. i = args.length;
  18402. if (!tpl) return;
  18403. while (--i) {
  18404. tpl = tpl.replace('{' + i + '}', args[i]);
  18405. }
  18406. return tpl;
  18407. }
  18408. });
  18409. }
  18410. function Field(key, obj, oldField) {
  18411. this.key = key;
  18412. this.validator = context;
  18413. $.extend(this, oldField, obj);
  18414. }
  18415. FieldFactory.prototype = context;
  18416. Field.prototype = new FieldFactory();
  18417. return Field;
  18418. }
  18419. /**
  18420. * Create Rules
  18421. *
  18422. * @class
  18423. * @param {Object} obj rules
  18424. * @param {Object} context context
  18425. */
  18426. function Rules(obj, context) {
  18427. if (!isObject(obj)) return;
  18428. var k, that = context ? context === true ? this : context : Rules.prototype;
  18429. for (k in obj) {
  18430. if (_checkRuleName(k)) {
  18431. that[k] = _getRule(obj[k]);
  18432. }
  18433. }
  18434. }
  18435. /**
  18436. * Create Messages
  18437. *
  18438. * @class
  18439. * @param {Object} obj rules
  18440. * @param {Object} context context
  18441. */
  18442. function Messages(obj, context) {
  18443. if (!isObject(obj)) return;
  18444. var k, that = context ? context === true ? this : context : Messages.prototype;
  18445. for (k in obj) {
  18446. that[k] = obj[k];
  18447. }
  18448. }
  18449. // Rule converted factory
  18450. function _getRule(fn) {
  18451. switch ($.type(fn)) {
  18452. case 'function':
  18453. return fn;
  18454. case 'array':
  18455. var f = function () {
  18456. return fn[0].test(this.value) || fn[1] || false;
  18457. };
  18458. f.msg = fn[1];
  18459. return f;
  18460. case 'regexp':
  18461. return function () {
  18462. return fn.test(this.value);
  18463. };
  18464. }
  18465. }
  18466. // Get instance by an element
  18467. function _getInstance(el) {
  18468. var wrap, k, options;
  18469. if (!el || !el.tagName) return;
  18470. switch (el.tagName) {
  18471. case 'INPUT':
  18472. case 'SELECT':
  18473. case 'TEXTAREA':
  18474. case 'BUTTON':
  18475. case 'FIELDSET':
  18476. wrap = el.form || $(el).closest('.' + CLS_WRAPPER);
  18477. break;
  18478. case 'FORM':
  18479. wrap = el;
  18480. break;
  18481. default:
  18482. wrap = $(el).closest('.' + CLS_WRAPPER);
  18483. }
  18484. for (k in preinitialized) {
  18485. if ($(wrap).is(k)) {
  18486. options = preinitialized[k];
  18487. break;
  18488. }
  18489. }
  18490. return $(wrap).data(NS) || $(wrap)[NS](options).data(NS);
  18491. }
  18492. // Get custom rules on the node
  18493. function _getDataRule(el, method) {
  18494. var fn = trim(attr(el, DATA_RULE + '-' + method));
  18495. if (fn && (fn = new Function('return ' + fn)())) {
  18496. return _getRule(fn);
  18497. }
  18498. }
  18499. // Get custom messages on the node
  18500. function _getDataMsg(el, field, m) {
  18501. var msg = field.msg,
  18502. item = field._r;
  18503. if (isObject(msg)) msg = msg[item];
  18504. if (!isString(msg)) {
  18505. msg = attr(el, DATA_MSG + '-' + item) || attr(el, DATA_MSG) || (m ? isString(m) ? m : m[item] : '');
  18506. }
  18507. return msg;
  18508. }
  18509. // Get message position
  18510. function _getPos(str) {
  18511. var pos;
  18512. if (str) pos = rPos.exec(str);
  18513. return pos && pos[0];
  18514. }
  18515. // Check whether the element is checkbox or radio
  18516. function _checkable(el) {
  18517. return el.tagName === 'INPUT' && el.type === 'checkbox' || el.type === 'radio';
  18518. }
  18519. // Parse date string to timestamp
  18520. function _parseDate(str) {
  18521. return Date.parse(str.replace(/\.|\-/g, '/'));
  18522. }
  18523. // Rule name only allows alphanumeric characters and underscores
  18524. function _checkRuleName(name) {
  18525. return /^\w+$/.test(name);
  18526. }
  18527. // Translate field key to jQuery selector.
  18528. function _key2selector(key) {
  18529. var isID = key.charAt(0) === '#';
  18530. key = key.replace(/([:.{(|)}/\[\]])/g, '\\$1');
  18531. return isID ? key : '[name="' + key + '"]:first';
  18532. }
  18533. // Fixed a issue cause by refresh page in IE.
  18534. $(window).on('beforeunload', function () {
  18535. this.focus();
  18536. });
  18537. $(document)
  18538. .on('click', ':submit', function () {
  18539. var input = this, attrNode;
  18540. if (!input.form) return;
  18541. // Shim for "formnovalidate"
  18542. attrNode = input.getAttributeNode('formnovalidate');
  18543. if (attrNode && attrNode.nodeValue !== null || attr(input, NOVALIDATE) !== null) {
  18544. novalidateonce = true;
  18545. }
  18546. })
  18547. // Automatic initializing form validation
  18548. .on('focusin submit validate', 'form,.' + CLS_WRAPPER, function (e) {
  18549. if (attr(this, NOVALIDATE) !== null) return;
  18550. var $form = $(this), me;
  18551. if (!$form.data(NS) && (me = _getInstance(this))) {
  18552. if (!$.isEmptyObject(me.fields)) {
  18553. // Execute event handler
  18554. if (e.type === 'focusin') {
  18555. me._focusin(e);
  18556. } else {
  18557. me._submit(e);
  18558. }
  18559. } else {
  18560. attr(this, NOVALIDATE, NOVALIDATE);
  18561. $form.off(CLS_NS).removeData(NS);
  18562. }
  18563. }
  18564. });
  18565. new Messages({
  18566. fallback: 'This field is not valid.',
  18567. loading: 'Validating...'
  18568. });
  18569. // Built-in rules (global)
  18570. new Rules({
  18571. /**
  18572. * required
  18573. *
  18574. * @example:
  18575. required
  18576. required(jqSelector)
  18577. required(anotherRule)
  18578. required(not, -1)
  18579. required(from, .contact)
  18580. */
  18581. required: function (element, params) {
  18582. var me = this,
  18583. val = trim(me.value),
  18584. isValid = true;
  18585. if (params) {
  18586. if (params.length === 1) {
  18587. if (!_checkRuleName(params[0])) {
  18588. if (!val && !$(params[0], me.$el).length) {
  18589. return null;
  18590. }
  18591. } else if (me.rules[params[0]]) {
  18592. if (!val && !me.test(element, params[0])) {
  18593. return null;
  18594. }
  18595. me._r = 'required'
  18596. }
  18597. } else if (params[0] === 'not') {
  18598. $.each(params.slice(1), function () {
  18599. return (isValid = val !== trim(this));
  18600. });
  18601. } else if (params[0] === 'from') {
  18602. var $elements = me.$el.find(params[1]),
  18603. VALIDATED = '_validated_',
  18604. ret;
  18605. isValid = $elements.filter(function () {
  18606. var field = me.getField(this);
  18607. return field && !!trim(field.getValue());
  18608. }).length >= (params[2] || 1);
  18609. if (isValid) {
  18610. if (!val) ret = null;
  18611. } else {
  18612. ret = _getDataMsg($elements[0], me) || false;
  18613. }
  18614. if (!$(element).data(VALIDATED)) {
  18615. $elements.data(VALIDATED, 1).each(function () {
  18616. if (element !== this) {
  18617. me._validate(this);
  18618. }
  18619. }).removeData(VALIDATED);
  18620. }
  18621. return ret;
  18622. }
  18623. }
  18624. return isValid && !!val;
  18625. },
  18626. /**
  18627. * integer
  18628. *
  18629. * @example:
  18630. integer
  18631. integer[+]
  18632. integer[+0]
  18633. integer[-]
  18634. integer[-0]
  18635. */
  18636. integer: function (element, params) {
  18637. var re, z = '0|',
  18638. p = '[1-9]\\d*',
  18639. key = params ? params[0] : '*';
  18640. switch (key) {
  18641. case '+':
  18642. re = p;
  18643. break;
  18644. case '-':
  18645. re = '-' + p;
  18646. break;
  18647. case '+0':
  18648. re = z + p;
  18649. break;
  18650. case '-0':
  18651. re = z + '-' + p;
  18652. break;
  18653. default:
  18654. re = z + '-?' + p;
  18655. }
  18656. re = '^(?:' + re + ')$';
  18657. return new RegExp(re).test(this.value) || (this.messages.integer && this.messages.integer[key]);
  18658. },
  18659. /**
  18660. * match another field
  18661. *
  18662. * @example:
  18663. match[password] Match the password field (two values ​​must be the same)
  18664. match[eq, password] Ditto
  18665. match[neq, count] The value must be not equal to the value of the count field
  18666. match[lt, count] The value must be less than the value of the count field
  18667. match[lte, count] The value must be less than or equal to the value of the count field
  18668. match[gt, count] The value must be greater than the value of the count field
  18669. match[gte, count] The value must be greater than or equal to the value of the count field
  18670. match[gte, startDate, date]
  18671. match[gte, startTime, time]
  18672. **/
  18673. match: function (element, params) {
  18674. if (!params) return;
  18675. var me = this,
  18676. isValid = true,
  18677. a, b,
  18678. key, msg, type = 'eq', parser,
  18679. selector2, elem2, field2;
  18680. if (params.length === 1) {
  18681. key = params[0];
  18682. } else {
  18683. type = params[0];
  18684. key = params[1];
  18685. }
  18686. selector2 = _key2selector(key);
  18687. elem2 = me.$el.find(selector2)[0];
  18688. // If the compared field is not exist
  18689. if (!elem2) return;
  18690. field2 = me.getField(elem2);
  18691. a = me.value;
  18692. b = field2.getValue();
  18693. if (!me._match) {
  18694. me.$el.on('valid' + CLS_NS_FIELD + CLS_NS, selector2, function () {
  18695. $(element).trigger('validate');
  18696. });
  18697. me._match = field2._match = 1;
  18698. }
  18699. // If both fields are blank
  18700. if (!me.required && a === '' && b === '') {
  18701. return null;
  18702. }
  18703. parser = params[2];
  18704. if (parser) {
  18705. if (/^date(time)?$/i.test(parser)) {
  18706. a = _parseDate(a);
  18707. b = _parseDate(b);
  18708. } else if (parser === 'time') {
  18709. a = +a.replace(/:/g, '');
  18710. b = +b.replace(/:/g, '');
  18711. }
  18712. }
  18713. // If the compared field is incorrect, we only ensure that this field is correct.
  18714. if (type !== 'eq' && !isNaN(+a) && isNaN(+b)) {
  18715. return true;
  18716. }
  18717. switch (type) {
  18718. case 'lt':
  18719. isValid = +a < +b;
  18720. break;
  18721. case 'lte':
  18722. isValid = +a <= +b;
  18723. break;
  18724. case 'gte':
  18725. isValid = +a >= +b;
  18726. break;
  18727. case 'gt':
  18728. isValid = +a > +b;
  18729. break;
  18730. case 'neq':
  18731. isValid = a !== b;
  18732. break;
  18733. default:
  18734. isValid = a === b;
  18735. }
  18736. return isValid || (
  18737. isObject(me.messages.match)
  18738. && me.messages.match[type].replace('{1}', me._getDisplay(elem2, field2.display || key))
  18739. );
  18740. },
  18741. /**
  18742. * range numbers
  18743. *
  18744. * @example:
  18745. range[0~99] Number 0-99
  18746. range[0~] Number greater than or equal to 0
  18747. range[~100] Number less than or equal to 100
  18748. **/
  18749. range: function (element, params) {
  18750. return this.getRangeMsg(this.value, params);
  18751. },
  18752. /**
  18753. * how many checkbox or radio inputs that checked
  18754. *
  18755. * @example:
  18756. checked; no empty, same to required
  18757. checked[1~3] 1-3 items
  18758. checked[1~] greater than 1 item
  18759. checked[~3] less than 3 items
  18760. checked[3] 3 items
  18761. **/
  18762. checked: function (element, params) {
  18763. if (!_checkable(element)) return;
  18764. var me = this,
  18765. elem, count;
  18766. if (element.name) {
  18767. count = me.$el.find('input[name="' + element.name + '"]').filter(function () {
  18768. var el = this;
  18769. if (!elem && _checkable(el)) elem = el;
  18770. return !el.disabled && el.checked;
  18771. }).length;
  18772. } else {
  18773. elem = element;
  18774. count = elem.checked;
  18775. }
  18776. if (params) {
  18777. return me.getRangeMsg(count, params);
  18778. } else {
  18779. return !!count || _getDataMsg(elem, me, '') || me.messages.required || false;
  18780. }
  18781. },
  18782. /**
  18783. * length of a characters (You can pass the second parameter "true", will calculate the length in bytes)
  18784. *
  18785. * @example:
  18786. length[6~16] 6-16 characters
  18787. length[6~] Greater than 6 characters
  18788. length[~16] Less than 16 characters
  18789. length[~16, true] Less than 16 characters, non-ASCII characters calculating two-character
  18790. **/
  18791. length: function (element, params) {
  18792. var value = this.value,
  18793. len = (params[1] === 'true' ? value.replace(rDoubleBytes, 'xx') : value).length;
  18794. return this.getRangeMsg(len, params, (params[1] ? '_2' : ''));
  18795. },
  18796. /**
  18797. * remote validation
  18798. *
  18799. * @description
  18800. * remote([get:]url [, name1, [name2 ...]]);
  18801. * Adaptation three kinds of results (Front for the successful, followed by a failure):
  18802. 1. text:
  18803. '' 'Error Message'
  18804. 2. json:
  18805. {"ok": ""} {"error": "Error Message"}
  18806. 3. json wrapper:
  18807. {"status": 1, "data": {"ok": ""}} {"status": 1, "data": {"error": "Error Message"}}
  18808. * @example
  18809. The simplest: remote(path/to/server);
  18810. With parameters: remote(path/to/server, name1, name2, ...);
  18811. By GET: remote(get:path/to/server, name1, name2, ...);
  18812. Name proxy: remote(path/to/server, name1, proxyname2:name2, proxyname3:#id3, ...)
  18813. Query String remote(path/to/server, foo=1&bar=2, name1, name2, ...)
  18814. CORS remote(cors:path/to/server)
  18815. JSONP remote(jsonp:path/to/server)
  18816. */
  18817. remote: function (element, params) {
  18818. if (!params) return;
  18819. var me = this,
  18820. arr = rAjaxType.exec(params[0]),
  18821. rule = me._rules[me._i],
  18822. data = {},
  18823. queryString = '',
  18824. url = arr[3],
  18825. type = arr[2] || 'POST', // GET / POST
  18826. rType = (arr[1] || '').toLowerCase(), // CORS / JSONP
  18827. dataType;
  18828. rule.must = true;
  18829. data[element.name] = me.value;
  18830. // There are extra fields
  18831. if (params[1]) {
  18832. $.map(params.slice(1), function (name) {
  18833. var arr, key;
  18834. if (~name.indexOf('=')) {
  18835. queryString += '&' + name;
  18836. } else {
  18837. arr = name.split(':');
  18838. name = trim(arr[0]);
  18839. key = trim(arr[1]) || name;
  18840. data[name] = me.$el.find(_key2selector(key)).val();
  18841. }
  18842. });
  18843. }
  18844. data = $.param(data) + queryString;
  18845. if (!me.must && rule.data && rule.data === data) {
  18846. return rule.result;
  18847. }
  18848. // Cross-domain request, force jsonp dataType
  18849. if (rType !== 'cors' && /^https?:/.test(url) && !~url.indexOf(location.host)) {
  18850. dataType = 'jsonp';
  18851. }
  18852. // Asynchronous validation need return jqXHR objects
  18853. return $.ajax({
  18854. url: url,
  18855. type: type,
  18856. data: data,
  18857. dataType: dataType
  18858. });
  18859. },
  18860. /**
  18861. * filter characters, direct filtration without prompting error (support custom regular expressions)
  18862. *
  18863. * @example
  18864. * filter filtering unsafe characters
  18865. * filter(regexp) filtering the "regexp" matched characters
  18866. */
  18867. filter: function (element, params) {
  18868. var value = this.value,
  18869. temp = value.replace(params ? (new RegExp('[' + params[0] + ']', 'gm')) : rUnsafe, '');
  18870. if (temp !== value) this.setValue(temp);
  18871. }
  18872. });
  18873. /**
  18874. * Config global options
  18875. *
  18876. * @static config
  18877. * @param {Object} options
  18878. */
  18879. Validator.config = function (key, value) {
  18880. if (isObject(key)) {
  18881. $.each(key, _config);
  18882. } else if (isString(key)) {
  18883. _config(key, value);
  18884. }
  18885. function _config(k, o) {
  18886. if (k === 'rules') {
  18887. new Rules(o);
  18888. } else if (k === 'messages') {
  18889. new Messages(o);
  18890. } else if (k in fieldDefaults) {
  18891. fieldDefaults[k] = o;
  18892. } else {
  18893. defaults[k] = o;
  18894. }
  18895. }
  18896. };
  18897. /**
  18898. * Config themes
  18899. *
  18900. * @static setTheme
  18901. * @param {String|Object} name
  18902. * @param {Object} obj
  18903. * @example
  18904. .setTheme( themeName, themeOptions )
  18905. .setTheme( multiThemes )
  18906. */
  18907. Validator.setTheme = function (name, obj) {
  18908. if (isObject(name)) {
  18909. $.extend(true, themes, name);
  18910. } else if (isString(name) && isObject(obj)) {
  18911. themes[name] = $.extend(themes[name], obj);
  18912. }
  18913. };
  18914. /**
  18915. * Resource loader
  18916. *
  18917. * @static load
  18918. * @param {String} str
  18919. * @example
  18920. .load('local=zh-CN') // load: local/zh-CN.js and jquery.validator.css
  18921. .load('local=zh-CN&css=') // load: local/zh-CN.js
  18922. .load('local&css') // load: local/en.js (set <html lang="en">) and jquery.validator.css
  18923. .load('local') // dito
  18924. */
  18925. Validator.load = function (str) {
  18926. if (!str) return;
  18927. var doc = document,
  18928. params = {},
  18929. node = doc.scripts[0],
  18930. dir, el, ONLOAD;
  18931. str.replace(/([^?=&]+)=([^&#]*)/g, function (m, key, value) {
  18932. params[key] = value;
  18933. });
  18934. dir = params.dir || Validator.dir;
  18935. if (!Validator.css && params.css !== '') {
  18936. el = doc.createElement('link');
  18937. el.rel = 'stylesheet';
  18938. el.href = Validator.css = dir + 'jquery.validator.css';
  18939. node.parentNode.insertBefore(el, node);
  18940. }
  18941. if (!Validator.local && ~str.indexOf('local') && params.local !== '') {
  18942. Validator.local = (params.local || doc.documentElement.lang || 'en').replace('_', '-');
  18943. Validator.pending = 1;
  18944. el = doc.createElement('script');
  18945. el.src = dir + 'local/' + Validator.local + '.js';
  18946. ONLOAD = 'onload' in el ? 'onload' : 'onreadystatechange';
  18947. el[ONLOAD] = function () {
  18948. if (!el.readyState || /loaded|complete/.test(el.readyState)) {
  18949. el = el[ONLOAD] = null;
  18950. delete Validator.pending;
  18951. $(window).triggerHandler('validatorready');
  18952. }
  18953. };
  18954. node.parentNode.insertBefore(el, node);
  18955. }
  18956. };
  18957. // Auto loading resources
  18958. (function () {
  18959. var scripts = document.scripts,
  18960. i = scripts.length, node, arr,
  18961. re = /(.*validator(?:\.min)?.js)(\?.*(?:local|css|dir)(?:=[\w\-]*)?)?/;
  18962. while (i-- && !arr) {
  18963. node = scripts[i];
  18964. arr = (node.hasAttribute ? node.src : node.getAttribute('src', 4) || '').match(re);
  18965. }
  18966. if (!arr) return;
  18967. Validator.dir = arr[1].split('/').slice(0, -1).join('/') + '/';
  18968. Validator.load(arr[2]);
  18969. })();
  18970. return $[NS] = Validator;
  18971. }));
  18972. /*********************************
  18973. * Themes, rules, and i18n support
  18974. * Locale: Chinese; 中文
  18975. *********************************/
  18976. (function (factory) {
  18977. typeof module === "object" && module.exports ? module.exports = factory(require("jquery")) :
  18978. typeof define === 'function' && define.amd ? define('validator-lang', ['jquery'], factory) :
  18979. factory(jQuery);
  18980. }(function ($) {
  18981. /* Global configuration
  18982. */
  18983. $.validator.config({
  18984. //stopOnError: true,
  18985. //focusCleanup: true,
  18986. //theme: 'yellow_right',
  18987. //timely: 2,
  18988. // Custom rules
  18989. rules: {
  18990. digits: [/^\d+$/, "请填写数字"]
  18991. , letters: [/^[a-z]+$/i, "请填写字母"]
  18992. , date: [/^\d{4}-\d{2}-\d{2}$/, "请填写有效的日期,格式:yyyy-mm-dd"]
  18993. , time: [/^([01]\d|2[0-3])(:[0-5]\d){1,2}$/, "请填写有效的时间,00:00到23:59之间"]
  18994. , email: [/^[\w\+\-]+(\.[\w\+\-]+)*@[a-z\d\-]+(\.[a-z\d\-]+)*\.([a-z]{2,4})$/i, "请填写有效的邮箱"]
  18995. , url: [/^(https?|s?ftp):\/\/\S+$/i, "请填写有效的网址"]
  18996. , qq: [/^[1-9]\d{4,}$/, "请填写有效的QQ号"]
  18997. , IDcard: [/^\d{6}(19|2\d)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)?$/, "请填写正确的身份证号码"]
  18998. , tel: [/^(?:(?:0\d{2,3}[\- ]?[1-9]\d{6,7})|(?:[48]00[\- ]?[1-9]\d{6}))$/, "请填写有效的电话号码"]
  18999. , mobile: [/^1[3-9]\d{9}$/, "请填写有效的手机号"]
  19000. , zipcode: [/^\d{6}$/, "请检查邮政编码格式"]
  19001. , chinese: [/^[\u0391-\uFFE5]+$/, "请填写中文字符"]
  19002. , username: [/^\w{3,12}$/, "请填写3-12位数字、字母、下划线"]
  19003. , password: [/^[\S]{6,16}$/, "请填写6-16位字符,不能包含空格"]
  19004. , accept: function (element, params) {
  19005. if (!params) return true;
  19006. var ext = params[0],
  19007. value = $(element).val();
  19008. return (ext === '*') ||
  19009. (new RegExp(".(?:" + ext + ")$", "i")).test(value) ||
  19010. this.renderMsg("只接受{1}后缀的文件", ext.replace(/\|/g, ','));
  19011. }
  19012. },
  19013. // Default error messages
  19014. messages: {
  19015. 0: "此处",
  19016. fallback: "{0}格式不正确",
  19017. loading: "正在验证...",
  19018. error: "网络异常",
  19019. timeout: "请求超时",
  19020. required: "{0}不能为空",
  19021. remote: "{0}已被使用",
  19022. integer: {
  19023. '*': "请填写整数",
  19024. '+': "请填写正整数",
  19025. '+0': "请填写正整数或0",
  19026. '-': "请填写负整数",
  19027. '-0': "请填写负整数或0"
  19028. },
  19029. match: {
  19030. eq: "{0}与{1}不一致",
  19031. neq: "{0}与{1}不能相同",
  19032. lt: "{0}必须小于{1}",
  19033. gt: "{0}必须大于{1}",
  19034. lte: "{0}不能大于{1}",
  19035. gte: "{0}不能小于{1}"
  19036. },
  19037. range: {
  19038. rg: "请填写{1}到{2}的数",
  19039. gte: "请填写不小于{1}的数",
  19040. lte: "请填写最大{1}的数",
  19041. gtlt: "请填写{1}到{2}之间的数",
  19042. gt: "请填写大于{1}的数",
  19043. lt: "请填写小于{1}的数"
  19044. },
  19045. checked: {
  19046. eq: "请选择{1}项",
  19047. rg: "请选择{1}到{2}项",
  19048. gte: "请至少选择{1}项",
  19049. lte: "请最多选择{1}项"
  19050. },
  19051. length: {
  19052. eq: "请填写{1}个字符",
  19053. rg: "请填写{1}到{2}个字符",
  19054. gte: "请至少填写{1}个字符",
  19055. lte: "请最多填写{1}个字符",
  19056. eq_2: "",
  19057. rg_2: "",
  19058. gte_2: "",
  19059. lte_2: ""
  19060. }
  19061. }
  19062. });
  19063. /* Themes
  19064. */
  19065. var TPL_ARROW = '<span class="n-arrow"><b>◆</b><i>◆</i></span>';
  19066. $.validator.setTheme({
  19067. 'simple_right': {
  19068. formClass: 'n-simple',
  19069. msgClass: 'n-right'
  19070. },
  19071. 'simple_bottom': {
  19072. formClass: 'n-simple',
  19073. msgClass: 'n-bottom'
  19074. },
  19075. 'yellow_top': {
  19076. formClass: 'n-yellow',
  19077. msgClass: 'n-top',
  19078. msgArrow: TPL_ARROW
  19079. },
  19080. 'yellow_right': {
  19081. formClass: 'n-yellow',
  19082. msgClass: 'n-right',
  19083. msgArrow: TPL_ARROW
  19084. },
  19085. 'yellow_right_effect': {
  19086. formClass: 'n-yellow',
  19087. msgClass: 'n-right',
  19088. msgArrow: TPL_ARROW,
  19089. msgShow: function ($msgbox, type) {
  19090. var $el = $msgbox.children();
  19091. if ($el.is(':animated')) return;
  19092. if (type === 'error') {
  19093. $el.css({left: '20px', opacity: 0})
  19094. .delay(100).show().stop()
  19095. .animate({left: '-4px', opacity: 1}, 150)
  19096. .animate({left: '3px'}, 80)
  19097. .animate({left: 0}, 80);
  19098. } else {
  19099. $el.css({left: 0, opacity: 1}).fadeIn(200);
  19100. }
  19101. },
  19102. msgHide: function ($msgbox, type) {
  19103. var $el = $msgbox.children();
  19104. $el.stop().delay(100).show()
  19105. .animate({left: '20px', opacity: 0}, 300, function () {
  19106. $msgbox.hide();
  19107. });
  19108. }
  19109. }
  19110. });
  19111. }));
  19112. define('form', ['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], function ($, undefined, Upload, Validator, undefined) {
  19113. var Form = {
  19114. config: {
  19115. fieldlisttpl: '<dd class="form-inline"><input type="text" name="<%=name%>[<%=index%>][key]" class="form-control" value="<%=row.key%>" size="10" /> <input type="text" name="<%=name%>[<%=index%>][value]" class="form-control" value="<%=row.value%>" /> <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>'
  19116. },
  19117. events: {
  19118. validator: function (form, success, error, submit) {
  19119. if (!form.is("form"))
  19120. return;
  19121. //绑定表单事件
  19122. form.validator($.extend({
  19123. validClass: 'has-success',
  19124. invalidClass: 'has-error',
  19125. bindClassTo: '.form-group',
  19126. formClass: 'n-default n-bootstrap',
  19127. msgClass: 'n-right',
  19128. stopOnError: true,
  19129. display: function (elem) {
  19130. return $(elem).closest('.form-group').find(".control-label").text().replace(/\:/, '');
  19131. },
  19132. dataFilter: function (data) {
  19133. if (data.code === 1) {
  19134. return data.msg ? {"ok": data.msg} : '';
  19135. } else {
  19136. return data.msg;
  19137. }
  19138. },
  19139. target: function (input) {
  19140. var target = $(input).data("target");
  19141. if (target && $(target).size() > 0) {
  19142. return $(target);
  19143. }
  19144. var $formitem = $(input).closest('.form-group'),
  19145. $msgbox = $formitem.find('span.msg-box');
  19146. if (!$msgbox.length) {
  19147. return [];
  19148. }
  19149. return $msgbox;
  19150. },
  19151. valid: function (ret) {
  19152. var that = this, submitBtn = $(".layer-footer [type=submit]", form);
  19153. that.holdSubmit(true);
  19154. submitBtn.addClass("disabled");
  19155. //验证通过提交表单
  19156. var submitResult = Form.api.submit($(ret), function (data, ret) {
  19157. that.holdSubmit(false);
  19158. submitBtn.removeClass("disabled");
  19159. if (false === $(this).triggerHandler("success.form", [data, ret])) {
  19160. return false;
  19161. }
  19162. if (typeof success === 'function') {
  19163. if (false === success.call($(this), data, ret)) {
  19164. return false;
  19165. }
  19166. }
  19167. //提示及关闭当前窗口
  19168. var msg = ret.hasOwnProperty("msg") && ret.msg !== "" ? ret.msg : __('Operation completed');
  19169. parent.Toastr.success(msg);
  19170. parent.$(".btn-refresh").trigger("click");
  19171. var index = parent.Layer.getFrameIndex(window.name);
  19172. parent.Layer.close(index);
  19173. return false;
  19174. }, function (data, ret) {
  19175. that.holdSubmit(false);
  19176. if (false === $(this).triggerHandler("error.form", [data, ret])) {
  19177. return false;
  19178. }
  19179. submitBtn.removeClass("disabled");
  19180. if (typeof error === 'function') {
  19181. if (false === error.call($(this), data, ret)) {
  19182. return false;
  19183. }
  19184. }
  19185. }, submit);
  19186. //如果提交失败则释放锁定
  19187. if (!submitResult) {
  19188. that.holdSubmit(false);
  19189. submitBtn.removeClass("disabled");
  19190. }
  19191. return false;
  19192. }
  19193. }, form.data("validator-options") || {}));
  19194. //移除提交按钮的disabled类
  19195. $(".layer-footer [type=submit],.fixed-footer [type=submit],.normal-footer [type=submit]", form).removeClass("disabled");
  19196. //自定义关闭按钮事件
  19197. form.on("click", ".layer-close", function () {
  19198. var index = parent.Layer.getFrameIndex(window.name);
  19199. parent.Layer.close(index);
  19200. return false;
  19201. });
  19202. },
  19203. selectpicker: function (form) {
  19204. //绑定select元素事件
  19205. if ($(".selectpicker", form).size() > 0) {
  19206. require(['bootstrap-select', 'bootstrap-select-lang'], function () {
  19207. $('.selectpicker', form).selectpicker();
  19208. $(form).on("reset", function () {
  19209. setTimeout(function () {
  19210. $('.selectpicker').selectpicker('refresh').trigger("change");
  19211. }, 1);
  19212. });
  19213. });
  19214. }
  19215. },
  19216. selectpage: function (form) {
  19217. //绑定selectpage元素事件
  19218. if ($(".selectpage", form).size() > 0) {
  19219. require(['selectpage'], function () {
  19220. $('.selectpage', form).selectPage({
  19221. eAjaxSuccess: function (data) {
  19222. data.list = typeof data.rows !== 'undefined' ? data.rows : (typeof data.list !== 'undefined' ? data.list : []);
  19223. data.totalRow = typeof data.total !== 'undefined' ? data.total : (typeof data.totalRow !== 'undefined' ? data.totalRow : data.list.length);
  19224. return data;
  19225. }
  19226. });
  19227. });
  19228. //给隐藏的元素添加上validate验证触发事件
  19229. $(document).on("change", ".sp_hidden", function () {
  19230. $(this).trigger("validate");
  19231. });
  19232. $(document).on("change", ".sp_input", function () {
  19233. $(this).closest(".sp_container").find(".sp_hidden").trigger("change");
  19234. });
  19235. $(form).on("reset", function () {
  19236. setTimeout(function () {
  19237. $('.selectpage', form).selectPageClear();
  19238. }, 1);
  19239. });
  19240. }
  19241. },
  19242. cxselect: function (form) {
  19243. //绑定cxselect元素事件
  19244. if ($("[data-toggle='cxselect']", form).size() > 0) {
  19245. require(['cxselect'], function () {
  19246. $.cxSelect.defaults.jsonName = 'name';
  19247. $.cxSelect.defaults.jsonValue = 'value';
  19248. $.cxSelect.defaults.jsonSpace = 'data';
  19249. $("[data-toggle='cxselect']", form).cxSelect();
  19250. });
  19251. }
  19252. },
  19253. citypicker: function (form) {
  19254. //绑定城市远程插件
  19255. if ($("[data-toggle='city-picker']", form).size() > 0) {
  19256. require(['citypicker'], function () {
  19257. $(form).on("reset", function () {
  19258. setTimeout(function () {
  19259. $("[data-toggle='city-picker']").citypicker('refresh');
  19260. }, 1);
  19261. });
  19262. });
  19263. }
  19264. },
  19265. datetimepicker: function (form) {
  19266. //绑定日期时间元素事件
  19267. if ($(".datetimepicker", form).size() > 0) {
  19268. require(['bootstrap-datetimepicker'], function () {
  19269. var options = {
  19270. format: 'YYYY-MM-DD HH:mm:ss',
  19271. icons: {
  19272. time: 'fa fa-clock-o',
  19273. date: 'fa fa-calendar',
  19274. up: 'fa fa-chevron-up',
  19275. down: 'fa fa-chevron-down',
  19276. previous: 'fa fa-chevron-left',
  19277. next: 'fa fa-chevron-right',
  19278. today: 'fa fa-history',
  19279. clear: 'fa fa-trash',
  19280. close: 'fa fa-remove'
  19281. },
  19282. showTodayButton: true,
  19283. showClose: true
  19284. };
  19285. $('.datetimepicker', form).parent().css('position', 'relative');
  19286. $('.datetimepicker', form).datetimepicker(options).on('dp.change', function (e) {
  19287. $(this, document).trigger("changed");
  19288. });
  19289. });
  19290. }
  19291. },
  19292. daterangepicker: function (form) {
  19293. //绑定日期时间元素事件
  19294. if ($(".datetimerange", form).size() > 0) {
  19295. require(['bootstrap-daterangepicker'], function () {
  19296. var ranges = {};
  19297. ranges[__('Today')] = [Moment().startOf('day'), Moment().endOf('day')];
  19298. ranges[__('Yesterday')] = [Moment().subtract(1, 'days').startOf('day'), Moment().subtract(1, 'days').endOf('day')];
  19299. ranges[__('Last 7 Days')] = [Moment().subtract(6, 'days').startOf('day'), Moment().endOf('day')];
  19300. ranges[__('Last 30 Days')] = [Moment().subtract(29, 'days').startOf('day'), Moment().endOf('day')];
  19301. ranges[__('This Month')] = [Moment().startOf('month'), Moment().endOf('month')];
  19302. ranges[__('Last Month')] = [Moment().subtract(1, 'month').startOf('month'), Moment().subtract(1, 'month').endOf('month')];
  19303. var options = {
  19304. timePicker: false,
  19305. autoUpdateInput: false,
  19306. timePickerSeconds: true,
  19307. timePicker24Hour: true,
  19308. autoApply: true,
  19309. locale: {
  19310. format: 'YYYY-MM-DD HH:mm:ss',
  19311. customRangeLabel: __("Custom Range"),
  19312. applyLabel: __("Apply"),
  19313. cancelLabel: __("Clear"),
  19314. },
  19315. ranges: ranges,
  19316. };
  19317. var origincallback = function (start, end) {
  19318. $(this.element).val(start.format(this.locale.format) + " - " + end.format(this.locale.format));
  19319. $(this.element).trigger('blur');
  19320. };
  19321. $(".datetimerange", form).each(function () {
  19322. var callback = typeof $(this).data('callback') == 'function' ? $(this).data('callback') : origincallback;
  19323. $(this).on('apply.daterangepicker', function (ev, picker) {
  19324. callback.call(picker, picker.startDate, picker.endDate);
  19325. });
  19326. $(this).on('cancel.daterangepicker', function (ev, picker) {
  19327. $(this).val('').trigger('blur');
  19328. });
  19329. $(this).daterangepicker($.extend(true, options, $(this).data()), callback);
  19330. });
  19331. });
  19332. }
  19333. },
  19334. /**
  19335. * 绑定上传事件
  19336. * @param form
  19337. * @deprecated Use faupload instead.
  19338. */
  19339. plupload: function (form) {
  19340. Form.events.faupload(form);
  19341. },
  19342. /**
  19343. * 绑定上传事件
  19344. * @param form
  19345. */
  19346. faupload: function (form) {
  19347. //绑定上传元素事件
  19348. if ($(".plupload,.faupload", form).size() > 0) {
  19349. Upload.api.upload($(".plupload,.faupload", form));
  19350. }
  19351. },
  19352. faselect: function (form) {
  19353. //绑定fachoose选择附件事件
  19354. if ($(".faselect,.fachoose", form).size() > 0) {
  19355. $(".faselect,.fachoose", form).off('click').on('click', function () {
  19356. var that = this;
  19357. var multiple = $(this).data("multiple") ? $(this).data("multiple") : false;
  19358. var mimetype = $(this).data("mimetype") ? $(this).data("mimetype") : '';
  19359. var admin_id = $(this).data("admin-id") ? $(this).data("admin-id") : '';
  19360. var user_id = $(this).data("user-id") ? $(this).data("user-id") : '';
  19361. var url = $(this).data("url") ? $(this).data("url") : (typeof Backend !== 'undefined' ? "general/attachment/select" : "user/attachment");
  19362. parent.Fast.api.open(url + "?element_id=" + $(this).attr("id") + "&multiple=" + multiple + "&mimetype=" + mimetype + "&admin_id=" + admin_id + "&user_id=" + user_id, __('Choose'), {
  19363. callback: function (data) {
  19364. var button = $("#" + $(that).attr("id"));
  19365. var maxcount = $(button).data("maxcount");
  19366. var input_id = $(button).data("input-id") ? $(button).data("input-id") : "";
  19367. maxcount = typeof maxcount !== "undefined" ? maxcount : 0;
  19368. if (input_id && data.multiple) {
  19369. var urlArr = [];
  19370. var inputObj = $("#" + input_id);
  19371. var value = $.trim(inputObj.val());
  19372. if (value !== "") {
  19373. urlArr.push(inputObj.val());
  19374. }
  19375. urlArr.push(data.url)
  19376. var result = urlArr.join(",");
  19377. if (maxcount > 0) {
  19378. var nums = value === '' ? 0 : value.split(/\,/).length;
  19379. var files = data.url !== "" ? data.url.split(/\,/) : [];
  19380. var remains = maxcount - nums;
  19381. if (files.length > remains) {
  19382. Toastr.error(__('You can choose up to %d file%s', remains));
  19383. return false;
  19384. }
  19385. }
  19386. inputObj.val(result).trigger("change").trigger("validate");
  19387. } else {
  19388. $("#" + input_id).val(data.url).trigger("change").trigger("validate");
  19389. }
  19390. }
  19391. });
  19392. return false;
  19393. });
  19394. }
  19395. },
  19396. fieldlist: function (form) {
  19397. //绑定fieldlist
  19398. if ($(".fieldlist", form).size() > 0) {
  19399. require(['dragsort', 'template'], function (undefined, Template) {
  19400. //刷新隐藏textarea的值
  19401. var refresh = function (name) {
  19402. var data = {};
  19403. var textarea = $("textarea[name='" + name + "']", form);
  19404. var container = $(".fieldlist[data-name='" + name + "']");
  19405. var template = container.data("template");
  19406. $.each($("input,select,textarea", container).serializeArray(), function (i, j) {
  19407. var reg = /\[(\w+)\]\[(\w+)\]$/g;
  19408. var match = reg.exec(j.name);
  19409. if (!match)
  19410. return true;
  19411. match[1] = "x" + parseInt(match[1]);
  19412. if (typeof data[match[1]] == 'undefined') {
  19413. data[match[1]] = {};
  19414. }
  19415. data[match[1]][match[2]] = j.value;
  19416. });
  19417. var result = template ? [] : {};
  19418. $.each(data, function (i, j) {
  19419. if (j) {
  19420. if (!template) {
  19421. if (j.key != '') {
  19422. result[j.key] = j.value;
  19423. }
  19424. } else {
  19425. result.push(j);
  19426. }
  19427. }
  19428. });
  19429. textarea.val(JSON.stringify(result));
  19430. };
  19431. //监听文本框改变事件
  19432. $(document).on('change keyup changed', ".fieldlist input,.fieldlist textarea,.fieldlist select", function () {
  19433. refresh($(this).closest(".fieldlist").data("name"));
  19434. });
  19435. //追加控制
  19436. $(".fieldlist", form).on("click", ".btn-append,.append", function (e, row) {
  19437. var container = $(this).closest(".fieldlist");
  19438. var tagName = container.data("tag") || (container.is("table") ? "tr" : "dd");
  19439. var index = container.data("index");
  19440. var name = container.data("name");
  19441. var template = container.data("template");
  19442. var data = container.data();
  19443. index = index ? parseInt(index) : 0;
  19444. container.data("index", index + 1);
  19445. row = row ? row : {};
  19446. var vars = {index: index, name: name, data: data, row: row};
  19447. var html = template ? Template(template, vars) : Template.render(Form.config.fieldlisttpl, vars);
  19448. $(html).attr("fieldlist-item", true).insertBefore($(tagName + ":last", container));
  19449. $(this).trigger("fa.event.appendfieldlist", $(this).closest(tagName).prev());
  19450. });
  19451. //移除控制
  19452. $(".fieldlist", form).on("click", ".btn-remove", function () {
  19453. var container = $(this).closest(".fieldlist");
  19454. var tagName = container.data("tag") || (container.is("table") ? "tr" : "dd");
  19455. $(this).closest(tagName).remove();
  19456. refresh(container.data("name"));
  19457. });
  19458. //渲染数据&拖拽排序
  19459. $(".fieldlist", form).each(function () {
  19460. var container = this;
  19461. var tagName = $(this).data("tag") || ($(this).is("table") ? "tr" : "dd");
  19462. $(this).dragsort({
  19463. itemSelector: tagName,
  19464. dragSelector: ".btn-dragsort",
  19465. dragEnd: function () {
  19466. refresh($(this).closest(".fieldlist").data("name"));
  19467. },
  19468. placeHolderTemplate: $("<" + tagName + "/>")
  19469. });
  19470. var textarea = $("textarea[name='" + $(this).data("name") + "']", form);
  19471. if (textarea.val() == '') {
  19472. return true;
  19473. }
  19474. var template = $(this).data("template");
  19475. textarea.on("fa.event.refreshfieldlist", function () {
  19476. $("[fieldlist-item]", container).remove();
  19477. var json = {};
  19478. try {
  19479. json = JSON.parse($(this).val());
  19480. } catch (e) {
  19481. }
  19482. $.each(json, function (i, j) {
  19483. $(".btn-append,.append", container).trigger('click', template ? j : {
  19484. key: i, value: j
  19485. });
  19486. });
  19487. });
  19488. textarea.trigger("fa.event.refreshfieldlist");
  19489. });
  19490. });
  19491. }
  19492. },
  19493. switcher: function (form) {
  19494. form.on("click", "[data-toggle='switcher']", function () {
  19495. if ($(this).hasClass("disabled")) {
  19496. return false;
  19497. }
  19498. var switcher = $.proxy(function () {
  19499. var input = $(this).prev("input");
  19500. input = $(this).data("input-id") ? $("#" + $(this).data("input-id")) : input;
  19501. if (input.size() > 0) {
  19502. var yes = $(this).data("yes");
  19503. var no = $(this).data("no");
  19504. if (input.val() == yes) {
  19505. input.val(no);
  19506. $("i", this).addClass("fa-flip-horizontal text-gray");
  19507. } else {
  19508. input.val(yes);
  19509. $("i", this).removeClass("fa-flip-horizontal text-gray");
  19510. }
  19511. input.trigger('change');
  19512. }
  19513. }, this);
  19514. if (typeof $(this).data("confirm") !== 'undefined') {
  19515. Layer.confirm($(this).data("confirm"), function (index) {
  19516. switcher();
  19517. Layer.close(index);
  19518. });
  19519. } else {
  19520. switcher();
  19521. }
  19522. return false;
  19523. });
  19524. },
  19525. bindevent: function (form) {
  19526. },
  19527. slider: function (form) {
  19528. if ($(".slider", form).size() > 0) {
  19529. require(['bootstrap-slider'], function () {
  19530. $('.slider').removeClass('hidden').css('width', function (index, value) {
  19531. return $(this).parents('.form-control').width();
  19532. }).slider().on('slide', function (ev) {
  19533. var data = $(this).data();
  19534. if (typeof data.unit !== 'undefined') {
  19535. $(this).parents('.form-control').siblings('.value').text(ev.value + data.unit);
  19536. }
  19537. });
  19538. });
  19539. }
  19540. }
  19541. },
  19542. api: {
  19543. submit: function (form, success, error, submit) {
  19544. if (form.size() === 0) {
  19545. Toastr.error("表单未初始化完成,无法提交");
  19546. return false;
  19547. }
  19548. if (typeof submit === 'function') {
  19549. if (false === submit.call(form, success, error)) {
  19550. return false;
  19551. }
  19552. }
  19553. var type = form.attr("method") ? form.attr("method").toUpperCase() : 'GET';
  19554. type = type && (type === 'GET' || type === 'POST') ? type : 'GET';
  19555. url = form.attr("action");
  19556. url = url ? url : location.href;
  19557. //修复当存在多选项元素时提交的BUG
  19558. var params = {};
  19559. var multipleList = $("[name$='[]']", form);
  19560. if (multipleList.size() > 0) {
  19561. var postFields = form.serializeArray().map(function (obj) {
  19562. return $(obj).prop("name");
  19563. });
  19564. $.each(multipleList, function (i, j) {
  19565. if (postFields.indexOf($(this).prop("name")) < 0) {
  19566. params[$(this).prop("name")] = '';
  19567. }
  19568. });
  19569. }
  19570. //调用Ajax请求方法
  19571. Fast.api.ajax({
  19572. type: type,
  19573. url: url,
  19574. data: form.serialize() + (Object.keys(params).length > 0 ? '&' + $.param(params) : ''),
  19575. dataType: 'json',
  19576. complete: function (xhr) {
  19577. var token = xhr.getResponseHeader('__token__');
  19578. if (token) {
  19579. $("input[name='__token__']").val(token);
  19580. }
  19581. }
  19582. }, function (data, ret) {
  19583. $('.form-group', form).removeClass('has-feedback has-success has-error');
  19584. if (data && typeof data === 'object') {
  19585. //刷新客户端token
  19586. if (typeof data.token !== 'undefined') {
  19587. $("input[name='__token__']").val(data.token);
  19588. }
  19589. //调用客户端事件
  19590. if (typeof data.callback !== 'undefined' && typeof data.callback === 'function') {
  19591. data.callback.call(form, data);
  19592. }
  19593. }
  19594. if (typeof success === 'function') {
  19595. if (false === success.call(form, data, ret)) {
  19596. return false;
  19597. }
  19598. }
  19599. }, function (data, ret) {
  19600. if (data && typeof data === 'object' && typeof data.token !== 'undefined') {
  19601. $("input[name='__token__']").val(data.token);
  19602. }
  19603. if (typeof error === 'function') {
  19604. if (false === error.call(form, data, ret)) {
  19605. return false;
  19606. }
  19607. }
  19608. });
  19609. return true;
  19610. },
  19611. bindevent: function (form, success, error, submit) {
  19612. form = typeof form === 'object' ? form : $(form);
  19613. var events = Form.events;
  19614. events.bindevent(form);
  19615. events.validator(form, success, error, submit);
  19616. events.selectpicker(form);
  19617. events.daterangepicker(form);
  19618. events.selectpage(form);
  19619. events.cxselect(form);
  19620. events.citypicker(form);
  19621. events.datetimepicker(form);
  19622. events.faupload(form);
  19623. events.faselect(form);
  19624. events.fieldlist(form);
  19625. events.slider(form);
  19626. events.switcher(form);
  19627. },
  19628. custom: {}
  19629. },
  19630. };
  19631. return Form;
  19632. });
  19633. /**
  19634. * FastAdmin通用搜索
  19635. *
  19636. * @author: pppscn <35696959@qq.com>
  19637. * @update 2017-05-07 <https://gitee.com/pp/fastadmin>
  19638. *
  19639. * @author: Karson <karsonzhang@163.com>
  19640. * @update 2018-04-05 <https://gitee.com/karson/fastadmin>
  19641. */
  19642. !function ($) {
  19643. 'use strict';
  19644. var ColumnsForSearch = [];
  19645. var sprintf = $.fn.bootstrapTable.utils.sprintf;
  19646. var initCommonSearch = function (pColumns, that) {
  19647. var vFormCommon = createFormCommon(pColumns, that);
  19648. var vModal = sprintf("<div class=\"commonsearch-table %s\">", that.options.searchFormVisible ? "" : "hidden");
  19649. vModal += vFormCommon;
  19650. vModal += "</div>";
  19651. that.$container.prepend($(vModal));
  19652. that.$commonsearch = $(".commonsearch-table", that.$container);
  19653. var form = $("form.form-commonsearch", that.$commonsearch);
  19654. require(['form'], function (Form) {
  19655. Form.api.bindevent(form);
  19656. form.validator("destroy");
  19657. });
  19658. // 表单提交
  19659. form.on("submit", function (event) {
  19660. event.preventDefault();
  19661. that.onCommonSearch();
  19662. return false;
  19663. });
  19664. // 重置搜索
  19665. form.on("click", "button[type=reset]", function (event) {
  19666. form[0].reset();
  19667. setTimeout(function () {
  19668. that.onCommonSearch();
  19669. }, 0);
  19670. });
  19671. };
  19672. var createFormCommon = function (pColumns, that) {
  19673. // 如果有使用模板则直接返回模板的内容
  19674. if (that.options.searchFormTemplate) {
  19675. return Template(that.options.searchFormTemplate, {columns: pColumns, table: that});
  19676. }
  19677. var htmlForm = [];
  19678. htmlForm.push(sprintf('<form class="form-horizontal form-commonsearch" novalidate method="post" action="%s" >', that.options.actionForm));
  19679. htmlForm.push('<fieldset>');
  19680. if (that.options.titleForm.length > 0)
  19681. htmlForm.push(sprintf("<legend>%s</legend>", that.options.titleForm));
  19682. htmlForm.push('<div class="row">');
  19683. for (var i in pColumns) {
  19684. var vObjCol = pColumns[i];
  19685. if (!vObjCol.checkbox && vObjCol.field !== 'operate' && vObjCol.searchable && vObjCol.operate !== false) {
  19686. var query = Fast.api.query(vObjCol.field);
  19687. var operate = Fast.api.query(vObjCol.field + "-operate");
  19688. var renderDefault = that.options.renderDefault && (typeof vObjCol.renderDefault == 'undefined' || vObjCol.renderDefault);
  19689. vObjCol.defaultValue = renderDefault && query ? query : (typeof vObjCol.defaultValue === 'undefined' ? '' : vObjCol.defaultValue);
  19690. vObjCol.operate = renderDefault && operate ? operate : (typeof vObjCol.operate === 'undefined' ? '=' : vObjCol.operate);
  19691. ColumnsForSearch.push(vObjCol);
  19692. htmlForm.push('<div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">');
  19693. htmlForm.push(sprintf('<label for="%s" class="control-label col-xs-4">%s</label>', vObjCol.field, vObjCol.title));
  19694. htmlForm.push('<div class="col-xs-8">');
  19695. vObjCol.operate = vObjCol.operate ? vObjCol.operate.toUpperCase() : '=';
  19696. 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));
  19697. var addClass = typeof vObjCol.addClass === 'undefined' ? (typeof vObjCol.addclass === 'undefined' ? 'form-control' : 'form-control ' + vObjCol.addclass) : 'form-control ' + vObjCol.addClass;
  19698. var extend = typeof vObjCol.extend === 'undefined' ? '' : vObjCol.extend;
  19699. var style = typeof vObjCol.style === 'undefined' ? '' : sprintf('style="%s"', vObjCol.style);
  19700. extend = typeof vObjCol.data !== 'undefined' && extend == '' ? vObjCol.data : extend;
  19701. extend = typeof vObjCol.autocomplete !== 'undefined' ? extend + ' autocomplete="' + (vObjCol.autocomplete === false || vObjCol.autocomplete === 'off' ? 'off' : 'on') + '"' : extend;
  19702. if (vObjCol.searchList) {
  19703. if (typeof vObjCol.searchList === 'function') {
  19704. htmlForm.push(vObjCol.searchList.call(this, vObjCol));
  19705. } else {
  19706. var optionList = [sprintf('<option value="">%s</option>', that.options.formatCommonChoose())];
  19707. if (typeof vObjCol.searchList === 'object' && typeof vObjCol.searchList.then === 'function') {
  19708. (function (vObjCol, that) {
  19709. $.when(vObjCol.searchList).done(function (ret) {
  19710. var searchList = [];
  19711. if (ret.data && ret.data.searchlist && $.isArray(ret.data.searchlist)) {
  19712. searchList = ret.data.searchlist;
  19713. } else if (ret.constructor === Array || ret.constructor === Object) {
  19714. searchList = ret;
  19715. }
  19716. var optionList = createOptionList(searchList, vObjCol, that);
  19717. $("form.form-commonsearch select[name='" + vObjCol.field + "']", that.$container).html(optionList.join('')).trigger("change");
  19718. });
  19719. })(vObjCol, that);
  19720. } else {
  19721. optionList = createOptionList(vObjCol.searchList, vObjCol, that);
  19722. }
  19723. htmlForm.push(sprintf('<select class="%s" name="%s" %s %s>%s</select>', addClass, vObjCol.field, style, extend, optionList.join('')));
  19724. }
  19725. } else {
  19726. var placeholder = typeof vObjCol.placeholder === 'undefined' ? vObjCol.title : vObjCol.placeholder;
  19727. var type = typeof vObjCol.type === 'undefined' ? 'text' : vObjCol.type;
  19728. var defaultValue = typeof vObjCol.defaultValue === 'undefined' ? '' : vObjCol.defaultValue;
  19729. if (/BETWEEN$/.test(vObjCol.operate)) {
  19730. var defaultValueArr = defaultValue.toString().match(/\|/) ? defaultValue.split('|') : ['', ''];
  19731. var placeholderArr = placeholder.toString().match(/\|/) ? placeholder.split('|') : [placeholder, placeholder];
  19732. htmlForm.push('<div class="row row-between">');
  19733. 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));
  19734. 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));
  19735. htmlForm.push('</div>');
  19736. } else {
  19737. 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));
  19738. }
  19739. }
  19740. htmlForm.push('</div>');
  19741. htmlForm.push('</div>');
  19742. }
  19743. }
  19744. htmlForm.push('<div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">');
  19745. htmlForm.push(createFormBtn(that).join(''));
  19746. htmlForm.push('</div>');
  19747. htmlForm.push('</div>');
  19748. htmlForm.push('</fieldset>');
  19749. htmlForm.push('</form>');
  19750. return htmlForm.join('');
  19751. };
  19752. var createFormBtn = function (that) {
  19753. var htmlBtn = [];
  19754. var searchSubmit = that.options.formatCommonSubmitButton();
  19755. var searchReset = that.options.formatCommonResetButton();
  19756. htmlBtn.push('<div class="col-sm-8 col-xs-offset-4">');
  19757. htmlBtn.push(sprintf('<button type="submit" class="btn btn-success" formnovalidate>%s</button> ', searchSubmit));
  19758. htmlBtn.push(sprintf('<button type="reset" class="btn btn-default" >%s</button> ', searchReset));
  19759. htmlBtn.push('</div>');
  19760. return htmlBtn;
  19761. };
  19762. var createOptionList = function (searchList, vObjCol, that) {
  19763. var isArray = searchList.constructor === Array;
  19764. var optionList = [];
  19765. optionList.push(sprintf('<option value="">%s</option>', that.options.formatCommonChoose()));
  19766. $.each(searchList, function (key, value) {
  19767. if (value.constructor === Object) {
  19768. key = value.id;
  19769. value = value.name;
  19770. } else {
  19771. key = isArray ? value : key;
  19772. }
  19773. optionList.push(sprintf("<option value='" + key + "' %s>" + value + "</option>", key == vObjCol.defaultValue ? 'selected' : ''));
  19774. });
  19775. return optionList;
  19776. };
  19777. var isSearchAvailble = function (that) {
  19778. //只支持服务端搜索
  19779. if (!that.options.commonSearch || that.options.sidePagination != 'server' || !that.options.url) {
  19780. return false;
  19781. }
  19782. return true;
  19783. };
  19784. var getSearchQuery = function (that, removeempty) {
  19785. var op = {};
  19786. var filter = {};
  19787. var value = '';
  19788. $("form.form-commonsearch .operate", that.$commonsearch).each(function (i) {
  19789. var name = $(this).data("name");
  19790. var sym = $(this).is("select") ? $("option:selected", this).val() : $(this).val().toUpperCase();
  19791. var obj = $("[name='" + name + "']", that.$commonsearch);
  19792. if (obj.size() == 0)
  19793. return true;
  19794. var vObjCol = ColumnsForSearch[i];
  19795. var process = !that.options.searchFormTemplate && vObjCol && typeof vObjCol.process == 'function' ? vObjCol.process : null;
  19796. if (obj.size() > 1) {
  19797. if (/BETWEEN$/.test(sym)) {
  19798. var value_begin = $.trim($("[name='" + name + "']:first", that.$commonsearch).val()),
  19799. value_end = $.trim($("[name='" + name + "']:last", that.$commonsearch).val());
  19800. if (value_begin.length || value_end.length) {
  19801. if (process) {
  19802. value_begin = process(value_begin, 'begin');
  19803. value_end = process(value_end, 'end');
  19804. }
  19805. value = value_begin + ',' + value_end;
  19806. } else {
  19807. value = '';
  19808. }
  19809. //如果是时间筛选,将operate置为RANGE
  19810. if ($("[name='" + name + "']:first", that.$commonsearch).hasClass("datetimepicker")) {
  19811. sym = 'RANGE';
  19812. }
  19813. } else {
  19814. value = $("[name='" + name + "']:checked", that.$commonsearch).val();
  19815. value = process ? process(value) : value;
  19816. }
  19817. } else {
  19818. value = process ? process(obj.val()) : obj.val();
  19819. }
  19820. if (removeempty && (value == '' || value == null || ($.isArray(value) && value.length == 0)) && !sym.match(/null/i)) {
  19821. return true;
  19822. }
  19823. op[name] = sym;
  19824. filter[name] = value;
  19825. });
  19826. return {op: op, filter: filter};
  19827. };
  19828. var getQueryParams = function (params, searchQuery, removeempty) {
  19829. params.filter = typeof params.filter === 'Object' ? params.filter : (params.filter ? JSON.parse(params.filter) : {});
  19830. params.op = typeof params.op === 'Object' ? params.op : (params.op ? JSON.parse(params.op) : {});
  19831. params.filter = $.extend({}, params.filter, searchQuery.filter);
  19832. params.op = $.extend({}, params.op, searchQuery.op);
  19833. //移除empty的值
  19834. if (removeempty) {
  19835. $.each(params.filter, function (i, j) {
  19836. if ((j == '' || j == null || ($.isArray(j) && j.length == 0)) && !params.op[i].match(/null/i)) {
  19837. delete params.filter[i];
  19838. delete params.op[i];
  19839. }
  19840. });
  19841. }
  19842. params.filter = JSON.stringify(params.filter);
  19843. params.op = JSON.stringify(params.op);
  19844. return params;
  19845. };
  19846. $.extend($.fn.bootstrapTable.defaults, {
  19847. commonSearch: false,
  19848. titleForm: "Common search",
  19849. actionForm: "",
  19850. searchFormTemplate: "",
  19851. searchFormVisible: true,
  19852. searchClass: 'searchit',
  19853. showSearch: true,
  19854. renderDefault: true,
  19855. onCommonSearch: function (field, text) {
  19856. return false;
  19857. },
  19858. onPostCommonSearch: function (table) {
  19859. return false;
  19860. }
  19861. });
  19862. $.extend($.fn.bootstrapTable.defaults.icons, {
  19863. commonSearchIcon: 'glyphicon-search'
  19864. });
  19865. $.extend($.fn.bootstrapTable.Constructor.EVENTS, {
  19866. 'common-search.bs.table': 'onCommonSearch',
  19867. 'post-common-search.bs.table': 'onPostCommonSearch'
  19868. });
  19869. $.extend($.fn.bootstrapTable.locales[$.fn.bootstrapTable.defaults.locale], {
  19870. formatCommonSearch: function () {
  19871. return "Common search";
  19872. },
  19873. formatCommonSubmitButton: function () {
  19874. return "Submit";
  19875. },
  19876. formatCommonResetButton: function () {
  19877. return "Reset";
  19878. },
  19879. formatCommonCloseButton: function () {
  19880. return "Close";
  19881. },
  19882. formatCommonChoose: function () {
  19883. return "Choose";
  19884. }
  19885. });
  19886. $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);
  19887. var BootstrapTable = $.fn.bootstrapTable.Constructor,
  19888. _initHeader = BootstrapTable.prototype.initHeader,
  19889. _initToolbar = BootstrapTable.prototype.initToolbar,
  19890. _load = BootstrapTable.prototype.load,
  19891. _initSearch = BootstrapTable.prototype.initSearch;
  19892. BootstrapTable.prototype.initHeader = function () {
  19893. _initHeader.apply(this, Array.prototype.slice.apply(arguments));
  19894. this.$header.find('th[data-field]').each(function (i) {
  19895. var column = $(this).data();
  19896. if (typeof column['width'] !== 'undefined' && column['width'].toString().indexOf("%") === -1) {
  19897. $(".th-inner", this).outerWidth(column['width']);
  19898. $(this).css("max-width", column['width']);
  19899. }
  19900. });
  19901. this.options.stateField = this.header.stateField;
  19902. };
  19903. BootstrapTable.prototype.initToolbar = function () {
  19904. _initToolbar.apply(this, Array.prototype.slice.apply(arguments));
  19905. if (!isSearchAvailble(this)) {
  19906. return;
  19907. }
  19908. var that = this,
  19909. html = [];
  19910. if (that.options.showSearch) {
  19911. html.push(sprintf('<div class="columns-%s pull-%s" style="margin-top:10px;margin-bottom:10px;">', this.options.buttonsAlign, this.options.buttonsAlign));
  19912. html.push(sprintf('<button class="btn btn-default%s' + '" type="button" name="commonSearch" title="%s">', that.options.iconSize === undefined ? '' : ' btn-' + that.options.iconSize, that.options.formatCommonSearch()));
  19913. html.push(sprintf('<i class="%s %s"></i>', that.options.iconsPrefix, that.options.icons.commonSearchIcon))
  19914. html.push('</button></div>');
  19915. }
  19916. if (that.$toolbar.find(".pull-right").size() > 0) {
  19917. $(html.join('')).insertBefore(that.$toolbar.find(".pull-right:first"));
  19918. } else {
  19919. that.$toolbar.append(html.join(''));
  19920. }
  19921. initCommonSearch(that.columns, that);
  19922. that.$toolbar.find('button[name="commonSearch"]')
  19923. .off('click').on('click', function () {
  19924. that.$commonsearch.toggleClass("hidden");
  19925. return;
  19926. });
  19927. that.$container.on("click", "." + that.options.searchClass, function () {
  19928. var value = $(this).data("value");
  19929. var field = $(this).data("field");
  19930. var ul = that.$container.closest(".panel-intro").find("ul[data-field='" + field + "']");
  19931. if (ul.length > 0) {
  19932. $('li a[data-value="' + value + '"][data-toggle="tab"]', ul).trigger('click');
  19933. return;
  19934. }
  19935. var obj = $("form [name='" + field + "']", that.$commonsearch);
  19936. if (obj.size() > 0) {
  19937. if (obj.is("select")) {
  19938. $("option[value='" + value + "']", obj).prop("selected", true);
  19939. } else if (obj.size() > 1) {
  19940. $("form [name='" + field + "'][value='" + value + "']", that.$commonsearch).prop("checked", true);
  19941. } else {
  19942. obj.val(value + "");
  19943. }
  19944. obj.trigger("change");
  19945. $("form", that.$commonsearch).trigger("submit");
  19946. }
  19947. });
  19948. var queryParams = that.options.queryParams;
  19949. //匹配默认搜索值
  19950. this.options.queryParams = function (params) {
  19951. return queryParams(getQueryParams(params, getSearchQuery(that, true)));
  19952. };
  19953. this.trigger('post-common-search', that);
  19954. };
  19955. BootstrapTable.prototype.onCommonSearch = function () {
  19956. var searchQuery = getSearchQuery(this);
  19957. this.trigger('common-search', this, searchQuery);
  19958. this.options.pageNumber = 1;
  19959. //this.options.pageSize = $.fn.bootstrapTable.defaults.pageSize;
  19960. this.refresh({});
  19961. };
  19962. BootstrapTable.prototype.load = function (data) {
  19963. _load.apply(this, Array.prototype.slice.apply(arguments));
  19964. if (!isSearchAvailble(this)) {
  19965. return;
  19966. }
  19967. };
  19968. BootstrapTable.prototype.initSearch = function () {
  19969. _initSearch.apply(this, Array.prototype.slice.apply(arguments));
  19970. if (!isSearchAvailble(this)) {
  19971. return;
  19972. }
  19973. var that = this;
  19974. var fp = $.isEmptyObject(this.filterColumnsPartial) ? null : this.filterColumnsPartial;
  19975. this.data = fp ? $.grep(this.data, function (item, i) {
  19976. for (var key in fp) {
  19977. var fval = fp[key].toLowerCase();
  19978. var value = item[key];
  19979. value = $.fn.bootstrapTable.utils.calculateObjectValue(that.header,
  19980. that.header.formatters[$.inArray(key, that.header.fields)],
  19981. [value, item, i], value);
  19982. if (!($.inArray(key, that.header.fields) !== -1 &&
  19983. (typeof value === 'string' || typeof value === 'number') &&
  19984. (value + '').toLowerCase().indexOf(fval) !== -1)) {
  19985. return false;
  19986. }
  19987. }
  19988. return true;
  19989. }) : this.data;
  19990. };
  19991. }(jQuery);
  19992. define("bootstrap-table-commonsearch", ["bootstrap-table"], (function (global) {
  19993. return function () {
  19994. var ret, fn;
  19995. return ret || global.$.fn.bootstrapTable.defaults;
  19996. };
  19997. }(this)));
  19998. /**
  19999. * 将BootstrapTable的行使用自定义的模板来渲染
  20000. *
  20001. * @author: karson
  20002. * @version: v0.0.1
  20003. *
  20004. * @update 2017-06-24 <http://github.com/karsonzhang/fastadmin>
  20005. */
  20006. !function ($) {
  20007. 'use strict';
  20008. $.extend($.fn.bootstrapTable.defaults, {
  20009. //是否启用模板渲染
  20010. templateView: false,
  20011. //数据格式化的模板ID或格式函数
  20012. templateFormatter: "itemtpl",
  20013. //添加的父类的class
  20014. templateParentClass: "row row-flex",
  20015. //向table添加的class
  20016. templateTableClass: "table-template",
  20017. });
  20018. var BootstrapTable = $.fn.bootstrapTable.Constructor,
  20019. _initContainer = BootstrapTable.prototype.initContainer,
  20020. _initBody = BootstrapTable.prototype.initBody,
  20021. _initRow = BootstrapTable.prototype.initRow;
  20022. BootstrapTable.prototype.initContainer = function () {
  20023. _initContainer.apply(this, Array.prototype.slice.apply(arguments));
  20024. var that = this;
  20025. if (!that.options.templateView) {
  20026. return;
  20027. }
  20028. that.options.cardView = true;
  20029. };
  20030. BootstrapTable.prototype.initBody = function () {
  20031. var that = this;
  20032. $.extend(that.options, {
  20033. showHeader: !that.options.templateView ? $.fn.bootstrapTable.defaults.showHeader : false,
  20034. showFooter: !that.options.templateView ? $.fn.bootstrapTable.defaults.showFooter : false,
  20035. });
  20036. $(that.$el).toggleClass(that.options.templateTableClass, that.options.templateView);
  20037. _initBody.apply(this, Array.prototype.slice.apply(arguments));
  20038. if (!that.options.templateView) {
  20039. return;
  20040. } else {
  20041. //由于Bootstrap是基于Table的,添加一个父类容器
  20042. $("> *:not(.no-records-found)", that.$body).wrapAll($("<div />").addClass(that.options.templateParentClass));
  20043. }
  20044. };
  20045. BootstrapTable.prototype.initRow = function (item, i, data, parentDom) {
  20046. var that = this;
  20047. //如果未启用则使用原生的initRow方法
  20048. if (!that.options.templateView) {
  20049. return _initRow.apply(that, Array.prototype.slice.apply(arguments));
  20050. }
  20051. var $content = '';
  20052. if (typeof that.options.templateFormatter === 'function') {
  20053. $content = that.options.templateFormatter.call(that, item, i, data);
  20054. } else {
  20055. var Template = require('template');
  20056. $content = Template(that.options.templateFormatter, {item: item, i: i, data: data});
  20057. }
  20058. return $content;
  20059. };
  20060. }(jQuery);
  20061. define("bootstrap-table-template", ["bootstrap-table", "template"], (function (global) {
  20062. return function () {
  20063. var ret, fn;
  20064. return ret || global.$.fn.bootstrapTable.defaults;
  20065. };
  20066. }(this)));
  20067. /**
  20068. * @author Jay <jwang@dizsoft.com>
  20069. */
  20070. (function ($) {
  20071. 'use strict';
  20072. var sprintf = $.fn.bootstrapTable.utils.sprintf;
  20073. $.extend($.fn.bootstrapTable.defaults, {
  20074. showJumpto: false,
  20075. exportOptions: {}
  20076. });
  20077. $.extend($.fn.bootstrapTable.locales, {
  20078. formatJumpto: function () {
  20079. return 'GO';
  20080. }
  20081. });
  20082. $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);
  20083. var BootstrapTable = $.fn.bootstrapTable.Constructor,
  20084. _initPagination = BootstrapTable.prototype.initPagination;
  20085. BootstrapTable.prototype.initPagination = function () {
  20086. this.showToolbar = this.options.showExport;
  20087. _initPagination.apply(this, Array.prototype.slice.apply(arguments));
  20088. if (this.options.showJumpto) {
  20089. var that = this,
  20090. $pageGroup = this.$pagination.find('ul.pagination'),
  20091. $jumpto = $pageGroup.find('li.jumpto');
  20092. if (!$jumpto.length) {
  20093. $jumpto = $([
  20094. '<li class="jumpto">',
  20095. '<input type="text" class="form-control">',
  20096. '<button class="btn' +
  20097. sprintf(' btn-%s', this.options.buttonsClass) +
  20098. sprintf(' btn-%s', this.options.iconSize) +
  20099. '" title="' + this.options.formatJumpto() + '" ' +
  20100. ' type="button">' + this.options.formatJumpto(),
  20101. '</button>',
  20102. '</li>'].join('')).appendTo($pageGroup);
  20103. $jumpto.find('button').click(function () {
  20104. that.selectPage(parseInt($jumpto.find('input').val()));
  20105. });
  20106. }
  20107. }
  20108. };
  20109. })(jQuery);
  20110. define("bootstrap-table-jumpto", ["bootstrap-table"], (function (global) {
  20111. return function () {
  20112. var ret, fn;
  20113. return ret || global.$.fn.bootstrapTable.defaults;
  20114. };
  20115. }(this)));
  20116. (function ($) {
  20117. 'use strict';
  20118. // Reasonable defaults
  20119. var PIXEL_STEP = 10;
  20120. var LINE_HEIGHT = 40;
  20121. var PAGE_HEIGHT = 800;
  20122. function normalizeWheel(event) {
  20123. var sX = 0; // spinX
  20124. var sY = 0; // spinY
  20125. var pX = 0; // pixelX
  20126. var pY = 0; // pixelY
  20127. // Legacy
  20128. if ('detail' in event) {
  20129. sY = event.detail;
  20130. }
  20131. if ('wheelDelta' in event) {
  20132. sY = -event.wheelDelta / 120;
  20133. }
  20134. if ('wheelDeltaY' in event) {
  20135. sY = -event.wheelDeltaY / 120;
  20136. }
  20137. if ('wheelDeltaX' in event) {
  20138. sX = -event.wheelDeltaX / 120;
  20139. }
  20140. // side scrolling on FF with DOMMouseScroll
  20141. if ('axis' in event && event.axis === event.HORIZONTAL_AXIS) {
  20142. sX = sY;
  20143. sY = 0;
  20144. }
  20145. pX = sX * PIXEL_STEP;
  20146. pY = sY * PIXEL_STEP;
  20147. if ('deltaY' in event) {
  20148. pY = event.deltaY;
  20149. }
  20150. if ('deltaX' in event) {
  20151. pX = event.deltaX;
  20152. }
  20153. if ((pX || pY) && event.deltaMode) {
  20154. if (event.deltaMode === 1) {
  20155. // delta in LINE units
  20156. pX *= LINE_HEIGHT;
  20157. pY *= LINE_HEIGHT;
  20158. } else {
  20159. // delta in PAGE units
  20160. pX *= PAGE_HEIGHT;
  20161. pY *= PAGE_HEIGHT;
  20162. }
  20163. }
  20164. // Fall-back if spin cannot be determined
  20165. if (pX && !sX) {
  20166. sX = pX < 1 ? -1 : 1;
  20167. }
  20168. if (pY && !sY) {
  20169. sY = pY < 1 ? -1 : 1;
  20170. }
  20171. return {
  20172. spinX: sX,
  20173. spinY: sY,
  20174. pixelX: pX,
  20175. pixelY: pY
  20176. };
  20177. }
  20178. var cachedWidth = null;
  20179. var getScrollBarWidth = function getScrollBarWidth() {
  20180. if (cachedWidth === null) {
  20181. var inner = $('<p/>').addClass('fixed-table-scroll-inner'),
  20182. outer = $('<div/>').addClass('fixed-table-scroll-outer'),
  20183. w1 = void 0,
  20184. w2 = void 0;
  20185. outer.append(inner);
  20186. $('body').append(outer);
  20187. w1 = inner[0].offsetWidth;
  20188. outer.css('overflow', 'scroll');
  20189. w2 = inner[0].offsetWidth;
  20190. if (w1 === w2) {
  20191. w2 = outer[0].clientWidth;
  20192. }
  20193. outer.remove();
  20194. cachedWidth = w1 - w2;
  20195. }
  20196. return cachedWidth;
  20197. };
  20198. //获取原本表格体的滑块宽度
  20199. var getTableBodyScrollBarWidth = function getTableBodyScrollBarWidth(tableBody) {
  20200. return tableBody[0].scrollHeight > tableBody[0].clientHeight ? 15 : 0;
  20201. };
  20202. $.extend($.fn.bootstrapTable.defaults, {
  20203. fixedColumns: false,
  20204. fixedNumber: 0,
  20205. fixedRightNumber: 0
  20206. });
  20207. var BootstrapTable = $.fn.bootstrapTable.Constructor,
  20208. _initBody = BootstrapTable.prototype.initBody,
  20209. _initContainer = BootstrapTable.prototype.initContainer,
  20210. _trigger = BootstrapTable.prototype.trigger,
  20211. _hideLoading = BootstrapTable.prototype.hideLoading,
  20212. _updateSelected = BootstrapTable.prototype.updateSelected;
  20213. BootstrapTable.prototype.fixedColumnsSupported = function () {
  20214. var that = this;
  20215. return that.options.fixedColumns && !that.options.detailView && !that.options.cardView;
  20216. };
  20217. BootstrapTable.prototype.initFixedContainer = function () {
  20218. if (!this.fixedColumnsSupported()) {
  20219. return;
  20220. }
  20221. if (this.options.fixedNumber) {
  20222. this.$tableContainer.find('.fixed-columns').size() == 0 && this.$tableContainer.append('<div class="fixed-columns"></div>');
  20223. this.$fixedColumns = this.$tableContainer.find('.fixed-columns');
  20224. }
  20225. if (this.options.fixedRightNumber) {
  20226. this.$tableContainer.find('.fixed-columns-right').size() == 0 && this.$tableContainer.append('<div class="fixed-columns-right"></div>');
  20227. this.$fixedColumnsRight = this.$tableContainer.find('.fixed-columns-right');
  20228. }
  20229. };
  20230. BootstrapTable.prototype.initContainer = function () {
  20231. _initContainer.apply(this, Array.prototype.slice.apply(arguments));
  20232. this.initFixedContainer();
  20233. };
  20234. BootstrapTable.prototype.initBody = function () {
  20235. _initBody.apply(this, Array.prototype.slice.apply(arguments));
  20236. if (!this.fixedColumnsSupported()) {
  20237. return;
  20238. }
  20239. if (this.options.showHeader && this.options.height) {
  20240. return;
  20241. }
  20242. this.initFixedColumnsBody();
  20243. this.initFixedColumnsEvents();
  20244. };
  20245. BootstrapTable.prototype.trigger = function () {
  20246. var that = this;
  20247. _trigger.apply(this, Array.prototype.slice.apply(arguments));
  20248. if (arguments[0] === 'pre-body') {
  20249. //如果上来就是cardView 设置表格高度为auto
  20250. if (this.options.cardView) {
  20251. this.$tableBody.css("height", "auto");
  20252. }
  20253. }
  20254. //监听cardView 显示/隐藏fixed部分
  20255. if (arguments[0] === 'toggle') {
  20256. if (arguments[1]) {
  20257. this.$tableBody.css("height", "auto");
  20258. this.$fixedColumns && this.$fixedColumns.hide();
  20259. this.$fixedColumnsRight && this.$fixedColumnsRight.hide();
  20260. } else {
  20261. this.$tableBody.css("height", "100%");
  20262. this.$fixedColumns && this.$fixedColumns.show();
  20263. this.$fixedColumnsRight && this.$fixedColumnsRight.show();
  20264. this.$fixedHeaderRight && this.$fixedHeaderRight.scrollLeft(this.$tableBody.find('table').width());
  20265. this.$fixedBodyRight && this.$fixedBodyRight.scrollLeft(this.$tableBody.find('table').width());
  20266. }
  20267. }
  20268. if (!that.fixedColumnsSupported()) {
  20269. return;
  20270. }
  20271. if (arguments[0] === 'post-header') {
  20272. this.initFixedColumnsHeader();
  20273. } else if (arguments[0] === 'scroll-body') {
  20274. if (this.needFixedColumns && this.options.fixedNumber) {
  20275. this.$fixedBody && this.$fixedBody.scrollTop(this.$tableBody.scrollTop());
  20276. }
  20277. if (this.needFixedColumns && this.options.fixedRightNumber) {
  20278. this.$fixedBodyRight && this.$fixedBodyRight.scrollTop(this.$tableBody.scrollTop());
  20279. }
  20280. } else if (arguments[0] === 'load-success') {
  20281. this.hideLoading();
  20282. }
  20283. };
  20284. BootstrapTable.prototype.updateSelected = function () {
  20285. var that = this;
  20286. _updateSelected.apply(this, Array.prototype.slice.apply(arguments));
  20287. if (!this.fixedColumnsSupported()) {
  20288. return;
  20289. }
  20290. this.$tableBody.find('tr').each(function (i, el) {
  20291. var $el = $(el);
  20292. var index = $el.data('index');
  20293. var classes = $el.attr('class');
  20294. var inputSelector = '[name="' + that.options.selectItemName + '"]';
  20295. var $input = $el.find(inputSelector);
  20296. if (typeof index === 'undefined') {
  20297. return;
  20298. }
  20299. var updateFixedBody = function updateFixedBody($fixedHeader, $fixedBody) {
  20300. var $tr = $fixedBody.find('tr[data-index="' + index + '"]');
  20301. $tr.attr('class', classes);
  20302. if ($input.length) {
  20303. $tr.find(inputSelector).prop('checked', $input.prop('checked'));
  20304. }
  20305. if (that.$selectAll.length) {
  20306. $fixedHeader.add($fixedBody).find('[name="btSelectAll"]').prop('checked', that.$selectAll.prop('checked'));
  20307. }
  20308. };
  20309. if (that.$fixedBody && that.options.fixedNumber) {
  20310. updateFixedBody(that.$fixedHeader, that.$fixedBody);
  20311. }
  20312. if (that.$fixedBodyRight && that.options.fixedRightNumber) {
  20313. updateFixedBody(that.$fixedHeaderRight, that.$fixedBodyRight);
  20314. }
  20315. });
  20316. };
  20317. BootstrapTable.prototype.hideLoading = function () {
  20318. _hideLoading.apply(this, Array.prototype.slice.apply(arguments));
  20319. if (this.needFixedColumns && this.options.fixedNumber) {
  20320. this.$fixedColumns.find('.fixed-table-loading').hide();
  20321. }
  20322. if (this.needFixedColumns && this.options.fixedRightNumber) {
  20323. this.$fixedColumnsRight.find('.fixed-table-loading').hide();
  20324. }
  20325. };
  20326. BootstrapTable.prototype.initFixedColumnsHeader = function () {
  20327. var that = this;
  20328. if (this.options.height) {
  20329. this.needFixedColumns = this.$tableHeader.outerWidth(true) < this.$tableHeader.find('table').outerWidth(true);
  20330. } else {
  20331. this.needFixedColumns = this.$tableBody.outerWidth(true) < this.$tableBody.find('table').outerWidth(true);
  20332. }
  20333. var initFixedHeader = function initFixedHeader($fixedColumns, isRight) {
  20334. $fixedColumns.find('.fixed-table-header').remove();
  20335. $fixedColumns.append(that.$tableHeader.clone(true));
  20336. $fixedColumns.find('.fixed-table-header').css('margin-right', "");
  20337. $fixedColumns.css({
  20338. width: that.getFixedColumnsWidth(isRight)
  20339. });
  20340. return $fixedColumns.find('.fixed-table-header');
  20341. };
  20342. if (this.needFixedColumns && this.options.fixedNumber) {
  20343. this.$fixedHeader = initFixedHeader(this.$fixedColumns);
  20344. this.$fixedHeader.css('margin-right', '');
  20345. } else if (this.$fixedColumns) {
  20346. this.$fixedColumns.html('').css('width', '');
  20347. }
  20348. if (this.needFixedColumns && this.options.fixedRightNumber) {
  20349. this.$fixedHeaderRight = initFixedHeader(this.$fixedColumnsRight, true);
  20350. this.$fixedHeaderRight.scrollLeft(this.$fixedHeaderRight.find('table').width());
  20351. } else if (this.$fixedColumnsRight) {
  20352. this.$fixedColumnsRight.html('').css('width', '');
  20353. }
  20354. this.initFixedColumnsBody();
  20355. this.initFixedColumnsEvents();
  20356. };
  20357. BootstrapTable.prototype.initFixedColumnsBody = function () {
  20358. var that = this;
  20359. var initFixedBody = function initFixedBody($fixedColumns, $fixedHeader) {
  20360. $fixedColumns.find('.fixed-table-body').remove();
  20361. $fixedColumns.append(that.$tableBody.clone(true));
  20362. var $fixedBody = $fixedColumns.find('.fixed-table-body');
  20363. var tableBody = that.$tableBody.get(0);
  20364. var scrollHeight = tableBody.scrollWidth > tableBody.clientWidth ? getScrollBarWidth() : 0;
  20365. var paginationHeight = $(".fixed-table-pagination").height();
  20366. if (typeof that.options.height !== 'undefined') paginationHeight = 0;
  20367. var height = that.$tableContainer.outerHeight(true) - scrollHeight - paginationHeight + 1;
  20368. $fixedColumns.css({
  20369. height: height
  20370. });
  20371. $fixedBody.css({
  20372. height: height - $fixedHeader.height()
  20373. });
  20374. return $fixedBody;
  20375. };
  20376. if (this.needFixedColumns && this.options.fixedNumber) {
  20377. this.$fixedBody = initFixedBody(this.$fixedColumns, this.$fixedHeader);
  20378. }
  20379. if (this.needFixedColumns && this.options.fixedRightNumber) {
  20380. this.$fixedBodyRight = initFixedBody(this.$fixedColumnsRight, this.$fixedHeaderRight);
  20381. this.$fixedBodyRight.scrollLeft(this.$fixedBodyRight.find('table').width());
  20382. this.$fixedBodyRight.css('overflow-y', 'hidden');
  20383. }
  20384. };
  20385. BootstrapTable.prototype.getFixedColumnsWidth = function (isRight) {
  20386. var visibleFields = this.getVisibleFields();
  20387. var width = 0;
  20388. var fixedNumber = this.options.fixedNumber;
  20389. var marginRight = 0;
  20390. if (isRight) {
  20391. visibleFields = visibleFields.reverse();
  20392. fixedNumber = this.options.fixedRightNumber;
  20393. //右侧固定列距离
  20394. this.$fixedColumnsRight.css('right', getTableBodyScrollBarWidth(this.$tableBody));
  20395. }
  20396. for (var i = 0; i < fixedNumber; i++) {
  20397. width += this.$header.find('th[data-field="' + visibleFields[i] + '"]').outerWidth();
  20398. }
  20399. return width + 1;
  20400. };
  20401. BootstrapTable.prototype.initFixedColumnsEvents = function () {
  20402. var that = this;
  20403. var toggleHover = function toggleHover(e, toggle) {
  20404. var tr = 'tr[data-index="' + $(e.currentTarget).data('index') + '"]';
  20405. var $trs = that.$tableBody.find(tr);
  20406. if (that.$fixedBody) {
  20407. $trs = $trs.add(that.$fixedBody.find(tr));
  20408. }
  20409. if (that.$fixedBodyRight) {
  20410. $trs = $trs.add(that.$fixedBodyRight.find(tr));
  20411. }
  20412. $trs.css('background-color', toggle ? $(e.currentTarget).css('background-color') : '');
  20413. };
  20414. this.$tableBody.find('tr').hover(function (e) {
  20415. toggleHover(e, true);
  20416. }, function (e) {
  20417. toggleHover(e, false);
  20418. });
  20419. var isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
  20420. var mousewheel = isFirefox ? 'DOMMouseScroll' : 'mousewheel';
  20421. var updateScroll = function updateScroll(e, fixedBody) {
  20422. var normalized = normalizeWheel(e);
  20423. var deltaY = Math.ceil(normalized.pixelY);
  20424. var top = that.$tableBody.scrollTop() + deltaY;
  20425. if (deltaY < 0 && top > 0 || deltaY > 0 && top < fixedBody.scrollHeight - fixedBody.clientHeight) {
  20426. e.preventDefault();
  20427. }
  20428. that.$tableBody.scrollTop(top);
  20429. if (that.$fixedBody) {
  20430. that.$fixedBody.scrollTop(top);
  20431. }
  20432. if (that.$fixedBodyRight) {
  20433. that.$fixedBodyRight.scrollTop(top);
  20434. }
  20435. };
  20436. if (this.needFixedColumns && this.options.fixedNumber) {
  20437. this.$fixedBody.find('tr').hover(function (e) {
  20438. toggleHover(e, true);
  20439. }, function (e) {
  20440. toggleHover(e, false);
  20441. });
  20442. this.$fixedBody[0].addEventListener(mousewheel, function (e) {
  20443. //给鼠标滑轮绑定事件
  20444. updateScroll(e, that.$fixedBody[0]);
  20445. });
  20446. //给固定表格的checkbox绑定事件
  20447. this.$fixedBody.find('input[name="' + this.options.selectItemName + '"]').off("click").on('click', function (e) {
  20448. e.stopImmediatePropagation();
  20449. var index = $(e.target).data("index");
  20450. $(that.$selectItem[index]).trigger("click");
  20451. });
  20452. //绑定TD点击事件
  20453. this.$fixedBody.find('> table > tbody > tr[data-index] > td').off('click dblclick').on('click dblclick', function (e) {
  20454. var index = $(this).closest("tr[data-index]").data("index");
  20455. $(that.$selectItem[index]).closest("tr[data-index]").find(">td:eq(" + $(this).index() + ")").trigger("click");
  20456. });
  20457. }
  20458. //给原本表格绑定scroll事件
  20459. $('div.fixed-table-body').off('scroll'); //给所有的body解绑 scroll
  20460. this.$tableBody.off('scroll').on('scroll', function (e) {
  20461. that.$tableHeader.scrollLeft(0);
  20462. if (that.$tableBody.scrollLeft() > 0) {
  20463. that.$tableHeader.scrollLeft(that.$tableBody.scrollLeft());
  20464. if (that.options.showFooter && !that.options.cardView) {
  20465. that.$tableFooter.scrollLeft(that.$tableBody.scrollLeft());
  20466. }
  20467. }
  20468. var top = that.$tableBody.scrollTop();
  20469. if (that.$fixedBody) {
  20470. that.$fixedBody.scrollTop(top);
  20471. }
  20472. if (that.$fixedBodyRight) {
  20473. that.$fixedBodyRight.scrollTop(top);
  20474. }
  20475. });
  20476. if (this.needFixedColumns && this.options.fixedRightNumber) {
  20477. this.$fixedBodyRight.find('tr').hover(function (e) {
  20478. toggleHover(e, true);
  20479. }, function (e) {
  20480. toggleHover(e, false);
  20481. });
  20482. this.$fixedBodyRight[0].addEventListener(mousewheel, function (e) {
  20483. //给鼠标滑轮绑定事件
  20484. updateScroll(e, that.$fixedBodyRight[0]);
  20485. });
  20486. //给固定表格的checkbox绑定事件
  20487. this.$fixedBodyRight.find('input[name="' + this.options.selectItemName + '"]').off("click").on('click', function (e) {
  20488. e.stopImmediatePropagation();
  20489. var index = $(e.target).data("index");
  20490. $(that.$selectItem[index]).trigger("click");
  20491. });
  20492. //绑定TD点击事件
  20493. this.$fixedBodyRight.find('> table > tbody > tr[data-index] > td').off('click dblclick').on('click dblclick', function (e) {
  20494. var index = $(this).closest("tr[data-index]").data("index");
  20495. $(that.$selectItem[index]).closest("tr[data-index]").find(">td:eq(" + $(this).index() + ")").trigger("click");
  20496. });
  20497. }
  20498. if (this.options.filterControl) {
  20499. $(this.$fixedColumns).off('keyup change').on('keyup change', function (e) {
  20500. var $target = $(e.target);
  20501. var value = $target.val();
  20502. var field = $target.parents('th').data('field');
  20503. var $coreTh = that.$header.find('th[data-field="' + field + '"]');
  20504. if ($target.is('input')) {
  20505. $coreTh.find('input').val(value);
  20506. } else if ($target.is('select')) {
  20507. var $select = $coreTh.find('select');
  20508. $select.find('option[selected]').removeAttr('selected');
  20509. $select.find('option[value="' + value + '"]').attr('selected', true);
  20510. }
  20511. that.triggerSearch();
  20512. });
  20513. }
  20514. };
  20515. })(jQuery);
  20516. define("bootstrap-table-fixed-columns", ["bootstrap-table"], (function (global) {
  20517. return function () {
  20518. var ret, fn;
  20519. return ret || global.$.fn.bootstrapTable.defaults;
  20520. };
  20521. }(this)));
  20522. define('table', ['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table', 'bootstrap-table-lang', 'bootstrap-table-export', 'bootstrap-table-commonsearch', 'bootstrap-table-template', 'bootstrap-table-jumpto', 'bootstrap-table-fixed-columns'], function ($, undefined, Moment) {
  20523. var Table = {
  20524. list: {},
  20525. // Bootstrap-table 基础配置
  20526. defaults: {
  20527. url: '',
  20528. sidePagination: 'server',
  20529. method: 'get', //请求方法
  20530. toolbar: ".toolbar", //工具栏
  20531. search: true, //是否启用快速搜索
  20532. cache: false,
  20533. commonSearch: true, //是否启用通用搜索
  20534. searchFormVisible: false, //是否始终显示搜索表单
  20535. titleForm: '', //为空则不显示标题,不定义默认显示:普通搜索
  20536. idTable: 'commonTable',
  20537. showExport: true,
  20538. exportDataType: "auto",
  20539. exportTypes: ['json', 'xml', 'csv', 'txt', 'doc', 'excel'],
  20540. exportOptions: {
  20541. fileName: 'export_' + Moment().format("YYYY-MM-DD"),
  20542. preventInjection: false,
  20543. mso: {
  20544. onMsoNumberFormat: function (cell, row, col) {
  20545. return !isNaN($(cell).text()) ? '\\@' : '';
  20546. },
  20547. },
  20548. ignoreColumn: [0, 'operate'] //默认不导出第一列(checkbox)与操作(operate)列
  20549. },
  20550. pageSize: localStorage.getItem("pagesize") || 10,
  20551. pageList: [10, 15, 20, 25, 50, 'All'],
  20552. pagination: true,
  20553. clickToSelect: true, //是否启用点击选中
  20554. dblClickToEdit: true, //是否启用双击编辑
  20555. singleSelect: false, //是否启用单选
  20556. showRefresh: false,
  20557. showJumpto: true,
  20558. locale: Config.language == 'zh-cn' ? 'zh-CN' : 'en-US',
  20559. showToggle: true,
  20560. showColumns: true,
  20561. pk: 'id',
  20562. sortName: 'id',
  20563. sortOrder: 'desc',
  20564. paginationFirstText: __("First"),
  20565. paginationPreText: __("Previous"),
  20566. paginationNextText: __("Next"),
  20567. paginationLastText: __("Last"),
  20568. cardView: false, //卡片视图
  20569. iosCardView: true, //ios卡片视图
  20570. checkOnInit: true, //是否在初始化时判断
  20571. escape: true, //是否对内容进行转义
  20572. fixDropdownPosition: true, //是否修复下拉的定位
  20573. selectedIds: [],
  20574. selectedData: [],
  20575. extend: {
  20576. index_url: '',
  20577. add_url: '',
  20578. edit_url: '',
  20579. del_url: '',
  20580. import_url: '',
  20581. multi_url: '',
  20582. dragsort_url: 'ajax/weigh',
  20583. }
  20584. },
  20585. // Bootstrap-table 列配置
  20586. columnDefaults: {
  20587. align: 'center',
  20588. valign: 'middle',
  20589. },
  20590. config: {
  20591. checkboxtd: 'tbody>tr>td.bs-checkbox',
  20592. toolbar: '.toolbar',
  20593. refreshbtn: '.btn-refresh',
  20594. addbtn: '.btn-add',
  20595. editbtn: '.btn-edit',
  20596. delbtn: '.btn-del',
  20597. importbtn: '.btn-import',
  20598. multibtn: '.btn-multi',
  20599. disabledbtn: '.btn-disabled',
  20600. editonebtn: '.btn-editone',
  20601. restoreonebtn: '.btn-restoreone',
  20602. destroyonebtn: '.btn-destroyone',
  20603. restoreallbtn: '.btn-restoreall',
  20604. destroyallbtn: '.btn-destroyall',
  20605. dragsortfield: 'weigh',
  20606. },
  20607. button: {
  20608. edit: {
  20609. name: 'edit',
  20610. icon: 'fa fa-pencil',
  20611. title: __('Edit'),
  20612. extend: 'data-toggle="tooltip"',
  20613. classname: 'btn btn-xs btn-success btn-editone'
  20614. },
  20615. del: {
  20616. name: 'del',
  20617. icon: 'fa fa-trash',
  20618. title: __('Del'),
  20619. extend: 'data-toggle="tooltip"',
  20620. classname: 'btn btn-xs btn-danger btn-delone'
  20621. },
  20622. dragsort: {
  20623. name: 'dragsort',
  20624. icon: 'fa fa-arrows',
  20625. title: __('Drag to sort'),
  20626. extend: 'data-toggle="tooltip"',
  20627. classname: 'btn btn-xs btn-primary btn-dragsort'
  20628. }
  20629. },
  20630. api: {
  20631. init: function (defaults, columnDefaults, locales) {
  20632. defaults = defaults ? defaults : {};
  20633. columnDefaults = columnDefaults ? columnDefaults : {};
  20634. locales = locales ? locales : {};
  20635. $.fn.bootstrapTable.Constructor.prototype.getSelectItem = function () {
  20636. return this.$selectItem;
  20637. };
  20638. // 写入bootstrap-table默认配置
  20639. $.extend(true, $.fn.bootstrapTable.defaults, Table.defaults, defaults);
  20640. // 写入bootstrap-table column配置
  20641. $.extend($.fn.bootstrapTable.columnDefaults, Table.columnDefaults, columnDefaults);
  20642. // 写入bootstrap-table locale配置
  20643. $.extend($.fn.bootstrapTable.locales[Table.defaults.locale], {
  20644. formatCommonSearch: function () {
  20645. return __('Common search');
  20646. },
  20647. formatCommonSubmitButton: function () {
  20648. return __('Submit');
  20649. },
  20650. formatCommonResetButton: function () {
  20651. return __('Reset');
  20652. },
  20653. formatCommonCloseButton: function () {
  20654. return __('Close');
  20655. },
  20656. formatCommonChoose: function () {
  20657. return __('Choose');
  20658. },
  20659. formatJumpto: function () {
  20660. return __('Go');
  20661. }
  20662. }, locales);
  20663. // 如果是iOS设备则判断是否启用卡片视图
  20664. if ($.fn.bootstrapTable.defaults.iosCardView && navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
  20665. Table.defaults.cardView = true;
  20666. $.fn.bootstrapTable.defaults.cardView = true;
  20667. }
  20668. if (typeof defaults.exportTypes != 'undefined') {
  20669. $.fn.bootstrapTable.defaults.exportTypes = defaults.exportTypes;
  20670. }
  20671. },
  20672. // 绑定事件
  20673. bindevent: function (table) {
  20674. //Bootstrap-table的父元素,包含table,toolbar,pagnation
  20675. var parenttable = table.closest('.bootstrap-table');
  20676. //Bootstrap-table配置
  20677. var options = table.bootstrapTable('getOptions');
  20678. //Bootstrap操作区
  20679. var toolbar = $(options.toolbar, parenttable);
  20680. //跨页提示按钮
  20681. var tipsBtn = $(".btn-selected-tips", parenttable);
  20682. if (tipsBtn.size() === 0) {
  20683. 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);
  20684. }
  20685. //点击提示按钮
  20686. tipsBtn.off("click").on("click", function (e) {
  20687. table.trigger("uncheckbox");
  20688. table.bootstrapTable("refresh");
  20689. });
  20690. //当刷新表格时
  20691. table.on('uncheckbox', function (status, res, e) {
  20692. options.selectedIds = [];
  20693. options.selectedData = [];
  20694. tipsBtn.tooltip('hide');
  20695. tipsBtn.addClass('hide');
  20696. });
  20697. //表格加载出错时
  20698. table.on('load-error.bs.table', function (status, res, e) {
  20699. if (e.status === 0) {
  20700. return;
  20701. }
  20702. Toastr.error(__('Unknown data format'));
  20703. });
  20704. //当加载数据成功时
  20705. table.on('load-success.bs.table', function (e, data) {
  20706. if (typeof data.rows === 'undefined' && typeof data.code != 'undefined') {
  20707. Toastr.error(data.msg);
  20708. }
  20709. });
  20710. //当刷新表格时
  20711. table.on('refresh.bs.table', function (e, settings, data) {
  20712. $(Table.config.refreshbtn, toolbar).find(".fa").addClass("fa-spin");
  20713. });
  20714. //当表格分页变更时
  20715. table.on('page-change.bs.table', function (e, page, pagesize) {
  20716. if (!isNaN(pagesize)) {
  20717. localStorage.setItem("pagesize", pagesize);
  20718. }
  20719. });
  20720. //当执行搜索时
  20721. table.on('search.bs.table common-search.bs.table', function (e, settings, data) {
  20722. table.trigger("uncheckbox");
  20723. });
  20724. if (options.dblClickToEdit) {
  20725. //当双击单元格时
  20726. table.on('dbl-click-row.bs.table', function (e, row, element, field) {
  20727. $(Table.config.editonebtn, element).trigger("click");
  20728. });
  20729. }
  20730. //渲染内容前
  20731. table.on('pre-body.bs.table', function (e, data) {
  20732. if (options.maintainSelected) {
  20733. $.each(data, function (i, row) {
  20734. row[options.stateField] = $.inArray(row[options.pk], options.selectedIds) > -1;
  20735. });
  20736. }
  20737. });
  20738. //当内容渲染完成后
  20739. table.on('post-body.bs.table', function (e, data) {
  20740. $(Table.config.refreshbtn, toolbar).find(".fa").removeClass("fa-spin");
  20741. if ($(Table.config.checkboxtd + ":first", table).find("input[type='checkbox'][data-index]").size() > 0) {
  20742. // 拖拽选择,需要重新绑定事件
  20743. require(['drag', 'drop'], function () {
  20744. var checkboxtd = $(Table.config.checkboxtd, table);
  20745. checkboxtd.drag("start", function (ev, dd) {
  20746. return $('<div class="selection" />').css('opacity', .65).appendTo(document.body);
  20747. }).drag(function (ev, dd) {
  20748. $(dd.proxy).css({
  20749. top: Math.min(ev.pageY, dd.startY),
  20750. left: Math.min(ev.pageX, dd.startX),
  20751. height: Math.abs(ev.pageY - dd.startY),
  20752. width: Math.abs(ev.pageX - dd.startX)
  20753. });
  20754. }).drag("end", function (ev, dd) {
  20755. $(dd.proxy).remove();
  20756. });
  20757. checkboxtd.drop("start", function () {
  20758. Table.api.toggleattr(this);
  20759. }).drop(function () {
  20760. // Table.api.toggleattr(this);
  20761. }).drop("end", function (e) {
  20762. var that = this;
  20763. setTimeout(function () {
  20764. if (e.type === 'mousemove') {
  20765. Table.api.toggleattr(that);
  20766. }
  20767. }, 0);
  20768. });
  20769. $.drop({
  20770. multi: true
  20771. });
  20772. });
  20773. }
  20774. });
  20775. var exportDataType = options.exportDataType;
  20776. // 处理选中筛选框后按钮的状态统一变更
  20777. table.on('check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table post-body.bs.table', function (e) {
  20778. var allIds = [];
  20779. $.each(table.bootstrapTable("getData"), function (i, item) {
  20780. allIds.push(typeof item[options.pk] != 'undefined' ? item[options.pk] : '');
  20781. });
  20782. var selectedIds = Table.api.selectedids(table, true),
  20783. selectedData = Table.api.selecteddata(table, true);
  20784. //开启分页checkbox分页记忆
  20785. if (options.maintainSelected) {
  20786. options.selectedIds = options.selectedIds.filter(function (element, index, self) {
  20787. return $.inArray(element, allIds) === -1;
  20788. }).concat(selectedIds);
  20789. options.selectedData = options.selectedData.filter(function (element, index, self) {
  20790. return $.inArray(element[options.pk], allIds) === -1;
  20791. }).concat(selectedData);
  20792. if (options.selectedIds.length > selectedIds.length) {
  20793. $("b", tipsBtn).text(options.selectedIds.length);
  20794. tipsBtn.removeClass('hide');
  20795. } else {
  20796. tipsBtn.addClass('hide');
  20797. }
  20798. } else {
  20799. options.selectedIds = selectedIds;
  20800. options.selectedData = selectedData;
  20801. }
  20802. //如果导出类型为auto时则自动判断
  20803. if (exportDataType === 'auto') {
  20804. options.exportDataType = selectedIds.length > 0 ? 'selected' : 'all';
  20805. }
  20806. $(Table.config.disabledbtn, toolbar).toggleClass('disabled', !options.selectedIds.length);
  20807. });
  20808. // 绑定TAB事件
  20809. $('.panel-heading [data-field] a[data-toggle="tab"]', table.closest(".panel-intro")).on('shown.bs.tab', function (e) {
  20810. var field = $(this).closest("[data-field]").data("field");
  20811. var value = $(this).data("value");
  20812. var object = $("[name='" + field + "']", table.closest(".bootstrap-table").find(".commonsearch-table"));
  20813. if (object.prop('tagName') == "SELECT") {
  20814. $("option[value='" + value + "']", object).prop("selected", true);
  20815. } else {
  20816. object.val(value);
  20817. }
  20818. table.trigger("uncheckbox");
  20819. table.bootstrapTable('refresh', {pageNumber: 1});
  20820. return false;
  20821. });
  20822. // 修复重置事件
  20823. $("form", table.closest(".bootstrap-table").find(".commonsearch-table")).on('reset', function () {
  20824. setTimeout(function () {
  20825. // $('.panel-heading [data-field] li.active a[data-toggle="tab"]').trigger('shown.bs.tab');
  20826. }, 0);
  20827. $('.panel-heading [data-field] li', table.closest(".panel-intro")).removeClass('active');
  20828. $('.panel-heading [data-field] li:first', table.closest(".panel-intro")).addClass('active');
  20829. });
  20830. // 刷新按钮事件
  20831. toolbar.on('click', Table.config.refreshbtn, function () {
  20832. table.bootstrapTable('refresh');
  20833. });
  20834. // 添加按钮事件
  20835. toolbar.on('click', Table.config.addbtn, function () {
  20836. var ids = Table.api.selectedids(table);
  20837. var url = options.extend.add_url;
  20838. if (url.indexOf("{ids}") !== -1) {
  20839. url = Table.api.replaceurl(url, {ids: ids.length > 0 ? ids.join(",") : 0}, table);
  20840. }
  20841. Fast.api.open(url, $(this).data("original-title") || $(this).attr("title") || __('Add'), $(this).data() || {});
  20842. });
  20843. // 导入按钮事件
  20844. if ($(Table.config.importbtn, toolbar).size() > 0) {
  20845. require(['upload'], function (Upload) {
  20846. Upload.api.upload($(Table.config.importbtn, toolbar), function (data, ret) {
  20847. Fast.api.ajax({
  20848. url: options.extend.import_url,
  20849. data: {file: data.url},
  20850. }, function (data, ret) {
  20851. table.trigger("uncheckbox");
  20852. table.bootstrapTable('refresh');
  20853. });
  20854. });
  20855. });
  20856. }
  20857. // 批量编辑按钮事件
  20858. toolbar.on('click', Table.config.editbtn, function () {
  20859. var that = this;
  20860. var ids = Table.api.selectedids(table);
  20861. if (ids.length > 10) {
  20862. return;
  20863. }
  20864. var title = $(that).data('title') || $(that).attr("title") || __('Edit');
  20865. var data = $(that).data() || {};
  20866. delete data.title;
  20867. //循环弹出多个编辑框
  20868. $.each(Table.api.selecteddata(table), function (index, row) {
  20869. var url = options.extend.edit_url;
  20870. row = $.extend({}, row ? row : {}, {ids: row[options.pk]});
  20871. url = Table.api.replaceurl(url, row, table);
  20872. Fast.api.open(url, typeof title === 'function' ? title.call(table, row) : title, data);
  20873. });
  20874. });
  20875. //清空回收站
  20876. $(document).on('click', Table.config.destroyallbtn, function () {
  20877. var that = this;
  20878. Layer.confirm(__('Are you sure you want to truncate?'), function () {
  20879. var url = $(that).data("url") ? $(that).data("url") : $(that).attr("href");
  20880. Fast.api.ajax(url, function () {
  20881. Layer.closeAll();
  20882. table.trigger("uncheckbox");
  20883. table.bootstrapTable('refresh');
  20884. }, function () {
  20885. Layer.closeAll();
  20886. });
  20887. });
  20888. return false;
  20889. });
  20890. //全部还原
  20891. $(document).on('click', Table.config.restoreallbtn, function () {
  20892. var that = this;
  20893. var url = $(that).data("url") ? $(that).data("url") : $(that).attr("href");
  20894. Fast.api.ajax(url, function () {
  20895. Layer.closeAll();
  20896. table.trigger("uncheckbox");
  20897. table.bootstrapTable('refresh');
  20898. }, function () {
  20899. Layer.closeAll();
  20900. });
  20901. return false;
  20902. });
  20903. //销毁或删除
  20904. $(document).on('click', Table.config.restoreonebtn + ',' + Table.config.destroyonebtn, function () {
  20905. var that = this;
  20906. var url = $(that).data("url") ? $(that).data("url") : $(that).attr("href");
  20907. var row = Fast.api.getrowbyindex(table, $(that).data("row-index"));
  20908. Fast.api.ajax({
  20909. url: url,
  20910. data: {ids: row[options.pk]}
  20911. }, function () {
  20912. table.trigger("uncheckbox");
  20913. table.bootstrapTable('refresh');
  20914. });
  20915. return false;
  20916. });
  20917. // 批量操作按钮事件
  20918. toolbar.on('click', Table.config.multibtn, function () {
  20919. var ids = Table.api.selectedids(table);
  20920. Table.api.multi($(this).data("action"), ids, table, this);
  20921. });
  20922. // 批量删除按钮事件
  20923. toolbar.on('click', Table.config.delbtn, function () {
  20924. var that = this;
  20925. var ids = Table.api.selectedids(table);
  20926. Layer.confirm(
  20927. __('Are you sure you want to delete the %s selected item?', ids.length),
  20928. {icon: 3, title: __('Warning'), offset: 0, shadeClose: true, btn: [__('OK'), __('Cancel')]},
  20929. function (index) {
  20930. Table.api.multi("del", ids, table, that);
  20931. Layer.close(index);
  20932. }
  20933. );
  20934. });
  20935. // 拖拽排序
  20936. require(['dragsort'], function () {
  20937. //绑定拖动排序
  20938. $("tbody", table).dragsort({
  20939. itemSelector: 'tr:visible',
  20940. dragSelector: "a.btn-dragsort",
  20941. dragEnd: function (a, b) {
  20942. var element = $("a.btn-dragsort", this);
  20943. var data = table.bootstrapTable('getData');
  20944. var current = data[parseInt($(this).data("index"))];
  20945. var options = table.bootstrapTable('getOptions');
  20946. //改变的值和改变的ID集合
  20947. var ids = $.map($("tbody tr:visible", table), function (tr) {
  20948. return data[parseInt($(tr).data("index"))][options.pk];
  20949. });
  20950. var changeid = current[options.pk];
  20951. var pid = typeof current.pid != 'undefined' ? current.pid : '';
  20952. var params = {
  20953. url: table.bootstrapTable('getOptions').extend.dragsort_url,
  20954. data: {
  20955. ids: ids.join(','),
  20956. changeid: changeid,
  20957. pid: pid,
  20958. field: Table.config.dragsortfield,
  20959. orderway: options.sortOrder,
  20960. table: options.extend.table,
  20961. pk: options.pk
  20962. }
  20963. };
  20964. Fast.api.ajax(params, function (data, ret) {
  20965. var success = $(element).data("success") || $.noop;
  20966. if (typeof success === 'function') {
  20967. if (false === success.call(element, data, ret)) {
  20968. return false;
  20969. }
  20970. }
  20971. table.bootstrapTable('refresh');
  20972. }, function (data, ret) {
  20973. var error = $(element).data("error") || $.noop;
  20974. if (typeof error === 'function') {
  20975. if (false === error.call(element, data, ret)) {
  20976. return false;
  20977. }
  20978. }
  20979. table.bootstrapTable('refresh');
  20980. });
  20981. },
  20982. placeHolderTemplate: ""
  20983. });
  20984. });
  20985. table.on("click", "input[data-id][name='checkbox']", function (e) {
  20986. var ids = $(this).data("id");
  20987. table.bootstrapTable($(this).prop("checked") ? 'checkBy' : 'uncheckBy', {
  20988. field: options.pk,
  20989. values: [ids]
  20990. });
  20991. });
  20992. table.on("click", "[data-id].btn-change", function (e) {
  20993. e.preventDefault();
  20994. var changer = $.proxy(function () {
  20995. Table.api.multi($(this).data("action") ? $(this).data("action") : '', [$(this).data("id")], table, this);
  20996. }, this);
  20997. if (typeof $(this).data("confirm") !== 'undefined') {
  20998. Layer.confirm($(this).data("confirm"), function (index) {
  20999. changer();
  21000. Layer.close(index);
  21001. });
  21002. } else {
  21003. changer();
  21004. }
  21005. });
  21006. table.on("click", "[data-id].btn-edit", function (e) {
  21007. e.preventDefault();
  21008. var ids = $(this).data("id");
  21009. var row = Table.api.getrowbyid(table, ids);
  21010. row.ids = ids;
  21011. var url = Table.api.replaceurl(options.extend.edit_url, row, table);
  21012. Fast.api.open(url, $(this).data("original-title") || $(this).attr("title") || __('Edit'), $(this).data() || {});
  21013. });
  21014. table.on("click", "[data-id].btn-del", function (e) {
  21015. e.preventDefault();
  21016. var id = $(this).data("id");
  21017. var that = this;
  21018. Layer.confirm(
  21019. __('Are you sure you want to delete this item?'),
  21020. {icon: 3, title: __('Warning'), shadeClose: true, btn: [__('OK'), __('Cancel')]},
  21021. function (index) {
  21022. Table.api.multi("del", id, table, that);
  21023. Layer.close(index);
  21024. }
  21025. );
  21026. });
  21027. //修复dropdown定位溢出的情况
  21028. if (options.fixDropdownPosition) {
  21029. var tableBody = table.closest(".fixed-table-body");
  21030. table.on('show.bs.dropdown fa.event.refreshdropdown', ".btn-group", function (e) {
  21031. var dropdownMenu = $(".dropdown-menu", this);
  21032. var btnGroup = $(this);
  21033. var isPullRight = dropdownMenu.hasClass("pull-right") || dropdownMenu.hasClass("dropdown-menu-right");
  21034. var left, top, position;
  21035. if (dropdownMenu.outerHeight() + btnGroup.outerHeight() > tableBody.outerHeight() - 41) {
  21036. position = 'fixed';
  21037. top = btnGroup.offset().top - $(window).scrollTop() + btnGroup.outerHeight();
  21038. left = isPullRight ? btnGroup.offset().left + btnGroup.outerWidth() - dropdownMenu.outerWidth() : btnGroup.offset().left;
  21039. } else {
  21040. if (btnGroup.offset().top + btnGroup.outerHeight() + dropdownMenu.outerHeight() > tableBody.offset().top + tableBody.outerHeight() - 30) {
  21041. position = 'absolute';
  21042. left = isPullRight ? -(dropdownMenu.outerWidth() - btnGroup.outerWidth()) : 0;
  21043. top = -(dropdownMenu.outerHeight() + 3);
  21044. }
  21045. }
  21046. if (left || top) {
  21047. dropdownMenu.css({
  21048. position: position, left: left, top: top, right: 'inherit'
  21049. });
  21050. }
  21051. });
  21052. var checkdropdown = function () {
  21053. if ($(".btn-group.open", table).length > 0 && $(".btn-group.open .dropdown-menu", table).css("position") == 'fixed') {
  21054. $(".btn-group.open", table).trigger("fa.event.refreshdropdown");
  21055. }
  21056. };
  21057. $(window).on("scroll", function () {
  21058. checkdropdown();
  21059. });
  21060. tableBody.on("scroll", function () {
  21061. checkdropdown();
  21062. });
  21063. }
  21064. var id = table.attr("id");
  21065. Table.list[id] = table;
  21066. return table;
  21067. },
  21068. // 批量操作请求
  21069. multi: function (action, ids, table, element) {
  21070. var options = table.bootstrapTable('getOptions');
  21071. var data = element ? $(element).data() : {};
  21072. ids = ($.isArray(ids) ? ids.join(",") : ids);
  21073. var url = typeof data.url !== "undefined" ? data.url : (action == "del" ? options.extend.del_url : options.extend.multi_url);
  21074. var params = typeof data.params !== "undefined" ? (typeof data.params == 'object' ? $.param(data.params) : data.params) : '';
  21075. options = {url: url, data: {action: action, ids: ids, params: params}};
  21076. Fast.api.ajax(options, function (data, ret) {
  21077. table.trigger("uncheckbox");
  21078. var success = $(element).data("success") || $.noop;
  21079. if (typeof success === 'function') {
  21080. if (false === success.call(element, data, ret)) {
  21081. return false;
  21082. }
  21083. }
  21084. table.bootstrapTable('refresh');
  21085. }, function (data, ret) {
  21086. var error = $(element).data("error") || $.noop;
  21087. if (typeof error === 'function') {
  21088. if (false === error.call(element, data, ret)) {
  21089. return false;
  21090. }
  21091. }
  21092. });
  21093. },
  21094. // 单元格元素事件
  21095. events: {
  21096. operate: {
  21097. 'click .btn-editone': function (e, value, row, index) {
  21098. e.stopPropagation();
  21099. e.preventDefault();
  21100. var table = $(this).closest('table');
  21101. var options = table.bootstrapTable('getOptions');
  21102. var ids = row[options.pk];
  21103. row = $.extend({}, row ? row : {}, {ids: ids});
  21104. var url = options.extend.edit_url;
  21105. Fast.api.open(Table.api.replaceurl(url, row, table), $(this).data("original-title") || $(this).attr("title") || __('Edit'), $(this).data() || {});
  21106. },
  21107. 'click .btn-delone': function (e, value, row, index) {
  21108. e.stopPropagation();
  21109. e.preventDefault();
  21110. var that = this;
  21111. var top = $(that).offset().top - $(window).scrollTop();
  21112. var left = $(that).offset().left - $(window).scrollLeft() - 260;
  21113. if (top + 154 > $(window).height()) {
  21114. top = top - 154;
  21115. }
  21116. if ($(window).width() < 480) {
  21117. top = left = undefined;
  21118. }
  21119. Layer.confirm(
  21120. __('Are you sure you want to delete this item?'),
  21121. {
  21122. icon: 3,
  21123. title: __('Warning'),
  21124. offset: [top, left],
  21125. shadeClose: true,
  21126. btn: [__('OK'), __('Cancel')]
  21127. },
  21128. function (index) {
  21129. var table = $(that).closest('table');
  21130. var options = table.bootstrapTable('getOptions');
  21131. Table.api.multi("del", row[options.pk], table, that);
  21132. Layer.close(index);
  21133. }
  21134. );
  21135. }
  21136. },//单元格图片预览
  21137. image: {
  21138. 'click .img-center': function (e, value, row, index) {
  21139. var data = [];
  21140. value = value === null ? '' : value.toString();
  21141. var arr = value != '' ? value.split(",") : [];
  21142. $.each(arr, function (index, value) {
  21143. data.push({
  21144. src: Fast.api.cdnurl(value),
  21145. });
  21146. });
  21147. Layer.photos({
  21148. photos: {
  21149. "start": $(this).parent().index(),
  21150. "data": data
  21151. },
  21152. anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)
  21153. });
  21154. },
  21155. }
  21156. },
  21157. // 单元格数据格式化
  21158. formatter: {
  21159. icon: function (value, row, index) {
  21160. value = value === null ? '' : value.toString();
  21161. value = value.indexOf(" ") > -1 ? value : "fa fa-" + value;
  21162. //渲染fontawesome图标
  21163. return '<i class="' + value + '"></i> ' + value;
  21164. },
  21165. image: function (value, row, index) {
  21166. value = value == null || value.length === 0 ? '' : value.toString();
  21167. value = value ? value : '/assets/img/blank.gif';
  21168. var classname = typeof this.classname !== 'undefined' ? this.classname : 'img-sm img-center';
  21169. return '<a href="javascript:"><img class="' + classname + '" src="' + Fast.api.cdnurl(value) + '" /></a>';
  21170. },
  21171. images: function (value, row, index) {
  21172. value = value == null || value.length === 0 ? '' : value.toString();
  21173. var classname = typeof this.classname !== 'undefined' ? this.classname : 'img-sm img-center';
  21174. var arr = value != '' ? value.split(',') : [];
  21175. var html = [];
  21176. $.each(arr, function (i, value) {
  21177. value = value ? value : '/assets/img/blank.gif';
  21178. html.push('<a href="javascript:"><img class="' + classname + '" src="' + Fast.api.cdnurl(value) + '" /></a>');
  21179. });
  21180. return html.join(' ');
  21181. },
  21182. content: function (value, row, index) {
  21183. var width = this.width != undefined ? (this.width.match(/^\d+$/) ? this.width + "px" : this.width) : "250px";
  21184. return "<div style='white-space: nowrap; text-overflow:ellipsis; overflow: hidden; max-width:" + width + ";'>" + value + "</div>";
  21185. },
  21186. status: function (value, row, index) {
  21187. var custom = {normal: 'success', hidden: 'gray', deleted: 'danger', locked: 'info'};
  21188. if (typeof this.custom !== 'undefined') {
  21189. custom = $.extend(custom, this.custom);
  21190. }
  21191. this.custom = custom;
  21192. this.icon = 'fa fa-circle';
  21193. return Table.api.formatter.normal.call(this, value, row, index);
  21194. },
  21195. normal: function (value, row, index) {
  21196. var colorArr = ["primary", "success", "danger", "warning", "info", "gray", "red", "yellow", "aqua", "blue", "navy", "teal", "olive", "lime", "fuchsia", "purple", "maroon"];
  21197. var custom = {};
  21198. if (typeof this.custom !== 'undefined') {
  21199. custom = $.extend(custom, this.custom);
  21200. }
  21201. value = value == null || value.length === 0 ? '' : value.toString();
  21202. var keys = typeof this.searchList === 'object' ? Object.keys(this.searchList) : [];
  21203. var index = keys.indexOf(value);
  21204. var color = value && typeof custom[value] !== 'undefined' ? custom[value] : null;
  21205. var display = index > -1 ? this.searchList[value] : null;
  21206. var icon = typeof this.icon !== 'undefined' ? this.icon : null;
  21207. if (!color) {
  21208. color = index > -1 && typeof colorArr[index] !== 'undefined' ? colorArr[index] : 'primary';
  21209. }
  21210. if (!display) {
  21211. display = __(value.charAt(0).toUpperCase() + value.slice(1));
  21212. }
  21213. var html = '<span class="text-' + color + '">' + (icon ? '<i class="' + icon + '"></i> ' : '') + display + '</span>';
  21214. if (this.operate != false) {
  21215. html = '<a href="javascript:;" class="searchit" data-toggle="tooltip" title="' + __('Click to search %s', display) + '" data-field="' + this.field + '" data-value="' + value + '">' + html + '</a>';
  21216. }
  21217. return html;
  21218. },
  21219. toggle: function (value, row, index) {
  21220. var table = this.table;
  21221. var options = table ? table.bootstrapTable('getOptions') : {};
  21222. var pk = options.pk || "id";
  21223. var color = typeof this.color !== 'undefined' ? this.color : 'success';
  21224. var yes = typeof this.yes !== 'undefined' ? this.yes : 1;
  21225. var no = typeof this.no !== 'undefined' ? this.no : 0;
  21226. var url = typeof this.url !== 'undefined' ? this.url : '';
  21227. var confirm = '';
  21228. var disable = false;
  21229. if (typeof this.confirm !== "undefined") {
  21230. confirm = typeof this.confirm === "function" ? this.confirm.call(this, value, row, index) : this.confirm;
  21231. }
  21232. if (typeof this.disable !== "undefined") {
  21233. disable = typeof this.disable === "function" ? this.disable.call(this, value, row, index) : this.disable;
  21234. }
  21235. return "<a href='javascript:;' data-toggle='tooltip' title='" + __('Click to toggle') + "' class='btn-change " + (disable ? 'btn disabled no-padding' : '') + "' data-index='" + index + "' data-id='"
  21236. + 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>";
  21237. },
  21238. url: function (value, row, index) {
  21239. value = value == null || value.length === 0 ? '' : value.toString();
  21240. 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>';
  21241. },
  21242. search: function (value, row, index) {
  21243. var field = this.field;
  21244. if (typeof this.customField !== 'undefined' && typeof row[this.customField] !== 'undefined') {
  21245. value = row[this.customField];
  21246. field = this.customField;
  21247. }
  21248. return '<a href="javascript:;" class="searchit" data-toggle="tooltip" title="' + __('Click to search %s', value) + '" data-field="' + field + '" data-value="' + value + '">' + value + '</a>';
  21249. },
  21250. addtabs: function (value, row, index) {
  21251. var url = Table.api.replaceurl(this.url || '', row, this.table);
  21252. var title = this.atitle ? this.atitle : __("Search %s", value);
  21253. return '<a href="' + Fast.api.fixurl(url) + '" class="addtabsit" data-value="' + value + '" title="' + title + '">' + value + '</a>';
  21254. },
  21255. dialog: function (value, row, index) {
  21256. var url = Table.api.replaceurl(this.url || '', row, this.table);
  21257. var title = this.atitle ? this.atitle : __("View %s", value);
  21258. return '<a href="' + Fast.api.fixurl(url) + '" class="dialogit" data-value="' + value + '" title="' + title + '">' + value + '</a>';
  21259. },
  21260. flag: function (value, row, index) {
  21261. var that = this;
  21262. value = value == null || value.length === 0 ? '' : value.toString();
  21263. var colorArr = {index: 'success', hot: 'warning', recommend: 'danger', 'new': 'info'};
  21264. //如果字段列有定义custom
  21265. if (typeof this.custom !== 'undefined') {
  21266. colorArr = $.extend(colorArr, this.custom);
  21267. }
  21268. var field = this.field;
  21269. if (typeof this.customField !== 'undefined' && typeof row[this.customField] !== 'undefined') {
  21270. value = row[this.customField];
  21271. field = this.customField;
  21272. }
  21273. if (typeof that.searchList === 'object' && typeof that.custom === 'undefined') {
  21274. var i = 0;
  21275. var searchValues = Object.values(colorArr);
  21276. $.each(that.searchList, function (key, val) {
  21277. if (typeof colorArr[key] == 'undefined') {
  21278. colorArr[key] = searchValues[i];
  21279. i = typeof searchValues[i + 1] === 'undefined' ? 0 : i + 1;
  21280. }
  21281. });
  21282. }
  21283. //渲染Flag
  21284. var html = [];
  21285. var arr = value != '' ? value.split(',') : [];
  21286. var color, display, label;
  21287. $.each(arr, function (i, value) {
  21288. value = value == null || value.length === 0 ? '' : value.toString();
  21289. if (value == '')
  21290. return true;
  21291. color = value && typeof colorArr[value] !== 'undefined' ? colorArr[value] : 'primary';
  21292. display = typeof that.searchList !== 'undefined' && typeof that.searchList[value] !== 'undefined' ? that.searchList[value] : __(value.charAt(0).toUpperCase() + value.slice(1));
  21293. label = '<span class="label label-' + color + '">' + display + '</span>';
  21294. if (that.operate) {
  21295. html.push('<a href="javascript:;" class="searchit" data-toggle="tooltip" title="' + __('Click to search %s', display) + '" data-field="' + field + '" data-value="' + value + '">' + label + '</a>');
  21296. } else {
  21297. html.push(label);
  21298. }
  21299. });
  21300. return html.join(' ');
  21301. },
  21302. label: function (value, row, index) {
  21303. return Table.api.formatter.flag.call(this, value, row, index);
  21304. },
  21305. datetime: function (value, row, index) {
  21306. var datetimeFormat = typeof this.datetimeFormat === 'undefined' ? 'YYYY-MM-DD HH:mm:ss' : this.datetimeFormat;
  21307. if (isNaN(value)) {
  21308. return value ? Moment(value).format(datetimeFormat) : __('None');
  21309. } else {
  21310. return value ? Moment(parseInt(value) * 1000).format(datetimeFormat) : __('None');
  21311. }
  21312. },
  21313. operate: function (value, row, index) {
  21314. var table = this.table;
  21315. // 操作配置
  21316. var options = table ? table.bootstrapTable('getOptions') : {};
  21317. // 默认按钮组
  21318. var buttons = $.extend([], this.buttons || []);
  21319. // 所有按钮名称
  21320. var names = [];
  21321. buttons.forEach(function (item) {
  21322. names.push(item.name);
  21323. });
  21324. if (options.extend.dragsort_url !== '' && names.indexOf('dragsort') === -1) {
  21325. buttons.push(Table.button.dragsort);
  21326. }
  21327. if (options.extend.edit_url !== '' && names.indexOf('edit') === -1) {
  21328. Table.button.edit.url = options.extend.edit_url;
  21329. buttons.push(Table.button.edit);
  21330. }
  21331. if (options.extend.del_url !== '' && names.indexOf('del') === -1) {
  21332. buttons.push(Table.button.del);
  21333. }
  21334. return Table.api.buttonlink(this, buttons, value, row, index, 'operate');
  21335. }
  21336. ,
  21337. buttons: function (value, row, index) {
  21338. // 默认按钮组
  21339. var buttons = $.extend([], this.buttons || []);
  21340. return Table.api.buttonlink(this, buttons, value, row, index, 'buttons');
  21341. }
  21342. },
  21343. buttonlink: function (column, buttons, value, row, index, type) {
  21344. var table = column.table;
  21345. column.clickToSelect = false;
  21346. type = typeof type === 'undefined' ? 'buttons' : type;
  21347. var options = table ? table.bootstrapTable('getOptions') : {};
  21348. var html = [];
  21349. var hidden, visible, disable, url, classname, icon, text, title, refresh, confirm, extend,
  21350. dropdown, link;
  21351. var fieldIndex = column.fieldIndex;
  21352. var dropdowns = {};
  21353. $.each(buttons, function (i, j) {
  21354. if (type === 'operate') {
  21355. if (j.name === 'dragsort' && typeof row[Table.config.dragsortfield] === 'undefined') {
  21356. return true;
  21357. }
  21358. if (['add', 'edit', 'del', 'multi', 'dragsort'].indexOf(j.name) > -1 && !options.extend[j.name + "_url"]) {
  21359. return true;
  21360. }
  21361. }
  21362. var attr = table.data(type + "-" + j.name);
  21363. if (typeof attr === 'undefined' || attr) {
  21364. hidden = typeof j.hidden === 'function' ? j.hidden.call(table, row, j) : (typeof j.hidden !== 'undefined' ? j.hidden : false);
  21365. if (hidden) {
  21366. return true;
  21367. }
  21368. visible = typeof j.visible === 'function' ? j.visible.call(table, row, j) : (typeof j.visible !== 'undefined' ? j.visible : true);
  21369. if (!visible) {
  21370. return true;
  21371. }
  21372. dropdown = j.dropdown ? j.dropdown : '';
  21373. url = j.url ? j.url : '';
  21374. url = typeof url === 'function' ? url.call(table, row, j) : (url ? Fast.api.fixurl(Table.api.replaceurl(url, row, table)) : 'javascript:;');
  21375. classname = j.classname ? j.classname : 'btn-primary btn-' + name + 'one';
  21376. icon = j.icon ? j.icon : '';
  21377. text = typeof j.text === 'function' ? j.text.call(table, row, j) : j.text ? j.text : '';
  21378. title = typeof j.title === 'function' ? j.title.call(table, row, j) : j.title ? j.title : text;
  21379. refresh = j.refresh ? 'data-refresh="' + j.refresh + '"' : '';
  21380. confirm = typeof j.confirm === 'function' ? j.confirm.call(table, row, j) : (typeof j.confirm !== 'undefined' ? j.confirm : false);
  21381. confirm = confirm ? 'data-confirm="' + confirm + '"' : '';
  21382. extend = j.extend ? j.extend : '';
  21383. disable = typeof j.disable === 'function' ? j.disable.call(table, row, j) : (typeof j.disable !== 'undefined' ? j.disable : false);
  21384. if (disable) {
  21385. classname = classname + ' disabled';
  21386. }
  21387. 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>';
  21388. if (dropdown) {
  21389. if (typeof dropdowns[dropdown] == 'undefined') {
  21390. dropdowns[dropdown] = [];
  21391. }
  21392. dropdowns[dropdown].push(link);
  21393. } else {
  21394. html.push(link);
  21395. }
  21396. }
  21397. });
  21398. if (!$.isEmptyObject(dropdowns)) {
  21399. var dropdownHtml = [];
  21400. $.each(dropdowns, function (i, j) {
  21401. 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>');
  21402. });
  21403. html.unshift(dropdownHtml);
  21404. }
  21405. return html.join(' ');
  21406. },
  21407. //替换URL中的数据
  21408. replaceurl: function (url, row, table) {
  21409. var options = table ? table.bootstrapTable('getOptions') : null;
  21410. var ids = options ? row[options.pk] : 0;
  21411. row.ids = ids ? ids : (typeof row.ids !== 'undefined' ? row.ids : 0);
  21412. url = url == null || url.length === 0 ? '' : url.toString();
  21413. //自动添加ids参数
  21414. url = !url.match(/\{ids\}/i) ? url + (url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + '{ids}' : url;
  21415. url = url.replace(/\{(.*?)\}/gi, function (matched) {
  21416. matched = matched.substring(1, matched.length - 1);
  21417. if (matched.indexOf(".") !== -1) {
  21418. var temp = row;
  21419. var arr = matched.split(/\./);
  21420. for (var i = 0; i < arr.length; i++) {
  21421. if (typeof temp[arr[i]] !== 'undefined') {
  21422. temp = temp[arr[i]];
  21423. }
  21424. }
  21425. return typeof temp === 'object' ? '' : temp;
  21426. }
  21427. return row[matched];
  21428. });
  21429. return url;
  21430. },
  21431. // 获取选中的条目ID集合
  21432. selectedids: function (table, current) {
  21433. var options = table.bootstrapTable('getOptions');
  21434. //如果有设置翻页记忆模式
  21435. if (!current && options.maintainSelected) {
  21436. return options.selectedIds;
  21437. }
  21438. return $.map(table.bootstrapTable('getSelections'), function (row) {
  21439. return row[options.pk];
  21440. });
  21441. },
  21442. //获取选中的数据
  21443. selecteddata: function (table, current) {
  21444. var options = table.bootstrapTable('getOptions');
  21445. //如果有设置翻页记忆模式
  21446. if (!current && options.maintainSelected) {
  21447. return options.selectedData;
  21448. }
  21449. return table.bootstrapTable('getSelections');
  21450. },
  21451. // 切换复选框状态
  21452. toggleattr: function (table) {
  21453. $("input[type='checkbox']", table).trigger('click');
  21454. },
  21455. // 根据行索引获取行数据
  21456. getrowdata: function (table, index) {
  21457. index = parseInt(index);
  21458. var data = table.bootstrapTable('getData');
  21459. return typeof data[index] !== 'undefined' ? data[index] : null;
  21460. },
  21461. // 根据行索引获取行数据
  21462. getrowbyindex: function (table, index) {
  21463. return Table.api.getrowdata(table, index);
  21464. },
  21465. // 根据主键ID获取行数据
  21466. getrowbyid: function (table, id) {
  21467. var row = {};
  21468. var options = table.bootstrapTable("getOptions");
  21469. $.each(Table.api.selecteddata(table), function (i, j) {
  21470. if (j[options.pk] == id) {
  21471. row = j;
  21472. return false;
  21473. }
  21474. });
  21475. return row;
  21476. }
  21477. },
  21478. };
  21479. return Table;
  21480. });
  21481. // jQuery List DragSort v0.5.2
  21482. // Website: http://dragsort.codeplex.com/
  21483. // License: http://dragsort.codeplex.com/license
  21484. (function ($) {
  21485. $.fn.dragsort = function (options) {
  21486. if (options == "destroy") {
  21487. $(this.selector).trigger("dragsort-uninit");
  21488. return;
  21489. }
  21490. var opts = $.extend({}, $.fn.dragsort.defaults, options);
  21491. var lists = [];
  21492. var list = null, lastPos = null;
  21493. this.each(function (i, cont) {
  21494. //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
  21495. if ($(cont).is("table") && $(cont).children().size() == 1 && $(cont).children().is("tbody"))
  21496. cont = $(cont).children().get(0);
  21497. var newList = {
  21498. draggedItem: null,
  21499. placeHolderItem: null,
  21500. pos: null,
  21501. offset: null,
  21502. offsetLimit: null,
  21503. scroll: null,
  21504. container: cont,
  21505. init: function () {
  21506. //set options to default values if not set
  21507. opts.tagName = opts.tagName == "" ? ($(this.container).children().size() == 0 ? "li" : $(this.container).children().get(0).tagName.toLowerCase()) : opts.tagName;
  21508. if (opts.itemSelector == "")
  21509. opts.itemSelector = opts.tagName;
  21510. if (opts.dragSelector == "")
  21511. opts.dragSelector = opts.tagName;
  21512. if (opts.placeHolderTemplate == "")
  21513. opts.placeHolderTemplate = "<" + opts.tagName + ">&nbsp;</" + opts.tagName + ">";
  21514. //listidx allows reference back to correct list variable instance
  21515. $(this.container).attr("data-listidx", i).mousedown(this.grabItem).bind("dragsort-uninit", this.uninit);
  21516. this.styleDragHandlers(true);
  21517. },
  21518. uninit: function () {
  21519. var list = lists[$(this).attr("data-listidx")];
  21520. $(list.container).unbind("mousedown", list.grabItem).unbind("dragsort-uninit");
  21521. list.styleDragHandlers(false);
  21522. },
  21523. getItems: function () {
  21524. return $(this.container).children(opts.itemSelector);
  21525. },
  21526. styleDragHandlers: function (cursor) {
  21527. this.getItems().map(function () {
  21528. return $(this).is(opts.dragSelector) ? this : $(this).find(opts.dragSelector).get();
  21529. }).css("cursor", cursor ? "pointer" : "");
  21530. },
  21531. grabItem: function (e) {
  21532. var list = lists[$(this).attr("data-listidx")];
  21533. var item = $(e.target).closest("[data-listidx] > " + opts.tagName).get(0);
  21534. var insideMoveableItem = list.getItems().filter(function () {
  21535. return this == item;
  21536. }).size() > 0;
  21537. //if not left click or if clicked on excluded element (e.g. text box) or not a moveable list item return
  21538. if (e.which != 1 || $(e.target).is(opts.dragSelectorExclude) || $(e.target).closest(opts.dragSelectorExclude).size() > 0 || !insideMoveableItem)
  21539. return;
  21540. //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,
  21541. //does also stop being able to click text boxes hence dragging on text boxes by default is disabled in dragSelectorExclude
  21542. //e.preventDefault();
  21543. //change cursor to move while dragging
  21544. var dragHandle = e.target;
  21545. while (!$(dragHandle).is(opts.dragSelector)) {
  21546. if (dragHandle == this) return;
  21547. dragHandle = dragHandle.parentNode;
  21548. }
  21549. $(dragHandle).attr("data-cursor", $(dragHandle).css("cursor"));
  21550. $(dragHandle).css("cursor", "move");
  21551. //on mousedown wait for movement of mouse before triggering dragsort script (dragStart) to allow clicking of hyperlinks to work
  21552. var listElem = this;
  21553. var trigger = function () {
  21554. list.dragStart.call(listElem, e);
  21555. $(list.container).unbind("mousemove", trigger);
  21556. };
  21557. $(list.container).mousemove(trigger).mouseup(function () {
  21558. $(list.container).unbind("mousemove", trigger);
  21559. $(dragHandle).css("cursor", $(dragHandle).attr("data-cursor"));
  21560. });
  21561. },
  21562. dragStart: function (e) {
  21563. if (list != null && list.draggedItem != null)
  21564. list.dropItem();
  21565. list = lists[$(this).attr("data-listidx")];
  21566. list.draggedItem = $(e.target).closest("[data-listidx] > " + opts.tagName)
  21567. //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
  21568. list.draggedItem.attr("data-origpos", $(this).attr("data-listidx") + "-" + $(list.container).children().index(list.draggedItem));
  21569. //calculate mouse offset relative to draggedItem
  21570. var mt = parseInt(list.draggedItem.css("marginTop"));
  21571. var ml = parseInt(list.draggedItem.css("marginLeft"));
  21572. list.offset = list.draggedItem.offset();
  21573. list.offset.top = e.pageY - list.offset.top + (isNaN(mt) ? 0 : mt) - 1;
  21574. list.offset.left = e.pageX - list.offset.left + (isNaN(ml) ? 0 : ml) - 1;
  21575. //calculate box the dragged item can't be dragged outside of
  21576. if (!opts.dragBetween) {
  21577. var containerHeight = $(list.container).outerHeight() == 0 ? Math.max(1, Math.round(0.5 + list.getItems().size() * list.draggedItem.outerWidth() / $(list.container).outerWidth())) * list.draggedItem.outerHeight() : $(list.container).outerHeight();
  21578. list.offsetLimit = $(list.container).offset();
  21579. list.offsetLimit.right = list.offsetLimit.left + $(list.container).outerWidth() - list.draggedItem.outerWidth();
  21580. list.offsetLimit.bottom = list.offsetLimit.top + containerHeight - list.draggedItem.outerHeight();
  21581. }
  21582. //create placeholder item
  21583. var h = list.draggedItem.height();
  21584. var w = list.draggedItem.width();
  21585. if (opts.tagName == "tr") {
  21586. list.draggedItem.children().each(function () {
  21587. $(this).width($(this).width());
  21588. });
  21589. list.placeHolderItem = list.draggedItem.clone().attr("data-placeholder", true);
  21590. list.draggedItem.after(list.placeHolderItem);
  21591. //list.placeHolderItem.children().each(function() { $(this).css({ borderWidth:0, width: $(this).width() + 1, height: $(this).height() + 1 }).html("&nbsp;"); });
  21592. list.placeHolderItem.children().each(function () {
  21593. $(this).html("&nbsp;");
  21594. });
  21595. } else {
  21596. list.draggedItem.after(opts.placeHolderTemplate);
  21597. list.placeHolderItem = list.draggedItem.next().css({
  21598. height: h,
  21599. width: w
  21600. }).attr("data-placeholder", true);
  21601. }
  21602. if (opts.tagName == "td") {
  21603. var listTable = list.draggedItem.closest("table").get(0);
  21604. $("<table id='" + listTable.id + "' style='border-width: 0px;' class='dragSortItem " + listTable.className + "'><tr></tr></table>").appendTo("body").children().append(list.draggedItem);
  21605. }
  21606. //style draggedItem while dragging
  21607. var orig = list.draggedItem.attr("style");
  21608. list.draggedItem.attr("data-origstyle", orig ? orig : "");
  21609. list.draggedItem.css({position: "absolute", opacity: 0.8, "z-index": 999, height: h, width: w});
  21610. //auto-scroll setup
  21611. list.scroll = {
  21612. moveX: 0,
  21613. moveY: 0,
  21614. maxX: $(document).width() - $(window).width(),
  21615. maxY: $(document).height() - $(window).height()
  21616. };
  21617. list.scroll.scrollY = window.setInterval(function () {
  21618. if (opts.scrollContainer != window) {
  21619. $(opts.scrollContainer).scrollTop($(opts.scrollContainer).scrollTop() + list.scroll.moveY);
  21620. return;
  21621. }
  21622. var t = $(opts.scrollContainer).scrollTop();
  21623. if (list.scroll.moveY > 0 && t < list.scroll.maxY || list.scroll.moveY < 0 && t > 0) {
  21624. $(opts.scrollContainer).scrollTop(t + list.scroll.moveY);
  21625. list.draggedItem.css("top", list.draggedItem.offset().top + list.scroll.moveY + 1);
  21626. }
  21627. }, 10);
  21628. list.scroll.scrollX = window.setInterval(function () {
  21629. if (opts.scrollContainer != window) {
  21630. $(opts.scrollContainer).scrollLeft($(opts.scrollContainer).scrollLeft() + list.scroll.moveX);
  21631. return;
  21632. }
  21633. var l = $(opts.scrollContainer).scrollLeft();
  21634. if (list.scroll.moveX > 0 && l < list.scroll.maxX || list.scroll.moveX < 0 && l > 0) {
  21635. $(opts.scrollContainer).scrollLeft(l + list.scroll.moveX);
  21636. list.draggedItem.css("left", list.draggedItem.offset().left + list.scroll.moveX + 1);
  21637. }
  21638. }, 10);
  21639. //misc
  21640. $(lists).each(function (i, l) {
  21641. l.createDropTargets();
  21642. l.buildPositionTable();
  21643. });
  21644. list.setPos(e.pageX, e.pageY);
  21645. $(document).bind("mousemove", list.swapItems);
  21646. $(document).bind("mouseup", list.dropItem);
  21647. if (opts.scrollContainer != window)
  21648. $(window).bind("wheel", list.wheel);
  21649. },
  21650. //set position of draggedItem
  21651. setPos: function (x, y) {
  21652. //remove mouse offset so mouse cursor remains in same place on draggedItem instead of top left corner
  21653. var top = y - this.offset.top;
  21654. var left = x - this.offset.left;
  21655. //limit top, left to within box draggedItem can't be dragged outside of
  21656. if (!opts.dragBetween) {
  21657. top = Math.min(this.offsetLimit.bottom, Math.max(top, this.offsetLimit.top));
  21658. left = Math.min(this.offsetLimit.right, Math.max(left, this.offsetLimit.left));
  21659. }
  21660. //adjust top & left calculations to parent offset
  21661. var parent = this.draggedItem.offsetParent().not("body").offset(); //offsetParent returns body even when it's static, if not static offset is only factoring margin
  21662. if (parent != null) {
  21663. top -= parent.top;
  21664. left -= parent.left;
  21665. }
  21666. //set x or y auto-scroll amount
  21667. if (opts.scrollContainer == window) {
  21668. y -= $(window).scrollTop();
  21669. x -= $(window).scrollLeft();
  21670. y = Math.max(0, y - $(window).height() + 5) + Math.min(0, y - 5);
  21671. x = Math.max(0, x - $(window).width() + 5) + Math.min(0, x - 5);
  21672. } else {
  21673. var cont = $(opts.scrollContainer);
  21674. var offset = cont.offset();
  21675. y = Math.max(0, y - cont.height() - offset.top) + Math.min(0, y - offset.top);
  21676. x = Math.max(0, x - cont.width() - offset.left) + Math.min(0, x - offset.left);
  21677. }
  21678. list.scroll.moveX = x == 0 ? 0 : x * opts.scrollSpeed / Math.abs(x);
  21679. list.scroll.moveY = y == 0 ? 0 : y * opts.scrollSpeed / Math.abs(y);
  21680. //move draggedItem to new mouse cursor location
  21681. this.draggedItem.css({top: top, left: left});
  21682. },
  21683. //if scroll container is a div allow mouse wheel to scroll div instead of window when mouse is hovering over
  21684. wheel: function (e) {
  21685. if (list && opts.scrollContainer != window) {
  21686. var cont = $(opts.scrollContainer);
  21687. var offset = cont.offset();
  21688. e = e.originalEvent;
  21689. if (e.clientX > offset.left && e.clientX < offset.left + cont.width() && e.clientY > offset.top && e.clientY < offset.top + cont.height()) {
  21690. var deltaY = (e.deltaMode == 0 ? 1 : 10) * e.deltaY;
  21691. cont.scrollTop(cont.scrollTop() + deltaY);
  21692. e.preventDefault();
  21693. }
  21694. }
  21695. },
  21696. //build a table recording all the positions of the moveable list items
  21697. buildPositionTable: function () {
  21698. var pos = [];
  21699. this.getItems().not([list.draggedItem[0], list.placeHolderItem[0]]).each(function (i) {
  21700. var loc = $(this).offset();
  21701. loc.right = loc.left + $(this).outerWidth();
  21702. loc.bottom = loc.top + $(this).outerHeight();
  21703. loc.elm = this;
  21704. pos[i] = loc;
  21705. });
  21706. this.pos = pos;
  21707. },
  21708. dropItem: function () {
  21709. if (list.draggedItem == null)
  21710. return;
  21711. //list.draggedItem.attr("style", "") doesn't work on IE8 and jQuery 1.5 or lower
  21712. //list.draggedItem.removeAttr("style") doesn't work on chrome and jQuery 1.6 (works jQuery 1.5 or lower)
  21713. var orig = list.draggedItem.attr("data-origstyle");
  21714. list.draggedItem.attr("style", orig);
  21715. if (orig == "")
  21716. list.draggedItem.removeAttr("style");
  21717. list.draggedItem.removeAttr("data-origstyle");
  21718. list.styleDragHandlers(true);
  21719. list.placeHolderItem.before(list.draggedItem);
  21720. list.placeHolderItem.remove();
  21721. $("[data-droptarget], .dragSortItem").remove();
  21722. window.clearInterval(list.scroll.scrollY);
  21723. window.clearInterval(list.scroll.scrollX);
  21724. //if position changed call dragEnd
  21725. if (list.draggedItem.attr("data-origpos") != $(lists).index(list) + "-" + $(list.container).children().index(list.draggedItem))
  21726. if (opts.dragEnd.apply(list.draggedItem) == false) { //if dragEnd returns false revert order
  21727. var pos = list.draggedItem.attr("data-origpos").split('-');
  21728. var nextItem = $(lists[pos[0]].container).children().not(list.draggedItem).eq(pos[1]);
  21729. if (nextItem.size() > 0)
  21730. nextItem.before(list.draggedItem);
  21731. else if (pos[1] == 0) //was the only item in list
  21732. $(lists[pos[0]].container).prepend(list.draggedItem);
  21733. else //was the last item in list
  21734. $(lists[pos[0]].container).append(list.draggedItem);
  21735. }
  21736. list.draggedItem.removeAttr("data-origpos");
  21737. list.draggedItem = null;
  21738. $(document).unbind("mousemove", list.swapItems);
  21739. $(document).unbind("mouseup", list.dropItem);
  21740. if (opts.scrollContainer != window)
  21741. $(window).unbind("wheel", list.wheel);
  21742. return false;
  21743. },
  21744. //swap the draggedItem (represented visually by placeholder) with the list item the it has been dragged on top of
  21745. swapItems: function (e) {
  21746. if (list.draggedItem == null)
  21747. return false;
  21748. //move draggedItem to mouse location
  21749. list.setPos(e.pageX, e.pageY);
  21750. //retrieve list and item position mouse cursor is over
  21751. var ei = list.findPos(e.pageX, e.pageY);
  21752. var nlist = list;
  21753. for (var i = 0; ei == -1 && opts.dragBetween && i < lists.length; i++) {
  21754. ei = lists[i].findPos(e.pageX, e.pageY);
  21755. nlist = lists[i];
  21756. }
  21757. //if not over another moveable list item return
  21758. if (ei == -1)
  21759. return false;
  21760. //save fixed items locations
  21761. var children = function () {
  21762. return $(nlist.container).children().not(nlist.draggedItem);
  21763. };
  21764. var fixed = children().not(opts.itemSelector).each(function (i) {
  21765. this.idx = children().index(this);
  21766. });
  21767. //if moving draggedItem up or left place placeHolder before list item the dragged item is hovering over otherwise place it after
  21768. if (lastPos == null || lastPos.top > list.draggedItem.offset().top || lastPos.left > list.draggedItem.offset().left)
  21769. $(nlist.pos[ei].elm).before(list.placeHolderItem);
  21770. else
  21771. $(nlist.pos[ei].elm).after(list.placeHolderItem);
  21772. //restore fixed items location
  21773. fixed.each(function () {
  21774. var elm = children().eq(this.idx).get(0);
  21775. if (this != elm && children().index(this) < this.idx)
  21776. $(this).insertAfter(elm);
  21777. else if (this != elm)
  21778. $(this).insertBefore(elm);
  21779. });
  21780. //misc
  21781. $(lists).each(function (i, l) {
  21782. l.createDropTargets();
  21783. l.buildPositionTable();
  21784. });
  21785. lastPos = list.draggedItem.offset();
  21786. return false;
  21787. },
  21788. //returns the index of the list item the mouse is over
  21789. findPos: function (x, y) {
  21790. for (var i = 0; i < this.pos.length; i++) {
  21791. if (this.pos[i].left < x && this.pos[i].right > x && this.pos[i].top < y && this.pos[i].bottom > y)
  21792. return i;
  21793. }
  21794. return -1;
  21795. },
  21796. //create drop targets which are placeholders at the end of other lists to allow dragging straight to the last position
  21797. createDropTargets: function () {
  21798. if (!opts.dragBetween)
  21799. return;
  21800. $(lists).each(function () {
  21801. var ph = $(this.container).find("[data-placeholder]");
  21802. var dt = $(this.container).find("[data-droptarget]");
  21803. if (ph.size() > 0 && dt.size() > 0)
  21804. dt.remove();
  21805. else if (ph.size() == 0 && dt.size() == 0) {
  21806. if (opts.tagName == "td")
  21807. $(opts.placeHolderTemplate).attr("data-droptarget", true).appendTo(this.container);
  21808. else
  21809. //list.placeHolderItem.clone().removeAttr("data-placeholder") crashes in IE7 and jquery 1.5.1 (doesn't in jquery 1.4.2 or IE8)
  21810. $(this.container).append(list.placeHolderItem.removeAttr("data-placeholder").clone().attr("data-droptarget", true));
  21811. list.placeHolderItem.attr("data-placeholder", true);
  21812. }
  21813. });
  21814. }
  21815. };
  21816. newList.init();
  21817. lists.push(newList);
  21818. });
  21819. return this;
  21820. };
  21821. $.fn.dragsort.defaults = {
  21822. tagName: "",
  21823. itemSelector: "",
  21824. dragSelector: "",
  21825. dragSelectorExclude: "input, textarea",
  21826. dragEnd: function () {
  21827. },
  21828. dragBetween: false,
  21829. placeHolderTemplate: "",
  21830. scrollContainer: window,
  21831. scrollSpeed: 5
  21832. };
  21833. })(jQuery);
  21834. define("dragsort", function () {
  21835. });
  21836. /*!
  21837. * jquery.event.drag - v 2.2
  21838. * Copyright (c) 2010 Three Dub Media - http://threedubmedia.com
  21839. * Open Source MIT License - http://threedubmedia.com/code/license
  21840. */
  21841. ;(function (e) {
  21842. e.fn.drag = function (k, g, j) {
  21843. var i = typeof k == "string" ? k : "", h = e.isFunction(k) ? k : e.isFunction(g) ? g : null;
  21844. if (i.indexOf("drag") !== 0) {
  21845. i = "drag" + i
  21846. }
  21847. j = (k == h ? g : j) || {};
  21848. return h ? this.bind(i, j, h) : this.trigger(i)
  21849. };
  21850. var b = e.event, a = b.special, d = a.drag = {
  21851. defaults: {which: 1, distance: 0, not: ":input", handle: null, relative: false, drop: true, click: false},
  21852. datakey: "dragdata",
  21853. noBubble: true,
  21854. add: function (i) {
  21855. var h = e.data(this, d.datakey), g = i.data || {};
  21856. h.related += 1;
  21857. e.each(d.defaults, function (j, k) {
  21858. if (g[j] !== undefined) {
  21859. h[j] = g[j]
  21860. }
  21861. })
  21862. },
  21863. remove: function () {
  21864. e.data(this, d.datakey).related -= 1
  21865. },
  21866. setup: function () {
  21867. if (e.data(this, d.datakey)) {
  21868. return
  21869. }
  21870. var g = e.extend({related: 0}, d.defaults);
  21871. e.data(this, d.datakey, g);
  21872. b.add(this, "touchstart mousedown", d.init, g);
  21873. if (this.attachEvent) {
  21874. this.attachEvent("ondragstart", d.dontstart)
  21875. }
  21876. },
  21877. teardown: function () {
  21878. var g = e.data(this, d.datakey) || {};
  21879. if (g.related) {
  21880. return
  21881. }
  21882. e.removeData(this, d.datakey);
  21883. b.remove(this, "touchstart mousedown", d.init);
  21884. d.textselect(true);
  21885. if (this.detachEvent) {
  21886. this.detachEvent("ondragstart", d.dontstart)
  21887. }
  21888. },
  21889. init: function (i) {
  21890. if (d.touched) {
  21891. return
  21892. }
  21893. var g = i.data, h;
  21894. if (i.which != 0 && g.which > 0 && i.which != g.which) {
  21895. return
  21896. }
  21897. if (e(i.target).is(g.not)) {
  21898. return
  21899. }
  21900. if (g.handle && !e(i.target).closest(g.handle, i.currentTarget).length) {
  21901. return
  21902. }
  21903. d.touched = i.type == "touchstart" ? this : null;
  21904. g.propagates = 1;
  21905. g.mousedown = this;
  21906. g.interactions = [d.interaction(this, g)];
  21907. g.target = i.target;
  21908. g.pageX = i.pageX;
  21909. g.pageY = i.pageY;
  21910. g.dragging = null;
  21911. h = d.hijack(i, "draginit", g);
  21912. if (!g.propagates) {
  21913. return
  21914. }
  21915. h = d.flatten(h);
  21916. if (h && h.length) {
  21917. g.interactions = [];
  21918. e.each(h, function () {
  21919. g.interactions.push(d.interaction(this, g))
  21920. })
  21921. }
  21922. g.propagates = g.interactions.length;
  21923. if (g.drop !== false && a.drop) {
  21924. a.drop.handler(i, g)
  21925. }
  21926. d.textselect(false);
  21927. if (d.touched) {
  21928. b.add(d.touched, "touchmove touchend", d.handler, g)
  21929. } else {
  21930. b.add(document, "mousemove mouseup", d.handler, g)
  21931. }
  21932. if (!d.touched || g.live) {
  21933. return false
  21934. }
  21935. },
  21936. interaction: function (h, g) {
  21937. var i = e(h)[g.relative ? "position" : "offset"]() || {top: 0, left: 0};
  21938. return {drag: h, callback: new d.callback(), droppable: [], offset: i}
  21939. },
  21940. handler: function (h) {
  21941. var g = h.data;
  21942. switch (h.type) {
  21943. case !g.dragging && "touchmove":
  21944. h.preventDefault();
  21945. case !g.dragging && "mousemove":
  21946. if (Math.pow(h.pageX - g.pageX, 2) + Math.pow(h.pageY - g.pageY, 2) < Math.pow(g.distance, 2)) {
  21947. break
  21948. }
  21949. h.target = g.target;
  21950. d.hijack(h, "dragstart", g);
  21951. if (g.propagates) {
  21952. g.dragging = true
  21953. }
  21954. case"touchmove":
  21955. h.preventDefault();
  21956. case"mousemove":
  21957. if (g.dragging) {
  21958. d.hijack(h, "drag", g);
  21959. if (g.propagates) {
  21960. if (g.drop !== false && a.drop) {
  21961. a.drop.handler(h, g)
  21962. }
  21963. break
  21964. }
  21965. h.type = "mouseup"
  21966. }
  21967. case"touchend":
  21968. case"mouseup":
  21969. default:
  21970. if (d.touched) {
  21971. b.remove(d.touched, "touchmove touchend", d.handler)
  21972. } else {
  21973. b.remove(document, "mousemove mouseup", d.handler)
  21974. }
  21975. if (g.dragging) {
  21976. if (g.drop !== false && a.drop) {
  21977. a.drop.handler(h, g)
  21978. }
  21979. d.hijack(h, "dragend", g)
  21980. }
  21981. d.textselect(true);
  21982. if (g.click === false && g.dragging) {
  21983. e.data(g.mousedown, "suppress.click", new Date().getTime() + 5)
  21984. }
  21985. g.dragging = d.touched = false;
  21986. break
  21987. }
  21988. },
  21989. hijack: function (h, o, r, p, k) {
  21990. if (!r) {
  21991. return
  21992. }
  21993. var q = {event: h.originalEvent, type: h.type}, m = o.indexOf("drop") ? "drag" : "drop", t, l = p || 0, j,
  21994. g, s, n = !isNaN(p) ? p : r.interactions.length;
  21995. h.type = o;
  21996. h.originalEvent = null;
  21997. r.results = [];
  21998. do {
  21999. if (j = r.interactions[l]) {
  22000. if (o !== "dragend" && j.cancelled) {
  22001. continue
  22002. }
  22003. s = d.properties(h, r, j);
  22004. j.results = [];
  22005. e(k || j[m] || r.droppable).each(function (u, i) {
  22006. s.target = i;
  22007. h.isPropagationStopped = function () {
  22008. return false
  22009. };
  22010. t = i ? b.dispatch.call(i, h, s) : null;
  22011. if (t === false) {
  22012. if (m == "drag") {
  22013. j.cancelled = true;
  22014. r.propagates -= 1
  22015. }
  22016. if (o == "drop") {
  22017. j[m][u] = null
  22018. }
  22019. } else {
  22020. if (o == "dropinit") {
  22021. j.droppable.push(d.element(t) || i)
  22022. }
  22023. }
  22024. if (o == "dragstart") {
  22025. j.proxy = e(d.element(t) || j.drag)[0]
  22026. }
  22027. j.results.push(t);
  22028. delete h.result;
  22029. if (o !== "dropinit") {
  22030. return t
  22031. }
  22032. });
  22033. r.results[l] = d.flatten(j.results);
  22034. if (o == "dropinit") {
  22035. j.droppable = d.flatten(j.droppable)
  22036. }
  22037. if (o == "dragstart" && !j.cancelled) {
  22038. s.update()
  22039. }
  22040. }
  22041. } while (++l < n);
  22042. h.type = q.type;
  22043. h.originalEvent = q.event;
  22044. return d.flatten(r.results)
  22045. },
  22046. properties: function (i, g, h) {
  22047. var j = h.callback;
  22048. j.drag = h.drag;
  22049. j.proxy = h.proxy || h.drag;
  22050. j.startX = g.pageX;
  22051. j.startY = g.pageY;
  22052. j.deltaX = i.pageX - g.pageX;
  22053. j.deltaY = i.pageY - g.pageY;
  22054. j.originalX = h.offset.left;
  22055. j.originalY = h.offset.top;
  22056. j.offsetX = j.originalX + j.deltaX;
  22057. j.offsetY = j.originalY + j.deltaY;
  22058. j.drop = d.flatten((h.drop || []).slice());
  22059. j.available = d.flatten((h.droppable || []).slice());
  22060. return j
  22061. },
  22062. element: function (g) {
  22063. if (g && (g.jquery || g.nodeType == 1)) {
  22064. return g
  22065. }
  22066. },
  22067. flatten: function (g) {
  22068. return e.map(g, function (h) {
  22069. return h && h.jquery ? e.makeArray(h) : h && h.length ? d.flatten(h) : h
  22070. })
  22071. },
  22072. textselect: function (g) {
  22073. e(document)[g ? "unbind" : "bind"]("selectstart", d.dontstart).css("MozUserSelect", g ? "" : "none");
  22074. document.unselectable = g ? "off" : "on"
  22075. },
  22076. dontstart: function () {
  22077. return false
  22078. },
  22079. callback: function () {
  22080. }
  22081. };
  22082. d.callback.prototype = {
  22083. update: function () {
  22084. if (a.drop && this.available.length) {
  22085. e.each(this.available, function (g) {
  22086. a.drop.locate(this, g)
  22087. })
  22088. }
  22089. }
  22090. };
  22091. var f = b.dispatch;
  22092. b.dispatch = function (g) {
  22093. if (e.data(this, "suppress." + g.type) - new Date().getTime() > 0) {
  22094. e.removeData(this, "suppress." + g.type);
  22095. return
  22096. }
  22097. return f.apply(this, arguments)
  22098. };
  22099. var c = b.fixHooks.touchstart = b.fixHooks.touchmove = b.fixHooks.touchend = b.fixHooks.touchcancel = {
  22100. props: "clientX clientY pageX pageY screenX screenY".split(" "),
  22101. filter: function (h, i) {
  22102. if (i) {
  22103. var g = (i.touches && i.touches[0]) || (i.changedTouches && i.changedTouches[0]) || null;
  22104. if (g) {
  22105. e.each(c.props, function (j, k) {
  22106. h[k] = g[k]
  22107. })
  22108. }
  22109. }
  22110. return h
  22111. }
  22112. };
  22113. a.draginit = a.dragstart = a.dragend = d
  22114. })(jQuery);
  22115. define("drag", function () {
  22116. });
  22117. /*!
  22118. * jquery.event.drop - v 2.2
  22119. * Copyright (c) 2010 Three Dub Media - http://threedubmedia.com
  22120. * Open Source MIT License - http://threedubmedia.com/code/license
  22121. */
  22122. ;(function (d) {
  22123. d.fn.drop = function (i, e, h) {
  22124. var g = typeof i == "string" ? i : "", f = d.isFunction(i) ? i : d.isFunction(e) ? e : null;
  22125. if (g.indexOf("drop") !== 0) {
  22126. g = "drop" + g
  22127. }
  22128. h = (i == f ? e : h) || {};
  22129. return f ? this.bind(g, h, f) : this.trigger(g)
  22130. };
  22131. d.drop = function (e) {
  22132. e = e || {};
  22133. b.multi = e.multi === true ? Infinity : e.multi === false ? 1 : !isNaN(e.multi) ? e.multi : b.multi;
  22134. b.delay = e.delay || b.delay;
  22135. b.tolerance = d.isFunction(e.tolerance) ? e.tolerance : e.tolerance === null ? null : b.tolerance;
  22136. b.mode = e.mode || b.mode || "intersect"
  22137. };
  22138. var c = d.event, a = c.special, b = d.event.special.drop = {
  22139. multi: 1, delay: 20, mode: "overlap", targets: [], datakey: "dropdata", noBubble: true, add: function (f) {
  22140. var e = d.data(this, b.datakey);
  22141. e.related += 1
  22142. }, remove: function () {
  22143. d.data(this, b.datakey).related -= 1
  22144. }, setup: function () {
  22145. if (d.data(this, b.datakey)) {
  22146. return
  22147. }
  22148. var e = {related: 0, active: [], anyactive: 0, winner: 0, location: {}};
  22149. d.data(this, b.datakey, e);
  22150. b.targets.push(this);
  22151. return false
  22152. }, teardown: function () {
  22153. var f = d.data(this, b.datakey) || {};
  22154. if (f.related) {
  22155. return
  22156. }
  22157. d.removeData(this, b.datakey);
  22158. var e = this;
  22159. b.targets = d.grep(b.targets, function (g) {
  22160. return (g !== e)
  22161. })
  22162. }, handler: function (g, e) {
  22163. var f, h;
  22164. if (!e) {
  22165. return
  22166. }
  22167. switch (g.type) {
  22168. case"mousedown":
  22169. case"touchstart":
  22170. h = d(b.targets);
  22171. if (typeof e.drop == "string") {
  22172. h = h.filter(e.drop)
  22173. }
  22174. h.each(function () {
  22175. var i = d.data(this, b.datakey);
  22176. i.active = [];
  22177. i.anyactive = 0;
  22178. i.winner = 0
  22179. });
  22180. e.droppable = h;
  22181. a.drag.hijack(g, "dropinit", e);
  22182. break;
  22183. case"mousemove":
  22184. case"touchmove":
  22185. b.event = g;
  22186. if (!b.timer) {
  22187. b.tolerate(e)
  22188. }
  22189. break;
  22190. case"mouseup":
  22191. case"touchend":
  22192. b.timer = clearTimeout(b.timer);
  22193. if (e.propagates) {
  22194. a.drag.hijack(g, "drop", e);
  22195. a.drag.hijack(g, "dropend", e)
  22196. }
  22197. break
  22198. }
  22199. }, locate: function (k, h) {
  22200. var l = d.data(k, b.datakey), g = d(k), i = g.offset() || {}, e = g.outerHeight(), j = g.outerWidth(),
  22201. f = {elem: k, width: j, height: e, top: i.top, left: i.left, right: i.left + j, bottom: i.top + e};
  22202. if (l) {
  22203. l.location = f;
  22204. l.index = h;
  22205. l.elem = k
  22206. }
  22207. return f
  22208. }, contains: function (e, f) {
  22209. 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)
  22210. }, modes: {
  22211. intersect: function (f, e, g) {
  22212. return this.contains(g, [f.pageX, f.pageY]) ? 1000000000 : this.modes.overlap.apply(this, arguments)
  22213. }, overlap: function (f, e, g) {
  22214. 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))
  22215. }, fit: function (f, e, g) {
  22216. return this.contains(g, e) ? 1 : 0
  22217. }, middle: function (f, e, g) {
  22218. return this.contains(g, [e.left + e.width * 0.5, e.top + e.height * 0.5]) ? 1 : 0
  22219. }
  22220. }, sort: function (f, e) {
  22221. return (e.winner - f.winner) || (f.index - e.index)
  22222. }, tolerate: function (q) {
  22223. var k, e, n, j, l, m, g, p = 0, f, h = q.interactions.length, r = [b.event.pageX, b.event.pageY],
  22224. o = b.tolerance || b.modes[b.mode];
  22225. do {
  22226. if (f = q.interactions[p]) {
  22227. if (!f) {
  22228. return
  22229. }
  22230. f.drop = [];
  22231. l = [];
  22232. m = f.droppable.length;
  22233. if (o) {
  22234. n = b.locate(f.proxy)
  22235. }
  22236. k = 0;
  22237. do {
  22238. if (g = f.droppable[k]) {
  22239. j = d.data(g, b.datakey);
  22240. e = j.location;
  22241. if (!e) {
  22242. continue
  22243. }
  22244. j.winner = o ? o.call(b, b.event, n, e) : b.contains(e, r) ? 1 : 0;
  22245. l.push(j)
  22246. }
  22247. } while (++k < m);
  22248. l.sort(b.sort);
  22249. k = 0;
  22250. do {
  22251. if (j = l[k]) {
  22252. if (j.winner && f.drop.length < b.multi) {
  22253. if (!j.active[p] && !j.anyactive) {
  22254. if (a.drag.hijack(b.event, "dropstart", q, p, j.elem)[0] !== false) {
  22255. j.active[p] = 1;
  22256. j.anyactive += 1
  22257. } else {
  22258. j.winner = 0
  22259. }
  22260. }
  22261. if (j.winner) {
  22262. f.drop.push(j.elem)
  22263. }
  22264. } else {
  22265. if (j.active[p] && j.anyactive == 1) {
  22266. a.drag.hijack(b.event, "dropend", q, p, j.elem);
  22267. j.active[p] = 0;
  22268. j.anyactive -= 1
  22269. }
  22270. }
  22271. }
  22272. } while (++k < m)
  22273. }
  22274. } while (++p < h);
  22275. if (b.last && r[0] == b.last.pageX && r[1] == b.last.pageY) {
  22276. delete b.timer
  22277. } else {
  22278. b.timer = setTimeout(function () {
  22279. b.tolerate(q)
  22280. }, b.delay)
  22281. }
  22282. b.last = b.event
  22283. }
  22284. };
  22285. a.dropinit = a.dropstart = a.dropend = b
  22286. })(jQuery);
  22287. define("drop", function () {
  22288. });
  22289. /**
  22290. * http://git.oschina.net/hbbcs/bootStrap-addTabs
  22291. * Created by joe on 2015-12-19.
  22292. * Modified by Karson
  22293. */
  22294. (function ($) {
  22295. $.fn.addtabs = function (options) {
  22296. var obj = $(this);
  22297. options = $.extend({
  22298. content: '', //直接指定所有页面TABS内容
  22299. close: true, //是否可以关闭
  22300. monitor: 'body', //监视的区域
  22301. nav: '.nav-addtabs',
  22302. tab: '.tab-addtabs',
  22303. iframeUse: true, //使用iframe还是ajax
  22304. iframeHeight: $(window).height() - 50, //固定TAB中IFRAME高度,根据需要自己修改
  22305. iframeForceRefresh: false, //点击后强制加载对应的iframe
  22306. iframeForceRefreshTable: false, //点击后强制刷新对应的iframe中的table
  22307. callback: function () {
  22308. //关闭后回调函数
  22309. }
  22310. }, options || {});
  22311. var navobj = $(options.nav);
  22312. var tabobj = $(options.tab);
  22313. if (history.pushState) {
  22314. //浏览器前进后退事件
  22315. $(window).on("popstate", function (e) {
  22316. var state = e.originalEvent.state;
  22317. if (state) {
  22318. $("a[addtabs=" + state.id + "]", options.monitor).data("pushstate", true).trigger("click");
  22319. }
  22320. });
  22321. }
  22322. $(options.monitor).on('click', '[addtabs]', function (e) {
  22323. if ($(this).attr('url').indexOf("javascript:") !== 0) {
  22324. if ($(this).is("a")) {
  22325. e.preventDefault();
  22326. }
  22327. var id = $(this).attr('addtabs');
  22328. var title = $(this).attr('title') ? $(this).attr('title') : $.trim($(this).text());
  22329. var url = $(this).attr('url');
  22330. var content = options.content ? options.content : $(this).attr('content');
  22331. var ajax = $(this).attr('ajax') === '1' || $(this).attr('ajax') === 'true';
  22332. var state = ({
  22333. url: url, title: title, id: id, content: content, ajax: ajax
  22334. });
  22335. document.title = title;
  22336. if (history.pushState && !$(this).data("pushstate")) {
  22337. var pushurl = url.indexOf("ref=addtabs") === -1 ? (url + (url.indexOf("?") > -1 ? "&" : "?") + "ref=addtabs") : url;
  22338. try {
  22339. window.history.pushState(state, title, pushurl);
  22340. } catch (e) {
  22341. }
  22342. }
  22343. $(this).data("pushstate", null);
  22344. _add.call(this, {
  22345. id: id,
  22346. title: $(this).attr('title') ? $(this).attr('title') : $(this).html(),
  22347. content: content,
  22348. url: url,
  22349. ajax: ajax
  22350. });
  22351. }
  22352. });
  22353. navobj.on('click', '.close-tab', function () {
  22354. var id = $(this).prev("a").attr("aria-controls");
  22355. _close(id);
  22356. return false;
  22357. });
  22358. navobj.on('dblclick', 'li[role=presentation]', function () {
  22359. $(this).find(".close-tab").trigger("click");
  22360. });
  22361. navobj.on('click', 'li[role=presentation]', function () {
  22362. $("a[addtabs=" + $("a", this).attr("node-id") + "]").trigger("click");
  22363. });
  22364. $(window).resize(function () {
  22365. if (typeof options.nav === 'object') {
  22366. var siblingsWidth = 0;
  22367. navobj.siblings().each(function () {
  22368. siblingsWidth += $(this).outerWidth();
  22369. });
  22370. navobj.width(navobj.parent().width() - siblingsWidth);
  22371. } else {
  22372. $("#nav").width($("#header").find("> .navbar").width() - $(".sidebar-toggle").outerWidth() - $(".navbar-custom-menu").outerWidth() - 20);
  22373. }
  22374. _drop();
  22375. });
  22376. var _add = function (opts) {
  22377. var id, tabid, conid, url;
  22378. id = opts.id;
  22379. tabid = 'tab_' + opts.id;
  22380. conid = 'con_' + opts.id;
  22381. url = opts.url;
  22382. url += (opts.url.indexOf("?") > -1 ? "&addtabs=1" : "?addtabs=1");
  22383. var tabitem = $('#' + tabid, navobj);
  22384. var conitem = $('#' + conid, tabobj);
  22385. navobj.find("[role='presentation']").removeClass('active');
  22386. tabobj.find("[role='tabpanel']").removeClass('active');
  22387. //如果TAB不存在,创建一个新的TAB
  22388. if (tabitem.size() === 0) {
  22389. //创建新TAB的title
  22390. tabitem = $('<li role="presentation" id="' + tabid + '"><a href="#' + conid + '" node-id="' + opts.id + '" aria-controls="' + id + '" role="tab" data-toggle="tab">' + opts.title + '</a></li>');
  22391. //是否允许关闭
  22392. if (options.close && $("li", navobj).size() > 0) {
  22393. tabitem.append(' <i class="close-tab fa fa-remove"></i>');
  22394. }
  22395. if (conitem.size() === 0) {
  22396. //创建新TAB的内容
  22397. conitem = $('<div role="tabpanel" class="tab-pane" id="' + conid + '"></div>');
  22398. //是否指定TAB内容
  22399. if (opts.content) {
  22400. conitem.append(opts.content);
  22401. } else if (options.iframeUse && !opts.ajax) {//没有内容,使用IFRAME打开链接
  22402. var height = options.iframeHeight;
  22403. conitem.append('<iframe src="' + url + '" width="100%" height="' + height + '" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling-x="no" scrolling-y="auto" allowtransparency="yes"></iframe></div>');
  22404. } else {
  22405. $.get(url, function (data) {
  22406. conitem.append(data);
  22407. });
  22408. }
  22409. tabobj.append(conitem);
  22410. }
  22411. //加入TABS
  22412. if ($('.tabdrop li', navobj).size() > 0) {
  22413. $('.tabdrop ul', navobj).append(tabitem);
  22414. } else {
  22415. navobj.append(tabitem);
  22416. }
  22417. } else {
  22418. //强制刷新iframe
  22419. if (options.iframeForceRefresh) {
  22420. $("#" + conid + " iframe").attr('src', function (i, val) {
  22421. return val;
  22422. });
  22423. } else if (options.iframeForceRefreshTable) {
  22424. try {
  22425. //检测iframe中是否存在刷新按钮
  22426. if ($("#" + conid + " iframe").contents().find(".btn-refresh:not([data-force-refresh=false])").size() > 0) {
  22427. $("#" + conid + " iframe")[0].contentWindow.$(".btn-refresh:not([data-force-refresh=false])").trigger("click");
  22428. }
  22429. } catch (e) {
  22430. }
  22431. }
  22432. }
  22433. localStorage.setItem("addtabs", $(this).prop('outerHTML'));
  22434. //激活TAB
  22435. tabitem.addClass('active');
  22436. conitem.addClass("active");
  22437. _drop();
  22438. };
  22439. var _close = function (id) {
  22440. var tabid = 'tab_' + id;
  22441. var conid = 'con_' + id;
  22442. var tabitem = $('#' + tabid, navobj);
  22443. var conitem = $('#' + conid, tabobj);
  22444. //如果关闭的是当前激活的TAB,激活他的前一个TAB
  22445. if (obj.find("li.active").not('.tabdrop').attr('id') === tabid) {
  22446. var prev = tabitem.prev().not(".tabdrop");
  22447. var next = tabitem.next().not(".tabdrop");
  22448. if (prev.size() > 0) {
  22449. prev.find('a').trigger("click");
  22450. } else if (next.size() > 0) {
  22451. next.find('a').trigger("click");
  22452. } else {
  22453. $(">li:not(.tabdrop):last > a", navobj).trigger('click');
  22454. }
  22455. }
  22456. //关闭TAB
  22457. tabitem.remove();
  22458. conitem.remove();
  22459. _drop();
  22460. options.callback();
  22461. };
  22462. var _drop = function () {
  22463. navobj.refreshAddtabs();
  22464. };
  22465. };
  22466. //刷新Addtabs
  22467. $.fn.refreshAddtabs = function () {
  22468. var navobj = $(this);
  22469. var dropdown = $(".tabdrop", navobj);
  22470. if (dropdown.size() === 0) {
  22471. dropdown = $('<li class="dropdown pull-right hide tabdrop"><a class="dropdown-toggle" data-toggle="dropdown" href="javascript:;">' +
  22472. '<i class="glyphicon glyphicon-align-justify"></i>' +
  22473. ' <b class="caret"></b></a><ul class="dropdown-menu"></ul></li>');
  22474. dropdown.prependTo(navobj);
  22475. }
  22476. //检测是否有下拉样式
  22477. if (navobj.parent().is('.tabs-below')) {
  22478. dropdown.addClass('dropup');
  22479. }
  22480. var collection = 0;
  22481. var maxwidth = navobj.width() - 65;
  22482. var liwidth = 0;
  22483. //检查超过一行的标签页
  22484. var litabs = navobj.append(dropdown.find('li')).find('>li').not('.tabdrop');
  22485. var totalwidth = 0;
  22486. litabs.each(function () {
  22487. totalwidth += $(this).outerWidth(true);
  22488. });
  22489. if (navobj.width() < totalwidth) {
  22490. litabs.each(function () {
  22491. liwidth += $(this).outerWidth(true);
  22492. if (liwidth > maxwidth) {
  22493. dropdown.find('ul').append($(this));
  22494. collection++;
  22495. }
  22496. });
  22497. if (collection > 0) {
  22498. dropdown.removeClass('hide');
  22499. if (dropdown.find('.active').length === 1) {
  22500. dropdown.addClass('active');
  22501. } else {
  22502. dropdown.removeClass('active');
  22503. }
  22504. }
  22505. } else {
  22506. dropdown.addClass('hide');
  22507. }
  22508. };
  22509. })(jQuery);
  22510. define("addtabs", function () {
  22511. });
  22512. /**
  22513. * @summary SelectPage
  22514. * @desc Simple and powerful selection plugin
  22515. * @file selectpage.js
  22516. * @version 2.19
  22517. * @author TerryZeng
  22518. * @contact https://terryz.github.io/
  22519. * @license MIT License
  22520. *
  22521. */
  22522. ;(function ($) {
  22523. "use strict";
  22524. /**
  22525. * Default options
  22526. */
  22527. var defaults = {
  22528. /**
  22529. * Data source
  22530. * @type {string|Object}
  22531. *
  22532. * string:server side request url address
  22533. * Object:JSON array,format:[{a:1,b:2,c:3},{...}]
  22534. */
  22535. data: undefined,
  22536. /**
  22537. * Language ('cn', 'en')
  22538. * @type string
  22539. * @default 'cn'
  22540. */
  22541. lang: 'cn',
  22542. /**
  22543. * Multiple select mode(tags)
  22544. * @type boolean
  22545. * @default false
  22546. */
  22547. multiple: false,
  22548. /**
  22549. * pagination or not
  22550. * @type boolean
  22551. * @default true
  22552. */
  22553. pagination: true,
  22554. /**
  22555. * Show up menu button
  22556. * @type boolean
  22557. * @default true
  22558. */
  22559. dropButton: true,
  22560. /**
  22561. * Result list visible size in pagination bar close
  22562. * @type number
  22563. * @default 10
  22564. */
  22565. listSize: 10,
  22566. /**
  22567. * Show control bar in multiple select mode
  22568. * @type boolean
  22569. * @default true
  22570. */
  22571. multipleControlbar: true,
  22572. /**
  22573. * Max selected item limited in multiple select mode
  22574. * @type number
  22575. * @default 0(unlimited)
  22576. */
  22577. maxSelectLimit: 0,
  22578. /**
  22579. * Select result item to close list, work on multiple select mode
  22580. * @type boolean
  22581. * @default false
  22582. */
  22583. selectToCloseList: false,
  22584. /**
  22585. * Init selected item key, the result will match to option.keyField option
  22586. * @type string
  22587. */
  22588. initRecord: undefined,
  22589. /**
  22590. * The table parameter in server side mode
  22591. * @type string
  22592. */
  22593. dbTable: 'tbl',
  22594. /**
  22595. * The value field, the value will fill to hidden element
  22596. * @type string
  22597. * @default 'id'
  22598. */
  22599. keyField: 'id',
  22600. /**
  22601. * The show text field, the text will show to input element or tags(multiple mode)
  22602. * @type string
  22603. * @default 'name'
  22604. */
  22605. showField: 'name',
  22606. /**
  22607. * Actually used to search field
  22608. * @type string
  22609. */
  22610. searchField: undefined,
  22611. /**
  22612. * Search type ('AND' or 'OR')
  22613. * @type string
  22614. * @default 'AND'
  22615. */
  22616. andOr: 'OR',
  22617. /**
  22618. * Result sort type
  22619. * @type array|boolean - if not set, will default used showField field
  22620. * @example
  22621. * orderBy : ['id desc']
  22622. */
  22623. orderBy: undefined,
  22624. /**
  22625. * Page size
  22626. * @type number
  22627. * @default 10
  22628. */
  22629. pageSize: 10,
  22630. /**
  22631. * Server side request parameters
  22632. * @type function
  22633. * @return object
  22634. * @example params : function(){return {'name':'aa','sex':1};}
  22635. */
  22636. params: undefined,
  22637. /**
  22638. * Custom result list item show text
  22639. * @type function
  22640. * @param data {object} row data
  22641. * @return string
  22642. */
  22643. formatItem: undefined,
  22644. /**
  22645. * Have some highlight item and lost focus, auto select the highlight item
  22646. * @type boolean
  22647. * @default false
  22648. */
  22649. autoFillResult: false,
  22650. /**
  22651. * Auto select first item in show up result list or search result
  22652. * depend on `autoFillResult` option set to true
  22653. * @type boolean
  22654. * @default false
  22655. */
  22656. autoSelectFirst: false,
  22657. /**
  22658. * Whether clear input element text when enter some keywords to search and no result return
  22659. * @type boolean
  22660. * @default true
  22661. */
  22662. noResultClean: true,
  22663. /**
  22664. * Select only mode
  22665. * @type boolean
  22666. */
  22667. selectOnly: false,
  22668. /**
  22669. * Input to search delay time, work on ajax data source
  22670. * @type number
  22671. * @default 0.5
  22672. */
  22673. inputDelay: 0.5,
  22674. /**
  22675. * -----------------------------------------Callback--------------------------------------------
  22676. */
  22677. /**
  22678. * Result list item selected callback
  22679. * @type function
  22680. * @param object - selected item json data
  22681. * @param self - plugin object
  22682. */
  22683. eSelect: undefined,
  22684. /**
  22685. * Before result list show up callback, you can do anything prepared
  22686. * @param self - plugin object
  22687. */
  22688. eOpen: undefined,
  22689. /**
  22690. * Server side return data convert callback
  22691. * @type function
  22692. * @param data {object} server side return data
  22693. * @param self {object} plugin object
  22694. * @return {object} return data format:
  22695. * @example
  22696. * {
  22697. * list : [{name:'aa',sex:1},{name:'bb',sex:1}...],
  22698. * totalRow : 100
  22699. * }
  22700. */
  22701. eAjaxSuccess: undefined,
  22702. /**
  22703. * Close selected item tag callback (multiple mode)
  22704. * @type function
  22705. * @param removeCount {number} remove item count
  22706. * @param self {object} plugin object
  22707. */
  22708. eTagRemove: undefined,
  22709. /**
  22710. * Clear selected item callback(single select mode)
  22711. * @type function
  22712. * @param self {object} plugin object
  22713. */
  22714. eClear: undefined
  22715. };
  22716. /**
  22717. * SelectPage class definition
  22718. * @constructor
  22719. * @param {Object} input - input element
  22720. * @param {Object} option
  22721. */
  22722. var SelectPage = function (input, option) {
  22723. //特殊字段处理
  22724. $.each({data: 'source', keyField: 'primaryKey', showField: 'field', pageSize: 'perPage'}, function (i, j) {
  22725. if (typeof option[j] !== 'undefined') {
  22726. option[i] = option[j];
  22727. delete option[j];
  22728. }
  22729. });
  22730. this.setOption(option);
  22731. this.setLanguage();
  22732. this.setCssClass();
  22733. this.setProp();
  22734. this.setElem(input);
  22735. this.setButtonAttrDefault();
  22736. this.setInitRecord();
  22737. this.eDropdownButton();
  22738. this.eInput();
  22739. this.eWhole();
  22740. };
  22741. /**
  22742. * Plugin version number
  22743. */
  22744. SelectPage.version = '2.19';
  22745. /**
  22746. * Plugin object cache key
  22747. */
  22748. SelectPage.dataKey = 'selectPageObject';
  22749. /**
  22750. * Options set
  22751. * @param {Object} option
  22752. */
  22753. SelectPage.prototype.setOption = function (option) {
  22754. //use showField to default
  22755. option.searchField = option.searchField || option.showField;
  22756. option.andOr = option.andOr.toUpperCase();
  22757. if (option.andOr !== 'AND' && option.andOr !== 'OR') option.andOr = 'AND';
  22758. //support multiple field set
  22759. var arr = ['searchField'];
  22760. for (var i = 0; i < arr.length; i++) {
  22761. option[arr[i]] = this.strToArray(option[arr[i]]);
  22762. }
  22763. //set default order field
  22764. option.orderBy = option.orderBy || option.showField;
  22765. //set multiple order field
  22766. //example: [ ['id', 'ASC'], ['name', 'DESC'] ]
  22767. if (option.orderBy !== false) option.orderBy = this.setOrderbyOption(option.orderBy, option.showField);
  22768. //close auto fill result and auto select first in multiple mode and select item not close list
  22769. if (option.multiple && !option.selectToCloseList) {
  22770. option.autoFillResult = false;
  22771. option.autoSelectFirst = false;
  22772. }
  22773. //show all item when pagination bar close, limited 200
  22774. if (!option.pagination) option.pageSize = 200;
  22775. if ($.type(option.listSize) !== 'number' || option.listSize < 0) option.listSize = 10;
  22776. if (typeof option.formatItem === 'string') {
  22777. var _formatItem = option.formatItem;
  22778. option.formatItem = function (row) {
  22779. if (typeof Template === 'function' && _formatItem.match(/\#([a-zA-Z0-9_\-]+)$/)) {
  22780. return Template(_formatItem.substring(1), row);
  22781. } else {
  22782. return _formatItem.replace(/\{(.*?)\}/gi, function (matched) {
  22783. matched = matched.substring(1, matched.length - 1);
  22784. return typeof row[matched] !== 'undefined' ? row[matched] : '';
  22785. });
  22786. }
  22787. };
  22788. }
  22789. this.option = option;
  22790. };
  22791. /**
  22792. * String convert to array
  22793. * @param str {string}
  22794. * @return {Array}
  22795. */
  22796. SelectPage.prototype.strToArray = function (str) {
  22797. return str ? str.replace(/[\s ]+/g, '').split(',') : '';
  22798. };
  22799. /**
  22800. * Set order field
  22801. * @param {Array} arg_order
  22802. * @param {string} arg_field - default sort field
  22803. * @return {Array}
  22804. */
  22805. SelectPage.prototype.setOrderbyOption = function (arg_order, arg_field) {
  22806. var arr = [], orders = [];
  22807. if (typeof arg_order === 'object') {
  22808. for (var i = 0; i < arg_order.length; i++) {
  22809. orders = $.trim(arg_order[i]).split(' ');
  22810. if (orders.length)
  22811. arr.push((orders.length === 2) ? orders.concat() : [orders[0], 'ASC']);
  22812. }
  22813. } else {
  22814. orders = $.trim(arg_order).split(' ');
  22815. arr[0] = (orders.length === 2) ? orders.concat() : (orders[0].toUpperCase().match(/^(ASC|DESC)$/i)) ? [arg_field, orders[0].toUpperCase()] : [orders[0], 'ASC'];
  22816. }
  22817. return arr;
  22818. };
  22819. /**
  22820. * i18n
  22821. */
  22822. SelectPage.prototype.setLanguage = function () {
  22823. var message, p = this.option;
  22824. switch (p.lang) {
  22825. // English
  22826. case 'en':
  22827. message = {
  22828. add_btn: 'Add button',
  22829. add_title: 'add a box',
  22830. del_btn: 'Del button',
  22831. del_title: 'delete a box',
  22832. next: 'Next',
  22833. next_title: 'Next' + p.pageSize + ' (Right key)',
  22834. prev: 'Prev',
  22835. prev_title: 'Prev' + p.pageSize + ' (Left key)',
  22836. first_title: 'First (Shift + Left key)',
  22837. last_title: 'Last (Shift + Right key)',
  22838. get_all_btn: 'Get All (Down key)',
  22839. get_all_alt: '(button)',
  22840. close_btn: 'Close (Tab key)',
  22841. close_alt: '(button)',
  22842. loading: 'loading...',
  22843. loading_alt: '(loading)',
  22844. page_info: 'page_num of page_count',
  22845. select_ng: 'Attention : Please choose from among the list.',
  22846. select_ok: 'OK : Correctly selected.',
  22847. not_found: 'not found',
  22848. ajax_error: 'An error occurred while connecting to server.',
  22849. clear: 'Clear content',
  22850. select_all: 'Select current page',
  22851. unselect_all: 'Clear current page',
  22852. clear_all: 'Clear all selected',
  22853. max_selected: 'You can only select up to max_selected_limit items'
  22854. };
  22855. break;
  22856. // 中文
  22857. case 'cn':
  22858. default:
  22859. message = {
  22860. add_btn: '添加按钮',
  22861. add_title: '添加区域',
  22862. del_btn: '删除按钮',
  22863. del_title: '删除区域',
  22864. next: '下一页',
  22865. next_title: '下' + p.pageSize + ' (→)',
  22866. prev: '上一页',
  22867. prev_title: '上' + p.pageSize + ' (←)',
  22868. first_title: '首页 (Shift + ←)',
  22869. last_title: '尾页 (Shift + →)',
  22870. get_all_btn: '获得全部 (↓)',
  22871. get_all_alt: '(按钮)',
  22872. close_btn: '关闭 (Tab键)',
  22873. close_alt: '(按钮)',
  22874. loading: '读取中...',
  22875. loading_alt: '(读取中)',
  22876. page_info: '第 page_num 页(共page_count页)',
  22877. select_ng: '请注意:请从列表中选择.',
  22878. select_ok: 'OK : 已经选择.',
  22879. not_found: '无查询结果',
  22880. ajax_error: '连接到服务器时发生错误!',
  22881. clear: '清除内容',
  22882. select_all: '选择当前页项目',
  22883. unselect_all: '取消选择当前页项目',
  22884. clear_all: '清除全部已选择项目',
  22885. max_selected: '最多只能选择 max_selected_limit 个项目'
  22886. };
  22887. break;
  22888. }
  22889. this.message = message;
  22890. };
  22891. /**
  22892. * Css classname defined
  22893. */
  22894. SelectPage.prototype.setCssClass = function () {
  22895. var css_class = {
  22896. container: 'sp_container',
  22897. container_open: 'sp_container_open',
  22898. re_area: 'sp_result_area',
  22899. result_open: 'sp_result_area_open',
  22900. control_box: 'sp_control_box',
  22901. //multiple select mode
  22902. element_box: 'sp_element_box',
  22903. navi: 'sp_navi',
  22904. //result list
  22905. results: 'sp_results',
  22906. re_off: 'sp_results_off',
  22907. select: 'sp_over',
  22908. select_ok: 'sp_select_ok',
  22909. select_ng: 'sp_select_ng',
  22910. selected: 'sp_selected',
  22911. input_off: 'sp_input_off',
  22912. message_box: 'sp_message_box',
  22913. disabled: 'sp_disabled',
  22914. button: 'sp_button',
  22915. caret_open: 'sp_caret_open',
  22916. btn_on: 'sp_btn_on',
  22917. btn_out: 'sp_btn_out',
  22918. input: 'sp_input',
  22919. clear_btn: 'sp_clear_btn',
  22920. align_right: 'sp_align_right'
  22921. };
  22922. this.css_class = css_class;
  22923. };
  22924. /**
  22925. * Plugin inner properties
  22926. */
  22927. SelectPage.prototype.setProp = function () {
  22928. this.prop = {
  22929. //input disabled status
  22930. disabled: false,
  22931. current_page: 1,
  22932. //total page
  22933. max_page: 1,
  22934. //ajax data loading status
  22935. is_loading: false,
  22936. xhr: false,
  22937. key_paging: false,
  22938. key_select: false,
  22939. //last selected item value
  22940. prev_value: '',
  22941. //last selected item text
  22942. selected_text: '',
  22943. last_input_time: undefined,
  22944. init_set: false
  22945. };
  22946. this.template = {
  22947. tag: {
  22948. content: '<li class="selected_tag" itemvalue="#item_value#">#item_text#<span class="tag_close"><i class="spfont sp-close"></i></span></li>',
  22949. textKey: '#item_text#',
  22950. valueKey: '#item_value#'
  22951. },
  22952. page: {
  22953. current: 'page_num',
  22954. total: 'page_count'
  22955. },
  22956. msg: {
  22957. maxSelectLimit: 'max_selected_limit'
  22958. }
  22959. };
  22960. };
  22961. /**
  22962. * Get the actual width/height of invisible DOM elements with jQuery.
  22963. * Source code come from dreamerslab/jquery.actual
  22964. * @param element
  22965. * @param method
  22966. * @returns {*}
  22967. */
  22968. SelectPage.prototype.elementRealSize = function (element, method) {
  22969. var defaults = {
  22970. absolute: false,
  22971. clone: false,
  22972. includeMargin: false,
  22973. display: 'block'
  22974. };
  22975. var configs = defaults, $target = element.eq(0), fix, restore, tmp = [], style = '', $hidden;
  22976. fix = function () {
  22977. // get all hidden parents
  22978. $hidden = $target.parents().addBack().filter(':hidden');
  22979. style += 'visibility: hidden !important; display: ' + configs.display + ' !important; ';
  22980. if (configs.absolute === true) style += 'position: absolute !important;';
  22981. // save the origin style props
  22982. // set the hidden el css to be got the actual value later
  22983. $hidden.each(function () {
  22984. // Save original style. If no style was set, attr() returns undefined
  22985. var $this = $(this), thisStyle = $this.attr('style');
  22986. tmp.push(thisStyle);
  22987. // Retain as much of the original style as possible, if there is one
  22988. $this.attr('style', thisStyle ? thisStyle + ';' + style : style);
  22989. });
  22990. };
  22991. restore = function () {
  22992. // restore origin style values
  22993. $hidden.each(function (i) {
  22994. var $this = $(this), _tmp = tmp[i];
  22995. if (_tmp === undefined) $this.removeAttr('style');
  22996. else $this.attr('style', _tmp);
  22997. });
  22998. };
  22999. fix();
  23000. // get the actual value with user specific methed
  23001. // it can be 'width', 'height', 'outerWidth', 'innerWidth'... etc
  23002. // configs.includeMargin only works for 'outerWidth' and 'outerHeight'
  23003. var actual = /(outer)/.test(method) ?
  23004. $target[method](configs.includeMargin) :
  23005. $target[method]();
  23006. restore();
  23007. // IMPORTANT, this plugin only return the value of the first element
  23008. return actual;
  23009. };
  23010. /**
  23011. * Dom building
  23012. * @param {Object} combo_input - original input element
  23013. */
  23014. SelectPage.prototype.setElem = function (combo_input) {
  23015. // 1. build Dom object
  23016. var elem = {}, p = this.option, css = this.css_class, msg = this.message, input = $(combo_input);
  23017. var cssWidth = input.css("width");
  23018. var orgWidth = input.outerWidth();
  23019. if (cssWidth.indexOf("%") > -1 || input.parent().size() > 0 && input.parent().width() == orgWidth) {
  23020. orgWidth = "100%";
  23021. } else {
  23022. // fix input width in hidden situation
  23023. if (orgWidth <= 0) orgWidth = this.elementRealSize(input, 'outerWidth');
  23024. if (orgWidth < 150) orgWidth = 150;
  23025. }
  23026. elem.combo_input = input.attr({'autocomplete': 'off'}).addClass(css.input).wrap('<div>');
  23027. if (p.selectOnly) elem.combo_input.prop('readonly', true);
  23028. elem.container = elem.combo_input.parent().addClass(css.container);
  23029. if (elem.combo_input.prop('disabled')) {
  23030. if (p.multiple) elem.container.addClass(css.disabled);
  23031. else elem.combo_input.addClass(css.input_off);
  23032. }
  23033. // set outer box width
  23034. elem.container.width(orgWidth);
  23035. elem.button = $('<div>').addClass(css.button);
  23036. //drop down button
  23037. elem.dropdown = $('<span class="sp_caret"></span>');
  23038. //clear button 'X' in single mode
  23039. elem.clear_btn = $('<div>').html($('<i>').addClass('spfont sp-close')).addClass(css.clear_btn).attr('title', msg.clear);
  23040. if (!p.dropButton) elem.clear_btn.addClass(css.align_right);
  23041. //main box in multiple mode
  23042. elem.element_box = $('<ul>').addClass(css.element_box);
  23043. if (p.multiple && p.multipleControlbar)
  23044. elem.control = $('<div>').addClass(css.control_box);
  23045. //result list box
  23046. elem.result_area = $('<div>').addClass(css.re_area);
  23047. //pagination bar
  23048. if (p.pagination) elem.navi = $('<div>').addClass('sp_pagination').append('<ul>');
  23049. elem.results = $('<ul>').addClass(css.results);
  23050. var namePrefix = '_text',
  23051. input_id = elem.combo_input.attr('id') || elem.combo_input.attr('name'),
  23052. input_name = elem.combo_input.attr('name') || 'selectPage',
  23053. hidden_name = input_name,
  23054. hidden_id = input_id;
  23055. //switch the id and name attributes of input/hidden element
  23056. elem.hidden = $('<input type="hidden" class="sp_hidden" />').attr({
  23057. name: hidden_name,
  23058. id: hidden_id
  23059. }).val('');
  23060. elem.combo_input.attr({
  23061. name: typeof input.data('name') !== 'undefined' ? input.data('name') : input_name + namePrefix,
  23062. id: input_id + namePrefix
  23063. });
  23064. // 2. DOM element put
  23065. elem.container.append(elem.hidden);
  23066. if (p.dropButton) {
  23067. elem.container.append(elem.button)
  23068. elem.button.append(elem.dropdown);
  23069. }
  23070. $(document.body).append(elem.result_area);
  23071. elem.result_area.append(elem.results);
  23072. if (p.pagination) elem.result_area.append(elem.navi);
  23073. //Multiple select mode
  23074. if (p.multiple) {
  23075. if (p.multipleControlbar) {
  23076. elem.control.append('<button type="button" class="btn btn-default sp_clear_all" ><i class="spfont sp-clear"></i></button>');
  23077. elem.control.append('<button type="button" class="btn btn-default sp_unselect_all" ><i class="spfont sp-unselect-all"></i></button>');
  23078. elem.control.append('<button type="button" class="btn btn-default sp_select_all" ><i class="spfont sp-select-all"></i></button>');
  23079. elem.control_text = $('<p>');
  23080. elem.control.append(elem.control_text);
  23081. elem.result_area.prepend(elem.control);
  23082. }
  23083. elem.container.addClass('sp_container_combo');
  23084. elem.combo_input.addClass('sp_combo_input').before(elem.element_box);
  23085. var li = $('<li>').addClass('input_box');
  23086. li.append(elem.combo_input);
  23087. elem.element_box.append(li);
  23088. if (elem.combo_input.attr('placeholder')) elem.combo_input.attr('placeholder_bak', elem.combo_input.attr('placeholder'));
  23089. }
  23090. this.elem = elem;
  23091. };
  23092. /**
  23093. * Drop down button set to default
  23094. */
  23095. SelectPage.prototype.setButtonAttrDefault = function () {
  23096. /*
  23097. if (this.option.selectOnly) {
  23098. if ($(this.elem.combo_input).val() !== '') {
  23099. if ($(this.elem.hidden).val() !== '') {
  23100. //选择条件
  23101. $(this.elem.combo_input).attr('title', this.message.select_ok).removeClass(this.css_class.select_ng).addClass(this.css_class.select_ok);
  23102. } else {
  23103. //输入方式
  23104. $(this.elem.combo_input).attr('title', this.message.select_ng).removeClass(this.css_class.select_ok).addClass(this.css_class.select_ng);
  23105. }
  23106. } else {
  23107. $(this.elem.hidden).val('');
  23108. $(this.elem.combo_input).removeAttr('title').removeClass(this.css_class.select_ng);
  23109. }
  23110. }
  23111. */
  23112. //this.elem.button.attr('title', this.message.get_all_btn);
  23113. if (this.option.dropButton)
  23114. this.elem.button.attr('title', this.message.close_btn);
  23115. };
  23116. /**
  23117. * Set item need selected after init
  23118. * set selected item ways:
  23119. * <input value="key">
  23120. * <input data-init="key">
  23121. */
  23122. SelectPage.prototype.setInitRecord = function (refresh) {
  23123. var self = this, p = self.option, el = self.elem, key = '';
  23124. if ($.type(el.combo_input.data('init')) != 'undefined')
  23125. p.initRecord = String(el.combo_input.data('init'));
  23126. //data-init and value attribute can be init plugin selected item
  23127. //but, if set data-init and value attribute in the same time, plugin will choose data-init attribute first
  23128. if (!refresh && !p.initRecord && el.combo_input.val())
  23129. p.initRecord = el.combo_input.val();
  23130. el.combo_input.val('');
  23131. if (!refresh) el.hidden.val(p.initRecord);
  23132. key = refresh && el.hidden.val() ? el.hidden.val() : p.initRecord;
  23133. if (key) {
  23134. if (typeof p.data === 'object') {
  23135. var data = new Array();
  23136. var keyarr = key.split(',');
  23137. $.each(keyarr, function (index, row) {
  23138. for (var i = 0; i < p.data.length; i++) {
  23139. if (p.data[i][p.keyField] == row) {
  23140. data.push(p.data[i]);
  23141. break;
  23142. }
  23143. }
  23144. });
  23145. if (!p.multiple && data.length > 1) data = [data[0]];
  23146. self.afterInit(self, data);
  23147. } else {//ajax data source mode to init selected item
  23148. var _paramsFunc = p.params, _params = {}, searchKey = p.searchField;
  23149. var _orgParams = {
  23150. searchTable: p.dbTable,
  23151. searchKey: p.keyField,
  23152. searchValue: key,
  23153. orderBy: p.orderBy,
  23154. showField: p.showField,
  23155. keyField: p.keyField,
  23156. keyValue: key,
  23157. searchField: p.searchField
  23158. };
  23159. if (_paramsFunc) {
  23160. var result = $.isFunction(_paramsFunc) ? _paramsFunc(self) : _paramsFunc;
  23161. if (result && $.isPlainObject(result)) {
  23162. _params = $.extend({}, _orgParams, result);
  23163. } else {
  23164. _params = _orgParams;
  23165. }
  23166. } else {
  23167. _params = _orgParams;
  23168. }
  23169. $.ajax({
  23170. dataType: 'json',
  23171. type: 'POST',
  23172. url: p.data,
  23173. data: _params,
  23174. success: function (json) {
  23175. var d = null;
  23176. if (p.eAjaxSuccess && $.isFunction(p.eAjaxSuccess))
  23177. d = p.eAjaxSuccess(json);
  23178. self.afterInit(self, d.list);
  23179. },
  23180. error: function (jqXHR, textStatus, errorThrown) {
  23181. self.ajaxErrorNotify(self, errorThrown);
  23182. }
  23183. });
  23184. }
  23185. }
  23186. };
  23187. /**
  23188. * Selected item set to plugin
  23189. * @param {Object} self
  23190. * @param {Object} data - selected item data
  23191. */
  23192. SelectPage.prototype.afterInit = function (self, data) {
  23193. if (!data || ($.isArray(data) && data.length === 0)) return;
  23194. if (!$.isArray(data)) data = [data];
  23195. var p = self.option, css = self.css_class;
  23196. self.data = data;
  23197. if (p.multiple) {
  23198. self.prop.init_set = true;
  23199. self.clearAll(self);
  23200. $.each(data, function (i, row) {
  23201. var value = row[p.keyField];
  23202. var text = row[p.showField];
  23203. var item = {text: text, value: value};
  23204. if (!self.isAlreadySelected(self, item)) self.addNewTag(self, row, item);
  23205. });
  23206. self.tagValuesSet(self);
  23207. self.inputResize(self);
  23208. self.elem.hidden.blur();
  23209. self.prop.init_set = false;
  23210. } else {
  23211. var row = data[0];
  23212. var value = row[p.keyField];
  23213. var text = row[p.showField];
  23214. self.elem.combo_input.val(text);
  23215. self.elem.hidden.val(value);
  23216. self.prop.prev_value = text;
  23217. self.prop.selected_text = text;
  23218. if (p.selectOnly) {
  23219. self.elem.combo_input.attr('title', self.message.select_ok).removeClass(css.select_ng).addClass(css.select_ok);
  23220. }
  23221. self.putClearButton();
  23222. }
  23223. };
  23224. /**
  23225. * Drop down button event bind
  23226. */
  23227. SelectPage.prototype.eDropdownButton = function () {
  23228. var self = this;
  23229. if (self.option.dropButton) {
  23230. self.elem.button.mouseup(function (ev) {
  23231. ev.stopPropagation();
  23232. if (self.elem.result_area.is(':hidden') && !self.elem.combo_input.prop('disabled')) {
  23233. self.elem.combo_input.focus();
  23234. } else self.hideResults(self);
  23235. });
  23236. }
  23237. };
  23238. /**
  23239. * Events bind
  23240. */
  23241. SelectPage.prototype.eInput = function () {
  23242. var self = this, p = self.option, el = self.elem, msg = self.message;
  23243. var showList = function () {
  23244. self.prop.page_move = false;
  23245. self.suggest(self);
  23246. self.setCssFocusedInput(self);
  23247. };
  23248. el.combo_input.keyup(function (e) {
  23249. self.processKey(self, e);
  23250. }).keydown(function (e) {
  23251. self.processControl(self, e);
  23252. }).focus(function (e) {
  23253. //When focus on input, show the result list
  23254. if (el.result_area.is(':hidden')) {
  23255. e.stopPropagation();
  23256. self.prop.first_show = true;
  23257. showList();
  23258. }
  23259. });
  23260. el.container.on('click.SelectPage', 'div.' + self.css_class.clear_btn, function (e) {
  23261. e.stopPropagation();
  23262. if (!self.disabled(self)) {
  23263. self.clearAll(self, true);
  23264. self.elem.hidden.change();
  23265. if (p.eClear && $.isFunction(p.eClear)) p.eClear(self);
  23266. }
  23267. });
  23268. el.result_area.on('mousedown.SelectPage', function (e) {
  23269. e.stopPropagation();
  23270. });
  23271. if (p.multiple) {
  23272. if (p.multipleControlbar) {
  23273. //Select all item of current page
  23274. el.control.find('.sp_select_all').on('click.SelectPage', function (e) {
  23275. self.selectAllLine(self);
  23276. }).hover(function () {
  23277. el.control_text.html(msg.select_all);
  23278. }, function () {
  23279. el.control_text.html('');
  23280. });
  23281. //Cancel select all item of current page
  23282. el.control.find('.sp_unselect_all').on('click.SelectPage', function (e) {
  23283. self.unSelectAllLine(self);
  23284. }).hover(function () {
  23285. el.control_text.html(msg.unselect_all);
  23286. }, function () {
  23287. el.control_text.html('');
  23288. });
  23289. //Clear all selected item
  23290. el.control.find('.sp_clear_all').on('click.SelectPage', function (e) {
  23291. self.clearAll(self, true);
  23292. }).hover(function () {
  23293. el.control_text.html(msg.clear_all);
  23294. }, function () {
  23295. el.control_text.html('');
  23296. });
  23297. }
  23298. el.element_box.on('click.SelectPage', function (e) {
  23299. var srcEl = e.target || e.srcElement;
  23300. if ($(srcEl).is('ul')) el.combo_input.focus();
  23301. });
  23302. //Tag close
  23303. el.element_box.on('click.SelectPage', 'span.tag_close', function () {
  23304. var li = $(this).closest('li'), data = li.data('dataObj');
  23305. self.removeTag(self, li);
  23306. showList();
  23307. if (p.eTagRemove && $.isFunction(p.eTagRemove)) p.eTagRemove([data]);
  23308. });
  23309. self.inputResize(self);
  23310. }
  23311. };
  23312. /**
  23313. * Out of plugin area click event handler
  23314. */
  23315. SelectPage.prototype.eWhole = function () {
  23316. var self = this, css = self.css_class;
  23317. var cleanContent = function (obj) {
  23318. obj.elem.combo_input.val('');
  23319. if (!obj.option.multiple) obj.elem.hidden.val('');
  23320. obj.prop.selected_text = '';
  23321. };
  23322. //Out of plugin area
  23323. $(document.body).off('mousedown.selectPage').on('mousedown.selectPage', function (e) {
  23324. var ele = e.target || e.srcElement;
  23325. var sp = $(ele).closest('div.' + css.container);
  23326. //Open status result list
  23327. $('div.' + css.container + '.' + css.container_open).each(function () {
  23328. if (this == sp[0]) return;
  23329. var $this = $(this), d = $this.find('input.' + css.input).data(SelectPage.dataKey);
  23330. if (!d.elem.combo_input.val() && d.elem.hidden.val() && !d.option.multiple) {
  23331. d.prop.current_page = 1;//reset page to 1
  23332. cleanContent(d);
  23333. d.hideResults(d);
  23334. return true;
  23335. }
  23336. if (d.elem.results.find('li').not('.' + css.message_box).length) {
  23337. if (d.option.autoFillResult) {
  23338. //have selected item, then hide result list
  23339. if (d.elem.hidden.val()) d.hideResults(d);
  23340. else if (d.elem.results.find('li.sp_over').length) {
  23341. //no one selected and have highlight item, select the highlight item
  23342. d.selectCurrentLine(d, true);
  23343. } else if (d.option.autoSelectFirst) {
  23344. //no one selected, no one highlight, select the first item
  23345. d.nextLine(d);
  23346. d.selectCurrentLine(d, true);
  23347. } else d.hideResults(d);
  23348. } else d.hideResults(d);
  23349. } else {
  23350. //when no one item match, clear search keywords
  23351. if (d.option.noResultClean) cleanContent(d);
  23352. else {
  23353. if (!d.option.multiple) d.elem.hidden.val('');
  23354. }
  23355. d.hideResults(d);
  23356. }
  23357. });
  23358. });
  23359. };
  23360. /**
  23361. * Result list event bind
  23362. */
  23363. SelectPage.prototype.eResultList = function () {
  23364. var self = this, css = this.css_class;
  23365. self.elem.results.children('li').hover(function () {
  23366. if (self.prop.key_select) {
  23367. self.prop.key_select = false;
  23368. return;
  23369. }
  23370. if (!$(this).hasClass(css.selected) && !$(this).hasClass(css.message_box)) {
  23371. $(this).addClass(css.select);
  23372. self.setCssFocusedResults(self);
  23373. }
  23374. }, function () {
  23375. $(this).removeClass(css.select);
  23376. }).click(function (e) {
  23377. if (self.prop.key_select) {
  23378. self.prop.key_select = false;
  23379. return;
  23380. }
  23381. e.preventDefault();
  23382. e.stopPropagation();
  23383. if (!$(this).hasClass(css.selected)) self.selectCurrentLine(self, false);
  23384. });
  23385. };
  23386. /**
  23387. * Reposition result list when list beyond the visible area
  23388. */
  23389. SelectPage.prototype.eScroll = function () {
  23390. var self = this, css = this.css_class;
  23391. $(window).on('scroll.SelectPage', function (e) {
  23392. $('div.' + css.container + '.' + css.container_open).each(function () {
  23393. var $this = $(this), d = $this.find('input.' + css.input).data(SelectPage.dataKey),
  23394. offset = d.elem.result_area.offset(),
  23395. screenScrollTop = $(window).scrollTop(),
  23396. docHeight = $(document).height(),
  23397. viewHeight = $(window).height(),
  23398. listHeight = d.elem.result_area.outerHeight(),
  23399. listBottom = offset.top + listHeight,
  23400. hasOverflow = docHeight > viewHeight,
  23401. down = d.elem.result_area.hasClass('shadowDown');
  23402. if (hasOverflow) {
  23403. if (down) {//open down
  23404. if (listBottom > (viewHeight + screenScrollTop)) d.calcResultsSize(d);
  23405. } else {//open up
  23406. if (offset.top < screenScrollTop) d.calcResultsSize(d);
  23407. }
  23408. }
  23409. });
  23410. });
  23411. };
  23412. /**
  23413. * Page bar button event bind
  23414. */
  23415. SelectPage.prototype.ePaging = function () {
  23416. var self = this;
  23417. if (!self.option.pagination) return;
  23418. self.elem.navi.find('li.csFirstPage').off('click').on('click', function (ev) {
  23419. //$(self.elem.combo_input).focus();
  23420. ev.preventDefault();
  23421. self.firstPage(self);
  23422. });
  23423. self.elem.navi.find('li.csPreviousPage').off('click').on('click', function (ev) {
  23424. //$(self.elem.combo_input).focus();
  23425. ev.preventDefault();
  23426. self.prevPage(self);
  23427. });
  23428. self.elem.navi.find('li.csNextPage').off('click').on('click', function (ev) {
  23429. //$(self.elem.combo_input).focus();
  23430. ev.preventDefault();
  23431. self.nextPage(self);
  23432. });
  23433. self.elem.navi.find('li.csLastPage').off('click').on('click', function (ev) {
  23434. //$(self.elem.combo_input).focus();
  23435. ev.preventDefault();
  23436. self.lastPage(self);
  23437. });
  23438. };
  23439. /**
  23440. * Ajax request fail
  23441. * @param {Object} self
  23442. * @param {string} errorThrown
  23443. */
  23444. SelectPage.prototype.ajaxErrorNotify = function (self, errorThrown) {
  23445. self.showMessage(self.message.ajax_error);
  23446. };
  23447. /**
  23448. * Message box
  23449. * @param {Object} self
  23450. * @param msg {string} the text need to show
  23451. */
  23452. SelectPage.prototype.showMessage = function (self, msg) {
  23453. if (!msg) return;
  23454. var msgLi = '<li class="' + self.css_class.message_box + '"><i class="spfont sp-warning"></i> ' + msg + '</li>';
  23455. self.elem.results.empty().append(msgLi).show();
  23456. self.calcResultsSize(self);
  23457. self.setOpenStatus(self, true);
  23458. self.elem.control.hide();
  23459. if (self.option.pagination) self.elem.navi.hide();
  23460. };
  23461. /**
  23462. * @desc Scroll
  23463. * @param {Object} self
  23464. * @param {boolean} enforce
  23465. */
  23466. SelectPage.prototype.scrollWindow = function (self, enforce) {
  23467. var current_result = self.getCurrentLine(self),
  23468. target_top = (current_result && !enforce) ? current_result.offset().top : self.elem.container.offset().top,
  23469. target_size;
  23470. self.prop.size_li = self.elem.results.children('li:first').outerHeight();
  23471. target_size = self.prop.size_li;
  23472. var gap, client_height = $(window).height(),
  23473. scroll_top = $(window).scrollTop(),
  23474. scroll_bottom = scroll_top + client_height - target_size;
  23475. if (current_result.length) {
  23476. if (target_top < scroll_top || target_size > client_height) {
  23477. //scroll to top
  23478. gap = target_top - scroll_top;
  23479. } else if (target_top > scroll_bottom) {
  23480. //scroll down
  23481. gap = target_top - scroll_bottom;
  23482. } else return; //do not scroll
  23483. } else if (target_top < scroll_top) gap = target_top - scroll_top;
  23484. window.scrollBy(0, gap);
  23485. };
  23486. /**
  23487. * change css class by status
  23488. * @param self
  23489. * @param status {boolean} true: open, false: close
  23490. */
  23491. SelectPage.prototype.setOpenStatus = function (self, status) {
  23492. var el = self.elem, css = self.css_class;
  23493. if (status) {
  23494. el.container.addClass(css.container_open);
  23495. el.result_area.addClass(css.result_open);
  23496. } else {
  23497. el.container.removeClass(css.container_open);
  23498. el.result_area.removeClass(css.result_open);
  23499. }
  23500. };
  23501. /**
  23502. * input element in focus css class set
  23503. * @param {Object} self
  23504. */
  23505. SelectPage.prototype.setCssFocusedInput = function (self) {
  23506. //$(self.elem.results).addClass(self.css_class.re_off);
  23507. //$(self.elem.combo_input).removeClass(self.css_class.input_off);
  23508. };
  23509. /**
  23510. * set result list get focus and input element lost focus
  23511. * @param {Object} self
  23512. */
  23513. SelectPage.prototype.setCssFocusedResults = function (self) {
  23514. //$(self.elem.results).removeClass(self.css_class.re_off);
  23515. //$(self.elem.combo_input).addClass(self.css_class.input_off);
  23516. };
  23517. /**
  23518. * Quick search input keywords listener
  23519. * @param {Object} self
  23520. */
  23521. SelectPage.prototype.checkValue = function (self) {
  23522. var now_value = self.elem.combo_input.val();
  23523. if (now_value != self.prop.prev_value) {
  23524. self.prop.prev_value = now_value;
  23525. self.prop.first_show = false;
  23526. if (self.option.selectOnly) self.setButtonAttrDefault();
  23527. if (!self.option.multiple && !now_value) {
  23528. self.elem.combo_input.val('');
  23529. self.elem.hidden.val('');
  23530. self.elem.clear_btn.remove();
  23531. }
  23532. self.suggest(self);
  23533. }
  23534. };
  23535. /**
  23536. * Input handle(regular input)
  23537. * @param {Object} self
  23538. * @param {Object} e - event object
  23539. */
  23540. SelectPage.prototype.processKey = function (self, e) {
  23541. if ($.inArray(e.keyCode, [37, 38, 39, 40, 27, 9, 13]) === -1) {
  23542. if (e.keyCode != 16) self.setCssFocusedInput(self); // except Shift(16)
  23543. self.inputResize(self);
  23544. if ($.type(self.option.data) === 'string') {
  23545. self.prop.last_input_time = e.timeStamp;
  23546. setTimeout(function () {
  23547. if ((e.timeStamp - self.prop.last_input_time) === 0)
  23548. self.checkValue(self);
  23549. }, self.option.inputDelay * 1000);
  23550. } else {
  23551. self.checkValue(self);
  23552. }
  23553. }
  23554. }
  23555. /**
  23556. * Input handle(control key)
  23557. * @param {Object} self
  23558. * @param {Object} e - event object
  23559. */
  23560. SelectPage.prototype.processControl = function (self, e) {
  23561. if (($.inArray(e.keyCode, [37, 38, 39, 40, 27, 9]) > -1 && self.elem.result_area.is(':visible')) ||
  23562. ($.inArray(e.keyCode, [13, 9]) > -1 && self.getCurrentLine(self))) {
  23563. e.preventDefault();
  23564. e.stopPropagation();
  23565. e.cancelBubble = true;
  23566. e.returnValue = false;
  23567. switch (e.keyCode) {
  23568. case 37:// left
  23569. if (e.shiftKey) self.firstPage(self);
  23570. else self.prevPage(self);
  23571. break;
  23572. case 38:// up
  23573. self.prop.key_select = true;
  23574. self.prevLine(self);
  23575. break;
  23576. case 39:// right
  23577. if (e.shiftKey) self.lastPage(self);
  23578. else self.nextPage(self);
  23579. break;
  23580. case 40:// down
  23581. if (self.elem.results.children('li').length) {
  23582. self.prop.key_select = true;
  23583. self.nextLine(self);
  23584. } else self.suggest(self);
  23585. break;
  23586. case 9:// tab
  23587. self.prop.key_paging = true;
  23588. self.selectCurrentLine(self, true);
  23589. //self.hideResults(self);
  23590. break;
  23591. case 13:// return
  23592. self.selectCurrentLine(self, true);
  23593. break;
  23594. case 27:// escape
  23595. self.prop.key_paging = true;
  23596. self.hideResults(self);
  23597. break;
  23598. }
  23599. }
  23600. };
  23601. /**
  23602. * Abort Ajax request
  23603. * @param {Object} self
  23604. */
  23605. SelectPage.prototype.abortAjax = function (self) {
  23606. if (self.prop.xhr) {
  23607. self.prop.xhr.abort();
  23608. self.prop.xhr = false;
  23609. }
  23610. };
  23611. /**
  23612. * Suggest result of search keywords
  23613. * @param {Object} self
  23614. */
  23615. SelectPage.prototype.suggest = function (self) {
  23616. var q_word, val = $.trim(self.elem.combo_input.val());
  23617. if (self.option.multiple) q_word = val;
  23618. else {
  23619. if (val && val === self.prop.selected_text) q_word = '';
  23620. else q_word = val;
  23621. }
  23622. q_word = q_word.split(/[\s ]+/);
  23623. //Before show up result list callback
  23624. if (self.option.eOpen && $.isFunction(self.option.eOpen))
  23625. self.option.eOpen.call(self);
  23626. self.abortAjax(self);
  23627. //self.setLoading(self);
  23628. var which_page_num = self.prop.current_page || 1;
  23629. if (typeof self.option.data == 'object') self.searchForJson(self, q_word, which_page_num);
  23630. else self.searchForDb(self, q_word, which_page_num);
  23631. };
  23632. /**
  23633. * Loading
  23634. * @param {Object} self
  23635. */
  23636. SelectPage.prototype.setLoading = function (self) {
  23637. if (self.elem.results.html() === '') {
  23638. //self.calcResultsSize(self);
  23639. self.setOpenStatus(self, true);
  23640. }
  23641. };
  23642. /**
  23643. * Search for ajax
  23644. * @param {Object} self
  23645. * @param {Array} q_word - query keyword
  23646. * @param {number} which_page_num - target page number
  23647. */
  23648. SelectPage.prototype.searchForDb = function (self, q_word, which_page_num) {
  23649. var p = self.option;
  23650. if (!p.eAjaxSuccess || !$.isFunction(p.eAjaxSuccess)) self.hideResults(self);
  23651. var _paramsFunc = p.params, _params = {}, searchKey = p.searchField;
  23652. //when have new query keyword, then reset page number to 1.
  23653. if (q_word.length && q_word[0] && q_word[0] !== self.prop.prev_value) which_page_num = 1;
  23654. var _orgParams = {
  23655. q_word: q_word,
  23656. pageNumber: which_page_num,
  23657. pageSize: p.pageSize,
  23658. andOr: p.andOr,
  23659. orderBy: p.orderBy,
  23660. searchTable: p.dbTable,
  23661. showField: self.option.showField,
  23662. keyField: self.option.keyField,
  23663. searchField: self.option.searchField
  23664. };
  23665. if (p.orderBy !== false) _orgParams.orderBy = p.orderBy;
  23666. _orgParams[searchKey] = q_word[0];
  23667. if (_paramsFunc) {
  23668. var result = $.isFunction(_paramsFunc) ? _paramsFunc(self) : _paramsFunc;
  23669. if (result && $.isPlainObject(result)) {
  23670. _params = $.extend({}, _orgParams, result);
  23671. } else {
  23672. _params = _orgParams;
  23673. }
  23674. } else {
  23675. _params = _orgParams;
  23676. }
  23677. self.prop.xhr = $.ajax({
  23678. dataType: 'json',
  23679. url: p.data,
  23680. type: 'POST',
  23681. data: _params,
  23682. success: function (returnData) {
  23683. if (!returnData || !$.isPlainObject(returnData)) {
  23684. self.hideResults(self);
  23685. self.ajaxErrorNotify(self, errorThrown);
  23686. return;
  23687. }
  23688. var data = {}, json = {};
  23689. try {
  23690. data = p.eAjaxSuccess(returnData);
  23691. json.originalResult = data.list;
  23692. json.cnt_whole = data.totalRow;
  23693. } catch (e) {
  23694. self.showMessage(self, self.message.ajax_error);
  23695. return;
  23696. }
  23697. if (self.elem.navi) {
  23698. $(self.elem.navi).toggleClass("hide", json.cnt_whole <= json.originalResult.length);
  23699. }
  23700. json.candidate = [];
  23701. json.keyField = [];
  23702. if (typeof json.originalResult != 'object') {
  23703. self.prop.xhr = null;
  23704. self.notFoundSearch(self);
  23705. return;
  23706. }
  23707. json.cnt_page = json.originalResult.length;
  23708. for (var i = 0; i < json.cnt_page; i++) {
  23709. for (var key in json.originalResult[i]) {
  23710. if (key == p.keyField) {
  23711. json.keyField.push(json.originalResult[i][key]);
  23712. }
  23713. if (key == p.showField) {
  23714. json.candidate.push(json.originalResult[i][key]);
  23715. }
  23716. }
  23717. }
  23718. self.prepareResults(self, json, q_word, which_page_num);
  23719. },
  23720. error: function (jqXHR, textStatus, errorThrown) {
  23721. if (textStatus != 'abort') {
  23722. self.hideResults(self);
  23723. self.ajaxErrorNotify(self, errorThrown);
  23724. }
  23725. },
  23726. complete: function () {
  23727. self.prop.xhr = null;
  23728. }
  23729. });
  23730. };
  23731. /**
  23732. * Search for json data source
  23733. * @param {Object} self
  23734. * @param {Array} q_word
  23735. * @param {number} which_page_num
  23736. */
  23737. SelectPage.prototype.searchForJson = function (self, q_word, which_page_num) {
  23738. var p = self.option, matched = [], esc_q = [], sorted = [], json = {}, i = 0, arr_reg = [];
  23739. //query keyword filter
  23740. do {
  23741. //'/\W/g'正则代表全部不是字母,数字,下划线,汉字的字符
  23742. //将非法字符进行转义
  23743. esc_q[i] = q_word[i].replace(/\W/g, '\\$&').toString();
  23744. arr_reg[i] = new RegExp(esc_q[i], 'gi');
  23745. i++;
  23746. } while (i < q_word.length);
  23747. // SELECT * FROM data WHERE field LIKE q_word;
  23748. for (var i = 0; i < p.data.length; i++) {
  23749. var flag = false, row = p.data[i], itemText;
  23750. for (var j = 0; j < arr_reg.length; j++) {
  23751. itemText = row[p.searchField];
  23752. if (p.formatItem && $.isFunction(p.formatItem))
  23753. itemText = p.formatItem(row);
  23754. if (itemText.match(arr_reg[j])) {
  23755. flag = true;
  23756. if (p.andOr == 'OR') break;
  23757. } else {
  23758. flag = false;
  23759. if (p.andOr == 'AND') break;
  23760. }
  23761. }
  23762. if (flag) matched.push(row);
  23763. }
  23764. // (CASE WHEN ...) then く order some column
  23765. if (p.orderBy === false) sorted = matched.concat();
  23766. else {
  23767. var reg1 = new RegExp('^' + esc_q[0] + '$', 'gi'),
  23768. reg2 = new RegExp('^' + esc_q[0], 'gi'),
  23769. matched1 = [], matched2 = [], matched3 = [];
  23770. for (var i = 0; i < matched.length; i++) {
  23771. var orderField = p.orderBy[0][0];
  23772. var orderValue = String(matched[i][orderField]);
  23773. if (orderValue.match(reg1)) {
  23774. matched1.push(matched[i]);
  23775. } else if (orderValue.match(reg2)) {
  23776. matched2.push(matched[i]);
  23777. } else {
  23778. matched3.push(matched[i]);
  23779. }
  23780. }
  23781. if (p.orderBy[0][1].match(/^asc$/i)) {
  23782. matched1 = self.sortAsc(self, matched1);
  23783. matched2 = self.sortAsc(self, matched2);
  23784. matched3 = self.sortAsc(self, matched3);
  23785. } else {
  23786. matched1 = self.sortDesc(self, matched1);
  23787. matched2 = self.sortDesc(self, matched2);
  23788. matched3 = self.sortDesc(self, matched3);
  23789. }
  23790. sorted = sorted.concat(matched1).concat(matched2).concat(matched3);
  23791. }
  23792. /*
  23793. if (sorted.length === undefined || sorted.length === 0 ) {
  23794. self.notFoundSearch(self);
  23795. return;
  23796. }
  23797. */
  23798. json.cnt_whole = sorted.length;
  23799. //page_move used to distinguish between init plugin or page moving
  23800. if (!self.prop.page_move) {
  23801. //only single mode can be used page number relocation
  23802. if (!p.multiple) {
  23803. //get selected item belong page number
  23804. var currentValue = self.elem.hidden.val();
  23805. if ($.type(currentValue) !== 'undefined' && $.trim(currentValue) !== '') {
  23806. var index = 0;
  23807. $.each(sorted, function (i, row) {
  23808. if (row[p.keyField] == currentValue) {
  23809. index = i + 1;
  23810. return false;
  23811. }
  23812. });
  23813. which_page_num = Math.ceil(index / p.pageSize);
  23814. if (which_page_num < 1) which_page_num = 1;
  23815. self.prop.current_page = which_page_num;
  23816. }
  23817. }
  23818. } else {
  23819. //set page number to 1 when result number less then page size
  23820. if (sorted.length <= ((which_page_num - 1) * p.pageSize)) {
  23821. which_page_num = 1;
  23822. self.prop.current_page = 1;
  23823. }
  23824. }
  23825. //LIMIT xx OFFSET xx
  23826. var start = (which_page_num - 1) * p.pageSize, end = start + p.pageSize;
  23827. //save original data
  23828. json.originalResult = [];
  23829. //after data filter handle
  23830. for (var i = start; i < end; i++) {
  23831. if (sorted[i] === undefined) break;
  23832. json.originalResult.push(sorted[i]);
  23833. for (var key in sorted[i]) {
  23834. if (key == p.keyField) {
  23835. if (json.keyField === undefined) json.keyField = [];
  23836. json.keyField.push(sorted[i][key]);
  23837. }
  23838. if (key == p.showField) {
  23839. if (json.candidate === undefined) json.candidate = [];
  23840. json.candidate.push(sorted[i][key]);
  23841. }
  23842. }
  23843. }
  23844. if (json.candidate === undefined) json.candidate = [];
  23845. json.cnt_page = json.candidate.length;
  23846. self.prepareResults(self, json, q_word, which_page_num);
  23847. };
  23848. /**
  23849. * Set order asc
  23850. * @param {Object} self
  23851. * @param {Array} arr - result array
  23852. */
  23853. SelectPage.prototype.sortAsc = function (self, arr) {
  23854. arr.sort(function (a, b) {
  23855. var valA = a[self.option.orderBy[0][0]], valB = b[self.option.orderBy[0][0]];
  23856. return $.type(valA) === 'number' ? valA - valB : String(valA).localeCompare(String(valB));
  23857. });
  23858. return arr;
  23859. };
  23860. /**
  23861. * Set order desc
  23862. * @param {Object} self
  23863. * @param {Array} arr - result array
  23864. */
  23865. SelectPage.prototype.sortDesc = function (self, arr) {
  23866. arr.sort(function (a, b) {
  23867. var valA = a[self.option.orderBy[0][0]], valB = b[self.option.orderBy[0][0]];
  23868. return $.type(valA) === 'number' ? valB - valA : String(valB).localeCompare(String(valA));
  23869. });
  23870. return arr;
  23871. };
  23872. /**
  23873. * Not result found handle
  23874. * @param {Object} self
  23875. */
  23876. SelectPage.prototype.notFoundSearch = function (self) {
  23877. self.elem.results.empty();
  23878. self.calcResultsSize(self);
  23879. self.setOpenStatus(self, true);
  23880. self.setCssFocusedInput(self);
  23881. };
  23882. /**
  23883. * Prepare data to show
  23884. * @param {Object} self
  23885. * @param {Object} json - data result
  23886. * @param {Array} q_word - query keyword
  23887. * @param {number} which_page_num - target page number
  23888. */
  23889. SelectPage.prototype.prepareResults = function (self, json, q_word, which_page_num) {
  23890. self.data = json.originalResult;
  23891. if (self.option.pagination) self.setNavi(self, json.cnt_whole, json.cnt_page, which_page_num);
  23892. if (!json.keyField) json.keyField = false;
  23893. if (self.option.selectOnly && json.candidate.length === 1 && json.candidate[0] == q_word[0]) {
  23894. self.elem.hidden.val(json.keyField[0]);
  23895. this.setButtonAttrDefault();
  23896. }
  23897. var is_query = false;
  23898. if (q_word && q_word.length && q_word[0]) is_query = true;
  23899. self.displayResults(self, json, is_query);
  23900. };
  23901. /**
  23902. * Build page bar
  23903. * @param {Object} self
  23904. * @param {number} cnt_whole - total record count
  23905. * @param {number} cnt_page
  23906. * @param {number} page_num - current page number
  23907. */
  23908. SelectPage.prototype.setNavi = function (self, cnt_whole, cnt_page, page_num) {
  23909. var msg = self.message;
  23910. /**
  23911. * build pagination bar
  23912. */
  23913. var buildPageNav = function (self, pagebar, page_num, last_page) {
  23914. var updatePageInfo = function () {
  23915. var pageInfo = msg.page_info;
  23916. return pageInfo.replace(self.template.page.current, page_num).replace(self.template.page.total, last_page);
  23917. };
  23918. if (pagebar.find('li').length === 0) {
  23919. pagebar.hide().empty();
  23920. var iconFist = 'spfont sp-first',
  23921. iconPrev = 'spfont sp-previous',
  23922. iconNext = 'spfont sp-next',
  23923. iconLast = 'spfont sp-last';
  23924. pagebar.append('<li class="csFirstPage" title="' + msg.first_title + '" ><a href="javascript:void(0);"> <i class="' + iconFist + '"></i> </a></li>');
  23925. pagebar.append('<li class="csPreviousPage" title="' + msg.prev_title + '" ><a href="javascript:void(0);"><i class="' + iconPrev + '"></i></a></li>');
  23926. //pagination information
  23927. pagebar.append('<li class="pageInfoBox"><a href="javascript:void(0);"> ' + updatePageInfo() + ' </a></li>');
  23928. pagebar.append('<li class="csNextPage" title="' + msg.next_title + '" ><a href="javascript:void(0);"><i class="' + iconNext + '"></i></a></li>');
  23929. pagebar.append('<li class="csLastPage" title="' + msg.last_title + '" ><a href="javascript:void(0);"> <i class="' + iconLast + '"></i> </a></li>');
  23930. pagebar.show();
  23931. } else {
  23932. pagebar.find('li.pageInfoBox a').html(updatePageInfo());
  23933. }
  23934. };
  23935. var pagebar = self.elem.navi.find('ul'),
  23936. last_page = Math.ceil(cnt_whole / self.option.pageSize); //calculate total page
  23937. if (last_page === 0) page_num = 0;
  23938. else {
  23939. if (last_page < page_num) page_num = last_page;
  23940. else if (page_num === 0) page_num = 1;
  23941. }
  23942. self.prop.current_page = page_num;//update current page number
  23943. self.prop.max_page = last_page;//update page count
  23944. buildPageNav(self, pagebar, page_num, last_page);
  23945. //update paging status
  23946. var dClass = 'disabled',
  23947. first = pagebar.find('li.csFirstPage'),
  23948. previous = pagebar.find('li.csPreviousPage'),
  23949. next = pagebar.find('li.csNextPage'),
  23950. last = pagebar.find('li.csLastPage');
  23951. //first and previous
  23952. if (page_num === 1 || page_num === 0) {
  23953. if (!first.hasClass(dClass)) first.addClass(dClass);
  23954. if (!previous.hasClass(dClass)) previous.addClass(dClass);
  23955. } else {
  23956. if (first.hasClass(dClass)) first.removeClass(dClass);
  23957. if (previous.hasClass(dClass)) previous.removeClass(dClass);
  23958. }
  23959. //next and last
  23960. if (page_num === last_page || last_page === 0) {
  23961. if (!next.hasClass(dClass)) next.addClass(dClass);
  23962. if (!last.hasClass(dClass)) last.addClass(dClass);
  23963. } else {
  23964. if (next.hasClass(dClass)) next.removeClass(dClass);
  23965. if (last.hasClass(dClass)) last.removeClass(dClass);
  23966. }
  23967. if (last_page > 1) self.ePaging(); //pagination event bind
  23968. };
  23969. /**
  23970. * Render result list
  23971. * @param {Object} self
  23972. * @param {Object} json - result data
  23973. * @param {boolean} is_query - used to different from search to open and just click to open
  23974. */
  23975. SelectPage.prototype.displayResults = function (self, json, is_query) {
  23976. var p = self.option, el = self.elem;
  23977. el.results.hide().empty();
  23978. if (p.multiple && $.type(p.maxSelectLimit) === 'number' && p.maxSelectLimit > 0) {
  23979. var selectedSize = el.element_box.find('li.selected_tag').length;
  23980. if (selectedSize > 0 && selectedSize >= p.maxSelectLimit) {
  23981. var msg = self.message.max_selected;
  23982. self.showMessage(self, msg.replace(self.template.msg.maxSelectLimit, p.maxSelectLimit));
  23983. return;
  23984. }
  23985. }
  23986. if (json.candidate.length) {
  23987. var arr_candidate = json.candidate,
  23988. arr_primary_key = json.keyField,
  23989. keystr = el.hidden.val(),
  23990. keyArr = keystr ? keystr.split(',') : new Array(),
  23991. itemText = '';
  23992. for (var i = 0; i < arr_candidate.length; i++) {
  23993. if (p.formatItem && $.isFunction(p.formatItem)) {
  23994. try {
  23995. itemText = p.formatItem(json.originalResult[i]);
  23996. } catch (e) {
  23997. console.error('formatItem内容格式化函数内容设置不正确!');
  23998. itemText = arr_candidate[i];
  23999. }
  24000. } else itemText = arr_candidate[i];
  24001. var list = $('<li>').html(itemText).attr({
  24002. pkey: arr_primary_key[i],
  24003. index: i
  24004. });
  24005. if (!p.formatItem) list.attr('title', itemText);
  24006. //Set selected item highlight
  24007. if ($.inArray(arr_primary_key[i].toString(), keyArr) !== -1) {
  24008. list.addClass(self.css_class.selected);
  24009. }
  24010. //cache item data
  24011. list.data('dataObj', json.originalResult[i]);
  24012. el.results.append(list);
  24013. }
  24014. } else {
  24015. var li = '<li class="' + self.css_class.message_box + '"><i class="spfont sp-warning"></i> ' +
  24016. self.message.not_found + '</li>';
  24017. el.results.append(li);
  24018. }
  24019. el.results.show();
  24020. if (p.multiple && p.multipleControlbar) el.control.show();
  24021. if (p.pagination) el.navi.show();
  24022. self.calcResultsSize(self);
  24023. self.setOpenStatus(self, true);
  24024. //Result item event bind
  24025. self.eResultList();
  24026. //scrolling listen
  24027. self.eScroll();
  24028. //auto highlight first item in search, have result and set autoSelectFirst to true situation
  24029. if (is_query && json.candidate.length && p.autoSelectFirst) self.nextLine(self);
  24030. };
  24031. /**
  24032. * Calculate result list size and position
  24033. * @param {Object} self
  24034. */
  24035. SelectPage.prototype.calcResultsSize = function (self) {
  24036. var p = self.option, el = self.elem;
  24037. var rePosition = function () {
  24038. if (el.container.css('position') === 'static') {
  24039. // position: static
  24040. var offset = el.combo_input.offset();
  24041. el.result_area.css({
  24042. top: offset.top + el.combo_input.outerHeight() + 'px',
  24043. left: offset.left + 'px'
  24044. });
  24045. } else {
  24046. if (!p.pagination) {
  24047. var itemHeight = el.results.find('li:first').outerHeight(true),
  24048. listHeight = itemHeight * p.listSize;
  24049. el.results.css({
  24050. 'max-height': listHeight,
  24051. 'overflow-y': 'auto'
  24052. });
  24053. }
  24054. //handle result list show up side(left, right, up or down)
  24055. var docWidth = $(document).width(),
  24056. docHeight = $(document).height(), //the document full height
  24057. viewHeight = $(window).height(), //browser visible area height
  24058. offset = el.container.offset(),
  24059. screenScrollTop = $(window).scrollTop(),
  24060. listWidth = el.result_area.outerWidth(),
  24061. //result list height
  24062. listHeight = el.result_area.outerHeight(),
  24063. //default left used input element left
  24064. defaultLeft = offset.left, //p.multiple ? -1 : 0;
  24065. //input element height
  24066. inputHeight = el.container.outerHeight(),
  24067. left = (offset.left + listWidth) > docWidth ?
  24068. defaultLeft - (listWidth - el.container.outerWidth()) :
  24069. defaultLeft,
  24070. //the actual top coordinate of input element(outer div)
  24071. screenTop = offset.top, //$(el.container).scrollTop();//offset.top - screenScrollTop;
  24072. top = 0, dist = 5, //set distance between input element and result list
  24073. //the actual top coordinate of result list
  24074. listBottom = screenTop + inputHeight + listHeight + dist,
  24075. listTop = screenTop + listHeight + dist,
  24076. hasOverflow = docHeight > viewHeight;
  24077. if ((screenTop - screenScrollTop - dist > listHeight) &&
  24078. (hasOverflow && listBottom > (viewHeight + screenScrollTop)) ||
  24079. (!hasOverflow && listBottom > viewHeight && screenTop >= listTop)) {
  24080. //open up
  24081. top = offset.top - listHeight - dist;
  24082. el.result_area.removeClass('shadowUp shadowDown').addClass('shadowUp');
  24083. } else {
  24084. //open down
  24085. top = offset.top + (p.multiple ? el.container.outerHeight() : inputHeight);
  24086. el.result_area.removeClass('shadowUp shadowDown').addClass('shadowDown');
  24087. top += dist;
  24088. }
  24089. return {
  24090. top: top + 'px', left: left + 'px'
  24091. };
  24092. }
  24093. };
  24094. if (el.result_area.is(':visible')) {
  24095. el.result_area.css(rePosition());
  24096. } else {
  24097. var pss = rePosition();
  24098. el.result_area.css(pss).show(1, function () {
  24099. var repss = rePosition();
  24100. if (pss.top !== repss.top || pss.left !== repss.left) el.result_area.css(repss);
  24101. });
  24102. }
  24103. };
  24104. /**
  24105. * hide result list
  24106. * @param {Object} self
  24107. */
  24108. SelectPage.prototype.hideResults = function (self) {
  24109. if (self.prop.key_paging) {
  24110. self.scrollWindow(self, true);
  24111. self.prop.key_paging = false;
  24112. }
  24113. self.setCssFocusedInput(self);
  24114. if (self.option.autoFillResult) {
  24115. //self.selectCurrentLine(self, true);
  24116. }
  24117. self.elem.results.empty();
  24118. self.elem.result_area.hide();
  24119. self.setOpenStatus(self, false);
  24120. //unbind window scroll listen
  24121. $(window).off('scroll.SelectPage');
  24122. self.abortAjax(self);
  24123. self.setButtonAttrDefault();
  24124. };
  24125. /**
  24126. * set plugin to disabled / enabled
  24127. * @param self
  24128. * @param disabled
  24129. */
  24130. SelectPage.prototype.disabled = function (self, disabled) {
  24131. var p = self.option, el = self.elem;
  24132. if ($.type(disabled) === 'undefined') return el.combo_input.prop('disabled');
  24133. if ($.type(disabled) === 'boolean') {
  24134. el.combo_input.prop('disabled', disabled);
  24135. if (disabled) el.container.addClass(self.css_class.disabled);
  24136. else el.container.removeClass(self.css_class.disabled);
  24137. }
  24138. };
  24139. /**
  24140. * Go fist page
  24141. * @param {Object} self
  24142. */
  24143. SelectPage.prototype.firstPage = function (self) {
  24144. if (self.prop.current_page > 1) {
  24145. self.prop.current_page = 1;
  24146. self.prop.page_move = true;
  24147. self.suggest(self);
  24148. }
  24149. };
  24150. /**
  24151. * Go previous page
  24152. * @param {Object} self
  24153. */
  24154. SelectPage.prototype.prevPage = function (self) {
  24155. if (self.prop.current_page > 1) {
  24156. self.prop.current_page--;
  24157. self.prop.page_move = true;
  24158. self.suggest(self);
  24159. }
  24160. };
  24161. /**
  24162. * Go next page
  24163. * @param {Object} self
  24164. */
  24165. SelectPage.prototype.nextPage = function (self) {
  24166. if (self.prop.current_page < self.prop.max_page) {
  24167. self.prop.current_page++;
  24168. self.prop.page_move = true;
  24169. self.suggest(self);
  24170. }
  24171. };
  24172. /**
  24173. * Go last page
  24174. * @param {Object} self
  24175. */
  24176. SelectPage.prototype.lastPage = function (self) {
  24177. if (self.prop.current_page < self.prop.max_page) {
  24178. self.prop.current_page = self.prop.max_page;
  24179. self.prop.page_move = true;
  24180. self.suggest(self);
  24181. }
  24182. };
  24183. /**
  24184. * do something after select/unSelect action
  24185. * @param {Object} self
  24186. * @param {boolean} reOpen
  24187. */
  24188. SelectPage.prototype.afterAction = function (self, reOpen) {
  24189. self.inputResize(self);
  24190. self.elem.combo_input.change();
  24191. self.setCssFocusedInput(self);
  24192. if (self.prop.init_set) return;
  24193. if (self.option.multiple) {
  24194. if (self.option.selectToCloseList) {
  24195. self.hideResults(self);
  24196. self.elem.combo_input.blur();
  24197. }
  24198. if (!self.option.selectToCloseList && reOpen) {
  24199. self.suggest(self);
  24200. self.elem.combo_input.focus();
  24201. }
  24202. } else {
  24203. self.hideResults(self);
  24204. self.elem.combo_input.blur();
  24205. }
  24206. };
  24207. /**
  24208. * Select current list item
  24209. * @param {Object} self
  24210. * @param {boolean} is_enter_key
  24211. */
  24212. SelectPage.prototype.selectCurrentLine = function (self, is_enter_key) {
  24213. self.scrollWindow(self, true);
  24214. var p = self.option, current = self.getCurrentLine(self);
  24215. if (current) {
  24216. var data = current.data('dataObj');
  24217. var text = data[p.showField] || current.text();
  24218. var value = current.attr('pkey');
  24219. if (!p.multiple) {
  24220. self.elem.combo_input.val(text);
  24221. self.elem.hidden.val(value);
  24222. } else {
  24223. //build tags in multiple selection mode
  24224. self.elem.combo_input.val('');
  24225. var item = {text: text, value: value};
  24226. if (!self.isAlreadySelected(self, item)) {
  24227. self.addNewTag(self, data, item);
  24228. self.tagValuesSet(self);
  24229. }
  24230. }
  24231. if (p.selectOnly) self.setButtonAttrDefault();
  24232. //Select item callback
  24233. if (p.eSelect && $.isFunction(p.eSelect)) p.eSelect(data, self);
  24234. self.prop.prev_value = self.elem.combo_input.val();
  24235. self.prop.selected_text = self.elem.combo_input.val();
  24236. self.putClearButton();
  24237. }
  24238. self.afterAction(self, true);
  24239. };
  24240. /**
  24241. * Show clear button when item selected in single selection mode
  24242. */
  24243. SelectPage.prototype.putClearButton = function () {
  24244. if (!this.option.multiple && !this.elem.combo_input.prop('disabled')) this.elem.container.append(this.elem.clear_btn);
  24245. };
  24246. /**
  24247. * Select all list item
  24248. * @param {Object} self
  24249. */
  24250. SelectPage.prototype.selectAllLine = function (self) {
  24251. var p = self.option, jsonarr = new Array();
  24252. self.elem.results.find('li').each(function (i, row) {
  24253. var $row = $(row), data = $row.data('dataObj');
  24254. var text = data[p.showField] || $row.text();
  24255. var value = $row.attr('pkey');
  24256. var item = {text: text, value: value};
  24257. if (!self.isAlreadySelected(self, item)) {
  24258. self.addNewTag(self, data, item);
  24259. self.tagValuesSet(self);
  24260. }
  24261. jsonarr.push(data);
  24262. //limited max selected items
  24263. if ($.type(p.maxSelectLimit) === 'number' &&
  24264. p.maxSelectLimit > 0 &&
  24265. p.maxSelectLimit === self.elem.element_box.find('li.selected_tag').length) {
  24266. return false;
  24267. }
  24268. });
  24269. if (p.eSelect && $.isFunction(p.eSelect)) p.eSelect(jsonarr, self);
  24270. self.afterAction(self, true);
  24271. };
  24272. /**
  24273. * Cancel select all item in current page
  24274. * @param {Object} self
  24275. */
  24276. SelectPage.prototype.unSelectAllLine = function (self) {
  24277. var p = self.option, size = self.elem.results.find('li').length, ds = [];
  24278. self.elem.results.find('li').each(function (i, row) {
  24279. var key = $(row).attr('pkey');
  24280. var tag = self.elem.element_box.find('li.selected_tag[itemvalue="' + key + '"]');
  24281. if (tag.length) ds.push(tag.data('dataObj'));
  24282. self.removeTag(self, tag);
  24283. });
  24284. self.afterAction(self, true);
  24285. if (p.eTagRemove && $.isFunction(p.eTagRemove)) p.eTagRemove(ds);
  24286. };
  24287. /**
  24288. * Clear all selected items
  24289. * @param {Object} self
  24290. * @param {boolean} open - open list after clear selected item
  24291. */
  24292. SelectPage.prototype.clearAll = function (self, open) {
  24293. var p = self.option, ds = [];
  24294. if (p.multiple) {
  24295. self.elem.element_box.find('li.selected_tag').each(function (i, row) {
  24296. ds.push($(row).data('dataObj'));
  24297. row.remove();
  24298. });
  24299. self.elem.element_box.find('li.selected_tag').remove();
  24300. }
  24301. self.reset(self);
  24302. self.afterAction(self, open);
  24303. if (p.multiple) {
  24304. if (p.eTagRemove && $.isFunction(p.eTagRemove)) p.eTagRemove(ds);
  24305. } else self.elem.clear_btn.remove();
  24306. };
  24307. /**
  24308. * reset
  24309. */
  24310. SelectPage.prototype.reset = function (self) {
  24311. self.elem.combo_input.val('');
  24312. self.elem.hidden.val('');
  24313. self.prop.prev_value = '';
  24314. self.prop.selected_text = '';
  24315. self.prop.current_page = 1;
  24316. };
  24317. /**
  24318. * Get current highlight item
  24319. * @param {Object} self
  24320. */
  24321. SelectPage.prototype.getCurrentLine = function (self) {
  24322. if (self.elem.result_area.is(':hidden')) return false;
  24323. var obj = self.elem.results.find('li.' + self.css_class.select);
  24324. if (obj.length) return obj;
  24325. else return false;
  24326. };
  24327. /**
  24328. * Check the result item is already selected or not
  24329. * @param {Object} self
  24330. * @param {Object} item - item info
  24331. */
  24332. SelectPage.prototype.isAlreadySelected = function (self, item) {
  24333. var isExist = false;
  24334. if (item.value) {
  24335. var keys = self.elem.hidden.val();
  24336. if (keys) {
  24337. var karr = keys.split(',');
  24338. if (karr && karr.length && $.inArray(item.value, karr) != -1) isExist = true;
  24339. }
  24340. }
  24341. return isExist;
  24342. };
  24343. /**
  24344. * Add a new tag in multiple selection mode
  24345. * @param {Object} self
  24346. * @param {object} data - raw row data
  24347. * @param {Object} item
  24348. */
  24349. SelectPage.prototype.addNewTag = function (self, data, item) {
  24350. if (!self.option.multiple || !data || !item) return;
  24351. var tmp = self.template.tag.content, tag;
  24352. tmp = tmp.replace(self.template.tag.textKey, item.text);
  24353. tmp = tmp.replace(self.template.tag.valueKey, item.value);
  24354. tag = $(tmp);
  24355. tag.data('dataObj', data);
  24356. if (self.elem.combo_input.prop('disabled')) tag.find('span.tag_close').hide();
  24357. self.elem.combo_input.closest('li').before(tag);
  24358. };
  24359. /**
  24360. * Remove a tag in multiple selection mode
  24361. * @param {Object} self
  24362. * @param {Object} item
  24363. */
  24364. SelectPage.prototype.removeTag = function (self, item) {
  24365. var key = $(item).attr('itemvalue');
  24366. var keys = self.elem.hidden.val();
  24367. if ($.type(key) != 'undefined' && keys) {
  24368. var keyarr = keys.split(','),
  24369. index = $.inArray(key.toString(), keyarr);
  24370. if (index != -1) {
  24371. keyarr.splice(index, 1);
  24372. self.elem.hidden.val(keyarr.toString()).trigger("change");
  24373. }
  24374. }
  24375. $(item).remove();
  24376. self.inputResize(self);
  24377. };
  24378. /**
  24379. * Selected item value(keyField) put in to hidden element
  24380. * @param {Object} self
  24381. */
  24382. SelectPage.prototype.tagValuesSet = function (self) {
  24383. if (!self.option.multiple) return;
  24384. var tags = self.elem.element_box.find('li.selected_tag');
  24385. if (tags && tags.length) {
  24386. var result = new Array();
  24387. $.each(tags, function (i, li) {
  24388. var v = $(li).attr('itemvalue');
  24389. if ($.type(v) !== 'undefined') result.push(v);
  24390. });
  24391. if (result.length) {
  24392. self.elem.hidden.val(result.join(',')).trigger("change");
  24393. }
  24394. }
  24395. };
  24396. /**
  24397. * auto resize input element width in multiple select mode
  24398. * @param {Object} self
  24399. */
  24400. SelectPage.prototype.inputResize = function (self) {
  24401. if (!self.option.multiple) return;
  24402. var width = '',
  24403. inputLi = self.elem.combo_input.closest('li');
  24404. var setDefaultSize = function (self, inputLi) {
  24405. inputLi.removeClass('full_width');
  24406. var minimumWidth = self.elem.combo_input.val().length + 1,
  24407. width = (minimumWidth * 0.75) + 'em';
  24408. self.elem.combo_input.css('width', width).removeAttr('placeholder');
  24409. };
  24410. if (self.elem.element_box.find('li.selected_tag').length === 0) {
  24411. if (!inputLi.hasClass('full_width')) inputLi.addClass('full_width');
  24412. if (self.elem.combo_input.attr('placeholder_bak')) {
  24413. self.elem.combo_input.attr('placeholder', self.elem.combo_input.attr('placeholder_bak')).removeAttr('style');
  24414. }
  24415. } else setDefaultSize(self, inputLi);
  24416. };
  24417. /**
  24418. * Move to next line
  24419. * @param {Object} self
  24420. */
  24421. SelectPage.prototype.nextLine = function (self) {
  24422. var obj = self.getCurrentLine(self), idx;
  24423. if (!obj) idx = -1;
  24424. else {
  24425. idx = self.elem.results.children('li').index(obj);
  24426. obj.removeClass(self.css_class.select);
  24427. }
  24428. idx++;
  24429. if (idx < self.elem.results.children('li').length) {
  24430. var next = self.elem.results.children('li').eq(idx);
  24431. next.addClass(self.css_class.select);
  24432. self.setCssFocusedResults(self);
  24433. } else self.setCssFocusedInput(self);
  24434. self.scrollWindow(self, false);
  24435. };
  24436. /**
  24437. * Move to previous line
  24438. * @param {Object} self
  24439. */
  24440. SelectPage.prototype.prevLine = function (self) {
  24441. var obj = self.getCurrentLine(self), idx;
  24442. if (!obj) idx = self.elem.results.children('li').length;
  24443. else {
  24444. idx = self.elem.results.children('li').index(obj);
  24445. obj.removeClass(self.css_class.select);
  24446. }
  24447. idx--;
  24448. if (idx > -1) {
  24449. var prev = self.elem.results.children('li').eq(idx);
  24450. prev.addClass(self.css_class.select);
  24451. self.setCssFocusedResults(self);
  24452. } else self.setCssFocusedInput(self);
  24453. self.scrollWindow(self, false);
  24454. };
  24455. /**
  24456. * SelectPage plugin definition
  24457. * @global
  24458. * @param option {Object} init plugin option
  24459. */
  24460. function Plugin(option) {
  24461. return this.each(function () {
  24462. var $this = $(this),
  24463. data = $this.data(SelectPage.dataKey),
  24464. params = $.extend({}, defaults, $this.data(), data && data.option, typeof option === 'object' && option);
  24465. if (!data) $this.data(SelectPage.dataKey, (data = new SelectPage(this, params)));
  24466. });
  24467. }
  24468. /**
  24469. * Get plugin object
  24470. * @param {object} obj
  24471. * @returns
  24472. */
  24473. function getPlugin(obj) {
  24474. return $(obj).closest('div.sp_container').find('input.sp_input');
  24475. }
  24476. /**
  24477. * Clear all selected item
  24478. */
  24479. function ClearSelected() {
  24480. return this.each(function () {
  24481. var $this = getPlugin(this),
  24482. data = $this.data(SelectPage.dataKey);
  24483. if (data) {
  24484. data.prop.init_set = true;
  24485. data.clearAll(data);
  24486. data.prop.init_set = false;
  24487. }
  24488. });
  24489. }
  24490. /**
  24491. * Refresh result list
  24492. * use case:
  24493. * 1.use $(obj).val('xxx') to modify selectpage selected item key
  24494. * 2.refresh selected item show content/tag text
  24495. */
  24496. function SelectedRefresh() {
  24497. return this.each(function () {
  24498. var $this = getPlugin(this),
  24499. data = $this.data(SelectPage.dataKey);
  24500. if (data && data.elem.hidden.val())
  24501. data.setInitRecord(true);
  24502. });
  24503. }
  24504. /**
  24505. * Modify plugin datasource, only work on json datasource mode
  24506. * @param {array} data - new datasource
  24507. * @example
  24508. * [{name:'aa',sex:1},{name:'bb',sex:0},{...}]
  24509. */
  24510. function ModifyDataSource(data) {
  24511. return this.each(function () {
  24512. if (data && $.isArray(data)) {
  24513. var $this = getPlugin(this),
  24514. plugin = $this.data(SelectPage.dataKey);
  24515. if (plugin) {
  24516. plugin.clearAll(plugin);
  24517. plugin.option.data = data;
  24518. }
  24519. }
  24520. });
  24521. }
  24522. /**
  24523. * Get plugin disabled status or Modify plugin disabled status
  24524. * @param disabled {boolean} set disabled status
  24525. */
  24526. function PluginDisabled(disabled) {
  24527. var status = false;
  24528. this.each(function () {
  24529. var $this = getPlugin(this),
  24530. plugin = $this.data(SelectPage.dataKey);
  24531. if (plugin) {
  24532. if ($.type(disabled) !== 'undefined')
  24533. plugin.disabled(plugin, disabled);
  24534. else
  24535. status = plugin.disabled(plugin);
  24536. }
  24537. });
  24538. return status;
  24539. }
  24540. /**
  24541. * Get selected item text
  24542. * @returns {string}
  24543. */
  24544. function GetInputText() {
  24545. var str = '';
  24546. this.each(function () {
  24547. var $this = getPlugin(this), data = $this.data(SelectPage.dataKey);
  24548. if (data) {
  24549. if (data.option.multiple) {
  24550. var tags = [];
  24551. data.elem.element_box.find('li.selected_tag').each(function (i, tag) {
  24552. tags.push($(tag).text());
  24553. });
  24554. str += tags.toString();
  24555. } else {
  24556. str += data.elem.combo_input.val();
  24557. }
  24558. }
  24559. });
  24560. return str;
  24561. }
  24562. var old = $.fn.selectPage;
  24563. $.fn.selectPage = Plugin;
  24564. $.fn.selectPage.Constructor = SelectPage;
  24565. $.fn.selectPageClear = ClearSelected;
  24566. $.fn.selectPageRefresh = SelectedRefresh;
  24567. $.fn.selectPageData = ModifyDataSource;
  24568. $.fn.selectPageDisabled = PluginDisabled;
  24569. $.fn.selectPageText = GetInputText;
  24570. // SelectPage no conflict
  24571. // =================
  24572. $.fn.selectPage.noConflict = function () {
  24573. $.fn.selectPage = old;
  24574. return this;
  24575. };
  24576. })(window.jQuery);
  24577. define("selectpage", function () {
  24578. });