require-built.js 1.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041
  1. /** vim: et:ts=4:sw=4:sts=4
  2. * @license RequireJS 2.1.5 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
  3. * Available via the MIT or new BSD license.
  4. * see: http://github.com/jrburke/requirejs for details
  5. */
  6. //Not using strict: uneven strict support in browsers, #392, and causes
  7. //problems with requirejs.exec()/transpiler plugins that may not be strict.
  8. /*jslint regexp: true, nomen: true, sloppy: true */
  9. /*global window, navigator, document, importScripts, setTimeout, opera */
  10. var requirejs, require, define;
  11. (function (global) {
  12. var req, s, head, baseElement, dataMain, src,
  13. interactiveScript, currentlyAddingScript, mainScript, subPath,
  14. version = '2.1.5',
  15. commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
  16. cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
  17. jsSuffixRegExp = /\.js$/,
  18. currDirRegExp = /^\.\//,
  19. op = Object.prototype,
  20. ostring = op.toString,
  21. hasOwn = op.hasOwnProperty,
  22. ap = Array.prototype,
  23. apsp = ap.splice,
  24. isBrowser = !!(typeof window !== 'undefined' && navigator && document),
  25. isWebWorker = !isBrowser && typeof importScripts !== 'undefined',
  26. //PS3 indicates loaded and complete, but need to wait for complete
  27. //specifically. Sequence is 'loading', 'loaded', execution,
  28. // then 'complete'. The UA check is unfortunate, but not sure how
  29. //to feature test w/o causing perf issues.
  30. readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ?
  31. /^complete$/ : /^(complete|loaded)$/,
  32. defContextName = '_',
  33. //Oh the tragedy, detecting opera. See the usage of isOpera for reason.
  34. isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]',
  35. contexts = {},
  36. cfg = {},
  37. globalDefQueue = [],
  38. useInteractive = false;
  39. function isFunction(it) {
  40. return ostring.call(it) === '[object Function]';
  41. }
  42. function isArray(it) {
  43. return ostring.call(it) === '[object Array]';
  44. }
  45. /**
  46. * Helper function for iterating over an array. If the func returns
  47. * a true value, it will break out of the loop.
  48. */
  49. function each(ary, func) {
  50. if (ary) {
  51. var i;
  52. for (i = 0; i < ary.length; i += 1) {
  53. if (ary[i] && func(ary[i], i, ary)) {
  54. break;
  55. }
  56. }
  57. }
  58. }
  59. /**
  60. * Helper function for iterating over an array backwards. If the func
  61. * returns a true value, it will break out of the loop.
  62. */
  63. function eachReverse(ary, func) {
  64. if (ary) {
  65. var i;
  66. for (i = ary.length - 1; i > -1; i -= 1) {
  67. if (ary[i] && func(ary[i], i, ary)) {
  68. break;
  69. }
  70. }
  71. }
  72. }
  73. function hasProp(obj, prop) {
  74. return hasOwn.call(obj, prop);
  75. }
  76. function getOwn(obj, prop) {
  77. return hasProp(obj, prop) && obj[prop];
  78. }
  79. /**
  80. * Cycles over properties in an object and calls a function for each
  81. * property value. If the function returns a truthy value, then the
  82. * iteration is stopped.
  83. */
  84. function eachProp(obj, func) {
  85. var prop;
  86. for (prop in obj) {
  87. if (hasProp(obj, prop)) {
  88. if (func(obj[prop], prop)) {
  89. break;
  90. }
  91. }
  92. }
  93. }
  94. /**
  95. * Simple function to mix in properties from source into target,
  96. * but only if target does not already have a property of the same name.
  97. */
  98. function mixin(target, source, force, deepStringMixin) {
  99. if (source) {
  100. eachProp(source, function (value, prop) {
  101. if (force || !hasProp(target, prop)) {
  102. if (deepStringMixin && typeof value !== 'string') {
  103. if (!target[prop]) {
  104. target[prop] = {};
  105. }
  106. mixin(target[prop], value, force, deepStringMixin);
  107. } else {
  108. target[prop] = value;
  109. }
  110. }
  111. });
  112. }
  113. return target;
  114. }
  115. //Similar to Function.prototype.bind, but the 'this' object is specified
  116. //first, since it is easier to read/figure out what 'this' will be.
  117. function bind(obj, fn) {
  118. return function () {
  119. return fn.apply(obj, arguments);
  120. };
  121. }
  122. function scripts() {
  123. return document.getElementsByTagName('script');
  124. }
  125. //Allow getting a global that expressed in
  126. //dot notation, like 'a.b.c'.
  127. function getGlobal(value) {
  128. if (!value) {
  129. return value;
  130. }
  131. var g = global;
  132. each(value.split('.'), function (part) {
  133. g = g[part];
  134. });
  135. return g;
  136. }
  137. /**
  138. * Constructs an error with a pointer to an URL with more information.
  139. * @param {String} id the error ID that maps to an ID on a web page.
  140. * @param {String} message human readable error.
  141. * @param {Error} [err] the original error, if there is one.
  142. *
  143. * @returns {Error}
  144. */
  145. function makeError(id, msg, err, requireModules) {
  146. var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' + id);
  147. e.requireType = id;
  148. e.requireModules = requireModules;
  149. if (err) {
  150. e.originalError = err;
  151. }
  152. return e;
  153. }
  154. if (typeof define !== 'undefined') {
  155. //If a define is already in play via another AMD loader,
  156. //do not overwrite.
  157. return;
  158. }
  159. if (typeof requirejs !== 'undefined') {
  160. if (isFunction(requirejs)) {
  161. //Do not overwrite and existing requirejs instance.
  162. return;
  163. }
  164. cfg = requirejs;
  165. requirejs = undefined;
  166. }
  167. //Allow for a require config object
  168. if (typeof require !== 'undefined' && !isFunction(require)) {
  169. //assume it is a config object.
  170. cfg = require;
  171. require = undefined;
  172. }
  173. function newContext(contextName) {
  174. var inCheckLoaded, Module, context, handlers,
  175. checkLoadedTimeoutId,
  176. config = {
  177. //Defaults. Do not set a default for map
  178. //config to speed up normalize(), which
  179. //will run faster if there is no default.
  180. waitSeconds: 7,
  181. baseUrl: './',
  182. paths: {},
  183. pkgs: {},
  184. shim: {},
  185. config: {}
  186. },
  187. registry = {},
  188. //registry of just enabled modules, to speed
  189. //cycle breaking code when lots of modules
  190. //are registered, but not activated.
  191. enabledRegistry = {},
  192. undefEvents = {},
  193. defQueue = [],
  194. defined = {},
  195. urlFetched = {},
  196. requireCounter = 1,
  197. unnormalizedCounter = 1;
  198. /**
  199. * Trims the . and .. from an array of path segments.
  200. * It will keep a leading path segment if a .. will become
  201. * the first path segment, to help with module name lookups,
  202. * which act like paths, but can be remapped. But the end result,
  203. * all paths that use this function should look normalized.
  204. * NOTE: this method MODIFIES the input array.
  205. * @param {Array} ary the array of path segments.
  206. */
  207. function trimDots(ary) {
  208. var i, part;
  209. for (i = 0; ary[i]; i += 1) {
  210. part = ary[i];
  211. if (part === '.') {
  212. ary.splice(i, 1);
  213. i -= 1;
  214. } else if (part === '..') {
  215. if (i === 1 && (ary[2] === '..' || ary[0] === '..')) {
  216. //End of the line. Keep at least one non-dot
  217. //path segment at the front so it can be mapped
  218. //correctly to disk. Otherwise, there is likely
  219. //no path mapping for a path starting with '..'.
  220. //This can still fail, but catches the most reasonable
  221. //uses of ..
  222. break;
  223. } else if (i > 0) {
  224. ary.splice(i - 1, 2);
  225. i -= 2;
  226. }
  227. }
  228. }
  229. }
  230. /**
  231. * Given a relative module name, like ./something, normalize it to
  232. * a real name that can be mapped to a path.
  233. * @param {String} name the relative name
  234. * @param {String} baseName a real name that the name arg is relative
  235. * to.
  236. * @param {Boolean} applyMap apply the map config to the value. Should
  237. * only be done if this normalization is for a dependency ID.
  238. * @returns {String} normalized name
  239. */
  240. function normalize(name, baseName, applyMap) {
  241. var pkgName, pkgConfig, mapValue, nameParts, i, j, nameSegment,
  242. foundMap, foundI, foundStarMap, starI,
  243. baseParts = baseName && baseName.split('/'),
  244. normalizedBaseParts = baseParts,
  245. map = config.map,
  246. starMap = map && map['*'];
  247. //Adjust any relative paths.
  248. if (name && name.charAt(0) === '.') {
  249. //If have a base name, try to normalize against it,
  250. //otherwise, assume it is a top-level require that will
  251. //be relative to baseUrl in the end.
  252. if (baseName) {
  253. if (getOwn(config.pkgs, baseName)) {
  254. //If the baseName is a package name, then just treat it as one
  255. //name to concat the name with.
  256. normalizedBaseParts = baseParts = [baseName];
  257. } else {
  258. //Convert baseName to array, and lop off the last part,
  259. //so that . matches that 'directory' and not name of the baseName's
  260. //module. For instance, baseName of 'one/two/three', maps to
  261. //'one/two/three.js', but we want the directory, 'one/two' for
  262. //this normalization.
  263. normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
  264. }
  265. name = normalizedBaseParts.concat(name.split('/'));
  266. trimDots(name);
  267. //Some use of packages may use a . path to reference the
  268. //'main' module name, so normalize for that.
  269. pkgConfig = getOwn(config.pkgs, (pkgName = name[0]));
  270. name = name.join('/');
  271. if (pkgConfig && name === pkgName + '/' + pkgConfig.main) {
  272. name = pkgName;
  273. }
  274. } else if (name.indexOf('./') === 0) {
  275. // No baseName, so this is ID is resolved relative
  276. // to baseUrl, pull off the leading dot.
  277. name = name.substring(2);
  278. }
  279. }
  280. //Apply map config if available.
  281. if (applyMap && map && (baseParts || starMap)) {
  282. nameParts = name.split('/');
  283. for (i = nameParts.length; i > 0; i -= 1) {
  284. nameSegment = nameParts.slice(0, i).join('/');
  285. if (baseParts) {
  286. //Find the longest baseName segment match in the config.
  287. //So, do joins on the biggest to smallest lengths of baseParts.
  288. for (j = baseParts.length; j > 0; j -= 1) {
  289. mapValue = getOwn(map, baseParts.slice(0, j).join('/'));
  290. //baseName segment has config, find if it has one for
  291. //this name.
  292. if (mapValue) {
  293. mapValue = getOwn(mapValue, nameSegment);
  294. if (mapValue) {
  295. //Match, update name to the new value.
  296. foundMap = mapValue;
  297. foundI = i;
  298. break;
  299. }
  300. }
  301. }
  302. }
  303. if (foundMap) {
  304. break;
  305. }
  306. //Check for a star map match, but just hold on to it,
  307. //if there is a shorter segment match later in a matching
  308. //config, then favor over this star map.
  309. if (!foundStarMap && starMap && getOwn(starMap, nameSegment)) {
  310. foundStarMap = getOwn(starMap, nameSegment);
  311. starI = i;
  312. }
  313. }
  314. if (!foundMap && foundStarMap) {
  315. foundMap = foundStarMap;
  316. foundI = starI;
  317. }
  318. if (foundMap) {
  319. nameParts.splice(0, foundI, foundMap);
  320. name = nameParts.join('/');
  321. }
  322. }
  323. return name;
  324. }
  325. function removeScript(name) {
  326. if (isBrowser) {
  327. each(scripts(), function (scriptNode) {
  328. if (scriptNode.getAttribute('data-requiremodule') === name &&
  329. scriptNode.getAttribute('data-requirecontext') === context.contextName) {
  330. scriptNode.parentNode.removeChild(scriptNode);
  331. return true;
  332. }
  333. });
  334. }
  335. }
  336. function hasPathFallback(id) {
  337. var pathConfig = getOwn(config.paths, id);
  338. if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) {
  339. removeScript(id);
  340. //Pop off the first array value, since it failed, and
  341. //retry
  342. pathConfig.shift();
  343. context.require.undef(id);
  344. context.require([id]);
  345. return true;
  346. }
  347. }
  348. //Turns a plugin!resource to [plugin, resource]
  349. //with the plugin being undefined if the name
  350. //did not have a plugin prefix.
  351. function splitPrefix(name) {
  352. var prefix,
  353. index = name ? name.indexOf('!') : -1;
  354. if (index > -1) {
  355. prefix = name.substring(0, index);
  356. name = name.substring(index + 1, name.length);
  357. }
  358. return [prefix, name];
  359. }
  360. /**
  361. * Creates a module mapping that includes plugin prefix, module
  362. * name, and path. If parentModuleMap is provided it will
  363. * also normalize the name via require.normalize()
  364. *
  365. * @param {String} name the module name
  366. * @param {String} [parentModuleMap] parent module map
  367. * for the module name, used to resolve relative names.
  368. * @param {Boolean} isNormalized: is the ID already normalized.
  369. * This is true if this call is done for a define() module ID.
  370. * @param {Boolean} applyMap: apply the map config to the ID.
  371. * Should only be true if this map is for a dependency.
  372. *
  373. * @returns {Object}
  374. */
  375. function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) {
  376. var url, pluginModule, suffix, nameParts,
  377. prefix = null,
  378. parentName = parentModuleMap ? parentModuleMap.name : null,
  379. originalName = name,
  380. isDefine = true,
  381. normalizedName = '';
  382. //If no name, then it means it is a require call, generate an
  383. //internal name.
  384. if (!name) {
  385. isDefine = false;
  386. name = '_@r' + (requireCounter += 1);
  387. }
  388. nameParts = splitPrefix(name);
  389. prefix = nameParts[0];
  390. name = nameParts[1];
  391. if (prefix) {
  392. prefix = normalize(prefix, parentName, applyMap);
  393. pluginModule = getOwn(defined, prefix);
  394. }
  395. //Account for relative paths if there is a base name.
  396. if (name) {
  397. if (prefix) {
  398. if (pluginModule && pluginModule.normalize) {
  399. //Plugin is loaded, use its normalize method.
  400. normalizedName = pluginModule.normalize(name, function (name) {
  401. return normalize(name, parentName, applyMap);
  402. });
  403. } else {
  404. normalizedName = normalize(name, parentName, applyMap);
  405. }
  406. } else {
  407. //A regular module.
  408. normalizedName = normalize(name, parentName, applyMap);
  409. //Normalized name may be a plugin ID due to map config
  410. //application in normalize. The map config values must
  411. //already be normalized, so do not need to redo that part.
  412. nameParts = splitPrefix(normalizedName);
  413. prefix = nameParts[0];
  414. normalizedName = nameParts[1];
  415. isNormalized = true;
  416. url = context.nameToUrl(normalizedName);
  417. }
  418. }
  419. //If the id is a plugin id that cannot be determined if it needs
  420. //normalization, stamp it with a unique ID so two matching relative
  421. //ids that may conflict can be separate.
  422. suffix = prefix && !pluginModule && !isNormalized ?
  423. '_unnormalized' + (unnormalizedCounter += 1) :
  424. '';
  425. return {
  426. prefix: prefix,
  427. name: normalizedName,
  428. parentMap: parentModuleMap,
  429. unnormalized: !!suffix,
  430. url: url,
  431. originalName: originalName,
  432. isDefine: isDefine,
  433. id: (prefix ?
  434. prefix + '!' + normalizedName :
  435. normalizedName) + suffix
  436. };
  437. }
  438. function getModule(depMap) {
  439. var id = depMap.id,
  440. mod = getOwn(registry, id);
  441. if (!mod) {
  442. mod = registry[id] = new context.Module(depMap);
  443. }
  444. return mod;
  445. }
  446. function on(depMap, name, fn) {
  447. var id = depMap.id,
  448. mod = getOwn(registry, id);
  449. if (hasProp(defined, id) &&
  450. (!mod || mod.defineEmitComplete)) {
  451. if (name === 'defined') {
  452. fn(defined[id]);
  453. }
  454. } else {
  455. getModule(depMap).on(name, fn);
  456. }
  457. }
  458. function onError(err, errback) {
  459. var ids = err.requireModules,
  460. notified = false;
  461. if (errback) {
  462. errback(err);
  463. } else {
  464. each(ids, function (id) {
  465. var mod = getOwn(registry, id);
  466. if (mod) {
  467. //Set error on module, so it skips timeout checks.
  468. mod.error = err;
  469. if (mod.events.error) {
  470. notified = true;
  471. mod.emit('error', err);
  472. }
  473. }
  474. });
  475. if (!notified) {
  476. req.onError(err);
  477. }
  478. }
  479. }
  480. /**
  481. * Internal method to transfer globalQueue items to this context's
  482. * defQueue.
  483. */
  484. function takeGlobalQueue() {
  485. //Push all the globalDefQueue items into the context's defQueue
  486. if (globalDefQueue.length) {
  487. //Array splice in the values since the context code has a
  488. //local var ref to defQueue, so cannot just reassign the one
  489. //on context.
  490. apsp.apply(defQueue,
  491. [defQueue.length - 1, 0].concat(globalDefQueue));
  492. globalDefQueue = [];
  493. }
  494. }
  495. handlers = {
  496. 'require': function (mod) {
  497. if (mod.require) {
  498. return mod.require;
  499. } else {
  500. return (mod.require = context.makeRequire(mod.map));
  501. }
  502. },
  503. 'exports': function (mod) {
  504. mod.usingExports = true;
  505. if (mod.map.isDefine) {
  506. if (mod.exports) {
  507. return mod.exports;
  508. } else {
  509. return (mod.exports = defined[mod.map.id] = {});
  510. }
  511. }
  512. },
  513. 'module': function (mod) {
  514. if (mod.module) {
  515. return mod.module;
  516. } else {
  517. return (mod.module = {
  518. id: mod.map.id,
  519. uri: mod.map.url,
  520. config: function () {
  521. return (config.config && getOwn(config.config, mod.map.id)) || {};
  522. },
  523. exports: defined[mod.map.id]
  524. });
  525. }
  526. }
  527. };
  528. function cleanRegistry(id) {
  529. //Clean up machinery used for waiting modules.
  530. delete registry[id];
  531. delete enabledRegistry[id];
  532. }
  533. function breakCycle(mod, traced, processed) {
  534. var id = mod.map.id;
  535. if (mod.error) {
  536. mod.emit('error', mod.error);
  537. } else {
  538. traced[id] = true;
  539. each(mod.depMaps, function (depMap, i) {
  540. var depId = depMap.id,
  541. dep = getOwn(registry, depId);
  542. //Only force things that have not completed
  543. //being defined, so still in the registry,
  544. //and only if it has not been matched up
  545. //in the module already.
  546. if (dep && !mod.depMatched[i] && !processed[depId]) {
  547. if (getOwn(traced, depId)) {
  548. mod.defineDep(i, defined[depId]);
  549. mod.check(); //pass false?
  550. } else {
  551. breakCycle(dep, traced, processed);
  552. }
  553. }
  554. });
  555. processed[id] = true;
  556. }
  557. }
  558. function checkLoaded() {
  559. var map, modId, err, usingPathFallback,
  560. waitInterval = config.waitSeconds * 1000,
  561. //It is possible to disable the wait interval by using waitSeconds of 0.
  562. expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),
  563. noLoads = [],
  564. reqCalls = [],
  565. stillLoading = false,
  566. needCycleCheck = true;
  567. //Do not bother if this call was a result of a cycle break.
  568. if (inCheckLoaded) {
  569. return;
  570. }
  571. inCheckLoaded = true;
  572. //Figure out the state of all the modules.
  573. eachProp(enabledRegistry, function (mod) {
  574. map = mod.map;
  575. modId = map.id;
  576. //Skip things that are not enabled or in error state.
  577. if (!mod.enabled) {
  578. return;
  579. }
  580. if (!map.isDefine) {
  581. reqCalls.push(mod);
  582. }
  583. if (!mod.error) {
  584. //If the module should be executed, and it has not
  585. //been inited and time is up, remember it.
  586. if (!mod.inited && expired) {
  587. if (hasPathFallback(modId)) {
  588. usingPathFallback = true;
  589. stillLoading = true;
  590. } else {
  591. noLoads.push(modId);
  592. removeScript(modId);
  593. }
  594. } else if (!mod.inited && mod.fetched && map.isDefine) {
  595. stillLoading = true;
  596. if (!map.prefix) {
  597. //No reason to keep looking for unfinished
  598. //loading. If the only stillLoading is a
  599. //plugin resource though, keep going,
  600. //because it may be that a plugin resource
  601. //is waiting on a non-plugin cycle.
  602. return (needCycleCheck = false);
  603. }
  604. }
  605. }
  606. });
  607. if (expired && noLoads.length) {
  608. //If wait time expired, throw error of unloaded modules.
  609. err = makeError('timeout', 'Load timeout for modules: ' + noLoads, null, noLoads);
  610. err.contextName = context.contextName;
  611. return onError(err);
  612. }
  613. //Not expired, check for a cycle.
  614. if (needCycleCheck) {
  615. each(reqCalls, function (mod) {
  616. breakCycle(mod, {}, {});
  617. });
  618. }
  619. //If still waiting on loads, and the waiting load is something
  620. //other than a plugin resource, or there are still outstanding
  621. //scripts, then just try back later.
  622. if ((!expired || usingPathFallback) && stillLoading) {
  623. //Something is still waiting to load. Wait for it, but only
  624. //if a timeout is not already in effect.
  625. if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) {
  626. checkLoadedTimeoutId = setTimeout(function () {
  627. checkLoadedTimeoutId = 0;
  628. checkLoaded();
  629. }, 50);
  630. }
  631. }
  632. inCheckLoaded = false;
  633. }
  634. Module = function (map) {
  635. this.events = getOwn(undefEvents, map.id) || {};
  636. this.map = map;
  637. this.shim = getOwn(config.shim, map.id);
  638. this.depExports = [];
  639. this.depMaps = [];
  640. this.depMatched = [];
  641. this.pluginMaps = {};
  642. this.depCount = 0;
  643. /* this.exports this.factory
  644. this.depMaps = [],
  645. this.enabled, this.fetched
  646. */
  647. };
  648. Module.prototype = {
  649. init: function (depMaps, factory, errback, options) {
  650. options = options || {};
  651. //Do not do more inits if already done. Can happen if there
  652. //are multiple define calls for the same module. That is not
  653. //a normal, common case, but it is also not unexpected.
  654. if (this.inited) {
  655. return;
  656. }
  657. this.factory = factory;
  658. if (errback) {
  659. //Register for errors on this module.
  660. this.on('error', errback);
  661. } else if (this.events.error) {
  662. //If no errback already, but there are error listeners
  663. //on this module, set up an errback to pass to the deps.
  664. errback = bind(this, function (err) {
  665. this.emit('error', err);
  666. });
  667. }
  668. //Do a copy of the dependency array, so that
  669. //source inputs are not modified. For example
  670. //"shim" deps are passed in here directly, and
  671. //doing a direct modification of the depMaps array
  672. //would affect that config.
  673. this.depMaps = depMaps && depMaps.slice(0);
  674. this.errback = errback;
  675. //Indicate this module has be initialized
  676. this.inited = true;
  677. this.ignore = options.ignore;
  678. //Could have option to init this module in enabled mode,
  679. //or could have been previously marked as enabled. However,
  680. //the dependencies are not known until init is called. So
  681. //if enabled previously, now trigger dependencies as enabled.
  682. if (options.enabled || this.enabled) {
  683. //Enable this module and dependencies.
  684. //Will call this.check()
  685. this.enable();
  686. } else {
  687. this.check();
  688. }
  689. },
  690. defineDep: function (i, depExports) {
  691. //Because of cycles, defined callback for a given
  692. //export can be called more than once.
  693. if (!this.depMatched[i]) {
  694. this.depMatched[i] = true;
  695. this.depCount -= 1;
  696. this.depExports[i] = depExports;
  697. }
  698. },
  699. fetch: function () {
  700. if (this.fetched) {
  701. return;
  702. }
  703. this.fetched = true;
  704. context.startTime = (new Date()).getTime();
  705. var map = this.map;
  706. //If the manager is for a plugin managed resource,
  707. //ask the plugin to load it now.
  708. if (this.shim) {
  709. context.makeRequire(this.map, {
  710. enableBuildCallback: true
  711. })(this.shim.deps || [], bind(this, function () {
  712. return map.prefix ? this.callPlugin() : this.load();
  713. }));
  714. } else {
  715. //Regular dependency.
  716. return map.prefix ? this.callPlugin() : this.load();
  717. }
  718. },
  719. load: function () {
  720. var url = this.map.url;
  721. //Regular dependency.
  722. if (!urlFetched[url]) {
  723. urlFetched[url] = true;
  724. context.load(this.map.id, url);
  725. }
  726. },
  727. /**
  728. * Checks if the module is ready to define itself, and if so,
  729. * define it.
  730. */
  731. check: function () {
  732. if (!this.enabled || this.enabling) {
  733. return;
  734. }
  735. var err, cjsModule,
  736. id = this.map.id,
  737. depExports = this.depExports,
  738. exports = this.exports,
  739. factory = this.factory;
  740. if (!this.inited) {
  741. this.fetch();
  742. } else if (this.error) {
  743. this.emit('error', this.error);
  744. } else if (!this.defining) {
  745. //The factory could trigger another require call
  746. //that would result in checking this module to
  747. //define itself again. If already in the process
  748. //of doing that, skip this work.
  749. this.defining = true;
  750. if (this.depCount < 1 && !this.defined) {
  751. if (isFunction(factory)) {
  752. //If there is an error listener, favor passing
  753. //to that instead of throwing an error.
  754. if (this.events.error) {
  755. try {
  756. exports = context.execCb(id, factory, depExports, exports);
  757. } catch (e) {
  758. err = e;
  759. }
  760. } else {
  761. exports = context.execCb(id, factory, depExports, exports);
  762. }
  763. if (this.map.isDefine) {
  764. //If setting exports via 'module' is in play,
  765. //favor that over return value and exports. After that,
  766. //favor a non-undefined return value over exports use.
  767. cjsModule = this.module;
  768. if (cjsModule &&
  769. cjsModule.exports !== undefined &&
  770. //Make sure it is not already the exports value
  771. cjsModule.exports !== this.exports) {
  772. exports = cjsModule.exports;
  773. } else if (exports === undefined && this.usingExports) {
  774. //exports already set the defined value.
  775. exports = this.exports;
  776. }
  777. }
  778. if (err) {
  779. err.requireMap = this.map;
  780. err.requireModules = [this.map.id];
  781. err.requireType = 'define';
  782. return onError((this.error = err));
  783. }
  784. } else {
  785. //Just a literal value
  786. exports = factory;
  787. }
  788. this.exports = exports;
  789. if (this.map.isDefine && !this.ignore) {
  790. defined[id] = exports;
  791. if (req.onResourceLoad) {
  792. req.onResourceLoad(context, this.map, this.depMaps);
  793. }
  794. }
  795. //Clean up
  796. cleanRegistry(id);
  797. this.defined = true;
  798. }
  799. //Finished the define stage. Allow calling check again
  800. //to allow define notifications below in the case of a
  801. //cycle.
  802. this.defining = false;
  803. if (this.defined && !this.defineEmitted) {
  804. this.defineEmitted = true;
  805. this.emit('defined', this.exports);
  806. this.defineEmitComplete = true;
  807. }
  808. }
  809. },
  810. callPlugin: function () {
  811. var map = this.map,
  812. id = map.id,
  813. //Map already normalized the prefix.
  814. pluginMap = makeModuleMap(map.prefix);
  815. //Mark this as a dependency for this plugin, so it
  816. //can be traced for cycles.
  817. this.depMaps.push(pluginMap);
  818. on(pluginMap, 'defined', bind(this, function (plugin) {
  819. var load, normalizedMap, normalizedMod,
  820. name = this.map.name,
  821. parentName = this.map.parentMap ? this.map.parentMap.name : null,
  822. localRequire = context.makeRequire(map.parentMap, {
  823. enableBuildCallback: true
  824. });
  825. //If current map is not normalized, wait for that
  826. //normalized name to load instead of continuing.
  827. if (this.map.unnormalized) {
  828. //Normalize the ID if the plugin allows it.
  829. if (plugin.normalize) {
  830. name = plugin.normalize(name, function (name) {
  831. return normalize(name, parentName, true);
  832. }) || '';
  833. }
  834. //prefix and name should already be normalized, no need
  835. //for applying map config again either.
  836. normalizedMap = makeModuleMap(map.prefix + '!' + name,
  837. this.map.parentMap);
  838. on(normalizedMap,
  839. 'defined', bind(this, function (value) {
  840. this.init([], function () { return value; }, null, {
  841. enabled: true,
  842. ignore: true
  843. });
  844. }));
  845. normalizedMod = getOwn(registry, normalizedMap.id);
  846. if (normalizedMod) {
  847. //Mark this as a dependency for this plugin, so it
  848. //can be traced for cycles.
  849. this.depMaps.push(normalizedMap);
  850. if (this.events.error) {
  851. normalizedMod.on('error', bind(this, function (err) {
  852. this.emit('error', err);
  853. }));
  854. }
  855. normalizedMod.enable();
  856. }
  857. return;
  858. }
  859. load = bind(this, function (value) {
  860. this.init([], function () { return value; }, null, {
  861. enabled: true
  862. });
  863. });
  864. load.error = bind(this, function (err) {
  865. this.inited = true;
  866. this.error = err;
  867. err.requireModules = [id];
  868. //Remove temp unnormalized modules for this module,
  869. //since they will never be resolved otherwise now.
  870. eachProp(registry, function (mod) {
  871. if (mod.map.id.indexOf(id + '_unnormalized') === 0) {
  872. cleanRegistry(mod.map.id);
  873. }
  874. });
  875. onError(err);
  876. });
  877. //Allow plugins to load other code without having to know the
  878. //context or how to 'complete' the load.
  879. load.fromText = bind(this, function (text, textAlt) {
  880. /*jslint evil: true */
  881. var moduleName = map.name,
  882. moduleMap = makeModuleMap(moduleName),
  883. hasInteractive = useInteractive;
  884. //As of 2.1.0, support just passing the text, to reinforce
  885. //fromText only being called once per resource. Still
  886. //support old style of passing moduleName but discard
  887. //that moduleName in favor of the internal ref.
  888. if (textAlt) {
  889. text = textAlt;
  890. }
  891. //Turn off interactive script matching for IE for any define
  892. //calls in the text, then turn it back on at the end.
  893. if (hasInteractive) {
  894. useInteractive = false;
  895. }
  896. //Prime the system by creating a module instance for
  897. //it.
  898. getModule(moduleMap);
  899. //Transfer any config to this other module.
  900. if (hasProp(config.config, id)) {
  901. config.config[moduleName] = config.config[id];
  902. }
  903. try {
  904. req.exec(text);
  905. } catch (e) {
  906. return onError(makeError('fromtexteval',
  907. 'fromText eval for ' + id +
  908. ' failed: ' + e,
  909. e,
  910. [id]));
  911. }
  912. if (hasInteractive) {
  913. useInteractive = true;
  914. }
  915. //Mark this as a dependency for the plugin
  916. //resource
  917. this.depMaps.push(moduleMap);
  918. //Support anonymous modules.
  919. context.completeLoad(moduleName);
  920. //Bind the value of that module to the value for this
  921. //resource ID.
  922. localRequire([moduleName], load);
  923. });
  924. //Use parentName here since the plugin's name is not reliable,
  925. //could be some weird string with no path that actually wants to
  926. //reference the parentName's path.
  927. plugin.load(map.name, localRequire, load, config);
  928. }));
  929. context.enable(pluginMap, this);
  930. this.pluginMaps[pluginMap.id] = pluginMap;
  931. },
  932. enable: function () {
  933. enabledRegistry[this.map.id] = this;
  934. this.enabled = true;
  935. //Set flag mentioning that the module is enabling,
  936. //so that immediate calls to the defined callbacks
  937. //for dependencies do not trigger inadvertent load
  938. //with the depCount still being zero.
  939. this.enabling = true;
  940. //Enable each dependency
  941. each(this.depMaps, bind(this, function (depMap, i) {
  942. var id, mod, handler;
  943. if (typeof depMap === 'string') {
  944. //Dependency needs to be converted to a depMap
  945. //and wired up to this module.
  946. depMap = makeModuleMap(depMap,
  947. (this.map.isDefine ? this.map : this.map.parentMap),
  948. false,
  949. !this.skipMap);
  950. this.depMaps[i] = depMap;
  951. handler = getOwn(handlers, depMap.id);
  952. if (handler) {
  953. this.depExports[i] = handler(this);
  954. return;
  955. }
  956. this.depCount += 1;
  957. on(depMap, 'defined', bind(this, function (depExports) {
  958. this.defineDep(i, depExports);
  959. this.check();
  960. }));
  961. if (this.errback) {
  962. on(depMap, 'error', this.errback);
  963. }
  964. }
  965. id = depMap.id;
  966. mod = registry[id];
  967. //Skip special modules like 'require', 'exports', 'module'
  968. //Also, don't call enable if it is already enabled,
  969. //important in circular dependency cases.
  970. if (!hasProp(handlers, id) && mod && !mod.enabled) {
  971. context.enable(depMap, this);
  972. }
  973. }));
  974. //Enable each plugin that is used in
  975. //a dependency
  976. eachProp(this.pluginMaps, bind(this, function (pluginMap) {
  977. var mod = getOwn(registry, pluginMap.id);
  978. if (mod && !mod.enabled) {
  979. context.enable(pluginMap, this);
  980. }
  981. }));
  982. this.enabling = false;
  983. this.check();
  984. },
  985. on: function (name, cb) {
  986. var cbs = this.events[name];
  987. if (!cbs) {
  988. cbs = this.events[name] = [];
  989. }
  990. cbs.push(cb);
  991. },
  992. emit: function (name, evt) {
  993. each(this.events[name], function (cb) {
  994. cb(evt);
  995. });
  996. if (name === 'error') {
  997. //Now that the error handler was triggered, remove
  998. //the listeners, since this broken Module instance
  999. //can stay around for a while in the registry.
  1000. delete this.events[name];
  1001. }
  1002. }
  1003. };
  1004. function callGetModule(args) {
  1005. //Skip modules already defined.
  1006. if (!hasProp(defined, args[0])) {
  1007. getModule(makeModuleMap(args[0], null, true)).init(args[1], args[2]);
  1008. }
  1009. }
  1010. function removeListener(node, func, name, ieName) {
  1011. //Favor detachEvent because of IE9
  1012. //issue, see attachEvent/addEventListener comment elsewhere
  1013. //in this file.
  1014. if (node.detachEvent && !isOpera) {
  1015. //Probably IE. If not it will throw an error, which will be
  1016. //useful to know.
  1017. if (ieName) {
  1018. node.detachEvent(ieName, func);
  1019. }
  1020. } else {
  1021. node.removeEventListener(name, func, false);
  1022. }
  1023. }
  1024. /**
  1025. * Given an event from a script node, get the requirejs info from it,
  1026. * and then removes the event listeners on the node.
  1027. * @param {Event} evt
  1028. * @returns {Object}
  1029. */
  1030. function getScriptData(evt) {
  1031. //Using currentTarget instead of target for Firefox 2.0's sake. Not
  1032. //all old browsers will be supported, but this one was easy enough
  1033. //to support and still makes sense.
  1034. var node = evt.currentTarget || evt.srcElement;
  1035. //Remove the listeners once here.
  1036. removeListener(node, context.onScriptLoad, 'load', 'onreadystatechange');
  1037. removeListener(node, context.onScriptError, 'error');
  1038. return {
  1039. node: node,
  1040. id: node && node.getAttribute('data-requiremodule')
  1041. };
  1042. }
  1043. function intakeDefines() {
  1044. var args;
  1045. //Any defined modules in the global queue, intake them now.
  1046. takeGlobalQueue();
  1047. //Make sure any remaining defQueue items get properly processed.
  1048. while (defQueue.length) {
  1049. args = defQueue.shift();
  1050. if (args[0] === null) {
  1051. return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1]));
  1052. } else {
  1053. //args are id, deps, factory. Should be normalized by the
  1054. //define() function.
  1055. callGetModule(args);
  1056. }
  1057. }
  1058. }
  1059. context = {
  1060. config: config,
  1061. contextName: contextName,
  1062. registry: registry,
  1063. defined: defined,
  1064. urlFetched: urlFetched,
  1065. defQueue: defQueue,
  1066. Module: Module,
  1067. makeModuleMap: makeModuleMap,
  1068. nextTick: req.nextTick,
  1069. onError: onError,
  1070. /**
  1071. * Set a configuration for the context.
  1072. * @param {Object} cfg config object to integrate.
  1073. */
  1074. configure: function (cfg) {
  1075. //Make sure the baseUrl ends in a slash.
  1076. if (cfg.baseUrl) {
  1077. if (cfg.baseUrl.charAt(cfg.baseUrl.length - 1) !== '/') {
  1078. cfg.baseUrl += '/';
  1079. }
  1080. }
  1081. //Save off the paths and packages since they require special processing,
  1082. //they are additive.
  1083. var pkgs = config.pkgs,
  1084. shim = config.shim,
  1085. objs = {
  1086. paths: true,
  1087. config: true,
  1088. map: true
  1089. };
  1090. eachProp(cfg, function (value, prop) {
  1091. if (objs[prop]) {
  1092. if (prop === 'map') {
  1093. if (!config.map) {
  1094. config.map = {};
  1095. }
  1096. mixin(config[prop], value, true, true);
  1097. } else {
  1098. mixin(config[prop], value, true);
  1099. }
  1100. } else {
  1101. config[prop] = value;
  1102. }
  1103. });
  1104. //Merge shim
  1105. if (cfg.shim) {
  1106. eachProp(cfg.shim, function (value, id) {
  1107. //Normalize the structure
  1108. if (isArray(value)) {
  1109. value = {
  1110. deps: value
  1111. };
  1112. }
  1113. if ((value.exports || value.init) && !value.exportsFn) {
  1114. value.exportsFn = context.makeShimExports(value);
  1115. }
  1116. shim[id] = value;
  1117. });
  1118. config.shim = shim;
  1119. }
  1120. //Adjust packages if necessary.
  1121. if (cfg.packages) {
  1122. each(cfg.packages, function (pkgObj) {
  1123. var location;
  1124. pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj;
  1125. location = pkgObj.location;
  1126. //Create a brand new object on pkgs, since currentPackages can
  1127. //be passed in again, and config.pkgs is the internal transformed
  1128. //state for all package configs.
  1129. pkgs[pkgObj.name] = {
  1130. name: pkgObj.name,
  1131. location: location || pkgObj.name,
  1132. //Remove leading dot in main, so main paths are normalized,
  1133. //and remove any trailing .js, since different package
  1134. //envs have different conventions: some use a module name,
  1135. //some use a file name.
  1136. main: (pkgObj.main || 'main')
  1137. .replace(currDirRegExp, '')
  1138. .replace(jsSuffixRegExp, '')
  1139. };
  1140. });
  1141. //Done with modifications, assing packages back to context config
  1142. config.pkgs = pkgs;
  1143. }
  1144. //If there are any "waiting to execute" modules in the registry,
  1145. //update the maps for them, since their info, like URLs to load,
  1146. //may have changed.
  1147. eachProp(registry, function (mod, id) {
  1148. //If module already has init called, since it is too
  1149. //late to modify them, and ignore unnormalized ones
  1150. //since they are transient.
  1151. if (!mod.inited && !mod.map.unnormalized) {
  1152. mod.map = makeModuleMap(id);
  1153. }
  1154. });
  1155. //If a deps array or a config callback is specified, then call
  1156. //require with those args. This is useful when require is defined as a
  1157. //config object before require.js is loaded.
  1158. if (cfg.deps || cfg.callback) {
  1159. context.require(cfg.deps || [], cfg.callback);
  1160. }
  1161. },
  1162. makeShimExports: function (value) {
  1163. function fn() {
  1164. var ret;
  1165. if (value.init) {
  1166. ret = value.init.apply(global, arguments);
  1167. }
  1168. return ret || (value.exports && getGlobal(value.exports));
  1169. }
  1170. return fn;
  1171. },
  1172. makeRequire: function (relMap, options) {
  1173. options = options || {};
  1174. function localRequire(deps, callback, errback) {
  1175. var id, map, requireMod;
  1176. if (options.enableBuildCallback && callback && isFunction(callback)) {
  1177. callback.__requireJsBuild = true;
  1178. }
  1179. if (typeof deps === 'string') {
  1180. if (isFunction(callback)) {
  1181. //Invalid call
  1182. return onError(makeError('requireargs', 'Invalid require call'), errback);
  1183. }
  1184. //If require|exports|module are requested, get the
  1185. //value for them from the special handlers. Caveat:
  1186. //this only works while module is being defined.
  1187. if (relMap && hasProp(handlers, deps)) {
  1188. return handlers[deps](registry[relMap.id]);
  1189. }
  1190. //Synchronous access to one module. If require.get is
  1191. //available (as in the Node adapter), prefer that.
  1192. if (req.get) {
  1193. return req.get(context, deps, relMap, localRequire);
  1194. }
  1195. //Normalize module name, if it contains . or ..
  1196. map = makeModuleMap(deps, relMap, false, true);
  1197. id = map.id;
  1198. if (!hasProp(defined, id)) {
  1199. return onError(makeError('notloaded', 'Module name "' +
  1200. id +
  1201. '" has not been loaded yet for context: ' +
  1202. contextName +
  1203. (relMap ? '' : '. Use require([])')));
  1204. }
  1205. return defined[id];
  1206. }
  1207. //Grab defines waiting in the global queue.
  1208. intakeDefines();
  1209. //Mark all the dependencies as needing to be loaded.
  1210. context.nextTick(function () {
  1211. //Some defines could have been added since the
  1212. //require call, collect them.
  1213. intakeDefines();
  1214. requireMod = getModule(makeModuleMap(null, relMap));
  1215. //Store if map config should be applied to this require
  1216. //call for dependencies.
  1217. requireMod.skipMap = options.skipMap;
  1218. requireMod.init(deps, callback, errback, {
  1219. enabled: true
  1220. });
  1221. checkLoaded();
  1222. });
  1223. return localRequire;
  1224. }
  1225. mixin(localRequire, {
  1226. isBrowser: isBrowser,
  1227. /**
  1228. * Converts a module name + .extension into an URL path.
  1229. * *Requires* the use of a module name. It does not support using
  1230. * plain URLs like nameToUrl.
  1231. */
  1232. toUrl: function (moduleNamePlusExt) {
  1233. var ext,
  1234. index = moduleNamePlusExt.lastIndexOf('.'),
  1235. segment = moduleNamePlusExt.split('/')[0],
  1236. isRelative = segment === '.' || segment === '..';
  1237. //Have a file extension alias, and it is not the
  1238. //dots from a relative path.
  1239. if (index !== -1 && (!isRelative || index > 1)) {
  1240. ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length);
  1241. moduleNamePlusExt = moduleNamePlusExt.substring(0, index);
  1242. }
  1243. return context.nameToUrl(normalize(moduleNamePlusExt,
  1244. relMap && relMap.id, true), ext, true);
  1245. },
  1246. defined: function (id) {
  1247. return hasProp(defined, makeModuleMap(id, relMap, false, true).id);
  1248. },
  1249. specified: function (id) {
  1250. id = makeModuleMap(id, relMap, false, true).id;
  1251. return hasProp(defined, id) || hasProp(registry, id);
  1252. }
  1253. });
  1254. //Only allow undef on top level require calls
  1255. if (!relMap) {
  1256. localRequire.undef = function (id) {
  1257. //Bind any waiting define() calls to this context,
  1258. //fix for #408
  1259. takeGlobalQueue();
  1260. var map = makeModuleMap(id, relMap, true),
  1261. mod = getOwn(registry, id);
  1262. delete defined[id];
  1263. delete urlFetched[map.url];
  1264. delete undefEvents[id];
  1265. if (mod) {
  1266. //Hold on to listeners in case the
  1267. //module will be attempted to be reloaded
  1268. //using a different config.
  1269. if (mod.events.defined) {
  1270. undefEvents[id] = mod.events;
  1271. }
  1272. cleanRegistry(id);
  1273. }
  1274. };
  1275. }
  1276. return localRequire;
  1277. },
  1278. /**
  1279. * Called to enable a module if it is still in the registry
  1280. * awaiting enablement. A second arg, parent, the parent module,
  1281. * is passed in for context, when this method is overriden by
  1282. * the optimizer. Not shown here to keep code compact.
  1283. */
  1284. enable: function (depMap) {
  1285. var mod = getOwn(registry, depMap.id);
  1286. if (mod) {
  1287. getModule(depMap).enable();
  1288. }
  1289. },
  1290. /**
  1291. * Internal method used by environment adapters to complete a load event.
  1292. * A load event could be a script load or just a load pass from a synchronous
  1293. * load call.
  1294. * @param {String} moduleName the name of the module to potentially complete.
  1295. */
  1296. completeLoad: function (moduleName) {
  1297. var found, args, mod,
  1298. shim = getOwn(config.shim, moduleName) || {},
  1299. shExports = shim.exports;
  1300. takeGlobalQueue();
  1301. while (defQueue.length) {
  1302. args = defQueue.shift();
  1303. if (args[0] === null) {
  1304. args[0] = moduleName;
  1305. //If already found an anonymous module and bound it
  1306. //to this name, then this is some other anon module
  1307. //waiting for its completeLoad to fire.
  1308. if (found) {
  1309. break;
  1310. }
  1311. found = true;
  1312. } else if (args[0] === moduleName) {
  1313. //Found matching define call for this script!
  1314. found = true;
  1315. }
  1316. callGetModule(args);
  1317. }
  1318. //Do this after the cycle of callGetModule in case the result
  1319. //of those calls/init calls changes the registry.
  1320. mod = getOwn(registry, moduleName);
  1321. if (!found && !hasProp(defined, moduleName) && mod && !mod.inited) {
  1322. if (config.enforceDefine && (!shExports || !getGlobal(shExports))) {
  1323. if (hasPathFallback(moduleName)) {
  1324. return;
  1325. } else {
  1326. return onError(makeError('nodefine',
  1327. 'No define call for ' + moduleName,
  1328. null,
  1329. [moduleName]));
  1330. }
  1331. } else {
  1332. //A script that does not call define(), so just simulate
  1333. //the call for it.
  1334. callGetModule([moduleName, (shim.deps || []), shim.exportsFn]);
  1335. }
  1336. }
  1337. checkLoaded();
  1338. },
  1339. /**
  1340. * Converts a module name to a file path. Supports cases where
  1341. * moduleName may actually be just an URL.
  1342. * Note that it **does not** call normalize on the moduleName,
  1343. * it is assumed to have already been normalized. This is an
  1344. * internal API, not a public one. Use toUrl for the public API.
  1345. */
  1346. nameToUrl: function (moduleName, ext, skipExt) {
  1347. var paths, pkgs, pkg, pkgPath, syms, i, parentModule, url,
  1348. parentPath;
  1349. //If a colon is in the URL, it indicates a protocol is used and it is just
  1350. //an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?)
  1351. //or ends with .js, then assume the user meant to use an url and not a module id.
  1352. //The slash is important for protocol-less URLs as well as full paths.
  1353. if (req.jsExtRegExp.test(moduleName)) {
  1354. //Just a plain path, not module name lookup, so just return it.
  1355. //Add extension if it is included. This is a bit wonky, only non-.js things pass
  1356. //an extension, this method probably needs to be reworked.
  1357. url = moduleName + (ext || '');
  1358. } else {
  1359. //A module that needs to be converted to a path.
  1360. paths = config.paths;
  1361. pkgs = config.pkgs;
  1362. syms = moduleName.split('/');
  1363. //For each module name segment, see if there is a path
  1364. //registered for it. Start with most specific name
  1365. //and work up from it.
  1366. for (i = syms.length; i > 0; i -= 1) {
  1367. parentModule = syms.slice(0, i).join('/');
  1368. pkg = getOwn(pkgs, parentModule);
  1369. parentPath = getOwn(paths, parentModule);
  1370. if (parentPath) {
  1371. //If an array, it means there are a few choices,
  1372. //Choose the one that is desired
  1373. if (isArray(parentPath)) {
  1374. parentPath = parentPath[0];
  1375. }
  1376. syms.splice(0, i, parentPath);
  1377. break;
  1378. } else if (pkg) {
  1379. //If module name is just the package name, then looking
  1380. //for the main module.
  1381. if (moduleName === pkg.name) {
  1382. pkgPath = pkg.location + '/' + pkg.main;
  1383. } else {
  1384. pkgPath = pkg.location;
  1385. }
  1386. syms.splice(0, i, pkgPath);
  1387. break;
  1388. }
  1389. }
  1390. //Join the path parts together, then figure out if baseUrl is needed.
  1391. url = syms.join('/');
  1392. url += (ext || (/\?/.test(url) || skipExt ? '' : '.js'));
  1393. url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;
  1394. }
  1395. return config.urlArgs ? url +
  1396. ((url.indexOf('?') === -1 ? '?' : '&') +
  1397. config.urlArgs) : url;
  1398. },
  1399. //Delegates to req.load. Broken out as a separate function to
  1400. //allow overriding in the optimizer.
  1401. load: function (id, url) {
  1402. req.load(context, id, url);
  1403. },
  1404. /**
  1405. * Executes a module callack function. Broken out as a separate function
  1406. * solely to allow the build system to sequence the files in the built
  1407. * layer in the right sequence.
  1408. *
  1409. * @private
  1410. */
  1411. execCb: function (name, callback, args, exports) {
  1412. return callback.apply(exports, args);
  1413. },
  1414. /**
  1415. * callback for script loads, used to check status of loading.
  1416. *
  1417. * @param {Event} evt the event from the browser for the script
  1418. * that was loaded.
  1419. */
  1420. onScriptLoad: function (evt) {
  1421. //Using currentTarget instead of target for Firefox 2.0's sake. Not
  1422. //all old browsers will be supported, but this one was easy enough
  1423. //to support and still makes sense.
  1424. if (evt.type === 'load' ||
  1425. (readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) {
  1426. //Reset interactive script so a script node is not held onto for
  1427. //to long.
  1428. interactiveScript = null;
  1429. //Pull out the name of the module and the context.
  1430. var data = getScriptData(evt);
  1431. context.completeLoad(data.id);
  1432. }
  1433. },
  1434. /**
  1435. * Callback for script errors.
  1436. */
  1437. onScriptError: function (evt) {
  1438. var data = getScriptData(evt);
  1439. if (!hasPathFallback(data.id)) {
  1440. return onError(makeError('scripterror', 'Script error', evt, [data.id]));
  1441. }
  1442. }
  1443. };
  1444. context.require = context.makeRequire();
  1445. return context;
  1446. }
  1447. /**
  1448. * Main entry point.
  1449. *
  1450. * If the only argument to require is a string, then the module that
  1451. * is represented by that string is fetched for the appropriate context.
  1452. *
  1453. * If the first argument is an array, then it will be treated as an array
  1454. * of dependency string names to fetch. An optional function callback can
  1455. * be specified to execute when all of those dependencies are available.
  1456. *
  1457. * Make a local req variable to help Caja compliance (it assumes things
  1458. * on a require that are not standardized), and to give a short
  1459. * name for minification/local scope use.
  1460. */
  1461. req = requirejs = function (deps, callback, errback, optional) {
  1462. //Find the right context, use default
  1463. var context, config,
  1464. contextName = defContextName;
  1465. // Determine if have config object in the call.
  1466. if (!isArray(deps) && typeof deps !== 'string') {
  1467. // deps is a config object
  1468. config = deps;
  1469. if (isArray(callback)) {
  1470. // Adjust args if there are dependencies
  1471. deps = callback;
  1472. callback = errback;
  1473. errback = optional;
  1474. } else {
  1475. deps = [];
  1476. }
  1477. }
  1478. if (config && config.context) {
  1479. contextName = config.context;
  1480. }
  1481. context = getOwn(contexts, contextName);
  1482. if (!context) {
  1483. context = contexts[contextName] = req.s.newContext(contextName);
  1484. }
  1485. if (config) {
  1486. context.configure(config);
  1487. }
  1488. return context.require(deps, callback, errback);
  1489. };
  1490. /**
  1491. * Support require.config() to make it easier to cooperate with other
  1492. * AMD loaders on globally agreed names.
  1493. */
  1494. req.config = function (config) {
  1495. return req(config);
  1496. };
  1497. /**
  1498. * Execute something after the current tick
  1499. * of the event loop. Override for other envs
  1500. * that have a better solution than setTimeout.
  1501. * @param {Function} fn function to execute later.
  1502. */
  1503. req.nextTick = typeof setTimeout !== 'undefined' ? function (fn) {
  1504. setTimeout(fn, 4);
  1505. } : function (fn) { fn(); };
  1506. /**
  1507. * Export require as a global, but only if it does not already exist.
  1508. */
  1509. if (!require) {
  1510. require = req;
  1511. }
  1512. req.version = version;
  1513. //Used to filter out dependencies that are already paths.
  1514. req.jsExtRegExp = /^\/|:|\?|\.js$/;
  1515. req.isBrowser = isBrowser;
  1516. s = req.s = {
  1517. contexts: contexts,
  1518. newContext: newContext
  1519. };
  1520. //Create default context.
  1521. req({});
  1522. //Exports some context-sensitive methods on global require.
  1523. each([
  1524. 'toUrl',
  1525. 'undef',
  1526. 'defined',
  1527. 'specified'
  1528. ], function (prop) {
  1529. //Reference from contexts instead of early binding to default context,
  1530. //so that during builds, the latest instance of the default context
  1531. //with its config gets used.
  1532. req[prop] = function () {
  1533. var ctx = contexts[defContextName];
  1534. return ctx.require[prop].apply(ctx, arguments);
  1535. };
  1536. });
  1537. if (isBrowser) {
  1538. head = s.head = document.getElementsByTagName('head')[0];
  1539. //If BASE tag is in play, using appendChild is a problem for IE6.
  1540. //When that browser dies, this can be removed. Details in this jQuery bug:
  1541. //http://dev.jquery.com/ticket/2709
  1542. baseElement = document.getElementsByTagName('base')[0];
  1543. if (baseElement) {
  1544. head = s.head = baseElement.parentNode;
  1545. }
  1546. }
  1547. /**
  1548. * Any errors that require explicitly generates will be passed to this
  1549. * function. Intercept/override it if you want custom error handling.
  1550. * @param {Error} err the error object.
  1551. */
  1552. req.onError = function (err) {
  1553. throw err;
  1554. };
  1555. /**
  1556. * Does the request to load a module for the browser case.
  1557. * Make this a separate function to allow other environments
  1558. * to override it.
  1559. *
  1560. * @param {Object} context the require context to find state.
  1561. * @param {String} moduleName the name of the module.
  1562. * @param {Object} url the URL to the module.
  1563. */
  1564. req.load = function (context, moduleName, url) {
  1565. var config = (context && context.config) || {},
  1566. node;
  1567. if (isBrowser) {
  1568. //In the browser so use a script tag
  1569. node = config.xhtml ?
  1570. document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') :
  1571. document.createElement('script');
  1572. node.type = config.scriptType || 'text/javascript';
  1573. node.charset = 'utf-8';
  1574. node.async = true;
  1575. node.setAttribute('data-requirecontext', context.contextName);
  1576. node.setAttribute('data-requiremodule', moduleName);
  1577. //Set up load listener. Test attachEvent first because IE9 has
  1578. //a subtle issue in its addEventListener and script onload firings
  1579. //that do not match the behavior of all other browsers with
  1580. //addEventListener support, which fire the onload event for a
  1581. //script right after the script execution. See:
  1582. //https://connect.microsoft.com/IE/feedback/details/648057/script-onload-event-is-not-fired-immediately-after-script-execution
  1583. //UNFORTUNATELY Opera implements attachEvent but does not follow the script
  1584. //script execution mode.
  1585. if (node.attachEvent &&
  1586. //Check if node.attachEvent is artificially added by custom script or
  1587. //natively supported by browser
  1588. //read https://github.com/jrburke/requirejs/issues/187
  1589. //if we can NOT find [native code] then it must NOT natively supported.
  1590. //in IE8, node.attachEvent does not have toString()
  1591. //Note the test for "[native code" with no closing brace, see:
  1592. //https://github.com/jrburke/requirejs/issues/273
  1593. !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) &&
  1594. !isOpera) {
  1595. //Probably IE. IE (at least 6-8) do not fire
  1596. //script onload right after executing the script, so
  1597. //we cannot tie the anonymous define call to a name.
  1598. //However, IE reports the script as being in 'interactive'
  1599. //readyState at the time of the define call.
  1600. useInteractive = true;
  1601. node.attachEvent('onreadystatechange', context.onScriptLoad);
  1602. //It would be great to add an error handler here to catch
  1603. //404s in IE9+. However, onreadystatechange will fire before
  1604. //the error handler, so that does not help. If addEventListener
  1605. //is used, then IE will fire error before load, but we cannot
  1606. //use that pathway given the connect.microsoft.com issue
  1607. //mentioned above about not doing the 'script execute,
  1608. //then fire the script load event listener before execute
  1609. //next script' that other browsers do.
  1610. //Best hope: IE10 fixes the issues,
  1611. //and then destroys all installs of IE 6-9.
  1612. //node.attachEvent('onerror', context.onScriptError);
  1613. } else {
  1614. node.addEventListener('load', context.onScriptLoad, false);
  1615. node.addEventListener('error', context.onScriptError, false);
  1616. }
  1617. node.src = url;
  1618. //For some cache cases in IE 6-8, the script executes before the end
  1619. //of the appendChild execution, so to tie an anonymous define
  1620. //call to the module name (which is stored on the node), hold on
  1621. //to a reference to this node, but clear after the DOM insertion.
  1622. currentlyAddingScript = node;
  1623. if (baseElement) {
  1624. head.insertBefore(node, baseElement);
  1625. } else {
  1626. head.appendChild(node);
  1627. }
  1628. currentlyAddingScript = null;
  1629. return node;
  1630. } else if (isWebWorker) {
  1631. try {
  1632. //In a web worker, use importScripts. This is not a very
  1633. //efficient use of importScripts, importScripts will block until
  1634. //its script is downloaded and evaluated. However, if web workers
  1635. //are in play, the expectation that a build has been done so that
  1636. //only one script needs to be loaded anyway. This may need to be
  1637. //reevaluated if other use cases become common.
  1638. importScripts(url);
  1639. //Account for anonymous modules
  1640. context.completeLoad(moduleName);
  1641. } catch (e) {
  1642. context.onError(makeError('importscripts',
  1643. 'importScripts failed for ' +
  1644. moduleName + ' at ' + url,
  1645. e,
  1646. [moduleName]));
  1647. }
  1648. }
  1649. };
  1650. function getInteractiveScript() {
  1651. if (interactiveScript && interactiveScript.readyState === 'interactive') {
  1652. return interactiveScript;
  1653. }
  1654. eachReverse(scripts(), function (script) {
  1655. if (script.readyState === 'interactive') {
  1656. return (interactiveScript = script);
  1657. }
  1658. });
  1659. return interactiveScript;
  1660. }
  1661. //Look for a data-main script attribute, which could also adjust the baseUrl.
  1662. if (isBrowser) {
  1663. //Figure out baseUrl. Get it from the script tag with require.js in it.
  1664. eachReverse(scripts(), function (script) {
  1665. //Set the 'head' where we can append children by
  1666. //using the script's parent.
  1667. if (!head) {
  1668. head = script.parentNode;
  1669. }
  1670. //Look for a data-main attribute to set main script for the page
  1671. //to load. If it is there, the path to data main becomes the
  1672. //baseUrl, if it is not already set.
  1673. dataMain = script.getAttribute('data-main');
  1674. if (dataMain) {
  1675. //Set final baseUrl if there is not already an explicit one.
  1676. if (!cfg.baseUrl) {
  1677. //Pull off the directory of data-main for use as the
  1678. //baseUrl.
  1679. src = dataMain.split('/');
  1680. mainScript = src.pop();
  1681. subPath = src.length ? src.join('/') + '/' : './';
  1682. cfg.baseUrl = subPath;
  1683. dataMain = mainScript;
  1684. }
  1685. //Strip off any trailing .js since dataMain is now
  1686. //like a module name.
  1687. dataMain = dataMain.replace(jsSuffixRegExp, '');
  1688. //Put the data-main script in the files to load.
  1689. cfg.deps = cfg.deps ? cfg.deps.concat(dataMain) : [dataMain];
  1690. return true;
  1691. }
  1692. });
  1693. }
  1694. /**
  1695. * The function that handles definitions of modules. Differs from
  1696. * require() in that a string for the module should be the first argument,
  1697. * and the function to execute after dependencies are loaded should
  1698. * return a value to define the module corresponding to the first argument's
  1699. * name.
  1700. */
  1701. define = function (name, deps, callback) {
  1702. var node, context;
  1703. //Allow for anonymous modules
  1704. if (typeof name !== 'string') {
  1705. //Adjust args appropriately
  1706. callback = deps;
  1707. deps = name;
  1708. name = null;
  1709. }
  1710. //This module may not have dependencies
  1711. if (!isArray(deps)) {
  1712. callback = deps;
  1713. deps = [];
  1714. }
  1715. //If no name, and callback is a function, then figure out if it a
  1716. //CommonJS thing with dependencies.
  1717. if (!deps.length && isFunction(callback)) {
  1718. //Remove comments from the callback string,
  1719. //look for require calls, and pull them into the dependencies,
  1720. //but only if there are function args.
  1721. if (callback.length) {
  1722. callback
  1723. .toString()
  1724. .replace(commentRegExp, '')
  1725. .replace(cjsRequireRegExp, function (match, dep) {
  1726. deps.push(dep);
  1727. });
  1728. //May be a CommonJS thing even without require calls, but still
  1729. //could use exports, and module. Avoid doing exports and module
  1730. //work though if it just needs require.
  1731. //REQUIRES the function to expect the CommonJS variables in the
  1732. //order listed below.
  1733. deps = (callback.length === 1 ? ['require'] : ['require', 'exports', 'module']).concat(deps);
  1734. }
  1735. }
  1736. //If in IE 6-8 and hit an anonymous define() call, do the interactive
  1737. //work.
  1738. if (useInteractive) {
  1739. node = currentlyAddingScript || getInteractiveScript();
  1740. if (node) {
  1741. if (!name) {
  1742. name = node.getAttribute('data-requiremodule');
  1743. }
  1744. context = contexts[node.getAttribute('data-requirecontext')];
  1745. }
  1746. }
  1747. //Always save off evaluating the def call until the script onload handler.
  1748. //This allows multiple modules to be in a file without prematurely
  1749. //tracing dependencies, and allows for anonymous module support,
  1750. //where the module name is not known until the script onload event
  1751. //occurs. If no context, use the global queue, and get it processed
  1752. //in the onscript load callback.
  1753. (context ? context.defQueue : globalDefQueue).push([name, deps, callback]);
  1754. };
  1755. define.amd = {
  1756. jQuery: true
  1757. };
  1758. /**
  1759. * Executes the text. Normally just uses eval, but can be modified
  1760. * to use a better, environment-specific call. Only used for transpiling
  1761. * loader plugins, not for plain JS modules.
  1762. * @param {String} text the text to execute/evaluate.
  1763. */
  1764. req.exec = function (text) {
  1765. /*jslint evil: true */
  1766. return eval(text);
  1767. };
  1768. //Set up with config info.
  1769. req(cfg);
  1770. }(this));
  1771. var components = {
  1772. "packages": [
  1773. {
  1774. "name": "elfinder",
  1775. "main": "elfinder-built.js"
  1776. },
  1777. {
  1778. "name": "jquery",
  1779. "main": "jquery-built.js"
  1780. },
  1781. {
  1782. "name": "jquery-ui",
  1783. "main": "jquery-ui-built.js"
  1784. }
  1785. ],
  1786. "shim": {
  1787. "jquery-ui": {
  1788. "deps": [
  1789. "jquery"
  1790. ],
  1791. "exports": "jQuery"
  1792. }
  1793. },
  1794. "baseUrl": "components"
  1795. };
  1796. if (typeof require !== "undefined" && require.config) {
  1797. require.config(components);
  1798. } else {
  1799. var require = components;
  1800. }
  1801. if (typeof exports !== "undefined" && typeof module !== "undefined") {
  1802. module.exports = components;
  1803. }
  1804. define('elfinder', function (require, exports, module) {
  1805. /*!
  1806. * elFinder - file manager for web
  1807. * Version 2.1.20 (2017-01-11)
  1808. * http://elfinder.org
  1809. *
  1810. * Copyright 2009-2017, Studio 42
  1811. * Licensed under a 3-clauses BSD license
  1812. */
  1813. !function(e,t){if("function"==typeof define&&define.amd)define(["jquery","jquery-ui"],t);else if("undefined"!=typeof exports){var n,i;try{n=require("jquery"),i=require("jquery-ui")}catch(a){}module.exports=t(n,i)}else t(e.jQuery,e.jQuery.ui,!0)}(this,function(e,t,n){n=n||!1;var i=function(t,n){var a,r,o,s=this,t=e(t),l=e("<div/>").append(t.contents()),d=t.attr("style"),c=t.attr("id")||"",u="elfinder-"+(c?c:Math.random().toString().substr(2,7)),h="mousedown."+u,p="keydown."+u,f="keypress."+u,m=!0,g=!0,v=["enable","disable","load","open","reload","select","add","remove","change","dblclick","getfile","lockfiles","unlockfiles","selectfiles","unselectfiles","dragstart","dragstop","search","searchend","viewchange"],b="",y={path:"",url:"",tmbUrl:"",disabled:[],separator:"/",archives:[],extract:[],copyOverwrite:!0,uploadOverwrite:!0,uploadMaxSize:0,jpgQuality:100,tmbCrop:!1,tmb:!1},w={},k=[],x={},C={},T=[],z=[],A=[],I=[],S=new s.command(s),U="auto",M=400,O="./sounds/",D=e(document.createElement("audio")).hide().appendTo("body")[0],F=0,E="",P=function(n){var i,a,r,o,l,d,c,u,h={},p={};s.api>=2.1?(s.commandMap=n.options.uiCmdMap&&Object.keys(n.options.uiCmdMap).length?n.options.uiCmdMap:{},E!==JSON.stringify(s.commandMap)&&(E=JSON.stringify(s.commandMap),Object.keys(s.commandMap).length&&(a=s.getUI("contextmenu"),a.data("cmdMaps")||a.data("cmdMaps",{}),i=n.cwd?n.cwd.volumeid:null,i&&!a.data("cmdMaps")[i]&&(a.data("cmdMaps")[i]=s.commandMap)))):s.options.sync=0,n.init?w={}:(u=b,r="elfinder-subtree-loaded "+s.res("class","navexpand"),c=s.res("class","navcollapse"),o=Object.keys(w),l=function(t,n){if(!w[n])return!0;var i="directory"===w[n].mime,a=w[n].phash;(!i||h[a]||!p[a]&&e("#"+s.navHash2Id(w[n].hash)).is(":hidden")&&e("#"+s.navHash2Id(a)).next(".elfinder-navbar-subtree").children().length>100)&&(i||a!==b)&&-1===e.inArray(n,z)?(i&&!h[a]&&(h[a]=!0,e("#"+s.navHash2Id(a)).removeClass(r).next(".elfinder-navbar-subtree").empty()),delete w[n]):i&&(p[a]=!0)},d=function(){o.length&&(e.each(o.splice(0,100),l),o.length&&setTimeout(d,20))},s.trigger("filesgc").one("filesgc",function(){o=[]}),s.one("opendone",function(){u!==b&&(t.data("lazycnt")?s.one("lazydone",d):d())})),s.sorters=[],b=n.cwd.hash,R(n.files),w[b]||R([n.cwd]),s.lastDir(b),s.autoSync()},R=function(t){var n,i,a={name:!0,perm:!0,date:!0,size:!0,kind:!0},r=0===s.sorters.length,o=t.length;for(i=0;o>i;i++)n=t[i],n.name&&n.hash&&n.mime&&(r&&n.phash===b&&(e.each(s.sortRules,function(e){(a[e]||"undefined"!=typeof n[e]||"mode"===e&&"undefined"!=typeof n.perm)&&s.sorters.push(e)}),r=!1),n.isroot&&n.phash&&(s.leafRoots[n.phash]?-1===e.inArray(n.hash,s.leafRoots[n.phash])&&s.leafRoots[n.phash].push(n.hash):s.leafRoots[n.phash]=[n.hash],w[n.phash]&&(w[n.phash].dirs||(w[n.phash].dirs=1),n.ts&&(w[n.phash].ts||0)<n.ts&&(w[n.phash].ts=n.ts))),w[n.hash]=n)},j=function(n){var i,a=n.keyCode,r=!(!n.ctrlKey&&!n.metaKey);m&&(e.each(C,function(e,t){t.type==n.type&&t.keyCode==a&&t.shiftKey==n.shiftKey&&t.ctrlKey==r&&t.altKey==n.altKey&&(n.preventDefault(),n.stopPropagation(),t.callback(n,s),s.debug("shortcut-exec",e+" : "+t.description))}),a!=e.ui.keyCode.TAB||e(n.target).is(":input")||n.preventDefault(),"keydown"===n.type&&a==e.ui.keyCode.ESCAPE&&(t.find(".ui-widget:visible").length||s.clipboard().length&&s.clipboard([]),e.ui.ddmanager&&(i=e.ui.ddmanager.current,i&&i.helper&&i.cancel()),t.find(".ui-widget.elfinder-button-menu").hide()))},H=new Date,N=window.parent!==window,q=function(){var t,n;if(N)try{n=e("iframe",window.parent.document),n.length&&e.each(n,function(n,i){return i.contentWindow===window?(t=e(i),!1):void 0})}catch(i){}return t}();return this.api=null,this.newAPI=!1,this.oldAPI=!1,this.netDrivers=[],this.options=e.extend(!0,{},this._options,n||{}),this.options.cssAutoLoad&&!function(n){var i,a,r,o,s=e('head > script[src$="js/elfinder.min.js"],script[src$="js/elfinder.full.js"]:first');s.length?(a=e("<style>.elfinder{visibility:hidden;overflow:hidden}</style>"),e("head").append(a),i=s.attr("src").replace(/js\/[^\/]+$/,""),n.loadCss([i+"css/elfinder.min.css",i+"css/theme.css"]),e.isArray(n.options.cssAutoLoad)&&n.loadCss(n.options.cssAutoLoad),o=1e3,r=setInterval(function(){--o>0&&"hidden"!==t.css("visibility")&&(clearInterval(r),a.remove(),n.trigger("cssloaded"))},10)):n.options.cssAutoLoad=!1}(this),this.optionProperties=["icon","csscls","tmbUrl","uiCmdMap","netkey"],n.ui&&(this.options.ui=n.ui),n.commands&&(this.options.commands=n.commands),n.uiOptions&&n.uiOptions.toolbar&&(this.options.uiOptions.toolbar=n.uiOptions.toolbar),n.uiOptions&&n.uiOptions.cwd&&n.uiOptions.cwd.listView&&n.uiOptions.cwd.listView.columns&&(this.options.uiOptions.cwd.listView.columns=n.uiOptions.cwd.listView.columns),n.uiOptions&&n.uiOptions.cwd&&n.uiOptions.cwd.listView&&n.uiOptions.cwd.listView.columnsCustomName&&(this.options.uiOptions.cwd.listView.columnsCustomName=n.uiOptions.cwd.listView.columnsCustomName),N||this.options.enableAlways||2!==e("body").children().length||(this.options.enableAlways=!0),this.isCORS=!1,function(){var t,i=document.createElement("a");i.href=n.url,n.urlUpload&&n.urlUpload!==n.url&&(t=document.createElement("a"),t.href=n.urlUpload),(window.location.host!==i.host||t&&window.location.host!==t.host)&&(s.isCORS=!0,e.isPlainObject(s.options.customHeaders)||(s.options.customHeaders={}),e.isPlainObject(s.options.xhrFields)||(s.options.xhrFields={}),s.options.requestType="post",s.options.customHeaders["X-Requested-With"]="XMLHttpRequest",s.options.xhrFields.withCredentials=!0)}(),e.extend(this.options.contextmenu,n.contextmenu),this.requestType=/^(get|post)$/i.test(this.options.requestType)?this.options.requestType.toLowerCase():"get",this.customData=e.isPlainObject(this.options.customData)?this.options.customData:{},this.customHeaders=e.isPlainObject(this.options.customHeaders)?this.options.customHeaders:{},this.xhrFields=e.isPlainObject(this.options.xhrFields)?this.options.xhrFields:{},this.abortCmdsOnOpen=this.options.abortCmdsOnOpen||["tmb"],this.id=c,this.navPrefix="nav"+(i.prototype.uniqueid?i.prototype.uniqueid:"")+"-",this.cwdPrefix=i.prototype.uniqueid?"cwd"+i.prototype.uniqueid+"-":"",++i.prototype.uniqueid,this.uploadURL=n.urlUpload||n.url,this.namespace=u,this.lang=this.i18[this.options.lang]&&this.i18[this.options.lang].messages?this.options.lang:"en",o="en"==this.lang?this.i18.en:e.extend(!0,{},this.i18.en,this.i18[this.lang]),this.direction=o.direction,this.messages=o.messages,this.dateFormat=this.options.dateFormat||o.dateFormat,this.fancyFormat=this.options.fancyDateFormat||o.fancyDateFormat,this.today=new Date(H.getFullYear(),H.getMonth(),H.getDate()).getTime()/1e3,this.yesterday=this.today-86400,r=this.options.UTCDate?"UTC":"",this.getHours="get"+r+"Hours",this.getMinutes="get"+r+"Minutes",this.getSeconds="get"+r+"Seconds",this.getDate="get"+r+"Date",this.getDay="get"+r+"Day",this.getMonth="get"+r+"Month",this.getFullYear="get"+r+"FullYear",this.cssClass="ui-helper-reset ui-helper-clearfix ui-widget ui-widget-content ui-corner-all elfinder elfinder-"+("rtl"==this.direction?"rtl":"ltr")+(this.UA.Touch?" elfinder-touch"+(this.options.resizable?" touch-punch":""):"")+(this.UA.Mobile?" elfinder-mobile":"")+" "+this.options.cssClass,this.zIndex,this.searchStatus={state:0,query:"",target:"",mime:"",mixed:!1,ininc:!1},this.storage=function(){try{return"localStorage"in window&&null!==window.localStorage?(s.UA.Safari&&(window.localStorage.setItem("elfstoragecheck",1),window.localStorage.removeItem("elfstoragecheck")),s.localStorage):s.cookie}catch(e){return s.cookie}}(),this.viewType=this.storage("view")||this.options.defaultView||"icons",this.sortType=this.storage("sortType")||this.options.sortType||"name",this.sortOrder=this.storage("sortOrder")||this.options.sortOrder||"asc",this.sortStickFolders=this.storage("sortStickFolders"),null===this.sortStickFolders?this.sortStickFolders=!!this.options.sortStickFolders:this.sortStickFolders=!!this.sortStickFolders,this.sortAlsoTreeview=this.storage("sortAlsoTreeview"),null===this.sortAlsoTreeview?this.sortAlsoTreeview=!!this.options.sortAlsoTreeview:this.sortAlsoTreeview=!!this.sortAlsoTreeview,this.sortRules=e.extend(!0,{},this._sortRules,this.options.sortRules),e.each(this.sortRules,function(e,t){"function"!=typeof t&&delete s.sortRules[e]}),this.compare=e.proxy(this.compare,this),this.notifyDelay=this.options.notifyDelay>0?parseInt(this.options.notifyDelay):500,this.draggingUiHelper=null,function(){var n,i,a,r,o=p+"draggable keyup."+u+"draggable";s.draggable={appendTo:t,addClasses:!1,distance:4,revert:!0,refreshPositions:!1,cursor:"crosshair",cursorAt:{left:50,top:47},scroll:!1,start:function(o,l){var d,c,u=l.helper,h=e.map(u.data("files")||[],function(e){return e||null}),p=!1;for(r=t.attr("style"),t.width(t.width()).height(t.height()),n="ltr"===s.direction,i=s.getUI("workzone").data("rectangle"),a=i.top+i.height,s.draggingUiHelper=u,d=h.length;d--;)if(c=h[d],w[c].locked){p=!0,u.data("locked",!0);break}!p&&s.trigger("lockfiles",{files:h}),u.data("autoScrTm",setInterval(function(){u.data("autoScr")&&s.autoScroll[u.data("autoScr")](u.data("autoScrVal"))},50))},drag:function(t,r){var o,s=r.helper;(o=i.top>t.pageY)||a<t.pageY?(i.cwdEdge>t.pageX?s.data("autoScr",(n?"navbar":"cwd")+(o?"Up":"Down")):s.data("autoScr",(n?"cwd":"navbar")+(o?"Up":"Down")),s.data("autoScrVal",Math.pow(o?i.top-t.pageY:t.pageY-a,1.3))):s.data("autoScr")&&s.data("refreshPositions",1).data("autoScr",null),s.data("refreshPositions")&&e(this).elfUiWidgetInstance("draggable")&&(s.data("refreshPositions")>0?(e(this).draggable("option",{refreshPositions:!0,elfRefresh:!0}),s.data("refreshPositions",-1)):(e(this).draggable("option",{refreshPositions:!1,elfRefresh:!1}),s.data("refreshPositions",null)))},stop:function(n,i){var a,l=i.helper;e(document).off(o),e(this).elfUiWidgetInstance("draggable")&&e(this).draggable("option",{refreshPositions:!1}),s.draggingUiHelper=null,s.trigger("focus").trigger("dragstop"),l.data("droped")||(a=e.map(l.data("files")||[],function(e){return e||null}),s.trigger("unlockfiles",{files:a}),s.trigger("selectfiles",{files:a})),s.enable(),t.attr("style",r),l.data("autoScrTm")&&clearInterval(l.data("autoScrTm"))},helper:function(t,n){var i,a,r,l=this.id?e(this):e(this).parents("[id]:first"),d=e('<div class="elfinder-drag-helper"><span class="elfinder-drag-helper-icon-status"/></div>'),c=function(t){var n,i=t.mime,a=s.tmb(t);return n='<div class="elfinder-cwd-icon '+s.mime2class(i)+' ui-corner-all"/>',a&&(n=e(n).addClass(a.className).css("background-image","url('"+a.url+"')").get(0).outerHTML),n};return s.draggingUiHelper&&s.draggingUiHelper.stop(!0,!0),s.trigger("dragstart",{target:l[0],originalEvent:t}),i=l.hasClass(s.res("class","cwdfile"))?s.selected():[s.navId2Hash(l.attr("id"))],d.append(c(w[i[0]])).data("files",i).data("locked",!1).data("droped",!1).data("namespace",u).data("dropover",0),(a=i.length)>1&&d.append(c(w[i[a-1]])+'<span class="elfinder-drag-num">'+a+"</span>"),e(document).on(o,function(e){var t=e.shiftKey||e.ctrlKey||e.metaKey;r!==t&&(r=t,d.is(":visible")&&d.data("dropover")&&!d.data("droped")&&(d.toggleClass("elfinder-drag-helper-plus",d.data("locked")?!0:r),s.trigger(r?"unlockfiles":"lockfiles",{files:i,helper:d})))}),d}}}(),this.droppable={greedy:!0,tolerance:"pointer",accept:".elfinder-cwd-file-wrapper,.elfinder-navbar-dir,.elfinder-cwd-file,.elfinder-cwd-filename",hoverClass:this.res("class","adroppable"),classes:{"ui-droppable-hover":this.res("class","adroppable")},autoDisable:!0,drop:function(t,n){var i,a,r,o=e(this),l=e.map(n.helper.data("files")||[],function(e){return e||null}),d=[],c=[],h=[],p=n.helper.hasClass("elfinder-drag-helper-plus"),f="class";if("undefined"==typeof t.button||n.helper.data("namespace")!==u||!s.insideWorkzone(t.pageX,t.pageY))return!1;for(a=o.hasClass(s.res(f,"cwdfile"))?s.cwdId2Hash(o.attr("id")):o.hasClass(s.res(f,"navdir"))?s.navId2Hash(o.attr("id")):b,i=l.length;i--;)r=l[i],r!=a&&w[r].phash!=a?d.push(r):(p&&r!==a&&w[a].write?c:h).push(r);return h.length?!1:(n.helper.data("droped",!0),c.length&&(n.helper.hide(),s.exec("duplicate",c)),void(d.length&&(n.helper.hide(),s.clipboard(d,!p),s.exec("paste",a,void 0,a).always(function(){s.clipboard([]),s.trigger("unlockfiles",{files:l})}),s.trigger("drop",{files:l}))))}},this.enabled=function(){return m&&this.visible()},this.visible=function(){return t[0].elfinder&&t.is(":visible")},this.isRoot=function(e){return!(!e.isroot&&e.phash)},this.root=function(t,n){t=t||b;var i,a;if(!n&&(e.each(s.roots,function(e,n){return 0===t.indexOf(e)?(i=n,!1):void 0}),i))return i;for(i=w[t];i&&i.phash&&(n||!i.isroot);)i=w[i.phash];if(i)return i.hash;for(;a in w&&w.hasOwnProperty(a);)if(i=w[a],!i.phash&&"directory"==!i.mime&&i.read)return i.hash;return""},this.cwd=function(){return w[b]||{}},this.option=function(t,n){var i;return n=n||b,s.optionsByHashes[n]&&"undefined"!=typeof s.optionsByHashes[n][t]?s.optionsByHashes[n][t]:b!==n?(i="",e.each(s.volOptions,function(e,a){return 0===n.indexOf(e)?(i=a[t]||"",!1):void 0}),i):y[t]||""},this.getDisabledCmds=function(t){var n=[];return e.isArray(t)||(t=[t]),e.each(t,function(t,i){var a=s.option("disabled",i);a&&e.each(a,function(t,i){-1===e.inArray(i,n)&&n.push(i)})}),n},this.file=function(e){return e?w[e]:void 0},this.files=function(){return e.extend(!0,{},w)},this.parents=function(e){for(var t,n=[];t=this.file(e);)n.unshift(t.hash),e=t.phash;return n},this.path2array=function(e,t){for(var n,i=[];e;){if(!(n=w[e])||!n.hash){i=[];break}i.unshift(t&&n.i18?n.i18:n.name),e=n.isroot?null:n.phash}return i},this.path=function(t,n,i){var a=w[t]&&w[t].path?w[t].path:this.path2array(t,n).join(y.separator);if(i&&w[t]){i=e.extend({notify:{type:"parents",cnt:1,hideCnt:!0}},i);var r,o=e.Deferred(),l=i.notify,d=!1,c=function(){s.request({data:{cmd:"parents",target:w[t].phash},notify:l,preventFail:!0}).done(u).fail(function(){o.reject()})},u=function(){s.one("parentsdone",function(){a=s.path(t,n),""===a&&d?(d=!1,c()):(l&&(clearTimeout(r),l.cnt=-parseInt(l.cnt||0),s.notify(l)),o.resolve(a))})};return a?o.resolve(a):(s.ui.tree?(l&&(r=setTimeout(function(){s.notify(l)},s.notifyDelay)),d=!0,u(!0)):c(),o)}return a},this.url=function(t){var n,i=w[t];if(!i||!i.read)return"";if("1"==i.url&&this.request({data:{cmd:"url",target:t},preventFail:!0,options:{async:!1}}).done(function(e){i.url=e.url||""}).fail(function(){i.url=""}),i.url)return i.url;if(n=0===i.hash.indexOf(s.cwd().volumeid)?y.url:this.option("url",i.hash))return n+e.map(this.path2array(t),function(e){return encodeURIComponent(e)}).slice(1).join("/");var a=e.extend({},this.customData,{cmd:"file",target:i.hash});return this.oldAPI&&(a.cmd="open",a.current=i.phash),this.options.url+(-1===this.options.url.indexOf("?")?"?":"&")+e.param(a,!0)},this.openUrl=function(t,n){var i=w[t],a="";if(!i||!i.read)return"";if(!n)if(i.url){if(1!=i.url)return i.url}else if(y.url&&0===i.hash.indexOf(s.cwd().volumeid))return y.url+e.map(this.path2array(t),function(e){return encodeURIComponent(e)}).slice(1).join("/");return a=this.options.url,a=a+(-1===a.indexOf("?")?"?":"&")+(this.oldAPI?"cmd=open&current="+i.phash:"cmd=file")+"&target="+i.hash,n&&(a+="&download=1"),e.each(this.options.customData,function(e,t){a+="&"+encodeURIComponent(e)+"="+encodeURIComponent(t)}),a},this.tmb=function(t){var n,i,a="elfinder-cwd-bgurl",r="";return e.isPlainObject(t)&&(s.searchStatus.state&&0!==t.hash.indexOf(s.cwd().volumeid)?(n=s.option("tmbUrl",t.hash),i=s.option("tmbCrop",t.hash)):(n=y.tmbUrl,i=y.tmbCrop),i&&(a+=" elfinder-cwd-bgurl-crop"),"self"===n&&0===t.mime.indexOf("image/")?(r=s.openUrl(t.hash),a+=" elfinder-cwd-bgself"):(s.oldAPI||n)&&t&&t.tmb&&1!=t.tmb&&(r=n+t.tmb),r)?{url:r,className:a}:!1},this.selected=function(){return k.slice(0)},this.selectedFiles=function(){return e.map(k,function(t){return w[t]?e.extend({},w[t]):null})},this.fileByName=function(e,t){var n;for(n in w)if(w.hasOwnProperty(n)&&w[n].phash==t&&w[n].name==e)return w[n]},this.validResponse=function(e,t){return t.error||this.rules[this.rules[e]?e:"defaults"](t)},this.returnBytes=function(e){var t;return isNaN(e)?(e||(e=""),e=e.replace(/b$/i,""),t=e.charAt(e.length-1).toLowerCase(),e=e.replace(/[tgmk]$/i,""),"t"==t?e=1024*e*1024*1024*1024:"g"==t?e=1024*e*1024*1024:"m"==t?e=1024*e*1024:"k"==t&&(e=1024*e),e=isNaN(e)?0:parseInt(e)):(e=parseInt(e),1>e&&(e=0)),e},this.request=function(t){var n,i,a,r=this,o=this.options,s=e.Deferred(),l=e.extend({},o.customData,{mimes:o.onlyMimes},t.data||t),d=l.cmd,c="open"===d,u=!(t.preventDefault||t.preventFail),h=!(t.preventDefault||t.preventDone),p=e.extend({},t.notify),f=!!t.cancel,m=!!t.raw,g=t.syncOnFail,v=!!t.lazy,w=t.prepare,k=e.extend({url:o.url,async:!0,type:this.requestType,dataType:"json",cache:!1,data:l,headers:this.customHeaders,xhrFields:this.xhrFields},t.options||{}),x=function(e){e.warning&&r.error(e.warning),c&&P(e),r.lazy(function(){e.removed&&e.removed.length&&r.remove(e),e.added&&e.added.length&&r.add(e),e.changed&&e.changed.length&&r.change(e)}).then(function(){return r.lazy(function(){r.trigger(d,e)})}).then(function(){return r.lazy(function(){r.trigger(d+"done")})}).then(function(){e.sync&&r.sync()})},C=function(e,t){var n,i;switch(t){case"abort":n=e.quiet?"":["errConnect","errAbort"];break;case"timeout":n=["errConnect","errTimeout"];break;case"parsererror":n=["errResponse","errDataNotJSON"],e.responseText&&(r.debug("backend-debug",{debug:{phpErrors:[e.responseText]}}),b||e.responseText&&n.push(e.responseText));break;default:if(e.responseText)try{i=JSON.parse(e.responseText),i&&i.error&&(n=i.error)}catch(a){}if(!n)if(403==e.status)n=["errConnect","errAccess","HTTP error "+e.status];else if(404==e.status)n=["errConnect","errNotFound","HTTP error "+e.status];else{if(414==e.status&&"get"===k.type)return k.type="post",void(s.xhr=e=r.transport.send(k).fail(n).done(T));n=e.quiet?"":["errConnect","HTTP error "+e.status]}}r.trigger(d+"done"),s.reject(n,e,t)},T=function(t){if(r.currentReqCmd=d,m)return t&&t.debug&&r.debug("backend-debug",t),s.resolve(t);if(!t)return s.reject(["errResponse","errDataEmpty"],i,t);if(!e.isPlainObject(t))return s.reject(["errResponse","errDataNotJSON"],i,t);if(t.error)return s.reject(t.error,i,t);if(!r.validResponse(d,t))return s.reject("errResponse",i,t);var n=function(){var n=function(n){r.leafRoots[l.target]&&t[n]&&e.each(r.leafRoots[l.target],function(e,i){var a;(a=r.file(i))&&t[n].push(a)})};c?n("files"):"tree"===d&&n("tree"),t=r.normalize(t),r.api||(r.api=t.api||1,"2.0"==r.api&&"undefined"!=typeof t.options.uploadMaxSize&&(r.api="2.1"),r.newAPI=r.api>=2,r.oldAPI=!r.newAPI),t.options&&(y=e.extend({},y,t.options)),t.netDrivers&&(r.netDrivers=t.netDrivers),t.maxTargets&&(r.maxTargets=t.maxTargets),c&&l.init&&(r.uplMaxSize=r.returnBytes(t.uplMaxSize),r.uplMaxFile=t.uplMaxFile?parseInt(t.uplMaxFile):20),"function"==typeof w&&w(t),s.resolve(t),t.debug&&r.debug("backend-debug",t)};v?r.lazy(n):n()},z=function(e){if(r.trigger(d+"done"),"autosync"==e.type){if("stop"!=e.data.action)return}else if(!("unload"==e.type||"destroy"==e.type||"openxhrabort"==e.type||e.data.added&&e.data.added.length))return;"pending"==i.state()&&(i.quiet=!0,i.abort(),"unload"!=e.type&&"destroy"!=e.type&&r.autoSync())},S=function(){if(s.fail(function(e,t,n){r.trigger(d+"fail",n),e&&(u?r.error(e):r.debug("error",r.i18n(e))),g&&r.sync()}),!d)return g=!1,s.reject("errCmdReq");if(r.maxTargets&&l.targets&&l.targets.length>r.maxTargets)return g=!1,s.reject(["errMaxTargets",r.maxTargets]);if(h&&s.done(x),p.type&&p.cnt&&(f&&(p.cancel=s),n=setTimeout(function(){r.notify(p),s.always(function(){p.cnt=-(parseInt(p.cnt)||0),r.notify(p)})},r.notifyDelay),s.always(function(){clearTimeout(n)})),c){for(;a=A.pop();)"pending"==a.state()&&(a.quiet=!0,a.abort());if(b!==l.target)for(;a=I.pop();)"pending"==a.state()&&(a.quiet=!0,a.abort())}return-1!==e.inArray(d,(r.cmdsToAdd+" autosync").split(" "))&&("autosync"!==d&&(r.autoSync("stop"),s.always(function(){r.autoSync()})),r.trigger("openxhrabort")),delete k.preventFail,s.xhr=i=r.transport.send(k).fail(C).done(T),c||l.compare&&"info"===d?(A.unshift(i),l.compare&&r.bind(r.cmdsToAdd+" autosync openxhrabort",z),s.always(function(){var t=e.inArray(i,A);l.compare&&r.unbind(r.cmdsToAdd+" autosync openxhrabort",z),-1!==t&&A.splice(t,1)})):-1!==e.inArray(d,r.abortCmdsOnOpen)&&(I.unshift(i),s.always(function(){var t=e.inArray(i,I);-1!==t&&I.splice(t,1)})),r.bind("unload destroy",z),s.always(function(){r.unbind("unload destroy",z)}),s},U={opts:t,result:!0};return r.trigger("request."+d,U,!0),U.result?"object"==typeof U.result&&U.result.promise?(U.result.done(S).fail(function(){r.trigger(d+"done"),s.reject()}),s):S():(r.trigger(d+"done"),s.reject())},this.diff=function(t,n,i){var a={},r=[],o=[],s=[],l=function(e){for(var t=s.length;t--;)if(s[t].hash==e)return!0};return e.each(t,function(e,t){a[t.hash]=t}),e.each(w,function(e,t){a[e]||n&&t.phash!==n||o.push(e)}),e.each(a,function(t,n){var a=w[t];a?e.each(n,function(t){return i&&-1!==e.inArray(t,i)||n[t]===a[t]?void 0:(s.push(n),!1)}):r.push(n)}),e.each(o,function(t,n){var i=w[n],r=i.phash;r&&"directory"==i.mime&&-1===e.inArray(r,o)&&a[r]&&!l(r)&&s.push(a[r])}),{added:r,removed:o,changed:s}},this.sync=function(t,n){this.autoSync("stop");var i=this,a=function(){var i="",a=0,r=0;return t&&n&&e.each(w,function(e,n){n.phash&&n.phash===t&&(++a,r=Math.max(r,n.ts)),i=a+":"+r}),i},r=a(),o=e.Deferred().done(function(){i.trigger("sync")}),s=[this.request({data:{cmd:"open",reload:1,target:b,tree:!t&&this.ui.tree?1:0,compare:r},preventDefault:!0})],l=function(){for(var e,t=[],n=i.file(i.root(b)),a=n?n.volumeid:null,r=i.cwd().phash;r;)(e=i.file(r))?(0!==r.indexOf(a)&&(i.isRoot(e)||t.push({target:r,cmd:"tree"}),t.push({target:r,cmd:"parents"}),n=i.file(i.root(r)),a=n?n.volumeid:null),r=e.phash):r=null;return t};return t||(b!==this.root()&&s.push(this.request({data:{cmd:"parents",target:b},preventDefault:!0})),e.each(l(),function(e,t){s.push(i.request({data:{cmd:t.cmd,target:t.target},preventDefault:!0}))})),e.when.apply(e,s).fail(function(t,a){n&&-1===e.inArray("errOpen",t)?o.reject(t&&0!=a.status?t:void 0):(o.reject(t),t&&i.request({data:{cmd:"open",target:i.lastDir("")||i.root(),tree:1,init:1},notify:{type:"open",cnt:1,hideCnt:!0}}))}).done(function(e){var n,a,s;if(e.cwd.compare&&r===e.cwd.compare)return o.reject();if(n={tree:[]},a=arguments.length,a>1)for(s=1;a>s;s++)arguments[s].tree&&arguments[s].tree.length&&n.tree.push.apply(n.tree,arguments[s].tree);i.api<2.1&&(n.tree=(n.tree||[]).push(e.cwd)),e=i.normalize(e),n=i.normalize(n);var l=i.diff(e.files.concat(n&&n.tree?n.tree:[]),t);return l.added.push(e.cwd),l.removed.length&&i.remove(l),l.added.length&&i.add(l),l.changed.length&&i.change(l),o.resolve(l)}).always(function(){i.autoSync()}),o},this.upload=function(e){return this.transport.upload(e,this)},this.bind=function(e,t){var n;if("function"==typeof t)for(e=(""+e).toLowerCase().split(/\s+/),n=0;n<e.length;n++)void 0===x[e[n]]&&(x[e[n]]=[]),x[e[n]].push(t);return this},this.unbind=function(t,n){var i,a,r;for(t=(""+t).toLowerCase().split(/\s+/),i=0;i<t.length;i++)a=x[t[i]]||[],r=e.inArray(n,a),r>-1&&a.splice(r,1);return n=null,this},this.trigger=function(t,n,i){var a,r,o,t=t.toLowerCase(),s="open"===t,l=x[t]||[];if(this.debug("event-"+t,n),s&&!i&&(o=JSON.stringify(n)),r=l.length)for(t=e.Event(t),i&&(t.data=n),a=0;r>a;a++)if(l[a]){l[a].length&&(i||(t.data=s?JSON.parse(o):e.extend(!0,{},n)));try{if(l[a](t,this)===!1||t.isDefaultPrevented()){this.debug("event-stoped",t.type);break}}catch(d){window.console&&window.console.log&&window.console.log(d)}}return this},this.getListeners=function(e){return e?x[e.toLowerCase()]:x},this.shortcut=function(t){var n,i,a,r,o;if(this.options.allowShortcuts&&t.pattern&&e.isFunction(t.callback))for(n=t.pattern.toUpperCase().split(/\s+/),r=0;r<n.length;r++)i=n[r],o=i.split("+"),a=1==(a=o.pop()).length?a>0?a:a.charCodeAt(0):a>0?a:e.ui.keyCode[a],a&&!C[i]&&(C[i]={keyCode:a,altKey:-1!=e.inArray("ALT",o),ctrlKey:-1!=e.inArray("CTRL",o),shiftKey:-1!=e.inArray("SHIFT",o),type:t.type||"keydown",callback:t.callback,description:t.description,pattern:i});return this},this.shortcuts=function(){var t=[];return e.each(C,function(e,n){t.push([n.pattern,s.i18n(n.description)])}),t},this.clipboard=function(t,n){var i=function(){return e.map(T,function(e){return e.hash})};return void 0!==t&&(T.length&&this.trigger("unlockfiles",{files:i()}),z=[],T=e.map(t||[],function(e){var t=w[e];return t?(z.push(e),{hash:e,phash:t.phash,name:t.name,mime:t.mime,read:t.read,locked:t.locked,cut:!!n}):null}),this.trigger("changeclipboard",{clipboard:T.slice(0,T.length)}),n&&this.trigger("lockfiles",{files:i()})),T.slice(0,T.length)},this.isCommandEnabled=function(t,n){var i,a=s.cwd().volumeid||"";return!n||a&&0===n.indexOf(a)?i=y.disabled:(i=s.option("disabled",n),i||(i=[])),this._commands[t]?-1===e.inArray(t,i):!1},this.exec=function(t,n,i,a){return"open"===t&&((this.searchStatus.state||this.searchStatus.ininc)&&this.trigger("searchend",{noupdate:!0}),this.autoSync("stop")),this._commands[t]&&this.isCommandEnabled(t,a)?this._commands[t].exec(n,i):e.Deferred().reject("No such command")},this.dialog=function(n,i){var a=e("<div/>").append(n).appendTo(t).elfinderdialog(i,this),r=a.closest(".ui-dialog"),o=function(){!a.data("draged")&&a.is(":visible")&&a.elfinderdialog("posInit")};return r.length&&(s.bind("resize",o),r.on("remove",function(){s.unbind("resize",o)})),a},this.toast=function(t){return e('<div class="ui-front"/>').appendTo(this.ui.toast).elfindertoast(t||{},this)},this.getUI=function(e){return this.ui[e]||t},this.getCommand=function(e){return void 0===e?this._commands:this._commands[e]},this.resize=function(e,n){t.css("width",e).height(n).trigger("resize"),this.trigger("resize",{width:t.width(),height:t.height()})},this.restoreSize=function(){this.resize(U,M)},this.show=function(){t.show(),this.enable().trigger("show")},this.hide=function(){this.options.enableAlways&&(g=m,m=!1),this.disable().trigger("hide"),t.hide()},this.lazy=function(n,i,a){var r=function(e){var n,i=t.data("lazycnt");e?(n=t.data("lazyrepaint")?!1:a.repaint,i?t.data("lazycnt",++i):t.data("lazycnt",1).addClass("elfinder-processing"),n&&t.data("lazyrepaint",!0).css("display")):i&&i>1?t.data("lazycnt",--i):(n=t.data("lazyrepaint"),t.data("lazycnt",0).removeData("lazyrepaint").removeClass("elfinder-processing"),n&&t.css("display"),s.trigger("lazydone"))},o=e.Deferred();return i=i||0,a=a||{},r(!0),setTimeout(function(){o.resolve(n.call(o)),r(!1)},i),o},this.destroy=function(){t&&t[0].elfinder&&(this.options.syncStart=!1,this.autoSync("forcestop"),this.trigger("destroy").disable(),T=[],k=[],x={},C={},e(window).off("."+u),e(document).off("."+u),s.trigger=function(){},t.off(),t.removeData(),t.empty(),t[0].elfinder=null,e(D).remove(),t.append(l.contents()).removeClass(this.cssClass).attr("style",d))},this.autoSync=function(t){var n;if(s.options.sync>=1e3){if(a&&(clearTimeout(a),a=null,s.trigger("autosync",{action:"stop"})),"stop"===t?++F:F=Math.max(0,--F),F||"forcestop"===t||!s.options.syncStart)return;n=function(t){var i;y.syncMinMs&&(t||a)&&(t&&s.trigger("autosync",{action:"start"}),i=Math.max(s.options.sync,y.syncMinMs),a&&clearTimeout(a),a=setTimeout(function(){var t,r=!0,o=b;y.syncChkAsTs&&(t=w[o].ts)?s.request({data:{cmd:"info",targets:[o],compare:t,reload:1},preventDefault:!0}).done(function(e){var i;r=!0,e.compare&&(i=e.compare,i==t&&(r=!1)),r?s.sync(o).always(function(){i&&(w[o].ts=i),n()}):n()}).fail(function(t,r){t&&0!=r.status?(s.error(t),-1!==e.inArray("errOpen",t)&&s.request({data:{cmd:"open",target:s.lastDir("")||s.root(),tree:1,init:1},notify:{type:"open",cnt:1,hideCnt:!0}})):a=setTimeout(function(){n()},i)}):s.sync(b,!0).always(function(){n()})},i))},n(!0)}},this.insideWorkzone=function(e,t,n){var i=this.getUI("workzone").data("rectangle");return n=n||1,!(e<i.left+n||e>i.left+i.width+n||t<i.top+n||t>i.top+i.height+n)},this.toFront=function(n){var i=t.children(":last");n=e(n),i.get(0)!==n.get(0)&&i.after(n)},this.getMaximizeCss=function(){return{width:"100%",height:"100%",margin:0,padding:0,top:0,left:0,display:"block",position:"fixed",zIndex:Math.max(s.zIndex?s.zIndex+1:0,1e3)}},function(){N&&s.UA.Fullscreen&&(s.UA.Fullscreen=!1,q&&"undefined"!=typeof q.attr("allowfullscreen")&&(s.UA.Fullscreen=!0));var n,i,a,r="elfinder-fullscreen",o="elfinder-fullscreen-native",l=function(){var n=0,i=0;e.each(t.children(".ui-dialog,.ui-draggable"),function(t,a){var r=e(a),o=r.position();o.top<0&&(r.css("top",n),n+=20),o.left<0&&(r.css("left",i),i+=20)})},d=s.UA.Fullscreen?{fullElm:function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||null},exitFull:function(){return document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen?document.msExitFullscreen():void 0},toFull:function(e){return e.requestFullscreen?e.requestFullscreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.msRequestFullscreen?e.msRequestFullscreen():!1}}:{fullElm:function(){var e;return t.hasClass(r)?t.get(0):(e=t.find("."+r),e.length?e.get(0):null)},exitFull:function(){var t;e(window).off("resize."+u,h),void 0!==i&&e("body").css("overflow",i),i=void 0,n&&(t=n.elm,c(t),e(t).trigger("resize",{fullscreen:"off"})),e(window).trigger("resize")},toFull:function(t){return i=e("body").css("overflow")||"",e("body").css("overflow","hidden"),e(t).css(s.getMaximizeCss()).addClass(r).trigger("resize",{fullscreen:"on"}),l(),e(window).on("resize."+u,h).trigger("resize"),!0}},c=function(t){n&&n.elm==t&&(e(t).removeClass(r+" "+o).attr("style",n.style),n=null)},h=function(t){var n;t.target===window&&(a&&clearTimeout(a),a=setTimeout(function(){(n=d.fullElm())&&e(n).trigger("resize",{fullscreen:"on"})},100))};e(document).on("fullscreenchange."+u+" webkitfullscreenchange."+u+" mozfullscreenchange."+u+" MSFullscreenChange."+u,function(t){if(s.UA.Fullscreen){var i=d.fullElm(),p=e(window);a&&clearTimeout(a),null===i?(p.off("resize."+u,h),n&&(i=n.elm,c(i),e(i).trigger("resize",{fullscreen:"off"}))):(e(i).addClass(r+" "+o).attr("style","width:100%; height:100%; margin:0; padding:0;").trigger("resize",{fullscreen:"on"}),p.on("resize."+u,h),l()),p.trigger("resize")}}),s.toggleFullscreen=function(t,i){var a=e(t).get(0),r=null;if(r=d.fullElm()){if(r==a){if(i===!0)return r}else if(i===!1)return r;return d.exitFull(),null}return i===!1?null:(n={elm:a,style:e(a).attr("style")},d.toFull(a)!==!1?a:(n=null,null))}}(),function(){var t,n="elfinder-maximized",i=function(e){if(e.target===window&&e.data&&e.data.elm){var n=e.data.elm;t&&clearTimeout(t),t=setTimeout(function(){n.trigger("resize",{maximize:"on"})},100)}},a=function(t){e(window).off("resize."+u,i),e("body").css("overflow",t.data("bodyOvf")),t.removeClass(n).attr("style",t.data("orgStyle")).removeData("bodyOvf").removeData("orgStyle"),t.trigger("resize",{maximize:"off"})},r=function(t){t.data("bodyOvf",e("body").css("overflow")||"").data("orgStyle",t.attr("style")).addClass(n).css(s.getMaximizeCss()),e("body").css("overflow","hidden"),e(window).on("resize."+u,{elm:t},i).trigger("resize")};s.toggleMaximize=function(t,i){var o=e(t),s=o.hasClass(n);if(s){if(i===!0)return;a(o)}else{if(i===!1)return;r(o)}}}(),e.fn.selectable&&e.fn.draggable&&e.fn.droppable?t.length?this.options.url?(e.extend(e.ui.keyCode,{F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,CONTEXTMENU:93}),this.dragUpload=!1,this.xhrUpload=("undefined"!=typeof XMLHttpRequestUpload||"undefined"!=typeof XMLHttpRequestEventTarget)&&"undefined"!=typeof File&&"undefined"!=typeof FormData,this.transport={},"object"==typeof this.options.transport&&(this.transport=this.options.transport,"function"==typeof this.transport.init&&this.transport.init(this)),"function"!=typeof this.transport.send&&(this.transport.send=function(t){
  1814. return e.ajax(t)}),"iframe"==this.transport.upload?this.transport.upload=e.proxy(this.uploads.iframe,this):"function"==typeof this.transport.upload?this.dragUpload=!!this.options.dragUploadAllow:this.xhrUpload&&this.options.dragUploadAllow?(this.transport.upload=e.proxy(this.uploads.xhr,this),this.dragUpload=!0):this.transport.upload=e.proxy(this.uploads.iframe,this),this.decodeRawString=e.isFunction(this.options.rawStringDecoder)?this.options.rawStringDecoder:function(e){var t=function(e){var t,n,i;for(t=0,n=e.length,i=[];n>t;t++)i.push(e.charCodeAt(t));return i},n=function(e){var n,i,a,r=[];for("string"==typeof e&&(e=t(e)),n=0,i=e.length;a=e[n],i>n;n++)a>=55296&&56319>=a?r.push((1023&a)+64<<10|1023&e[++n]):r.push(a);return r},i=function(e){var t,n,i,a,r=String.fromCharCode;for(t=0,n=e.length,a="";i=e[t],n>t;t++)a+=127>=i?r(i):223>=i&&i>=194?r((31&i)<<6|63&e[++t]):239>=i&&i>=224?r((15&i)<<12|(63&e[++t])<<6|63&e[++t]):247>=i&&i>=240?r(55296|((7&i)<<8|(63&e[++t])<<2|e[++t]>>>4&3)-64,56320|(15&e[t++])<<6|63&e[t]):r(65533);return a};return i(n(e))},this.error=function(){var e=arguments[0],t=arguments[1]||null;return 1==arguments.length&&"function"==typeof e?s.bind("error",e):e===!0?this:s.trigger("error",{error:e,opts:t})},e.each(v,function(t,n){s[n]=function(){var t=arguments[0];return 1==arguments.length&&"function"==typeof t?s.bind(n,t):s.trigger(n,e.isPlainObject(t)?t:{})}}),this.enable(function(){!m&&s.visible()&&s.ui.overlay.is(":hidden")&&!t.children(".elfinder-dialog").find("."+s.res("class","editing")).length&&(m=!0,document.activeElement&&document.activeElement.blur(),t.removeClass("elfinder-disabled"))}).disable(function(){g=m,m=!1,t.addClass("elfinder-disabled")}).open(function(){k=[]}).select(function(t){var n=0,i=[];k=e.map(t.data.selected||t.data.value||[],function(e){return i.length||s.maxTargets&&++n>s.maxTargets?(i.push(e),null):w[e]?e:null}),i.length&&(s.trigger("unselectfiles",{files:i,inselect:!0}),s.toast({mode:"warning",msg:s.i18n(["errMaxTargets",s.maxTargets])}))}).error(function(t){var n={cssClass:"elfinder-dialog-error",title:s.i18n(s.i18n("error")),resizable:!1,destroyOnClose:!0,buttons:{}};n.buttons[s.i18n(s.i18n("btnClose"))]=function(){e(this).elfinderdialog("close")},t.data.opts&&e.isPlainObject(t.data.opts)&&e.extend(n,t.data.opts),s.dialog('<span class="elfinder-dialog-icon elfinder-dialog-icon-error"/>'+s.i18n(t.data.error),n)}).bind("tree parents",function(e){R(e.data.tree||[])}).bind("tmb",function(t){e.each(t.data.images||[],function(e,t){w[e]&&(w[e].tmb=t)})}).add(function(e){R(e.data.added||[])}).change(function(t){e.each(t.data.changed||[],function(t,n){var i=n.hash;w[i]&&e.each(["locked","hidden","width","height"],function(e,t){w[i][t]&&!n[t]&&delete w[i][t]}),w[i]=w[i]?e.extend(w[i],n):n})}).remove(function(t){var n=t.data.removed||[],i=n.length,a={},r=function(t){var n=w[t];n&&("directory"===n.mime&&(a[t]&&delete s.roots[a[t]],e.each(w,function(e,n){n.phash==t&&r(e)})),delete w[t])};for(e.each(s.roots,function(e,t){a[t]=e});i--;)r(n[i])}).bind("searchstart",function(t){e.extend(s.searchStatus,t.data),s.searchStatus.state=1}).bind("search",function(e){s.searchStatus.state=2,R(e.data.files||[])}).bind("searchend",function(){s.searchStatus.state=0,s.searchStatus.mixed=!1}),!0===this.options.sound&&this.bind("rm",function(t){var n=D.canPlayType&&D.canPlayType('audio/wav; codecs="1"');n&&""!=n&&"no"!=n&&e(D).html('<source src="'+O+'rm.wav" type="audio/wav">')[0].play()}),e.each(this.options.handlers,function(e,t){s.bind(e,t)}),this.history=new this.history(this),this.commands.getfile&&("function"==typeof this.options.getFileCallback?(this.bind("dblclick",function(e){e.preventDefault(),s.exec("getfile").fail(function(){s.exec("open")})}),this.shortcut({pattern:"enter",description:this.i18n("cmdgetfile"),callback:function(){s.exec("getfile").fail(function(){s.exec("mac"==s.OS?"rename":"open")})}}).shortcut({pattern:"ctrl+enter",description:this.i18n("mac"==this.OS?"cmdrename":"cmdopen"),callback:function(){s.exec("mac"==s.OS?"rename":"open")}})):this.options.getFileCallback=null),this.roots={},this.leafRoots={},this._commands={},e.isArray(this.options.commands)||(this.options.commands=[]),-1!==e.inArray("*",this.options.commands)&&(this.options.commands=Object.keys(this.commands)),e.each(this.commands,function(t,n){var i,a,r=e.extend({},n.prototype);if(e.isFunction(n)&&!s._commands[t]&&(n.prototype.forceLoad||-1!==e.inArray(t,s.options.commands))){if(i=n.prototype.extendsCmd||""){if(!e.isFunction(s.commands[i]))return!0;n.prototype=e.extend({},S,new s.commands[i],n.prototype)}else n.prototype=e.extend({},S,n.prototype);s._commands[t]=new n,n.prototype=r,a=s.options.commandsOptions[t]||{},i&&s.options.commandsOptions[i]&&(a=e.extend(!0,{},s.options.commandsOptions[i],a)),s._commands[t].setup(t,a),s._commands[t].linkedCmds.length&&e.each(s._commands[t].linkedCmds,function(t,n){var i=s.commands[n];e.isFunction(i)&&!s._commands[n]&&(i.prototype=S,s._commands[n]=new i,s._commands[n].setup(n,s.options.commandsOptions[n]||{}))})}}),this.commandMap={},this.volOptions={},this.optionsByHashes={},t.addClass(this.cssClass).on(h,function(){!m&&s.enable()}),this.ui={workzone:e("<div/>").appendTo(t).elfinderworkzone(this),navbar:e("<div/>").appendTo(t).elfindernavbar(this,this.options.uiOptions.navbar||{}),contextmenu:e("<div/>").appendTo(t).elfindercontextmenu(this),overlay:e("<div/>").appendTo(t).elfinderoverlay({show:function(){s.disable()},hide:function(){g&&s.enable()}}),cwd:e("<div/>").appendTo(t).elfindercwd(this,this.options.uiOptions.cwd||{}),notify:this.dialog("",{cssClass:"elfinder-dialog-notify",position:this.options.notifyDialog.position,absolute:!0,resizable:!1,autoOpen:!1,closeOnEscape:!1,title:"&nbsp;",width:parseInt(this.options.notifyDialog.width)}),statusbar:e('<div class="ui-widget-header ui-helper-clearfix ui-corner-bottom elfinder-statusbar"/>').hide().appendTo(t),toast:e('<div class="elfinder-toast"/>').appendTo(t),bottomtray:e('<div class="elfinder-bottomtray">').appendTo(t)},this.uiAutoHide=[],this.one("open",function(){s.uiAutoHide.length&&setTimeout(function(){s.trigger("uiautohide")},500)}),this.bind("uiautohide",function(){s.uiAutoHide.length&&s.uiAutoHide.shift()()}),e.each(this.options.ui||[],function(n,i){var a="elfinder"+i,r=s.options.uiOptions[i]||{};!s.ui[i]&&e.fn[a]&&(s.ui[i]=e("<"+(r.tag||"div")+"/>").appendTo(t),s.ui[i][a](s,r))}),t[0].elfinder=this,this.options.resizable&&e.fn.resizable&&t.resizable({resize:function(e,t){s.resize(t.size.width,t.size.height)},handles:"se",minWidth:300,minHeight:200}),this.options.width&&(U=this.options.width),this.options.height&&(M=parseInt(this.options.height)),this.options.soundPath&&(O=this.options.soundPath.replace(/\/+$/,"")+"/"),s.resize(U,M),e(document).on("click."+u,function(n){m&&!s.options.enableAlways&&!e(n.target).closest(t).length&&s.disable()}).on(p+" "+f,j),s.options.useBrowserHistory&&e(window).on("popstate."+u,function(t){var n=t.originalEvent.state&&t.originalEvent.state.thash;n&&!e.isEmptyObject(s.files())&&s.request({data:{cmd:"open",target:n,onhistory:1},notify:{type:"open",cnt:1,hideCnt:!0},syncOnFail:!0})}),function(){var n;e(window).on("resize."+u,function(e){e.target===this&&(n&&clearTimeout(n),n=setTimeout(function(){s.trigger("resize",{width:t.width(),height:t.height()})},100))}).on("beforeunload."+u,function(n){var i,a;return t.is(":visible")&&(s.ui.notify.children().length&&-1!==e.inArray("hasNotifyDialog",s.options.windowCloseConfirm)?i=s.i18n("ntfsmth"):t.find("."+s.res("class","editing")).length&&-1!==e.inArray("editingFile",s.options.windowCloseConfirm)?i=s.i18n("editingFile"):(a=Object.keys(s.selected()).length)&&-1!==e.inArray("hasSelectedItem",s.options.windowCloseConfirm)?i=s.i18n("hasSelected",""+a):(a=Object.keys(s.clipboard()).length)&&-1!==e.inArray("hasClipboardData",s.options.windowCloseConfirm)&&(i=s.i18n("hasClipboard",""+a)),i)?(n.returnValue=i,i):void s.trigger("unload")})}(),e(window).on("message."+u,function(e){var t,n,i=e.originalEvent||null;if(i&&0===s.uploadURL.indexOf(i.origin))try{t=JSON.parse(i.data),n=t.data||null,n&&(n.error?(t.bind&&s.trigger(t.bind+"fail",n),s.error(n.error)):(n.warning&&s.error(n.warning),n.removed&&n.removed.length&&s.remove(n),n.added&&n.added.length&&s.add(n),n.changed&&n.changed.length&&s.change(n),t.bind&&(s.trigger(t.bind,n),s.trigger(t.bind+"done")),n.sync&&s.sync()))}catch(e){s.sync()}}),s.options.enableAlways?(e(window).on("focus."+u,function(e){e.target===this&&s.enable()}),N&&e(window.top).on("focus."+u,function(){!s.enable()||q&&!q.is(":visible")||setTimeout(function(){e(window).focus()},10)})):N&&e(window).on("blur."+u,function(e){m&&e.target===this&&s.disable()}),function(){var e=s.getUI("navbar"),t=s.getUI("cwd").parent();s.autoScroll={navbarUp:function(t){e.scrollTop(Math.max(0,e.scrollTop()-t))},navbarDown:function(t){e.scrollTop(e.scrollTop()+t)},cwdUp:function(e){t.scrollTop(Math.max(0,t.scrollTop()-e))},cwdDown:function(e){t.scrollTop(t.scrollTop()+e)}}}(),s.dragUpload&&!function(){var n,i,a=function(t){return"TEXTAREA"!==t.target.nodeName&&"INPUT"!==t.target.nodeName&&0===e(t.target).closest("div.ui-dialog-content").length},r="native-drag-enter",o="native-drag-disable",l="class",d=s.res(l,"navdir"),u=(s.res(l,"droppable"),s.res(l,"adroppable"),s.res(l,"navarrow"),s.res(l,"adroppable")),h=s.getUI("workzone"),p="ltr"===s.direction,f=function(){i&&clearTimeout(i),i=null};t.on("dragenter",function(e){f(),a(e)&&(e.preventDefault(),e.stopPropagation(),n=h.data("rectangle"))}).on("dragleave",function(e){f(),a(e)&&(e.preventDefault(),e.stopPropagation())}).on("dragover",function(e){var t;a(e)?(e.preventDefault(),e.stopPropagation(),e.originalEvent.dataTransfer.dropEffect="none",i||(i=setTimeout(function(){var a,r=n.top+n.height;((t=e.pageY<n.top)||e.pageY>r)&&(a=n.cwdEdge>e.pageX?(p?"navbar":"cwd")+(t?"Up":"Down"):(p?"cwd":"navbar")+(t?"Up":"Down"),s.autoScroll[a](Math.pow(t?n.top-e.pageY:e.pageY-r,1.3))),i=null},20))):f()}).on("drop",function(e){f(),a(e)&&(e.stopPropagation(),e.preventDefault())}),t.on("dragenter",".native-droppable",function(t){if(t.originalEvent.dataTransfer){var n,i=e(t.currentTarget),a=t.currentTarget.id||null,l=null;if(!a){l=s.cwd(),i.data(o,!1);try{e.each(t.originalEvent.dataTransfer.types,function(e,t){"elfinderfrom:"===t.substr(0,13)&&(n=t.substr(13).toLowerCase())})}catch(t){}}l&&(!l.write||n&&n===(window.location.href+l.hash).toLowerCase())?i.data(o,!0):(t.preventDefault(),t.stopPropagation(),i.data(r,!0),i.addClass(u))}}).on("dragleave",".native-droppable",function(t){if(t.originalEvent.dataTransfer){var n=e(t.currentTarget);t.preventDefault(),t.stopPropagation(),n.data(r)?n.data(r,!1):n.removeClass(u)}}).on("dragover",".native-droppable",function(t){if(t.originalEvent.dataTransfer){var n=e(t.currentTarget);t.preventDefault(),t.stopPropagation(),t.originalEvent.dataTransfer.dropEffect=n.data(o)?"none":"copy",n.data(r,!1)}}).on("drop",".native-droppable",function(t){if(t.originalEvent&&t.originalEvent.dataTransfer){var n=e(t.currentTarget);t.preventDefault(),t.stopPropagation(),n.removeClass(u),c=t.currentTarget.id?n.hasClass(d)?s.navId2Hash(t.currentTarget.id):s.cwdId2Hash(t.currentTarget.id):s.cwd().hash,t.originalEvent._target=c,s.exec("upload",{dropEvt:t.originalEvent,target:c},void 0,c)}})}(),s.UA.Touch&&!function(){var n,i,a,r,o,l,d,c,h=s.getUI("navbar"),p=s.getUI("toolbar"),f=function(e){e.preventDefault()},m=function(){e(document).off("touchmove",f)},g=50;t.on("touchstart touchmove touchend",function(v){if("touchend"===v.type)return n=!1,i=!1,void m();var b,y,w,k,x,C,T=v.originalEvent.touches||[{}],z=T[0].pageX||null,A=T[0].pageY||null,I="ltr"===s.direction;null===z||null===A||"touchstart"===v.type&&T.length>1||("touchstart"===v.type?(a=t.offset(),r=t.width(),h&&(n=!1,h.is(":hidden")?(c||(c=Math.max(50,r/10)),(I?z-a.left:r+a.left-z)<c&&(n=z)):(l=h.width(),y=Math.max.apply(Math,e.map(h.children(".elfinder-tree"),function(t){return e(t).width()})),w=I?z<a.left+l&&y-h.scrollLeft()-5<=l:z>a.left+r-l&&y+h.scrollLeft()-5<=l,w?(c=Math.max(50,r/10),n=z):n=!1)),p&&(d=p.height(),o=a.top,A-o<(p.is(":hidden")?g:d+30)?(i=A,e(document).on("touchmove."+u,f),setTimeout(function(){m()},500)):i=!1)):(h&&n!==!1&&(b=(I?n>z:z>n)?"navhide":"navshow",k=Math.abs(n-z),("navhide"===b&&k>.6*l||k>("navhide"===b?l/3:45)&&("navshow"===b||(I?z<a.left+20:z>a.left+r-20)))&&(s.getUI("navbar").trigger(b,{handleW:c}),n=!1)),p&&i!==!1&&(x=p.offset().top,Math.abs(i-A)>Math.min(45,d/3)&&(C=i>A?"slideUp":"slideDown",("slideDown"===C||x+20>A)&&(p.is("slideDown"===C?":hidden":":visible")&&(p.stop(!0,!0).trigger("toggle",{duration:100,handleH:g}),m()),i=!1)))))})}(),N&&t.on("click",function(t){e(window).focus()}),this.options.enableByMouseOver&&t.on("mouseenter",function(t){N&&e(window).focus(),!s.enabled()&&s.enable()}),this.options.cssAutoLoad||this.trigger("cssloaded"),void this.trigger("init").request({data:{cmd:"open",target:s.startDir(),init:1,tree:this.ui.tree?1:0},preventDone:!0,notify:{type:"open",cnt:1,hideCnt:!0},freeze:!0}).fail(function(){s.trigger("fail").disable().lastDir(""),x={},C={},e(document).add(t).off("."+u),s.trigger=function(){}}).done(function(n){var i=t.css("z-index");i&&"auto"!==i&&"inherit"!==i?s.zIndex=i:t.parents().each(function(t,n){var i=e(n).css("z-index");return"auto"!==i&&"inherit"!==i&&(i=parseInt(i))?(s.zIndex=i,!1):void 0}),s.load().debug("api",s.api),t.trigger("resize"),P(n),s.trigger("open",n),N&&s.options.enableAlways&&e(window).focus()})):alert(this.i18n("errURL")):alert(this.i18n("errNode")):alert(this.i18n("errJqui"))};("undefined"==typeof n||n)&&(window.elFinder=i),i.prototype={uniqueid:0,res:function(e,t){return this.resources[e]&&this.resources[e][t]},OS:-1!==navigator.userAgent.indexOf("Mac")?"mac":-1!==navigator.userAgent.indexOf("Win")?"win":"other",UA:function(){var e=!document.uniqueID&&!window.opera&&!window.sidebar&&window.localStorage&&"WebkitAppearance"in document.documentElement.style;return{ltIE6:"undefined"==typeof window.addEventListener&&"undefined"==typeof document.documentElement.style.maxHeight,ltIE7:"undefined"==typeof window.addEventListener&&"undefined"==typeof document.querySelectorAll,ltIE8:"undefined"==typeof window.addEventListener&&"undefined"==typeof document.getElementsByClassName,IE:document.uniqueID,Firefox:window.sidebar,Opera:window.opera,Webkit:e,Chrome:e&&window.chrome,Safari:e&&!window.chrome,Mobile:"undefined"!=typeof window.orientation,Touch:"undefined"!=typeof window.ontouchstart,iOS:navigator.platform.match(/^iP(?:[ao]d|hone)/),Fullscreen:"undefined"!=typeof(document.exitFullscreen||document.webkitExitFullscreen||document.mozCancelFullScreen||document.msExitFullscreen)}}(),currentReqCmd:"",i18:{en:{translator:"",language:"English",direction:"ltr",dateFormat:"d.m.Y H:i",fancyDateFormat:"$1 H:i",messages:{}},months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["msJan","msFeb","msMar","msApr","msMay","msJun","msJul","msAug","msSep","msOct","msNov","msDec"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},kinds:{unknown:"Unknown",directory:"Folder",symlink:"Alias","symlink-broken":"AliasBroken","application/x-empty":"TextPlain","application/postscript":"Postscript","application/vnd.ms-office":"MsOffice","application/msword":"MsWord","application/vnd.ms-word":"MsWord","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"MsWord","application/vnd.ms-word.document.macroEnabled.12":"MsWord","application/vnd.openxmlformats-officedocument.wordprocessingml.template":"MsWord","application/vnd.ms-word.template.macroEnabled.12":"MsWord","application/vnd.ms-excel":"MsExcel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"MsExcel","application/vnd.ms-excel.sheet.macroEnabled.12":"MsExcel","application/vnd.openxmlformats-officedocument.spreadsheetml.template":"MsExcel","application/vnd.ms-excel.template.macroEnabled.12":"MsExcel","application/vnd.ms-excel.sheet.binary.macroEnabled.12":"MsExcel","application/vnd.ms-excel.addin.macroEnabled.12":"MsExcel","application/vnd.ms-powerpoint":"MsPP","application/vnd.openxmlformats-officedocument.presentationml.presentation":"MsPP","application/vnd.ms-powerpoint.presentation.macroEnabled.12":"MsPP","application/vnd.openxmlformats-officedocument.presentationml.slideshow":"MsPP","application/vnd.ms-powerpoint.slideshow.macroEnabled.12":"MsPP","application/vnd.openxmlformats-officedocument.presentationml.template":"MsPP","application/vnd.ms-powerpoint.template.macroEnabled.12":"MsPP","application/vnd.ms-powerpoint.addin.macroEnabled.12":"MsPP","application/vnd.openxmlformats-officedocument.presentationml.slide":"MsPP","application/vnd.ms-powerpoint.slide.macroEnabled.12":"MsPP","application/pdf":"PDF","application/xml":"XML","application/vnd.oasis.opendocument.text":"OO","application/vnd.oasis.opendocument.text-template":"OO","application/vnd.oasis.opendocument.text-web":"OO","application/vnd.oasis.opendocument.text-master":"OO","application/vnd.oasis.opendocument.graphics":"OO","application/vnd.oasis.opendocument.graphics-template":"OO","application/vnd.oasis.opendocument.presentation":"OO","application/vnd.oasis.opendocument.presentation-template":"OO","application/vnd.oasis.opendocument.spreadsheet":"OO","application/vnd.oasis.opendocument.spreadsheet-template":"OO","application/vnd.oasis.opendocument.chart":"OO","application/vnd.oasis.opendocument.formula":"OO","application/vnd.oasis.opendocument.database":"OO","application/vnd.oasis.opendocument.image":"OO","application/vnd.openofficeorg.extension":"OO","application/x-shockwave-flash":"AppFlash","application/flash-video":"Flash video","application/x-bittorrent":"Torrent","application/javascript":"JS","application/rtf":"RTF","application/rtfd":"RTF","application/x-font-ttf":"TTF","application/x-font-otf":"OTF","application/x-rpm":"RPM","application/x-web-config":"TextPlain","application/xhtml+xml":"HTML","application/docbook+xml":"DOCBOOK","application/x-awk":"AWK","application/x-gzip":"GZIP","application/x-bzip2":"BZIP","application/x-xz":"XZ","application/zip":"ZIP","application/x-zip":"ZIP","application/x-rar":"RAR","application/x-tar":"TAR","application/x-7z-compressed":"7z","application/x-jar":"JAR","text/plain":"TextPlain","text/x-php":"PHP","text/html":"HTML","text/javascript":"JS","text/css":"CSS","text/rtf":"RTF","text/rtfd":"RTF","text/x-c":"C","text/x-csrc":"C","text/x-chdr":"CHeader","text/x-c++":"CPP","text/x-c++src":"CPP","text/x-c++hdr":"CPPHeader","text/x-shellscript":"Shell","application/x-csh":"Shell","text/x-python":"Python","text/x-java":"Java","text/x-java-source":"Java","text/x-ruby":"Ruby","text/x-perl":"Perl","text/x-sql":"SQL","text/xml":"XML","text/x-comma-separated-values":"CSV","text/x-markdown":"Markdown","image/x-ms-bmp":"BMP","image/jpeg":"JPEG","image/gif":"GIF","image/png":"PNG","image/tiff":"TIFF","image/x-targa":"TGA","image/vnd.adobe.photoshop":"PSD","image/xbm":"XBITMAP","image/pxm":"PXM","audio/mpeg":"AudioMPEG","audio/midi":"AudioMIDI","audio/ogg":"AudioOGG","audio/mp4":"AudioMPEG4","audio/x-m4a":"AudioMPEG4","audio/wav":"AudioWAV","audio/x-mp3-playlist":"AudioPlaylist","video/x-dv":"VideoDV","video/mp4":"VideoMPEG4","video/mpeg":"VideoMPEG","video/x-msvideo":"VideoAVI","video/quicktime":"VideoMOV","video/x-ms-wmv":"VideoWM","video/x-flv":"VideoFlash","video/x-matroska":"VideoMKV","video/ogg":"VideoOGG"},rules:{defaults:function(t){return!(!t||t.added&&!e.isArray(t.added)||t.removed&&!e.isArray(t.removed)||t.changed&&!e.isArray(t.changed))},open:function(t){return t&&t.cwd&&t.files&&e.isPlainObject(t.cwd)&&e.isArray(t.files)},tree:function(t){return t&&t.tree&&e.isArray(t.tree)},parents:function(t){return t&&t.tree&&e.isArray(t.tree)},tmb:function(t){return t&&t.images&&(e.isPlainObject(t.images)||e.isArray(t.images))},upload:function(t){return t&&(e.isPlainObject(t.added)||e.isArray(t.added))},search:function(t){return t&&t.files&&e.isArray(t.files)}},commands:{},cmdsToAdd:"archive duplicate extract mkdir mkfile paste rm upload",parseUploadData:function(t){var n;if(!e.trim(t))return{error:["errResponse","errDataEmpty"]};try{n=JSON.parse(t)}catch(i){return{error:["errResponse","errDataNotJSON"]}}return this.validResponse("upload",n)?(n=this.normalize(n),n.removed=e.merge(n.removed||[],e.map(n.added||[],function(e){return e.hash})),n):{error:["errResponse"]}},iframeCnt:0,uploads:{xhrUploading:!1,checkExists:function(t,n,i){var a,r,o=e.Deferred(),s=function(){for(var e=t.length;--e>-1;)t[e]._remove=!0},l=function(){var l=[],d={},c=[],u=[],h=function(e){var n=e==u.length-1,a={title:i.i18n("cmdupload"),text:["errExists",u[e].name,"confirmRepl"],all:!n,accept:{label:"btnYes",callback:function(t){n||t?o.resolve(l,d):h(++e)}},reject:{label:"btnNo",callback:function(i){var a;if(i)for(a=u.length;e<a--;)t[u[a].i]._remove=!0;else t[u[e].i]._remove=!0;n||i?o.resolve(l,d):h(++e)}},cancel:{label:"btnCancel",callback:function(){s(),o.resolve(l,d)}},buttons:[{label:"btnBackup",callback:function(t){var i;if(t)for(i=u.length;e<i--;)l.push(u[i].name);else l.push(u[e].name);n||t?o.resolve(l,d):h(++e)}}]};i.iframeCnt>0&&delete a.reject,i.confirm(a)};return i.file(n).read?(a=e.map(t,function(e,t){return e.name?{i:t,name:e.name}:null}),r=e.map(a,function(e){return e.name}),void i.request({data:{cmd:"ls",target:n,intersect:r},notify:{type:"preupload",cnt:1,hideCnt:!0},preventFail:!0}).done(function(t){var r,l;t&&(t.error?s():i.options.overwriteUploadConfirm&&!i.UA.iOS&&i.option("uploadOverwrite",n)&&t.list&&(e.isArray(t.list)?c=t.list||[]:(r=[],c=e.map(t.list,function(e){return"string"==typeof e?e:(r=r.concat(e),null)}),r.length&&(c=c.concat(r)),d=t.list),u=e.map(a,function(t){return-1!==e.inArray(t.name,c)?t:null}),c.length&&n==i.cwd().hash&&(l=e.map(i.files(),function(e){return e.phash==n?e.name:null}),e.map(c,function(t){return-1===e.inArray(t,l)?!0:null}).length&&i.sync()))),u.length>0?h(0):o.resolve([])}).fail(function(e){s(),o.resolve([]),e&&i.error(e)})):void o.resolve([])};return i.api>=2.1&&"object"==typeof t[0]?(l(),o):o.resolve([])},checkFile:function(t,n,i){if(t.checked||"files"==t.type)return t.files;if("data"==t.type){var a,r=e.Deferred(),o=[],s=[],l=0,d=[],c=function(e){var t,i,a,r=[],u=function(e){return Array.prototype.slice.call(e||[],0)},h=n.options.folderUploadExclude[n.OS]||null;a=e.length;for(var p=0;a>p;p++)if(i=e[p])if(i.isFile)l++,i.file(function(e){h&&e.name.match(h)||(s.push(i.fullPath||""),o.push(e)),l--});else if(i.isDirectory&&n.api>=2.1){l++,d.push(i.fullPath),t=i.createReader();var r=[],f=function(){t.readEntries(function(e){if(e.length)r=r.concat(u(e)),f();else{for(var t=0;t<r.length;t++)c([r[t]]);l--}},function(){l--})};f()}};return a=e.map(t.files.items,function(e){return e.getAsEntry?e.getAsEntry():e.webkitGetAsEntry()}),a.length>0?(n.uploads.checkExists(a,i,n).done(function(t,u){var h,p=[];n.options.overwriteUploadConfirm&&!n.UA.iOS&&n.option("uploadOverwrite",i)&&(a=e.map(a,function(a){var r,o,s,l;return a.isDirectory&&(r=e.inArray(a.name,t),-1!==r&&(t.splice(r,1),o=n.uniqueName(a.name+n.options.backupSuffix,null,""),e.each(u,function(e,t){return a.name==t?(s=e,!1):void 0}),s||(s=n.fileByName(a.name,i).hash),n.lockfiles({files:[s]}),l=n.request({data:{cmd:"rename",target:s,name:o},notify:{type:"rename",cnt:1}}).fail(function(e){a._remove=!0,n.sync()}).always(function(){n.unlockfiles({files:[s]})}),p.push(l))),a._remove?null:a})),e.when.apply(e,p).done(function(){a.length>0?(h=setTimeout(function(){n.notify({type:"readdir",cnt:1,hideCnt:!0})},n.options.notifyDelay),c(a),setTimeout(function e(){l>0?setTimeout(e,10):(h&&clearTimeout(h),n.notify({type:"readdir",cnt:-1}),r.resolve([o,s,t,u,d]))},10)):r.reject()})}),r.promise()):r.reject()}var u=[],h=[],p=t.files[0];if("html"==t.type){var f,m=e("<html/>").append(e.parseHTML(p.replace(/ src=/gi," _elfsrc=")));e("img[_elfsrc]",m).each(function(){var t,n,i=e(this),a=i.closest("a");a&&a.attr("href")&&a.attr("href").match(/\.(?:jpe?g|gif|bmp|png)/i)&&(n=a.attr("href")),t=i.attr("_elfsrc"),t&&(n?(-1==e.inArray(n,u)&&u.push(n),-1==e.inArray(t,h)&&h.push(t)):-1==e.inArray(t,u)&&u.push(t))}),f=e("a[href]",m),f.each(function(){var t,n=function(e){var t=document.createElement("a");return t.href=e,t};e(this).text()&&(t=n(e(this).attr("href")),!t.href||1!==f.length&&t.pathname.match(/(?:\.html?|\/[^\/.]*)$/i)||-1==e.inArray(t.href,u)&&-1==e.inArray(t.href,h)&&u.push(t.href))})}else{var g,v,b;for(g=/(http[^<>"{}|\\^\[\]`\s]+)/gi;v=g.exec(p);)b=v[1].replace(/&amp;/g,"&"),-1==e.inArray(b,u)&&u.push(b)}return u},xhr:function(t,n){var i=n?n:this,a=i.getUI(),r=new XMLHttpRequest,o=null,s=null,l=t.checked,d=t.isDataType||"data"==t.type,c=t.target||i.cwd().hash,u=t.dropEvt||null,h=-1!=i.option("uploadMaxConn",c),p=Math.min(5,Math.max(1,i.option("uploadMaxConn",c))),f=1e4,m=30,g=0,v=e.Deferred().fail(function(e){if(i.uploads.xhrUploading){setTimeout(function(){i.sync()},5e3);var t=y.length?d?y[0][0]:y[0]:{};t._cid&&(b=new FormData,y=[{_chunkfail:!0}],b.append("chunk",t._chunk),b.append("cid",t._cid),d=!1,R(y))}i.uploads.xhrUploading=!1,y=null,e&&i.error(e)}).done(function(e){r=null,i.uploads.xhrUploading=!1,y=null,e&&(i.currentReqCmd="upload",e.warning&&i.error(e.warning),e.removed&&i.remove(e),e.added&&i.add(e),e.changed&&i.change(e),i.trigger("upload",e),i.trigger("uploaddone"),e.sync&&i.sync(),e.debug&&n.debug("backend-debug",e))}).always(function(){a.off("uploadabort",U),e(window).off("unload",U),o&&clearTimeout(o),s&&clearTimeout(s),l&&!t.multiupload&&S()&&i.notify({type:"upload",cnt:-w,progress:0,size:0}),P&&z.children(".elfinder-notify-chunkmerge").length&&i.notify({type:"chunkmerge",cnt:-1})}),b=new FormData,y=t.input?t.input.files:i.uploads.checkFile(t,i,c),w=t.checked&&d?y[0].length:y.length,k=0,x=0,C=0,T=!1,z=i.ui.notify,A=!0,I=!1,S=function(){return T=T||z.children(".elfinder-notify-upload").length},U=function(){I=!0,r&&(r.quiet=!0,r.abort()),S()&&i.notify({type:"upload",cnt:-1*z.children(".elfinder-notify-upload").data("cnt"),progress:0,size:0})},M=function(e){z.children(".elfinder-notify-upload").children(".elfinder-notify-cancel")[e?"show":"hide"]()},O=function(e){return e||(e=C),setTimeout(function(){T=!0,i.notify({type:"upload",cnt:w,progress:k-x,size:e,cancel:function(){a.trigger("uploadabort"),v.resolve()}}),x=k,t.multiupload?A&&M(!0):M(A&&e>k)},i.options.notifyDelay)},D=function(){g++<=m?(S()&&x&&i.notify({type:"upload",cnt:0,progress:0,size:x}),r.quiet=!0,r.abort(),x=k=0,setTimeout(function(){I||(r.open("POST",i.uploadURL,!0),r.send(b))},f)):(a.trigger("uploadabort"),v.reject(["errAbort","errTimeout"]))},F=t.renames||null,E=t.hashes||null,P=!1;if(a.one("uploadabort",U),e(window).one("unload."+n.namespace,U),!P&&(x=k),!d&&!w)return v.reject(["errUploadNoFiles"]);r.addEventListener("error",function(){0==r.status?I?v.reject():!d&&t.files&&e.map(t.files,function(e){return e.type||e.size!==(i.UA.Safari?1802:0)?null:e}).length?(errors.push("errFolderUpload"),v.reject(["errAbort","errFolderUpload"])):t.input&&e.map(t.input.files,function(e){return e.type||e.size!==(i.UA.Safari?1802:0)?null:e}).length?v.reject(["errUploadNoFiles"]):D():(a.trigger("uploadabort"),v.reject("errConnect"))},!1),r.addEventListener("load",function(e){var n,l=r.status,c=0,u="";if(l>=400?u=l>500?"errResponse":"errConnect":r.responseText||(u=["errResponse","errDataEmpty"]),u){a.trigger("uploadabort");var h=d?y[0][0]:y[0];return v.reject(h._cid?null:u)}if(k=C,S()&&(c=k-x)&&i.notify({type:"upload",cnt:0,progress:c,size:0}),n=i.parseUploadData(r.responseText),n._chunkmerged){b=new FormData;var p=[{_chunkmerged:n._chunkmerged,_name:n._name,_mtime:n._mtime}];return P=!0,a.off("uploadabort",U),s=setTimeout(function(){i.notify({type:"chunkmerge",cnt:1})},i.options.notifyDelay),void(d?R(p,y[1]):R(p))}n._multiupload=!!t.multiupload,n.error?(i.trigger("uploadfail",n),n._chunkfailure||n._multiupload?(I=!0,i.uploads.xhrUploading=!1,o&&clearTimeout(o),z.children(".elfinder-notify-upload").length?(i.notify({type:"upload",cnt:-w,progress:0,size:0}),v.reject(n.error)):v.reject()):v.reject(n.error)):v.resolve(n)},!1),r.upload.addEventListener("loadstart",function(e){!P&&e.lengthComputable&&(k=e.loaded,g&&(k=0),C=e.total,k||(k=parseInt(.05*C)),S()&&(i.notify({type:"upload",cnt:0,progress:k-x,size:t.multiupload?0:C}),x=k))},!1),r.upload.addEventListener("progress",function(e){var n;e.lengthComputable&&!P&&r.readyState<2&&(k=e.loaded,!t.checked&&k>0&&!o&&(o=O(r._totalSize-k)),C||(C=e.total,k||(k=parseInt(.05*C))),n=k-x,S()&&n/e.total>=.05&&(i.notify({type:"upload",cnt:0,progress:n,size:0}),x=k),!t.multiupload&&k>=C&&(A=!1,M(!1)))},!1);var R=function(a,s){var f,m,g,y,k,x,C,T,z,U,D,P,R,j=0,H=1,N=[],q=0,_=w,L=0,W=[],B=(new Date).getTime().toString().substr(-9),V=Math.min((n.uplMaxSize?n.uplMaxSize:2097152)-8190,n.options.uploadMaxChunkSize),$=h?!1:"",K=function(a,r){var s,l,h=[],p=0;if(!I){for(;a.length&&h.length<r;)h.push(a.shift());if(p=h.length){l=p;for(var f=0;p>f&&!I;f++)s=d?h[f][0][0]._cid||null:h[f][0]._cid||null,R[s]?P--:n.exec("upload",{type:t.type,isDataType:d,files:h[f],checked:!0,target:c,dropEvt:u,renames:F,hashes:E,multiupload:!0},void 0,c).fail(function(e){e&&"No such command"===e&&(I=!0,n.error(["errUpload","errPerm"])),s&&(R[s]=!0)}).always(function(t){t&&t.added&&(U=e.merge(U,t.added)),P<=++D&&(n.trigger("multiupload",{added:U}),o&&clearTimeout(o),S()&&i.notify({type:"upload",cnt:-w,progress:0,size:0})),a.length?K(a,1):--l<=1&&(A=!1,M(!1))})}}(h.length<1||I)&&(I?(o&&clearTimeout(o),s&&(R[s]=!0),v.reject()):(v.resolve(),i.uploads.xhrUploading=!1))},G=function(){i.uploads.xhrUploading?setTimeout(function(){G()},100):(i.uploads.xhrUploading=!0,K(N,p))};if(!l&&(d||"files"==t.type)){for((f=n.option("uploadMaxSize",c))||(f=0),y=0;y<a.length;y++){try{T=a[y],m=T.size,$===!1&&($="",i.api>=2.1&&("slice"in T?$="slice":"mozSlice"in T?$="mozSlice":"webkitSlice"in T&&($="webkitSlice")))}catch(J){w--,_--;continue}if(f&&m>f||!$&&n.uplMaxSize&&m>n.uplMaxSize)i.error(i.i18n("errUploadFile",T.name)+" "+i.i18n("errUploadFileSize")),w--,_--;else if(!T.type||i.uploadMimeCheck(T.type,c))if($&&m>V){for(k=0,x=V,C=-1,_=Math.floor(m/V),g=T.lastModified?Math.round(T.lastModified/1e3):0,L+=m,W[B]=0;m>=k;)z=T[$](k,x),z._chunk=T.name+"."+ ++C+"_"+_+".part",z._cid=B,z._range=k+","+z.size+","+m,z._mtime=g,W[B]++,j&&q++,"undefined"==typeof N[q]&&(N[q]=[],d&&(N[q][0]=[],N[q][1]=[])),j=V,H=1,d?(N[q][0].push(z),N[q][1].push(s[y])):N[q].push(z),k=x,x=k+V;null==z?(i.error(i.i18n("errUploadFile",T.name)+" "+i.i18n("errUploadFileSize")),w--,_--):(_+=C,j=0,H=1,q++)}else(n.uplMaxSize&&j+m>=n.uplMaxSize||H>n.uplMaxFile)&&(j=0,H=1,q++),"undefined"==typeof N[q]&&(N[q]=[],d&&(N[q][0]=[],N[q][1]=[])),d?(N[q][0].push(T),N[q][1].push(s[y])):N[q].push(T),j+=m,L+=m,H++;else i.error(i.i18n("errUploadFile",T.name)+" "+i.i18n("errUploadMime")+" ("+i.escape(T.type)+")"),w--,_--}if(0==N.length)return t.checked=!0,!1;if(N.length>1)return o=O(L),U=[],D=0,P=N.length,R=[],G(),!0;d?(a=N[0][0],s=N[0][1]):a=N[0]}return l||(n.UA.Safari&&t.files?r._totalSize=L:o=O(L)),l=!0,a.length||v.reject(["errUploadNoFiles"]),r.open("POST",i.uploadURL,!0),n.customHeaders&&e.each(n.customHeaders,function(e){r.setRequestHeader(e,this)}),n.xhrFields&&e.each(n.xhrFields,function(e){e in r&&(r[e]=this)}),b.append("cmd","upload"),b.append(i.newAPI?"target":"current",c),F&&F.length&&(e.each(F,function(e,t){b.append("renames[]",t)}),b.append("suffix",n.options.backupSuffix)),E&&e.each(E,function(e,t){b.append("hashes["+e+"]",t)}),e.each(i.options.customData,function(e,t){b.append(e,t)}),e.each(i.options.onlyMimes,function(e,t){b.append("mimes["+e+"]",t)}),e.each(a,function(e,t){t._chunkmerged?(b.append("chunk",t._chunkmerged),b.append("upload[]",t._name),b.append("mtime[]",t._mtime)):(t._chunkfail?(b.append("upload[]","chunkfail"),b.append("mimes","chunkfail")):b.append("upload[]",t),
  1815. t._chunk?(b.append("chunk",t._chunk),b.append("cid",t._cid),b.append("range",t._range),b.append("mtime[]",t._mtime)):b.append("mtime[]",t.lastModified?Math.round(t.lastModified/1e3):0)),n.UA.iOS&&b.append("overwrite",0)}),d&&e.each(s,function(e,t){b.append("upload_path[]",t)}),u&&b.append("dropWith",parseInt((u.altKey?"1":"0")+(u.ctrlKey?"1":"0")+(u.metaKey?"1":"0")+(u.shiftKey?"1":"0"),2)),r.send(b),!0};if(d)l?R(y[0],y[1]):y.done(function(t){if(F=[],w=t[0].length){if(t[4]&&t[4].length)return void n.request({data:{cmd:"mkdir",target:c,dirs:t[4]},notify:{type:"mkdir",cnt:t[4].length}}).fail(function(e){e=e||["errUnknown"],"errCmdParams"===e[0]?p=1:(p=0,v.reject(e))}).done(function(n){n.hashes&&(t[1]=e.map(t[1],function(e){return e=e.replace(/\/[^\/]*$/,""),""===e?c:n.hashes[e]}))}).always(function(e){p&&(F=t[2],E=t[3],R(t[0],t[1]))});t[1]=e.map(t[1],function(){return c}),F=t[2],E=t[3],R(t[0],t[1])}else v.reject(["errUploadNoFiles"])}).fail(function(){v.reject()});else if(y.length>0)if(null==F){var j=[],H=[],N=n.options.folderUploadExclude[n.OS]||null;e.each(y,function(t,n){var i=n.webkitRelativePath||n.relativePath||"";return i?(N&&n.name.match(N)?(n._remove=!0,i=void 0):(i=i.replace(/\/[^\/]*$/,""),i&&-1===e.inArray(i,j)&&j.push(i)),void H.push(i)):!1}),n.getUI().find("div.elfinder-upload-dialog-wrapper").elfinderdialog("close"),F=[],E={},j.length?!function(){var t=e.map(j,function(e){return-1===e.indexOf("/")?{name:e}:null}),i=[];n.uploads.checkExists(t,c,n).done(function(a,r){var o,s,l,u=[];n.options.overwriteUploadConfirm&&!n.UA.iOS&&n.option("uploadOverwrite",c)&&(i=e.map(t,function(e){return e._remove?e.name:null}),t=e.map(t,function(e){return e._remove?null:e})),i.length&&e.each(H.concat(),function(t,n){0===e.inArray(n,i)&&(y[t]._remove=!0,delete H[t])}),y=e.map(y,function(e){return e._remove?null:e}),H=e.map(H,function(e){return void 0===e?null:e}),t.length?(o=e.Deferred(),a.length?e.each(a,function(t,i){s=n.uniqueName(i+n.options.backupSuffix,null,""),e.each(r,function(e,t){return a[0]==t?(l=e,!1):void 0}),l||(l=n.fileByName(a[0],c).hash),n.lockfiles({files:[l]}),u.push(n.request({data:{cmd:"rename",target:l,name:s},notify:{type:"rename",cnt:1}}).fail(function(e){v.reject(e),n.sync()}).always(function(){n.unlockfiles({files:[l]})}))}):u.push(null),e.when.apply(e,u).done(function(){n.request({data:{cmd:"mkdir",target:c,dirs:j},notify:{type:"mkdir",cnt:j.length}}).fail(function(e){e=e||["errUnknown"],"errCmdParams"===e[0]?p=1:(p=0,v.reject(e))}).done(function(t){t.hashes&&(H=e.map(H.concat(),function(e){return""===e?c:t.hashes["/"+e]}))}).always(function(e){p&&(d=!0,R(y,H)||v.reject())})})):v.reject()})}():n.uploads.checkExists(y,c,n).done(function(t,i){n.options.overwriteUploadConfirm&&!n.UA.iOS&&n.option("uploadOverwrite",c)&&(F=t,E=i,y=e.map(y,function(e){return e._remove?null:e})),w=y.length,w>0?R(y)||v.reject():v.reject()})}else R(y)||v.reject();else v.reject();return v},iframe:function(t,n){var i,a,r,o,s=n?n:this,l=t.input?t.input:!1,d=l?!1:s.uploads.checkFile(t,s),c=e.Deferred().fail(function(e){e&&s.error(e)}),u="iframe-"+n.namespace+ ++s.iframeCnt,h=e('<form action="'+s.uploadURL+'" method="post" enctype="multipart/form-data" encoding="multipart/form-data" target="'+u+'" style="display:none"><input type="hidden" name="cmd" value="upload" /></form>'),p=this.UA.IE,f=function(){o&&clearTimeout(o),r&&clearTimeout(r),a&&s.notify({type:"upload",cnt:-i}),setTimeout(function(){p&&e('<iframe src="javascript:false;"/>').appendTo(h),h.remove(),m.remove()},100)},m=e('<iframe src="'+(p?"javascript:false;":"about:blank")+'" name="'+u+'" style="position:absolute;left:-1000px;top:-1000px" />').on("load",function(){m.off("load").on("load",function(){f(),c.resolve()}),r=setTimeout(function(){a=!0,s.notify({type:"upload",cnt:i})},s.options.notifyDelay),s.options.iframeTimeout>0&&(o=setTimeout(function(){f(),c.reject([errors.connect,errors.timeout])},s.options.iframeTimeout)),h.submit()}),g=t.target||s.cwd().hash,v=[],b=[],y=[],w={};if(d&&d.length)e.each(d,function(e,t){h.append('<input type="hidden" name="upload[]" value="'+t+'"/>')}),i=1;else{if(!(l&&e(l).is(":file")&&e(l).val()))return c.reject();n.options.overwriteUploadConfirm&&!n.UA.iOS&&n.option("uploadOverwrite",g)&&(v=l.files?l.files:[{name:e(l).val().replace(/^(?:.+[\\\/])?([^\\\/]+)$/,"$1")}],b.push(s.uploads.checkExists(v,g,s).done(function(t,n){y=t,w=n,i=e.map(v,function(e){return e._remove?null:e}).length,i!=v.length&&(i=0)}))),i=l.files?l.files.length:1,h.append(l)}return e.when.apply(e,b).done(function(){return 1>i?c.reject():(h.append('<input type="hidden" name="'+(s.newAPI?"target":"current")+'" value="'+g+'"/>').append('<input type="hidden" name="html" value="1"/>').append('<input type="hidden" name="node" value="'+s.id+'"/>').append(e(l).attr("name","upload[]")),y.length>0&&(e.each(y,function(e,t){h.append('<input type="hidden" name="renames[]" value="'+s.escape(t)+'"/>')}),h.append('<input type="hidden" name="suffix" value="'+n.options.backupSuffix+'"/>')),w&&e.each(y,function(e,t){h.append('<input type="hidden" name="['+e+']" value="'+s.escape(t)+'"/>')}),e.each(s.options.onlyMimes||[],function(e,t){h.append('<input type="hidden" name="mimes[]" value="'+s.escape(t)+'"/>')}),e.each(s.options.customData,function(e,t){h.append('<input type="hidden" name="'+e+'" value="'+s.escape(t)+'"/>')}),h.appendTo("body"),void m.appendTo("body"))}),c}},one:function(e,t){var n=this,i=function(a,r){return setTimeout(function(){n.unbind(e,i)},3),t.apply(n.getListeners(a.type),arguments)};return this.bind(e,i)},localStorage:function(e,t){var n,i,a,r=window.localStorage,o="elfinder-"+e+this.id;if(e=window.location.pathname+"-elfinder-"+e+this.id,null===t)return r.removeItem(e);if(void 0===t&&!(n=r.getItem(e))&&(i=r.getItem(o))&&(t=i,r.removeItem(o)),void 0!==t){a=typeof t,"string"!==a&&"number"!==a&&(t=JSON.stringify(t));try{r.setItem(e,t)}catch(s){try{r.clear(),r.setItem(e,t)}catch(s){self.debug("error",s.toString())}}n=r.getItem(e)}if(n&&("{"===n.substr(0,1)||"["===n.substr(0,1)))try{return JSON.parse(n)}catch(s){}return n},cookie:function(t,n){var i,a,r,o,s,l;if(t="elfinder-"+t+this.id,void 0===n){if(document.cookie&&""!=document.cookie)for(r=document.cookie.split(";"),t+="=",o=0;o<r.length;o++)if(r[o]=e.trim(r[o]),r[o].substring(0,t.length)==t){if(s=decodeURIComponent(r[o].substring(t.length)),"{"===s.substr(0,1)||"["===s.substr(0,1))try{return JSON.parse(s)}catch(d){}return s}return""}return a=e.extend({},this.options.cookie),null===n?(n="",a.expires=-1):(l=typeof n,"string"!==l&&"number"!==l&&(n=JSON.stringify(n))),"number"==typeof a.expires&&(i=new Date,i.setTime(i.getTime()+864e5*a.expires),a.expires=i),document.cookie=t+"="+encodeURIComponent(n)+"; expires="+a.expires.toUTCString()+(a.path?"; path="+a.path:"")+(a.domain?"; domain="+a.domain:"")+(a.secure?"; secure":""),n},startDir:function(){var e=window.location.hash;return e&&e.match(/^#elf_/)?e.replace(/^#elf_/,""):this.options.startPathHash?this.options.startPathHash:this.lastDir()},lastDir:function(e){return this.options.rememberLastDir?this.storage("lastdir",e):""},_node:e("<span/>"),escape:function(e){return this._node.text(e).html().replace(/"/g,"&quot;").replace(/'/g,"&#039;")},normalize:function(t){var n,i,a,r,o=this,s=function(t){var s,l;return t&&t.hash&&t.name&&t.mime?("application/x-empty"==t.mime&&(t.mime="text/plain"),t.options&&(o.optionsByHashes[t.hash]=t.options),t.phash&&"directory"!==t.mime||(t.volumeid&&(s=t.volumeid,o.isRoot(t)&&(o.volOptions[s]||(o.volOptions[s]={}),l=o.volOptions[s],t.options&&(l=e.extend(l,t.options)),t.disabled&&(l.disabled=t.disabled),t.tmbUrl&&(l.tmbUrl=t.tmbUrl),e.each(o.optionProperties,function(e,n){l[n]&&(t[n]=l[n])}),o.roots[s]=t.hash),r!==s&&(r=s,a=o.option("i18nFolderName",s))),!t.i18&&o.isRoot(t)&&(n="volume_"+t.name,i=o.i18n(!1,n),n!==i&&(t.i18=i)),a&&!t.i18&&(n="folder_"+t.name,i=o.i18n(!1,n),n!==i&&(t.i18=i)),o.leafRoots[t.hash]&&(t.dirs||(t.dirs=1),e.each(o.leafRoots[t.hash],function(){var e=o.file(this);e&&e.ts&&(t.ts||0)<e.ts&&(t.ts=e.ts)}))),t):null};return t.cwd&&(t.cwd.volumeid&&t.options&&Object.keys(t.options).length&&(o.volOptions[t.cwd.volumeid]=t.options),t.cwd=s(t.cwd)),t.files&&(t.files=e.map(t.files,s)),t.tree&&(t.tree=e.map(t.tree,s)),t.added&&(t.added=e.map(t.added,s)),t.changed&&(t.changed=e.map(t.changed,s)),t.api&&(t.init=!0),t.cwd&&t.cwd.options&&t.options&&e.extend(t.options,t.cwd.options),t},setSort:function(e,t,n,i){this.storage("sortType",this.sortType=this.sortRules[e]?e:"name"),this.storage("sortOrder",this.sortOrder=/asc|desc/.test(t)?t:"asc"),this.storage("sortStickFolders",(this.sortStickFolders=!!n)?1:""),this.storage("sortAlsoTreeview",(this.sortAlsoTreeview=!!i)?1:""),this.trigger("sortchange")},_sortRules:{name:function(e,t){return i.prototype.naturalCompare(e.i18||e.name,t.i18||t.name)},size:function(e,t){var n=parseInt(e.size)||0,i=parseInt(t.size)||0;return n===i?0:n>i?1:-1},kind:function(e,t){return i.prototype.naturalCompare(e.mime,t.mime)},date:function(e,t){var n=e.ts||e.date,i=t.ts||t.date;return n===i?0:n>i?1:-1},perm:function(e,t){var n=function(e){return(e.write?2:0)+(e.read?1:0)},i=n(e),a=n(t);return i===a?0:i>a?1:-1},mode:function(e,t){var n=e.mode||e.perm||"",a=t.mode||t.perm||"";return i.prototype.naturalCompare(n,a)},owner:function(e,t){var n=e.owner||"",a=t.owner||"";return i.prototype.naturalCompare(n,a)},group:function(e,t){var n=e.group||"",a=t.group||"";return i.prototype.naturalCompare(n,a)}},sorters:[],naturalCompare:function(e,t){var n=i.prototype.naturalCompare;return"undefined"==typeof n.loc&&(n.loc=navigator.userLanguage||navigator.browserLanguage||navigator.language||"en-US"),"undefined"==typeof n.sort&&("11".localeCompare("2",n.loc,{numeric:!0})>0?window.Intl&&window.Intl.Collator?n.sort=new Intl.Collator(n.loc,{numeric:!0}).compare:n.sort=function(e,t){return e.localeCompare(t,n.loc,{numeric:!0})}:(n.sort=function(e,t){var i,a,r=/(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi,o=/(^[ ]*|[ ]*$)/g,s=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,l=/^0x[0-9a-f]+$/i,d=/^0/,c=/^[\x01\x21-\x2f\x3a-\x40\x5b-\x60\x7b-\x7e]/,u=function(e){return n.sort.insensitive&&(""+e).toLowerCase()||""+e},h=u(e).replace(o,"").replace(/^_/,"")||"",p=u(t).replace(o,"").replace(/^_/,"")||"",f=h.replace(r,"\x00$1\x00").replace(/\0$/,"").replace(/^\0/,"").split("\x00"),m=p.replace(r,"\x00$1\x00").replace(/\0$/,"").replace(/^\0/,"").split("\x00"),g=parseInt(h.match(l))||1!=f.length&&h.match(s)&&Date.parse(h),v=parseInt(p.match(l))||g&&p.match(s)&&Date.parse(p)||null,b=0;if(v){if(v>g)return-1;if(g>v)return 1}for(var y=0,w=Math.max(f.length,m.length);w>y;y++){if(i=!(f[y]||"").match(d)&&parseFloat(f[y])||f[y]||0,a=!(m[y]||"").match(d)&&parseFloat(m[y])||m[y]||0,isNaN(i)!==isNaN(a)){if(isNaN(i)&&("string"!=typeof i||!i.match(c)))return 1;if("string"!=typeof a||!a.match(c))return-1}if(0===parseInt(i,10)&&(i=0),0===parseInt(a,10)&&(a=0),typeof i!=typeof a&&(i+="",a+=""),n.sort.insensitive&&"string"==typeof i&&"string"==typeof a&&(b=i.localeCompare(a,n.loc),0!==b))return b;if(a>i)return-1;if(i>a)return 1}return 0},n.sort.insensitive=!0)),n.sort(e,t)},compare:function(e,t){var n,i=this,a=i.sortType,r="asc"==i.sortOrder,o=i.sortStickFolders,s=i.sortRules,l=s[a],d="directory"==e.mime,c="directory"==t.mime;if(o){if(d&&!c)return-1;if(!d&&c)return 1}return n=r?l(e,t):l(t,e),"name"!==a&&0===n?n=r?s.name(e,t):s.name(t,e):n},sortFiles:function(e){return e.sort(this.compare)},notify:function(t){var n,i,a,r=t.type,o=this.i18n("undefined"!=typeof t.msg?t.msg:this.messages["ntf"+r]?"ntf"+r:"ntfsmth"),s=this.ui.notify,l=s.children(".elfinder-notify-"+r),d=l.children("div.elfinder-notify-cancel").children("button"),c='<div class="elfinder-notify elfinder-notify-{type}"><span class="elfinder-dialog-icon elfinder-dialog-icon-{type}"/><span class="elfinder-notify-msg">{msg}</span> <span class="elfinder-notify-cnt"/><div class="elfinder-notify-progressbar"><div class="elfinder-notify-progress"/></div><div class="elfinder-notify-cancel"/></div>',u=t.cnt,h="undefined"!=typeof t.size?parseInt(t.size):null,p="undefined"!=typeof t.progress&&t.progress>=0?t.progress:null,f=t.cancel,m="ui-state-hover",g=function(){l._esc&&e(document).off("keydown",l._esc),l.remove(),!s.children().length&&s.elfinderdialog("close")};return r?(l.length?"undefined"!=typeof t.msg&&l.children("span.elfinder-notify-msg").html(o):(l=e(c.replace(/\{type\}/g,r).replace(/\{msg\}/g,o)).appendTo(s).data("cnt",0),null!=p&&l.data({progress:0,total:0}),f&&(d=e('<button type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"><span class="ui-button-text">'+this.i18n("btnCancel")+"</span></button>").hover(function(t){e(this).toggleClass(m,"mouseenter"==t.type)}),l.children("div.elfinder-notify-cancel").append(d))),n=u+parseInt(l.data("cnt")),n>0?(f&&d.length&&(e.isFunction(f)||"object"==typeof f&&f.promise)&&(l._esc=function(t){"keydown"==t.type&&t.keyCode!=e.ui.keyCode.ESCAPE||(t.preventDefault(),t.stopPropagation(),g(),f.promise?(f.xhr&&(f.xhr.quiet=!0,f.xhr.abort()),f.reject()):f(t))},d.on("click",function(e){l._esc(e)}),e(document).on("keydown."+this.namespace,l._esc)),!t.hideCnt&&l.children(".elfinder-notify-cnt").text("("+n+")"),s.is(":hidden")&&s.elfinderdialog("open",this),l.data("cnt",n),null!=p&&(i=l.data("total"))>=0&&(a=l.data("progress"))>=0&&(i+=null!=h?h:u,a+=p,null==h&&0>u&&(a+=100*u),l.data({progress:a,total:i}),null!=h&&(a*=100,i=Math.max(1,i)),p=parseInt(a/i),l.find(".elfinder-notify-progress").animate({width:(100>p?p:100)+"%"},20))):g(),this):this},confirm:function(t){var n,i=this,a=!1,r={cssClass:"elfinder-dialog-confirm",modal:!0,resizable:!1,title:this.i18n(t.title||"confirmReq"),buttons:{},close:function(){!a&&t.cancel.callback(),e(this).elfinderdialog("destroy")}},o=this.i18n("apllyAll");return r.buttons[this.i18n(t.accept.label)]=function(){t.accept.callback(!(!n||!n.prop("checked"))),a=!0,e(this).elfinderdialog("close")},t.reject&&(r.buttons[this.i18n(t.reject.label)]=function(){t.reject.callback(!(!n||!n.prop("checked"))),a=!0,e(this).elfinderdialog("close")}),t.buttons&&t.buttons.length>0&&e.each(t.buttons,function(t,o){r.buttons[i.i18n(o.label)]=function(){o.callback(!(!n||!n.prop("checked"))),a=!0,e(this).elfinderdialog("close")}}),r.buttons[this.i18n(t.cancel.label)]=function(){e(this).elfinderdialog("close")},t.all&&(r.create=function(){var t=e('<div class="elfinder-dialog-confirm-applyall"/>');n=e('<input type="checkbox" />'),e(this).next().find(".ui-dialog-buttonset").prepend(t.append(e("<label>"+o+"</label>").prepend(n)))}),t.optionsCallback&&e.isFunction(t.optionsCallback)&&t.optionsCallback(r),this.dialog('<span class="elfinder-dialog-icon elfinder-dialog-icon-confirm"/>'+this.i18n(t.text),r)},uniqueName:function(e,t,n){var i,a,r=0,o="";if(e=this.i18n(e),t=t||this.cwd().hash,n="undefined"==typeof n?" ":n,(i=e.match(/^(.+)(\.[^.]+)$/))&&(o=i[2],e=i[1]),a=e+o,!this.fileByName(a,t))return a;for(;1e4>r;)if(a=e+n+ ++r+o,!this.fileByName(a,t))return a;return e+Math.random()+o},i18n:function(){var t,n,i,a,r=this,o=this.messages,s=[],l=[],d=function(e){var t;return 0===e.indexOf("#")&&(t=r.file(e.substr(1)))?t.name:e},c=0;for(arguments.length&&arguments[0]===!1&&(a=function(e){return e},c=1),t=c;t<arguments.length;t++)if(i=arguments[t],e.isArray(i))for(n=0;n<i.length;n++)i[n]instanceof jQuery?s.push(i[n]):"undefined"!=typeof i[n]&&s.push(d(""+i[n]));else i instanceof jQuery?s.push(i[n]):"undefined"!=typeof i&&s.push(d(""+i));for(t=0;t<s.length;t++)-1===e.inArray(t,l)&&(i=s[t],"string"==typeof i?(i=o[i]||(a?a(i):r.escape(i)),i=i.replace(/\$(\d+)/g,function(e,n){return n=t+parseInt(n),n>0&&s[n]&&l.push(n),a?a(s[n]):r.escape(s[n])})):i=i.get(0).outerHTML,s[t]=i);return e.map(s,function(t,n){return-1===e.inArray(n,l)?t:null}).join("<br>")},mime2class:function(e){var t="elfinder-cwd-icon-";return e=e.split("/"),t+e[0]+("image"!=e[0]&&e[1]?" "+t+e[1].replace(/(\.|\+)/g,"-"):"")},mime2kind:function(e){var t,n="object"==typeof e,i=n?e.mime:e;return n&&e.alias&&"symlink-broken"!=i?t="Alias":this.kinds[i]&&(t=!n||"directory"!==i||e.phash&&!e.isroot?this.kinds[i]:"Root"),t||(t=0===i.indexOf("text")?"Text":0===i.indexOf("image")?"Image":0===i.indexOf("audio")?"Audio":0===i.indexOf("video")?"Video":0===i.indexOf("application")?"App":i),this.messages["kind"+t]?this.i18n("kind"+t):i},formatDate:function(e,t){var n,i,a,r,o,s,l,d,c,u,h,p=this,t=t||e.ts,f=p.i18;return p.options.clientFormatDate&&t>0?(n=new Date(1e3*t),d=n[p.getHours](),c=d>12?d-12:d,u=n[p.getMinutes](),h=n[p.getSeconds](),r=n[p.getDate](),o=n[p.getDay](),s=n[p.getMonth]()+1,l=n[p.getFullYear](),i=t>=this.yesterday?this.fancyFormat:this.dateFormat,a=i.replace(/[a-z]/gi,function(e){switch(e){case"d":return r>9?r:"0"+r;case"j":return r;case"D":return p.i18n(f.daysShort[o]);case"l":return p.i18n(f.days[o]);case"m":return s>9?s:"0"+s;case"n":return s;case"M":return p.i18n(f.monthsShort[s-1]);case"F":return p.i18n(f.months[s-1]);case"Y":return l;case"y":return(""+l).substr(2);case"H":return d>9?d:"0"+d;case"G":return d;case"g":return c;case"h":return c>9?c:"0"+c;case"a":return d>=12?"pm":"am";case"A":return d>=12?"PM":"AM";case"i":return u>9?u:"0"+u;case"s":return h>9?h:"0"+h}return e}),t>=this.yesterday?a.replace("$1",this.i18n(t>=this.today?"Today":"Yesterday")):a):e.date?e.date.replace(/([a-z]+)\s/i,function(e,t){return p.i18n(t)+" "}):p.i18n("dateUnknown")},perms2class:function(e){var t="";return e.read||e.write?e.read?e.write||(t="elfinder-ro"):t="elfinder-wo":t="elfinder-na",e.type&&(t+=" elfinder-"+this.escape(e.type)),t},formatPermissions:function(e){var t=[];return e.read&&t.push(this.i18n("read")),e.write&&t.push(this.i18n("write")),t.length?t.join(" "+this.i18n("and")+" "):this.i18n("noaccess")},formatSize:function(e){var t=1,n="b";return"unknown"==e?this.i18n("unknown"):(e>1073741824?(t=1073741824,n="GB"):e>1048576?(t=1048576,n="MB"):e>1024&&(t=1024,n="KB"),e/=t,(e>0?t>=1048576?e.toFixed(2):Math.round(e):0)+" "+n)},formatFileMode:function(t,n){var i,a,r,o,s,l,d,c,u;if(n||(n=this.options.fileModeStyle.toLowerCase()),t=e.trim(t),t.match(/[rwxs-]{9}$/i)){if(c=t=t.substr(-9),"string"==n)return c;for(u="",r=0,i=0;7>i;i+=3)a=t.substr(i,3),o=0,a.match(/[r]/i)&&(o+=4),a.match(/[w]/i)&&(o+=2),a.match(/[xs]/i)&&(a.match(/[xs]/)&&(o+=1),a.match(/[s]/i)&&(0==i?r+=4:3==i&&(r+=2))),u+=o.toString(8);r&&(u=r.toString(8)+u)}else{if(t=parseInt(t,8),u=t?t.toString(8):"",!t||"octal"==n)return u;for(a=t.toString(8),r=0,a.length>3&&(a=a.substr(-4),r=parseInt(a.substr(0,1),8),a=a.substr(1)),s=1==(1&r),d=2==(2&r),l=4==(4&r),c="",i=0;3>i;i++)c+=4==(4&parseInt(a.substr(i,1),8))?"r":"-",c+=2==(2&parseInt(a.substr(i,1),8))?"w":"-",c+=1==(1&parseInt(a.substr(i,1),8))?0==i&&l||1==i&&d?"s":"x":"-"}return"both"==n?c+" ("+u+")":"string"==n?c:u},uploadMimeCheck:function(t,n){n=n||this.cwd().hash;var i,a,r=!0,o=this.option("uploadMime",n),s=function(n){var i=!1;return"string"==typeof n&&"all"===n.toLowerCase()?i=!0:e.isArray(n)&&n.length&&e.each(n,function(e,n){return n=n.toLowerCase(),"all"===n||0===t.indexOf(n)?(i=!0,!1):void 0}),i};return t&&e.isPlainObject(o)&&(t=t.toLowerCase(),i=s(o.allow),a=s(o.deny),"allow"===o.firstOrder?(r=!1,a||i!==!0||(r=!0)):(r=!0,a!==!0||i||(r=!1))),r},sequence:function(e){var t=e.length,n=function(t,i){return++i,e[i]?n(t.then(e[i]),i):t};return t>1?n(e[0](),0):e[0]()},reloadContents:function(t){var n,i=e.Deferred();try{n=e('<iframe width="1" height="1" scrolling="no" frameborder="no" style="position:absolute; top:-1px; left:-1px" crossorigin="use-credentials">').attr("src",t).one("load",function(){var n=e(this);try{this.contentDocument.location.reload(!0),n.one("load",function(){n.remove(),i.resolve()})}catch(a){n.attr("src","").attr("src",t).one("load",function(){n.remove(),i.resolve()})}}).appendTo("body")}catch(a){n&&n.remove(),i.reject()}return i},makeNetmountOptionOauth:function(t,n,i,a){return{vars:{},name:n,inputs:{offline:e('<input type="checkbox"/>').on("change",function(){e(this).parents("table.elfinder-netmount-tb").find("select:first").trigger("change","reset")}),host:e('<span><span class="elfinder-info-spinner"/></span><input type="hidden"/>'),path:e('<input type="text" value="root"/>'),user:e('<input type="hidden"/>'),pass:e('<input type="hidden"/>')},select:function(n,r,o){var s=this.inputs,l=s.offline,d=e(s.host[0]),o=o||null;this.vars.mbtn=s.host.closest(".ui-dialog").children(".ui-dialog-buttonpane:first").find("button.elfinder-btncnt-0"),d.data("inrequest")||!d.find("span.elfinder-info-spinner").length&&"reset"!==o&&("winfocus"!==o||d.siblings("span.elfinder-button-icon-reload").length)?(l.closest("tr")[a||s.user.val()?"hide":"show"](),d.data("funcexpup")&&d.data("funcexpup")()):(1===l.parent().children().length&&(s.path.parent().prev().html(n.i18n("folderId")),l.attr("title",n.i18n("offlineAccess")),l.uniqueId().after(e("<label/>").attr("for",l.attr("id")).html(" "+n.i18n("offlineAccess")))),d.data("inrequest",!0).empty().addClass("elfinder-info-spinner").parent().find("span.elfinder-button-icon").remove(),n.request({data:{cmd:"netmount",protocol:t,host:i,user:"init",options:{id:n.id,offline:l.prop("checked")?1:0,pass:s.host[1].value}},preventDefault:!0}).done(function(e){d.removeClass("elfinder-info-spinner").html(e.body.replace(/\{msg:([^}]+)\}/g,function(e,t){return n.i18n(t,i)}))}),a&&l.closest("tr").hide()),this.vars.mbtn[e(s.host[1]).val()?"show":"hide"]()},done:function(n,r){var o=this.inputs,s=this.protocol,l=e(o.host[0]),d=e(o.host[1]),c="&nbsp;";if(a&&o.offline.closest("tr").hide(),"makebtn"==r.mode)l.removeClass("elfinder-info-spinner").removeData("expires").removeData("funcexpup"),o.host.find("input").hover(function(){e(this).toggleClass("ui-state-hover")}),d.val(""),o.path.val("root").next().remove(),o.user.val(""),o.pass.val(""),!a&&o.offline.closest("tr").show(),this.vars.mbtn.hide();else{if(r.expires&&(c="()",l.data("expires",r.expires)),l.html(i+c).removeClass("elfinder-info-spinner"),r.expires&&(l.data("funcexpup",function(){var e=Math.floor((l.data("expires")-+new Date/1e3)/60);3>e?l.parent().children(".elfinder-button-icon-reload").click():(l.text(l.text().replace(/\(.*\)/,"("+n.i18n(["minsLeft",e])+")")),setTimeout(function(){l.is(":visible")&&l.data("funcexpup")()},6e4))}),l.data("funcexpup")()),r.reset)return void s.trigger("change","reset");l.parent().append(e('<span class="elfinder-button-icon elfinder-button-icon-reload" title="'+n.i18n("reAuth")+'">').on("click",function(){d.val("reauth"),s.trigger("change","reset")})),d.val(t),this.vars.mbtn.show(),r.folders&&o.path.next().remove().end().after(e("<div/>").append(e('<select class="ui-corner-all" style="max-width:200px;">').append(e(e.map(r.folders,function(e,t){return'<option value="'+(t+"").trim()+'">'+n.escape(e)+"</option>"}).join(""))).on("change",function(){o.path.val(e(this).val())}))),o.user.val("done"),o.pass.val("done"),o.offline.closest("tr").hide()}l.removeData("inrequest")},fail:function(t,n){e(this.inputs.host[0]).removeData("inrequest"),this.protocol.trigger("change","reset")}}},findCwdNodes:function(t,n){var i=this,a=this.getUI("cwd"),r=this.cwd().hash,o=e();return n=n||{},e.each(t,function(e,t){return t.phash===r&&(o=o.add(a.find("#"+i.cwdHash2Id(t.hash))),n.firstOnly)?!1:void 0}),o},convAbsUrl:function(e){if(e.match(/^http/i))return e;if("//"===e.substr(0,2))return window.location.protocol+e;var t,n=window.location.protocol+"//"+window.location.host,i=/[^\/]+\/\.\.\//;for(t="/"===e.substr(0,1)?n+e:n+window.location.pathname.replace(/\/[^\/]+$/,"/")+e,t=t.replace("/./","/");i.test(t);)t=t.replace(i,"");return t},navHash2Id:function(e){return this.navPrefix+e},navId2Hash:function(e){return"string"==typeof e?e.substr(this.navPrefix.length):!1},cwdHash2Id:function(e){return this.cwdPrefix+e},cwdId2Hash:function(e){return"string"==typeof e?e.substr(this.cwdPrefix.length):!1},isInWindow:function(e,t){if(!t&&e.is(":hidden"))return!1;var n,i;return(n=e.get(0))?(i=n.getBoundingClientRect(),!!document.elementFromPoint(i.left,i.top)):!1},loadScript:function(t,n,i,a){var r={dataType:"script",cache:!0},o=null;return e.isFunction(n)&&(o=function(){if(a)if("undefined"==typeof a.obj[a.name])var e=a.timeout?a.timeout/10:1e3,t=setInterval(function(){--e>0&&"undefined"!=typeof a.obj[a.name]&&(clearInterval(t),n())},10);else n();else n()}),i&&"tag"===i.loadType?(e.each(t,function(t,n){e("head").append(e('<script defer="defer">').attr("src",n))}),o()):(i=e.isPlainObject(i)?e.extend(r,i):r,function s(){e.ajax(e.extend(i,{url:t.shift(),success:t.length?s:o}))}()),this},loadCss:function(t){var n=this;return"string"==typeof t&&(t=[t]),e.each(t,function(t,i){i=n.convAbsUrl(i).replace(/^https?:/i,""),e("head > link[href='+url+']").length||e("head").append('<link rel="stylesheet" type="text/css" href="'+i+'" />')}),this},log:function(e){return window.console&&window.console.log&&window.console.log(e),this},debug:function(t,n){var i=this.options.debug;return("all"==i||i===!0||e.isArray(i)&&-1!=e.inArray(t,i))&&window.console&&window.console.log&&window.console.log("elfinder debug: ["+t+"] ["+this.id+"]",n),"backend-debug"===t&&this.trigger("backenddebug",n),this},time:function(e){window.console&&window.console.time&&window.console.time(e)},timeEnd:function(e){window.console&&window.console.timeEnd&&window.console.timeEnd(e)}},Object.keys||(Object.keys=function(){var e=Object.prototype.hasOwnProperty,t=!{toString:null}.propertyIsEnumerable("toString"),n=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],i=n.length;return function(a){if("object"!=typeof a&&"function"!=typeof a||null===a)throw new TypeError("Object.keys called on non-object");var r=[];for(var o in a)e.call(a,o)&&r.push(o);if(t)for(var s=0;i>s;s++)e.call(a,n[s])&&r.push(n[s]);return r}}()),i.prototype.version="2.1.20",function(){if(e.ui&&e.ui.ddmanager){var t=e.ui.ddmanager.prepareOffsets;e.ui.ddmanager.prepareOffsets=function(n,i){var a=function(e){if(e.is(":hidden"))return!0;var t=e[0].getBoundingClientRect();return!document.elementFromPoint(t.left,t.top)};if("mousedown"===i.type||n.options.elfRefresh){var r,o,s=e.ui.ddmanager.droppables[n.options.scope]||[],l=s.length;for(r=0;l>r;r++)o=s[r],o.options.autoDisable&&(!o.options.disabled||o.options.autoDisable>1)&&(o.options.disabled=a(o.element),o.options.autoDisable=o.options.disabled?2:1)}return t(n,i)}}}(),function(e){function t(t,n){if(!(t.originalEvent.touches.length>1)){e(t.currentTarget).hasClass("touch-punch-keep-default")||t.preventDefault();var i=t.originalEvent.changedTouches[0],a=document.createEvent("MouseEvents");a.initMouseEvent(n,!0,!0,window,1,i.screenX,i.screenY,i.clientX,i.clientY,!1,!1,!1,!1,0,null),t.target.dispatchEvent(a)}}if(e.support.touch="ontouchend"in document,e.support.touch){var n,i,a,r=e.ui.mouse.prototype,o=r._mouseInit,s=r._mouseDestroy;r._touchStart=function(e){var r=this;!n&&r._mouseCapture(e.originalEvent.changedTouches[0])&&(i=e.originalEvent.changedTouches[0].screenX.toFixed(0),a=e.originalEvent.changedTouches[0].screenY.toFixed(0),n=!0,r._touchMoved=!1,t(e,"mouseover"),t(e,"mousemove"),t(e,"mousedown"))},r._touchMove=function(e){if(n){var r=e.originalEvent.changedTouches[0].screenX.toFixed(0),o=e.originalEvent.changedTouches[0].screenY.toFixed(0);Math.abs(i-r)<=2&&Math.abs(a-o)<=2||(this._touchMoved=!0,t(e,"mousemove"))}},r._touchEnd=function(e){n&&(t(e,"mouseup"),t(e,"mouseout"),this._touchMoved||t(e,"click"),n=!1,this._touchMoved=!1)},r._mouseInit=function(){var t=this;t.element.hasClass("touch-punch")&&t.element.bind({touchstart:e.proxy(t,"_touchStart"),touchmove:e.proxy(t,"_touchMove"),touchend:e.proxy(t,"_touchEnd")}),o.call(t)},r._mouseDestroy=function(){var t=this;t.element.hasClass("touch-punch")&&t.element.unbind({touchstart:e.proxy(t,"_touchStart"),touchmove:e.proxy(t,"_touchMove"),touchend:e.proxy(t,"_touchEnd")}),s.call(t)}}}(jQuery),e.fn.elfinder=function(e){return"instance"==e?this.getElFinder():this.each(function(){var t="string"==typeof e?e:"";switch(this.elfinder||new i(this,"object"==typeof e?e:{}),t){case"close":case"hide":this.elfinder.hide();break;case"open":case"show":this.elfinder.show();break;case"destroy":this.elfinder.destroy()}})},e.fn.getElFinder=function(){var e;return this.each(function(){return this.elfinder?(e=this.elfinder,!1):void 0}),e},e.fn.elfUiWidgetInstance=function(e){try{return this[e]("instance")}catch(t){var n=this.data("ui-"+e);return n&&"object"==typeof n&&n.widgetFullName==="ui-"+e?n:null}},i.prototype._options={url:"",requestType:"get",transport:{},urlUpload:"",dragUploadAllow:"auto",overwriteUploadConfirm:!0,uploadMaxChunkSize:10485760,folderUploadExclude:{win:/^(?:desktop\.ini|thumbs\.db)$/i,mac:/^\.ds_store$/i},iframeTimeout:0,customData:{},handlers:{},customHeaders:{},xhrFields:{},lang:"en",cssAutoLoad:!0,cssClass:"",commands:["*"],commandsOptions:{getfile:{onlyURL:!1,multiple:!1,folders:!1,oncomplete:"",getPath:!0,getImgSize:!1},open:{method:"post"},upload:{ui:"button"},download:{maxRequests:10},quicklook:{autoplay:!0,width:450,height:300,googleDocsMimes:[]},edit:{mimes:[],editors:[],encodings:["Big5","Big5-HKSCS","Cp437","Cp737","Cp775","Cp850","Cp852","Cp855","Cp857","Cp858","Cp862","Cp866","Cp874","EUC-CN","EUC-JP","EUC-KR","ISO-2022-CN","ISO-2022-JP","ISO-2022-KR","ISO-8859-1","ISO-8859-2","ISO-8859-3","ISO-8859-4","ISO-8859-5","ISO-8859-6","ISO-8859-7","ISO-8859-8","ISO-8859-9","ISO-8859-13","ISO-8859-15","KOI8-R","KOI8-U","Shift-JIS","Windows-1250","Windows-1251","Windows-1252","Windows-1253","Windows-1254","Windows-1257"]},search:{incsearch:{enable:!0,minlen:1,wait:500}},info:{nullUrlDirLinkSelf:!0,custom:{}},mkdir:{intoNewFolderToolbtn:!1},resize:{grid8px:"enable"},help:{view:["about","shortcuts","help","debug"]}},getFileCallback:null,defaultView:"icons",startPathHash:"",sound:!0,ui:["toolbar","tree","path","stat"],uiOptions:{toolbar:[["back","forward"],["netmount"],["mkdir","mkfile","upload"],["open","download","getfile"],["info","chmod"],["quicklook"],["copy","cut","paste"],["rm"],["duplicate","rename","edit","resize"],["extract","archive"],["search"],["view","sort"],["help"],["fullscreen"],{displayTextLabel:!1,labelExcludeUA:["Mobile"],autoHideUA:["Mobile"]}],tree:{openRootOnLoad:!0,openCwdOnOpen:!0,syncTree:!0},navbar:{minWidth:150,maxWidth:500,autoHideUA:[]},cwd:{oldSchool:!1,showSelectCheckboxUA:["Touch"],listView:{columns:["perm","date","size","kind"],columnsCustomName:{},fixedHeader:!0}}},onlyMimes:[],sortRules:{},sortType:"name",sortOrder:"asc",sortStickFolders:!0,sortAlsoTreeview:!1,clientFormatDate:!0,UTCDate:!1,dateFormat:"",fancyDateFormat:"",fileModeStyle:"both",width:"auto",height:400,resizable:!0,notifyDelay:500,notifyDialog:{position:{top:"12px",right:"12px"},width:280},allowShortcuts:!0,rememberLastDir:!0,reloadClearHistory:!1,useBrowserHistory:!0,showFiles:50,showThreshold:50,validName:!1,backupSuffix:"~",sync:0,syncStart:!0,loadTmbs:5,cookie:{expires:30,domain:"",path:"/",secure:!1},contextmenu:{navbar:["open","download","|","upload","mkdir","|","copy","cut","paste","duplicate","|","rm","|","rename","|","archive","|","places","info","chmod","netunmount"],cwd:["reload","back","|","upload","mkdir","mkfile","paste","|","view","sort","colwidth","|","info","|","fullscreen"],files:["getfile","|","open","download","opendir","quicklook","|","upload","mkdir","|","copy","cut","paste","duplicate","|","rm","|","edit","rename","resize","|","archive","extract","|","places","info","chmod","netunmount"]},enableAlways:!1,enableByMouseOver:!0,windowCloseConfirm:["hasNotifyDialog","editingFile"],rawStringDecoder:"object"==typeof Encoding&&e.isFunction(Encoding.convert)?function(e){return Encoding.convert(e,{to:"UNICODE",type:"string"})}:null,debug:["error","warning","event-destroy"]},i.prototype._options.commandsOptions.netmount={ftp:{name:"FTP",inputs:{host:e('<input type="text"/>'),port:e('<input type="text" placeholder="21"/>'),
  1816. path:e('<input type="text" value="/"/>'),user:e('<input type="text"/>'),pass:e('<input type="password"/>'),encoding:e('<input type="text" placeholder="Optional"/>'),locale:e('<input type="text" placeholder="Optional"/>')}},dropbox:{name:"Dropbox.com",inputs:{host:e('<span><span class="elfinder-info-spinner"/></span></span><input type="hidden"/>'),path:e('<input type="text" value="/"/>'),user:e('<input type="hidden"/>'),pass:e('<input type="hidden"/>')},select:function(e){var t=this;t.inputs.host.find("span").length&&e.request({data:{cmd:"netmount",protocol:"dropbox",host:"dropbox.com",user:"init",pass:"init",options:{url:e.uploadURL,id:e.id}},preventDefault:!0}).done(function(n){t.inputs.host.find("span").removeClass("elfinder-info-spinner"),t.inputs.host.find("span").html(n.body.replace(/\{msg:([^}]+)\}/g,function(t,n){return e.i18n(n,"Dropbox.com")}))}).fail(function(){})},done:function(t,n){var i=this;"makebtn"==n.mode?(i.inputs.host.find("span").removeClass("elfinder-info-spinner"),i.inputs.host.find("input").hover(function(){e(this).toggleClass("ui-state-hover")}),i.inputs.host[1].value=""):(i.inputs.host.find("span").removeClass("elfinder-info-spinner"),i.inputs.host.find("span").html("Dropbox.com"),i.inputs.host[1].value="dropbox",i.inputs.user.val("done"),i.inputs.pass.val("done"))}},googledrive:i.prototype.makeNetmountOptionOauth("googledrive","Google Drive","Google"),onedrive:i.prototype.makeNetmountOptionOauth("onedrive","One Drive","OneDrive"),box:i.prototype.makeNetmountOptionOauth("box","Box","Box",!0)},i.prototype.history=function(t){var n,i=this,a=!0,r=[],o=function(){r=[t.cwd().hash],n=0,a=!0},s=t.options.useBrowserHistory&&window.history&&window.history.pushState?window.history:null,l=function(s){return s&&i.canForward()||!s&&i.canBack()?(a=!1,t.exec("open",r[s?++n:--n]).fail(o)):e.Deferred().reject()};this.canBack=function(){return n>0},this.canForward=function(){return n<r.length-1},this.back=l,this.forward=function(){return l(!0)},t.open(function(){var e=r.length,i=t.cwd().hash;a&&(n>=0&&e>n+1&&r.splice(n+1),r[r.length-1]!=i&&r.push(i),n=r.length-1),a=!0,s&&(s.state?s.state.thash!=i&&s.pushState({thash:i},null,location.pathname+location.search+"#elf_"+i):s.replaceState({thash:i},null,location.pathname+location.search+"#elf_"+i))}).reload(t.options.reloadClearHistory&&o)},i.prototype.command=function(t){this.fm=t,this.name="",this.className="",this.title="",this.linkedCmds=[],this.state=-1,this.alwaysEnabled=!1,this._disabled=!1,this.disableOnSearch=!1,this.updateOnSelect=!0,this._handlers={enable:function(){this.update(void 0,this.value)},disable:function(){this.update(-1,this.value)},"open reload load sync":function(){this._disabled=!(this.alwaysEnabled||this.fm.isCommandEnabled(this.name)),this.update(void 0,this.value),this.change()}},this.handlers={},this.shortcuts=[],this.options={ui:"button"},this.setup=function(t,n){var i,a,r,o,s=this,l=this.fm;for(this.name=t,this.title=l.messages["cmd"+t]?l.i18n("cmd"+t):this.extendsCmd&&l.messages["cmd"+this.extendsCmd]?l.i18n("cmd"+this.extendsCmd):t,this.options=e.extend({},this.options,n),this.listeners=[],n.shortcuts&&("function"==typeof n.shortcuts?r=n.shortcuts(this.fm,this.shortcuts):e.isArray(n.shortcuts)&&(r=n.shortcuts),this.shortcuts=r||[]),this.updateOnSelect&&(this._handlers.select=function(){this.update(void 0,this.value)}),e.each(e.extend({},s._handlers,s.handlers),function(t,n){l.bind(t,e.proxy(n,s))}),i=0;i<this.shortcuts.length;i++)a=this.shortcuts[i],o=a.callback||s.exec,a.callback=function(){l.isCommandEnabled(s.name)&&o.call(s)},!a.description&&(a.description=this.title),l.shortcut(a);this.disableOnSearch&&l.bind("search searchend",function(e){s._disabled="search"===e.type?!0:!(this.alwaysEnabled||l.isCommandEnabled(t)),s.update(void 0,s.value)}),this.init()},this.init=function(){},this.exec=function(t,n){return e.Deferred().reject()},this.disabled=function(){return this.state<0},this.enabled=function(){return this.state>-1},this.active=function(){return this.state>0},this.getstate=function(){return-1},this.update=function(e,t){var n=this.state,i=this.value;this._disabled?this.state=-1:this.state=void 0!==e?e:this.getstate(),this.value=t,n==this.state&&i==this.value||this.change()},this.change=function(e){var t,n;if("function"==typeof e)this.listeners.push(e);else for(n=0;n<this.listeners.length;n++){t=this.listeners[n];try{t(this.state,this.value)}catch(i){this.fm.debug("error",i)}}return this},this.hashes=function(n){return n?e.map(e.isArray(n)?n:[n],function(e){return t.file(e)?e:null}):t.selected()},this.files=function(t){var n=this.fm;return t?e.map(e.isArray(t)?t:[t],function(e){return n.file(e)||null}):n.selectedFiles()}},i.prototype.resources={"class":{hover:"ui-state-hover",active:"ui-state-active",disabled:"ui-state-disabled",draggable:"ui-draggable",droppable:"ui-droppable",adroppable:"elfinder-droppable-active",cwdfile:"elfinder-cwd-file",cwd:"elfinder-cwd",tree:"elfinder-tree",treeroot:"elfinder-navbar-root",navdir:"elfinder-navbar-dir",navdirwrap:"elfinder-navbar-dir-wrapper",navarrow:"elfinder-navbar-arrow",navsubtree:"elfinder-navbar-subtree",navcollapse:"elfinder-navbar-collapsed",navexpand:"elfinder-navbar-expanded",treedir:"elfinder-tree-dir",placedir:"elfinder-place-dir",searchbtn:"elfinder-button-search",editing:"elfinder-to-editing"},tpl:{perms:'<span class="elfinder-perms"/>',lock:'<span class="elfinder-lock"/>',symlink:'<span class="elfinder-symlink"/>',navicon:'<span class="elfinder-nav-icon"/>',navspinner:'<span class="elfinder-navbar-spinner"/>',navdir:'<div class="elfinder-navbar-wrapper"><span id="{id}" class="ui-corner-all elfinder-navbar-dir {cssclass}"><span class="elfinder-navbar-arrow"/><span class="elfinder-navbar-icon" {style}/>{symlink}{permissions}{name}</span><div class="elfinder-navbar-subtree" style="display:none"/></div>',placedir:'<div class="elfinder-navbar-wrapper"><span id="{id}" class="ui-corner-all elfinder-navbar-dir {cssclass}" title="{title}"><span class="elfinder-navbar-arrow"/><span class="elfinder-navbar-icon" {style}/>{symlink}{permissions}{name}</span><div class="elfinder-navbar-subtree" style="display:none"/></div>'},mimes:{text:["application/x-empty","application/javascript","application/xhtml+xml","audio/x-mp3-playlist","application/x-web-config","application/docbook+xml","application/x-php","application/x-perl","application/x-awk","application/x-config","application/x-csh","application/xml"]},mixin:{make:function(){var t,n,i,a,r,o,s,l,d,c=this.fm,u=this.name,h=c.getUI("workzone"),p=this.origin&&"navbar"===this.origin?"tree":"cwd",f=c.getUI(p),m="tree"===p,g=m?"navHash2Id":"cwdHash2Id",v=!m&&"list"!=c.storage("view"),b=c.selected(),y=this.move||!1,w=h.hasClass("elfinder-cwd-wrapper-empty"),k=function(){U.is(":hidden")||U.addClass("ui-front").elfinderoverlay("hide").off("click",O),S.removeClass("ui-front").css("position",""),v?n.css("max-height",""):i&&i.css("width","").parent("td").css("overflow","")},x=e.Deferred().fail(function(e){r&&a.attr("class",r),w&&h.addClass("elfinder-cwd-wrapper-empty"),b&&(y&&c.trigger("unlockfiles",{files:b}),c.clipboard([]),c.trigger("selectfiles",{files:b})),e&&c.error(e)}).always(function(){k(),M(),c.enable(),c.trigger("resMixinMake")}),C="tmp_"+parseInt(1e5*Math.random()),T=m?c.file(b[0]).hash:c.cwd().hash,z=new Date,A={hash:C,phash:T,name:c.uniqueName(this.prefix,T),mime:this.mime,read:!0,write:!0,date:"Today "+z.getHours()+":"+z.getMinutes(),move:y},I=this.data||{},S=f.trigger("create."+c.namespace,A).find("#"+c[g](C)).on("unselect."+c.namespace,function(){setTimeout(function(){D&&D.blur()},50)}),U=c.getUI("overlay"),M=function(){c.unbind("resize",E),D.remove(),m&&S.closest(".elfinder-navbar-wrapper").remove(),S.remove()},O=function(e){P||(M(),e.stopPropagation(),x.reject())},D=e(v?"<textarea/>":'<input type="text"/>').on("keyup text",function(){v?(this.style.height="1px",this.style.height=this.scrollHeight+"px"):t&&(this.style.width=t+"px",this.scrollWidth>t&&(this.style.width=this.scrollWidth+10+"px"))}).keydown(function(t){t.stopImmediatePropagation(),t.keyCode==e.ui.keyCode.ESCAPE?x.reject():t.keyCode==e.ui.keyCode.ENTER&&D.blur()}).mousedown(function(e){e.stopPropagation()}).blur(function(){var t,n=e.trim(D.val()),i=D.parent(),a=!0;if(!P&&i.length){if(c.options.validName&&c.options.validName.test)try{a=c.options.validName.test(n)}catch(r){a=!1}if(!n||".."===n||!a)return P=!0,c.error("errInvName",{modal:!0,close:F}),!1;if(c.fileByName(n,T))return P=!0,c.error(["errExists",n],{modal:!0,close:F}),!1;t=b&&y?c.exec("cut",b):null,e.when(t).done(function(){k(),D.hide().before(e("<span>").text(n)),c.lockfiles({files:[C]}),c.request({data:e.extend({cmd:u,name:n,target:T},I||{}),notify:{type:u,cnt:1},preventFail:!0,syncOnFail:!0}).fail(function(e){c.unlockfiles({files:[C]}),P=!0,D.show().prev().remove(),c.error(e,{modal:!0,close:F})}).done(function(t){if(x.resolve(t),t&&t.added&&t.added[0]){var n=t.added[0],i=n.hash,a=f.find("#"+c[g](i));b&&y&&c.one(u+"done",function(){c.exec("paste",i)}),c.one(u+"done",function(){var i,r,o={directory:{cmd:"open",msg:"cmdopendir"},"text/plain":{cmd:"edit",msg:"cmdedit"},"default":{cmd:"open",msg:"cmdopen"}};a=f.find("#"+c[g](n.hash)),1===t.added.length&&(i=o[n.mime]||o["default"],r=e("<div/>").append(e('<button type="button" class="ui-button ui-widget ui-state-default ui-corner-all elfinder-tabstop"><span class="ui-button-text">'+c.i18n(i.msg)+"</span></button>").on("mouseenter mouseleave",function(t){e(this).toggleClass("ui-state-hover","mouseenter"==t.type)}).on("click",function(){c.exec(i.cmd,n.hash)}))),a.length?(a.trigger("scrolltoview"),!y&&r&&c.toast({msg:c.i18n(["complete",c.i18n("cmd"+u)]),extNode:r})):(c.trigger("selectfiles",{files:e.map(t.added,function(e){return e.hash})}),!y&&c.toast({msg:c.i18n(["complete",c.i18n("cmd"+u)]),extNode:r}))})}})}).fail(function(){x.reject()})}}),F=function(){var e=D.val().replace(/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/gi,"");P=!1,c.UA.Mobile&&U.on("click",O).removeClass("ui-front").elfinderoverlay("show"),D.select().focus(),D[0].setSelectionRange&&D[0].setSelectionRange(0,e.length)},E=function(){S.trigger("scrolltoview")},P=!1;return!m&&this.disabled()||!S.length?x.reject():(m?(a=e("#"+c[g](T)),o=c.res("class","navcollapse"),s=c.res("class","navexpand"),l=c.res("class","navarrow"),d=c.res("class","navsubtree"),S.closest("."+d).show(),a.hasClass(o)||(r=a.attr("class"),a.addClass(o+" "+s+" elfinder-subtree-loaded")),a.is("."+o+":not(."+s+")")&&a.children("."+l).click().data("dfrd").done(function(){D.val()===A.name&&D.val(c.uniqueName(this.prefix,T)).select().focus()}.bind(this)),n=S.contents().filter(function(){return 3==this.nodeType&&e(this).parent().attr("id")===c.navHash2Id(A.hash)}),n.replaceWith(D.val(A.name))):(w&&h.removeClass("elfinder-cwd-wrapper-empty"),n=S.find(".elfinder-cwd-filename"),i=n.parent(),S.css("position","relative").addClass("ui-front"),v?n.css("max-height","none"):(t=i.width(),i.width(t-15).parent("td").css("overflow","visible")),n.empty("").append(D.val(A.name))),c.bind("resize",E),D.trigger("keyup"),F(),x)}},blink:function(e,t){var n,i={slowonce:function(){e.hide().delay(250).fadeIn(750).delay(500).fadeOut(3500)},lookme:function(){e.show().fadeOut(500).fadeIn(750)}};t=t||"slowonce",n=i[t]||i.lookme,e.stop(!0,!0),n()}},e.fn.dialogelfinder=function(t){var n="elfinderPosition",i="elfinderDestroyOnClose";if(this.not(".elfinder").each(function(){var a=(e(document),e('<div class="ui-widget-header dialogelfinder-drag ui-corner-top">'+(t.title||"Files")+"</div>")),r=(e('<a href="#" class="dialogelfinder-drag-close ui-corner-all"><span class="ui-icon ui-icon-closethick"> </span></a>').appendTo(a).click(function(e){e.preventDefault(),r.dialogelfinder("close")}),e(this).addClass("dialogelfinder").css("position","absolute").hide().appendTo("body").draggable({handle:".dialogelfinder-drag",containment:"window",stop:function(){r.trigger("resize"),o.trigger("resize")}}).elfinder(t).prepend(a)),o=r.elfinder("instance");r.width(parseInt(r.width())||840).data(i,!!t.destroyOnClose).find(".elfinder-toolbar").removeClass("ui-corner-top"),t.position&&r.data(n,t.position),t.autoOpen!==!1&&e(this).dialogelfinder("open")}),"open"==t){var a=e(this),r=a.data(n)||{top:parseInt(e(document).scrollTop()+(e(window).height()<a.height()?2:(e(window).height()-a.height())/2)),left:parseInt(e(document).scrollLeft()+(e(window).width()<a.width()?2:(e(window).width()-a.width())/2))};a.is(":hidden")&&(a.addClass("ui-front").css(r).show().trigger("resize"),setTimeout(function(){a.trigger("resize").mousedown()},200))}else if("close"==t){var a=e(this).removeClass("ui-front");a.is(":visible")&&(a.data(i)?a.elfinder("destroy").remove():a.elfinder("close"))}else if("instance"==t)return e(this).getElFinder();return this},"function"==typeof i&&i.prototype.i18&&(i.prototype.i18.en={translator:"Troex Nevelin &lt;troex@fury.scancode.ru&gt;",language:"English",direction:"ltr",dateFormat:"M d, Y h:i A",fancyDateFormat:"$1 h:i A",messages:{error:"Error",errUnknown:"Unknown error.",errUnknownCmd:"Unknown command.",errJqui:"Invalid jQuery UI configuration. Selectable, draggable and droppable components must be included.",errNode:"elFinder requires DOM Element to be created.",errURL:"Invalid elFinder configuration! URL option is not set.",errAccess:"Access denied.",errConnect:"Unable to connect to backend.",errAbort:"Connection aborted.",errTimeout:"Connection timeout.",errNotFound:"Backend not found.",errResponse:"Invalid backend response.",errConf:"Invalid backend configuration.",errJSON:"PHP JSON module not installed.",errNoVolumes:"Readable volumes not available.",errCmdParams:'Invalid parameters for command "$1".',errDataNotJSON:"Data is not JSON.",errDataEmpty:"Data is empty.",errCmdReq:"Backend request requires command name.",errOpen:'Unable to open "$1".',errNotFolder:"Object is not a folder.",errNotFile:"Object is not a file.",errRead:'Unable to read "$1".',errWrite:'Unable to write into "$1".',errPerm:"Permission denied.",errLocked:'"$1" is locked and can not be renamed, moved or removed.',errExists:'File named "$1" already exists.',errInvName:"Invalid file name.",errFolderNotFound:"Folder not found.",errFileNotFound:"File not found.",errTrgFolderNotFound:'Target folder "$1" not found.',errPopup:"Browser prevented opening popup window. To open file enable it in browser options.",errMkdir:'Unable to create folder "$1".',errMkfile:'Unable to create file "$1".',errRename:'Unable to rename "$1".',errCopyFrom:'Copying files from volume "$1" not allowed.',errCopyTo:'Copying files to volume "$1" not allowed.',errMkOutLink:"Unable to create a link to outside the volume root.",errUpload:"Upload error.",errUploadFile:'Unable to upload "$1".',errUploadNoFiles:"No files found for upload.",errUploadTotalSize:"Data exceeds the maximum allowed size.",errUploadFileSize:"File exceeds maximum allowed size.",errUploadMime:"File type not allowed.",errUploadTransfer:'"$1" transfer error.',errUploadTemp:"Unable to make temporary file for upload.",errNotReplace:'Object "$1" already exists at this location and can not be replaced by object with another type.',errReplace:'Unable to replace "$1".',errSave:'Unable to save "$1".',errCopy:'Unable to copy "$1".',errMove:'Unable to move "$1".',errCopyInItself:'Unable to copy "$1" into itself.',errRm:'Unable to remove "$1".',errRmSrc:"Unable remove source file(s).",errExtract:'Unable to extract files from "$1".',errArchive:"Unable to create archive.",errArcType:"Unsupported archive type.",errNoArchive:"File is not archive or has unsupported archive type.",errCmdNoSupport:"Backend does not support this command.",errReplByChild:'The folder "$1" can\'t be replaced by an item it contains.',errArcSymlinks:"For security reason denied to unpack archives contains symlinks or files with not allowed names.",errArcMaxSize:"Archive files exceeds maximum allowed size.",errResize:'Unable to resize "$1".',errResizeDegree:"Invalid rotate degree.",errResizeRotate:"Unable to rotate image.",errResizeSize:"Invalid image size.",errResizeNoChange:"Image size not changed.",errUsupportType:"Unsupported file type.",errNotUTF8Content:'File "$1" is not in UTF-8 and cannot be edited.',errNetMount:'Unable to mount "$1".',errNetMountNoDriver:"Unsupported protocol.",errNetMountFailed:"Mount failed.",errNetMountHostReq:"Host required.",errSessionExpires:"Your session has expired due to inactivity.",errCreatingTempDir:'Unable to create temporary directory: "$1"',errFtpDownloadFile:'Unable to download file from FTP: "$1"',errFtpUploadFile:'Unable to upload file to FTP: "$1"',errFtpMkdir:'Unable to create remote directory on FTP: "$1"',errArchiveExec:'Error while archiving files: "$1"',errExtractExec:'Error while extracting files: "$1"',errNetUnMount:"Unable to unmount",errConvUTF8:"Not convertible to UTF-8",errFolderUpload:"Try the modern browser, If you'd like to upload the folder.",errSearchTimeout:'Timed out while searching "$1". Search result is partial.',errReauthRequire:"Re-authorization is required.",errMaxTargets:"Max number of selectable items is $1.",cmdarchive:"Create archive",cmdback:"Back",cmdcopy:"Copy",cmdcut:"Cut",cmddownload:"Download",cmdduplicate:"Duplicate",cmdedit:"Edit file",cmdextract:"Extract files from archive",cmdforward:"Forward",cmdgetfile:"Select files",cmdhelp:"About this software",cmdhome:"Home",cmdinfo:"Get info",cmdmkdir:"New folder",cmdmkdirin:"Into New Folder",cmdmkfile:"New text file",cmdopen:"Open",cmdpaste:"Paste",cmdquicklook:"Preview",cmdreload:"Reload",cmdrename:"Rename",cmdrm:"Delete",cmdsearch:"Find files",cmdup:"Go to parent directory",cmdupload:"Upload files",cmdview:"View",cmdresize:"Resize & Rotate",cmdsort:"Sort",cmdnetmount:"Mount network volume",cmdnetunmount:"Unmount",cmdplaces:"To Places",cmdchmod:"Change mode",cmdopendir:"Open a folder",cmdcolwidth:"Reset column width",cmdfullscreen:"Full Screen",cmdmove:"Move",btnClose:"Close",btnSave:"Save",btnRm:"Remove",btnApply:"Apply",btnCancel:"Cancel",btnNo:"No",btnYes:"Yes",btnMount:"Mount",btnApprove:"Goto $1 & approve",btnUnmount:"Unmount",btnConv:"Convert",btnCwd:"Here",btnVolume:"Volume",btnAll:"All",btnMime:"MIME Type",btnFileName:"Filename",btnSaveClose:"Save & Close",btnBackup:"Backup",ntfopen:"Open folder",ntffile:"Open file",ntfreload:"Reload folder content",ntfmkdir:"Creating directory",ntfmkfile:"Creating files",ntfrm:"Delete files",ntfcopy:"Copy files",ntfmove:"Move files",ntfprepare:"Prepare to copy files",ntfrename:"Rename files",ntfupload:"Uploading files",ntfdownload:"Downloading files",ntfsave:"Save files",ntfarchive:"Creating archive",ntfextract:"Extracting files from archive",ntfsearch:"Searching files",ntfresize:"Resizing images",ntfsmth:"Doing something",ntfloadimg:"Loading image",ntfnetmount:"Mounting network volume",ntfnetunmount:"Unmounting network volume",ntfdim:"Acquiring image dimension",ntfreaddir:"Reading folder infomation",ntfurl:"Getting URL of link",ntfchmod:"Changing file mode",ntfpreupload:"Verifying upload file name",ntfzipdl:"Creating a file for download",ntfparents:"Getting path infomation",ntfchunkmerge:"Processing the uploaded file",dateUnknown:"unknown",Today:"Today",Yesterday:"Yesterday",msJan:"Jan",msFeb:"Feb",msMar:"Mar",msApr:"Apr",msMay:"May",msJun:"Jun",msJul:"Jul",msAug:"Aug",msSep:"Sep",msOct:"Oct",msNov:"Nov",msDec:"Dec",January:"January",February:"February",March:"March",April:"April",May:"May",June:"June",July:"July",August:"August",September:"September",October:"October",November:"November",December:"December",Sunday:"Sunday",Monday:"Monday",Tuesday:"Tuesday",Wednesday:"Wednesday",Thursday:"Thursday",Friday:"Friday",Saturday:"Saturday",Sun:"Sun",Mon:"Mon",Tue:"Tue",Wed:"Wed",Thu:"Thu",Fri:"Fri",Sat:"Sat",sortname:"by name",sortkind:"by kind",sortsize:"by size",sortdate:"by date",sortFoldersFirst:"Folders first",sortperm:"by permission",sortmode:"by mode",sortowner:"by owner",sortgroup:"by group",sortAlsoTreeview:"Also Treeview","untitled file.txt":"NewFile.txt","untitled folder":"NewFolder",Archive:"NewArchive",confirmReq:"Confirmation required",confirmRm:"Are you sure you want to remove files?<br/>This cannot be undone!",confirmRepl:"Replace old file with new one?",confirmConvUTF8:"Not in UTF-8<br/>Convert to UTF-8?<br/>Contents become UTF-8 by saving after conversion.",confirmNonUTF8:"Character encoding of this file couldn't be detected. It need to temporarily convert to UTF-8 for editting.<br/>Please select character encoding of this file.",confirmNotSave:"It has been modified.<br/>Losing work if you do not save changes.",apllyAll:"Apply to all",name:"Name",size:"Size",perms:"Permissions",modify:"Modified",kind:"Kind",read:"read",write:"write",noaccess:"no access",and:"and",unknown:"unknown",selectall:"Select all files",selectfiles:"Select file(s)",selectffile:"Select first file",selectlfile:"Select last file",viewlist:"List view",viewicons:"Icons view",places:"Places",calc:"Calculate",path:"Path",aliasfor:"Alias for",locked:"Locked",dim:"Dimensions",files:"Files",folders:"Folders",items:"Items",yes:"yes",no:"no",link:"Link",searcresult:"Search results",selected:"selected items",about:"About",shortcuts:"Shortcuts",help:"Help",webfm:"Web file manager",ver:"Version",protocolver:"protocol version",homepage:"Project home",docs:"Documentation",github:"Fork us on Github",twitter:"Follow us on twitter",facebook:"Join us on facebook",team:"Team",chiefdev:"chief developer",developer:"developer",contributor:"contributor",maintainer:"maintainer",translator:"translator",icons:"Icons",dontforget:"and don't forget to take your towel",shortcutsof:"Shortcuts disabled",dropFiles:"Drop files here",or:"or",selectForUpload:"Select files",moveFiles:"Move files",copyFiles:"Copy files",rmFromPlaces:"Remove from places",aspectRatio:"Aspect ratio",scale:"Scale",width:"Width",height:"Height",resize:"Resize",crop:"Crop",rotate:"Rotate","rotate-cw":"Rotate 90 degrees CW","rotate-ccw":"Rotate 90 degrees CCW",degree:"°",netMountDialogTitle:"Mount network volume",protocol:"Protocol",host:"Host",port:"Port",user:"User",pass:"Password",confirmUnmount:"Are you unmount $1?",dropFilesBrowser:"Drop or Paste files from browser",dropPasteFiles:"Drop files, Paste URLs or images(clipboard) here",encoding:"Encoding",locale:"Locale",searchTarget:"Target: $1",searchMime:"Search by input MIME Type",owner:"Owner",group:"Group",other:"Other",execute:"Execute",perm:"Permission",mode:"Mode",emptyFolder:"Folder is empty",emptyFolderDrop:"Folder is empty\\A Drop to add items",emptyFolderLTap:"Folder is empty\\A Long tap to add items",quality:"Quality",autoSync:"Auto sync",moveUp:"Move up",getLink:"Get URL link",selectedItems:"Selected items ($1)",folderId:"Folder ID",offlineAccess:"Allow offline access",reAuth:"To re-authenticate",nowLoading:"Now loading...",openMulti:"Open multiple files",openMultiConfirm:"You are trying to open the $1 files. Are you sure you want to open in browser?",emptySearch:"Search results is empty in search target.",editingFile:"It is editing a file.",hasSelected:"You have selected $1 items.",hasClipboard:"You have $1 items in the clipboard.",incSearchOnly:"Incremental search is only from the current view.",reinstate:"Reinstate",complete:"$1 complete",contextmenu:"Context menu",pageTurning:"Page turning",volumeRoots:"Volume roots",reset:"Reset",bgcolor:"Background color",colorPicker:"Color picker","8pxgrid":"8px Grid",enabled:"Enabled",disabled:"Disabled",emptyIncSearch:"Search results is empty in current view.\\APress [Enter] to expand search target.",textLabel:"Text label",minsLeft:"$1 mins left",openAsEncoding:"Reopen with selected encoding",saveAsEncoding:"Save with the selected encoding",selectFolder:"Select folder",kindUnknown:"Unknown",kindRoot:"Volume Root",kindFolder:"Folder",kindAlias:"Alias",kindAliasBroken:"Broken alias",kindApp:"Application",kindPostscript:"Postscript document",kindMsOffice:"Microsoft Office document",kindMsWord:"Microsoft Word document",kindMsExcel:"Microsoft Excel document",kindMsPP:"Microsoft Powerpoint presentation",kindOO:"Open Office document",kindAppFlash:"Flash application",kindPDF:"Portable Document Format (PDF)",kindTorrent:"Bittorrent file",kind7z:"7z archive",kindTAR:"TAR archive",kindGZIP:"GZIP archive",kindBZIP:"BZIP archive",kindXZ:"XZ archive",kindZIP:"ZIP archive",kindRAR:"RAR archive",kindJAR:"Java JAR file",kindTTF:"True Type font",kindOTF:"Open Type font",kindRPM:"RPM package",kindText:"Text document",kindTextPlain:"Plain text",kindPHP:"PHP source",kindCSS:"Cascading style sheet",kindHTML:"HTML document",kindJS:"Javascript source",kindRTF:"Rich Text Format",kindC:"C source",kindCHeader:"C header source",kindCPP:"C++ source",kindCPPHeader:"C++ header source",kindShell:"Unix shell script",kindPython:"Python source",kindJava:"Java source",kindRuby:"Ruby source",kindPerl:"Perl script",kindSQL:"SQL source",kindXML:"XML document",kindAWK:"AWK source",kindCSV:"Comma separated values",kindDOCBOOK:"Docbook XML document",kindMarkdown:"Markdown text",kindImage:"Image",kindBMP:"BMP image",kindJPEG:"JPEG image",kindGIF:"GIF Image",kindPNG:"PNG Image",kindTIFF:"TIFF image",kindTGA:"TGA image",kindPSD:"Adobe Photoshop image",kindXBITMAP:"X bitmap image",kindPXM:"Pixelmator image",kindAudio:"Audio media",kindAudioMPEG:"MPEG audio",kindAudioMPEG4:"MPEG-4 audio",kindAudioMIDI:"MIDI audio",kindAudioOGG:"Ogg Vorbis audio",kindAudioWAV:"WAV audio",AudioPlaylist:"MP3 playlist",kindVideo:"Video media",kindVideoDV:"DV movie",kindVideoMPEG:"MPEG movie",kindVideoMPEG4:"MPEG-4 movie",kindVideoAVI:"AVI movie",kindVideoMOV:"Quick Time movie",kindVideoWM:"Windows Media movie",kindVideoFlash:"Flash movie",kindVideoMKV:"Matroska movie",kindVideoOGG:"Ogg movie"}}),e.fn.elfinderbutton=function(t){return this.each(function(){var n,i="class",a=t.fm,r=a.res(i,"disabled"),o=a.res(i,"active"),s=a.res(i,"hover"),l="elfinder-button-menu-item",d="elfinder-button-menu-item-selected",c=e('<span class="elfinder-button-text">'+t.title+"</span>"),u=e(this).addClass("ui-state-default elfinder-button").attr("title",t.title).append('<span class="elfinder-button-icon elfinder-button-icon-'+(t.className?t.className:t.name)+'"/>',c).hover(function(e){!u.hasClass(r)&&u["mouseleave"==e.type?"removeClass":"addClass"](s)}).click(function(e){u.hasClass(r)||(n&&t.variants.length>1?(n.is(":hidden")&&t.fm.getUI().click(),e.stopPropagation(),n.slideToggle(100)):t.exec())}),h=function(){n.hide()};c.hide(),e.isArray(t.variants)&&(u.addClass("elfinder-menubutton"),n=e('<div class="ui-front ui-widget ui-widget-content elfinder-button-menu ui-corner-all"/>').hide().appendTo(u).on("mouseenter mouseleave","."+l,function(){e(this).toggleClass(s)}).on("click","."+l,function(i){i.preventDefault(),i.stopPropagation(),u.removeClass(s),n.hide(),t.exec(t.fm.selected(),e(this).data("value"))}),t.fm.bind("disable select",h).getUI().click(h),t.change(function(){n.html(""),e.each(t.variants,function(i,a){n.append(e('<div class="'+l+'">'+a[1]+"</div>").data("value",a[0]).addClass(a[0]==t.value?d:""))})})),t.change(function(){t.disabled()?u.removeClass(o+" "+s).addClass(r):(u.removeClass(r),u[t.active()?"addClass":"removeClass"](o))}).change()})},e.fn.elfindercontextmenu=function(t){return this.each(function(){var n,i,a,r,o,s,l,d="elfinder-contextmenu-item",c="elfinder-contextsubmenu-item",u="elfinder-contextmenu-extra-icon",h={distance:8,start:function(){p.data("touching")&&p.find(".ui-state-hover").removeClass("ui-state-hover")},stop:function(){p.data("draged",!0)}},p=e(this).addClass("touch-punch ui-helper-reset ui-front ui-widget ui-state-default ui-corner-all elfinder-contextmenu elfinder-contextmenu-"+t.direction).hide().on("touchstart",function(e){p.data("touching",!0)}).on("touchend",function(e){p.removeData("touching")}).on("mouseenter mouseleave","."+d,function(t){e(this).toggleClass("ui-state-hover",!("mouseenter"!==t.type&&(p.data("draged")||!p.data("submenuKeep")))),p.data("draged")&&p.data("submenuKeep")&&p.find(".elfinder-contextmenu-sub:visible").parent().addClass("ui-state-hover")}).on("mouseenter mouseleave","."+u,function(t){e(this).parent().toggleClass("ui-state-hover","mouseleave"===t.type)}).on("mouseenter mouseleave","."+d+",."+c,function(t){var n=function(t,n){e.each(n?o:a,function(e,i){return t[0]===i?((n?o:a)._cur=e,n?s=t:r=t,!1):void 0})};if(t.originalEvent){var i=e(this);"mouseenter"===t.type?i.hasClass(c)?(s&&s.removeClass("ui-state-hover"),o=r.find("div."+c),n(i,!0)):(r&&r.removeClass("ui-state-hover"),n(i)):i.hasClass(c)?(s=null,o=null):(r&&r.removeClass("ui-state-hover"),function(e){setTimeout(function(){e===r&&(r=null)},250)}(r))}}).on("contextmenu",function(){return!1}).on("mouseup",function(){setTimeout(function(){p.removeData("draged")},100)}).draggable(h),f="ltr"==t.direction?"left":"right",m=e.extend({},t.options.contextmenu),g='<div class="'+d+'{className}"><span class="elfinder-button-icon {icon} elfinder-contextmenu-icon"{style}/><span>{label}</span></div>',v=function(n,i,a,r){var o="",s="",l="";return r&&(r.className&&(o=" "+r.className),r.iconClass&&(l=r.iconClass,i=""),r.iconImg&&(s=" style=\"background:url('"+t.escape(r.iconImg)+"') 0 0 no-repeat;background-size:contain;\"")),e(g.replace("{icon}",i?"elfinder-button-icon-"+i:l?l:"").replace("{label}",n).replace("{style}",s).replace("{className}",o)).click(function(e){e.stopPropagation(),e.preventDefault(),a()})},b=function(){var n="touchstart.contextmenuAutoToggle";p.data("hideTm")&&clearTimeout(p.data("hideTm")),p.is(":visible")&&p.on("touchstart",function(e){e.originalEvent.touches.length>1||(p.stop().show(),p.data("hideTm")&&clearTimeout(p.data("hideTm")))}).data("hideTm",setTimeout(function(){i.find(".elfinder-cwd-file").off(n),i.find(".elfinder-cwd-file.ui-selected").one(n,function(t){if(!(t.originalEvent.touches.length>1)){var a=e(t.target);return!p.first().length||a.is("input:checkbox")||a.hasClass("elfinder-cwd-select")?void i.find(".elfinder-cwd-file").off(n):(w(t.originalEvent.touches[0].pageX,t.originalEvent.touches[0].pageY),!1)}}).one("unselect."+t.namespace,function(){i.find(".elfinder-cwd-file").off(n)}),p.fadeOut({duration:300,fail:function(){p.css("opacity","1").show()}})},4500))},y=function(n){var i=n.keyCode,l=e.ui.keyCode.ESCAPE,d=e.ui.keyCode.ENTER,u=e.ui.keyCode.LEFT,h=e.ui.keyCode.RIGHT,p=e.ui.keyCode.UP,f=e.ui.keyCode.DOWN,m="ltr"===t.direction?h:u,g=m===h?u:h;-1!==e.inArray(i,[l,d,u,h,p,f])&&(n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation(),i==l||i===g?r&&o&&s?(s.trigger("mouseleave"),r.addClass("ui-state-hover"),o=null,s=null):i==l&&k():i==p||i==f?o?(s&&s.trigger("mouseleave"),i==f&&(!s||o.length<=++o._cur)?o._cur=0:i==p&&(!s||--o._cur<0)&&(o._cur=o.length-1),s=o.eq(o._cur).trigger("mouseenter")):(o=null,r&&r.trigger("mouseleave"),i==f&&(!r||a.length<=++a._cur)?a._cur=0:i==p&&(!r||--a._cur<0)&&(a._cur=a.length-1),r=a.eq(a._cur).addClass("ui-state-hover")):!r||i!=d&&i!==m||(r.hasClass("elfinder-contextmenu-group")?s?i==d&&s.click():(r.trigger("mouseenter"),o=r.find("div."+c),o._cur=0,s=o.first().addClass("ui-state-hover")):i==d&&r.click()))},w=function(i,a,d){var c,u=p.outerWidth(),h=p.outerHeight(),m=n.attr("style"),g=n.offset(),v=n.width(),w=n.height(),k=t.UA.Mobile?40:2,x=t.UA.Mobile?20:2,i=i-(g?g.left:0),a=a-(g?g.top:0),d=e.extend(d||{},{top:Math.max(0,w>a+x+h?a+x:a-(a+h-w)),left:Math.max(0,u+k>i||v>i+k+u?i+k:i-k-u),opacity:"1"});l=!0,t.autoSync("stop"),t.toFront(p),n.width(v),p.stop().removeAttr("style").css(d).show(),n.attr("style",m),d[f]=parseInt(p.width()),p.find(".elfinder-contextmenu-sub").css(d),t.UA.iOS&&e("div.elfinder div.overflow-scrolling-touch").css("-webkit-overflow-scrolling","auto"),r=null,o=null,s=null,e(document).on("keydown."+t.namespace,y),c=e._data(document).events,c&&c.keydown&&c.keydown.unshift(c.keydown.pop()),t.UA.Mobile&&b()},k=function(){if(e(document).off("keydown."+t.namespace,y),T=null,p.is(":visible")||p.children().length){p.removeAttr("style").hide().empty().removeData("submenuKeep");
  1817. try{p.draggable("instance")||p.draggable(h)}catch(n){p.hasClass("ui-draggable")||p.draggable(h)}p.data("prevNode")&&(p.data("prevNode").after(p),p.removeData("prevNode")),t.trigger("closecontextmenu"),t.UA.iOS&&e("div.elfinder div.overflow-scrolling-touch").css("-webkit-overflow-scrolling","touch")}l&&t.searchStatus.state<1&&!t.searchStatus.ininc&&t.autoSync(),l=!1},x=function(i,r){var o=!1,s=!1,l={},u=[],h="cwd"===i,g=0;T=i,p.data("cmdMaps")&&e.each(p.data("cmdMaps"),function(e,t){return 0==r[0].indexOf(e,0)?(l=t,!1):void 0}),h||(u=t.getDisabledCmds(r)),"navbar"===i&&t.select({selected:r,origin:"navbar"}),g=t.selected().length,g>1&&p.append('<div class="ui-corner-top ui-widget-header elfinder-contextmenu-header"><span>'+t.i18n("selectedItems",""+g)+"</span></div>"),a=e(),e.each(m[i]||[],function(a,m){var g,b,y,w;if("|"===m)return void(o&&(s=!0));if(l[m]&&(m=l[m]),g=t.getCommand(m),!g||h||t.searchStatus.state&&g.disableOnSearch||(g.__disabled=g._disabled,g._disabled=!(g.alwaysEnabled||(t._commands[m]?-1===e.inArray(m,u):!1)),e.each(g.linkedCmds,function(n,i){var a;(a=t.getCommand(i))&&(a.__disabled=a._disabled,a._disabled=!(a.alwaysEnabled||(t._commands[i]?-1===e.inArray(i,u):!1)))})),g&&-1!=g.getstate(r)){if(g.variants){if(!g.variants.length)return;b=v(g.title,g.className?g.className:g.name,function(){}),y=e('<div class="ui-front ui-corner-all elfinder-contextmenu-sub"/>').hide().appendTo(b.append('<span class="elfinder-contextmenu-arrow"/>')),w=function(e){if(e){var i=n.attr("style");n.width(n.width()),y.css({left:"auto",right:"auto"});var a,r,o,s=b.offset(),l=s.left,d=s.top,c=b.outerWidth(),u=y.outerWidth(!0),h=y.outerHeight(!0),m=n.offset(),g=m.left+n.width(),v=m.top+n.height();o=l+c+u-g,a=l>u&&o>0?t.UA.Mobile?10-u:c-o:c,"right"===f&&u>l&&(a=t.UA.Mobile?30-c:c-(u-l)),o=d+5+h-v,r=o>0&&v>d?5-o:o>0?30-h:5,p.find(".elfinder-contextmenu-sub:visible").hide().parent().removeClass("ui-state-hover"),y.css({top:r}).css(f,a).show(),n.attr("style",i)}else y.hide()},b.addClass("elfinder-contextmenu-group").on("touchstart",".elfinder-contextmenu-sub",function(e){b.data("touching",!0)}).on("mouseleave",".elfinder-contextmenu-sub",function(e){p.data("draged")||p.removeData("submenuKeep")}).on("click","."+c,function(t){var n;t.stopPropagation(),p.data("draged")||(p.hide(),n=e(this).data("exec"),e.isPlainObject(n)&&(n._currentType=i),k(),g.exec(r,n))}).on("touchend",function(e){p.data("submenuKeep",!0)}).on("mouseenter mouseleave",function(e){"mouseleave"===e.type?p.data("submenuKeep")||b.data("timer",setTimeout(function(){b.removeData("timer"),w(!1)},250)):(b.data("timer")&&(clearTimeout(b.data("timer")),b.removeData("timer")),b.data("touching")||w(!0)),b.removeData("touching")}),e.each(g.variants,function(t,n){y.append("|"===n?'<div class="elfinder-contextmenu-separator"/>':e('<div class="'+d+" "+c+'"><span>'+n[1]+"</span></div>").data("exec",n[0]))})}else b=v(g.title,g.className?g.className:g.name,function(){p.data("draged")||(k(),g.exec(r,{_currentType:i}))}),g.extra&&g.extra.node?(e('<span class="elfinder-button-icon elfinder-button-icon-'+(g.extra.icon||"")+' elfinder-contextmenu-extra-icon"/>').append(g.extra.node).appendTo(b),e(g.extra.node).trigger("ready")):b.remove(".elfinder-contextmenu-extra-icon");g.extendsCmd&&b.children("span.elfinder-button-icon").addClass("elfinder-button-icon-"+g.extendsCmd),s&&p.append('<div class="elfinder-contextmenu-separator"/>'),p.append(b),o=!0,s=!1}g&&"undefined"!=typeof g.__disabled&&(g._disabled=g.__disabled,delete g.__disabled,e.each(g.linkedCmds,function(e,n){var i;(i=t.getCommand(n))&&(i._disabled=i.__disabled,delete i.__disabled)}))}),a=p.children("div."+d)},C=function(t){T="raw",e.each(t,function(e,t){var n;"|"===t?p.append('<div class="elfinder-contextmenu-separator"/>'):t.label&&"function"==typeof t.callback&&(n=v(t.label,t.icon,function(){p.data("draged")||(!t.remain&&k(),t.callback())},t.options||null),p.append(n))}),a=p.children("div."+d)},T=null;t.one("load",function(){n=t.getUI(),i=t.getUI("cwd"),t.bind("contextmenu",function(n){var a,r=n.data,o={};r.type&&"files"===r.type||i.trigger("unselectall"),k(),r.type&&r.targets?x(r.type,r.targets):r.raw&&C(r.raw),p.children().length&&(a=r.prevNode||null,a&&(p.data("prevNode",p.prev()),a.after(p)),r.fitHeight&&(o={maxHeight:Math.min(t.getUI().height(),e(window).height()),overflowY:"auto"},p.draggable("destroy").removeClass("ui-draggable")),w(r.x,r.y,o))}).one("destroy",function(){p.remove()}).bind("disable",k).bind("select",function(){"files"===T&&k()}).getUI().click(k)}).shortcut({pattern:"mac"===t.OS?"ctrl+m":"contextmenu shift+f10",description:"contextmenu",callback:function(n){n.stopPropagation(),n.preventDefault(),e(document).one("contextmenu."+t.namespace,function(e){e.preventDefault(),e.stopPropagation()});var i,a,r,o,s=t.selected();s.length?(i="files",a=s,o=e("#"+t.cwdHash2Id(s[0]))):(i="cwd",a=[t.cwd().hash],r=t.getUI("workzone").offset()),o&&o.length||(o=t.getUI("workzone")),r=o.offset(),r.top+=o.height()/2,r.left+=o.width()/2,t.trigger("contextmenu",{type:i,targets:a,x:r.left,y:r.top})}})})},e.fn.elfindercwd=function(t,n){return this.not(".elfinder-cwd").each(function(){var i,a=t.UA.Mobile,r="list"==t.viewType,o="select."+t.namespace,s="unselect."+t.namespace,l="disable."+t.namespace,d="enable."+t.namespace,c="class",u=t.res(c,"cwdfile"),h="."+u,p="ui-selected",f=t.res(c,"disabled"),m=t.res(c,"draggable"),g=t.res(c,"droppable"),v=t.res(c,"hover"),b=t.res(c,"adroppable"),y=u+"-tmp",w=t.options.loadTmbs>0?t.options.loadTmbs:5,k="",x={},C=[],T=[],z=void 0,A=[],I=function(){for(var e="",t=0;t<A.length;t++)e+='<td class="elfinder-col-'+A[t]+'">{'+A[t]+"}</td>";return e},S=function(){return'<tr id="{id}" class="'+u+' {permsclass} {dirclass}" title="{tooltip}"{css}><td class="elfinder-col-name"><div class="elfinder-cwd-file-wrapper"><span class="elfinder-cwd-icon {mime}"{style}/>{marker}<span class="elfinder-cwd-filename">{name}</span></div>'+U+"</td>"+I()+"</tr>"},U=e.map(n.showSelectCheckboxUA,function(e){return t.UA[e]||e.match(/^all$/i)?!0:null}).length?'<div class="elfinder-cwd-select"><input type="checkbox"></div>':"",M=!1,O=null,D={icon:'<div id="{id}" class="'+u+' {permsclass} {dirclass} ui-corner-all" title="{tooltip}"><div class="elfinder-cwd-file-wrapper ui-corner-all"><div class="elfinder-cwd-icon {mime} ui-corner-all" unselectable="on"{style}/>{marker}</div><div class="elfinder-cwd-filename" title="{nametitle}">{name}</div>'+U+"</div>",row:""},F=t.res("tpl","perms"),E=t.res("tpl","lock"),P=t.res("tpl","symlink"),R={id:function(e){return t.cwdHash2Id(e.hash)},name:function(e){var n=t.escape(e.i18||e.name);return!r&&(n=n.replace(/([_.])/g,"&#8203;$1")),n},nametitle:function(e){return t.escape(e.i18||e.name)},permsclass:function(e){return t.perms2class(e)},perm:function(e){return t.formatPermissions(e)},dirclass:function(e){var i="directory"==e.mime?"directory":"";return e.isroot&&(i+=" isroot"),e.csscls&&(i+=" "+t.escape(e.csscls)),n.getClass&&(i+=" "+n.getClass(e)),i},style:function(e){return e.icon?"style=\"background:url('"+t.escape(e.icon)+"') 0 0 no-repeat;background-size:contain;\"":""},mime:function(e){return t.mime2class(e.mime)},size:function(e){return"directory"!==e.mime||e.size?t.formatSize(e.size):"-"},date:function(e){return t.formatDate(e)},kind:function(e){return t.mime2kind(e)},mode:function(e){return e.perm?t.formatFileMode(e.perm):""},modestr:function(e){return e.perm?t.formatFileMode(e.perm,"string"):""},modeoct:function(e){return e.perm?t.formatFileMode(e.perm,"octal"):""},modeboth:function(e){return e.perm?t.formatFileMode(e.perm,"both"):""},marker:function(e){return(e.alias||"symlink-broken"==e.mime?P:"")+(e.read&&e.write?"":F)+(e.locked?E:"")},tooltip:function(e){var n=t.formatDate(e)+(e.size>0?" ("+t.formatSize(e.size)+")":""),i="";return i=k&&e.path?t.escape(e.path.replace(/\/[^\/]*$/,"")):e.tooltip?t.escape(e.tooltip).replace(/\r/g,"&#13;"):"",r&&(i+=(i?"&#13;":"")+t.escape(e.i18||e.name)),i?i+"&#13;"+n:n}},j=function(e){return D[r?"row":"icon"].replace(/\{([a-z0-9_]+)\}/g,function(n,i){return R[i]?R[i](e,t):e[i]?e[i]:""})},H=e(),N=!1,q=function(t,n){function i(e,t){return e[t+"All"]("[id]:not(."+f+"):not(.elfinder-cwd-parent):first")}var a,l,d,c,u,h=e.ui.keyCode,m=t==h.LEFT||t==h.UP,g=ge.find("[id]."+p);if(g.length)if(a=g.filter(m?":first":":last"),d=i(a,m?"prev":"next"),d.length)if(r||t==h.LEFT||t==h.RIGHT)l=d;else if(c=a.position().top,u=a.position().left,l=a,m){do l=l.prev("[id]");while(l.length&&!(l.position().top<c&&l.position().left<=u));l.hasClass(f)&&(l=i(l,"next"))}else{do l=l.next("[id]");while(l.length&&!(l.position().top>c&&l.position().left>=u));l.hasClass(f)&&(l=i(l,"prev")),l.length||(d=ge.find("[id]:not(."+f+"):last"),d.position().top>c&&(l=d))}else l=a;else l=H.length?m?H.prev():H:ge.find("[id]:not(."+f+"):not(.elfinder-cwd-parent):"+(m?"last":"first"));l&&l.length&&!l.hasClass("elfinder-cwd-parent")&&(a&&n?l=a.add(a[m?"prevUntil":"nextUntil"]("#"+l.attr("id"))).add(l):g.trigger(s),l.trigger(o),K(l.filter(m?":first":":last")),$())},_=[],L=function(n){e("#"+t.cwdHash2Id(n)).trigger(o)},W=function(){t.cwd().hash;U&&ye.find("input").prop("checked",!0),t.lazy(function(){var n;ge.find("[id]:not(."+p+"):not(.elfinder-cwd-parent)").trigger(o),t.maxTargets&&(z||T).length>t.maxTargets?(n=e.map(z||T,function(e){return t.file(e)||null}),n=t.sortFiles(n),_=e.map(n,function(e){return e.hash})):_=(z||T).concat(),$(),U&&ye.data("pending",!1)},0,{repaint:!0})},B=function(){U&&ye.find("input").prop("checked",!1),_.length?(N=!1,_=[],ge.find("[id]."+p).trigger(s),U&&ge.find("input:checkbox").prop("checked",!1)):t.select({selected:[]}),$(),U&&ye.data("pending",!1),ge.removeClass("elfinder-cwd-allselected")},V=void 0,$=function(){if(U){var e=_.length===T.length;ye.find("input").prop("checked",e),ge[e?"addClass":"removeClass"]("elfinder-cwd-allselected")}t.trigger("select",{selected:_})},K=function(e,n){var i=e.position().top,a=e.outerHeight(!0),o=ve.scrollTop(),s=ve.get(0).clientHeight,l=ne?ne.outerHeight(!0):0;i+l+a>o+s?ve.scrollTop(parseInt(i+l+a-s)):o>i&&ve.scrollTop(i),r&&ve.scrollLeft(0),!!n&&t.resources.blink(e,"lookme")},G=[],J={},Y=function(e){for(var t=G.length;t--;)if(G[t].hash==e)return t;return-1},X="elfscrstop",Z={filter:h,stop:$,delay:250,appendTo:"body",autoRefresh:!1,selected:function(t,n){e(n.selected).trigger(o)},unselected:function(t,n){e(n.unselected).trigger(s)}},Q=function(n){var n=t.cwd().phash,i=t.file(n)||null,a=function(n){n&&(xe=e(j(e.extend(!0,{},n,{name:"..",mime:"directory"}))).addClass("elfinder-cwd-parent").bind("mousedown click mouseup touchstart touchmove touchend dblclick mouseenter",function(e){e.preventDefault(),e.stopPropagation()}).dblclick(function(){t.exec("open",t.cwdId2Hash(this.id))}),(r?ge.find("tbody"):ge).prepend(xe))};i?a(i):t.getUI("tree").hasClass("elfinder-tree")?t.one("parents",function(){a(t.file(n)||null)}):t.request({data:{cmd:"parents",target:t.cwd().hash},preventFail:!0}).done(function(e){a(t.file(n)||null)})},ee=t.options.showFiles,te=function(){var i,s,l=r?ge.children("table").children("tbody"):ge,d=!1,c=!!e.htmlPrefilter,u=e(c?document.createDocumentFragment():"<div/>"),h=function(n){var i,s,d,n=n||null,h=[],f=!1,m={},g="self"===t.option("tmbUrl");i=G.splice(0,ee+(n||0)/(J.hpi||1)),J.renderd+=i.length,G.length||(be.hide(),ve.off(X,te)),s=[],h=e.map(i,function(e){return e.hash&&e.name?("directory"==e.mime&&(f=!0),(e.tmb||g&&0===e.mime.indexOf("image/"))&&(m[e.hash]=e.tmb),x[e.hash]&&s.push(e.hash),j(e)):null}),u.empty().append(h.join("")),f&&!a&&oe(u),d=[],_.length&&u.find("[id]:not(."+p+"):not(.elfinder-cwd-parent)").each(function(){-1!==e.inArray(t.cwdId2Hash(this.id),_)&&d.push(e(this))}),l.append(c?u:u.children()),d.length&&(e.each(d,function(e,t){t.trigger(o)}),$()),s.length&&t.trigger("lockfiles",{files:s}),!J.hpi&&pe(l,i.length),r&&(ge.find("thead").show(),ie({fitWidth:!O})),Object.keys(m).length&&(Object.keys(J.attachTmbs).length<1&&(ve.off(X,se).on(X,se),t.unbind("resize",se).bind("resize",se)),e.extend(J.attachTmbs,m),se(m)),ve.trigger(X)};J.renderd?d||(i=ve.height()+ve.scrollTop()+t.options.showThreshold+J.row-J.renderd*J.hpi)>0&&(d=!0,t.lazy(function(){h(i),d=!1})):(d=!0,ve.scrollTop(0),s=t.cwd().phash,h(),n.oldSchool&&s&&!k&&Q(s),r&&(O&&ae(),ie({fitWidth:!0})),J.itemH=(r?l.find("tr:first"):l.find("[id]:first")).outerHeight(!0),t.trigger("cwdrender"),d=!1)},ne=null,ie=function(i){if(n.listView.fixedHeader){var a,r,o,s,l,d,c,u,h,p,f,m,g,v=function(){var e,n;"ltr"===t.direction?(e=-1*ve.scrollLeft(),n="left"):(e=ve.scrollLeft(),n="right"),r.css(n)!==e&&r.css(n,e)},i=i||{};if(l=ge.find("tbody"),u=l.children("tr:first"),u.length){if(o=l.parent(),ne?(s=e("#"+t.namespace+"-cwd-thead"),c=s.children("tr:first")):(g=!0,l.addClass("elfinder-cwd-fixheader"),s=ge.find("thead").attr("id",t.namespace+"-cwd-thead"),c=s.children("tr:first"),d=c.outerHeight(!0),ge.css("margin-top",d-parseInt(o.css("padding-top"))),r=e("<div/>").addClass(ge.attr("class")).append(e("<table/>").append(s)),ne=e("<div/>").addClass(ve.attr("class")+" elfinder-cwd-fixheader").removeClass("ui-droppable native-droppable").css(ve.position()).css("height",d).append(r),"rtl"===t.direction&&ne.css("right",t.getUI().width()-ve.width()+"px"),v(),ve.after(ne).on("scroll.fixheader resize.fixheader",function(e){v(),"resize"===e.type&&(e.stopPropagation(),ie())})),g||i.fitWidth||Math.abs(u.outerWidth()-c.outerWidth())>2){a=A.length+1;for(var b=0;a>b&&(h=c.children("td:eq("+b+")"),p=u.children("td:eq("+b+")"),f=h.width(),m=p.width(),"undefined"==typeof h.data("delta")&&h.data("delta",h.outerWidth()-f-(p.outerWidth()-m)),m-=h.data("delta"),g||i.fitWidth||f!==m);b++)h.css("width",m+"px")}ne.data("widthTimer")&&clearTimeout(ne.data("widthTimer")),ne.data("widthTimer",setTimeout(function(){ne&&("rtl"===t.direction&&ne.css("right",t.getUI().width()-ve.width()+"px"),ne.css(ve.position()).css("width",ge.outerWidth()+"px"))},10))}}},ae=function(){if(r&&O){var t,n="elfinder-cwd-colwidth",i=ge.find("tr[id]:first");i.hasClass(n)||(t=ge.find("tr."+n),t.removeClass(n).find("td").css("width",""),i.addClass(n),ge.find("table:first").css("table-layout","fixed"),e.each(e.merge(["name"],A),function(e,t){var n=O[t]||i.find("td.elfinder-col-"+t).width();i.find("td.elfinder-col-"+t).width(n)}))}},re=e.extend({},t.droppable,{over:function(n,i){var a,r,o,s=e(this),l=i.helper,d=n.shiftKey||n.ctrlKey||n.metaKey;return n.stopPropagation(),l.data("dropover",l.data("dropover")+1),s.data("dropover",!0),l.data("namespace")===t.namespace&&t.insideWorkzone(n.pageX,n.pageY)?(s.hasClass(t.res(c,"cwdfile"))?(a=t.cwdId2Hash(s.attr("id")),s.data("dropover",a)):(a=t.cwd().hash,t.cwd().write&&s.data("dropover",a)),o=t.file(l.data("files")[0]).phash===a,s.data("dropover")===a?e.each(l.data("files"),function(e,t){return t===a||o&&!d&&!l.hasClass("elfinder-drag-helper-plus")?(s.removeClass(b),!1):void 0}):s.removeClass(b),l.data("locked")||o?r="elfinder-drag-helper-plus":(r="elfinder-drag-helper-move",d&&(r+=" elfinder-drag-helper-plus")),s.hasClass(b)&&l.addClass(r),void setTimeout(function(){s.hasClass(b)&&l.addClass(r)},20)):(s.removeClass(b),void l.removeClass("elfinder-drag-helper-move elfinder-drag-helper-plus"))},out:function(t,n){var i=n.helper;t.stopPropagation(),i.removeClass("elfinder-drag-helper-move elfinder-drag-helper-plus").data("dropover",Math.max(i.data("dropover")-1,0)),e(this).removeData("dropover").removeClass(b)},deactivate:function(){e(this).removeData("dropover").removeClass(b)},drop:function(e,n){B(),t.droppable.drop.call(this,e,n)}}),oe=function(n){n=n?n:r?ge.find("tbody"):ge;var i=n.children(".directory:not(."+g+",.elfinder-na,.elfinder-ro)");t.isCommandEnabled("paste")&&i.droppable(re),t.isCommandEnabled("upload")&&i.addClass("native-droppable"),n.children(".isroot").each(function(n,i){var a=e(i),r=t.cwdId2Hash(i.id);t.isCommandEnabled("paste",r)?a.hasClass(g+",elfinder-na,elfinder-ro")||a.droppable(re):a.hasClass(g)&&a.droppable("destroy"),t.isCommandEnabled("upload",r)?a.hasClass("native-droppable,elfinder-na,elfinder-ro")||a.addClass("native-droppable"):a.hasClass("native-droppable")&&a.removeClass("native-droppable")})},se=function(n,i){var a=(t.option("tmbUrl"),[]),r=function(t,n){e("<img/>").on("load",function(){t.find(".elfinder-cwd-icon").addClass(n.className).css("background-image","url('"+n.url+"')")}).attr("src",n.url)},o=function(n,o){var s,l,d=e("#"+t.cwdHash2Id(n)),c=[];d.length&&t.isInWindow(d,!0)&&("1"!=o?(s=t.file(n),s.tmb!==o&&(s.tmb=o),l=t.tmb(s),i?t.reloadContents(l.url).done(function(){d.find(".elfinder-cwd-icon").addClass(l.className).css("background-image","url('"+l.url+"')")}):r(d,l)):i?c.push(n):J.getTmbs.push(n),a.push(n)),e.each(a,function(e,t){delete J.attachTmbs[t]}),i?le(c):J.getTmbs.length&&le(),Object.keys(J.attachTmbs).length<1&&J.getTmbs.length<1&&(ve.off(X,se),t.unbind("resize",se))};e.isPlainObject(n)&&Object.keys(n).length?(e.extend(J.attachTmbs,n),e.each(n,o)):(J.attachThumbTm&&clearTimeout(J.attachThumbTm),J.attachThumbTm=setTimeout(function(){e.each(J.attachTmbs,o)},0))},le=function(n){var i=[],a=!1;if(!J.gettingTmb||n){if(n||(J.gettingTmb=!0),t.oldAPI)return void t.request({data:{cmd:"tmb",current:t.cwd().hash},preventFail:!0}).done(function(e){J.gettingTmb=!1,e.images&&Object.keys(e.images).length&&se(e.images),e.tmb&&le()}).fail(function(){J.gettingTmb=!1});n?(a=!0,i=n.splice(0,w)):i=J.getTmbs.splice(0,w),i.length&&(a||t.isInWindow(e("#"+t.cwdHash2Id(i[0])),!0)||t.isInWindow(e("#"+t.cwdHash2Id(i[i.length-1])),!0)?t.request({data:{cmd:"tmb",targets:i},preventFail:!0}).done(function(e){J.gettingTmb=!1,e.images&&Object.keys(e.images).length&&se(e.images,a),a?n.length&&le(n):J.getTmbs.length&&le()}).fail(function(){J.gettingTmb=!1}):(e.each(i,function(e,t){J.attachTmbs[t]="1"}),J.gettingTmb=!1,se()))}},de=function(n,i){var o,s,l,d,c,u=r?ge.find("tbody"):ge,h=n.length,p={},f={},m=function(e){for(var n,i=ge.find("[id]:first");i.length;){if(n=t.file(t.cwdId2Hash(i.attr("id"))),!i.hasClass("elfinder-cwd-parent")&&n&&t.compare(e,n)<0)return i;i=i.next("[id]")}},g=function(e){var n,i=G.length;for(n=0;i>n;n++)if(t.compare(e,G[n])<0)return n;return i||-1},v=!!e.htmlPrefilter,b=e(v?document.createDocumentFragment():"<div/>");if(h>ee)me(),_=n.concat(),$();else{for(h&&Ce.removeClass("elfinder-cwd-wrapper-empty");h--;)o=n[h],s=o.hash,e("#"+t.cwdHash2Id(s)).length||((l=m(o))&&!l.length&&(l=null),!l&&(c=g(o))>=0?G.splice(c,0,o):(b.empty().append(j(o)),"directory"===o.mime&&!a&&oe(b),d=v?b:b.children(),l?l.before(d):u.append(d)),e("#"+t.cwdHash2Id(s)).length&&"directory"!==o.mime&&o.tmb&&(1==o.tmb?f[s]=o.tmb:p[s]=o.tmb));ae(),pe(u),(Object.keys(p).length||Object.keys(f).length)&&(Object.keys(J.attachTmbs).length<1&&(ve.off(X,se).on(X,se),t.unbind("resize",se).bind("resize",se)),e.extend(J.attachTmbs,p,f),Object.keys(p).length&&se(p,"change"===i&&"resize"===t.currentReqCmd),Object.keys(f).length&&se(f))}},ce=function(n){var i,a,r,o=n.length;if(!t.cwd().hash&&"open"!==t.currentReqCmd)return void e.each(C.reverse(),function(e,n){return t.files()[n]?(t.one(t.currentReqCmd+"done",function(e,t){!t.cwd().hash&&t.exec("open",n)}),!1):void 0});for(;o--;)if(i=n[o],(a=e("#"+t.cwdHash2Id(i))).length)try{a.remove(),--J.renderd}catch(s){t.debug("error",s)}else-1!=(r=Y(i))&&G.splice(r,1);ae()},ue={name:t.i18n("name"),perm:t.i18n("perms"),date:t.i18n("modify"),size:t.i18n("size"),kind:t.i18n("kind"),modestr:t.i18n("mode"),modeoct:t.i18n("mode"),modeboth:t.i18n("mode")},he=function(){for(var i="",a="",r=e.extend({},ue,n.listView.columnsCustomName),o=0;o<A.length;o++)i="undefined"!=typeof r[A[o]]?r[A[o]]:t.i18n(A[o]),a+='<td class="elfinder-cwd-view-th-'+A[o]+' sortable-item">'+i+"</td>";return a},pe=function(e,t){var n,i=1;e=e||(r?ge.find("tbody"):ge),G.length>0&&(e.css({height:"auto"}),n=e.height(),t&&(r||(i=Math.floor(e.width()/e.find("[id]:first").width()),t=Math.ceil(t/i)*i),J.hpi=n/t,J.row=J.hpi*i),be.css({top:J.hpi*G.length+n+"px"}).show())},fe={contextmenu:function(e){e.preventDefault(),t.trigger("contextmenu",{type:"cwd",targets:[t.cwd().hash],x:e.pageX,y:e.pageY})},touchstart:function(e){e.originalEvent.touches.length>1||(ge.data("longtap",null),ve.data("touching",{x:e.originalEvent.touches[0].pageX,y:e.originalEvent.touches[0].pageY}),e.target!==this&&e.target!==ge.get(0)||ge.data("tmlongtap",setTimeout(function(){ge.data("longtap",!0),t.trigger("contextmenu",{type:"cwd",targets:[t.cwd().hash],x:ve.data("touching").x,y:ve.data("touching").y})},500)))},touchend:function(e){"touchmove"===e.type&&(!ve.data("touching")||Math.abs(ve.data("touching").x-e.originalEvent.touches[0].pageX)+Math.abs(ve.data("touching").y-e.originalEvent.touches[0].pageY)>4)&&ve.data("touching",null),clearTimeout(ge.data("tmlongtap"))},click:function(e){ge.data("longtap")&&(e.preventDefault(),e.stopPropagation())}},me=function(){var n;Ce.append(ye).removeClass("elfinder-cwd-wrapper-empty elfinder-search-result elfinder-incsearch-result"),(t.searchStatus.state>1||t.searchStatus.ininc)&&Ce.addClass("elfinder-search-result"+(t.searchStatus.ininc?" elfinder-incsearch-result":"")),H=e();try{ge.empty()}catch(i){ge.html("")}ne&&(ve.off("scroll.fixheader resize.fixheader"),ne.remove(),ne=null),ge.removeClass("elfinder-cwd-view-icons elfinder-cwd-view-list").addClass("elfinder-cwd-view-"+(r?"list":"icons")).attr("style","").css("height","auto"),be.hide(),ve[r?"addClass":"removeClass"]("elfinder-cwd-wrapper-list")._padding=parseInt(ve.css("padding-top"))+parseInt(ve.css("padding-bottom")),t.UA.iOS&&ve.removeClass("overflow-scrolling-touch").addClass("overflow-scrolling-touch"),r&&(ge.html("<table><thead/><tbody/></table>"),n=e('<tr class="ui-state-default"><td class="elfinder-cwd-view-th-name">'+ue.name+"</td>"+he()+"</tr>"),ge.find("thead").hide().append(n.on("contextmenu."+t.namespace,fe.contextmenu).on("touchstart."+t.namespace,"td",fe.touchstart).on("touchmove."+t.namespace+" touchend."+t.namespace+" mouseup."+t.namespace,"td",fe.touchend).on("click."+t.namespace,"td",fe.click)).find("td:first").append(ye),e.fn.sortable&&n.addClass("touch-punch touch-punch-keep-default").sortable({axis:"x",distance:8,items:"> .sortable-item",start:function(t,n){e(n.item[0]).data("dragging",!0),n.placeholder.width(n.helper.removeClass("ui-state-hover").width()).removeClass("ui-state-active").addClass("ui-state-hover").css("visibility","visible")},update:function(n,i){var a,r,o=e(i.item[0]).attr("class").split(" ")[0].replace("elfinder-cwd-view-th-","");A=e.map(e(this).children(),function(t){var n=e(t).attr("class").split(" ")[0].replace("elfinder-cwd-view-th-","");return r||(o===n?r=!0:a=n),"name"===n?null:n}),D.row=S(),t.storage("cwdCols",A),a=".elfinder-col-"+a+":first",o=".elfinder-col-"+o+":first",t.lazy(function(){ge.find("tbody tr").each(function(){var t=e(this);t.children(a).after(t.children(o))})})},stop:function(t,n){setTimeout(function(){e(n.item[0]).removeData("dragging")},100)}}),e.fn.resizable&&n.find("td").addClass("touch-punch").resizable({handles:"ltr"===t.direction?"e":"w",start:function(t,n){var i=ge.find("td.elfinder-col-"+n.element.attr("class").split(" ")[0].replace("elfinder-cwd-view-th-","")+":first");n.element.data("resizeTarget",i).data("targetWidth",i.width()),M=!0,"fixed"!==ge.find("table").css("table-layout")&&(ge.find("tbody tr:first td").each(function(){e(this).width(e(this).width())}),ge.find("table").css("table-layout","fixed"))},resize:function(e,t){t.element.data("resizeTarget").width(t.element.data("targetWidth")-(t.originalSize.width-t.size.width))},stop:function(){M=!1,ie({fitWidth:!0}),O={},ge.find("tbody tr:first td").each(function(){var t=e(this).attr("class").split(" ")[0].replace("elfinder-col-","");O[t]=e(this).width()}),t.storage("cwdColWidth",O)}}).find(".ui-resizable-handle").addClass("ui-icon ui-icon-grip-dotted-vertical")),t.lazy(function(){G=e.map(z||T,function(e){return t.file(e)||null}),G=t.sortFiles(G),J={renderd:0,attachTmbs:{},getTmbs:[],lazyOpts:{tm:0}},Ce[G.length<1?"addClass":"removeClass"]("elfinder-cwd-wrapper-empty"),ve.off(X,te).on(X,te).trigger(X),t.cwd().write?(ve[t.isCommandEnabled("upload")?"addClass":"removeClass"]("native-droppable"),ve.droppable("enable")):ve.removeClass("native-droppable").droppable("disable").removeClass("ui-state-disabled")})},ge=e(this).addClass("ui-helper-clearfix elfinder-cwd").attr("unselectable","on").on("click."+t.namespace,h,function(n){var i,a,r,l,d,c=this.id?e(this):e(this).parents("[id]:first"),u=e(n.target);if(U&&(u.is("input:checkbox")||u.hasClass("elfinder-cwd-select")))return n.stopPropagation(),n.preventDefault(),ve.data("touching")||(c.trigger(c.hasClass(p)?s:o),$()),setTimeout(function(){u.prop("checked",c.hasClass(p))},10),!1;if(ge.data("longtap"))return void n.stopPropagation();if(n.shiftKey&&(i=c.prevAll(V||"."+p+":first"),a=c.nextAll(V||"."+p+":first"),r=i.length,l=a.length),n.shiftKey&&(r||l))d=r?c.prevUntil("#"+i.attr("id")):c.nextUntil("#"+a.attr("id")),d.add(c).trigger(o);else if(n.ctrlKey||n.metaKey)c.trigger(c.hasClass(p)?s:o);else{if(ve.data("touching")&&c.hasClass(p))return ve.data("touching",null),void t.dblclick({file:t.cwdId2Hash(this.id)});B(),c.trigger(o)}$()}).on("dblclick."+t.namespace,h,function(e){t.dblclick({file:t.cwdId2Hash(this.id)})}).on("touchstart."+t.namespace,h,function(n){if(!(n.originalEvent.touches.length>1)){var i,a=this.id?e(this):e(this).parents("[id]:first"),r=e(n.target);return ve.data("touching",{x:n.originalEvent.touches[0].pageX,y:n.originalEvent.touches[0].pageY}),U&&(r.is("input:checkbox")||r.hasClass("elfinder-cwd-select"))?void setTimeout(function(){ve.data("touching")&&(a.trigger(a.hasClass(p)?s:o),$())},150):void("INPUT"!=n.target.nodeName&&"TEXTAREA"!=n.target.nodeName&&(i=a.prevAll("."+p+":first").length+a.nextAll("."+p+":first").length,ge.data("longtap",null),a.addClass(v).data("tmlongtap",setTimeout(function(){ge.data("longtap",!0),("TD"!=n.target.nodeName||t.selected().length>0)&&(a.trigger(o),$(),t.trigger("contextmenu",{type:"files",targets:t.selected(),x:n.originalEvent.touches[0].pageX,y:n.originalEvent.touches[0].pageY}))},500))))}}).on("touchmove."+t.namespace+" touchend."+t.namespace,h,function(n){if("INPUT"!=n.target.nodeName&&"TEXTAREA"!=n.target.nodeName&&!e(n.target).hasClass("elfinder-cwd-select")){var i=this.id?e(this):e(this).parents("[id]:first");clearTimeout(i.data("tmlongtap")),"touchmove"===n.type?(ve.data("touching",null),i.removeClass(v)):ve.data("touching")&&!ge.data("longtap")&&i.hasClass(p)&&(n.preventDefault(),ve.data("touching",null),t.dblclick({file:t.cwdId2Hash(this.id)}))}}).on("mouseenter."+t.namespace,h,function(n){var i=e(this),s=null,l=r?i:i.children("div.elfinder-cwd-file-wrapper,div.elfinder-cwd-filename");a||i.hasClass(y)||l.hasClass(m)||l.hasClass(f)||l.on("mousedown",function(n){n.shiftKey&&!t.UA.IE&&ge.data("selectable")&&(ge.selectable("destroy").data("selectable",!1),setTimeout(function(){ge.selectable(Z).data("selectable",!0)},10)),l.draggable("option","disabled",n.shiftKey).removeClass("ui-state-disabled"),n.shiftKey?l.attr("draggable","true"):l.removeAttr("draggable").draggable("option","cursorAt",{left:50-parseInt(e(n.currentTarget).css("margin-left")),top:47})}).on("dragstart",function(n){var i=n.dataTransfer||n.originalEvent.dataTransfer||null;if(s=null,i&&!t.UA.IE){var a,r=this.id?e(this):e(this).parents("[id]:first"),l=e("<span>"),d="",c=null,u=null,h=[],p=function(n){var i,a=n.mime,r=t.tmb(n);return i='<div class="elfinder-cwd-icon '+t.mime2class(a)+' ui-corner-all"/>',r&&(i=e(i).addClass(r.className).css("background-image","url('"+r.url+"')").get(0).outerHTML),i},f=[];if(r.trigger(o),$(),e.each(_,function(n,i){var a=t.file(i),r=a.url;if(a&&"directory"!==a.mime){if(r){if("1"==r)return f.push(i),!0}else r=t.url(a.hash);r&&(r=t.convAbsUrl(r),h.push(i),e("<a>").attr("href",r).text(r).appendTo(l),d+=r+"\n",c||(c=a.mime+":"+a.name+":"+r),u||(u=r+"\n"+a.name))}}),f.length)return e.each(f,function(e,n){var i=t.file(n);i.url="",t.request({data:{cmd:"url",target:n},notify:{type:"url",cnt:1},preventDefault:!0}).always(function(e){i.url=e.url?e.url:"1"})}),!1;if(!d)return!1;i.setDragImage&&(s=e('<div class="elfinder-drag-helper html5-native"></div>').append(p(t.file(h[0]))).appendTo(e(document.body)),(a=h.length)>1&&s.append(p(t.file(h[a-1]))+'<span class="elfinder-drag-num">'+a+"</span>"),i.setDragImage(s.get(0),50,47)),i.effectAllowed="copyLink",i.setData("DownloadURL",c),i.setData("text/x-moz-url",u),i.setData("text/uri-list",d),i.setData("text/plain",d),i.setData("text/html",l.html()),i.setData("elfinderfrom",window.location.href+t.cwd().hash),i.setData("elfinderfrom:"+i.getData("elfinderfrom"),"")}}).on("dragend",function(e){B(),s&&s.remove()}).draggable(t.draggable)}).on(o,h,function(n){var i=e(this),a=t.cwdId2Hash(i.attr("id"));N||i.hasClass(f)||(V="#"+this.id,i.addClass(p).children().addClass(v).find("input:checkbox").prop("checked",!0),-1===e.inArray(a,_)&&_.push(a),H=ge.find("[id]."+p+":last").next())}).on(s,h,function(n){var i,a=e(this),r=t.cwdId2Hash(a.attr("id"));N||(a.removeClass(p).children().removeClass(v).find("input:checkbox").prop("checked",!1),ge.hasClass("elfinder-cwd-allselected")&&(U&&ye.children("input").prop("checked",!1),ge.removeClass("elfinder-cwd-allselected")),i=e.inArray(r,_),-1!==i&&(V=void 0,_.splice(i,1)))}).on(l,h,function(){var t=e(this).removeClass(v+" "+p).addClass(f),n=t.children(),i=r?t:n.find("div.elfinder-cwd-file-wrapper,div.elfinder-cwd-filename");n.removeClass(v+" "+p),t.hasClass(g)&&t.droppable("disable"),i.hasClass(m)&&i.draggable("disable")}).on(d,h,function(){var t=e(this).removeClass(f),n=r?t:t.children("div.elfinder-cwd-file-wrapper,div.elfinder-cwd-filename");t.hasClass(g)&&t.droppable("enable"),n.hasClass(m)&&n.draggable("enable")}).on("scrolltoview",h,function(){K(e(this),!0)}).on("mouseenter."+t.namespace+" mouseleave."+t.namespace,h,function(n){t.trigger("hover",{hash:t.cwdId2Hash(e(this).attr("id")),type:n.type}),e(this).toggleClass(v,"mouseenter"==n.type)}).on("contextmenu."+t.namespace,function(n){var i=e(n.target).closest("."+u);i.length&&("TD"!=n.target.nodeName||e.inArray(t.cwdId2Hash(i.get(0).id),t.selected())>-1)&&(n.stopPropagation(),n.preventDefault(),i.hasClass(f)||ve.data("touching")||(i.hasClass(p)||(B(),i.trigger(o),$()),t.trigger("contextmenu",{type:"files",targets:t.selected(),x:n.pageX,y:n.pageY})))}).on("click."+t.namespace,function(e){e.target!==this||ge.data("longtap")||!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&B()}).on("create."+t.namespace,function(n,i){var a=r?ge.find("tbody"):ge,o=a.find(".elfinder-cwd-parent"),s=i.move||!1,i=e(j(i)).addClass(y),l=t.selected();l.length?s&&t.trigger("lockfiles",{files:l}):B(),o.length?o.after(i):a.prepend(i),ae(),ve.scrollTop(0).scrollLeft(0)}).on("unselectall",B).on("selectfile",function(n,i){e("#"+t.cwdHash2Id(i)).trigger(o),$()}).on("colwidth",function(){r&&(ge.find("table").css("table-layout","").find("td").css("width",""),ie({fitWidth:!0}),t.storage("cwdColWidth",O=null))}),ve=e('<div class="elfinder-cwd-wrapper"/>').droppable(e.extend({},re,{autoDisable:!1})).on("contextmenu."+t.namespace,fe.contextmenu).on("touchstart."+t.namespace,fe.touchstart).on("touchmove."+t.namespace+" touchend."+t.namespace,fe.touchend).on("click."+t.namespace,fe.click).on("scroll."+t.namespace,function(){J.seltm&&clearTimeout(J.seltm),J.scrtm&&clearTimeout(J.scrtm),J.scrtm&&Math.abs((J.scrolltop||0)-(J.scrolltop=e(this).scrollTop()))<2?(J.scrtm=0,ve.trigger(X)):J.scrtm=setTimeout(function(){J.scrtm=0,ve.trigger(X)},100)}),be=e("<div>&nbsp;</div>").css({position:"absolute",width:"1px",height:"1px"}).hide(),ye=U?e('<div class="elfinder-cwd-selectall"><input type="checkbox"/></div>').attr("title",t.i18n("selectall")).on("touchstart mousedown click",function(t){return t.stopPropagation(),t.preventDefault(),e(this).data("pending")||"click"===t.type?!1:(ye.data("pending",!0),void(ge.hasClass("elfinder-cwd-allselected")?(ye.find("input").prop("checked",!1),setTimeout(function(){B()},10)):W()))}):e(),we=null,ke=function(t){
  1818. var n=function(){var t=0;ve.siblings("div.elfinder-panel:visible").each(function(){t+=e(this).outerHeight(!0)}),ve.height(Ce.height()-t-ve._padding)};t&&n(),we&&clearTimeout(we),we=setTimeout(function(){!t&&n();var e,i;ge.css("height","auto"),e=ve[0].clientHeight-parseInt(ve.css("padding-top"))-parseInt(ve.css("padding-bottom"))-parseInt(ge.css("margin-top")),i=ge.outerHeight(!0),e>i&&ge.height(e)},20),r&&!M&&ie()},xe=e(this).parent().resize(ke),Ce=xe.children(".elfinder-workzone").append(ve.append(this).append(be));R=e.extend(R,n.replacement||{});try{O=t.storage("cwdColWidth")?t.storage("cwdColWidth"):null}catch(Te){O=null}(A=t.storage("cwdCols"))?(A=e.map(A,function(e){return-1!==n.listView.columns.indexOf(e)?e:null}),n.listView.columns.length>A.length&&e.each(n.listView.columns,function(e,t){-1===A.indexOf(t)&&A.push(t)})):A=n.listView.columns,D.row=S(),a&&e("body").on("touchstart touchmove touchend",function(e){}),U&&ge.addClass("elfinder-has-checkbox"),e(window).on("scroll."+t.namespace,function(){i&&clearTimeout(i),i=setTimeout(function(){ve.trigger(X)},50)}),e(document).on("keydown."+t.namespace,function(n){n.keyCode==e.ui.keyCode.ESCAPE&&(t.getUI().find(".ui-widget:visible").length||B())}),t.one("init",function(){var n,i,r,o,s=document.createElement("style");document.head.appendChild(s),n=s.sheet,n.insertRule('.elfinder-cwd-wrapper-empty .elfinder-cwd:after{ content:"'+t.i18n("emptyFolder")+'" }',0),n.insertRule('.elfinder-cwd-wrapper-empty .ui-droppable .elfinder-cwd:after{ content:"'+t.i18n("emptyFolder"+(a?"LTap":"Drop"))+'" }',1),n.insertRule('.elfinder-cwd-wrapper-empty .ui-droppable-disabled .elfinder-cwd:after{ content:"'+t.i18n("emptyFolder")+'" }',2),n.insertRule('.elfinder-cwd-wrapper-empty.elfinder-search-result .elfinder-cwd:after{ content:"'+t.i18n("emptySearch")+'" }',3),n.insertRule('.elfinder-cwd-wrapper-empty.elfinder-search-result.elfinder-incsearch-result .elfinder-cwd:after{ content:"'+t.i18n("emptyIncSearch")+'" }',3),a||(ge.selectable(Z).data("selectable",!0),i=function(){ge.data("selectable")&&(J.seltm&&clearTimeout(J.seltm),J.seltm=0,ge.selectable("enable").selectable("refresh"))},ve.on(X,function(){ge.off("mousedown",i).one("mousedown",i),J.seltm=setTimeout(function(){ge.off("mousedown",i),i()},2e3)}),o=e('<div style="position:absolute"/>'),r=t.getUI(),r.on("resize",function(e,t){var n;t&&t.fullscreen&&(n=r.offset(),"on"===t.fullscreen?(o.css({top:-1*n.top,left:-1*n.left}).appendTo(r),Z.appendTo=o):(o.detach(),Z.appendTo="body"),ge.selectable("option",{appendTo:Z.appendTo})),i()}))}).bind("open add remove searchend",function(){var n=t.cwd().hash;T=e.map(t.files(),function(e){return e.phash==n?e.hash:null})}).bind("open",function(){C=t.parents(t.cwd().hash),z=void 0,B(),me(),ke()}).bind("search",function(n){T=e.map(n.data.files,function(e){return e.hash}),z=void 0,t.searchStatus.ininc=!1,me(),t.autoSync("stop"),ke()}).bind("searchend",function(e){(k||z)&&(k="",z&&t.trigger("incsearchend",e.data),e.data&&e.data.noupdate||me()),t.autoSync(),ke()}).bind("searchstart",function(e){B(),k=e.data.query}).bind("incsearchstart",function(n){_=[],t.lazy(function(){if(k=n.data.query||""){var i=new RegExp(k.replace(/([\\*\;\.\?\[\]\{\}\(\)\^\$\-\|])/g,"\\$1"),"i");z=e.map(T,function(e){var n=t.file(e);return n&&(n.name.match(i)||n.i18&&n.i18.match(i))?n.hash:null}),t.trigger("incsearch",{hashes:z,query:k}).searchStatus.ininc=!0,me(),t.autoSync("stop")}else t.trigger("incsearchend");ke()})}).bind("incsearchend",function(e){k="",t.searchStatus.ininc=!1,z=void 0,e.data&&e.data.noupdate||me(),t.autoSync()}).bind("sortchange",function(){var e=ve.scrollLeft();me(),t.one("cwdrender",function(){ve.scrollLeft(e),_.length&&$(),ke()})}).bind("viewchange",function(){var e="list"==t.storage("view"),n=ge.hasClass("elfinder-cwd-allselected");e!=r&&(r=e,t.viewType=r?"list":"icons",me(),n&&(ge.addClass("elfinder-cwd-allselected"),ye.find("input").prop("checked",!0)),_.length&&$()),ke()}).bind("wzresize",function(){var n,i=r?ge.find("tbody"):ge;ke(!0),J.hpi&&pe(i,i.find("[id]").length),n=ge.offset(),Ce.data("rectangle",e.extend({width:Ce.width(),height:Ce.height(),cwdEdge:"ltr"===t.direction?n.left:n.left+ge.width()},Ce.offset())),J.itemH=(r?i.find("tr:first"):i.find("[id]:first")).outerHeight(!0)}).bind("changeclipboard",function(t){x={},t.data&&t.data.clipboard&&t.data.clipboard.length&&e.each(t.data.clipboard,function(e,t){t.cut&&(x[t.hash]=!0)})}).bind("resMixinMake",function(){ae()}).bind("tmbreload",function(t){var n={},i=t.data&&t.data.files?t.data.files:null;e.each(i,function(e,t){t.tmb&&"1"!=t.tmb&&(n[t.hash]=t.tmb)}),Object.keys(n).length&&se(n,!0)}).add(function(n){var i=t.cwd().hash,a=k?new RegExp(k.replace(/([\\*\;\.\?\[\]\{\}\(\)\^\$\-\|])/g,"\\$1"),"i"):null,o=a?e.map(n.data.added||[],function(e){return t.searchStatus.ininc&&e.phash!=i||!(e.name.match(a)||e.i18&&e.i18.match(a))?null:e}):e.map(n.data.added||[],function(e){return e.phash==i?e:null});de(o),r&&ke(),ve.trigger(X)}).change(function(n){var i=t.cwd().hash,a=t.selected();k?e.each(n.data.changed||[],function(t,n){ce([n.hash]),-1!==n.name.indexOf(k)&&(de([n],"change"),-1!==e.inArray(n.hash,a)&&L(n.hash))}):e.each(e.map(n.data.changed||[],function(e){return e.phash==i?e:null}),function(t,n){ce([n.hash]),de([n],"change"),-1!==e.inArray(n.hash,a)&&L(n.hash)}),$()}).remove(function(e){var t=r?ge.find("tbody"):ge;ce(e.data.removed||[]),$(),G.length<1&&t.children().length<1?(Ce.addClass("elfinder-cwd-wrapper-empty"),U&&ye.find("input").prop("checked",!1),be.hide(),ve.off(X,te),ke()):(pe(t),ve.trigger(X))}).dragstart(function(t){var n=e(t.data.target),i=t.data.originalEvent;n.hasClass(h.substr(1))&&(n.hasClass(p)||(!(i.ctrlKey||i.metaKey||i.shiftKey)&&B(),n.trigger(o),$())),ge.selectable("disable").removeClass(f),N=!0}).dragstop(function(){ge.selectable("enable"),N=!1}).bind("lockfiles unlockfiles selectfiles unselectfiles",function(n){var i,a,r,c,u={lockfiles:l,unlockfiles:d,selectfiles:o,unselectfiles:s},h=u[n.type],p=n.data.files||[],f=p.length,m=n.data.helper||e();if(f>0&&(i=t.parents(p[0])),h!==o&&h!==s||(r=h===o,c=r?_.concat():_,e.each(p,function(t,n){var i=e.inArray(n,c),a=ge.hasClass("elfinder-cwd-allselected");-1===i?r&&_.push(n):(a&&(U&&ye.children("input").prop("checked",!1),ge.removeClass("elfinder-cwd-allselected"),a=!1),!r&&_.splice(i,1))})),!m.data("locked")){for(;f--;)e("#"+t.cwdHash2Id(p[f])).trigger(h);!n.data.inselect&&$()}ve.data("dropover")&&-1!==i.indexOf(ve.data("dropover"))&&(a="lockfiles"!==n.type,m.toggleClass("elfinder-drag-helper-plus",a),ve.toggleClass(b,a))}).bind("mkdir mkfile duplicate upload rename archive extract paste multiupload",function(n){if("upload"!=n.type||!n.data._multiupload){var i=t.cwd().hash;B(),e.each((n.data.added||[]).concat(n.data.changed||[]),function(e,t){t&&t.phash==i&&L(t.hash)}),$()}}).shortcut({pattern:"ctrl+a",description:"selectall",callback:W}).shortcut({pattern:"left right up down shift+left shift+right shift+up shift+down",description:"selectfiles",type:"keydown",callback:function(e){q(e.keyCode,e.shiftKey)}}).shortcut({pattern:"home",description:"selectffile",callback:function(e){B(),K(ge.find("[id]:first").trigger(o)),$()}}).shortcut({pattern:"end",description:"selectlfile",callback:function(e){B(),K(ge.find("[id]:last").trigger(o)),$()}}).shortcut({pattern:"page_up",description:"pageTurning",callback:function(e){J.itemH&&ve.scrollTop(Math.round(ve.scrollTop()-Math.floor((ve.height()+(r?-1*J.itemH:16))/J.itemH)*J.itemH))}}).shortcut({pattern:"page_down",description:"pageTurning",callback:function(e){J.itemH&&ve.scrollTop(Math.round(ve.scrollTop()+Math.floor((ve.height()+(r?-1*J.itemH:16))/J.itemH)*J.itemH))}})}),this},e.fn.elfinderdialog=function(t,n){var i,a,r=-1!=window.navigator.platform.indexOf("Win");return n&&n.ui?a=n.getUI():(a=this.closest(".elfinder"),n||(n=a.elfinder("instance"))),"string"==typeof t?((i=this.closest(".ui-dialog")).length&&("open"==t?"none"==i.css("display")&&i.fadeIn(120,function(){i.trigger("open")}):"close"==t||"destroy"==t?(i.stop(!0),(i.is(":visible")||a.is(":hidden"))&&i.hide().trigger("close"),"destroy"==t&&i.remove()):"toTop"==t?i.trigger("totop"):"posInit"==t?i.trigger("posinit"):"tabstopsInit"==t&&i.trigger("tabstopsInit")),this):(t=e.extend({},e.fn.elfinderdialog.defaults,t),t.allowMinimize&&"auto"===t.allowMinimize&&(t.allowMinimize=!!this.find("textarea,input").length),t.headerBtnPos&&"auto"===t.headerBtnPos&&(t.headerBtnPos=r?"right":"left"),t.headerBtnOrder&&"auto"===t.headerBtnOrder&&(t.headerBtnOrder=r?"close:maximize:minimize":"close:minimize:maximize"),t.modal&&t.allowMinimize&&(t.allowMinimize=!1),this.filter(":not(.ui-dialog-content)").each(function(){var i=e(this).addClass("ui-dialog-content ui-widget-content"),o="elfinder-dialog-active",s="elfinder-dialog",l="elfinder-dialog-notify",d="ui-state-hover",c="elfinder-tabstop",u="elfinder-focus",h=parseInt(1e6*Math.random()),p=e('<div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix"><span class="elfinder-dialog-title">'+t.title+"</span></div>"),f=e('<div class="ui-dialog-buttonset"/>'),m=e('<div class=" ui-helper-clearfix ui-dialog-buttonpane ui-widget-content"/>').append(f),g=0,v=0,b=e(),y=function(){b=T.find("."+c),b.length&&(b.attr("tabindex","-1"),b.filter("."+u).length||f.children("."+c+":"+(r?"first":"last")).addClass(u))},w=function(t){var n=b.filter(":visible"),i=t?null:n.filter("."+u+":first");return i&&i.length||(i=n.first()),t&&e.each(n,function(e,a){return a===t&&n[e+1]?(i=n.eq(e+1),!1):void 0}),i},k=function(t){var n=b.filter(":visible"),i=n.last();return e.each(n,function(e,a){return a===t&&n[e-1]?(i=n.eq(e-1),!1):void 0}),i},x=function(){e.each(t.headerBtnOrder.split(":").reverse(),function(e,t){C[t]&&C[t]()}),r&&p.children(".elfinder-titlebar-button").addClass("elfinder-titlebar-button-right")},C={close:function(){p.prepend(e('<span class="ui-widget-header ui-dialog-titlebar-close ui-corner-all elfinder-titlebar-button"><span class="ui-icon ui-icon-closethick"/></span>').on("mousedown",function(e){e.preventDefault(),e.stopPropagation(),i.elfinderdialog("close")}))},maximize:function(){t.allowMaximize&&(T.on("resize",function(e,t){var n,a;if(t&&t.maximize){if(a=p.find(".elfinder-titlebar-full"),n="on"===t.maximize,a.children("span.ui-icon").toggleClass("ui-icon-plusthick",!n).toggleClass("ui-icon-arrowreturnthick-1-s",n),n){try{T.hasClass("ui-draggable")&&T.draggable("disable"),T.hasClass("ui-resizable")&&T.resizable("disable")}catch(e){}"undefined"==typeof a.data("style")&&(i.height(i.height()),a.data("style",i.attr("style")||"")),i.css("width","100%").css("height",T.height()-T.children(".ui-dialog-titlebar").outerHeight(!0)-m.outerHeight(!0))}else{i.attr("style",a.data("style")),a.removeData("style");try{T.hasClass("ui-draggable")&&T.draggable("enable"),T.hasClass("ui-resizable")&&T.resizable("enable")}catch(e){}}T.trigger("resize")}}),p.prepend(e('<span class="ui-widget-header ui-corner-all elfinder-titlebar-button elfinder-titlebar-full"><span class="ui-icon ui-icon-plusthick"/></span>').on("mousedown",function(e){e.preventDefault(),e.stopPropagation(),n.toggleMaximize(T)})))},minimize:function(){t.allowMinimize&&p.on("dblclick",function(t){e(this).children(".elfinder-titlebar-minimize").trigger("mousedown")}).prepend(e('<span class="ui-widget-header ui-corner-all elfinder-titlebar-button elfinder-titlebar-minimize"><span class="ui-icon ui-icon-minusthick"/></span>').on("mousedown",function(t){var i,r=e(this);if(t.preventDefault(),t.stopPropagation(),"undefined"!=typeof r.data("style"))a.append(T),T.attr("style",r.data("style")).removeClass("elfinder-dialog-minimized").off("mousedown.minimize"),r.removeData("style").show(),p.children(".elfinder-titlebar-full").show(),T.children(".ui-widget-content").slideDown("fast",function(){var e;if(this===T.children(".ui-widget-content:first").get(0)){if(T.find("."+n.res("class","editing"))&&n.disable(),e={minimize:"off"},T.hasClass("elfinder-maximized"))e.maximize="on";else try{T.hasClass("ui-draggable")&&T.draggable("enable"),T.hasClass("ui-resizable")&&T.resizable("enable")}catch(t){}T.trigger("resize",e)}});else{try{T.hasClass("ui-draggable")&&T.draggable("disable"),T.hasClass("ui-resizable")&&T.resizable("disable")}catch(t){}r.data("style",T.attr("style")||"").hide(),p.children(".elfinder-titlebar-full").hide(),i=T.width(),T.children(".ui-widget-content").slideUp("fast",function(){this===T.children(".ui-widget-content:first").get(0)&&(T.trigger("resize",{minimize:"on"}),T.attr("style","").css({maxWidth:i}).addClass("elfinder-dialog-minimized").one("mousedown.minimize",function(e){r.trigger("mousedown")}).appendTo(n.getUI("bottomtray")))})}}))}},T=e('<div class="ui-front ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable std42-dialog touch-punch '+s+" "+t.cssClass+'"/>').hide().append(i).appendTo(a).draggable({handle:".ui-dialog-titlebar",containment:"document",stop:function(e,n){T.css({height:t.height}),i.data("draged",!0)}}).css({width:t.width,height:t.height}).on("mousedown",function(e){T.hasClass("ui-front")||setTimeout(function(){T.is(":visible:not(.elfinder-dialog-minimized)")&&T.trigger("totop")},10)}).on("open",function(){var r=e(this),d=r.outerWidth()>a.width()-10?a.width()-10:null;d&&r.css({width:d,left:"5px"}),T.hasClass(l)||a.children("."+s+":visible:not(."+l+")").each(function(){var t=e(this),n=parseInt(t.css("top")),i=parseInt(t.css("left")),a=parseInt(T.css("top")),r=parseInt(T.css("left"));t[0]==T[0]||n!=a&&i!=r||T.css({top:n+(d?15:10)+"px",left:(d?5:i+10)+"px"})}),T.data("modal")&&n.getUI("overlay").elfinderoverlay("show"),T.trigger("totop"),"function"==typeof t.open&&e.proxy(t.open,i[0])(),n.UA.Mobile&&w().focus(),t.closeOnEscape&&e(document).on("keyup."+h,function(t){t.keyCode==e.ui.keyCode.ESCAPE&&T.hasClass(o)&&i.elfinderdialog("close")})}).on("close",function(){var r;t.closeOnEscape&&e(document).off("keyup."+h),t.allowMaximize&&n.toggleMaximize(T,!1),T.data("modal")&&n.getUI("overlay").elfinderoverlay("hide"),"function"==typeof t.close?e.proxy(t.close,i[0])():t.destroyOnClose&&T.hide().remove(),r=a.children("."+s+":visible"),r.length?r.filter(":last").trigger("totop"):setTimeout(function(){n.enable()},20)}).on("totop",function(){T.hasClass("elfinder-dialog-minimized")&&p.children(".elfinder-titlebar-minimize").trigger("mousedown"),n.toFront(T),a.children("."+s).removeClass(o+" ui-front"),T.addClass(o+" ui-front"),!n.UA.Mobile&&w().focus()}).on("posinit",function(){var e=t.position;e||T.data("resizing")||(e={top:Math.max(0,parseInt((a.height()-T.outerHeight())/2-42))+"px",left:Math.max(0,parseInt((a.width()-T.outerWidth())/2))+"px"}),t.absolute&&(e.position="absolute"),e&&T.css(e)}).on("resize",function(n,a){"function"==typeof t.resize&&e.proxy(t.resize,i[0])(n,a)}).on("tabstopsInit",y).on("focus","."+c,function(){e(this).addClass(d).parent("label").addClass(d),this.id&&e(this).parent().find("label[for="+this.id+"]").addClass(d)}).on("blur","."+c,function(){e(this).removeClass(d).parent("label").removeClass(d),this.id&&e(this).parent().find("label[for="+this.id+"]").removeClass(d)}).on("mouseenter mouseleave","."+c,function(n){var i=e(this);t.btnHoverFocus?"mouseenter"==n.type&&i.focus():i.toggleClass(d,"mouseenter"==n.type)}).on("keydown","."+c,function(t){var n=e(this);if(n.is(":focus"))if(t.stopPropagation(),t.keyCode==e.ui.keyCode.ENTER)t.preventDefault(),n.click();else if(t.keyCode==e.ui.keyCode.TAB&&t.shiftKey||t.keyCode==e.ui.keyCode.LEFT||t.keyCode==e.ui.keyCode.UP){if(n.is("input:text")&&!t.ctrlKey&&!t.metaKey&&t.keyCode==e.ui.keyCode.LEFT)return;if(n.is("select")&&t.keyCode!=e.ui.keyCode.TAB)return;if(n.is("textarea")&&!t.ctrlKey&&!t.metaKey)return;t.preventDefault(),k(this).focus()}else if(t.keyCode==e.ui.keyCode.TAB||t.keyCode==e.ui.keyCode.RIGHT||t.keyCode==e.ui.keyCode.DOWN){if(n.is("input:text")&&!t.ctrlKey&&!t.metaKey&&t.keyCode==e.ui.keyCode.RIGHT)return;if(n.is("select")&&t.keyCode!=e.ui.keyCode.TAB)return;if(n.is("textarea")&&!t.ctrlKey&&!t.metaKey)return;t.preventDefault(),w(this).focus()}}).data({modal:t.modal});T.prepend(p),x(),e.each(t.buttons,function(t,n){var a=e('<button type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only elfinder-btncnt-'+v++ +" "+c+'"><span class="ui-button-text">'+t+"</span></button>").on("click",e.proxy(n,i[0]));r?f.append(a):f.prepend(a)}),f.children().length&&(T.append(m),T.show(),m.find("button").each(function(t,n){g+=e(n).outerWidth(!0)}),T.hide(),g+=20,T.width()<g&&T.width(g)),T.trigger("posinit").data("margin-y",i.outerHeight(!0)-i.height()),t.resizable&&e.fn.resizable&&T.resizable({minWidth:t.minWidth,minHeight:t.minHeight,start:function(){T.data("resizing")!==!0&&T.data("resizing")&&clearTimeout(T.data("resizing")),T.data("resizing",!0)},stop:function(){T.data("resizing",setTimeout(function(){T.data("resizing",!1)},200))},resize:function(t,n){var a=0;T.children(".ui-widget-header,.ui-dialog-buttonpane").each(function(){a+=e(this).outerHeight(!0)}),i.height(n.size.height-a-T.data("margin-y")),T.trigger("resize")}}),"function"==typeof t.create&&e.proxy(t.create,this)(),y(),t.autoOpen&&i.elfinderdialog("open")}),this)},e.fn.elfinderdialog.defaults={cssClass:"",title:"",modal:!1,resizable:!0,autoOpen:!0,closeOnEscape:!0,destroyOnClose:!1,buttons:{},btnHoverFocus:!0,position:null,absolute:!1,width:320,height:"auto",minWidth:200,minHeight:110,allowMinimize:"auto",allowMaximize:!1,headerBtnPos:"auto",headerBtnOrder:"auto"},e.fn.elfinderfullscreenbutton=function(t){return this.each(function(){var n=e(this).elfinderbutton(t),i=n.children(".elfinder-button-icon");t.change(function(){var e=t.value;i.toggleClass("elfinder-button-icon-unfullscreen",e),n.attr("title",e?t.fm.i18n("reinstate"):t.fm.i18n("cmdfullscreen")),t.className=e?"unfullscreen":"",t.title=t.fm.i18n(e?"reinstate":"cmdfullscreen")})})},e.fn.elfindermkdirbutton=function(t){return this.each(function(){var n=e(this).elfinderbutton(t);t.change(function(){n.attr("title",t.value)})})},e.fn.elfindernavbar=function(t,n){return this.not(".elfinder-navbar").each(function(){var i,a,r,o,s=e(this).hide().addClass("ui-state-default elfinder-navbar"),l=s.parent(),d=l.children(".elfinder-workzone").append(s),c=s.outerHeight()-s.height(),u="ltr"==t.direction,h=function(){var n=t.getUI("cwd"),i=t.getUI("workzone"),a=i.data("rectangle"),r=n.offset();i.data("rectangle",e.extend(a,{cwdEdge:"ltr"===t.direction?r.left:r.left+n.width()}))};t.one("cssloaded",function(){var e=c;c=s.outerHeight()-s.height(),e!==c&&t.trigger("wzresize")}).bind("wzresize",function(){s.height(d.height()-c)}),t.UA.Touch&&(r=t.storage("autoHide")||{},"undefined"==typeof r.navbar&&(r.navbar=n.autoHideUA&&n.autoHideUA.length>0&&e.map(n.autoHideUA,function(e){return t.UA[e]?!0:null}).length,t.storage("autoHide",r)),r.navbar&&t.one("init",function(){t.uiAutoHide.push(function(){s.stop(!0,!0).trigger("navhide",{duration:"slow",init:!0})})}),t.bind("load",function(){a=e('<div class="elfinder-navbar-swipe-handle"/>').hide().appendTo(d),"none"!==a.css("pointer-events")&&(a.remove(),a=null)}),s.on("navshow navhide",function(n,i){var o="navshow"===n.type?"show":"hide",l=i&&i.duration?i.duration:"fast",d=i&&i.handleW?i.handleW:Math.max(50,t.getUI().width()/10);s.stop(!0,!0)[o](l,function(){"show"===o?a&&a.stop(!0,!0).hide():a&&(a.width(d?d:""),t.resources.blink(a,"slowonce")),t.trigger("navbar"+o).getUI("cwd").trigger("resize"),i.init&&t.trigger("uiautohide"),h()}),r.navbar="show"!==o,t.storage("autoHide",e.extend(t.storage("autoHide"),{navbar:r.navbar}))})),e.fn.resizable&&!t.UA.Mobile&&(i=s.resizable({handles:u?"e":"w",minWidth:n.minWidth||150,maxWidth:n.maxWidth||500,stop:function(e,n){t.storage("navbarWidth",n.size.width),h()}}).on("resize scroll",function(n){u||"resize"!==n.type||s.css("left",0),clearTimeout(e(this).data("posinit")),e(this).data("posinit",setTimeout(function(){var e=t.UA.Opera&&s.scrollLeft()?20:2;i.css({top:parseInt(s.scrollTop())+"px",left:u?"auto":parseInt(s.scrollLeft()+e),right:u?-1*parseInt(s.scrollLeft()-e):"auto"}),"resize"===n.type&&t.getUI("cwd").trigger("resize")},50))}).find(".ui-resizable-handle").addClass("ui-front"),t.one("open",function(){setTimeout(function(){s.trigger("resize")},150)})),(o=t.storage("navbarWidth"))?s.width(o):t.UA.Mobile&&t.one("cssloaded",function(){s.data("defWidth",s.width()),e(window).on("resize."+t.namespace,function(e){o=s.parent().width()/2,s.data("defWidth")>o?s.width(o):s.width(s.data("defWidth")),s.data("width",s.width())})})}),this},e.fn.elfinderoverlay=function(t){var n=this.parent().elfinder("instance");if(this.filter(":not(.elfinder-overlay)").each(function(){t=e.extend({},t),e(this).addClass("ui-front ui-widget-overlay elfinder-overlay").hide().mousedown(function(e){e.preventDefault(),e.stopPropagation()}).data({cnt:0,show:"function"==typeof t.show?t.show:function(){},hide:"function"==typeof t.hide?t.hide:function(){}})}),"show"==t){var i=this.eq(0),a=i.data("cnt")+1,r=i.data("show");n.toFront(i),i.data("cnt",a),i.is(":hidden")&&(i.show(),r())}if("hide"==t){var i=this.eq(0),a=i.data("cnt")-1,o=i.data("hide");i.data("cnt",a),0>=a&&(i.hide(),o())}return this},e.fn.elfinderpanel=function(t){return this.each(function(){var n=e(this).addClass("elfinder-panel ui-state-default ui-corner-all"),i="margin-"+("ltr"==t.direction?"left":"right");t.one("load",function(e){var a=t.getUI("navbar");n.css(i,parseInt(a.outerWidth(!0))),a.on("resize",function(){n.is(":visible")&&n.css(i,parseInt(a.outerWidth(!0)))})})})},e.fn.elfinderpath=function(t){return this.each(function(){var n="",a="",r=[],o="statusbar",s=t.res("class","hover"),l="path"+(i.prototype.uniqueid?i.prototype.uniqueid:"")+"-",d=e('<div class="ui-widget-header ui-helper-clearfix elfinder-workzone-path"/>'),c=e(this).addClass("elfinder-path").html("&nbsp;").on("mousedown","span.elfinder-path-dir",function(i){var a=e(this).attr("id").substr(l.length);i.preventDefault(),a!=t.cwd().hash&&(e(this).addClass(s),n?t.exec("search",n,{target:a,mime:r.join(" ")}):t.exec("open",a))}).prependTo(t.getUI("statusbar").show()),u=e('<div class="elfinder-path-roots"/>').on("click",function(n){n.stopPropagation(),n.preventDefault();var i=e.map(t.roots,function(e){return t.file(e)}),a=[];e.each(i,function(e,n){n.phash||t.root(t.cwd().hash,!0)===n.hash||a.push({label:t.escape(n.i18||n.name),icon:"home",callback:function(){t.exec("open",n.hash)},options:{iconClass:n.csscls||"",iconImg:n.icon||""}})}),t.trigger("contextmenu",{raw:a,x:n.pageX,y:n.pageY})}).append('<span class="elfinder-button-icon elfinder-button-icon-menu" />').appendTo(d),h=function(n){var i=[];return e.each(t.parents(n),function(e,a){var r=n===a?"elfinder-path-dir elfinder-path-cwd":"elfinder-path-dir",o=t.file(a),s=t.escape(o.i18||o.name);i.push('<span id="'+l+a+'" class="'+r+'" title="'+s+'">'+s+"</span>")}),i.join('<span class="elfinder-path-other">'+t.option("separator")+"</span>")},p=function(){var n;c.children("span.elfinder-path-dir").attr("style",""),n="ltr"===t.direction?e("#"+l+t.cwd().hash).prevAll("span.elfinder-path-dir:first"):e(),c.scrollLeft(n.length?n.position().left:0)},f=function(){var t,n,i=c.children("span.elfinder-path-dir"),a=i.length;return"workzone"===o||2>a?void i.attr("style",""):(c.width(c.css("max-width")),i.css({maxWidth:100/a+"%",display:"inline-block"}),t=c.width()-9,c.children("span.elfinder-path-other").each(function(){t-=e(this).width()}),n=[],i.each(function(i){var a=e(this),r=a.width();t-=r,r<this.scrollWidth&&n.push(i)}),c.width(""),void(n.length?(t>0&&(t/=n.length,e.each(n,function(n,a){var r=e(i[a]);r.css("max-width",r.width()+t)})),i.last().attr("style","")):i.attr("style","")))};t.bind("open searchend parents",function(){n="",a="",r=[],c.html(h(t.cwd().hash)),Object.keys(t.roots).length>1?(c.css("margin",""),u.show()):(c.css("margin",0),u.hide()),f()}).bind("searchstart",function(e){e.data&&(n=e.data.query||"",a=e.data.target||"",r=e.data.mimes||[])}).bind("search",function(e){var n="";n=a?h(a):t.i18n("btnAll"),c.html('<span class="elfinder-path-other">'+t.i18n("searcresult")+": </span>"+n),f()}).bind("navbarshow navbarhide",function(e){var n=t.getUI("workzone");"navbarshow"===e.type?(n.height(n.height()+d.outerHeight()),c.prependTo(t.getUI("statusbar")),d.detach(),o="statusbar",t.unbind("open",p)):(d.append(c).insertBefore(n),n.height(n.height()-d.outerHeight()),o="workzone",p(),t.bind("open",p)),t.trigger("uiresize")}).bind("resize",f)})},e.fn.elfinderplaces=function(t,n){return this.each(function(){var i={},a="class",r=t.res(a,"navdir"),o=t.res(a,"navcollapse"),s=t.res(a,"navexpand"),l=t.res(a,"hover"),d=t.res(a,"treeroot"),c=t.res(a,"adroppable"),u=t.res("tpl","placedir"),h=t.res("tpl","perms"),p=e(t.res("tpl","navspinner")),f="places"+(n.suffix?n.suffix:""),m=null,g=function(e){return e.substr(6)},v=function(e){return"place-"+e},b=function(){var n=[],a={};n=e.map(S.children().find("[id]"),function(e){return g(e.id)}),n.length?e.each(n.reverse(),function(e,t){a[t]=i[t]}):a=null,t.storage(f,a)},y=function(n,i){return e(u.replace(/\{id\}/,v(n?n.hash:i)).replace(/\{name\}/,t.escape(n?n.i18||n.name:i)).replace(/\{cssclass\}/,n?t.perms2class(n)+(n.notfound?" elfinder-na":"")+(n.csscls?" "+n.csscls:""):"").replace(/\{permissions\}/,!n||n.read&&n.write&&!n.notfound?"":h).replace(/\{title\}/,n&&n.path?t.escape(n.path):"").replace(/\{symlink\}/,"").replace(/\{style\}/,""))},w=function(e){var n,a;return"directory"!==e.mime?!1:(a=e.hash,t.files().hasOwnProperty(a)||t.trigger("tree",{tree:[e]}),n=y(e,a),i[a]=e,S.prepend(n),I.addClass(o),z.toggle(S.children().length>1),!0)},k=function(t){var n,a,r=null;return i[t]&&(delete i[t],n=e("#"+v(t)),n.length&&(r=n.text(),n.parent().remove(),a=S.children().length,z.toggle(a>1),a||(I.removeClass(o),U.removeClass(s),S.slideToggle(!1)))),r},x=function(n){var i=e("#"+v(n)),a=i.parent(),r=a.prev("div"),o="ui-state-hover",s=t.getUI("contextmenu");m&&clearTimeout(m),r.length&&(s.find(":first").data("placesHash",n),i.addClass(o),a.insertBefore(r),r=a.prev("div"),m=setTimeout(function(){i.removeClass(o),s.find(":first").data("placesHash")===n&&s.hide().empty()},1500)),r.length||(i.removeClass(o),s.hide().empty())},C=function(t,n){var a=t.hash,r=e("#"+v(n||a)),o=y(t,a);return r.length>0?(r.parent().replaceWith(o),i[a]=t,!0):!1},T=function(){e.each(i,function(n,i){var a=t.file(n)||i,o=y(a,n),s=null;return a||o.hide(),S.children().length&&(e.each(S.children(),function(){var t=e(this);return(a.i18||a.name).localeCompare(t.children("."+r).text())<0?s=!o.insertBefore(t):void 0}),null!==s)?!0:void(!e("#"+v(n)).length&&S.append(o))}),b()},z=e('<span class="elfinder-button-icon elfinder-button-icon-sort elfinder-places-root-icon" title="'+t.i18n("cmdsort")+'"/>').hide().on("click",function(e){e.stopPropagation(),S.empty(),T()}),A=y({hash:"root-"+t.namespace,name:t.i18n(n.name,"places"),read:!0,write:!0}),I=A.children("."+r).addClass(d).click(function(e){e.stopPropagation(),I.hasClass(o)&&(U.toggleClass(s),S.slideToggle(),t.storage("placesState",U.hasClass(s)?1:0))}).append(z),S=A.children("."+t.res(a,"navsubtree")),U=e(this).addClass(t.res(a,"tree")+" elfinder-places ui-corner-all").hide().append(A).appendTo(t.getUI("navbar")).on("mouseenter mouseleave","."+r,function(t){e(this).toggleClass("ui-state-hover","mouseenter"==t.type)}).on("click","."+r,function(n){var i=e(this);return i.data("longtap")?void n.stopPropagation():void(!i.hasClass("elfinder-na")&&t.exec("open",i.attr("id").substr(6)))}).on("contextmenu","."+r+":not(."+d+")",function(n){var i=e(this),a=i.attr("id").substr(6);n.preventDefault(),t.trigger("contextmenu",{raw:[{label:t.i18n("moveUp"),icon:"up",remain:!0,callback:function(){x(a),b()}},"|",{label:t.i18n("rmFromPlaces"),icon:"rm",callback:function(){k(a),b()}}],x:n.pageX,y:n.pageY}),i.addClass("ui-state-hover"),t.getUI("contextmenu").children().on("mouseenter",function(){i.addClass("ui-state-hover")}),t.bind("closecontextmenu",function(){i.removeClass("ui-state-hover")})}).droppable({tolerance:"pointer",accept:".elfinder-cwd-file-wrapper,.elfinder-tree-dir,.elfinder-cwd-file",hoverClass:t.res("class","adroppable"),classes:{"ui-droppable-hover":t.res("class","adroppable")},over:function(n,a){var r=a.helper,o=e.map(r.data("files"),function(e){return"directory"!==t.file(e).mime||i[e]?null:e});n.stopPropagation(),r.data("dropover",r.data("dropover")+1),t.insideWorkzone(n.pageX,n.pageY)&&(o.length>0?(r.addClass("elfinder-drag-helper-plus"),t.trigger("unlockfiles",{files:r.data("files"),helper:r})):e(this).removeClass(c))},out:function(n,i){var a=i.helper,r=n.shiftKey||n.ctrlKey||n.metaKey;n.stopPropagation(),a.toggleClass("elfinder-drag-helper-move elfinder-drag-helper-plus",a.data("locked")?!0:r).data("dropover",Math.max(a.data("dropover")-1,0)),e(this).removeData("dropover").removeClass(c),t.trigger(r?"unlockfiles":"lockfiles",{files:a.data("files"),helper:a})},drop:function(n,a){var r=a.helper,o=!0;e.each(r.data("files"),function(e,n){var a=t.file(n);a&&"directory"==a.mime&&!i[a.hash]?w(a):o=!1}),b(),o&&r.hide()}}).on("touchstart","."+r+":not(."+d+")",function(n){if(!(n.originalEvent.touches.length>1))var i=e(this).attr("id").substr(6),a=e(this).addClass(l).data("longtap",null).data("tmlongtap",setTimeout(function(){a.data("longtap",!0),t.trigger("contextmenu",{raw:[{label:t.i18n("rmFromPlaces"),icon:"rm",callback:function(){k(i),b()}}],x:n.originalEvent.touches[0].pageX,y:n.originalEvent.touches[0].pageY})},500))}).on("touchmove touchend","."+r+":not(."+d+")",function(t){clearTimeout(e(this).data("tmlongtap")),"touchmove"==t.type&&e(this).removeClass(l)});e.fn.sortable&&S.addClass("touch-punch").sortable({appendTo:t.getUI(),revert:!1,helper:function(n){var i=e(n.target).parent();return i.children().removeClass("ui-state-hover"),e('<div class="ui-widget elfinder-place-drag elfinder-'+t.direction+'"/>').append(e('<div class="elfinder-navbar"/>').show().append(i.clone()))},stop:function(t,n){var i=e(n.item[0]),a=U.offset().top,r=U.offset().left,o=U.width(),s=U.height(),l=t.pageX,d=t.pageY;l>r&&r+o>l&&d>a&&d+s>d||(k(g(i.children(":first").attr("id"))),b())},update:function(e,t){b()}}),e(this).on("regist",function(t,n){var a=!1;e.each(n,function(e,t){t&&"directory"==t.mime&&!i[t.hash]&&w(t)&&(a=!0)}),a&&b()}),t.one("load",function(){var n,a;t.oldAPI||(U.show().parent().show(),i={},n=t.storage(f),"string"==typeof n?(n=e.map(n.split(","),function(e){return e||null}),e.each(n,function(e,t){var n=t.split("#");i[n[0]]=n[1]?n[1]:n[0]})):e.isPlainObject(n)&&(i=n),t.trigger("placesload",{dirs:i,storageKey:f},!0),a=Object.keys(i),a.length&&(I.prepend(p),t.request({data:{cmd:"info",targets:a},preventDefault:!0}).done(function(n){var a={};e.each(n.files,function(e,t){var n=t.hash;a[n]=t}),e.each(i,function(t,n){w(a[t]||e.extend({notfound:!0},n))}),t.storage("placesState")>0&&I.click()}).always(function(){p.remove()})),t.change(function(t){var n=!1;e.each(t.data.changed,function(e,t){i[t.hash]&&("directory"!==t.mime?k(t.hash)&&(n=!0):C(t)&&(n=!0))}),n&&b()}).bind("rename",function(t){var n=!1;t.data.removed&&e.each(t.data.removed,function(e,i){t.data.added[e]&&C(t.data.added[e],i)&&(n=!0)}),n&&b()}).bind("rm paste",function(t){var n=[],i=!1;t.data.removed&&e.each(t.data.removed,function(e,t){var i=k(t);i&&n.push(i)}),n.length&&(i=!0),t.data.added&&n.length&&e.each(t.data.added,function(t,i){1!==e.inArray(i.name,n)&&"directory"==i.mime&&w(i)}),i&&b()}).bind("sync netmount",function(n){var a=Object.keys(i);a.length&&(I.prepend(p),t.request({data:{cmd:"info",targets:a},preventDefault:!0}).done(function(a){var r={},o=!1,s=t.cwd().hash;e.each(a.files||[],function(e,n){var i=n.hash;r[i]=n,t.files().hasOwnProperty(n.hash)||t.trigger("tree",{tree:[n]})}),e.each(i,function(t,i){!i.notfound!=!!r[t]?i.phash===s&&"netmount"!==n.type||r[t]&&"directory"!==r[t].mime?k(t)&&(o=!0):C(r[t]||e.extend({notfound:!0},i))&&(o=!0):r[t]&&r[t].phash!=s&&C(r[t])}),o&&b()}).always(function(){p.remove()}))}))})})},e.fn.elfindersearchbutton=function(t){return this.each(function(){
  1819. var n,i=!1,a=t.fm,r=t.options.incsearch||{enable:!1},o=function(e){return a.namespace+e},s=a.getUI("toolbar"),l=a.res("class","searchbtn"),d=e(this).hide().addClass("ui-widget-content elfinder-button "+l),c=function(){p.data("inctm")&&clearTimeout(p.data("inctm")),n&&n.slideUp();var r=e.trim(p.val()),s=!e("#"+o("SearchFromAll")).prop("checked"),l=e("#"+o("SearchMime")).prop("checked");s&&(s=e("#"+o("SearchFromVol")).prop("checked")?a.root(a.cwd().hash):a.cwd().hash),l&&(l=r,r="."),r?t.exec(r,s,l).done(function(){i=!0,p.focus()}).fail(function(){u()}):a.trigger("searchend")},u=function(){p.data("inctm")&&clearTimeout(p.data("inctm")),p.val("").blur(),(i||h)&&(i=!1,h="",a.lazy(function(){a.trigger("searchend")}))},h="",p=e('<input type="text" size="42"/>').on("focus",function(){h="",n&&n.slideDown()}).on("blur",function(){n&&(n.data("infocus")?n.data("infocus",!1):n.slideUp())}).appendTo(d).on("keypress",function(e){e.stopPropagation()}).on("keydown",function(t){t.stopPropagation(),t.keyCode==e.ui.keyCode.ENTER&&c(),t.keyCode==e.ui.keyCode.ESCAPE&&(t.preventDefault(),u())});r.enable&&(r.minlen=r.minlen||2,r.wait=r.wait||500,p.attr("title",a.i18n("incSearchOnly")).on("compositionstart",function(){p.data("composing",!0)}).on("compositionend",function(){p.removeData("composing"),p.trigger("input")}).on("input",function(){p.data("composing")||(p.data("inctm")&&clearTimeout(p.data("inctm")),p.data("inctm",setTimeout(function(){var e=p.val();(0===e.length||e.length>=r.minlen)&&(h!==e&&a.trigger("incsearchstart",{query:e}),h=e,""===e&&a.searchStatus.state>1&&a.searchStatus.query&&p.val(a.searchStatus.query).select())},r.wait)))}),a.UA.ltIE8&&p.on("keydown",function(e){229===e.keyCode&&(p.data("imetm")&&clearTimeout(p.data("imetm")),p.data("composing",!0),p.data("imetm",setTimeout(function(){p.removeData("composing")},100)))}).on("keyup",function(t){p.data("imetm")&&clearTimeout(p.data("imetm")),p.data("composing")?t.keyCode===e.ui.keyCode.ENTER&&p.trigger("compositionend"):p.trigger("input")})),e('<span class="ui-icon ui-icon-search" title="'+t.title+'"/>').appendTo(d).click(c),e('<span class="ui-icon ui-icon-close"/>').appendTo(d).click(u),a.bind("toolbarload",function(){var e=d.parent();if(e.length&&(s.prepend(d.show()),e.remove(),a.UA.ltIE7)){var t=d.children("ltr"==a.direction?".ui-icon-close":".ui-icon-search");t.css({right:"",left:parseInt(d.width())-t.outerWidth(!0)})}}),a.one("open",function(){n=a.api<2.1?null:e('<div class="ui-front ui-widget ui-widget-content elfinder-button-menu ui-corner-all"/>').append(e('<div class="buttonset"/>').append(e('<input id="'+o("SearchFromCwd")+'" name="serchfrom" type="radio" checked="checked"/><label for="'+o("SearchFromCwd")+'">'+a.i18n("btnCwd")+"</label>"),e('<input id="'+o("SearchFromVol")+'" name="serchfrom" type="radio"/><label for="'+o("SearchFromVol")+'">'+a.i18n("btnVolume")+"</label>"),e('<input id="'+o("SearchFromAll")+'" name="serchfrom" type="radio"/><label for="'+o("SearchFromAll")+'">'+a.i18n("btnAll")+"</label>")),e('<div class="buttonset"/>').append(e('<input id="'+o("SearchName")+'" name="serchcol" type="radio" checked="checked"/><label for="'+o("SearchName")+'">'+a.i18n("btnFileName")+"</label>"),e('<input id="'+o("SearchMime")+'" name="serchcol" type="radio"/><label for="'+o("SearchMime")+'">'+a.i18n("btnMime")+"</label>"))).hide().appendTo(d),n&&(n.find("div.buttonset").buttonset(),e("#"+o("SearchFromAll")).next("label").attr("title",a.i18n("searchTarget",a.i18n("btnAll"))),e("#"+o("SearchMime")).next("label").attr("title",a.i18n("searchMime")),n.on("mousedown","div.buttonset",function(e){e.stopPropagation(),n.data("infocus",!0)}).on("click","input",function(t){t.stopPropagation(),e.trim(p.val())&&c()}))}).select(function(){p.blur()}).bind("searchend",function(){p.val("")}).bind("open parents",function(){var t=[],n=a.file(a.root(a.cwd().hash));n&&(e.each(a.parents(a.cwd().hash),function(e,n){t.push(a.file(n).name)}),e("#"+o("SearchFromCwd")).next("label").attr("title",a.i18n("searchTarget",t.join(a.option("separator")))),e("#"+o("SearchFromVol")).next("label").attr("title",a.i18n("searchTarget",n.name)))}).shortcut({pattern:"ctrl+f f3",description:t.title,callback:function(){p.select().focus()}})})},e.fn.elfindersortbutton=function(t){return this.each(function(){var n=t.fm,i=t.name,a="class",r=n.res(a,"disabled"),o=n.res(a,"hover"),s="elfinder-button-menu-item",l=s+"-selected",d=l+"-asc",c=l+"-desc",u=e('<span class="elfinder-button-text">'+t.title+"</span>"),h=e(this).addClass("ui-state-default elfinder-button elfinder-menubutton elfiner-button-"+i).attr("title",t.title).append('<span class="elfinder-button-icon elfinder-button-icon-'+i+'"/>',u).hover(function(e){!h.hasClass(r)&&h.toggleClass(o)}).click(function(e){h.hasClass(r)||(e.stopPropagation(),p.is(":hidden")&&t.fm.getUI().click(),p.slideToggle(100))}),p=e('<div class="ui-front ui-widget ui-widget-content elfinder-button-menu ui-corner-all"/>').hide().appendTo(h).on("mouseenter mouseleave","."+s,function(){e(this).toggleClass(o)}).on("click","."+s,function(e){e.preventDefault(),e.stopPropagation(),m()}),f=function(){p.children("[rel]").removeClass(l+" "+d+" "+c).filter('[rel="'+n.sortType+'"]').addClass(l+" "+("asc"==n.sortOrder?d:c)),p.children(".elfinder-sort-stick").toggleClass(l,n.sortStickFolders),p.children(".elfinder-sort-tree").toggleClass(l,n.sortAlsoTreeview)},m=function(){p.hide()};u.hide(),e.each(n.sortRules,function(t,i){p.append(e('<div class="'+s+'" rel="'+t+'"><span class="ui-icon ui-icon-arrowthick-1-n"/><span class="ui-icon ui-icon-arrowthick-1-s"/>'+n.i18n("sort"+t)+"</div>").data("type",t))}),p.children().click(function(i){var a=e(this).attr("rel");t.exec([],{type:a,order:a==n.sortType?"asc"==n.sortOrder?"desc":"asc":n.sortOrder,stick:n.sortStickFolders,tree:n.sortAlsoTreeview})}),e('<div class="'+s+" "+s+'-separated elfinder-sort-ext elfinder-sort-stick"><span class="ui-icon ui-icon-check"/>'+n.i18n("sortFoldersFirst")+"</div>").appendTo(p).click(function(){t.exec([],{type:n.sortType,order:n.sortOrder,stick:!n.sortStickFolders,tree:n.sortAlsoTreeview})}),e.fn.elfindertree&&-1!==e.inArray("tree",n.options.ui)&&e('<div class="'+s+" "+s+'-separated elfinder-sort-ext elfinder-sort-tree"><span class="ui-icon ui-icon-check"/>'+n.i18n("sortAlsoTreeview")+"</div>").appendTo(p).click(function(){t.exec([],{type:n.sortType,order:n.sortOrder,stick:n.sortStickFolders,tree:!n.sortAlsoTreeview})}),n.bind("disable select",m).getUI().click(m),n.bind("sortchange",f),p.children().length>1?t.change(function(){h.toggleClass(r,t.disabled()),f()}).change():h.addClass(r)})},e.fn.elfinderstat=function(t){return this.each(function(){var n=e(this).addClass("elfinder-stat-size"),i=e('<div class="elfinder-stat-selected"/>').on("click","a",function(n){var i=e(this).data("hash");n.preventDefault(),t.exec("opendir",[i])}),a=t.i18n("size"),r=t.i18n("items"),o=t.i18n("selected"),s=function(i,o){var s=0,l=0;e.each(i,function(e,t){o&&t.phash!=o||(s++,l+=parseInt(t.size)||0)}),n.html(r+': <span class="elfinder-stat-incsearch"></span>'+s+", "+a+": "+t.formatSize(l))},l=function(e){n.find("span.elfinder-stat-incsearch").html(e?e.hashes.length+" / ":"")},d=!1;t.getUI("statusbar").prepend(n).append(i).show(),t.bind("open reload add remove change searchend",function(){s(t.files(),t.cwd().hash)}).bind("searchend",function(){d=!1}).search(function(e){d=!0,s(e.data.files)}).select(function(){var n,r=0,s=0,l=t.selectedFiles(),c=[];return 1==l.length?(n=l[0],r=n.size,d&&c.push('<a href="#elf_'+n.phash+'" data-hash="'+n.hash+'">'+(n.path?n.path.replace(/\/[^\/]*$/,""):"..")+"</a>"),c.push(t.escape(n.name)),void i.html(c.join("/")+(r>0?", "+t.formatSize(r):""))):(e.each(l,function(e,t){s++,r+=parseInt(t.size)||0}),void i.html(s?o+": "+s+", "+a+": "+t.formatSize(r):"&nbsp;"))}).bind("incsearch",function(e){l(e.data)}).bind("incsearchend",function(){l()})})},e.fn.elfindertoast=function(t,n){var i={mode:"success",msg:"",showMethod:"fadeIn",showDuration:300,showEasing:"swing",onShown:void 0,hideMethod:"fadeOut",hideDuration:1500,hideEasing:"swing",onHidden:void 0,timeOut:3e3,extNode:void 0};return this.each(function(){t=e.extend({},i,t||{});var n,a=e(this),r=function(e){a.stop(),a[t.showMethod]({duration:t.showDuration,easing:t.showEasing,complete:function(){t.onShown&&t.onShown(),!e&&t.timeOut&&(n=setTimeout(o,t.timeOut))}})},o=function(){a[t.hideMethod]({duration:t.hideDuration,easing:t.hideEasing,complete:function(){t.onHidden&&t.onHidden(),a.remove()}})};a.on("click",function(e){e.stopPropagation(),e.preventDefault(),a.stop().remove()}).on("mouseenter mouseleave",function(e){t.timeOut&&(n&&clearTimeout(n),n=null,"mouseenter"===e.type?r(!0):n=setTimeout(o,t.timeOut))}).hide().addClass("toast-"+t.mode).append(e('<div class="elfinder-toast-msg"/>').html(t.msg)),t.extNode&&a.append(t.extNode),r()})},e.fn.elfindertoolbar=function(t,n){return this.not(".elfinder-toolbar").each(function(){var i,a,r,o,s,l,d,c,u=t._commands,h=e(this).addClass("ui-helper-clearfix ui-widget-header ui-corner-top elfinder-toolbar"),p={displayTextLabel:!1,labelExcludeUA:["Mobile"],autoHideUA:["Mobile"]},f=function(t){return e.map(t,function(t){return e.isPlainObject(t)?(p=e.extend(p,t),null):[t]})},m=function(n){var l;for(e.each(g,function(e,t){t.detach()}),h.empty(),i=v.length;i--;)if(v[i]){for(o=e('<div class="ui-widget-content ui-corner-all elfinder-buttonset"/>'),a=v[i].length;a--;)l=v[i][a],n&&-1!==e.inArray(l,n)||!(r=u[l])||(s="elfinder"+r.options.ui,!g[l]&&e.fn[s]&&(g[l]=e("<div/>")[s](r)),g[l]&&(c&&g[l].find(".elfinder-button-text").show(),o.prepend(g[l])));o.children().length&&h.prepend(o),o.children(":gt(0)").before('<span class="ui-widget-content elfinder-toolbar-button-separator"/>')}!h.data("swipeClose")&&h.children().length?h.show():h.hide(),t.trigger("toolbarload").trigger("uiresize")},g={},v=f(n||[]),b=null,y="";c=t.storage("toolbarTextLabel"),c=null===c?p.displayTextLabel&&(!p.labelExcludeUA||!p.labelExcludeUA.length||!e.map(p.labelExcludeUA,function(e){return t.UA[e]?!0:null}).length):1==c,h.on("contextmenu",function(e){e.stopPropagation(),e.preventDefault(),t.trigger("contextmenu",{raw:[{label:t.i18n("textLabel"),icon:"accept",callback:function(){c=!c,h.height("").find(".elfinder-button-text")[c?"show":"hide"](),t.trigger("uiresize").storage("toolbarTextLabel",c?"1":"0")}}],x:e.pageX,y:e.pageY})}).on("touchstart",function(e){e.originalEvent.touches.length>1||(h.data("tmlongtap")&&clearTimeout(h.data("tmlongtap")),h.removeData("longtap").data("longtap",{x:e.originalEvent.touches[0].pageX,y:e.originalEvent.touches[0].pageY}).data("tmlongtap",setTimeout(function(){h.removeData("longtapTm").trigger({type:"contextmenu",pageX:h.data("longtap").x,pageY:h.data("longtap").y}).data("longtap",{longtap:!0})},500)))}).on("touchmove touchend",function(e){h.data("tmlongtap")&&(("touchend"===e.type||Math.abs(h.data("longtap").x-e.originalEvent.touches[0].pageX)+Math.abs(h.data("longtap").y-e.originalEvent.touches[0].pageY)>4)&&clearTimeout(h.data("tmlongtap")),h.removeData("longtapTm"))}).on("click",function(e){h.data("longtap")&&h.data("longtap").longtap&&(e.stopImmediatePropagation(),e.preventDefault())}).on("touchend click",".elfinder-button",function(e){h.data("longtap")&&h.data("longtap").longtap&&(e.stopImmediatePropagation(),e.preventDefault())}),h.prev().length&&h.parent().prepend(this),m(),t.bind("open sync select",function(n){var i,a,r=t.option("disabled");"select"===n.type&&(a=t.selected(),a.length&&(r=t.getDisabledCmds(a))),b&&b.toString()===r.sort().toString()||(m(r&&r.length?r:null),i=!0),b=r.concat().sort(),(i||y!==JSON.stringify(t.commandMap))&&(y=JSON.stringify(t.commandMap),i||e.each(e("div.elfinder-button"),function(){var t=e(this).data("origin");t&&e(this).after(t).detach()}),Object.keys(t.commandMap).length&&e.each(t.commandMap,function(n,i){var a,r=t._commands[i],o=r?"elfinder"+r.options.ui:null;o&&e.fn[o]&&(a=g[n],a&&(!g[i]&&e.fn[o]&&(g[i]=e("<div/>")[o](t._commands[i]),g[i]&&(c&&g[i].find(".elfinder-button-text").show(),r.extendsCmd&&g[i].children("span.elfinder-button-icon").addClass("elfinder-button-icon-"+r.extendsCmd))),g[i]&&(a.after(g[i]),g[i].data("origin",a.detach()))))}))}),t.UA.Touch&&(d=t.storage("autoHide")||{},"undefined"==typeof d.toolbar&&(d.toolbar=p.autoHideUA&&p.autoHideUA.length>0&&e.map(p.autoHideUA,function(e){return t.UA[e]?!0:null}).length,t.storage("autoHide",d)),d.toolbar&&t.one("init",function(){t.uiAutoHide.push(function(){h.stop(!0,!0).trigger("toggle",{duration:500,init:!0})})}),t.bind("load",function(){l=e('<div class="elfinder-toolbar-swipe-handle"/>').hide().appendTo(t.getUI()),"none"!==l.css("pointer-events")&&(l.remove(),l=null)}),h.on("toggle",function(n,i){var a=t.getUI("workzone"),r=h.is(":hidden"),o=a.height(),s=h.height(),c=h.outerHeight(!0),u=c-s,p=e.extend({step:function(e){a.height(o+(r?-1*(e+u):s-e)),t.trigger("resize")},always:function(){h.css("height",""),t.trigger("uiresize"),l&&(r?l.stop(!0,!0).hide():(l.height(i.handleH?i.handleH:""),t.resources.blink(l,"slowonce"))),i.init&&t.trigger("uiautohide")}},i);h.data("swipeClose",!r).stop(!0,!0).animate({height:"toggle"},p),d.toolbar=!r,t.storage("autoHide",e.extend(t.storage("autoHide"),{toolbar:d.toolbar}))}))}),this},e.fn.elfindertree=function(t,n){var i=t.res("class","tree");return this.not("."+i).each(function(){var a="class",r=t.UA.Mobile,o=t.res(a,"treeroot"),s=n.openRootOnLoad,l=n.openCwdOnOpen,d=t.res(a,"navsubtree"),c=t.res(a,"treedir"),u="span."+c,h=t.res(a,"navcollapse"),p=t.res(a,"navexpand"),f="elfinder-subtree-loaded",m=t.res(a,"navarrow"),g=t.res(a,"active"),v=t.res(a,"adroppable"),b=t.res(a,"hover"),y=t.res(a,"disabled"),w=t.res(a,"draggable"),k=t.res(a,"droppable"),x="elfinder-navbar-wrapper-root",C="elfinder-navbar-wrapper-pastable",T="elfinder-navbar-wrapper-uploadable",z=function(e){var t=B.offset().left;return e>=t&&e<=t+B.width()},A=t.droppable.drop,I=e.extend(!0,{},t.droppable,{over:function(n,i){var a,r,o=e(this),s=i.helper,l=b+" "+v;return n.stopPropagation(),s.data("dropover",s.data("dropover")+1),o.data("dropover",!0),i.helper.data("namespace")===t.namespace&&z(n.clientX)&&t.insideWorkzone(n.pageX,n.pageY)?(o.addClass(b),o.is("."+h+":not(."+p+")")&&o.data("expandTimer",setTimeout(function(){o.is("."+h+"."+b)&&o.children("."+m).click()},500)),o.is(".elfinder-ro,.elfinder-na")?(o.removeClass(v),void s.removeClass("elfinder-drag-helper-move elfinder-drag-helper-plus")):(a=t.navId2Hash(o.attr("id")),o.data("dropover",a),e.each(i.helper.data("files"),function(e,n){return n===a||t.file(n).phash===a&&!i.helper.hasClass("elfinder-drag-helper-plus")?(o.removeClass(l),!1):void 0}),s.data("locked")?r="elfinder-drag-helper-plus":(r="elfinder-drag-helper-move",(n.shiftKey||n.ctrlKey||n.metaKey)&&(r+=" elfinder-drag-helper-plus")),o.hasClass(v)&&s.addClass(r),void setTimeout(function(){o.hasClass(v)&&s.addClass(r)},20))):(o.removeClass(l),void s.removeClass("elfinder-drag-helper-move elfinder-drag-helper-plus"))},out:function(t,n){var i=e(this),a=n.helper;t.stopPropagation(),a.removeClass("elfinder-drag-helper-move elfinder-drag-helper-plus").data("dropover",Math.max(a.data("dropover")-1,0)),i.data("expandTimer")&&clearTimeout(i.data("expandTimer")),i.removeData("dropover").removeClass(b+" "+v)},deactivate:function(){e(this).removeData("dropover").removeClass(b+" "+v)},drop:function(e,t){z(e.clientX)&&A.call(this,e,t)}}),S=e(t.res("tpl","navspinner")),U=t.res("tpl","navdir"),M=t.res("tpl","perms"),O=(t.res("tpl","lock"),t.res("tpl","symlink")),D={id:function(e){return t.navHash2Id(e.hash)},cssclass:function(e){var i=(e.phash&&!e.isroot?"":o)+" "+c+" "+t.perms2class(e);return e.dirs&&!e.link&&(i+=" "+h),n.getClass&&(i+=" "+n.getClass(e)),e.csscls&&(i+=" "+t.escape(e.csscls)),i},permissions:function(e){return e.read&&e.write?"":M},symlink:function(e){return e.alias?O:""},style:function(e){return e.icon?"style=\"background:url('"+t.escape(e.icon)+"') 0 0 no-repeat;background-size:contain;\"":""}},F=function(e){return e.name=t.escape(e.i18||e.name),U.replace(/(?:\{([a-z]+)\})/gi,function(t,n){return e[n]||(D[n]?D[n](e):"")})},E=function(t){return e.map(t||[],function(e){return"directory"==e.mime?e:null})},P=function(n){return n?e("#"+t.navHash2Id(n)).next("."+d):W},R=function(n,i){for(var a,r=n.children(":first");r.length;){if(a=t.file(t.navId2Hash(r.children("[id]").attr("id"))),(a=t.file(t.navId2Hash(r.children("[id]").attr("id"))))&&H(i,a)<0)return r;r=r.next()}return e("")},j=function(n){for(var i,a,o,s,l,d,c=n.length,u=[],h=c,p=e(),f={},m={},g=!0;h--;)i=n[h],f[i.hash]||e("#"+t.navHash2Id(i.hash)).length||(f[i.hash]=!0,(a=P(i.phash)).length?i.phash&&((s=!a.children().length)||(o=R(a,i)).length)?s?(m[i.phash]||(m[i.phash]=[]),m[i.phash].push(i)):(d=F(i),o.before(d),!r&&(p=p.add(d))):(d=F(i),a[g||i.phash?"append":"prepend"](d),g=!1,i.phash&&!i.isroot||(l=e("#"+t.navHash2Id(i.hash)).parent().addClass(x),!i.disabled||i.disabled.length<1?l.addClass(C+" "+T):(-1===e.inArray("paste",i.disabled)&&l.addClass(C),-1===e.inArray("upload",i.disabled)&&l.addClass(T))),!r&&_(null,l)):u.push(i));return Object.keys(m).length&&e.each(m,function(n,i){var a=P(n),o=[];i.sort(H),e.each(i,function(e,t){o.push(F(t))}),a.append(o.join("")),!r&&t.lazy(function(){_(null,a)})}),u.length&&u.length<c?void j(u):void(!r&&p.length&&t.lazy(function(){_(p)}))},H=function(e,n){if(t.sortAlsoTreeview){var i,a="asc"==t.sortOrder,r=t.sortType,o=t.sortRules;return i=a?o[t.sortType](e,n):o[t.sortType](n,e),"name"!==r&&0===i?i=a?o.name(e,n):o.name(n,e):i}return t.sortRules.name(e,n)},N=function(n){var i=e(this),a=e.Deferred();return i.data("autoScrTm")&&clearTimeout(i.data("autoScrTm")),i.data("autoScrTm",setTimeout(function(){var i=e("#"+(n||t.navHash2Id(t.cwd().hash)));if(i.length){var r=W.parent().stop(!1,!0),o=r.offset().top,s=r.height(),l=o+s-i.outerHeight(),d=i.offset().top;o>d||d>l?r.animate({scrollTop:r.scrollTop()+d-o-s/3},{duration:"fast",complete:function(){a.resolve()}}):a.resolve()}else a.reject()},100)),a},q=function(i,a,r,c){var v,b,y,w,k,x,C=t.cwd(),T=C.hash,z=e("#"+t.navHash2Id(T)),i=i||!1,a=a||[],c=c||$,A="parents",I=[],U=function(e){var n=t.file(e);return!n||!n.isroot&&n.phash?"parents":"tree"},M=function(n,i){var a,r;D[n+i]||("tree"===n&&i!==T&&(a=e("#"+t.navHash2Id(i)),a.length&&(r=e(t.res("tpl","navspinner")).insertBefore(a.children("."+m)),a.removeClass(h))),D[n+i]=!0,I.push(t.request({data:{cmd:n,target:i},preventFail:!0}).done(function(){e("#"+t.navHash2Id("tree"===n?i:t.root(i))).addClass(f)}).always(function(){r&&(r.remove(),a.addClass(h+" "+p).next("."+d).show())})))},O=function(e){for(var n,i,a=t.root(e);a;)a&&(a=t.file(a))&&(n=a.phash)&&0!==n.indexOf(a.volumeid)?(i=U(n),"parents"===i&&M("tree",n),M(i,n),a=t.root(n)):a=null},D={};if(s&&(v=e("#"+t.navHash2Id(t.root())),v.hasClass(f)&&v.addClass(p).next("."+d).show(),s=!1),z.hasClass(g)||(W.find(u+"."+g).removeClass(g),z.addClass(g)),n.syncTree||!z.length){if(z.length&&(i||!r||!C.isroot))return i&&!r||(z.addClass(f),l&&z.hasClass(h)&&z.addClass(p).next("."+d).slideDown()),void(!c&&i||(w=z.parentsUntil("."+o).filter("."+d),k=w.length,x=1,w.show().prev(u).addClass(p,function(){!i&&k==x++&&N()}),!k&&!i&&N()));if(t.newAPI){if(b=t.file(T),b&&b.phash&&!b.isroot&&(y=e("#"+t.navHash2Id(b.phash)),y.length&&y.hasClass(f)))return void t.lazy(function(){j([b]),q(i,[],!1,c)});i||(C.isroot&&C.phash?(A="tree"===U(C.phash)?"tree":"parents",O(T),T=C.phash):C.phash?O(C.phash):A=null),A&&M(A,T),y=C.root?e("#"+t.navHash2Id(C.root)):null,y&&(S.insertBefore(y.children("."+m)),y.removeClass(h)),e.when.apply(e,I).done(function(n){var o,s,l;if(n||(n={tree:[]}),t.api<2.1&&n.tree.push(C),s=arguments.length,s>1)for(l=1;s>l;l++)arguments[l].tree&&arguments[l].tree.length&&n.tree.push.apply(n.tree,arguments[l].tree);o=E(n.tree),C.isroot&&C.hash===T&&!o.length&&(delete C.isroot,delete C.phash),a=JSON.parse(JSON.stringify(e.merge(a,o))),j(a),L(a,f),!i&&C.isroot&&e("#"+t.navHash2Id(C.hash).length)&&q(!0,[],r,c),T==C.hash&&t.visible()&&q(i,[],!1,c)}).always(function(){y&&(S.remove(),y.addClass(h+" "+f))})}}},_=function(n,i){var a,r=100;n||(i&&!i.closest("div."+x).hasClass(T)||(i||W.find("div."+T)).find(u+":not(.elfinder-ro,.elfinder-na)").addClass("native-droppable"),n=!i||i.closest("div."+x).hasClass(C)?(i||W.find("div."+C)).find(u+":not(."+k+")"):e()),n.length>r&&(a=n.slice(r),n=n.slice(0,r)),n.droppable(I),a&&t.lazy(function(){_(a)},20)},L=function(n,i){var a=i==f?"."+h+":not(."+f+")":":not(."+h+")";e.each(n,function(n,r){e("#"+t.navHash2Id(r.phash)+a).filter(function(){return e.map(e(this).next("."+d).children(),function(t){return e(t).children().hasClass(o)?null:t}).length>0}).addClass(i)})},W=e(this).addClass(i).on("mouseenter mouseleave",u,function(n){var i=e(this),a="mouseenter"==n.type;i.hasClass(v+" "+y)||(!r&&a&&!i.hasClass(o+" "+w+" elfinder-na elfinder-wo")&&i.draggable(t.draggable),i.toggleClass(b,a))}).on("dragenter",u,function(t){if(t.originalEvent.dataTransfer){var n=e(this);n.addClass(b),n.is("."+h+":not(."+p+")")&&n.data("expandTimer",setTimeout(function(){n.is("."+h+"."+b)&&n.children("."+m).click()},500))}}).on("dragleave",u,function(t){if(t.originalEvent.dataTransfer){var n=e(this);n.data("expandTimer")&&clearTimeout(n.data("expandTimer")),n.removeClass(b)}}).on("click",u,function(n){var i=e(this),a=t.navId2Hash(i.attr("id"));t.file(a);return i.data("longtap")?void n.stopPropagation():void(a==t.cwd().hash||i.hasClass(y)?(i.hasClass(h)&&i.children("."+m).click(),t.select({selected:[a],origin:"tree"})):t.exec("open",a).done(function(){t.select({selected:[a],origin:"tree"})}))}).on("touchstart",u,function(n){if(!(n.originalEvent.touches.length>1))var i=n.originalEvent,a=e(this).addClass(b).data("longtap",null).data("tmlongtap",setTimeout(function(e){a.data("longtap",!0),t.trigger("contextmenu",{type:"navbar",targets:[t.navId2Hash(a.attr("id"))],x:i.touches[0].pageX,y:i.touches[0].pageY})},500))}).on("touchmove touchend",u,function(t){clearTimeout(e(this).data("tmlongtap")),"touchmove"==t.type&&e(this).removeClass(b)}).on("click",u+"."+h+" ."+m,function(n){var i,a=e(this),r=a.parent(u),o=r.next("."+d),s=e.Deferred(),l=30;n.stopPropagation(),r.hasClass(f)?(r.toggleClass(p),t.lazy(function(){i=r.hasClass(p)?o.children().length+o.find("div.elfinder-navbar-subtree[style*=block]").children().length:o.find("div:visible").length,i>l?(o.toggle(),t.draggingUiHelper&&t.draggingUiHelper.data("refreshPositions",1)):o.stop(!0,!0).slideToggle("normal",function(){t.draggingUiHelper&&t.draggingUiHelper.data("refreshPositions",1)})}).always(function(){s.resolve()})):(S.insertBefore(a),r.removeClass(h),t.request({cmd:"tree",target:t.navId2Hash(r.attr("id"))}).done(function(e){j(JSON.parse(JSON.stringify(E(e.tree)))),o.children().length&&(r.addClass(h+" "+p),o.children().length>l?(o.show(),t.draggingUiHelper&&t.draggingUiHelper.data("refreshPositions",1)):o.stop(!0,!0).slideDown("normal",function(){t.draggingUiHelper&&t.draggingUiHelper.data("refreshPositions",1)})),q(!0)}).always(function(e){S.remove(),r.addClass(f),t.one("treedone",function(){s.resolve()})})),a.data("dfrd",s)}).on("contextmenu",u,function(n){var i=e(this);n.preventDefault(),t.trigger("contextmenu",{type:"navbar",targets:[t.navId2Hash(e(this).attr("id"))],x:n.pageX,y:n.pageY}),i.addClass("ui-state-hover"),t.getUI("contextmenu").children().on("mouseenter",function(){i.addClass("ui-state-hover")}),t.bind("closecontextmenu",function(){i.removeClass("ui-state-hover")})}).on("scrolltoview",u,function(){var n=e(this);N(n.attr("id")).done(function(){t.resources.blink(n,"lookme")})}).on("create."+t.namespace,function(n,i){var a=P(i.phash),r=i.move||!1,o=e(F(i)).addClass("elfinder-navbar-wrapper-tmp"),s=t.selected();r&&s.length&&t.trigger("lockfiles",{files:s}),a.prepend(o)}),B=t.getUI("navbar").append(W).show(),V=t.sortAlsoTreeview,$=!1;t.open(function(n){var i=n.data,a=E(i.files),r=t.getUI("contextmenu");i.init&&W.empty(),t.UA.iOS&&B.removeClass("overflow-scrolling-touch").addClass("overflow-scrolling-touch"),$=!0,a.length?t.lazy(function(){r.data("cmdMaps")||r.data("cmdMaps",{}),j(a),L(a,f),e.each(a,function(e,t){t.volumeid&&t.uiCmdMap&&Object.keys(t.uiCmdMap).length&&!r.data("cmdMaps")[t.volumeid]&&(r.data("cmdMaps")[t.volumeid]=t.uiCmdMap)}),q(!1,a,i.init),$=!1}):(q(!1,a,i.init),$=!1)}).add(function(e){var t=E(e.data.added);t.length&&(j(t),L(t,h))}).change(function(n){var i,a,o,s,l,c,h,m,g,v,b=E(n.data.changed),y=b.length,w=y;for(e();w--;)if(i=b[w],(a=e("#"+t.navHash2Id(i.hash))).length){if(v=a.parent(),i.phash){if(s=a.closest("."+d),l=P(i.phash),c=a.parent().next(),h=R(l,i),!l.length)continue;l[0]===s[0]&&c.get(0)===h.get(0)||(h.length?h.before(v):l.append(v))}m=a.hasClass(p),g=a.hasClass(f),o=e(F(i)),a.replaceWith(o.children(u)),!r&&_(null,v),i.dirs&&(m||g)&&(a=e("#"+t.navHash2Id(i.hash)))&&a.next("."+d).children().length&&(m&&a.addClass(p),g&&a.addClass(f))}t.cwd().hash&&q(!0)}).remove(function(n){for(var i,a,r=n.data.removed,o=r.length;o--;)(i=e("#"+t.navHash2Id(r[o]))).length&&(a=i.closest("."+d),i.parent().detach(),a.children().length||a.hide().prev(u).removeClass(h+" "+p+" "+f))}).bind("lockfiles unlockfiles",function(n){var i="lockfiles"==n.type,a=n.data.helper?n.data.helper.data("locked"):!1,r=i&&!a?"disable":"enable",o=e.map(n.data.files||[],function(e){var n=t.file(e);return n&&"directory"==n.mime?e:null});e.each(o,function(n,o){var s=e("#"+t.navHash2Id(o));s.length&&!a&&(s.hasClass(w)&&s.draggable(r),s.hasClass(k)&&s.droppable(r),s[i?"addClass":"removeClass"](y))})}).bind("sortchange",function(){if(t.sortAlsoTreeview||V!==t.sortAlsoTreeview){var e=E(t.files());V=t.sortAlsoTreeview,W.empty(),j(e),q()}})}),this},e.fn.elfinderuploadbutton=function(t){return this.each(function(){var n=e(this).elfinderbutton(t).off("click"),i=e("<form/>").appendTo(n),a=e('<input type="file" multiple="true" title="'+t.fm.i18n("selectForUpload")+'"/>').change(function(){var n=e(this);n.val()&&(t.exec({input:n.remove()[0]}),a.clone(!0).appendTo(i))}).on("dragover",function(e){e.originalEvent.dataTransfer.dropEffect="copy"});i.append(a.clone(!0)),t.change(function(){i[t.disabled()?"hide":"show"]()}).change()})},e.fn.elfinderviewbutton=function(t){return this.each(function(){var n=e(this).elfinderbutton(t),i=n.children(".elfinder-button-icon");t.change(function(){var e="icons"==t.value;i.toggleClass("elfinder-button-icon-view-list",e),t.className=e?"view-list":"",t.title=t.fm.i18n(e?"viewlist":"viewicons"),n.attr("title",t.title)})})},e.fn.elfinderworkzone=function(t){var n="elfinder-workzone";return this.not("."+n).each(function(){var i=e(this).addClass(n),a=i.outerHeight(!0)-i.height(),r=Math.round(i.height()),o=i.parent(),s=function(){var s=o.height()-a,l=o.attr("style"),d=Math.round(i.height());o.css("overflow","hidden").children(":visible:not(."+n+")").each(function(){var t=e(this);"absolute"!=t.css("position")&&"fixed"!=t.css("position")&&(s-=t.outerHeight(!0))}),o.attr("style",l||""),s=Math.max(0,Math.round(s)),r===s&&d===s||(r=Math.round(i.height()),i.height(s),t.trigger("wzresize"))};o.add(window).on("resize."+t.namespace,s),t.one("cssloaded",function(){var e=a;a=i.outerHeight(!0)-i.height(),e!==a&&t.trigger("uiresize")}).bind("uiresize",s)}),this},i.prototype.commands.archive=function(){var t,n=this,i=n.fm,a=[];this.variants=[],this.disableOnSearch=!1,i.bind("open reload",function(){n.variants=[],e.each(a=i.option("archivers").create||[],function(e,t){n.variants.push([t,i.mime2kind(t)])}),n.change()}),this.getstate=function(n){var r,n=this.files(n),o=n.length,s=o&&!i.isRoot(n[0])&&(i.file(n[0].phash)||{}).write&&!e.map(n,function(e){return e.read?null:!0}).length;return s&&i.searchStatus.state>1&&(r=i.cwd().volumeid,s=o===e.map(n,function(e){return e.read&&0===e.hash.indexOf(r)?e:null}).length),s&&!this._disabled&&a.length&&(o||t&&"pending"==t.state())?0:-1},this.exec=function(r,o){var s,l,d=this.files(r),c=d.length,u=o||a[0],h=i.file(d[0].phash)||null,p=["errArchive","errPerm","errCreatingTempDir","errFtpDownloadFile","errFtpUploadFile","errFtpMkdir","errArchiveExec","errExtractExec","errRm"];if(t=e.Deferred().fail(function(e){e&&i.error(e)}),!c||!a.length||-1===e.inArray(u,a))return t.reject();if(!h.write)return t.reject(p);for(s=0;c>s;s++)if(!d[s].read)return t.reject(p);return n.mime=u,n.prefix=(c>1?"Archive":d[0].name)+(i.option("archivers").createext?"."+i.option("archivers").createext[u]:""),n.data={targets:n.hashes(r),type:u},i.cwd().hash!==h.hash?l=i.exec("open",h.hash).done(function(){i.one("cwdrender",function(){i.selectfiles({files:r}),t=e.proxy(i.res("mixin","make"),n)()})}):(i.selectfiles({files:r}),t=e.proxy(i.res("mixin","make"),n)()),t}},(i.prototype.commands.back=function(){this.alwaysEnabled=!0,this.updateOnSelect=!1,this.shortcuts=[{pattern:"ctrl+left backspace"}],this.getstate=function(){return this.fm.history.canBack()?0:-1},this.exec=function(){return this.fm.history.back()}}).prototype={forceLoad:!0},i.prototype.commands.chmod=function(){this.updateOnSelect=!1;var t=this.fm,n={0:"owner",1:"group",2:"other"},i={read:t.i18n("read"),write:t.i18n("write"),execute:t.i18n("execute"),perm:t.i18n("perm"),kind:t.i18n("kind"),files:t.i18n("files")},a=function(e){return!isNaN(parseInt(e,8)&&parseInt(e,8)<=511)||e.match(/^([r-][w-][x-]){3}$/i)};this.tpl={main:'<div class="ui-helper-clearfix elfinder-info-title"><span class="elfinder-cwd-icon {class} ui-corner-all"/>{title}</div>{dataTable}',itemTitle:'<strong>{name}</strong><span id="elfinder-info-kind">{kind}</span>',groupTitle:"<strong>{items}: {num}</strong>",dataTable:'<table id="{id}-table-perm"><tr><td>{0}</td><td>{1}</td><td>{2}</td></tr></table><div class="">'+i.perm+': <input id="{id}-perm" type="text" size="4" maxlength="3" value="{value}"></div>',fieldset:'<fieldset id="{id}-fieldset-{level}"><legend>{f_title}{name}</legend><input type="checkbox" value="4" id="{id}-read-{level}-perm"{checked-r}> <label for="{id}-read-{level}-perm">'+i.read+'</label><br><input type="checkbox" value="6" id="{id}-write-{level}-perm"{checked-w}> <label for="{id}-write-{level}-perm">'+i.write+'</label><br><input type="checkbox" value="5" id="{id}-execute-{level}-perm"{checked-x}> <label for="{id}-execute-{level}-perm">'+i.execute+"</label><br>"},this.shortcuts=[{}],this.getstate=function(e){var t=this.fm;return e=e||t.selected(),0==e.length&&(e=[t.cwd().hash]),!this._disabled&&this.checkstate(this.files(e))?0:-1},this.checkstate=function(t){var n=t.length;if(!n)return!1;var i=e.map(t,function(e){return e.isowner&&e.perm&&a(e.perm)&&(1==n||"directory"!=e.mime)?e:null}).length;return n==i},this.exec=function(t){var r=this.files(t);r.length||(t=[this.fm.cwd().hash],r=this.files(t));var o,s,l=this.fm,d=e.Deferred().always(function(){l.enable()}),c=this.tpl,t=this.hashes(t),u=r.length,h=r[0],p=l.namespace+"-perm-"+h.hash,f=c.main,m=' checked="checked"',g=function(){var e={};return e[l.i18n("btnApply")]=v,e[l.i18n("btnCancel")]=function(){z.elfinderdialog("close")},e},v=function(){var n=e.trim(e("#"+p+"-perm").val());return a(n)?(z.elfinderdialog("close"),void l.request({data:{cmd:"chmod",targets:t,mode:n},notify:{type:"chmod",cnt:u}}).fail(function(e){d.reject(e)}).done(function(e){d.resolve(e)})):!1},b=function(){for(var t,i="",a=0;3>a;a++)t=0,e("#"+p+"-read-"+n[a]+"-perm").is(":checked")&&(t=4|t),e("#"+p+"-write-"+n[a]+"-perm").is(":checked")&&(t=2|t),e("#"+p+"-execute-"+n[a]+"-perm").is(":checked")&&(t=1|t),i+=t.toString(8);e("#"+p+"-perm").val(i)},y=function(t){for(var i,a=0;3>a;a++)i=parseInt(t.slice(a,a+1),8),e("#"+p+"-read-"+n[a]+"-perm").prop("checked",!1),e("#"+p+"-write-"+n[a]+"-perm").prop("checked",!1),e("#"+p+"-execute-"+n[a]+"-perm").prop("checked",!1),4==(4&i)&&e("#"+p+"-read-"+n[a]+"-perm").prop("checked",!0),2==(2&i)&&e("#"+p+"-write-"+n[a]+"-perm").prop("checked",!0),1==(1&i)&&e("#"+p+"-execute-"+n[a]+"-perm").prop("checked",!0);b()},w=function(e){for(var t,n,i,a="777",r="",o=e.length,s=0;o>s;s++){t=C(e[s].perm),r="";for(var l=0;3>l;l++)n=parseInt(t.slice(l,l+1),8),i=parseInt(a.slice(l,l+1),8),
  1820. 4!=(4&n)&&4==(4&i)&&(i-=4),2!=(2&n)&&2==(2&i)&&(i-=2),1!=(1&n)&&1==(1&i)&&(i-=1),r+=i.toString(8);a=r}return a},k=function(e){return e?":"+e:""},x=function(e,t){for(var a,r,o="",s=c.dataTable,d=0;3>d;d++)a=parseInt(e.slice(d,d+1),8),o+=a.toString(8),r=c.fieldset.replace("{f_title}",l.i18n(n[d])).replace("{name}",k(t[n[d]])).replace(/\{level\}/g,n[d]),s=s.replace("{"+d+"}",r).replace("{checked-r}",4==(4&a)?m:"").replace("{checked-w}",2==(2&a)?m:"").replace("{checked-x}",1==(1&a)?m:"");return s=s.replace("{value}",o).replace("{valueCaption}",i.perm)},C=function(e){if(isNaN(parseInt(e,8))){for(var t=e.split(""),n=[],i=0,a=t.length;a>i;i++)0===i||3===i||6===i?t[i].match(/[r]/i)?n.push(1):t[i].match(/[-]/)&&n.push(0):1===i||4===i||7===i?t[i].match(/[w]/i)?n.push(1):t[i].match(/[-]/)&&n.push(0):t[i].match(/[x]/i)?n.push(1):t[i].match(/[-]/)&&n.push(0);n.splice(3,0,","),n.splice(7,0,",");for(var r=n.join(""),o=r.split(","),s=[],l=0,d=o.length;d>l;l++){var c=parseInt(o[l],2).toString(8);s.push(c)}e=s.join("")}else e=parseInt(e,8).toString(8);return e},T={title:this.title,width:"auto",buttons:g(),close:function(){e(this).elfinderdialog("destroy")}},z=l.getUI().find("#"+p),A="";return z.length?(z.elfinderdialog("toTop"),e.Deferred().resolve()):(f=f.replace("{class}",u>1?"elfinder-cwd-icon-group":l.mime2class(h.mime)),u>1?o=c.groupTitle.replace("{items}",l.i18n("items")).replace("{num}",u):(o=c.itemTitle.replace("{name}",h.name).replace("{kind}",l.mime2kind(h)),A=l.tmb(h)),s=x(w(r),1==r.length?r[0]:{}),f=f.replace("{title}",o).replace("{dataTable}",s).replace(/{id}/g,p),z=l.dialog(f,T),z.attr("id",p),A&&e("<img/>").on("load",function(){z.find(".elfinder-cwd-icon").addClass(A.className).css("background-image","url('"+A.url+"')")}).attr("src",A.url),e("#"+p+"-table-perm :checkbox").on("click",function(){b("perm")}),e("#"+p+"-perm").on("keydown",function(t){var n=t.keyCode;return t.stopPropagation(),n==e.ui.keyCode.ENTER?void v():void 0}).on("focus",function(t){e(this).select()}).on("keyup",function(t){3==e(this).val().length&&(e(this).select(),y(e(this).val()))}),d)}},i.prototype.commands.colwidth=function(){this.alwaysEnabled=!0,this.updateOnSelect=!1,this.getstate=function(){return"fixed"===this.fm.getUI("cwd").find("table").css("table-layout")?0:-1},this.exec=function(){this.fm.getUI("cwd").trigger("colwidth")}},i.prototype.commands.copy=function(){this.shortcuts=[{pattern:"ctrl+c ctrl+insert"}],this.getstate=function(t){var t=this.files(t),n=t.length;return!this._disabled&&n&&e.map(t,function(e){return e.read?e:null}).length==n?0:-1},this.exec=function(t){var n=this.fm,i=e.Deferred().fail(function(e){n.error(e)});return e.each(this.files(t),function(e,t){return t.read?void 0:!i.reject(["errCopy",t.name,"errPerm"])}),"rejected"==i.state()?i:i.resolve(n.clipboard(this.hashes(t)))}},i.prototype.commands.cut=function(){var t=this.fm;this.shortcuts=[{pattern:"ctrl+x shift+insert"}],this.getstate=function(n){var n=this.files(n),i=n.length;return!this._disabled&&i&&e.map(n,function(e){return!e.read||e.locked||t.isRoot(e)?null:e}).length==i?0:-1},this.exec=function(n){var i=e.Deferred().fail(function(e){t.error(e)});return e.each(this.files(n),function(e,n){return!n.read||n.locked||t.isRoot(n)?!i.reject(["errCopy",n.name,"errPerm"]):n.locked?!i.reject(["errLocked",n.name]):void 0}),"rejected"==i.state()?i:i.resolve(t.clipboard(this.hashes(n),!0))}},i.prototype.commands.zipdl=function(){},i.prototype.commands.download=function(){var t=this,n=this.fm,i=!1,a=!1,r=function(r,o){var s,l,d=n.api>2?n.getCommand("zipdl"):null;if(null!==d&&(n.searchStatus.state>1?a=n.searchStatus.mixed:n.leafRoots[n.cwd().hash]&&(s=n.cwd().volumeid,e.each(r,function(e,t){return 0!==t.indexOf(s)?(a=!0,!1):void 0})),i=n.isCommandEnabled("zipdl",r[0])),a){if(l=d?"zipdl":"download",r=e.map(r,function(t){var i=n.file(t),a=i&&(d||"directory"!==i.mime)&&n.isCommandEnabled(l,t)?t:null;return i&&o&&!a&&e("#"+n.cwdHash2Id(i.hash)).trigger("unselect"),a}),!r.length)return[]}else if(!n.isCommandEnabled("download",r[0]))return[];return e.map(t.files(r),function(t){var a=!t.read||!i&&"directory"==t.mime?null:t;return o&&!a&&e("#"+n.cwdHash2Id(t.hash)).trigger("unselect"),a})};this.linkedCmds=["zipdl"],this.shortcuts=[{pattern:"shift+enter"}],this.getstate=function(e){var e=this.hashes(e),t=e.length,a=this.options.maxRequests||10;n.api>2?n.getCommand("zipdl"):null;return 1>t?-1:(t=r(e).length,t&&(i||a>=t&&(!n.UA.IE&&!n.UA.Mobile||1==t))?0:-1)},n.bind("contextmenu",function(n){var i,a,r=t.fm,o=null,s=function(t){var n=t.url||r.url(t.hash);return{icon:"link",node:e("<a/>").attr({href:n,target:"_blank",title:r.i18n("link")}).text(t.name).on("mousedown click touchstart touchmove touchend contextmenu",function(e){e.stopPropagation()}).on("dragstart",function(n){var i=n.dataTransfer||n.originalEvent.dataTransfer||null;if(o=null,i){var a=function(t){var n,i=t.mime,a=r.tmb(t);return n='<div class="elfinder-cwd-icon '+r.mime2class(i)+' ui-corner-all"/>',a&&(n=e(n).addClass(a.className).css("background-image","url('"+a.url+"')").get(0).outerHTML),n};i.effectAllowed="copyLink",i.setDragImage&&(o=e('<div class="elfinder-drag-helper html5-native">').append(a(t)).appendTo(e(document.body)),i.setDragImage(o.get(0),50,47)),r.UA.IE||(i.setData("elfinderfrom",window.location.href+t.phash),i.setData("elfinderfrom:"+i.getData("elfinderfrom"),""))}}).on("dragend",function(e){o&&o.remove()})}};if(t.extra=null,n.data&&(i=n.data.targets||[],1===i.length&&(a=r.file(i[0]))&&"directory"!==a.mime))if("1"!=a.url)t.extra=s(a);else{var l;t.extra={icon:"link",node:e("<a/>").attr({href:"#",title:r.i18n("getLink"),draggable:"false"}).text(a.name).on("click touchstart",function(e){if(!("touchstart"===e.type&&e.originalEvent.touches.length>1)){var t=l.parent();e.stopPropagation(),e.preventDefault(),t.removeClass("ui-state-disabled").addClass("elfinder-button-icon-spinner"),r.request({data:{cmd:"url",target:a.hash},preventDefault:!0}).always(function(e){if(t.removeClass("elfinder-button-icon-spinner"),e.url){var n=r.file(a.hash);n.url=e.url,l.replaceWith(s(a).node)}else t.addClass("ui-state-disabled")})}})},l=t.extra.node,l.ready(function(){setTimeout(function(){l.parent().addClass("ui-state-disabled").css("pointer-events","auto")},10)})}}),this.exec=function(t){var n,o,s,l,t=this.hashes(t),d=this.fm,c=(d.options.url,r(t,!0)),u=e.Deferred(),h="",p={},f=!1,m=function(t){return function(){var n=e.Deferred(),i=d.file(d.root(t[0])),a=i?" ("+(i.i18||i.name)+")":"";return d.request({data:{cmd:"zipdl",targets:t},notify:{type:"zipdl",cnt:1,hideCnt:!0,msg:d.i18n("ntfzipdl")+a},cancel:!0,preventDefault:!0}).done(function(i){var a,r,s,c,u,h={},p="dlw"+ +new Date;i.error?(d.error(i.error),n.resolve()):i.zipdl&&(a=i.zipdl,f||!l&&d.UA.Mobile?(o=d.options.url+(-1===d.options.url.indexOf("?")?"?":"&")+"cmd=zipdl&download=1",e.each([t[0],a.file,a.name,a.mime],function(e,t){o+="&targets%5B%5D="+encodeURIComponent(t)}),e.each(d.options.customData,function(e,t){o+="&"+encodeURIComponent(e)+"="+encodeURIComponent(t)}),o+="&"+encodeURIComponent(a.name),s=e("<a/>").attr("href",o).attr("download",encodeURIComponent(a.name)).attr("target","_blank").on("click",function(){n.resolve(),r.elfinderdialog("destroy")}).append('<span class="elfinder-button-icon elfinder-button-icon-download"></span>'+d.escape(a.name)),h[d.i18n("btnCancel")]=function(){r.elfinderdialog("destroy")},r=d.dialog(s,{title:d.i18n("link"),buttons:h,width:"200px",destroyOnClose:!0,close:function(){"resolved"!==n.state()&&n.resolve()}})):(c=e('<form action="'+d.options.url+'" method="post" target="'+p+'" style="display:none"/>').append('<input type="hidden" name="cmd" value="zipdl"/>').append('<input type="hidden" name="download" value="1"/>'),e.each([t[0],a.file,a.name,a.mime],function(e,t){c.append('<input type="hidden" name="targets[]" value="'+d.escape(t)+'"/>')}),e.each(d.options.customData,function(e,t){c.append('<input type="hidden" name="'+e+'" value="'+d.escape(t)+'"/>')}),c.attr("target",p).appendTo("body"),u=e('<iframe style="display:none" name="'+p+'">').appendTo("body").ready(function(){c.submit().remove(),n.resolve(),setTimeout(function(){u.remove()},d.UA.Firefox?2e4:1e3)})))}).fail(function(e){e&&d.error(e),n.resolve()}),n.promise()}};if(!c.length)return u.reject();if(s=e("<a>").hide().appendTo(e("body")),l="string"==typeof s.get(0).download,i&&(c.length>1||"directory"===c[0].mime))return s.remove(),a?(f=d.UA.Mobile,p={},e.each(c,function(e,t){var n=t.hash.split("_",2);p[n[0]]?p[n[0]].push(t.hash):p[n[0]]=[t.hash]})):p=[e.map(c,function(e){return e.hash})],u=d.sequence(e.map(p,function(e){return m(e)})).always(function(){d.trigger("download",{files:c})});for(n=0;n<c.length;n++)o=d.openUrl(c[n].hash,!0),l?s.attr("href",o).attr("download",encodeURIComponent(c[n].name)).attr("target","_blank").get(0).click():d.UA.Mobile?setTimeout(function(){window.open(o)||d.error("errPopup")},100):h+='<iframe class="downloader" id="downloader-'+c[n].hash+'" style="display:none" src="'+o+'"/>';return s.remove(),e(h).appendTo("body").ready(function(){setTimeout(function(){e(h).each(function(){e("#"+e(this).attr("id")).remove()})},d.UA.Firefox?2e4+1e4*n:1e3)}),d.trigger("download",{files:c}),u.resolve()}},i.prototype.commands.duplicate=function(){var t=this.fm;this.getstate=function(n){var n=this.files(n),i=n.length;return!this._disabled&&i&&t.cwd().write&&e.map(n,function(e){return e.read&&e.phash===t.cwd().hash&&!t.isRoot(e)?e:null}).length==i?0:-1},this.exec=function(t){var n=this.fm,i=this.files(t),a=i.length,r=e.Deferred().fail(function(e){e&&n.error(e)});return a?(e.each(i,function(e,t){return t.read&&n.file(t.phash).write?void 0:!r.reject(["errCopy",t.name,"errPerm"])}),"rejected"==r.state()?r:n.request({data:{cmd:"duplicate",targets:this.hashes(t)},notify:{type:"copy",cnt:a}}).done(function(t){var i;t&&t.added&&t.added[0]&&n.one("duplicatedone",function(){i=n.findCwdNodes(t.added),i.length?i.trigger("scrolltoview"):(n.trigger("selectfiles",{files:e.map(t.added,function(e){return e.hash})}),n.toast({msg:n.i18n(["complete",n.i18n("cmdduplicate")])}))})})):r.reject()}},i.prototype.commands.edit=function(){var t=this,n=this.fm,i=n.res("mimes","text")||[],a=function(e){return e.replace(/\s+$/,"")},r=function(i){var a,r=e('<select class="ui-corner-all"/>');return i&&e.each(i,function(e,t){a=n.escape(t.value),r.append('<option value="'+a+'">'+(t.caption?n.escape(t.caption):a)+"</option>")}),e.each(t.options.encodings,function(e,t){r.append('<option value="'+t+'">'+t+"</option>")}),r},o=function(n){return e.map(n,function(n){return 0!==n.mime.indexOf("text/")&&-1===e.inArray(n.mime,i)||!n.mime.indexOf("text/rtf")||t.onlyMimes.length&&-1===e.inArray(n.mime,t.onlyMimes)||!n.read||!n.write?null:n})},s=function(o,s,d,c){var u,h=e.Deferred(),p=function(){u&&(y()?u.attr("title",n.i18n("saveAsEncoding")).addClass("elfinder-edit-changed"):u.attr("title",n.i18n("openAsEncoding")).removeClass("elfinder-edit-changed"))},f=e('<textarea class="elfinder-file-edit '+n.res("class","editing")+'" rows="20" id="'+o+'-ta">'+n.escape(d)+"</textarea>").on("input propertychange",p),m=f.val(),g=function(){f.editor&&f.editor.save(f[0],f.editor.instance),m=f.val(),h.notifyWith(f,[u?u.val():void 0])},v=function(){f.elfinderdialog("close")},b=function(){g(),v()},y=function(){return f.editor&&f.editor.save(f[0],f.editor.instance),a(m)!==a(f.val())},w={title:n.escape(s.name),width:t.options.dialogWidth||450,buttons:{},allowMaximize:!0,btnHoverFocus:!1,closeOnEscape:!1,close:function(){var i=function(){h.reject(),f.editor&&f.editor.close(f[0],f.editor.instance),f.elfinderdialog("destroy")};n.toggleMaximize(e(this).closest(".ui-dialog"),!1),y()?n.confirm({title:t.title,text:"confirmNotSave",accept:{label:"btnSaveClose",callback:function(){g(),i()}},cancel:{label:"btnClose",callback:i}}):i()},open:function(){var t,i=c&&"unknown"!==c?[{value:c}]:[];""!==d&&c&&"UTF-8"===c||i.push({value:"UTF-8"}),u=r(i).on("touchstart",function(e){e.stopPropagation()}).on("change",function(){y()||""===a(f.val())||(v(),l(s,e(this).val()))}).on("mouseover",p),f.parent().prev().find(".elfinder-titlebar-button:last").after(e('<span class="elfinder-titlebar-button-right"/>').append(u)),n.disable(),f.focus(),f[0].setSelectionRange&&f[0].setSelectionRange(0,0),f.editor&&(t=f.editor.load(f[0])||null,t&&t.done?t.done(function(e){f.editor.instance=e,f.editor.focus(f[0],f.editor.instance)}):(f.editor.instance=t,f.editor.focus(f[0],f.editor.instance)))},resize:function(e,t){f.editor&&f.editor.resize(f[0],f.editor.instance,e,t||{})}},k=function(t,n){if(n=n||i.concat("text/"),-1!==e.inArray(t,n))return!0;var a,r;for(r=n.length,a=0;r>a;a++)if(0===t.indexOf(n[a]))return!0;return!1},x=function(e,t){if(!t||!t.length)return!0;var n,i,a=e.replace(/^.+\.([^.]+)|(.+)$/,"$1$2").toLowerCase();for(i=t.length,n=0;i>n;n++)if(a===t[n].toLowerCase())return!0;return!1};return f.getContent=function(){return f.val()},e.each(t.options.editors||[],function(e,t){return k(s.mime,t.mimes||null)&&x(s.name,t.exts||null)&&"function"==typeof t.load&&"function"==typeof t.save?(f.editor={load:t.load,save:t.save,close:"function"==typeof t.close?t.close:function(){},focus:"function"==typeof t.focus?t.focus:function(){},resize:"function"==typeof t.resize?t.resize:function(){},instance:null,doSave:g,doCancel:v,doClose:b,file:s,fm:n},!1):void 0}),f.editor||f.keydown(function(t){var n,i,a=t.keyCode;t.stopPropagation(),a==e.ui.keyCode.TAB&&(t.preventDefault(),this.setSelectionRange&&(n=this.value,i=this.selectionStart,this.value=n.substr(0,i)+" "+n.substr(this.selectionEnd),i+=1,this.setSelectionRange(i,i))),(t.ctrlKey||t.metaKey)&&(a!="Q".charCodeAt(0)&&a!="W".charCodeAt(0)||(t.preventDefault(),v()),a=="S".charCodeAt(0)&&(t.preventDefault(),g()))}).on("mouseenter",function(){this.focus()}),w.buttons[n.i18n("btnSave")]=g,w.buttons[n.i18n("btnSaveClose")]=b,w.buttons[n.i18n("btnCancel")]=v,n.dialog(f,w).attr("id",o).on("keydown keyup keypress",function(e){e.stopPropagation()}),h.promise()},l=function(i,a){var o,d=i.hash,c=(n.options,e.Deferred()),u="edit-"+n.namespace+"-"+i.hash,h=n.getUI().find("#"+u),a=a?a:0;return h.length?(h.elfinderdialog("toTop"),c.resolve()):i.read&&i.write?(n.request({data:{cmd:"get",target:d,conv:a},notify:{type:"file",cnt:1}}).done(function(a){var o;a.doconv?n.confirm({title:t.title,text:"unknown"===a.doconv?"confirmNonUTF8":"confirmConvUTF8",accept:{label:"btnConv",callback:function(){c=l(i,o.val())}},cancel:{label:"btnCancel",callback:function(){c.reject()}},optionsCallback:function(t){t.create=function(){var t=e('<div class="elfinder-dialog-confirm-encoding"/>'),i={value:a.doconv};"unknown"===a.doconv&&(i.caption="-"),o=r([i]),e(this).next().find(".ui-dialog-buttonset").prepend(t.append(e("<label>"+n.i18n("encoding")+" </label>").append(o)))}}}):s(u,i,a.content,a.encoding).progress(function(e){var t=this;n.request({options:{type:"post"},data:{cmd:"put",target:d,encoding:e||a.encoding,content:t.getContent()},notify:{type:"save",cnt:1},syncOnFail:!0}).fail(function(e){c.reject(e)}).done(function(e){e.changed&&e.changed.length&&n.change(e),c.resolve(e),setTimeout(function(){t.focus(),t.editor&&t.editor.focus(t[0],t.editor.instance)},50)})})}).fail(function(t){var i=e.isArray(t)?t[0]:t;"errConvUTF8"!==i&&n.sync(),c.reject(t)}),c.promise()):(o=["errOpen",i.name,"errPerm"],n.error(o),c.reject(o))};this.shortcuts=[{pattern:"ctrl+e"}],this.init=function(){this.onlyMimes=this.options.mimes||[]},this.getstate=function(e){var e=this.files(e),t=e.length;return!this._disabled&&t&&o(e).length==t?0:-1},this.exec=function(t){for(var n,i=o(this.files(t)),a=[];n=i.shift();)a.push(l(n));return a.length?e.when.apply(null,a):e.Deferred().reject()}},i.prototype.commands.extract=function(){var t=this,n=t.fm,i=[],a=function(t){return e.map(t,function(t){return t.read&&-1!==e.inArray(t.mime,i)?t:null})};this.variants=[],this.disableOnSearch=!0,n.bind("open reload",function(){i=n.option("archivers").extract||[],n.api>2?t.variants=[["makedir",n.i18n("cmdmkdir")],["intohere",n.i18n("btnCwd")]]:t.variants=[["intohere",n.i18n("btnCwd")]],t.change()}),this.getstate=function(e){var e=this.files(e),t=e.length;return!this._disabled&&t&&this.fm.cwd().write&&a(e).length==t?0:-1},this.exec=function(t,a){var r,o,s,l=this.files(t),d=e.Deferred(),c=l.length,u="makedir"==a?1:0,h=!1,p=!1,f=0,m=e.map(n.files(t),function(e){return e.name}),g={};e.map(n.files(t),function(e){g[e.name]=e});var v=function(e){switch(e){case"overwrite_all":h=!0;break;case"omit_all":p=!0}},b=function(t){t.read&&n.file(t.phash).write?-1===e.inArray(t.mime,i)?(o=["errExtract",t.name,"errNoArchive"],n.error(o),d.reject(o)):n.request({data:{cmd:"extract",target:t.hash,makedir:u},notify:{type:"extract",cnt:1},syncOnFail:!0}).fail(function(e){"rejected"!=d.state()&&d.reject(e)}).done(function(){}):(o=["errExtract",t.name,"errPerm"],n.error(o),d.reject(o))},y=function(t,i){var a=t[i],o=a.name.replace(/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/gi,""),l=e.inArray(o,m)>=0,w=function(){c>i+1?y(t,i+1):d.resolve()};!u&&l&&"directory"!=g[o].mime?n.confirm({title:n.i18n("ntfextract"),text:["errExists",o,"confirmRepl"],accept:{label:"btnYes",callback:function(e){if(s=e?"overwrite_all":"overwrite",v(s),h||p){if(h){for(r=i;c>r;r++)b(t[r]);d.resolve()}}else"overwrite"==s&&b(a),c>i+1?y(t,i+1):d.resolve()}},reject:{label:"btnNo",callback:function(e){s=e?"omit_all":"omit",v(s),!h&&!p&&c>i+1?y(t,i+1):p&&d.resolve()}},cancel:{label:"btnCancel",callback:function(){d.resolve()}},all:c>i+1}):u?(b(a),w()):0==f?n.confirm({title:n.i18n("cmdextract"),text:[n.i18n("cmdextract")+' "'+a.name+'"',"confirmRepl"],accept:{label:"btnYes",callback:function(e){e&&(f=1),b(a),w()}},reject:{label:"btnNo",callback:function(e){e&&(f=-1),w()}},cancel:{label:"btnCancel",callback:function(){d.resolve()}},all:c>i+1}):(f>0&&b(a),w())};return this.enabled()&&c&&i.length?(c>0&&y(l,0),d):d.reject()}},(i.prototype.commands.forward=function(){this.alwaysEnabled=!0,this.updateOnSelect=!0,this.shortcuts=[{pattern:"ctrl+right"}],this.getstate=function(){return this.fm.history.canForward()?0:-1},this.exec=function(){return this.fm.history.forward()}}).prototype={forceLoad:!0},i.prototype.commands.fullscreen=function(){var e=this,t=this.fm,n=function(t,n){n&&n.fullscreen&&e.update(void 0,"on"===n.fullscreen)};this.alwaysEnabled=!0,this.updateOnSelect=!1,this.value=!1,this.options={ui:"fullscreenbutton"},this.getstate=function(){return 0},this.exec=function(){var n=t.getUI().get(0),i=t.toggleFullscreen(n);e.update(void 0,i===n)},t.bind("init",function(){t.getUI().off("resize."+t.namespace,n).on("resize."+t.namespace,n)})},(i.prototype.commands.getfile=function(){var t=this,n=this.fm,i=function(n){var i=t.options;return n=e.map(n,function(e){return("directory"!=e.mime||i.folders)&&e.read?e:null}),i.multiple||1==n.length?n:[]};this.alwaysEnabled=!0,this.callback=n.options.getFileCallback,this._disabled="function"==typeof this.callback,this.getstate=function(e){var e=this.files(e),t=e.length;return this.callback&&t&&i(e).length==t?0:-1},this.exec=function(n){var i,a,r,o=this.fm,s=this.options,l=this.files(n),d=l.length,c=o.option("url"),u=o.option("tmbUrl"),h=e.Deferred().done(function(e){var n,i=function(){"close"==s.oncomplete?o.hide():"destroy"==s.oncomplete&&o.destroy()};o.trigger("getfile",{files:e}),n=t.callback(e,o),"object"==typeof n&&"function"==typeof n.done?n.done(i).fail(function(e){e&&o.error(e)}):i()}),p=function(t){return s.onlyURL?s.multiple?e.map(l,function(e){return e.url}):l[0].url:s.multiple?l:l[0]},f=[];for(i=0;d>i;i++){if(a=l[i],"directory"==a.mime&&!s.folders)return h.reject();a.baseUrl=c,"1"==a.url?f.push(o.request({data:{cmd:"url",target:a.hash},notify:{type:"url",cnt:1,hideCnt:!0},preventDefault:!0}).done(function(e){if(e.url){var t=o.file(this.hash);t.url=this.url=e.url}}.bind(a))):a.url=o.url(a.hash),s.onlyURL||(s.getPath&&(a.path=o.path(a.hash),""===a.path&&a.phash&&!function(){var t=e.Deferred();f.push(t),o.path(a.hash,!1,{}).done(function(e){a.path=e}).fail(function(){a.path=""}).always(function(){t.resolve()})}()),a.tmb&&1!=a.tmb&&(a.tmb=u+a.tmb),a.width||a.height||(a.dim?(r=a.dim.split("x"),a.width=r[0],a.height=r[1]):s.getImgSize&&-1!==a.mime.indexOf("image")&&f.push(o.request({data:{cmd:"dim",target:a.hash},notify:{type:"dim",cnt:1,hideCnt:!0},preventDefault:!0}).done(function(e){if(e.dim){var t=e.dim.split("x"),n=o.file(this.hash);n.width=this.width=t[0],n.height=this.height=t[1]}}.bind(a)))))}return f.length?(e.when.apply(null,f).always(function(){h.resolve(p(l))}),h):h.resolve(p(l))}}).prototype={forceLoad:!0},(i.prototype.commands.help=function(){var t,n,i=this.fm,a=this,r='<div class="elfinder-help-link"> <a href="{url}" target="_blank">{link}</a></div>',o='<div class="elfinder-help-team"><div>{author}</div>{work}</div>',s=/\{url\}/,l=/\{link\}/,d=/\{author\}/,c=/\{work\}/,u="replace",h="ui-priority-primary",p="ui-priority-secondary",f="elfinder-help-license",m='<li class="ui-state-default ui-corner-top elfinder-help-tab-{id}"><a href="#'+i.namespace+'-help-{id}">{title}</a></li>',g=['<div class="ui-tabs ui-widget ui-widget-content ui-corner-all elfinder-help">','<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">'],v='<div class="elfinder-help-shortcut"><div class="elfinder-help-shortcut-pattern">{pattern}</div> {descrip}</div>',b='<div class="elfinder-help-separator"/>',y=function(){g.push('<div id="'+i.namespace+'-help-about" class="ui-tabs-panel ui-widget-content ui-corner-bottom"><div class="elfinder-help-logo"/>'),g.push("<h3>elFinder</h3>"),g.push('<div class="'+h+'">'+i.i18n("webfm")+"</div>"),g.push('<div class="'+p+'">'+i.i18n("ver")+": "+i.version+", "+i.i18n("protocolver")+': <span class="apiver"></span></div>'),g.push('<div class="'+p+'">jQuery/jQuery UI: '+e().jquery+"/"+e.ui.version+"</div>"),g.push(b),g.push(r[u](s,"http://elfinder.org/")[u](l,i.i18n("homepage"))),g.push(r[u](s,"https://github.com/Studio-42/elFinder/wiki")[u](l,i.i18n("docs"))),g.push(r[u](s,"https://github.com/Studio-42/elFinder")[u](l,i.i18n("github"))),g.push(r[u](s,"http://twitter.com/elrte_elfinder")[u](l,i.i18n("twitter"))),g.push(b),g.push('<div class="'+h+'">'+i.i18n("team")+"</div>"),g.push(o[u](d,'Dmitry "dio" Levashov &lt;dio@std42.ru&gt;')[u](c,i.i18n("chiefdev"))),g.push(o[u](d,"Troex Nevelin &lt;troex@fury.scancode.ru&gt;")[u](c,i.i18n("maintainer"))),g.push(o[u](d,"Alexey Sukhotin &lt;strogg@yandex.ru&gt;")[u](c,i.i18n("contributor"))),g.push(o[u](d,"Naoki Sawada &lt;hypweb@gmail.com&gt;")[u](c,i.i18n("contributor"))),i.i18[i.lang].translator&&e.each(i.i18[i.lang].translator.split(", "),function(){g.push(o[u](d,e.trim(this))[u](c,i.i18n("translator")+" ("+i.i18[i.lang].language+")"))}),g.push(b),g.push('<div class="'+f+'">'+i.i18n("icons")+': Pixelmixer, <a href="http://p.yusukekamiyamane.com" target="_blank">Fugue</a></div>'),g.push(b),g.push('<div class="'+f+'">Licence: BSD Licence</div>'),g.push('<div class="'+f+'">Copyright © 2009-2016, Studio 42</div>'),g.push('<div class="'+f+'">„ …'+i.i18n("dontforget")+" ”</div>"),g.push("</div>")},w=function(){var t=i.shortcuts();g.push('<div id="'+i.namespace+'-help-shortcuts" class="ui-tabs-panel ui-widget-content ui-corner-bottom">'),t.length?(g.push('<div class="ui-widget-content elfinder-help-shortcuts">'),e.each(t,function(e,t){g.push(v.replace(/\{pattern\}/,t[0]).replace(/\{descrip\}/,t[1]))}),g.push("</div>")):g.push('<div class="elfinder-help-disabled">'+i.i18n("shortcutsof")+"</div>"),g.push("</div>")},k=function(){g.push('<div id="'+i.namespace+'-help-help" class="ui-tabs-panel ui-widget-content ui-corner-bottom">'),g.push('<a href="https://github.com/Studio-42/elFinder/wiki" target="_blank" class="elfinder-dont-panic"><span>DON\'T PANIC</span></a>'),g.push("</div>")},x=function(){g.push('<div id="'+i.namespace+'-help-debug" class="ui-tabs-panel ui-widget-content ui-corner-bottom">'),g.push('<div class="ui-widget-content elfinder-help-debug"><ul></ul></div>'),g.push("</div>")},C=function(){var r,o,s,l,d=function(t,n){return e.each(n,function(n,i){t.append(e("<dt/>").text(n)),"undefined"==typeof i?t.append(e("<dd/>").append(e("<span/>").text("undfined"))):"object"!=typeof i||i?"object"==typeof i&&(e.isPlainObject(i)||i.length)?t.append(e("<dd/>").append(d(e("<dl/>"),i))):t.append(e("<dd/>").append(e("<span/>").text(i&&"object"==typeof i?"[]":i?i:'""'))):t.append(e("<dd/>").append(e("<span/>").text("null")))}),t},c=n.children("li").length;(a.debug.options||a.debug.debug)&&(c>=5&&(n.children("li:last").remove(),t.children("div:last").remove()),s=i.namespace+"-help-debug-"+ +new Date,r=e("<li/>").html('<a href="#'+s+'">'+a.debug.debug.cmd+"</a>").prependTo(n),o=e('<div id="'+s+'"/>'),a.debug.debug&&(l=e("<fieldset>").append(e("<legend/>").text("debug"),d(e("<dl/>"),a.debug.debug)),o.append(l)),a.debug.options&&(l=e("<fieldset>").append(e("<legend/>").text("options"),d(e("<dl/>"),a.debug.options)),o.append(l)),n.after(o),t.tabs("refresh"),n.find("a:first").on("click",function(e){e.stopPropagation()}).click())},T="";this.alwaysEnabled=!0,this.updateOnSelect=!1,this.state=-1,this.shortcuts=[{pattern:"f1",description:this.title}],i.one("load",function(){var r,o=a.options.view||["about","shortcuts","help","debug"];e.each(o,function(e,t){g.push(m[u](/\{id\}/g,t)[u](/\{title\}/,i.i18n(t)))}),g.push("</ul>"),-1!==e.inArray("about",o)&&y(),-1!==e.inArray("shortcuts",o)&&w(),-1!==e.inArray("help",o)&&k(),-1!==e.inArray("debug",o)&&x(),g.push("</div>"),T=e(g.join("")),T.find(".ui-tabs-nav li").hover(function(){e(this).toggleClass("ui-state-hover")}).children().click(function(t){var n=e(this);t.preventDefault(),t.stopPropagation(),n.hasClass("ui-tabs-selected")||(n.parent().addClass("ui-tabs-selected ui-state-active").siblings().removeClass("ui-tabs-selected").removeClass("ui-state-active"),T.children(".ui-tabs-panel").hide().filter(n.attr("href")).show())}).filter(":first").click(),r=T.find(".elfinder-help-tab-debug").hide(),t=T.find("#"+i.namespace+"-help-debug").children("div:first").tabs(),n=t.children("ul:first"),a.debug={},i.bind("backenddebug",function(t){t.data&&t.data.debug&&(r.show(),a.debug={options:t.data.options,debug:e.extend({cmd:i.currentReqCmd},t.data.debug)},a.dialog&&C())}),T.find("#"+i.namespace+"-help-about").find(".apiver").text(i.api),a.dialog=i.dialog(T,{title:a.title,width:530,autoOpen:!1,destroyOnClose:!1}),a.state=0}),this.getstate=function(){return 0},this.exec=function(){this.dialog.elfinderdialog("open").find(".ui-tabs-nav li a:first").click()}}).prototype={forceLoad:!0},(i.prototype.commands.home=function(){this.title="Home",this.alwaysEnabled=!0,this.updateOnSelect=!1,this.shortcuts=[{pattern:"ctrl+home ctrl+shift+up",description:"Home"}],this.getstate=function(){var e=this.fm.root(),t=this.fm.cwd().hash;return e&&t&&e!=t?0:-1},this.exec=function(){return this.fm.exec("open",this.fm.root())}}).prototype={forceLoad:!0},(i.prototype.commands.info=function(){var t=this.fm,n="elfinder-info-spinner",i="elfinder-info-button",a={calc:t.i18n("calc"),size:t.i18n("size"),unknown:t.i18n("unknown"),path:t.i18n("path"),aliasfor:t.i18n("aliasfor"),modify:t.i18n("modify"),perms:t.i18n("perms"),locked:t.i18n("locked"),dim:t.i18n("dim"),kind:t.i18n("kind"),files:t.i18n("files"),folders:t.i18n("folders"),roots:t.i18n("volumeRoots"),items:t.i18n("items"),yes:t.i18n("yes"),no:t.i18n("no"),link:t.i18n("link"),owner:t.i18n("owner"),group:t.i18n("group"),perm:t.i18n("perm"),getlink:t.i18n("getLink")};this.tpl={main:'<div class="ui-helper-clearfix elfinder-info-title {dirclass}"><span class="elfinder-cwd-icon {class} ui-corner-all"/>{title}</div><table class="elfinder-info-tb">{content}</table>',itemTitle:'<strong>{name}</strong><span class="elfinder-info-kind">{kind}</span>',groupTitle:"<strong>{items}: {num}</strong>",row:"<tr><td>{label} : </td><td>{value}</td></tr>",spinner:'<span>{text}</span> <span class="'+n+" "+n+'-{name}"/>'},this.alwaysEnabled=!0,this.updateOnSelect=!1,this.shortcuts=[{pattern:"ctrl+i"}],this.init=function(){e.each(a,function(e,n){a[e]=t.i18n(n)})},this.getstate=function(){return 0},this.exec=function(t){var r=this.files(t);r.length||(r=this.files([this.fm.cwd().hash]));var o,s,l,d,c,u,h,p=this.fm,f=this.options,m=this.tpl,g=m.row,v=r.length,b=[],y=m.main,w="{label}",k="{value}",x=[],C={title:this.title,width:"auto",close:function(){e(this).elfinderdialog("destroy"),e.each(x,function(e,t){var n=t&&t.xhr?t.xhr:null;n&&"pending"==n.state()&&(n.quiet=!0,n.abort())})}},T=[],z=function(e,t){I.find("."+n+"-"+t).parent().html(e)},A=p.namespace+"-info-"+e.map(r,function(e){return e.hash}).join("-"),I=p.getUI().find("#"+A),S=[],U=function(t){var n=function(t){var n=[];return"directory"===t.mime&&e.each(p.leafRoots,function(e,i){var a;if(e===t.hash)n.push.apply(n,i);else for(a=(p.file(e)||{}).phash;a;)a===t.hash&&n.push.apply(n,i),a=(p.file(a)||{}).phash}),n},i=function(t){var n=e.Deferred(),i=p.file(t),a=i?i.phash:t;return a&&!p.file(a)?p.request({data:{cmd:"parents",target:a},preventFail:!0}).done(function(){p.one("parentsdone",function(){n.resolve()})}).fail(function(){n.resolve()}):n.resolve(),n},r=function(){var t=e.Deferred(),n=Object.keys(p.leafRoots).length;return n>0?e.each(p.leafRoots,function(e){i(e).done(function(){--n,1>n&&t.resolve()})}):t.resolve(),t};p.autoSync("stop"),r().done(function(){var i=[],r={},o=[];e.each(t,function(){i.push.apply(i,n(p.file(this)))}),t.push.apply(t,i),e.each(t,function(){var e=p.root(this);r[e]?r[e].push(this):r[e]=[this]}),e.each(r,function(){o.push(p.request({data:{cmd:"size",targets:this},preventDefault:!0}))}),x.push.apply(x,o),e.when.apply(e,o).fail(function(){z(a.unknown,"size")}).done(function(){var e,t=0,n=arguments.length;for(e=0;n>e;e++)t+=parseInt(arguments[e].size);z(t>=0?p.formatSize(t):a.unknown,"size")}),p.autoSync()})};if(!v)return e.Deferred().reject();if(I.length)return I.elfinderdialog("toTop"),e.Deferred().resolve();if(1==v){if(l=r[0],y=y.replace("{dirclass}",l.csscls?p.escape(l.csscls):"").replace("{class}",p.mime2class(l.mime)),d=m.itemTitle.replace("{name}",p.escape(l.i18||l.name)).replace("{kind}",'<span title="'+p.escape(l.mime)+'">'+p.mime2kind(l)+"</span>"),s=p.tmb(l),l.read?"directory"!=l.mime||l.alias?o=p.formatSize(l.size):(o=m.spinner.replace("{text}",a.calc).replace("{name}","size"),T.push(l.hash)):o=a.unknown,b.push(g.replace(w,a.size).replace(k,o)),l.alias&&b.push(g.replace(w,a.aliasfor).replace(k,l.alias)),(h=p.path(l.hash,!0))?b.push(g.replace(w,a.path).replace(k,p.escape(h))):(b.push(g.replace(w,a.path).replace(k,m.spinner.replace("{text}",a.calc).replace("{name}","path"))),x.push(p.path(l.hash,!0,{notify:null}).fail(function(){z(a.unknown,"path")}).done(function(e){z(e,"path")}))),l.read){var M,O=p.escape(l.name);if("1"==l.url)b.push(g.replace(w,a.link).replace(k,'<button class="'+i+" "+n+'-url">'+a.getlink+"</button>"));else{if(f.nullUrlDirLinkSelf&&"directory"==l.mime&&null===l.url){var D=window.location;M=D.pathname+D.search+"#elf_"+l.hash}else M=p.url(l.hash);b.push(g.replace(w,a.link).replace(k,'<a href="'+M+'" target="_blank">'+O+"</a>"))}}l.dim?b.push(g.replace(w,a.dim).replace(k,l.dim)):-1!==l.mime.indexOf("image")&&(l.width&&l.height?b.push(g.replace(w,a.dim).replace(k,l.width+"x"+l.height)):(b.push(g.replace(w,a.dim).replace(k,m.spinner.replace("{text}",a.calc).replace("{name}","dim"))),x.push(p.request({data:{cmd:"dim",target:l.hash},preventDefault:!0}).fail(function(){z(a.unknown,"dim")}).done(function(e){if(z(e.dim||a.unknown,"dim"),e.dim){var t=e.dim.split("x"),n=p.file(l.hash);n.width=t[0],n.height=t[1]}})))),b.push(g.replace(w,a.modify).replace(k,p.formatDate(l))),b.push(g.replace(w,a.perms).replace(k,p.formatPermissions(l))),b.push(g.replace(w,a.locked).replace(k,l.locked?a.yes:a.no)),l.owner&&b.push(g.replace(w,a.owner).replace(k,l.owner)),l.group&&b.push(g.replace(w,a.group).replace(k,l.group)),l.perm&&b.push(g.replace(w,a.perm).replace(k,p.formatFileMode(l.perm))),f.custom&&e.each(f.custom,function(t,n){
  1821. n.mimes&&!e.map(n.mimes,function(e){return l.mime===e||0===l.mime.indexOf(e+"/")?!0:null}).length||n.hashRegex&&!l.hash.match(n.hashRegex)||(b.push(g.replace(w,p.i18n(n.label)).replace(k,n.tpl.replace("{id}",A))),n.action&&"function"==typeof n.action&&S.push(n.action))})}else y=y.replace("{class}","elfinder-cwd-icon-group"),d=m.groupTitle.replace("{items}",a.items).replace("{num}",v),c=e.map(r,function(e){return"directory"==e.mime?1:null}).length,c?(u=e.map(r,function(e){return"directory"!==e.mime||e.phash&&!e.isroot?null:1}).length,c-=u,b.push(g.replace(w,a.kind).replace(k,u===v||c===v?a[u?"roots":"folders"]:e.map({roots:u,folders:c,files:v-u-c},function(e,t){return e?a[t]+" "+e:null}).join(", "))),b.push(g.replace(w,a.size).replace(k,m.spinner.replace("{text}",a.calc).replace("{name}","size"))),T=e.map(r,function(e){return e.hash})):(o=0,e.each(r,function(e,t){var n=parseInt(t.size);n>=0&&o>=0?o+=n:o="unknown"}),b.push(g.replace(w,a.kind).replace(k,a.files)),b.push(g.replace(w,a.size).replace(k,p.formatSize(o))));y=y.replace("{title}",d).replace("{content}",b.join("")),I=p.dialog(y,C),I.attr("id",A),l&&"1"==l.url&&I.on("click","."+n+"-url",function(){e(this).parent().html(m.spinner.replace("{text}",p.i18n("ntfurl")).replace("{name}","url")),p.request({data:{cmd:"url",target:l.hash},preventDefault:!0}).fail(function(){z(O,"url")}).done(function(e){if(e.url){z('<a href="'+e.url+'" target="_blank">'+O+"</a>"||O,"url");var t=p.file(l.hash);t.url=e.url}else z(O,"url")})}),s&&e("<img/>").on("load",function(){I.find(".elfinder-cwd-icon").addClass(s.className).css("background-image","url('"+s.url+"')")}).attr("src",s.url),T.length&&U(T),S.length&&e.each(S,function(e,t){try{t(l,p,I)}catch(n){p.debug("error",n)}})}}).prototype={forceLoad:!0},i.prototype.commands.mkdir=function(){var t,n=this.fm,i=this;this.value="",this.disableOnSearch=!0,this.updateOnSelect=!1,this.mime="directory",this.prefix="untitled folder",this.exec=function(a){return this.origin=t?t:"cwd",a||this.options.intoNewFolderToolbtn||n.getUI("cwd").trigger("unselectall"),this.move=!("navbar"===this.origin||!n.selected().length),e.proxy(n.res("mixin","make"),i)()},this.shortcuts=[{pattern:"ctrl+shift+n"}],this.init=function(){this.options.intoNewFolderToolbtn&&(this.options.ui="mkdirbutton")},n.bind("select",function(e){var a=e.data&&e.data.selected?e.data.selected:[];t=a.length?e.data.origin||"":"",i.title=a.length&&"navbar"!==t?n.i18n("cmdmkdirin"):n.i18n("cmdmkdir"),i.update(void 0,i.title)}),this.getstate=function(i){var a=n.cwd(),i="navbar"===t||i&&i[0]!=a.hash?this.files(i||n.selected()):[],r=i.length;return"navbar"===t?!this._disabled&&r&&i[0].write&&i[0].read?0:-1:this._disabled||!a.write||r&&e.map(i,function(e){return e.read&&!e.locked?e:null}).length!=r?-1:0}},i.prototype.commands.mkfile=function(){this.disableOnSearch=!0,this.updateOnSelect=!1,this.mime="text/plain",this.prefix="untitled file.txt",this.exec=e.proxy(this.fm.res("mixin","make"),this),this.getstate=function(){return!this._disabled&&this.fm.cwd().write?0:-1}},i.prototype.commands.netmount=function(){var t,n=this;this.alwaysEnabled=!0,this.updateOnSelect=!1,this.drivers=[],this.handlers={load:function(){this.drivers=this.fm.netDrivers}},this.getstate=function(){return this.drivers.length?0:-1},this.exec=function(){var i,a=n.fm,r=e.Deferred(),o=n.options,s=function(){var s,l=function(){d.protocol.trigger("change","winfocus")},d={protocol:e("<select/>").on("change",function(e,n){var r=this.value;t.find(".elfinder-netmount-tr").hide(),t.find(".elfinder-netmount-tr-"+r).show(),i.children(".ui-dialog-buttonpane:first").find("button").show(),"function"==typeof o[r].select&&o[r].select(a,e,n),setTimeout(function(){t.find("input:text.elfinder-tabstop:visible:first").focus()},20)}).addClass("ui-corner-all")},c={title:a.i18n("netMountDialogTitle"),resizable:!1,modal:!0,destroyOnClose:!0,open:function(){e(window).on("focus."+a.namespace,l),d.protocol.change()},close:function(){"pending"==r.state()&&r.reject(),e(window).off("focus."+a.namespace,l)},buttons:{}},u=e("<div/>");return t=e('<table class="elfinder-info-tb elfinder-netmount-tb"/>').append(e("<tr/>").append(e("<td>"+a.i18n("protocol")+"</td>")).append(e("<td/>").append(d.protocol))),e.each(n.drivers,function(n,i){o[i]&&(d.protocol.append('<option value="'+i+'">'+a.i18n(o[i].name||i)+"</option>"),e.each(o[i].inputs,function(n,r){r.attr("name",n),"hidden"!=r.attr("type")?(r.addClass("ui-corner-all elfinder-netmount-inputs-"+i),t.append(e("<tr/>").addClass("elfinder-netmount-tr elfinder-netmount-tr-"+i).append(e("<td>"+a.i18n(n)+"</td>")).append(e("<td/>").append(r)))):(r.addClass("elfinder-netmount-inputs-"+i),u.append(r))}),o[i].protocol=d.protocol)}),t.append(u),t.find(".elfinder-netmount-tr").hide(),c.buttons[a.i18n("btnMount")]=function(){var i=d.protocol.val(),s={cmd:"netmount",protocol:i},l=o[i];return e.each(t.find("input.elfinder-netmount-inputs-"+i),function(t,n){var i;i="function"==typeof n.val?e.trim(n.val()):e.trim(n.value),i&&(s[n.name]=i)}),s.host?(a.request({data:s,notify:{type:"netmount",cnt:1,hideCnt:!0}}).done(function(e){var t;e.added&&e.added.length&&(e.added[0].phash&&(t=a.file(e.added[0].phash))&&(t.dirs||(t.dirs=1,a.change({changed:[t]}))),a.one("netmountdone",function(){a.exec("open",e.added[0].hash)})),r.resolve()}).fail(function(e){l.fail&&"function"==typeof l.fail&&l.fail(a,e),r.reject(e)}),void n.dialog.elfinderdialog("close")):a.trigger("error",{error:"errNetMountHostReq"})},c.buttons[a.i18n("btnCancel")]=function(){n.dialog.elfinderdialog("close")},t.find("select,input").addClass("elfinder-tabstop"),s=a.dialog(t,c),i=s.closest(".ui-dialog"),s.ready(function(){d.protocol.change(),s.elfinderdialog("posInit")}),s};return n.dialog?n.dialog.elfinderdialog("open"):n.dialog=s(),r.promise()},n.fm.bind("netmount",function(e){var i=e.data||null,a=n.options;i&&i.protocol&&a[i.protocol]&&"function"==typeof a[i.protocol].done&&(a[i.protocol].done(n.fm,i),t.find("select,input").addClass("elfinder-tabstop"),n.dialog.elfinderdialog("tabstopsInit"))})},i.prototype.commands.netunmount=function(){this.alwaysEnabled=!0,this.updateOnSelect=!1,this.drivers=[],this.handlers={load:function(){this.drivers=this.fm.netDrivers}},this.getstate=function(e){var t=this.fm;return e&&this.drivers.length&&!this._disabled&&t.file(e[0]).netkey?0:-1},this.exec=function(t){var n=this,i=this.fm,a=e.Deferred().fail(function(e){e&&i.error(e)}),r=i.file(t[0]);return this._disabled?a.reject():("pending"==a.state()&&i.confirm({title:n.title,text:i.i18n("confirmUnmount",r.name),accept:{label:"btnUnmount",callback:function(){var t=i.root()==r.hash,n=e("#"+i.navHash2Id(r.hash)).parent(),o=(n.next().length?n.next():n.prev()).find(".elfinder-navbar-root");i.request({data:{cmd:"netmount",protocol:"netunmount",host:r.netkey,user:r.hash,pass:"dum"},notify:{type:"netunmount",cnt:1,hideCnt:!0},preventFail:!0}).fail(function(e){a.reject(e)}).done(function(e){var n=i.root();if(t){if(o.length)n=i.navId2Hash(o[0].id);else{var r=i.files();for(var s in r)if("directory"==i.file(s).mime){n=s;break}}i.exec("open",n)}a.resolve()})}},cancel:{label:"btnCancel",callback:function(){a.reject()}}}),a)}},(i.prototype.commands.open=function(){this.alwaysEnabled=!0,this._handlers={dblclick:function(e){e.preventDefault(),this.exec()},"select enable disable reload":function(e){this.update("disable"==e.type?-1:void 0)}},this.shortcuts=[{pattern:"ctrl+down numpad_enter"+("mac"!=this.fm.OS&&" enter")}],this.getstate=function(t){var t=this.files(t),n=t.length;return 1==n?t[0].read?0:-1:n&&!this.fm.UA.Mobile&&e.map(t,function(e){return"directory"!=e.mime&&e.read?e:null}).length==n?0:-1},this.exec=function(t,n){var i,a,r,o,s,l,d,c,u,h,p,f,m=this.fm,g=e.Deferred().fail(function(e){e&&m.error(e)}),v=this.files(t),b=v.length,y="object"==typeof n?n.thash:!1,n=this.options;if(!b&&!y)return g.reject();if(y||1==b&&(i=v[0])&&"directory"==i.mime)return y||!i||i.read?m.request({data:{cmd:"open",target:y||i.hash},notify:{type:"open",cnt:1,hideCnt:!0},syncOnFail:!0,lazy:!1}):g.reject(["errOpen",i.name,"errPerm"]);if(v=e.map(v,function(e){return"directory"!=e.mime?e:null}),b!=v.length)return g.reject();var w=function(){try{u=new RegExp(m.option("dispInlineRegex"))}catch(y){u=!1}for(h=e("<a>").hide().appendTo(e("body")),p="string"==typeof h.get(0).download,b=v.length;b--;){if(i=v[b],!i.read)return g.reject(["errOpen",i.name,"errPerm"]);if(f=u&&i.mime.match(u),a=m.openUrl(i.hash,!f),m.UA.Mobile||!f)if(p)!f&&h.attr("download",i.name),h.attr("href",a).attr("target","_blank").get(0).click();else{var w=window.open(a);if(!w)return g.reject("errPopup")}else{s=d=Math.round(2*e(window).width()/3),l=c=Math.round(2*e(window).height()/3),parseInt(i.width)&&parseInt(i.height)?(s=parseInt(i.width),l=parseInt(i.height)):i.dim&&(r=i.dim.split("x"),s=parseInt(r[0]),l=parseInt(r[1])),d>=s&&c>=l?(d=s,c=l):s-d>l-c?c=Math.round(l*(d/s)):d=Math.round(s*(c/l)),o="width="+d+",height="+c,0===a.indexOf(m.options.url)&&(a="");var w=window.open(a,"new_window",o+",top=50,left=50,scrollbars=yes,resizable=yes");if(!w)return g.reject("errPopup");if(""===a){var k=document.createElement("form");k.action=m.options.url,k.method="string"==typeof n.method&&"get"===n.method.toLowerCase()?"GET":"POST",k.target="new_window",k.style.display="none";var x=e.extend({},m.options.customData,{cmd:"file",target:i.hash});e.each(x,function(e,t){var n=document.createElement("input");n.name=e,n.value=t,k.appendChild(n)}),document.body.appendChild(k),k.submit()}w.focus()}}return h.remove(),g.resolve(t)};return b>1?m.confirm({title:"openMulti",text:["openMultiConfirm",b+""],accept:{label:"cmdopen",callback:function(){w()}},cancel:{label:"btnCancel",callback:function(){g.reject()}},buttons:m.getCommand("zipdl")&&m.isCommandEnabled("zipdl",m.cwd().hash)?[{label:"cmddownload",callback:function(){m.exec("download",t),g.reject()}}]:[]}):w(),g}}).prototype={forceLoad:!0},i.prototype.commands.opendir=function(){this.alwaysEnabled=!0,this.getstate=function(){var e,t=this.fm.selected(),n=t.length;return 1!==n?-1:(e=this.fm.getUI("workzone"),e.hasClass("elfinder-search-result")?0:-1)},this.exec=function(t){var n,i=this.fm,a=e.Deferred(),r=this.files(t),o=r.length;return o&&r[0].phash?(n=r[0].phash,i.trigger("searchend",{noupdate:!0}),i.request({data:{cmd:"open",target:n},notify:{type:"open",cnt:1,hideCnt:!0},syncOnFail:!1}),a):a.reject()}},i.prototype.commands.paste=function(){this.updateOnSelect=!1,this.handlers={changeclipboard:function(){this.update()}},this.shortcuts=[{pattern:"ctrl+v shift+insert"}],this.getstate=function(t){if(this._disabled)return-1;if(t){if(e.isArray(t)){if(1!=t.length)return-1;t=this.fm.file(t[0])}}else t=this.fm.cwd();return this.fm.clipboard().length&&"directory"==t.mime&&t.write?0:-1},this.exec=function(t){var n,i,a=this,r=a.fm,t=t?this.files(t)[0]:r.cwd(),o=r.clipboard(),s=o.length,l=s?o[0].cut:!1,d=l?"errMove":"errCopy",c=[],u=[],h=e.Deferred().fail(function(e){e&&r.error(e)}).always(function(){r.unlockfiles({files:e.map(o,function(e){return e.hash})})}),p=function(t){return t.length&&r._commands.duplicate?r.exec("duplicate",t):e.Deferred().resolve()},f=function(n){var i,o=e.Deferred(),s=[],d={},c=function(t,n){for(var i=[],a=t.length;a--;)-1!==e.inArray(t[a].name,n)&&i.unshift(a);return i},u=function(e){var t=s[e],i=n[t],a=e==s.length-1;i&&r.confirm({title:r.i18n(l?"moveFiles":"copyFiles"),text:["errExists",i.name,"confirmRepl"],all:!a,accept:{label:"btnYes",callback:function(t){a||t?p(n):u(++e)}},reject:{label:"btnNo",callback:function(t){var i;if(t)for(i=s.length;e<i--;)n[s[i]].remove=!0;else n[s[e]].remove=!0;a||t?p(n):u(++e)}},cancel:{label:"btnCancel",callback:function(){o.resolve()}},buttons:[{label:"btnBackup",callback:function(t){var i;if(t)for(i=s.length;e<i--;)n[s[i]].rename=!0;else n[s[e]].rename=!0;a||t?p(n):u(++e)}}]})},h=function(t){var i,a={};t&&(e.isArray(t)?t.length&&("string"==typeof t[0]?s=c(n,t):(e.each(t,function(e,t){a[t.name]=t.hash}),s=c(n,e.map(a,function(e,t){return t})),e.each(n,function(e,t){a[t.name]&&(d[a[t.name]]=t.name)}))):(i=[],s=e.map(t,function(e){return"string"==typeof e?e:(i=i.concat(e),null)}),i.length&&(s=s.concat(i)),s=c(n,s),d=t)),s.length?u(0):p(n)},p=function(n){var i,a=[],n=e.map(n,function(e){return e.rename&&a.push(e.name),e.remove?null:e}),s=n.length;return s?(i=n[0].phash,n=e.map(n,function(e){return e.hash}),void r.request({data:{cmd:"paste",dst:t.hash,targets:n,cut:l?1:0,src:i,renames:a,hashes:d,suffix:r.options.backupSuffix},notify:{type:l?"move":"copy",cnt:s}}).done(function(n){var i,a;o.resolve(n),n&&n.added&&n.added[0]&&r.one("pastedone",function(){i=r.findCwdNodes(n.added),i.length?i.trigger("scrolltoview"):(t.hash!==r.cwd().hash?a=e("<div/>").append(e('<button type="button" class="ui-button ui-widget ui-state-default ui-corner-all"><span class="ui-button-text">'+r.i18n("cmdopendir")+"</span></button>").on("mouseenter mouseleave",function(t){e(this).toggleClass("ui-state-hover","mouseenter"==t.type)}).on("click",function(){r.exec("open",t.hash).done(function(){r.one("opendone",function(){r.trigger("selectfiles",{files:e.map(n.added,function(e){return e.hash})})})})})):r.trigger("selectfiles",{files:e.map(n.added,function(e){return e.hash})}),r.toast({msg:r.i18n(["complete",r.i18n("cmd"+(l?"move":"copy"))]),extNode:a}))})}).always(function(){r.unlockfiles({files:n})})):o.resolve()};return r.isCommandEnabled(a.name,t.hash)&&n.length?(r.oldAPI?p(n):r.option("copyOverwrite")?(i=e.map(n,function(e){return e.name}),t.hash==r.cwd().hash?h(e.map(r.files(),function(e){return e.phash==t.hash?{hash:e.hash,name:e.name}:null})):r.request({data:{cmd:"ls",target:t.hash,intersect:i},notify:{type:"prepare",cnt:1,hideCnt:!0},preventFail:!0}).always(function(e){h(e.list)})):p(n),o):o.resolve()};return s&&t&&"directory"==t.mime?t.write?(n=r.parents(t.hash),e.each(o,function(a,o){return o.read?l&&o.locked?!h.reject(["errLocked",o.name]):-1!==e.inArray(o.hash,n)?!h.reject(["errCopyInItself",o.name]):o.mime&&"directory"!==o.mime&&!r.uploadMimeCheck(o.mime,t.hash)?!h.reject([d,o.name,"errUploadMime"]):(i=r.parents(o.hash),i.pop(),-1!==e.inArray(t.hash,i)&&e.map(i,function(e){var n=r.file(e);return n.phash==t.hash&&n.name==o.name?n:null}).length?!h.reject(["errReplByChild",o.name]):void(o.phash==t.hash?u.push(o.hash):c.push({hash:o.hash,phash:o.phash,name:o.name}))):!h.reject([d,o.name,"errPerm"])}),"rejected"==h.state()?h:e.when(p(u),f(c)).always(function(){l&&r.clipboard([])})):h.reject([d,o[0].name,"errPerm"]):h.reject()}},i.prototype.commands.places=function(){var t=this,n=this.fm,i=function(n){return e.map(t.files(n),function(e){return"directory"==e.mime?e:null})},a=null;this.getstate=function(e){var e=this.hashes(e),t=e.length;return a&&t&&t==i(e).length?0:-1},this.exec=function(e){var t=this.files(e);a.trigger("regist",[t])},n.one("load",function(){a=n.ui.places})},(i.prototype.commands.quicklook=function(){var t,n,i,a,r=this,o=r.fm,s=0,l=1,d=2,c=s,u="elfinder-quicklook-navbar-icon",h="elfinder-quicklook-fullscreen",p=function(t){e(document).trigger(e.Event("keydown",{keyCode:t,ctrlKey:!1,shiftKey:!1,altKey:!1,metaKey:!1}))},f=function(e){var t=o.getUI().offset(),n=e.find(".elfinder-cwd-file-wrapper"),i=n.offset();return{opacity:0,width:n.width(),height:n.height(),top:i.top-t.top,left:i.left-t.left}},m=function(){var i=e(window),a=o.getUI().offset(),r=Math.min(t,e(window).width()-10),s=Math.min(n,e(window).height()-80);return{opacity:1,width:r,height:s,top:parseInt((i.height()-s-60)/2+i.scrollTop()-a.top),left:parseInt((i.width()-r)/2+i.scrollLeft()-a.left)}},g=function(e){var t=document.createElement(e.substr(0,e.indexOf("/"))),n=!1;try{n=t.canPlayType&&t.canPlayType(e)}catch(i){}return n&&""!==n&&"no"!=n},v=!1,b=!1,y=null,w=e.ui.keyCode.LEFT,k=e.ui.keyCode.RIGHT,x="mousemove touchstart "+("onwheel"in document?"wheel":"onmousewheel"in document?"mousewheel":"DOMMouseScroll"),C=e('<div class="elfinder-quicklook-title"/>'),T=e("<div/>"),z=e('<div class="elfinder-quicklook-info"/>'),A=e('<div class="ui-front elfinder-quicklook-cover"/>'),I=e('<div class="'+u+" "+u+'-fullscreen"/>').on("click touchstart",function(t){if(!b){var n=r.window,a=n.hasClass(h),s=e(window),l=function(){r.preview.trigger("changesize")};t.stopPropagation(),t.preventDefault(),a?(F="",S(),n.toggleClass(h).css(n.data("position")),s.trigger(r.resize).off(r.resize,l),D.off("mouseenter mouseleave"),A.off(x)):(n.toggleClass(h).data("position",{left:n.css("left"),top:n.css("top"),width:n.width(),height:n.height(),display:"block"}).removeAttr("style"),e(window).on(r.resize,l).trigger(r.resize),A.on(x,function(e){v||("mousemove"!==e.type&&"touchstart"!==e.type||(S(),y=setTimeout(function(){(o.UA.Mobile||D.parent().find(".elfinder-quicklook-navbar:hover").length<1)&&D.fadeOut("slow",function(){A.show()})},3e3)),A.is(":visible")&&(U(),A.data("tm",setTimeout(function(){A.show()},3e3))))}).show().trigger("mousemove"),D.on("mouseenter mouseleave",function(e){v||("mouseenter"===e.type?S():A.trigger("mousemove"))})),o.zIndex&&n.css("z-index",o.zIndex+1),o.UA.Mobile?D.attr("style",F):D.attr("style",F).draggable(a?"destroy":{start:function(){v=!0,b=!0,A.show(),S()},stop:function(){v=!1,F=r.navbar.attr("style"),setTimeout(function(){b=!1},20)}}),e(this).toggleClass(u+"-fullscreen-off");var d=n;i.is(".ui-resizable")&&(d=d.add(i)),e.fn.resizable&&d.resizable(a?"enable":"disable").removeClass("ui-state-disabled"),n.trigger("viewchange")}}),S=function(){r.window.hasClass(h)&&(y&&clearTimeout(y),y=null,D.stop(!0,!0).css("display","block"),U())},U=function(){A.data("tm")&&clearTimeout(A.data("tm")),A.removeData("tm"),A.hide()},M=e('<div class="'+u+" "+u+'-prev"/>').on("click touchstart",function(e){return!b&&p(w),!1}),O=e('<div class="'+u+" "+u+'-next"/>').on("click touchstart",function(e){return!b&&p(k),!1}),D=e('<div class="elfinder-quicklook-navbar"/>').append(M).append(I).append(O).append('<div class="elfinder-quicklook-navbar-separator"/>').append(e('<div class="'+u+" "+u+'-close"/>').on("click touchstart",function(e){return!b&&r.window.trigger("close"),!1})),F="";(this.navbar=D)._show=S,this.resize="resize."+o.namespace,this.info=e('<div class="elfinder-quicklook-info-wrapper"/>').append(T).append(z),this.preview=e('<div class="elfinder-quicklook-preview ui-helper-clearfix"/>').on("change",function(){S(),D.attr("style",F),r.preview.attr("style","").removeClass("elfinder-overflow-auto"),r.info.attr("style","").hide(),T.removeAttr("class").attr("style",""),z.html("")}).on("update",function(t){var n,i=r.fm,o=(r.preview,t.file),s='<div class="elfinder-quicklook-info-data">{value}</div>';o&&(t.forceUpdate||r.window.data("hash")!==o.hash)?(!o.read&&t.stopImmediatePropagation(),r.window.data("hash",o.hash),r.preview.off("changesize").trigger("change").children().remove(),C.html(i.escape(o.name)),M.css("visibility",""),O.css("visibility",""),o.hash===i.cwdId2Hash(a.find("[id]:first").attr("id"))&&M.css("visibility","hidden"),o.hash===i.cwdId2Hash(a.find("[id]:last").attr("id"))&&O.css("visibility","hidden"),z.html(s.replace(/\{value\}/,i.escape(o.name))+s.replace(/\{value\}/,i.mime2kind(o))+("directory"==o.mime?"":s.replace(/\{value\}/,i.formatSize(o.size)))+s.replace(/\{value\}/,i.i18n("modify")+": "+i.formatDate(o))),T.addClass("elfinder-cwd-icon ui-corner-all "+i.mime2class(o.mime)),o.read&&(n=i.tmb(o))&&e("<img/>").hide().appendTo(r.preview).on("load",function(){T.addClass(n.className).css("background-image","url('"+n.url+"')"),e(this).remove()}).attr("src",n.url),r.info.delay(100).fadeIn(10),r.window.hasClass(h)&&A.trigger("mousemove")):t.stopImmediatePropagation()}),this.window=e('<div class="ui-front ui-helper-reset ui-widget elfinder-quicklook touch-punch" style="position:absolute"/>').hide().addClass(o.UA.Touch?"elfinder-touch":"").on("click",function(e){e.stopPropagation()}).append(e('<div class="elfinder-quicklook-titlebar"/>').append(C,e('<span class="ui-icon ui-icon-circle-close"/>').mousedown(function(e){e.stopPropagation(),r.window.trigger("close")})),this.preview,r.info.hide(),A.hide(),D).draggable({handle:"div.elfinder-quicklook-titlebar"}).on("open",function(t){var n,i=r.window,a=r.value;r.closed()&&a&&(n=e("#"+o.cwdHash2Id(a.hash))).length&&(F="",D.attr("style",""),c=l,n.trigger("scrolltoview"),U(),i.css(f(n)).show().animate(m(),550,function(){c=d,r.update(1,r.value),S()}))}).on("close",function(e){var t=r.window,n=r.preview.trigger("change"),i=(r.value,a.find("#"+o.cwdHash2Id(t.data("hash")))),d=function(){c=s,t.hide(),n.children().remove(),r.update(0,r.value)};t.data("hash",""),r.opened()&&(c=l,t.hasClass(h)&&I.click(),i.length?t.animate(f(i),500,d):d())}),this.alwaysEnabled=!0,this.value=null,this.handlers={select:function(){this.update(void 0,this.fm.selectedFiles()[0])},error:function(){r.window.is(":visible")&&r.window.data("hash","").trigger("close")},"searchshow searchhide":function(){this.opened()&&this.window.trigger("close")}},this.shortcuts=[{pattern:"space"}],this.support={audio:{ogg:g('audio/ogg; codecs="vorbis"'),mp3:g("audio/mpeg;"),wav:g('audio/wav; codecs="1"'),m4a:g("audio/mp4;")||g("audio/x-m4a;")||g("audio/aac;")},video:{ogg:g('video/ogg; codecs="theora"'),webm:g('video/webm; codecs="vp8, vorbis"'),mp4:g('video/mp4; codecs="avc1.42E01E"')||g('video/mp4; codecs="avc1.42E01E, mp4a.40.2"')}},this.closed=function(){return c==s},this.opened=function(){return c==d},this.init=function(){var s,l=this.options,d=this.window,c=this.preview;t=l.width>0?parseInt(l.width):450,n=l.height>0?parseInt(l.height):300,o.one("load",function(){i=o.getUI(),a=o.getUI("cwd"),o.zIndex&&d.css("z-index",o.zIndex+1),d.appendTo(i),e(document).keydown(function(t){t.keyCode==e.ui.keyCode.ESCAPE&&r.opened()&&d.trigger("close")}),e.fn.resizable&&d.resizable({handles:"se",minWidth:350,minHeight:120,resize:function(){c.trigger("changesize")}}),r.change(function(){r.opened()&&setTimeout(function(){r.value?c.trigger(e.Event("update",{file:r.value})):(p(k),setTimeout(function(){!r.value&&d.trigger("close")},10))},10)}),c.on("update",function(e){if(o.searchStatus.mixed&&o.searchStatus.state>1)try{r.dispInlineRegex=new RegExp(o.option("dispInlineRegex",e.file.hash))}catch(t){r.dispInlineRegex=/.*/}r.info.show()}),e.each(o.commands.quicklook.plugins||[],function(e,t){"function"==typeof t&&new t(r)})}),o.bind("open",function(){var e=s;s=o.cwd().hash,r.opened()&&e!==s&&d.trigger("close");try{r.dispInlineRegex=new RegExp(o.option("dispInlineRegex"))}catch(t){r.dispInlineRegex=/.*/}}),o.bind("destroy",function(){r.window.remove()})},this.getstate=function(){var t=this.fm,n=t.selected(),i=1===n.length&&e("#"+t.cwdHash2Id(n[0])).length;return i?c==d?1:0:-1},this.exec=function(){this.enabled()&&this.window.trigger(this.opened()?"close":"open")},this.hideinfo=function(){this.info.stop(!0,!0).hide()}}).prototype={forceLoad:!0},i.prototype.commands.quicklook.plugins=[function(t){var n=["image/jpeg","image/png","image/gif","image/svg+xml","image/x-ms-bmp"],i=t.preview;e.each(navigator.mimeTypes,function(t,i){var a=i.type;0===a.indexOf("image/")&&e.inArray(a,n)&&n.push(a)}),i.on("update",function(a){var r,o,s,l,d=t.fm,c=a.file;t.dispInlineRegex.test(c.mime)&&-1!==e.inArray(c.mime,n)&&(a.stopImmediatePropagation(),s=e('<div class="elfinder-quicklook-info-data"> '+d.i18n("nowLoading")+'<span class="elfinder-info-spinner"></div>').appendTo(t.info.find(".elfinder-quicklook-info")),r=d.openUrl(c.hash),r+=-1===r.indexOf("?")?"?_=":(l=r.match(/[\?&](_+)=/))?"&"+"_".repeat(l[1].length+1)+"=":"&_=",r+=c.ts||+new Date,o=e("<img/>").hide().appendTo(i).on("load",function(){setTimeout(function(){var e=(o.width()/o.height()).toFixed(2);i.on("changesize",function(){var t,n,a=parseInt(i.width()),r=parseInt(i.height());e<(a/r).toFixed(2)?(n=r,t=Math.floor(n*e)):(t=a,n=Math.floor(t/e)),o.width(t).height(n).css("margin-top",r>n?Math.floor((r-n)/2):0)}).trigger("changesize"),s.remove(),t.hideinfo(),o.fadeIn(100)},1)}).on("error",function(){s.remove()}).attr("src",r))})},function(t){var n=["text/html","application/xhtml+xml"],i=t.preview,a=t.fm;i.on("update",function(r){var o,s,l=r.file;t.dispInlineRegex.test(l.mime)&&-1!==e.inArray(l.mime,n)&&(r.stopImmediatePropagation(),s=e('<div class="elfinder-quicklook-info-data"> '+a.i18n("nowLoading")+'<span class="elfinder-info-spinner"></div>').appendTo(t.info.find(".elfinder-quicklook-info")),i.one("change",function(){"pending"==o.state()&&o.reject()}).addClass("elfinder-overflow-auto"),o=a.request({data:{cmd:"get",target:l.hash,current:l.phash,conv:1},preventDefault:!0}).done(function(n){t.hideinfo();var a=e('<iframe class="elfinder-quicklook-preview-html"/>').appendTo(i)[0].contentWindow.document;a.open(),a.write(n.content),a.close()}).always(function(){s.remove()}))})},function(t){var n=t.fm,i=n.res("mimes","text"),a=t.preview;a.on("update",function(r){var o,s,l=r.file,d=l.mime;0!==d.indexOf("text/")&&-1===e.inArray(d,i)||(r.stopImmediatePropagation(),s=e('<div class="elfinder-quicklook-info-data"> '+n.i18n("nowLoading")+'<span class="elfinder-info-spinner"></div>').appendTo(t.info.find(".elfinder-quicklook-info")),a.one("change",function(){"pending"==o.state()&&o.reject()}),o=n.request({data:{cmd:"get",target:l.hash,conv:1},preventDefault:!0}).done(function(i){t.hideinfo(),e('<div class="elfinder-quicklook-preview-text-wrapper"><pre class="elfinder-quicklook-preview-text">'+n.escape(i.content)+"</pre></div>").appendTo(a)}).always(function(){s.remove()}))})},function(t){var n=t.fm,i="application/pdf",a=t.preview,r=!1;n.UA.Safari&&"mac"==n.OS||n.UA.IE?r=!0:e.each(navigator.plugins,function(t,n){e.each(n,function(e,t){return t.type==i?!(r=!0):void 0})}),r&&a.on("update",function(r){var o,s=r.file;t.dispInlineRegex.test(s.mime)&&s.mime==i&&(r.stopImmediatePropagation(),a.one("change",function(){o.off("load").remove()}).addClass("elfinder-overflow-auto"),o=e('<iframe class="elfinder-quicklook-preview-pdf"/>').hide().appendTo(a).on("load",function(){t.hideinfo(),o.show()}).attr("src",n.url(s.hash)))})},function(t){var n=t.fm,i="application/x-shockwave-flash",a=t.preview,r=!1;e.each(navigator.plugins,function(t,n){e.each(n,function(e,t){return t.type==i?!(r=!0):void 0})}),r&&a.on("update",function(r){var o,s=r.file;t.dispInlineRegex.test(s.mime)&&s.mime==i&&(r.stopImmediatePropagation(),t.hideinfo(),o=e('<embed class="elfinder-quicklook-preview-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="'+n.url(s.hash)+'" quality="high" type="application/x-shockwave-flash" wmode="transparent" />').appendTo(a))})},function(t){var n,i=t.preview,a=!!t.options.autoplay,r={"audio/mpeg":"mp3","audio/mpeg3":"mp3","audio/mp3":"mp3","audio/x-mpeg3":"mp3","audio/x-mp3":"mp3","audio/x-wav":"wav","audio/wav":"wav","audio/x-m4a":"m4a","audio/aac":"m4a","audio/mp4":"m4a","audio/x-mp4":"m4a","audio/ogg":"ogg"},o=t.window,s=t.navbar;i.on("update",function(l){var d=l.file,c=r[d.mime],u=function(){s.css("bottom",o.hasClass("elfinder-quicklook-fullscreen")?"50px":"")};t.support.audio[c]&&(l.stopImmediatePropagation(),n=e('<audio class="elfinder-quicklook-preview-audio" controls preload="auto" autobuffer><source src="'+t.fm.openUrl(d.hash)+'" /></audio>').appendTo(i),a&&n[0].play(),o.on("viewchange.audio",u),u())}).on("change",function(){n&&n.parent().length&&(o.off("viewchange.audio"),n[0].pause(),n.remove(),n=null)})},function(t){var n,i=t.preview,a=!!t.options.autoplay,r={"video/mp4":"mp4","video/x-m4v":"mp4","video/quicktime":"mp4","video/ogg":"ogg","application/ogg":"ogg","video/webm":"webm"},o=t.window,s=t.navbar;i.on("update",function(l){var d=l.file,c=r[d.mime],u=function(){t.fm.UA.iOS?o.hasClass("elfinder-quicklook-fullscreen")?(i.css("height","-webkit-calc(100% - 50px)"),s._show()):i.css("height",""):s.css("bottom",o.hasClass("elfinder-quicklook-fullscreen")?"50px":"")};t.support.video[c]&&(l.stopImmediatePropagation(),t.hideinfo(),n=e('<video class="elfinder-quicklook-preview-video" controls preload="auto" autobuffer><source src="'+t.fm.openUrl(d.hash)+'" /></video>').appendTo(i),a&&n[0].play(),o.on("viewchange.video",u),u())}).on("change",function(){n&&n.parent().length&&(o.off("viewchange.video"),n[0].pause(),n.remove(),n=null)})},function(t){var n,i=t.preview,a=[],r=t.window,o=t.navbar;e.each(navigator.plugins,function(t,n){e.each(n,function(e,t){(0===t.type.indexOf("audio/")||0===t.type.indexOf("video/"))&&a.push(t.type)})}),i.on("update",function(s){var l,d=s.file,c=d.mime,u=function(){o.css("bottom",r.hasClass("elfinder-quicklook-fullscreen")?"50px":"")};-1!==e.inArray(d.mime,a)&&(s.stopImmediatePropagation(),(l=0===c.indexOf("video/"))&&t.hideinfo(),n=e('<embed src="'+t.fm.openUrl(d.hash)+'" type="'+c+'" class="elfinder-quicklook-preview-'+(l?"video":"audio")+'"/>').appendTo(i),r.on("viewchange.embed",u),u())}).on("change",function(){n&&n.parent().length&&(r.off("viewchange.embed"),n.remove(),n=null)})},function(t){var n=["application/zip","application/x-gzip","application/x-tar"],a=t.preview,r=t.fm;"undefined"!=typeof Uint8Array&&i.Zlib&&a.on("update",function(o){var s,l,d,c=o.file;-1!==e.inArray(c.mime,n)&&(o.stopImmediatePropagation(),d=e('<div class="elfinder-quicklook-info-data"> '+r.i18n("nowLoading")+'<span class="elfinder-info-spinner"></div>').appendTo(t.info.find(".elfinder-quicklook-info")),a.one("change",function(){d.remove(),l&&l.readyState<4&&l.abort()}),l=new XMLHttpRequest,l.onload=function(n){var o,u,h,p,f,m,g,v,b,y,w,k=[];4===this.readyState&&this.response?setTimeout(function(){try{if("application/zip"===c.mime)u=new i.Zlib.Unzip(new Uint8Array(l.response)),k=u.getFilenames();else for("application/x-gzip"===c.mime?(u=new i.Zlib.Gunzip(new Uint8Array(l.response)),h=u.decompress()):h=new Uint8Array(l.response),p=h.length,f=0,w=function(e){return String.fromCharCode.apply(null,e).replace(/\0+$/,"")};p>f&&0!==h[f];)m=h.subarray(f,f+512),g=w(m.subarray(0,100)),(v=w(m.subarray(345,500)))&&(g=v+g),b=parseInt(w(m.subarray(124,136)),8),y=512*Math.ceil(b/512),"././@LongLink"===g&&(g=w(h.subarray(f+512,f+512+y))),"pax_global_header"!==g&&k.push(g),f=f+512+y}catch(n){d.remove(),r.debug("error",n)}k&&k.length&&(k=e.map(k,function(e){return r.decodeRawString(e)}),k.sort(),d.remove(),o="<strong>"+r.escape(c.mime)+"</strong> ("+r.formatSize(c.size)+")<hr/>",s=e('<div class="elfinder-quicklook-preview-archive-wrapper">'+o+'<pre class="elfinder-quicklook-preview-text">'+r.escape(k.join("\n"))+"</pre></div>").appendTo(a),t.hideinfo())},70):d.remove()},l.open("GET",r.openUrl(c.hash,r.xhrFields.withCredentials||!1),!0),l.responseType="arraybuffer",r.customHeaders&&e.each(r.customHeaders,function(e){l.setRequestHeader(e,this)}),r.xhrFields&&e.each(r.xhrFields,function(e){e in l&&(l[e]=this)}),l.send())})},function(t){var n,i=t.fm,a=t.options.googleDocsMimes||[],r=t.preview,o=(t.window,t.navbar);r.on("update",function(s){var l,d=t.window,c=s.file,u=function(){o.css("bottom",d.hasClass("elfinder-quicklook-fullscreen")?"56px":"")};-1!==e.inArray(c.mime,a)&&("1"==c.url&&e('<div class="elfinder-quicklook-info-data"><button class="elfinder-info-button">'+i.i18n("getLink")+"</button></div>").appendTo(t.info.find(".elfinder-quicklook-info")).on("click",function(){var t=e(this);t.html('<span class="elfinder-info-spinner">'),i.request({data:{cmd:"url",target:c.hash},preventDefault:!0}).always(function(){t.html("")}).done(function(e){var t=i.file(c.hash);c.url=t.url=e.url||"",c.url&&r.trigger({type:"update",file:c,forceUpdate:!0})})}),""!==c.url&&"1"!=c.url&&(s.stopImmediatePropagation(),r.one("change",function(){d.off("viewchange.googledocs"),l.remove(),n.off("load").remove(),n=null}).addClass("elfinder-overflow-auto"),l=e('<div class="elfinder-quicklook-info-data"> '+i.i18n("nowLoading")+'<span class="elfinder-info-spinner"></div>').appendTo(t.info.find(".elfinder-quicklook-info")),n=e('<iframe class="elfinder-quicklook-preview-iframe"/>').css("background-color","transparent").appendTo(r).on("load",function(){t.hideinfo(),l.remove(),e(this).css("background-color","#fff").show()}).attr("src","//docs.google.com/gview?embedded=true&url="+encodeURIComponent(i.convAbsUrl(i.url(c.hash)))),
  1822. d.on("viewchange.googledocs",u),u()))})}];try{(function(){(function(){"use strict";function e(e){throw e}function t(e,t){var n=e.split("."),i=m;!(n[0]in i)&&i.execScript&&i.execScript("var "+n[0]);for(var a;n.length&&(a=n.shift());)n.length||t===f?i=i[a]?i[a]:i[a]={}:i[a]=t}function n(e){var t,n,i,a,r,o,s,l,d,c,u=e.length,h=0,p=Number.POSITIVE_INFINITY;for(l=0;u>l;++l)e[l]>h&&(h=e[l]),e[l]<p&&(p=e[l]);for(t=1<<h,n=new(g?Uint32Array:Array)(t),i=1,a=0,r=2;h>=i;){for(l=0;u>l;++l)if(e[l]===i){for(o=0,s=a,d=0;i>d;++d)o=o<<1|1&s,s>>=1;for(c=i<<16|l,d=o;t>d;d+=r)n[d]=c;++a}++i,a<<=1,r<<=1}return[n,h,p]}function i(t,n){switch(this.l=[],this.m=32768,this.d=this.f=this.c=this.t=0,this.input=g?new Uint8Array(t):t,this.u=!1,this.n=A,this.L=!1,!n&&(n={})||(n.index&&(this.c=n.index),n.bufferSize&&(this.m=n.bufferSize),n.bufferType&&(this.n=n.bufferType),n.resize&&(this.L=n.resize)),this.n){case z:this.a=32768,this.b=new(g?Uint8Array:Array)(32768+this.m+258);break;case A:this.a=0,this.b=new(g?Uint8Array:Array)(this.m),this.e=this.X,this.B=this.S,this.q=this.W;break;default:e(Error("invalid inflate mode"))}}function a(t,n){for(var i,a=t.f,r=t.d,o=t.input,s=t.c,l=o.length;n>r;)s>=l&&e(Error("input buffer is broken")),a|=o[s++]<<r,r+=8;return i=a&(1<<n)-1,t.f=a>>>n,t.d=r-n,t.c=s,i}function r(e,t){for(var n,i,a=e.f,r=e.d,o=e.input,s=e.c,l=o.length,d=t[0],c=t[1];c>r&&!(s>=l);)a|=o[s++]<<r,r+=8;return n=d[a&(1<<c)-1],i=n>>>16,e.f=a>>i,e.d=r-i,e.c=s,65535&n}function o(e){function t(e,t,n){var i,o,s,l=this.K;for(s=0;e>s;)switch(i=r(this,t)){case 16:for(o=3+a(this,2);o--;)n[s++]=l;break;case 17:for(o=3+a(this,3);o--;)n[s++]=0;l=0;break;case 18:for(o=11+a(this,7);o--;)n[s++]=0;l=0;break;default:l=n[s++]=i}return this.K=l,n}var i,o,s,l,d=a(e,5)+257,c=a(e,5)+1,u=a(e,4)+4,h=new(g?Uint8Array:Array)(M.length);for(l=0;u>l;++l)h[M[l]]=a(e,3);if(!g)for(l=u,u=h.length;u>l;++l)h[M[l]]=0;i=n(h),o=new(g?Uint8Array:Array)(d),s=new(g?Uint8Array:Array)(c),e.K=0,e.q(n(t.call(e,d,i,o)),n(t.call(e,c,i,s)))}function s(e){e=e||{},this.files=[],this.v=e.comment}function l(e,t){t=t||{},this.input=g&&e instanceof Array?new Uint8Array(e):e,this.c=0,this.ca=t.verify||!1,this.j=t.password}function d(e,t){this.input=e,this.offset=t}function c(e,t){this.input=e,this.offset=t}function u(t){var n,i,a,r,o=[],s={};if(!t.i){if(t.o===f){var l,c=t.input;if(!t.D)e:{var u,h=t.input;for(u=h.length-12;u>0;--u)if(h[u]===G[0]&&h[u+1]===G[1]&&h[u+2]===G[2]&&h[u+3]===G[3]){t.D=u;break e}e(Error("End of Central Directory Record not found"))}l=t.D,(c[l++]!==G[0]||c[l++]!==G[1]||c[l++]!==G[2]||c[l++]!==G[3])&&e(Error("invalid signature")),t.ia=c[l++]|c[l++]<<8,t.ka=c[l++]|c[l++]<<8,t.la=c[l++]|c[l++]<<8,t.ba=c[l++]|c[l++]<<8,t.R=(c[l++]|c[l++]<<8|c[l++]<<16|c[l++]<<24)>>>0,t.o=(c[l++]|c[l++]<<8|c[l++]<<16|c[l++]<<24)>>>0,t.w=c[l++]|c[l++]<<8,t.v=g?c.subarray(l,l+t.w):c.slice(l,l+t.w)}for(n=t.o,a=0,r=t.ba;r>a;++a)i=new d(t.input,n),i.parse(),n+=i.length,o[a]=i,s[i.filename]=a;t.R<n-t.o&&e(Error("invalid file header size")),t.i=o,t.G=s}}function h(e,t,n){return n^=e.s(t),e.k(t,n),n}var p,f=void 0,m=this,g="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array&&"undefined"!=typeof DataView;new(g?Uint8Array:Array)(256);var v;for(v=0;256>v;++v)for(var b=v,y=7,b=b>>>1;b;b>>>=1)--y;var w,k=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],x=g?new Uint32Array(k):k,C=[];for(w=0;288>w;w++)switch(!0){case 143>=w:C.push([w+48,8]);break;case 255>=w:C.push([w-144+400,9]);break;case 279>=w:C.push([w-256+0,7]);break;case 287>=w:C.push([w-280+192,8]);break;default:e("invalid literal: "+w)}var T=function(){function t(t){switch(!0){case 3===t:return[257,t-3,0];case 4===t:return[258,t-4,0];case 5===t:return[259,t-5,0];case 6===t:return[260,t-6,0];case 7===t:return[261,t-7,0];case 8===t:return[262,t-8,0];case 9===t:return[263,t-9,0];case 10===t:return[264,t-10,0];case 12>=t:return[265,t-11,1];case 14>=t:return[266,t-13,1];case 16>=t:return[267,t-15,1];case 18>=t:return[268,t-17,1];case 22>=t:return[269,t-19,2];case 26>=t:return[270,t-23,2];case 30>=t:return[271,t-27,2];case 34>=t:return[272,t-31,2];case 42>=t:return[273,t-35,3];case 50>=t:return[274,t-43,3];case 58>=t:return[275,t-51,3];case 66>=t:return[276,t-59,3];case 82>=t:return[277,t-67,4];case 98>=t:return[278,t-83,4];case 114>=t:return[279,t-99,4];case 130>=t:return[280,t-115,4];case 162>=t:return[281,t-131,5];case 194>=t:return[282,t-163,5];case 226>=t:return[283,t-195,5];case 257>=t:return[284,t-227,5];case 258===t:return[285,t-258,0];default:e("invalid length: "+t)}}var n,i,a=[];for(n=3;258>=n;n++)i=t(n),a[n]=i[2]<<24|i[1]<<16|i[0];return a}();g&&new Uint32Array(T);var z=0,A=1;i.prototype.r=function(){for(;!this.u;){var t=a(this,3);switch(1&t&&(this.u=!0),t>>>=1){case 0:var n=this.input,i=this.c,r=this.b,s=this.a,l=n.length,d=f,c=f,u=r.length,h=f;switch(this.d=this.f=0,i+1>=l&&e(Error("invalid uncompressed block header: LEN")),d=n[i++]|n[i++]<<8,i+1>=l&&e(Error("invalid uncompressed block header: NLEN")),c=n[i++]|n[i++]<<8,d===~c&&e(Error("invalid uncompressed block header: length verify")),i+d>n.length&&e(Error("input buffer is broken")),this.n){case z:for(;s+d>r.length;){if(h=u-s,d-=h,g)r.set(n.subarray(i,i+h),s),s+=h,i+=h;else for(;h--;)r[s++]=n[i++];this.a=s,r=this.e(),s=this.a}break;case A:for(;s+d>r.length;)r=this.e({H:2});break;default:e(Error("invalid inflate mode"))}if(g)r.set(n.subarray(i,i+d),s),s+=d,i+=d;else for(;d--;)r[s++]=n[i++];this.c=i,this.a=s,this.b=r;break;case 1:this.q(L,B);break;case 2:o(this);break;default:e(Error("unknown BTYPE: "+t))}}return this.B()};var I,S,U=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],M=g?new Uint16Array(U):U,O=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],D=g?new Uint16Array(O):O,F=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],E=g?new Uint8Array(F):F,P=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],R=g?new Uint16Array(P):P,j=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],H=g?new Uint8Array(j):j,N=new(g?Uint8Array:Array)(288);for(I=0,S=N.length;S>I;++I)N[I]=143>=I?8:255>=I?9:279>=I?7:8;var q,_,L=n(N),W=new(g?Uint8Array:Array)(30);for(q=0,_=W.length;_>q;++q)W[q]=5;var B=n(W);p=i.prototype,p.q=function(e,t){var n=this.b,i=this.a;this.C=e;for(var o,s,l,d,c=n.length-258;256!==(o=r(this,e));)if(256>o)i>=c&&(this.a=i,n=this.e(),i=this.a),n[i++]=o;else for(s=o-257,d=D[s],0<E[s]&&(d+=a(this,E[s])),o=r(this,t),l=R[o],0<H[o]&&(l+=a(this,H[o])),i>=c&&(this.a=i,n=this.e(),i=this.a);d--;)n[i]=n[i++-l];for(;8<=this.d;)this.d-=8,this.c--;this.a=i},p.W=function(e,t){var n=this.b,i=this.a;this.C=e;for(var o,s,l,d,c=n.length;256!==(o=r(this,e));)if(256>o)i>=c&&(n=this.e(),c=n.length),n[i++]=o;else for(s=o-257,d=D[s],0<E[s]&&(d+=a(this,E[s])),o=r(this,t),l=R[o],0<H[o]&&(l+=a(this,H[o])),i+d>c&&(n=this.e(),c=n.length);d--;)n[i]=n[i++-l];for(;8<=this.d;)this.d-=8,this.c--;this.a=i},p.e=function(){var e,t,n=new(g?Uint8Array:Array)(this.a-32768),i=this.a-32768,a=this.b;if(g)n.set(a.subarray(32768,n.length));else for(e=0,t=n.length;t>e;++e)n[e]=a[e+32768];if(this.l.push(n),this.t+=n.length,g)a.set(a.subarray(i,i+32768));else for(e=0;32768>e;++e)a[e]=a[i+e];return this.a=32768,a},p.X=function(e){var t,n,i,a,r=this.input.length/this.c+1|0,o=this.input,s=this.b;return e&&("number"==typeof e.H&&(r=e.H),"number"==typeof e.Q&&(r+=e.Q)),2>r?(n=(o.length-this.c)/this.C[2],a=258*(n/2)|0,i=a<s.length?s.length+a:s.length<<1):i=s.length*r,g?(t=new Uint8Array(i),t.set(s)):t=s,this.b=t},p.B=function(){var e,t,n,i,a,r=0,o=this.b,s=this.l,l=new(g?Uint8Array:Array)(this.t+(this.a-32768));if(0===s.length)return g?this.b.subarray(32768,this.a):this.b.slice(32768,this.a);for(t=0,n=s.length;n>t;++t)for(e=s[t],i=0,a=e.length;a>i;++i)l[r++]=e[i];for(t=32768,n=this.a;n>t;++t)l[r++]=o[t];return this.l=[],this.buffer=l},p.S=function(){var e,t=this.a;return g?this.L?(e=new Uint8Array(t),e.set(this.b.subarray(0,t))):e=this.b.subarray(0,t):(this.b.length>t&&(this.b.length=t),e=this.b),this.buffer=e},s.prototype.M=function(e){this.j=e},s.prototype.s=function(e){var t=65535&e[2]|2;return t*(1^t)>>8&255},s.prototype.k=function(e,t){e[0]=(x[255&(e[0]^t)]^e[0]>>>8)>>>0,e[1]=(6681*(20173*(e[1]+(255&e[0]))>>>0)>>>0)+1>>>0,e[2]=(x[255&(e[2]^e[1]>>>24)]^e[2]>>>8)>>>0},s.prototype.U=function(e){var t,n,i=[305419896,591751049,878082192];for(g&&(i=new Uint32Array(i)),t=0,n=e.length;n>t;++t)this.k(i,255&e[t]);return i};var V={P:0,N:8},$=[80,75,1,2],K=[80,75,3,4],G=[80,75,5,6];d.prototype.parse=function(){var t=this.input,n=this.offset;(t[n++]!==$[0]||t[n++]!==$[1]||t[n++]!==$[2]||t[n++]!==$[3])&&e(Error("invalid file header signature")),this.version=t[n++],this.ja=t[n++],this.$=t[n++]|t[n++]<<8,this.I=t[n++]|t[n++]<<8,this.A=t[n++]|t[n++]<<8,this.time=t[n++]|t[n++]<<8,this.V=t[n++]|t[n++]<<8,this.p=(t[n++]|t[n++]<<8|t[n++]<<16|t[n++]<<24)>>>0,this.z=(t[n++]|t[n++]<<8|t[n++]<<16|t[n++]<<24)>>>0,this.J=(t[n++]|t[n++]<<8|t[n++]<<16|t[n++]<<24)>>>0,this.h=t[n++]|t[n++]<<8,this.g=t[n++]|t[n++]<<8,this.F=t[n++]|t[n++]<<8,this.fa=t[n++]|t[n++]<<8,this.ha=t[n++]|t[n++]<<8,this.ga=t[n++]|t[n++]<<8|t[n++]<<16|t[n++]<<24,this.aa=(t[n++]|t[n++]<<8|t[n++]<<16|t[n++]<<24)>>>0,this.filename=String.fromCharCode.apply(null,g?t.subarray(n,n+=this.h):t.slice(n,n+=this.h)),this.Y=g?t.subarray(n,n+=this.g):t.slice(n,n+=this.g),this.v=g?t.subarray(n,n+this.F):t.slice(n,n+this.F),this.length=n-this.offset};var J={O:1,da:8,ea:2048};c.prototype.parse=function(){var t=this.input,n=this.offset;(t[n++]!==K[0]||t[n++]!==K[1]||t[n++]!==K[2]||t[n++]!==K[3])&&e(Error("invalid local file header signature")),this.$=t[n++]|t[n++]<<8,this.I=t[n++]|t[n++]<<8,this.A=t[n++]|t[n++]<<8,this.time=t[n++]|t[n++]<<8,this.V=t[n++]|t[n++]<<8,this.p=(t[n++]|t[n++]<<8|t[n++]<<16|t[n++]<<24)>>>0,this.z=(t[n++]|t[n++]<<8|t[n++]<<16|t[n++]<<24)>>>0,this.J=(t[n++]|t[n++]<<8|t[n++]<<16|t[n++]<<24)>>>0,this.h=t[n++]|t[n++]<<8,this.g=t[n++]|t[n++]<<8,this.filename=String.fromCharCode.apply(null,g?t.subarray(n,n+=this.h):t.slice(n,n+=this.h)),this.Y=g?t.subarray(n,n+=this.g):t.slice(n,n+=this.g),this.length=n-this.offset},p=l.prototype,p.Z=function(){var e,t,n,i=[];for(this.i||u(this),n=this.i,e=0,t=n.length;t>e;++e)i[e]=n[e].filename;return i},p.r=function(t,n){var a;this.G||u(this),a=this.G[t],a===f&&e(Error(t+" not found"));var r;r=n||{};var o,s,l,d,p,m,v,b,y=this.input,w=this.i;if(w||u(this),w[a]===f&&e(Error("wrong index")),s=w[a].aa,o=new c(this.input,s),o.parse(),s+=o.length,l=o.z,0!==(o.I&J.O)){for(!r.password&&!this.j&&e(Error("please set password")),m=this.T(r.password||this.j),v=s,b=s+12;b>v;++v)h(this,m,y[v]);for(s+=12,l-=12,v=s,b=s+l;b>v;++v)y[v]=h(this,m,y[v])}switch(o.A){case V.P:d=g?this.input.subarray(s,s+l):this.input.slice(s,s+l);break;case V.N:d=new i(this.input,{index:s,bufferSize:o.J}).r();break;default:e(Error("unknown compression type"))}if(this.ca){var k,C=f,T="number"==typeof C?C:C=0,z=d.length;for(k=-1,T=7&z;T--;++C)k=k>>>8^x[255&(k^d[C])];for(T=z>>3;T--;C+=8)k=k>>>8^x[255&(k^d[C])],k=k>>>8^x[255&(k^d[C+1])],k=k>>>8^x[255&(k^d[C+2])],k=k>>>8^x[255&(k^d[C+3])],k=k>>>8^x[255&(k^d[C+4])],k=k>>>8^x[255&(k^d[C+5])],k=k>>>8^x[255&(k^d[C+6])],k=k>>>8^x[255&(k^d[C+7])];p=(4294967295^k)>>>0,o.p!==p&&e(Error("wrong crc: file=0x"+o.p.toString(16)+", data=0x"+p.toString(16)))}return d},p.M=function(e){this.j=e},p.k=s.prototype.k,p.T=s.prototype.U,p.s=s.prototype.s,t("Zlib.Unzip",l),t("Zlib.Unzip.prototype.decompress",l.prototype.r),t("Zlib.Unzip.prototype.getFilenames",l.prototype.Z),t("Zlib.Unzip.prototype.setPassword",l.prototype.M)}).call(this),function(){"use strict";function e(e){throw e}function t(e,t){var n=e.split("."),i=u;!(n[0]in i)&&i.execScript&&i.execScript("var "+n[0]);for(var a;n.length&&(a=n.shift());)n.length||t===c?i=i[a]?i[a]:i[a]={}:i[a]=t}function n(e,t,n){var i,a="number"==typeof t?t:t=0,r="number"==typeof n?n:e.length;for(i=-1,a=7&r;a--;++t)i=i>>>8^v[255&(i^e[t])];for(a=r>>3;a--;t+=8)i=i>>>8^v[255&(i^e[t])],i=i>>>8^v[255&(i^e[t+1])],i=i>>>8^v[255&(i^e[t+2])],i=i>>>8^v[255&(i^e[t+3])],i=i>>>8^v[255&(i^e[t+4])],i=i>>>8^v[255&(i^e[t+5])],i=i>>>8^v[255&(i^e[t+6])],i=i>>>8^v[255&(i^e[t+7])];return(4294967295^i)>>>0}function i(){}function a(e){var t,n,i,a,r,o,s,l,d,c,u=e.length,p=0,f=Number.POSITIVE_INFINITY;for(l=0;u>l;++l)e[l]>p&&(p=e[l]),e[l]<f&&(f=e[l]);for(t=1<<p,n=new(h?Uint32Array:Array)(t),i=1,a=0,r=2;p>=i;){for(l=0;u>l;++l)if(e[l]===i){for(o=0,s=a,d=0;i>d;++d)o=o<<1|1&s,s>>=1;for(c=i<<16|l,d=o;t>d;d+=r)n[d]=c;++a}++i,a<<=1,r<<=1}return[n,p,f]}function r(t,n){switch(this.i=[],this.j=32768,this.d=this.f=this.c=this.n=0,this.input=h?new Uint8Array(t):t,this.o=!1,this.k=x,this.z=!1,!n&&(n={})||(n.index&&(this.c=n.index),n.bufferSize&&(this.j=n.bufferSize),n.bufferType&&(this.k=n.bufferType),n.resize&&(this.z=n.resize)),this.k){case k:this.a=32768,this.b=new(h?Uint8Array:Array)(32768+this.j+258);break;case x:this.a=0,this.b=new(h?Uint8Array:Array)(this.j),this.e=this.F,this.q=this.B,this.l=this.D;break;default:e(Error("invalid inflate mode"))}}function o(t,n){for(var i,a=t.f,r=t.d,o=t.input,s=t.c,l=o.length;n>r;)s>=l&&e(Error("input buffer is broken")),a|=o[s++]<<r,r+=8;return i=a&(1<<n)-1,t.f=a>>>n,t.d=r-n,t.c=s,i}function s(e,t){for(var n,i,a=e.f,r=e.d,o=e.input,s=e.c,l=o.length,d=t[0],c=t[1];c>r&&!(s>=l);)a|=o[s++]<<r,r+=8;return n=d[a&(1<<c)-1],i=n>>>16,e.f=a>>i,e.d=r-i,e.c=s,65535&n}function l(e){function t(e,t,n){var i,a,r,l=this.w;for(r=0;e>r;)switch(i=s(this,t)){case 16:for(a=3+o(this,2);a--;)n[r++]=l;break;case 17:for(a=3+o(this,3);a--;)n[r++]=0;l=0;break;case 18:for(a=11+o(this,7);a--;)n[r++]=0;l=0;break;default:l=n[r++]=i}return this.w=l,n}var n,i,r,l,d=o(e,5)+257,c=o(e,5)+1,u=o(e,4)+4,p=new(h?Uint8Array:Array)(A.length);for(l=0;u>l;++l)p[A[l]]=o(e,3);if(!h)for(l=u,u=p.length;u>l;++l)p[A[l]]=0;n=a(p),i=new(h?Uint8Array:Array)(d),r=new(h?Uint8Array:Array)(c),e.w=0,e.l(a(t.call(e,d,n,i)),a(t.call(e,c,n,r)))}function d(e){this.input=e,this.c=0,this.m=[],this.s=!1}var c=void 0,u=this,h="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array&&"undefined"!=typeof DataView;new(h?Uint8Array:Array)(256);var p;for(p=0;256>p;++p)for(var f=p,m=7,f=f>>>1;f;f>>>=1)--m;var g=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],v=h?new Uint32Array(g):g;i.prototype.getName=function(){return this.name},i.prototype.getData=function(){return this.data},i.prototype.H=function(){return this.I},t("Zlib.GunzipMember",i),t("Zlib.GunzipMember.prototype.getName",i.prototype.getName),t("Zlib.GunzipMember.prototype.getData",i.prototype.getData),t("Zlib.GunzipMember.prototype.getMtime",i.prototype.H);var b,y=[];for(b=0;288>b;b++)switch(!0){case 143>=b:y.push([b+48,8]);break;case 255>=b:y.push([b-144+400,9]);break;case 279>=b:y.push([b-256+0,7]);break;case 287>=b:y.push([b-280+192,8]);break;default:e("invalid literal: "+b)}var w=function(){function t(t){switch(!0){case 3===t:return[257,t-3,0];case 4===t:return[258,t-4,0];case 5===t:return[259,t-5,0];case 6===t:return[260,t-6,0];case 7===t:return[261,t-7,0];case 8===t:return[262,t-8,0];case 9===t:return[263,t-9,0];case 10===t:return[264,t-10,0];case 12>=t:return[265,t-11,1];case 14>=t:return[266,t-13,1];case 16>=t:return[267,t-15,1];case 18>=t:return[268,t-17,1];case 22>=t:return[269,t-19,2];case 26>=t:return[270,t-23,2];case 30>=t:return[271,t-27,2];case 34>=t:return[272,t-31,2];case 42>=t:return[273,t-35,3];case 50>=t:return[274,t-43,3];case 58>=t:return[275,t-51,3];case 66>=t:return[276,t-59,3];case 82>=t:return[277,t-67,4];case 98>=t:return[278,t-83,4];case 114>=t:return[279,t-99,4];case 130>=t:return[280,t-115,4];case 162>=t:return[281,t-131,5];case 194>=t:return[282,t-163,5];case 226>=t:return[283,t-195,5];case 257>=t:return[284,t-227,5];case 258===t:return[285,t-258,0];default:e("invalid length: "+t)}}var n,i,a=[];for(n=3;258>=n;n++)i=t(n),a[n]=i[2]<<24|i[1]<<16|i[0];return a}();h&&new Uint32Array(w);var k=0,x=1;r.prototype.g=function(){for(;!this.o;){var t=o(this,3);switch(1&t&&(this.o=!0),t>>>=1){case 0:var n=this.input,i=this.c,a=this.b,r=this.a,s=n.length,d=c,u=c,p=a.length,f=c;switch(this.d=this.f=0,i+1>=s&&e(Error("invalid uncompressed block header: LEN")),d=n[i++]|n[i++]<<8,i+1>=s&&e(Error("invalid uncompressed block header: NLEN")),u=n[i++]|n[i++]<<8,d===~u&&e(Error("invalid uncompressed block header: length verify")),i+d>n.length&&e(Error("input buffer is broken")),this.k){case k:for(;r+d>a.length;){if(f=p-r,d-=f,h)a.set(n.subarray(i,i+f),r),r+=f,i+=f;else for(;f--;)a[r++]=n[i++];this.a=r,a=this.e(),r=this.a}break;case x:for(;r+d>a.length;)a=this.e({t:2});break;default:e(Error("invalid inflate mode"))}if(h)a.set(n.subarray(i,i+d),r),r+=d,i+=d;else for(;d--;)a[r++]=n[i++];this.c=i,this.a=r,this.b=a;break;case 1:this.l(H,q);break;case 2:l(this);break;default:e(Error("unknown BTYPE: "+t))}}return this.q()};var C,T,z=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],A=h?new Uint16Array(z):z,I=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],S=h?new Uint16Array(I):I,U=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],M=h?new Uint8Array(U):U,O=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],D=h?new Uint16Array(O):O,F=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],E=h?new Uint8Array(F):F,P=new(h?Uint8Array:Array)(288);for(C=0,T=P.length;T>C;++C)P[C]=143>=C?8:255>=C?9:279>=C?7:8;var R,j,H=a(P),N=new(h?Uint8Array:Array)(30);for(R=0,j=N.length;j>R;++R)N[R]=5;var q=a(N);r.prototype.l=function(e,t){var n=this.b,i=this.a;this.r=e;for(var a,r,l,d,c=n.length-258;256!==(a=s(this,e));)if(256>a)i>=c&&(this.a=i,n=this.e(),i=this.a),n[i++]=a;else for(r=a-257,d=S[r],0<M[r]&&(d+=o(this,M[r])),a=s(this,t),l=D[a],0<E[a]&&(l+=o(this,E[a])),i>=c&&(this.a=i,n=this.e(),i=this.a);d--;)n[i]=n[i++-l];for(;8<=this.d;)this.d-=8,this.c--;this.a=i},r.prototype.D=function(e,t){var n=this.b,i=this.a;this.r=e;for(var a,r,l,d,c=n.length;256!==(a=s(this,e));)if(256>a)i>=c&&(n=this.e(),c=n.length),n[i++]=a;else for(r=a-257,d=S[r],0<M[r]&&(d+=o(this,M[r])),a=s(this,t),l=D[a],0<E[a]&&(l+=o(this,E[a])),i+d>c&&(n=this.e(),c=n.length);d--;)n[i]=n[i++-l];for(;8<=this.d;)this.d-=8,this.c--;this.a=i},r.prototype.e=function(){var e,t,n=new(h?Uint8Array:Array)(this.a-32768),i=this.a-32768,a=this.b;if(h)n.set(a.subarray(32768,n.length));else for(e=0,t=n.length;t>e;++e)n[e]=a[e+32768];if(this.i.push(n),this.n+=n.length,h)a.set(a.subarray(i,i+32768));else for(e=0;32768>e;++e)a[e]=a[i+e];return this.a=32768,a},r.prototype.F=function(e){var t,n,i,a,r=this.input.length/this.c+1|0,o=this.input,s=this.b;return e&&("number"==typeof e.t&&(r=e.t),"number"==typeof e.A&&(r+=e.A)),2>r?(n=(o.length-this.c)/this.r[2],a=258*(n/2)|0,i=a<s.length?s.length+a:s.length<<1):i=s.length*r,h?(t=new Uint8Array(i),t.set(s)):t=s,this.b=t},r.prototype.q=function(){var e,t,n,i,a,r=0,o=this.b,s=this.i,l=new(h?Uint8Array:Array)(this.n+(this.a-32768));if(0===s.length)return h?this.b.subarray(32768,this.a):this.b.slice(32768,this.a);for(t=0,n=s.length;n>t;++t)for(e=s[t],i=0,a=e.length;a>i;++i)l[r++]=e[i];for(t=32768,n=this.a;n>t;++t)l[r++]=o[t];return this.i=[],this.buffer=l},r.prototype.B=function(){var e,t=this.a;return h?this.z?(e=new Uint8Array(t),e.set(this.b.subarray(0,t))):e=this.b.subarray(0,t):(this.b.length>t&&(this.b.length=t),e=this.b),this.buffer=e},d.prototype.G=function(){return this.s||this.g(),this.m.slice()},d.prototype.g=function(){for(var t=this.input.length;this.c<t;){var a=new i,o=c,s=c,l=c,d=c,u=c,p=c,f=c,m=c,g=c,v=this.input,b=this.c;switch(a.u=v[b++],a.v=v[b++],(31!==a.u||139!==a.v)&&e(Error("invalid file signature:"+a.u+","+a.v)),a.p=v[b++],a.p){case 8:break;default:e(Error("unknown compression method: "+a.p))}if(a.h=v[b++],m=v[b++]|v[b++]<<8|v[b++]<<16|v[b++]<<24,a.I=new Date(1e3*m),a.O=v[b++],a.N=v[b++],0<(4&a.h)&&(a.J=v[b++]|v[b++]<<8,b+=a.J),0<(8&a.h)){for(f=[],p=0;0<(u=v[b++]);)f[p++]=String.fromCharCode(u);a.name=f.join("")}if(0<(16&a.h)){for(f=[],p=0;0<(u=v[b++]);)f[p++]=String.fromCharCode(u);a.K=f.join("")}0<(2&a.h)&&(a.C=65535&n(v,0,b),a.C!==(v[b++]|v[b++]<<8)&&e(Error("invalid header crc16"))),o=v[v.length-4]|v[v.length-3]<<8|v[v.length-2]<<16|v[v.length-1]<<24,v.length-b-4-4<512*o&&(d=o),s=new r(v,{index:b,bufferSize:d}),a.data=l=s.g(),b=s.c,a.L=g=(v[b++]|v[b++]<<8|v[b++]<<16|v[b++]<<24)>>>0,n(l,c,c)!==g&&e(Error("invalid CRC-32 checksum: 0x"+n(l,c,c).toString(16)+" / 0x"+g.toString(16))),a.M=o=(v[b++]|v[b++]<<8|v[b++]<<16|v[b++]<<24)>>>0,(4294967295&l.length)!==o&&e(Error("invalid input size: "+(4294967295&l.length)+" / "+o)),this.m.push(a),this.c=b}this.s=!0;var y,w,k,x=this.m,C=0,T=0;for(y=0,w=x.length;w>y;++y)T+=x[y].data.length;if(h)for(k=new Uint8Array(T),y=0;w>y;++y)k.set(x[y].data,C),C+=x[y].data.length;else{for(k=[],y=0;w>y;++y)k[y]=x[y].data;k=Array.prototype.concat.apply([],k)}return k},t("Zlib.Gunzip",d),t("Zlib.Gunzip.prototype.decompress",d.prototype.g),t("Zlib.Gunzip.prototype.getMembers",d.prototype.G)}.call(this)}).bind(i)()}catch(a){}return(i.prototype.commands.reload=function(){var t=this,n=!1;this.alwaysEnabled=!0,this.updateOnSelect=!0,this.shortcuts=[{pattern:"ctrl+shift+r f5"}],this.getstate=function(){return 0},this.init=function(){this.fm.bind("search searchend",function(e){n="search"==e.type})},this.fm.bind("contextmenu",function(n){var i=t.fm;i.options.sync>=1e3&&(t.extra={icon:"accept",node:e("<span/>").attr({title:i.i18n("autoSync")}).on("click touchstart",function(t){"touchstart"===t.type&&t.originalEvent.touches.length>1||(t.stopPropagation(),t.preventDefault(),e(this).parent().toggleClass("ui-state-disabled",i.options.syncStart).parent().removeClass("ui-state-hover"),i.options.syncStart=!i.options.syncStart,i.autoSync(i.options.syncStart?null:"stop"))}).on("ready",function(){e(this).parent().toggleClass("ui-state-disabled",!i.options.syncStart).css("pointer-events","auto")})})}),this.exec=function(){var t=this.fm;if(!n){var i=t.sync(),a=setTimeout(function(){t.notify({type:"reload",cnt:1,hideCnt:!0}),i.always(function(){t.notify({type:"reload",cnt:-1})})},t.notifyDelay);return i.always(function(){clearTimeout(a),t.trigger("reload")})}e("div.elfinder-toolbar > div."+t.res("class","searchbtn")+" > span.ui-icon-search").click()}}).prototype={forceLoad:!0},i.prototype.commands.rename=function(){this.shortcuts=[{pattern:"f2"+("mac"==this.fm.OS?" enter":"")}],this.getstate=function(e){var e=this.files(e);return this._disabled||1!=e.length||!e[0].phash||e[0].locked?-1:0},this.exec=function(t,n){var i,a=this.fm,r=a.getUI("cwd"),o=t||(a.selected().length?a.selected():!1)||[a.cwd().hash],s=o.length,l=a.file(o.shift()),d=".elfinder-cwd-filename",n=n||{},c=a.cwd().hash==l.hash,u=n._currentType?n._currentType:c?"navbar":"files",h="navbar"===u,p=e("#"+a[h?"navHash2Id":"cwdHash2Id"](l.hash)),f="files"===u&&"list"!=a.storage("view"),m=function(){setTimeout(function(){y&&y.blur()},50)},g=function(){C.is(":hidden")||C.addClass("ui-front").elfinderoverlay("hide").off("click",T),x.removeClass("ui-front").css("position","").off("unselect."+a.namespace,m),f?k.css("max-height",""):h||x.css("width","").parent("td").css("overflow","")},v=e.Deferred().done(function(e){c&&a.exec("open",e.added[0].hash)}).fail(function(e){var t=y.parent(),n=a.escape(l.i18||l.name);f&&(n=n.replace(/([_.])/g,"&#8203;$1")),h?y.replaceWith(n):t.length?(y.remove(),t.html(n)):(p.find(d).html(n),setTimeout(function(){r.find("#"+a.cwdHash2Id(l.hash)).click()},50)),e&&a.error(e)}).always(function(){g(),a.unbind("resize",z),a.enable()}),b=function(){var t=e.trim(y.val()),n=(y.parent(),!0);if(!A&&x.length){if(y.off("blur"),y[0].setSelectionRange&&y[0].setSelectionRange(0,0),t==l.name)return v.reject();if(a.options.validName&&a.options.validName.test)try{n=a.options.validName.test(t)}catch(i){n=!1}if(!t||".."===t||!n)return A=!0,a.error("errInvName",{modal:!0,close:w}),!1;if(a.fileByName(t,l.phash))return A=!0,a.error(["errExists",t],{modal:!0,close:w}),!1;g(),(h?y:k).html(a.escape(t)),a.lockfiles({files:[l.hash]}),a.request({data:{cmd:"rename",target:l.hash,name:t},notify:{type:"rename",cnt:1}}).fail(function(t){v.reject(),t&&e.isArray(t)&&"errRename"===t[0]||a.sync()}).done(function(e){if(v.resolve(e),!h&&e&&e.added&&e.added[0]){var t=a.findCwdNodes(e.added);t.length&&t.trigger("scrolltoview")}}).always(function(){a.unlockfiles({files:[l.hash]})})}},y=e(f?"<textarea/>":'<input type="text"/>').on("keyup text",function(){f?(this.style.height="1px",this.style.height=this.scrollHeight+"px"):i&&(this.style.width=i+"px",this.scrollWidth>i&&(this.style.width=this.scrollWidth+10+"px"))}).on("keydown",function(t){t.stopImmediatePropagation(),t.keyCode==e.ui.keyCode.ESCAPE?v.reject():t.keyCode==e.ui.keyCode.ENTER&&(t.preventDefault(),y.blur())}).on("mousedown click dblclick",function(e){e.stopPropagation(),"dblclick"===e.type&&e.preventDefault()}).on("blur",b),w=function(){var e=y.val().replace(/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/gi,"");A&&(A=!1,y.on("blur",b)),a.UA.Mobile&&C.on("click",T).removeClass("ui-front").elfinderoverlay("show"),y.select().focus(),y[0].setSelectionRange&&y[0].setSelectionRange(0,e.length)},k=h?p.contents().filter(function(){return 3==this.nodeType&&e(this).parent().attr("id")===a.navHash2Id(l.hash)}):p.find(d),x=k.parent(),C=a.getUI("overlay"),T=function(e){A||(e.stopPropagation(),v.reject())},z=function(){p.trigger("scrolltoview")},A=!1;return x.addClass("ui-front").css("position","relative").on("unselect."+a.namespace,m),a.bind("resize",z),h?k.replaceWith(y.val(l.name)):(f?k.css("max-height","none"):h||(i=x.width(),x.width(i-15).parent("td").css("overflow","visible")),k.empty().append(y.val(l.name))),s>1?v.reject():l&&k.length?l.locked?v.reject(["errLocked",l.name]):(a.one("select",function(){y.parent().length&&l&&-1===e.inArray(l.hash,a.selected())&&y.blur()}),y.trigger("keyup"),w(),v):v.reject("errCmdParams",this.title)}},i.prototype.commands.resize=function(){this.updateOnSelect=!1,this.getstate=function(){var e=this.fm.selectedFiles();return!this._disabled&&1==e.length&&e[0].read&&e[0].write&&-1!==e[0].mime.indexOf("image/")?0:-1},this.resizeRequest=function(t,n,i){var a=this.fm,n=n||a.file(t.target),r=n?a.openUrl(n.hash):null,o=n?n.tmb:null,s=a.isCommandEnabled("resize",t.target);if(s&&(!n||n&&n.read&&n.write&&-1!==n.mime.indexOf("image/")))return a.request({data:e.extend(t,{cmd:"resize"}),notify:{type:"resize",cnt:1},prepare:function(e){var t;return e&&(e.added&&e.added.length&&e.added[0].tmb?t=e.added[0]:e.changed&&e.changed.length&&e.changed[0].tmb&&(t=e.changed[0]),
  1823. t&&(n=t,r=a.openUrl(n.hash),n.tmb&&"1"!=n.tmb&&n.tmb===o))?void(n.tmb=""):void(o="")}}).fail(function(e){i&&i.reject(e)}).done(function(){var e="1"!=n.url?a.url(n.hash):"";o&&a.one("resizedone",function(){a.reloadContents(a.tmb(n).url).done(function(){a.trigger("tmbreload",{files:[{hash:n.hash,tmb:o}]})})}),a.reloadContents(r),e&&e!==r&&a.reloadContents(e),i&&i.resolve()});var l;return l=n?-1===n.mime.indexOf("image/")?["errResize",n.name,"errUsupportType"]:["errResize",n.name,"errPerm"]:["errResize",t.target,"errPerm"],i?i.reject(l):a.error(l),e.Deferred().reject(l)},this.exec=function(t){var n,i,a=this,r=this.fm,o=this.files(t),s=e.Deferred(),l=r.api>1,d=650,c=r.getUI(),u=e().controlgroup?"controlgroup":"buttonset",h="undefind"==typeof this.options.grid8px||"disable"!==this.options.grid8px,p=function(t,n){var i,o,p,f,m="image/jpeg"===t.mime,g=e('<div class="elfinder-dialog-resize '+r.res("class","editing")+'"/>'),v='<input type="text" size="5"/>',b='<div class="elfinder-resize-row"/>',y='<div class="elfinder-resize-label"/>',w=e('<div class="elfinder-resize-control"/>').on("focus","input[type=text]",function(){e(this).select()}),k=e('<div class="elfinder-resize-preview"/>').on("touchmove",function(e){e.stopPropagation(),e.preventDefault()}),x=e('<div class="elfinder-resize-spinner">'+r.i18n("ntfloadimg")+"</div>"),C=e('<div class="elfinder-resize-handle touch-punch"/>'),T=e('<div class="elfinder-resize-handle touch-punch"/>'),z=e('<div class="elfinder-resize-uiresize"/>'),A=e('<div class="elfinder-resize-uicrop"/>'),I=e('<div class="elfinder-resize-rotate"/>'),S=e("<button/>").attr("title",r.i18n("rotate-cw")).append(e('<span class="elfinder-button-icon elfinder-button-icon-rotate-l"/>')),U=e("<button/>").attr("title",r.i18n("rotate-ccw")).append(e('<span class="elfinder-button-icon elfinder-button-icon-rotate-r"/>')),M=e("<span />"),O=e('<button class="elfinder-resize-reset">').text(r.i18n("reset")).on("click",function(){Ce()}).button({icons:{primary:"ui-icon-arrowrefresh-1-n"},text:!1}),D=e('<div class="elfinder-resize-type"/>').append('<input class="" type="radio" name="type" id="'+n+'-resize" value="resize" checked="checked" /><label for="'+n+'-resize">'+r.i18n("resize")+"</label>",'<input class="api2" type="radio" name="type" id="'+n+'-crop" value="crop" /><label class="api2" for="'+n+'-crop">'+r.i18n("crop")+"</label>",'<input class="api2" type="radio" name="type" id="'+n+'-rotate" value="rotate" /><label class="api2" for="'+n+'-rotate">'+r.i18n("rotate")+"</label>"),F="resize",E=(D[u]()[u]("disable").find("input").change(function(){F=e(this).val(),Ce(),Ie(!0),Se(!0),Ue(!0),"resize"==F?(z.show(),I.hide(),A.hide(),Ie(),m&&he.insertAfter(z.find(".elfinder-resize-grid8"))):"crop"==F?(I.hide(),z.hide(),A.show(),Se(),m&&he.insertAfter(A.find(".elfinder-resize-grid8"))):"rotate"==F&&(z.hide(),A.hide(),I.show(),Ue())}),e(v).change(function(){var e=parseInt(E.val()),t=parseInt(ne?Math.round(e/Z):P.val());e>0&&t>0&&(Te.updateView(e,t),P.val(t))})),P=e(v).change(function(){var e=parseInt(P.val()),t=parseInt(ne?Math.round(e*Z):E.val());t>0&&e>0&&(Te.updateView(t,e),E.val(t))}),R=e(v).change(function(){ze.updateView()}),j=e(v).change(function(){ze.updateView()}),H=e(v).change(function(){ze.updateView("w")}),N=e(v).change(function(){ze.updateView("h")}),q=m&&l?e(v).val(r.option("jpgQuality")).addClass("quality").on("blur",function(){var e=Math.min(100,Math.max(1,parseInt(this.value)));g.find("input.quality").val(e)}):null,_=e('<input type="text" size="3" maxlength="3" value="0" />').change(function(){Ae.update()}),L=e('<div class="elfinder-resize-rotate-slider touch-punch"/>').slider({min:0,max:360,value:_.val(),animate:!0,change:function(e,t){t.value!=L.slider("value")&&Ae.update(t.value)},slide:function(e,t){Ae.update(t.value,!1)}}).find(".ui-slider-handle").addClass("elfinder-tabstop").off("keydown").on("keydown",function(t){t.keyCode!=e.ui.keyCode.LEFT&&t.keyCode!=e.ui.keyCode.RIGHT||(t.stopPropagation(),t.preventDefault(),Ae.update(Number(_.val())+(t.keyCode==e.ui.keyCode.RIGHT?1:-1),!1))}).end(),W={},B=function(e){var t,n,i,a,r,o,s;try{t=W[Math.round(e.offsetX)][Math.round(e.offsetY)]}catch(e){}t&&(n=t[0],i=t[1],a=t[2],r=t[3],o=t[4],s=t[5],$(n,i,a,"click"===e.type))},V=function(t){$(e(this).css("backgroundColor"),"","","click"===t.type)},$=function(t,n,i,a){var r,o,s;"string"==typeof t&&(n="",t&&(r=e("<span>").css("backgroundColor",t).css("backgroundColor"))&&(o=r.match(/rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i))&&(t=Number(o[1]),n=Number(o[2]),i=Number(o[3]))),s=""===n?t:"#"+K(t,n,i),Y.val(s).css({backgroundColor:s,backgroundImage:"none",color:384>t+n+i?"#fff":"#000"}),k.css("backgroundColor",s),a&&(ke.off(".picker").removeClass("elfinder-resize-picking"),X.off(".picker").removeClass("elfinder-resize-picking"))},K=function(t,n,i){return e.map([t,n,i],function(e){return("0"+parseInt(e).toString(16)).slice(-2)}).join("")},G=e("<button>").text(r.i18n("colorPicker")).on("click",function(){ke.on("mousemove.picker click.picker",B).addClass("elfinder-resize-picking"),X.on("mousemove.picker click.picker","span",V).addClass("elfinder-resize-picking")}).button({icons:{primary:"ui-icon-pin-s"},text:!1}),J=e("<button>").text(r.i18n("reset")).on("click",function(){$("","","",!0)}).button({icons:{primary:"ui-icon-arrowrefresh-1-n"},text:!1}),Y=e('<input class="elfinder-resize-bg" type="text">').on("focus",function(){e(this).attr("style","")}).on("blur",function(){$(e(this).val())}),X=e('<div class="elfinder-resize-pallet">').on("click","span",function(){$(e(this).css("backgroundColor"))}),Z=1,Q=1,ee=0,te=0,ne=!0,ie=!1,ae=0,re=0,oe=0,se=0,le=0,de=m?h:!1,ce=e("<button>").html(r.i18n("aspectRatio")).on("click",function(){ne=!ne,ce.button("option",{icons:{primary:ne?"ui-icon-locked":"ui-icon-unlocked"}}),Te.fixHeight(),C.resizable("option","aspectRatio",ne).data("uiResizable")._aspectRatio=ne}).button({icons:{primary:ne?"ui-icon-locked":"ui-icon-unlocked"},text:!1}),ue=e("<button>").html(r.i18n("aspectRatio")).on("click",function(){ie=!ie,ue.button("option",{icons:{primary:ie?"ui-icon-locked":"ui-icon-unlocked"}}),T.resizable("option","aspectRatio",ie).data("uiResizable")._aspectRatio=ie}).button({icons:{primary:ie?"ui-icon-locked":"ui-icon-unlocked"},text:!1}),he=e("<button>").html(r.i18n(de?"enabled":"disabled")).toggleClass("ui-state-active",de).on("click",function(){de=!de,he.html(r.i18n(de?"enabled":"disabled")).toggleClass("ui-state-active",de),de&&(E.val(xe(E.val())),P.val(xe(P.val())),H.val(xe(H.val())),N.val(xe(N.val())),R.val(xe(R.val())),j.val(xe(j.val())),z.is(":visible")?Te.updateView(E.val(),P.val()):A.is(":visible")&&ze.updateView())}).button(),pe=function(){var e;e=Math.min(ae,re)/Math.sqrt(Math.pow(ee,2)+Math.pow(te,2)),oe=Math.ceil(ee*e),se=Math.ceil(te*e),ke.width(oe).height(se).css("margin-top",(re-se)/2+"px").css("margin-left",(ae-oe)/2+"px"),ke.is(":visible")&&Y.is(":visible")&&("image/png"!==t.mime?(k.css("backgroundColor",Y.val()),setTimeout(function(){i&&i.width!==oe&&me()},0)):(Y.parent().hide(),X.hide()))},fe=function(){Te.updateView(ee,te),pe(),be.width(ve.width()).height(ve.height()),ye.width(ve.width()).height(ve.height()),ze.updateView()},me=function(){if(o){var t,n,a,r,s,l,d,c,u,h,p,f,m,g,v,b,y,w,k,x={},C=[],T=function(e,t,n){var i,a,r,o=Math.max(Math.max(e,t),n),s=Math.min(Math.min(e,t),n);return o===s?i=0:e===o?i=((t-n)/(o-s)*60+360)%360:t===o?i=(n-e)/(o-s)*60+120:n===o&&(i=(e-t)/(o-s)*60+240),a=(o-s)/o,r=(.3*e+.59*t+.11*n)/255,[i,a,r,"hsl"]};e:try{n=i.width=ke.width(),a=i.height=ke.height(),m=n/ee,o.scale(m,m),o.drawImage(ke.get(0),0,0),f=o.getImageData(0,0,n,a).data,g=.1*n,v=.9*n,b=.1*a,y=.9*a;for(var z=0;a-1>z;z++)for(var A=0;n-1>A;A++){if(t=4*A+z*n*4,r=f[t],s=f[t+1],l=f[t+2],d=f[t+3],255!==d){Y.parent().hide(),X.hide();break e}h=T(r,s,l),p=Math.round(h[0]),c=Math.round(100*h[1]),u=Math.round(100*h[2]),W[A]||(W[A]={}),W[A][z]=[r,s,l,p,c,u],(g>A||A>v)&&(b>z||z>y)&&(w=r+","+s+","+l,x[w]?++x[w]:x[w]=1)}X.children(":first").length||(k=1,e.each(x,function(e,t){C.push({c:e,v:t})}),e.each(C.sort(function(e,t){return e.v>t.v?-1:1}),function(){return this.v<2||k>10?!1:(X.append(e('<span style="width:20px;height:20px;display:inline-block;background-color:rgb('+this.c+');">')),void++k)}))}catch(I){G.hide(),X.hide()}}},ge=function(){try{i=document.createElement("canvas"),o=i.getContext("2d")}catch(e){G.hide(),X.hide()}},ve=e("<img/>").on("load",function(){ee=ve.get(0).width||ve.width(),te=ve.get(0).height||ve.height(),p.show();var t,n=te/ee;1>n&&k.height()>k.width()*n&&k.height(k.width()*n),k.height()>ve.height()+20&&k.height(ve.height()+20),re=k.height()-(C.outerHeight()-C.height()),x.remove(),Z=ee/te,C.append(ve.show()).show(),E.val(ee),P.val(te),ge(),fe(),D[u]("enable"),t=w.find("input,select").prop("disabled",!1).filter(":text").on("keydown",function(t){return t.keyCode==e.ui.keyCode.ENTER?(t.stopPropagation(),t.preventDefault(),void r.confirm({title:e("input:checked",D).val(),text:"confirmReq",accept:{label:"btnApply",callback:function(){Me()}},cancel:{label:"btnCancel",callback:function(){e(this).focus()}}})):void 0}).on("keyup",function(){var t=e(this);t.hasClass("elfinder-resize-bg")||setTimeout(function(){t.val(t.val().replace(/[^0-9]/g,""))},10)}).filter(":first"),!r.UA.Mobile&&t.focus(),Ie()}).on("error",function(){x.text("Unable to load image").css("background","transparent")}),be=e("<div/>"),ye=e("<img/>"),we=e("<div/>"),ke=e('<img class="elfinder-resize-imgrotate" />'),xe=function(e,t){return e=de?8*Math.round(e/8):Math.round(e),e=Math.max(0,e),t&&e>t&&(e=de?8*Math.floor(t/8):t),e},Ce=function(){E.val(ee),P.val(te),Te.updateView(ee,te),R.val(0),j.val(0),H.val(ee),N.val(te),ze.updateView()},Te={update:function(){E.val(xe(ve.width()/Q)),P.val(xe(ve.height()/Q))},updateView:function(e,t){e>ae||t>re?e/ae>t/re?(Q=ae/e,ve.width(ae).height(Math.ceil(t*Q))):(Q=re/t,ve.height(re).width(Math.ceil(e*Q))):ve.width(e).height(t),Q=ve.width()/e,M.text("1 : "+(1/Q).toFixed(2)),Te.updateHandle()},updateHandle:function(){C.width(ve.width()).height(ve.height())},fixHeight:function(){var e,t;ne&&(e=E.val(),t=xe(e/Z),Te.updateView(e,t),P.val(t))}},ze={update:function(e){R.val(xe((T.data("x")||T.position().left)/Q,ee)),j.val(xe((T.data("y")||T.position().top)/Q,te)),"xy"!==e&&(H.val(xe((T.data("w")||T.width())/Q,ee-R.val())),N.val(xe((T.data("h")||T.height())/Q,te-j.val())))},updateView:function(e){var t,n,i,a,r;R.val(xe(R.val(),ee-(de?8:1))),j.val(xe(j.val(),te-(de?8:1))),H.val(xe(H.val(),ee-R.val())),N.val(xe(N.val(),te-j.val())),ie&&(t=we.width()/we.height(),"w"===e?N.val(xe(parseInt(H.val())/t)):"h"===e&&H.val(xe(parseInt(N.val())*t))),n=Math.round(parseInt(R.val())*Q),i=Math.round(parseInt(j.val())*Q),"xy"!==e?(a=Math.round(parseInt(H.val())*Q),r=Math.round(parseInt(N.val())*Q)):(a=T.data("w"),r=T.data("h")),T.data({x:n,y:i,w:a,h:r}).width(a).height(r).css({left:n,top:i}),we.width(a).height(r)},resize_update:function(e,t){T.data({x:t.position.left,y:t.position.top,w:t.size.width,h:t.size.height}),ze.update(),ze.updateView()},drag_update:function(e,t){T.data({x:t.position.left,y:t.position.top}),ze.update("xy")}},Ae={mouseStartAngle:0,imageStartAngle:0,imageBeingRotated:!1,update:function(e,t){"undefined"==typeof e&&(le=e=parseInt(_.val())),"undefined"==typeof t&&(t=!0),!t||r.UA.Opera||r.UA.ltIE8?ke.rotate(e):ke.animate({rotate:e+"deg"}),e%=360,0>e&&(e+=360),_.val(parseInt(e)),L.slider("value",_.val())},execute:function(e){if(Ae.imageBeingRotated){var t=Ae.getCenter(ke),n=e.pageX-t[0],i=e.pageY-t[1],a=Math.atan2(i,n),r=a-Ae.mouseStartAngle+Ae.imageStartAngle;return r=Math.round(180*parseFloat(r)/Math.PI),e.shiftKey&&(r=15*Math.round((r+6)/15)),ke.rotate(r),r%=360,0>r&&(r+=360),_.val(r),L.slider("value",_.val()),!1}},start:function(t){Ae.imageBeingRotated=!0;var n=Ae.getCenter(ke),i=t.pageX-n[0],a=t.pageY-n[1];return Ae.mouseStartAngle=Math.atan2(a,i),Ae.imageStartAngle=parseFloat(ke.rotate())*Math.PI/180,e(document).mousemove(Ae.execute),!1},stop:function(t){return Ae.imageBeingRotated?(e(document).unbind("mousemove",Ae.execute),setTimeout(function(){Ae.imageBeingRotated=!1},10),!1):void 0},getCenter:function(e){var t=ke.rotate();ke.rotate(0);var n=ke.offset(),i=n.left+ke.width()/2,a=n.top+ke.height()/2;return ke.rotate(t),Array(i,a)}},Ie=function(t){e.fn.resizable&&(t?(C.filter(":ui-resizable").resizable("destroy"),C.hide()):(C.show(),C.resizable({alsoResize:ve,aspectRatio:ne,resize:Te.update,stop:Te.fixHeight}),Re()))},Se=function(t){e.fn.draggable&&e.fn.resizable&&(t?(T.filter(":ui-resizable").resizable("destroy").filter(":ui-draggable").draggable("destroy"),be.hide()):(be.show(),T.resizable({containment:be,aspectRatio:ie,resize:ze.resize_update,handles:"all"}).draggable({handle:we,containment:ye,drag:ze.drag_update,stop:function(){ze.updateView("xy")}}),Re(),ze.update()))},Ue=function(t){e.fn.draggable&&e.fn.resizable&&(t?ke.hide():(ke.show(),Re()))},Me=function(){var e,n,i,o,l,d,c="";if("resize"==F)e=parseInt(E.val())||0,n=parseInt(P.val())||0;else if("crop"==F)e=parseInt(H.val())||0,n=parseInt(N.val())||0,i=parseInt(R.val())||0,o=parseInt(j.val())||0;else if("rotate"==F){if(e=ee,n=te,l=parseInt(_.val())||0,0>l||l>360)return r.error("Invalid rotate degree");if(0==l||360==l)return r.error("errResizeNoChange");c=Y.val()}if(d=q?parseInt(q.val()):0,"rotate"!=F){if(0>=e||0>=n)return r.error("Invalid image size");if(e==ee&&n==te)return r.error("errResizeNoChange")}g.elfinderdialog("close"),a.resizeRequest({target:t.hash,width:e,height:n,x:i,y:o,degree:l,quality:d,bg:c,mode:F},t,s)},Oe={},De="elfinder-resize-handle-hline",Fe="elfinder-resize-handle-vline",Ee="elfinder-resize-handle-point",Pe=r.openUrl(t.hash,!!r.isCORS),Re=function(){if(!f.hasClass("elfinder-dialog-minimized")){var t,n=e(window).height(),i=e(window).width(),a=g.find("div.elfinder-resize-control").width(),r=k.width();f.width();f.width(Math.min(d,i-30)),k.attr("style",""),ee&&te&&(ae=k.width()-(C.outerWidth()-C.width()),re=k.height()-(C.outerHeight()-C.height()),Te.updateView(ee,te)),r=k.width(),t=g.width()-20,r>t?k.width(t):a>t-r&&(i>n?k.width(t-a-20):k.css({"float":"none",marginLeft:"auto",marginRight:"auto"})),ae=k.width()-(C.outerWidth()-C.width()),c.hasClass("elfinder-fullscreen")?f.height()>n&&(n-=2,k.height(n-f.height()+k.height()),f.css("top",0-c.offset().top)):(n-=30,k.height()>n&&k.height(n)),re=k.height()-(C.outerHeight()-C.height()),ee&&te&&fe(),ve.height()&&k.height()>ve.height()+20&&(k.height(ve.height()+20),re=k.height()-(C.outerHeight()-C.height()),pe())}};r.isCORS&&(ve.attr("crossorigin","use-credentials"),ye.attr("crossorigin","use-credentials"),ke.attr("crossorigin","use-credentials")),ke.mousedown(Ae.start),e(document).mouseup(Ae.stop),z.append(e(b).append(e(y).text(r.i18n("width")),E),e(b).append(e(y).text(r.i18n("height")),P,e('<div class="elfinder-resize-whctrls">').append(ce,O)),q?e(b).append(e(y).text(r.i18n("quality")),q,e("<span/>").text(" (1-100)")):e(),m?e(b).append(e(y).text(r.i18n("8pxgrid")).addClass("elfinder-resize-grid8"),he):e(),e(b).append(e(y).text(r.i18n("scale")),M)),l&&(A.append(e(b).append(e(y).text("X"),R),e(b).append(e(y).text("Y")).append(j),e(b).append(e(y).text(r.i18n("width")),H),e(b).append(e(y).text(r.i18n("height")),N,e('<div class="elfinder-resize-whctrls">').append(ue,O.clone(!0))),q?e(b).append(e(y).text(r.i18n("quality")),q.clone(!0),e("<span/>").text(" (1-100)")):e(),m?e(b).append(e(y).text(r.i18n("8pxgrid")).addClass("elfinder-resize-grid8")):e()),I.append(e(b).addClass("elfinder-resize-degree").append(e(y).text(r.i18n("rotate")),_,e("<span/>").text(r.i18n("degree")),e("<div/>").append(S,U)[u]()),e(b).css("height","20px").append(L),q?e(b).addClass("elfinder-resize-quality").append(e(y).text(r.i18n("quality")),q.clone(!0),e("<span/>").text(" (1-100)")):e(),e(b).append(e(y).text(r.i18n("bgcolor")),Y,G,J),e(b).css("height","20px").append(X)),S.on("click",function(){le-=90,Ae.update(le)}),U.on("click",function(){le+=90,Ae.update(le)})),g.append(D).on("resize",function(e){e.stopPropagation()}),l?w.append(e(b),z,A.hide(),I.hide()):w.append(e(b),z),C.append('<div class="'+De+" "+De+'-top"/>','<div class="'+De+" "+De+'-bottom"/>','<div class="'+Fe+" "+Fe+'-left"/>','<div class="'+Fe+" "+Fe+'-right"/>','<div class="'+Ee+" "+Ee+'-e"/>','<div class="'+Ee+" "+Ee+'-se"/>','<div class="'+Ee+" "+Ee+'-s"/>'),k.append(x).append(C.hide()).append(ve.hide()),l&&(T.css("position","absolute").append('<div class="'+De+" "+De+'-top"/>','<div class="'+De+" "+De+'-bottom"/>','<div class="'+Fe+" "+Fe+'-left"/>','<div class="'+Fe+" "+Fe+'-right"/>','<div class="'+Ee+" "+Ee+'-n"/>','<div class="'+Ee+" "+Ee+'-e"/>','<div class="'+Ee+" "+Ee+'-s"/>','<div class="'+Ee+" "+Ee+'-w"/>','<div class="'+Ee+" "+Ee+'-ne"/>','<div class="'+Ee+" "+Ee+'-se"/>','<div class="'+Ee+" "+Ee+'-sw"/>','<div class="'+Ee+" "+Ee+'-nw"/>'),k.append(be.css("position","absolute").hide().append(ye,T.append(we))),k.append(ke.hide())),k.css("overflow","hidden"),g.append(k,w),Oe[r.i18n("btnApply")]=Me,Oe[r.i18n("btnCancel")]=function(){g.elfinderdialog("close")},g.find("input,button").addClass("elfinder-tabstop"),f=r.dialog(g,{title:r.escape(t.name),width:d,resizable:!1,buttons:Oe,open:function(){p=f.find(".ui-dialog-titlebar .elfinder-titlebar-minimize").hide(),r.bind("resize",Re),ve.attr("src",Pe+(-1===Pe.indexOf("?")?"?":"&")+"_="+Math.random()),ye.attr("src",ve.attr("src")),ke.attr("src",ve.attr("src"))},close:function(){r.unbind("resize",Re),e(this).elfinderdialog("destroy")},resize:function(e,t){t&&"off"===t.minimize&&Re()}}).attr("id",n).parent(),r.UA.ltIE8&&e(".elfinder-dialog").css("filter",""),we.css({opacity:.2,"background-color":"#fff",position:"absolute"}),T.css("cursor","move"),T.find(".elfinder-resize-handle-point").css({"background-color":"#fff",opacity:.5,"border-color":"#000"}),l||D.find(".api2").remove(),w.find("input,select").prop("disabled",!0)};return o.length&&-1!==o[0].mime.indexOf("image/")?(n="resize-"+r.namespace+"-"+o[0].hash,i=r.getUI().find("#"+n),i.length?(i.elfinderdialog("toTop"),s.resolve()):(p(o[0],n),s)):s.reject()}},function(e){var t=function(e,t){var n=0;for(n in t)if("undefined"!=typeof e[t[n]])return t[n];return e[t[n]]="",t[n]};if(e.cssHooks.rotate={get:function(t,n,i){return e(t).rotate()},set:function(t,n){return e(t).rotate(n),n}},e.cssHooks.transform={get:function(e,n,i){var a=t(e.style,["WebkitTransform","MozTransform","OTransform","msTransform","transform"]);return e.style[a]},set:function(e,n){var i=t(e.style,["WebkitTransform","MozTransform","OTransform","msTransform","transform"]);return e.style[i]=n,n}},e.fn.rotate=function(e){if("undefined"==typeof e){if(window.opera){var t=this.css("transform").match(/rotate\((.*?)\)/);return t&&t[1]?Math.round(180*parseFloat(t[1])/Math.PI):0}var t=this.css("transform").match(/rotate\((.*?)\)/);return t&&t[1]?parseInt(t[1]):0}return this.css("transform",this.css("transform").replace(/none|rotate\(.*?\)/,"")+"rotate("+parseInt(e)+"deg)"),this},e.fx.step.rotate=function(t){0==t.state&&(t.start=e(t.elem).rotate(),t.now=t.start),e(t.elem).rotate(t.now)},"undefined"==typeof window.addEventListener&&"undefined"==typeof document.getElementsByClassName){var n=function(e){for(var t=e,n=t.offsetLeft,i=t.offsetTop;t.offsetParent&&(t=t.offsetParent,t==document.body||"static"==t.currentStyle.position);)t!=document.body&&t!=document.documentElement&&(n-=t.scrollLeft,i-=t.scrollTop),n+=t.offsetLeft,i+=t.offsetTop;return{x:n,y:i}},i=function(e){if("static"==e.currentStyle.position){var t=n(e);e.style.position="absolute",e.style.left=t.x+"px",e.style.top=t.y+"px"}},a=function(e,t){var n,a=1,r=1,o=1,s=1;if("undefined"!=typeof e.style.msTransform)return!0;i(e),n=t.match(/rotate\((.*?)\)/);var l=n&&n[1]?parseInt(n[1]):0;l%=360,0>l&&(l=360+l);var d=l*Math.PI/180,c=Math.cos(d),u=Math.sin(d);a*=c,r*=-u,o*=u,s*=c,e.style.filter=(e.style.filter||"").replace(/progid:DXImageTransform\.Microsoft\.Matrix\([^)]*\)/,"")+("progid:DXImageTransform.Microsoft.Matrix(M11="+a+",M12="+r+",M21="+o+",M22="+s+",FilterType='bilinear',sizingMethod='auto expand')");var h=parseInt(e.style.width||e.width||0),p=parseInt(e.style.height||e.height||0),d=l*Math.PI/180,f=Math.abs(Math.cos(d)),m=Math.abs(Math.sin(d)),g=(h-(h*f+p*m))/2,v=(p-(h*m+p*f))/2;return e.style.marginLeft=Math.floor(g)+"px",e.style.marginTop=Math.floor(v)+"px",!0},r=e.cssHooks.transform.set;e.cssHooks.transform.set=function(e,t){return r.apply(this,[e,t]),a(e,t),t}}}(jQuery),i.prototype.commands.rm=function(){this.shortcuts=[{pattern:"delete ctrl+backspace"}],this.getstate=function(t){var n=this.fm;return t=t||n.selected(),!this._disabled&&t.length&&e.map(t,function(e){var t=n.file(e);return!t||t.locked||n.isRoot(t)?null:e}).length==t.length?0:-1},this.exec=function(t){var n,i,a,r,o,s,l,d,c=this,u=this.fm,h=e.Deferred().fail(function(e){e&&u.error(e)}),p=this.files(t),f=p.length,m=u.cwd().hash,g='<div class="ui-helper-clearfix elfinder-rm-title"><span class="elfinder-cwd-icon {class} ui-corner-all"/>{title}<div class="elfinder-rm-desc">{desc}</div></div>';return f?(e.each(p,function(e,t){return u.isRoot(t)?!h.reject(["errRm",t.name,"errPerm"]):t.locked?!h.reject(["errLocked",t.name]):void 0}),"pending"==h.state()&&(n=this.hashes(t),f=p.length,l=[],f>1?(e.map(p,function(e){return"directory"==e.mime?1:null}).length||(o=0,e.each(p,function(e,t){if(!t.size||"unknown"==t.size)return o="unknown",!1;var n=parseInt(t.size);n>=0&&o>=0&&(o+=n)}),l.push(u.i18n("size")+": "+u.formatSize(o))),i=[e(g.replace("{class}","elfinder-cwd-icon-group").replace("{title}","<strong>"+u.i18n("items")+": "+f+"</strong>").replace("{desc}",l.join("<br>")))]):(a=p[0],s=u.tmb(a),a.size&&l.push(u.i18n("size")+": "+u.formatSize(a.size)),l.push(u.i18n("modify")+": "+u.formatDate(a)),r=u.escape(a.i18||a.name).replace(/([_.])/g,"&#8203;$1"),i=[e(g.replace("{class}",u.mime2class(a.mime)).replace("{title}","<strong>"+r+"</strong>").replace("{desc}",l.join("<br>")))]),i.push("confirmRm"),u.lockfiles({files:n}),d=u.confirm({title:c.title,text:i,accept:{label:"btnRm",callback:function(){u.request({data:{cmd:"rm",targets:n},notify:{type:"rm",cnt:f},preventFail:!0}).fail(function(e){h.reject(e)}).done(function(e){h.done(e)}).always(function(){u.unlockfiles({files:n})})}},cancel:{label:"btnCancel",callback:function(){u.unlockfiles({files:n}),1===n.length&&u.file(n[0]).phash!==m?u.select({selected:n}):u.selectfiles({files:n}),h.reject()}}}),s&&e("<img/>").on("load",function(){d.find(".elfinder-cwd-icon").addClass(s.className).css("background-image","url('"+s.url+"')")}).attr("src",s.url)),h):h.reject()}},i.prototype.commands.search=function(){this.title="Find files",this.options={ui:"searchbutton"},this.alwaysEnabled=!0,this.updateOnSelect=!1,this.getstate=function(){return 0},this.exec=function(t,n,i){var a,r=this.fm,o=[],s=r.options.onlyMimes;return"string"==typeof t&&t?("object"==typeof n&&(i=n.mime||"",n=n.target||""),n=n?n:"",i?(i=e.trim(i).replace(","," ").split(" "),s.length&&(i=e.map(i,function(t){return t=e.trim(t),t&&(-1!==e.inArray(t,s)||e.map(s,function(e){return 0===t.indexOf(e)?!0:null}).length)?t:null}))):i=[].concat(s),r.trigger("searchstart",{query:t,target:n,mimes:i}),!s.length||i.length?""===n&&r.api>=2.1?e.each(r.roots,function(e,n){o.push(r.request({data:{cmd:"search",q:t,target:n,mimes:i},notify:{type:"search",cnt:1,hideCnt:!o.length},cancel:!0,preventDone:!0}))}):(o.push(r.request({data:{cmd:"search",q:t,target:n,mimes:i},notify:{type:"search",cnt:1,hideCnt:!0},cancel:!0,preventDone:!0})),""!==n&&r.api>=2.1&&Object.keys(r.leafRoots).length&&e.each(r.leafRoots,function(s,l){for(a=s;a;)n===a&&e.each(l,function(){o.push(r.request({data:{cmd:"search",q:t,target:this,mimes:i},notify:{type:"search",cnt:1,hideCnt:!1},cancel:!0,preventDone:!0}))}),a=(r.file(a)||{}).phash})):o=[e.Deferred().resolve({files:[]})],r.searchStatus.mixed=o.length>1,e.when.apply(e,o).done(function(e){var t,n=arguments.length;if(e.warning&&r.error(e.warning),n>1)for(e.files=e.files||[],t=1;n>t;t++)arguments[t].warning&&r.error(arguments[t].warning),arguments[t].files&&e.files.push.apply(e.files,arguments[t].files);r.lazy(function(){r.trigger("search",e)}).then(function(){return r.lazy(function(){r.trigger("searchdone")})}).then(function(){e.sync&&r.sync()})})):(r.getUI("toolbar").find("."+r.res("class","searchbtn")+" :text").focus(),e.Deferred().reject())}},i.prototype.commands.sort=function(){var t=this,n=t.fm,i=function(){t.variants=[],e.each(n.sortRules,function(i,a){var r={type:i,order:i==n.sortType?"asc"==n.sortOrder?"desc":"asc":n.sortOrder};if(-1!==e.inArray(i,n.sorters)){var o=i==n.sortType?"asc"==r.order?"s":"n":"";t.variants.push([r,(o?'<span class="ui-icon ui-icon-arrowthick-1-'+o+'"></span>':"")+"&nbsp;"+n.i18n("sort"+i)])}}),t.variants.push("|"),t.variants.push([{type:n.sortType,order:n.sortOrder,stick:!n.sortStickFolders,tree:n.sortAlsoTreeview},(n.sortStickFolders?'<span class="ui-icon ui-icon-check"/>':"")+"&nbsp;"+n.i18n("sortFoldersFirst")]),n.ui.tree&&(t.variants.push("|"),t.variants.push([{type:n.sortType,order:n.sortOrder,stick:n.sortStickFolders,tree:!n.sortAlsoTreeview},(n.sortAlsoTreeview?'<span class="ui-icon ui-icon-check"/>':"")+"&nbsp;"+n.i18n("sortAlsoTreeview")]))};this.options={ui:"sortbutton"},n.bind("open sortchange",i).bind("open",function(){n.unbind("add",i).one("add",i),n.getUI("toolbar").find(".elfiner-button-sort .elfinder-button-menu .elfinder-button-menu-item").each(function(){var t=e(this),i=t.attr("rel");t.toggle(!i||-1!==e.inArray(i,n.sorters))})}).bind("cwdrender",function(){var i=e(n.cwd).find("div.elfinder-cwd-wrapper-list table");i.length&&e.each(n.sortRules,function(a,r){var o=i.find("thead tr td.elfinder-cwd-view-th-"+a);if(o.length){var s,l=a==n.sortType,d={type:a,order:l?"asc"==n.sortOrder?"desc":"asc":n.sortOrder};l&&(o.addClass("ui-state-active"),s="asc"==n.sortOrder?"n":"s",e('<span class="ui-icon ui-icon-triangle-1-'+s+'"/>').appendTo(o)),e(o).on("click",function(i){e(this).data("dragging")||(i.stopPropagation(),n.getUI("cwd").data("longtap")||t.exec([],d))}).hover(function(){e(this).addClass("ui-state-hover")},function(){e(this).removeClass("ui-state-hover")})}})}),this.getstate=function(){return 0},this.exec=function(t,n){var i=this.fm,a=e.extend({type:i.sortType,order:i.sortOrder,stick:i.sortStickFolders,tree:i.sortAlsoTreeview},n);return i.lazy(function(){i.setSort(a.type,a.order,a.stick,a.tree),this.resolve()})}},(i.prototype.commands.up=function(){this.alwaysEnabled=!0,this.updateOnSelect=!1,this.shortcuts=[{pattern:"ctrl+up"}],this.getstate=function(){return this.fm.cwd().phash?0:-1},this.exec=function(){var t=this.fm,n=t.cwd().hash;return this.fm.cwd().phash?this.fm.exec("open",this.fm.cwd().phash).done(function(){t.one("opendone",function(){t.selectfiles({files:[n]})})}):e.Deferred().reject()}}).prototype={forceLoad:!0},i.prototype.commands.upload=function(){var t=this.fm.res("class","hover");this.disableOnSearch=!0,this.updateOnSelect=!1,this.shortcuts=[{pattern:"ctrl+u"}],this.getstate=function(e){var t,n=this.fm,e=e||[n.cwd().hash];return this._disabled||1!=e.length||(t=n.file(e[0])),t&&"directory"==t.mime&&t.write?0:-1},this.exec=function(n){var i,a,r,o,s,l,d,c=this.fm,u=c.cwd().hash,h=function(){var e,t=n&&n instanceof Array?n:null;return n||(t=t||1!==(e=c.selected()).length||"directory"!==c.file(e[0]).mime?[u]:e),t},p=h(),f=!p&&n&&n.target?n.target:p[0],m=f?c.file(f):c.cwd(),g=function(t){c.upload(t).fail(function(e){w.reject(e)}).done(function(t){var n;c.getUI("cwd");if(w.resolve(t),t&&t.added&&t.added[0]&&!c.ui.notify.children(".elfinder-notify-upload").length){var i=c.findCwdNodes(t.added);i.length?i.trigger("scrolltoview"):(m.hash!==u?n=e("<div/>").append(e('<button type="button" class="ui-button ui-widget ui-state-default ui-corner-all elfinder-tabstop"><span class="ui-button-text">'+c.i18n("cmdopendir")+"</span></button>").on("mouseenter mouseleave",function(t){e(this).toggleClass("ui-state-hover","mouseenter"==t.type)}).on("click",function(){c.exec("open",f).done(function(){c.one("opendone",function(){c.trigger("selectfiles",{files:e.map(t.added,function(e){return e.hash})})})})})):c.trigger("selectfiles",{files:e.map(t.added,function(e){return e.hash})}),c.toast({msg:c.i18n(["complete",c.i18n("cmdupload")]),extNode:n}))}})},v=function(e){"files"!==e.type&&i.elfinderdialog("close"),p&&(e.target=p[0]),g(e)},b=function(){var t=m.hash,n=e.map(c.files(),function(e){return"directory"===e.mime&&e.write&&e.phash&&e.phash===t?e:null});return n.length?e('<div class="elfinder-upload-dirselect elfinder-tabstop" title="'+c.i18n("folders")+'"/>').on("click",function(t){t.stopPropagation(),t.preventDefault(),n=c.sortFiles(n);var a=e(this),r=(c.cwd(),i.closest("div.ui-dialog")),o=function(e,t){return{label:c.escape(e.i18||e.name),icon:t,remain:!1,callback:function(){var t=r.children(".ui-dialog-titlebar:first").find("span.elfinder-upload-target");p=[e.hash],t.html(" - "+c.escape(e.i18||e.name)),a.focus()},options:{className:p&&p.length&&e.hash===p[0]?"ui-state-active":"",iconClass:e.csscls||"",iconImg:e.icon||""}}},s=[o(m,"opendir"),"|"];e.each(n,function(e,t){s.push(o(t,"dir"))}),a.blur(),c.trigger("contextmenu",{raw:s,x:t.pageX||e(this).offset().left,y:t.pageY||e(this).offset().top,prevNode:r,fitHeight:!0})}).append('<span class="elfinder-button-icon elfinder-button-icon-dir" />'):e()},y=function(n,i){var a=e('<input type="file" '+n+"/>").change(function(){v({input:a.get(0),type:"files"})}).on("dragover",function(e){e.originalEvent.dataTransfer.dropEffect="copy"});return e('<div class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only elfinder-tabstop elfinder-focus"><span class="ui-button-text">'+c.i18n(i)+"</span></div>").append(e("<form/>").append(a)).on("click",function(e){e.target===this&&(e.stopPropagation(),e.preventDefault(),a.click())}).hover(function(){e(this).toggleClass(t)})},w=e.Deferred();return o=function(t){t.stopPropagation(),t.preventDefault();var n,i=!1,a="",r=null,o="",s=null,l=t._target||null,d=t.dataTransfer||null,u=d.items&&d.items.length&&d.items[0].kind?d.items[0].kind:"";if(d){try{if(r=d.getData("elfinderfrom"),r&&(o=window.location.href+c.cwd().hash,!l&&r===o||l===o))return void w.reject()}catch(t){}if("file"===u&&(d.items[0].getAsEntry||d.items[0].webkitGetAsEntry))i=d,a="data";else if("string"!==u&&d.files&&d.files.length&&-1===e.inArray("Text",d.types))i=d.files,a="files";else{try{(s=d.getData("text/html"))&&s.match(/<(?:img|a)/i)&&(i=[s],a="html")}catch(t){}!i&&(s=d.getData("text"))&&(i=[s],a="text")}}i?g({files:i,type:a,target:l,dropEvt:t}):(n=["errUploadNoFiles"],"file"===u&&n.push("errFolderUpload"),c.error(n),w.reject())},!p&&n?(n.input||n.files?(n.type="files",g(n)):n.dropEvt&&o(n.dropEvt),w):(s=function(t){var n,t=t.originalEvent||t,i=[],a=[];if(t.clipboardData){if(t.clipboardData.items&&t.clipboardData.items.length){a=t.clipboardData.items;for(var r=0;r<a.length;r++)"file"==t.clipboardData.items[r].kind&&(n=t.clipboardData.items[r].getAsFile(),i.push(n))}else t.clipboardData.files&&t.clipboardData.files.length&&(i=t.clipboardData.files);if(i.length)return void v({files:i,type:"files"})}var o=t.target||t.srcElement;setTimeout(function(){if(o.innerHTML){e(o).find("img").each(function(t,n){n.src.match(/^webkit-fake-url:\/\//)&&e(n).remove()});var t=o.innerHTML.replace(/<br[^>]*>/gi," "),n=t.match(/<[^>]+>/)?"html":"text";o.innerHTML="",v({files:[t],type:n})}},1)},i=e('<div class="elfinder-upload-dialog-wrapper"/>').append(y("multiple","selectForUpload")),!c.UA.Mobile&&function(e){return"undefined"!=typeof e.webkitdirectory||"undefined"!=typeof e.directory}(document.createElement("input"))&&i.append(y("multiple webkitdirectory directory","selectFolder")),m.dirs&&(m.hash===u||e("#"+c.navHash2Id(m.hash)).hasClass("elfinder-subtree-loaded")?b().appendTo(i):(l=e('<div class="elfinder-upload-dirselect" title="'+c.i18n("nowLoading")+'"/>').append('<span class="elfinder-button-icon elfinder-button-icon-spinner" />').appendTo(i),c.request({cmd:"tree",
  1824. target:m.hash}).done(function(){c.one("treedone",function(){l.replaceWith(b()),d.elfinderdialog("tabstopsInit")})}).fail(function(){l.remove()}))),c.dragUpload?a=e('<div class="ui-corner-all elfinder-upload-dropbox elfinder-tabstop" contenteditable="true" data-ph="'+c.i18n("dropPasteFiles")+'"></div>').on("paste",function(e){s(e)}).on("mousedown click",function(){e(this).focus()}).on("focus",function(){this.innerHTML=""}).on("mouseover",function(){e(this).addClass(t)}).on("mouseout",function(){e(this).removeClass(t)}).on("dragenter",function(n){n.stopPropagation(),n.preventDefault(),e(this).addClass(t)}).on("dragleave",function(n){n.stopPropagation(),n.preventDefault(),e(this).removeClass(t)}).on("dragover",function(n){n.stopPropagation(),n.preventDefault(),n.originalEvent.dataTransfer.dropEffect="copy",e(this).addClass(t)}).on("drop",function(e){i.elfinderdialog("close"),p&&(e.originalEvent._target=p[0]),o(e.originalEvent)}).prependTo(i).after('<div class="elfinder-upload-dialog-or">'+c.i18n("or")+"</div>")[0]:r=e('<div class="ui-corner-all elfinder-upload-dropbox" contenteditable="true">'+c.i18n("dropFilesBrowser")+"</div>").on("paste drop",function(e){s(e)}).on("mousedown click",function(){e(this).focus()}).on("focus",function(){this.innerHTML=""}).on("dragenter mouseover",function(){e(this).addClass(t)}).on("dragleave mouseout",function(){e(this).removeClass(t)}).prependTo(i).after('<div class="elfinder-upload-dialog-or">'+c.i18n("or")+"</div>")[0],d=c.dialog(i,{title:this.title+'<span class="elfinder-upload-target">'+(m?" - "+c.escape(m.i18||m.name):"")+"</span>",modal:!0,resizable:!1,destroyOnClose:!0}),w)}},i.prototype.commands.view=function(){var e=this.fm;this.value=e.viewType,this.alwaysEnabled=!0,this.updateOnSelect=!1,this.options={ui:"viewbutton"},this.getstate=function(){return 0},this.exec=function(){var t=this,n=e.storage("view","list"==this.value?"icons":"list");return e.lazy(function(){e.viewchange(),t.update(void 0,n),this.resolve()})}},i});
  1825. });
  1826. define('jquery', function (require, exports, module) {
  1827. /*!
  1828. * jQuery JavaScript Library v3.2.1
  1829. * https://jquery.com/
  1830. *
  1831. * Includes Sizzle.js
  1832. * https://sizzlejs.com/
  1833. *
  1834. * Copyright JS Foundation and other contributors
  1835. * Released under the MIT license
  1836. * https://jquery.org/license
  1837. *
  1838. * Date: 2017-03-20T18:59Z
  1839. */
  1840. ( function( global, factory ) {
  1841. "use strict";
  1842. if ( typeof module === "object" && typeof module.exports === "object" ) {
  1843. // For CommonJS and CommonJS-like environments where a proper `window`
  1844. // is present, execute the factory and get jQuery.
  1845. // For environments that do not have a `window` with a `document`
  1846. // (such as Node.js), expose a factory as module.exports.
  1847. // This accentuates the need for the creation of a real `window`.
  1848. // e.g. var jQuery = require("jquery")(window);
  1849. // See ticket #14549 for more info.
  1850. module.exports = global.document ?
  1851. factory( global, true ) :
  1852. function( w ) {
  1853. if ( !w.document ) {
  1854. throw new Error( "jQuery requires a window with a document" );
  1855. }
  1856. return factory( w );
  1857. };
  1858. } else {
  1859. factory( global );
  1860. }
  1861. // Pass this if window is not defined yet
  1862. } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  1863. // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
  1864. // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
  1865. // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
  1866. // enough that all such attempts are guarded in a try block.
  1867. "use strict";
  1868. var arr = [];
  1869. var document = window.document;
  1870. var getProto = Object.getPrototypeOf;
  1871. var slice = arr.slice;
  1872. var concat = arr.concat;
  1873. var push = arr.push;
  1874. var indexOf = arr.indexOf;
  1875. var class2type = {};
  1876. var toString = class2type.toString;
  1877. var hasOwn = class2type.hasOwnProperty;
  1878. var fnToString = hasOwn.toString;
  1879. var ObjectFunctionString = fnToString.call( Object );
  1880. var support = {};
  1881. function DOMEval( code, doc ) {
  1882. doc = doc || document;
  1883. var script = doc.createElement( "script" );
  1884. script.text = code;
  1885. doc.head.appendChild( script ).parentNode.removeChild( script );
  1886. }
  1887. /* global Symbol */
  1888. // Defining this global in .eslintrc.json would create a danger of using the global
  1889. // unguarded in another place, it seems safer to define global only for this module
  1890. var
  1891. version = "3.2.1",
  1892. // Define a local copy of jQuery
  1893. jQuery = function( selector, context ) {
  1894. // The jQuery object is actually just the init constructor 'enhanced'
  1895. // Need init if jQuery is called (just allow error to be thrown if not included)
  1896. return new jQuery.fn.init( selector, context );
  1897. },
  1898. // Support: Android <=4.0 only
  1899. // Make sure we trim BOM and NBSP
  1900. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
  1901. // Matches dashed string for camelizing
  1902. rmsPrefix = /^-ms-/,
  1903. rdashAlpha = /-([a-z])/g,
  1904. // Used by jQuery.camelCase as callback to replace()
  1905. fcamelCase = function( all, letter ) {
  1906. return letter.toUpperCase();
  1907. };
  1908. jQuery.fn = jQuery.prototype = {
  1909. // The current version of jQuery being used
  1910. jquery: version,
  1911. constructor: jQuery,
  1912. // The default length of a jQuery object is 0
  1913. length: 0,
  1914. toArray: function() {
  1915. return slice.call( this );
  1916. },
  1917. // Get the Nth element in the matched element set OR
  1918. // Get the whole matched element set as a clean array
  1919. get: function( num ) {
  1920. // Return all the elements in a clean array
  1921. if ( num == null ) {
  1922. return slice.call( this );
  1923. }
  1924. // Return just the one element from the set
  1925. return num < 0 ? this[ num + this.length ] : this[ num ];
  1926. },
  1927. // Take an array of elements and push it onto the stack
  1928. // (returning the new matched element set)
  1929. pushStack: function( elems ) {
  1930. // Build a new jQuery matched element set
  1931. var ret = jQuery.merge( this.constructor(), elems );
  1932. // Add the old object onto the stack (as a reference)
  1933. ret.prevObject = this;
  1934. // Return the newly-formed element set
  1935. return ret;
  1936. },
  1937. // Execute a callback for every element in the matched set.
  1938. each: function( callback ) {
  1939. return jQuery.each( this, callback );
  1940. },
  1941. map: function( callback ) {
  1942. return this.pushStack( jQuery.map( this, function( elem, i ) {
  1943. return callback.call( elem, i, elem );
  1944. } ) );
  1945. },
  1946. slice: function() {
  1947. return this.pushStack( slice.apply( this, arguments ) );
  1948. },
  1949. first: function() {
  1950. return this.eq( 0 );
  1951. },
  1952. last: function() {
  1953. return this.eq( -1 );
  1954. },
  1955. eq: function( i ) {
  1956. var len = this.length,
  1957. j = +i + ( i < 0 ? len : 0 );
  1958. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  1959. },
  1960. end: function() {
  1961. return this.prevObject || this.constructor();
  1962. },
  1963. // For internal use only.
  1964. // Behaves like an Array's method, not like a jQuery method.
  1965. push: push,
  1966. sort: arr.sort,
  1967. splice: arr.splice
  1968. };
  1969. jQuery.extend = jQuery.fn.extend = function() {
  1970. var options, name, src, copy, copyIsArray, clone,
  1971. target = arguments[ 0 ] || {},
  1972. i = 1,
  1973. length = arguments.length,
  1974. deep = false;
  1975. // Handle a deep copy situation
  1976. if ( typeof target === "boolean" ) {
  1977. deep = target;
  1978. // Skip the boolean and the target
  1979. target = arguments[ i ] || {};
  1980. i++;
  1981. }
  1982. // Handle case when target is a string or something (possible in deep copy)
  1983. if ( typeof target !== "object" && !jQuery.isFunction( target ) ) {
  1984. target = {};
  1985. }
  1986. // Extend jQuery itself if only one argument is passed
  1987. if ( i === length ) {
  1988. target = this;
  1989. i--;
  1990. }
  1991. for ( ; i < length; i++ ) {
  1992. // Only deal with non-null/undefined values
  1993. if ( ( options = arguments[ i ] ) != null ) {
  1994. // Extend the base object
  1995. for ( name in options ) {
  1996. src = target[ name ];
  1997. copy = options[ name ];
  1998. // Prevent never-ending loop
  1999. if ( target === copy ) {
  2000. continue;
  2001. }
  2002. // Recurse if we're merging plain objects or arrays
  2003. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  2004. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  2005. if ( copyIsArray ) {
  2006. copyIsArray = false;
  2007. clone = src && Array.isArray( src ) ? src : [];
  2008. } else {
  2009. clone = src && jQuery.isPlainObject( src ) ? src : {};
  2010. }
  2011. // Never move original objects, clone them
  2012. target[ name ] = jQuery.extend( deep, clone, copy );
  2013. // Don't bring in undefined values
  2014. } else if ( copy !== undefined ) {
  2015. target[ name ] = copy;
  2016. }
  2017. }
  2018. }
  2019. }
  2020. // Return the modified object
  2021. return target;
  2022. };
  2023. jQuery.extend( {
  2024. // Unique for each copy of jQuery on the page
  2025. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  2026. // Assume jQuery is ready without the ready module
  2027. isReady: true,
  2028. error: function( msg ) {
  2029. throw new Error( msg );
  2030. },
  2031. noop: function() {},
  2032. isFunction: function( obj ) {
  2033. return jQuery.type( obj ) === "function";
  2034. },
  2035. isWindow: function( obj ) {
  2036. return obj != null && obj === obj.window;
  2037. },
  2038. isNumeric: function( obj ) {
  2039. // As of jQuery 3.0, isNumeric is limited to
  2040. // strings and numbers (primitives or objects)
  2041. // that can be coerced to finite numbers (gh-2662)
  2042. var type = jQuery.type( obj );
  2043. return ( type === "number" || type === "string" ) &&
  2044. // parseFloat NaNs numeric-cast false positives ("")
  2045. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  2046. // subtraction forces infinities to NaN
  2047. !isNaN( obj - parseFloat( obj ) );
  2048. },
  2049. isPlainObject: function( obj ) {
  2050. var proto, Ctor;
  2051. // Detect obvious negatives
  2052. // Use toString instead of jQuery.type to catch host objects
  2053. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  2054. return false;
  2055. }
  2056. proto = getProto( obj );
  2057. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  2058. if ( !proto ) {
  2059. return true;
  2060. }
  2061. // Objects with prototype are plain iff they were constructed by a global Object function
  2062. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  2063. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  2064. },
  2065. isEmptyObject: function( obj ) {
  2066. /* eslint-disable no-unused-vars */
  2067. // See https://github.com/eslint/eslint/issues/6125
  2068. var name;
  2069. for ( name in obj ) {
  2070. return false;
  2071. }
  2072. return true;
  2073. },
  2074. type: function( obj ) {
  2075. if ( obj == null ) {
  2076. return obj + "";
  2077. }
  2078. // Support: Android <=2.3 only (functionish RegExp)
  2079. return typeof obj === "object" || typeof obj === "function" ?
  2080. class2type[ toString.call( obj ) ] || "object" :
  2081. typeof obj;
  2082. },
  2083. // Evaluates a script in a global context
  2084. globalEval: function( code ) {
  2085. DOMEval( code );
  2086. },
  2087. // Convert dashed to camelCase; used by the css and data modules
  2088. // Support: IE <=9 - 11, Edge 12 - 13
  2089. // Microsoft forgot to hump their vendor prefix (#9572)
  2090. camelCase: function( string ) {
  2091. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  2092. },
  2093. each: function( obj, callback ) {
  2094. var length, i = 0;
  2095. if ( isArrayLike( obj ) ) {
  2096. length = obj.length;
  2097. for ( ; i < length; i++ ) {
  2098. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  2099. break;
  2100. }
  2101. }
  2102. } else {
  2103. for ( i in obj ) {
  2104. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  2105. break;
  2106. }
  2107. }
  2108. }
  2109. return obj;
  2110. },
  2111. // Support: Android <=4.0 only
  2112. trim: function( text ) {
  2113. return text == null ?
  2114. "" :
  2115. ( text + "" ).replace( rtrim, "" );
  2116. },
  2117. // results is for internal usage only
  2118. makeArray: function( arr, results ) {
  2119. var ret = results || [];
  2120. if ( arr != null ) {
  2121. if ( isArrayLike( Object( arr ) ) ) {
  2122. jQuery.merge( ret,
  2123. typeof arr === "string" ?
  2124. [ arr ] : arr
  2125. );
  2126. } else {
  2127. push.call( ret, arr );
  2128. }
  2129. }
  2130. return ret;
  2131. },
  2132. inArray: function( elem, arr, i ) {
  2133. return arr == null ? -1 : indexOf.call( arr, elem, i );
  2134. },
  2135. // Support: Android <=4.0 only, PhantomJS 1 only
  2136. // push.apply(_, arraylike) throws on ancient WebKit
  2137. merge: function( first, second ) {
  2138. var len = +second.length,
  2139. j = 0,
  2140. i = first.length;
  2141. for ( ; j < len; j++ ) {
  2142. first[ i++ ] = second[ j ];
  2143. }
  2144. first.length = i;
  2145. return first;
  2146. },
  2147. grep: function( elems, callback, invert ) {
  2148. var callbackInverse,
  2149. matches = [],
  2150. i = 0,
  2151. length = elems.length,
  2152. callbackExpect = !invert;
  2153. // Go through the array, only saving the items
  2154. // that pass the validator function
  2155. for ( ; i < length; i++ ) {
  2156. callbackInverse = !callback( elems[ i ], i );
  2157. if ( callbackInverse !== callbackExpect ) {
  2158. matches.push( elems[ i ] );
  2159. }
  2160. }
  2161. return matches;
  2162. },
  2163. // arg is for internal usage only
  2164. map: function( elems, callback, arg ) {
  2165. var length, value,
  2166. i = 0,
  2167. ret = [];
  2168. // Go through the array, translating each of the items to their new values
  2169. if ( isArrayLike( elems ) ) {
  2170. length = elems.length;
  2171. for ( ; i < length; i++ ) {
  2172. value = callback( elems[ i ], i, arg );
  2173. if ( value != null ) {
  2174. ret.push( value );
  2175. }
  2176. }
  2177. // Go through every key on the object,
  2178. } else {
  2179. for ( i in elems ) {
  2180. value = callback( elems[ i ], i, arg );
  2181. if ( value != null ) {
  2182. ret.push( value );
  2183. }
  2184. }
  2185. }
  2186. // Flatten any nested arrays
  2187. return concat.apply( [], ret );
  2188. },
  2189. // A global GUID counter for objects
  2190. guid: 1,
  2191. // Bind a function to a context, optionally partially applying any
  2192. // arguments.
  2193. proxy: function( fn, context ) {
  2194. var tmp, args, proxy;
  2195. if ( typeof context === "string" ) {
  2196. tmp = fn[ context ];
  2197. context = fn;
  2198. fn = tmp;
  2199. }
  2200. // Quick check to determine if target is callable, in the spec
  2201. // this throws a TypeError, but we will just return undefined.
  2202. if ( !jQuery.isFunction( fn ) ) {
  2203. return undefined;
  2204. }
  2205. // Simulated bind
  2206. args = slice.call( arguments, 2 );
  2207. proxy = function() {
  2208. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  2209. };
  2210. // Set the guid of unique handler to the same of original handler, so it can be removed
  2211. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  2212. return proxy;
  2213. },
  2214. now: Date.now,
  2215. // jQuery.support is not used in Core but other projects attach their
  2216. // properties to it so it needs to exist.
  2217. support: support
  2218. } );
  2219. if ( typeof Symbol === "function" ) {
  2220. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  2221. }
  2222. // Populate the class2type map
  2223. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  2224. function( i, name ) {
  2225. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  2226. } );
  2227. function isArrayLike( obj ) {
  2228. // Support: real iOS 8.2 only (not reproducible in simulator)
  2229. // `in` check used to prevent JIT error (gh-2145)
  2230. // hasOwn isn't used here due to false negatives
  2231. // regarding Nodelist length in IE
  2232. var length = !!obj && "length" in obj && obj.length,
  2233. type = jQuery.type( obj );
  2234. if ( type === "function" || jQuery.isWindow( obj ) ) {
  2235. return false;
  2236. }
  2237. return type === "array" || length === 0 ||
  2238. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  2239. }
  2240. var Sizzle =
  2241. /*!
  2242. * Sizzle CSS Selector Engine v2.3.3
  2243. * https://sizzlejs.com/
  2244. *
  2245. * Copyright jQuery Foundation and other contributors
  2246. * Released under the MIT license
  2247. * http://jquery.org/license
  2248. *
  2249. * Date: 2016-08-08
  2250. */
  2251. (function( window ) {
  2252. var i,
  2253. support,
  2254. Expr,
  2255. getText,
  2256. isXML,
  2257. tokenize,
  2258. compile,
  2259. select,
  2260. outermostContext,
  2261. sortInput,
  2262. hasDuplicate,
  2263. // Local document vars
  2264. setDocument,
  2265. document,
  2266. docElem,
  2267. documentIsHTML,
  2268. rbuggyQSA,
  2269. rbuggyMatches,
  2270. matches,
  2271. contains,
  2272. // Instance-specific data
  2273. expando = "sizzle" + 1 * new Date(),
  2274. preferredDoc = window.document,
  2275. dirruns = 0,
  2276. done = 0,
  2277. classCache = createCache(),
  2278. tokenCache = createCache(),
  2279. compilerCache = createCache(),
  2280. sortOrder = function( a, b ) {
  2281. if ( a === b ) {
  2282. hasDuplicate = true;
  2283. }
  2284. return 0;
  2285. },
  2286. // Instance methods
  2287. hasOwn = ({}).hasOwnProperty,
  2288. arr = [],
  2289. pop = arr.pop,
  2290. push_native = arr.push,
  2291. push = arr.push,
  2292. slice = arr.slice,
  2293. // Use a stripped-down indexOf as it's faster than native
  2294. // https://jsperf.com/thor-indexof-vs-for/5
  2295. indexOf = function( list, elem ) {
  2296. var i = 0,
  2297. len = list.length;
  2298. for ( ; i < len; i++ ) {
  2299. if ( list[i] === elem ) {
  2300. return i;
  2301. }
  2302. }
  2303. return -1;
  2304. },
  2305. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  2306. // Regular expressions
  2307. // http://www.w3.org/TR/css3-selectors/#whitespace
  2308. whitespace = "[\\x20\\t\\r\\n\\f]",
  2309. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  2310. identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
  2311. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  2312. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  2313. // Operator (capture 2)
  2314. "*([*^$|!~]?=)" + whitespace +
  2315. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  2316. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  2317. "*\\]",
  2318. pseudos = ":(" + identifier + ")(?:\\((" +
  2319. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  2320. // 1. quoted (capture 3; capture 4 or capture 5)
  2321. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  2322. // 2. simple (capture 6)
  2323. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  2324. // 3. anything else (capture 2)
  2325. ".*" +
  2326. ")\\)|)",
  2327. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  2328. rwhitespace = new RegExp( whitespace + "+", "g" ),
  2329. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  2330. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  2331. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  2332. rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
  2333. rpseudo = new RegExp( pseudos ),
  2334. ridentifier = new RegExp( "^" + identifier + "$" ),
  2335. matchExpr = {
  2336. "ID": new RegExp( "^#(" + identifier + ")" ),
  2337. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  2338. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  2339. "ATTR": new RegExp( "^" + attributes ),
  2340. "PSEUDO": new RegExp( "^" + pseudos ),
  2341. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  2342. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  2343. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  2344. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  2345. // For use in libraries implementing .is()
  2346. // We use this for POS matching in `select`
  2347. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  2348. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  2349. },
  2350. rinputs = /^(?:input|select|textarea|button)$/i,
  2351. rheader = /^h\d$/i,
  2352. rnative = /^[^{]+\{\s*\[native \w/,
  2353. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  2354. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  2355. rsibling = /[+~]/,
  2356. // CSS escapes
  2357. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  2358. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  2359. funescape = function( _, escaped, escapedWhitespace ) {
  2360. var high = "0x" + escaped - 0x10000;
  2361. // NaN means non-codepoint
  2362. // Support: Firefox<24
  2363. // Workaround erroneous numeric interpretation of +"0x"
  2364. return high !== high || escapedWhitespace ?
  2365. escaped :
  2366. high < 0 ?
  2367. // BMP codepoint
  2368. String.fromCharCode( high + 0x10000 ) :
  2369. // Supplemental Plane codepoint (surrogate pair)
  2370. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  2371. },
  2372. // CSS string/identifier serialization
  2373. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  2374. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  2375. fcssescape = function( ch, asCodePoint ) {
  2376. if ( asCodePoint ) {
  2377. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  2378. if ( ch === "\0" ) {
  2379. return "\uFFFD";
  2380. }
  2381. // Control characters and (dependent upon position) numbers get escaped as code points
  2382. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  2383. }
  2384. // Other potentially-special ASCII characters get backslash-escaped
  2385. return "\\" + ch;
  2386. },
  2387. // Used for iframes
  2388. // See setDocument()
  2389. // Removing the function wrapper causes a "Permission Denied"
  2390. // error in IE
  2391. unloadHandler = function() {
  2392. setDocument();
  2393. },
  2394. disabledAncestor = addCombinator(
  2395. function( elem ) {
  2396. return elem.disabled === true && ("form" in elem || "label" in elem);
  2397. },
  2398. { dir: "parentNode", next: "legend" }
  2399. );
  2400. // Optimize for push.apply( _, NodeList )
  2401. try {
  2402. push.apply(
  2403. (arr = slice.call( preferredDoc.childNodes )),
  2404. preferredDoc.childNodes
  2405. );
  2406. // Support: Android<4.0
  2407. // Detect silently failing push.apply
  2408. arr[ preferredDoc.childNodes.length ].nodeType;
  2409. } catch ( e ) {
  2410. push = { apply: arr.length ?
  2411. // Leverage slice if possible
  2412. function( target, els ) {
  2413. push_native.apply( target, slice.call(els) );
  2414. } :
  2415. // Support: IE<9
  2416. // Otherwise append directly
  2417. function( target, els ) {
  2418. var j = target.length,
  2419. i = 0;
  2420. // Can't trust NodeList.length
  2421. while ( (target[j++] = els[i++]) ) {}
  2422. target.length = j - 1;
  2423. }
  2424. };
  2425. }
  2426. function Sizzle( selector, context, results, seed ) {
  2427. var m, i, elem, nid, match, groups, newSelector,
  2428. newContext = context && context.ownerDocument,
  2429. // nodeType defaults to 9, since context defaults to document
  2430. nodeType = context ? context.nodeType : 9;
  2431. results = results || [];
  2432. // Return early from calls with invalid selector or context
  2433. if ( typeof selector !== "string" || !selector ||
  2434. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  2435. return results;
  2436. }
  2437. // Try to shortcut find operations (as opposed to filters) in HTML documents
  2438. if ( !seed ) {
  2439. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  2440. setDocument( context );
  2441. }
  2442. context = context || document;
  2443. if ( documentIsHTML ) {
  2444. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  2445. // (excepting DocumentFragment context, where the methods don't exist)
  2446. if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
  2447. // ID selector
  2448. if ( (m = match[1]) ) {
  2449. // Document context
  2450. if ( nodeType === 9 ) {
  2451. if ( (elem = context.getElementById( m )) ) {
  2452. // Support: IE, Opera, Webkit
  2453. // TODO: identify versions
  2454. // getElementById can match elements by name instead of ID
  2455. if ( elem.id === m ) {
  2456. results.push( elem );
  2457. return results;
  2458. }
  2459. } else {
  2460. return results;
  2461. }
  2462. // Element context
  2463. } else {
  2464. // Support: IE, Opera, Webkit
  2465. // TODO: identify versions
  2466. // getElementById can match elements by name instead of ID
  2467. if ( newContext && (elem = newContext.getElementById( m )) &&
  2468. contains( context, elem ) &&
  2469. elem.id === m ) {
  2470. results.push( elem );
  2471. return results;
  2472. }
  2473. }
  2474. // Type selector
  2475. } else if ( match[2] ) {
  2476. push.apply( results, context.getElementsByTagName( selector ) );
  2477. return results;
  2478. // Class selector
  2479. } else if ( (m = match[3]) && support.getElementsByClassName &&
  2480. context.getElementsByClassName ) {
  2481. push.apply( results, context.getElementsByClassName( m ) );
  2482. return results;
  2483. }
  2484. }
  2485. // Take advantage of querySelectorAll
  2486. if ( support.qsa &&
  2487. !compilerCache[ selector + " " ] &&
  2488. (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
  2489. if ( nodeType !== 1 ) {
  2490. newContext = context;
  2491. newSelector = selector;
  2492. // qSA looks outside Element context, which is not what we want
  2493. // Thanks to Andrew Dupont for this workaround technique
  2494. // Support: IE <=8
  2495. // Exclude object elements
  2496. } else if ( context.nodeName.toLowerCase() !== "object" ) {
  2497. // Capture the context ID, setting it first if necessary
  2498. if ( (nid = context.getAttribute( "id" )) ) {
  2499. nid = nid.replace( rcssescape, fcssescape );
  2500. } else {
  2501. context.setAttribute( "id", (nid = expando) );
  2502. }
  2503. // Prefix every selector in the list
  2504. groups = tokenize( selector );
  2505. i = groups.length;
  2506. while ( i-- ) {
  2507. groups[i] = "#" + nid + " " + toSelector( groups[i] );
  2508. }
  2509. newSelector = groups.join( "," );
  2510. // Expand context for sibling selectors
  2511. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  2512. context;
  2513. }
  2514. if ( newSelector ) {
  2515. try {
  2516. push.apply( results,
  2517. newContext.querySelectorAll( newSelector )
  2518. );
  2519. return results;
  2520. } catch ( qsaError ) {
  2521. } finally {
  2522. if ( nid === expando ) {
  2523. context.removeAttribute( "id" );
  2524. }
  2525. }
  2526. }
  2527. }
  2528. }
  2529. }
  2530. // All others
  2531. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  2532. }
  2533. /**
  2534. * Create key-value caches of limited size
  2535. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  2536. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  2537. * deleting the oldest entry
  2538. */
  2539. function createCache() {
  2540. var keys = [];
  2541. function cache( key, value ) {
  2542. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  2543. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  2544. // Only keep the most recent entries
  2545. delete cache[ keys.shift() ];
  2546. }
  2547. return (cache[ key + " " ] = value);
  2548. }
  2549. return cache;
  2550. }
  2551. /**
  2552. * Mark a function for special use by Sizzle
  2553. * @param {Function} fn The function to mark
  2554. */
  2555. function markFunction( fn ) {
  2556. fn[ expando ] = true;
  2557. return fn;
  2558. }
  2559. /**
  2560. * Support testing using an element
  2561. * @param {Function} fn Passed the created element and returns a boolean result
  2562. */
  2563. function assert( fn ) {
  2564. var el = document.createElement("fieldset");
  2565. try {
  2566. return !!fn( el );
  2567. } catch (e) {
  2568. return false;
  2569. } finally {
  2570. // Remove from its parent by default
  2571. if ( el.parentNode ) {
  2572. el.parentNode.removeChild( el );
  2573. }
  2574. // release memory in IE
  2575. el = null;
  2576. }
  2577. }
  2578. /**
  2579. * Adds the same handler for all of the specified attrs
  2580. * @param {String} attrs Pipe-separated list of attributes
  2581. * @param {Function} handler The method that will be applied
  2582. */
  2583. function addHandle( attrs, handler ) {
  2584. var arr = attrs.split("|"),
  2585. i = arr.length;
  2586. while ( i-- ) {
  2587. Expr.attrHandle[ arr[i] ] = handler;
  2588. }
  2589. }
  2590. /**
  2591. * Checks document order of two siblings
  2592. * @param {Element} a
  2593. * @param {Element} b
  2594. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  2595. */
  2596. function siblingCheck( a, b ) {
  2597. var cur = b && a,
  2598. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  2599. a.sourceIndex - b.sourceIndex;
  2600. // Use IE sourceIndex if available on both nodes
  2601. if ( diff ) {
  2602. return diff;
  2603. }
  2604. // Check if b follows a
  2605. if ( cur ) {
  2606. while ( (cur = cur.nextSibling) ) {
  2607. if ( cur === b ) {
  2608. return -1;
  2609. }
  2610. }
  2611. }
  2612. return a ? 1 : -1;
  2613. }
  2614. /**
  2615. * Returns a function to use in pseudos for input types
  2616. * @param {String} type
  2617. */
  2618. function createInputPseudo( type ) {
  2619. return function( elem ) {
  2620. var name = elem.nodeName.toLowerCase();
  2621. return name === "input" && elem.type === type;
  2622. };
  2623. }
  2624. /**
  2625. * Returns a function to use in pseudos for buttons
  2626. * @param {String} type
  2627. */
  2628. function createButtonPseudo( type ) {
  2629. return function( elem ) {
  2630. var name = elem.nodeName.toLowerCase();
  2631. return (name === "input" || name === "button") && elem.type === type;
  2632. };
  2633. }
  2634. /**
  2635. * Returns a function to use in pseudos for :enabled/:disabled
  2636. * @param {Boolean} disabled true for :disabled; false for :enabled
  2637. */
  2638. function createDisabledPseudo( disabled ) {
  2639. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  2640. return function( elem ) {
  2641. // Only certain elements can match :enabled or :disabled
  2642. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  2643. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  2644. if ( "form" in elem ) {
  2645. // Check for inherited disabledness on relevant non-disabled elements:
  2646. // * listed form-associated elements in a disabled fieldset
  2647. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  2648. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  2649. // * option elements in a disabled optgroup
  2650. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  2651. // All such elements have a "form" property.
  2652. if ( elem.parentNode && elem.disabled === false ) {
  2653. // Option elements defer to a parent optgroup if present
  2654. if ( "label" in elem ) {
  2655. if ( "label" in elem.parentNode ) {
  2656. return elem.parentNode.disabled === disabled;
  2657. } else {
  2658. return elem.disabled === disabled;
  2659. }
  2660. }
  2661. // Support: IE 6 - 11
  2662. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  2663. return elem.isDisabled === disabled ||
  2664. // Where there is no isDisabled, check manually
  2665. /* jshint -W018 */
  2666. elem.isDisabled !== !disabled &&
  2667. disabledAncestor( elem ) === disabled;
  2668. }
  2669. return elem.disabled === disabled;
  2670. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  2671. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  2672. // even exist on them, let alone have a boolean value.
  2673. } else if ( "label" in elem ) {
  2674. return elem.disabled === disabled;
  2675. }
  2676. // Remaining elements are neither :enabled nor :disabled
  2677. return false;
  2678. };
  2679. }
  2680. /**
  2681. * Returns a function to use in pseudos for positionals
  2682. * @param {Function} fn
  2683. */
  2684. function createPositionalPseudo( fn ) {
  2685. return markFunction(function( argument ) {
  2686. argument = +argument;
  2687. return markFunction(function( seed, matches ) {
  2688. var j,
  2689. matchIndexes = fn( [], seed.length, argument ),
  2690. i = matchIndexes.length;
  2691. // Match elements found at the specified indexes
  2692. while ( i-- ) {
  2693. if ( seed[ (j = matchIndexes[i]) ] ) {
  2694. seed[j] = !(matches[j] = seed[j]);
  2695. }
  2696. }
  2697. });
  2698. });
  2699. }
  2700. /**
  2701. * Checks a node for validity as a Sizzle context
  2702. * @param {Element|Object=} context
  2703. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  2704. */
  2705. function testContext( context ) {
  2706. return context && typeof context.getElementsByTagName !== "undefined" && context;
  2707. }
  2708. // Expose support vars for convenience
  2709. support = Sizzle.support = {};
  2710. /**
  2711. * Detects XML nodes
  2712. * @param {Element|Object} elem An element or a document
  2713. * @returns {Boolean} True iff elem is a non-HTML XML node
  2714. */
  2715. isXML = Sizzle.isXML = function( elem ) {
  2716. // documentElement is verified for cases where it doesn't yet exist
  2717. // (such as loading iframes in IE - #4833)
  2718. var documentElement = elem && (elem.ownerDocument || elem).documentElement;
  2719. return documentElement ? documentElement.nodeName !== "HTML" : false;
  2720. };
  2721. /**
  2722. * Sets document-related variables once based on the current document
  2723. * @param {Element|Object} [doc] An element or document object to use to set the document
  2724. * @returns {Object} Returns the current document
  2725. */
  2726. setDocument = Sizzle.setDocument = function( node ) {
  2727. var hasCompare, subWindow,
  2728. doc = node ? node.ownerDocument || node : preferredDoc;
  2729. // Return early if doc is invalid or already selected
  2730. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  2731. return document;
  2732. }
  2733. // Update global variables
  2734. document = doc;
  2735. docElem = document.documentElement;
  2736. documentIsHTML = !isXML( document );
  2737. // Support: IE 9-11, Edge
  2738. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  2739. if ( preferredDoc !== document &&
  2740. (subWindow = document.defaultView) && subWindow.top !== subWindow ) {
  2741. // Support: IE 11, Edge
  2742. if ( subWindow.addEventListener ) {
  2743. subWindow.addEventListener( "unload", unloadHandler, false );
  2744. // Support: IE 9 - 10 only
  2745. } else if ( subWindow.attachEvent ) {
  2746. subWindow.attachEvent( "onunload", unloadHandler );
  2747. }
  2748. }
  2749. /* Attributes
  2750. ---------------------------------------------------------------------- */
  2751. // Support: IE<8
  2752. // Verify that getAttribute really returns attributes and not properties
  2753. // (excepting IE8 booleans)
  2754. support.attributes = assert(function( el ) {
  2755. el.className = "i";
  2756. return !el.getAttribute("className");
  2757. });
  2758. /* getElement(s)By*
  2759. ---------------------------------------------------------------------- */
  2760. // Check if getElementsByTagName("*") returns only elements
  2761. support.getElementsByTagName = assert(function( el ) {
  2762. el.appendChild( document.createComment("") );
  2763. return !el.getElementsByTagName("*").length;
  2764. });
  2765. // Support: IE<9
  2766. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  2767. // Support: IE<10
  2768. // Check if getElementById returns elements by name
  2769. // The broken getElementById methods don't pick up programmatically-set names,
  2770. // so use a roundabout getElementsByName test
  2771. support.getById = assert(function( el ) {
  2772. docElem.appendChild( el ).id = expando;
  2773. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  2774. });
  2775. // ID filter and find
  2776. if ( support.getById ) {
  2777. Expr.filter["ID"] = function( id ) {
  2778. var attrId = id.replace( runescape, funescape );
  2779. return function( elem ) {
  2780. return elem.getAttribute("id") === attrId;
  2781. };
  2782. };
  2783. Expr.find["ID"] = function( id, context ) {
  2784. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  2785. var elem = context.getElementById( id );
  2786. return elem ? [ elem ] : [];
  2787. }
  2788. };
  2789. } else {
  2790. Expr.filter["ID"] = function( id ) {
  2791. var attrId = id.replace( runescape, funescape );
  2792. return function( elem ) {
  2793. var node = typeof elem.getAttributeNode !== "undefined" &&
  2794. elem.getAttributeNode("id");
  2795. return node && node.value === attrId;
  2796. };
  2797. };
  2798. // Support: IE 6 - 7 only
  2799. // getElementById is not reliable as a find shortcut
  2800. Expr.find["ID"] = function( id, context ) {
  2801. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  2802. var node, i, elems,
  2803. elem = context.getElementById( id );
  2804. if ( elem ) {
  2805. // Verify the id attribute
  2806. node = elem.getAttributeNode("id");
  2807. if ( node && node.value === id ) {
  2808. return [ elem ];
  2809. }
  2810. // Fall back on getElementsByName
  2811. elems = context.getElementsByName( id );
  2812. i = 0;
  2813. while ( (elem = elems[i++]) ) {
  2814. node = elem.getAttributeNode("id");
  2815. if ( node && node.value === id ) {
  2816. return [ elem ];
  2817. }
  2818. }
  2819. }
  2820. return [];
  2821. }
  2822. };
  2823. }
  2824. // Tag
  2825. Expr.find["TAG"] = support.getElementsByTagName ?
  2826. function( tag, context ) {
  2827. if ( typeof context.getElementsByTagName !== "undefined" ) {
  2828. return context.getElementsByTagName( tag );
  2829. // DocumentFragment nodes don't have gEBTN
  2830. } else if ( support.qsa ) {
  2831. return context.querySelectorAll( tag );
  2832. }
  2833. } :
  2834. function( tag, context ) {
  2835. var elem,
  2836. tmp = [],
  2837. i = 0,
  2838. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  2839. results = context.getElementsByTagName( tag );
  2840. // Filter out possible comments
  2841. if ( tag === "*" ) {
  2842. while ( (elem = results[i++]) ) {
  2843. if ( elem.nodeType === 1 ) {
  2844. tmp.push( elem );
  2845. }
  2846. }
  2847. return tmp;
  2848. }
  2849. return results;
  2850. };
  2851. // Class
  2852. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  2853. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  2854. return context.getElementsByClassName( className );
  2855. }
  2856. };
  2857. /* QSA/matchesSelector
  2858. ---------------------------------------------------------------------- */
  2859. // QSA and matchesSelector support
  2860. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  2861. rbuggyMatches = [];
  2862. // qSa(:focus) reports false when true (Chrome 21)
  2863. // We allow this because of a bug in IE8/9 that throws an error
  2864. // whenever `document.activeElement` is accessed on an iframe
  2865. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  2866. // See https://bugs.jquery.com/ticket/13378
  2867. rbuggyQSA = [];
  2868. if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
  2869. // Build QSA regex
  2870. // Regex strategy adopted from Diego Perini
  2871. assert(function( el ) {
  2872. // Select is set to empty string on purpose
  2873. // This is to test IE's treatment of not explicitly
  2874. // setting a boolean content attribute,
  2875. // since its presence should be enough
  2876. // https://bugs.jquery.com/ticket/12359
  2877. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  2878. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  2879. "<option selected=''></option></select>";
  2880. // Support: IE8, Opera 11-12.16
  2881. // Nothing should be selected when empty strings follow ^= or $= or *=
  2882. // The test attribute must be unknown in Opera but "safe" for WinRT
  2883. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  2884. if ( el.querySelectorAll("[msallowcapture^='']").length ) {
  2885. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  2886. }
  2887. // Support: IE8
  2888. // Boolean attributes and "value" are not treated correctly
  2889. if ( !el.querySelectorAll("[selected]").length ) {
  2890. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  2891. }
  2892. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  2893. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  2894. rbuggyQSA.push("~=");
  2895. }
  2896. // Webkit/Opera - :checked should return selected option elements
  2897. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  2898. // IE8 throws error here and will not see later tests
  2899. if ( !el.querySelectorAll(":checked").length ) {
  2900. rbuggyQSA.push(":checked");
  2901. }
  2902. // Support: Safari 8+, iOS 8+
  2903. // https://bugs.webkit.org/show_bug.cgi?id=136851
  2904. // In-page `selector#id sibling-combinator selector` fails
  2905. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  2906. rbuggyQSA.push(".#.+[+~]");
  2907. }
  2908. });
  2909. assert(function( el ) {
  2910. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  2911. "<select disabled='disabled'><option/></select>";
  2912. // Support: Windows 8 Native Apps
  2913. // The type and name attributes are restricted during .innerHTML assignment
  2914. var input = document.createElement("input");
  2915. input.setAttribute( "type", "hidden" );
  2916. el.appendChild( input ).setAttribute( "name", "D" );
  2917. // Support: IE8
  2918. // Enforce case-sensitivity of name attribute
  2919. if ( el.querySelectorAll("[name=d]").length ) {
  2920. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  2921. }
  2922. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  2923. // IE8 throws error here and will not see later tests
  2924. if ( el.querySelectorAll(":enabled").length !== 2 ) {
  2925. rbuggyQSA.push( ":enabled", ":disabled" );
  2926. }
  2927. // Support: IE9-11+
  2928. // IE's :disabled selector does not pick up the children of disabled fieldsets
  2929. docElem.appendChild( el ).disabled = true;
  2930. if ( el.querySelectorAll(":disabled").length !== 2 ) {
  2931. rbuggyQSA.push( ":enabled", ":disabled" );
  2932. }
  2933. // Opera 10-11 does not throw on post-comma invalid pseudos
  2934. el.querySelectorAll("*,:x");
  2935. rbuggyQSA.push(",.*:");
  2936. });
  2937. }
  2938. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  2939. docElem.webkitMatchesSelector ||
  2940. docElem.mozMatchesSelector ||
  2941. docElem.oMatchesSelector ||
  2942. docElem.msMatchesSelector) )) ) {
  2943. assert(function( el ) {
  2944. // Check to see if it's possible to do matchesSelector
  2945. // on a disconnected node (IE 9)
  2946. support.disconnectedMatch = matches.call( el, "*" );
  2947. // This should fail with an exception
  2948. // Gecko does not error, returns false instead
  2949. matches.call( el, "[s!='']:x" );
  2950. rbuggyMatches.push( "!=", pseudos );
  2951. });
  2952. }
  2953. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  2954. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  2955. /* Contains
  2956. ---------------------------------------------------------------------- */
  2957. hasCompare = rnative.test( docElem.compareDocumentPosition );
  2958. // Element contains another
  2959. // Purposefully self-exclusive
  2960. // As in, an element does not contain itself
  2961. contains = hasCompare || rnative.test( docElem.contains ) ?
  2962. function( a, b ) {
  2963. var adown = a.nodeType === 9 ? a.documentElement : a,
  2964. bup = b && b.parentNode;
  2965. return a === bup || !!( bup && bup.nodeType === 1 && (
  2966. adown.contains ?
  2967. adown.contains( bup ) :
  2968. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  2969. ));
  2970. } :
  2971. function( a, b ) {
  2972. if ( b ) {
  2973. while ( (b = b.parentNode) ) {
  2974. if ( b === a ) {
  2975. return true;
  2976. }
  2977. }
  2978. }
  2979. return false;
  2980. };
  2981. /* Sorting
  2982. ---------------------------------------------------------------------- */
  2983. // Document order sorting
  2984. sortOrder = hasCompare ?
  2985. function( a, b ) {
  2986. // Flag for duplicate removal
  2987. if ( a === b ) {
  2988. hasDuplicate = true;
  2989. return 0;
  2990. }
  2991. // Sort on method existence if only one input has compareDocumentPosition
  2992. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  2993. if ( compare ) {
  2994. return compare;
  2995. }
  2996. // Calculate position if both inputs belong to the same document
  2997. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  2998. a.compareDocumentPosition( b ) :
  2999. // Otherwise we know they are disconnected
  3000. 1;
  3001. // Disconnected nodes
  3002. if ( compare & 1 ||
  3003. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  3004. // Choose the first element that is related to our preferred document
  3005. if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  3006. return -1;
  3007. }
  3008. if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  3009. return 1;
  3010. }
  3011. // Maintain original order
  3012. return sortInput ?
  3013. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  3014. 0;
  3015. }
  3016. return compare & 4 ? -1 : 1;
  3017. } :
  3018. function( a, b ) {
  3019. // Exit early if the nodes are identical
  3020. if ( a === b ) {
  3021. hasDuplicate = true;
  3022. return 0;
  3023. }
  3024. var cur,
  3025. i = 0,
  3026. aup = a.parentNode,
  3027. bup = b.parentNode,
  3028. ap = [ a ],
  3029. bp = [ b ];
  3030. // Parentless nodes are either documents or disconnected
  3031. if ( !aup || !bup ) {
  3032. return a === document ? -1 :
  3033. b === document ? 1 :
  3034. aup ? -1 :
  3035. bup ? 1 :
  3036. sortInput ?
  3037. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  3038. 0;
  3039. // If the nodes are siblings, we can do a quick check
  3040. } else if ( aup === bup ) {
  3041. return siblingCheck( a, b );
  3042. }
  3043. // Otherwise we need full lists of their ancestors for comparison
  3044. cur = a;
  3045. while ( (cur = cur.parentNode) ) {
  3046. ap.unshift( cur );
  3047. }
  3048. cur = b;
  3049. while ( (cur = cur.parentNode) ) {
  3050. bp.unshift( cur );
  3051. }
  3052. // Walk down the tree looking for a discrepancy
  3053. while ( ap[i] === bp[i] ) {
  3054. i++;
  3055. }
  3056. return i ?
  3057. // Do a sibling check if the nodes have a common ancestor
  3058. siblingCheck( ap[i], bp[i] ) :
  3059. // Otherwise nodes in our document sort first
  3060. ap[i] === preferredDoc ? -1 :
  3061. bp[i] === preferredDoc ? 1 :
  3062. 0;
  3063. };
  3064. return document;
  3065. };
  3066. Sizzle.matches = function( expr, elements ) {
  3067. return Sizzle( expr, null, null, elements );
  3068. };
  3069. Sizzle.matchesSelector = function( elem, expr ) {
  3070. // Set document vars if needed
  3071. if ( ( elem.ownerDocument || elem ) !== document ) {
  3072. setDocument( elem );
  3073. }
  3074. // Make sure that attribute selectors are quoted
  3075. expr = expr.replace( rattributeQuotes, "='$1']" );
  3076. if ( support.matchesSelector && documentIsHTML &&
  3077. !compilerCache[ expr + " " ] &&
  3078. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  3079. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  3080. try {
  3081. var ret = matches.call( elem, expr );
  3082. // IE 9's matchesSelector returns false on disconnected nodes
  3083. if ( ret || support.disconnectedMatch ||
  3084. // As well, disconnected nodes are said to be in a document
  3085. // fragment in IE 9
  3086. elem.document && elem.document.nodeType !== 11 ) {
  3087. return ret;
  3088. }
  3089. } catch (e) {}
  3090. }
  3091. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  3092. };
  3093. Sizzle.contains = function( context, elem ) {
  3094. // Set document vars if needed
  3095. if ( ( context.ownerDocument || context ) !== document ) {
  3096. setDocument( context );
  3097. }
  3098. return contains( context, elem );
  3099. };
  3100. Sizzle.attr = function( elem, name ) {
  3101. // Set document vars if needed
  3102. if ( ( elem.ownerDocument || elem ) !== document ) {
  3103. setDocument( elem );
  3104. }
  3105. var fn = Expr.attrHandle[ name.toLowerCase() ],
  3106. // Don't get fooled by Object.prototype properties (jQuery #13807)
  3107. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  3108. fn( elem, name, !documentIsHTML ) :
  3109. undefined;
  3110. return val !== undefined ?
  3111. val :
  3112. support.attributes || !documentIsHTML ?
  3113. elem.getAttribute( name ) :
  3114. (val = elem.getAttributeNode(name)) && val.specified ?
  3115. val.value :
  3116. null;
  3117. };
  3118. Sizzle.escape = function( sel ) {
  3119. return (sel + "").replace( rcssescape, fcssescape );
  3120. };
  3121. Sizzle.error = function( msg ) {
  3122. throw new Error( "Syntax error, unrecognized expression: " + msg );
  3123. };
  3124. /**
  3125. * Document sorting and removing duplicates
  3126. * @param {ArrayLike} results
  3127. */
  3128. Sizzle.uniqueSort = function( results ) {
  3129. var elem,
  3130. duplicates = [],
  3131. j = 0,
  3132. i = 0;
  3133. // Unless we *know* we can detect duplicates, assume their presence
  3134. hasDuplicate = !support.detectDuplicates;
  3135. sortInput = !support.sortStable && results.slice( 0 );
  3136. results.sort( sortOrder );
  3137. if ( hasDuplicate ) {
  3138. while ( (elem = results[i++]) ) {
  3139. if ( elem === results[ i ] ) {
  3140. j = duplicates.push( i );
  3141. }
  3142. }
  3143. while ( j-- ) {
  3144. results.splice( duplicates[ j ], 1 );
  3145. }
  3146. }
  3147. // Clear input after sorting to release objects
  3148. // See https://github.com/jquery/sizzle/pull/225
  3149. sortInput = null;
  3150. return results;
  3151. };
  3152. /**
  3153. * Utility function for retrieving the text value of an array of DOM nodes
  3154. * @param {Array|Element} elem
  3155. */
  3156. getText = Sizzle.getText = function( elem ) {
  3157. var node,
  3158. ret = "",
  3159. i = 0,
  3160. nodeType = elem.nodeType;
  3161. if ( !nodeType ) {
  3162. // If no nodeType, this is expected to be an array
  3163. while ( (node = elem[i++]) ) {
  3164. // Do not traverse comment nodes
  3165. ret += getText( node );
  3166. }
  3167. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  3168. // Use textContent for elements
  3169. // innerText usage removed for consistency of new lines (jQuery #11153)
  3170. if ( typeof elem.textContent === "string" ) {
  3171. return elem.textContent;
  3172. } else {
  3173. // Traverse its children
  3174. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  3175. ret += getText( elem );
  3176. }
  3177. }
  3178. } else if ( nodeType === 3 || nodeType === 4 ) {
  3179. return elem.nodeValue;
  3180. }
  3181. // Do not include comment or processing instruction nodes
  3182. return ret;
  3183. };
  3184. Expr = Sizzle.selectors = {
  3185. // Can be adjusted by the user
  3186. cacheLength: 50,
  3187. createPseudo: markFunction,
  3188. match: matchExpr,
  3189. attrHandle: {},
  3190. find: {},
  3191. relative: {
  3192. ">": { dir: "parentNode", first: true },
  3193. " ": { dir: "parentNode" },
  3194. "+": { dir: "previousSibling", first: true },
  3195. "~": { dir: "previousSibling" }
  3196. },
  3197. preFilter: {
  3198. "ATTR": function( match ) {
  3199. match[1] = match[1].replace( runescape, funescape );
  3200. // Move the given value to match[3] whether quoted or unquoted
  3201. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  3202. if ( match[2] === "~=" ) {
  3203. match[3] = " " + match[3] + " ";
  3204. }
  3205. return match.slice( 0, 4 );
  3206. },
  3207. "CHILD": function( match ) {
  3208. /* matches from matchExpr["CHILD"]
  3209. 1 type (only|nth|...)
  3210. 2 what (child|of-type)
  3211. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  3212. 4 xn-component of xn+y argument ([+-]?\d*n|)
  3213. 5 sign of xn-component
  3214. 6 x of xn-component
  3215. 7 sign of y-component
  3216. 8 y of y-component
  3217. */
  3218. match[1] = match[1].toLowerCase();
  3219. if ( match[1].slice( 0, 3 ) === "nth" ) {
  3220. // nth-* requires argument
  3221. if ( !match[3] ) {
  3222. Sizzle.error( match[0] );
  3223. }
  3224. // numeric x and y parameters for Expr.filter.CHILD
  3225. // remember that false/true cast respectively to 0/1
  3226. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  3227. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  3228. // other types prohibit arguments
  3229. } else if ( match[3] ) {
  3230. Sizzle.error( match[0] );
  3231. }
  3232. return match;
  3233. },
  3234. "PSEUDO": function( match ) {
  3235. var excess,
  3236. unquoted = !match[6] && match[2];
  3237. if ( matchExpr["CHILD"].test( match[0] ) ) {
  3238. return null;
  3239. }
  3240. // Accept quoted arguments as-is
  3241. if ( match[3] ) {
  3242. match[2] = match[4] || match[5] || "";
  3243. // Strip excess characters from unquoted arguments
  3244. } else if ( unquoted && rpseudo.test( unquoted ) &&
  3245. // Get excess from tokenize (recursively)
  3246. (excess = tokenize( unquoted, true )) &&
  3247. // advance to the next closing parenthesis
  3248. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  3249. // excess is a negative index
  3250. match[0] = match[0].slice( 0, excess );
  3251. match[2] = unquoted.slice( 0, excess );
  3252. }
  3253. // Return only captures needed by the pseudo filter method (type and argument)
  3254. return match.slice( 0, 3 );
  3255. }
  3256. },
  3257. filter: {
  3258. "TAG": function( nodeNameSelector ) {
  3259. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  3260. return nodeNameSelector === "*" ?
  3261. function() { return true; } :
  3262. function( elem ) {
  3263. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  3264. };
  3265. },
  3266. "CLASS": function( className ) {
  3267. var pattern = classCache[ className + " " ];
  3268. return pattern ||
  3269. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  3270. classCache( className, function( elem ) {
  3271. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
  3272. });
  3273. },
  3274. "ATTR": function( name, operator, check ) {
  3275. return function( elem ) {
  3276. var result = Sizzle.attr( elem, name );
  3277. if ( result == null ) {
  3278. return operator === "!=";
  3279. }
  3280. if ( !operator ) {
  3281. return true;
  3282. }
  3283. result += "";
  3284. return operator === "=" ? result === check :
  3285. operator === "!=" ? result !== check :
  3286. operator === "^=" ? check && result.indexOf( check ) === 0 :
  3287. operator === "*=" ? check && result.indexOf( check ) > -1 :
  3288. operator === "$=" ? check && result.slice( -check.length ) === check :
  3289. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  3290. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  3291. false;
  3292. };
  3293. },
  3294. "CHILD": function( type, what, argument, first, last ) {
  3295. var simple = type.slice( 0, 3 ) !== "nth",
  3296. forward = type.slice( -4 ) !== "last",
  3297. ofType = what === "of-type";
  3298. return first === 1 && last === 0 ?
  3299. // Shortcut for :nth-*(n)
  3300. function( elem ) {
  3301. return !!elem.parentNode;
  3302. } :
  3303. function( elem, context, xml ) {
  3304. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  3305. dir = simple !== forward ? "nextSibling" : "previousSibling",
  3306. parent = elem.parentNode,
  3307. name = ofType && elem.nodeName.toLowerCase(),
  3308. useCache = !xml && !ofType,
  3309. diff = false;
  3310. if ( parent ) {
  3311. // :(first|last|only)-(child|of-type)
  3312. if ( simple ) {
  3313. while ( dir ) {
  3314. node = elem;
  3315. while ( (node = node[ dir ]) ) {
  3316. if ( ofType ?
  3317. node.nodeName.toLowerCase() === name :
  3318. node.nodeType === 1 ) {
  3319. return false;
  3320. }
  3321. }
  3322. // Reverse direction for :only-* (if we haven't yet done so)
  3323. start = dir = type === "only" && !start && "nextSibling";
  3324. }
  3325. return true;
  3326. }
  3327. start = [ forward ? parent.firstChild : parent.lastChild ];
  3328. // non-xml :nth-child(...) stores cache data on `parent`
  3329. if ( forward && useCache ) {
  3330. // Seek `elem` from a previously-cached index
  3331. // ...in a gzip-friendly way
  3332. node = parent;
  3333. outerCache = node[ expando ] || (node[ expando ] = {});
  3334. // Support: IE <9 only
  3335. // Defend against cloned attroperties (jQuery gh-1709)
  3336. uniqueCache = outerCache[ node.uniqueID ] ||
  3337. (outerCache[ node.uniqueID ] = {});
  3338. cache = uniqueCache[ type ] || [];
  3339. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  3340. diff = nodeIndex && cache[ 2 ];
  3341. node = nodeIndex && parent.childNodes[ nodeIndex ];
  3342. while ( (node = ++nodeIndex && node && node[ dir ] ||
  3343. // Fallback to seeking `elem` from the start
  3344. (diff = nodeIndex = 0) || start.pop()) ) {
  3345. // When found, cache indexes on `parent` and break
  3346. if ( node.nodeType === 1 && ++diff && node === elem ) {
  3347. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  3348. break;
  3349. }
  3350. }
  3351. } else {
  3352. // Use previously-cached element index if available
  3353. if ( useCache ) {
  3354. // ...in a gzip-friendly way
  3355. node = elem;
  3356. outerCache = node[ expando ] || (node[ expando ] = {});
  3357. // Support: IE <9 only
  3358. // Defend against cloned attroperties (jQuery gh-1709)
  3359. uniqueCache = outerCache[ node.uniqueID ] ||
  3360. (outerCache[ node.uniqueID ] = {});
  3361. cache = uniqueCache[ type ] || [];
  3362. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  3363. diff = nodeIndex;
  3364. }
  3365. // xml :nth-child(...)
  3366. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  3367. if ( diff === false ) {
  3368. // Use the same loop as above to seek `elem` from the start
  3369. while ( (node = ++nodeIndex && node && node[ dir ] ||
  3370. (diff = nodeIndex = 0) || start.pop()) ) {
  3371. if ( ( ofType ?
  3372. node.nodeName.toLowerCase() === name :
  3373. node.nodeType === 1 ) &&
  3374. ++diff ) {
  3375. // Cache the index of each encountered element
  3376. if ( useCache ) {
  3377. outerCache = node[ expando ] || (node[ expando ] = {});
  3378. // Support: IE <9 only
  3379. // Defend against cloned attroperties (jQuery gh-1709)
  3380. uniqueCache = outerCache[ node.uniqueID ] ||
  3381. (outerCache[ node.uniqueID ] = {});
  3382. uniqueCache[ type ] = [ dirruns, diff ];
  3383. }
  3384. if ( node === elem ) {
  3385. break;
  3386. }
  3387. }
  3388. }
  3389. }
  3390. }
  3391. // Incorporate the offset, then check against cycle size
  3392. diff -= last;
  3393. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  3394. }
  3395. };
  3396. },
  3397. "PSEUDO": function( pseudo, argument ) {
  3398. // pseudo-class names are case-insensitive
  3399. // http://www.w3.org/TR/selectors/#pseudo-classes
  3400. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  3401. // Remember that setFilters inherits from pseudos
  3402. var args,
  3403. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  3404. Sizzle.error( "unsupported pseudo: " + pseudo );
  3405. // The user may use createPseudo to indicate that
  3406. // arguments are needed to create the filter function
  3407. // just as Sizzle does
  3408. if ( fn[ expando ] ) {
  3409. return fn( argument );
  3410. }
  3411. // But maintain support for old signatures
  3412. if ( fn.length > 1 ) {
  3413. args = [ pseudo, pseudo, "", argument ];
  3414. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  3415. markFunction(function( seed, matches ) {
  3416. var idx,
  3417. matched = fn( seed, argument ),
  3418. i = matched.length;
  3419. while ( i-- ) {
  3420. idx = indexOf( seed, matched[i] );
  3421. seed[ idx ] = !( matches[ idx ] = matched[i] );
  3422. }
  3423. }) :
  3424. function( elem ) {
  3425. return fn( elem, 0, args );
  3426. };
  3427. }
  3428. return fn;
  3429. }
  3430. },
  3431. pseudos: {
  3432. // Potentially complex pseudos
  3433. "not": markFunction(function( selector ) {
  3434. // Trim the selector passed to compile
  3435. // to avoid treating leading and trailing
  3436. // spaces as combinators
  3437. var input = [],
  3438. results = [],
  3439. matcher = compile( selector.replace( rtrim, "$1" ) );
  3440. return matcher[ expando ] ?
  3441. markFunction(function( seed, matches, context, xml ) {
  3442. var elem,
  3443. unmatched = matcher( seed, null, xml, [] ),
  3444. i = seed.length;
  3445. // Match elements unmatched by `matcher`
  3446. while ( i-- ) {
  3447. if ( (elem = unmatched[i]) ) {
  3448. seed[i] = !(matches[i] = elem);
  3449. }
  3450. }
  3451. }) :
  3452. function( elem, context, xml ) {
  3453. input[0] = elem;
  3454. matcher( input, null, xml, results );
  3455. // Don't keep the element (issue #299)
  3456. input[0] = null;
  3457. return !results.pop();
  3458. };
  3459. }),
  3460. "has": markFunction(function( selector ) {
  3461. return function( elem ) {
  3462. return Sizzle( selector, elem ).length > 0;
  3463. };
  3464. }),
  3465. "contains": markFunction(function( text ) {
  3466. text = text.replace( runescape, funescape );
  3467. return function( elem ) {
  3468. return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
  3469. };
  3470. }),
  3471. // "Whether an element is represented by a :lang() selector
  3472. // is based solely on the element's language value
  3473. // being equal to the identifier C,
  3474. // or beginning with the identifier C immediately followed by "-".
  3475. // The matching of C against the element's language value is performed case-insensitively.
  3476. // The identifier C does not have to be a valid language name."
  3477. // http://www.w3.org/TR/selectors/#lang-pseudo
  3478. "lang": markFunction( function( lang ) {
  3479. // lang value must be a valid identifier
  3480. if ( !ridentifier.test(lang || "") ) {
  3481. Sizzle.error( "unsupported lang: " + lang );
  3482. }
  3483. lang = lang.replace( runescape, funescape ).toLowerCase();
  3484. return function( elem ) {
  3485. var elemLang;
  3486. do {
  3487. if ( (elemLang = documentIsHTML ?
  3488. elem.lang :
  3489. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  3490. elemLang = elemLang.toLowerCase();
  3491. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  3492. }
  3493. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  3494. return false;
  3495. };
  3496. }),
  3497. // Miscellaneous
  3498. "target": function( elem ) {
  3499. var hash = window.location && window.location.hash;
  3500. return hash && hash.slice( 1 ) === elem.id;
  3501. },
  3502. "root": function( elem ) {
  3503. return elem === docElem;
  3504. },
  3505. "focus": function( elem ) {
  3506. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  3507. },
  3508. // Boolean properties
  3509. "enabled": createDisabledPseudo( false ),
  3510. "disabled": createDisabledPseudo( true ),
  3511. "checked": function( elem ) {
  3512. // In CSS3, :checked should return both checked and selected elements
  3513. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  3514. var nodeName = elem.nodeName.toLowerCase();
  3515. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  3516. },
  3517. "selected": function( elem ) {
  3518. // Accessing this property makes selected-by-default
  3519. // options in Safari work properly
  3520. if ( elem.parentNode ) {
  3521. elem.parentNode.selectedIndex;
  3522. }
  3523. return elem.selected === true;
  3524. },
  3525. // Contents
  3526. "empty": function( elem ) {
  3527. // http://www.w3.org/TR/selectors/#empty-pseudo
  3528. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  3529. // but not by others (comment: 8; processing instruction: 7; etc.)
  3530. // nodeType < 6 works because attributes (2) do not appear as children
  3531. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  3532. if ( elem.nodeType < 6 ) {
  3533. return false;
  3534. }
  3535. }
  3536. return true;
  3537. },
  3538. "parent": function( elem ) {
  3539. return !Expr.pseudos["empty"]( elem );
  3540. },
  3541. // Element/input types
  3542. "header": function( elem ) {
  3543. return rheader.test( elem.nodeName );
  3544. },
  3545. "input": function( elem ) {
  3546. return rinputs.test( elem.nodeName );
  3547. },
  3548. "button": function( elem ) {
  3549. var name = elem.nodeName.toLowerCase();
  3550. return name === "input" && elem.type === "button" || name === "button";
  3551. },
  3552. "text": function( elem ) {
  3553. var attr;
  3554. return elem.nodeName.toLowerCase() === "input" &&
  3555. elem.type === "text" &&
  3556. // Support: IE<8
  3557. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  3558. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  3559. },
  3560. // Position-in-collection
  3561. "first": createPositionalPseudo(function() {
  3562. return [ 0 ];
  3563. }),
  3564. "last": createPositionalPseudo(function( matchIndexes, length ) {
  3565. return [ length - 1 ];
  3566. }),
  3567. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  3568. return [ argument < 0 ? argument + length : argument ];
  3569. }),
  3570. "even": createPositionalPseudo(function( matchIndexes, length ) {
  3571. var i = 0;
  3572. for ( ; i < length; i += 2 ) {
  3573. matchIndexes.push( i );
  3574. }
  3575. return matchIndexes;
  3576. }),
  3577. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  3578. var i = 1;
  3579. for ( ; i < length; i += 2 ) {
  3580. matchIndexes.push( i );
  3581. }
  3582. return matchIndexes;
  3583. }),
  3584. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  3585. var i = argument < 0 ? argument + length : argument;
  3586. for ( ; --i >= 0; ) {
  3587. matchIndexes.push( i );
  3588. }
  3589. return matchIndexes;
  3590. }),
  3591. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  3592. var i = argument < 0 ? argument + length : argument;
  3593. for ( ; ++i < length; ) {
  3594. matchIndexes.push( i );
  3595. }
  3596. return matchIndexes;
  3597. })
  3598. }
  3599. };
  3600. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  3601. // Add button/input type pseudos
  3602. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  3603. Expr.pseudos[ i ] = createInputPseudo( i );
  3604. }
  3605. for ( i in { submit: true, reset: true } ) {
  3606. Expr.pseudos[ i ] = createButtonPseudo( i );
  3607. }
  3608. // Easy API for creating new setFilters
  3609. function setFilters() {}
  3610. setFilters.prototype = Expr.filters = Expr.pseudos;
  3611. Expr.setFilters = new setFilters();
  3612. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  3613. var matched, match, tokens, type,
  3614. soFar, groups, preFilters,
  3615. cached = tokenCache[ selector + " " ];
  3616. if ( cached ) {
  3617. return parseOnly ? 0 : cached.slice( 0 );
  3618. }
  3619. soFar = selector;
  3620. groups = [];
  3621. preFilters = Expr.preFilter;
  3622. while ( soFar ) {
  3623. // Comma and first run
  3624. if ( !matched || (match = rcomma.exec( soFar )) ) {
  3625. if ( match ) {
  3626. // Don't consume trailing commas as valid
  3627. soFar = soFar.slice( match[0].length ) || soFar;
  3628. }
  3629. groups.push( (tokens = []) );
  3630. }
  3631. matched = false;
  3632. // Combinators
  3633. if ( (match = rcombinators.exec( soFar )) ) {
  3634. matched = match.shift();
  3635. tokens.push({
  3636. value: matched,
  3637. // Cast descendant combinators to space
  3638. type: match[0].replace( rtrim, " " )
  3639. });
  3640. soFar = soFar.slice( matched.length );
  3641. }
  3642. // Filters
  3643. for ( type in Expr.filter ) {
  3644. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  3645. (match = preFilters[ type ]( match ))) ) {
  3646. matched = match.shift();
  3647. tokens.push({
  3648. value: matched,
  3649. type: type,
  3650. matches: match
  3651. });
  3652. soFar = soFar.slice( matched.length );
  3653. }
  3654. }
  3655. if ( !matched ) {
  3656. break;
  3657. }
  3658. }
  3659. // Return the length of the invalid excess
  3660. // if we're just parsing
  3661. // Otherwise, throw an error or return tokens
  3662. return parseOnly ?
  3663. soFar.length :
  3664. soFar ?
  3665. Sizzle.error( selector ) :
  3666. // Cache the tokens
  3667. tokenCache( selector, groups ).slice( 0 );
  3668. };
  3669. function toSelector( tokens ) {
  3670. var i = 0,
  3671. len = tokens.length,
  3672. selector = "";
  3673. for ( ; i < len; i++ ) {
  3674. selector += tokens[i].value;
  3675. }
  3676. return selector;
  3677. }
  3678. function addCombinator( matcher, combinator, base ) {
  3679. var dir = combinator.dir,
  3680. skip = combinator.next,
  3681. key = skip || dir,
  3682. checkNonElements = base && key === "parentNode",
  3683. doneName = done++;
  3684. return combinator.first ?
  3685. // Check against closest ancestor/preceding element
  3686. function( elem, context, xml ) {
  3687. while ( (elem = elem[ dir ]) ) {
  3688. if ( elem.nodeType === 1 || checkNonElements ) {
  3689. return matcher( elem, context, xml );
  3690. }
  3691. }
  3692. return false;
  3693. } :
  3694. // Check against all ancestor/preceding elements
  3695. function( elem, context, xml ) {
  3696. var oldCache, uniqueCache, outerCache,
  3697. newCache = [ dirruns, doneName ];
  3698. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  3699. if ( xml ) {
  3700. while ( (elem = elem[ dir ]) ) {
  3701. if ( elem.nodeType === 1 || checkNonElements ) {
  3702. if ( matcher( elem, context, xml ) ) {
  3703. return true;
  3704. }
  3705. }
  3706. }
  3707. } else {
  3708. while ( (elem = elem[ dir ]) ) {
  3709. if ( elem.nodeType === 1 || checkNonElements ) {
  3710. outerCache = elem[ expando ] || (elem[ expando ] = {});
  3711. // Support: IE <9 only
  3712. // Defend against cloned attroperties (jQuery gh-1709)
  3713. uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
  3714. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  3715. elem = elem[ dir ] || elem;
  3716. } else if ( (oldCache = uniqueCache[ key ]) &&
  3717. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  3718. // Assign to newCache so results back-propagate to previous elements
  3719. return (newCache[ 2 ] = oldCache[ 2 ]);
  3720. } else {
  3721. // Reuse newcache so results back-propagate to previous elements
  3722. uniqueCache[ key ] = newCache;
  3723. // A match means we're done; a fail means we have to keep checking
  3724. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  3725. return true;
  3726. }
  3727. }
  3728. }
  3729. }
  3730. }
  3731. return false;
  3732. };
  3733. }
  3734. function elementMatcher( matchers ) {
  3735. return matchers.length > 1 ?
  3736. function( elem, context, xml ) {
  3737. var i = matchers.length;
  3738. while ( i-- ) {
  3739. if ( !matchers[i]( elem, context, xml ) ) {
  3740. return false;
  3741. }
  3742. }
  3743. return true;
  3744. } :
  3745. matchers[0];
  3746. }
  3747. function multipleContexts( selector, contexts, results ) {
  3748. var i = 0,
  3749. len = contexts.length;
  3750. for ( ; i < len; i++ ) {
  3751. Sizzle( selector, contexts[i], results );
  3752. }
  3753. return results;
  3754. }
  3755. function condense( unmatched, map, filter, context, xml ) {
  3756. var elem,
  3757. newUnmatched = [],
  3758. i = 0,
  3759. len = unmatched.length,
  3760. mapped = map != null;
  3761. for ( ; i < len; i++ ) {
  3762. if ( (elem = unmatched[i]) ) {
  3763. if ( !filter || filter( elem, context, xml ) ) {
  3764. newUnmatched.push( elem );
  3765. if ( mapped ) {
  3766. map.push( i );
  3767. }
  3768. }
  3769. }
  3770. }
  3771. return newUnmatched;
  3772. }
  3773. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  3774. if ( postFilter && !postFilter[ expando ] ) {
  3775. postFilter = setMatcher( postFilter );
  3776. }
  3777. if ( postFinder && !postFinder[ expando ] ) {
  3778. postFinder = setMatcher( postFinder, postSelector );
  3779. }
  3780. return markFunction(function( seed, results, context, xml ) {
  3781. var temp, i, elem,
  3782. preMap = [],
  3783. postMap = [],
  3784. preexisting = results.length,
  3785. // Get initial elements from seed or context
  3786. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  3787. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  3788. matcherIn = preFilter && ( seed || !selector ) ?
  3789. condense( elems, preMap, preFilter, context, xml ) :
  3790. elems,
  3791. matcherOut = matcher ?
  3792. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  3793. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  3794. // ...intermediate processing is necessary
  3795. [] :
  3796. // ...otherwise use results directly
  3797. results :
  3798. matcherIn;
  3799. // Find primary matches
  3800. if ( matcher ) {
  3801. matcher( matcherIn, matcherOut, context, xml );
  3802. }
  3803. // Apply postFilter
  3804. if ( postFilter ) {
  3805. temp = condense( matcherOut, postMap );
  3806. postFilter( temp, [], context, xml );
  3807. // Un-match failing elements by moving them back to matcherIn
  3808. i = temp.length;
  3809. while ( i-- ) {
  3810. if ( (elem = temp[i]) ) {
  3811. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  3812. }
  3813. }
  3814. }
  3815. if ( seed ) {
  3816. if ( postFinder || preFilter ) {
  3817. if ( postFinder ) {
  3818. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  3819. temp = [];
  3820. i = matcherOut.length;
  3821. while ( i-- ) {
  3822. if ( (elem = matcherOut[i]) ) {
  3823. // Restore matcherIn since elem is not yet a final match
  3824. temp.push( (matcherIn[i] = elem) );
  3825. }
  3826. }
  3827. postFinder( null, (matcherOut = []), temp, xml );
  3828. }
  3829. // Move matched elements from seed to results to keep them synchronized
  3830. i = matcherOut.length;
  3831. while ( i-- ) {
  3832. if ( (elem = matcherOut[i]) &&
  3833. (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
  3834. seed[temp] = !(results[temp] = elem);
  3835. }
  3836. }
  3837. }
  3838. // Add elements to results, through postFinder if defined
  3839. } else {
  3840. matcherOut = condense(
  3841. matcherOut === results ?
  3842. matcherOut.splice( preexisting, matcherOut.length ) :
  3843. matcherOut
  3844. );
  3845. if ( postFinder ) {
  3846. postFinder( null, results, matcherOut, xml );
  3847. } else {
  3848. push.apply( results, matcherOut );
  3849. }
  3850. }
  3851. });
  3852. }
  3853. function matcherFromTokens( tokens ) {
  3854. var checkContext, matcher, j,
  3855. len = tokens.length,
  3856. leadingRelative = Expr.relative[ tokens[0].type ],
  3857. implicitRelative = leadingRelative || Expr.relative[" "],
  3858. i = leadingRelative ? 1 : 0,
  3859. // The foundational matcher ensures that elements are reachable from top-level context(s)
  3860. matchContext = addCombinator( function( elem ) {
  3861. return elem === checkContext;
  3862. }, implicitRelative, true ),
  3863. matchAnyContext = addCombinator( function( elem ) {
  3864. return indexOf( checkContext, elem ) > -1;
  3865. }, implicitRelative, true ),
  3866. matchers = [ function( elem, context, xml ) {
  3867. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  3868. (checkContext = context).nodeType ?
  3869. matchContext( elem, context, xml ) :
  3870. matchAnyContext( elem, context, xml ) );
  3871. // Avoid hanging onto element (issue #299)
  3872. checkContext = null;
  3873. return ret;
  3874. } ];
  3875. for ( ; i < len; i++ ) {
  3876. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  3877. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  3878. } else {
  3879. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  3880. // Return special upon seeing a positional matcher
  3881. if ( matcher[ expando ] ) {
  3882. // Find the next relative operator (if any) for proper handling
  3883. j = ++i;
  3884. for ( ; j < len; j++ ) {
  3885. if ( Expr.relative[ tokens[j].type ] ) {
  3886. break;
  3887. }
  3888. }
  3889. return setMatcher(
  3890. i > 1 && elementMatcher( matchers ),
  3891. i > 1 && toSelector(
  3892. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  3893. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  3894. ).replace( rtrim, "$1" ),
  3895. matcher,
  3896. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  3897. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  3898. j < len && toSelector( tokens )
  3899. );
  3900. }
  3901. matchers.push( matcher );
  3902. }
  3903. }
  3904. return elementMatcher( matchers );
  3905. }
  3906. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  3907. var bySet = setMatchers.length > 0,
  3908. byElement = elementMatchers.length > 0,
  3909. superMatcher = function( seed, context, xml, results, outermost ) {
  3910. var elem, j, matcher,
  3911. matchedCount = 0,
  3912. i = "0",
  3913. unmatched = seed && [],
  3914. setMatched = [],
  3915. contextBackup = outermostContext,
  3916. // We must always have either seed elements or outermost context
  3917. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  3918. // Use integer dirruns iff this is the outermost matcher
  3919. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  3920. len = elems.length;
  3921. if ( outermost ) {
  3922. outermostContext = context === document || context || outermost;
  3923. }
  3924. // Add elements passing elementMatchers directly to results
  3925. // Support: IE<9, Safari
  3926. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  3927. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  3928. if ( byElement && elem ) {
  3929. j = 0;
  3930. if ( !context && elem.ownerDocument !== document ) {
  3931. setDocument( elem );
  3932. xml = !documentIsHTML;
  3933. }
  3934. while ( (matcher = elementMatchers[j++]) ) {
  3935. if ( matcher( elem, context || document, xml) ) {
  3936. results.push( elem );
  3937. break;
  3938. }
  3939. }
  3940. if ( outermost ) {
  3941. dirruns = dirrunsUnique;
  3942. }
  3943. }
  3944. // Track unmatched elements for set filters
  3945. if ( bySet ) {
  3946. // They will have gone through all possible matchers
  3947. if ( (elem = !matcher && elem) ) {
  3948. matchedCount--;
  3949. }
  3950. // Lengthen the array for every element, matched or not
  3951. if ( seed ) {
  3952. unmatched.push( elem );
  3953. }
  3954. }
  3955. }
  3956. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  3957. // makes the latter nonnegative.
  3958. matchedCount += i;
  3959. // Apply set filters to unmatched elements
  3960. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  3961. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  3962. // no element matchers and no seed.
  3963. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  3964. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  3965. // numerically zero.
  3966. if ( bySet && i !== matchedCount ) {
  3967. j = 0;
  3968. while ( (matcher = setMatchers[j++]) ) {
  3969. matcher( unmatched, setMatched, context, xml );
  3970. }
  3971. if ( seed ) {
  3972. // Reintegrate element matches to eliminate the need for sorting
  3973. if ( matchedCount > 0 ) {
  3974. while ( i-- ) {
  3975. if ( !(unmatched[i] || setMatched[i]) ) {
  3976. setMatched[i] = pop.call( results );
  3977. }
  3978. }
  3979. }
  3980. // Discard index placeholder values to get only actual matches
  3981. setMatched = condense( setMatched );
  3982. }
  3983. // Add matches to results
  3984. push.apply( results, setMatched );
  3985. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  3986. if ( outermost && !seed && setMatched.length > 0 &&
  3987. ( matchedCount + setMatchers.length ) > 1 ) {
  3988. Sizzle.uniqueSort( results );
  3989. }
  3990. }
  3991. // Override manipulation of globals by nested matchers
  3992. if ( outermost ) {
  3993. dirruns = dirrunsUnique;
  3994. outermostContext = contextBackup;
  3995. }
  3996. return unmatched;
  3997. };
  3998. return bySet ?
  3999. markFunction( superMatcher ) :
  4000. superMatcher;
  4001. }
  4002. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  4003. var i,
  4004. setMatchers = [],
  4005. elementMatchers = [],
  4006. cached = compilerCache[ selector + " " ];
  4007. if ( !cached ) {
  4008. // Generate a function of recursive functions that can be used to check each element
  4009. if ( !match ) {
  4010. match = tokenize( selector );
  4011. }
  4012. i = match.length;
  4013. while ( i-- ) {
  4014. cached = matcherFromTokens( match[i] );
  4015. if ( cached[ expando ] ) {
  4016. setMatchers.push( cached );
  4017. } else {
  4018. elementMatchers.push( cached );
  4019. }
  4020. }
  4021. // Cache the compiled function
  4022. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  4023. // Save selector and tokenization
  4024. cached.selector = selector;
  4025. }
  4026. return cached;
  4027. };
  4028. /**
  4029. * A low-level selection function that works with Sizzle's compiled
  4030. * selector functions
  4031. * @param {String|Function} selector A selector or a pre-compiled
  4032. * selector function built with Sizzle.compile
  4033. * @param {Element} context
  4034. * @param {Array} [results]
  4035. * @param {Array} [seed] A set of elements to match against
  4036. */
  4037. select = Sizzle.select = function( selector, context, results, seed ) {
  4038. var i, tokens, token, type, find,
  4039. compiled = typeof selector === "function" && selector,
  4040. match = !seed && tokenize( (selector = compiled.selector || selector) );
  4041. results = results || [];
  4042. // Try to minimize operations if there is only one selector in the list and no seed
  4043. // (the latter of which guarantees us context)
  4044. if ( match.length === 1 ) {
  4045. // Reduce context if the leading compound selector is an ID
  4046. tokens = match[0] = match[0].slice( 0 );
  4047. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  4048. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
  4049. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  4050. if ( !context ) {
  4051. return results;
  4052. // Precompiled matchers will still verify ancestry, so step up a level
  4053. } else if ( compiled ) {
  4054. context = context.parentNode;
  4055. }
  4056. selector = selector.slice( tokens.shift().value.length );
  4057. }
  4058. // Fetch a seed set for right-to-left matching
  4059. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  4060. while ( i-- ) {
  4061. token = tokens[i];
  4062. // Abort if we hit a combinator
  4063. if ( Expr.relative[ (type = token.type) ] ) {
  4064. break;
  4065. }
  4066. if ( (find = Expr.find[ type ]) ) {
  4067. // Search, expanding context for leading sibling combinators
  4068. if ( (seed = find(
  4069. token.matches[0].replace( runescape, funescape ),
  4070. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  4071. )) ) {
  4072. // If seed is empty or no tokens remain, we can return early
  4073. tokens.splice( i, 1 );
  4074. selector = seed.length && toSelector( tokens );
  4075. if ( !selector ) {
  4076. push.apply( results, seed );
  4077. return results;
  4078. }
  4079. break;
  4080. }
  4081. }
  4082. }
  4083. }
  4084. // Compile and execute a filtering function if one is not provided
  4085. // Provide `match` to avoid retokenization if we modified the selector above
  4086. ( compiled || compile( selector, match ) )(
  4087. seed,
  4088. context,
  4089. !documentIsHTML,
  4090. results,
  4091. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  4092. );
  4093. return results;
  4094. };
  4095. // One-time assignments
  4096. // Sort stability
  4097. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  4098. // Support: Chrome 14-35+
  4099. // Always assume duplicates if they aren't passed to the comparison function
  4100. support.detectDuplicates = !!hasDuplicate;
  4101. // Initialize against the default document
  4102. setDocument();
  4103. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  4104. // Detached nodes confoundingly follow *each other*
  4105. support.sortDetached = assert(function( el ) {
  4106. // Should return 1, but returns 4 (following)
  4107. return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
  4108. });
  4109. // Support: IE<8
  4110. // Prevent attribute/property "interpolation"
  4111. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  4112. if ( !assert(function( el ) {
  4113. el.innerHTML = "<a href='#'></a>";
  4114. return el.firstChild.getAttribute("href") === "#" ;
  4115. }) ) {
  4116. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  4117. if ( !isXML ) {
  4118. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  4119. }
  4120. });
  4121. }
  4122. // Support: IE<9
  4123. // Use defaultValue in place of getAttribute("value")
  4124. if ( !support.attributes || !assert(function( el ) {
  4125. el.innerHTML = "<input/>";
  4126. el.firstChild.setAttribute( "value", "" );
  4127. return el.firstChild.getAttribute( "value" ) === "";
  4128. }) ) {
  4129. addHandle( "value", function( elem, name, isXML ) {
  4130. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  4131. return elem.defaultValue;
  4132. }
  4133. });
  4134. }
  4135. // Support: IE<9
  4136. // Use getAttributeNode to fetch booleans when getAttribute lies
  4137. if ( !assert(function( el ) {
  4138. return el.getAttribute("disabled") == null;
  4139. }) ) {
  4140. addHandle( booleans, function( elem, name, isXML ) {
  4141. var val;
  4142. if ( !isXML ) {
  4143. return elem[ name ] === true ? name.toLowerCase() :
  4144. (val = elem.getAttributeNode( name )) && val.specified ?
  4145. val.value :
  4146. null;
  4147. }
  4148. });
  4149. }
  4150. return Sizzle;
  4151. })( window );
  4152. jQuery.find = Sizzle;
  4153. jQuery.expr = Sizzle.selectors;
  4154. // Deprecated
  4155. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  4156. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  4157. jQuery.text = Sizzle.getText;
  4158. jQuery.isXMLDoc = Sizzle.isXML;
  4159. jQuery.contains = Sizzle.contains;
  4160. jQuery.escapeSelector = Sizzle.escape;
  4161. var dir = function( elem, dir, until ) {
  4162. var matched = [],
  4163. truncate = until !== undefined;
  4164. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  4165. if ( elem.nodeType === 1 ) {
  4166. if ( truncate && jQuery( elem ).is( until ) ) {
  4167. break;
  4168. }
  4169. matched.push( elem );
  4170. }
  4171. }
  4172. return matched;
  4173. };
  4174. var siblings = function( n, elem ) {
  4175. var matched = [];
  4176. for ( ; n; n = n.nextSibling ) {
  4177. if ( n.nodeType === 1 && n !== elem ) {
  4178. matched.push( n );
  4179. }
  4180. }
  4181. return matched;
  4182. };
  4183. var rneedsContext = jQuery.expr.match.needsContext;
  4184. function nodeName( elem, name ) {
  4185. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  4186. };
  4187. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  4188. var risSimple = /^.[^:#\[\.,]*$/;
  4189. // Implement the identical functionality for filter and not
  4190. function winnow( elements, qualifier, not ) {
  4191. if ( jQuery.isFunction( qualifier ) ) {
  4192. return jQuery.grep( elements, function( elem, i ) {
  4193. return !!qualifier.call( elem, i, elem ) !== not;
  4194. } );
  4195. }
  4196. // Single element
  4197. if ( qualifier.nodeType ) {
  4198. return jQuery.grep( elements, function( elem ) {
  4199. return ( elem === qualifier ) !== not;
  4200. } );
  4201. }
  4202. // Arraylike of elements (jQuery, arguments, Array)
  4203. if ( typeof qualifier !== "string" ) {
  4204. return jQuery.grep( elements, function( elem ) {
  4205. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  4206. } );
  4207. }
  4208. // Simple selector that can be filtered directly, removing non-Elements
  4209. if ( risSimple.test( qualifier ) ) {
  4210. return jQuery.filter( qualifier, elements, not );
  4211. }
  4212. // Complex selector, compare the two sets, removing non-Elements
  4213. qualifier = jQuery.filter( qualifier, elements );
  4214. return jQuery.grep( elements, function( elem ) {
  4215. return ( indexOf.call( qualifier, elem ) > -1 ) !== not && elem.nodeType === 1;
  4216. } );
  4217. }
  4218. jQuery.filter = function( expr, elems, not ) {
  4219. var elem = elems[ 0 ];
  4220. if ( not ) {
  4221. expr = ":not(" + expr + ")";
  4222. }
  4223. if ( elems.length === 1 && elem.nodeType === 1 ) {
  4224. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  4225. }
  4226. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  4227. return elem.nodeType === 1;
  4228. } ) );
  4229. };
  4230. jQuery.fn.extend( {
  4231. find: function( selector ) {
  4232. var i, ret,
  4233. len = this.length,
  4234. self = this;
  4235. if ( typeof selector !== "string" ) {
  4236. return this.pushStack( jQuery( selector ).filter( function() {
  4237. for ( i = 0; i < len; i++ ) {
  4238. if ( jQuery.contains( self[ i ], this ) ) {
  4239. return true;
  4240. }
  4241. }
  4242. } ) );
  4243. }
  4244. ret = this.pushStack( [] );
  4245. for ( i = 0; i < len; i++ ) {
  4246. jQuery.find( selector, self[ i ], ret );
  4247. }
  4248. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  4249. },
  4250. filter: function( selector ) {
  4251. return this.pushStack( winnow( this, selector || [], false ) );
  4252. },
  4253. not: function( selector ) {
  4254. return this.pushStack( winnow( this, selector || [], true ) );
  4255. },
  4256. is: function( selector ) {
  4257. return !!winnow(
  4258. this,
  4259. // If this is a positional/relative selector, check membership in the returned set
  4260. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  4261. typeof selector === "string" && rneedsContext.test( selector ) ?
  4262. jQuery( selector ) :
  4263. selector || [],
  4264. false
  4265. ).length;
  4266. }
  4267. } );
  4268. // Initialize a jQuery object
  4269. // A central reference to the root jQuery(document)
  4270. var rootjQuery,
  4271. // A simple way to check for HTML strings
  4272. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  4273. // Strict HTML recognition (#11290: must start with <)
  4274. // Shortcut simple #id case for speed
  4275. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  4276. init = jQuery.fn.init = function( selector, context, root ) {
  4277. var match, elem;
  4278. // HANDLE: $(""), $(null), $(undefined), $(false)
  4279. if ( !selector ) {
  4280. return this;
  4281. }
  4282. // Method init() accepts an alternate rootjQuery
  4283. // so migrate can support jQuery.sub (gh-2101)
  4284. root = root || rootjQuery;
  4285. // Handle HTML strings
  4286. if ( typeof selector === "string" ) {
  4287. if ( selector[ 0 ] === "<" &&
  4288. selector[ selector.length - 1 ] === ">" &&
  4289. selector.length >= 3 ) {
  4290. // Assume that strings that start and end with <> are HTML and skip the regex check
  4291. match = [ null, selector, null ];
  4292. } else {
  4293. match = rquickExpr.exec( selector );
  4294. }
  4295. // Match html or make sure no context is specified for #id
  4296. if ( match && ( match[ 1 ] || !context ) ) {
  4297. // HANDLE: $(html) -> $(array)
  4298. if ( match[ 1 ] ) {
  4299. context = context instanceof jQuery ? context[ 0 ] : context;
  4300. // Option to run scripts is true for back-compat
  4301. // Intentionally let the error be thrown if parseHTML is not present
  4302. jQuery.merge( this, jQuery.parseHTML(
  4303. match[ 1 ],
  4304. context && context.nodeType ? context.ownerDocument || context : document,
  4305. true
  4306. ) );
  4307. // HANDLE: $(html, props)
  4308. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  4309. for ( match in context ) {
  4310. // Properties of context are called as methods if possible
  4311. if ( jQuery.isFunction( this[ match ] ) ) {
  4312. this[ match ]( context[ match ] );
  4313. // ...and otherwise set as attributes
  4314. } else {
  4315. this.attr( match, context[ match ] );
  4316. }
  4317. }
  4318. }
  4319. return this;
  4320. // HANDLE: $(#id)
  4321. } else {
  4322. elem = document.getElementById( match[ 2 ] );
  4323. if ( elem ) {
  4324. // Inject the element directly into the jQuery object
  4325. this[ 0 ] = elem;
  4326. this.length = 1;
  4327. }
  4328. return this;
  4329. }
  4330. // HANDLE: $(expr, $(...))
  4331. } else if ( !context || context.jquery ) {
  4332. return ( context || root ).find( selector );
  4333. // HANDLE: $(expr, context)
  4334. // (which is just equivalent to: $(context).find(expr)
  4335. } else {
  4336. return this.constructor( context ).find( selector );
  4337. }
  4338. // HANDLE: $(DOMElement)
  4339. } else if ( selector.nodeType ) {
  4340. this[ 0 ] = selector;
  4341. this.length = 1;
  4342. return this;
  4343. // HANDLE: $(function)
  4344. // Shortcut for document ready
  4345. } else if ( jQuery.isFunction( selector ) ) {
  4346. return root.ready !== undefined ?
  4347. root.ready( selector ) :
  4348. // Execute immediately if ready is not present
  4349. selector( jQuery );
  4350. }
  4351. return jQuery.makeArray( selector, this );
  4352. };
  4353. // Give the init function the jQuery prototype for later instantiation
  4354. init.prototype = jQuery.fn;
  4355. // Initialize central reference
  4356. rootjQuery = jQuery( document );
  4357. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  4358. // Methods guaranteed to produce a unique set when starting from a unique set
  4359. guaranteedUnique = {
  4360. children: true,
  4361. contents: true,
  4362. next: true,
  4363. prev: true
  4364. };
  4365. jQuery.fn.extend( {
  4366. has: function( target ) {
  4367. var targets = jQuery( target, this ),
  4368. l = targets.length;
  4369. return this.filter( function() {
  4370. var i = 0;
  4371. for ( ; i < l; i++ ) {
  4372. if ( jQuery.contains( this, targets[ i ] ) ) {
  4373. return true;
  4374. }
  4375. }
  4376. } );
  4377. },
  4378. closest: function( selectors, context ) {
  4379. var cur,
  4380. i = 0,
  4381. l = this.length,
  4382. matched = [],
  4383. targets = typeof selectors !== "string" && jQuery( selectors );
  4384. // Positional selectors never match, since there's no _selection_ context
  4385. if ( !rneedsContext.test( selectors ) ) {
  4386. for ( ; i < l; i++ ) {
  4387. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  4388. // Always skip document fragments
  4389. if ( cur.nodeType < 11 && ( targets ?
  4390. targets.index( cur ) > -1 :
  4391. // Don't pass non-elements to Sizzle
  4392. cur.nodeType === 1 &&
  4393. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  4394. matched.push( cur );
  4395. break;
  4396. }
  4397. }
  4398. }
  4399. }
  4400. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  4401. },
  4402. // Determine the position of an element within the set
  4403. index: function( elem ) {
  4404. // No argument, return index in parent
  4405. if ( !elem ) {
  4406. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  4407. }
  4408. // Index in selector
  4409. if ( typeof elem === "string" ) {
  4410. return indexOf.call( jQuery( elem ), this[ 0 ] );
  4411. }
  4412. // Locate the position of the desired element
  4413. return indexOf.call( this,
  4414. // If it receives a jQuery object, the first element is used
  4415. elem.jquery ? elem[ 0 ] : elem
  4416. );
  4417. },
  4418. add: function( selector, context ) {
  4419. return this.pushStack(
  4420. jQuery.uniqueSort(
  4421. jQuery.merge( this.get(), jQuery( selector, context ) )
  4422. )
  4423. );
  4424. },
  4425. addBack: function( selector ) {
  4426. return this.add( selector == null ?
  4427. this.prevObject : this.prevObject.filter( selector )
  4428. );
  4429. }
  4430. } );
  4431. function sibling( cur, dir ) {
  4432. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  4433. return cur;
  4434. }
  4435. jQuery.each( {
  4436. parent: function( elem ) {
  4437. var parent = elem.parentNode;
  4438. return parent && parent.nodeType !== 11 ? parent : null;
  4439. },
  4440. parents: function( elem ) {
  4441. return dir( elem, "parentNode" );
  4442. },
  4443. parentsUntil: function( elem, i, until ) {
  4444. return dir( elem, "parentNode", until );
  4445. },
  4446. next: function( elem ) {
  4447. return sibling( elem, "nextSibling" );
  4448. },
  4449. prev: function( elem ) {
  4450. return sibling( elem, "previousSibling" );
  4451. },
  4452. nextAll: function( elem ) {
  4453. return dir( elem, "nextSibling" );
  4454. },
  4455. prevAll: function( elem ) {
  4456. return dir( elem, "previousSibling" );
  4457. },
  4458. nextUntil: function( elem, i, until ) {
  4459. return dir( elem, "nextSibling", until );
  4460. },
  4461. prevUntil: function( elem, i, until ) {
  4462. return dir( elem, "previousSibling", until );
  4463. },
  4464. siblings: function( elem ) {
  4465. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  4466. },
  4467. children: function( elem ) {
  4468. return siblings( elem.firstChild );
  4469. },
  4470. contents: function( elem ) {
  4471. if ( nodeName( elem, "iframe" ) ) {
  4472. return elem.contentDocument;
  4473. }
  4474. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  4475. // Treat the template element as a regular one in browsers that
  4476. // don't support it.
  4477. if ( nodeName( elem, "template" ) ) {
  4478. elem = elem.content || elem;
  4479. }
  4480. return jQuery.merge( [], elem.childNodes );
  4481. }
  4482. }, function( name, fn ) {
  4483. jQuery.fn[ name ] = function( until, selector ) {
  4484. var matched = jQuery.map( this, fn, until );
  4485. if ( name.slice( -5 ) !== "Until" ) {
  4486. selector = until;
  4487. }
  4488. if ( selector && typeof selector === "string" ) {
  4489. matched = jQuery.filter( selector, matched );
  4490. }
  4491. if ( this.length > 1 ) {
  4492. // Remove duplicates
  4493. if ( !guaranteedUnique[ name ] ) {
  4494. jQuery.uniqueSort( matched );
  4495. }
  4496. // Reverse order for parents* and prev-derivatives
  4497. if ( rparentsprev.test( name ) ) {
  4498. matched.reverse();
  4499. }
  4500. }
  4501. return this.pushStack( matched );
  4502. };
  4503. } );
  4504. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  4505. // Convert String-formatted options into Object-formatted ones
  4506. function createOptions( options ) {
  4507. var object = {};
  4508. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  4509. object[ flag ] = true;
  4510. } );
  4511. return object;
  4512. }
  4513. /*
  4514. * Create a callback list using the following parameters:
  4515. *
  4516. * options: an optional list of space-separated options that will change how
  4517. * the callback list behaves or a more traditional option object
  4518. *
  4519. * By default a callback list will act like an event callback list and can be
  4520. * "fired" multiple times.
  4521. *
  4522. * Possible options:
  4523. *
  4524. * once: will ensure the callback list can only be fired once (like a Deferred)
  4525. *
  4526. * memory: will keep track of previous values and will call any callback added
  4527. * after the list has been fired right away with the latest "memorized"
  4528. * values (like a Deferred)
  4529. *
  4530. * unique: will ensure a callback can only be added once (no duplicate in the list)
  4531. *
  4532. * stopOnFalse: interrupt callings when a callback returns false
  4533. *
  4534. */
  4535. jQuery.Callbacks = function( options ) {
  4536. // Convert options from String-formatted to Object-formatted if needed
  4537. // (we check in cache first)
  4538. options = typeof options === "string" ?
  4539. createOptions( options ) :
  4540. jQuery.extend( {}, options );
  4541. var // Flag to know if list is currently firing
  4542. firing,
  4543. // Last fire value for non-forgettable lists
  4544. memory,
  4545. // Flag to know if list was already fired
  4546. fired,
  4547. // Flag to prevent firing
  4548. locked,
  4549. // Actual callback list
  4550. list = [],
  4551. // Queue of execution data for repeatable lists
  4552. queue = [],
  4553. // Index of currently firing callback (modified by add/remove as needed)
  4554. firingIndex = -1,
  4555. // Fire callbacks
  4556. fire = function() {
  4557. // Enforce single-firing
  4558. locked = locked || options.once;
  4559. // Execute callbacks for all pending executions,
  4560. // respecting firingIndex overrides and runtime changes
  4561. fired = firing = true;
  4562. for ( ; queue.length; firingIndex = -1 ) {
  4563. memory = queue.shift();
  4564. while ( ++firingIndex < list.length ) {
  4565. // Run callback and check for early termination
  4566. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  4567. options.stopOnFalse ) {
  4568. // Jump to end and forget the data so .add doesn't re-fire
  4569. firingIndex = list.length;
  4570. memory = false;
  4571. }
  4572. }
  4573. }
  4574. // Forget the data if we're done with it
  4575. if ( !options.memory ) {
  4576. memory = false;
  4577. }
  4578. firing = false;
  4579. // Clean up if we're done firing for good
  4580. if ( locked ) {
  4581. // Keep an empty list if we have data for future add calls
  4582. if ( memory ) {
  4583. list = [];
  4584. // Otherwise, this object is spent
  4585. } else {
  4586. list = "";
  4587. }
  4588. }
  4589. },
  4590. // Actual Callbacks object
  4591. self = {
  4592. // Add a callback or a collection of callbacks to the list
  4593. add: function() {
  4594. if ( list ) {
  4595. // If we have memory from a past run, we should fire after adding
  4596. if ( memory && !firing ) {
  4597. firingIndex = list.length - 1;
  4598. queue.push( memory );
  4599. }
  4600. ( function add( args ) {
  4601. jQuery.each( args, function( _, arg ) {
  4602. if ( jQuery.isFunction( arg ) ) {
  4603. if ( !options.unique || !self.has( arg ) ) {
  4604. list.push( arg );
  4605. }
  4606. } else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) {
  4607. // Inspect recursively
  4608. add( arg );
  4609. }
  4610. } );
  4611. } )( arguments );
  4612. if ( memory && !firing ) {
  4613. fire();
  4614. }
  4615. }
  4616. return this;
  4617. },
  4618. // Remove a callback from the list
  4619. remove: function() {
  4620. jQuery.each( arguments, function( _, arg ) {
  4621. var index;
  4622. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  4623. list.splice( index, 1 );
  4624. // Handle firing indexes
  4625. if ( index <= firingIndex ) {
  4626. firingIndex--;
  4627. }
  4628. }
  4629. } );
  4630. return this;
  4631. },
  4632. // Check if a given callback is in the list.
  4633. // If no argument is given, return whether or not list has callbacks attached.
  4634. has: function( fn ) {
  4635. return fn ?
  4636. jQuery.inArray( fn, list ) > -1 :
  4637. list.length > 0;
  4638. },
  4639. // Remove all callbacks from the list
  4640. empty: function() {
  4641. if ( list ) {
  4642. list = [];
  4643. }
  4644. return this;
  4645. },
  4646. // Disable .fire and .add
  4647. // Abort any current/pending executions
  4648. // Clear all callbacks and values
  4649. disable: function() {
  4650. locked = queue = [];
  4651. list = memory = "";
  4652. return this;
  4653. },
  4654. disabled: function() {
  4655. return !list;
  4656. },
  4657. // Disable .fire
  4658. // Also disable .add unless we have memory (since it would have no effect)
  4659. // Abort any pending executions
  4660. lock: function() {
  4661. locked = queue = [];
  4662. if ( !memory && !firing ) {
  4663. list = memory = "";
  4664. }
  4665. return this;
  4666. },
  4667. locked: function() {
  4668. return !!locked;
  4669. },
  4670. // Call all callbacks with the given context and arguments
  4671. fireWith: function( context, args ) {
  4672. if ( !locked ) {
  4673. args = args || [];
  4674. args = [ context, args.slice ? args.slice() : args ];
  4675. queue.push( args );
  4676. if ( !firing ) {
  4677. fire();
  4678. }
  4679. }
  4680. return this;
  4681. },
  4682. // Call all the callbacks with the given arguments
  4683. fire: function() {
  4684. self.fireWith( this, arguments );
  4685. return this;
  4686. },
  4687. // To know if the callbacks have already been called at least once
  4688. fired: function() {
  4689. return !!fired;
  4690. }
  4691. };
  4692. return self;
  4693. };
  4694. function Identity( v ) {
  4695. return v;
  4696. }
  4697. function Thrower( ex ) {
  4698. throw ex;
  4699. }
  4700. function adoptValue( value, resolve, reject, noValue ) {
  4701. var method;
  4702. try {
  4703. // Check for promise aspect first to privilege synchronous behavior
  4704. if ( value && jQuery.isFunction( ( method = value.promise ) ) ) {
  4705. method.call( value ).done( resolve ).fail( reject );
  4706. // Other thenables
  4707. } else if ( value && jQuery.isFunction( ( method = value.then ) ) ) {
  4708. method.call( value, resolve, reject );
  4709. // Other non-thenables
  4710. } else {
  4711. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  4712. // * false: [ value ].slice( 0 ) => resolve( value )
  4713. // * true: [ value ].slice( 1 ) => resolve()
  4714. resolve.apply( undefined, [ value ].slice( noValue ) );
  4715. }
  4716. // For Promises/A+, convert exceptions into rejections
  4717. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  4718. // Deferred#then to conditionally suppress rejection.
  4719. } catch ( value ) {
  4720. // Support: Android 4.0 only
  4721. // Strict mode functions invoked without .call/.apply get global-object context
  4722. reject.apply( undefined, [ value ] );
  4723. }
  4724. }
  4725. jQuery.extend( {
  4726. Deferred: function( func ) {
  4727. var tuples = [
  4728. // action, add listener, callbacks,
  4729. // ... .then handlers, argument index, [final state]
  4730. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  4731. jQuery.Callbacks( "memory" ), 2 ],
  4732. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  4733. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  4734. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  4735. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  4736. ],
  4737. state = "pending",
  4738. promise = {
  4739. state: function() {
  4740. return state;
  4741. },
  4742. always: function() {
  4743. deferred.done( arguments ).fail( arguments );
  4744. return this;
  4745. },
  4746. "catch": function( fn ) {
  4747. return promise.then( null, fn );
  4748. },
  4749. // Keep pipe for back-compat
  4750. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  4751. var fns = arguments;
  4752. return jQuery.Deferred( function( newDefer ) {
  4753. jQuery.each( tuples, function( i, tuple ) {
  4754. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  4755. var fn = jQuery.isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  4756. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  4757. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  4758. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  4759. deferred[ tuple[ 1 ] ]( function() {
  4760. var returned = fn && fn.apply( this, arguments );
  4761. if ( returned && jQuery.isFunction( returned.promise ) ) {
  4762. returned.promise()
  4763. .progress( newDefer.notify )
  4764. .done( newDefer.resolve )
  4765. .fail( newDefer.reject );
  4766. } else {
  4767. newDefer[ tuple[ 0 ] + "With" ](
  4768. this,
  4769. fn ? [ returned ] : arguments
  4770. );
  4771. }
  4772. } );
  4773. } );
  4774. fns = null;
  4775. } ).promise();
  4776. },
  4777. then: function( onFulfilled, onRejected, onProgress ) {
  4778. var maxDepth = 0;
  4779. function resolve( depth, deferred, handler, special ) {
  4780. return function() {
  4781. var that = this,
  4782. args = arguments,
  4783. mightThrow = function() {
  4784. var returned, then;
  4785. // Support: Promises/A+ section 2.3.3.3.3
  4786. // https://promisesaplus.com/#point-59
  4787. // Ignore double-resolution attempts
  4788. if ( depth < maxDepth ) {
  4789. return;
  4790. }
  4791. returned = handler.apply( that, args );
  4792. // Support: Promises/A+ section 2.3.1
  4793. // https://promisesaplus.com/#point-48
  4794. if ( returned === deferred.promise() ) {
  4795. throw new TypeError( "Thenable self-resolution" );
  4796. }
  4797. // Support: Promises/A+ sections 2.3.3.1, 3.5
  4798. // https://promisesaplus.com/#point-54
  4799. // https://promisesaplus.com/#point-75
  4800. // Retrieve `then` only once
  4801. then = returned &&
  4802. // Support: Promises/A+ section 2.3.4
  4803. // https://promisesaplus.com/#point-64
  4804. // Only check objects and functions for thenability
  4805. ( typeof returned === "object" ||
  4806. typeof returned === "function" ) &&
  4807. returned.then;
  4808. // Handle a returned thenable
  4809. if ( jQuery.isFunction( then ) ) {
  4810. // Special processors (notify) just wait for resolution
  4811. if ( special ) {
  4812. then.call(
  4813. returned,
  4814. resolve( maxDepth, deferred, Identity, special ),
  4815. resolve( maxDepth, deferred, Thrower, special )
  4816. );
  4817. // Normal processors (resolve) also hook into progress
  4818. } else {
  4819. // ...and disregard older resolution values
  4820. maxDepth++;
  4821. then.call(
  4822. returned,
  4823. resolve( maxDepth, deferred, Identity, special ),
  4824. resolve( maxDepth, deferred, Thrower, special ),
  4825. resolve( maxDepth, deferred, Identity,
  4826. deferred.notifyWith )
  4827. );
  4828. }
  4829. // Handle all other returned values
  4830. } else {
  4831. // Only substitute handlers pass on context
  4832. // and multiple values (non-spec behavior)
  4833. if ( handler !== Identity ) {
  4834. that = undefined;
  4835. args = [ returned ];
  4836. }
  4837. // Process the value(s)
  4838. // Default process is resolve
  4839. ( special || deferred.resolveWith )( that, args );
  4840. }
  4841. },
  4842. // Only normal processors (resolve) catch and reject exceptions
  4843. process = special ?
  4844. mightThrow :
  4845. function() {
  4846. try {
  4847. mightThrow();
  4848. } catch ( e ) {
  4849. if ( jQuery.Deferred.exceptionHook ) {
  4850. jQuery.Deferred.exceptionHook( e,
  4851. process.stackTrace );
  4852. }
  4853. // Support: Promises/A+ section 2.3.3.3.4.1
  4854. // https://promisesaplus.com/#point-61
  4855. // Ignore post-resolution exceptions
  4856. if ( depth + 1 >= maxDepth ) {
  4857. // Only substitute handlers pass on context
  4858. // and multiple values (non-spec behavior)
  4859. if ( handler !== Thrower ) {
  4860. that = undefined;
  4861. args = [ e ];
  4862. }
  4863. deferred.rejectWith( that, args );
  4864. }
  4865. }
  4866. };
  4867. // Support: Promises/A+ section 2.3.3.3.1
  4868. // https://promisesaplus.com/#point-57
  4869. // Re-resolve promises immediately to dodge false rejection from
  4870. // subsequent errors
  4871. if ( depth ) {
  4872. process();
  4873. } else {
  4874. // Call an optional hook to record the stack, in case of exception
  4875. // since it's otherwise lost when execution goes async
  4876. if ( jQuery.Deferred.getStackHook ) {
  4877. process.stackTrace = jQuery.Deferred.getStackHook();
  4878. }
  4879. window.setTimeout( process );
  4880. }
  4881. };
  4882. }
  4883. return jQuery.Deferred( function( newDefer ) {
  4884. // progress_handlers.add( ... )
  4885. tuples[ 0 ][ 3 ].add(
  4886. resolve(
  4887. 0,
  4888. newDefer,
  4889. jQuery.isFunction( onProgress ) ?
  4890. onProgress :
  4891. Identity,
  4892. newDefer.notifyWith
  4893. )
  4894. );
  4895. // fulfilled_handlers.add( ... )
  4896. tuples[ 1 ][ 3 ].add(
  4897. resolve(
  4898. 0,
  4899. newDefer,
  4900. jQuery.isFunction( onFulfilled ) ?
  4901. onFulfilled :
  4902. Identity
  4903. )
  4904. );
  4905. // rejected_handlers.add( ... )
  4906. tuples[ 2 ][ 3 ].add(
  4907. resolve(
  4908. 0,
  4909. newDefer,
  4910. jQuery.isFunction( onRejected ) ?
  4911. onRejected :
  4912. Thrower
  4913. )
  4914. );
  4915. } ).promise();
  4916. },
  4917. // Get a promise for this deferred
  4918. // If obj is provided, the promise aspect is added to the object
  4919. promise: function( obj ) {
  4920. return obj != null ? jQuery.extend( obj, promise ) : promise;
  4921. }
  4922. },
  4923. deferred = {};
  4924. // Add list-specific methods
  4925. jQuery.each( tuples, function( i, tuple ) {
  4926. var list = tuple[ 2 ],
  4927. stateString = tuple[ 5 ];
  4928. // promise.progress = list.add
  4929. // promise.done = list.add
  4930. // promise.fail = list.add
  4931. promise[ tuple[ 1 ] ] = list.add;
  4932. // Handle state
  4933. if ( stateString ) {
  4934. list.add(
  4935. function() {
  4936. // state = "resolved" (i.e., fulfilled)
  4937. // state = "rejected"
  4938. state = stateString;
  4939. },
  4940. // rejected_callbacks.disable
  4941. // fulfilled_callbacks.disable
  4942. tuples[ 3 - i ][ 2 ].disable,
  4943. // progress_callbacks.lock
  4944. tuples[ 0 ][ 2 ].lock
  4945. );
  4946. }
  4947. // progress_handlers.fire
  4948. // fulfilled_handlers.fire
  4949. // rejected_handlers.fire
  4950. list.add( tuple[ 3 ].fire );
  4951. // deferred.notify = function() { deferred.notifyWith(...) }
  4952. // deferred.resolve = function() { deferred.resolveWith(...) }
  4953. // deferred.reject = function() { deferred.rejectWith(...) }
  4954. deferred[ tuple[ 0 ] ] = function() {
  4955. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  4956. return this;
  4957. };
  4958. // deferred.notifyWith = list.fireWith
  4959. // deferred.resolveWith = list.fireWith
  4960. // deferred.rejectWith = list.fireWith
  4961. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  4962. } );
  4963. // Make the deferred a promise
  4964. promise.promise( deferred );
  4965. // Call given func if any
  4966. if ( func ) {
  4967. func.call( deferred, deferred );
  4968. }
  4969. // All done!
  4970. return deferred;
  4971. },
  4972. // Deferred helper
  4973. when: function( singleValue ) {
  4974. var
  4975. // count of uncompleted subordinates
  4976. remaining = arguments.length,
  4977. // count of unprocessed arguments
  4978. i = remaining,
  4979. // subordinate fulfillment data
  4980. resolveContexts = Array( i ),
  4981. resolveValues = slice.call( arguments ),
  4982. // the master Deferred
  4983. master = jQuery.Deferred(),
  4984. // subordinate callback factory
  4985. updateFunc = function( i ) {
  4986. return function( value ) {
  4987. resolveContexts[ i ] = this;
  4988. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  4989. if ( !( --remaining ) ) {
  4990. master.resolveWith( resolveContexts, resolveValues );
  4991. }
  4992. };
  4993. };
  4994. // Single- and empty arguments are adopted like Promise.resolve
  4995. if ( remaining <= 1 ) {
  4996. adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
  4997. !remaining );
  4998. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  4999. if ( master.state() === "pending" ||
  5000. jQuery.isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  5001. return master.then();
  5002. }
  5003. }
  5004. // Multiple arguments are aggregated like Promise.all array elements
  5005. while ( i-- ) {
  5006. adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
  5007. }
  5008. return master.promise();
  5009. }
  5010. } );
  5011. // These usually indicate a programmer mistake during development,
  5012. // warn about them ASAP rather than swallowing them by default.
  5013. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  5014. jQuery.Deferred.exceptionHook = function( error, stack ) {
  5015. // Support: IE 8 - 9 only
  5016. // Console exists when dev tools are open, which can happen at any time
  5017. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  5018. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  5019. }
  5020. };
  5021. jQuery.readyException = function( error ) {
  5022. window.setTimeout( function() {
  5023. throw error;
  5024. } );
  5025. };
  5026. // The deferred used on DOM ready
  5027. var readyList = jQuery.Deferred();
  5028. jQuery.fn.ready = function( fn ) {
  5029. readyList
  5030. .then( fn )
  5031. // Wrap jQuery.readyException in a function so that the lookup
  5032. // happens at the time of error handling instead of callback
  5033. // registration.
  5034. .catch( function( error ) {
  5035. jQuery.readyException( error );
  5036. } );
  5037. return this;
  5038. };
  5039. jQuery.extend( {
  5040. // Is the DOM ready to be used? Set to true once it occurs.
  5041. isReady: false,
  5042. // A counter to track how many items to wait for before
  5043. // the ready event fires. See #6781
  5044. readyWait: 1,
  5045. // Handle when the DOM is ready
  5046. ready: function( wait ) {
  5047. // Abort if there are pending holds or we're already ready
  5048. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  5049. return;
  5050. }
  5051. // Remember that the DOM is ready
  5052. jQuery.isReady = true;
  5053. // If a normal DOM Ready event fired, decrement, and wait if need be
  5054. if ( wait !== true && --jQuery.readyWait > 0 ) {
  5055. return;
  5056. }
  5057. // If there are functions bound, to execute
  5058. readyList.resolveWith( document, [ jQuery ] );
  5059. }
  5060. } );
  5061. jQuery.ready.then = readyList.then;
  5062. // The ready event handler and self cleanup method
  5063. function completed() {
  5064. document.removeEventListener( "DOMContentLoaded", completed );
  5065. window.removeEventListener( "load", completed );
  5066. jQuery.ready();
  5067. }
  5068. // Catch cases where $(document).ready() is called
  5069. // after the browser event has already occurred.
  5070. // Support: IE <=9 - 10 only
  5071. // Older IE sometimes signals "interactive" too soon
  5072. if ( document.readyState === "complete" ||
  5073. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  5074. // Handle it asynchronously to allow scripts the opportunity to delay ready
  5075. window.setTimeout( jQuery.ready );
  5076. } else {
  5077. // Use the handy event callback
  5078. document.addEventListener( "DOMContentLoaded", completed );
  5079. // A fallback to window.onload, that will always work
  5080. window.addEventListener( "load", completed );
  5081. }
  5082. // Multifunctional method to get and set values of a collection
  5083. // The value/s can optionally be executed if it's a function
  5084. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  5085. var i = 0,
  5086. len = elems.length,
  5087. bulk = key == null;
  5088. // Sets many values
  5089. if ( jQuery.type( key ) === "object" ) {
  5090. chainable = true;
  5091. for ( i in key ) {
  5092. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  5093. }
  5094. // Sets one value
  5095. } else if ( value !== undefined ) {
  5096. chainable = true;
  5097. if ( !jQuery.isFunction( value ) ) {
  5098. raw = true;
  5099. }
  5100. if ( bulk ) {
  5101. // Bulk operations run against the entire set
  5102. if ( raw ) {
  5103. fn.call( elems, value );
  5104. fn = null;
  5105. // ...except when executing function values
  5106. } else {
  5107. bulk = fn;
  5108. fn = function( elem, key, value ) {
  5109. return bulk.call( jQuery( elem ), value );
  5110. };
  5111. }
  5112. }
  5113. if ( fn ) {
  5114. for ( ; i < len; i++ ) {
  5115. fn(
  5116. elems[ i ], key, raw ?
  5117. value :
  5118. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  5119. );
  5120. }
  5121. }
  5122. }
  5123. if ( chainable ) {
  5124. return elems;
  5125. }
  5126. // Gets
  5127. if ( bulk ) {
  5128. return fn.call( elems );
  5129. }
  5130. return len ? fn( elems[ 0 ], key ) : emptyGet;
  5131. };
  5132. var acceptData = function( owner ) {
  5133. // Accepts only:
  5134. // - Node
  5135. // - Node.ELEMENT_NODE
  5136. // - Node.DOCUMENT_NODE
  5137. // - Object
  5138. // - Any
  5139. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  5140. };
  5141. function Data() {
  5142. this.expando = jQuery.expando + Data.uid++;
  5143. }
  5144. Data.uid = 1;
  5145. Data.prototype = {
  5146. cache: function( owner ) {
  5147. // Check if the owner object already has a cache
  5148. var value = owner[ this.expando ];
  5149. // If not, create one
  5150. if ( !value ) {
  5151. value = {};
  5152. // We can accept data for non-element nodes in modern browsers,
  5153. // but we should not, see #8335.
  5154. // Always return an empty object.
  5155. if ( acceptData( owner ) ) {
  5156. // If it is a node unlikely to be stringify-ed or looped over
  5157. // use plain assignment
  5158. if ( owner.nodeType ) {
  5159. owner[ this.expando ] = value;
  5160. // Otherwise secure it in a non-enumerable property
  5161. // configurable must be true to allow the property to be
  5162. // deleted when data is removed
  5163. } else {
  5164. Object.defineProperty( owner, this.expando, {
  5165. value: value,
  5166. configurable: true
  5167. } );
  5168. }
  5169. }
  5170. }
  5171. return value;
  5172. },
  5173. set: function( owner, data, value ) {
  5174. var prop,
  5175. cache = this.cache( owner );
  5176. // Handle: [ owner, key, value ] args
  5177. // Always use camelCase key (gh-2257)
  5178. if ( typeof data === "string" ) {
  5179. cache[ jQuery.camelCase( data ) ] = value;
  5180. // Handle: [ owner, { properties } ] args
  5181. } else {
  5182. // Copy the properties one-by-one to the cache object
  5183. for ( prop in data ) {
  5184. cache[ jQuery.camelCase( prop ) ] = data[ prop ];
  5185. }
  5186. }
  5187. return cache;
  5188. },
  5189. get: function( owner, key ) {
  5190. return key === undefined ?
  5191. this.cache( owner ) :
  5192. // Always use camelCase key (gh-2257)
  5193. owner[ this.expando ] && owner[ this.expando ][ jQuery.camelCase( key ) ];
  5194. },
  5195. access: function( owner, key, value ) {
  5196. // In cases where either:
  5197. //
  5198. // 1. No key was specified
  5199. // 2. A string key was specified, but no value provided
  5200. //
  5201. // Take the "read" path and allow the get method to determine
  5202. // which value to return, respectively either:
  5203. //
  5204. // 1. The entire cache object
  5205. // 2. The data stored at the key
  5206. //
  5207. if ( key === undefined ||
  5208. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  5209. return this.get( owner, key );
  5210. }
  5211. // When the key is not a string, or both a key and value
  5212. // are specified, set or extend (existing objects) with either:
  5213. //
  5214. // 1. An object of properties
  5215. // 2. A key and value
  5216. //
  5217. this.set( owner, key, value );
  5218. // Since the "set" path can have two possible entry points
  5219. // return the expected data based on which path was taken[*]
  5220. return value !== undefined ? value : key;
  5221. },
  5222. remove: function( owner, key ) {
  5223. var i,
  5224. cache = owner[ this.expando ];
  5225. if ( cache === undefined ) {
  5226. return;
  5227. }
  5228. if ( key !== undefined ) {
  5229. // Support array or space separated string of keys
  5230. if ( Array.isArray( key ) ) {
  5231. // If key is an array of keys...
  5232. // We always set camelCase keys, so remove that.
  5233. key = key.map( jQuery.camelCase );
  5234. } else {
  5235. key = jQuery.camelCase( key );
  5236. // If a key with the spaces exists, use it.
  5237. // Otherwise, create an array by matching non-whitespace
  5238. key = key in cache ?
  5239. [ key ] :
  5240. ( key.match( rnothtmlwhite ) || [] );
  5241. }
  5242. i = key.length;
  5243. while ( i-- ) {
  5244. delete cache[ key[ i ] ];
  5245. }
  5246. }
  5247. // Remove the expando if there's no more data
  5248. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  5249. // Support: Chrome <=35 - 45
  5250. // Webkit & Blink performance suffers when deleting properties
  5251. // from DOM nodes, so set to undefined instead
  5252. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  5253. if ( owner.nodeType ) {
  5254. owner[ this.expando ] = undefined;
  5255. } else {
  5256. delete owner[ this.expando ];
  5257. }
  5258. }
  5259. },
  5260. hasData: function( owner ) {
  5261. var cache = owner[ this.expando ];
  5262. return cache !== undefined && !jQuery.isEmptyObject( cache );
  5263. }
  5264. };
  5265. var dataPriv = new Data();
  5266. var dataUser = new Data();
  5267. // Implementation Summary
  5268. //
  5269. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  5270. // 2. Improve the module's maintainability by reducing the storage
  5271. // paths to a single mechanism.
  5272. // 3. Use the same single mechanism to support "private" and "user" data.
  5273. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  5274. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  5275. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  5276. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  5277. rmultiDash = /[A-Z]/g;
  5278. function getData( data ) {
  5279. if ( data === "true" ) {
  5280. return true;
  5281. }
  5282. if ( data === "false" ) {
  5283. return false;
  5284. }
  5285. if ( data === "null" ) {
  5286. return null;
  5287. }
  5288. // Only convert to a number if it doesn't change the string
  5289. if ( data === +data + "" ) {
  5290. return +data;
  5291. }
  5292. if ( rbrace.test( data ) ) {
  5293. return JSON.parse( data );
  5294. }
  5295. return data;
  5296. }
  5297. function dataAttr( elem, key, data ) {
  5298. var name;
  5299. // If nothing was found internally, try to fetch any
  5300. // data from the HTML5 data-* attribute
  5301. if ( data === undefined && elem.nodeType === 1 ) {
  5302. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  5303. data = elem.getAttribute( name );
  5304. if ( typeof data === "string" ) {
  5305. try {
  5306. data = getData( data );
  5307. } catch ( e ) {}
  5308. // Make sure we set the data so it isn't changed later
  5309. dataUser.set( elem, key, data );
  5310. } else {
  5311. data = undefined;
  5312. }
  5313. }
  5314. return data;
  5315. }
  5316. jQuery.extend( {
  5317. hasData: function( elem ) {
  5318. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  5319. },
  5320. data: function( elem, name, data ) {
  5321. return dataUser.access( elem, name, data );
  5322. },
  5323. removeData: function( elem, name ) {
  5324. dataUser.remove( elem, name );
  5325. },
  5326. // TODO: Now that all calls to _data and _removeData have been replaced
  5327. // with direct calls to dataPriv methods, these can be deprecated.
  5328. _data: function( elem, name, data ) {
  5329. return dataPriv.access( elem, name, data );
  5330. },
  5331. _removeData: function( elem, name ) {
  5332. dataPriv.remove( elem, name );
  5333. }
  5334. } );
  5335. jQuery.fn.extend( {
  5336. data: function( key, value ) {
  5337. var i, name, data,
  5338. elem = this[ 0 ],
  5339. attrs = elem && elem.attributes;
  5340. // Gets all values
  5341. if ( key === undefined ) {
  5342. if ( this.length ) {
  5343. data = dataUser.get( elem );
  5344. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  5345. i = attrs.length;
  5346. while ( i-- ) {
  5347. // Support: IE 11 only
  5348. // The attrs elements can be null (#14894)
  5349. if ( attrs[ i ] ) {
  5350. name = attrs[ i ].name;
  5351. if ( name.indexOf( "data-" ) === 0 ) {
  5352. name = jQuery.camelCase( name.slice( 5 ) );
  5353. dataAttr( elem, name, data[ name ] );
  5354. }
  5355. }
  5356. }
  5357. dataPriv.set( elem, "hasDataAttrs", true );
  5358. }
  5359. }
  5360. return data;
  5361. }
  5362. // Sets multiple values
  5363. if ( typeof key === "object" ) {
  5364. return this.each( function() {
  5365. dataUser.set( this, key );
  5366. } );
  5367. }
  5368. return access( this, function( value ) {
  5369. var data;
  5370. // The calling jQuery object (element matches) is not empty
  5371. // (and therefore has an element appears at this[ 0 ]) and the
  5372. // `value` parameter was not undefined. An empty jQuery object
  5373. // will result in `undefined` for elem = this[ 0 ] which will
  5374. // throw an exception if an attempt to read a data cache is made.
  5375. if ( elem && value === undefined ) {
  5376. // Attempt to get data from the cache
  5377. // The key will always be camelCased in Data
  5378. data = dataUser.get( elem, key );
  5379. if ( data !== undefined ) {
  5380. return data;
  5381. }
  5382. // Attempt to "discover" the data in
  5383. // HTML5 custom data-* attrs
  5384. data = dataAttr( elem, key );
  5385. if ( data !== undefined ) {
  5386. return data;
  5387. }
  5388. // We tried really hard, but the data doesn't exist.
  5389. return;
  5390. }
  5391. // Set the data...
  5392. this.each( function() {
  5393. // We always store the camelCased key
  5394. dataUser.set( this, key, value );
  5395. } );
  5396. }, null, value, arguments.length > 1, null, true );
  5397. },
  5398. removeData: function( key ) {
  5399. return this.each( function() {
  5400. dataUser.remove( this, key );
  5401. } );
  5402. }
  5403. } );
  5404. jQuery.extend( {
  5405. queue: function( elem, type, data ) {
  5406. var queue;
  5407. if ( elem ) {
  5408. type = ( type || "fx" ) + "queue";
  5409. queue = dataPriv.get( elem, type );
  5410. // Speed up dequeue by getting out quickly if this is just a lookup
  5411. if ( data ) {
  5412. if ( !queue || Array.isArray( data ) ) {
  5413. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  5414. } else {
  5415. queue.push( data );
  5416. }
  5417. }
  5418. return queue || [];
  5419. }
  5420. },
  5421. dequeue: function( elem, type ) {
  5422. type = type || "fx";
  5423. var queue = jQuery.queue( elem, type ),
  5424. startLength = queue.length,
  5425. fn = queue.shift(),
  5426. hooks = jQuery._queueHooks( elem, type ),
  5427. next = function() {
  5428. jQuery.dequeue( elem, type );
  5429. };
  5430. // If the fx queue is dequeued, always remove the progress sentinel
  5431. if ( fn === "inprogress" ) {
  5432. fn = queue.shift();
  5433. startLength--;
  5434. }
  5435. if ( fn ) {
  5436. // Add a progress sentinel to prevent the fx queue from being
  5437. // automatically dequeued
  5438. if ( type === "fx" ) {
  5439. queue.unshift( "inprogress" );
  5440. }
  5441. // Clear up the last queue stop function
  5442. delete hooks.stop;
  5443. fn.call( elem, next, hooks );
  5444. }
  5445. if ( !startLength && hooks ) {
  5446. hooks.empty.fire();
  5447. }
  5448. },
  5449. // Not public - generate a queueHooks object, or return the current one
  5450. _queueHooks: function( elem, type ) {
  5451. var key = type + "queueHooks";
  5452. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  5453. empty: jQuery.Callbacks( "once memory" ).add( function() {
  5454. dataPriv.remove( elem, [ type + "queue", key ] );
  5455. } )
  5456. } );
  5457. }
  5458. } );
  5459. jQuery.fn.extend( {
  5460. queue: function( type, data ) {
  5461. var setter = 2;
  5462. if ( typeof type !== "string" ) {
  5463. data = type;
  5464. type = "fx";
  5465. setter--;
  5466. }
  5467. if ( arguments.length < setter ) {
  5468. return jQuery.queue( this[ 0 ], type );
  5469. }
  5470. return data === undefined ?
  5471. this :
  5472. this.each( function() {
  5473. var queue = jQuery.queue( this, type, data );
  5474. // Ensure a hooks for this queue
  5475. jQuery._queueHooks( this, type );
  5476. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  5477. jQuery.dequeue( this, type );
  5478. }
  5479. } );
  5480. },
  5481. dequeue: function( type ) {
  5482. return this.each( function() {
  5483. jQuery.dequeue( this, type );
  5484. } );
  5485. },
  5486. clearQueue: function( type ) {
  5487. return this.queue( type || "fx", [] );
  5488. },
  5489. // Get a promise resolved when queues of a certain type
  5490. // are emptied (fx is the type by default)
  5491. promise: function( type, obj ) {
  5492. var tmp,
  5493. count = 1,
  5494. defer = jQuery.Deferred(),
  5495. elements = this,
  5496. i = this.length,
  5497. resolve = function() {
  5498. if ( !( --count ) ) {
  5499. defer.resolveWith( elements, [ elements ] );
  5500. }
  5501. };
  5502. if ( typeof type !== "string" ) {
  5503. obj = type;
  5504. type = undefined;
  5505. }
  5506. type = type || "fx";
  5507. while ( i-- ) {
  5508. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  5509. if ( tmp && tmp.empty ) {
  5510. count++;
  5511. tmp.empty.add( resolve );
  5512. }
  5513. }
  5514. resolve();
  5515. return defer.promise( obj );
  5516. }
  5517. } );
  5518. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  5519. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  5520. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  5521. var isHiddenWithinTree = function( elem, el ) {
  5522. // isHiddenWithinTree might be called from jQuery#filter function;
  5523. // in that case, element will be second argument
  5524. elem = el || elem;
  5525. // Inline style trumps all
  5526. return elem.style.display === "none" ||
  5527. elem.style.display === "" &&
  5528. // Otherwise, check computed style
  5529. // Support: Firefox <=43 - 45
  5530. // Disconnected elements can have computed display: none, so first confirm that elem is
  5531. // in the document.
  5532. jQuery.contains( elem.ownerDocument, elem ) &&
  5533. jQuery.css( elem, "display" ) === "none";
  5534. };
  5535. var swap = function( elem, options, callback, args ) {
  5536. var ret, name,
  5537. old = {};
  5538. // Remember the old values, and insert the new ones
  5539. for ( name in options ) {
  5540. old[ name ] = elem.style[ name ];
  5541. elem.style[ name ] = options[ name ];
  5542. }
  5543. ret = callback.apply( elem, args || [] );
  5544. // Revert the old values
  5545. for ( name in options ) {
  5546. elem.style[ name ] = old[ name ];
  5547. }
  5548. return ret;
  5549. };
  5550. function adjustCSS( elem, prop, valueParts, tween ) {
  5551. var adjusted,
  5552. scale = 1,
  5553. maxIterations = 20,
  5554. currentValue = tween ?
  5555. function() {
  5556. return tween.cur();
  5557. } :
  5558. function() {
  5559. return jQuery.css( elem, prop, "" );
  5560. },
  5561. initial = currentValue(),
  5562. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  5563. // Starting value computation is required for potential unit mismatches
  5564. initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  5565. rcssNum.exec( jQuery.css( elem, prop ) );
  5566. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  5567. // Trust units reported by jQuery.css
  5568. unit = unit || initialInUnit[ 3 ];
  5569. // Make sure we update the tween properties later on
  5570. valueParts = valueParts || [];
  5571. // Iteratively approximate from a nonzero starting point
  5572. initialInUnit = +initial || 1;
  5573. do {
  5574. // If previous iteration zeroed out, double until we get *something*.
  5575. // Use string for doubling so we don't accidentally see scale as unchanged below
  5576. scale = scale || ".5";
  5577. // Adjust and apply
  5578. initialInUnit = initialInUnit / scale;
  5579. jQuery.style( elem, prop, initialInUnit + unit );
  5580. // Update scale, tolerating zero or NaN from tween.cur()
  5581. // Break the loop if scale is unchanged or perfect, or if we've just had enough.
  5582. } while (
  5583. scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations
  5584. );
  5585. }
  5586. if ( valueParts ) {
  5587. initialInUnit = +initialInUnit || +initial || 0;
  5588. // Apply relative offset (+=/-=) if specified
  5589. adjusted = valueParts[ 1 ] ?
  5590. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  5591. +valueParts[ 2 ];
  5592. if ( tween ) {
  5593. tween.unit = unit;
  5594. tween.start = initialInUnit;
  5595. tween.end = adjusted;
  5596. }
  5597. }
  5598. return adjusted;
  5599. }
  5600. var defaultDisplayMap = {};
  5601. function getDefaultDisplay( elem ) {
  5602. var temp,
  5603. doc = elem.ownerDocument,
  5604. nodeName = elem.nodeName,
  5605. display = defaultDisplayMap[ nodeName ];
  5606. if ( display ) {
  5607. return display;
  5608. }
  5609. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  5610. display = jQuery.css( temp, "display" );
  5611. temp.parentNode.removeChild( temp );
  5612. if ( display === "none" ) {
  5613. display = "block";
  5614. }
  5615. defaultDisplayMap[ nodeName ] = display;
  5616. return display;
  5617. }
  5618. function showHide( elements, show ) {
  5619. var display, elem,
  5620. values = [],
  5621. index = 0,
  5622. length = elements.length;
  5623. // Determine new display value for elements that need to change
  5624. for ( ; index < length; index++ ) {
  5625. elem = elements[ index ];
  5626. if ( !elem.style ) {
  5627. continue;
  5628. }
  5629. display = elem.style.display;
  5630. if ( show ) {
  5631. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  5632. // check is required in this first loop unless we have a nonempty display value (either
  5633. // inline or about-to-be-restored)
  5634. if ( display === "none" ) {
  5635. values[ index ] = dataPriv.get( elem, "display" ) || null;
  5636. if ( !values[ index ] ) {
  5637. elem.style.display = "";
  5638. }
  5639. }
  5640. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  5641. values[ index ] = getDefaultDisplay( elem );
  5642. }
  5643. } else {
  5644. if ( display !== "none" ) {
  5645. values[ index ] = "none";
  5646. // Remember what we're overwriting
  5647. dataPriv.set( elem, "display", display );
  5648. }
  5649. }
  5650. }
  5651. // Set the display of the elements in a second loop to avoid constant reflow
  5652. for ( index = 0; index < length; index++ ) {
  5653. if ( values[ index ] != null ) {
  5654. elements[ index ].style.display = values[ index ];
  5655. }
  5656. }
  5657. return elements;
  5658. }
  5659. jQuery.fn.extend( {
  5660. show: function() {
  5661. return showHide( this, true );
  5662. },
  5663. hide: function() {
  5664. return showHide( this );
  5665. },
  5666. toggle: function( state ) {
  5667. if ( typeof state === "boolean" ) {
  5668. return state ? this.show() : this.hide();
  5669. }
  5670. return this.each( function() {
  5671. if ( isHiddenWithinTree( this ) ) {
  5672. jQuery( this ).show();
  5673. } else {
  5674. jQuery( this ).hide();
  5675. }
  5676. } );
  5677. }
  5678. } );
  5679. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  5680. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]+)/i );
  5681. var rscriptType = ( /^$|\/(?:java|ecma)script/i );
  5682. // We have to close these tags to support XHTML (#13200)
  5683. var wrapMap = {
  5684. // Support: IE <=9 only
  5685. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  5686. // XHTML parsers do not magically insert elements in the
  5687. // same way that tag soup parsers do. So we cannot shorten
  5688. // this by omitting <tbody> or other required elements.
  5689. thead: [ 1, "<table>", "</table>" ],
  5690. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  5691. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  5692. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  5693. _default: [ 0, "", "" ]
  5694. };
  5695. // Support: IE <=9 only
  5696. wrapMap.optgroup = wrapMap.option;
  5697. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  5698. wrapMap.th = wrapMap.td;
  5699. function getAll( context, tag ) {
  5700. // Support: IE <=9 - 11 only
  5701. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  5702. var ret;
  5703. if ( typeof context.getElementsByTagName !== "undefined" ) {
  5704. ret = context.getElementsByTagName( tag || "*" );
  5705. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  5706. ret = context.querySelectorAll( tag || "*" );
  5707. } else {
  5708. ret = [];
  5709. }
  5710. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  5711. return jQuery.merge( [ context ], ret );
  5712. }
  5713. return ret;
  5714. }
  5715. // Mark scripts as having already been evaluated
  5716. function setGlobalEval( elems, refElements ) {
  5717. var i = 0,
  5718. l = elems.length;
  5719. for ( ; i < l; i++ ) {
  5720. dataPriv.set(
  5721. elems[ i ],
  5722. "globalEval",
  5723. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  5724. );
  5725. }
  5726. }
  5727. var rhtml = /<|&#?\w+;/;
  5728. function buildFragment( elems, context, scripts, selection, ignored ) {
  5729. var elem, tmp, tag, wrap, contains, j,
  5730. fragment = context.createDocumentFragment(),
  5731. nodes = [],
  5732. i = 0,
  5733. l = elems.length;
  5734. for ( ; i < l; i++ ) {
  5735. elem = elems[ i ];
  5736. if ( elem || elem === 0 ) {
  5737. // Add nodes directly
  5738. if ( jQuery.type( elem ) === "object" ) {
  5739. // Support: Android <=4.0 only, PhantomJS 1 only
  5740. // push.apply(_, arraylike) throws on ancient WebKit
  5741. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  5742. // Convert non-html into a text node
  5743. } else if ( !rhtml.test( elem ) ) {
  5744. nodes.push( context.createTextNode( elem ) );
  5745. // Convert html into DOM nodes
  5746. } else {
  5747. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  5748. // Deserialize a standard representation
  5749. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  5750. wrap = wrapMap[ tag ] || wrapMap._default;
  5751. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  5752. // Descend through wrappers to the right content
  5753. j = wrap[ 0 ];
  5754. while ( j-- ) {
  5755. tmp = tmp.lastChild;
  5756. }
  5757. // Support: Android <=4.0 only, PhantomJS 1 only
  5758. // push.apply(_, arraylike) throws on ancient WebKit
  5759. jQuery.merge( nodes, tmp.childNodes );
  5760. // Remember the top-level container
  5761. tmp = fragment.firstChild;
  5762. // Ensure the created nodes are orphaned (#12392)
  5763. tmp.textContent = "";
  5764. }
  5765. }
  5766. }
  5767. // Remove wrapper from fragment
  5768. fragment.textContent = "";
  5769. i = 0;
  5770. while ( ( elem = nodes[ i++ ] ) ) {
  5771. // Skip elements already in the context collection (trac-4087)
  5772. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  5773. if ( ignored ) {
  5774. ignored.push( elem );
  5775. }
  5776. continue;
  5777. }
  5778. contains = jQuery.contains( elem.ownerDocument, elem );
  5779. // Append to fragment
  5780. tmp = getAll( fragment.appendChild( elem ), "script" );
  5781. // Preserve script evaluation history
  5782. if ( contains ) {
  5783. setGlobalEval( tmp );
  5784. }
  5785. // Capture executables
  5786. if ( scripts ) {
  5787. j = 0;
  5788. while ( ( elem = tmp[ j++ ] ) ) {
  5789. if ( rscriptType.test( elem.type || "" ) ) {
  5790. scripts.push( elem );
  5791. }
  5792. }
  5793. }
  5794. }
  5795. return fragment;
  5796. }
  5797. ( function() {
  5798. var fragment = document.createDocumentFragment(),
  5799. div = fragment.appendChild( document.createElement( "div" ) ),
  5800. input = document.createElement( "input" );
  5801. // Support: Android 4.0 - 4.3 only
  5802. // Check state lost if the name is set (#11217)
  5803. // Support: Windows Web Apps (WWA)
  5804. // `name` and `type` must use .setAttribute for WWA (#14901)
  5805. input.setAttribute( "type", "radio" );
  5806. input.setAttribute( "checked", "checked" );
  5807. input.setAttribute( "name", "t" );
  5808. div.appendChild( input );
  5809. // Support: Android <=4.1 only
  5810. // Older WebKit doesn't clone checked state correctly in fragments
  5811. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  5812. // Support: IE <=11 only
  5813. // Make sure textarea (and checkbox) defaultValue is properly cloned
  5814. div.innerHTML = "<textarea>x</textarea>";
  5815. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  5816. } )();
  5817. var documentElement = document.documentElement;
  5818. var
  5819. rkeyEvent = /^key/,
  5820. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  5821. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  5822. function returnTrue() {
  5823. return true;
  5824. }
  5825. function returnFalse() {
  5826. return false;
  5827. }
  5828. // Support: IE <=9 only
  5829. // See #13393 for more info
  5830. function safeActiveElement() {
  5831. try {
  5832. return document.activeElement;
  5833. } catch ( err ) { }
  5834. }
  5835. function on( elem, types, selector, data, fn, one ) {
  5836. var origFn, type;
  5837. // Types can be a map of types/handlers
  5838. if ( typeof types === "object" ) {
  5839. // ( types-Object, selector, data )
  5840. if ( typeof selector !== "string" ) {
  5841. // ( types-Object, data )
  5842. data = data || selector;
  5843. selector = undefined;
  5844. }
  5845. for ( type in types ) {
  5846. on( elem, type, selector, data, types[ type ], one );
  5847. }
  5848. return elem;
  5849. }
  5850. if ( data == null && fn == null ) {
  5851. // ( types, fn )
  5852. fn = selector;
  5853. data = selector = undefined;
  5854. } else if ( fn == null ) {
  5855. if ( typeof selector === "string" ) {
  5856. // ( types, selector, fn )
  5857. fn = data;
  5858. data = undefined;
  5859. } else {
  5860. // ( types, data, fn )
  5861. fn = data;
  5862. data = selector;
  5863. selector = undefined;
  5864. }
  5865. }
  5866. if ( fn === false ) {
  5867. fn = returnFalse;
  5868. } else if ( !fn ) {
  5869. return elem;
  5870. }
  5871. if ( one === 1 ) {
  5872. origFn = fn;
  5873. fn = function( event ) {
  5874. // Can use an empty set, since event contains the info
  5875. jQuery().off( event );
  5876. return origFn.apply( this, arguments );
  5877. };
  5878. // Use same guid so caller can remove using origFn
  5879. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  5880. }
  5881. return elem.each( function() {
  5882. jQuery.event.add( this, types, fn, data, selector );
  5883. } );
  5884. }
  5885. /*
  5886. * Helper functions for managing events -- not part of the public interface.
  5887. * Props to Dean Edwards' addEvent library for many of the ideas.
  5888. */
  5889. jQuery.event = {
  5890. global: {},
  5891. add: function( elem, types, handler, data, selector ) {
  5892. var handleObjIn, eventHandle, tmp,
  5893. events, t, handleObj,
  5894. special, handlers, type, namespaces, origType,
  5895. elemData = dataPriv.get( elem );
  5896. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  5897. if ( !elemData ) {
  5898. return;
  5899. }
  5900. // Caller can pass in an object of custom data in lieu of the handler
  5901. if ( handler.handler ) {
  5902. handleObjIn = handler;
  5903. handler = handleObjIn.handler;
  5904. selector = handleObjIn.selector;
  5905. }
  5906. // Ensure that invalid selectors throw exceptions at attach time
  5907. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  5908. if ( selector ) {
  5909. jQuery.find.matchesSelector( documentElement, selector );
  5910. }
  5911. // Make sure that the handler has a unique ID, used to find/remove it later
  5912. if ( !handler.guid ) {
  5913. handler.guid = jQuery.guid++;
  5914. }
  5915. // Init the element's event structure and main handler, if this is the first
  5916. if ( !( events = elemData.events ) ) {
  5917. events = elemData.events = {};
  5918. }
  5919. if ( !( eventHandle = elemData.handle ) ) {
  5920. eventHandle = elemData.handle = function( e ) {
  5921. // Discard the second event of a jQuery.event.trigger() and
  5922. // when an event is called after a page has unloaded
  5923. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  5924. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  5925. };
  5926. }
  5927. // Handle multiple events separated by a space
  5928. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  5929. t = types.length;
  5930. while ( t-- ) {
  5931. tmp = rtypenamespace.exec( types[ t ] ) || [];
  5932. type = origType = tmp[ 1 ];
  5933. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  5934. // There *must* be a type, no attaching namespace-only handlers
  5935. if ( !type ) {
  5936. continue;
  5937. }
  5938. // If event changes its type, use the special event handlers for the changed type
  5939. special = jQuery.event.special[ type ] || {};
  5940. // If selector defined, determine special event api type, otherwise given type
  5941. type = ( selector ? special.delegateType : special.bindType ) || type;
  5942. // Update special based on newly reset type
  5943. special = jQuery.event.special[ type ] || {};
  5944. // handleObj is passed to all event handlers
  5945. handleObj = jQuery.extend( {
  5946. type: type,
  5947. origType: origType,
  5948. data: data,
  5949. handler: handler,
  5950. guid: handler.guid,
  5951. selector: selector,
  5952. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  5953. namespace: namespaces.join( "." )
  5954. }, handleObjIn );
  5955. // Init the event handler queue if we're the first
  5956. if ( !( handlers = events[ type ] ) ) {
  5957. handlers = events[ type ] = [];
  5958. handlers.delegateCount = 0;
  5959. // Only use addEventListener if the special events handler returns false
  5960. if ( !special.setup ||
  5961. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  5962. if ( elem.addEventListener ) {
  5963. elem.addEventListener( type, eventHandle );
  5964. }
  5965. }
  5966. }
  5967. if ( special.add ) {
  5968. special.add.call( elem, handleObj );
  5969. if ( !handleObj.handler.guid ) {
  5970. handleObj.handler.guid = handler.guid;
  5971. }
  5972. }
  5973. // Add to the element's handler list, delegates in front
  5974. if ( selector ) {
  5975. handlers.splice( handlers.delegateCount++, 0, handleObj );
  5976. } else {
  5977. handlers.push( handleObj );
  5978. }
  5979. // Keep track of which events have ever been used, for event optimization
  5980. jQuery.event.global[ type ] = true;
  5981. }
  5982. },
  5983. // Detach an event or set of events from an element
  5984. remove: function( elem, types, handler, selector, mappedTypes ) {
  5985. var j, origCount, tmp,
  5986. events, t, handleObj,
  5987. special, handlers, type, namespaces, origType,
  5988. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  5989. if ( !elemData || !( events = elemData.events ) ) {
  5990. return;
  5991. }
  5992. // Once for each type.namespace in types; type may be omitted
  5993. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  5994. t = types.length;
  5995. while ( t-- ) {
  5996. tmp = rtypenamespace.exec( types[ t ] ) || [];
  5997. type = origType = tmp[ 1 ];
  5998. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  5999. // Unbind all events (on this namespace, if provided) for the element
  6000. if ( !type ) {
  6001. for ( type in events ) {
  6002. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  6003. }
  6004. continue;
  6005. }
  6006. special = jQuery.event.special[ type ] || {};
  6007. type = ( selector ? special.delegateType : special.bindType ) || type;
  6008. handlers = events[ type ] || [];
  6009. tmp = tmp[ 2 ] &&
  6010. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  6011. // Remove matching events
  6012. origCount = j = handlers.length;
  6013. while ( j-- ) {
  6014. handleObj = handlers[ j ];
  6015. if ( ( mappedTypes || origType === handleObj.origType ) &&
  6016. ( !handler || handler.guid === handleObj.guid ) &&
  6017. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  6018. ( !selector || selector === handleObj.selector ||
  6019. selector === "**" && handleObj.selector ) ) {
  6020. handlers.splice( j, 1 );
  6021. if ( handleObj.selector ) {
  6022. handlers.delegateCount--;
  6023. }
  6024. if ( special.remove ) {
  6025. special.remove.call( elem, handleObj );
  6026. }
  6027. }
  6028. }
  6029. // Remove generic event handler if we removed something and no more handlers exist
  6030. // (avoids potential for endless recursion during removal of special event handlers)
  6031. if ( origCount && !handlers.length ) {
  6032. if ( !special.teardown ||
  6033. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  6034. jQuery.removeEvent( elem, type, elemData.handle );
  6035. }
  6036. delete events[ type ];
  6037. }
  6038. }
  6039. // Remove data and the expando if it's no longer used
  6040. if ( jQuery.isEmptyObject( events ) ) {
  6041. dataPriv.remove( elem, "handle events" );
  6042. }
  6043. },
  6044. dispatch: function( nativeEvent ) {
  6045. // Make a writable jQuery.Event from the native event object
  6046. var event = jQuery.event.fix( nativeEvent );
  6047. var i, j, ret, matched, handleObj, handlerQueue,
  6048. args = new Array( arguments.length ),
  6049. handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
  6050. special = jQuery.event.special[ event.type ] || {};
  6051. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  6052. args[ 0 ] = event;
  6053. for ( i = 1; i < arguments.length; i++ ) {
  6054. args[ i ] = arguments[ i ];
  6055. }
  6056. event.delegateTarget = this;
  6057. // Call the preDispatch hook for the mapped type, and let it bail if desired
  6058. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  6059. return;
  6060. }
  6061. // Determine handlers
  6062. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  6063. // Run delegates first; they may want to stop propagation beneath us
  6064. i = 0;
  6065. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  6066. event.currentTarget = matched.elem;
  6067. j = 0;
  6068. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  6069. !event.isImmediatePropagationStopped() ) {
  6070. // Triggered event must either 1) have no namespace, or 2) have namespace(s)
  6071. // a subset or equal to those in the bound event (both can have no namespace).
  6072. if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) {
  6073. event.handleObj = handleObj;
  6074. event.data = handleObj.data;
  6075. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  6076. handleObj.handler ).apply( matched.elem, args );
  6077. if ( ret !== undefined ) {
  6078. if ( ( event.result = ret ) === false ) {
  6079. event.preventDefault();
  6080. event.stopPropagation();
  6081. }
  6082. }
  6083. }
  6084. }
  6085. }
  6086. // Call the postDispatch hook for the mapped type
  6087. if ( special.postDispatch ) {
  6088. special.postDispatch.call( this, event );
  6089. }
  6090. return event.result;
  6091. },
  6092. handlers: function( event, handlers ) {
  6093. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  6094. handlerQueue = [],
  6095. delegateCount = handlers.delegateCount,
  6096. cur = event.target;
  6097. // Find delegate handlers
  6098. if ( delegateCount &&
  6099. // Support: IE <=9
  6100. // Black-hole SVG <use> instance trees (trac-13180)
  6101. cur.nodeType &&
  6102. // Support: Firefox <=42
  6103. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  6104. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  6105. // Support: IE 11 only
  6106. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  6107. !( event.type === "click" && event.button >= 1 ) ) {
  6108. for ( ; cur !== this; cur = cur.parentNode || this ) {
  6109. // Don't check non-elements (#13208)
  6110. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  6111. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  6112. matchedHandlers = [];
  6113. matchedSelectors = {};
  6114. for ( i = 0; i < delegateCount; i++ ) {
  6115. handleObj = handlers[ i ];
  6116. // Don't conflict with Object.prototype properties (#13203)
  6117. sel = handleObj.selector + " ";
  6118. if ( matchedSelectors[ sel ] === undefined ) {
  6119. matchedSelectors[ sel ] = handleObj.needsContext ?
  6120. jQuery( sel, this ).index( cur ) > -1 :
  6121. jQuery.find( sel, this, null, [ cur ] ).length;
  6122. }
  6123. if ( matchedSelectors[ sel ] ) {
  6124. matchedHandlers.push( handleObj );
  6125. }
  6126. }
  6127. if ( matchedHandlers.length ) {
  6128. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  6129. }
  6130. }
  6131. }
  6132. }
  6133. // Add the remaining (directly-bound) handlers
  6134. cur = this;
  6135. if ( delegateCount < handlers.length ) {
  6136. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  6137. }
  6138. return handlerQueue;
  6139. },
  6140. addProp: function( name, hook ) {
  6141. Object.defineProperty( jQuery.Event.prototype, name, {
  6142. enumerable: true,
  6143. configurable: true,
  6144. get: jQuery.isFunction( hook ) ?
  6145. function() {
  6146. if ( this.originalEvent ) {
  6147. return hook( this.originalEvent );
  6148. }
  6149. } :
  6150. function() {
  6151. if ( this.originalEvent ) {
  6152. return this.originalEvent[ name ];
  6153. }
  6154. },
  6155. set: function( value ) {
  6156. Object.defineProperty( this, name, {
  6157. enumerable: true,
  6158. configurable: true,
  6159. writable: true,
  6160. value: value
  6161. } );
  6162. }
  6163. } );
  6164. },
  6165. fix: function( originalEvent ) {
  6166. return originalEvent[ jQuery.expando ] ?
  6167. originalEvent :
  6168. new jQuery.Event( originalEvent );
  6169. },
  6170. special: {
  6171. load: {
  6172. // Prevent triggered image.load events from bubbling to window.load
  6173. noBubble: true
  6174. },
  6175. focus: {
  6176. // Fire native event if possible so blur/focus sequence is correct
  6177. trigger: function() {
  6178. if ( this !== safeActiveElement() && this.focus ) {
  6179. this.focus();
  6180. return false;
  6181. }
  6182. },
  6183. delegateType: "focusin"
  6184. },
  6185. blur: {
  6186. trigger: function() {
  6187. if ( this === safeActiveElement() && this.blur ) {
  6188. this.blur();
  6189. return false;
  6190. }
  6191. },
  6192. delegateType: "focusout"
  6193. },
  6194. click: {
  6195. // For checkbox, fire native event so checked state will be right
  6196. trigger: function() {
  6197. if ( this.type === "checkbox" && this.click && nodeName( this, "input" ) ) {
  6198. this.click();
  6199. return false;
  6200. }
  6201. },
  6202. // For cross-browser consistency, don't fire native .click() on links
  6203. _default: function( event ) {
  6204. return nodeName( event.target, "a" );
  6205. }
  6206. },
  6207. beforeunload: {
  6208. postDispatch: function( event ) {
  6209. // Support: Firefox 20+
  6210. // Firefox doesn't alert if the returnValue field is not set.
  6211. if ( event.result !== undefined && event.originalEvent ) {
  6212. event.originalEvent.returnValue = event.result;
  6213. }
  6214. }
  6215. }
  6216. }
  6217. };
  6218. jQuery.removeEvent = function( elem, type, handle ) {
  6219. // This "if" is needed for plain objects
  6220. if ( elem.removeEventListener ) {
  6221. elem.removeEventListener( type, handle );
  6222. }
  6223. };
  6224. jQuery.Event = function( src, props ) {
  6225. // Allow instantiation without the 'new' keyword
  6226. if ( !( this instanceof jQuery.Event ) ) {
  6227. return new jQuery.Event( src, props );
  6228. }
  6229. // Event object
  6230. if ( src && src.type ) {
  6231. this.originalEvent = src;
  6232. this.type = src.type;
  6233. // Events bubbling up the document may have been marked as prevented
  6234. // by a handler lower down the tree; reflect the correct value.
  6235. this.isDefaultPrevented = src.defaultPrevented ||
  6236. src.defaultPrevented === undefined &&
  6237. // Support: Android <=2.3 only
  6238. src.returnValue === false ?
  6239. returnTrue :
  6240. returnFalse;
  6241. // Create target properties
  6242. // Support: Safari <=6 - 7 only
  6243. // Target should not be a text node (#504, #13143)
  6244. this.target = ( src.target && src.target.nodeType === 3 ) ?
  6245. src.target.parentNode :
  6246. src.target;
  6247. this.currentTarget = src.currentTarget;
  6248. this.relatedTarget = src.relatedTarget;
  6249. // Event type
  6250. } else {
  6251. this.type = src;
  6252. }
  6253. // Put explicitly provided properties onto the event object
  6254. if ( props ) {
  6255. jQuery.extend( this, props );
  6256. }
  6257. // Create a timestamp if incoming event doesn't have one
  6258. this.timeStamp = src && src.timeStamp || jQuery.now();
  6259. // Mark it as fixed
  6260. this[ jQuery.expando ] = true;
  6261. };
  6262. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  6263. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  6264. jQuery.Event.prototype = {
  6265. constructor: jQuery.Event,
  6266. isDefaultPrevented: returnFalse,
  6267. isPropagationStopped: returnFalse,
  6268. isImmediatePropagationStopped: returnFalse,
  6269. isSimulated: false,
  6270. preventDefault: function() {
  6271. var e = this.originalEvent;
  6272. this.isDefaultPrevented = returnTrue;
  6273. if ( e && !this.isSimulated ) {
  6274. e.preventDefault();
  6275. }
  6276. },
  6277. stopPropagation: function() {
  6278. var e = this.originalEvent;
  6279. this.isPropagationStopped = returnTrue;
  6280. if ( e && !this.isSimulated ) {
  6281. e.stopPropagation();
  6282. }
  6283. },
  6284. stopImmediatePropagation: function() {
  6285. var e = this.originalEvent;
  6286. this.isImmediatePropagationStopped = returnTrue;
  6287. if ( e && !this.isSimulated ) {
  6288. e.stopImmediatePropagation();
  6289. }
  6290. this.stopPropagation();
  6291. }
  6292. };
  6293. // Includes all common event props including KeyEvent and MouseEvent specific props
  6294. jQuery.each( {
  6295. altKey: true,
  6296. bubbles: true,
  6297. cancelable: true,
  6298. changedTouches: true,
  6299. ctrlKey: true,
  6300. detail: true,
  6301. eventPhase: true,
  6302. metaKey: true,
  6303. pageX: true,
  6304. pageY: true,
  6305. shiftKey: true,
  6306. view: true,
  6307. "char": true,
  6308. charCode: true,
  6309. key: true,
  6310. keyCode: true,
  6311. button: true,
  6312. buttons: true,
  6313. clientX: true,
  6314. clientY: true,
  6315. offsetX: true,
  6316. offsetY: true,
  6317. pointerId: true,
  6318. pointerType: true,
  6319. screenX: true,
  6320. screenY: true,
  6321. targetTouches: true,
  6322. toElement: true,
  6323. touches: true,
  6324. which: function( event ) {
  6325. var button = event.button;
  6326. // Add which for key events
  6327. if ( event.which == null && rkeyEvent.test( event.type ) ) {
  6328. return event.charCode != null ? event.charCode : event.keyCode;
  6329. }
  6330. // Add which for click: 1 === left; 2 === middle; 3 === right
  6331. if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  6332. if ( button & 1 ) {
  6333. return 1;
  6334. }
  6335. if ( button & 2 ) {
  6336. return 3;
  6337. }
  6338. if ( button & 4 ) {
  6339. return 2;
  6340. }
  6341. return 0;
  6342. }
  6343. return event.which;
  6344. }
  6345. }, jQuery.event.addProp );
  6346. // Create mouseenter/leave events using mouseover/out and event-time checks
  6347. // so that event delegation works in jQuery.
  6348. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  6349. //
  6350. // Support: Safari 7 only
  6351. // Safari sends mouseenter too often; see:
  6352. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  6353. // for the description of the bug (it existed in older Chrome versions as well).
  6354. jQuery.each( {
  6355. mouseenter: "mouseover",
  6356. mouseleave: "mouseout",
  6357. pointerenter: "pointerover",
  6358. pointerleave: "pointerout"
  6359. }, function( orig, fix ) {
  6360. jQuery.event.special[ orig ] = {
  6361. delegateType: fix,
  6362. bindType: fix,
  6363. handle: function( event ) {
  6364. var ret,
  6365. target = this,
  6366. related = event.relatedTarget,
  6367. handleObj = event.handleObj;
  6368. // For mouseenter/leave call the handler if related is outside the target.
  6369. // NB: No relatedTarget if the mouse left/entered the browser window
  6370. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  6371. event.type = handleObj.origType;
  6372. ret = handleObj.handler.apply( this, arguments );
  6373. event.type = fix;
  6374. }
  6375. return ret;
  6376. }
  6377. };
  6378. } );
  6379. jQuery.fn.extend( {
  6380. on: function( types, selector, data, fn ) {
  6381. return on( this, types, selector, data, fn );
  6382. },
  6383. one: function( types, selector, data, fn ) {
  6384. return on( this, types, selector, data, fn, 1 );
  6385. },
  6386. off: function( types, selector, fn ) {
  6387. var handleObj, type;
  6388. if ( types && types.preventDefault && types.handleObj ) {
  6389. // ( event ) dispatched jQuery.Event
  6390. handleObj = types.handleObj;
  6391. jQuery( types.delegateTarget ).off(
  6392. handleObj.namespace ?
  6393. handleObj.origType + "." + handleObj.namespace :
  6394. handleObj.origType,
  6395. handleObj.selector,
  6396. handleObj.handler
  6397. );
  6398. return this;
  6399. }
  6400. if ( typeof types === "object" ) {
  6401. // ( types-object [, selector] )
  6402. for ( type in types ) {
  6403. this.off( type, selector, types[ type ] );
  6404. }
  6405. return this;
  6406. }
  6407. if ( selector === false || typeof selector === "function" ) {
  6408. // ( types [, fn] )
  6409. fn = selector;
  6410. selector = undefined;
  6411. }
  6412. if ( fn === false ) {
  6413. fn = returnFalse;
  6414. }
  6415. return this.each( function() {
  6416. jQuery.event.remove( this, types, fn, selector );
  6417. } );
  6418. }
  6419. } );
  6420. var
  6421. /* eslint-disable max-len */
  6422. // See https://github.com/eslint/eslint/issues/3229
  6423. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
  6424. /* eslint-enable */
  6425. // Support: IE <=10 - 11, Edge 12 - 13
  6426. // In IE/Edge using regex groups here causes severe slowdowns.
  6427. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  6428. rnoInnerhtml = /<script|<style|<link/i,
  6429. // checked="checked" or checked
  6430. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  6431. rscriptTypeMasked = /^true\/(.*)/,
  6432. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  6433. // Prefer a tbody over its parent table for containing new rows
  6434. function manipulationTarget( elem, content ) {
  6435. if ( nodeName( elem, "table" ) &&
  6436. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  6437. return jQuery( ">tbody", elem )[ 0 ] || elem;
  6438. }
  6439. return elem;
  6440. }
  6441. // Replace/restore the type attribute of script elements for safe DOM manipulation
  6442. function disableScript( elem ) {
  6443. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  6444. return elem;
  6445. }
  6446. function restoreScript( elem ) {
  6447. var match = rscriptTypeMasked.exec( elem.type );
  6448. if ( match ) {
  6449. elem.type = match[ 1 ];
  6450. } else {
  6451. elem.removeAttribute( "type" );
  6452. }
  6453. return elem;
  6454. }
  6455. function cloneCopyEvent( src, dest ) {
  6456. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  6457. if ( dest.nodeType !== 1 ) {
  6458. return;
  6459. }
  6460. // 1. Copy private data: events, handlers, etc.
  6461. if ( dataPriv.hasData( src ) ) {
  6462. pdataOld = dataPriv.access( src );
  6463. pdataCur = dataPriv.set( dest, pdataOld );
  6464. events = pdataOld.events;
  6465. if ( events ) {
  6466. delete pdataCur.handle;
  6467. pdataCur.events = {};
  6468. for ( type in events ) {
  6469. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  6470. jQuery.event.add( dest, type, events[ type ][ i ] );
  6471. }
  6472. }
  6473. }
  6474. }
  6475. // 2. Copy user data
  6476. if ( dataUser.hasData( src ) ) {
  6477. udataOld = dataUser.access( src );
  6478. udataCur = jQuery.extend( {}, udataOld );
  6479. dataUser.set( dest, udataCur );
  6480. }
  6481. }
  6482. // Fix IE bugs, see support tests
  6483. function fixInput( src, dest ) {
  6484. var nodeName = dest.nodeName.toLowerCase();
  6485. // Fails to persist the checked state of a cloned checkbox or radio button.
  6486. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  6487. dest.checked = src.checked;
  6488. // Fails to return the selected option to the default selected state when cloning options
  6489. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  6490. dest.defaultValue = src.defaultValue;
  6491. }
  6492. }
  6493. function domManip( collection, args, callback, ignored ) {
  6494. // Flatten any nested arrays
  6495. args = concat.apply( [], args );
  6496. var fragment, first, scripts, hasScripts, node, doc,
  6497. i = 0,
  6498. l = collection.length,
  6499. iNoClone = l - 1,
  6500. value = args[ 0 ],
  6501. isFunction = jQuery.isFunction( value );
  6502. // We can't cloneNode fragments that contain checked, in WebKit
  6503. if ( isFunction ||
  6504. ( l > 1 && typeof value === "string" &&
  6505. !support.checkClone && rchecked.test( value ) ) ) {
  6506. return collection.each( function( index ) {
  6507. var self = collection.eq( index );
  6508. if ( isFunction ) {
  6509. args[ 0 ] = value.call( this, index, self.html() );
  6510. }
  6511. domManip( self, args, callback, ignored );
  6512. } );
  6513. }
  6514. if ( l ) {
  6515. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  6516. first = fragment.firstChild;
  6517. if ( fragment.childNodes.length === 1 ) {
  6518. fragment = first;
  6519. }
  6520. // Require either new content or an interest in ignored elements to invoke the callback
  6521. if ( first || ignored ) {
  6522. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  6523. hasScripts = scripts.length;
  6524. // Use the original fragment for the last item
  6525. // instead of the first because it can end up
  6526. // being emptied incorrectly in certain situations (#8070).
  6527. for ( ; i < l; i++ ) {
  6528. node = fragment;
  6529. if ( i !== iNoClone ) {
  6530. node = jQuery.clone( node, true, true );
  6531. // Keep references to cloned scripts for later restoration
  6532. if ( hasScripts ) {
  6533. // Support: Android <=4.0 only, PhantomJS 1 only
  6534. // push.apply(_, arraylike) throws on ancient WebKit
  6535. jQuery.merge( scripts, getAll( node, "script" ) );
  6536. }
  6537. }
  6538. callback.call( collection[ i ], node, i );
  6539. }
  6540. if ( hasScripts ) {
  6541. doc = scripts[ scripts.length - 1 ].ownerDocument;
  6542. // Reenable scripts
  6543. jQuery.map( scripts, restoreScript );
  6544. // Evaluate executable scripts on first document insertion
  6545. for ( i = 0; i < hasScripts; i++ ) {
  6546. node = scripts[ i ];
  6547. if ( rscriptType.test( node.type || "" ) &&
  6548. !dataPriv.access( node, "globalEval" ) &&
  6549. jQuery.contains( doc, node ) ) {
  6550. if ( node.src ) {
  6551. // Optional AJAX dependency, but won't run scripts if not present
  6552. if ( jQuery._evalUrl ) {
  6553. jQuery._evalUrl( node.src );
  6554. }
  6555. } else {
  6556. DOMEval( node.textContent.replace( rcleanScript, "" ), doc );
  6557. }
  6558. }
  6559. }
  6560. }
  6561. }
  6562. }
  6563. return collection;
  6564. }
  6565. function remove( elem, selector, keepData ) {
  6566. var node,
  6567. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  6568. i = 0;
  6569. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  6570. if ( !keepData && node.nodeType === 1 ) {
  6571. jQuery.cleanData( getAll( node ) );
  6572. }
  6573. if ( node.parentNode ) {
  6574. if ( keepData && jQuery.contains( node.ownerDocument, node ) ) {
  6575. setGlobalEval( getAll( node, "script" ) );
  6576. }
  6577. node.parentNode.removeChild( node );
  6578. }
  6579. }
  6580. return elem;
  6581. }
  6582. jQuery.extend( {
  6583. htmlPrefilter: function( html ) {
  6584. return html.replace( rxhtmlTag, "<$1></$2>" );
  6585. },
  6586. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  6587. var i, l, srcElements, destElements,
  6588. clone = elem.cloneNode( true ),
  6589. inPage = jQuery.contains( elem.ownerDocument, elem );
  6590. // Fix IE cloning issues
  6591. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  6592. !jQuery.isXMLDoc( elem ) ) {
  6593. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  6594. destElements = getAll( clone );
  6595. srcElements = getAll( elem );
  6596. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  6597. fixInput( srcElements[ i ], destElements[ i ] );
  6598. }
  6599. }
  6600. // Copy the events from the original to the clone
  6601. if ( dataAndEvents ) {
  6602. if ( deepDataAndEvents ) {
  6603. srcElements = srcElements || getAll( elem );
  6604. destElements = destElements || getAll( clone );
  6605. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  6606. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  6607. }
  6608. } else {
  6609. cloneCopyEvent( elem, clone );
  6610. }
  6611. }
  6612. // Preserve script evaluation history
  6613. destElements = getAll( clone, "script" );
  6614. if ( destElements.length > 0 ) {
  6615. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  6616. }
  6617. // Return the cloned set
  6618. return clone;
  6619. },
  6620. cleanData: function( elems ) {
  6621. var data, elem, type,
  6622. special = jQuery.event.special,
  6623. i = 0;
  6624. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  6625. if ( acceptData( elem ) ) {
  6626. if ( ( data = elem[ dataPriv.expando ] ) ) {
  6627. if ( data.events ) {
  6628. for ( type in data.events ) {
  6629. if ( special[ type ] ) {
  6630. jQuery.event.remove( elem, type );
  6631. // This is a shortcut to avoid jQuery.event.remove's overhead
  6632. } else {
  6633. jQuery.removeEvent( elem, type, data.handle );
  6634. }
  6635. }
  6636. }
  6637. // Support: Chrome <=35 - 45+
  6638. // Assign undefined instead of using delete, see Data#remove
  6639. elem[ dataPriv.expando ] = undefined;
  6640. }
  6641. if ( elem[ dataUser.expando ] ) {
  6642. // Support: Chrome <=35 - 45+
  6643. // Assign undefined instead of using delete, see Data#remove
  6644. elem[ dataUser.expando ] = undefined;
  6645. }
  6646. }
  6647. }
  6648. }
  6649. } );
  6650. jQuery.fn.extend( {
  6651. detach: function( selector ) {
  6652. return remove( this, selector, true );
  6653. },
  6654. remove: function( selector ) {
  6655. return remove( this, selector );
  6656. },
  6657. text: function( value ) {
  6658. return access( this, function( value ) {
  6659. return value === undefined ?
  6660. jQuery.text( this ) :
  6661. this.empty().each( function() {
  6662. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  6663. this.textContent = value;
  6664. }
  6665. } );
  6666. }, null, value, arguments.length );
  6667. },
  6668. append: function() {
  6669. return domManip( this, arguments, function( elem ) {
  6670. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  6671. var target = manipulationTarget( this, elem );
  6672. target.appendChild( elem );
  6673. }
  6674. } );
  6675. },
  6676. prepend: function() {
  6677. return domManip( this, arguments, function( elem ) {
  6678. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  6679. var target = manipulationTarget( this, elem );
  6680. target.insertBefore( elem, target.firstChild );
  6681. }
  6682. } );
  6683. },
  6684. before: function() {
  6685. return domManip( this, arguments, function( elem ) {
  6686. if ( this.parentNode ) {
  6687. this.parentNode.insertBefore( elem, this );
  6688. }
  6689. } );
  6690. },
  6691. after: function() {
  6692. return domManip( this, arguments, function( elem ) {
  6693. if ( this.parentNode ) {
  6694. this.parentNode.insertBefore( elem, this.nextSibling );
  6695. }
  6696. } );
  6697. },
  6698. empty: function() {
  6699. var elem,
  6700. i = 0;
  6701. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  6702. if ( elem.nodeType === 1 ) {
  6703. // Prevent memory leaks
  6704. jQuery.cleanData( getAll( elem, false ) );
  6705. // Remove any remaining nodes
  6706. elem.textContent = "";
  6707. }
  6708. }
  6709. return this;
  6710. },
  6711. clone: function( dataAndEvents, deepDataAndEvents ) {
  6712. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  6713. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  6714. return this.map( function() {
  6715. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  6716. } );
  6717. },
  6718. html: function( value ) {
  6719. return access( this, function( value ) {
  6720. var elem = this[ 0 ] || {},
  6721. i = 0,
  6722. l = this.length;
  6723. if ( value === undefined && elem.nodeType === 1 ) {
  6724. return elem.innerHTML;
  6725. }
  6726. // See if we can take a shortcut and just use innerHTML
  6727. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  6728. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  6729. value = jQuery.htmlPrefilter( value );
  6730. try {
  6731. for ( ; i < l; i++ ) {
  6732. elem = this[ i ] || {};
  6733. // Remove element nodes and prevent memory leaks
  6734. if ( elem.nodeType === 1 ) {
  6735. jQuery.cleanData( getAll( elem, false ) );
  6736. elem.innerHTML = value;
  6737. }
  6738. }
  6739. elem = 0;
  6740. // If using innerHTML throws an exception, use the fallback method
  6741. } catch ( e ) {}
  6742. }
  6743. if ( elem ) {
  6744. this.empty().append( value );
  6745. }
  6746. }, null, value, arguments.length );
  6747. },
  6748. replaceWith: function() {
  6749. var ignored = [];
  6750. // Make the changes, replacing each non-ignored context element with the new content
  6751. return domManip( this, arguments, function( elem ) {
  6752. var parent = this.parentNode;
  6753. if ( jQuery.inArray( this, ignored ) < 0 ) {
  6754. jQuery.cleanData( getAll( this ) );
  6755. if ( parent ) {
  6756. parent.replaceChild( elem, this );
  6757. }
  6758. }
  6759. // Force callback invocation
  6760. }, ignored );
  6761. }
  6762. } );
  6763. jQuery.each( {
  6764. appendTo: "append",
  6765. prependTo: "prepend",
  6766. insertBefore: "before",
  6767. insertAfter: "after",
  6768. replaceAll: "replaceWith"
  6769. }, function( name, original ) {
  6770. jQuery.fn[ name ] = function( selector ) {
  6771. var elems,
  6772. ret = [],
  6773. insert = jQuery( selector ),
  6774. last = insert.length - 1,
  6775. i = 0;
  6776. for ( ; i <= last; i++ ) {
  6777. elems = i === last ? this : this.clone( true );
  6778. jQuery( insert[ i ] )[ original ]( elems );
  6779. // Support: Android <=4.0 only, PhantomJS 1 only
  6780. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  6781. push.apply( ret, elems.get() );
  6782. }
  6783. return this.pushStack( ret );
  6784. };
  6785. } );
  6786. var rmargin = ( /^margin/ );
  6787. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  6788. var getStyles = function( elem ) {
  6789. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  6790. // IE throws on elements created in popups
  6791. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  6792. var view = elem.ownerDocument.defaultView;
  6793. if ( !view || !view.opener ) {
  6794. view = window;
  6795. }
  6796. return view.getComputedStyle( elem );
  6797. };
  6798. ( function() {
  6799. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  6800. // so they're executed at the same time to save the second computation.
  6801. function computeStyleTests() {
  6802. // This is a singleton, we need to execute it only once
  6803. if ( !div ) {
  6804. return;
  6805. }
  6806. div.style.cssText =
  6807. "box-sizing:border-box;" +
  6808. "position:relative;display:block;" +
  6809. "margin:auto;border:1px;padding:1px;" +
  6810. "top:1%;width:50%";
  6811. div.innerHTML = "";
  6812. documentElement.appendChild( container );
  6813. var divStyle = window.getComputedStyle( div );
  6814. pixelPositionVal = divStyle.top !== "1%";
  6815. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  6816. reliableMarginLeftVal = divStyle.marginLeft === "2px";
  6817. boxSizingReliableVal = divStyle.width === "4px";
  6818. // Support: Android 4.0 - 4.3 only
  6819. // Some styles come back with percentage values, even though they shouldn't
  6820. div.style.marginRight = "50%";
  6821. pixelMarginRightVal = divStyle.marginRight === "4px";
  6822. documentElement.removeChild( container );
  6823. // Nullify the div so it wouldn't be stored in the memory and
  6824. // it will also be a sign that checks already performed
  6825. div = null;
  6826. }
  6827. var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, reliableMarginLeftVal,
  6828. container = document.createElement( "div" ),
  6829. div = document.createElement( "div" );
  6830. // Finish early in limited (non-browser) environments
  6831. if ( !div.style ) {
  6832. return;
  6833. }
  6834. // Support: IE <=9 - 11 only
  6835. // Style of cloned element affects source element cloned (#8908)
  6836. div.style.backgroundClip = "content-box";
  6837. div.cloneNode( true ).style.backgroundClip = "";
  6838. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  6839. container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" +
  6840. "padding:0;margin-top:1px;position:absolute";
  6841. container.appendChild( div );
  6842. jQuery.extend( support, {
  6843. pixelPosition: function() {
  6844. computeStyleTests();
  6845. return pixelPositionVal;
  6846. },
  6847. boxSizingReliable: function() {
  6848. computeStyleTests();
  6849. return boxSizingReliableVal;
  6850. },
  6851. pixelMarginRight: function() {
  6852. computeStyleTests();
  6853. return pixelMarginRightVal;
  6854. },
  6855. reliableMarginLeft: function() {
  6856. computeStyleTests();
  6857. return reliableMarginLeftVal;
  6858. }
  6859. } );
  6860. } )();
  6861. function curCSS( elem, name, computed ) {
  6862. var width, minWidth, maxWidth, ret,
  6863. // Support: Firefox 51+
  6864. // Retrieving style before computed somehow
  6865. // fixes an issue with getting wrong values
  6866. // on detached elements
  6867. style = elem.style;
  6868. computed = computed || getStyles( elem );
  6869. // getPropertyValue is needed for:
  6870. // .css('filter') (IE 9 only, #12537)
  6871. // .css('--customProperty) (#3144)
  6872. if ( computed ) {
  6873. ret = computed.getPropertyValue( name ) || computed[ name ];
  6874. if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
  6875. ret = jQuery.style( elem, name );
  6876. }
  6877. // A tribute to the "awesome hack by Dean Edwards"
  6878. // Android Browser returns percentage for some values,
  6879. // but width seems to be reliably pixels.
  6880. // This is against the CSSOM draft spec:
  6881. // https://drafts.csswg.org/cssom/#resolved-values
  6882. if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) {
  6883. // Remember the original values
  6884. width = style.width;
  6885. minWidth = style.minWidth;
  6886. maxWidth = style.maxWidth;
  6887. // Put in the new values to get a computed value out
  6888. style.minWidth = style.maxWidth = style.width = ret;
  6889. ret = computed.width;
  6890. // Revert the changed values
  6891. style.width = width;
  6892. style.minWidth = minWidth;
  6893. style.maxWidth = maxWidth;
  6894. }
  6895. }
  6896. return ret !== undefined ?
  6897. // Support: IE <=9 - 11 only
  6898. // IE returns zIndex value as an integer.
  6899. ret + "" :
  6900. ret;
  6901. }
  6902. function addGetHookIf( conditionFn, hookFn ) {
  6903. // Define the hook, we'll check on the first run if it's really needed.
  6904. return {
  6905. get: function() {
  6906. if ( conditionFn() ) {
  6907. // Hook not needed (or it's not possible to use it due
  6908. // to missing dependency), remove it.
  6909. delete this.get;
  6910. return;
  6911. }
  6912. // Hook needed; redefine it so that the support test is not executed again.
  6913. return ( this.get = hookFn ).apply( this, arguments );
  6914. }
  6915. };
  6916. }
  6917. var
  6918. // Swappable if display is none or starts with table
  6919. // except "table", "table-cell", or "table-caption"
  6920. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  6921. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  6922. rcustomProp = /^--/,
  6923. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  6924. cssNormalTransform = {
  6925. letterSpacing: "0",
  6926. fontWeight: "400"
  6927. },
  6928. cssPrefixes = [ "Webkit", "Moz", "ms" ],
  6929. emptyStyle = document.createElement( "div" ).style;
  6930. // Return a css property mapped to a potentially vendor prefixed property
  6931. function vendorPropName( name ) {
  6932. // Shortcut for names that are not vendor prefixed
  6933. if ( name in emptyStyle ) {
  6934. return name;
  6935. }
  6936. // Check for vendor prefixed names
  6937. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  6938. i = cssPrefixes.length;
  6939. while ( i-- ) {
  6940. name = cssPrefixes[ i ] + capName;
  6941. if ( name in emptyStyle ) {
  6942. return name;
  6943. }
  6944. }
  6945. }
  6946. // Return a property mapped along what jQuery.cssProps suggests or to
  6947. // a vendor prefixed property.
  6948. function finalPropName( name ) {
  6949. var ret = jQuery.cssProps[ name ];
  6950. if ( !ret ) {
  6951. ret = jQuery.cssProps[ name ] = vendorPropName( name ) || name;
  6952. }
  6953. return ret;
  6954. }
  6955. function setPositiveNumber( elem, value, subtract ) {
  6956. // Any relative (+/-) values have already been
  6957. // normalized at this point
  6958. var matches = rcssNum.exec( value );
  6959. return matches ?
  6960. // Guard against undefined "subtract", e.g., when used as in cssHooks
  6961. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  6962. value;
  6963. }
  6964. function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
  6965. var i,
  6966. val = 0;
  6967. // If we already have the right measurement, avoid augmentation
  6968. if ( extra === ( isBorderBox ? "border" : "content" ) ) {
  6969. i = 4;
  6970. // Otherwise initialize for horizontal or vertical properties
  6971. } else {
  6972. i = name === "width" ? 1 : 0;
  6973. }
  6974. for ( ; i < 4; i += 2 ) {
  6975. // Both box models exclude margin, so add it if we want it
  6976. if ( extra === "margin" ) {
  6977. val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
  6978. }
  6979. if ( isBorderBox ) {
  6980. // border-box includes padding, so remove it if we want content
  6981. if ( extra === "content" ) {
  6982. val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  6983. }
  6984. // At this point, extra isn't border nor margin, so remove border
  6985. if ( extra !== "margin" ) {
  6986. val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  6987. }
  6988. } else {
  6989. // At this point, extra isn't content, so add padding
  6990. val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  6991. // At this point, extra isn't content nor padding, so add border
  6992. if ( extra !== "padding" ) {
  6993. val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  6994. }
  6995. }
  6996. }
  6997. return val;
  6998. }
  6999. function getWidthOrHeight( elem, name, extra ) {
  7000. // Start with computed style
  7001. var valueIsBorderBox,
  7002. styles = getStyles( elem ),
  7003. val = curCSS( elem, name, styles ),
  7004. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  7005. // Computed unit is not pixels. Stop here and return.
  7006. if ( rnumnonpx.test( val ) ) {
  7007. return val;
  7008. }
  7009. // Check for style in case a browser which returns unreliable values
  7010. // for getComputedStyle silently falls back to the reliable elem.style
  7011. valueIsBorderBox = isBorderBox &&
  7012. ( support.boxSizingReliable() || val === elem.style[ name ] );
  7013. // Fall back to offsetWidth/Height when value is "auto"
  7014. // This happens for inline elements with no explicit setting (gh-3571)
  7015. if ( val === "auto" ) {
  7016. val = elem[ "offset" + name[ 0 ].toUpperCase() + name.slice( 1 ) ];
  7017. }
  7018. // Normalize "", auto, and prepare for extra
  7019. val = parseFloat( val ) || 0;
  7020. // Use the active box-sizing model to add/subtract irrelevant styles
  7021. return ( val +
  7022. augmentWidthOrHeight(
  7023. elem,
  7024. name,
  7025. extra || ( isBorderBox ? "border" : "content" ),
  7026. valueIsBorderBox,
  7027. styles
  7028. )
  7029. ) + "px";
  7030. }
  7031. jQuery.extend( {
  7032. // Add in style property hooks for overriding the default
  7033. // behavior of getting and setting a style property
  7034. cssHooks: {
  7035. opacity: {
  7036. get: function( elem, computed ) {
  7037. if ( computed ) {
  7038. // We should always get a number back from opacity
  7039. var ret = curCSS( elem, "opacity" );
  7040. return ret === "" ? "1" : ret;
  7041. }
  7042. }
  7043. }
  7044. },
  7045. // Don't automatically add "px" to these possibly-unitless properties
  7046. cssNumber: {
  7047. "animationIterationCount": true,
  7048. "columnCount": true,
  7049. "fillOpacity": true,
  7050. "flexGrow": true,
  7051. "flexShrink": true,
  7052. "fontWeight": true,
  7053. "lineHeight": true,
  7054. "opacity": true,
  7055. "order": true,
  7056. "orphans": true,
  7057. "widows": true,
  7058. "zIndex": true,
  7059. "zoom": true
  7060. },
  7061. // Add in properties whose names you wish to fix before
  7062. // setting or getting the value
  7063. cssProps: {
  7064. "float": "cssFloat"
  7065. },
  7066. // Get and set the style property on a DOM Node
  7067. style: function( elem, name, value, extra ) {
  7068. // Don't set styles on text and comment nodes
  7069. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  7070. return;
  7071. }
  7072. // Make sure that we're working with the right name
  7073. var ret, type, hooks,
  7074. origName = jQuery.camelCase( name ),
  7075. isCustomProp = rcustomProp.test( name ),
  7076. style = elem.style;
  7077. // Make sure that we're working with the right name. We don't
  7078. // want to query the value if it is a CSS custom property
  7079. // since they are user-defined.
  7080. if ( !isCustomProp ) {
  7081. name = finalPropName( origName );
  7082. }
  7083. // Gets hook for the prefixed version, then unprefixed version
  7084. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  7085. // Check if we're setting a value
  7086. if ( value !== undefined ) {
  7087. type = typeof value;
  7088. // Convert "+=" or "-=" to relative numbers (#7345)
  7089. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  7090. value = adjustCSS( elem, name, ret );
  7091. // Fixes bug #9237
  7092. type = "number";
  7093. }
  7094. // Make sure that null and NaN values aren't set (#7116)
  7095. if ( value == null || value !== value ) {
  7096. return;
  7097. }
  7098. // If a number was passed in, add the unit (except for certain CSS properties)
  7099. if ( type === "number" ) {
  7100. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  7101. }
  7102. // background-* props affect original clone's values
  7103. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  7104. style[ name ] = "inherit";
  7105. }
  7106. // If a hook was provided, use that value, otherwise just set the specified value
  7107. if ( !hooks || !( "set" in hooks ) ||
  7108. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  7109. if ( isCustomProp ) {
  7110. style.setProperty( name, value );
  7111. } else {
  7112. style[ name ] = value;
  7113. }
  7114. }
  7115. } else {
  7116. // If a hook was provided get the non-computed value from there
  7117. if ( hooks && "get" in hooks &&
  7118. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  7119. return ret;
  7120. }
  7121. // Otherwise just get the value from the style object
  7122. return style[ name ];
  7123. }
  7124. },
  7125. css: function( elem, name, extra, styles ) {
  7126. var val, num, hooks,
  7127. origName = jQuery.camelCase( name ),
  7128. isCustomProp = rcustomProp.test( name );
  7129. // Make sure that we're working with the right name. We don't
  7130. // want to modify the value if it is a CSS custom property
  7131. // since they are user-defined.
  7132. if ( !isCustomProp ) {
  7133. name = finalPropName( origName );
  7134. }
  7135. // Try prefixed name followed by the unprefixed name
  7136. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  7137. // If a hook was provided get the computed value from there
  7138. if ( hooks && "get" in hooks ) {
  7139. val = hooks.get( elem, true, extra );
  7140. }
  7141. // Otherwise, if a way to get the computed value exists, use that
  7142. if ( val === undefined ) {
  7143. val = curCSS( elem, name, styles );
  7144. }
  7145. // Convert "normal" to computed value
  7146. if ( val === "normal" && name in cssNormalTransform ) {
  7147. val = cssNormalTransform[ name ];
  7148. }
  7149. // Make numeric if forced or a qualifier was provided and val looks numeric
  7150. if ( extra === "" || extra ) {
  7151. num = parseFloat( val );
  7152. return extra === true || isFinite( num ) ? num || 0 : val;
  7153. }
  7154. return val;
  7155. }
  7156. } );
  7157. jQuery.each( [ "height", "width" ], function( i, name ) {
  7158. jQuery.cssHooks[ name ] = {
  7159. get: function( elem, computed, extra ) {
  7160. if ( computed ) {
  7161. // Certain elements can have dimension info if we invisibly show them
  7162. // but it must have a current display style that would benefit
  7163. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  7164. // Support: Safari 8+
  7165. // Table columns in Safari have non-zero offsetWidth & zero
  7166. // getBoundingClientRect().width unless display is changed.
  7167. // Support: IE <=11 only
  7168. // Running getBoundingClientRect on a disconnected node
  7169. // in IE throws an error.
  7170. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  7171. swap( elem, cssShow, function() {
  7172. return getWidthOrHeight( elem, name, extra );
  7173. } ) :
  7174. getWidthOrHeight( elem, name, extra );
  7175. }
  7176. },
  7177. set: function( elem, value, extra ) {
  7178. var matches,
  7179. styles = extra && getStyles( elem ),
  7180. subtract = extra && augmentWidthOrHeight(
  7181. elem,
  7182. name,
  7183. extra,
  7184. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  7185. styles
  7186. );
  7187. // Convert to pixels if value adjustment is needed
  7188. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  7189. ( matches[ 3 ] || "px" ) !== "px" ) {
  7190. elem.style[ name ] = value;
  7191. value = jQuery.css( elem, name );
  7192. }
  7193. return setPositiveNumber( elem, value, subtract );
  7194. }
  7195. };
  7196. } );
  7197. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  7198. function( elem, computed ) {
  7199. if ( computed ) {
  7200. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  7201. elem.getBoundingClientRect().left -
  7202. swap( elem, { marginLeft: 0 }, function() {
  7203. return elem.getBoundingClientRect().left;
  7204. } )
  7205. ) + "px";
  7206. }
  7207. }
  7208. );
  7209. // These hooks are used by animate to expand properties
  7210. jQuery.each( {
  7211. margin: "",
  7212. padding: "",
  7213. border: "Width"
  7214. }, function( prefix, suffix ) {
  7215. jQuery.cssHooks[ prefix + suffix ] = {
  7216. expand: function( value ) {
  7217. var i = 0,
  7218. expanded = {},
  7219. // Assumes a single number if not a string
  7220. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  7221. for ( ; i < 4; i++ ) {
  7222. expanded[ prefix + cssExpand[ i ] + suffix ] =
  7223. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  7224. }
  7225. return expanded;
  7226. }
  7227. };
  7228. if ( !rmargin.test( prefix ) ) {
  7229. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  7230. }
  7231. } );
  7232. jQuery.fn.extend( {
  7233. css: function( name, value ) {
  7234. return access( this, function( elem, name, value ) {
  7235. var styles, len,
  7236. map = {},
  7237. i = 0;
  7238. if ( Array.isArray( name ) ) {
  7239. styles = getStyles( elem );
  7240. len = name.length;
  7241. for ( ; i < len; i++ ) {
  7242. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  7243. }
  7244. return map;
  7245. }
  7246. return value !== undefined ?
  7247. jQuery.style( elem, name, value ) :
  7248. jQuery.css( elem, name );
  7249. }, name, value, arguments.length > 1 );
  7250. }
  7251. } );
  7252. function Tween( elem, options, prop, end, easing ) {
  7253. return new Tween.prototype.init( elem, options, prop, end, easing );
  7254. }
  7255. jQuery.Tween = Tween;
  7256. Tween.prototype = {
  7257. constructor: Tween,
  7258. init: function( elem, options, prop, end, easing, unit ) {
  7259. this.elem = elem;
  7260. this.prop = prop;
  7261. this.easing = easing || jQuery.easing._default;
  7262. this.options = options;
  7263. this.start = this.now = this.cur();
  7264. this.end = end;
  7265. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  7266. },
  7267. cur: function() {
  7268. var hooks = Tween.propHooks[ this.prop ];
  7269. return hooks && hooks.get ?
  7270. hooks.get( this ) :
  7271. Tween.propHooks._default.get( this );
  7272. },
  7273. run: function( percent ) {
  7274. var eased,
  7275. hooks = Tween.propHooks[ this.prop ];
  7276. if ( this.options.duration ) {
  7277. this.pos = eased = jQuery.easing[ this.easing ](
  7278. percent, this.options.duration * percent, 0, 1, this.options.duration
  7279. );
  7280. } else {
  7281. this.pos = eased = percent;
  7282. }
  7283. this.now = ( this.end - this.start ) * eased + this.start;
  7284. if ( this.options.step ) {
  7285. this.options.step.call( this.elem, this.now, this );
  7286. }
  7287. if ( hooks && hooks.set ) {
  7288. hooks.set( this );
  7289. } else {
  7290. Tween.propHooks._default.set( this );
  7291. }
  7292. return this;
  7293. }
  7294. };
  7295. Tween.prototype.init.prototype = Tween.prototype;
  7296. Tween.propHooks = {
  7297. _default: {
  7298. get: function( tween ) {
  7299. var result;
  7300. // Use a property on the element directly when it is not a DOM element,
  7301. // or when there is no matching style property that exists.
  7302. if ( tween.elem.nodeType !== 1 ||
  7303. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  7304. return tween.elem[ tween.prop ];
  7305. }
  7306. // Passing an empty string as a 3rd parameter to .css will automatically
  7307. // attempt a parseFloat and fallback to a string if the parse fails.
  7308. // Simple values such as "10px" are parsed to Float;
  7309. // complex values such as "rotate(1rad)" are returned as-is.
  7310. result = jQuery.css( tween.elem, tween.prop, "" );
  7311. // Empty strings, null, undefined and "auto" are converted to 0.
  7312. return !result || result === "auto" ? 0 : result;
  7313. },
  7314. set: function( tween ) {
  7315. // Use step hook for back compat.
  7316. // Use cssHook if its there.
  7317. // Use .style if available and use plain properties where available.
  7318. if ( jQuery.fx.step[ tween.prop ] ) {
  7319. jQuery.fx.step[ tween.prop ]( tween );
  7320. } else if ( tween.elem.nodeType === 1 &&
  7321. ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null ||
  7322. jQuery.cssHooks[ tween.prop ] ) ) {
  7323. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  7324. } else {
  7325. tween.elem[ tween.prop ] = tween.now;
  7326. }
  7327. }
  7328. }
  7329. };
  7330. // Support: IE <=9 only
  7331. // Panic based approach to setting things on disconnected nodes
  7332. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  7333. set: function( tween ) {
  7334. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  7335. tween.elem[ tween.prop ] = tween.now;
  7336. }
  7337. }
  7338. };
  7339. jQuery.easing = {
  7340. linear: function( p ) {
  7341. return p;
  7342. },
  7343. swing: function( p ) {
  7344. return 0.5 - Math.cos( p * Math.PI ) / 2;
  7345. },
  7346. _default: "swing"
  7347. };
  7348. jQuery.fx = Tween.prototype.init;
  7349. // Back compat <1.8 extension point
  7350. jQuery.fx.step = {};
  7351. var
  7352. fxNow, inProgress,
  7353. rfxtypes = /^(?:toggle|show|hide)$/,
  7354. rrun = /queueHooks$/;
  7355. function schedule() {
  7356. if ( inProgress ) {
  7357. if ( document.hidden === false && window.requestAnimationFrame ) {
  7358. window.requestAnimationFrame( schedule );
  7359. } else {
  7360. window.setTimeout( schedule, jQuery.fx.interval );
  7361. }
  7362. jQuery.fx.tick();
  7363. }
  7364. }
  7365. // Animations created synchronously will run synchronously
  7366. function createFxNow() {
  7367. window.setTimeout( function() {
  7368. fxNow = undefined;
  7369. } );
  7370. return ( fxNow = jQuery.now() );
  7371. }
  7372. // Generate parameters to create a standard animation
  7373. function genFx( type, includeWidth ) {
  7374. var which,
  7375. i = 0,
  7376. attrs = { height: type };
  7377. // If we include width, step value is 1 to do all cssExpand values,
  7378. // otherwise step value is 2 to skip over Left and Right
  7379. includeWidth = includeWidth ? 1 : 0;
  7380. for ( ; i < 4; i += 2 - includeWidth ) {
  7381. which = cssExpand[ i ];
  7382. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  7383. }
  7384. if ( includeWidth ) {
  7385. attrs.opacity = attrs.width = type;
  7386. }
  7387. return attrs;
  7388. }
  7389. function createTween( value, prop, animation ) {
  7390. var tween,
  7391. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  7392. index = 0,
  7393. length = collection.length;
  7394. for ( ; index < length; index++ ) {
  7395. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  7396. // We're done with this property
  7397. return tween;
  7398. }
  7399. }
  7400. }
  7401. function defaultPrefilter( elem, props, opts ) {
  7402. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  7403. isBox = "width" in props || "height" in props,
  7404. anim = this,
  7405. orig = {},
  7406. style = elem.style,
  7407. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  7408. dataShow = dataPriv.get( elem, "fxshow" );
  7409. // Queue-skipping animations hijack the fx hooks
  7410. if ( !opts.queue ) {
  7411. hooks = jQuery._queueHooks( elem, "fx" );
  7412. if ( hooks.unqueued == null ) {
  7413. hooks.unqueued = 0;
  7414. oldfire = hooks.empty.fire;
  7415. hooks.empty.fire = function() {
  7416. if ( !hooks.unqueued ) {
  7417. oldfire();
  7418. }
  7419. };
  7420. }
  7421. hooks.unqueued++;
  7422. anim.always( function() {
  7423. // Ensure the complete handler is called before this completes
  7424. anim.always( function() {
  7425. hooks.unqueued--;
  7426. if ( !jQuery.queue( elem, "fx" ).length ) {
  7427. hooks.empty.fire();
  7428. }
  7429. } );
  7430. } );
  7431. }
  7432. // Detect show/hide animations
  7433. for ( prop in props ) {
  7434. value = props[ prop ];
  7435. if ( rfxtypes.test( value ) ) {
  7436. delete props[ prop ];
  7437. toggle = toggle || value === "toggle";
  7438. if ( value === ( hidden ? "hide" : "show" ) ) {
  7439. // Pretend to be hidden if this is a "show" and
  7440. // there is still data from a stopped show/hide
  7441. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  7442. hidden = true;
  7443. // Ignore all other no-op show/hide data
  7444. } else {
  7445. continue;
  7446. }
  7447. }
  7448. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  7449. }
  7450. }
  7451. // Bail out if this is a no-op like .hide().hide()
  7452. propTween = !jQuery.isEmptyObject( props );
  7453. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  7454. return;
  7455. }
  7456. // Restrict "overflow" and "display" styles during box animations
  7457. if ( isBox && elem.nodeType === 1 ) {
  7458. // Support: IE <=9 - 11, Edge 12 - 13
  7459. // Record all 3 overflow attributes because IE does not infer the shorthand
  7460. // from identically-valued overflowX and overflowY
  7461. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  7462. // Identify a display type, preferring old show/hide data over the CSS cascade
  7463. restoreDisplay = dataShow && dataShow.display;
  7464. if ( restoreDisplay == null ) {
  7465. restoreDisplay = dataPriv.get( elem, "display" );
  7466. }
  7467. display = jQuery.css( elem, "display" );
  7468. if ( display === "none" ) {
  7469. if ( restoreDisplay ) {
  7470. display = restoreDisplay;
  7471. } else {
  7472. // Get nonempty value(s) by temporarily forcing visibility
  7473. showHide( [ elem ], true );
  7474. restoreDisplay = elem.style.display || restoreDisplay;
  7475. display = jQuery.css( elem, "display" );
  7476. showHide( [ elem ] );
  7477. }
  7478. }
  7479. // Animate inline elements as inline-block
  7480. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  7481. if ( jQuery.css( elem, "float" ) === "none" ) {
  7482. // Restore the original display value at the end of pure show/hide animations
  7483. if ( !propTween ) {
  7484. anim.done( function() {
  7485. style.display = restoreDisplay;
  7486. } );
  7487. if ( restoreDisplay == null ) {
  7488. display = style.display;
  7489. restoreDisplay = display === "none" ? "" : display;
  7490. }
  7491. }
  7492. style.display = "inline-block";
  7493. }
  7494. }
  7495. }
  7496. if ( opts.overflow ) {
  7497. style.overflow = "hidden";
  7498. anim.always( function() {
  7499. style.overflow = opts.overflow[ 0 ];
  7500. style.overflowX = opts.overflow[ 1 ];
  7501. style.overflowY = opts.overflow[ 2 ];
  7502. } );
  7503. }
  7504. // Implement show/hide animations
  7505. propTween = false;
  7506. for ( prop in orig ) {
  7507. // General show/hide setup for this element animation
  7508. if ( !propTween ) {
  7509. if ( dataShow ) {
  7510. if ( "hidden" in dataShow ) {
  7511. hidden = dataShow.hidden;
  7512. }
  7513. } else {
  7514. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  7515. }
  7516. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  7517. if ( toggle ) {
  7518. dataShow.hidden = !hidden;
  7519. }
  7520. // Show elements before animating them
  7521. if ( hidden ) {
  7522. showHide( [ elem ], true );
  7523. }
  7524. /* eslint-disable no-loop-func */
  7525. anim.done( function() {
  7526. /* eslint-enable no-loop-func */
  7527. // The final step of a "hide" animation is actually hiding the element
  7528. if ( !hidden ) {
  7529. showHide( [ elem ] );
  7530. }
  7531. dataPriv.remove( elem, "fxshow" );
  7532. for ( prop in orig ) {
  7533. jQuery.style( elem, prop, orig[ prop ] );
  7534. }
  7535. } );
  7536. }
  7537. // Per-property setup
  7538. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  7539. if ( !( prop in dataShow ) ) {
  7540. dataShow[ prop ] = propTween.start;
  7541. if ( hidden ) {
  7542. propTween.end = propTween.start;
  7543. propTween.start = 0;
  7544. }
  7545. }
  7546. }
  7547. }
  7548. function propFilter( props, specialEasing ) {
  7549. var index, name, easing, value, hooks;
  7550. // camelCase, specialEasing and expand cssHook pass
  7551. for ( index in props ) {
  7552. name = jQuery.camelCase( index );
  7553. easing = specialEasing[ name ];
  7554. value = props[ index ];
  7555. if ( Array.isArray( value ) ) {
  7556. easing = value[ 1 ];
  7557. value = props[ index ] = value[ 0 ];
  7558. }
  7559. if ( index !== name ) {
  7560. props[ name ] = value;
  7561. delete props[ index ];
  7562. }
  7563. hooks = jQuery.cssHooks[ name ];
  7564. if ( hooks && "expand" in hooks ) {
  7565. value = hooks.expand( value );
  7566. delete props[ name ];
  7567. // Not quite $.extend, this won't overwrite existing keys.
  7568. // Reusing 'index' because we have the correct "name"
  7569. for ( index in value ) {
  7570. if ( !( index in props ) ) {
  7571. props[ index ] = value[ index ];
  7572. specialEasing[ index ] = easing;
  7573. }
  7574. }
  7575. } else {
  7576. specialEasing[ name ] = easing;
  7577. }
  7578. }
  7579. }
  7580. function Animation( elem, properties, options ) {
  7581. var result,
  7582. stopped,
  7583. index = 0,
  7584. length = Animation.prefilters.length,
  7585. deferred = jQuery.Deferred().always( function() {
  7586. // Don't match elem in the :animated selector
  7587. delete tick.elem;
  7588. } ),
  7589. tick = function() {
  7590. if ( stopped ) {
  7591. return false;
  7592. }
  7593. var currentTime = fxNow || createFxNow(),
  7594. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  7595. // Support: Android 2.3 only
  7596. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  7597. temp = remaining / animation.duration || 0,
  7598. percent = 1 - temp,
  7599. index = 0,
  7600. length = animation.tweens.length;
  7601. for ( ; index < length; index++ ) {
  7602. animation.tweens[ index ].run( percent );
  7603. }
  7604. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  7605. // If there's more to do, yield
  7606. if ( percent < 1 && length ) {
  7607. return remaining;
  7608. }
  7609. // If this was an empty animation, synthesize a final progress notification
  7610. if ( !length ) {
  7611. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  7612. }
  7613. // Resolve the animation and report its conclusion
  7614. deferred.resolveWith( elem, [ animation ] );
  7615. return false;
  7616. },
  7617. animation = deferred.promise( {
  7618. elem: elem,
  7619. props: jQuery.extend( {}, properties ),
  7620. opts: jQuery.extend( true, {
  7621. specialEasing: {},
  7622. easing: jQuery.easing._default
  7623. }, options ),
  7624. originalProperties: properties,
  7625. originalOptions: options,
  7626. startTime: fxNow || createFxNow(),
  7627. duration: options.duration,
  7628. tweens: [],
  7629. createTween: function( prop, end ) {
  7630. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  7631. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  7632. animation.tweens.push( tween );
  7633. return tween;
  7634. },
  7635. stop: function( gotoEnd ) {
  7636. var index = 0,
  7637. // If we are going to the end, we want to run all the tweens
  7638. // otherwise we skip this part
  7639. length = gotoEnd ? animation.tweens.length : 0;
  7640. if ( stopped ) {
  7641. return this;
  7642. }
  7643. stopped = true;
  7644. for ( ; index < length; index++ ) {
  7645. animation.tweens[ index ].run( 1 );
  7646. }
  7647. // Resolve when we played the last frame; otherwise, reject
  7648. if ( gotoEnd ) {
  7649. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  7650. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  7651. } else {
  7652. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  7653. }
  7654. return this;
  7655. }
  7656. } ),
  7657. props = animation.props;
  7658. propFilter( props, animation.opts.specialEasing );
  7659. for ( ; index < length; index++ ) {
  7660. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  7661. if ( result ) {
  7662. if ( jQuery.isFunction( result.stop ) ) {
  7663. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  7664. jQuery.proxy( result.stop, result );
  7665. }
  7666. return result;
  7667. }
  7668. }
  7669. jQuery.map( props, createTween, animation );
  7670. if ( jQuery.isFunction( animation.opts.start ) ) {
  7671. animation.opts.start.call( elem, animation );
  7672. }
  7673. // Attach callbacks from options
  7674. animation
  7675. .progress( animation.opts.progress )
  7676. .done( animation.opts.done, animation.opts.complete )
  7677. .fail( animation.opts.fail )
  7678. .always( animation.opts.always );
  7679. jQuery.fx.timer(
  7680. jQuery.extend( tick, {
  7681. elem: elem,
  7682. anim: animation,
  7683. queue: animation.opts.queue
  7684. } )
  7685. );
  7686. return animation;
  7687. }
  7688. jQuery.Animation = jQuery.extend( Animation, {
  7689. tweeners: {
  7690. "*": [ function( prop, value ) {
  7691. var tween = this.createTween( prop, value );
  7692. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  7693. return tween;
  7694. } ]
  7695. },
  7696. tweener: function( props, callback ) {
  7697. if ( jQuery.isFunction( props ) ) {
  7698. callback = props;
  7699. props = [ "*" ];
  7700. } else {
  7701. props = props.match( rnothtmlwhite );
  7702. }
  7703. var prop,
  7704. index = 0,
  7705. length = props.length;
  7706. for ( ; index < length; index++ ) {
  7707. prop = props[ index ];
  7708. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  7709. Animation.tweeners[ prop ].unshift( callback );
  7710. }
  7711. },
  7712. prefilters: [ defaultPrefilter ],
  7713. prefilter: function( callback, prepend ) {
  7714. if ( prepend ) {
  7715. Animation.prefilters.unshift( callback );
  7716. } else {
  7717. Animation.prefilters.push( callback );
  7718. }
  7719. }
  7720. } );
  7721. jQuery.speed = function( speed, easing, fn ) {
  7722. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  7723. complete: fn || !fn && easing ||
  7724. jQuery.isFunction( speed ) && speed,
  7725. duration: speed,
  7726. easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
  7727. };
  7728. // Go to the end state if fx are off
  7729. if ( jQuery.fx.off ) {
  7730. opt.duration = 0;
  7731. } else {
  7732. if ( typeof opt.duration !== "number" ) {
  7733. if ( opt.duration in jQuery.fx.speeds ) {
  7734. opt.duration = jQuery.fx.speeds[ opt.duration ];
  7735. } else {
  7736. opt.duration = jQuery.fx.speeds._default;
  7737. }
  7738. }
  7739. }
  7740. // Normalize opt.queue - true/undefined/null -> "fx"
  7741. if ( opt.queue == null || opt.queue === true ) {
  7742. opt.queue = "fx";
  7743. }
  7744. // Queueing
  7745. opt.old = opt.complete;
  7746. opt.complete = function() {
  7747. if ( jQuery.isFunction( opt.old ) ) {
  7748. opt.old.call( this );
  7749. }
  7750. if ( opt.queue ) {
  7751. jQuery.dequeue( this, opt.queue );
  7752. }
  7753. };
  7754. return opt;
  7755. };
  7756. jQuery.fn.extend( {
  7757. fadeTo: function( speed, to, easing, callback ) {
  7758. // Show any hidden elements after setting opacity to 0
  7759. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  7760. // Animate to the value specified
  7761. .end().animate( { opacity: to }, speed, easing, callback );
  7762. },
  7763. animate: function( prop, speed, easing, callback ) {
  7764. var empty = jQuery.isEmptyObject( prop ),
  7765. optall = jQuery.speed( speed, easing, callback ),
  7766. doAnimation = function() {
  7767. // Operate on a copy of prop so per-property easing won't be lost
  7768. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  7769. // Empty animations, or finishing resolves immediately
  7770. if ( empty || dataPriv.get( this, "finish" ) ) {
  7771. anim.stop( true );
  7772. }
  7773. };
  7774. doAnimation.finish = doAnimation;
  7775. return empty || optall.queue === false ?
  7776. this.each( doAnimation ) :
  7777. this.queue( optall.queue, doAnimation );
  7778. },
  7779. stop: function( type, clearQueue, gotoEnd ) {
  7780. var stopQueue = function( hooks ) {
  7781. var stop = hooks.stop;
  7782. delete hooks.stop;
  7783. stop( gotoEnd );
  7784. };
  7785. if ( typeof type !== "string" ) {
  7786. gotoEnd = clearQueue;
  7787. clearQueue = type;
  7788. type = undefined;
  7789. }
  7790. if ( clearQueue && type !== false ) {
  7791. this.queue( type || "fx", [] );
  7792. }
  7793. return this.each( function() {
  7794. var dequeue = true,
  7795. index = type != null && type + "queueHooks",
  7796. timers = jQuery.timers,
  7797. data = dataPriv.get( this );
  7798. if ( index ) {
  7799. if ( data[ index ] && data[ index ].stop ) {
  7800. stopQueue( data[ index ] );
  7801. }
  7802. } else {
  7803. for ( index in data ) {
  7804. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  7805. stopQueue( data[ index ] );
  7806. }
  7807. }
  7808. }
  7809. for ( index = timers.length; index--; ) {
  7810. if ( timers[ index ].elem === this &&
  7811. ( type == null || timers[ index ].queue === type ) ) {
  7812. timers[ index ].anim.stop( gotoEnd );
  7813. dequeue = false;
  7814. timers.splice( index, 1 );
  7815. }
  7816. }
  7817. // Start the next in the queue if the last step wasn't forced.
  7818. // Timers currently will call their complete callbacks, which
  7819. // will dequeue but only if they were gotoEnd.
  7820. if ( dequeue || !gotoEnd ) {
  7821. jQuery.dequeue( this, type );
  7822. }
  7823. } );
  7824. },
  7825. finish: function( type ) {
  7826. if ( type !== false ) {
  7827. type = type || "fx";
  7828. }
  7829. return this.each( function() {
  7830. var index,
  7831. data = dataPriv.get( this ),
  7832. queue = data[ type + "queue" ],
  7833. hooks = data[ type + "queueHooks" ],
  7834. timers = jQuery.timers,
  7835. length = queue ? queue.length : 0;
  7836. // Enable finishing flag on private data
  7837. data.finish = true;
  7838. // Empty the queue first
  7839. jQuery.queue( this, type, [] );
  7840. if ( hooks && hooks.stop ) {
  7841. hooks.stop.call( this, true );
  7842. }
  7843. // Look for any active animations, and finish them
  7844. for ( index = timers.length; index--; ) {
  7845. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  7846. timers[ index ].anim.stop( true );
  7847. timers.splice( index, 1 );
  7848. }
  7849. }
  7850. // Look for any animations in the old queue and finish them
  7851. for ( index = 0; index < length; index++ ) {
  7852. if ( queue[ index ] && queue[ index ].finish ) {
  7853. queue[ index ].finish.call( this );
  7854. }
  7855. }
  7856. // Turn off finishing flag
  7857. delete data.finish;
  7858. } );
  7859. }
  7860. } );
  7861. jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
  7862. var cssFn = jQuery.fn[ name ];
  7863. jQuery.fn[ name ] = function( speed, easing, callback ) {
  7864. return speed == null || typeof speed === "boolean" ?
  7865. cssFn.apply( this, arguments ) :
  7866. this.animate( genFx( name, true ), speed, easing, callback );
  7867. };
  7868. } );
  7869. // Generate shortcuts for custom animations
  7870. jQuery.each( {
  7871. slideDown: genFx( "show" ),
  7872. slideUp: genFx( "hide" ),
  7873. slideToggle: genFx( "toggle" ),
  7874. fadeIn: { opacity: "show" },
  7875. fadeOut: { opacity: "hide" },
  7876. fadeToggle: { opacity: "toggle" }
  7877. }, function( name, props ) {
  7878. jQuery.fn[ name ] = function( speed, easing, callback ) {
  7879. return this.animate( props, speed, easing, callback );
  7880. };
  7881. } );
  7882. jQuery.timers = [];
  7883. jQuery.fx.tick = function() {
  7884. var timer,
  7885. i = 0,
  7886. timers = jQuery.timers;
  7887. fxNow = jQuery.now();
  7888. for ( ; i < timers.length; i++ ) {
  7889. timer = timers[ i ];
  7890. // Run the timer and safely remove it when done (allowing for external removal)
  7891. if ( !timer() && timers[ i ] === timer ) {
  7892. timers.splice( i--, 1 );
  7893. }
  7894. }
  7895. if ( !timers.length ) {
  7896. jQuery.fx.stop();
  7897. }
  7898. fxNow = undefined;
  7899. };
  7900. jQuery.fx.timer = function( timer ) {
  7901. jQuery.timers.push( timer );
  7902. jQuery.fx.start();
  7903. };
  7904. jQuery.fx.interval = 13;
  7905. jQuery.fx.start = function() {
  7906. if ( inProgress ) {
  7907. return;
  7908. }
  7909. inProgress = true;
  7910. schedule();
  7911. };
  7912. jQuery.fx.stop = function() {
  7913. inProgress = null;
  7914. };
  7915. jQuery.fx.speeds = {
  7916. slow: 600,
  7917. fast: 200,
  7918. // Default speed
  7919. _default: 400
  7920. };
  7921. // Based off of the plugin by Clint Helfers, with permission.
  7922. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  7923. jQuery.fn.delay = function( time, type ) {
  7924. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  7925. type = type || "fx";
  7926. return this.queue( type, function( next, hooks ) {
  7927. var timeout = window.setTimeout( next, time );
  7928. hooks.stop = function() {
  7929. window.clearTimeout( timeout );
  7930. };
  7931. } );
  7932. };
  7933. ( function() {
  7934. var input = document.createElement( "input" ),
  7935. select = document.createElement( "select" ),
  7936. opt = select.appendChild( document.createElement( "option" ) );
  7937. input.type = "checkbox";
  7938. // Support: Android <=4.3 only
  7939. // Default value for a checkbox should be "on"
  7940. support.checkOn = input.value !== "";
  7941. // Support: IE <=11 only
  7942. // Must access selectedIndex to make default options select
  7943. support.optSelected = opt.selected;
  7944. // Support: IE <=11 only
  7945. // An input loses its value after becoming a radio
  7946. input = document.createElement( "input" );
  7947. input.value = "t";
  7948. input.type = "radio";
  7949. support.radioValue = input.value === "t";
  7950. } )();
  7951. var boolHook,
  7952. attrHandle = jQuery.expr.attrHandle;
  7953. jQuery.fn.extend( {
  7954. attr: function( name, value ) {
  7955. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  7956. },
  7957. removeAttr: function( name ) {
  7958. return this.each( function() {
  7959. jQuery.removeAttr( this, name );
  7960. } );
  7961. }
  7962. } );
  7963. jQuery.extend( {
  7964. attr: function( elem, name, value ) {
  7965. var ret, hooks,
  7966. nType = elem.nodeType;
  7967. // Don't get/set attributes on text, comment and attribute nodes
  7968. if ( nType === 3 || nType === 8 || nType === 2 ) {
  7969. return;
  7970. }
  7971. // Fallback to prop when attributes are not supported
  7972. if ( typeof elem.getAttribute === "undefined" ) {
  7973. return jQuery.prop( elem, name, value );
  7974. }
  7975. // Attribute hooks are determined by the lowercase version
  7976. // Grab necessary hook if one is defined
  7977. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  7978. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  7979. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  7980. }
  7981. if ( value !== undefined ) {
  7982. if ( value === null ) {
  7983. jQuery.removeAttr( elem, name );
  7984. return;
  7985. }
  7986. if ( hooks && "set" in hooks &&
  7987. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  7988. return ret;
  7989. }
  7990. elem.setAttribute( name, value + "" );
  7991. return value;
  7992. }
  7993. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  7994. return ret;
  7995. }
  7996. ret = jQuery.find.attr( elem, name );
  7997. // Non-existent attributes return null, we normalize to undefined
  7998. return ret == null ? undefined : ret;
  7999. },
  8000. attrHooks: {
  8001. type: {
  8002. set: function( elem, value ) {
  8003. if ( !support.radioValue && value === "radio" &&
  8004. nodeName( elem, "input" ) ) {
  8005. var val = elem.value;
  8006. elem.setAttribute( "type", value );
  8007. if ( val ) {
  8008. elem.value = val;
  8009. }
  8010. return value;
  8011. }
  8012. }
  8013. }
  8014. },
  8015. removeAttr: function( elem, value ) {
  8016. var name,
  8017. i = 0,
  8018. // Attribute names can contain non-HTML whitespace characters
  8019. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  8020. attrNames = value && value.match( rnothtmlwhite );
  8021. if ( attrNames && elem.nodeType === 1 ) {
  8022. while ( ( name = attrNames[ i++ ] ) ) {
  8023. elem.removeAttribute( name );
  8024. }
  8025. }
  8026. }
  8027. } );
  8028. // Hooks for boolean attributes
  8029. boolHook = {
  8030. set: function( elem, value, name ) {
  8031. if ( value === false ) {
  8032. // Remove boolean attributes when set to false
  8033. jQuery.removeAttr( elem, name );
  8034. } else {
  8035. elem.setAttribute( name, name );
  8036. }
  8037. return name;
  8038. }
  8039. };
  8040. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  8041. var getter = attrHandle[ name ] || jQuery.find.attr;
  8042. attrHandle[ name ] = function( elem, name, isXML ) {
  8043. var ret, handle,
  8044. lowercaseName = name.toLowerCase();
  8045. if ( !isXML ) {
  8046. // Avoid an infinite loop by temporarily removing this function from the getter
  8047. handle = attrHandle[ lowercaseName ];
  8048. attrHandle[ lowercaseName ] = ret;
  8049. ret = getter( elem, name, isXML ) != null ?
  8050. lowercaseName :
  8051. null;
  8052. attrHandle[ lowercaseName ] = handle;
  8053. }
  8054. return ret;
  8055. };
  8056. } );
  8057. var rfocusable = /^(?:input|select|textarea|button)$/i,
  8058. rclickable = /^(?:a|area)$/i;
  8059. jQuery.fn.extend( {
  8060. prop: function( name, value ) {
  8061. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  8062. },
  8063. removeProp: function( name ) {
  8064. return this.each( function() {
  8065. delete this[ jQuery.propFix[ name ] || name ];
  8066. } );
  8067. }
  8068. } );
  8069. jQuery.extend( {
  8070. prop: function( elem, name, value ) {
  8071. var ret, hooks,
  8072. nType = elem.nodeType;
  8073. // Don't get/set properties on text, comment and attribute nodes
  8074. if ( nType === 3 || nType === 8 || nType === 2 ) {
  8075. return;
  8076. }
  8077. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  8078. // Fix name and attach hooks
  8079. name = jQuery.propFix[ name ] || name;
  8080. hooks = jQuery.propHooks[ name ];
  8081. }
  8082. if ( value !== undefined ) {
  8083. if ( hooks && "set" in hooks &&
  8084. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  8085. return ret;
  8086. }
  8087. return ( elem[ name ] = value );
  8088. }
  8089. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  8090. return ret;
  8091. }
  8092. return elem[ name ];
  8093. },
  8094. propHooks: {
  8095. tabIndex: {
  8096. get: function( elem ) {
  8097. // Support: IE <=9 - 11 only
  8098. // elem.tabIndex doesn't always return the
  8099. // correct value when it hasn't been explicitly set
  8100. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  8101. // Use proper attribute retrieval(#12072)
  8102. var tabindex = jQuery.find.attr( elem, "tabindex" );
  8103. if ( tabindex ) {
  8104. return parseInt( tabindex, 10 );
  8105. }
  8106. if (
  8107. rfocusable.test( elem.nodeName ) ||
  8108. rclickable.test( elem.nodeName ) &&
  8109. elem.href
  8110. ) {
  8111. return 0;
  8112. }
  8113. return -1;
  8114. }
  8115. }
  8116. },
  8117. propFix: {
  8118. "for": "htmlFor",
  8119. "class": "className"
  8120. }
  8121. } );
  8122. // Support: IE <=11 only
  8123. // Accessing the selectedIndex property
  8124. // forces the browser to respect setting selected
  8125. // on the option
  8126. // The getter ensures a default option is selected
  8127. // when in an optgroup
  8128. // eslint rule "no-unused-expressions" is disabled for this code
  8129. // since it considers such accessions noop
  8130. if ( !support.optSelected ) {
  8131. jQuery.propHooks.selected = {
  8132. get: function( elem ) {
  8133. /* eslint no-unused-expressions: "off" */
  8134. var parent = elem.parentNode;
  8135. if ( parent && parent.parentNode ) {
  8136. parent.parentNode.selectedIndex;
  8137. }
  8138. return null;
  8139. },
  8140. set: function( elem ) {
  8141. /* eslint no-unused-expressions: "off" */
  8142. var parent = elem.parentNode;
  8143. if ( parent ) {
  8144. parent.selectedIndex;
  8145. if ( parent.parentNode ) {
  8146. parent.parentNode.selectedIndex;
  8147. }
  8148. }
  8149. }
  8150. };
  8151. }
  8152. jQuery.each( [
  8153. "tabIndex",
  8154. "readOnly",
  8155. "maxLength",
  8156. "cellSpacing",
  8157. "cellPadding",
  8158. "rowSpan",
  8159. "colSpan",
  8160. "useMap",
  8161. "frameBorder",
  8162. "contentEditable"
  8163. ], function() {
  8164. jQuery.propFix[ this.toLowerCase() ] = this;
  8165. } );
  8166. // Strip and collapse whitespace according to HTML spec
  8167. // https://html.spec.whatwg.org/multipage/infrastructure.html#strip-and-collapse-whitespace
  8168. function stripAndCollapse( value ) {
  8169. var tokens = value.match( rnothtmlwhite ) || [];
  8170. return tokens.join( " " );
  8171. }
  8172. function getClass( elem ) {
  8173. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  8174. }
  8175. jQuery.fn.extend( {
  8176. addClass: function( value ) {
  8177. var classes, elem, cur, curValue, clazz, j, finalValue,
  8178. i = 0;
  8179. if ( jQuery.isFunction( value ) ) {
  8180. return this.each( function( j ) {
  8181. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  8182. } );
  8183. }
  8184. if ( typeof value === "string" && value ) {
  8185. classes = value.match( rnothtmlwhite ) || [];
  8186. while ( ( elem = this[ i++ ] ) ) {
  8187. curValue = getClass( elem );
  8188. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  8189. if ( cur ) {
  8190. j = 0;
  8191. while ( ( clazz = classes[ j++ ] ) ) {
  8192. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  8193. cur += clazz + " ";
  8194. }
  8195. }
  8196. // Only assign if different to avoid unneeded rendering.
  8197. finalValue = stripAndCollapse( cur );
  8198. if ( curValue !== finalValue ) {
  8199. elem.setAttribute( "class", finalValue );
  8200. }
  8201. }
  8202. }
  8203. }
  8204. return this;
  8205. },
  8206. removeClass: function( value ) {
  8207. var classes, elem, cur, curValue, clazz, j, finalValue,
  8208. i = 0;
  8209. if ( jQuery.isFunction( value ) ) {
  8210. return this.each( function( j ) {
  8211. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  8212. } );
  8213. }
  8214. if ( !arguments.length ) {
  8215. return this.attr( "class", "" );
  8216. }
  8217. if ( typeof value === "string" && value ) {
  8218. classes = value.match( rnothtmlwhite ) || [];
  8219. while ( ( elem = this[ i++ ] ) ) {
  8220. curValue = getClass( elem );
  8221. // This expression is here for better compressibility (see addClass)
  8222. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  8223. if ( cur ) {
  8224. j = 0;
  8225. while ( ( clazz = classes[ j++ ] ) ) {
  8226. // Remove *all* instances
  8227. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  8228. cur = cur.replace( " " + clazz + " ", " " );
  8229. }
  8230. }
  8231. // Only assign if different to avoid unneeded rendering.
  8232. finalValue = stripAndCollapse( cur );
  8233. if ( curValue !== finalValue ) {
  8234. elem.setAttribute( "class", finalValue );
  8235. }
  8236. }
  8237. }
  8238. }
  8239. return this;
  8240. },
  8241. toggleClass: function( value, stateVal ) {
  8242. var type = typeof value;
  8243. if ( typeof stateVal === "boolean" && type === "string" ) {
  8244. return stateVal ? this.addClass( value ) : this.removeClass( value );
  8245. }
  8246. if ( jQuery.isFunction( value ) ) {
  8247. return this.each( function( i ) {
  8248. jQuery( this ).toggleClass(
  8249. value.call( this, i, getClass( this ), stateVal ),
  8250. stateVal
  8251. );
  8252. } );
  8253. }
  8254. return this.each( function() {
  8255. var className, i, self, classNames;
  8256. if ( type === "string" ) {
  8257. // Toggle individual class names
  8258. i = 0;
  8259. self = jQuery( this );
  8260. classNames = value.match( rnothtmlwhite ) || [];
  8261. while ( ( className = classNames[ i++ ] ) ) {
  8262. // Check each className given, space separated list
  8263. if ( self.hasClass( className ) ) {
  8264. self.removeClass( className );
  8265. } else {
  8266. self.addClass( className );
  8267. }
  8268. }
  8269. // Toggle whole class name
  8270. } else if ( value === undefined || type === "boolean" ) {
  8271. className = getClass( this );
  8272. if ( className ) {
  8273. // Store className if set
  8274. dataPriv.set( this, "__className__", className );
  8275. }
  8276. // If the element has a class name or if we're passed `false`,
  8277. // then remove the whole classname (if there was one, the above saved it).
  8278. // Otherwise bring back whatever was previously saved (if anything),
  8279. // falling back to the empty string if nothing was stored.
  8280. if ( this.setAttribute ) {
  8281. this.setAttribute( "class",
  8282. className || value === false ?
  8283. "" :
  8284. dataPriv.get( this, "__className__" ) || ""
  8285. );
  8286. }
  8287. }
  8288. } );
  8289. },
  8290. hasClass: function( selector ) {
  8291. var className, elem,
  8292. i = 0;
  8293. className = " " + selector + " ";
  8294. while ( ( elem = this[ i++ ] ) ) {
  8295. if ( elem.nodeType === 1 &&
  8296. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  8297. return true;
  8298. }
  8299. }
  8300. return false;
  8301. }
  8302. } );
  8303. var rreturn = /\r/g;
  8304. jQuery.fn.extend( {
  8305. val: function( value ) {
  8306. var hooks, ret, isFunction,
  8307. elem = this[ 0 ];
  8308. if ( !arguments.length ) {
  8309. if ( elem ) {
  8310. hooks = jQuery.valHooks[ elem.type ] ||
  8311. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  8312. if ( hooks &&
  8313. "get" in hooks &&
  8314. ( ret = hooks.get( elem, "value" ) ) !== undefined
  8315. ) {
  8316. return ret;
  8317. }
  8318. ret = elem.value;
  8319. // Handle most common string cases
  8320. if ( typeof ret === "string" ) {
  8321. return ret.replace( rreturn, "" );
  8322. }
  8323. // Handle cases where value is null/undef or number
  8324. return ret == null ? "" : ret;
  8325. }
  8326. return;
  8327. }
  8328. isFunction = jQuery.isFunction( value );
  8329. return this.each( function( i ) {
  8330. var val;
  8331. if ( this.nodeType !== 1 ) {
  8332. return;
  8333. }
  8334. if ( isFunction ) {
  8335. val = value.call( this, i, jQuery( this ).val() );
  8336. } else {
  8337. val = value;
  8338. }
  8339. // Treat null/undefined as ""; convert numbers to string
  8340. if ( val == null ) {
  8341. val = "";
  8342. } else if ( typeof val === "number" ) {
  8343. val += "";
  8344. } else if ( Array.isArray( val ) ) {
  8345. val = jQuery.map( val, function( value ) {
  8346. return value == null ? "" : value + "";
  8347. } );
  8348. }
  8349. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  8350. // If set returns undefined, fall back to normal setting
  8351. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  8352. this.value = val;
  8353. }
  8354. } );
  8355. }
  8356. } );
  8357. jQuery.extend( {
  8358. valHooks: {
  8359. option: {
  8360. get: function( elem ) {
  8361. var val = jQuery.find.attr( elem, "value" );
  8362. return val != null ?
  8363. val :
  8364. // Support: IE <=10 - 11 only
  8365. // option.text throws exceptions (#14686, #14858)
  8366. // Strip and collapse whitespace
  8367. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  8368. stripAndCollapse( jQuery.text( elem ) );
  8369. }
  8370. },
  8371. select: {
  8372. get: function( elem ) {
  8373. var value, option, i,
  8374. options = elem.options,
  8375. index = elem.selectedIndex,
  8376. one = elem.type === "select-one",
  8377. values = one ? null : [],
  8378. max = one ? index + 1 : options.length;
  8379. if ( index < 0 ) {
  8380. i = max;
  8381. } else {
  8382. i = one ? index : 0;
  8383. }
  8384. // Loop through all the selected options
  8385. for ( ; i < max; i++ ) {
  8386. option = options[ i ];
  8387. // Support: IE <=9 only
  8388. // IE8-9 doesn't update selected after form reset (#2551)
  8389. if ( ( option.selected || i === index ) &&
  8390. // Don't return options that are disabled or in a disabled optgroup
  8391. !option.disabled &&
  8392. ( !option.parentNode.disabled ||
  8393. !nodeName( option.parentNode, "optgroup" ) ) ) {
  8394. // Get the specific value for the option
  8395. value = jQuery( option ).val();
  8396. // We don't need an array for one selects
  8397. if ( one ) {
  8398. return value;
  8399. }
  8400. // Multi-Selects return an array
  8401. values.push( value );
  8402. }
  8403. }
  8404. return values;
  8405. },
  8406. set: function( elem, value ) {
  8407. var optionSet, option,
  8408. options = elem.options,
  8409. values = jQuery.makeArray( value ),
  8410. i = options.length;
  8411. while ( i-- ) {
  8412. option = options[ i ];
  8413. /* eslint-disable no-cond-assign */
  8414. if ( option.selected =
  8415. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  8416. ) {
  8417. optionSet = true;
  8418. }
  8419. /* eslint-enable no-cond-assign */
  8420. }
  8421. // Force browsers to behave consistently when non-matching value is set
  8422. if ( !optionSet ) {
  8423. elem.selectedIndex = -1;
  8424. }
  8425. return values;
  8426. }
  8427. }
  8428. }
  8429. } );
  8430. // Radios and checkboxes getter/setter
  8431. jQuery.each( [ "radio", "checkbox" ], function() {
  8432. jQuery.valHooks[ this ] = {
  8433. set: function( elem, value ) {
  8434. if ( Array.isArray( value ) ) {
  8435. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  8436. }
  8437. }
  8438. };
  8439. if ( !support.checkOn ) {
  8440. jQuery.valHooks[ this ].get = function( elem ) {
  8441. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  8442. };
  8443. }
  8444. } );
  8445. // Return jQuery for attributes-only inclusion
  8446. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/;
  8447. jQuery.extend( jQuery.event, {
  8448. trigger: function( event, data, elem, onlyHandlers ) {
  8449. var i, cur, tmp, bubbleType, ontype, handle, special,
  8450. eventPath = [ elem || document ],
  8451. type = hasOwn.call( event, "type" ) ? event.type : event,
  8452. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  8453. cur = tmp = elem = elem || document;
  8454. // Don't do events on text and comment nodes
  8455. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  8456. return;
  8457. }
  8458. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  8459. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  8460. return;
  8461. }
  8462. if ( type.indexOf( "." ) > -1 ) {
  8463. // Namespaced trigger; create a regexp to match event type in handle()
  8464. namespaces = type.split( "." );
  8465. type = namespaces.shift();
  8466. namespaces.sort();
  8467. }
  8468. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  8469. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  8470. event = event[ jQuery.expando ] ?
  8471. event :
  8472. new jQuery.Event( type, typeof event === "object" && event );
  8473. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  8474. event.isTrigger = onlyHandlers ? 2 : 3;
  8475. event.namespace = namespaces.join( "." );
  8476. event.rnamespace = event.namespace ?
  8477. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  8478. null;
  8479. // Clean up the event in case it is being reused
  8480. event.result = undefined;
  8481. if ( !event.target ) {
  8482. event.target = elem;
  8483. }
  8484. // Clone any incoming data and prepend the event, creating the handler arg list
  8485. data = data == null ?
  8486. [ event ] :
  8487. jQuery.makeArray( data, [ event ] );
  8488. // Allow special events to draw outside the lines
  8489. special = jQuery.event.special[ type ] || {};
  8490. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  8491. return;
  8492. }
  8493. // Determine event propagation path in advance, per W3C events spec (#9951)
  8494. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  8495. if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
  8496. bubbleType = special.delegateType || type;
  8497. if ( !rfocusMorph.test( bubbleType + type ) ) {
  8498. cur = cur.parentNode;
  8499. }
  8500. for ( ; cur; cur = cur.parentNode ) {
  8501. eventPath.push( cur );
  8502. tmp = cur;
  8503. }
  8504. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  8505. if ( tmp === ( elem.ownerDocument || document ) ) {
  8506. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  8507. }
  8508. }
  8509. // Fire handlers on the event path
  8510. i = 0;
  8511. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  8512. event.type = i > 1 ?
  8513. bubbleType :
  8514. special.bindType || type;
  8515. // jQuery handler
  8516. handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
  8517. dataPriv.get( cur, "handle" );
  8518. if ( handle ) {
  8519. handle.apply( cur, data );
  8520. }
  8521. // Native handler
  8522. handle = ontype && cur[ ontype ];
  8523. if ( handle && handle.apply && acceptData( cur ) ) {
  8524. event.result = handle.apply( cur, data );
  8525. if ( event.result === false ) {
  8526. event.preventDefault();
  8527. }
  8528. }
  8529. }
  8530. event.type = type;
  8531. // If nobody prevented the default action, do it now
  8532. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  8533. if ( ( !special._default ||
  8534. special._default.apply( eventPath.pop(), data ) === false ) &&
  8535. acceptData( elem ) ) {
  8536. // Call a native DOM method on the target with the same name as the event.
  8537. // Don't do default actions on window, that's where global variables be (#6170)
  8538. if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) {
  8539. // Don't re-trigger an onFOO event when we call its FOO() method
  8540. tmp = elem[ ontype ];
  8541. if ( tmp ) {
  8542. elem[ ontype ] = null;
  8543. }
  8544. // Prevent re-triggering of the same event, since we already bubbled it above
  8545. jQuery.event.triggered = type;
  8546. elem[ type ]();
  8547. jQuery.event.triggered = undefined;
  8548. if ( tmp ) {
  8549. elem[ ontype ] = tmp;
  8550. }
  8551. }
  8552. }
  8553. }
  8554. return event.result;
  8555. },
  8556. // Piggyback on a donor event to simulate a different one
  8557. // Used only for `focus(in | out)` events
  8558. simulate: function( type, elem, event ) {
  8559. var e = jQuery.extend(
  8560. new jQuery.Event(),
  8561. event,
  8562. {
  8563. type: type,
  8564. isSimulated: true
  8565. }
  8566. );
  8567. jQuery.event.trigger( e, null, elem );
  8568. }
  8569. } );
  8570. jQuery.fn.extend( {
  8571. trigger: function( type, data ) {
  8572. return this.each( function() {
  8573. jQuery.event.trigger( type, data, this );
  8574. } );
  8575. },
  8576. triggerHandler: function( type, data ) {
  8577. var elem = this[ 0 ];
  8578. if ( elem ) {
  8579. return jQuery.event.trigger( type, data, elem, true );
  8580. }
  8581. }
  8582. } );
  8583. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  8584. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  8585. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  8586. function( i, name ) {
  8587. // Handle event binding
  8588. jQuery.fn[ name ] = function( data, fn ) {
  8589. return arguments.length > 0 ?
  8590. this.on( name, null, data, fn ) :
  8591. this.trigger( name );
  8592. };
  8593. } );
  8594. jQuery.fn.extend( {
  8595. hover: function( fnOver, fnOut ) {
  8596. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  8597. }
  8598. } );
  8599. support.focusin = "onfocusin" in window;
  8600. // Support: Firefox <=44
  8601. // Firefox doesn't have focus(in | out) events
  8602. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  8603. //
  8604. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  8605. // focus(in | out) events fire after focus & blur events,
  8606. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  8607. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  8608. if ( !support.focusin ) {
  8609. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  8610. // Attach a single capturing handler on the document while someone wants focusin/focusout
  8611. var handler = function( event ) {
  8612. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  8613. };
  8614. jQuery.event.special[ fix ] = {
  8615. setup: function() {
  8616. var doc = this.ownerDocument || this,
  8617. attaches = dataPriv.access( doc, fix );
  8618. if ( !attaches ) {
  8619. doc.addEventListener( orig, handler, true );
  8620. }
  8621. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  8622. },
  8623. teardown: function() {
  8624. var doc = this.ownerDocument || this,
  8625. attaches = dataPriv.access( doc, fix ) - 1;
  8626. if ( !attaches ) {
  8627. doc.removeEventListener( orig, handler, true );
  8628. dataPriv.remove( doc, fix );
  8629. } else {
  8630. dataPriv.access( doc, fix, attaches );
  8631. }
  8632. }
  8633. };
  8634. } );
  8635. }
  8636. var location = window.location;
  8637. var nonce = jQuery.now();
  8638. var rquery = ( /\?/ );
  8639. // Cross-browser xml parsing
  8640. jQuery.parseXML = function( data ) {
  8641. var xml;
  8642. if ( !data || typeof data !== "string" ) {
  8643. return null;
  8644. }
  8645. // Support: IE 9 - 11 only
  8646. // IE throws on parseFromString with invalid input.
  8647. try {
  8648. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  8649. } catch ( e ) {
  8650. xml = undefined;
  8651. }
  8652. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  8653. jQuery.error( "Invalid XML: " + data );
  8654. }
  8655. return xml;
  8656. };
  8657. var
  8658. rbracket = /\[\]$/,
  8659. rCRLF = /\r?\n/g,
  8660. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  8661. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  8662. function buildParams( prefix, obj, traditional, add ) {
  8663. var name;
  8664. if ( Array.isArray( obj ) ) {
  8665. // Serialize array item.
  8666. jQuery.each( obj, function( i, v ) {
  8667. if ( traditional || rbracket.test( prefix ) ) {
  8668. // Treat each array item as a scalar.
  8669. add( prefix, v );
  8670. } else {
  8671. // Item is non-scalar (array or object), encode its numeric index.
  8672. buildParams(
  8673. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  8674. v,
  8675. traditional,
  8676. add
  8677. );
  8678. }
  8679. } );
  8680. } else if ( !traditional && jQuery.type( obj ) === "object" ) {
  8681. // Serialize object item.
  8682. for ( name in obj ) {
  8683. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  8684. }
  8685. } else {
  8686. // Serialize scalar item.
  8687. add( prefix, obj );
  8688. }
  8689. }
  8690. // Serialize an array of form elements or a set of
  8691. // key/values into a query string
  8692. jQuery.param = function( a, traditional ) {
  8693. var prefix,
  8694. s = [],
  8695. add = function( key, valueOrFunction ) {
  8696. // If value is a function, invoke it and use its return value
  8697. var value = jQuery.isFunction( valueOrFunction ) ?
  8698. valueOrFunction() :
  8699. valueOrFunction;
  8700. s[ s.length ] = encodeURIComponent( key ) + "=" +
  8701. encodeURIComponent( value == null ? "" : value );
  8702. };
  8703. // If an array was passed in, assume that it is an array of form elements.
  8704. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  8705. // Serialize the form elements
  8706. jQuery.each( a, function() {
  8707. add( this.name, this.value );
  8708. } );
  8709. } else {
  8710. // If traditional, encode the "old" way (the way 1.3.2 or older
  8711. // did it), otherwise encode params recursively.
  8712. for ( prefix in a ) {
  8713. buildParams( prefix, a[ prefix ], traditional, add );
  8714. }
  8715. }
  8716. // Return the resulting serialization
  8717. return s.join( "&" );
  8718. };
  8719. jQuery.fn.extend( {
  8720. serialize: function() {
  8721. return jQuery.param( this.serializeArray() );
  8722. },
  8723. serializeArray: function() {
  8724. return this.map( function() {
  8725. // Can add propHook for "elements" to filter or add form elements
  8726. var elements = jQuery.prop( this, "elements" );
  8727. return elements ? jQuery.makeArray( elements ) : this;
  8728. } )
  8729. .filter( function() {
  8730. var type = this.type;
  8731. // Use .is( ":disabled" ) so that fieldset[disabled] works
  8732. return this.name && !jQuery( this ).is( ":disabled" ) &&
  8733. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  8734. ( this.checked || !rcheckableType.test( type ) );
  8735. } )
  8736. .map( function( i, elem ) {
  8737. var val = jQuery( this ).val();
  8738. if ( val == null ) {
  8739. return null;
  8740. }
  8741. if ( Array.isArray( val ) ) {
  8742. return jQuery.map( val, function( val ) {
  8743. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  8744. } );
  8745. }
  8746. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  8747. } ).get();
  8748. }
  8749. } );
  8750. var
  8751. r20 = /%20/g,
  8752. rhash = /#.*$/,
  8753. rantiCache = /([?&])_=[^&]*/,
  8754. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  8755. // #7653, #8125, #8152: local protocol detection
  8756. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  8757. rnoContent = /^(?:GET|HEAD)$/,
  8758. rprotocol = /^\/\//,
  8759. /* Prefilters
  8760. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  8761. * 2) These are called:
  8762. * - BEFORE asking for a transport
  8763. * - AFTER param serialization (s.data is a string if s.processData is true)
  8764. * 3) key is the dataType
  8765. * 4) the catchall symbol "*" can be used
  8766. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  8767. */
  8768. prefilters = {},
  8769. /* Transports bindings
  8770. * 1) key is the dataType
  8771. * 2) the catchall symbol "*" can be used
  8772. * 3) selection will start with transport dataType and THEN go to "*" if needed
  8773. */
  8774. transports = {},
  8775. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  8776. allTypes = "*/".concat( "*" ),
  8777. // Anchor tag for parsing the document origin
  8778. originAnchor = document.createElement( "a" );
  8779. originAnchor.href = location.href;
  8780. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  8781. function addToPrefiltersOrTransports( structure ) {
  8782. // dataTypeExpression is optional and defaults to "*"
  8783. return function( dataTypeExpression, func ) {
  8784. if ( typeof dataTypeExpression !== "string" ) {
  8785. func = dataTypeExpression;
  8786. dataTypeExpression = "*";
  8787. }
  8788. var dataType,
  8789. i = 0,
  8790. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  8791. if ( jQuery.isFunction( func ) ) {
  8792. // For each dataType in the dataTypeExpression
  8793. while ( ( dataType = dataTypes[ i++ ] ) ) {
  8794. // Prepend if requested
  8795. if ( dataType[ 0 ] === "+" ) {
  8796. dataType = dataType.slice( 1 ) || "*";
  8797. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  8798. // Otherwise append
  8799. } else {
  8800. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  8801. }
  8802. }
  8803. }
  8804. };
  8805. }
  8806. // Base inspection function for prefilters and transports
  8807. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  8808. var inspected = {},
  8809. seekingTransport = ( structure === transports );
  8810. function inspect( dataType ) {
  8811. var selected;
  8812. inspected[ dataType ] = true;
  8813. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  8814. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  8815. if ( typeof dataTypeOrTransport === "string" &&
  8816. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  8817. options.dataTypes.unshift( dataTypeOrTransport );
  8818. inspect( dataTypeOrTransport );
  8819. return false;
  8820. } else if ( seekingTransport ) {
  8821. return !( selected = dataTypeOrTransport );
  8822. }
  8823. } );
  8824. return selected;
  8825. }
  8826. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  8827. }
  8828. // A special extend for ajax options
  8829. // that takes "flat" options (not to be deep extended)
  8830. // Fixes #9887
  8831. function ajaxExtend( target, src ) {
  8832. var key, deep,
  8833. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  8834. for ( key in src ) {
  8835. if ( src[ key ] !== undefined ) {
  8836. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  8837. }
  8838. }
  8839. if ( deep ) {
  8840. jQuery.extend( true, target, deep );
  8841. }
  8842. return target;
  8843. }
  8844. /* Handles responses to an ajax request:
  8845. * - finds the right dataType (mediates between content-type and expected dataType)
  8846. * - returns the corresponding response
  8847. */
  8848. function ajaxHandleResponses( s, jqXHR, responses ) {
  8849. var ct, type, finalDataType, firstDataType,
  8850. contents = s.contents,
  8851. dataTypes = s.dataTypes;
  8852. // Remove auto dataType and get content-type in the process
  8853. while ( dataTypes[ 0 ] === "*" ) {
  8854. dataTypes.shift();
  8855. if ( ct === undefined ) {
  8856. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  8857. }
  8858. }
  8859. // Check if we're dealing with a known content-type
  8860. if ( ct ) {
  8861. for ( type in contents ) {
  8862. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  8863. dataTypes.unshift( type );
  8864. break;
  8865. }
  8866. }
  8867. }
  8868. // Check to see if we have a response for the expected dataType
  8869. if ( dataTypes[ 0 ] in responses ) {
  8870. finalDataType = dataTypes[ 0 ];
  8871. } else {
  8872. // Try convertible dataTypes
  8873. for ( type in responses ) {
  8874. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  8875. finalDataType = type;
  8876. break;
  8877. }
  8878. if ( !firstDataType ) {
  8879. firstDataType = type;
  8880. }
  8881. }
  8882. // Or just use first one
  8883. finalDataType = finalDataType || firstDataType;
  8884. }
  8885. // If we found a dataType
  8886. // We add the dataType to the list if needed
  8887. // and return the corresponding response
  8888. if ( finalDataType ) {
  8889. if ( finalDataType !== dataTypes[ 0 ] ) {
  8890. dataTypes.unshift( finalDataType );
  8891. }
  8892. return responses[ finalDataType ];
  8893. }
  8894. }
  8895. /* Chain conversions given the request and the original response
  8896. * Also sets the responseXXX fields on the jqXHR instance
  8897. */
  8898. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  8899. var conv2, current, conv, tmp, prev,
  8900. converters = {},
  8901. // Work with a copy of dataTypes in case we need to modify it for conversion
  8902. dataTypes = s.dataTypes.slice();
  8903. // Create converters map with lowercased keys
  8904. if ( dataTypes[ 1 ] ) {
  8905. for ( conv in s.converters ) {
  8906. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  8907. }
  8908. }
  8909. current = dataTypes.shift();
  8910. // Convert to each sequential dataType
  8911. while ( current ) {
  8912. if ( s.responseFields[ current ] ) {
  8913. jqXHR[ s.responseFields[ current ] ] = response;
  8914. }
  8915. // Apply the dataFilter if provided
  8916. if ( !prev && isSuccess && s.dataFilter ) {
  8917. response = s.dataFilter( response, s.dataType );
  8918. }
  8919. prev = current;
  8920. current = dataTypes.shift();
  8921. if ( current ) {
  8922. // There's only work to do if current dataType is non-auto
  8923. if ( current === "*" ) {
  8924. current = prev;
  8925. // Convert response if prev dataType is non-auto and differs from current
  8926. } else if ( prev !== "*" && prev !== current ) {
  8927. // Seek a direct converter
  8928. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  8929. // If none found, seek a pair
  8930. if ( !conv ) {
  8931. for ( conv2 in converters ) {
  8932. // If conv2 outputs current
  8933. tmp = conv2.split( " " );
  8934. if ( tmp[ 1 ] === current ) {
  8935. // If prev can be converted to accepted input
  8936. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  8937. converters[ "* " + tmp[ 0 ] ];
  8938. if ( conv ) {
  8939. // Condense equivalence converters
  8940. if ( conv === true ) {
  8941. conv = converters[ conv2 ];
  8942. // Otherwise, insert the intermediate dataType
  8943. } else if ( converters[ conv2 ] !== true ) {
  8944. current = tmp[ 0 ];
  8945. dataTypes.unshift( tmp[ 1 ] );
  8946. }
  8947. break;
  8948. }
  8949. }
  8950. }
  8951. }
  8952. // Apply converter (if not an equivalence)
  8953. if ( conv !== true ) {
  8954. // Unless errors are allowed to bubble, catch and return them
  8955. if ( conv && s.throws ) {
  8956. response = conv( response );
  8957. } else {
  8958. try {
  8959. response = conv( response );
  8960. } catch ( e ) {
  8961. return {
  8962. state: "parsererror",
  8963. error: conv ? e : "No conversion from " + prev + " to " + current
  8964. };
  8965. }
  8966. }
  8967. }
  8968. }
  8969. }
  8970. }
  8971. return { state: "success", data: response };
  8972. }
  8973. jQuery.extend( {
  8974. // Counter for holding the number of active queries
  8975. active: 0,
  8976. // Last-Modified header cache for next request
  8977. lastModified: {},
  8978. etag: {},
  8979. ajaxSettings: {
  8980. url: location.href,
  8981. type: "GET",
  8982. isLocal: rlocalProtocol.test( location.protocol ),
  8983. global: true,
  8984. processData: true,
  8985. async: true,
  8986. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  8987. /*
  8988. timeout: 0,
  8989. data: null,
  8990. dataType: null,
  8991. username: null,
  8992. password: null,
  8993. cache: null,
  8994. throws: false,
  8995. traditional: false,
  8996. headers: {},
  8997. */
  8998. accepts: {
  8999. "*": allTypes,
  9000. text: "text/plain",
  9001. html: "text/html",
  9002. xml: "application/xml, text/xml",
  9003. json: "application/json, text/javascript"
  9004. },
  9005. contents: {
  9006. xml: /\bxml\b/,
  9007. html: /\bhtml/,
  9008. json: /\bjson\b/
  9009. },
  9010. responseFields: {
  9011. xml: "responseXML",
  9012. text: "responseText",
  9013. json: "responseJSON"
  9014. },
  9015. // Data converters
  9016. // Keys separate source (or catchall "*") and destination types with a single space
  9017. converters: {
  9018. // Convert anything to text
  9019. "* text": String,
  9020. // Text to html (true = no transformation)
  9021. "text html": true,
  9022. // Evaluate text as a json expression
  9023. "text json": JSON.parse,
  9024. // Parse text as xml
  9025. "text xml": jQuery.parseXML
  9026. },
  9027. // For options that shouldn't be deep extended:
  9028. // you can add your own custom options here if
  9029. // and when you create one that shouldn't be
  9030. // deep extended (see ajaxExtend)
  9031. flatOptions: {
  9032. url: true,
  9033. context: true
  9034. }
  9035. },
  9036. // Creates a full fledged settings object into target
  9037. // with both ajaxSettings and settings fields.
  9038. // If target is omitted, writes into ajaxSettings.
  9039. ajaxSetup: function( target, settings ) {
  9040. return settings ?
  9041. // Building a settings object
  9042. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  9043. // Extending ajaxSettings
  9044. ajaxExtend( jQuery.ajaxSettings, target );
  9045. },
  9046. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  9047. ajaxTransport: addToPrefiltersOrTransports( transports ),
  9048. // Main method
  9049. ajax: function( url, options ) {
  9050. // If url is an object, simulate pre-1.5 signature
  9051. if ( typeof url === "object" ) {
  9052. options = url;
  9053. url = undefined;
  9054. }
  9055. // Force options to be an object
  9056. options = options || {};
  9057. var transport,
  9058. // URL without anti-cache param
  9059. cacheURL,
  9060. // Response headers
  9061. responseHeadersString,
  9062. responseHeaders,
  9063. // timeout handle
  9064. timeoutTimer,
  9065. // Url cleanup var
  9066. urlAnchor,
  9067. // Request state (becomes false upon send and true upon completion)
  9068. completed,
  9069. // To know if global events are to be dispatched
  9070. fireGlobals,
  9071. // Loop variable
  9072. i,
  9073. // uncached part of the url
  9074. uncached,
  9075. // Create the final options object
  9076. s = jQuery.ajaxSetup( {}, options ),
  9077. // Callbacks context
  9078. callbackContext = s.context || s,
  9079. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  9080. globalEventContext = s.context &&
  9081. ( callbackContext.nodeType || callbackContext.jquery ) ?
  9082. jQuery( callbackContext ) :
  9083. jQuery.event,
  9084. // Deferreds
  9085. deferred = jQuery.Deferred(),
  9086. completeDeferred = jQuery.Callbacks( "once memory" ),
  9087. // Status-dependent callbacks
  9088. statusCode = s.statusCode || {},
  9089. // Headers (they are sent all at once)
  9090. requestHeaders = {},
  9091. requestHeadersNames = {},
  9092. // Default abort message
  9093. strAbort = "canceled",
  9094. // Fake xhr
  9095. jqXHR = {
  9096. readyState: 0,
  9097. // Builds headers hashtable if needed
  9098. getResponseHeader: function( key ) {
  9099. var match;
  9100. if ( completed ) {
  9101. if ( !responseHeaders ) {
  9102. responseHeaders = {};
  9103. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  9104. responseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ];
  9105. }
  9106. }
  9107. match = responseHeaders[ key.toLowerCase() ];
  9108. }
  9109. return match == null ? null : match;
  9110. },
  9111. // Raw string
  9112. getAllResponseHeaders: function() {
  9113. return completed ? responseHeadersString : null;
  9114. },
  9115. // Caches the header
  9116. setRequestHeader: function( name, value ) {
  9117. if ( completed == null ) {
  9118. name = requestHeadersNames[ name.toLowerCase() ] =
  9119. requestHeadersNames[ name.toLowerCase() ] || name;
  9120. requestHeaders[ name ] = value;
  9121. }
  9122. return this;
  9123. },
  9124. // Overrides response content-type header
  9125. overrideMimeType: function( type ) {
  9126. if ( completed == null ) {
  9127. s.mimeType = type;
  9128. }
  9129. return this;
  9130. },
  9131. // Status-dependent callbacks
  9132. statusCode: function( map ) {
  9133. var code;
  9134. if ( map ) {
  9135. if ( completed ) {
  9136. // Execute the appropriate callbacks
  9137. jqXHR.always( map[ jqXHR.status ] );
  9138. } else {
  9139. // Lazy-add the new callbacks in a way that preserves old ones
  9140. for ( code in map ) {
  9141. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  9142. }
  9143. }
  9144. }
  9145. return this;
  9146. },
  9147. // Cancel the request
  9148. abort: function( statusText ) {
  9149. var finalText = statusText || strAbort;
  9150. if ( transport ) {
  9151. transport.abort( finalText );
  9152. }
  9153. done( 0, finalText );
  9154. return this;
  9155. }
  9156. };
  9157. // Attach deferreds
  9158. deferred.promise( jqXHR );
  9159. // Add protocol if not provided (prefilters might expect it)
  9160. // Handle falsy url in the settings object (#10093: consistency with old signature)
  9161. // We also use the url parameter if available
  9162. s.url = ( ( url || s.url || location.href ) + "" )
  9163. .replace( rprotocol, location.protocol + "//" );
  9164. // Alias method option to type as per ticket #12004
  9165. s.type = options.method || options.type || s.method || s.type;
  9166. // Extract dataTypes list
  9167. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  9168. // A cross-domain request is in order when the origin doesn't match the current origin.
  9169. if ( s.crossDomain == null ) {
  9170. urlAnchor = document.createElement( "a" );
  9171. // Support: IE <=8 - 11, Edge 12 - 13
  9172. // IE throws exception on accessing the href property if url is malformed,
  9173. // e.g. http://example.com:80x/
  9174. try {
  9175. urlAnchor.href = s.url;
  9176. // Support: IE <=8 - 11 only
  9177. // Anchor's host property isn't correctly set when s.url is relative
  9178. urlAnchor.href = urlAnchor.href;
  9179. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  9180. urlAnchor.protocol + "//" + urlAnchor.host;
  9181. } catch ( e ) {
  9182. // If there is an error parsing the URL, assume it is crossDomain,
  9183. // it can be rejected by the transport if it is invalid
  9184. s.crossDomain = true;
  9185. }
  9186. }
  9187. // Convert data if not already a string
  9188. if ( s.data && s.processData && typeof s.data !== "string" ) {
  9189. s.data = jQuery.param( s.data, s.traditional );
  9190. }
  9191. // Apply prefilters
  9192. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  9193. // If request was aborted inside a prefilter, stop there
  9194. if ( completed ) {
  9195. return jqXHR;
  9196. }
  9197. // We can fire global events as of now if asked to
  9198. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  9199. fireGlobals = jQuery.event && s.global;
  9200. // Watch for a new set of requests
  9201. if ( fireGlobals && jQuery.active++ === 0 ) {
  9202. jQuery.event.trigger( "ajaxStart" );
  9203. }
  9204. // Uppercase the type
  9205. s.type = s.type.toUpperCase();
  9206. // Determine if request has content
  9207. s.hasContent = !rnoContent.test( s.type );
  9208. // Save the URL in case we're toying with the If-Modified-Since
  9209. // and/or If-None-Match header later on
  9210. // Remove hash to simplify url manipulation
  9211. cacheURL = s.url.replace( rhash, "" );
  9212. // More options handling for requests with no content
  9213. if ( !s.hasContent ) {
  9214. // Remember the hash so we can put it back
  9215. uncached = s.url.slice( cacheURL.length );
  9216. // If data is available, append data to url
  9217. if ( s.data ) {
  9218. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  9219. // #9682: remove data so that it's not used in an eventual retry
  9220. delete s.data;
  9221. }
  9222. // Add or update anti-cache param if needed
  9223. if ( s.cache === false ) {
  9224. cacheURL = cacheURL.replace( rantiCache, "$1" );
  9225. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
  9226. }
  9227. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  9228. s.url = cacheURL + uncached;
  9229. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  9230. } else if ( s.data && s.processData &&
  9231. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  9232. s.data = s.data.replace( r20, "+" );
  9233. }
  9234. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  9235. if ( s.ifModified ) {
  9236. if ( jQuery.lastModified[ cacheURL ] ) {
  9237. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  9238. }
  9239. if ( jQuery.etag[ cacheURL ] ) {
  9240. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  9241. }
  9242. }
  9243. // Set the correct header, if data is being sent
  9244. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  9245. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  9246. }
  9247. // Set the Accepts header for the server, depending on the dataType
  9248. jqXHR.setRequestHeader(
  9249. "Accept",
  9250. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  9251. s.accepts[ s.dataTypes[ 0 ] ] +
  9252. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  9253. s.accepts[ "*" ]
  9254. );
  9255. // Check for headers option
  9256. for ( i in s.headers ) {
  9257. jqXHR.setRequestHeader( i, s.headers[ i ] );
  9258. }
  9259. // Allow custom headers/mimetypes and early abort
  9260. if ( s.beforeSend &&
  9261. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  9262. // Abort if not done already and return
  9263. return jqXHR.abort();
  9264. }
  9265. // Aborting is no longer a cancellation
  9266. strAbort = "abort";
  9267. // Install callbacks on deferreds
  9268. completeDeferred.add( s.complete );
  9269. jqXHR.done( s.success );
  9270. jqXHR.fail( s.error );
  9271. // Get transport
  9272. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  9273. // If no transport, we auto-abort
  9274. if ( !transport ) {
  9275. done( -1, "No Transport" );
  9276. } else {
  9277. jqXHR.readyState = 1;
  9278. // Send global event
  9279. if ( fireGlobals ) {
  9280. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  9281. }
  9282. // If request was aborted inside ajaxSend, stop there
  9283. if ( completed ) {
  9284. return jqXHR;
  9285. }
  9286. // Timeout
  9287. if ( s.async && s.timeout > 0 ) {
  9288. timeoutTimer = window.setTimeout( function() {
  9289. jqXHR.abort( "timeout" );
  9290. }, s.timeout );
  9291. }
  9292. try {
  9293. completed = false;
  9294. transport.send( requestHeaders, done );
  9295. } catch ( e ) {
  9296. // Rethrow post-completion exceptions
  9297. if ( completed ) {
  9298. throw e;
  9299. }
  9300. // Propagate others as results
  9301. done( -1, e );
  9302. }
  9303. }
  9304. // Callback for when everything is done
  9305. function done( status, nativeStatusText, responses, headers ) {
  9306. var isSuccess, success, error, response, modified,
  9307. statusText = nativeStatusText;
  9308. // Ignore repeat invocations
  9309. if ( completed ) {
  9310. return;
  9311. }
  9312. completed = true;
  9313. // Clear timeout if it exists
  9314. if ( timeoutTimer ) {
  9315. window.clearTimeout( timeoutTimer );
  9316. }
  9317. // Dereference transport for early garbage collection
  9318. // (no matter how long the jqXHR object will be used)
  9319. transport = undefined;
  9320. // Cache response headers
  9321. responseHeadersString = headers || "";
  9322. // Set readyState
  9323. jqXHR.readyState = status > 0 ? 4 : 0;
  9324. // Determine if successful
  9325. isSuccess = status >= 200 && status < 300 || status === 304;
  9326. // Get response data
  9327. if ( responses ) {
  9328. response = ajaxHandleResponses( s, jqXHR, responses );
  9329. }
  9330. // Convert no matter what (that way responseXXX fields are always set)
  9331. response = ajaxConvert( s, response, jqXHR, isSuccess );
  9332. // If successful, handle type chaining
  9333. if ( isSuccess ) {
  9334. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  9335. if ( s.ifModified ) {
  9336. modified = jqXHR.getResponseHeader( "Last-Modified" );
  9337. if ( modified ) {
  9338. jQuery.lastModified[ cacheURL ] = modified;
  9339. }
  9340. modified = jqXHR.getResponseHeader( "etag" );
  9341. if ( modified ) {
  9342. jQuery.etag[ cacheURL ] = modified;
  9343. }
  9344. }
  9345. // if no content
  9346. if ( status === 204 || s.type === "HEAD" ) {
  9347. statusText = "nocontent";
  9348. // if not modified
  9349. } else if ( status === 304 ) {
  9350. statusText = "notmodified";
  9351. // If we have data, let's convert it
  9352. } else {
  9353. statusText = response.state;
  9354. success = response.data;
  9355. error = response.error;
  9356. isSuccess = !error;
  9357. }
  9358. } else {
  9359. // Extract error from statusText and normalize for non-aborts
  9360. error = statusText;
  9361. if ( status || !statusText ) {
  9362. statusText = "error";
  9363. if ( status < 0 ) {
  9364. status = 0;
  9365. }
  9366. }
  9367. }
  9368. // Set data for the fake xhr object
  9369. jqXHR.status = status;
  9370. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  9371. // Success/Error
  9372. if ( isSuccess ) {
  9373. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  9374. } else {
  9375. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  9376. }
  9377. // Status-dependent callbacks
  9378. jqXHR.statusCode( statusCode );
  9379. statusCode = undefined;
  9380. if ( fireGlobals ) {
  9381. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  9382. [ jqXHR, s, isSuccess ? success : error ] );
  9383. }
  9384. // Complete
  9385. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  9386. if ( fireGlobals ) {
  9387. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  9388. // Handle the global AJAX counter
  9389. if ( !( --jQuery.active ) ) {
  9390. jQuery.event.trigger( "ajaxStop" );
  9391. }
  9392. }
  9393. }
  9394. return jqXHR;
  9395. },
  9396. getJSON: function( url, data, callback ) {
  9397. return jQuery.get( url, data, callback, "json" );
  9398. },
  9399. getScript: function( url, callback ) {
  9400. return jQuery.get( url, undefined, callback, "script" );
  9401. }
  9402. } );
  9403. jQuery.each( [ "get", "post" ], function( i, method ) {
  9404. jQuery[ method ] = function( url, data, callback, type ) {
  9405. // Shift arguments if data argument was omitted
  9406. if ( jQuery.isFunction( data ) ) {
  9407. type = type || callback;
  9408. callback = data;
  9409. data = undefined;
  9410. }
  9411. // The url can be an options object (which then must have .url)
  9412. return jQuery.ajax( jQuery.extend( {
  9413. url: url,
  9414. type: method,
  9415. dataType: type,
  9416. data: data,
  9417. success: callback
  9418. }, jQuery.isPlainObject( url ) && url ) );
  9419. };
  9420. } );
  9421. jQuery._evalUrl = function( url ) {
  9422. return jQuery.ajax( {
  9423. url: url,
  9424. // Make this explicit, since user can override this through ajaxSetup (#11264)
  9425. type: "GET",
  9426. dataType: "script",
  9427. cache: true,
  9428. async: false,
  9429. global: false,
  9430. "throws": true
  9431. } );
  9432. };
  9433. jQuery.fn.extend( {
  9434. wrapAll: function( html ) {
  9435. var wrap;
  9436. if ( this[ 0 ] ) {
  9437. if ( jQuery.isFunction( html ) ) {
  9438. html = html.call( this[ 0 ] );
  9439. }
  9440. // The elements to wrap the target around
  9441. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  9442. if ( this[ 0 ].parentNode ) {
  9443. wrap.insertBefore( this[ 0 ] );
  9444. }
  9445. wrap.map( function() {
  9446. var elem = this;
  9447. while ( elem.firstElementChild ) {
  9448. elem = elem.firstElementChild;
  9449. }
  9450. return elem;
  9451. } ).append( this );
  9452. }
  9453. return this;
  9454. },
  9455. wrapInner: function( html ) {
  9456. if ( jQuery.isFunction( html ) ) {
  9457. return this.each( function( i ) {
  9458. jQuery( this ).wrapInner( html.call( this, i ) );
  9459. } );
  9460. }
  9461. return this.each( function() {
  9462. var self = jQuery( this ),
  9463. contents = self.contents();
  9464. if ( contents.length ) {
  9465. contents.wrapAll( html );
  9466. } else {
  9467. self.append( html );
  9468. }
  9469. } );
  9470. },
  9471. wrap: function( html ) {
  9472. var isFunction = jQuery.isFunction( html );
  9473. return this.each( function( i ) {
  9474. jQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html );
  9475. } );
  9476. },
  9477. unwrap: function( selector ) {
  9478. this.parent( selector ).not( "body" ).each( function() {
  9479. jQuery( this ).replaceWith( this.childNodes );
  9480. } );
  9481. return this;
  9482. }
  9483. } );
  9484. jQuery.expr.pseudos.hidden = function( elem ) {
  9485. return !jQuery.expr.pseudos.visible( elem );
  9486. };
  9487. jQuery.expr.pseudos.visible = function( elem ) {
  9488. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  9489. };
  9490. jQuery.ajaxSettings.xhr = function() {
  9491. try {
  9492. return new window.XMLHttpRequest();
  9493. } catch ( e ) {}
  9494. };
  9495. var xhrSuccessStatus = {
  9496. // File protocol always yields status code 0, assume 200
  9497. 0: 200,
  9498. // Support: IE <=9 only
  9499. // #1450: sometimes IE returns 1223 when it should be 204
  9500. 1223: 204
  9501. },
  9502. xhrSupported = jQuery.ajaxSettings.xhr();
  9503. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  9504. support.ajax = xhrSupported = !!xhrSupported;
  9505. jQuery.ajaxTransport( function( options ) {
  9506. var callback, errorCallback;
  9507. // Cross domain only allowed if supported through XMLHttpRequest
  9508. if ( support.cors || xhrSupported && !options.crossDomain ) {
  9509. return {
  9510. send: function( headers, complete ) {
  9511. var i,
  9512. xhr = options.xhr();
  9513. xhr.open(
  9514. options.type,
  9515. options.url,
  9516. options.async,
  9517. options.username,
  9518. options.password
  9519. );
  9520. // Apply custom fields if provided
  9521. if ( options.xhrFields ) {
  9522. for ( i in options.xhrFields ) {
  9523. xhr[ i ] = options.xhrFields[ i ];
  9524. }
  9525. }
  9526. // Override mime type if needed
  9527. if ( options.mimeType && xhr.overrideMimeType ) {
  9528. xhr.overrideMimeType( options.mimeType );
  9529. }
  9530. // X-Requested-With header
  9531. // For cross-domain requests, seeing as conditions for a preflight are
  9532. // akin to a jigsaw puzzle, we simply never set it to be sure.
  9533. // (it can always be set on a per-request basis or even using ajaxSetup)
  9534. // For same-domain requests, won't change header if already provided.
  9535. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  9536. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  9537. }
  9538. // Set headers
  9539. for ( i in headers ) {
  9540. xhr.setRequestHeader( i, headers[ i ] );
  9541. }
  9542. // Callback
  9543. callback = function( type ) {
  9544. return function() {
  9545. if ( callback ) {
  9546. callback = errorCallback = xhr.onload =
  9547. xhr.onerror = xhr.onabort = xhr.onreadystatechange = null;
  9548. if ( type === "abort" ) {
  9549. xhr.abort();
  9550. } else if ( type === "error" ) {
  9551. // Support: IE <=9 only
  9552. // On a manual native abort, IE9 throws
  9553. // errors on any property access that is not readyState
  9554. if ( typeof xhr.status !== "number" ) {
  9555. complete( 0, "error" );
  9556. } else {
  9557. complete(
  9558. // File: protocol always yields status 0; see #8605, #14207
  9559. xhr.status,
  9560. xhr.statusText
  9561. );
  9562. }
  9563. } else {
  9564. complete(
  9565. xhrSuccessStatus[ xhr.status ] || xhr.status,
  9566. xhr.statusText,
  9567. // Support: IE <=9 only
  9568. // IE9 has no XHR2 but throws on binary (trac-11426)
  9569. // For XHR2 non-text, let the caller handle it (gh-2498)
  9570. ( xhr.responseType || "text" ) !== "text" ||
  9571. typeof xhr.responseText !== "string" ?
  9572. { binary: xhr.response } :
  9573. { text: xhr.responseText },
  9574. xhr.getAllResponseHeaders()
  9575. );
  9576. }
  9577. }
  9578. };
  9579. };
  9580. // Listen to events
  9581. xhr.onload = callback();
  9582. errorCallback = xhr.onerror = callback( "error" );
  9583. // Support: IE 9 only
  9584. // Use onreadystatechange to replace onabort
  9585. // to handle uncaught aborts
  9586. if ( xhr.onabort !== undefined ) {
  9587. xhr.onabort = errorCallback;
  9588. } else {
  9589. xhr.onreadystatechange = function() {
  9590. // Check readyState before timeout as it changes
  9591. if ( xhr.readyState === 4 ) {
  9592. // Allow onerror to be called first,
  9593. // but that will not handle a native abort
  9594. // Also, save errorCallback to a variable
  9595. // as xhr.onerror cannot be accessed
  9596. window.setTimeout( function() {
  9597. if ( callback ) {
  9598. errorCallback();
  9599. }
  9600. } );
  9601. }
  9602. };
  9603. }
  9604. // Create the abort callback
  9605. callback = callback( "abort" );
  9606. try {
  9607. // Do send the request (this may raise an exception)
  9608. xhr.send( options.hasContent && options.data || null );
  9609. } catch ( e ) {
  9610. // #14683: Only rethrow if this hasn't been notified as an error yet
  9611. if ( callback ) {
  9612. throw e;
  9613. }
  9614. }
  9615. },
  9616. abort: function() {
  9617. if ( callback ) {
  9618. callback();
  9619. }
  9620. }
  9621. };
  9622. }
  9623. } );
  9624. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  9625. jQuery.ajaxPrefilter( function( s ) {
  9626. if ( s.crossDomain ) {
  9627. s.contents.script = false;
  9628. }
  9629. } );
  9630. // Install script dataType
  9631. jQuery.ajaxSetup( {
  9632. accepts: {
  9633. script: "text/javascript, application/javascript, " +
  9634. "application/ecmascript, application/x-ecmascript"
  9635. },
  9636. contents: {
  9637. script: /\b(?:java|ecma)script\b/
  9638. },
  9639. converters: {
  9640. "text script": function( text ) {
  9641. jQuery.globalEval( text );
  9642. return text;
  9643. }
  9644. }
  9645. } );
  9646. // Handle cache's special case and crossDomain
  9647. jQuery.ajaxPrefilter( "script", function( s ) {
  9648. if ( s.cache === undefined ) {
  9649. s.cache = false;
  9650. }
  9651. if ( s.crossDomain ) {
  9652. s.type = "GET";
  9653. }
  9654. } );
  9655. // Bind script tag hack transport
  9656. jQuery.ajaxTransport( "script", function( s ) {
  9657. // This transport only deals with cross domain requests
  9658. if ( s.crossDomain ) {
  9659. var script, callback;
  9660. return {
  9661. send: function( _, complete ) {
  9662. script = jQuery( "<script>" ).prop( {
  9663. charset: s.scriptCharset,
  9664. src: s.url
  9665. } ).on(
  9666. "load error",
  9667. callback = function( evt ) {
  9668. script.remove();
  9669. callback = null;
  9670. if ( evt ) {
  9671. complete( evt.type === "error" ? 404 : 200, evt.type );
  9672. }
  9673. }
  9674. );
  9675. // Use native DOM manipulation to avoid our domManip AJAX trickery
  9676. document.head.appendChild( script[ 0 ] );
  9677. },
  9678. abort: function() {
  9679. if ( callback ) {
  9680. callback();
  9681. }
  9682. }
  9683. };
  9684. }
  9685. } );
  9686. var oldCallbacks = [],
  9687. rjsonp = /(=)\?(?=&|$)|\?\?/;
  9688. // Default jsonp settings
  9689. jQuery.ajaxSetup( {
  9690. jsonp: "callback",
  9691. jsonpCallback: function() {
  9692. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  9693. this[ callback ] = true;
  9694. return callback;
  9695. }
  9696. } );
  9697. // Detect, normalize options and install callbacks for jsonp requests
  9698. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  9699. var callbackName, overwritten, responseContainer,
  9700. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  9701. "url" :
  9702. typeof s.data === "string" &&
  9703. ( s.contentType || "" )
  9704. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  9705. rjsonp.test( s.data ) && "data"
  9706. );
  9707. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  9708. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  9709. // Get callback name, remembering preexisting value associated with it
  9710. callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
  9711. s.jsonpCallback() :
  9712. s.jsonpCallback;
  9713. // Insert callback into url or form data
  9714. if ( jsonProp ) {
  9715. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  9716. } else if ( s.jsonp !== false ) {
  9717. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  9718. }
  9719. // Use data converter to retrieve json after script execution
  9720. s.converters[ "script json" ] = function() {
  9721. if ( !responseContainer ) {
  9722. jQuery.error( callbackName + " was not called" );
  9723. }
  9724. return responseContainer[ 0 ];
  9725. };
  9726. // Force json dataType
  9727. s.dataTypes[ 0 ] = "json";
  9728. // Install callback
  9729. overwritten = window[ callbackName ];
  9730. window[ callbackName ] = function() {
  9731. responseContainer = arguments;
  9732. };
  9733. // Clean-up function (fires after converters)
  9734. jqXHR.always( function() {
  9735. // If previous value didn't exist - remove it
  9736. if ( overwritten === undefined ) {
  9737. jQuery( window ).removeProp( callbackName );
  9738. // Otherwise restore preexisting value
  9739. } else {
  9740. window[ callbackName ] = overwritten;
  9741. }
  9742. // Save back as free
  9743. if ( s[ callbackName ] ) {
  9744. // Make sure that re-using the options doesn't screw things around
  9745. s.jsonpCallback = originalSettings.jsonpCallback;
  9746. // Save the callback name for future use
  9747. oldCallbacks.push( callbackName );
  9748. }
  9749. // Call if it was a function and we have a response
  9750. if ( responseContainer && jQuery.isFunction( overwritten ) ) {
  9751. overwritten( responseContainer[ 0 ] );
  9752. }
  9753. responseContainer = overwritten = undefined;
  9754. } );
  9755. // Delegate to script
  9756. return "script";
  9757. }
  9758. } );
  9759. // Support: Safari 8 only
  9760. // In Safari 8 documents created via document.implementation.createHTMLDocument
  9761. // collapse sibling forms: the second one becomes a child of the first one.
  9762. // Because of that, this security measure has to be disabled in Safari 8.
  9763. // https://bugs.webkit.org/show_bug.cgi?id=137337
  9764. support.createHTMLDocument = ( function() {
  9765. var body = document.implementation.createHTMLDocument( "" ).body;
  9766. body.innerHTML = "<form></form><form></form>";
  9767. return body.childNodes.length === 2;
  9768. } )();
  9769. // Argument "data" should be string of html
  9770. // context (optional): If specified, the fragment will be created in this context,
  9771. // defaults to document
  9772. // keepScripts (optional): If true, will include scripts passed in the html string
  9773. jQuery.parseHTML = function( data, context, keepScripts ) {
  9774. if ( typeof data !== "string" ) {
  9775. return [];
  9776. }
  9777. if ( typeof context === "boolean" ) {
  9778. keepScripts = context;
  9779. context = false;
  9780. }
  9781. var base, parsed, scripts;
  9782. if ( !context ) {
  9783. // Stop scripts or inline event handlers from being executed immediately
  9784. // by using document.implementation
  9785. if ( support.createHTMLDocument ) {
  9786. context = document.implementation.createHTMLDocument( "" );
  9787. // Set the base href for the created document
  9788. // so any parsed elements with URLs
  9789. // are based on the document's URL (gh-2965)
  9790. base = context.createElement( "base" );
  9791. base.href = document.location.href;
  9792. context.head.appendChild( base );
  9793. } else {
  9794. context = document;
  9795. }
  9796. }
  9797. parsed = rsingleTag.exec( data );
  9798. scripts = !keepScripts && [];
  9799. // Single tag
  9800. if ( parsed ) {
  9801. return [ context.createElement( parsed[ 1 ] ) ];
  9802. }
  9803. parsed = buildFragment( [ data ], context, scripts );
  9804. if ( scripts && scripts.length ) {
  9805. jQuery( scripts ).remove();
  9806. }
  9807. return jQuery.merge( [], parsed.childNodes );
  9808. };
  9809. /**
  9810. * Load a url into a page
  9811. */
  9812. jQuery.fn.load = function( url, params, callback ) {
  9813. var selector, type, response,
  9814. self = this,
  9815. off = url.indexOf( " " );
  9816. if ( off > -1 ) {
  9817. selector = stripAndCollapse( url.slice( off ) );
  9818. url = url.slice( 0, off );
  9819. }
  9820. // If it's a function
  9821. if ( jQuery.isFunction( params ) ) {
  9822. // We assume that it's the callback
  9823. callback = params;
  9824. params = undefined;
  9825. // Otherwise, build a param string
  9826. } else if ( params && typeof params === "object" ) {
  9827. type = "POST";
  9828. }
  9829. // If we have elements to modify, make the request
  9830. if ( self.length > 0 ) {
  9831. jQuery.ajax( {
  9832. url: url,
  9833. // If "type" variable is undefined, then "GET" method will be used.
  9834. // Make value of this field explicit since
  9835. // user can override it through ajaxSetup method
  9836. type: type || "GET",
  9837. dataType: "html",
  9838. data: params
  9839. } ).done( function( responseText ) {
  9840. // Save response for use in complete callback
  9841. response = arguments;
  9842. self.html( selector ?
  9843. // If a selector was specified, locate the right elements in a dummy div
  9844. // Exclude scripts to avoid IE 'Permission Denied' errors
  9845. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  9846. // Otherwise use the full result
  9847. responseText );
  9848. // If the request succeeds, this function gets "data", "status", "jqXHR"
  9849. // but they are ignored because response was set above.
  9850. // If it fails, this function gets "jqXHR", "status", "error"
  9851. } ).always( callback && function( jqXHR, status ) {
  9852. self.each( function() {
  9853. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  9854. } );
  9855. } );
  9856. }
  9857. return this;
  9858. };
  9859. // Attach a bunch of functions for handling common AJAX events
  9860. jQuery.each( [
  9861. "ajaxStart",
  9862. "ajaxStop",
  9863. "ajaxComplete",
  9864. "ajaxError",
  9865. "ajaxSuccess",
  9866. "ajaxSend"
  9867. ], function( i, type ) {
  9868. jQuery.fn[ type ] = function( fn ) {
  9869. return this.on( type, fn );
  9870. };
  9871. } );
  9872. jQuery.expr.pseudos.animated = function( elem ) {
  9873. return jQuery.grep( jQuery.timers, function( fn ) {
  9874. return elem === fn.elem;
  9875. } ).length;
  9876. };
  9877. jQuery.offset = {
  9878. setOffset: function( elem, options, i ) {
  9879. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  9880. position = jQuery.css( elem, "position" ),
  9881. curElem = jQuery( elem ),
  9882. props = {};
  9883. // Set position first, in-case top/left are set even on static elem
  9884. if ( position === "static" ) {
  9885. elem.style.position = "relative";
  9886. }
  9887. curOffset = curElem.offset();
  9888. curCSSTop = jQuery.css( elem, "top" );
  9889. curCSSLeft = jQuery.css( elem, "left" );
  9890. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  9891. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  9892. // Need to be able to calculate position if either
  9893. // top or left is auto and position is either absolute or fixed
  9894. if ( calculatePosition ) {
  9895. curPosition = curElem.position();
  9896. curTop = curPosition.top;
  9897. curLeft = curPosition.left;
  9898. } else {
  9899. curTop = parseFloat( curCSSTop ) || 0;
  9900. curLeft = parseFloat( curCSSLeft ) || 0;
  9901. }
  9902. if ( jQuery.isFunction( options ) ) {
  9903. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  9904. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  9905. }
  9906. if ( options.top != null ) {
  9907. props.top = ( options.top - curOffset.top ) + curTop;
  9908. }
  9909. if ( options.left != null ) {
  9910. props.left = ( options.left - curOffset.left ) + curLeft;
  9911. }
  9912. if ( "using" in options ) {
  9913. options.using.call( elem, props );
  9914. } else {
  9915. curElem.css( props );
  9916. }
  9917. }
  9918. };
  9919. jQuery.fn.extend( {
  9920. offset: function( options ) {
  9921. // Preserve chaining for setter
  9922. if ( arguments.length ) {
  9923. return options === undefined ?
  9924. this :
  9925. this.each( function( i ) {
  9926. jQuery.offset.setOffset( this, options, i );
  9927. } );
  9928. }
  9929. var doc, docElem, rect, win,
  9930. elem = this[ 0 ];
  9931. if ( !elem ) {
  9932. return;
  9933. }
  9934. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  9935. // Support: IE <=11 only
  9936. // Running getBoundingClientRect on a
  9937. // disconnected node in IE throws an error
  9938. if ( !elem.getClientRects().length ) {
  9939. return { top: 0, left: 0 };
  9940. }
  9941. rect = elem.getBoundingClientRect();
  9942. doc = elem.ownerDocument;
  9943. docElem = doc.documentElement;
  9944. win = doc.defaultView;
  9945. return {
  9946. top: rect.top + win.pageYOffset - docElem.clientTop,
  9947. left: rect.left + win.pageXOffset - docElem.clientLeft
  9948. };
  9949. },
  9950. position: function() {
  9951. if ( !this[ 0 ] ) {
  9952. return;
  9953. }
  9954. var offsetParent, offset,
  9955. elem = this[ 0 ],
  9956. parentOffset = { top: 0, left: 0 };
  9957. // Fixed elements are offset from window (parentOffset = {top:0, left: 0},
  9958. // because it is its only offset parent
  9959. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  9960. // Assume getBoundingClientRect is there when computed position is fixed
  9961. offset = elem.getBoundingClientRect();
  9962. } else {
  9963. // Get *real* offsetParent
  9964. offsetParent = this.offsetParent();
  9965. // Get correct offsets
  9966. offset = this.offset();
  9967. if ( !nodeName( offsetParent[ 0 ], "html" ) ) {
  9968. parentOffset = offsetParent.offset();
  9969. }
  9970. // Add offsetParent borders
  9971. parentOffset = {
  9972. top: parentOffset.top + jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ),
  9973. left: parentOffset.left + jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true )
  9974. };
  9975. }
  9976. // Subtract parent offsets and element margins
  9977. return {
  9978. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  9979. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  9980. };
  9981. },
  9982. // This method will return documentElement in the following cases:
  9983. // 1) For the element inside the iframe without offsetParent, this method will return
  9984. // documentElement of the parent window
  9985. // 2) For the hidden or detached element
  9986. // 3) For body or html element, i.e. in case of the html node - it will return itself
  9987. //
  9988. // but those exceptions were never presented as a real life use-cases
  9989. // and might be considered as more preferable results.
  9990. //
  9991. // This logic, however, is not guaranteed and can change at any point in the future
  9992. offsetParent: function() {
  9993. return this.map( function() {
  9994. var offsetParent = this.offsetParent;
  9995. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  9996. offsetParent = offsetParent.offsetParent;
  9997. }
  9998. return offsetParent || documentElement;
  9999. } );
  10000. }
  10001. } );
  10002. // Create scrollLeft and scrollTop methods
  10003. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  10004. var top = "pageYOffset" === prop;
  10005. jQuery.fn[ method ] = function( val ) {
  10006. return access( this, function( elem, method, val ) {
  10007. // Coalesce documents and windows
  10008. var win;
  10009. if ( jQuery.isWindow( elem ) ) {
  10010. win = elem;
  10011. } else if ( elem.nodeType === 9 ) {
  10012. win = elem.defaultView;
  10013. }
  10014. if ( val === undefined ) {
  10015. return win ? win[ prop ] : elem[ method ];
  10016. }
  10017. if ( win ) {
  10018. win.scrollTo(
  10019. !top ? val : win.pageXOffset,
  10020. top ? val : win.pageYOffset
  10021. );
  10022. } else {
  10023. elem[ method ] = val;
  10024. }
  10025. }, method, val, arguments.length );
  10026. };
  10027. } );
  10028. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  10029. // Add the top/left cssHooks using jQuery.fn.position
  10030. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  10031. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  10032. // getComputedStyle returns percent when specified for top/left/bottom/right;
  10033. // rather than make the css module depend on the offset module, just check for it here
  10034. jQuery.each( [ "top", "left" ], function( i, prop ) {
  10035. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  10036. function( elem, computed ) {
  10037. if ( computed ) {
  10038. computed = curCSS( elem, prop );
  10039. // If curCSS returns percentage, fallback to offset
  10040. return rnumnonpx.test( computed ) ?
  10041. jQuery( elem ).position()[ prop ] + "px" :
  10042. computed;
  10043. }
  10044. }
  10045. );
  10046. } );
  10047. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  10048. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  10049. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  10050. function( defaultExtra, funcName ) {
  10051. // Margin is only for outerHeight, outerWidth
  10052. jQuery.fn[ funcName ] = function( margin, value ) {
  10053. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  10054. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  10055. return access( this, function( elem, type, value ) {
  10056. var doc;
  10057. if ( jQuery.isWindow( elem ) ) {
  10058. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  10059. return funcName.indexOf( "outer" ) === 0 ?
  10060. elem[ "inner" + name ] :
  10061. elem.document.documentElement[ "client" + name ];
  10062. }
  10063. // Get document width or height
  10064. if ( elem.nodeType === 9 ) {
  10065. doc = elem.documentElement;
  10066. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  10067. // whichever is greatest
  10068. return Math.max(
  10069. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  10070. elem.body[ "offset" + name ], doc[ "offset" + name ],
  10071. doc[ "client" + name ]
  10072. );
  10073. }
  10074. return value === undefined ?
  10075. // Get width or height on the element, requesting but not forcing parseFloat
  10076. jQuery.css( elem, type, extra ) :
  10077. // Set width or height on the element
  10078. jQuery.style( elem, type, value, extra );
  10079. }, type, chainable ? margin : undefined, chainable );
  10080. };
  10081. } );
  10082. } );
  10083. jQuery.fn.extend( {
  10084. bind: function( types, data, fn ) {
  10085. return this.on( types, null, data, fn );
  10086. },
  10087. unbind: function( types, fn ) {
  10088. return this.off( types, null, fn );
  10089. },
  10090. delegate: function( selector, types, data, fn ) {
  10091. return this.on( types, selector, data, fn );
  10092. },
  10093. undelegate: function( selector, types, fn ) {
  10094. // ( namespace ) or ( selector, types [, fn] )
  10095. return arguments.length === 1 ?
  10096. this.off( selector, "**" ) :
  10097. this.off( types, selector || "**", fn );
  10098. }
  10099. } );
  10100. jQuery.holdReady = function( hold ) {
  10101. if ( hold ) {
  10102. jQuery.readyWait++;
  10103. } else {
  10104. jQuery.ready( true );
  10105. }
  10106. };
  10107. jQuery.isArray = Array.isArray;
  10108. jQuery.parseJSON = JSON.parse;
  10109. jQuery.nodeName = nodeName;
  10110. // Register as a named AMD module, since jQuery can be concatenated with other
  10111. // files that may use define, but not via a proper concatenation script that
  10112. // understands anonymous AMD modules. A named AMD is safest and most robust
  10113. // way to register. Lowercase jquery is used because AMD module names are
  10114. // derived from file names, and jQuery is normally delivered in a lowercase
  10115. // file name. Do this after creating the global so that if an AMD module wants
  10116. // to call noConflict to hide this version of jQuery, it will work.
  10117. // Note that for maximum portability, libraries that are not jQuery should
  10118. // declare themselves as anonymous modules, and avoid setting a global if an
  10119. // AMD loader is present. jQuery is a special case. For more information, see
  10120. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  10121. if ( typeof define === "function" && define.amd ) {
  10122. define( "jquery", [], function() {
  10123. return jQuery;
  10124. } );
  10125. }
  10126. var
  10127. // Map over jQuery in case of overwrite
  10128. _jQuery = window.jQuery,
  10129. // Map over the $ in case of overwrite
  10130. _$ = window.$;
  10131. jQuery.noConflict = function( deep ) {
  10132. if ( window.$ === jQuery ) {
  10133. window.$ = _$;
  10134. }
  10135. if ( deep && window.jQuery === jQuery ) {
  10136. window.jQuery = _jQuery;
  10137. }
  10138. return jQuery;
  10139. };
  10140. // Expose jQuery and $ identifiers, even in AMD
  10141. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  10142. // and CommonJS for browser emulators (#13566)
  10143. if ( !noGlobal ) {
  10144. window.jQuery = window.$ = jQuery;
  10145. }
  10146. return jQuery;
  10147. } );
  10148. });
  10149. define('jquery-ui', function (require, exports, module) {
  10150. /*! jQuery UI - v1.12.1 - 2016-09-14
  10151. * http://jqueryui.com
  10152. * Includes: widget.js, position.js, data.js, disable-selection.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js, effects/effect-clip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect-fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effect-puff.js, effects/effect-pulsate.js, effects/effect-scale.js, effects/effect-shake.js, effects/effect-size.js, effects/effect-slide.js, effects/effect-transfer.js, focusable.js, form-reset-mixin.js, jquery-1-7.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio.js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/draggable.js, widgets/droppable.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, widgets/resizable.js, widgets/selectable.js, widgets/selectmenu.js, widgets/slider.js, widgets/sortable.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.js
  10153. * Copyright jQuery Foundation and other contributors; Licensed MIT */
  10154. (function( factory ) {
  10155. if ( typeof define === "function" && define.amd ) {
  10156. // AMD. Register as an anonymous module.
  10157. define([ "jquery" ], factory );
  10158. } else {
  10159. // Browser globals
  10160. factory( jQuery );
  10161. }
  10162. }(function( $ ) {
  10163. $.ui = $.ui || {};
  10164. var version = $.ui.version = "1.12.1";
  10165. /*!
  10166. * jQuery UI Widget 1.12.1
  10167. * http://jqueryui.com
  10168. *
  10169. * Copyright jQuery Foundation and other contributors
  10170. * Released under the MIT license.
  10171. * http://jquery.org/license
  10172. */
  10173. //>>label: Widget
  10174. //>>group: Core
  10175. //>>description: Provides a factory for creating stateful widgets with a common API.
  10176. //>>docs: http://api.jqueryui.com/jQuery.widget/
  10177. //>>demos: http://jqueryui.com/widget/
  10178. var widgetUuid = 0;
  10179. var widgetSlice = Array.prototype.slice;
  10180. $.cleanData = ( function( orig ) {
  10181. return function( elems ) {
  10182. var events, elem, i;
  10183. for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) {
  10184. try {
  10185. // Only trigger remove when necessary to save time
  10186. events = $._data( elem, "events" );
  10187. if ( events && events.remove ) {
  10188. $( elem ).triggerHandler( "remove" );
  10189. }
  10190. // Http://bugs.jquery.com/ticket/8235
  10191. } catch ( e ) {}
  10192. }
  10193. orig( elems );
  10194. };
  10195. } )( $.cleanData );
  10196. $.widget = function( name, base, prototype ) {
  10197. var existingConstructor, constructor, basePrototype;
  10198. // ProxiedPrototype allows the provided prototype to remain unmodified
  10199. // so that it can be used as a mixin for multiple widgets (#8876)
  10200. var proxiedPrototype = {};
  10201. var namespace = name.split( "." )[ 0 ];
  10202. name = name.split( "." )[ 1 ];
  10203. var fullName = namespace + "-" + name;
  10204. if ( !prototype ) {
  10205. prototype = base;
  10206. base = $.Widget;
  10207. }
  10208. if ( $.isArray( prototype ) ) {
  10209. prototype = $.extend.apply( null, [ {} ].concat( prototype ) );
  10210. }
  10211. // Create selector for plugin
  10212. $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
  10213. return !!$.data( elem, fullName );
  10214. };
  10215. $[ namespace ] = $[ namespace ] || {};
  10216. existingConstructor = $[ namespace ][ name ];
  10217. constructor = $[ namespace ][ name ] = function( options, element ) {
  10218. // Allow instantiation without "new" keyword
  10219. if ( !this._createWidget ) {
  10220. return new constructor( options, element );
  10221. }
  10222. // Allow instantiation without initializing for simple inheritance
  10223. // must use "new" keyword (the code above always passes args)
  10224. if ( arguments.length ) {
  10225. this._createWidget( options, element );
  10226. }
  10227. };
  10228. // Extend with the existing constructor to carry over any static properties
  10229. $.extend( constructor, existingConstructor, {
  10230. version: prototype.version,
  10231. // Copy the object used to create the prototype in case we need to
  10232. // redefine the widget later
  10233. _proto: $.extend( {}, prototype ),
  10234. // Track widgets that inherit from this widget in case this widget is
  10235. // redefined after a widget inherits from it
  10236. _childConstructors: []
  10237. } );
  10238. basePrototype = new base();
  10239. // We need to make the options hash a property directly on the new instance
  10240. // otherwise we'll modify the options hash on the prototype that we're
  10241. // inheriting from
  10242. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  10243. $.each( prototype, function( prop, value ) {
  10244. if ( !$.isFunction( value ) ) {
  10245. proxiedPrototype[ prop ] = value;
  10246. return;
  10247. }
  10248. proxiedPrototype[ prop ] = ( function() {
  10249. function _super() {
  10250. return base.prototype[ prop ].apply( this, arguments );
  10251. }
  10252. function _superApply( args ) {
  10253. return base.prototype[ prop ].apply( this, args );
  10254. }
  10255. return function() {
  10256. var __super = this._super;
  10257. var __superApply = this._superApply;
  10258. var returnValue;
  10259. this._super = _super;
  10260. this._superApply = _superApply;
  10261. returnValue = value.apply( this, arguments );
  10262. this._super = __super;
  10263. this._superApply = __superApply;
  10264. return returnValue;
  10265. };
  10266. } )();
  10267. } );
  10268. constructor.prototype = $.widget.extend( basePrototype, {
  10269. // TODO: remove support for widgetEventPrefix
  10270. // always use the name + a colon as the prefix, e.g., draggable:start
  10271. // don't prefix for widgets that aren't DOM-based
  10272. widgetEventPrefix: existingConstructor ? ( basePrototype.widgetEventPrefix || name ) : name
  10273. }, proxiedPrototype, {
  10274. constructor: constructor,
  10275. namespace: namespace,
  10276. widgetName: name,
  10277. widgetFullName: fullName
  10278. } );
  10279. // If this widget is being redefined then we need to find all widgets that
  10280. // are inheriting from it and redefine all of them so that they inherit from
  10281. // the new version of this widget. We're essentially trying to replace one
  10282. // level in the prototype chain.
  10283. if ( existingConstructor ) {
  10284. $.each( existingConstructor._childConstructors, function( i, child ) {
  10285. var childPrototype = child.prototype;
  10286. // Redefine the child widget using the same prototype that was
  10287. // originally used, but inherit from the new version of the base
  10288. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor,
  10289. child._proto );
  10290. } );
  10291. // Remove the list of existing child constructors from the old constructor
  10292. // so the old child constructors can be garbage collected
  10293. delete existingConstructor._childConstructors;
  10294. } else {
  10295. base._childConstructors.push( constructor );
  10296. }
  10297. $.widget.bridge( name, constructor );
  10298. return constructor;
  10299. };
  10300. $.widget.extend = function( target ) {
  10301. var input = widgetSlice.call( arguments, 1 );
  10302. var inputIndex = 0;
  10303. var inputLength = input.length;
  10304. var key;
  10305. var value;
  10306. for ( ; inputIndex < inputLength; inputIndex++ ) {
  10307. for ( key in input[ inputIndex ] ) {
  10308. value = input[ inputIndex ][ key ];
  10309. if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
  10310. // Clone objects
  10311. if ( $.isPlainObject( value ) ) {
  10312. target[ key ] = $.isPlainObject( target[ key ] ) ?
  10313. $.widget.extend( {}, target[ key ], value ) :
  10314. // Don't extend strings, arrays, etc. with objects
  10315. $.widget.extend( {}, value );
  10316. // Copy everything else by reference
  10317. } else {
  10318. target[ key ] = value;
  10319. }
  10320. }
  10321. }
  10322. }
  10323. return target;
  10324. };
  10325. $.widget.bridge = function( name, object ) {
  10326. var fullName = object.prototype.widgetFullName || name;
  10327. $.fn[ name ] = function( options ) {
  10328. var isMethodCall = typeof options === "string";
  10329. var args = widgetSlice.call( arguments, 1 );
  10330. var returnValue = this;
  10331. if ( isMethodCall ) {
  10332. // If this is an empty collection, we need to have the instance method
  10333. // return undefined instead of the jQuery instance
  10334. if ( !this.length && options === "instance" ) {
  10335. returnValue = undefined;
  10336. } else {
  10337. this.each( function() {
  10338. var methodValue;
  10339. var instance = $.data( this, fullName );
  10340. if ( options === "instance" ) {
  10341. returnValue = instance;
  10342. return false;
  10343. }
  10344. if ( !instance ) {
  10345. return $.error( "cannot call methods on " + name +
  10346. " prior to initialization; " +
  10347. "attempted to call method '" + options + "'" );
  10348. }
  10349. if ( !$.isFunction( instance[ options ] ) || options.charAt( 0 ) === "_" ) {
  10350. return $.error( "no such method '" + options + "' for " + name +
  10351. " widget instance" );
  10352. }
  10353. methodValue = instance[ options ].apply( instance, args );
  10354. if ( methodValue !== instance && methodValue !== undefined ) {
  10355. returnValue = methodValue && methodValue.jquery ?
  10356. returnValue.pushStack( methodValue.get() ) :
  10357. methodValue;
  10358. return false;
  10359. }
  10360. } );
  10361. }
  10362. } else {
  10363. // Allow multiple hashes to be passed on init
  10364. if ( args.length ) {
  10365. options = $.widget.extend.apply( null, [ options ].concat( args ) );
  10366. }
  10367. this.each( function() {
  10368. var instance = $.data( this, fullName );
  10369. if ( instance ) {
  10370. instance.option( options || {} );
  10371. if ( instance._init ) {
  10372. instance._init();
  10373. }
  10374. } else {
  10375. $.data( this, fullName, new object( options, this ) );
  10376. }
  10377. } );
  10378. }
  10379. return returnValue;
  10380. };
  10381. };
  10382. $.Widget = function( /* options, element */ ) {};
  10383. $.Widget._childConstructors = [];
  10384. $.Widget.prototype = {
  10385. widgetName: "widget",
  10386. widgetEventPrefix: "",
  10387. defaultElement: "<div>",
  10388. options: {
  10389. classes: {},
  10390. disabled: false,
  10391. // Callbacks
  10392. create: null
  10393. },
  10394. _createWidget: function( options, element ) {
  10395. element = $( element || this.defaultElement || this )[ 0 ];
  10396. this.element = $( element );
  10397. this.uuid = widgetUuid++;
  10398. this.eventNamespace = "." + this.widgetName + this.uuid;
  10399. this.bindings = $();
  10400. this.hoverable = $();
  10401. this.focusable = $();
  10402. this.classesElementLookup = {};
  10403. if ( element !== this ) {
  10404. $.data( element, this.widgetFullName, this );
  10405. this._on( true, this.element, {
  10406. remove: function( event ) {
  10407. if ( event.target === element ) {
  10408. this.destroy();
  10409. }
  10410. }
  10411. } );
  10412. this.document = $( element.style ?
  10413. // Element within the document
  10414. element.ownerDocument :
  10415. // Element is window or document
  10416. element.document || element );
  10417. this.window = $( this.document[ 0 ].defaultView || this.document[ 0 ].parentWindow );
  10418. }
  10419. this.options = $.widget.extend( {},
  10420. this.options,
  10421. this._getCreateOptions(),
  10422. options );
  10423. this._create();
  10424. if ( this.options.disabled ) {
  10425. this._setOptionDisabled( this.options.disabled );
  10426. }
  10427. this._trigger( "create", null, this._getCreateEventData() );
  10428. this._init();
  10429. },
  10430. _getCreateOptions: function() {
  10431. return {};
  10432. },
  10433. _getCreateEventData: $.noop,
  10434. _create: $.noop,
  10435. _init: $.noop,
  10436. destroy: function() {
  10437. var that = this;
  10438. this._destroy();
  10439. $.each( this.classesElementLookup, function( key, value ) {
  10440. that._removeClass( value, key );
  10441. } );
  10442. // We can probably remove the unbind calls in 2.0
  10443. // all event bindings should go through this._on()
  10444. this.element
  10445. .off( this.eventNamespace )
  10446. .removeData( this.widgetFullName );
  10447. this.widget()
  10448. .off( this.eventNamespace )
  10449. .removeAttr( "aria-disabled" );
  10450. // Clean up events and states
  10451. this.bindings.off( this.eventNamespace );
  10452. },
  10453. _destroy: $.noop,
  10454. widget: function() {
  10455. return this.element;
  10456. },
  10457. option: function( key, value ) {
  10458. var options = key;
  10459. var parts;
  10460. var curOption;
  10461. var i;
  10462. if ( arguments.length === 0 ) {
  10463. // Don't return a reference to the internal hash
  10464. return $.widget.extend( {}, this.options );
  10465. }
  10466. if ( typeof key === "string" ) {
  10467. // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  10468. options = {};
  10469. parts = key.split( "." );
  10470. key = parts.shift();
  10471. if ( parts.length ) {
  10472. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  10473. for ( i = 0; i < parts.length - 1; i++ ) {
  10474. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  10475. curOption = curOption[ parts[ i ] ];
  10476. }
  10477. key = parts.pop();
  10478. if ( arguments.length === 1 ) {
  10479. return curOption[ key ] === undefined ? null : curOption[ key ];
  10480. }
  10481. curOption[ key ] = value;
  10482. } else {
  10483. if ( arguments.length === 1 ) {
  10484. return this.options[ key ] === undefined ? null : this.options[ key ];
  10485. }
  10486. options[ key ] = value;
  10487. }
  10488. }
  10489. this._setOptions( options );
  10490. return this;
  10491. },
  10492. _setOptions: function( options ) {
  10493. var key;
  10494. for ( key in options ) {
  10495. this._setOption( key, options[ key ] );
  10496. }
  10497. return this;
  10498. },
  10499. _setOption: function( key, value ) {
  10500. if ( key === "classes" ) {
  10501. this._setOptionClasses( value );
  10502. }
  10503. this.options[ key ] = value;
  10504. if ( key === "disabled" ) {
  10505. this._setOptionDisabled( value );
  10506. }
  10507. return this;
  10508. },
  10509. _setOptionClasses: function( value ) {
  10510. var classKey, elements, currentElements;
  10511. for ( classKey in value ) {
  10512. currentElements = this.classesElementLookup[ classKey ];
  10513. if ( value[ classKey ] === this.options.classes[ classKey ] ||
  10514. !currentElements ||
  10515. !currentElements.length ) {
  10516. continue;
  10517. }
  10518. // We are doing this to create a new jQuery object because the _removeClass() call
  10519. // on the next line is going to destroy the reference to the current elements being
  10520. // tracked. We need to save a copy of this collection so that we can add the new classes
  10521. // below.
  10522. elements = $( currentElements.get() );
  10523. this._removeClass( currentElements, classKey );
  10524. // We don't use _addClass() here, because that uses this.options.classes
  10525. // for generating the string of classes. We want to use the value passed in from
  10526. // _setOption(), this is the new value of the classes option which was passed to
  10527. // _setOption(). We pass this value directly to _classes().
  10528. elements.addClass( this._classes( {
  10529. element: elements,
  10530. keys: classKey,
  10531. classes: value,
  10532. add: true
  10533. } ) );
  10534. }
  10535. },
  10536. _setOptionDisabled: function( value ) {
  10537. this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value );
  10538. // If the widget is becoming disabled, then nothing is interactive
  10539. if ( value ) {
  10540. this._removeClass( this.hoverable, null, "ui-state-hover" );
  10541. this._removeClass( this.focusable, null, "ui-state-focus" );
  10542. }
  10543. },
  10544. enable: function() {
  10545. return this._setOptions( { disabled: false } );
  10546. },
  10547. disable: function() {
  10548. return this._setOptions( { disabled: true } );
  10549. },
  10550. _classes: function( options ) {
  10551. var full = [];
  10552. var that = this;
  10553. options = $.extend( {
  10554. element: this.element,
  10555. classes: this.options.classes || {}
  10556. }, options );
  10557. function processClassString( classes, checkOption ) {
  10558. var current, i;
  10559. for ( i = 0; i < classes.length; i++ ) {
  10560. current = that.classesElementLookup[ classes[ i ] ] || $();
  10561. if ( options.add ) {
  10562. current = $( $.unique( current.get().concat( options.element.get() ) ) );
  10563. } else {
  10564. current = $( current.not( options.element ).get() );
  10565. }
  10566. that.classesElementLookup[ classes[ i ] ] = current;
  10567. full.push( classes[ i ] );
  10568. if ( checkOption && options.classes[ classes[ i ] ] ) {
  10569. full.push( options.classes[ classes[ i ] ] );
  10570. }
  10571. }
  10572. }
  10573. this._on( options.element, {
  10574. "remove": "_untrackClassesElement"
  10575. } );
  10576. if ( options.keys ) {
  10577. processClassString( options.keys.match( /\S+/g ) || [], true );
  10578. }
  10579. if ( options.extra ) {
  10580. processClassString( options.extra.match( /\S+/g ) || [] );
  10581. }
  10582. return full.join( " " );
  10583. },
  10584. _untrackClassesElement: function( event ) {
  10585. var that = this;
  10586. $.each( that.classesElementLookup, function( key, value ) {
  10587. if ( $.inArray( event.target, value ) !== -1 ) {
  10588. that.classesElementLookup[ key ] = $( value.not( event.target ).get() );
  10589. }
  10590. } );
  10591. },
  10592. _removeClass: function( element, keys, extra ) {
  10593. return this._toggleClass( element, keys, extra, false );
  10594. },
  10595. _addClass: function( element, keys, extra ) {
  10596. return this._toggleClass( element, keys, extra, true );
  10597. },
  10598. _toggleClass: function( element, keys, extra, add ) {
  10599. add = ( typeof add === "boolean" ) ? add : extra;
  10600. var shift = ( typeof element === "string" || element === null ),
  10601. options = {
  10602. extra: shift ? keys : extra,
  10603. keys: shift ? element : keys,
  10604. element: shift ? this.element : element,
  10605. add: add
  10606. };
  10607. options.element.toggleClass( this._classes( options ), add );
  10608. return this;
  10609. },
  10610. _on: function( suppressDisabledCheck, element, handlers ) {
  10611. var delegateElement;
  10612. var instance = this;
  10613. // No suppressDisabledCheck flag, shuffle arguments
  10614. if ( typeof suppressDisabledCheck !== "boolean" ) {
  10615. handlers = element;
  10616. element = suppressDisabledCheck;
  10617. suppressDisabledCheck = false;
  10618. }
  10619. // No element argument, shuffle and use this.element
  10620. if ( !handlers ) {
  10621. handlers = element;
  10622. element = this.element;
  10623. delegateElement = this.widget();
  10624. } else {
  10625. element = delegateElement = $( element );
  10626. this.bindings = this.bindings.add( element );
  10627. }
  10628. $.each( handlers, function( event, handler ) {
  10629. function handlerProxy() {
  10630. // Allow widgets to customize the disabled handling
  10631. // - disabled as an array instead of boolean
  10632. // - disabled class as method for disabling individual parts
  10633. if ( !suppressDisabledCheck &&
  10634. ( instance.options.disabled === true ||
  10635. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  10636. return;
  10637. }
  10638. return ( typeof handler === "string" ? instance[ handler ] : handler )
  10639. .apply( instance, arguments );
  10640. }
  10641. // Copy the guid so direct unbinding works
  10642. if ( typeof handler !== "string" ) {
  10643. handlerProxy.guid = handler.guid =
  10644. handler.guid || handlerProxy.guid || $.guid++;
  10645. }
  10646. var match = event.match( /^([\w:-]*)\s*(.*)$/ );
  10647. var eventName = match[ 1 ] + instance.eventNamespace;
  10648. var selector = match[ 2 ];
  10649. if ( selector ) {
  10650. delegateElement.on( eventName, selector, handlerProxy );
  10651. } else {
  10652. element.on( eventName, handlerProxy );
  10653. }
  10654. } );
  10655. },
  10656. _off: function( element, eventName ) {
  10657. eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) +
  10658. this.eventNamespace;
  10659. element.off( eventName ).off( eventName );
  10660. // Clear the stack to avoid memory leaks (#10056)
  10661. this.bindings = $( this.bindings.not( element ).get() );
  10662. this.focusable = $( this.focusable.not( element ).get() );
  10663. this.hoverable = $( this.hoverable.not( element ).get() );
  10664. },
  10665. _delay: function( handler, delay ) {
  10666. function handlerProxy() {
  10667. return ( typeof handler === "string" ? instance[ handler ] : handler )
  10668. .apply( instance, arguments );
  10669. }
  10670. var instance = this;
  10671. return setTimeout( handlerProxy, delay || 0 );
  10672. },
  10673. _hoverable: function( element ) {
  10674. this.hoverable = this.hoverable.add( element );
  10675. this._on( element, {
  10676. mouseenter: function( event ) {
  10677. this._addClass( $( event.currentTarget ), null, "ui-state-hover" );
  10678. },
  10679. mouseleave: function( event ) {
  10680. this._removeClass( $( event.currentTarget ), null, "ui-state-hover" );
  10681. }
  10682. } );
  10683. },
  10684. _focusable: function( element ) {
  10685. this.focusable = this.focusable.add( element );
  10686. this._on( element, {
  10687. focusin: function( event ) {
  10688. this._addClass( $( event.currentTarget ), null, "ui-state-focus" );
  10689. },
  10690. focusout: function( event ) {
  10691. this._removeClass( $( event.currentTarget ), null, "ui-state-focus" );
  10692. }
  10693. } );
  10694. },
  10695. _trigger: function( type, event, data ) {
  10696. var prop, orig;
  10697. var callback = this.options[ type ];
  10698. data = data || {};
  10699. event = $.Event( event );
  10700. event.type = ( type === this.widgetEventPrefix ?
  10701. type :
  10702. this.widgetEventPrefix + type ).toLowerCase();
  10703. // The original event may come from any element
  10704. // so we need to reset the target on the new event
  10705. event.target = this.element[ 0 ];
  10706. // Copy original event properties over to the new event
  10707. orig = event.originalEvent;
  10708. if ( orig ) {
  10709. for ( prop in orig ) {
  10710. if ( !( prop in event ) ) {
  10711. event[ prop ] = orig[ prop ];
  10712. }
  10713. }
  10714. }
  10715. this.element.trigger( event, data );
  10716. return !( $.isFunction( callback ) &&
  10717. callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false ||
  10718. event.isDefaultPrevented() );
  10719. }
  10720. };
  10721. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  10722. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  10723. if ( typeof options === "string" ) {
  10724. options = { effect: options };
  10725. }
  10726. var hasOptions;
  10727. var effectName = !options ?
  10728. method :
  10729. options === true || typeof options === "number" ?
  10730. defaultEffect :
  10731. options.effect || defaultEffect;
  10732. options = options || {};
  10733. if ( typeof options === "number" ) {
  10734. options = { duration: options };
  10735. }
  10736. hasOptions = !$.isEmptyObject( options );
  10737. options.complete = callback;
  10738. if ( options.delay ) {
  10739. element.delay( options.delay );
  10740. }
  10741. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  10742. element[ method ]( options );
  10743. } else if ( effectName !== method && element[ effectName ] ) {
  10744. element[ effectName ]( options.duration, options.easing, callback );
  10745. } else {
  10746. element.queue( function( next ) {
  10747. $( this )[ method ]();
  10748. if ( callback ) {
  10749. callback.call( element[ 0 ] );
  10750. }
  10751. next();
  10752. } );
  10753. }
  10754. };
  10755. } );
  10756. var widget = $.widget;
  10757. /*!
  10758. * jQuery UI Position 1.12.1
  10759. * http://jqueryui.com
  10760. *
  10761. * Copyright jQuery Foundation and other contributors
  10762. * Released under the MIT license.
  10763. * http://jquery.org/license
  10764. *
  10765. * http://api.jqueryui.com/position/
  10766. */
  10767. //>>label: Position
  10768. //>>group: Core
  10769. //>>description: Positions elements relative to other elements.
  10770. //>>docs: http://api.jqueryui.com/position/
  10771. //>>demos: http://jqueryui.com/position/
  10772. ( function() {
  10773. var cachedScrollbarWidth,
  10774. max = Math.max,
  10775. abs = Math.abs,
  10776. rhorizontal = /left|center|right/,
  10777. rvertical = /top|center|bottom/,
  10778. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  10779. rposition = /^\w+/,
  10780. rpercent = /%$/,
  10781. _position = $.fn.position;
  10782. function getOffsets( offsets, width, height ) {
  10783. return [
  10784. parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  10785. parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  10786. ];
  10787. }
  10788. function parseCss( element, property ) {
  10789. return parseInt( $.css( element, property ), 10 ) || 0;
  10790. }
  10791. function getDimensions( elem ) {
  10792. var raw = elem[ 0 ];
  10793. if ( raw.nodeType === 9 ) {
  10794. return {
  10795. width: elem.width(),
  10796. height: elem.height(),
  10797. offset: { top: 0, left: 0 }
  10798. };
  10799. }
  10800. if ( $.isWindow( raw ) ) {
  10801. return {
  10802. width: elem.width(),
  10803. height: elem.height(),
  10804. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  10805. };
  10806. }
  10807. if ( raw.preventDefault ) {
  10808. return {
  10809. width: 0,
  10810. height: 0,
  10811. offset: { top: raw.pageY, left: raw.pageX }
  10812. };
  10813. }
  10814. return {
  10815. width: elem.outerWidth(),
  10816. height: elem.outerHeight(),
  10817. offset: elem.offset()
  10818. };
  10819. }
  10820. $.position = {
  10821. scrollbarWidth: function() {
  10822. if ( cachedScrollbarWidth !== undefined ) {
  10823. return cachedScrollbarWidth;
  10824. }
  10825. var w1, w2,
  10826. div = $( "<div " +
  10827. "style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'>" +
  10828. "<div style='height:100px;width:auto;'></div></div>" ),
  10829. innerDiv = div.children()[ 0 ];
  10830. $( "body" ).append( div );
  10831. w1 = innerDiv.offsetWidth;
  10832. div.css( "overflow", "scroll" );
  10833. w2 = innerDiv.offsetWidth;
  10834. if ( w1 === w2 ) {
  10835. w2 = div[ 0 ].clientWidth;
  10836. }
  10837. div.remove();
  10838. return ( cachedScrollbarWidth = w1 - w2 );
  10839. },
  10840. getScrollInfo: function( within ) {
  10841. var overflowX = within.isWindow || within.isDocument ? "" :
  10842. within.element.css( "overflow-x" ),
  10843. overflowY = within.isWindow || within.isDocument ? "" :
  10844. within.element.css( "overflow-y" ),
  10845. hasOverflowX = overflowX === "scroll" ||
  10846. ( overflowX === "auto" && within.width < within.element[ 0 ].scrollWidth ),
  10847. hasOverflowY = overflowY === "scroll" ||
  10848. ( overflowY === "auto" && within.height < within.element[ 0 ].scrollHeight );
  10849. return {
  10850. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  10851. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  10852. };
  10853. },
  10854. getWithinInfo: function( element ) {
  10855. var withinElement = $( element || window ),
  10856. isWindow = $.isWindow( withinElement[ 0 ] ),
  10857. isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9,
  10858. hasOffset = !isWindow && !isDocument;
  10859. return {
  10860. element: withinElement,
  10861. isWindow: isWindow,
  10862. isDocument: isDocument,
  10863. offset: hasOffset ? $( element ).offset() : { left: 0, top: 0 },
  10864. scrollLeft: withinElement.scrollLeft(),
  10865. scrollTop: withinElement.scrollTop(),
  10866. width: withinElement.outerWidth(),
  10867. height: withinElement.outerHeight()
  10868. };
  10869. }
  10870. };
  10871. $.fn.position = function( options ) {
  10872. if ( !options || !options.of ) {
  10873. return _position.apply( this, arguments );
  10874. }
  10875. // Make a copy, we don't want to modify arguments
  10876. options = $.extend( {}, options );
  10877. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  10878. target = $( options.of ),
  10879. within = $.position.getWithinInfo( options.within ),
  10880. scrollInfo = $.position.getScrollInfo( within ),
  10881. collision = ( options.collision || "flip" ).split( " " ),
  10882. offsets = {};
  10883. dimensions = getDimensions( target );
  10884. if ( target[ 0 ].preventDefault ) {
  10885. // Force left top to allow flipping
  10886. options.at = "left top";
  10887. }
  10888. targetWidth = dimensions.width;
  10889. targetHeight = dimensions.height;
  10890. targetOffset = dimensions.offset;
  10891. // Clone to reuse original targetOffset later
  10892. basePosition = $.extend( {}, targetOffset );
  10893. // Force my and at to have valid horizontal and vertical positions
  10894. // if a value is missing or invalid, it will be converted to center
  10895. $.each( [ "my", "at" ], function() {
  10896. var pos = ( options[ this ] || "" ).split( " " ),
  10897. horizontalOffset,
  10898. verticalOffset;
  10899. if ( pos.length === 1 ) {
  10900. pos = rhorizontal.test( pos[ 0 ] ) ?
  10901. pos.concat( [ "center" ] ) :
  10902. rvertical.test( pos[ 0 ] ) ?
  10903. [ "center" ].concat( pos ) :
  10904. [ "center", "center" ];
  10905. }
  10906. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  10907. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  10908. // Calculate offsets
  10909. horizontalOffset = roffset.exec( pos[ 0 ] );
  10910. verticalOffset = roffset.exec( pos[ 1 ] );
  10911. offsets[ this ] = [
  10912. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  10913. verticalOffset ? verticalOffset[ 0 ] : 0
  10914. ];
  10915. // Reduce to just the positions without the offsets
  10916. options[ this ] = [
  10917. rposition.exec( pos[ 0 ] )[ 0 ],
  10918. rposition.exec( pos[ 1 ] )[ 0 ]
  10919. ];
  10920. } );
  10921. // Normalize collision option
  10922. if ( collision.length === 1 ) {
  10923. collision[ 1 ] = collision[ 0 ];
  10924. }
  10925. if ( options.at[ 0 ] === "right" ) {
  10926. basePosition.left += targetWidth;
  10927. } else if ( options.at[ 0 ] === "center" ) {
  10928. basePosition.left += targetWidth / 2;
  10929. }
  10930. if ( options.at[ 1 ] === "bottom" ) {
  10931. basePosition.top += targetHeight;
  10932. } else if ( options.at[ 1 ] === "center" ) {
  10933. basePosition.top += targetHeight / 2;
  10934. }
  10935. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  10936. basePosition.left += atOffset[ 0 ];
  10937. basePosition.top += atOffset[ 1 ];
  10938. return this.each( function() {
  10939. var collisionPosition, using,
  10940. elem = $( this ),
  10941. elemWidth = elem.outerWidth(),
  10942. elemHeight = elem.outerHeight(),
  10943. marginLeft = parseCss( this, "marginLeft" ),
  10944. marginTop = parseCss( this, "marginTop" ),
  10945. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) +
  10946. scrollInfo.width,
  10947. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) +
  10948. scrollInfo.height,
  10949. position = $.extend( {}, basePosition ),
  10950. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  10951. if ( options.my[ 0 ] === "right" ) {
  10952. position.left -= elemWidth;
  10953. } else if ( options.my[ 0 ] === "center" ) {
  10954. position.left -= elemWidth / 2;
  10955. }
  10956. if ( options.my[ 1 ] === "bottom" ) {
  10957. position.top -= elemHeight;
  10958. } else if ( options.my[ 1 ] === "center" ) {
  10959. position.top -= elemHeight / 2;
  10960. }
  10961. position.left += myOffset[ 0 ];
  10962. position.top += myOffset[ 1 ];
  10963. collisionPosition = {
  10964. marginLeft: marginLeft,
  10965. marginTop: marginTop
  10966. };
  10967. $.each( [ "left", "top" ], function( i, dir ) {
  10968. if ( $.ui.position[ collision[ i ] ] ) {
  10969. $.ui.position[ collision[ i ] ][ dir ]( position, {
  10970. targetWidth: targetWidth,
  10971. targetHeight: targetHeight,
  10972. elemWidth: elemWidth,
  10973. elemHeight: elemHeight,
  10974. collisionPosition: collisionPosition,
  10975. collisionWidth: collisionWidth,
  10976. collisionHeight: collisionHeight,
  10977. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  10978. my: options.my,
  10979. at: options.at,
  10980. within: within,
  10981. elem: elem
  10982. } );
  10983. }
  10984. } );
  10985. if ( options.using ) {
  10986. // Adds feedback as second argument to using callback, if present
  10987. using = function( props ) {
  10988. var left = targetOffset.left - position.left,
  10989. right = left + targetWidth - elemWidth,
  10990. top = targetOffset.top - position.top,
  10991. bottom = top + targetHeight - elemHeight,
  10992. feedback = {
  10993. target: {
  10994. element: target,
  10995. left: targetOffset.left,
  10996. top: targetOffset.top,
  10997. width: targetWidth,
  10998. height: targetHeight
  10999. },
  11000. element: {
  11001. element: elem,
  11002. left: position.left,
  11003. top: position.top,
  11004. width: elemWidth,
  11005. height: elemHeight
  11006. },
  11007. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  11008. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  11009. };
  11010. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  11011. feedback.horizontal = "center";
  11012. }
  11013. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  11014. feedback.vertical = "middle";
  11015. }
  11016. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  11017. feedback.important = "horizontal";
  11018. } else {
  11019. feedback.important = "vertical";
  11020. }
  11021. options.using.call( this, props, feedback );
  11022. };
  11023. }
  11024. elem.offset( $.extend( position, { using: using } ) );
  11025. } );
  11026. };
  11027. $.ui.position = {
  11028. fit: {
  11029. left: function( position, data ) {
  11030. var within = data.within,
  11031. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  11032. outerWidth = within.width,
  11033. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  11034. overLeft = withinOffset - collisionPosLeft,
  11035. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  11036. newOverRight;
  11037. // Element is wider than within
  11038. if ( data.collisionWidth > outerWidth ) {
  11039. // Element is initially over the left side of within
  11040. if ( overLeft > 0 && overRight <= 0 ) {
  11041. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth -
  11042. withinOffset;
  11043. position.left += overLeft - newOverRight;
  11044. // Element is initially over right side of within
  11045. } else if ( overRight > 0 && overLeft <= 0 ) {
  11046. position.left = withinOffset;
  11047. // Element is initially over both left and right sides of within
  11048. } else {
  11049. if ( overLeft > overRight ) {
  11050. position.left = withinOffset + outerWidth - data.collisionWidth;
  11051. } else {
  11052. position.left = withinOffset;
  11053. }
  11054. }
  11055. // Too far left -> align with left edge
  11056. } else if ( overLeft > 0 ) {
  11057. position.left += overLeft;
  11058. // Too far right -> align with right edge
  11059. } else if ( overRight > 0 ) {
  11060. position.left -= overRight;
  11061. // Adjust based on position and margin
  11062. } else {
  11063. position.left = max( position.left - collisionPosLeft, position.left );
  11064. }
  11065. },
  11066. top: function( position, data ) {
  11067. var within = data.within,
  11068. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  11069. outerHeight = data.within.height,
  11070. collisionPosTop = position.top - data.collisionPosition.marginTop,
  11071. overTop = withinOffset - collisionPosTop,
  11072. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  11073. newOverBottom;
  11074. // Element is taller than within
  11075. if ( data.collisionHeight > outerHeight ) {
  11076. // Element is initially over the top of within
  11077. if ( overTop > 0 && overBottom <= 0 ) {
  11078. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight -
  11079. withinOffset;
  11080. position.top += overTop - newOverBottom;
  11081. // Element is initially over bottom of within
  11082. } else if ( overBottom > 0 && overTop <= 0 ) {
  11083. position.top = withinOffset;
  11084. // Element is initially over both top and bottom of within
  11085. } else {
  11086. if ( overTop > overBottom ) {
  11087. position.top = withinOffset + outerHeight - data.collisionHeight;
  11088. } else {
  11089. position.top = withinOffset;
  11090. }
  11091. }
  11092. // Too far up -> align with top
  11093. } else if ( overTop > 0 ) {
  11094. position.top += overTop;
  11095. // Too far down -> align with bottom edge
  11096. } else if ( overBottom > 0 ) {
  11097. position.top -= overBottom;
  11098. // Adjust based on position and margin
  11099. } else {
  11100. position.top = max( position.top - collisionPosTop, position.top );
  11101. }
  11102. }
  11103. },
  11104. flip: {
  11105. left: function( position, data ) {
  11106. var within = data.within,
  11107. withinOffset = within.offset.left + within.scrollLeft,
  11108. outerWidth = within.width,
  11109. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  11110. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  11111. overLeft = collisionPosLeft - offsetLeft,
  11112. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  11113. myOffset = data.my[ 0 ] === "left" ?
  11114. -data.elemWidth :
  11115. data.my[ 0 ] === "right" ?
  11116. data.elemWidth :
  11117. 0,
  11118. atOffset = data.at[ 0 ] === "left" ?
  11119. data.targetWidth :
  11120. data.at[ 0 ] === "right" ?
  11121. -data.targetWidth :
  11122. 0,
  11123. offset = -2 * data.offset[ 0 ],
  11124. newOverRight,
  11125. newOverLeft;
  11126. if ( overLeft < 0 ) {
  11127. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth -
  11128. outerWidth - withinOffset;
  11129. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  11130. position.left += myOffset + atOffset + offset;
  11131. }
  11132. } else if ( overRight > 0 ) {
  11133. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset +
  11134. atOffset + offset - offsetLeft;
  11135. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  11136. position.left += myOffset + atOffset + offset;
  11137. }
  11138. }
  11139. },
  11140. top: function( position, data ) {
  11141. var within = data.within,
  11142. withinOffset = within.offset.top + within.scrollTop,
  11143. outerHeight = within.height,
  11144. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  11145. collisionPosTop = position.top - data.collisionPosition.marginTop,
  11146. overTop = collisionPosTop - offsetTop,
  11147. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  11148. top = data.my[ 1 ] === "top",
  11149. myOffset = top ?
  11150. -data.elemHeight :
  11151. data.my[ 1 ] === "bottom" ?
  11152. data.elemHeight :
  11153. 0,
  11154. atOffset = data.at[ 1 ] === "top" ?
  11155. data.targetHeight :
  11156. data.at[ 1 ] === "bottom" ?
  11157. -data.targetHeight :
  11158. 0,
  11159. offset = -2 * data.offset[ 1 ],
  11160. newOverTop,
  11161. newOverBottom;
  11162. if ( overTop < 0 ) {
  11163. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight -
  11164. outerHeight - withinOffset;
  11165. if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) {
  11166. position.top += myOffset + atOffset + offset;
  11167. }
  11168. } else if ( overBottom > 0 ) {
  11169. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset +
  11170. offset - offsetTop;
  11171. if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) {
  11172. position.top += myOffset + atOffset + offset;
  11173. }
  11174. }
  11175. }
  11176. },
  11177. flipfit: {
  11178. left: function() {
  11179. $.ui.position.flip.left.apply( this, arguments );
  11180. $.ui.position.fit.left.apply( this, arguments );
  11181. },
  11182. top: function() {
  11183. $.ui.position.flip.top.apply( this, arguments );
  11184. $.ui.position.fit.top.apply( this, arguments );
  11185. }
  11186. }
  11187. };
  11188. } )();
  11189. var position = $.ui.position;
  11190. /*!
  11191. * jQuery UI :data 1.12.1
  11192. * http://jqueryui.com
  11193. *
  11194. * Copyright jQuery Foundation and other contributors
  11195. * Released under the MIT license.
  11196. * http://jquery.org/license
  11197. */
  11198. //>>label: :data Selector
  11199. //>>group: Core
  11200. //>>description: Selects elements which have data stored under the specified key.
  11201. //>>docs: http://api.jqueryui.com/data-selector/
  11202. var data = $.extend( $.expr[ ":" ], {
  11203. data: $.expr.createPseudo ?
  11204. $.expr.createPseudo( function( dataName ) {
  11205. return function( elem ) {
  11206. return !!$.data( elem, dataName );
  11207. };
  11208. } ) :
  11209. // Support: jQuery <1.8
  11210. function( elem, i, match ) {
  11211. return !!$.data( elem, match[ 3 ] );
  11212. }
  11213. } );
  11214. /*!
  11215. * jQuery UI Disable Selection 1.12.1
  11216. * http://jqueryui.com
  11217. *
  11218. * Copyright jQuery Foundation and other contributors
  11219. * Released under the MIT license.
  11220. * http://jquery.org/license
  11221. */
  11222. //>>label: disableSelection
  11223. //>>group: Core
  11224. //>>description: Disable selection of text content within the set of matched elements.
  11225. //>>docs: http://api.jqueryui.com/disableSelection/
  11226. // This file is deprecated
  11227. var disableSelection = $.fn.extend( {
  11228. disableSelection: ( function() {
  11229. var eventType = "onselectstart" in document.createElement( "div" ) ?
  11230. "selectstart" :
  11231. "mousedown";
  11232. return function() {
  11233. return this.on( eventType + ".ui-disableSelection", function( event ) {
  11234. event.preventDefault();
  11235. } );
  11236. };
  11237. } )(),
  11238. enableSelection: function() {
  11239. return this.off( ".ui-disableSelection" );
  11240. }
  11241. } );
  11242. /*!
  11243. * jQuery UI Effects 1.12.1
  11244. * http://jqueryui.com
  11245. *
  11246. * Copyright jQuery Foundation and other contributors
  11247. * Released under the MIT license.
  11248. * http://jquery.org/license
  11249. */
  11250. //>>label: Effects Core
  11251. //>>group: Effects
  11252. // jscs:disable maximumLineLength
  11253. //>>description: Extends the internal jQuery effects. Includes morphing and easing. Required by all other effects.
  11254. // jscs:enable maximumLineLength
  11255. //>>docs: http://api.jqueryui.com/category/effects-core/
  11256. //>>demos: http://jqueryui.com/effect/
  11257. var dataSpace = "ui-effects-",
  11258. dataSpaceStyle = "ui-effects-style",
  11259. dataSpaceAnimated = "ui-effects-animated",
  11260. // Create a local jQuery because jQuery Color relies on it and the
  11261. // global may not exist with AMD and a custom build (#10199)
  11262. jQuery = $;
  11263. $.effects = {
  11264. effect: {}
  11265. };
  11266. /*!
  11267. * jQuery Color Animations v2.1.2
  11268. * https://github.com/jquery/jquery-color
  11269. *
  11270. * Copyright 2014 jQuery Foundation and other contributors
  11271. * Released under the MIT license.
  11272. * http://jquery.org/license
  11273. *
  11274. * Date: Wed Jan 16 08:47:09 2013 -0600
  11275. */
  11276. ( function( jQuery, undefined ) {
  11277. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor " +
  11278. "borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  11279. // Plusequals test for += 100 -= 100
  11280. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  11281. // A set of RE's that can match strings and generate color tuples.
  11282. stringParsers = [ {
  11283. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  11284. parse: function( execResult ) {
  11285. return [
  11286. execResult[ 1 ],
  11287. execResult[ 2 ],
  11288. execResult[ 3 ],
  11289. execResult[ 4 ]
  11290. ];
  11291. }
  11292. }, {
  11293. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  11294. parse: function( execResult ) {
  11295. return [
  11296. execResult[ 1 ] * 2.55,
  11297. execResult[ 2 ] * 2.55,
  11298. execResult[ 3 ] * 2.55,
  11299. execResult[ 4 ]
  11300. ];
  11301. }
  11302. }, {
  11303. // This regex ignores A-F because it's compared against an already lowercased string
  11304. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  11305. parse: function( execResult ) {
  11306. return [
  11307. parseInt( execResult[ 1 ], 16 ),
  11308. parseInt( execResult[ 2 ], 16 ),
  11309. parseInt( execResult[ 3 ], 16 )
  11310. ];
  11311. }
  11312. }, {
  11313. // This regex ignores A-F because it's compared against an already lowercased string
  11314. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  11315. parse: function( execResult ) {
  11316. return [
  11317. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  11318. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  11319. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  11320. ];
  11321. }
  11322. }, {
  11323. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  11324. space: "hsla",
  11325. parse: function( execResult ) {
  11326. return [
  11327. execResult[ 1 ],
  11328. execResult[ 2 ] / 100,
  11329. execResult[ 3 ] / 100,
  11330. execResult[ 4 ]
  11331. ];
  11332. }
  11333. } ],
  11334. // JQuery.Color( )
  11335. color = jQuery.Color = function( color, green, blue, alpha ) {
  11336. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  11337. },
  11338. spaces = {
  11339. rgba: {
  11340. props: {
  11341. red: {
  11342. idx: 0,
  11343. type: "byte"
  11344. },
  11345. green: {
  11346. idx: 1,
  11347. type: "byte"
  11348. },
  11349. blue: {
  11350. idx: 2,
  11351. type: "byte"
  11352. }
  11353. }
  11354. },
  11355. hsla: {
  11356. props: {
  11357. hue: {
  11358. idx: 0,
  11359. type: "degrees"
  11360. },
  11361. saturation: {
  11362. idx: 1,
  11363. type: "percent"
  11364. },
  11365. lightness: {
  11366. idx: 2,
  11367. type: "percent"
  11368. }
  11369. }
  11370. }
  11371. },
  11372. propTypes = {
  11373. "byte": {
  11374. floor: true,
  11375. max: 255
  11376. },
  11377. "percent": {
  11378. max: 1
  11379. },
  11380. "degrees": {
  11381. mod: 360,
  11382. floor: true
  11383. }
  11384. },
  11385. support = color.support = {},
  11386. // Element for support tests
  11387. supportElem = jQuery( "<p>" )[ 0 ],
  11388. // Colors = jQuery.Color.names
  11389. colors,
  11390. // Local aliases of functions called often
  11391. each = jQuery.each;
  11392. // Determine rgba support immediately
  11393. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  11394. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  11395. // Define cache name and alpha properties
  11396. // for rgba and hsla spaces
  11397. each( spaces, function( spaceName, space ) {
  11398. space.cache = "_" + spaceName;
  11399. space.props.alpha = {
  11400. idx: 3,
  11401. type: "percent",
  11402. def: 1
  11403. };
  11404. } );
  11405. function clamp( value, prop, allowEmpty ) {
  11406. var type = propTypes[ prop.type ] || {};
  11407. if ( value == null ) {
  11408. return ( allowEmpty || !prop.def ) ? null : prop.def;
  11409. }
  11410. // ~~ is an short way of doing floor for positive numbers
  11411. value = type.floor ? ~~value : parseFloat( value );
  11412. // IE will pass in empty strings as value for alpha,
  11413. // which will hit this case
  11414. if ( isNaN( value ) ) {
  11415. return prop.def;
  11416. }
  11417. if ( type.mod ) {
  11418. // We add mod before modding to make sure that negatives values
  11419. // get converted properly: -10 -> 350
  11420. return ( value + type.mod ) % type.mod;
  11421. }
  11422. // For now all property types without mod have min and max
  11423. return 0 > value ? 0 : type.max < value ? type.max : value;
  11424. }
  11425. function stringParse( string ) {
  11426. var inst = color(),
  11427. rgba = inst._rgba = [];
  11428. string = string.toLowerCase();
  11429. each( stringParsers, function( i, parser ) {
  11430. var parsed,
  11431. match = parser.re.exec( string ),
  11432. values = match && parser.parse( match ),
  11433. spaceName = parser.space || "rgba";
  11434. if ( values ) {
  11435. parsed = inst[ spaceName ]( values );
  11436. // If this was an rgba parse the assignment might happen twice
  11437. // oh well....
  11438. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  11439. rgba = inst._rgba = parsed._rgba;
  11440. // Exit each( stringParsers ) here because we matched
  11441. return false;
  11442. }
  11443. } );
  11444. // Found a stringParser that handled it
  11445. if ( rgba.length ) {
  11446. // If this came from a parsed string, force "transparent" when alpha is 0
  11447. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  11448. if ( rgba.join() === "0,0,0,0" ) {
  11449. jQuery.extend( rgba, colors.transparent );
  11450. }
  11451. return inst;
  11452. }
  11453. // Named colors
  11454. return colors[ string ];
  11455. }
  11456. color.fn = jQuery.extend( color.prototype, {
  11457. parse: function( red, green, blue, alpha ) {
  11458. if ( red === undefined ) {
  11459. this._rgba = [ null, null, null, null ];
  11460. return this;
  11461. }
  11462. if ( red.jquery || red.nodeType ) {
  11463. red = jQuery( red ).css( green );
  11464. green = undefined;
  11465. }
  11466. var inst = this,
  11467. type = jQuery.type( red ),
  11468. rgba = this._rgba = [];
  11469. // More than 1 argument specified - assume ( red, green, blue, alpha )
  11470. if ( green !== undefined ) {
  11471. red = [ red, green, blue, alpha ];
  11472. type = "array";
  11473. }
  11474. if ( type === "string" ) {
  11475. return this.parse( stringParse( red ) || colors._default );
  11476. }
  11477. if ( type === "array" ) {
  11478. each( spaces.rgba.props, function( key, prop ) {
  11479. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  11480. } );
  11481. return this;
  11482. }
  11483. if ( type === "object" ) {
  11484. if ( red instanceof color ) {
  11485. each( spaces, function( spaceName, space ) {
  11486. if ( red[ space.cache ] ) {
  11487. inst[ space.cache ] = red[ space.cache ].slice();
  11488. }
  11489. } );
  11490. } else {
  11491. each( spaces, function( spaceName, space ) {
  11492. var cache = space.cache;
  11493. each( space.props, function( key, prop ) {
  11494. // If the cache doesn't exist, and we know how to convert
  11495. if ( !inst[ cache ] && space.to ) {
  11496. // If the value was null, we don't need to copy it
  11497. // if the key was alpha, we don't need to copy it either
  11498. if ( key === "alpha" || red[ key ] == null ) {
  11499. return;
  11500. }
  11501. inst[ cache ] = space.to( inst._rgba );
  11502. }
  11503. // This is the only case where we allow nulls for ALL properties.
  11504. // call clamp with alwaysAllowEmpty
  11505. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  11506. } );
  11507. // Everything defined but alpha?
  11508. if ( inst[ cache ] &&
  11509. jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  11510. // Use the default of 1
  11511. inst[ cache ][ 3 ] = 1;
  11512. if ( space.from ) {
  11513. inst._rgba = space.from( inst[ cache ] );
  11514. }
  11515. }
  11516. } );
  11517. }
  11518. return this;
  11519. }
  11520. },
  11521. is: function( compare ) {
  11522. var is = color( compare ),
  11523. same = true,
  11524. inst = this;
  11525. each( spaces, function( _, space ) {
  11526. var localCache,
  11527. isCache = is[ space.cache ];
  11528. if ( isCache ) {
  11529. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  11530. each( space.props, function( _, prop ) {
  11531. if ( isCache[ prop.idx ] != null ) {
  11532. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  11533. return same;
  11534. }
  11535. } );
  11536. }
  11537. return same;
  11538. } );
  11539. return same;
  11540. },
  11541. _space: function() {
  11542. var used = [],
  11543. inst = this;
  11544. each( spaces, function( spaceName, space ) {
  11545. if ( inst[ space.cache ] ) {
  11546. used.push( spaceName );
  11547. }
  11548. } );
  11549. return used.pop();
  11550. },
  11551. transition: function( other, distance ) {
  11552. var end = color( other ),
  11553. spaceName = end._space(),
  11554. space = spaces[ spaceName ],
  11555. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  11556. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  11557. result = start.slice();
  11558. end = end[ space.cache ];
  11559. each( space.props, function( key, prop ) {
  11560. var index = prop.idx,
  11561. startValue = start[ index ],
  11562. endValue = end[ index ],
  11563. type = propTypes[ prop.type ] || {};
  11564. // If null, don't override start value
  11565. if ( endValue === null ) {
  11566. return;
  11567. }
  11568. // If null - use end
  11569. if ( startValue === null ) {
  11570. result[ index ] = endValue;
  11571. } else {
  11572. if ( type.mod ) {
  11573. if ( endValue - startValue > type.mod / 2 ) {
  11574. startValue += type.mod;
  11575. } else if ( startValue - endValue > type.mod / 2 ) {
  11576. startValue -= type.mod;
  11577. }
  11578. }
  11579. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  11580. }
  11581. } );
  11582. return this[ spaceName ]( result );
  11583. },
  11584. blend: function( opaque ) {
  11585. // If we are already opaque - return ourself
  11586. if ( this._rgba[ 3 ] === 1 ) {
  11587. return this;
  11588. }
  11589. var rgb = this._rgba.slice(),
  11590. a = rgb.pop(),
  11591. blend = color( opaque )._rgba;
  11592. return color( jQuery.map( rgb, function( v, i ) {
  11593. return ( 1 - a ) * blend[ i ] + a * v;
  11594. } ) );
  11595. },
  11596. toRgbaString: function() {
  11597. var prefix = "rgba(",
  11598. rgba = jQuery.map( this._rgba, function( v, i ) {
  11599. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  11600. } );
  11601. if ( rgba[ 3 ] === 1 ) {
  11602. rgba.pop();
  11603. prefix = "rgb(";
  11604. }
  11605. return prefix + rgba.join() + ")";
  11606. },
  11607. toHslaString: function() {
  11608. var prefix = "hsla(",
  11609. hsla = jQuery.map( this.hsla(), function( v, i ) {
  11610. if ( v == null ) {
  11611. v = i > 2 ? 1 : 0;
  11612. }
  11613. // Catch 1 and 2
  11614. if ( i && i < 3 ) {
  11615. v = Math.round( v * 100 ) + "%";
  11616. }
  11617. return v;
  11618. } );
  11619. if ( hsla[ 3 ] === 1 ) {
  11620. hsla.pop();
  11621. prefix = "hsl(";
  11622. }
  11623. return prefix + hsla.join() + ")";
  11624. },
  11625. toHexString: function( includeAlpha ) {
  11626. var rgba = this._rgba.slice(),
  11627. alpha = rgba.pop();
  11628. if ( includeAlpha ) {
  11629. rgba.push( ~~( alpha * 255 ) );
  11630. }
  11631. return "#" + jQuery.map( rgba, function( v ) {
  11632. // Default to 0 when nulls exist
  11633. v = ( v || 0 ).toString( 16 );
  11634. return v.length === 1 ? "0" + v : v;
  11635. } ).join( "" );
  11636. },
  11637. toString: function() {
  11638. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  11639. }
  11640. } );
  11641. color.fn.parse.prototype = color.fn;
  11642. // Hsla conversions adapted from:
  11643. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  11644. function hue2rgb( p, q, h ) {
  11645. h = ( h + 1 ) % 1;
  11646. if ( h * 6 < 1 ) {
  11647. return p + ( q - p ) * h * 6;
  11648. }
  11649. if ( h * 2 < 1 ) {
  11650. return q;
  11651. }
  11652. if ( h * 3 < 2 ) {
  11653. return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6;
  11654. }
  11655. return p;
  11656. }
  11657. spaces.hsla.to = function( rgba ) {
  11658. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  11659. return [ null, null, null, rgba[ 3 ] ];
  11660. }
  11661. var r = rgba[ 0 ] / 255,
  11662. g = rgba[ 1 ] / 255,
  11663. b = rgba[ 2 ] / 255,
  11664. a = rgba[ 3 ],
  11665. max = Math.max( r, g, b ),
  11666. min = Math.min( r, g, b ),
  11667. diff = max - min,
  11668. add = max + min,
  11669. l = add * 0.5,
  11670. h, s;
  11671. if ( min === max ) {
  11672. h = 0;
  11673. } else if ( r === max ) {
  11674. h = ( 60 * ( g - b ) / diff ) + 360;
  11675. } else if ( g === max ) {
  11676. h = ( 60 * ( b - r ) / diff ) + 120;
  11677. } else {
  11678. h = ( 60 * ( r - g ) / diff ) + 240;
  11679. }
  11680. // Chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  11681. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  11682. if ( diff === 0 ) {
  11683. s = 0;
  11684. } else if ( l <= 0.5 ) {
  11685. s = diff / add;
  11686. } else {
  11687. s = diff / ( 2 - add );
  11688. }
  11689. return [ Math.round( h ) % 360, s, l, a == null ? 1 : a ];
  11690. };
  11691. spaces.hsla.from = function( hsla ) {
  11692. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  11693. return [ null, null, null, hsla[ 3 ] ];
  11694. }
  11695. var h = hsla[ 0 ] / 360,
  11696. s = hsla[ 1 ],
  11697. l = hsla[ 2 ],
  11698. a = hsla[ 3 ],
  11699. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  11700. p = 2 * l - q;
  11701. return [
  11702. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  11703. Math.round( hue2rgb( p, q, h ) * 255 ),
  11704. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  11705. a
  11706. ];
  11707. };
  11708. each( spaces, function( spaceName, space ) {
  11709. var props = space.props,
  11710. cache = space.cache,
  11711. to = space.to,
  11712. from = space.from;
  11713. // Makes rgba() and hsla()
  11714. color.fn[ spaceName ] = function( value ) {
  11715. // Generate a cache for this space if it doesn't exist
  11716. if ( to && !this[ cache ] ) {
  11717. this[ cache ] = to( this._rgba );
  11718. }
  11719. if ( value === undefined ) {
  11720. return this[ cache ].slice();
  11721. }
  11722. var ret,
  11723. type = jQuery.type( value ),
  11724. arr = ( type === "array" || type === "object" ) ? value : arguments,
  11725. local = this[ cache ].slice();
  11726. each( props, function( key, prop ) {
  11727. var val = arr[ type === "object" ? key : prop.idx ];
  11728. if ( val == null ) {
  11729. val = local[ prop.idx ];
  11730. }
  11731. local[ prop.idx ] = clamp( val, prop );
  11732. } );
  11733. if ( from ) {
  11734. ret = color( from( local ) );
  11735. ret[ cache ] = local;
  11736. return ret;
  11737. } else {
  11738. return color( local );
  11739. }
  11740. };
  11741. // Makes red() green() blue() alpha() hue() saturation() lightness()
  11742. each( props, function( key, prop ) {
  11743. // Alpha is included in more than one space
  11744. if ( color.fn[ key ] ) {
  11745. return;
  11746. }
  11747. color.fn[ key ] = function( value ) {
  11748. var vtype = jQuery.type( value ),
  11749. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  11750. local = this[ fn ](),
  11751. cur = local[ prop.idx ],
  11752. match;
  11753. if ( vtype === "undefined" ) {
  11754. return cur;
  11755. }
  11756. if ( vtype === "function" ) {
  11757. value = value.call( this, cur );
  11758. vtype = jQuery.type( value );
  11759. }
  11760. if ( value == null && prop.empty ) {
  11761. return this;
  11762. }
  11763. if ( vtype === "string" ) {
  11764. match = rplusequals.exec( value );
  11765. if ( match ) {
  11766. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  11767. }
  11768. }
  11769. local[ prop.idx ] = value;
  11770. return this[ fn ]( local );
  11771. };
  11772. } );
  11773. } );
  11774. // Add cssHook and .fx.step function for each named hook.
  11775. // accept a space separated string of properties
  11776. color.hook = function( hook ) {
  11777. var hooks = hook.split( " " );
  11778. each( hooks, function( i, hook ) {
  11779. jQuery.cssHooks[ hook ] = {
  11780. set: function( elem, value ) {
  11781. var parsed, curElem,
  11782. backgroundColor = "";
  11783. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" ||
  11784. ( parsed = stringParse( value ) ) ) ) {
  11785. value = color( parsed || value );
  11786. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  11787. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  11788. while (
  11789. ( backgroundColor === "" || backgroundColor === "transparent" ) &&
  11790. curElem && curElem.style
  11791. ) {
  11792. try {
  11793. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  11794. curElem = curElem.parentNode;
  11795. } catch ( e ) {
  11796. }
  11797. }
  11798. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  11799. backgroundColor :
  11800. "_default" );
  11801. }
  11802. value = value.toRgbaString();
  11803. }
  11804. try {
  11805. elem.style[ hook ] = value;
  11806. } catch ( e ) {
  11807. // Wrapped to prevent IE from throwing errors on "invalid" values like
  11808. // 'auto' or 'inherit'
  11809. }
  11810. }
  11811. };
  11812. jQuery.fx.step[ hook ] = function( fx ) {
  11813. if ( !fx.colorInit ) {
  11814. fx.start = color( fx.elem, hook );
  11815. fx.end = color( fx.end );
  11816. fx.colorInit = true;
  11817. }
  11818. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  11819. };
  11820. } );
  11821. };
  11822. color.hook( stepHooks );
  11823. jQuery.cssHooks.borderColor = {
  11824. expand: function( value ) {
  11825. var expanded = {};
  11826. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  11827. expanded[ "border" + part + "Color" ] = value;
  11828. } );
  11829. return expanded;
  11830. }
  11831. };
  11832. // Basic color names only.
  11833. // Usage of any of the other color names requires adding yourself or including
  11834. // jquery.color.svg-names.js.
  11835. colors = jQuery.Color.names = {
  11836. // 4.1. Basic color keywords
  11837. aqua: "#00ffff",
  11838. black: "#000000",
  11839. blue: "#0000ff",
  11840. fuchsia: "#ff00ff",
  11841. gray: "#808080",
  11842. green: "#008000",
  11843. lime: "#00ff00",
  11844. maroon: "#800000",
  11845. navy: "#000080",
  11846. olive: "#808000",
  11847. purple: "#800080",
  11848. red: "#ff0000",
  11849. silver: "#c0c0c0",
  11850. teal: "#008080",
  11851. white: "#ffffff",
  11852. yellow: "#ffff00",
  11853. // 4.2.3. "transparent" color keyword
  11854. transparent: [ null, null, null, 0 ],
  11855. _default: "#ffffff"
  11856. };
  11857. } )( jQuery );
  11858. /******************************************************************************/
  11859. /****************************** CLASS ANIMATIONS ******************************/
  11860. /******************************************************************************/
  11861. ( function() {
  11862. var classAnimationActions = [ "add", "remove", "toggle" ],
  11863. shorthandStyles = {
  11864. border: 1,
  11865. borderBottom: 1,
  11866. borderColor: 1,
  11867. borderLeft: 1,
  11868. borderRight: 1,
  11869. borderTop: 1,
  11870. borderWidth: 1,
  11871. margin: 1,
  11872. padding: 1
  11873. };
  11874. $.each(
  11875. [ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ],
  11876. function( _, prop ) {
  11877. $.fx.step[ prop ] = function( fx ) {
  11878. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  11879. jQuery.style( fx.elem, prop, fx.end );
  11880. fx.setAttr = true;
  11881. }
  11882. };
  11883. }
  11884. );
  11885. function getElementStyles( elem ) {
  11886. var key, len,
  11887. style = elem.ownerDocument.defaultView ?
  11888. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  11889. elem.currentStyle,
  11890. styles = {};
  11891. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  11892. len = style.length;
  11893. while ( len-- ) {
  11894. key = style[ len ];
  11895. if ( typeof style[ key ] === "string" ) {
  11896. styles[ $.camelCase( key ) ] = style[ key ];
  11897. }
  11898. }
  11899. // Support: Opera, IE <9
  11900. } else {
  11901. for ( key in style ) {
  11902. if ( typeof style[ key ] === "string" ) {
  11903. styles[ key ] = style[ key ];
  11904. }
  11905. }
  11906. }
  11907. return styles;
  11908. }
  11909. function styleDifference( oldStyle, newStyle ) {
  11910. var diff = {},
  11911. name, value;
  11912. for ( name in newStyle ) {
  11913. value = newStyle[ name ];
  11914. if ( oldStyle[ name ] !== value ) {
  11915. if ( !shorthandStyles[ name ] ) {
  11916. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  11917. diff[ name ] = value;
  11918. }
  11919. }
  11920. }
  11921. }
  11922. return diff;
  11923. }
  11924. // Support: jQuery <1.8
  11925. if ( !$.fn.addBack ) {
  11926. $.fn.addBack = function( selector ) {
  11927. return this.add( selector == null ?
  11928. this.prevObject : this.prevObject.filter( selector )
  11929. );
  11930. };
  11931. }
  11932. $.effects.animateClass = function( value, duration, easing, callback ) {
  11933. var o = $.speed( duration, easing, callback );
  11934. return this.queue( function() {
  11935. var animated = $( this ),
  11936. baseClass = animated.attr( "class" ) || "",
  11937. applyClassChange,
  11938. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  11939. // Map the animated objects to store the original styles.
  11940. allAnimations = allAnimations.map( function() {
  11941. var el = $( this );
  11942. return {
  11943. el: el,
  11944. start: getElementStyles( this )
  11945. };
  11946. } );
  11947. // Apply class change
  11948. applyClassChange = function() {
  11949. $.each( classAnimationActions, function( i, action ) {
  11950. if ( value[ action ] ) {
  11951. animated[ action + "Class" ]( value[ action ] );
  11952. }
  11953. } );
  11954. };
  11955. applyClassChange();
  11956. // Map all animated objects again - calculate new styles and diff
  11957. allAnimations = allAnimations.map( function() {
  11958. this.end = getElementStyles( this.el[ 0 ] );
  11959. this.diff = styleDifference( this.start, this.end );
  11960. return this;
  11961. } );
  11962. // Apply original class
  11963. animated.attr( "class", baseClass );
  11964. // Map all animated objects again - this time collecting a promise
  11965. allAnimations = allAnimations.map( function() {
  11966. var styleInfo = this,
  11967. dfd = $.Deferred(),
  11968. opts = $.extend( {}, o, {
  11969. queue: false,
  11970. complete: function() {
  11971. dfd.resolve( styleInfo );
  11972. }
  11973. } );
  11974. this.el.animate( this.diff, opts );
  11975. return dfd.promise();
  11976. } );
  11977. // Once all animations have completed:
  11978. $.when.apply( $, allAnimations.get() ).done( function() {
  11979. // Set the final class
  11980. applyClassChange();
  11981. // For each animated element,
  11982. // clear all css properties that were animated
  11983. $.each( arguments, function() {
  11984. var el = this.el;
  11985. $.each( this.diff, function( key ) {
  11986. el.css( key, "" );
  11987. } );
  11988. } );
  11989. // This is guarnteed to be there if you use jQuery.speed()
  11990. // it also handles dequeuing the next anim...
  11991. o.complete.call( animated[ 0 ] );
  11992. } );
  11993. } );
  11994. };
  11995. $.fn.extend( {
  11996. addClass: ( function( orig ) {
  11997. return function( classNames, speed, easing, callback ) {
  11998. return speed ?
  11999. $.effects.animateClass.call( this,
  12000. { add: classNames }, speed, easing, callback ) :
  12001. orig.apply( this, arguments );
  12002. };
  12003. } )( $.fn.addClass ),
  12004. removeClass: ( function( orig ) {
  12005. return function( classNames, speed, easing, callback ) {
  12006. return arguments.length > 1 ?
  12007. $.effects.animateClass.call( this,
  12008. { remove: classNames }, speed, easing, callback ) :
  12009. orig.apply( this, arguments );
  12010. };
  12011. } )( $.fn.removeClass ),
  12012. toggleClass: ( function( orig ) {
  12013. return function( classNames, force, speed, easing, callback ) {
  12014. if ( typeof force === "boolean" || force === undefined ) {
  12015. if ( !speed ) {
  12016. // Without speed parameter
  12017. return orig.apply( this, arguments );
  12018. } else {
  12019. return $.effects.animateClass.call( this,
  12020. ( force ? { add: classNames } : { remove: classNames } ),
  12021. speed, easing, callback );
  12022. }
  12023. } else {
  12024. // Without force parameter
  12025. return $.effects.animateClass.call( this,
  12026. { toggle: classNames }, force, speed, easing );
  12027. }
  12028. };
  12029. } )( $.fn.toggleClass ),
  12030. switchClass: function( remove, add, speed, easing, callback ) {
  12031. return $.effects.animateClass.call( this, {
  12032. add: add,
  12033. remove: remove
  12034. }, speed, easing, callback );
  12035. }
  12036. } );
  12037. } )();
  12038. /******************************************************************************/
  12039. /*********************************** EFFECTS **********************************/
  12040. /******************************************************************************/
  12041. ( function() {
  12042. if ( $.expr && $.expr.filters && $.expr.filters.animated ) {
  12043. $.expr.filters.animated = ( function( orig ) {
  12044. return function( elem ) {
  12045. return !!$( elem ).data( dataSpaceAnimated ) || orig( elem );
  12046. };
  12047. } )( $.expr.filters.animated );
  12048. }
  12049. if ( $.uiBackCompat !== false ) {
  12050. $.extend( $.effects, {
  12051. // Saves a set of properties in a data storage
  12052. save: function( element, set ) {
  12053. var i = 0, length = set.length;
  12054. for ( ; i < length; i++ ) {
  12055. if ( set[ i ] !== null ) {
  12056. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  12057. }
  12058. }
  12059. },
  12060. // Restores a set of previously saved properties from a data storage
  12061. restore: function( element, set ) {
  12062. var val, i = 0, length = set.length;
  12063. for ( ; i < length; i++ ) {
  12064. if ( set[ i ] !== null ) {
  12065. val = element.data( dataSpace + set[ i ] );
  12066. element.css( set[ i ], val );
  12067. }
  12068. }
  12069. },
  12070. setMode: function( el, mode ) {
  12071. if ( mode === "toggle" ) {
  12072. mode = el.is( ":hidden" ) ? "show" : "hide";
  12073. }
  12074. return mode;
  12075. },
  12076. // Wraps the element around a wrapper that copies position properties
  12077. createWrapper: function( element ) {
  12078. // If the element is already wrapped, return it
  12079. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  12080. return element.parent();
  12081. }
  12082. // Wrap the element
  12083. var props = {
  12084. width: element.outerWidth( true ),
  12085. height: element.outerHeight( true ),
  12086. "float": element.css( "float" )
  12087. },
  12088. wrapper = $( "<div></div>" )
  12089. .addClass( "ui-effects-wrapper" )
  12090. .css( {
  12091. fontSize: "100%",
  12092. background: "transparent",
  12093. border: "none",
  12094. margin: 0,
  12095. padding: 0
  12096. } ),
  12097. // Store the size in case width/height are defined in % - Fixes #5245
  12098. size = {
  12099. width: element.width(),
  12100. height: element.height()
  12101. },
  12102. active = document.activeElement;
  12103. // Support: Firefox
  12104. // Firefox incorrectly exposes anonymous content
  12105. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  12106. try {
  12107. active.id;
  12108. } catch ( e ) {
  12109. active = document.body;
  12110. }
  12111. element.wrap( wrapper );
  12112. // Fixes #7595 - Elements lose focus when wrapped.
  12113. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  12114. $( active ).trigger( "focus" );
  12115. }
  12116. // Hotfix for jQuery 1.4 since some change in wrap() seems to actually
  12117. // lose the reference to the wrapped element
  12118. wrapper = element.parent();
  12119. // Transfer positioning properties to the wrapper
  12120. if ( element.css( "position" ) === "static" ) {
  12121. wrapper.css( { position: "relative" } );
  12122. element.css( { position: "relative" } );
  12123. } else {
  12124. $.extend( props, {
  12125. position: element.css( "position" ),
  12126. zIndex: element.css( "z-index" )
  12127. } );
  12128. $.each( [ "top", "left", "bottom", "right" ], function( i, pos ) {
  12129. props[ pos ] = element.css( pos );
  12130. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  12131. props[ pos ] = "auto";
  12132. }
  12133. } );
  12134. element.css( {
  12135. position: "relative",
  12136. top: 0,
  12137. left: 0,
  12138. right: "auto",
  12139. bottom: "auto"
  12140. } );
  12141. }
  12142. element.css( size );
  12143. return wrapper.css( props ).show();
  12144. },
  12145. removeWrapper: function( element ) {
  12146. var active = document.activeElement;
  12147. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  12148. element.parent().replaceWith( element );
  12149. // Fixes #7595 - Elements lose focus when wrapped.
  12150. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  12151. $( active ).trigger( "focus" );
  12152. }
  12153. }
  12154. return element;
  12155. }
  12156. } );
  12157. }
  12158. $.extend( $.effects, {
  12159. version: "1.12.1",
  12160. define: function( name, mode, effect ) {
  12161. if ( !effect ) {
  12162. effect = mode;
  12163. mode = "effect";
  12164. }
  12165. $.effects.effect[ name ] = effect;
  12166. $.effects.effect[ name ].mode = mode;
  12167. return effect;
  12168. },
  12169. scaledDimensions: function( element, percent, direction ) {
  12170. if ( percent === 0 ) {
  12171. return {
  12172. height: 0,
  12173. width: 0,
  12174. outerHeight: 0,
  12175. outerWidth: 0
  12176. };
  12177. }
  12178. var x = direction !== "horizontal" ? ( ( percent || 100 ) / 100 ) : 1,
  12179. y = direction !== "vertical" ? ( ( percent || 100 ) / 100 ) : 1;
  12180. return {
  12181. height: element.height() * y,
  12182. width: element.width() * x,
  12183. outerHeight: element.outerHeight() * y,
  12184. outerWidth: element.outerWidth() * x
  12185. };
  12186. },
  12187. clipToBox: function( animation ) {
  12188. return {
  12189. width: animation.clip.right - animation.clip.left,
  12190. height: animation.clip.bottom - animation.clip.top,
  12191. left: animation.clip.left,
  12192. top: animation.clip.top
  12193. };
  12194. },
  12195. // Injects recently queued functions to be first in line (after "inprogress")
  12196. unshift: function( element, queueLength, count ) {
  12197. var queue = element.queue();
  12198. if ( queueLength > 1 ) {
  12199. queue.splice.apply( queue,
  12200. [ 1, 0 ].concat( queue.splice( queueLength, count ) ) );
  12201. }
  12202. element.dequeue();
  12203. },
  12204. saveStyle: function( element ) {
  12205. element.data( dataSpaceStyle, element[ 0 ].style.cssText );
  12206. },
  12207. restoreStyle: function( element ) {
  12208. element[ 0 ].style.cssText = element.data( dataSpaceStyle ) || "";
  12209. element.removeData( dataSpaceStyle );
  12210. },
  12211. mode: function( element, mode ) {
  12212. var hidden = element.is( ":hidden" );
  12213. if ( mode === "toggle" ) {
  12214. mode = hidden ? "show" : "hide";
  12215. }
  12216. if ( hidden ? mode === "hide" : mode === "show" ) {
  12217. mode = "none";
  12218. }
  12219. return mode;
  12220. },
  12221. // Translates a [top,left] array into a baseline value
  12222. getBaseline: function( origin, original ) {
  12223. var y, x;
  12224. switch ( origin[ 0 ] ) {
  12225. case "top":
  12226. y = 0;
  12227. break;
  12228. case "middle":
  12229. y = 0.5;
  12230. break;
  12231. case "bottom":
  12232. y = 1;
  12233. break;
  12234. default:
  12235. y = origin[ 0 ] / original.height;
  12236. }
  12237. switch ( origin[ 1 ] ) {
  12238. case "left":
  12239. x = 0;
  12240. break;
  12241. case "center":
  12242. x = 0.5;
  12243. break;
  12244. case "right":
  12245. x = 1;
  12246. break;
  12247. default:
  12248. x = origin[ 1 ] / original.width;
  12249. }
  12250. return {
  12251. x: x,
  12252. y: y
  12253. };
  12254. },
  12255. // Creates a placeholder element so that the original element can be made absolute
  12256. createPlaceholder: function( element ) {
  12257. var placeholder,
  12258. cssPosition = element.css( "position" ),
  12259. position = element.position();
  12260. // Lock in margins first to account for form elements, which
  12261. // will change margin if you explicitly set height
  12262. // see: http://jsfiddle.net/JZSMt/3/ https://bugs.webkit.org/show_bug.cgi?id=107380
  12263. // Support: Safari
  12264. element.css( {
  12265. marginTop: element.css( "marginTop" ),
  12266. marginBottom: element.css( "marginBottom" ),
  12267. marginLeft: element.css( "marginLeft" ),
  12268. marginRight: element.css( "marginRight" )
  12269. } )
  12270. .outerWidth( element.outerWidth() )
  12271. .outerHeight( element.outerHeight() );
  12272. if ( /^(static|relative)/.test( cssPosition ) ) {
  12273. cssPosition = "absolute";
  12274. placeholder = $( "<" + element[ 0 ].nodeName + ">" ).insertAfter( element ).css( {
  12275. // Convert inline to inline block to account for inline elements
  12276. // that turn to inline block based on content (like img)
  12277. display: /^(inline|ruby)/.test( element.css( "display" ) ) ?
  12278. "inline-block" :
  12279. "block",
  12280. visibility: "hidden",
  12281. // Margins need to be set to account for margin collapse
  12282. marginTop: element.css( "marginTop" ),
  12283. marginBottom: element.css( "marginBottom" ),
  12284. marginLeft: element.css( "marginLeft" ),
  12285. marginRight: element.css( "marginRight" ),
  12286. "float": element.css( "float" )
  12287. } )
  12288. .outerWidth( element.outerWidth() )
  12289. .outerHeight( element.outerHeight() )
  12290. .addClass( "ui-effects-placeholder" );
  12291. element.data( dataSpace + "placeholder", placeholder );
  12292. }
  12293. element.css( {
  12294. position: cssPosition,
  12295. left: position.left,
  12296. top: position.top
  12297. } );
  12298. return placeholder;
  12299. },
  12300. removePlaceholder: function( element ) {
  12301. var dataKey = dataSpace + "placeholder",
  12302. placeholder = element.data( dataKey );
  12303. if ( placeholder ) {
  12304. placeholder.remove();
  12305. element.removeData( dataKey );
  12306. }
  12307. },
  12308. // Removes a placeholder if it exists and restores
  12309. // properties that were modified during placeholder creation
  12310. cleanUp: function( element ) {
  12311. $.effects.restoreStyle( element );
  12312. $.effects.removePlaceholder( element );
  12313. },
  12314. setTransition: function( element, list, factor, value ) {
  12315. value = value || {};
  12316. $.each( list, function( i, x ) {
  12317. var unit = element.cssUnit( x );
  12318. if ( unit[ 0 ] > 0 ) {
  12319. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  12320. }
  12321. } );
  12322. return value;
  12323. }
  12324. } );
  12325. // Return an effect options object for the given parameters:
  12326. function _normalizeArguments( effect, options, speed, callback ) {
  12327. // Allow passing all options as the first parameter
  12328. if ( $.isPlainObject( effect ) ) {
  12329. options = effect;
  12330. effect = effect.effect;
  12331. }
  12332. // Convert to an object
  12333. effect = { effect: effect };
  12334. // Catch (effect, null, ...)
  12335. if ( options == null ) {
  12336. options = {};
  12337. }
  12338. // Catch (effect, callback)
  12339. if ( $.isFunction( options ) ) {
  12340. callback = options;
  12341. speed = null;
  12342. options = {};
  12343. }
  12344. // Catch (effect, speed, ?)
  12345. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  12346. callback = speed;
  12347. speed = options;
  12348. options = {};
  12349. }
  12350. // Catch (effect, options, callback)
  12351. if ( $.isFunction( speed ) ) {
  12352. callback = speed;
  12353. speed = null;
  12354. }
  12355. // Add options to effect
  12356. if ( options ) {
  12357. $.extend( effect, options );
  12358. }
  12359. speed = speed || options.duration;
  12360. effect.duration = $.fx.off ? 0 :
  12361. typeof speed === "number" ? speed :
  12362. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  12363. $.fx.speeds._default;
  12364. effect.complete = callback || options.complete;
  12365. return effect;
  12366. }
  12367. function standardAnimationOption( option ) {
  12368. // Valid standard speeds (nothing, number, named speed)
  12369. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  12370. return true;
  12371. }
  12372. // Invalid strings - treat as "normal" speed
  12373. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  12374. return true;
  12375. }
  12376. // Complete callback
  12377. if ( $.isFunction( option ) ) {
  12378. return true;
  12379. }
  12380. // Options hash (but not naming an effect)
  12381. if ( typeof option === "object" && !option.effect ) {
  12382. return true;
  12383. }
  12384. // Didn't match any standard API
  12385. return false;
  12386. }
  12387. $.fn.extend( {
  12388. effect: function( /* effect, options, speed, callback */ ) {
  12389. var args = _normalizeArguments.apply( this, arguments ),
  12390. effectMethod = $.effects.effect[ args.effect ],
  12391. defaultMode = effectMethod.mode,
  12392. queue = args.queue,
  12393. queueName = queue || "fx",
  12394. complete = args.complete,
  12395. mode = args.mode,
  12396. modes = [],
  12397. prefilter = function( next ) {
  12398. var el = $( this ),
  12399. normalizedMode = $.effects.mode( el, mode ) || defaultMode;
  12400. // Sentinel for duck-punching the :animated psuedo-selector
  12401. el.data( dataSpaceAnimated, true );
  12402. // Save effect mode for later use,
  12403. // we can't just call $.effects.mode again later,
  12404. // as the .show() below destroys the initial state
  12405. modes.push( normalizedMode );
  12406. // See $.uiBackCompat inside of run() for removal of defaultMode in 1.13
  12407. if ( defaultMode && ( normalizedMode === "show" ||
  12408. ( normalizedMode === defaultMode && normalizedMode === "hide" ) ) ) {
  12409. el.show();
  12410. }
  12411. if ( !defaultMode || normalizedMode !== "none" ) {
  12412. $.effects.saveStyle( el );
  12413. }
  12414. if ( $.isFunction( next ) ) {
  12415. next();
  12416. }
  12417. };
  12418. if ( $.fx.off || !effectMethod ) {
  12419. // Delegate to the original method (e.g., .show()) if possible
  12420. if ( mode ) {
  12421. return this[ mode ]( args.duration, complete );
  12422. } else {
  12423. return this.each( function() {
  12424. if ( complete ) {
  12425. complete.call( this );
  12426. }
  12427. } );
  12428. }
  12429. }
  12430. function run( next ) {
  12431. var elem = $( this );
  12432. function cleanup() {
  12433. elem.removeData( dataSpaceAnimated );
  12434. $.effects.cleanUp( elem );
  12435. if ( args.mode === "hide" ) {
  12436. elem.hide();
  12437. }
  12438. done();
  12439. }
  12440. function done() {
  12441. if ( $.isFunction( complete ) ) {
  12442. complete.call( elem[ 0 ] );
  12443. }
  12444. if ( $.isFunction( next ) ) {
  12445. next();
  12446. }
  12447. }
  12448. // Override mode option on a per element basis,
  12449. // as toggle can be either show or hide depending on element state
  12450. args.mode = modes.shift();
  12451. if ( $.uiBackCompat !== false && !defaultMode ) {
  12452. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  12453. // Call the core method to track "olddisplay" properly
  12454. elem[ mode ]();
  12455. done();
  12456. } else {
  12457. effectMethod.call( elem[ 0 ], args, done );
  12458. }
  12459. } else {
  12460. if ( args.mode === "none" ) {
  12461. // Call the core method to track "olddisplay" properly
  12462. elem[ mode ]();
  12463. done();
  12464. } else {
  12465. effectMethod.call( elem[ 0 ], args, cleanup );
  12466. }
  12467. }
  12468. }
  12469. // Run prefilter on all elements first to ensure that
  12470. // any showing or hiding happens before placeholder creation,
  12471. // which ensures that any layout changes are correctly captured.
  12472. return queue === false ?
  12473. this.each( prefilter ).each( run ) :
  12474. this.queue( queueName, prefilter ).queue( queueName, run );
  12475. },
  12476. show: ( function( orig ) {
  12477. return function( option ) {
  12478. if ( standardAnimationOption( option ) ) {
  12479. return orig.apply( this, arguments );
  12480. } else {
  12481. var args = _normalizeArguments.apply( this, arguments );
  12482. args.mode = "show";
  12483. return this.effect.call( this, args );
  12484. }
  12485. };
  12486. } )( $.fn.show ),
  12487. hide: ( function( orig ) {
  12488. return function( option ) {
  12489. if ( standardAnimationOption( option ) ) {
  12490. return orig.apply( this, arguments );
  12491. } else {
  12492. var args = _normalizeArguments.apply( this, arguments );
  12493. args.mode = "hide";
  12494. return this.effect.call( this, args );
  12495. }
  12496. };
  12497. } )( $.fn.hide ),
  12498. toggle: ( function( orig ) {
  12499. return function( option ) {
  12500. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  12501. return orig.apply( this, arguments );
  12502. } else {
  12503. var args = _normalizeArguments.apply( this, arguments );
  12504. args.mode = "toggle";
  12505. return this.effect.call( this, args );
  12506. }
  12507. };
  12508. } )( $.fn.toggle ),
  12509. cssUnit: function( key ) {
  12510. var style = this.css( key ),
  12511. val = [];
  12512. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  12513. if ( style.indexOf( unit ) > 0 ) {
  12514. val = [ parseFloat( style ), unit ];
  12515. }
  12516. } );
  12517. return val;
  12518. },
  12519. cssClip: function( clipObj ) {
  12520. if ( clipObj ) {
  12521. return this.css( "clip", "rect(" + clipObj.top + "px " + clipObj.right + "px " +
  12522. clipObj.bottom + "px " + clipObj.left + "px)" );
  12523. }
  12524. return parseClip( this.css( "clip" ), this );
  12525. },
  12526. transfer: function( options, done ) {
  12527. var element = $( this ),
  12528. target = $( options.to ),
  12529. targetFixed = target.css( "position" ) === "fixed",
  12530. body = $( "body" ),
  12531. fixTop = targetFixed ? body.scrollTop() : 0,
  12532. fixLeft = targetFixed ? body.scrollLeft() : 0,
  12533. endPosition = target.offset(),
  12534. animation = {
  12535. top: endPosition.top - fixTop,
  12536. left: endPosition.left - fixLeft,
  12537. height: target.innerHeight(),
  12538. width: target.innerWidth()
  12539. },
  12540. startPosition = element.offset(),
  12541. transfer = $( "<div class='ui-effects-transfer'></div>" )
  12542. .appendTo( "body" )
  12543. .addClass( options.className )
  12544. .css( {
  12545. top: startPosition.top - fixTop,
  12546. left: startPosition.left - fixLeft,
  12547. height: element.innerHeight(),
  12548. width: element.innerWidth(),
  12549. position: targetFixed ? "fixed" : "absolute"
  12550. } )
  12551. .animate( animation, options.duration, options.easing, function() {
  12552. transfer.remove();
  12553. if ( $.isFunction( done ) ) {
  12554. done();
  12555. }
  12556. } );
  12557. }
  12558. } );
  12559. function parseClip( str, element ) {
  12560. var outerWidth = element.outerWidth(),
  12561. outerHeight = element.outerHeight(),
  12562. clipRegex = /^rect\((-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto)\)$/,
  12563. values = clipRegex.exec( str ) || [ "", 0, outerWidth, outerHeight, 0 ];
  12564. return {
  12565. top: parseFloat( values[ 1 ] ) || 0,
  12566. right: values[ 2 ] === "auto" ? outerWidth : parseFloat( values[ 2 ] ),
  12567. bottom: values[ 3 ] === "auto" ? outerHeight : parseFloat( values[ 3 ] ),
  12568. left: parseFloat( values[ 4 ] ) || 0
  12569. };
  12570. }
  12571. $.fx.step.clip = function( fx ) {
  12572. if ( !fx.clipInit ) {
  12573. fx.start = $( fx.elem ).cssClip();
  12574. if ( typeof fx.end === "string" ) {
  12575. fx.end = parseClip( fx.end, fx.elem );
  12576. }
  12577. fx.clipInit = true;
  12578. }
  12579. $( fx.elem ).cssClip( {
  12580. top: fx.pos * ( fx.end.top - fx.start.top ) + fx.start.top,
  12581. right: fx.pos * ( fx.end.right - fx.start.right ) + fx.start.right,
  12582. bottom: fx.pos * ( fx.end.bottom - fx.start.bottom ) + fx.start.bottom,
  12583. left: fx.pos * ( fx.end.left - fx.start.left ) + fx.start.left
  12584. } );
  12585. };
  12586. } )();
  12587. /******************************************************************************/
  12588. /*********************************** EASING ***********************************/
  12589. /******************************************************************************/
  12590. ( function() {
  12591. // Based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  12592. var baseEasings = {};
  12593. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  12594. baseEasings[ name ] = function( p ) {
  12595. return Math.pow( p, i + 2 );
  12596. };
  12597. } );
  12598. $.extend( baseEasings, {
  12599. Sine: function( p ) {
  12600. return 1 - Math.cos( p * Math.PI / 2 );
  12601. },
  12602. Circ: function( p ) {
  12603. return 1 - Math.sqrt( 1 - p * p );
  12604. },
  12605. Elastic: function( p ) {
  12606. return p === 0 || p === 1 ? p :
  12607. -Math.pow( 2, 8 * ( p - 1 ) ) * Math.sin( ( ( p - 1 ) * 80 - 7.5 ) * Math.PI / 15 );
  12608. },
  12609. Back: function( p ) {
  12610. return p * p * ( 3 * p - 2 );
  12611. },
  12612. Bounce: function( p ) {
  12613. var pow2,
  12614. bounce = 4;
  12615. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  12616. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  12617. }
  12618. } );
  12619. $.each( baseEasings, function( name, easeIn ) {
  12620. $.easing[ "easeIn" + name ] = easeIn;
  12621. $.easing[ "easeOut" + name ] = function( p ) {
  12622. return 1 - easeIn( 1 - p );
  12623. };
  12624. $.easing[ "easeInOut" + name ] = function( p ) {
  12625. return p < 0.5 ?
  12626. easeIn( p * 2 ) / 2 :
  12627. 1 - easeIn( p * -2 + 2 ) / 2;
  12628. };
  12629. } );
  12630. } )();
  12631. var effect = $.effects;
  12632. /*!
  12633. * jQuery UI Effects Blind 1.12.1
  12634. * http://jqueryui.com
  12635. *
  12636. * Copyright jQuery Foundation and other contributors
  12637. * Released under the MIT license.
  12638. * http://jquery.org/license
  12639. */
  12640. //>>label: Blind Effect
  12641. //>>group: Effects
  12642. //>>description: Blinds the element.
  12643. //>>docs: http://api.jqueryui.com/blind-effect/
  12644. //>>demos: http://jqueryui.com/effect/
  12645. var effectsEffectBlind = $.effects.define( "blind", "hide", function( options, done ) {
  12646. var map = {
  12647. up: [ "bottom", "top" ],
  12648. vertical: [ "bottom", "top" ],
  12649. down: [ "top", "bottom" ],
  12650. left: [ "right", "left" ],
  12651. horizontal: [ "right", "left" ],
  12652. right: [ "left", "right" ]
  12653. },
  12654. element = $( this ),
  12655. direction = options.direction || "up",
  12656. start = element.cssClip(),
  12657. animate = { clip: $.extend( {}, start ) },
  12658. placeholder = $.effects.createPlaceholder( element );
  12659. animate.clip[ map[ direction ][ 0 ] ] = animate.clip[ map[ direction ][ 1 ] ];
  12660. if ( options.mode === "show" ) {
  12661. element.cssClip( animate.clip );
  12662. if ( placeholder ) {
  12663. placeholder.css( $.effects.clipToBox( animate ) );
  12664. }
  12665. animate.clip = start;
  12666. }
  12667. if ( placeholder ) {
  12668. placeholder.animate( $.effects.clipToBox( animate ), options.duration, options.easing );
  12669. }
  12670. element.animate( animate, {
  12671. queue: false,
  12672. duration: options.duration,
  12673. easing: options.easing,
  12674. complete: done
  12675. } );
  12676. } );
  12677. /*!
  12678. * jQuery UI Effects Bounce 1.12.1
  12679. * http://jqueryui.com
  12680. *
  12681. * Copyright jQuery Foundation and other contributors
  12682. * Released under the MIT license.
  12683. * http://jquery.org/license
  12684. */
  12685. //>>label: Bounce Effect
  12686. //>>group: Effects
  12687. //>>description: Bounces an element horizontally or vertically n times.
  12688. //>>docs: http://api.jqueryui.com/bounce-effect/
  12689. //>>demos: http://jqueryui.com/effect/
  12690. var effectsEffectBounce = $.effects.define( "bounce", function( options, done ) {
  12691. var upAnim, downAnim, refValue,
  12692. element = $( this ),
  12693. // Defaults:
  12694. mode = options.mode,
  12695. hide = mode === "hide",
  12696. show = mode === "show",
  12697. direction = options.direction || "up",
  12698. distance = options.distance,
  12699. times = options.times || 5,
  12700. // Number of internal animations
  12701. anims = times * 2 + ( show || hide ? 1 : 0 ),
  12702. speed = options.duration / anims,
  12703. easing = options.easing,
  12704. // Utility:
  12705. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  12706. motion = ( direction === "up" || direction === "left" ),
  12707. i = 0,
  12708. queuelen = element.queue().length;
  12709. $.effects.createPlaceholder( element );
  12710. refValue = element.css( ref );
  12711. // Default distance for the BIGGEST bounce is the outer Distance / 3
  12712. if ( !distance ) {
  12713. distance = element[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  12714. }
  12715. if ( show ) {
  12716. downAnim = { opacity: 1 };
  12717. downAnim[ ref ] = refValue;
  12718. // If we are showing, force opacity 0 and set the initial position
  12719. // then do the "first" animation
  12720. element
  12721. .css( "opacity", 0 )
  12722. .css( ref, motion ? -distance * 2 : distance * 2 )
  12723. .animate( downAnim, speed, easing );
  12724. }
  12725. // Start at the smallest distance if we are hiding
  12726. if ( hide ) {
  12727. distance = distance / Math.pow( 2, times - 1 );
  12728. }
  12729. downAnim = {};
  12730. downAnim[ ref ] = refValue;
  12731. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  12732. for ( ; i < times; i++ ) {
  12733. upAnim = {};
  12734. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  12735. element
  12736. .animate( upAnim, speed, easing )
  12737. .animate( downAnim, speed, easing );
  12738. distance = hide ? distance * 2 : distance / 2;
  12739. }
  12740. // Last Bounce when Hiding
  12741. if ( hide ) {
  12742. upAnim = { opacity: 0 };
  12743. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  12744. element.animate( upAnim, speed, easing );
  12745. }
  12746. element.queue( done );
  12747. $.effects.unshift( element, queuelen, anims + 1 );
  12748. } );
  12749. /*!
  12750. * jQuery UI Effects Clip 1.12.1
  12751. * http://jqueryui.com
  12752. *
  12753. * Copyright jQuery Foundation and other contributors
  12754. * Released under the MIT license.
  12755. * http://jquery.org/license
  12756. */
  12757. //>>label: Clip Effect
  12758. //>>group: Effects
  12759. //>>description: Clips the element on and off like an old TV.
  12760. //>>docs: http://api.jqueryui.com/clip-effect/
  12761. //>>demos: http://jqueryui.com/effect/
  12762. var effectsEffectClip = $.effects.define( "clip", "hide", function( options, done ) {
  12763. var start,
  12764. animate = {},
  12765. element = $( this ),
  12766. direction = options.direction || "vertical",
  12767. both = direction === "both",
  12768. horizontal = both || direction === "horizontal",
  12769. vertical = both || direction === "vertical";
  12770. start = element.cssClip();
  12771. animate.clip = {
  12772. top: vertical ? ( start.bottom - start.top ) / 2 : start.top,
  12773. right: horizontal ? ( start.right - start.left ) / 2 : start.right,
  12774. bottom: vertical ? ( start.bottom - start.top ) / 2 : start.bottom,
  12775. left: horizontal ? ( start.right - start.left ) / 2 : start.left
  12776. };
  12777. $.effects.createPlaceholder( element );
  12778. if ( options.mode === "show" ) {
  12779. element.cssClip( animate.clip );
  12780. animate.clip = start;
  12781. }
  12782. element.animate( animate, {
  12783. queue: false,
  12784. duration: options.duration,
  12785. easing: options.easing,
  12786. complete: done
  12787. } );
  12788. } );
  12789. /*!
  12790. * jQuery UI Effects Drop 1.12.1
  12791. * http://jqueryui.com
  12792. *
  12793. * Copyright jQuery Foundation and other contributors
  12794. * Released under the MIT license.
  12795. * http://jquery.org/license
  12796. */
  12797. //>>label: Drop Effect
  12798. //>>group: Effects
  12799. //>>description: Moves an element in one direction and hides it at the same time.
  12800. //>>docs: http://api.jqueryui.com/drop-effect/
  12801. //>>demos: http://jqueryui.com/effect/
  12802. var effectsEffectDrop = $.effects.define( "drop", "hide", function( options, done ) {
  12803. var distance,
  12804. element = $( this ),
  12805. mode = options.mode,
  12806. show = mode === "show",
  12807. direction = options.direction || "left",
  12808. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  12809. motion = ( direction === "up" || direction === "left" ) ? "-=" : "+=",
  12810. oppositeMotion = ( motion === "+=" ) ? "-=" : "+=",
  12811. animation = {
  12812. opacity: 0
  12813. };
  12814. $.effects.createPlaceholder( element );
  12815. distance = options.distance ||
  12816. element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2;
  12817. animation[ ref ] = motion + distance;
  12818. if ( show ) {
  12819. element.css( animation );
  12820. animation[ ref ] = oppositeMotion + distance;
  12821. animation.opacity = 1;
  12822. }
  12823. // Animate
  12824. element.animate( animation, {
  12825. queue: false,
  12826. duration: options.duration,
  12827. easing: options.easing,
  12828. complete: done
  12829. } );
  12830. } );
  12831. /*!
  12832. * jQuery UI Effects Explode 1.12.1
  12833. * http://jqueryui.com
  12834. *
  12835. * Copyright jQuery Foundation and other contributors
  12836. * Released under the MIT license.
  12837. * http://jquery.org/license
  12838. */
  12839. //>>label: Explode Effect
  12840. //>>group: Effects
  12841. // jscs:disable maximumLineLength
  12842. //>>description: Explodes an element in all directions into n pieces. Implodes an element to its original wholeness.
  12843. // jscs:enable maximumLineLength
  12844. //>>docs: http://api.jqueryui.com/explode-effect/
  12845. //>>demos: http://jqueryui.com/effect/
  12846. var effectsEffectExplode = $.effects.define( "explode", "hide", function( options, done ) {
  12847. var i, j, left, top, mx, my,
  12848. rows = options.pieces ? Math.round( Math.sqrt( options.pieces ) ) : 3,
  12849. cells = rows,
  12850. element = $( this ),
  12851. mode = options.mode,
  12852. show = mode === "show",
  12853. // Show and then visibility:hidden the element before calculating offset
  12854. offset = element.show().css( "visibility", "hidden" ).offset(),
  12855. // Width and height of a piece
  12856. width = Math.ceil( element.outerWidth() / cells ),
  12857. height = Math.ceil( element.outerHeight() / rows ),
  12858. pieces = [];
  12859. // Children animate complete:
  12860. function childComplete() {
  12861. pieces.push( this );
  12862. if ( pieces.length === rows * cells ) {
  12863. animComplete();
  12864. }
  12865. }
  12866. // Clone the element for each row and cell.
  12867. for ( i = 0; i < rows; i++ ) { // ===>
  12868. top = offset.top + i * height;
  12869. my = i - ( rows - 1 ) / 2;
  12870. for ( j = 0; j < cells; j++ ) { // |||
  12871. left = offset.left + j * width;
  12872. mx = j - ( cells - 1 ) / 2;
  12873. // Create a clone of the now hidden main element that will be absolute positioned
  12874. // within a wrapper div off the -left and -top equal to size of our pieces
  12875. element
  12876. .clone()
  12877. .appendTo( "body" )
  12878. .wrap( "<div></div>" )
  12879. .css( {
  12880. position: "absolute",
  12881. visibility: "visible",
  12882. left: -j * width,
  12883. top: -i * height
  12884. } )
  12885. // Select the wrapper - make it overflow: hidden and absolute positioned based on
  12886. // where the original was located +left and +top equal to the size of pieces
  12887. .parent()
  12888. .addClass( "ui-effects-explode" )
  12889. .css( {
  12890. position: "absolute",
  12891. overflow: "hidden",
  12892. width: width,
  12893. height: height,
  12894. left: left + ( show ? mx * width : 0 ),
  12895. top: top + ( show ? my * height : 0 ),
  12896. opacity: show ? 0 : 1
  12897. } )
  12898. .animate( {
  12899. left: left + ( show ? 0 : mx * width ),
  12900. top: top + ( show ? 0 : my * height ),
  12901. opacity: show ? 1 : 0
  12902. }, options.duration || 500, options.easing, childComplete );
  12903. }
  12904. }
  12905. function animComplete() {
  12906. element.css( {
  12907. visibility: "visible"
  12908. } );
  12909. $( pieces ).remove();
  12910. done();
  12911. }
  12912. } );
  12913. /*!
  12914. * jQuery UI Effects Fade 1.12.1
  12915. * http://jqueryui.com
  12916. *
  12917. * Copyright jQuery Foundation and other contributors
  12918. * Released under the MIT license.
  12919. * http://jquery.org/license
  12920. */
  12921. //>>label: Fade Effect
  12922. //>>group: Effects
  12923. //>>description: Fades the element.
  12924. //>>docs: http://api.jqueryui.com/fade-effect/
  12925. //>>demos: http://jqueryui.com/effect/
  12926. var effectsEffectFade = $.effects.define( "fade", "toggle", function( options, done ) {
  12927. var show = options.mode === "show";
  12928. $( this )
  12929. .css( "opacity", show ? 0 : 1 )
  12930. .animate( {
  12931. opacity: show ? 1 : 0
  12932. }, {
  12933. queue: false,
  12934. duration: options.duration,
  12935. easing: options.easing,
  12936. complete: done
  12937. } );
  12938. } );
  12939. /*!
  12940. * jQuery UI Effects Fold 1.12.1
  12941. * http://jqueryui.com
  12942. *
  12943. * Copyright jQuery Foundation and other contributors
  12944. * Released under the MIT license.
  12945. * http://jquery.org/license
  12946. */
  12947. //>>label: Fold Effect
  12948. //>>group: Effects
  12949. //>>description: Folds an element first horizontally and then vertically.
  12950. //>>docs: http://api.jqueryui.com/fold-effect/
  12951. //>>demos: http://jqueryui.com/effect/
  12952. var effectsEffectFold = $.effects.define( "fold", "hide", function( options, done ) {
  12953. // Create element
  12954. var element = $( this ),
  12955. mode = options.mode,
  12956. show = mode === "show",
  12957. hide = mode === "hide",
  12958. size = options.size || 15,
  12959. percent = /([0-9]+)%/.exec( size ),
  12960. horizFirst = !!options.horizFirst,
  12961. ref = horizFirst ? [ "right", "bottom" ] : [ "bottom", "right" ],
  12962. duration = options.duration / 2,
  12963. placeholder = $.effects.createPlaceholder( element ),
  12964. start = element.cssClip(),
  12965. animation1 = { clip: $.extend( {}, start ) },
  12966. animation2 = { clip: $.extend( {}, start ) },
  12967. distance = [ start[ ref[ 0 ] ], start[ ref[ 1 ] ] ],
  12968. queuelen = element.queue().length;
  12969. if ( percent ) {
  12970. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  12971. }
  12972. animation1.clip[ ref[ 0 ] ] = size;
  12973. animation2.clip[ ref[ 0 ] ] = size;
  12974. animation2.clip[ ref[ 1 ] ] = 0;
  12975. if ( show ) {
  12976. element.cssClip( animation2.clip );
  12977. if ( placeholder ) {
  12978. placeholder.css( $.effects.clipToBox( animation2 ) );
  12979. }
  12980. animation2.clip = start;
  12981. }
  12982. // Animate
  12983. element
  12984. .queue( function( next ) {
  12985. if ( placeholder ) {
  12986. placeholder
  12987. .animate( $.effects.clipToBox( animation1 ), duration, options.easing )
  12988. .animate( $.effects.clipToBox( animation2 ), duration, options.easing );
  12989. }
  12990. next();
  12991. } )
  12992. .animate( animation1, duration, options.easing )
  12993. .animate( animation2, duration, options.easing )
  12994. .queue( done );
  12995. $.effects.unshift( element, queuelen, 4 );
  12996. } );
  12997. /*!
  12998. * jQuery UI Effects Highlight 1.12.1
  12999. * http://jqueryui.com
  13000. *
  13001. * Copyright jQuery Foundation and other contributors
  13002. * Released under the MIT license.
  13003. * http://jquery.org/license
  13004. */
  13005. //>>label: Highlight Effect
  13006. //>>group: Effects
  13007. //>>description: Highlights the background of an element in a defined color for a custom duration.
  13008. //>>docs: http://api.jqueryui.com/highlight-effect/
  13009. //>>demos: http://jqueryui.com/effect/
  13010. var effectsEffectHighlight = $.effects.define( "highlight", "show", function( options, done ) {
  13011. var element = $( this ),
  13012. animation = {
  13013. backgroundColor: element.css( "backgroundColor" )
  13014. };
  13015. if ( options.mode === "hide" ) {
  13016. animation.opacity = 0;
  13017. }
  13018. $.effects.saveStyle( element );
  13019. element
  13020. .css( {
  13021. backgroundImage: "none",
  13022. backgroundColor: options.color || "#ffff99"
  13023. } )
  13024. .animate( animation, {
  13025. queue: false,
  13026. duration: options.duration,
  13027. easing: options.easing,
  13028. complete: done
  13029. } );
  13030. } );
  13031. /*!
  13032. * jQuery UI Effects Size 1.12.1
  13033. * http://jqueryui.com
  13034. *
  13035. * Copyright jQuery Foundation and other contributors
  13036. * Released under the MIT license.
  13037. * http://jquery.org/license
  13038. */
  13039. //>>label: Size Effect
  13040. //>>group: Effects
  13041. //>>description: Resize an element to a specified width and height.
  13042. //>>docs: http://api.jqueryui.com/size-effect/
  13043. //>>demos: http://jqueryui.com/effect/
  13044. var effectsEffectSize = $.effects.define( "size", function( options, done ) {
  13045. // Create element
  13046. var baseline, factor, temp,
  13047. element = $( this ),
  13048. // Copy for children
  13049. cProps = [ "fontSize" ],
  13050. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  13051. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  13052. // Set options
  13053. mode = options.mode,
  13054. restore = mode !== "effect",
  13055. scale = options.scale || "both",
  13056. origin = options.origin || [ "middle", "center" ],
  13057. position = element.css( "position" ),
  13058. pos = element.position(),
  13059. original = $.effects.scaledDimensions( element ),
  13060. from = options.from || original,
  13061. to = options.to || $.effects.scaledDimensions( element, 0 );
  13062. $.effects.createPlaceholder( element );
  13063. if ( mode === "show" ) {
  13064. temp = from;
  13065. from = to;
  13066. to = temp;
  13067. }
  13068. // Set scaling factor
  13069. factor = {
  13070. from: {
  13071. y: from.height / original.height,
  13072. x: from.width / original.width
  13073. },
  13074. to: {
  13075. y: to.height / original.height,
  13076. x: to.width / original.width
  13077. }
  13078. };
  13079. // Scale the css box
  13080. if ( scale === "box" || scale === "both" ) {
  13081. // Vertical props scaling
  13082. if ( factor.from.y !== factor.to.y ) {
  13083. from = $.effects.setTransition( element, vProps, factor.from.y, from );
  13084. to = $.effects.setTransition( element, vProps, factor.to.y, to );
  13085. }
  13086. // Horizontal props scaling
  13087. if ( factor.from.x !== factor.to.x ) {
  13088. from = $.effects.setTransition( element, hProps, factor.from.x, from );
  13089. to = $.effects.setTransition( element, hProps, factor.to.x, to );
  13090. }
  13091. }
  13092. // Scale the content
  13093. if ( scale === "content" || scale === "both" ) {
  13094. // Vertical props scaling
  13095. if ( factor.from.y !== factor.to.y ) {
  13096. from = $.effects.setTransition( element, cProps, factor.from.y, from );
  13097. to = $.effects.setTransition( element, cProps, factor.to.y, to );
  13098. }
  13099. }
  13100. // Adjust the position properties based on the provided origin points
  13101. if ( origin ) {
  13102. baseline = $.effects.getBaseline( origin, original );
  13103. from.top = ( original.outerHeight - from.outerHeight ) * baseline.y + pos.top;
  13104. from.left = ( original.outerWidth - from.outerWidth ) * baseline.x + pos.left;
  13105. to.top = ( original.outerHeight - to.outerHeight ) * baseline.y + pos.top;
  13106. to.left = ( original.outerWidth - to.outerWidth ) * baseline.x + pos.left;
  13107. }
  13108. element.css( from );
  13109. // Animate the children if desired
  13110. if ( scale === "content" || scale === "both" ) {
  13111. vProps = vProps.concat( [ "marginTop", "marginBottom" ] ).concat( cProps );
  13112. hProps = hProps.concat( [ "marginLeft", "marginRight" ] );
  13113. // Only animate children with width attributes specified
  13114. // TODO: is this right? should we include anything with css width specified as well
  13115. element.find( "*[width]" ).each( function() {
  13116. var child = $( this ),
  13117. childOriginal = $.effects.scaledDimensions( child ),
  13118. childFrom = {
  13119. height: childOriginal.height * factor.from.y,
  13120. width: childOriginal.width * factor.from.x,
  13121. outerHeight: childOriginal.outerHeight * factor.from.y,
  13122. outerWidth: childOriginal.outerWidth * factor.from.x
  13123. },
  13124. childTo = {
  13125. height: childOriginal.height * factor.to.y,
  13126. width: childOriginal.width * factor.to.x,
  13127. outerHeight: childOriginal.height * factor.to.y,
  13128. outerWidth: childOriginal.width * factor.to.x
  13129. };
  13130. // Vertical props scaling
  13131. if ( factor.from.y !== factor.to.y ) {
  13132. childFrom = $.effects.setTransition( child, vProps, factor.from.y, childFrom );
  13133. childTo = $.effects.setTransition( child, vProps, factor.to.y, childTo );
  13134. }
  13135. // Horizontal props scaling
  13136. if ( factor.from.x !== factor.to.x ) {
  13137. childFrom = $.effects.setTransition( child, hProps, factor.from.x, childFrom );
  13138. childTo = $.effects.setTransition( child, hProps, factor.to.x, childTo );
  13139. }
  13140. if ( restore ) {
  13141. $.effects.saveStyle( child );
  13142. }
  13143. // Animate children
  13144. child.css( childFrom );
  13145. child.animate( childTo, options.duration, options.easing, function() {
  13146. // Restore children
  13147. if ( restore ) {
  13148. $.effects.restoreStyle( child );
  13149. }
  13150. } );
  13151. } );
  13152. }
  13153. // Animate
  13154. element.animate( to, {
  13155. queue: false,
  13156. duration: options.duration,
  13157. easing: options.easing,
  13158. complete: function() {
  13159. var offset = element.offset();
  13160. if ( to.opacity === 0 ) {
  13161. element.css( "opacity", from.opacity );
  13162. }
  13163. if ( !restore ) {
  13164. element
  13165. .css( "position", position === "static" ? "relative" : position )
  13166. .offset( offset );
  13167. // Need to save style here so that automatic style restoration
  13168. // doesn't restore to the original styles from before the animation.
  13169. $.effects.saveStyle( element );
  13170. }
  13171. done();
  13172. }
  13173. } );
  13174. } );
  13175. /*!
  13176. * jQuery UI Effects Scale 1.12.1
  13177. * http://jqueryui.com
  13178. *
  13179. * Copyright jQuery Foundation and other contributors
  13180. * Released under the MIT license.
  13181. * http://jquery.org/license
  13182. */
  13183. //>>label: Scale Effect
  13184. //>>group: Effects
  13185. //>>description: Grows or shrinks an element and its content.
  13186. //>>docs: http://api.jqueryui.com/scale-effect/
  13187. //>>demos: http://jqueryui.com/effect/
  13188. var effectsEffectScale = $.effects.define( "scale", function( options, done ) {
  13189. // Create element
  13190. var el = $( this ),
  13191. mode = options.mode,
  13192. percent = parseInt( options.percent, 10 ) ||
  13193. ( parseInt( options.percent, 10 ) === 0 ? 0 : ( mode !== "effect" ? 0 : 100 ) ),
  13194. newOptions = $.extend( true, {
  13195. from: $.effects.scaledDimensions( el ),
  13196. to: $.effects.scaledDimensions( el, percent, options.direction || "both" ),
  13197. origin: options.origin || [ "middle", "center" ]
  13198. }, options );
  13199. // Fade option to support puff
  13200. if ( options.fade ) {
  13201. newOptions.from.opacity = 1;
  13202. newOptions.to.opacity = 0;
  13203. }
  13204. $.effects.effect.size.call( this, newOptions, done );
  13205. } );
  13206. /*!
  13207. * jQuery UI Effects Puff 1.12.1
  13208. * http://jqueryui.com
  13209. *
  13210. * Copyright jQuery Foundation and other contributors
  13211. * Released under the MIT license.
  13212. * http://jquery.org/license
  13213. */
  13214. //>>label: Puff Effect
  13215. //>>group: Effects
  13216. //>>description: Creates a puff effect by scaling the element up and hiding it at the same time.
  13217. //>>docs: http://api.jqueryui.com/puff-effect/
  13218. //>>demos: http://jqueryui.com/effect/
  13219. var effectsEffectPuff = $.effects.define( "puff", "hide", function( options, done ) {
  13220. var newOptions = $.extend( true, {}, options, {
  13221. fade: true,
  13222. percent: parseInt( options.percent, 10 ) || 150
  13223. } );
  13224. $.effects.effect.scale.call( this, newOptions, done );
  13225. } );
  13226. /*!
  13227. * jQuery UI Effects Pulsate 1.12.1
  13228. * http://jqueryui.com
  13229. *
  13230. * Copyright jQuery Foundation and other contributors
  13231. * Released under the MIT license.
  13232. * http://jquery.org/license
  13233. */
  13234. //>>label: Pulsate Effect
  13235. //>>group: Effects
  13236. //>>description: Pulsates an element n times by changing the opacity to zero and back.
  13237. //>>docs: http://api.jqueryui.com/pulsate-effect/
  13238. //>>demos: http://jqueryui.com/effect/
  13239. var effectsEffectPulsate = $.effects.define( "pulsate", "show", function( options, done ) {
  13240. var element = $( this ),
  13241. mode = options.mode,
  13242. show = mode === "show",
  13243. hide = mode === "hide",
  13244. showhide = show || hide,
  13245. // Showing or hiding leaves off the "last" animation
  13246. anims = ( ( options.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  13247. duration = options.duration / anims,
  13248. animateTo = 0,
  13249. i = 1,
  13250. queuelen = element.queue().length;
  13251. if ( show || !element.is( ":visible" ) ) {
  13252. element.css( "opacity", 0 ).show();
  13253. animateTo = 1;
  13254. }
  13255. // Anims - 1 opacity "toggles"
  13256. for ( ; i < anims; i++ ) {
  13257. element.animate( { opacity: animateTo }, duration, options.easing );
  13258. animateTo = 1 - animateTo;
  13259. }
  13260. element.animate( { opacity: animateTo }, duration, options.easing );
  13261. element.queue( done );
  13262. $.effects.unshift( element, queuelen, anims + 1 );
  13263. } );
  13264. /*!
  13265. * jQuery UI Effects Shake 1.12.1
  13266. * http://jqueryui.com
  13267. *
  13268. * Copyright jQuery Foundation and other contributors
  13269. * Released under the MIT license.
  13270. * http://jquery.org/license
  13271. */
  13272. //>>label: Shake Effect
  13273. //>>group: Effects
  13274. //>>description: Shakes an element horizontally or vertically n times.
  13275. //>>docs: http://api.jqueryui.com/shake-effect/
  13276. //>>demos: http://jqueryui.com/effect/
  13277. var effectsEffectShake = $.effects.define( "shake", function( options, done ) {
  13278. var i = 1,
  13279. element = $( this ),
  13280. direction = options.direction || "left",
  13281. distance = options.distance || 20,
  13282. times = options.times || 3,
  13283. anims = times * 2 + 1,
  13284. speed = Math.round( options.duration / anims ),
  13285. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  13286. positiveMotion = ( direction === "up" || direction === "left" ),
  13287. animation = {},
  13288. animation1 = {},
  13289. animation2 = {},
  13290. queuelen = element.queue().length;
  13291. $.effects.createPlaceholder( element );
  13292. // Animation
  13293. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  13294. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  13295. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  13296. // Animate
  13297. element.animate( animation, speed, options.easing );
  13298. // Shakes
  13299. for ( ; i < times; i++ ) {
  13300. element
  13301. .animate( animation1, speed, options.easing )
  13302. .animate( animation2, speed, options.easing );
  13303. }
  13304. element
  13305. .animate( animation1, speed, options.easing )
  13306. .animate( animation, speed / 2, options.easing )
  13307. .queue( done );
  13308. $.effects.unshift( element, queuelen, anims + 1 );
  13309. } );
  13310. /*!
  13311. * jQuery UI Effects Slide 1.12.1
  13312. * http://jqueryui.com
  13313. *
  13314. * Copyright jQuery Foundation and other contributors
  13315. * Released under the MIT license.
  13316. * http://jquery.org/license
  13317. */
  13318. //>>label: Slide Effect
  13319. //>>group: Effects
  13320. //>>description: Slides an element in and out of the viewport.
  13321. //>>docs: http://api.jqueryui.com/slide-effect/
  13322. //>>demos: http://jqueryui.com/effect/
  13323. var effectsEffectSlide = $.effects.define( "slide", "show", function( options, done ) {
  13324. var startClip, startRef,
  13325. element = $( this ),
  13326. map = {
  13327. up: [ "bottom", "top" ],
  13328. down: [ "top", "bottom" ],
  13329. left: [ "right", "left" ],
  13330. right: [ "left", "right" ]
  13331. },
  13332. mode = options.mode,
  13333. direction = options.direction || "left",
  13334. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  13335. positiveMotion = ( direction === "up" || direction === "left" ),
  13336. distance = options.distance ||
  13337. element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ),
  13338. animation = {};
  13339. $.effects.createPlaceholder( element );
  13340. startClip = element.cssClip();
  13341. startRef = element.position()[ ref ];
  13342. // Define hide animation
  13343. animation[ ref ] = ( positiveMotion ? -1 : 1 ) * distance + startRef;
  13344. animation.clip = element.cssClip();
  13345. animation.clip[ map[ direction ][ 1 ] ] = animation.clip[ map[ direction ][ 0 ] ];
  13346. // Reverse the animation if we're showing
  13347. if ( mode === "show" ) {
  13348. element.cssClip( animation.clip );
  13349. element.css( ref, animation[ ref ] );
  13350. animation.clip = startClip;
  13351. animation[ ref ] = startRef;
  13352. }
  13353. // Actually animate
  13354. element.animate( animation, {
  13355. queue: false,
  13356. duration: options.duration,
  13357. easing: options.easing,
  13358. complete: done
  13359. } );
  13360. } );
  13361. /*!
  13362. * jQuery UI Effects Transfer 1.12.1
  13363. * http://jqueryui.com
  13364. *
  13365. * Copyright jQuery Foundation and other contributors
  13366. * Released under the MIT license.
  13367. * http://jquery.org/license
  13368. */
  13369. //>>label: Transfer Effect
  13370. //>>group: Effects
  13371. //>>description: Displays a transfer effect from one element to another.
  13372. //>>docs: http://api.jqueryui.com/transfer-effect/
  13373. //>>demos: http://jqueryui.com/effect/
  13374. var effect;
  13375. if ( $.uiBackCompat !== false ) {
  13376. effect = $.effects.define( "transfer", function( options, done ) {
  13377. $( this ).transfer( options, done );
  13378. } );
  13379. }
  13380. var effectsEffectTransfer = effect;
  13381. /*!
  13382. * jQuery UI Focusable 1.12.1
  13383. * http://jqueryui.com
  13384. *
  13385. * Copyright jQuery Foundation and other contributors
  13386. * Released under the MIT license.
  13387. * http://jquery.org/license
  13388. */
  13389. //>>label: :focusable Selector
  13390. //>>group: Core
  13391. //>>description: Selects elements which can be focused.
  13392. //>>docs: http://api.jqueryui.com/focusable-selector/
  13393. // Selectors
  13394. $.ui.focusable = function( element, hasTabindex ) {
  13395. var map, mapName, img, focusableIfVisible, fieldset,
  13396. nodeName = element.nodeName.toLowerCase();
  13397. if ( "area" === nodeName ) {
  13398. map = element.parentNode;
  13399. mapName = map.name;
  13400. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  13401. return false;
  13402. }
  13403. img = $( "img[usemap='#" + mapName + "']" );
  13404. return img.length > 0 && img.is( ":visible" );
  13405. }
  13406. if ( /^(input|select|textarea|button|object)$/.test( nodeName ) ) {
  13407. focusableIfVisible = !element.disabled;
  13408. if ( focusableIfVisible ) {
  13409. // Form controls within a disabled fieldset are disabled.
  13410. // However, controls within the fieldset's legend do not get disabled.
  13411. // Since controls generally aren't placed inside legends, we skip
  13412. // this portion of the check.
  13413. fieldset = $( element ).closest( "fieldset" )[ 0 ];
  13414. if ( fieldset ) {
  13415. focusableIfVisible = !fieldset.disabled;
  13416. }
  13417. }
  13418. } else if ( "a" === nodeName ) {
  13419. focusableIfVisible = element.href || hasTabindex;
  13420. } else {
  13421. focusableIfVisible = hasTabindex;
  13422. }
  13423. return focusableIfVisible && $( element ).is( ":visible" ) && visible( $( element ) );
  13424. };
  13425. // Support: IE 8 only
  13426. // IE 8 doesn't resolve inherit to visible/hidden for computed values
  13427. function visible( element ) {
  13428. var visibility = element.css( "visibility" );
  13429. while ( visibility === "inherit" ) {
  13430. element = element.parent();
  13431. visibility = element.css( "visibility" );
  13432. }
  13433. return visibility !== "hidden";
  13434. }
  13435. $.extend( $.expr[ ":" ], {
  13436. focusable: function( element ) {
  13437. return $.ui.focusable( element, $.attr( element, "tabindex" ) != null );
  13438. }
  13439. } );
  13440. var focusable = $.ui.focusable;
  13441. // Support: IE8 Only
  13442. // IE8 does not support the form attribute and when it is supplied. It overwrites the form prop
  13443. // with a string, so we need to find the proper form.
  13444. var form = $.fn.form = function() {
  13445. return typeof this[ 0 ].form === "string" ? this.closest( "form" ) : $( this[ 0 ].form );
  13446. };
  13447. /*!
  13448. * jQuery UI Form Reset Mixin 1.12.1
  13449. * http://jqueryui.com
  13450. *
  13451. * Copyright jQuery Foundation and other contributors
  13452. * Released under the MIT license.
  13453. * http://jquery.org/license
  13454. */
  13455. //>>label: Form Reset Mixin
  13456. //>>group: Core
  13457. //>>description: Refresh input widgets when their form is reset
  13458. //>>docs: http://api.jqueryui.com/form-reset-mixin/
  13459. var formResetMixin = $.ui.formResetMixin = {
  13460. _formResetHandler: function() {
  13461. var form = $( this );
  13462. // Wait for the form reset to actually happen before refreshing
  13463. setTimeout( function() {
  13464. var instances = form.data( "ui-form-reset-instances" );
  13465. $.each( instances, function() {
  13466. this.refresh();
  13467. } );
  13468. } );
  13469. },
  13470. _bindFormResetHandler: function() {
  13471. this.form = this.element.form();
  13472. if ( !this.form.length ) {
  13473. return;
  13474. }
  13475. var instances = this.form.data( "ui-form-reset-instances" ) || [];
  13476. if ( !instances.length ) {
  13477. // We don't use _on() here because we use a single event handler per form
  13478. this.form.on( "reset.ui-form-reset", this._formResetHandler );
  13479. }
  13480. instances.push( this );
  13481. this.form.data( "ui-form-reset-instances", instances );
  13482. },
  13483. _unbindFormResetHandler: function() {
  13484. if ( !this.form.length ) {
  13485. return;
  13486. }
  13487. var instances = this.form.data( "ui-form-reset-instances" );
  13488. instances.splice( $.inArray( this, instances ), 1 );
  13489. if ( instances.length ) {
  13490. this.form.data( "ui-form-reset-instances", instances );
  13491. } else {
  13492. this.form
  13493. .removeData( "ui-form-reset-instances" )
  13494. .off( "reset.ui-form-reset" );
  13495. }
  13496. }
  13497. };
  13498. /*!
  13499. * jQuery UI Support for jQuery core 1.7.x 1.12.1
  13500. * http://jqueryui.com
  13501. *
  13502. * Copyright jQuery Foundation and other contributors
  13503. * Released under the MIT license.
  13504. * http://jquery.org/license
  13505. *
  13506. */
  13507. //>>label: jQuery 1.7 Support
  13508. //>>group: Core
  13509. //>>description: Support version 1.7.x of jQuery core
  13510. // Support: jQuery 1.7 only
  13511. // Not a great way to check versions, but since we only support 1.7+ and only
  13512. // need to detect <1.8, this is a simple check that should suffice. Checking
  13513. // for "1.7." would be a bit safer, but the version string is 1.7, not 1.7.0
  13514. // and we'll never reach 1.70.0 (if we do, we certainly won't be supporting
  13515. // 1.7 anymore). See #11197 for why we're not using feature detection.
  13516. if ( $.fn.jquery.substring( 0, 3 ) === "1.7" ) {
  13517. // Setters for .innerWidth(), .innerHeight(), .outerWidth(), .outerHeight()
  13518. // Unlike jQuery Core 1.8+, these only support numeric values to set the
  13519. // dimensions in pixels
  13520. $.each( [ "Width", "Height" ], function( i, name ) {
  13521. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  13522. type = name.toLowerCase(),
  13523. orig = {
  13524. innerWidth: $.fn.innerWidth,
  13525. innerHeight: $.fn.innerHeight,
  13526. outerWidth: $.fn.outerWidth,
  13527. outerHeight: $.fn.outerHeight
  13528. };
  13529. function reduce( elem, size, border, margin ) {
  13530. $.each( side, function() {
  13531. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  13532. if ( border ) {
  13533. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  13534. }
  13535. if ( margin ) {
  13536. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  13537. }
  13538. } );
  13539. return size;
  13540. }
  13541. $.fn[ "inner" + name ] = function( size ) {
  13542. if ( size === undefined ) {
  13543. return orig[ "inner" + name ].call( this );
  13544. }
  13545. return this.each( function() {
  13546. $( this ).css( type, reduce( this, size ) + "px" );
  13547. } );
  13548. };
  13549. $.fn[ "outer" + name ] = function( size, margin ) {
  13550. if ( typeof size !== "number" ) {
  13551. return orig[ "outer" + name ].call( this, size );
  13552. }
  13553. return this.each( function() {
  13554. $( this ).css( type, reduce( this, size, true, margin ) + "px" );
  13555. } );
  13556. };
  13557. } );
  13558. $.fn.addBack = function( selector ) {
  13559. return this.add( selector == null ?
  13560. this.prevObject : this.prevObject.filter( selector )
  13561. );
  13562. };
  13563. }
  13564. ;
  13565. /*!
  13566. * jQuery UI Keycode 1.12.1
  13567. * http://jqueryui.com
  13568. *
  13569. * Copyright jQuery Foundation and other contributors
  13570. * Released under the MIT license.
  13571. * http://jquery.org/license
  13572. */
  13573. //>>label: Keycode
  13574. //>>group: Core
  13575. //>>description: Provide keycodes as keynames
  13576. //>>docs: http://api.jqueryui.com/jQuery.ui.keyCode/
  13577. var keycode = $.ui.keyCode = {
  13578. BACKSPACE: 8,
  13579. COMMA: 188,
  13580. DELETE: 46,
  13581. DOWN: 40,
  13582. END: 35,
  13583. ENTER: 13,
  13584. ESCAPE: 27,
  13585. HOME: 36,
  13586. LEFT: 37,
  13587. PAGE_DOWN: 34,
  13588. PAGE_UP: 33,
  13589. PERIOD: 190,
  13590. RIGHT: 39,
  13591. SPACE: 32,
  13592. TAB: 9,
  13593. UP: 38
  13594. };
  13595. // Internal use only
  13596. var escapeSelector = $.ui.escapeSelector = ( function() {
  13597. var selectorEscape = /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g;
  13598. return function( selector ) {
  13599. return selector.replace( selectorEscape, "\\$1" );
  13600. };
  13601. } )();
  13602. /*!
  13603. * jQuery UI Labels 1.12.1
  13604. * http://jqueryui.com
  13605. *
  13606. * Copyright jQuery Foundation and other contributors
  13607. * Released under the MIT license.
  13608. * http://jquery.org/license
  13609. */
  13610. //>>label: labels
  13611. //>>group: Core
  13612. //>>description: Find all the labels associated with a given input
  13613. //>>docs: http://api.jqueryui.com/labels/
  13614. var labels = $.fn.labels = function() {
  13615. var ancestor, selector, id, labels, ancestors;
  13616. // Check control.labels first
  13617. if ( this[ 0 ].labels && this[ 0 ].labels.length ) {
  13618. return this.pushStack( this[ 0 ].labels );
  13619. }
  13620. // Support: IE <= 11, FF <= 37, Android <= 2.3 only
  13621. // Above browsers do not support control.labels. Everything below is to support them
  13622. // as well as document fragments. control.labels does not work on document fragments
  13623. labels = this.eq( 0 ).parents( "label" );
  13624. // Look for the label based on the id
  13625. id = this.attr( "id" );
  13626. if ( id ) {
  13627. // We don't search against the document in case the element
  13628. // is disconnected from the DOM
  13629. ancestor = this.eq( 0 ).parents().last();
  13630. // Get a full set of top level ancestors
  13631. ancestors = ancestor.add( ancestor.length ? ancestor.siblings() : this.siblings() );
  13632. // Create a selector for the label based on the id
  13633. selector = "label[for='" + $.ui.escapeSelector( id ) + "']";
  13634. labels = labels.add( ancestors.find( selector ).addBack( selector ) );
  13635. }
  13636. // Return whatever we have found for labels
  13637. return this.pushStack( labels );
  13638. };
  13639. /*!
  13640. * jQuery UI Scroll Parent 1.12.1
  13641. * http://jqueryui.com
  13642. *
  13643. * Copyright jQuery Foundation and other contributors
  13644. * Released under the MIT license.
  13645. * http://jquery.org/license
  13646. */
  13647. //>>label: scrollParent
  13648. //>>group: Core
  13649. //>>description: Get the closest ancestor element that is scrollable.
  13650. //>>docs: http://api.jqueryui.com/scrollParent/
  13651. var scrollParent = $.fn.scrollParent = function( includeHidden ) {
  13652. var position = this.css( "position" ),
  13653. excludeStaticParent = position === "absolute",
  13654. overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
  13655. scrollParent = this.parents().filter( function() {
  13656. var parent = $( this );
  13657. if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
  13658. return false;
  13659. }
  13660. return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) +
  13661. parent.css( "overflow-x" ) );
  13662. } ).eq( 0 );
  13663. return position === "fixed" || !scrollParent.length ?
  13664. $( this[ 0 ].ownerDocument || document ) :
  13665. scrollParent;
  13666. };
  13667. /*!
  13668. * jQuery UI Tabbable 1.12.1
  13669. * http://jqueryui.com
  13670. *
  13671. * Copyright jQuery Foundation and other contributors
  13672. * Released under the MIT license.
  13673. * http://jquery.org/license
  13674. */
  13675. //>>label: :tabbable Selector
  13676. //>>group: Core
  13677. //>>description: Selects elements which can be tabbed to.
  13678. //>>docs: http://api.jqueryui.com/tabbable-selector/
  13679. var tabbable = $.extend( $.expr[ ":" ], {
  13680. tabbable: function( element ) {
  13681. var tabIndex = $.attr( element, "tabindex" ),
  13682. hasTabindex = tabIndex != null;
  13683. return ( !hasTabindex || tabIndex >= 0 ) && $.ui.focusable( element, hasTabindex );
  13684. }
  13685. } );
  13686. /*!
  13687. * jQuery UI Unique ID 1.12.1
  13688. * http://jqueryui.com
  13689. *
  13690. * Copyright jQuery Foundation and other contributors
  13691. * Released under the MIT license.
  13692. * http://jquery.org/license
  13693. */
  13694. //>>label: uniqueId
  13695. //>>group: Core
  13696. //>>description: Functions to generate and remove uniqueId's
  13697. //>>docs: http://api.jqueryui.com/uniqueId/
  13698. var uniqueId = $.fn.extend( {
  13699. uniqueId: ( function() {
  13700. var uuid = 0;
  13701. return function() {
  13702. return this.each( function() {
  13703. if ( !this.id ) {
  13704. this.id = "ui-id-" + ( ++uuid );
  13705. }
  13706. } );
  13707. };
  13708. } )(),
  13709. removeUniqueId: function() {
  13710. return this.each( function() {
  13711. if ( /^ui-id-\d+$/.test( this.id ) ) {
  13712. $( this ).removeAttr( "id" );
  13713. }
  13714. } );
  13715. }
  13716. } );
  13717. /*!
  13718. * jQuery UI Accordion 1.12.1
  13719. * http://jqueryui.com
  13720. *
  13721. * Copyright jQuery Foundation and other contributors
  13722. * Released under the MIT license.
  13723. * http://jquery.org/license
  13724. */
  13725. //>>label: Accordion
  13726. //>>group: Widgets
  13727. // jscs:disable maximumLineLength
  13728. //>>description: Displays collapsible content panels for presenting information in a limited amount of space.
  13729. // jscs:enable maximumLineLength
  13730. //>>docs: http://api.jqueryui.com/accordion/
  13731. //>>demos: http://jqueryui.com/accordion/
  13732. //>>css.structure: ../../themes/base/core.css
  13733. //>>css.structure: ../../themes/base/accordion.css
  13734. //>>css.theme: ../../themes/base/theme.css
  13735. var widgetsAccordion = $.widget( "ui.accordion", {
  13736. version: "1.12.1",
  13737. options: {
  13738. active: 0,
  13739. animate: {},
  13740. classes: {
  13741. "ui-accordion-header": "ui-corner-top",
  13742. "ui-accordion-header-collapsed": "ui-corner-all",
  13743. "ui-accordion-content": "ui-corner-bottom"
  13744. },
  13745. collapsible: false,
  13746. event: "click",
  13747. header: "> li > :first-child, > :not(li):even",
  13748. heightStyle: "auto",
  13749. icons: {
  13750. activeHeader: "ui-icon-triangle-1-s",
  13751. header: "ui-icon-triangle-1-e"
  13752. },
  13753. // Callbacks
  13754. activate: null,
  13755. beforeActivate: null
  13756. },
  13757. hideProps: {
  13758. borderTopWidth: "hide",
  13759. borderBottomWidth: "hide",
  13760. paddingTop: "hide",
  13761. paddingBottom: "hide",
  13762. height: "hide"
  13763. },
  13764. showProps: {
  13765. borderTopWidth: "show",
  13766. borderBottomWidth: "show",
  13767. paddingTop: "show",
  13768. paddingBottom: "show",
  13769. height: "show"
  13770. },
  13771. _create: function() {
  13772. var options = this.options;
  13773. this.prevShow = this.prevHide = $();
  13774. this._addClass( "ui-accordion", "ui-widget ui-helper-reset" );
  13775. this.element.attr( "role", "tablist" );
  13776. // Don't allow collapsible: false and active: false / null
  13777. if ( !options.collapsible && ( options.active === false || options.active == null ) ) {
  13778. options.active = 0;
  13779. }
  13780. this._processPanels();
  13781. // handle negative values
  13782. if ( options.active < 0 ) {
  13783. options.active += this.headers.length;
  13784. }
  13785. this._refresh();
  13786. },
  13787. _getCreateEventData: function() {
  13788. return {
  13789. header: this.active,
  13790. panel: !this.active.length ? $() : this.active.next()
  13791. };
  13792. },
  13793. _createIcons: function() {
  13794. var icon, children,
  13795. icons = this.options.icons;
  13796. if ( icons ) {
  13797. icon = $( "<span>" );
  13798. this._addClass( icon, "ui-accordion-header-icon", "ui-icon " + icons.header );
  13799. icon.prependTo( this.headers );
  13800. children = this.active.children( ".ui-accordion-header-icon" );
  13801. this._removeClass( children, icons.header )
  13802. ._addClass( children, null, icons.activeHeader )
  13803. ._addClass( this.headers, "ui-accordion-icons" );
  13804. }
  13805. },
  13806. _destroyIcons: function() {
  13807. this._removeClass( this.headers, "ui-accordion-icons" );
  13808. this.headers.children( ".ui-accordion-header-icon" ).remove();
  13809. },
  13810. _destroy: function() {
  13811. var contents;
  13812. // Clean up main element
  13813. this.element.removeAttr( "role" );
  13814. // Clean up headers
  13815. this.headers
  13816. .removeAttr( "role aria-expanded aria-selected aria-controls tabIndex" )
  13817. .removeUniqueId();
  13818. this._destroyIcons();
  13819. // Clean up content panels
  13820. contents = this.headers.next()
  13821. .css( "display", "" )
  13822. .removeAttr( "role aria-hidden aria-labelledby" )
  13823. .removeUniqueId();
  13824. if ( this.options.heightStyle !== "content" ) {
  13825. contents.css( "height", "" );
  13826. }
  13827. },
  13828. _setOption: function( key, value ) {
  13829. if ( key === "active" ) {
  13830. // _activate() will handle invalid values and update this.options
  13831. this._activate( value );
  13832. return;
  13833. }
  13834. if ( key === "event" ) {
  13835. if ( this.options.event ) {
  13836. this._off( this.headers, this.options.event );
  13837. }
  13838. this._setupEvents( value );
  13839. }
  13840. this._super( key, value );
  13841. // Setting collapsible: false while collapsed; open first panel
  13842. if ( key === "collapsible" && !value && this.options.active === false ) {
  13843. this._activate( 0 );
  13844. }
  13845. if ( key === "icons" ) {
  13846. this._destroyIcons();
  13847. if ( value ) {
  13848. this._createIcons();
  13849. }
  13850. }
  13851. },
  13852. _setOptionDisabled: function( value ) {
  13853. this._super( value );
  13854. this.element.attr( "aria-disabled", value );
  13855. // Support: IE8 Only
  13856. // #5332 / #6059 - opacity doesn't cascade to positioned elements in IE
  13857. // so we need to add the disabled class to the headers and panels
  13858. this._toggleClass( null, "ui-state-disabled", !!value );
  13859. this._toggleClass( this.headers.add( this.headers.next() ), null, "ui-state-disabled",
  13860. !!value );
  13861. },
  13862. _keydown: function( event ) {
  13863. if ( event.altKey || event.ctrlKey ) {
  13864. return;
  13865. }
  13866. var keyCode = $.ui.keyCode,
  13867. length = this.headers.length,
  13868. currentIndex = this.headers.index( event.target ),
  13869. toFocus = false;
  13870. switch ( event.keyCode ) {
  13871. case keyCode.RIGHT:
  13872. case keyCode.DOWN:
  13873. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  13874. break;
  13875. case keyCode.LEFT:
  13876. case keyCode.UP:
  13877. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  13878. break;
  13879. case keyCode.SPACE:
  13880. case keyCode.ENTER:
  13881. this._eventHandler( event );
  13882. break;
  13883. case keyCode.HOME:
  13884. toFocus = this.headers[ 0 ];
  13885. break;
  13886. case keyCode.END:
  13887. toFocus = this.headers[ length - 1 ];
  13888. break;
  13889. }
  13890. if ( toFocus ) {
  13891. $( event.target ).attr( "tabIndex", -1 );
  13892. $( toFocus ).attr( "tabIndex", 0 );
  13893. $( toFocus ).trigger( "focus" );
  13894. event.preventDefault();
  13895. }
  13896. },
  13897. _panelKeyDown: function( event ) {
  13898. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  13899. $( event.currentTarget ).prev().trigger( "focus" );
  13900. }
  13901. },
  13902. refresh: function() {
  13903. var options = this.options;
  13904. this._processPanels();
  13905. // Was collapsed or no panel
  13906. if ( ( options.active === false && options.collapsible === true ) ||
  13907. !this.headers.length ) {
  13908. options.active = false;
  13909. this.active = $();
  13910. // active false only when collapsible is true
  13911. } else if ( options.active === false ) {
  13912. this._activate( 0 );
  13913. // was active, but active panel is gone
  13914. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  13915. // all remaining panel are disabled
  13916. if ( this.headers.length === this.headers.find( ".ui-state-disabled" ).length ) {
  13917. options.active = false;
  13918. this.active = $();
  13919. // activate previous panel
  13920. } else {
  13921. this._activate( Math.max( 0, options.active - 1 ) );
  13922. }
  13923. // was active, active panel still exists
  13924. } else {
  13925. // make sure active index is correct
  13926. options.active = this.headers.index( this.active );
  13927. }
  13928. this._destroyIcons();
  13929. this._refresh();
  13930. },
  13931. _processPanels: function() {
  13932. var prevHeaders = this.headers,
  13933. prevPanels = this.panels;
  13934. this.headers = this.element.find( this.options.header );
  13935. this._addClass( this.headers, "ui-accordion-header ui-accordion-header-collapsed",
  13936. "ui-state-default" );
  13937. this.panels = this.headers.next().filter( ":not(.ui-accordion-content-active)" ).hide();
  13938. this._addClass( this.panels, "ui-accordion-content", "ui-helper-reset ui-widget-content" );
  13939. // Avoid memory leaks (#10056)
  13940. if ( prevPanels ) {
  13941. this._off( prevHeaders.not( this.headers ) );
  13942. this._off( prevPanels.not( this.panels ) );
  13943. }
  13944. },
  13945. _refresh: function() {
  13946. var maxHeight,
  13947. options = this.options,
  13948. heightStyle = options.heightStyle,
  13949. parent = this.element.parent();
  13950. this.active = this._findActive( options.active );
  13951. this._addClass( this.active, "ui-accordion-header-active", "ui-state-active" )
  13952. ._removeClass( this.active, "ui-accordion-header-collapsed" );
  13953. this._addClass( this.active.next(), "ui-accordion-content-active" );
  13954. this.active.next().show();
  13955. this.headers
  13956. .attr( "role", "tab" )
  13957. .each( function() {
  13958. var header = $( this ),
  13959. headerId = header.uniqueId().attr( "id" ),
  13960. panel = header.next(),
  13961. panelId = panel.uniqueId().attr( "id" );
  13962. header.attr( "aria-controls", panelId );
  13963. panel.attr( "aria-labelledby", headerId );
  13964. } )
  13965. .next()
  13966. .attr( "role", "tabpanel" );
  13967. this.headers
  13968. .not( this.active )
  13969. .attr( {
  13970. "aria-selected": "false",
  13971. "aria-expanded": "false",
  13972. tabIndex: -1
  13973. } )
  13974. .next()
  13975. .attr( {
  13976. "aria-hidden": "true"
  13977. } )
  13978. .hide();
  13979. // Make sure at least one header is in the tab order
  13980. if ( !this.active.length ) {
  13981. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  13982. } else {
  13983. this.active.attr( {
  13984. "aria-selected": "true",
  13985. "aria-expanded": "true",
  13986. tabIndex: 0
  13987. } )
  13988. .next()
  13989. .attr( {
  13990. "aria-hidden": "false"
  13991. } );
  13992. }
  13993. this._createIcons();
  13994. this._setupEvents( options.event );
  13995. if ( heightStyle === "fill" ) {
  13996. maxHeight = parent.height();
  13997. this.element.siblings( ":visible" ).each( function() {
  13998. var elem = $( this ),
  13999. position = elem.css( "position" );
  14000. if ( position === "absolute" || position === "fixed" ) {
  14001. return;
  14002. }
  14003. maxHeight -= elem.outerHeight( true );
  14004. } );
  14005. this.headers.each( function() {
  14006. maxHeight -= $( this ).outerHeight( true );
  14007. } );
  14008. this.headers.next()
  14009. .each( function() {
  14010. $( this ).height( Math.max( 0, maxHeight -
  14011. $( this ).innerHeight() + $( this ).height() ) );
  14012. } )
  14013. .css( "overflow", "auto" );
  14014. } else if ( heightStyle === "auto" ) {
  14015. maxHeight = 0;
  14016. this.headers.next()
  14017. .each( function() {
  14018. var isVisible = $( this ).is( ":visible" );
  14019. if ( !isVisible ) {
  14020. $( this ).show();
  14021. }
  14022. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  14023. if ( !isVisible ) {
  14024. $( this ).hide();
  14025. }
  14026. } )
  14027. .height( maxHeight );
  14028. }
  14029. },
  14030. _activate: function( index ) {
  14031. var active = this._findActive( index )[ 0 ];
  14032. // Trying to activate the already active panel
  14033. if ( active === this.active[ 0 ] ) {
  14034. return;
  14035. }
  14036. // Trying to collapse, simulate a click on the currently active header
  14037. active = active || this.active[ 0 ];
  14038. this._eventHandler( {
  14039. target: active,
  14040. currentTarget: active,
  14041. preventDefault: $.noop
  14042. } );
  14043. },
  14044. _findActive: function( selector ) {
  14045. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  14046. },
  14047. _setupEvents: function( event ) {
  14048. var events = {
  14049. keydown: "_keydown"
  14050. };
  14051. if ( event ) {
  14052. $.each( event.split( " " ), function( index, eventName ) {
  14053. events[ eventName ] = "_eventHandler";
  14054. } );
  14055. }
  14056. this._off( this.headers.add( this.headers.next() ) );
  14057. this._on( this.headers, events );
  14058. this._on( this.headers.next(), { keydown: "_panelKeyDown" } );
  14059. this._hoverable( this.headers );
  14060. this._focusable( this.headers );
  14061. },
  14062. _eventHandler: function( event ) {
  14063. var activeChildren, clickedChildren,
  14064. options = this.options,
  14065. active = this.active,
  14066. clicked = $( event.currentTarget ),
  14067. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  14068. collapsing = clickedIsActive && options.collapsible,
  14069. toShow = collapsing ? $() : clicked.next(),
  14070. toHide = active.next(),
  14071. eventData = {
  14072. oldHeader: active,
  14073. oldPanel: toHide,
  14074. newHeader: collapsing ? $() : clicked,
  14075. newPanel: toShow
  14076. };
  14077. event.preventDefault();
  14078. if (
  14079. // click on active header, but not collapsible
  14080. ( clickedIsActive && !options.collapsible ) ||
  14081. // allow canceling activation
  14082. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  14083. return;
  14084. }
  14085. options.active = collapsing ? false : this.headers.index( clicked );
  14086. // When the call to ._toggle() comes after the class changes
  14087. // it causes a very odd bug in IE 8 (see #6720)
  14088. this.active = clickedIsActive ? $() : clicked;
  14089. this._toggle( eventData );
  14090. // Switch classes
  14091. // corner classes on the previously active header stay after the animation
  14092. this._removeClass( active, "ui-accordion-header-active", "ui-state-active" );
  14093. if ( options.icons ) {
  14094. activeChildren = active.children( ".ui-accordion-header-icon" );
  14095. this._removeClass( activeChildren, null, options.icons.activeHeader )
  14096. ._addClass( activeChildren, null, options.icons.header );
  14097. }
  14098. if ( !clickedIsActive ) {
  14099. this._removeClass( clicked, "ui-accordion-header-collapsed" )
  14100. ._addClass( clicked, "ui-accordion-header-active", "ui-state-active" );
  14101. if ( options.icons ) {
  14102. clickedChildren = clicked.children( ".ui-accordion-header-icon" );
  14103. this._removeClass( clickedChildren, null, options.icons.header )
  14104. ._addClass( clickedChildren, null, options.icons.activeHeader );
  14105. }
  14106. this._addClass( clicked.next(), "ui-accordion-content-active" );
  14107. }
  14108. },
  14109. _toggle: function( data ) {
  14110. var toShow = data.newPanel,
  14111. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  14112. // Handle activating a panel during the animation for another activation
  14113. this.prevShow.add( this.prevHide ).stop( true, true );
  14114. this.prevShow = toShow;
  14115. this.prevHide = toHide;
  14116. if ( this.options.animate ) {
  14117. this._animate( toShow, toHide, data );
  14118. } else {
  14119. toHide.hide();
  14120. toShow.show();
  14121. this._toggleComplete( data );
  14122. }
  14123. toHide.attr( {
  14124. "aria-hidden": "true"
  14125. } );
  14126. toHide.prev().attr( {
  14127. "aria-selected": "false",
  14128. "aria-expanded": "false"
  14129. } );
  14130. // if we're switching panels, remove the old header from the tab order
  14131. // if we're opening from collapsed state, remove the previous header from the tab order
  14132. // if we're collapsing, then keep the collapsing header in the tab order
  14133. if ( toShow.length && toHide.length ) {
  14134. toHide.prev().attr( {
  14135. "tabIndex": -1,
  14136. "aria-expanded": "false"
  14137. } );
  14138. } else if ( toShow.length ) {
  14139. this.headers.filter( function() {
  14140. return parseInt( $( this ).attr( "tabIndex" ), 10 ) === 0;
  14141. } )
  14142. .attr( "tabIndex", -1 );
  14143. }
  14144. toShow
  14145. .attr( "aria-hidden", "false" )
  14146. .prev()
  14147. .attr( {
  14148. "aria-selected": "true",
  14149. "aria-expanded": "true",
  14150. tabIndex: 0
  14151. } );
  14152. },
  14153. _animate: function( toShow, toHide, data ) {
  14154. var total, easing, duration,
  14155. that = this,
  14156. adjust = 0,
  14157. boxSizing = toShow.css( "box-sizing" ),
  14158. down = toShow.length &&
  14159. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  14160. animate = this.options.animate || {},
  14161. options = down && animate.down || animate,
  14162. complete = function() {
  14163. that._toggleComplete( data );
  14164. };
  14165. if ( typeof options === "number" ) {
  14166. duration = options;
  14167. }
  14168. if ( typeof options === "string" ) {
  14169. easing = options;
  14170. }
  14171. // fall back from options to animation in case of partial down settings
  14172. easing = easing || options.easing || animate.easing;
  14173. duration = duration || options.duration || animate.duration;
  14174. if ( !toHide.length ) {
  14175. return toShow.animate( this.showProps, duration, easing, complete );
  14176. }
  14177. if ( !toShow.length ) {
  14178. return toHide.animate( this.hideProps, duration, easing, complete );
  14179. }
  14180. total = toShow.show().outerHeight();
  14181. toHide.animate( this.hideProps, {
  14182. duration: duration,
  14183. easing: easing,
  14184. step: function( now, fx ) {
  14185. fx.now = Math.round( now );
  14186. }
  14187. } );
  14188. toShow
  14189. .hide()
  14190. .animate( this.showProps, {
  14191. duration: duration,
  14192. easing: easing,
  14193. complete: complete,
  14194. step: function( now, fx ) {
  14195. fx.now = Math.round( now );
  14196. if ( fx.prop !== "height" ) {
  14197. if ( boxSizing === "content-box" ) {
  14198. adjust += fx.now;
  14199. }
  14200. } else if ( that.options.heightStyle !== "content" ) {
  14201. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  14202. adjust = 0;
  14203. }
  14204. }
  14205. } );
  14206. },
  14207. _toggleComplete: function( data ) {
  14208. var toHide = data.oldPanel,
  14209. prev = toHide.prev();
  14210. this._removeClass( toHide, "ui-accordion-content-active" );
  14211. this._removeClass( prev, "ui-accordion-header-active" )
  14212. ._addClass( prev, "ui-accordion-header-collapsed" );
  14213. // Work around for rendering bug in IE (#5421)
  14214. if ( toHide.length ) {
  14215. toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className;
  14216. }
  14217. this._trigger( "activate", null, data );
  14218. }
  14219. } );
  14220. var safeActiveElement = $.ui.safeActiveElement = function( document ) {
  14221. var activeElement;
  14222. // Support: IE 9 only
  14223. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  14224. try {
  14225. activeElement = document.activeElement;
  14226. } catch ( error ) {
  14227. activeElement = document.body;
  14228. }
  14229. // Support: IE 9 - 11 only
  14230. // IE may return null instead of an element
  14231. // Interestingly, this only seems to occur when NOT in an iframe
  14232. if ( !activeElement ) {
  14233. activeElement = document.body;
  14234. }
  14235. // Support: IE 11 only
  14236. // IE11 returns a seemingly empty object in some cases when accessing
  14237. // document.activeElement from an <iframe>
  14238. if ( !activeElement.nodeName ) {
  14239. activeElement = document.body;
  14240. }
  14241. return activeElement;
  14242. };
  14243. /*!
  14244. * jQuery UI Menu 1.12.1
  14245. * http://jqueryui.com
  14246. *
  14247. * Copyright jQuery Foundation and other contributors
  14248. * Released under the MIT license.
  14249. * http://jquery.org/license
  14250. */
  14251. //>>label: Menu
  14252. //>>group: Widgets
  14253. //>>description: Creates nestable menus.
  14254. //>>docs: http://api.jqueryui.com/menu/
  14255. //>>demos: http://jqueryui.com/menu/
  14256. //>>css.structure: ../../themes/base/core.css
  14257. //>>css.structure: ../../themes/base/menu.css
  14258. //>>css.theme: ../../themes/base/theme.css
  14259. var widgetsMenu = $.widget( "ui.menu", {
  14260. version: "1.12.1",
  14261. defaultElement: "<ul>",
  14262. delay: 300,
  14263. options: {
  14264. icons: {
  14265. submenu: "ui-icon-caret-1-e"
  14266. },
  14267. items: "> *",
  14268. menus: "ul",
  14269. position: {
  14270. my: "left top",
  14271. at: "right top"
  14272. },
  14273. role: "menu",
  14274. // Callbacks
  14275. blur: null,
  14276. focus: null,
  14277. select: null
  14278. },
  14279. _create: function() {
  14280. this.activeMenu = this.element;
  14281. // Flag used to prevent firing of the click handler
  14282. // as the event bubbles up through nested menus
  14283. this.mouseHandled = false;
  14284. this.element
  14285. .uniqueId()
  14286. .attr( {
  14287. role: this.options.role,
  14288. tabIndex: 0
  14289. } );
  14290. this._addClass( "ui-menu", "ui-widget ui-widget-content" );
  14291. this._on( {
  14292. // Prevent focus from sticking to links inside menu after clicking
  14293. // them (focus should always stay on UL during navigation).
  14294. "mousedown .ui-menu-item": function( event ) {
  14295. event.preventDefault();
  14296. },
  14297. "click .ui-menu-item": function( event ) {
  14298. var target = $( event.target );
  14299. var active = $( $.ui.safeActiveElement( this.document[ 0 ] ) );
  14300. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  14301. this.select( event );
  14302. // Only set the mouseHandled flag if the event will bubble, see #9469.
  14303. if ( !event.isPropagationStopped() ) {
  14304. this.mouseHandled = true;
  14305. }
  14306. // Open submenu on click
  14307. if ( target.has( ".ui-menu" ).length ) {
  14308. this.expand( event );
  14309. } else if ( !this.element.is( ":focus" ) &&
  14310. active.closest( ".ui-menu" ).length ) {
  14311. // Redirect focus to the menu
  14312. this.element.trigger( "focus", [ true ] );
  14313. // If the active item is on the top level, let it stay active.
  14314. // Otherwise, blur the active item since it is no longer visible.
  14315. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  14316. clearTimeout( this.timer );
  14317. }
  14318. }
  14319. }
  14320. },
  14321. "mouseenter .ui-menu-item": function( event ) {
  14322. // Ignore mouse events while typeahead is active, see #10458.
  14323. // Prevents focusing the wrong item when typeahead causes a scroll while the mouse
  14324. // is over an item in the menu
  14325. if ( this.previousFilter ) {
  14326. return;
  14327. }
  14328. var actualTarget = $( event.target ).closest( ".ui-menu-item" ),
  14329. target = $( event.currentTarget );
  14330. // Ignore bubbled events on parent items, see #11641
  14331. if ( actualTarget[ 0 ] !== target[ 0 ] ) {
  14332. return;
  14333. }
  14334. // Remove ui-state-active class from siblings of the newly focused menu item
  14335. // to avoid a jump caused by adjacent elements both having a class with a border
  14336. this._removeClass( target.siblings().children( ".ui-state-active" ),
  14337. null, "ui-state-active" );
  14338. this.focus( event, target );
  14339. },
  14340. mouseleave: "collapseAll",
  14341. "mouseleave .ui-menu": "collapseAll",
  14342. focus: function( event, keepActiveItem ) {
  14343. // If there's already an active item, keep it active
  14344. // If not, activate the first item
  14345. var item = this.active || this.element.find( this.options.items ).eq( 0 );
  14346. if ( !keepActiveItem ) {
  14347. this.focus( event, item );
  14348. }
  14349. },
  14350. blur: function( event ) {
  14351. this._delay( function() {
  14352. var notContained = !$.contains(
  14353. this.element[ 0 ],
  14354. $.ui.safeActiveElement( this.document[ 0 ] )
  14355. );
  14356. if ( notContained ) {
  14357. this.collapseAll( event );
  14358. }
  14359. } );
  14360. },
  14361. keydown: "_keydown"
  14362. } );
  14363. this.refresh();
  14364. // Clicks outside of a menu collapse any open menus
  14365. this._on( this.document, {
  14366. click: function( event ) {
  14367. if ( this._closeOnDocumentClick( event ) ) {
  14368. this.collapseAll( event );
  14369. }
  14370. // Reset the mouseHandled flag
  14371. this.mouseHandled = false;
  14372. }
  14373. } );
  14374. },
  14375. _destroy: function() {
  14376. var items = this.element.find( ".ui-menu-item" )
  14377. .removeAttr( "role aria-disabled" ),
  14378. submenus = items.children( ".ui-menu-item-wrapper" )
  14379. .removeUniqueId()
  14380. .removeAttr( "tabIndex role aria-haspopup" );
  14381. // Destroy (sub)menus
  14382. this.element
  14383. .removeAttr( "aria-activedescendant" )
  14384. .find( ".ui-menu" ).addBack()
  14385. .removeAttr( "role aria-labelledby aria-expanded aria-hidden aria-disabled " +
  14386. "tabIndex" )
  14387. .removeUniqueId()
  14388. .show();
  14389. submenus.children().each( function() {
  14390. var elem = $( this );
  14391. if ( elem.data( "ui-menu-submenu-caret" ) ) {
  14392. elem.remove();
  14393. }
  14394. } );
  14395. },
  14396. _keydown: function( event ) {
  14397. var match, prev, character, skip,
  14398. preventDefault = true;
  14399. switch ( event.keyCode ) {
  14400. case $.ui.keyCode.PAGE_UP:
  14401. this.previousPage( event );
  14402. break;
  14403. case $.ui.keyCode.PAGE_DOWN:
  14404. this.nextPage( event );
  14405. break;
  14406. case $.ui.keyCode.HOME:
  14407. this._move( "first", "first", event );
  14408. break;
  14409. case $.ui.keyCode.END:
  14410. this._move( "last", "last", event );
  14411. break;
  14412. case $.ui.keyCode.UP:
  14413. this.previous( event );
  14414. break;
  14415. case $.ui.keyCode.DOWN:
  14416. this.next( event );
  14417. break;
  14418. case $.ui.keyCode.LEFT:
  14419. this.collapse( event );
  14420. break;
  14421. case $.ui.keyCode.RIGHT:
  14422. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  14423. this.expand( event );
  14424. }
  14425. break;
  14426. case $.ui.keyCode.ENTER:
  14427. case $.ui.keyCode.SPACE:
  14428. this._activate( event );
  14429. break;
  14430. case $.ui.keyCode.ESCAPE:
  14431. this.collapse( event );
  14432. break;
  14433. default:
  14434. preventDefault = false;
  14435. prev = this.previousFilter || "";
  14436. skip = false;
  14437. // Support number pad values
  14438. character = event.keyCode >= 96 && event.keyCode <= 105 ?
  14439. ( event.keyCode - 96 ).toString() : String.fromCharCode( event.keyCode );
  14440. clearTimeout( this.filterTimer );
  14441. if ( character === prev ) {
  14442. skip = true;
  14443. } else {
  14444. character = prev + character;
  14445. }
  14446. match = this._filterMenuItems( character );
  14447. match = skip && match.index( this.active.next() ) !== -1 ?
  14448. this.active.nextAll( ".ui-menu-item" ) :
  14449. match;
  14450. // If no matches on the current filter, reset to the last character pressed
  14451. // to move down the menu to the first item that starts with that character
  14452. if ( !match.length ) {
  14453. character = String.fromCharCode( event.keyCode );
  14454. match = this._filterMenuItems( character );
  14455. }
  14456. if ( match.length ) {
  14457. this.focus( event, match );
  14458. this.previousFilter = character;
  14459. this.filterTimer = this._delay( function() {
  14460. delete this.previousFilter;
  14461. }, 1000 );
  14462. } else {
  14463. delete this.previousFilter;
  14464. }
  14465. }
  14466. if ( preventDefault ) {
  14467. event.preventDefault();
  14468. }
  14469. },
  14470. _activate: function( event ) {
  14471. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  14472. if ( this.active.children( "[aria-haspopup='true']" ).length ) {
  14473. this.expand( event );
  14474. } else {
  14475. this.select( event );
  14476. }
  14477. }
  14478. },
  14479. refresh: function() {
  14480. var menus, items, newSubmenus, newItems, newWrappers,
  14481. that = this,
  14482. icon = this.options.icons.submenu,
  14483. submenus = this.element.find( this.options.menus );
  14484. this._toggleClass( "ui-menu-icons", null, !!this.element.find( ".ui-icon" ).length );
  14485. // Initialize nested menus
  14486. newSubmenus = submenus.filter( ":not(.ui-menu)" )
  14487. .hide()
  14488. .attr( {
  14489. role: this.options.role,
  14490. "aria-hidden": "true",
  14491. "aria-expanded": "false"
  14492. } )
  14493. .each( function() {
  14494. var menu = $( this ),
  14495. item = menu.prev(),
  14496. submenuCaret = $( "<span>" ).data( "ui-menu-submenu-caret", true );
  14497. that._addClass( submenuCaret, "ui-menu-icon", "ui-icon " + icon );
  14498. item
  14499. .attr( "aria-haspopup", "true" )
  14500. .prepend( submenuCaret );
  14501. menu.attr( "aria-labelledby", item.attr( "id" ) );
  14502. } );
  14503. this._addClass( newSubmenus, "ui-menu", "ui-widget ui-widget-content ui-front" );
  14504. menus = submenus.add( this.element );
  14505. items = menus.find( this.options.items );
  14506. // Initialize menu-items containing spaces and/or dashes only as dividers
  14507. items.not( ".ui-menu-item" ).each( function() {
  14508. var item = $( this );
  14509. if ( that._isDivider( item ) ) {
  14510. that._addClass( item, "ui-menu-divider", "ui-widget-content" );
  14511. }
  14512. } );
  14513. // Don't refresh list items that are already adapted
  14514. newItems = items.not( ".ui-menu-item, .ui-menu-divider" );
  14515. newWrappers = newItems.children()
  14516. .not( ".ui-menu" )
  14517. .uniqueId()
  14518. .attr( {
  14519. tabIndex: -1,
  14520. role: this._itemRole()
  14521. } );
  14522. this._addClass( newItems, "ui-menu-item" )
  14523. ._addClass( newWrappers, "ui-menu-item-wrapper" );
  14524. // Add aria-disabled attribute to any disabled menu item
  14525. items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  14526. // If the active item has been removed, blur the menu
  14527. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  14528. this.blur();
  14529. }
  14530. },
  14531. _itemRole: function() {
  14532. return {
  14533. menu: "menuitem",
  14534. listbox: "option"
  14535. }[ this.options.role ];
  14536. },
  14537. _setOption: function( key, value ) {
  14538. if ( key === "icons" ) {
  14539. var icons = this.element.find( ".ui-menu-icon" );
  14540. this._removeClass( icons, null, this.options.icons.submenu )
  14541. ._addClass( icons, null, value.submenu );
  14542. }
  14543. this._super( key, value );
  14544. },
  14545. _setOptionDisabled: function( value ) {
  14546. this._super( value );
  14547. this.element.attr( "aria-disabled", String( value ) );
  14548. this._toggleClass( null, "ui-state-disabled", !!value );
  14549. },
  14550. focus: function( event, item ) {
  14551. var nested, focused, activeParent;
  14552. this.blur( event, event && event.type === "focus" );
  14553. this._scrollIntoView( item );
  14554. this.active = item.first();
  14555. focused = this.active.children( ".ui-menu-item-wrapper" );
  14556. this._addClass( focused, null, "ui-state-active" );
  14557. // Only update aria-activedescendant if there's a role
  14558. // otherwise we assume focus is managed elsewhere
  14559. if ( this.options.role ) {
  14560. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  14561. }
  14562. // Highlight active parent menu item, if any
  14563. activeParent = this.active
  14564. .parent()
  14565. .closest( ".ui-menu-item" )
  14566. .children( ".ui-menu-item-wrapper" );
  14567. this._addClass( activeParent, null, "ui-state-active" );
  14568. if ( event && event.type === "keydown" ) {
  14569. this._close();
  14570. } else {
  14571. this.timer = this._delay( function() {
  14572. this._close();
  14573. }, this.delay );
  14574. }
  14575. nested = item.children( ".ui-menu" );
  14576. if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
  14577. this._startOpening( nested );
  14578. }
  14579. this.activeMenu = item.parent();
  14580. this._trigger( "focus", event, { item: item } );
  14581. },
  14582. _scrollIntoView: function( item ) {
  14583. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  14584. if ( this._hasScroll() ) {
  14585. borderTop = parseFloat( $.css( this.activeMenu[ 0 ], "borderTopWidth" ) ) || 0;
  14586. paddingTop = parseFloat( $.css( this.activeMenu[ 0 ], "paddingTop" ) ) || 0;
  14587. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  14588. scroll = this.activeMenu.scrollTop();
  14589. elementHeight = this.activeMenu.height();
  14590. itemHeight = item.outerHeight();
  14591. if ( offset < 0 ) {
  14592. this.activeMenu.scrollTop( scroll + offset );
  14593. } else if ( offset + itemHeight > elementHeight ) {
  14594. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  14595. }
  14596. }
  14597. },
  14598. blur: function( event, fromFocus ) {
  14599. if ( !fromFocus ) {
  14600. clearTimeout( this.timer );
  14601. }
  14602. if ( !this.active ) {
  14603. return;
  14604. }
  14605. this._removeClass( this.active.children( ".ui-menu-item-wrapper" ),
  14606. null, "ui-state-active" );
  14607. this._trigger( "blur", event, { item: this.active } );
  14608. this.active = null;
  14609. },
  14610. _startOpening: function( submenu ) {
  14611. clearTimeout( this.timer );
  14612. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  14613. // shift in the submenu position when mousing over the caret icon
  14614. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  14615. return;
  14616. }
  14617. this.timer = this._delay( function() {
  14618. this._close();
  14619. this._open( submenu );
  14620. }, this.delay );
  14621. },
  14622. _open: function( submenu ) {
  14623. var position = $.extend( {
  14624. of: this.active
  14625. }, this.options.position );
  14626. clearTimeout( this.timer );
  14627. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  14628. .hide()
  14629. .attr( "aria-hidden", "true" );
  14630. submenu
  14631. .show()
  14632. .removeAttr( "aria-hidden" )
  14633. .attr( "aria-expanded", "true" )
  14634. .position( position );
  14635. },
  14636. collapseAll: function( event, all ) {
  14637. clearTimeout( this.timer );
  14638. this.timer = this._delay( function() {
  14639. // If we were passed an event, look for the submenu that contains the event
  14640. var currentMenu = all ? this.element :
  14641. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  14642. // If we found no valid submenu ancestor, use the main menu to close all
  14643. // sub menus anyway
  14644. if ( !currentMenu.length ) {
  14645. currentMenu = this.element;
  14646. }
  14647. this._close( currentMenu );
  14648. this.blur( event );
  14649. // Work around active item staying active after menu is blurred
  14650. this._removeClass( currentMenu.find( ".ui-state-active" ), null, "ui-state-active" );
  14651. this.activeMenu = currentMenu;
  14652. }, this.delay );
  14653. },
  14654. // With no arguments, closes the currently active menu - if nothing is active
  14655. // it closes all menus. If passed an argument, it will search for menus BELOW
  14656. _close: function( startMenu ) {
  14657. if ( !startMenu ) {
  14658. startMenu = this.active ? this.active.parent() : this.element;
  14659. }
  14660. startMenu.find( ".ui-menu" )
  14661. .hide()
  14662. .attr( "aria-hidden", "true" )
  14663. .attr( "aria-expanded", "false" );
  14664. },
  14665. _closeOnDocumentClick: function( event ) {
  14666. return !$( event.target ).closest( ".ui-menu" ).length;
  14667. },
  14668. _isDivider: function( item ) {
  14669. // Match hyphen, em dash, en dash
  14670. return !/[^\-\u2014\u2013\s]/.test( item.text() );
  14671. },
  14672. collapse: function( event ) {
  14673. var newItem = this.active &&
  14674. this.active.parent().closest( ".ui-menu-item", this.element );
  14675. if ( newItem && newItem.length ) {
  14676. this._close();
  14677. this.focus( event, newItem );
  14678. }
  14679. },
  14680. expand: function( event ) {
  14681. var newItem = this.active &&
  14682. this.active
  14683. .children( ".ui-menu " )
  14684. .find( this.options.items )
  14685. .first();
  14686. if ( newItem && newItem.length ) {
  14687. this._open( newItem.parent() );
  14688. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  14689. this._delay( function() {
  14690. this.focus( event, newItem );
  14691. } );
  14692. }
  14693. },
  14694. next: function( event ) {
  14695. this._move( "next", "first", event );
  14696. },
  14697. previous: function( event ) {
  14698. this._move( "prev", "last", event );
  14699. },
  14700. isFirstItem: function() {
  14701. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  14702. },
  14703. isLastItem: function() {
  14704. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  14705. },
  14706. _move: function( direction, filter, event ) {
  14707. var next;
  14708. if ( this.active ) {
  14709. if ( direction === "first" || direction === "last" ) {
  14710. next = this.active
  14711. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  14712. .eq( -1 );
  14713. } else {
  14714. next = this.active
  14715. [ direction + "All" ]( ".ui-menu-item" )
  14716. .eq( 0 );
  14717. }
  14718. }
  14719. if ( !next || !next.length || !this.active ) {
  14720. next = this.activeMenu.find( this.options.items )[ filter ]();
  14721. }
  14722. this.focus( event, next );
  14723. },
  14724. nextPage: function( event ) {
  14725. var item, base, height;
  14726. if ( !this.active ) {
  14727. this.next( event );
  14728. return;
  14729. }
  14730. if ( this.isLastItem() ) {
  14731. return;
  14732. }
  14733. if ( this._hasScroll() ) {
  14734. base = this.active.offset().top;
  14735. height = this.element.height();
  14736. this.active.nextAll( ".ui-menu-item" ).each( function() {
  14737. item = $( this );
  14738. return item.offset().top - base - height < 0;
  14739. } );
  14740. this.focus( event, item );
  14741. } else {
  14742. this.focus( event, this.activeMenu.find( this.options.items )
  14743. [ !this.active ? "first" : "last" ]() );
  14744. }
  14745. },
  14746. previousPage: function( event ) {
  14747. var item, base, height;
  14748. if ( !this.active ) {
  14749. this.next( event );
  14750. return;
  14751. }
  14752. if ( this.isFirstItem() ) {
  14753. return;
  14754. }
  14755. if ( this._hasScroll() ) {
  14756. base = this.active.offset().top;
  14757. height = this.element.height();
  14758. this.active.prevAll( ".ui-menu-item" ).each( function() {
  14759. item = $( this );
  14760. return item.offset().top - base + height > 0;
  14761. } );
  14762. this.focus( event, item );
  14763. } else {
  14764. this.focus( event, this.activeMenu.find( this.options.items ).first() );
  14765. }
  14766. },
  14767. _hasScroll: function() {
  14768. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  14769. },
  14770. select: function( event ) {
  14771. // TODO: It should never be possible to not have an active item at this
  14772. // point, but the tests don't trigger mouseenter before click.
  14773. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  14774. var ui = { item: this.active };
  14775. if ( !this.active.has( ".ui-menu" ).length ) {
  14776. this.collapseAll( event, true );
  14777. }
  14778. this._trigger( "select", event, ui );
  14779. },
  14780. _filterMenuItems: function( character ) {
  14781. var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ),
  14782. regex = new RegExp( "^" + escapedCharacter, "i" );
  14783. return this.activeMenu
  14784. .find( this.options.items )
  14785. // Only match on items, not dividers or other content (#10571)
  14786. .filter( ".ui-menu-item" )
  14787. .filter( function() {
  14788. return regex.test(
  14789. $.trim( $( this ).children( ".ui-menu-item-wrapper" ).text() ) );
  14790. } );
  14791. }
  14792. } );
  14793. /*!
  14794. * jQuery UI Autocomplete 1.12.1
  14795. * http://jqueryui.com
  14796. *
  14797. * Copyright jQuery Foundation and other contributors
  14798. * Released under the MIT license.
  14799. * http://jquery.org/license
  14800. */
  14801. //>>label: Autocomplete
  14802. //>>group: Widgets
  14803. //>>description: Lists suggested words as the user is typing.
  14804. //>>docs: http://api.jqueryui.com/autocomplete/
  14805. //>>demos: http://jqueryui.com/autocomplete/
  14806. //>>css.structure: ../../themes/base/core.css
  14807. //>>css.structure: ../../themes/base/autocomplete.css
  14808. //>>css.theme: ../../themes/base/theme.css
  14809. $.widget( "ui.autocomplete", {
  14810. version: "1.12.1",
  14811. defaultElement: "<input>",
  14812. options: {
  14813. appendTo: null,
  14814. autoFocus: false,
  14815. delay: 300,
  14816. minLength: 1,
  14817. position: {
  14818. my: "left top",
  14819. at: "left bottom",
  14820. collision: "none"
  14821. },
  14822. source: null,
  14823. // Callbacks
  14824. change: null,
  14825. close: null,
  14826. focus: null,
  14827. open: null,
  14828. response: null,
  14829. search: null,
  14830. select: null
  14831. },
  14832. requestIndex: 0,
  14833. pending: 0,
  14834. _create: function() {
  14835. // Some browsers only repeat keydown events, not keypress events,
  14836. // so we use the suppressKeyPress flag to determine if we've already
  14837. // handled the keydown event. #7269
  14838. // Unfortunately the code for & in keypress is the same as the up arrow,
  14839. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  14840. // events when we know the keydown event was used to modify the
  14841. // search term. #7799
  14842. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  14843. nodeName = this.element[ 0 ].nodeName.toLowerCase(),
  14844. isTextarea = nodeName === "textarea",
  14845. isInput = nodeName === "input";
  14846. // Textareas are always multi-line
  14847. // Inputs are always single-line, even if inside a contentEditable element
  14848. // IE also treats inputs as contentEditable
  14849. // All other element types are determined by whether or not they're contentEditable
  14850. this.isMultiLine = isTextarea || !isInput && this._isContentEditable( this.element );
  14851. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  14852. this.isNewMenu = true;
  14853. this._addClass( "ui-autocomplete-input" );
  14854. this.element.attr( "autocomplete", "off" );
  14855. this._on( this.element, {
  14856. keydown: function( event ) {
  14857. if ( this.element.prop( "readOnly" ) ) {
  14858. suppressKeyPress = true;
  14859. suppressInput = true;
  14860. suppressKeyPressRepeat = true;
  14861. return;
  14862. }
  14863. suppressKeyPress = false;
  14864. suppressInput = false;
  14865. suppressKeyPressRepeat = false;
  14866. var keyCode = $.ui.keyCode;
  14867. switch ( event.keyCode ) {
  14868. case keyCode.PAGE_UP:
  14869. suppressKeyPress = true;
  14870. this._move( "previousPage", event );
  14871. break;
  14872. case keyCode.PAGE_DOWN:
  14873. suppressKeyPress = true;
  14874. this._move( "nextPage", event );
  14875. break;
  14876. case keyCode.UP:
  14877. suppressKeyPress = true;
  14878. this._keyEvent( "previous", event );
  14879. break;
  14880. case keyCode.DOWN:
  14881. suppressKeyPress = true;
  14882. this._keyEvent( "next", event );
  14883. break;
  14884. case keyCode.ENTER:
  14885. // when menu is open and has focus
  14886. if ( this.menu.active ) {
  14887. // #6055 - Opera still allows the keypress to occur
  14888. // which causes forms to submit
  14889. suppressKeyPress = true;
  14890. event.preventDefault();
  14891. this.menu.select( event );
  14892. }
  14893. break;
  14894. case keyCode.TAB:
  14895. if ( this.menu.active ) {
  14896. this.menu.select( event );
  14897. }
  14898. break;
  14899. case keyCode.ESCAPE:
  14900. if ( this.menu.element.is( ":visible" ) ) {
  14901. if ( !this.isMultiLine ) {
  14902. this._value( this.term );
  14903. }
  14904. this.close( event );
  14905. // Different browsers have different default behavior for escape
  14906. // Single press can mean undo or clear
  14907. // Double press in IE means clear the whole form
  14908. event.preventDefault();
  14909. }
  14910. break;
  14911. default:
  14912. suppressKeyPressRepeat = true;
  14913. // search timeout should be triggered before the input value is changed
  14914. this._searchTimeout( event );
  14915. break;
  14916. }
  14917. },
  14918. keypress: function( event ) {
  14919. if ( suppressKeyPress ) {
  14920. suppressKeyPress = false;
  14921. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  14922. event.preventDefault();
  14923. }
  14924. return;
  14925. }
  14926. if ( suppressKeyPressRepeat ) {
  14927. return;
  14928. }
  14929. // Replicate some key handlers to allow them to repeat in Firefox and Opera
  14930. var keyCode = $.ui.keyCode;
  14931. switch ( event.keyCode ) {
  14932. case keyCode.PAGE_UP:
  14933. this._move( "previousPage", event );
  14934. break;
  14935. case keyCode.PAGE_DOWN:
  14936. this._move( "nextPage", event );
  14937. break;
  14938. case keyCode.UP:
  14939. this._keyEvent( "previous", event );
  14940. break;
  14941. case keyCode.DOWN:
  14942. this._keyEvent( "next", event );
  14943. break;
  14944. }
  14945. },
  14946. input: function( event ) {
  14947. if ( suppressInput ) {
  14948. suppressInput = false;
  14949. event.preventDefault();
  14950. return;
  14951. }
  14952. this._searchTimeout( event );
  14953. },
  14954. focus: function() {
  14955. this.selectedItem = null;
  14956. this.previous = this._value();
  14957. },
  14958. blur: function( event ) {
  14959. if ( this.cancelBlur ) {
  14960. delete this.cancelBlur;
  14961. return;
  14962. }
  14963. clearTimeout( this.searching );
  14964. this.close( event );
  14965. this._change( event );
  14966. }
  14967. } );
  14968. this._initSource();
  14969. this.menu = $( "<ul>" )
  14970. .appendTo( this._appendTo() )
  14971. .menu( {
  14972. // disable ARIA support, the live region takes care of that
  14973. role: null
  14974. } )
  14975. .hide()
  14976. .menu( "instance" );
  14977. this._addClass( this.menu.element, "ui-autocomplete", "ui-front" );
  14978. this._on( this.menu.element, {
  14979. mousedown: function( event ) {
  14980. // prevent moving focus out of the text field
  14981. event.preventDefault();
  14982. // IE doesn't prevent moving focus even with event.preventDefault()
  14983. // so we set a flag to know when we should ignore the blur event
  14984. this.cancelBlur = true;
  14985. this._delay( function() {
  14986. delete this.cancelBlur;
  14987. // Support: IE 8 only
  14988. // Right clicking a menu item or selecting text from the menu items will
  14989. // result in focus moving out of the input. However, we've already received
  14990. // and ignored the blur event because of the cancelBlur flag set above. So
  14991. // we restore focus to ensure that the menu closes properly based on the user's
  14992. // next actions.
  14993. if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) {
  14994. this.element.trigger( "focus" );
  14995. }
  14996. } );
  14997. },
  14998. menufocus: function( event, ui ) {
  14999. var label, item;
  15000. // support: Firefox
  15001. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  15002. if ( this.isNewMenu ) {
  15003. this.isNewMenu = false;
  15004. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  15005. this.menu.blur();
  15006. this.document.one( "mousemove", function() {
  15007. $( event.target ).trigger( event.originalEvent );
  15008. } );
  15009. return;
  15010. }
  15011. }
  15012. item = ui.item.data( "ui-autocomplete-item" );
  15013. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  15014. // use value to match what will end up in the input, if it was a key event
  15015. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  15016. this._value( item.value );
  15017. }
  15018. }
  15019. // Announce the value in the liveRegion
  15020. label = ui.item.attr( "aria-label" ) || item.value;
  15021. if ( label && $.trim( label ).length ) {
  15022. this.liveRegion.children().hide();
  15023. $( "<div>" ).text( label ).appendTo( this.liveRegion );
  15024. }
  15025. },
  15026. menuselect: function( event, ui ) {
  15027. var item = ui.item.data( "ui-autocomplete-item" ),
  15028. previous = this.previous;
  15029. // Only trigger when focus was lost (click on menu)
  15030. if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) {
  15031. this.element.trigger( "focus" );
  15032. this.previous = previous;
  15033. // #6109 - IE triggers two focus events and the second
  15034. // is asynchronous, so we need to reset the previous
  15035. // term synchronously and asynchronously :-(
  15036. this._delay( function() {
  15037. this.previous = previous;
  15038. this.selectedItem = item;
  15039. } );
  15040. }
  15041. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  15042. this._value( item.value );
  15043. }
  15044. // reset the term after the select event
  15045. // this allows custom select handling to work properly
  15046. this.term = this._value();
  15047. this.close( event );
  15048. this.selectedItem = item;
  15049. }
  15050. } );
  15051. this.liveRegion = $( "<div>", {
  15052. role: "status",
  15053. "aria-live": "assertive",
  15054. "aria-relevant": "additions"
  15055. } )
  15056. .appendTo( this.document[ 0 ].body );
  15057. this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
  15058. // Turning off autocomplete prevents the browser from remembering the
  15059. // value when navigating through history, so we re-enable autocomplete
  15060. // if the page is unloaded before the widget is destroyed. #7790
  15061. this._on( this.window, {
  15062. beforeunload: function() {
  15063. this.element.removeAttr( "autocomplete" );
  15064. }
  15065. } );
  15066. },
  15067. _destroy: function() {
  15068. clearTimeout( this.searching );
  15069. this.element.removeAttr( "autocomplete" );
  15070. this.menu.element.remove();
  15071. this.liveRegion.remove();
  15072. },
  15073. _setOption: function( key, value ) {
  15074. this._super( key, value );
  15075. if ( key === "source" ) {
  15076. this._initSource();
  15077. }
  15078. if ( key === "appendTo" ) {
  15079. this.menu.element.appendTo( this._appendTo() );
  15080. }
  15081. if ( key === "disabled" && value && this.xhr ) {
  15082. this.xhr.abort();
  15083. }
  15084. },
  15085. _isEventTargetInWidget: function( event ) {
  15086. var menuElement = this.menu.element[ 0 ];
  15087. return event.target === this.element[ 0 ] ||
  15088. event.target === menuElement ||
  15089. $.contains( menuElement, event.target );
  15090. },
  15091. _closeOnClickOutside: function( event ) {
  15092. if ( !this._isEventTargetInWidget( event ) ) {
  15093. this.close();
  15094. }
  15095. },
  15096. _appendTo: function() {
  15097. var element = this.options.appendTo;
  15098. if ( element ) {
  15099. element = element.jquery || element.nodeType ?
  15100. $( element ) :
  15101. this.document.find( element ).eq( 0 );
  15102. }
  15103. if ( !element || !element[ 0 ] ) {
  15104. element = this.element.closest( ".ui-front, dialog" );
  15105. }
  15106. if ( !element.length ) {
  15107. element = this.document[ 0 ].body;
  15108. }
  15109. return element;
  15110. },
  15111. _initSource: function() {
  15112. var array, url,
  15113. that = this;
  15114. if ( $.isArray( this.options.source ) ) {
  15115. array = this.options.source;
  15116. this.source = function( request, response ) {
  15117. response( $.ui.autocomplete.filter( array, request.term ) );
  15118. };
  15119. } else if ( typeof this.options.source === "string" ) {
  15120. url = this.options.source;
  15121. this.source = function( request, response ) {
  15122. if ( that.xhr ) {
  15123. that.xhr.abort();
  15124. }
  15125. that.xhr = $.ajax( {
  15126. url: url,
  15127. data: request,
  15128. dataType: "json",
  15129. success: function( data ) {
  15130. response( data );
  15131. },
  15132. error: function() {
  15133. response( [] );
  15134. }
  15135. } );
  15136. };
  15137. } else {
  15138. this.source = this.options.source;
  15139. }
  15140. },
  15141. _searchTimeout: function( event ) {
  15142. clearTimeout( this.searching );
  15143. this.searching = this._delay( function() {
  15144. // Search if the value has changed, or if the user retypes the same value (see #7434)
  15145. var equalValues = this.term === this._value(),
  15146. menuVisible = this.menu.element.is( ":visible" ),
  15147. modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
  15148. if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) {
  15149. this.selectedItem = null;
  15150. this.search( null, event );
  15151. }
  15152. }, this.options.delay );
  15153. },
  15154. search: function( value, event ) {
  15155. value = value != null ? value : this._value();
  15156. // Always save the actual value, not the one passed as an argument
  15157. this.term = this._value();
  15158. if ( value.length < this.options.minLength ) {
  15159. return this.close( event );
  15160. }
  15161. if ( this._trigger( "search", event ) === false ) {
  15162. return;
  15163. }
  15164. return this._search( value );
  15165. },
  15166. _search: function( value ) {
  15167. this.pending++;
  15168. this._addClass( "ui-autocomplete-loading" );
  15169. this.cancelSearch = false;
  15170. this.source( { term: value }, this._response() );
  15171. },
  15172. _response: function() {
  15173. var index = ++this.requestIndex;
  15174. return $.proxy( function( content ) {
  15175. if ( index === this.requestIndex ) {
  15176. this.__response( content );
  15177. }
  15178. this.pending--;
  15179. if ( !this.pending ) {
  15180. this._removeClass( "ui-autocomplete-loading" );
  15181. }
  15182. }, this );
  15183. },
  15184. __response: function( content ) {
  15185. if ( content ) {
  15186. content = this._normalize( content );
  15187. }
  15188. this._trigger( "response", null, { content: content } );
  15189. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  15190. this._suggest( content );
  15191. this._trigger( "open" );
  15192. } else {
  15193. // use ._close() instead of .close() so we don't cancel future searches
  15194. this._close();
  15195. }
  15196. },
  15197. close: function( event ) {
  15198. this.cancelSearch = true;
  15199. this._close( event );
  15200. },
  15201. _close: function( event ) {
  15202. // Remove the handler that closes the menu on outside clicks
  15203. this._off( this.document, "mousedown" );
  15204. if ( this.menu.element.is( ":visible" ) ) {
  15205. this.menu.element.hide();
  15206. this.menu.blur();
  15207. this.isNewMenu = true;
  15208. this._trigger( "close", event );
  15209. }
  15210. },
  15211. _change: function( event ) {
  15212. if ( this.previous !== this._value() ) {
  15213. this._trigger( "change", event, { item: this.selectedItem } );
  15214. }
  15215. },
  15216. _normalize: function( items ) {
  15217. // assume all items have the right format when the first item is complete
  15218. if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
  15219. return items;
  15220. }
  15221. return $.map( items, function( item ) {
  15222. if ( typeof item === "string" ) {
  15223. return {
  15224. label: item,
  15225. value: item
  15226. };
  15227. }
  15228. return $.extend( {}, item, {
  15229. label: item.label || item.value,
  15230. value: item.value || item.label
  15231. } );
  15232. } );
  15233. },
  15234. _suggest: function( items ) {
  15235. var ul = this.menu.element.empty();
  15236. this._renderMenu( ul, items );
  15237. this.isNewMenu = true;
  15238. this.menu.refresh();
  15239. // Size and position menu
  15240. ul.show();
  15241. this._resizeMenu();
  15242. ul.position( $.extend( {
  15243. of: this.element
  15244. }, this.options.position ) );
  15245. if ( this.options.autoFocus ) {
  15246. this.menu.next();
  15247. }
  15248. // Listen for interactions outside of the widget (#6642)
  15249. this._on( this.document, {
  15250. mousedown: "_closeOnClickOutside"
  15251. } );
  15252. },
  15253. _resizeMenu: function() {
  15254. var ul = this.menu.element;
  15255. ul.outerWidth( Math.max(
  15256. // Firefox wraps long text (possibly a rounding bug)
  15257. // so we add 1px to avoid the wrapping (#7513)
  15258. ul.width( "" ).outerWidth() + 1,
  15259. this.element.outerWidth()
  15260. ) );
  15261. },
  15262. _renderMenu: function( ul, items ) {
  15263. var that = this;
  15264. $.each( items, function( index, item ) {
  15265. that._renderItemData( ul, item );
  15266. } );
  15267. },
  15268. _renderItemData: function( ul, item ) {
  15269. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  15270. },
  15271. _renderItem: function( ul, item ) {
  15272. return $( "<li>" )
  15273. .append( $( "<div>" ).text( item.label ) )
  15274. .appendTo( ul );
  15275. },
  15276. _move: function( direction, event ) {
  15277. if ( !this.menu.element.is( ":visible" ) ) {
  15278. this.search( null, event );
  15279. return;
  15280. }
  15281. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  15282. this.menu.isLastItem() && /^next/.test( direction ) ) {
  15283. if ( !this.isMultiLine ) {
  15284. this._value( this.term );
  15285. }
  15286. this.menu.blur();
  15287. return;
  15288. }
  15289. this.menu[ direction ]( event );
  15290. },
  15291. widget: function() {
  15292. return this.menu.element;
  15293. },
  15294. _value: function() {
  15295. return this.valueMethod.apply( this.element, arguments );
  15296. },
  15297. _keyEvent: function( keyEvent, event ) {
  15298. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  15299. this._move( keyEvent, event );
  15300. // Prevents moving cursor to beginning/end of the text field in some browsers
  15301. event.preventDefault();
  15302. }
  15303. },
  15304. // Support: Chrome <=50
  15305. // We should be able to just use this.element.prop( "isContentEditable" )
  15306. // but hidden elements always report false in Chrome.
  15307. // https://code.google.com/p/chromium/issues/detail?id=313082
  15308. _isContentEditable: function( element ) {
  15309. if ( !element.length ) {
  15310. return false;
  15311. }
  15312. var editable = element.prop( "contentEditable" );
  15313. if ( editable === "inherit" ) {
  15314. return this._isContentEditable( element.parent() );
  15315. }
  15316. return editable === "true";
  15317. }
  15318. } );
  15319. $.extend( $.ui.autocomplete, {
  15320. escapeRegex: function( value ) {
  15321. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  15322. },
  15323. filter: function( array, term ) {
  15324. var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
  15325. return $.grep( array, function( value ) {
  15326. return matcher.test( value.label || value.value || value );
  15327. } );
  15328. }
  15329. } );
  15330. // Live region extension, adding a `messages` option
  15331. // NOTE: This is an experimental API. We are still investigating
  15332. // a full solution for string manipulation and internationalization.
  15333. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  15334. options: {
  15335. messages: {
  15336. noResults: "No search results.",
  15337. results: function( amount ) {
  15338. return amount + ( amount > 1 ? " results are" : " result is" ) +
  15339. " available, use up and down arrow keys to navigate.";
  15340. }
  15341. }
  15342. },
  15343. __response: function( content ) {
  15344. var message;
  15345. this._superApply( arguments );
  15346. if ( this.options.disabled || this.cancelSearch ) {
  15347. return;
  15348. }
  15349. if ( content && content.length ) {
  15350. message = this.options.messages.results( content.length );
  15351. } else {
  15352. message = this.options.messages.noResults;
  15353. }
  15354. this.liveRegion.children().hide();
  15355. $( "<div>" ).text( message ).appendTo( this.liveRegion );
  15356. }
  15357. } );
  15358. var widgetsAutocomplete = $.ui.autocomplete;
  15359. /*!
  15360. * jQuery UI Controlgroup 1.12.1
  15361. * http://jqueryui.com
  15362. *
  15363. * Copyright jQuery Foundation and other contributors
  15364. * Released under the MIT license.
  15365. * http://jquery.org/license
  15366. */
  15367. //>>label: Controlgroup
  15368. //>>group: Widgets
  15369. //>>description: Visually groups form control widgets
  15370. //>>docs: http://api.jqueryui.com/controlgroup/
  15371. //>>demos: http://jqueryui.com/controlgroup/
  15372. //>>css.structure: ../../themes/base/core.css
  15373. //>>css.structure: ../../themes/base/controlgroup.css
  15374. //>>css.theme: ../../themes/base/theme.css
  15375. var controlgroupCornerRegex = /ui-corner-([a-z]){2,6}/g;
  15376. var widgetsControlgroup = $.widget( "ui.controlgroup", {
  15377. version: "1.12.1",
  15378. defaultElement: "<div>",
  15379. options: {
  15380. direction: "horizontal",
  15381. disabled: null,
  15382. onlyVisible: true,
  15383. items: {
  15384. "button": "input[type=button], input[type=submit], input[type=reset], button, a",
  15385. "controlgroupLabel": ".ui-controlgroup-label",
  15386. "checkboxradio": "input[type='checkbox'], input[type='radio']",
  15387. "selectmenu": "select",
  15388. "spinner": ".ui-spinner-input"
  15389. }
  15390. },
  15391. _create: function() {
  15392. this._enhance();
  15393. },
  15394. // To support the enhanced option in jQuery Mobile, we isolate DOM manipulation
  15395. _enhance: function() {
  15396. this.element.attr( "role", "toolbar" );
  15397. this.refresh();
  15398. },
  15399. _destroy: function() {
  15400. this._callChildMethod( "destroy" );
  15401. this.childWidgets.removeData( "ui-controlgroup-data" );
  15402. this.element.removeAttr( "role" );
  15403. if ( this.options.items.controlgroupLabel ) {
  15404. this.element
  15405. .find( this.options.items.controlgroupLabel )
  15406. .find( ".ui-controlgroup-label-contents" )
  15407. .contents().unwrap();
  15408. }
  15409. },
  15410. _initWidgets: function() {
  15411. var that = this,
  15412. childWidgets = [];
  15413. // First we iterate over each of the items options
  15414. $.each( this.options.items, function( widget, selector ) {
  15415. var labels;
  15416. var options = {};
  15417. // Make sure the widget has a selector set
  15418. if ( !selector ) {
  15419. return;
  15420. }
  15421. if ( widget === "controlgroupLabel" ) {
  15422. labels = that.element.find( selector );
  15423. labels.each( function() {
  15424. var element = $( this );
  15425. if ( element.children( ".ui-controlgroup-label-contents" ).length ) {
  15426. return;
  15427. }
  15428. element.contents()
  15429. .wrapAll( "<span class='ui-controlgroup-label-contents'></span>" );
  15430. } );
  15431. that._addClass( labels, null, "ui-widget ui-widget-content ui-state-default" );
  15432. childWidgets = childWidgets.concat( labels.get() );
  15433. return;
  15434. }
  15435. // Make sure the widget actually exists
  15436. if ( !$.fn[ widget ] ) {
  15437. return;
  15438. }
  15439. // We assume everything is in the middle to start because we can't determine
  15440. // first / last elements until all enhancments are done.
  15441. if ( that[ "_" + widget + "Options" ] ) {
  15442. options = that[ "_" + widget + "Options" ]( "middle" );
  15443. } else {
  15444. options = { classes: {} };
  15445. }
  15446. // Find instances of this widget inside controlgroup and init them
  15447. that.element
  15448. .find( selector )
  15449. .each( function() {
  15450. var element = $( this );
  15451. var instance = element[ widget ]( "instance" );
  15452. // We need to clone the default options for this type of widget to avoid
  15453. // polluting the variable options which has a wider scope than a single widget.
  15454. var instanceOptions = $.widget.extend( {}, options );
  15455. // If the button is the child of a spinner ignore it
  15456. // TODO: Find a more generic solution
  15457. if ( widget === "button" && element.parent( ".ui-spinner" ).length ) {
  15458. return;
  15459. }
  15460. // Create the widget if it doesn't exist
  15461. if ( !instance ) {
  15462. instance = element[ widget ]()[ widget ]( "instance" );
  15463. }
  15464. if ( instance ) {
  15465. instanceOptions.classes =
  15466. that._resolveClassesValues( instanceOptions.classes, instance );
  15467. }
  15468. element[ widget ]( instanceOptions );
  15469. // Store an instance of the controlgroup to be able to reference
  15470. // from the outermost element for changing options and refresh
  15471. var widgetElement = element[ widget ]( "widget" );
  15472. $.data( widgetElement[ 0 ], "ui-controlgroup-data",
  15473. instance ? instance : element[ widget ]( "instance" ) );
  15474. childWidgets.push( widgetElement[ 0 ] );
  15475. } );
  15476. } );
  15477. this.childWidgets = $( $.unique( childWidgets ) );
  15478. this._addClass( this.childWidgets, "ui-controlgroup-item" );
  15479. },
  15480. _callChildMethod: function( method ) {
  15481. this.childWidgets.each( function() {
  15482. var element = $( this ),
  15483. data = element.data( "ui-controlgroup-data" );
  15484. if ( data && data[ method ] ) {
  15485. data[ method ]();
  15486. }
  15487. } );
  15488. },
  15489. _updateCornerClass: function( element, position ) {
  15490. var remove = "ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right ui-corner-all";
  15491. var add = this._buildSimpleOptions( position, "label" ).classes.label;
  15492. this._removeClass( element, null, remove );
  15493. this._addClass( element, null, add );
  15494. },
  15495. _buildSimpleOptions: function( position, key ) {
  15496. var direction = this.options.direction === "vertical";
  15497. var result = {
  15498. classes: {}
  15499. };
  15500. result.classes[ key ] = {
  15501. "middle": "",
  15502. "first": "ui-corner-" + ( direction ? "top" : "left" ),
  15503. "last": "ui-corner-" + ( direction ? "bottom" : "right" ),
  15504. "only": "ui-corner-all"
  15505. }[ position ];
  15506. return result;
  15507. },
  15508. _spinnerOptions: function( position ) {
  15509. var options = this._buildSimpleOptions( position, "ui-spinner" );
  15510. options.classes[ "ui-spinner-up" ] = "";
  15511. options.classes[ "ui-spinner-down" ] = "";
  15512. return options;
  15513. },
  15514. _buttonOptions: function( position ) {
  15515. return this._buildSimpleOptions( position, "ui-button" );
  15516. },
  15517. _checkboxradioOptions: function( position ) {
  15518. return this._buildSimpleOptions( position, "ui-checkboxradio-label" );
  15519. },
  15520. _selectmenuOptions: function( position ) {
  15521. var direction = this.options.direction === "vertical";
  15522. return {
  15523. width: direction ? "auto" : false,
  15524. classes: {
  15525. middle: {
  15526. "ui-selectmenu-button-open": "",
  15527. "ui-selectmenu-button-closed": ""
  15528. },
  15529. first: {
  15530. "ui-selectmenu-button-open": "ui-corner-" + ( direction ? "top" : "tl" ),
  15531. "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "top" : "left" )
  15532. },
  15533. last: {
  15534. "ui-selectmenu-button-open": direction ? "" : "ui-corner-tr",
  15535. "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "bottom" : "right" )
  15536. },
  15537. only: {
  15538. "ui-selectmenu-button-open": "ui-corner-top",
  15539. "ui-selectmenu-button-closed": "ui-corner-all"
  15540. }
  15541. }[ position ]
  15542. };
  15543. },
  15544. _resolveClassesValues: function( classes, instance ) {
  15545. var result = {};
  15546. $.each( classes, function( key ) {
  15547. var current = instance.options.classes[ key ] || "";
  15548. current = $.trim( current.replace( controlgroupCornerRegex, "" ) );
  15549. result[ key ] = ( current + " " + classes[ key ] ).replace( /\s+/g, " " );
  15550. } );
  15551. return result;
  15552. },
  15553. _setOption: function( key, value ) {
  15554. if ( key === "direction" ) {
  15555. this._removeClass( "ui-controlgroup-" + this.options.direction );
  15556. }
  15557. this._super( key, value );
  15558. if ( key === "disabled" ) {
  15559. this._callChildMethod( value ? "disable" : "enable" );
  15560. return;
  15561. }
  15562. this.refresh();
  15563. },
  15564. refresh: function() {
  15565. var children,
  15566. that = this;
  15567. this._addClass( "ui-controlgroup ui-controlgroup-" + this.options.direction );
  15568. if ( this.options.direction === "horizontal" ) {
  15569. this._addClass( null, "ui-helper-clearfix" );
  15570. }
  15571. this._initWidgets();
  15572. children = this.childWidgets;
  15573. // We filter here because we need to track all childWidgets not just the visible ones
  15574. if ( this.options.onlyVisible ) {
  15575. children = children.filter( ":visible" );
  15576. }
  15577. if ( children.length ) {
  15578. // We do this last because we need to make sure all enhancment is done
  15579. // before determining first and last
  15580. $.each( [ "first", "last" ], function( index, value ) {
  15581. var instance = children[ value ]().data( "ui-controlgroup-data" );
  15582. if ( instance && that[ "_" + instance.widgetName + "Options" ] ) {
  15583. var options = that[ "_" + instance.widgetName + "Options" ](
  15584. children.length === 1 ? "only" : value
  15585. );
  15586. options.classes = that._resolveClassesValues( options.classes, instance );
  15587. instance.element[ instance.widgetName ]( options );
  15588. } else {
  15589. that._updateCornerClass( children[ value ](), value );
  15590. }
  15591. } );
  15592. // Finally call the refresh method on each of the child widgets.
  15593. this._callChildMethod( "refresh" );
  15594. }
  15595. }
  15596. } );
  15597. /*!
  15598. * jQuery UI Checkboxradio 1.12.1
  15599. * http://jqueryui.com
  15600. *
  15601. * Copyright jQuery Foundation and other contributors
  15602. * Released under the MIT license.
  15603. * http://jquery.org/license
  15604. */
  15605. //>>label: Checkboxradio
  15606. //>>group: Widgets
  15607. //>>description: Enhances a form with multiple themeable checkboxes or radio buttons.
  15608. //>>docs: http://api.jqueryui.com/checkboxradio/
  15609. //>>demos: http://jqueryui.com/checkboxradio/
  15610. //>>css.structure: ../../themes/base/core.css
  15611. //>>css.structure: ../../themes/base/button.css
  15612. //>>css.structure: ../../themes/base/checkboxradio.css
  15613. //>>css.theme: ../../themes/base/theme.css
  15614. $.widget( "ui.checkboxradio", [ $.ui.formResetMixin, {
  15615. version: "1.12.1",
  15616. options: {
  15617. disabled: null,
  15618. label: null,
  15619. icon: true,
  15620. classes: {
  15621. "ui-checkboxradio-label": "ui-corner-all",
  15622. "ui-checkboxradio-icon": "ui-corner-all"
  15623. }
  15624. },
  15625. _getCreateOptions: function() {
  15626. var disabled, labels;
  15627. var that = this;
  15628. var options = this._super() || {};
  15629. // We read the type here, because it makes more sense to throw a element type error first,
  15630. // rather then the error for lack of a label. Often if its the wrong type, it
  15631. // won't have a label (e.g. calling on a div, btn, etc)
  15632. this._readType();
  15633. labels = this.element.labels();
  15634. // If there are multiple labels, use the last one
  15635. this.label = $( labels[ labels.length - 1 ] );
  15636. if ( !this.label.length ) {
  15637. $.error( "No label found for checkboxradio widget" );
  15638. }
  15639. this.originalLabel = "";
  15640. // We need to get the label text but this may also need to make sure it does not contain the
  15641. // input itself.
  15642. this.label.contents().not( this.element[ 0 ] ).each( function() {
  15643. // The label contents could be text, html, or a mix. We concat each element to get a
  15644. // string representation of the label, without the input as part of it.
  15645. that.originalLabel += this.nodeType === 3 ? $( this ).text() : this.outerHTML;
  15646. } );
  15647. // Set the label option if we found label text
  15648. if ( this.originalLabel ) {
  15649. options.label = this.originalLabel;
  15650. }
  15651. disabled = this.element[ 0 ].disabled;
  15652. if ( disabled != null ) {
  15653. options.disabled = disabled;
  15654. }
  15655. return options;
  15656. },
  15657. _create: function() {
  15658. var checked = this.element[ 0 ].checked;
  15659. this._bindFormResetHandler();
  15660. if ( this.options.disabled == null ) {
  15661. this.options.disabled = this.element[ 0 ].disabled;
  15662. }
  15663. this._setOption( "disabled", this.options.disabled );
  15664. this._addClass( "ui-checkboxradio", "ui-helper-hidden-accessible" );
  15665. this._addClass( this.label, "ui-checkboxradio-label", "ui-button ui-widget" );
  15666. if ( this.type === "radio" ) {
  15667. this._addClass( this.label, "ui-checkboxradio-radio-label" );
  15668. }
  15669. if ( this.options.label && this.options.label !== this.originalLabel ) {
  15670. this._updateLabel();
  15671. } else if ( this.originalLabel ) {
  15672. this.options.label = this.originalLabel;
  15673. }
  15674. this._enhance();
  15675. if ( checked ) {
  15676. this._addClass( this.label, "ui-checkboxradio-checked", "ui-state-active" );
  15677. if ( this.icon ) {
  15678. this._addClass( this.icon, null, "ui-state-hover" );
  15679. }
  15680. }
  15681. this._on( {
  15682. change: "_toggleClasses",
  15683. focus: function() {
  15684. this._addClass( this.label, null, "ui-state-focus ui-visual-focus" );
  15685. },
  15686. blur: function() {
  15687. this._removeClass( this.label, null, "ui-state-focus ui-visual-focus" );
  15688. }
  15689. } );
  15690. },
  15691. _readType: function() {
  15692. var nodeName = this.element[ 0 ].nodeName.toLowerCase();
  15693. this.type = this.element[ 0 ].type;
  15694. if ( nodeName !== "input" || !/radio|checkbox/.test( this.type ) ) {
  15695. $.error( "Can't create checkboxradio on element.nodeName=" + nodeName +
  15696. " and element.type=" + this.type );
  15697. }
  15698. },
  15699. // Support jQuery Mobile enhanced option
  15700. _enhance: function() {
  15701. this._updateIcon( this.element[ 0 ].checked );
  15702. },
  15703. widget: function() {
  15704. return this.label;
  15705. },
  15706. _getRadioGroup: function() {
  15707. var group;
  15708. var name = this.element[ 0 ].name;
  15709. var nameSelector = "input[name='" + $.ui.escapeSelector( name ) + "']";
  15710. if ( !name ) {
  15711. return $( [] );
  15712. }
  15713. if ( this.form.length ) {
  15714. group = $( this.form[ 0 ].elements ).filter( nameSelector );
  15715. } else {
  15716. // Not inside a form, check all inputs that also are not inside a form
  15717. group = $( nameSelector ).filter( function() {
  15718. return $( this ).form().length === 0;
  15719. } );
  15720. }
  15721. return group.not( this.element );
  15722. },
  15723. _toggleClasses: function() {
  15724. var checked = this.element[ 0 ].checked;
  15725. this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
  15726. if ( this.options.icon && this.type === "checkbox" ) {
  15727. this._toggleClass( this.icon, null, "ui-icon-check ui-state-checked", checked )
  15728. ._toggleClass( this.icon, null, "ui-icon-blank", !checked );
  15729. }
  15730. if ( this.type === "radio" ) {
  15731. this._getRadioGroup()
  15732. .each( function() {
  15733. var instance = $( this ).checkboxradio( "instance" );
  15734. if ( instance ) {
  15735. instance._removeClass( instance.label,
  15736. "ui-checkboxradio-checked", "ui-state-active" );
  15737. }
  15738. } );
  15739. }
  15740. },
  15741. _destroy: function() {
  15742. this._unbindFormResetHandler();
  15743. if ( this.icon ) {
  15744. this.icon.remove();
  15745. this.iconSpace.remove();
  15746. }
  15747. },
  15748. _setOption: function( key, value ) {
  15749. // We don't allow the value to be set to nothing
  15750. if ( key === "label" && !value ) {
  15751. return;
  15752. }
  15753. this._super( key, value );
  15754. if ( key === "disabled" ) {
  15755. this._toggleClass( this.label, null, "ui-state-disabled", value );
  15756. this.element[ 0 ].disabled = value;
  15757. // Don't refresh when setting disabled
  15758. return;
  15759. }
  15760. this.refresh();
  15761. },
  15762. _updateIcon: function( checked ) {
  15763. var toAdd = "ui-icon ui-icon-background ";
  15764. if ( this.options.icon ) {
  15765. if ( !this.icon ) {
  15766. this.icon = $( "<span>" );
  15767. this.iconSpace = $( "<span> </span>" );
  15768. this._addClass( this.iconSpace, "ui-checkboxradio-icon-space" );
  15769. }
  15770. if ( this.type === "checkbox" ) {
  15771. toAdd += checked ? "ui-icon-check ui-state-checked" : "ui-icon-blank";
  15772. this._removeClass( this.icon, null, checked ? "ui-icon-blank" : "ui-icon-check" );
  15773. } else {
  15774. toAdd += "ui-icon-blank";
  15775. }
  15776. this._addClass( this.icon, "ui-checkboxradio-icon", toAdd );
  15777. if ( !checked ) {
  15778. this._removeClass( this.icon, null, "ui-icon-check ui-state-checked" );
  15779. }
  15780. this.icon.prependTo( this.label ).after( this.iconSpace );
  15781. } else if ( this.icon !== undefined ) {
  15782. this.icon.remove();
  15783. this.iconSpace.remove();
  15784. delete this.icon;
  15785. }
  15786. },
  15787. _updateLabel: function() {
  15788. // Remove the contents of the label ( minus the icon, icon space, and input )
  15789. var contents = this.label.contents().not( this.element[ 0 ] );
  15790. if ( this.icon ) {
  15791. contents = contents.not( this.icon[ 0 ] );
  15792. }
  15793. if ( this.iconSpace ) {
  15794. contents = contents.not( this.iconSpace[ 0 ] );
  15795. }
  15796. contents.remove();
  15797. this.label.append( this.options.label );
  15798. },
  15799. refresh: function() {
  15800. var checked = this.element[ 0 ].checked,
  15801. isDisabled = this.element[ 0 ].disabled;
  15802. this._updateIcon( checked );
  15803. this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
  15804. if ( this.options.label !== null ) {
  15805. this._updateLabel();
  15806. }
  15807. if ( isDisabled !== this.options.disabled ) {
  15808. this._setOptions( { "disabled": isDisabled } );
  15809. }
  15810. }
  15811. } ] );
  15812. var widgetsCheckboxradio = $.ui.checkboxradio;
  15813. /*!
  15814. * jQuery UI Button 1.12.1
  15815. * http://jqueryui.com
  15816. *
  15817. * Copyright jQuery Foundation and other contributors
  15818. * Released under the MIT license.
  15819. * http://jquery.org/license
  15820. */
  15821. //>>label: Button
  15822. //>>group: Widgets
  15823. //>>description: Enhances a form with themeable buttons.
  15824. //>>docs: http://api.jqueryui.com/button/
  15825. //>>demos: http://jqueryui.com/button/
  15826. //>>css.structure: ../../themes/base/core.css
  15827. //>>css.structure: ../../themes/base/button.css
  15828. //>>css.theme: ../../themes/base/theme.css
  15829. $.widget( "ui.button", {
  15830. version: "1.12.1",
  15831. defaultElement: "<button>",
  15832. options: {
  15833. classes: {
  15834. "ui-button": "ui-corner-all"
  15835. },
  15836. disabled: null,
  15837. icon: null,
  15838. iconPosition: "beginning",
  15839. label: null,
  15840. showLabel: true
  15841. },
  15842. _getCreateOptions: function() {
  15843. var disabled,
  15844. // This is to support cases like in jQuery Mobile where the base widget does have
  15845. // an implementation of _getCreateOptions
  15846. options = this._super() || {};
  15847. this.isInput = this.element.is( "input" );
  15848. disabled = this.element[ 0 ].disabled;
  15849. if ( disabled != null ) {
  15850. options.disabled = disabled;
  15851. }
  15852. this.originalLabel = this.isInput ? this.element.val() : this.element.html();
  15853. if ( this.originalLabel ) {
  15854. options.label = this.originalLabel;
  15855. }
  15856. return options;
  15857. },
  15858. _create: function() {
  15859. if ( !this.option.showLabel & !this.options.icon ) {
  15860. this.options.showLabel = true;
  15861. }
  15862. // We have to check the option again here even though we did in _getCreateOptions,
  15863. // because null may have been passed on init which would override what was set in
  15864. // _getCreateOptions
  15865. if ( this.options.disabled == null ) {
  15866. this.options.disabled = this.element[ 0 ].disabled || false;
  15867. }
  15868. this.hasTitle = !!this.element.attr( "title" );
  15869. // Check to see if the label needs to be set or if its already correct
  15870. if ( this.options.label && this.options.label !== this.originalLabel ) {
  15871. if ( this.isInput ) {
  15872. this.element.val( this.options.label );
  15873. } else {
  15874. this.element.html( this.options.label );
  15875. }
  15876. }
  15877. this._addClass( "ui-button", "ui-widget" );
  15878. this._setOption( "disabled", this.options.disabled );
  15879. this._enhance();
  15880. if ( this.element.is( "a" ) ) {
  15881. this._on( {
  15882. "keyup": function( event ) {
  15883. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  15884. event.preventDefault();
  15885. // Support: PhantomJS <= 1.9, IE 8 Only
  15886. // If a native click is available use it so we actually cause navigation
  15887. // otherwise just trigger a click event
  15888. if ( this.element[ 0 ].click ) {
  15889. this.element[ 0 ].click();
  15890. } else {
  15891. this.element.trigger( "click" );
  15892. }
  15893. }
  15894. }
  15895. } );
  15896. }
  15897. },
  15898. _enhance: function() {
  15899. if ( !this.element.is( "button" ) ) {
  15900. this.element.attr( "role", "button" );
  15901. }
  15902. if ( this.options.icon ) {
  15903. this._updateIcon( "icon", this.options.icon );
  15904. this._updateTooltip();
  15905. }
  15906. },
  15907. _updateTooltip: function() {
  15908. this.title = this.element.attr( "title" );
  15909. if ( !this.options.showLabel && !this.title ) {
  15910. this.element.attr( "title", this.options.label );
  15911. }
  15912. },
  15913. _updateIcon: function( option, value ) {
  15914. var icon = option !== "iconPosition",
  15915. position = icon ? this.options.iconPosition : value,
  15916. displayBlock = position === "top" || position === "bottom";
  15917. // Create icon
  15918. if ( !this.icon ) {
  15919. this.icon = $( "<span>" );
  15920. this._addClass( this.icon, "ui-button-icon", "ui-icon" );
  15921. if ( !this.options.showLabel ) {
  15922. this._addClass( "ui-button-icon-only" );
  15923. }
  15924. } else if ( icon ) {
  15925. // If we are updating the icon remove the old icon class
  15926. this._removeClass( this.icon, null, this.options.icon );
  15927. }
  15928. // If we are updating the icon add the new icon class
  15929. if ( icon ) {
  15930. this._addClass( this.icon, null, value );
  15931. }
  15932. this._attachIcon( position );
  15933. // If the icon is on top or bottom we need to add the ui-widget-icon-block class and remove
  15934. // the iconSpace if there is one.
  15935. if ( displayBlock ) {
  15936. this._addClass( this.icon, null, "ui-widget-icon-block" );
  15937. if ( this.iconSpace ) {
  15938. this.iconSpace.remove();
  15939. }
  15940. } else {
  15941. // Position is beginning or end so remove the ui-widget-icon-block class and add the
  15942. // space if it does not exist
  15943. if ( !this.iconSpace ) {
  15944. this.iconSpace = $( "<span> </span>" );
  15945. this._addClass( this.iconSpace, "ui-button-icon-space" );
  15946. }
  15947. this._removeClass( this.icon, null, "ui-wiget-icon-block" );
  15948. this._attachIconSpace( position );
  15949. }
  15950. },
  15951. _destroy: function() {
  15952. this.element.removeAttr( "role" );
  15953. if ( this.icon ) {
  15954. this.icon.remove();
  15955. }
  15956. if ( this.iconSpace ) {
  15957. this.iconSpace.remove();
  15958. }
  15959. if ( !this.hasTitle ) {
  15960. this.element.removeAttr( "title" );
  15961. }
  15962. },
  15963. _attachIconSpace: function( iconPosition ) {
  15964. this.icon[ /^(?:end|bottom)/.test( iconPosition ) ? "before" : "after" ]( this.iconSpace );
  15965. },
  15966. _attachIcon: function( iconPosition ) {
  15967. this.element[ /^(?:end|bottom)/.test( iconPosition ) ? "append" : "prepend" ]( this.icon );
  15968. },
  15969. _setOptions: function( options ) {
  15970. var newShowLabel = options.showLabel === undefined ?
  15971. this.options.showLabel :
  15972. options.showLabel,
  15973. newIcon = options.icon === undefined ? this.options.icon : options.icon;
  15974. if ( !newShowLabel && !newIcon ) {
  15975. options.showLabel = true;
  15976. }
  15977. this._super( options );
  15978. },
  15979. _setOption: function( key, value ) {
  15980. if ( key === "icon" ) {
  15981. if ( value ) {
  15982. this._updateIcon( key, value );
  15983. } else if ( this.icon ) {
  15984. this.icon.remove();
  15985. if ( this.iconSpace ) {
  15986. this.iconSpace.remove();
  15987. }
  15988. }
  15989. }
  15990. if ( key === "iconPosition" ) {
  15991. this._updateIcon( key, value );
  15992. }
  15993. // Make sure we can't end up with a button that has neither text nor icon
  15994. if ( key === "showLabel" ) {
  15995. this._toggleClass( "ui-button-icon-only", null, !value );
  15996. this._updateTooltip();
  15997. }
  15998. if ( key === "label" ) {
  15999. if ( this.isInput ) {
  16000. this.element.val( value );
  16001. } else {
  16002. // If there is an icon, append it, else nothing then append the value
  16003. // this avoids removal of the icon when setting label text
  16004. this.element.html( value );
  16005. if ( this.icon ) {
  16006. this._attachIcon( this.options.iconPosition );
  16007. this._attachIconSpace( this.options.iconPosition );
  16008. }
  16009. }
  16010. }
  16011. this._super( key, value );
  16012. if ( key === "disabled" ) {
  16013. this._toggleClass( null, "ui-state-disabled", value );
  16014. this.element[ 0 ].disabled = value;
  16015. if ( value ) {
  16016. this.element.blur();
  16017. }
  16018. }
  16019. },
  16020. refresh: function() {
  16021. // Make sure to only check disabled if its an element that supports this otherwise
  16022. // check for the disabled class to determine state
  16023. var isDisabled = this.element.is( "input, button" ) ?
  16024. this.element[ 0 ].disabled : this.element.hasClass( "ui-button-disabled" );
  16025. if ( isDisabled !== this.options.disabled ) {
  16026. this._setOptions( { disabled: isDisabled } );
  16027. }
  16028. this._updateTooltip();
  16029. }
  16030. } );
  16031. // DEPRECATED
  16032. if ( $.uiBackCompat !== false ) {
  16033. // Text and Icons options
  16034. $.widget( "ui.button", $.ui.button, {
  16035. options: {
  16036. text: true,
  16037. icons: {
  16038. primary: null,
  16039. secondary: null
  16040. }
  16041. },
  16042. _create: function() {
  16043. if ( this.options.showLabel && !this.options.text ) {
  16044. this.options.showLabel = this.options.text;
  16045. }
  16046. if ( !this.options.showLabel && this.options.text ) {
  16047. this.options.text = this.options.showLabel;
  16048. }
  16049. if ( !this.options.icon && ( this.options.icons.primary ||
  16050. this.options.icons.secondary ) ) {
  16051. if ( this.options.icons.primary ) {
  16052. this.options.icon = this.options.icons.primary;
  16053. } else {
  16054. this.options.icon = this.options.icons.secondary;
  16055. this.options.iconPosition = "end";
  16056. }
  16057. } else if ( this.options.icon ) {
  16058. this.options.icons.primary = this.options.icon;
  16059. }
  16060. this._super();
  16061. },
  16062. _setOption: function( key, value ) {
  16063. if ( key === "text" ) {
  16064. this._super( "showLabel", value );
  16065. return;
  16066. }
  16067. if ( key === "showLabel" ) {
  16068. this.options.text = value;
  16069. }
  16070. if ( key === "icon" ) {
  16071. this.options.icons.primary = value;
  16072. }
  16073. if ( key === "icons" ) {
  16074. if ( value.primary ) {
  16075. this._super( "icon", value.primary );
  16076. this._super( "iconPosition", "beginning" );
  16077. } else if ( value.secondary ) {
  16078. this._super( "icon", value.secondary );
  16079. this._super( "iconPosition", "end" );
  16080. }
  16081. }
  16082. this._superApply( arguments );
  16083. }
  16084. } );
  16085. $.fn.button = ( function( orig ) {
  16086. return function() {
  16087. if ( !this.length || ( this.length && this[ 0 ].tagName !== "INPUT" ) ||
  16088. ( this.length && this[ 0 ].tagName === "INPUT" && (
  16089. this.attr( "type" ) !== "checkbox" && this.attr( "type" ) !== "radio"
  16090. ) ) ) {
  16091. return orig.apply( this, arguments );
  16092. }
  16093. if ( !$.ui.checkboxradio ) {
  16094. $.error( "Checkboxradio widget missing" );
  16095. }
  16096. if ( arguments.length === 0 ) {
  16097. return this.checkboxradio( {
  16098. "icon": false
  16099. } );
  16100. }
  16101. return this.checkboxradio.apply( this, arguments );
  16102. };
  16103. } )( $.fn.button );
  16104. $.fn.buttonset = function() {
  16105. if ( !$.ui.controlgroup ) {
  16106. $.error( "Controlgroup widget missing" );
  16107. }
  16108. if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" && arguments[ 2 ] ) {
  16109. return this.controlgroup.apply( this,
  16110. [ arguments[ 0 ], "items.button", arguments[ 2 ] ] );
  16111. }
  16112. if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" ) {
  16113. return this.controlgroup.apply( this, [ arguments[ 0 ], "items.button" ] );
  16114. }
  16115. if ( typeof arguments[ 0 ] === "object" && arguments[ 0 ].items ) {
  16116. arguments[ 0 ].items = {
  16117. button: arguments[ 0 ].items
  16118. };
  16119. }
  16120. return this.controlgroup.apply( this, arguments );
  16121. };
  16122. }
  16123. var widgetsButton = $.ui.button;
  16124. // jscs:disable maximumLineLength
  16125. /* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */
  16126. /*!
  16127. * jQuery UI Datepicker 1.12.1
  16128. * http://jqueryui.com
  16129. *
  16130. * Copyright jQuery Foundation and other contributors
  16131. * Released under the MIT license.
  16132. * http://jquery.org/license
  16133. */
  16134. //>>label: Datepicker
  16135. //>>group: Widgets
  16136. //>>description: Displays a calendar from an input or inline for selecting dates.
  16137. //>>docs: http://api.jqueryui.com/datepicker/
  16138. //>>demos: http://jqueryui.com/datepicker/
  16139. //>>css.structure: ../../themes/base/core.css
  16140. //>>css.structure: ../../themes/base/datepicker.css
  16141. //>>css.theme: ../../themes/base/theme.css
  16142. $.extend( $.ui, { datepicker: { version: "1.12.1" } } );
  16143. var datepicker_instActive;
  16144. function datepicker_getZindex( elem ) {
  16145. var position, value;
  16146. while ( elem.length && elem[ 0 ] !== document ) {
  16147. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  16148. // This makes behavior of this function consistent across browsers
  16149. // WebKit always returns auto if the element is positioned
  16150. position = elem.css( "position" );
  16151. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  16152. // IE returns 0 when zIndex is not specified
  16153. // other browsers return a string
  16154. // we ignore the case of nested elements with an explicit value of 0
  16155. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  16156. value = parseInt( elem.css( "zIndex" ), 10 );
  16157. if ( !isNaN( value ) && value !== 0 ) {
  16158. return value;
  16159. }
  16160. }
  16161. elem = elem.parent();
  16162. }
  16163. return 0;
  16164. }
  16165. /* Date picker manager.
  16166. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  16167. Settings for (groups of) date pickers are maintained in an instance object,
  16168. allowing multiple different settings on the same page. */
  16169. function Datepicker() {
  16170. this._curInst = null; // The current instance in use
  16171. this._keyEvent = false; // If the last event was a key event
  16172. this._disabledInputs = []; // List of date picker inputs that have been disabled
  16173. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  16174. this._inDialog = false; // True if showing within a "dialog", false if not
  16175. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  16176. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  16177. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  16178. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  16179. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  16180. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  16181. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  16182. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  16183. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  16184. this.regional = []; // Available regional settings, indexed by language code
  16185. this.regional[ "" ] = { // Default regional settings
  16186. closeText: "Done", // Display text for close link
  16187. prevText: "Prev", // Display text for previous month link
  16188. nextText: "Next", // Display text for next month link
  16189. currentText: "Today", // Display text for current month link
  16190. monthNames: [ "January","February","March","April","May","June",
  16191. "July","August","September","October","November","December" ], // Names of months for drop-down and formatting
  16192. monthNamesShort: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ], // For formatting
  16193. dayNames: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], // For formatting
  16194. dayNamesShort: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ], // For formatting
  16195. dayNamesMin: [ "Su","Mo","Tu","We","Th","Fr","Sa" ], // Column headings for days starting at Sunday
  16196. weekHeader: "Wk", // Column header for week of the year
  16197. dateFormat: "mm/dd/yy", // See format options on parseDate
  16198. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  16199. isRTL: false, // True if right-to-left language, false if left-to-right
  16200. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  16201. yearSuffix: "" // Additional text to append to the year in the month headers
  16202. };
  16203. this._defaults = { // Global defaults for all the date picker instances
  16204. showOn: "focus", // "focus" for popup on focus,
  16205. // "button" for trigger button, or "both" for either
  16206. showAnim: "fadeIn", // Name of jQuery animation for popup
  16207. showOptions: {}, // Options for enhanced animations
  16208. defaultDate: null, // Used when field is blank: actual date,
  16209. // +/-number for offset from today, null for today
  16210. appendText: "", // Display text following the input box, e.g. showing the format
  16211. buttonText: "...", // Text for trigger button
  16212. buttonImage: "", // URL for trigger button image
  16213. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  16214. hideIfNoPrevNext: false, // True to hide next/previous month links
  16215. // if not applicable, false to just disable them
  16216. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  16217. gotoCurrent: false, // True if today link goes back to current selection instead
  16218. changeMonth: false, // True if month can be selected directly, false if only prev/next
  16219. changeYear: false, // True if year can be selected directly, false if only prev/next
  16220. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  16221. // either relative to today's year (-nn:+nn), relative to currently displayed year
  16222. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  16223. showOtherMonths: false, // True to show dates in other months, false to leave blank
  16224. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  16225. showWeek: false, // True to show week of the year, false to not show it
  16226. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  16227. // takes a Date and returns the number of the week for it
  16228. shortYearCutoff: "+10", // Short year values < this are in the current century,
  16229. // > this are in the previous century,
  16230. // string value starting with "+" for current year + value
  16231. minDate: null, // The earliest selectable date, or null for no limit
  16232. maxDate: null, // The latest selectable date, or null for no limit
  16233. duration: "fast", // Duration of display/closure
  16234. beforeShowDay: null, // Function that takes a date and returns an array with
  16235. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  16236. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  16237. beforeShow: null, // Function that takes an input field and
  16238. // returns a set of custom settings for the date picker
  16239. onSelect: null, // Define a callback function when a date is selected
  16240. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  16241. onClose: null, // Define a callback function when the datepicker is closed
  16242. numberOfMonths: 1, // Number of months to show at a time
  16243. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  16244. stepMonths: 1, // Number of months to step back/forward
  16245. stepBigMonths: 12, // Number of months to step back/forward for the big links
  16246. altField: "", // Selector for an alternate field to store selected dates into
  16247. altFormat: "", // The date format to use for the alternate field
  16248. constrainInput: true, // The input is constrained by the current date format
  16249. showButtonPanel: false, // True to show button panel, false to not show it
  16250. autoSize: false, // True to size the input for the date format, false to leave as is
  16251. disabled: false // The initial disabled state
  16252. };
  16253. $.extend( this._defaults, this.regional[ "" ] );
  16254. this.regional.en = $.extend( true, {}, this.regional[ "" ] );
  16255. this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en );
  16256. this.dpDiv = datepicker_bindHover( $( "<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) );
  16257. }
  16258. $.extend( Datepicker.prototype, {
  16259. /* Class name added to elements to indicate already configured with a date picker. */
  16260. markerClassName: "hasDatepicker",
  16261. //Keep track of the maximum number of rows displayed (see #7043)
  16262. maxRows: 4,
  16263. // TODO rename to "widget" when switching to widget factory
  16264. _widgetDatepicker: function() {
  16265. return this.dpDiv;
  16266. },
  16267. /* Override the default settings for all instances of the date picker.
  16268. * @param settings object - the new settings to use as defaults (anonymous object)
  16269. * @return the manager object
  16270. */
  16271. setDefaults: function( settings ) {
  16272. datepicker_extendRemove( this._defaults, settings || {} );
  16273. return this;
  16274. },
  16275. /* Attach the date picker to a jQuery selection.
  16276. * @param target element - the target input field or division or span
  16277. * @param settings object - the new settings to use for this date picker instance (anonymous)
  16278. */
  16279. _attachDatepicker: function( target, settings ) {
  16280. var nodeName, inline, inst;
  16281. nodeName = target.nodeName.toLowerCase();
  16282. inline = ( nodeName === "div" || nodeName === "span" );
  16283. if ( !target.id ) {
  16284. this.uuid += 1;
  16285. target.id = "dp" + this.uuid;
  16286. }
  16287. inst = this._newInst( $( target ), inline );
  16288. inst.settings = $.extend( {}, settings || {} );
  16289. if ( nodeName === "input" ) {
  16290. this._connectDatepicker( target, inst );
  16291. } else if ( inline ) {
  16292. this._inlineDatepicker( target, inst );
  16293. }
  16294. },
  16295. /* Create a new instance object. */
  16296. _newInst: function( target, inline ) {
  16297. var id = target[ 0 ].id.replace( /([^A-Za-z0-9_\-])/g, "\\\\$1" ); // escape jQuery meta chars
  16298. return { id: id, input: target, // associated target
  16299. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  16300. drawMonth: 0, drawYear: 0, // month being drawn
  16301. inline: inline, // is datepicker inline or not
  16302. dpDiv: ( !inline ? this.dpDiv : // presentation div
  16303. datepicker_bindHover( $( "<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) ) ) };
  16304. },
  16305. /* Attach the date picker to an input field. */
  16306. _connectDatepicker: function( target, inst ) {
  16307. var input = $( target );
  16308. inst.append = $( [] );
  16309. inst.trigger = $( [] );
  16310. if ( input.hasClass( this.markerClassName ) ) {
  16311. return;
  16312. }
  16313. this._attachments( input, inst );
  16314. input.addClass( this.markerClassName ).on( "keydown", this._doKeyDown ).
  16315. on( "keypress", this._doKeyPress ).on( "keyup", this._doKeyUp );
  16316. this._autoSize( inst );
  16317. $.data( target, "datepicker", inst );
  16318. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  16319. if ( inst.settings.disabled ) {
  16320. this._disableDatepicker( target );
  16321. }
  16322. },
  16323. /* Make attachments based on settings. */
  16324. _attachments: function( input, inst ) {
  16325. var showOn, buttonText, buttonImage,
  16326. appendText = this._get( inst, "appendText" ),
  16327. isRTL = this._get( inst, "isRTL" );
  16328. if ( inst.append ) {
  16329. inst.append.remove();
  16330. }
  16331. if ( appendText ) {
  16332. inst.append = $( "<span class='" + this._appendClass + "'>" + appendText + "</span>" );
  16333. input[ isRTL ? "before" : "after" ]( inst.append );
  16334. }
  16335. input.off( "focus", this._showDatepicker );
  16336. if ( inst.trigger ) {
  16337. inst.trigger.remove();
  16338. }
  16339. showOn = this._get( inst, "showOn" );
  16340. if ( showOn === "focus" || showOn === "both" ) { // pop-up date picker when in the marked field
  16341. input.on( "focus", this._showDatepicker );
  16342. }
  16343. if ( showOn === "button" || showOn === "both" ) { // pop-up date picker when button clicked
  16344. buttonText = this._get( inst, "buttonText" );
  16345. buttonImage = this._get( inst, "buttonImage" );
  16346. inst.trigger = $( this._get( inst, "buttonImageOnly" ) ?
  16347. $( "<img/>" ).addClass( this._triggerClass ).
  16348. attr( { src: buttonImage, alt: buttonText, title: buttonText } ) :
  16349. $( "<button type='button'></button>" ).addClass( this._triggerClass ).
  16350. html( !buttonImage ? buttonText : $( "<img/>" ).attr(
  16351. { src:buttonImage, alt:buttonText, title:buttonText } ) ) );
  16352. input[ isRTL ? "before" : "after" ]( inst.trigger );
  16353. inst.trigger.on( "click", function() {
  16354. if ( $.datepicker._datepickerShowing && $.datepicker._lastInput === input[ 0 ] ) {
  16355. $.datepicker._hideDatepicker();
  16356. } else if ( $.datepicker._datepickerShowing && $.datepicker._lastInput !== input[ 0 ] ) {
  16357. $.datepicker._hideDatepicker();
  16358. $.datepicker._showDatepicker( input[ 0 ] );
  16359. } else {
  16360. $.datepicker._showDatepicker( input[ 0 ] );
  16361. }
  16362. return false;
  16363. } );
  16364. }
  16365. },
  16366. /* Apply the maximum length for the date format. */
  16367. _autoSize: function( inst ) {
  16368. if ( this._get( inst, "autoSize" ) && !inst.inline ) {
  16369. var findMax, max, maxI, i,
  16370. date = new Date( 2009, 12 - 1, 20 ), // Ensure double digits
  16371. dateFormat = this._get( inst, "dateFormat" );
  16372. if ( dateFormat.match( /[DM]/ ) ) {
  16373. findMax = function( names ) {
  16374. max = 0;
  16375. maxI = 0;
  16376. for ( i = 0; i < names.length; i++ ) {
  16377. if ( names[ i ].length > max ) {
  16378. max = names[ i ].length;
  16379. maxI = i;
  16380. }
  16381. }
  16382. return maxI;
  16383. };
  16384. date.setMonth( findMax( this._get( inst, ( dateFormat.match( /MM/ ) ?
  16385. "monthNames" : "monthNamesShort" ) ) ) );
  16386. date.setDate( findMax( this._get( inst, ( dateFormat.match( /DD/ ) ?
  16387. "dayNames" : "dayNamesShort" ) ) ) + 20 - date.getDay() );
  16388. }
  16389. inst.input.attr( "size", this._formatDate( inst, date ).length );
  16390. }
  16391. },
  16392. /* Attach an inline date picker to a div. */
  16393. _inlineDatepicker: function( target, inst ) {
  16394. var divSpan = $( target );
  16395. if ( divSpan.hasClass( this.markerClassName ) ) {
  16396. return;
  16397. }
  16398. divSpan.addClass( this.markerClassName ).append( inst.dpDiv );
  16399. $.data( target, "datepicker", inst );
  16400. this._setDate( inst, this._getDefaultDate( inst ), true );
  16401. this._updateDatepicker( inst );
  16402. this._updateAlternate( inst );
  16403. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  16404. if ( inst.settings.disabled ) {
  16405. this._disableDatepicker( target );
  16406. }
  16407. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  16408. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  16409. inst.dpDiv.css( "display", "block" );
  16410. },
  16411. /* Pop-up the date picker in a "dialog" box.
  16412. * @param input element - ignored
  16413. * @param date string or Date - the initial date to display
  16414. * @param onSelect function - the function to call when a date is selected
  16415. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  16416. * @param pos int[2] - coordinates for the dialog's position within the screen or
  16417. * event - with x/y coordinates or
  16418. * leave empty for default (screen centre)
  16419. * @return the manager object
  16420. */
  16421. _dialogDatepicker: function( input, date, onSelect, settings, pos ) {
  16422. var id, browserWidth, browserHeight, scrollX, scrollY,
  16423. inst = this._dialogInst; // internal instance
  16424. if ( !inst ) {
  16425. this.uuid += 1;
  16426. id = "dp" + this.uuid;
  16427. this._dialogInput = $( "<input type='text' id='" + id +
  16428. "' style='position: absolute; top: -100px; width: 0px;'/>" );
  16429. this._dialogInput.on( "keydown", this._doKeyDown );
  16430. $( "body" ).append( this._dialogInput );
  16431. inst = this._dialogInst = this._newInst( this._dialogInput, false );
  16432. inst.settings = {};
  16433. $.data( this._dialogInput[ 0 ], "datepicker", inst );
  16434. }
  16435. datepicker_extendRemove( inst.settings, settings || {} );
  16436. date = ( date && date.constructor === Date ? this._formatDate( inst, date ) : date );
  16437. this._dialogInput.val( date );
  16438. this._pos = ( pos ? ( pos.length ? pos : [ pos.pageX, pos.pageY ] ) : null );
  16439. if ( !this._pos ) {
  16440. browserWidth = document.documentElement.clientWidth;
  16441. browserHeight = document.documentElement.clientHeight;
  16442. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  16443. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  16444. this._pos = // should use actual width/height below
  16445. [ ( browserWidth / 2 ) - 100 + scrollX, ( browserHeight / 2 ) - 150 + scrollY ];
  16446. }
  16447. // Move input on screen for focus, but hidden behind dialog
  16448. this._dialogInput.css( "left", ( this._pos[ 0 ] + 20 ) + "px" ).css( "top", this._pos[ 1 ] + "px" );
  16449. inst.settings.onSelect = onSelect;
  16450. this._inDialog = true;
  16451. this.dpDiv.addClass( this._dialogClass );
  16452. this._showDatepicker( this._dialogInput[ 0 ] );
  16453. if ( $.blockUI ) {
  16454. $.blockUI( this.dpDiv );
  16455. }
  16456. $.data( this._dialogInput[ 0 ], "datepicker", inst );
  16457. return this;
  16458. },
  16459. /* Detach a datepicker from its control.
  16460. * @param target element - the target input field or division or span
  16461. */
  16462. _destroyDatepicker: function( target ) {
  16463. var nodeName,
  16464. $target = $( target ),
  16465. inst = $.data( target, "datepicker" );
  16466. if ( !$target.hasClass( this.markerClassName ) ) {
  16467. return;
  16468. }
  16469. nodeName = target.nodeName.toLowerCase();
  16470. $.removeData( target, "datepicker" );
  16471. if ( nodeName === "input" ) {
  16472. inst.append.remove();
  16473. inst.trigger.remove();
  16474. $target.removeClass( this.markerClassName ).
  16475. off( "focus", this._showDatepicker ).
  16476. off( "keydown", this._doKeyDown ).
  16477. off( "keypress", this._doKeyPress ).
  16478. off( "keyup", this._doKeyUp );
  16479. } else if ( nodeName === "div" || nodeName === "span" ) {
  16480. $target.removeClass( this.markerClassName ).empty();
  16481. }
  16482. if ( datepicker_instActive === inst ) {
  16483. datepicker_instActive = null;
  16484. }
  16485. },
  16486. /* Enable the date picker to a jQuery selection.
  16487. * @param target element - the target input field or division or span
  16488. */
  16489. _enableDatepicker: function( target ) {
  16490. var nodeName, inline,
  16491. $target = $( target ),
  16492. inst = $.data( target, "datepicker" );
  16493. if ( !$target.hasClass( this.markerClassName ) ) {
  16494. return;
  16495. }
  16496. nodeName = target.nodeName.toLowerCase();
  16497. if ( nodeName === "input" ) {
  16498. target.disabled = false;
  16499. inst.trigger.filter( "button" ).
  16500. each( function() { this.disabled = false; } ).end().
  16501. filter( "img" ).css( { opacity: "1.0", cursor: "" } );
  16502. } else if ( nodeName === "div" || nodeName === "span" ) {
  16503. inline = $target.children( "." + this._inlineClass );
  16504. inline.children().removeClass( "ui-state-disabled" );
  16505. inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ).
  16506. prop( "disabled", false );
  16507. }
  16508. this._disabledInputs = $.map( this._disabledInputs,
  16509. function( value ) { return ( value === target ? null : value ); } ); // delete entry
  16510. },
  16511. /* Disable the date picker to a jQuery selection.
  16512. * @param target element - the target input field or division or span
  16513. */
  16514. _disableDatepicker: function( target ) {
  16515. var nodeName, inline,
  16516. $target = $( target ),
  16517. inst = $.data( target, "datepicker" );
  16518. if ( !$target.hasClass( this.markerClassName ) ) {
  16519. return;
  16520. }
  16521. nodeName = target.nodeName.toLowerCase();
  16522. if ( nodeName === "input" ) {
  16523. target.disabled = true;
  16524. inst.trigger.filter( "button" ).
  16525. each( function() { this.disabled = true; } ).end().
  16526. filter( "img" ).css( { opacity: "0.5", cursor: "default" } );
  16527. } else if ( nodeName === "div" || nodeName === "span" ) {
  16528. inline = $target.children( "." + this._inlineClass );
  16529. inline.children().addClass( "ui-state-disabled" );
  16530. inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ).
  16531. prop( "disabled", true );
  16532. }
  16533. this._disabledInputs = $.map( this._disabledInputs,
  16534. function( value ) { return ( value === target ? null : value ); } ); // delete entry
  16535. this._disabledInputs[ this._disabledInputs.length ] = target;
  16536. },
  16537. /* Is the first field in a jQuery collection disabled as a datepicker?
  16538. * @param target element - the target input field or division or span
  16539. * @return boolean - true if disabled, false if enabled
  16540. */
  16541. _isDisabledDatepicker: function( target ) {
  16542. if ( !target ) {
  16543. return false;
  16544. }
  16545. for ( var i = 0; i < this._disabledInputs.length; i++ ) {
  16546. if ( this._disabledInputs[ i ] === target ) {
  16547. return true;
  16548. }
  16549. }
  16550. return false;
  16551. },
  16552. /* Retrieve the instance data for the target control.
  16553. * @param target element - the target input field or division or span
  16554. * @return object - the associated instance data
  16555. * @throws error if a jQuery problem getting data
  16556. */
  16557. _getInst: function( target ) {
  16558. try {
  16559. return $.data( target, "datepicker" );
  16560. }
  16561. catch ( err ) {
  16562. throw "Missing instance data for this datepicker";
  16563. }
  16564. },
  16565. /* Update or retrieve the settings for a date picker attached to an input field or division.
  16566. * @param target element - the target input field or division or span
  16567. * @param name object - the new settings to update or
  16568. * string - the name of the setting to change or retrieve,
  16569. * when retrieving also "all" for all instance settings or
  16570. * "defaults" for all global defaults
  16571. * @param value any - the new value for the setting
  16572. * (omit if above is an object or to retrieve a value)
  16573. */
  16574. _optionDatepicker: function( target, name, value ) {
  16575. var settings, date, minDate, maxDate,
  16576. inst = this._getInst( target );
  16577. if ( arguments.length === 2 && typeof name === "string" ) {
  16578. return ( name === "defaults" ? $.extend( {}, $.datepicker._defaults ) :
  16579. ( inst ? ( name === "all" ? $.extend( {}, inst.settings ) :
  16580. this._get( inst, name ) ) : null ) );
  16581. }
  16582. settings = name || {};
  16583. if ( typeof name === "string" ) {
  16584. settings = {};
  16585. settings[ name ] = value;
  16586. }
  16587. if ( inst ) {
  16588. if ( this._curInst === inst ) {
  16589. this._hideDatepicker();
  16590. }
  16591. date = this._getDateDatepicker( target, true );
  16592. minDate = this._getMinMaxDate( inst, "min" );
  16593. maxDate = this._getMinMaxDate( inst, "max" );
  16594. datepicker_extendRemove( inst.settings, settings );
  16595. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  16596. if ( minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined ) {
  16597. inst.settings.minDate = this._formatDate( inst, minDate );
  16598. }
  16599. if ( maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined ) {
  16600. inst.settings.maxDate = this._formatDate( inst, maxDate );
  16601. }
  16602. if ( "disabled" in settings ) {
  16603. if ( settings.disabled ) {
  16604. this._disableDatepicker( target );
  16605. } else {
  16606. this._enableDatepicker( target );
  16607. }
  16608. }
  16609. this._attachments( $( target ), inst );
  16610. this._autoSize( inst );
  16611. this._setDate( inst, date );
  16612. this._updateAlternate( inst );
  16613. this._updateDatepicker( inst );
  16614. }
  16615. },
  16616. // Change method deprecated
  16617. _changeDatepicker: function( target, name, value ) {
  16618. this._optionDatepicker( target, name, value );
  16619. },
  16620. /* Redraw the date picker attached to an input field or division.
  16621. * @param target element - the target input field or division or span
  16622. */
  16623. _refreshDatepicker: function( target ) {
  16624. var inst = this._getInst( target );
  16625. if ( inst ) {
  16626. this._updateDatepicker( inst );
  16627. }
  16628. },
  16629. /* Set the dates for a jQuery selection.
  16630. * @param target element - the target input field or division or span
  16631. * @param date Date - the new date
  16632. */
  16633. _setDateDatepicker: function( target, date ) {
  16634. var inst = this._getInst( target );
  16635. if ( inst ) {
  16636. this._setDate( inst, date );
  16637. this._updateDatepicker( inst );
  16638. this._updateAlternate( inst );
  16639. }
  16640. },
  16641. /* Get the date(s) for the first entry in a jQuery selection.
  16642. * @param target element - the target input field or division or span
  16643. * @param noDefault boolean - true if no default date is to be used
  16644. * @return Date - the current date
  16645. */
  16646. _getDateDatepicker: function( target, noDefault ) {
  16647. var inst = this._getInst( target );
  16648. if ( inst && !inst.inline ) {
  16649. this._setDateFromField( inst, noDefault );
  16650. }
  16651. return ( inst ? this._getDate( inst ) : null );
  16652. },
  16653. /* Handle keystrokes. */
  16654. _doKeyDown: function( event ) {
  16655. var onSelect, dateStr, sel,
  16656. inst = $.datepicker._getInst( event.target ),
  16657. handled = true,
  16658. isRTL = inst.dpDiv.is( ".ui-datepicker-rtl" );
  16659. inst._keyEvent = true;
  16660. if ( $.datepicker._datepickerShowing ) {
  16661. switch ( event.keyCode ) {
  16662. case 9: $.datepicker._hideDatepicker();
  16663. handled = false;
  16664. break; // hide on tab out
  16665. case 13: sel = $( "td." + $.datepicker._dayOverClass + ":not(." +
  16666. $.datepicker._currentClass + ")", inst.dpDiv );
  16667. if ( sel[ 0 ] ) {
  16668. $.datepicker._selectDay( event.target, inst.selectedMonth, inst.selectedYear, sel[ 0 ] );
  16669. }
  16670. onSelect = $.datepicker._get( inst, "onSelect" );
  16671. if ( onSelect ) {
  16672. dateStr = $.datepicker._formatDate( inst );
  16673. // Trigger custom callback
  16674. onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] );
  16675. } else {
  16676. $.datepicker._hideDatepicker();
  16677. }
  16678. return false; // don't submit the form
  16679. case 27: $.datepicker._hideDatepicker();
  16680. break; // hide on escape
  16681. case 33: $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  16682. -$.datepicker._get( inst, "stepBigMonths" ) :
  16683. -$.datepicker._get( inst, "stepMonths" ) ), "M" );
  16684. break; // previous month/year on page up/+ ctrl
  16685. case 34: $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  16686. +$.datepicker._get( inst, "stepBigMonths" ) :
  16687. +$.datepicker._get( inst, "stepMonths" ) ), "M" );
  16688. break; // next month/year on page down/+ ctrl
  16689. case 35: if ( event.ctrlKey || event.metaKey ) {
  16690. $.datepicker._clearDate( event.target );
  16691. }
  16692. handled = event.ctrlKey || event.metaKey;
  16693. break; // clear on ctrl or command +end
  16694. case 36: if ( event.ctrlKey || event.metaKey ) {
  16695. $.datepicker._gotoToday( event.target );
  16696. }
  16697. handled = event.ctrlKey || event.metaKey;
  16698. break; // current on ctrl or command +home
  16699. case 37: if ( event.ctrlKey || event.metaKey ) {
  16700. $.datepicker._adjustDate( event.target, ( isRTL ? +1 : -1 ), "D" );
  16701. }
  16702. handled = event.ctrlKey || event.metaKey;
  16703. // -1 day on ctrl or command +left
  16704. if ( event.originalEvent.altKey ) {
  16705. $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  16706. -$.datepicker._get( inst, "stepBigMonths" ) :
  16707. -$.datepicker._get( inst, "stepMonths" ) ), "M" );
  16708. }
  16709. // next month/year on alt +left on Mac
  16710. break;
  16711. case 38: if ( event.ctrlKey || event.metaKey ) {
  16712. $.datepicker._adjustDate( event.target, -7, "D" );
  16713. }
  16714. handled = event.ctrlKey || event.metaKey;
  16715. break; // -1 week on ctrl or command +up
  16716. case 39: if ( event.ctrlKey || event.metaKey ) {
  16717. $.datepicker._adjustDate( event.target, ( isRTL ? -1 : +1 ), "D" );
  16718. }
  16719. handled = event.ctrlKey || event.metaKey;
  16720. // +1 day on ctrl or command +right
  16721. if ( event.originalEvent.altKey ) {
  16722. $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  16723. +$.datepicker._get( inst, "stepBigMonths" ) :
  16724. +$.datepicker._get( inst, "stepMonths" ) ), "M" );
  16725. }
  16726. // next month/year on alt +right
  16727. break;
  16728. case 40: if ( event.ctrlKey || event.metaKey ) {
  16729. $.datepicker._adjustDate( event.target, +7, "D" );
  16730. }
  16731. handled = event.ctrlKey || event.metaKey;
  16732. break; // +1 week on ctrl or command +down
  16733. default: handled = false;
  16734. }
  16735. } else if ( event.keyCode === 36 && event.ctrlKey ) { // display the date picker on ctrl+home
  16736. $.datepicker._showDatepicker( this );
  16737. } else {
  16738. handled = false;
  16739. }
  16740. if ( handled ) {
  16741. event.preventDefault();
  16742. event.stopPropagation();
  16743. }
  16744. },
  16745. /* Filter entered characters - based on date format. */
  16746. _doKeyPress: function( event ) {
  16747. var chars, chr,
  16748. inst = $.datepicker._getInst( event.target );
  16749. if ( $.datepicker._get( inst, "constrainInput" ) ) {
  16750. chars = $.datepicker._possibleChars( $.datepicker._get( inst, "dateFormat" ) );
  16751. chr = String.fromCharCode( event.charCode == null ? event.keyCode : event.charCode );
  16752. return event.ctrlKey || event.metaKey || ( chr < " " || !chars || chars.indexOf( chr ) > -1 );
  16753. }
  16754. },
  16755. /* Synchronise manual entry and field/alternate field. */
  16756. _doKeyUp: function( event ) {
  16757. var date,
  16758. inst = $.datepicker._getInst( event.target );
  16759. if ( inst.input.val() !== inst.lastVal ) {
  16760. try {
  16761. date = $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ),
  16762. ( inst.input ? inst.input.val() : null ),
  16763. $.datepicker._getFormatConfig( inst ) );
  16764. if ( date ) { // only if valid
  16765. $.datepicker._setDateFromField( inst );
  16766. $.datepicker._updateAlternate( inst );
  16767. $.datepicker._updateDatepicker( inst );
  16768. }
  16769. }
  16770. catch ( err ) {
  16771. }
  16772. }
  16773. return true;
  16774. },
  16775. /* Pop-up the date picker for a given input field.
  16776. * If false returned from beforeShow event handler do not show.
  16777. * @param input element - the input field attached to the date picker or
  16778. * event - if triggered by focus
  16779. */
  16780. _showDatepicker: function( input ) {
  16781. input = input.target || input;
  16782. if ( input.nodeName.toLowerCase() !== "input" ) { // find from button/image trigger
  16783. input = $( "input", input.parentNode )[ 0 ];
  16784. }
  16785. if ( $.datepicker._isDisabledDatepicker( input ) || $.datepicker._lastInput === input ) { // already here
  16786. return;
  16787. }
  16788. var inst, beforeShow, beforeShowSettings, isFixed,
  16789. offset, showAnim, duration;
  16790. inst = $.datepicker._getInst( input );
  16791. if ( $.datepicker._curInst && $.datepicker._curInst !== inst ) {
  16792. $.datepicker._curInst.dpDiv.stop( true, true );
  16793. if ( inst && $.datepicker._datepickerShowing ) {
  16794. $.datepicker._hideDatepicker( $.datepicker._curInst.input[ 0 ] );
  16795. }
  16796. }
  16797. beforeShow = $.datepicker._get( inst, "beforeShow" );
  16798. beforeShowSettings = beforeShow ? beforeShow.apply( input, [ input, inst ] ) : {};
  16799. if ( beforeShowSettings === false ) {
  16800. return;
  16801. }
  16802. datepicker_extendRemove( inst.settings, beforeShowSettings );
  16803. inst.lastVal = null;
  16804. $.datepicker._lastInput = input;
  16805. $.datepicker._setDateFromField( inst );
  16806. if ( $.datepicker._inDialog ) { // hide cursor
  16807. input.value = "";
  16808. }
  16809. if ( !$.datepicker._pos ) { // position below input
  16810. $.datepicker._pos = $.datepicker._findPos( input );
  16811. $.datepicker._pos[ 1 ] += input.offsetHeight; // add the height
  16812. }
  16813. isFixed = false;
  16814. $( input ).parents().each( function() {
  16815. isFixed |= $( this ).css( "position" ) === "fixed";
  16816. return !isFixed;
  16817. } );
  16818. offset = { left: $.datepicker._pos[ 0 ], top: $.datepicker._pos[ 1 ] };
  16819. $.datepicker._pos = null;
  16820. //to avoid flashes on Firefox
  16821. inst.dpDiv.empty();
  16822. // determine sizing offscreen
  16823. inst.dpDiv.css( { position: "absolute", display: "block", top: "-1000px" } );
  16824. $.datepicker._updateDatepicker( inst );
  16825. // fix width for dynamic number of date pickers
  16826. // and adjust position before showing
  16827. offset = $.datepicker._checkOffset( inst, offset, isFixed );
  16828. inst.dpDiv.css( { position: ( $.datepicker._inDialog && $.blockUI ?
  16829. "static" : ( isFixed ? "fixed" : "absolute" ) ), display: "none",
  16830. left: offset.left + "px", top: offset.top + "px" } );
  16831. if ( !inst.inline ) {
  16832. showAnim = $.datepicker._get( inst, "showAnim" );
  16833. duration = $.datepicker._get( inst, "duration" );
  16834. inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 );
  16835. $.datepicker._datepickerShowing = true;
  16836. if ( $.effects && $.effects.effect[ showAnim ] ) {
  16837. inst.dpDiv.show( showAnim, $.datepicker._get( inst, "showOptions" ), duration );
  16838. } else {
  16839. inst.dpDiv[ showAnim || "show" ]( showAnim ? duration : null );
  16840. }
  16841. if ( $.datepicker._shouldFocusInput( inst ) ) {
  16842. inst.input.trigger( "focus" );
  16843. }
  16844. $.datepicker._curInst = inst;
  16845. }
  16846. },
  16847. /* Generate the date picker content. */
  16848. _updateDatepicker: function( inst ) {
  16849. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  16850. datepicker_instActive = inst; // for delegate hover events
  16851. inst.dpDiv.empty().append( this._generateHTML( inst ) );
  16852. this._attachHandlers( inst );
  16853. var origyearshtml,
  16854. numMonths = this._getNumberOfMonths( inst ),
  16855. cols = numMonths[ 1 ],
  16856. width = 17,
  16857. activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" );
  16858. if ( activeCell.length > 0 ) {
  16859. datepicker_handleMouseover.apply( activeCell.get( 0 ) );
  16860. }
  16861. inst.dpDiv.removeClass( "ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4" ).width( "" );
  16862. if ( cols > 1 ) {
  16863. inst.dpDiv.addClass( "ui-datepicker-multi-" + cols ).css( "width", ( width * cols ) + "em" );
  16864. }
  16865. inst.dpDiv[ ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ? "add" : "remove" ) +
  16866. "Class" ]( "ui-datepicker-multi" );
  16867. inst.dpDiv[ ( this._get( inst, "isRTL" ) ? "add" : "remove" ) +
  16868. "Class" ]( "ui-datepicker-rtl" );
  16869. if ( inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  16870. inst.input.trigger( "focus" );
  16871. }
  16872. // Deffered render of the years select (to avoid flashes on Firefox)
  16873. if ( inst.yearshtml ) {
  16874. origyearshtml = inst.yearshtml;
  16875. setTimeout( function() {
  16876. //assure that inst.yearshtml didn't change.
  16877. if ( origyearshtml === inst.yearshtml && inst.yearshtml ) {
  16878. inst.dpDiv.find( "select.ui-datepicker-year:first" ).replaceWith( inst.yearshtml );
  16879. }
  16880. origyearshtml = inst.yearshtml = null;
  16881. }, 0 );
  16882. }
  16883. },
  16884. // #6694 - don't focus the input if it's already focused
  16885. // this breaks the change event in IE
  16886. // Support: IE and jQuery <1.9
  16887. _shouldFocusInput: function( inst ) {
  16888. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  16889. },
  16890. /* Check positioning to remain on screen. */
  16891. _checkOffset: function( inst, offset, isFixed ) {
  16892. var dpWidth = inst.dpDiv.outerWidth(),
  16893. dpHeight = inst.dpDiv.outerHeight(),
  16894. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  16895. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  16896. viewWidth = document.documentElement.clientWidth + ( isFixed ? 0 : $( document ).scrollLeft() ),
  16897. viewHeight = document.documentElement.clientHeight + ( isFixed ? 0 : $( document ).scrollTop() );
  16898. offset.left -= ( this._get( inst, "isRTL" ) ? ( dpWidth - inputWidth ) : 0 );
  16899. offset.left -= ( isFixed && offset.left === inst.input.offset().left ) ? $( document ).scrollLeft() : 0;
  16900. offset.top -= ( isFixed && offset.top === ( inst.input.offset().top + inputHeight ) ) ? $( document ).scrollTop() : 0;
  16901. // Now check if datepicker is showing outside window viewport - move to a better place if so.
  16902. offset.left -= Math.min( offset.left, ( offset.left + dpWidth > viewWidth && viewWidth > dpWidth ) ?
  16903. Math.abs( offset.left + dpWidth - viewWidth ) : 0 );
  16904. offset.top -= Math.min( offset.top, ( offset.top + dpHeight > viewHeight && viewHeight > dpHeight ) ?
  16905. Math.abs( dpHeight + inputHeight ) : 0 );
  16906. return offset;
  16907. },
  16908. /* Find an object's position on the screen. */
  16909. _findPos: function( obj ) {
  16910. var position,
  16911. inst = this._getInst( obj ),
  16912. isRTL = this._get( inst, "isRTL" );
  16913. while ( obj && ( obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden( obj ) ) ) {
  16914. obj = obj[ isRTL ? "previousSibling" : "nextSibling" ];
  16915. }
  16916. position = $( obj ).offset();
  16917. return [ position.left, position.top ];
  16918. },
  16919. /* Hide the date picker from view.
  16920. * @param input element - the input field attached to the date picker
  16921. */
  16922. _hideDatepicker: function( input ) {
  16923. var showAnim, duration, postProcess, onClose,
  16924. inst = this._curInst;
  16925. if ( !inst || ( input && inst !== $.data( input, "datepicker" ) ) ) {
  16926. return;
  16927. }
  16928. if ( this._datepickerShowing ) {
  16929. showAnim = this._get( inst, "showAnim" );
  16930. duration = this._get( inst, "duration" );
  16931. postProcess = function() {
  16932. $.datepicker._tidyDialog( inst );
  16933. };
  16934. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  16935. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  16936. inst.dpDiv.hide( showAnim, $.datepicker._get( inst, "showOptions" ), duration, postProcess );
  16937. } else {
  16938. inst.dpDiv[ ( showAnim === "slideDown" ? "slideUp" :
  16939. ( showAnim === "fadeIn" ? "fadeOut" : "hide" ) ) ]( ( showAnim ? duration : null ), postProcess );
  16940. }
  16941. if ( !showAnim ) {
  16942. postProcess();
  16943. }
  16944. this._datepickerShowing = false;
  16945. onClose = this._get( inst, "onClose" );
  16946. if ( onClose ) {
  16947. onClose.apply( ( inst.input ? inst.input[ 0 ] : null ), [ ( inst.input ? inst.input.val() : "" ), inst ] );
  16948. }
  16949. this._lastInput = null;
  16950. if ( this._inDialog ) {
  16951. this._dialogInput.css( { position: "absolute", left: "0", top: "-100px" } );
  16952. if ( $.blockUI ) {
  16953. $.unblockUI();
  16954. $( "body" ).append( this.dpDiv );
  16955. }
  16956. }
  16957. this._inDialog = false;
  16958. }
  16959. },
  16960. /* Tidy up after a dialog display. */
  16961. _tidyDialog: function( inst ) {
  16962. inst.dpDiv.removeClass( this._dialogClass ).off( ".ui-datepicker-calendar" );
  16963. },
  16964. /* Close date picker if clicked elsewhere. */
  16965. _checkExternalClick: function( event ) {
  16966. if ( !$.datepicker._curInst ) {
  16967. return;
  16968. }
  16969. var $target = $( event.target ),
  16970. inst = $.datepicker._getInst( $target[ 0 ] );
  16971. if ( ( ( $target[ 0 ].id !== $.datepicker._mainDivId &&
  16972. $target.parents( "#" + $.datepicker._mainDivId ).length === 0 &&
  16973. !$target.hasClass( $.datepicker.markerClassName ) &&
  16974. !$target.closest( "." + $.datepicker._triggerClass ).length &&
  16975. $.datepicker._datepickerShowing && !( $.datepicker._inDialog && $.blockUI ) ) ) ||
  16976. ( $target.hasClass( $.datepicker.markerClassName ) && $.datepicker._curInst !== inst ) ) {
  16977. $.datepicker._hideDatepicker();
  16978. }
  16979. },
  16980. /* Adjust one of the date sub-fields. */
  16981. _adjustDate: function( id, offset, period ) {
  16982. var target = $( id ),
  16983. inst = this._getInst( target[ 0 ] );
  16984. if ( this._isDisabledDatepicker( target[ 0 ] ) ) {
  16985. return;
  16986. }
  16987. this._adjustInstDate( inst, offset +
  16988. ( period === "M" ? this._get( inst, "showCurrentAtPos" ) : 0 ), // undo positioning
  16989. period );
  16990. this._updateDatepicker( inst );
  16991. },
  16992. /* Action for current link. */
  16993. _gotoToday: function( id ) {
  16994. var date,
  16995. target = $( id ),
  16996. inst = this._getInst( target[ 0 ] );
  16997. if ( this._get( inst, "gotoCurrent" ) && inst.currentDay ) {
  16998. inst.selectedDay = inst.currentDay;
  16999. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  17000. inst.drawYear = inst.selectedYear = inst.currentYear;
  17001. } else {
  17002. date = new Date();
  17003. inst.selectedDay = date.getDate();
  17004. inst.drawMonth = inst.selectedMonth = date.getMonth();
  17005. inst.drawYear = inst.selectedYear = date.getFullYear();
  17006. }
  17007. this._notifyChange( inst );
  17008. this._adjustDate( target );
  17009. },
  17010. /* Action for selecting a new month/year. */
  17011. _selectMonthYear: function( id, select, period ) {
  17012. var target = $( id ),
  17013. inst = this._getInst( target[ 0 ] );
  17014. inst[ "selected" + ( period === "M" ? "Month" : "Year" ) ] =
  17015. inst[ "draw" + ( period === "M" ? "Month" : "Year" ) ] =
  17016. parseInt( select.options[ select.selectedIndex ].value, 10 );
  17017. this._notifyChange( inst );
  17018. this._adjustDate( target );
  17019. },
  17020. /* Action for selecting a day. */
  17021. _selectDay: function( id, month, year, td ) {
  17022. var inst,
  17023. target = $( id );
  17024. if ( $( td ).hasClass( this._unselectableClass ) || this._isDisabledDatepicker( target[ 0 ] ) ) {
  17025. return;
  17026. }
  17027. inst = this._getInst( target[ 0 ] );
  17028. inst.selectedDay = inst.currentDay = $( "a", td ).html();
  17029. inst.selectedMonth = inst.currentMonth = month;
  17030. inst.selectedYear = inst.currentYear = year;
  17031. this._selectDate( id, this._formatDate( inst,
  17032. inst.currentDay, inst.currentMonth, inst.currentYear ) );
  17033. },
  17034. /* Erase the input field and hide the date picker. */
  17035. _clearDate: function( id ) {
  17036. var target = $( id );
  17037. this._selectDate( target, "" );
  17038. },
  17039. /* Update the input field with the selected date. */
  17040. _selectDate: function( id, dateStr ) {
  17041. var onSelect,
  17042. target = $( id ),
  17043. inst = this._getInst( target[ 0 ] );
  17044. dateStr = ( dateStr != null ? dateStr : this._formatDate( inst ) );
  17045. if ( inst.input ) {
  17046. inst.input.val( dateStr );
  17047. }
  17048. this._updateAlternate( inst );
  17049. onSelect = this._get( inst, "onSelect" );
  17050. if ( onSelect ) {
  17051. onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] ); // trigger custom callback
  17052. } else if ( inst.input ) {
  17053. inst.input.trigger( "change" ); // fire the change event
  17054. }
  17055. if ( inst.inline ) {
  17056. this._updateDatepicker( inst );
  17057. } else {
  17058. this._hideDatepicker();
  17059. this._lastInput = inst.input[ 0 ];
  17060. if ( typeof( inst.input[ 0 ] ) !== "object" ) {
  17061. inst.input.trigger( "focus" ); // restore focus
  17062. }
  17063. this._lastInput = null;
  17064. }
  17065. },
  17066. /* Update any alternate field to synchronise with the main field. */
  17067. _updateAlternate: function( inst ) {
  17068. var altFormat, date, dateStr,
  17069. altField = this._get( inst, "altField" );
  17070. if ( altField ) { // update alternate field too
  17071. altFormat = this._get( inst, "altFormat" ) || this._get( inst, "dateFormat" );
  17072. date = this._getDate( inst );
  17073. dateStr = this.formatDate( altFormat, date, this._getFormatConfig( inst ) );
  17074. $( altField ).val( dateStr );
  17075. }
  17076. },
  17077. /* Set as beforeShowDay function to prevent selection of weekends.
  17078. * @param date Date - the date to customise
  17079. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  17080. */
  17081. noWeekends: function( date ) {
  17082. var day = date.getDay();
  17083. return [ ( day > 0 && day < 6 ), "" ];
  17084. },
  17085. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  17086. * @param date Date - the date to get the week for
  17087. * @return number - the number of the week within the year that contains this date
  17088. */
  17089. iso8601Week: function( date ) {
  17090. var time,
  17091. checkDate = new Date( date.getTime() );
  17092. // Find Thursday of this week starting on Monday
  17093. checkDate.setDate( checkDate.getDate() + 4 - ( checkDate.getDay() || 7 ) );
  17094. time = checkDate.getTime();
  17095. checkDate.setMonth( 0 ); // Compare with Jan 1
  17096. checkDate.setDate( 1 );
  17097. return Math.floor( Math.round( ( time - checkDate ) / 86400000 ) / 7 ) + 1;
  17098. },
  17099. /* Parse a string value into a date object.
  17100. * See formatDate below for the possible formats.
  17101. *
  17102. * @param format string - the expected format of the date
  17103. * @param value string - the date in the above format
  17104. * @param settings Object - attributes include:
  17105. * shortYearCutoff number - the cutoff year for determining the century (optional)
  17106. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  17107. * dayNames string[7] - names of the days from Sunday (optional)
  17108. * monthNamesShort string[12] - abbreviated names of the months (optional)
  17109. * monthNames string[12] - names of the months (optional)
  17110. * @return Date - the extracted date value or null if value is blank
  17111. */
  17112. parseDate: function( format, value, settings ) {
  17113. if ( format == null || value == null ) {
  17114. throw "Invalid arguments";
  17115. }
  17116. value = ( typeof value === "object" ? value.toString() : value + "" );
  17117. if ( value === "" ) {
  17118. return null;
  17119. }
  17120. var iFormat, dim, extra,
  17121. iValue = 0,
  17122. shortYearCutoffTemp = ( settings ? settings.shortYearCutoff : null ) || this._defaults.shortYearCutoff,
  17123. shortYearCutoff = ( typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  17124. new Date().getFullYear() % 100 + parseInt( shortYearCutoffTemp, 10 ) ),
  17125. dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort,
  17126. dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames,
  17127. monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort,
  17128. monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames,
  17129. year = -1,
  17130. month = -1,
  17131. day = -1,
  17132. doy = -1,
  17133. literal = false,
  17134. date,
  17135. // Check whether a format character is doubled
  17136. lookAhead = function( match ) {
  17137. var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
  17138. if ( matches ) {
  17139. iFormat++;
  17140. }
  17141. return matches;
  17142. },
  17143. // Extract a number from the string value
  17144. getNumber = function( match ) {
  17145. var isDoubled = lookAhead( match ),
  17146. size = ( match === "@" ? 14 : ( match === "!" ? 20 :
  17147. ( match === "y" && isDoubled ? 4 : ( match === "o" ? 3 : 2 ) ) ) ),
  17148. minSize = ( match === "y" ? size : 1 ),
  17149. digits = new RegExp( "^\\d{" + minSize + "," + size + "}" ),
  17150. num = value.substring( iValue ).match( digits );
  17151. if ( !num ) {
  17152. throw "Missing number at position " + iValue;
  17153. }
  17154. iValue += num[ 0 ].length;
  17155. return parseInt( num[ 0 ], 10 );
  17156. },
  17157. // Extract a name from the string value and convert to an index
  17158. getName = function( match, shortNames, longNames ) {
  17159. var index = -1,
  17160. names = $.map( lookAhead( match ) ? longNames : shortNames, function( v, k ) {
  17161. return [ [ k, v ] ];
  17162. } ).sort( function( a, b ) {
  17163. return -( a[ 1 ].length - b[ 1 ].length );
  17164. } );
  17165. $.each( names, function( i, pair ) {
  17166. var name = pair[ 1 ];
  17167. if ( value.substr( iValue, name.length ).toLowerCase() === name.toLowerCase() ) {
  17168. index = pair[ 0 ];
  17169. iValue += name.length;
  17170. return false;
  17171. }
  17172. } );
  17173. if ( index !== -1 ) {
  17174. return index + 1;
  17175. } else {
  17176. throw "Unknown name at position " + iValue;
  17177. }
  17178. },
  17179. // Confirm that a literal character matches the string value
  17180. checkLiteral = function() {
  17181. if ( value.charAt( iValue ) !== format.charAt( iFormat ) ) {
  17182. throw "Unexpected literal at position " + iValue;
  17183. }
  17184. iValue++;
  17185. };
  17186. for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
  17187. if ( literal ) {
  17188. if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
  17189. literal = false;
  17190. } else {
  17191. checkLiteral();
  17192. }
  17193. } else {
  17194. switch ( format.charAt( iFormat ) ) {
  17195. case "d":
  17196. day = getNumber( "d" );
  17197. break;
  17198. case "D":
  17199. getName( "D", dayNamesShort, dayNames );
  17200. break;
  17201. case "o":
  17202. doy = getNumber( "o" );
  17203. break;
  17204. case "m":
  17205. month = getNumber( "m" );
  17206. break;
  17207. case "M":
  17208. month = getName( "M", monthNamesShort, monthNames );
  17209. break;
  17210. case "y":
  17211. year = getNumber( "y" );
  17212. break;
  17213. case "@":
  17214. date = new Date( getNumber( "@" ) );
  17215. year = date.getFullYear();
  17216. month = date.getMonth() + 1;
  17217. day = date.getDate();
  17218. break;
  17219. case "!":
  17220. date = new Date( ( getNumber( "!" ) - this._ticksTo1970 ) / 10000 );
  17221. year = date.getFullYear();
  17222. month = date.getMonth() + 1;
  17223. day = date.getDate();
  17224. break;
  17225. case "'":
  17226. if ( lookAhead( "'" ) ) {
  17227. checkLiteral();
  17228. } else {
  17229. literal = true;
  17230. }
  17231. break;
  17232. default:
  17233. checkLiteral();
  17234. }
  17235. }
  17236. }
  17237. if ( iValue < value.length ) {
  17238. extra = value.substr( iValue );
  17239. if ( !/^\s+/.test( extra ) ) {
  17240. throw "Extra/unparsed characters found in date: " + extra;
  17241. }
  17242. }
  17243. if ( year === -1 ) {
  17244. year = new Date().getFullYear();
  17245. } else if ( year < 100 ) {
  17246. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  17247. ( year <= shortYearCutoff ? 0 : -100 );
  17248. }
  17249. if ( doy > -1 ) {
  17250. month = 1;
  17251. day = doy;
  17252. do {
  17253. dim = this._getDaysInMonth( year, month - 1 );
  17254. if ( day <= dim ) {
  17255. break;
  17256. }
  17257. month++;
  17258. day -= dim;
  17259. } while ( true );
  17260. }
  17261. date = this._daylightSavingAdjust( new Date( year, month - 1, day ) );
  17262. if ( date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day ) {
  17263. throw "Invalid date"; // E.g. 31/02/00
  17264. }
  17265. return date;
  17266. },
  17267. /* Standard date formats. */
  17268. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  17269. COOKIE: "D, dd M yy",
  17270. ISO_8601: "yy-mm-dd",
  17271. RFC_822: "D, d M y",
  17272. RFC_850: "DD, dd-M-y",
  17273. RFC_1036: "D, d M y",
  17274. RFC_1123: "D, d M yy",
  17275. RFC_2822: "D, d M yy",
  17276. RSS: "D, d M y", // RFC 822
  17277. TICKS: "!",
  17278. TIMESTAMP: "@",
  17279. W3C: "yy-mm-dd", // ISO 8601
  17280. _ticksTo1970: ( ( ( 1970 - 1 ) * 365 + Math.floor( 1970 / 4 ) - Math.floor( 1970 / 100 ) +
  17281. Math.floor( 1970 / 400 ) ) * 24 * 60 * 60 * 10000000 ),
  17282. /* Format a date object into a string value.
  17283. * The format can be combinations of the following:
  17284. * d - day of month (no leading zero)
  17285. * dd - day of month (two digit)
  17286. * o - day of year (no leading zeros)
  17287. * oo - day of year (three digit)
  17288. * D - day name short
  17289. * DD - day name long
  17290. * m - month of year (no leading zero)
  17291. * mm - month of year (two digit)
  17292. * M - month name short
  17293. * MM - month name long
  17294. * y - year (two digit)
  17295. * yy - year (four digit)
  17296. * @ - Unix timestamp (ms since 01/01/1970)
  17297. * ! - Windows ticks (100ns since 01/01/0001)
  17298. * "..." - literal text
  17299. * '' - single quote
  17300. *
  17301. * @param format string - the desired format of the date
  17302. * @param date Date - the date value to format
  17303. * @param settings Object - attributes include:
  17304. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  17305. * dayNames string[7] - names of the days from Sunday (optional)
  17306. * monthNamesShort string[12] - abbreviated names of the months (optional)
  17307. * monthNames string[12] - names of the months (optional)
  17308. * @return string - the date in the above format
  17309. */
  17310. formatDate: function( format, date, settings ) {
  17311. if ( !date ) {
  17312. return "";
  17313. }
  17314. var iFormat,
  17315. dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort,
  17316. dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames,
  17317. monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort,
  17318. monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames,
  17319. // Check whether a format character is doubled
  17320. lookAhead = function( match ) {
  17321. var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
  17322. if ( matches ) {
  17323. iFormat++;
  17324. }
  17325. return matches;
  17326. },
  17327. // Format a number, with leading zero if necessary
  17328. formatNumber = function( match, value, len ) {
  17329. var num = "" + value;
  17330. if ( lookAhead( match ) ) {
  17331. while ( num.length < len ) {
  17332. num = "0" + num;
  17333. }
  17334. }
  17335. return num;
  17336. },
  17337. // Format a name, short or long as requested
  17338. formatName = function( match, value, shortNames, longNames ) {
  17339. return ( lookAhead( match ) ? longNames[ value ] : shortNames[ value ] );
  17340. },
  17341. output = "",
  17342. literal = false;
  17343. if ( date ) {
  17344. for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
  17345. if ( literal ) {
  17346. if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
  17347. literal = false;
  17348. } else {
  17349. output += format.charAt( iFormat );
  17350. }
  17351. } else {
  17352. switch ( format.charAt( iFormat ) ) {
  17353. case "d":
  17354. output += formatNumber( "d", date.getDate(), 2 );
  17355. break;
  17356. case "D":
  17357. output += formatName( "D", date.getDay(), dayNamesShort, dayNames );
  17358. break;
  17359. case "o":
  17360. output += formatNumber( "o",
  17361. Math.round( ( new Date( date.getFullYear(), date.getMonth(), date.getDate() ).getTime() - new Date( date.getFullYear(), 0, 0 ).getTime() ) / 86400000 ), 3 );
  17362. break;
  17363. case "m":
  17364. output += formatNumber( "m", date.getMonth() + 1, 2 );
  17365. break;
  17366. case "M":
  17367. output += formatName( "M", date.getMonth(), monthNamesShort, monthNames );
  17368. break;
  17369. case "y":
  17370. output += ( lookAhead( "y" ) ? date.getFullYear() :
  17371. ( date.getFullYear() % 100 < 10 ? "0" : "" ) + date.getFullYear() % 100 );
  17372. break;
  17373. case "@":
  17374. output += date.getTime();
  17375. break;
  17376. case "!":
  17377. output += date.getTime() * 10000 + this._ticksTo1970;
  17378. break;
  17379. case "'":
  17380. if ( lookAhead( "'" ) ) {
  17381. output += "'";
  17382. } else {
  17383. literal = true;
  17384. }
  17385. break;
  17386. default:
  17387. output += format.charAt( iFormat );
  17388. }
  17389. }
  17390. }
  17391. }
  17392. return output;
  17393. },
  17394. /* Extract all possible characters from the date format. */
  17395. _possibleChars: function( format ) {
  17396. var iFormat,
  17397. chars = "",
  17398. literal = false,
  17399. // Check whether a format character is doubled
  17400. lookAhead = function( match ) {
  17401. var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
  17402. if ( matches ) {
  17403. iFormat++;
  17404. }
  17405. return matches;
  17406. };
  17407. for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
  17408. if ( literal ) {
  17409. if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
  17410. literal = false;
  17411. } else {
  17412. chars += format.charAt( iFormat );
  17413. }
  17414. } else {
  17415. switch ( format.charAt( iFormat ) ) {
  17416. case "d": case "m": case "y": case "@":
  17417. chars += "0123456789";
  17418. break;
  17419. case "D": case "M":
  17420. return null; // Accept anything
  17421. case "'":
  17422. if ( lookAhead( "'" ) ) {
  17423. chars += "'";
  17424. } else {
  17425. literal = true;
  17426. }
  17427. break;
  17428. default:
  17429. chars += format.charAt( iFormat );
  17430. }
  17431. }
  17432. }
  17433. return chars;
  17434. },
  17435. /* Get a setting value, defaulting if necessary. */
  17436. _get: function( inst, name ) {
  17437. return inst.settings[ name ] !== undefined ?
  17438. inst.settings[ name ] : this._defaults[ name ];
  17439. },
  17440. /* Parse existing date and initialise date picker. */
  17441. _setDateFromField: function( inst, noDefault ) {
  17442. if ( inst.input.val() === inst.lastVal ) {
  17443. return;
  17444. }
  17445. var dateFormat = this._get( inst, "dateFormat" ),
  17446. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  17447. defaultDate = this._getDefaultDate( inst ),
  17448. date = defaultDate,
  17449. settings = this._getFormatConfig( inst );
  17450. try {
  17451. date = this.parseDate( dateFormat, dates, settings ) || defaultDate;
  17452. } catch ( event ) {
  17453. dates = ( noDefault ? "" : dates );
  17454. }
  17455. inst.selectedDay = date.getDate();
  17456. inst.drawMonth = inst.selectedMonth = date.getMonth();
  17457. inst.drawYear = inst.selectedYear = date.getFullYear();
  17458. inst.currentDay = ( dates ? date.getDate() : 0 );
  17459. inst.currentMonth = ( dates ? date.getMonth() : 0 );
  17460. inst.currentYear = ( dates ? date.getFullYear() : 0 );
  17461. this._adjustInstDate( inst );
  17462. },
  17463. /* Retrieve the default date shown on opening. */
  17464. _getDefaultDate: function( inst ) {
  17465. return this._restrictMinMax( inst,
  17466. this._determineDate( inst, this._get( inst, "defaultDate" ), new Date() ) );
  17467. },
  17468. /* A date may be specified as an exact value or a relative one. */
  17469. _determineDate: function( inst, date, defaultDate ) {
  17470. var offsetNumeric = function( offset ) {
  17471. var date = new Date();
  17472. date.setDate( date.getDate() + offset );
  17473. return date;
  17474. },
  17475. offsetString = function( offset ) {
  17476. try {
  17477. return $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ),
  17478. offset, $.datepicker._getFormatConfig( inst ) );
  17479. }
  17480. catch ( e ) {
  17481. // Ignore
  17482. }
  17483. var date = ( offset.toLowerCase().match( /^c/ ) ?
  17484. $.datepicker._getDate( inst ) : null ) || new Date(),
  17485. year = date.getFullYear(),
  17486. month = date.getMonth(),
  17487. day = date.getDate(),
  17488. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  17489. matches = pattern.exec( offset );
  17490. while ( matches ) {
  17491. switch ( matches[ 2 ] || "d" ) {
  17492. case "d" : case "D" :
  17493. day += parseInt( matches[ 1 ], 10 ); break;
  17494. case "w" : case "W" :
  17495. day += parseInt( matches[ 1 ], 10 ) * 7; break;
  17496. case "m" : case "M" :
  17497. month += parseInt( matches[ 1 ], 10 );
  17498. day = Math.min( day, $.datepicker._getDaysInMonth( year, month ) );
  17499. break;
  17500. case "y": case "Y" :
  17501. year += parseInt( matches[ 1 ], 10 );
  17502. day = Math.min( day, $.datepicker._getDaysInMonth( year, month ) );
  17503. break;
  17504. }
  17505. matches = pattern.exec( offset );
  17506. }
  17507. return new Date( year, month, day );
  17508. },
  17509. newDate = ( date == null || date === "" ? defaultDate : ( typeof date === "string" ? offsetString( date ) :
  17510. ( typeof date === "number" ? ( isNaN( date ) ? defaultDate : offsetNumeric( date ) ) : new Date( date.getTime() ) ) ) );
  17511. newDate = ( newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate );
  17512. if ( newDate ) {
  17513. newDate.setHours( 0 );
  17514. newDate.setMinutes( 0 );
  17515. newDate.setSeconds( 0 );
  17516. newDate.setMilliseconds( 0 );
  17517. }
  17518. return this._daylightSavingAdjust( newDate );
  17519. },
  17520. /* Handle switch to/from daylight saving.
  17521. * Hours may be non-zero on daylight saving cut-over:
  17522. * > 12 when midnight changeover, but then cannot generate
  17523. * midnight datetime, so jump to 1AM, otherwise reset.
  17524. * @param date (Date) the date to check
  17525. * @return (Date) the corrected date
  17526. */
  17527. _daylightSavingAdjust: function( date ) {
  17528. if ( !date ) {
  17529. return null;
  17530. }
  17531. date.setHours( date.getHours() > 12 ? date.getHours() + 2 : 0 );
  17532. return date;
  17533. },
  17534. /* Set the date(s) directly. */
  17535. _setDate: function( inst, date, noChange ) {
  17536. var clear = !date,
  17537. origMonth = inst.selectedMonth,
  17538. origYear = inst.selectedYear,
  17539. newDate = this._restrictMinMax( inst, this._determineDate( inst, date, new Date() ) );
  17540. inst.selectedDay = inst.currentDay = newDate.getDate();
  17541. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  17542. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  17543. if ( ( origMonth !== inst.selectedMonth || origYear !== inst.selectedYear ) && !noChange ) {
  17544. this._notifyChange( inst );
  17545. }
  17546. this._adjustInstDate( inst );
  17547. if ( inst.input ) {
  17548. inst.input.val( clear ? "" : this._formatDate( inst ) );
  17549. }
  17550. },
  17551. /* Retrieve the date(s) directly. */
  17552. _getDate: function( inst ) {
  17553. var startDate = ( !inst.currentYear || ( inst.input && inst.input.val() === "" ) ? null :
  17554. this._daylightSavingAdjust( new Date(
  17555. inst.currentYear, inst.currentMonth, inst.currentDay ) ) );
  17556. return startDate;
  17557. },
  17558. /* Attach the onxxx handlers. These are declared statically so
  17559. * they work with static code transformers like Caja.
  17560. */
  17561. _attachHandlers: function( inst ) {
  17562. var stepMonths = this._get( inst, "stepMonths" ),
  17563. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  17564. inst.dpDiv.find( "[data-handler]" ).map( function() {
  17565. var handler = {
  17566. prev: function() {
  17567. $.datepicker._adjustDate( id, -stepMonths, "M" );
  17568. },
  17569. next: function() {
  17570. $.datepicker._adjustDate( id, +stepMonths, "M" );
  17571. },
  17572. hide: function() {
  17573. $.datepicker._hideDatepicker();
  17574. },
  17575. today: function() {
  17576. $.datepicker._gotoToday( id );
  17577. },
  17578. selectDay: function() {
  17579. $.datepicker._selectDay( id, +this.getAttribute( "data-month" ), +this.getAttribute( "data-year" ), this );
  17580. return false;
  17581. },
  17582. selectMonth: function() {
  17583. $.datepicker._selectMonthYear( id, this, "M" );
  17584. return false;
  17585. },
  17586. selectYear: function() {
  17587. $.datepicker._selectMonthYear( id, this, "Y" );
  17588. return false;
  17589. }
  17590. };
  17591. $( this ).on( this.getAttribute( "data-event" ), handler[ this.getAttribute( "data-handler" ) ] );
  17592. } );
  17593. },
  17594. /* Generate the HTML for the current state of the date picker. */
  17595. _generateHTML: function( inst ) {
  17596. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  17597. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  17598. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  17599. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  17600. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  17601. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  17602. tempDate = new Date(),
  17603. today = this._daylightSavingAdjust(
  17604. new Date( tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate() ) ), // clear time
  17605. isRTL = this._get( inst, "isRTL" ),
  17606. showButtonPanel = this._get( inst, "showButtonPanel" ),
  17607. hideIfNoPrevNext = this._get( inst, "hideIfNoPrevNext" ),
  17608. navigationAsDateFormat = this._get( inst, "navigationAsDateFormat" ),
  17609. numMonths = this._getNumberOfMonths( inst ),
  17610. showCurrentAtPos = this._get( inst, "showCurrentAtPos" ),
  17611. stepMonths = this._get( inst, "stepMonths" ),
  17612. isMultiMonth = ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ),
  17613. currentDate = this._daylightSavingAdjust( ( !inst.currentDay ? new Date( 9999, 9, 9 ) :
  17614. new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) ),
  17615. minDate = this._getMinMaxDate( inst, "min" ),
  17616. maxDate = this._getMinMaxDate( inst, "max" ),
  17617. drawMonth = inst.drawMonth - showCurrentAtPos,
  17618. drawYear = inst.drawYear;
  17619. if ( drawMonth < 0 ) {
  17620. drawMonth += 12;
  17621. drawYear--;
  17622. }
  17623. if ( maxDate ) {
  17624. maxDraw = this._daylightSavingAdjust( new Date( maxDate.getFullYear(),
  17625. maxDate.getMonth() - ( numMonths[ 0 ] * numMonths[ 1 ] ) + 1, maxDate.getDate() ) );
  17626. maxDraw = ( minDate && maxDraw < minDate ? minDate : maxDraw );
  17627. while ( this._daylightSavingAdjust( new Date( drawYear, drawMonth, 1 ) ) > maxDraw ) {
  17628. drawMonth--;
  17629. if ( drawMonth < 0 ) {
  17630. drawMonth = 11;
  17631. drawYear--;
  17632. }
  17633. }
  17634. }
  17635. inst.drawMonth = drawMonth;
  17636. inst.drawYear = drawYear;
  17637. prevText = this._get( inst, "prevText" );
  17638. prevText = ( !navigationAsDateFormat ? prevText : this.formatDate( prevText,
  17639. this._daylightSavingAdjust( new Date( drawYear, drawMonth - stepMonths, 1 ) ),
  17640. this._getFormatConfig( inst ) ) );
  17641. prev = ( this._canAdjustMonth( inst, -1, drawYear, drawMonth ) ?
  17642. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  17643. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w" ) + "'>" + prevText + "</span></a>" :
  17644. ( hideIfNoPrevNext ? "" : "<a class='ui-datepicker-prev ui-corner-all ui-state-disabled' title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w" ) + "'>" + prevText + "</span></a>" ) );
  17645. nextText = this._get( inst, "nextText" );
  17646. nextText = ( !navigationAsDateFormat ? nextText : this.formatDate( nextText,
  17647. this._daylightSavingAdjust( new Date( drawYear, drawMonth + stepMonths, 1 ) ),
  17648. this._getFormatConfig( inst ) ) );
  17649. next = ( this._canAdjustMonth( inst, +1, drawYear, drawMonth ) ?
  17650. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  17651. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e" ) + "'>" + nextText + "</span></a>" :
  17652. ( hideIfNoPrevNext ? "" : "<a class='ui-datepicker-next ui-corner-all ui-state-disabled' title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e" ) + "'>" + nextText + "</span></a>" ) );
  17653. currentText = this._get( inst, "currentText" );
  17654. gotoDate = ( this._get( inst, "gotoCurrent" ) && inst.currentDay ? currentDate : today );
  17655. currentText = ( !navigationAsDateFormat ? currentText :
  17656. this.formatDate( currentText, gotoDate, this._getFormatConfig( inst ) ) );
  17657. controls = ( !inst.inline ? "<button type='button' class='ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all' data-handler='hide' data-event='click'>" +
  17658. this._get( inst, "closeText" ) + "</button>" : "" );
  17659. buttonPanel = ( showButtonPanel ) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + ( isRTL ? controls : "" ) +
  17660. ( this._isInRange( inst, gotoDate ) ? "<button type='button' class='ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all' data-handler='today' data-event='click'" +
  17661. ">" + currentText + "</button>" : "" ) + ( isRTL ? "" : controls ) + "</div>" : "";
  17662. firstDay = parseInt( this._get( inst, "firstDay" ), 10 );
  17663. firstDay = ( isNaN( firstDay ) ? 0 : firstDay );
  17664. showWeek = this._get( inst, "showWeek" );
  17665. dayNames = this._get( inst, "dayNames" );
  17666. dayNamesMin = this._get( inst, "dayNamesMin" );
  17667. monthNames = this._get( inst, "monthNames" );
  17668. monthNamesShort = this._get( inst, "monthNamesShort" );
  17669. beforeShowDay = this._get( inst, "beforeShowDay" );
  17670. showOtherMonths = this._get( inst, "showOtherMonths" );
  17671. selectOtherMonths = this._get( inst, "selectOtherMonths" );
  17672. defaultDate = this._getDefaultDate( inst );
  17673. html = "";
  17674. for ( row = 0; row < numMonths[ 0 ]; row++ ) {
  17675. group = "";
  17676. this.maxRows = 4;
  17677. for ( col = 0; col < numMonths[ 1 ]; col++ ) {
  17678. selectedDate = this._daylightSavingAdjust( new Date( drawYear, drawMonth, inst.selectedDay ) );
  17679. cornerClass = " ui-corner-all";
  17680. calender = "";
  17681. if ( isMultiMonth ) {
  17682. calender += "<div class='ui-datepicker-group";
  17683. if ( numMonths[ 1 ] > 1 ) {
  17684. switch ( col ) {
  17685. case 0: calender += " ui-datepicker-group-first";
  17686. cornerClass = " ui-corner-" + ( isRTL ? "right" : "left" ); break;
  17687. case numMonths[ 1 ] - 1: calender += " ui-datepicker-group-last";
  17688. cornerClass = " ui-corner-" + ( isRTL ? "left" : "right" ); break;
  17689. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  17690. }
  17691. }
  17692. calender += "'>";
  17693. }
  17694. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  17695. ( /all|left/.test( cornerClass ) && row === 0 ? ( isRTL ? next : prev ) : "" ) +
  17696. ( /all|right/.test( cornerClass ) && row === 0 ? ( isRTL ? prev : next ) : "" ) +
  17697. this._generateMonthYearHeader( inst, drawMonth, drawYear, minDate, maxDate,
  17698. row > 0 || col > 0, monthNames, monthNamesShort ) + // draw month headers
  17699. "</div><table class='ui-datepicker-calendar'><thead>" +
  17700. "<tr>";
  17701. thead = ( showWeek ? "<th class='ui-datepicker-week-col'>" + this._get( inst, "weekHeader" ) + "</th>" : "" );
  17702. for ( dow = 0; dow < 7; dow++ ) { // days of the week
  17703. day = ( dow + firstDay ) % 7;
  17704. thead += "<th scope='col'" + ( ( dow + firstDay + 6 ) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "" ) + ">" +
  17705. "<span title='" + dayNames[ day ] + "'>" + dayNamesMin[ day ] + "</span></th>";
  17706. }
  17707. calender += thead + "</tr></thead><tbody>";
  17708. daysInMonth = this._getDaysInMonth( drawYear, drawMonth );
  17709. if ( drawYear === inst.selectedYear && drawMonth === inst.selectedMonth ) {
  17710. inst.selectedDay = Math.min( inst.selectedDay, daysInMonth );
  17711. }
  17712. leadDays = ( this._getFirstDayOfMonth( drawYear, drawMonth ) - firstDay + 7 ) % 7;
  17713. curRows = Math.ceil( ( leadDays + daysInMonth ) / 7 ); // calculate the number of rows to generate
  17714. numRows = ( isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows ); //If multiple months, use the higher number of rows (see #7043)
  17715. this.maxRows = numRows;
  17716. printDate = this._daylightSavingAdjust( new Date( drawYear, drawMonth, 1 - leadDays ) );
  17717. for ( dRow = 0; dRow < numRows; dRow++ ) { // create date picker rows
  17718. calender += "<tr>";
  17719. tbody = ( !showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  17720. this._get( inst, "calculateWeek" )( printDate ) + "</td>" );
  17721. for ( dow = 0; dow < 7; dow++ ) { // create date picker days
  17722. daySettings = ( beforeShowDay ?
  17723. beforeShowDay.apply( ( inst.input ? inst.input[ 0 ] : null ), [ printDate ] ) : [ true, "" ] );
  17724. otherMonth = ( printDate.getMonth() !== drawMonth );
  17725. unselectable = ( otherMonth && !selectOtherMonths ) || !daySettings[ 0 ] ||
  17726. ( minDate && printDate < minDate ) || ( maxDate && printDate > maxDate );
  17727. tbody += "<td class='" +
  17728. ( ( dow + firstDay + 6 ) % 7 >= 5 ? " ui-datepicker-week-end" : "" ) + // highlight weekends
  17729. ( otherMonth ? " ui-datepicker-other-month" : "" ) + // highlight days from other months
  17730. ( ( printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent ) || // user pressed key
  17731. ( defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime() ) ?
  17732. // or defaultDate is current printedDate and defaultDate is selectedDate
  17733. " " + this._dayOverClass : "" ) + // highlight selected day
  17734. ( unselectable ? " " + this._unselectableClass + " ui-state-disabled" : "" ) + // highlight unselectable days
  17735. ( otherMonth && !showOtherMonths ? "" : " " + daySettings[ 1 ] + // highlight custom dates
  17736. ( printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "" ) + // highlight selected day
  17737. ( printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "" ) ) + "'" + // highlight today (if different)
  17738. ( ( !otherMonth || showOtherMonths ) && daySettings[ 2 ] ? " title='" + daySettings[ 2 ].replace( /'/g, "&#39;" ) + "'" : "" ) + // cell title
  17739. ( unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'" ) + ">" + // actions
  17740. ( otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  17741. ( unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  17742. ( printDate.getTime() === today.getTime() ? " ui-state-highlight" : "" ) +
  17743. ( printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "" ) + // highlight selected day
  17744. ( otherMonth ? " ui-priority-secondary" : "" ) + // distinguish dates from other months
  17745. "' href='#'>" + printDate.getDate() + "</a>" ) ) + "</td>"; // display selectable date
  17746. printDate.setDate( printDate.getDate() + 1 );
  17747. printDate = this._daylightSavingAdjust( printDate );
  17748. }
  17749. calender += tbody + "</tr>";
  17750. }
  17751. drawMonth++;
  17752. if ( drawMonth > 11 ) {
  17753. drawMonth = 0;
  17754. drawYear++;
  17755. }
  17756. calender += "</tbody></table>" + ( isMultiMonth ? "</div>" +
  17757. ( ( numMonths[ 0 ] > 0 && col === numMonths[ 1 ] - 1 ) ? "<div class='ui-datepicker-row-break'></div>" : "" ) : "" );
  17758. group += calender;
  17759. }
  17760. html += group;
  17761. }
  17762. html += buttonPanel;
  17763. inst._keyEvent = false;
  17764. return html;
  17765. },
  17766. /* Generate the month and year header. */
  17767. _generateMonthYearHeader: function( inst, drawMonth, drawYear, minDate, maxDate,
  17768. secondary, monthNames, monthNamesShort ) {
  17769. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  17770. changeMonth = this._get( inst, "changeMonth" ),
  17771. changeYear = this._get( inst, "changeYear" ),
  17772. showMonthAfterYear = this._get( inst, "showMonthAfterYear" ),
  17773. html = "<div class='ui-datepicker-title'>",
  17774. monthHtml = "";
  17775. // Month selection
  17776. if ( secondary || !changeMonth ) {
  17777. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[ drawMonth ] + "</span>";
  17778. } else {
  17779. inMinYear = ( minDate && minDate.getFullYear() === drawYear );
  17780. inMaxYear = ( maxDate && maxDate.getFullYear() === drawYear );
  17781. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  17782. for ( month = 0; month < 12; month++ ) {
  17783. if ( ( !inMinYear || month >= minDate.getMonth() ) && ( !inMaxYear || month <= maxDate.getMonth() ) ) {
  17784. monthHtml += "<option value='" + month + "'" +
  17785. ( month === drawMonth ? " selected='selected'" : "" ) +
  17786. ">" + monthNamesShort[ month ] + "</option>";
  17787. }
  17788. }
  17789. monthHtml += "</select>";
  17790. }
  17791. if ( !showMonthAfterYear ) {
  17792. html += monthHtml + ( secondary || !( changeMonth && changeYear ) ? "&#xa0;" : "" );
  17793. }
  17794. // Year selection
  17795. if ( !inst.yearshtml ) {
  17796. inst.yearshtml = "";
  17797. if ( secondary || !changeYear ) {
  17798. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  17799. } else {
  17800. // determine range of years to display
  17801. years = this._get( inst, "yearRange" ).split( ":" );
  17802. thisYear = new Date().getFullYear();
  17803. determineYear = function( value ) {
  17804. var year = ( value.match( /c[+\-].*/ ) ? drawYear + parseInt( value.substring( 1 ), 10 ) :
  17805. ( value.match( /[+\-].*/ ) ? thisYear + parseInt( value, 10 ) :
  17806. parseInt( value, 10 ) ) );
  17807. return ( isNaN( year ) ? thisYear : year );
  17808. };
  17809. year = determineYear( years[ 0 ] );
  17810. endYear = Math.max( year, determineYear( years[ 1 ] || "" ) );
  17811. year = ( minDate ? Math.max( year, minDate.getFullYear() ) : year );
  17812. endYear = ( maxDate ? Math.min( endYear, maxDate.getFullYear() ) : endYear );
  17813. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  17814. for ( ; year <= endYear; year++ ) {
  17815. inst.yearshtml += "<option value='" + year + "'" +
  17816. ( year === drawYear ? " selected='selected'" : "" ) +
  17817. ">" + year + "</option>";
  17818. }
  17819. inst.yearshtml += "</select>";
  17820. html += inst.yearshtml;
  17821. inst.yearshtml = null;
  17822. }
  17823. }
  17824. html += this._get( inst, "yearSuffix" );
  17825. if ( showMonthAfterYear ) {
  17826. html += ( secondary || !( changeMonth && changeYear ) ? "&#xa0;" : "" ) + monthHtml;
  17827. }
  17828. html += "</div>"; // Close datepicker_header
  17829. return html;
  17830. },
  17831. /* Adjust one of the date sub-fields. */
  17832. _adjustInstDate: function( inst, offset, period ) {
  17833. var year = inst.selectedYear + ( period === "Y" ? offset : 0 ),
  17834. month = inst.selectedMonth + ( period === "M" ? offset : 0 ),
  17835. day = Math.min( inst.selectedDay, this._getDaysInMonth( year, month ) ) + ( period === "D" ? offset : 0 ),
  17836. date = this._restrictMinMax( inst, this._daylightSavingAdjust( new Date( year, month, day ) ) );
  17837. inst.selectedDay = date.getDate();
  17838. inst.drawMonth = inst.selectedMonth = date.getMonth();
  17839. inst.drawYear = inst.selectedYear = date.getFullYear();
  17840. if ( period === "M" || period === "Y" ) {
  17841. this._notifyChange( inst );
  17842. }
  17843. },
  17844. /* Ensure a date is within any min/max bounds. */
  17845. _restrictMinMax: function( inst, date ) {
  17846. var minDate = this._getMinMaxDate( inst, "min" ),
  17847. maxDate = this._getMinMaxDate( inst, "max" ),
  17848. newDate = ( minDate && date < minDate ? minDate : date );
  17849. return ( maxDate && newDate > maxDate ? maxDate : newDate );
  17850. },
  17851. /* Notify change of month/year. */
  17852. _notifyChange: function( inst ) {
  17853. var onChange = this._get( inst, "onChangeMonthYear" );
  17854. if ( onChange ) {
  17855. onChange.apply( ( inst.input ? inst.input[ 0 ] : null ),
  17856. [ inst.selectedYear, inst.selectedMonth + 1, inst ] );
  17857. }
  17858. },
  17859. /* Determine the number of months to show. */
  17860. _getNumberOfMonths: function( inst ) {
  17861. var numMonths = this._get( inst, "numberOfMonths" );
  17862. return ( numMonths == null ? [ 1, 1 ] : ( typeof numMonths === "number" ? [ 1, numMonths ] : numMonths ) );
  17863. },
  17864. /* Determine the current maximum date - ensure no time components are set. */
  17865. _getMinMaxDate: function( inst, minMax ) {
  17866. return this._determineDate( inst, this._get( inst, minMax + "Date" ), null );
  17867. },
  17868. /* Find the number of days in a given month. */
  17869. _getDaysInMonth: function( year, month ) {
  17870. return 32 - this._daylightSavingAdjust( new Date( year, month, 32 ) ).getDate();
  17871. },
  17872. /* Find the day of the week of the first of a month. */
  17873. _getFirstDayOfMonth: function( year, month ) {
  17874. return new Date( year, month, 1 ).getDay();
  17875. },
  17876. /* Determines if we should allow a "next/prev" month display change. */
  17877. _canAdjustMonth: function( inst, offset, curYear, curMonth ) {
  17878. var numMonths = this._getNumberOfMonths( inst ),
  17879. date = this._daylightSavingAdjust( new Date( curYear,
  17880. curMonth + ( offset < 0 ? offset : numMonths[ 0 ] * numMonths[ 1 ] ), 1 ) );
  17881. if ( offset < 0 ) {
  17882. date.setDate( this._getDaysInMonth( date.getFullYear(), date.getMonth() ) );
  17883. }
  17884. return this._isInRange( inst, date );
  17885. },
  17886. /* Is the given date in the accepted range? */
  17887. _isInRange: function( inst, date ) {
  17888. var yearSplit, currentYear,
  17889. minDate = this._getMinMaxDate( inst, "min" ),
  17890. maxDate = this._getMinMaxDate( inst, "max" ),
  17891. minYear = null,
  17892. maxYear = null,
  17893. years = this._get( inst, "yearRange" );
  17894. if ( years ) {
  17895. yearSplit = years.split( ":" );
  17896. currentYear = new Date().getFullYear();
  17897. minYear = parseInt( yearSplit[ 0 ], 10 );
  17898. maxYear = parseInt( yearSplit[ 1 ], 10 );
  17899. if ( yearSplit[ 0 ].match( /[+\-].*/ ) ) {
  17900. minYear += currentYear;
  17901. }
  17902. if ( yearSplit[ 1 ].match( /[+\-].*/ ) ) {
  17903. maxYear += currentYear;
  17904. }
  17905. }
  17906. return ( ( !minDate || date.getTime() >= minDate.getTime() ) &&
  17907. ( !maxDate || date.getTime() <= maxDate.getTime() ) &&
  17908. ( !minYear || date.getFullYear() >= minYear ) &&
  17909. ( !maxYear || date.getFullYear() <= maxYear ) );
  17910. },
  17911. /* Provide the configuration settings for formatting/parsing. */
  17912. _getFormatConfig: function( inst ) {
  17913. var shortYearCutoff = this._get( inst, "shortYearCutoff" );
  17914. shortYearCutoff = ( typeof shortYearCutoff !== "string" ? shortYearCutoff :
  17915. new Date().getFullYear() % 100 + parseInt( shortYearCutoff, 10 ) );
  17916. return { shortYearCutoff: shortYearCutoff,
  17917. dayNamesShort: this._get( inst, "dayNamesShort" ), dayNames: this._get( inst, "dayNames" ),
  17918. monthNamesShort: this._get( inst, "monthNamesShort" ), monthNames: this._get( inst, "monthNames" ) };
  17919. },
  17920. /* Format the given date for display. */
  17921. _formatDate: function( inst, day, month, year ) {
  17922. if ( !day ) {
  17923. inst.currentDay = inst.selectedDay;
  17924. inst.currentMonth = inst.selectedMonth;
  17925. inst.currentYear = inst.selectedYear;
  17926. }
  17927. var date = ( day ? ( typeof day === "object" ? day :
  17928. this._daylightSavingAdjust( new Date( year, month, day ) ) ) :
  17929. this._daylightSavingAdjust( new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) );
  17930. return this.formatDate( this._get( inst, "dateFormat" ), date, this._getFormatConfig( inst ) );
  17931. }
  17932. } );
  17933. /*
  17934. * Bind hover events for datepicker elements.
  17935. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  17936. * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  17937. */
  17938. function datepicker_bindHover( dpDiv ) {
  17939. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  17940. return dpDiv.on( "mouseout", selector, function() {
  17941. $( this ).removeClass( "ui-state-hover" );
  17942. if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) {
  17943. $( this ).removeClass( "ui-datepicker-prev-hover" );
  17944. }
  17945. if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) {
  17946. $( this ).removeClass( "ui-datepicker-next-hover" );
  17947. }
  17948. } )
  17949. .on( "mouseover", selector, datepicker_handleMouseover );
  17950. }
  17951. function datepicker_handleMouseover() {
  17952. if ( !$.datepicker._isDisabledDatepicker( datepicker_instActive.inline ? datepicker_instActive.dpDiv.parent()[ 0 ] : datepicker_instActive.input[ 0 ] ) ) {
  17953. $( this ).parents( ".ui-datepicker-calendar" ).find( "a" ).removeClass( "ui-state-hover" );
  17954. $( this ).addClass( "ui-state-hover" );
  17955. if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) {
  17956. $( this ).addClass( "ui-datepicker-prev-hover" );
  17957. }
  17958. if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) {
  17959. $( this ).addClass( "ui-datepicker-next-hover" );
  17960. }
  17961. }
  17962. }
  17963. /* jQuery extend now ignores nulls! */
  17964. function datepicker_extendRemove( target, props ) {
  17965. $.extend( target, props );
  17966. for ( var name in props ) {
  17967. if ( props[ name ] == null ) {
  17968. target[ name ] = props[ name ];
  17969. }
  17970. }
  17971. return target;
  17972. }
  17973. /* Invoke the datepicker functionality.
  17974. @param options string - a command, optionally followed by additional parameters or
  17975. Object - settings for attaching new datepicker functionality
  17976. @return jQuery object */
  17977. $.fn.datepicker = function( options ) {
  17978. /* Verify an empty collection wasn't passed - Fixes #6976 */
  17979. if ( !this.length ) {
  17980. return this;
  17981. }
  17982. /* Initialise the date picker. */
  17983. if ( !$.datepicker.initialized ) {
  17984. $( document ).on( "mousedown", $.datepicker._checkExternalClick );
  17985. $.datepicker.initialized = true;
  17986. }
  17987. /* Append datepicker main container to body if not exist. */
  17988. if ( $( "#" + $.datepicker._mainDivId ).length === 0 ) {
  17989. $( "body" ).append( $.datepicker.dpDiv );
  17990. }
  17991. var otherArgs = Array.prototype.slice.call( arguments, 1 );
  17992. if ( typeof options === "string" && ( options === "isDisabled" || options === "getDate" || options === "widget" ) ) {
  17993. return $.datepicker[ "_" + options + "Datepicker" ].
  17994. apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) );
  17995. }
  17996. if ( options === "option" && arguments.length === 2 && typeof arguments[ 1 ] === "string" ) {
  17997. return $.datepicker[ "_" + options + "Datepicker" ].
  17998. apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) );
  17999. }
  18000. return this.each( function() {
  18001. typeof options === "string" ?
  18002. $.datepicker[ "_" + options + "Datepicker" ].
  18003. apply( $.datepicker, [ this ].concat( otherArgs ) ) :
  18004. $.datepicker._attachDatepicker( this, options );
  18005. } );
  18006. };
  18007. $.datepicker = new Datepicker(); // singleton instance
  18008. $.datepicker.initialized = false;
  18009. $.datepicker.uuid = new Date().getTime();
  18010. $.datepicker.version = "1.12.1";
  18011. var widgetsDatepicker = $.datepicker;
  18012. // This file is deprecated
  18013. var ie = $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  18014. /*!
  18015. * jQuery UI Mouse 1.12.1
  18016. * http://jqueryui.com
  18017. *
  18018. * Copyright jQuery Foundation and other contributors
  18019. * Released under the MIT license.
  18020. * http://jquery.org/license
  18021. */
  18022. //>>label: Mouse
  18023. //>>group: Widgets
  18024. //>>description: Abstracts mouse-based interactions to assist in creating certain widgets.
  18025. //>>docs: http://api.jqueryui.com/mouse/
  18026. var mouseHandled = false;
  18027. $( document ).on( "mouseup", function() {
  18028. mouseHandled = false;
  18029. } );
  18030. var widgetsMouse = $.widget( "ui.mouse", {
  18031. version: "1.12.1",
  18032. options: {
  18033. cancel: "input, textarea, button, select, option",
  18034. distance: 1,
  18035. delay: 0
  18036. },
  18037. _mouseInit: function() {
  18038. var that = this;
  18039. this.element
  18040. .on( "mousedown." + this.widgetName, function( event ) {
  18041. return that._mouseDown( event );
  18042. } )
  18043. .on( "click." + this.widgetName, function( event ) {
  18044. if ( true === $.data( event.target, that.widgetName + ".preventClickEvent" ) ) {
  18045. $.removeData( event.target, that.widgetName + ".preventClickEvent" );
  18046. event.stopImmediatePropagation();
  18047. return false;
  18048. }
  18049. } );
  18050. this.started = false;
  18051. },
  18052. // TODO: make sure destroying one instance of mouse doesn't mess with
  18053. // other instances of mouse
  18054. _mouseDestroy: function() {
  18055. this.element.off( "." + this.widgetName );
  18056. if ( this._mouseMoveDelegate ) {
  18057. this.document
  18058. .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  18059. .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
  18060. }
  18061. },
  18062. _mouseDown: function( event ) {
  18063. // don't let more than one widget handle mouseStart
  18064. if ( mouseHandled ) {
  18065. return;
  18066. }
  18067. this._mouseMoved = false;
  18068. // We may have missed mouseup (out of window)
  18069. ( this._mouseStarted && this._mouseUp( event ) );
  18070. this._mouseDownEvent = event;
  18071. var that = this,
  18072. btnIsLeft = ( event.which === 1 ),
  18073. // event.target.nodeName works around a bug in IE 8 with
  18074. // disabled inputs (#7620)
  18075. elIsCancel = ( typeof this.options.cancel === "string" && event.target.nodeName ?
  18076. $( event.target ).closest( this.options.cancel ).length : false );
  18077. if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) {
  18078. return true;
  18079. }
  18080. this.mouseDelayMet = !this.options.delay;
  18081. if ( !this.mouseDelayMet ) {
  18082. this._mouseDelayTimer = setTimeout( function() {
  18083. that.mouseDelayMet = true;
  18084. }, this.options.delay );
  18085. }
  18086. if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
  18087. this._mouseStarted = ( this._mouseStart( event ) !== false );
  18088. if ( !this._mouseStarted ) {
  18089. event.preventDefault();
  18090. return true;
  18091. }
  18092. }
  18093. // Click event may never have fired (Gecko & Opera)
  18094. if ( true === $.data( event.target, this.widgetName + ".preventClickEvent" ) ) {
  18095. $.removeData( event.target, this.widgetName + ".preventClickEvent" );
  18096. }
  18097. // These delegates are required to keep context
  18098. this._mouseMoveDelegate = function( event ) {
  18099. return that._mouseMove( event );
  18100. };
  18101. this._mouseUpDelegate = function( event ) {
  18102. return that._mouseUp( event );
  18103. };
  18104. this.document
  18105. .on( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  18106. .on( "mouseup." + this.widgetName, this._mouseUpDelegate );
  18107. event.preventDefault();
  18108. mouseHandled = true;
  18109. return true;
  18110. },
  18111. _mouseMove: function( event ) {
  18112. // Only check for mouseups outside the document if you've moved inside the document
  18113. // at least once. This prevents the firing of mouseup in the case of IE<9, which will
  18114. // fire a mousemove event if content is placed under the cursor. See #7778
  18115. // Support: IE <9
  18116. if ( this._mouseMoved ) {
  18117. // IE mouseup check - mouseup happened when mouse was out of window
  18118. if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) &&
  18119. !event.button ) {
  18120. return this._mouseUp( event );
  18121. // Iframe mouseup check - mouseup occurred in another document
  18122. } else if ( !event.which ) {
  18123. // Support: Safari <=8 - 9
  18124. // Safari sets which to 0 if you press any of the following keys
  18125. // during a drag (#14461)
  18126. if ( event.originalEvent.altKey || event.originalEvent.ctrlKey ||
  18127. event.originalEvent.metaKey || event.originalEvent.shiftKey ) {
  18128. this.ignoreMissingWhich = true;
  18129. } else if ( !this.ignoreMissingWhich ) {
  18130. return this._mouseUp( event );
  18131. }
  18132. }
  18133. }
  18134. if ( event.which || event.button ) {
  18135. this._mouseMoved = true;
  18136. }
  18137. if ( this._mouseStarted ) {
  18138. this._mouseDrag( event );
  18139. return event.preventDefault();
  18140. }
  18141. if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
  18142. this._mouseStarted =
  18143. ( this._mouseStart( this._mouseDownEvent, event ) !== false );
  18144. ( this._mouseStarted ? this._mouseDrag( event ) : this._mouseUp( event ) );
  18145. }
  18146. return !this._mouseStarted;
  18147. },
  18148. _mouseUp: function( event ) {
  18149. this.document
  18150. .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  18151. .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
  18152. if ( this._mouseStarted ) {
  18153. this._mouseStarted = false;
  18154. if ( event.target === this._mouseDownEvent.target ) {
  18155. $.data( event.target, this.widgetName + ".preventClickEvent", true );
  18156. }
  18157. this._mouseStop( event );
  18158. }
  18159. if ( this._mouseDelayTimer ) {
  18160. clearTimeout( this._mouseDelayTimer );
  18161. delete this._mouseDelayTimer;
  18162. }
  18163. this.ignoreMissingWhich = false;
  18164. mouseHandled = false;
  18165. event.preventDefault();
  18166. },
  18167. _mouseDistanceMet: function( event ) {
  18168. return ( Math.max(
  18169. Math.abs( this._mouseDownEvent.pageX - event.pageX ),
  18170. Math.abs( this._mouseDownEvent.pageY - event.pageY )
  18171. ) >= this.options.distance
  18172. );
  18173. },
  18174. _mouseDelayMet: function( /* event */ ) {
  18175. return this.mouseDelayMet;
  18176. },
  18177. // These are placeholder methods, to be overriden by extending plugin
  18178. _mouseStart: function( /* event */ ) {},
  18179. _mouseDrag: function( /* event */ ) {},
  18180. _mouseStop: function( /* event */ ) {},
  18181. _mouseCapture: function( /* event */ ) { return true; }
  18182. } );
  18183. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  18184. var plugin = $.ui.plugin = {
  18185. add: function( module, option, set ) {
  18186. var i,
  18187. proto = $.ui[ module ].prototype;
  18188. for ( i in set ) {
  18189. proto.plugins[ i ] = proto.plugins[ i ] || [];
  18190. proto.plugins[ i ].push( [ option, set[ i ] ] );
  18191. }
  18192. },
  18193. call: function( instance, name, args, allowDisconnected ) {
  18194. var i,
  18195. set = instance.plugins[ name ];
  18196. if ( !set ) {
  18197. return;
  18198. }
  18199. if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode ||
  18200. instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
  18201. return;
  18202. }
  18203. for ( i = 0; i < set.length; i++ ) {
  18204. if ( instance.options[ set[ i ][ 0 ] ] ) {
  18205. set[ i ][ 1 ].apply( instance.element, args );
  18206. }
  18207. }
  18208. }
  18209. };
  18210. var safeBlur = $.ui.safeBlur = function( element ) {
  18211. // Support: IE9 - 10 only
  18212. // If the <body> is blurred, IE will switch windows, see #9420
  18213. if ( element && element.nodeName.toLowerCase() !== "body" ) {
  18214. $( element ).trigger( "blur" );
  18215. }
  18216. };
  18217. /*!
  18218. * jQuery UI Draggable 1.12.1
  18219. * http://jqueryui.com
  18220. *
  18221. * Copyright jQuery Foundation and other contributors
  18222. * Released under the MIT license.
  18223. * http://jquery.org/license
  18224. */
  18225. //>>label: Draggable
  18226. //>>group: Interactions
  18227. //>>description: Enables dragging functionality for any element.
  18228. //>>docs: http://api.jqueryui.com/draggable/
  18229. //>>demos: http://jqueryui.com/draggable/
  18230. //>>css.structure: ../../themes/base/draggable.css
  18231. $.widget( "ui.draggable", $.ui.mouse, {
  18232. version: "1.12.1",
  18233. widgetEventPrefix: "drag",
  18234. options: {
  18235. addClasses: true,
  18236. appendTo: "parent",
  18237. axis: false,
  18238. connectToSortable: false,
  18239. containment: false,
  18240. cursor: "auto",
  18241. cursorAt: false,
  18242. grid: false,
  18243. handle: false,
  18244. helper: "original",
  18245. iframeFix: false,
  18246. opacity: false,
  18247. refreshPositions: false,
  18248. revert: false,
  18249. revertDuration: 500,
  18250. scope: "default",
  18251. scroll: true,
  18252. scrollSensitivity: 20,
  18253. scrollSpeed: 20,
  18254. snap: false,
  18255. snapMode: "both",
  18256. snapTolerance: 20,
  18257. stack: false,
  18258. zIndex: false,
  18259. // Callbacks
  18260. drag: null,
  18261. start: null,
  18262. stop: null
  18263. },
  18264. _create: function() {
  18265. if ( this.options.helper === "original" ) {
  18266. this._setPositionRelative();
  18267. }
  18268. if ( this.options.addClasses ) {
  18269. this._addClass( "ui-draggable" );
  18270. }
  18271. this._setHandleClassName();
  18272. this._mouseInit();
  18273. },
  18274. _setOption: function( key, value ) {
  18275. this._super( key, value );
  18276. if ( key === "handle" ) {
  18277. this._removeHandleClassName();
  18278. this._setHandleClassName();
  18279. }
  18280. },
  18281. _destroy: function() {
  18282. if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
  18283. this.destroyOnClear = true;
  18284. return;
  18285. }
  18286. this._removeHandleClassName();
  18287. this._mouseDestroy();
  18288. },
  18289. _mouseCapture: function( event ) {
  18290. var o = this.options;
  18291. // Among others, prevent a drag on a resizable-handle
  18292. if ( this.helper || o.disabled ||
  18293. $( event.target ).closest( ".ui-resizable-handle" ).length > 0 ) {
  18294. return false;
  18295. }
  18296. //Quit if we're not on a valid handle
  18297. this.handle = this._getHandle( event );
  18298. if ( !this.handle ) {
  18299. return false;
  18300. }
  18301. this._blurActiveElement( event );
  18302. this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix );
  18303. return true;
  18304. },
  18305. _blockFrames: function( selector ) {
  18306. this.iframeBlocks = this.document.find( selector ).map( function() {
  18307. var iframe = $( this );
  18308. return $( "<div>" )
  18309. .css( "position", "absolute" )
  18310. .appendTo( iframe.parent() )
  18311. .outerWidth( iframe.outerWidth() )
  18312. .outerHeight( iframe.outerHeight() )
  18313. .offset( iframe.offset() )[ 0 ];
  18314. } );
  18315. },
  18316. _unblockFrames: function() {
  18317. if ( this.iframeBlocks ) {
  18318. this.iframeBlocks.remove();
  18319. delete this.iframeBlocks;
  18320. }
  18321. },
  18322. _blurActiveElement: function( event ) {
  18323. var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ),
  18324. target = $( event.target );
  18325. // Don't blur if the event occurred on an element that is within
  18326. // the currently focused element
  18327. // See #10527, #12472
  18328. if ( target.closest( activeElement ).length ) {
  18329. return;
  18330. }
  18331. // Blur any element that currently has focus, see #4261
  18332. $.ui.safeBlur( activeElement );
  18333. },
  18334. _mouseStart: function( event ) {
  18335. var o = this.options;
  18336. //Create and append the visible helper
  18337. this.helper = this._createHelper( event );
  18338. this._addClass( this.helper, "ui-draggable-dragging" );
  18339. //Cache the helper size
  18340. this._cacheHelperProportions();
  18341. //If ddmanager is used for droppables, set the global draggable
  18342. if ( $.ui.ddmanager ) {
  18343. $.ui.ddmanager.current = this;
  18344. }
  18345. /*
  18346. * - Position generation -
  18347. * This block generates everything position related - it's the core of draggables.
  18348. */
  18349. //Cache the margins of the original element
  18350. this._cacheMargins();
  18351. //Store the helper's css position
  18352. this.cssPosition = this.helper.css( "position" );
  18353. this.scrollParent = this.helper.scrollParent( true );
  18354. this.offsetParent = this.helper.offsetParent();
  18355. this.hasFixedAncestor = this.helper.parents().filter( function() {
  18356. return $( this ).css( "position" ) === "fixed";
  18357. } ).length > 0;
  18358. //The element's absolute position on the page minus margins
  18359. this.positionAbs = this.element.offset();
  18360. this._refreshOffsets( event );
  18361. //Generate the original position
  18362. this.originalPosition = this.position = this._generatePosition( event, false );
  18363. this.originalPageX = event.pageX;
  18364. this.originalPageY = event.pageY;
  18365. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  18366. ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) );
  18367. //Set a containment if given in the options
  18368. this._setContainment();
  18369. //Trigger event + callbacks
  18370. if ( this._trigger( "start", event ) === false ) {
  18371. this._clear();
  18372. return false;
  18373. }
  18374. //Recache the helper size
  18375. this._cacheHelperProportions();
  18376. //Prepare the droppable offsets
  18377. if ( $.ui.ddmanager && !o.dropBehaviour ) {
  18378. $.ui.ddmanager.prepareOffsets( this, event );
  18379. }
  18380. // Execute the drag once - this causes the helper not to be visible before getting its
  18381. // correct position
  18382. this._mouseDrag( event, true );
  18383. // If the ddmanager is used for droppables, inform the manager that dragging has started
  18384. // (see #5003)
  18385. if ( $.ui.ddmanager ) {
  18386. $.ui.ddmanager.dragStart( this, event );
  18387. }
  18388. return true;
  18389. },
  18390. _refreshOffsets: function( event ) {
  18391. this.offset = {
  18392. top: this.positionAbs.top - this.margins.top,
  18393. left: this.positionAbs.left - this.margins.left,
  18394. scroll: false,
  18395. parent: this._getParentOffset(),
  18396. relative: this._getRelativeOffset()
  18397. };
  18398. this.offset.click = {
  18399. left: event.pageX - this.offset.left,
  18400. top: event.pageY - this.offset.top
  18401. };
  18402. },
  18403. _mouseDrag: function( event, noPropagation ) {
  18404. // reset any necessary cached properties (see #5009)
  18405. if ( this.hasFixedAncestor ) {
  18406. this.offset.parent = this._getParentOffset();
  18407. }
  18408. //Compute the helpers position
  18409. this.position = this._generatePosition( event, true );
  18410. this.positionAbs = this._convertPositionTo( "absolute" );
  18411. //Call plugins and callbacks and use the resulting position if something is returned
  18412. if ( !noPropagation ) {
  18413. var ui = this._uiHash();
  18414. if ( this._trigger( "drag", event, ui ) === false ) {
  18415. this._mouseUp( new $.Event( "mouseup", event ) );
  18416. return false;
  18417. }
  18418. this.position = ui.position;
  18419. }
  18420. this.helper[ 0 ].style.left = this.position.left + "px";
  18421. this.helper[ 0 ].style.top = this.position.top + "px";
  18422. if ( $.ui.ddmanager ) {
  18423. $.ui.ddmanager.drag( this, event );
  18424. }
  18425. return false;
  18426. },
  18427. _mouseStop: function( event ) {
  18428. //If we are using droppables, inform the manager about the drop
  18429. var that = this,
  18430. dropped = false;
  18431. if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
  18432. dropped = $.ui.ddmanager.drop( this, event );
  18433. }
  18434. //if a drop comes from outside (a sortable)
  18435. if ( this.dropped ) {
  18436. dropped = this.dropped;
  18437. this.dropped = false;
  18438. }
  18439. if ( ( this.options.revert === "invalid" && !dropped ) ||
  18440. ( this.options.revert === "valid" && dropped ) ||
  18441. this.options.revert === true || ( $.isFunction( this.options.revert ) &&
  18442. this.options.revert.call( this.element, dropped ) )
  18443. ) {
  18444. $( this.helper ).animate(
  18445. this.originalPosition,
  18446. parseInt( this.options.revertDuration, 10 ),
  18447. function() {
  18448. if ( that._trigger( "stop", event ) !== false ) {
  18449. that._clear();
  18450. }
  18451. }
  18452. );
  18453. } else {
  18454. if ( this._trigger( "stop", event ) !== false ) {
  18455. this._clear();
  18456. }
  18457. }
  18458. return false;
  18459. },
  18460. _mouseUp: function( event ) {
  18461. this._unblockFrames();
  18462. // If the ddmanager is used for droppables, inform the manager that dragging has stopped
  18463. // (see #5003)
  18464. if ( $.ui.ddmanager ) {
  18465. $.ui.ddmanager.dragStop( this, event );
  18466. }
  18467. // Only need to focus if the event occurred on the draggable itself, see #10527
  18468. if ( this.handleElement.is( event.target ) ) {
  18469. // The interaction is over; whether or not the click resulted in a drag,
  18470. // focus the element
  18471. this.element.trigger( "focus" );
  18472. }
  18473. return $.ui.mouse.prototype._mouseUp.call( this, event );
  18474. },
  18475. cancel: function() {
  18476. if ( this.helper.is( ".ui-draggable-dragging" ) ) {
  18477. this._mouseUp( new $.Event( "mouseup", { target: this.element[ 0 ] } ) );
  18478. } else {
  18479. this._clear();
  18480. }
  18481. return this;
  18482. },
  18483. _getHandle: function( event ) {
  18484. return this.options.handle ?
  18485. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  18486. true;
  18487. },
  18488. _setHandleClassName: function() {
  18489. this.handleElement = this.options.handle ?
  18490. this.element.find( this.options.handle ) : this.element;
  18491. this._addClass( this.handleElement, "ui-draggable-handle" );
  18492. },
  18493. _removeHandleClassName: function() {
  18494. this._removeClass( this.handleElement, "ui-draggable-handle" );
  18495. },
  18496. _createHelper: function( event ) {
  18497. var o = this.options,
  18498. helperIsFunction = $.isFunction( o.helper ),
  18499. helper = helperIsFunction ?
  18500. $( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
  18501. ( o.helper === "clone" ?
  18502. this.element.clone().removeAttr( "id" ) :
  18503. this.element );
  18504. if ( !helper.parents( "body" ).length ) {
  18505. helper.appendTo( ( o.appendTo === "parent" ?
  18506. this.element[ 0 ].parentNode :
  18507. o.appendTo ) );
  18508. }
  18509. // Http://bugs.jqueryui.com/ticket/9446
  18510. // a helper function can return the original element
  18511. // which wouldn't have been set to relative in _create
  18512. if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
  18513. this._setPositionRelative();
  18514. }
  18515. if ( helper[ 0 ] !== this.element[ 0 ] &&
  18516. !( /(fixed|absolute)/ ).test( helper.css( "position" ) ) ) {
  18517. helper.css( "position", "absolute" );
  18518. }
  18519. return helper;
  18520. },
  18521. _setPositionRelative: function() {
  18522. if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) {
  18523. this.element[ 0 ].style.position = "relative";
  18524. }
  18525. },
  18526. _adjustOffsetFromHelper: function( obj ) {
  18527. if ( typeof obj === "string" ) {
  18528. obj = obj.split( " " );
  18529. }
  18530. if ( $.isArray( obj ) ) {
  18531. obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
  18532. }
  18533. if ( "left" in obj ) {
  18534. this.offset.click.left = obj.left + this.margins.left;
  18535. }
  18536. if ( "right" in obj ) {
  18537. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  18538. }
  18539. if ( "top" in obj ) {
  18540. this.offset.click.top = obj.top + this.margins.top;
  18541. }
  18542. if ( "bottom" in obj ) {
  18543. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  18544. }
  18545. },
  18546. _isRootNode: function( element ) {
  18547. return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
  18548. },
  18549. _getParentOffset: function() {
  18550. //Get the offsetParent and cache its position
  18551. var po = this.offsetParent.offset(),
  18552. document = this.document[ 0 ];
  18553. // This is a special case where we need to modify a offset calculated on start, since the
  18554. // following happened:
  18555. // 1. The position of the helper is absolute, so it's position is calculated based on the
  18556. // next positioned parent
  18557. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
  18558. // the document, which means that the scroll is included in the initial calculation of the
  18559. // offset of the parent, and never recalculated upon drag
  18560. if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== document &&
  18561. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
  18562. po.left += this.scrollParent.scrollLeft();
  18563. po.top += this.scrollParent.scrollTop();
  18564. }
  18565. if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
  18566. po = { top: 0, left: 0 };
  18567. }
  18568. return {
  18569. top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
  18570. left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
  18571. };
  18572. },
  18573. _getRelativeOffset: function() {
  18574. if ( this.cssPosition !== "relative" ) {
  18575. return { top: 0, left: 0 };
  18576. }
  18577. var p = this.element.position(),
  18578. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  18579. return {
  18580. top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
  18581. ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
  18582. left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
  18583. ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
  18584. };
  18585. },
  18586. _cacheMargins: function() {
  18587. this.margins = {
  18588. left: ( parseInt( this.element.css( "marginLeft" ), 10 ) || 0 ),
  18589. top: ( parseInt( this.element.css( "marginTop" ), 10 ) || 0 ),
  18590. right: ( parseInt( this.element.css( "marginRight" ), 10 ) || 0 ),
  18591. bottom: ( parseInt( this.element.css( "marginBottom" ), 10 ) || 0 )
  18592. };
  18593. },
  18594. _cacheHelperProportions: function() {
  18595. this.helperProportions = {
  18596. width: this.helper.outerWidth(),
  18597. height: this.helper.outerHeight()
  18598. };
  18599. },
  18600. _setContainment: function() {
  18601. var isUserScrollable, c, ce,
  18602. o = this.options,
  18603. document = this.document[ 0 ];
  18604. this.relativeContainer = null;
  18605. if ( !o.containment ) {
  18606. this.containment = null;
  18607. return;
  18608. }
  18609. if ( o.containment === "window" ) {
  18610. this.containment = [
  18611. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  18612. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  18613. $( window ).scrollLeft() + $( window ).width() -
  18614. this.helperProportions.width - this.margins.left,
  18615. $( window ).scrollTop() +
  18616. ( $( window ).height() || document.body.parentNode.scrollHeight ) -
  18617. this.helperProportions.height - this.margins.top
  18618. ];
  18619. return;
  18620. }
  18621. if ( o.containment === "document" ) {
  18622. this.containment = [
  18623. 0,
  18624. 0,
  18625. $( document ).width() - this.helperProportions.width - this.margins.left,
  18626. ( $( document ).height() || document.body.parentNode.scrollHeight ) -
  18627. this.helperProportions.height - this.margins.top
  18628. ];
  18629. return;
  18630. }
  18631. if ( o.containment.constructor === Array ) {
  18632. this.containment = o.containment;
  18633. return;
  18634. }
  18635. if ( o.containment === "parent" ) {
  18636. o.containment = this.helper[ 0 ].parentNode;
  18637. }
  18638. c = $( o.containment );
  18639. ce = c[ 0 ];
  18640. if ( !ce ) {
  18641. return;
  18642. }
  18643. isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) );
  18644. this.containment = [
  18645. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) +
  18646. ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  18647. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) +
  18648. ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
  18649. ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  18650. ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) -
  18651. ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) -
  18652. this.helperProportions.width -
  18653. this.margins.left -
  18654. this.margins.right,
  18655. ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  18656. ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) -
  18657. ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) -
  18658. this.helperProportions.height -
  18659. this.margins.top -
  18660. this.margins.bottom
  18661. ];
  18662. this.relativeContainer = c;
  18663. },
  18664. _convertPositionTo: function( d, pos ) {
  18665. if ( !pos ) {
  18666. pos = this.position;
  18667. }
  18668. var mod = d === "absolute" ? 1 : -1,
  18669. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  18670. return {
  18671. top: (
  18672. // The absolute mouse position
  18673. pos.top +
  18674. // Only for relative positioned nodes: Relative offset from element to offset parent
  18675. this.offset.relative.top * mod +
  18676. // The offsetParent's offset without borders (offset + border)
  18677. this.offset.parent.top * mod -
  18678. ( ( this.cssPosition === "fixed" ?
  18679. -this.offset.scroll.top :
  18680. ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod )
  18681. ),
  18682. left: (
  18683. // The absolute mouse position
  18684. pos.left +
  18685. // Only for relative positioned nodes: Relative offset from element to offset parent
  18686. this.offset.relative.left * mod +
  18687. // The offsetParent's offset without borders (offset + border)
  18688. this.offset.parent.left * mod -
  18689. ( ( this.cssPosition === "fixed" ?
  18690. -this.offset.scroll.left :
  18691. ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod )
  18692. )
  18693. };
  18694. },
  18695. _generatePosition: function( event, constrainPosition ) {
  18696. var containment, co, top, left,
  18697. o = this.options,
  18698. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
  18699. pageX = event.pageX,
  18700. pageY = event.pageY;
  18701. // Cache the scroll
  18702. if ( !scrollIsRootNode || !this.offset.scroll ) {
  18703. this.offset.scroll = {
  18704. top: this.scrollParent.scrollTop(),
  18705. left: this.scrollParent.scrollLeft()
  18706. };
  18707. }
  18708. /*
  18709. * - Position constraining -
  18710. * Constrain the position to a mix of grid, containment.
  18711. */
  18712. // If we are not dragging yet, we won't check for options
  18713. if ( constrainPosition ) {
  18714. if ( this.containment ) {
  18715. if ( this.relativeContainer ) {
  18716. co = this.relativeContainer.offset();
  18717. containment = [
  18718. this.containment[ 0 ] + co.left,
  18719. this.containment[ 1 ] + co.top,
  18720. this.containment[ 2 ] + co.left,
  18721. this.containment[ 3 ] + co.top
  18722. ];
  18723. } else {
  18724. containment = this.containment;
  18725. }
  18726. if ( event.pageX - this.offset.click.left < containment[ 0 ] ) {
  18727. pageX = containment[ 0 ] + this.offset.click.left;
  18728. }
  18729. if ( event.pageY - this.offset.click.top < containment[ 1 ] ) {
  18730. pageY = containment[ 1 ] + this.offset.click.top;
  18731. }
  18732. if ( event.pageX - this.offset.click.left > containment[ 2 ] ) {
  18733. pageX = containment[ 2 ] + this.offset.click.left;
  18734. }
  18735. if ( event.pageY - this.offset.click.top > containment[ 3 ] ) {
  18736. pageY = containment[ 3 ] + this.offset.click.top;
  18737. }
  18738. }
  18739. if ( o.grid ) {
  18740. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid
  18741. // argument errors in IE (see ticket #6950)
  18742. top = o.grid[ 1 ] ? this.originalPageY + Math.round( ( pageY -
  18743. this.originalPageY ) / o.grid[ 1 ] ) * o.grid[ 1 ] : this.originalPageY;
  18744. pageY = containment ? ( ( top - this.offset.click.top >= containment[ 1 ] ||
  18745. top - this.offset.click.top > containment[ 3 ] ) ?
  18746. top :
  18747. ( ( top - this.offset.click.top >= containment[ 1 ] ) ?
  18748. top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : top;
  18749. left = o.grid[ 0 ] ? this.originalPageX +
  18750. Math.round( ( pageX - this.originalPageX ) / o.grid[ 0 ] ) * o.grid[ 0 ] :
  18751. this.originalPageX;
  18752. pageX = containment ? ( ( left - this.offset.click.left >= containment[ 0 ] ||
  18753. left - this.offset.click.left > containment[ 2 ] ) ?
  18754. left :
  18755. ( ( left - this.offset.click.left >= containment[ 0 ] ) ?
  18756. left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : left;
  18757. }
  18758. if ( o.axis === "y" ) {
  18759. pageX = this.originalPageX;
  18760. }
  18761. if ( o.axis === "x" ) {
  18762. pageY = this.originalPageY;
  18763. }
  18764. }
  18765. return {
  18766. top: (
  18767. // The absolute mouse position
  18768. pageY -
  18769. // Click offset (relative to the element)
  18770. this.offset.click.top -
  18771. // Only for relative positioned nodes: Relative offset from element to offset parent
  18772. this.offset.relative.top -
  18773. // The offsetParent's offset without borders (offset + border)
  18774. this.offset.parent.top +
  18775. ( this.cssPosition === "fixed" ?
  18776. -this.offset.scroll.top :
  18777. ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
  18778. ),
  18779. left: (
  18780. // The absolute mouse position
  18781. pageX -
  18782. // Click offset (relative to the element)
  18783. this.offset.click.left -
  18784. // Only for relative positioned nodes: Relative offset from element to offset parent
  18785. this.offset.relative.left -
  18786. // The offsetParent's offset without borders (offset + border)
  18787. this.offset.parent.left +
  18788. ( this.cssPosition === "fixed" ?
  18789. -this.offset.scroll.left :
  18790. ( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
  18791. )
  18792. };
  18793. },
  18794. _clear: function() {
  18795. this._removeClass( this.helper, "ui-draggable-dragging" );
  18796. if ( this.helper[ 0 ] !== this.element[ 0 ] && !this.cancelHelperRemoval ) {
  18797. this.helper.remove();
  18798. }
  18799. this.helper = null;
  18800. this.cancelHelperRemoval = false;
  18801. if ( this.destroyOnClear ) {
  18802. this.destroy();
  18803. }
  18804. },
  18805. // From now on bulk stuff - mainly helpers
  18806. _trigger: function( type, event, ui ) {
  18807. ui = ui || this._uiHash();
  18808. $.ui.plugin.call( this, type, [ event, ui, this ], true );
  18809. // Absolute position and offset (see #6884 ) have to be recalculated after plugins
  18810. if ( /^(drag|start|stop)/.test( type ) ) {
  18811. this.positionAbs = this._convertPositionTo( "absolute" );
  18812. ui.offset = this.positionAbs;
  18813. }
  18814. return $.Widget.prototype._trigger.call( this, type, event, ui );
  18815. },
  18816. plugins: {},
  18817. _uiHash: function() {
  18818. return {
  18819. helper: this.helper,
  18820. position: this.position,
  18821. originalPosition: this.originalPosition,
  18822. offset: this.positionAbs
  18823. };
  18824. }
  18825. } );
  18826. $.ui.plugin.add( "draggable", "connectToSortable", {
  18827. start: function( event, ui, draggable ) {
  18828. var uiSortable = $.extend( {}, ui, {
  18829. item: draggable.element
  18830. } );
  18831. draggable.sortables = [];
  18832. $( draggable.options.connectToSortable ).each( function() {
  18833. var sortable = $( this ).sortable( "instance" );
  18834. if ( sortable && !sortable.options.disabled ) {
  18835. draggable.sortables.push( sortable );
  18836. // RefreshPositions is called at drag start to refresh the containerCache
  18837. // which is used in drag. This ensures it's initialized and synchronized
  18838. // with any changes that might have happened on the page since initialization.
  18839. sortable.refreshPositions();
  18840. sortable._trigger( "activate", event, uiSortable );
  18841. }
  18842. } );
  18843. },
  18844. stop: function( event, ui, draggable ) {
  18845. var uiSortable = $.extend( {}, ui, {
  18846. item: draggable.element
  18847. } );
  18848. draggable.cancelHelperRemoval = false;
  18849. $.each( draggable.sortables, function() {
  18850. var sortable = this;
  18851. if ( sortable.isOver ) {
  18852. sortable.isOver = 0;
  18853. // Allow this sortable to handle removing the helper
  18854. draggable.cancelHelperRemoval = true;
  18855. sortable.cancelHelperRemoval = false;
  18856. // Use _storedCSS To restore properties in the sortable,
  18857. // as this also handles revert (#9675) since the draggable
  18858. // may have modified them in unexpected ways (#8809)
  18859. sortable._storedCSS = {
  18860. position: sortable.placeholder.css( "position" ),
  18861. top: sortable.placeholder.css( "top" ),
  18862. left: sortable.placeholder.css( "left" )
  18863. };
  18864. sortable._mouseStop( event );
  18865. // Once drag has ended, the sortable should return to using
  18866. // its original helper, not the shared helper from draggable
  18867. sortable.options.helper = sortable.options._helper;
  18868. } else {
  18869. // Prevent this Sortable from removing the helper.
  18870. // However, don't set the draggable to remove the helper
  18871. // either as another connected Sortable may yet handle the removal.
  18872. sortable.cancelHelperRemoval = true;
  18873. sortable._trigger( "deactivate", event, uiSortable );
  18874. }
  18875. } );
  18876. },
  18877. drag: function( event, ui, draggable ) {
  18878. $.each( draggable.sortables, function() {
  18879. var innermostIntersecting = false,
  18880. sortable = this;
  18881. // Copy over variables that sortable's _intersectsWith uses
  18882. sortable.positionAbs = draggable.positionAbs;
  18883. sortable.helperProportions = draggable.helperProportions;
  18884. sortable.offset.click = draggable.offset.click;
  18885. if ( sortable._intersectsWith( sortable.containerCache ) ) {
  18886. innermostIntersecting = true;
  18887. $.each( draggable.sortables, function() {
  18888. // Copy over variables that sortable's _intersectsWith uses
  18889. this.positionAbs = draggable.positionAbs;
  18890. this.helperProportions = draggable.helperProportions;
  18891. this.offset.click = draggable.offset.click;
  18892. if ( this !== sortable &&
  18893. this._intersectsWith( this.containerCache ) &&
  18894. $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) {
  18895. innermostIntersecting = false;
  18896. }
  18897. return innermostIntersecting;
  18898. } );
  18899. }
  18900. if ( innermostIntersecting ) {
  18901. // If it intersects, we use a little isOver variable and set it once,
  18902. // so that the move-in stuff gets fired only once.
  18903. if ( !sortable.isOver ) {
  18904. sortable.isOver = 1;
  18905. // Store draggable's parent in case we need to reappend to it later.
  18906. draggable._parent = ui.helper.parent();
  18907. sortable.currentItem = ui.helper
  18908. .appendTo( sortable.element )
  18909. .data( "ui-sortable-item", true );
  18910. // Store helper option to later restore it
  18911. sortable.options._helper = sortable.options.helper;
  18912. sortable.options.helper = function() {
  18913. return ui.helper[ 0 ];
  18914. };
  18915. // Fire the start events of the sortable with our passed browser event,
  18916. // and our own helper (so it doesn't create a new one)
  18917. event.target = sortable.currentItem[ 0 ];
  18918. sortable._mouseCapture( event, true );
  18919. sortable._mouseStart( event, true, true );
  18920. // Because the browser event is way off the new appended portlet,
  18921. // modify necessary variables to reflect the changes
  18922. sortable.offset.click.top = draggable.offset.click.top;
  18923. sortable.offset.click.left = draggable.offset.click.left;
  18924. sortable.offset.parent.left -= draggable.offset.parent.left -
  18925. sortable.offset.parent.left;
  18926. sortable.offset.parent.top -= draggable.offset.parent.top -
  18927. sortable.offset.parent.top;
  18928. draggable._trigger( "toSortable", event );
  18929. // Inform draggable that the helper is in a valid drop zone,
  18930. // used solely in the revert option to handle "valid/invalid".
  18931. draggable.dropped = sortable.element;
  18932. // Need to refreshPositions of all sortables in the case that
  18933. // adding to one sortable changes the location of the other sortables (#9675)
  18934. $.each( draggable.sortables, function() {
  18935. this.refreshPositions();
  18936. } );
  18937. // Hack so receive/update callbacks work (mostly)
  18938. draggable.currentItem = draggable.element;
  18939. sortable.fromOutside = draggable;
  18940. }
  18941. if ( sortable.currentItem ) {
  18942. sortable._mouseDrag( event );
  18943. // Copy the sortable's position because the draggable's can potentially reflect
  18944. // a relative position, while sortable is always absolute, which the dragged
  18945. // element has now become. (#8809)
  18946. ui.position = sortable.position;
  18947. }
  18948. } else {
  18949. // If it doesn't intersect with the sortable, and it intersected before,
  18950. // we fake the drag stop of the sortable, but make sure it doesn't remove
  18951. // the helper by using cancelHelperRemoval.
  18952. if ( sortable.isOver ) {
  18953. sortable.isOver = 0;
  18954. sortable.cancelHelperRemoval = true;
  18955. // Calling sortable's mouseStop would trigger a revert,
  18956. // so revert must be temporarily false until after mouseStop is called.
  18957. sortable.options._revert = sortable.options.revert;
  18958. sortable.options.revert = false;
  18959. sortable._trigger( "out", event, sortable._uiHash( sortable ) );
  18960. sortable._mouseStop( event, true );
  18961. // Restore sortable behaviors that were modfied
  18962. // when the draggable entered the sortable area (#9481)
  18963. sortable.options.revert = sortable.options._revert;
  18964. sortable.options.helper = sortable.options._helper;
  18965. if ( sortable.placeholder ) {
  18966. sortable.placeholder.remove();
  18967. }
  18968. // Restore and recalculate the draggable's offset considering the sortable
  18969. // may have modified them in unexpected ways. (#8809, #10669)
  18970. ui.helper.appendTo( draggable._parent );
  18971. draggable._refreshOffsets( event );
  18972. ui.position = draggable._generatePosition( event, true );
  18973. draggable._trigger( "fromSortable", event );
  18974. // Inform draggable that the helper is no longer in a valid drop zone
  18975. draggable.dropped = false;
  18976. // Need to refreshPositions of all sortables just in case removing
  18977. // from one sortable changes the location of other sortables (#9675)
  18978. $.each( draggable.sortables, function() {
  18979. this.refreshPositions();
  18980. } );
  18981. }
  18982. }
  18983. } );
  18984. }
  18985. } );
  18986. $.ui.plugin.add( "draggable", "cursor", {
  18987. start: function( event, ui, instance ) {
  18988. var t = $( "body" ),
  18989. o = instance.options;
  18990. if ( t.css( "cursor" ) ) {
  18991. o._cursor = t.css( "cursor" );
  18992. }
  18993. t.css( "cursor", o.cursor );
  18994. },
  18995. stop: function( event, ui, instance ) {
  18996. var o = instance.options;
  18997. if ( o._cursor ) {
  18998. $( "body" ).css( "cursor", o._cursor );
  18999. }
  19000. }
  19001. } );
  19002. $.ui.plugin.add( "draggable", "opacity", {
  19003. start: function( event, ui, instance ) {
  19004. var t = $( ui.helper ),
  19005. o = instance.options;
  19006. if ( t.css( "opacity" ) ) {
  19007. o._opacity = t.css( "opacity" );
  19008. }
  19009. t.css( "opacity", o.opacity );
  19010. },
  19011. stop: function( event, ui, instance ) {
  19012. var o = instance.options;
  19013. if ( o._opacity ) {
  19014. $( ui.helper ).css( "opacity", o._opacity );
  19015. }
  19016. }
  19017. } );
  19018. $.ui.plugin.add( "draggable", "scroll", {
  19019. start: function( event, ui, i ) {
  19020. if ( !i.scrollParentNotHidden ) {
  19021. i.scrollParentNotHidden = i.helper.scrollParent( false );
  19022. }
  19023. if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] &&
  19024. i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
  19025. i.overflowOffset = i.scrollParentNotHidden.offset();
  19026. }
  19027. },
  19028. drag: function( event, ui, i ) {
  19029. var o = i.options,
  19030. scrolled = false,
  19031. scrollParent = i.scrollParentNotHidden[ 0 ],
  19032. document = i.document[ 0 ];
  19033. if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
  19034. if ( !o.axis || o.axis !== "x" ) {
  19035. if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY <
  19036. o.scrollSensitivity ) {
  19037. scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
  19038. } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
  19039. scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
  19040. }
  19041. }
  19042. if ( !o.axis || o.axis !== "y" ) {
  19043. if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX <
  19044. o.scrollSensitivity ) {
  19045. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
  19046. } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
  19047. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
  19048. }
  19049. }
  19050. } else {
  19051. if ( !o.axis || o.axis !== "x" ) {
  19052. if ( event.pageY - $( document ).scrollTop() < o.scrollSensitivity ) {
  19053. scrolled = $( document ).scrollTop( $( document ).scrollTop() - o.scrollSpeed );
  19054. } else if ( $( window ).height() - ( event.pageY - $( document ).scrollTop() ) <
  19055. o.scrollSensitivity ) {
  19056. scrolled = $( document ).scrollTop( $( document ).scrollTop() + o.scrollSpeed );
  19057. }
  19058. }
  19059. if ( !o.axis || o.axis !== "y" ) {
  19060. if ( event.pageX - $( document ).scrollLeft() < o.scrollSensitivity ) {
  19061. scrolled = $( document ).scrollLeft(
  19062. $( document ).scrollLeft() - o.scrollSpeed
  19063. );
  19064. } else if ( $( window ).width() - ( event.pageX - $( document ).scrollLeft() ) <
  19065. o.scrollSensitivity ) {
  19066. scrolled = $( document ).scrollLeft(
  19067. $( document ).scrollLeft() + o.scrollSpeed
  19068. );
  19069. }
  19070. }
  19071. }
  19072. if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
  19073. $.ui.ddmanager.prepareOffsets( i, event );
  19074. }
  19075. }
  19076. } );
  19077. $.ui.plugin.add( "draggable", "snap", {
  19078. start: function( event, ui, i ) {
  19079. var o = i.options;
  19080. i.snapElements = [];
  19081. $( o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap )
  19082. .each( function() {
  19083. var $t = $( this ),
  19084. $o = $t.offset();
  19085. if ( this !== i.element[ 0 ] ) {
  19086. i.snapElements.push( {
  19087. item: this,
  19088. width: $t.outerWidth(), height: $t.outerHeight(),
  19089. top: $o.top, left: $o.left
  19090. } );
  19091. }
  19092. } );
  19093. },
  19094. drag: function( event, ui, inst ) {
  19095. var ts, bs, ls, rs, l, r, t, b, i, first,
  19096. o = inst.options,
  19097. d = o.snapTolerance,
  19098. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  19099. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  19100. for ( i = inst.snapElements.length - 1; i >= 0; i-- ) {
  19101. l = inst.snapElements[ i ].left - inst.margins.left;
  19102. r = l + inst.snapElements[ i ].width;
  19103. t = inst.snapElements[ i ].top - inst.margins.top;
  19104. b = t + inst.snapElements[ i ].height;
  19105. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d ||
  19106. !$.contains( inst.snapElements[ i ].item.ownerDocument,
  19107. inst.snapElements[ i ].item ) ) {
  19108. if ( inst.snapElements[ i ].snapping ) {
  19109. ( inst.options.snap.release &&
  19110. inst.options.snap.release.call(
  19111. inst.element,
  19112. event,
  19113. $.extend( inst._uiHash(), { snapItem: inst.snapElements[ i ].item } )
  19114. ) );
  19115. }
  19116. inst.snapElements[ i ].snapping = false;
  19117. continue;
  19118. }
  19119. if ( o.snapMode !== "inner" ) {
  19120. ts = Math.abs( t - y2 ) <= d;
  19121. bs = Math.abs( b - y1 ) <= d;
  19122. ls = Math.abs( l - x2 ) <= d;
  19123. rs = Math.abs( r - x1 ) <= d;
  19124. if ( ts ) {
  19125. ui.position.top = inst._convertPositionTo( "relative", {
  19126. top: t - inst.helperProportions.height,
  19127. left: 0
  19128. } ).top;
  19129. }
  19130. if ( bs ) {
  19131. ui.position.top = inst._convertPositionTo( "relative", {
  19132. top: b,
  19133. left: 0
  19134. } ).top;
  19135. }
  19136. if ( ls ) {
  19137. ui.position.left = inst._convertPositionTo( "relative", {
  19138. top: 0,
  19139. left: l - inst.helperProportions.width
  19140. } ).left;
  19141. }
  19142. if ( rs ) {
  19143. ui.position.left = inst._convertPositionTo( "relative", {
  19144. top: 0,
  19145. left: r
  19146. } ).left;
  19147. }
  19148. }
  19149. first = ( ts || bs || ls || rs );
  19150. if ( o.snapMode !== "outer" ) {
  19151. ts = Math.abs( t - y1 ) <= d;
  19152. bs = Math.abs( b - y2 ) <= d;
  19153. ls = Math.abs( l - x1 ) <= d;
  19154. rs = Math.abs( r - x2 ) <= d;
  19155. if ( ts ) {
  19156. ui.position.top = inst._convertPositionTo( "relative", {
  19157. top: t,
  19158. left: 0
  19159. } ).top;
  19160. }
  19161. if ( bs ) {
  19162. ui.position.top = inst._convertPositionTo( "relative", {
  19163. top: b - inst.helperProportions.height,
  19164. left: 0
  19165. } ).top;
  19166. }
  19167. if ( ls ) {
  19168. ui.position.left = inst._convertPositionTo( "relative", {
  19169. top: 0,
  19170. left: l
  19171. } ).left;
  19172. }
  19173. if ( rs ) {
  19174. ui.position.left = inst._convertPositionTo( "relative", {
  19175. top: 0,
  19176. left: r - inst.helperProportions.width
  19177. } ).left;
  19178. }
  19179. }
  19180. if ( !inst.snapElements[ i ].snapping && ( ts || bs || ls || rs || first ) ) {
  19181. ( inst.options.snap.snap &&
  19182. inst.options.snap.snap.call(
  19183. inst.element,
  19184. event,
  19185. $.extend( inst._uiHash(), {
  19186. snapItem: inst.snapElements[ i ].item
  19187. } ) ) );
  19188. }
  19189. inst.snapElements[ i ].snapping = ( ts || bs || ls || rs || first );
  19190. }
  19191. }
  19192. } );
  19193. $.ui.plugin.add( "draggable", "stack", {
  19194. start: function( event, ui, instance ) {
  19195. var min,
  19196. o = instance.options,
  19197. group = $.makeArray( $( o.stack ) ).sort( function( a, b ) {
  19198. return ( parseInt( $( a ).css( "zIndex" ), 10 ) || 0 ) -
  19199. ( parseInt( $( b ).css( "zIndex" ), 10 ) || 0 );
  19200. } );
  19201. if ( !group.length ) { return; }
  19202. min = parseInt( $( group[ 0 ] ).css( "zIndex" ), 10 ) || 0;
  19203. $( group ).each( function( i ) {
  19204. $( this ).css( "zIndex", min + i );
  19205. } );
  19206. this.css( "zIndex", ( min + group.length ) );
  19207. }
  19208. } );
  19209. $.ui.plugin.add( "draggable", "zIndex", {
  19210. start: function( event, ui, instance ) {
  19211. var t = $( ui.helper ),
  19212. o = instance.options;
  19213. if ( t.css( "zIndex" ) ) {
  19214. o._zIndex = t.css( "zIndex" );
  19215. }
  19216. t.css( "zIndex", o.zIndex );
  19217. },
  19218. stop: function( event, ui, instance ) {
  19219. var o = instance.options;
  19220. if ( o._zIndex ) {
  19221. $( ui.helper ).css( "zIndex", o._zIndex );
  19222. }
  19223. }
  19224. } );
  19225. var widgetsDraggable = $.ui.draggable;
  19226. /*!
  19227. * jQuery UI Resizable 1.12.1
  19228. * http://jqueryui.com
  19229. *
  19230. * Copyright jQuery Foundation and other contributors
  19231. * Released under the MIT license.
  19232. * http://jquery.org/license
  19233. */
  19234. //>>label: Resizable
  19235. //>>group: Interactions
  19236. //>>description: Enables resize functionality for any element.
  19237. //>>docs: http://api.jqueryui.com/resizable/
  19238. //>>demos: http://jqueryui.com/resizable/
  19239. //>>css.structure: ../../themes/base/core.css
  19240. //>>css.structure: ../../themes/base/resizable.css
  19241. //>>css.theme: ../../themes/base/theme.css
  19242. $.widget( "ui.resizable", $.ui.mouse, {
  19243. version: "1.12.1",
  19244. widgetEventPrefix: "resize",
  19245. options: {
  19246. alsoResize: false,
  19247. animate: false,
  19248. animateDuration: "slow",
  19249. animateEasing: "swing",
  19250. aspectRatio: false,
  19251. autoHide: false,
  19252. classes: {
  19253. "ui-resizable-se": "ui-icon ui-icon-gripsmall-diagonal-se"
  19254. },
  19255. containment: false,
  19256. ghost: false,
  19257. grid: false,
  19258. handles: "e,s,se",
  19259. helper: false,
  19260. maxHeight: null,
  19261. maxWidth: null,
  19262. minHeight: 10,
  19263. minWidth: 10,
  19264. // See #7960
  19265. zIndex: 90,
  19266. // Callbacks
  19267. resize: null,
  19268. start: null,
  19269. stop: null
  19270. },
  19271. _num: function( value ) {
  19272. return parseFloat( value ) || 0;
  19273. },
  19274. _isNumber: function( value ) {
  19275. return !isNaN( parseFloat( value ) );
  19276. },
  19277. _hasScroll: function( el, a ) {
  19278. if ( $( el ).css( "overflow" ) === "hidden" ) {
  19279. return false;
  19280. }
  19281. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  19282. has = false;
  19283. if ( el[ scroll ] > 0 ) {
  19284. return true;
  19285. }
  19286. // TODO: determine which cases actually cause this to happen
  19287. // if the element doesn't have the scroll set, see if it's possible to
  19288. // set the scroll
  19289. el[ scroll ] = 1;
  19290. has = ( el[ scroll ] > 0 );
  19291. el[ scroll ] = 0;
  19292. return has;
  19293. },
  19294. _create: function() {
  19295. var margins,
  19296. o = this.options,
  19297. that = this;
  19298. this._addClass( "ui-resizable" );
  19299. $.extend( this, {
  19300. _aspectRatio: !!( o.aspectRatio ),
  19301. aspectRatio: o.aspectRatio,
  19302. originalElement: this.element,
  19303. _proportionallyResizeElements: [],
  19304. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  19305. } );
  19306. // Wrap the element if it cannot hold child nodes
  19307. if ( this.element[ 0 ].nodeName.match( /^(canvas|textarea|input|select|button|img)$/i ) ) {
  19308. this.element.wrap(
  19309. $( "<div class='ui-wrapper' style='overflow: hidden;'></div>" ).css( {
  19310. position: this.element.css( "position" ),
  19311. width: this.element.outerWidth(),
  19312. height: this.element.outerHeight(),
  19313. top: this.element.css( "top" ),
  19314. left: this.element.css( "left" )
  19315. } )
  19316. );
  19317. this.element = this.element.parent().data(
  19318. "ui-resizable", this.element.resizable( "instance" )
  19319. );
  19320. this.elementIsWrapper = true;
  19321. margins = {
  19322. marginTop: this.originalElement.css( "marginTop" ),
  19323. marginRight: this.originalElement.css( "marginRight" ),
  19324. marginBottom: this.originalElement.css( "marginBottom" ),
  19325. marginLeft: this.originalElement.css( "marginLeft" )
  19326. };
  19327. this.element.css( margins );
  19328. this.originalElement.css( "margin", 0 );
  19329. // support: Safari
  19330. // Prevent Safari textarea resize
  19331. this.originalResizeStyle = this.originalElement.css( "resize" );
  19332. this.originalElement.css( "resize", "none" );
  19333. this._proportionallyResizeElements.push( this.originalElement.css( {
  19334. position: "static",
  19335. zoom: 1,
  19336. display: "block"
  19337. } ) );
  19338. // Support: IE9
  19339. // avoid IE jump (hard set the margin)
  19340. this.originalElement.css( margins );
  19341. this._proportionallyResize();
  19342. }
  19343. this._setupHandles();
  19344. if ( o.autoHide ) {
  19345. $( this.element )
  19346. .on( "mouseenter", function() {
  19347. if ( o.disabled ) {
  19348. return;
  19349. }
  19350. that._removeClass( "ui-resizable-autohide" );
  19351. that._handles.show();
  19352. } )
  19353. .on( "mouseleave", function() {
  19354. if ( o.disabled ) {
  19355. return;
  19356. }
  19357. if ( !that.resizing ) {
  19358. that._addClass( "ui-resizable-autohide" );
  19359. that._handles.hide();
  19360. }
  19361. } );
  19362. }
  19363. this._mouseInit();
  19364. },
  19365. _destroy: function() {
  19366. this._mouseDestroy();
  19367. var wrapper,
  19368. _destroy = function( exp ) {
  19369. $( exp )
  19370. .removeData( "resizable" )
  19371. .removeData( "ui-resizable" )
  19372. .off( ".resizable" )
  19373. .find( ".ui-resizable-handle" )
  19374. .remove();
  19375. };
  19376. // TODO: Unwrap at same DOM position
  19377. if ( this.elementIsWrapper ) {
  19378. _destroy( this.element );
  19379. wrapper = this.element;
  19380. this.originalElement.css( {
  19381. position: wrapper.css( "position" ),
  19382. width: wrapper.outerWidth(),
  19383. height: wrapper.outerHeight(),
  19384. top: wrapper.css( "top" ),
  19385. left: wrapper.css( "left" )
  19386. } ).insertAfter( wrapper );
  19387. wrapper.remove();
  19388. }
  19389. this.originalElement.css( "resize", this.originalResizeStyle );
  19390. _destroy( this.originalElement );
  19391. return this;
  19392. },
  19393. _setOption: function( key, value ) {
  19394. this._super( key, value );
  19395. switch ( key ) {
  19396. case "handles":
  19397. this._removeHandles();
  19398. this._setupHandles();
  19399. break;
  19400. default:
  19401. break;
  19402. }
  19403. },
  19404. _setupHandles: function() {
  19405. var o = this.options, handle, i, n, hname, axis, that = this;
  19406. this.handles = o.handles ||
  19407. ( !$( ".ui-resizable-handle", this.element ).length ?
  19408. "e,s,se" : {
  19409. n: ".ui-resizable-n",
  19410. e: ".ui-resizable-e",
  19411. s: ".ui-resizable-s",
  19412. w: ".ui-resizable-w",
  19413. se: ".ui-resizable-se",
  19414. sw: ".ui-resizable-sw",
  19415. ne: ".ui-resizable-ne",
  19416. nw: ".ui-resizable-nw"
  19417. } );
  19418. this._handles = $();
  19419. if ( this.handles.constructor === String ) {
  19420. if ( this.handles === "all" ) {
  19421. this.handles = "n,e,s,w,se,sw,ne,nw";
  19422. }
  19423. n = this.handles.split( "," );
  19424. this.handles = {};
  19425. for ( i = 0; i < n.length; i++ ) {
  19426. handle = $.trim( n[ i ] );
  19427. hname = "ui-resizable-" + handle;
  19428. axis = $( "<div>" );
  19429. this._addClass( axis, "ui-resizable-handle " + hname );
  19430. axis.css( { zIndex: o.zIndex } );
  19431. this.handles[ handle ] = ".ui-resizable-" + handle;
  19432. this.element.append( axis );
  19433. }
  19434. }
  19435. this._renderAxis = function( target ) {
  19436. var i, axis, padPos, padWrapper;
  19437. target = target || this.element;
  19438. for ( i in this.handles ) {
  19439. if ( this.handles[ i ].constructor === String ) {
  19440. this.handles[ i ] = this.element.children( this.handles[ i ] ).first().show();
  19441. } else if ( this.handles[ i ].jquery || this.handles[ i ].nodeType ) {
  19442. this.handles[ i ] = $( this.handles[ i ] );
  19443. this._on( this.handles[ i ], { "mousedown": that._mouseDown } );
  19444. }
  19445. if ( this.elementIsWrapper &&
  19446. this.originalElement[ 0 ]
  19447. .nodeName
  19448. .match( /^(textarea|input|select|button)$/i ) ) {
  19449. axis = $( this.handles[ i ], this.element );
  19450. padWrapper = /sw|ne|nw|se|n|s/.test( i ) ?
  19451. axis.outerHeight() :
  19452. axis.outerWidth();
  19453. padPos = [ "padding",
  19454. /ne|nw|n/.test( i ) ? "Top" :
  19455. /se|sw|s/.test( i ) ? "Bottom" :
  19456. /^e$/.test( i ) ? "Right" : "Left" ].join( "" );
  19457. target.css( padPos, padWrapper );
  19458. this._proportionallyResize();
  19459. }
  19460. this._handles = this._handles.add( this.handles[ i ] );
  19461. }
  19462. };
  19463. // TODO: make renderAxis a prototype function
  19464. this._renderAxis( this.element );
  19465. this._handles = this._handles.add( this.element.find( ".ui-resizable-handle" ) );
  19466. this._handles.disableSelection();
  19467. this._handles.on( "mouseover", function() {
  19468. if ( !that.resizing ) {
  19469. if ( this.className ) {
  19470. axis = this.className.match( /ui-resizable-(se|sw|ne|nw|n|e|s|w)/i );
  19471. }
  19472. that.axis = axis && axis[ 1 ] ? axis[ 1 ] : "se";
  19473. }
  19474. } );
  19475. if ( o.autoHide ) {
  19476. this._handles.hide();
  19477. this._addClass( "ui-resizable-autohide" );
  19478. }
  19479. },
  19480. _removeHandles: function() {
  19481. this._handles.remove();
  19482. },
  19483. _mouseCapture: function( event ) {
  19484. var i, handle,
  19485. capture = false;
  19486. for ( i in this.handles ) {
  19487. handle = $( this.handles[ i ] )[ 0 ];
  19488. if ( handle === event.target || $.contains( handle, event.target ) ) {
  19489. capture = true;
  19490. }
  19491. }
  19492. return !this.options.disabled && capture;
  19493. },
  19494. _mouseStart: function( event ) {
  19495. var curleft, curtop, cursor,
  19496. o = this.options,
  19497. el = this.element;
  19498. this.resizing = true;
  19499. this._renderProxy();
  19500. curleft = this._num( this.helper.css( "left" ) );
  19501. curtop = this._num( this.helper.css( "top" ) );
  19502. if ( o.containment ) {
  19503. curleft += $( o.containment ).scrollLeft() || 0;
  19504. curtop += $( o.containment ).scrollTop() || 0;
  19505. }
  19506. this.offset = this.helper.offset();
  19507. this.position = { left: curleft, top: curtop };
  19508. this.size = this._helper ? {
  19509. width: this.helper.width(),
  19510. height: this.helper.height()
  19511. } : {
  19512. width: el.width(),
  19513. height: el.height()
  19514. };
  19515. this.originalSize = this._helper ? {
  19516. width: el.outerWidth(),
  19517. height: el.outerHeight()
  19518. } : {
  19519. width: el.width(),
  19520. height: el.height()
  19521. };
  19522. this.sizeDiff = {
  19523. width: el.outerWidth() - el.width(),
  19524. height: el.outerHeight() - el.height()
  19525. };
  19526. this.originalPosition = { left: curleft, top: curtop };
  19527. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  19528. this.aspectRatio = ( typeof o.aspectRatio === "number" ) ?
  19529. o.aspectRatio :
  19530. ( ( this.originalSize.width / this.originalSize.height ) || 1 );
  19531. cursor = $( ".ui-resizable-" + this.axis ).css( "cursor" );
  19532. $( "body" ).css( "cursor", cursor === "auto" ? this.axis + "-resize" : cursor );
  19533. this._addClass( "ui-resizable-resizing" );
  19534. this._propagate( "start", event );
  19535. return true;
  19536. },
  19537. _mouseDrag: function( event ) {
  19538. var data, props,
  19539. smp = this.originalMousePosition,
  19540. a = this.axis,
  19541. dx = ( event.pageX - smp.left ) || 0,
  19542. dy = ( event.pageY - smp.top ) || 0,
  19543. trigger = this._change[ a ];
  19544. this._updatePrevProperties();
  19545. if ( !trigger ) {
  19546. return false;
  19547. }
  19548. data = trigger.apply( this, [ event, dx, dy ] );
  19549. this._updateVirtualBoundaries( event.shiftKey );
  19550. if ( this._aspectRatio || event.shiftKey ) {
  19551. data = this._updateRatio( data, event );
  19552. }
  19553. data = this._respectSize( data, event );
  19554. this._updateCache( data );
  19555. this._propagate( "resize", event );
  19556. props = this._applyChanges();
  19557. if ( !this._helper && this._proportionallyResizeElements.length ) {
  19558. this._proportionallyResize();
  19559. }
  19560. if ( !$.isEmptyObject( props ) ) {
  19561. this._updatePrevProperties();
  19562. this._trigger( "resize", event, this.ui() );
  19563. this._applyChanges();
  19564. }
  19565. return false;
  19566. },
  19567. _mouseStop: function( event ) {
  19568. this.resizing = false;
  19569. var pr, ista, soffseth, soffsetw, s, left, top,
  19570. o = this.options, that = this;
  19571. if ( this._helper ) {
  19572. pr = this._proportionallyResizeElements;
  19573. ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName );
  19574. soffseth = ista && this._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height;
  19575. soffsetw = ista ? 0 : that.sizeDiff.width;
  19576. s = {
  19577. width: ( that.helper.width() - soffsetw ),
  19578. height: ( that.helper.height() - soffseth )
  19579. };
  19580. left = ( parseFloat( that.element.css( "left" ) ) +
  19581. ( that.position.left - that.originalPosition.left ) ) || null;
  19582. top = ( parseFloat( that.element.css( "top" ) ) +
  19583. ( that.position.top - that.originalPosition.top ) ) || null;
  19584. if ( !o.animate ) {
  19585. this.element.css( $.extend( s, { top: top, left: left } ) );
  19586. }
  19587. that.helper.height( that.size.height );
  19588. that.helper.width( that.size.width );
  19589. if ( this._helper && !o.animate ) {
  19590. this._proportionallyResize();
  19591. }
  19592. }
  19593. $( "body" ).css( "cursor", "auto" );
  19594. this._removeClass( "ui-resizable-resizing" );
  19595. this._propagate( "stop", event );
  19596. if ( this._helper ) {
  19597. this.helper.remove();
  19598. }
  19599. return false;
  19600. },
  19601. _updatePrevProperties: function() {
  19602. this.prevPosition = {
  19603. top: this.position.top,
  19604. left: this.position.left
  19605. };
  19606. this.prevSize = {
  19607. width: this.size.width,
  19608. height: this.size.height
  19609. };
  19610. },
  19611. _applyChanges: function() {
  19612. var props = {};
  19613. if ( this.position.top !== this.prevPosition.top ) {
  19614. props.top = this.position.top + "px";
  19615. }
  19616. if ( this.position.left !== this.prevPosition.left ) {
  19617. props.left = this.position.left + "px";
  19618. }
  19619. if ( this.size.width !== this.prevSize.width ) {
  19620. props.width = this.size.width + "px";
  19621. }
  19622. if ( this.size.height !== this.prevSize.height ) {
  19623. props.height = this.size.height + "px";
  19624. }
  19625. this.helper.css( props );
  19626. return props;
  19627. },
  19628. _updateVirtualBoundaries: function( forceAspectRatio ) {
  19629. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  19630. o = this.options;
  19631. b = {
  19632. minWidth: this._isNumber( o.minWidth ) ? o.minWidth : 0,
  19633. maxWidth: this._isNumber( o.maxWidth ) ? o.maxWidth : Infinity,
  19634. minHeight: this._isNumber( o.minHeight ) ? o.minHeight : 0,
  19635. maxHeight: this._isNumber( o.maxHeight ) ? o.maxHeight : Infinity
  19636. };
  19637. if ( this._aspectRatio || forceAspectRatio ) {
  19638. pMinWidth = b.minHeight * this.aspectRatio;
  19639. pMinHeight = b.minWidth / this.aspectRatio;
  19640. pMaxWidth = b.maxHeight * this.aspectRatio;
  19641. pMaxHeight = b.maxWidth / this.aspectRatio;
  19642. if ( pMinWidth > b.minWidth ) {
  19643. b.minWidth = pMinWidth;
  19644. }
  19645. if ( pMinHeight > b.minHeight ) {
  19646. b.minHeight = pMinHeight;
  19647. }
  19648. if ( pMaxWidth < b.maxWidth ) {
  19649. b.maxWidth = pMaxWidth;
  19650. }
  19651. if ( pMaxHeight < b.maxHeight ) {
  19652. b.maxHeight = pMaxHeight;
  19653. }
  19654. }
  19655. this._vBoundaries = b;
  19656. },
  19657. _updateCache: function( data ) {
  19658. this.offset = this.helper.offset();
  19659. if ( this._isNumber( data.left ) ) {
  19660. this.position.left = data.left;
  19661. }
  19662. if ( this._isNumber( data.top ) ) {
  19663. this.position.top = data.top;
  19664. }
  19665. if ( this._isNumber( data.height ) ) {
  19666. this.size.height = data.height;
  19667. }
  19668. if ( this._isNumber( data.width ) ) {
  19669. this.size.width = data.width;
  19670. }
  19671. },
  19672. _updateRatio: function( data ) {
  19673. var cpos = this.position,
  19674. csize = this.size,
  19675. a = this.axis;
  19676. if ( this._isNumber( data.height ) ) {
  19677. data.width = ( data.height * this.aspectRatio );
  19678. } else if ( this._isNumber( data.width ) ) {
  19679. data.height = ( data.width / this.aspectRatio );
  19680. }
  19681. if ( a === "sw" ) {
  19682. data.left = cpos.left + ( csize.width - data.width );
  19683. data.top = null;
  19684. }
  19685. if ( a === "nw" ) {
  19686. data.top = cpos.top + ( csize.height - data.height );
  19687. data.left = cpos.left + ( csize.width - data.width );
  19688. }
  19689. return data;
  19690. },
  19691. _respectSize: function( data ) {
  19692. var o = this._vBoundaries,
  19693. a = this.axis,
  19694. ismaxw = this._isNumber( data.width ) && o.maxWidth && ( o.maxWidth < data.width ),
  19695. ismaxh = this._isNumber( data.height ) && o.maxHeight && ( o.maxHeight < data.height ),
  19696. isminw = this._isNumber( data.width ) && o.minWidth && ( o.minWidth > data.width ),
  19697. isminh = this._isNumber( data.height ) && o.minHeight && ( o.minHeight > data.height ),
  19698. dw = this.originalPosition.left + this.originalSize.width,
  19699. dh = this.originalPosition.top + this.originalSize.height,
  19700. cw = /sw|nw|w/.test( a ), ch = /nw|ne|n/.test( a );
  19701. if ( isminw ) {
  19702. data.width = o.minWidth;
  19703. }
  19704. if ( isminh ) {
  19705. data.height = o.minHeight;
  19706. }
  19707. if ( ismaxw ) {
  19708. data.width = o.maxWidth;
  19709. }
  19710. if ( ismaxh ) {
  19711. data.height = o.maxHeight;
  19712. }
  19713. if ( isminw && cw ) {
  19714. data.left = dw - o.minWidth;
  19715. }
  19716. if ( ismaxw && cw ) {
  19717. data.left = dw - o.maxWidth;
  19718. }
  19719. if ( isminh && ch ) {
  19720. data.top = dh - o.minHeight;
  19721. }
  19722. if ( ismaxh && ch ) {
  19723. data.top = dh - o.maxHeight;
  19724. }
  19725. // Fixing jump error on top/left - bug #2330
  19726. if ( !data.width && !data.height && !data.left && data.top ) {
  19727. data.top = null;
  19728. } else if ( !data.width && !data.height && !data.top && data.left ) {
  19729. data.left = null;
  19730. }
  19731. return data;
  19732. },
  19733. _getPaddingPlusBorderDimensions: function( element ) {
  19734. var i = 0,
  19735. widths = [],
  19736. borders = [
  19737. element.css( "borderTopWidth" ),
  19738. element.css( "borderRightWidth" ),
  19739. element.css( "borderBottomWidth" ),
  19740. element.css( "borderLeftWidth" )
  19741. ],
  19742. paddings = [
  19743. element.css( "paddingTop" ),
  19744. element.css( "paddingRight" ),
  19745. element.css( "paddingBottom" ),
  19746. element.css( "paddingLeft" )
  19747. ];
  19748. for ( ; i < 4; i++ ) {
  19749. widths[ i ] = ( parseFloat( borders[ i ] ) || 0 );
  19750. widths[ i ] += ( parseFloat( paddings[ i ] ) || 0 );
  19751. }
  19752. return {
  19753. height: widths[ 0 ] + widths[ 2 ],
  19754. width: widths[ 1 ] + widths[ 3 ]
  19755. };
  19756. },
  19757. _proportionallyResize: function() {
  19758. if ( !this._proportionallyResizeElements.length ) {
  19759. return;
  19760. }
  19761. var prel,
  19762. i = 0,
  19763. element = this.helper || this.element;
  19764. for ( ; i < this._proportionallyResizeElements.length; i++ ) {
  19765. prel = this._proportionallyResizeElements[ i ];
  19766. // TODO: Seems like a bug to cache this.outerDimensions
  19767. // considering that we are in a loop.
  19768. if ( !this.outerDimensions ) {
  19769. this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
  19770. }
  19771. prel.css( {
  19772. height: ( element.height() - this.outerDimensions.height ) || 0,
  19773. width: ( element.width() - this.outerDimensions.width ) || 0
  19774. } );
  19775. }
  19776. },
  19777. _renderProxy: function() {
  19778. var el = this.element, o = this.options;
  19779. this.elementOffset = el.offset();
  19780. if ( this._helper ) {
  19781. this.helper = this.helper || $( "<div style='overflow:hidden;'></div>" );
  19782. this._addClass( this.helper, this._helper );
  19783. this.helper.css( {
  19784. width: this.element.outerWidth(),
  19785. height: this.element.outerHeight(),
  19786. position: "absolute",
  19787. left: this.elementOffset.left + "px",
  19788. top: this.elementOffset.top + "px",
  19789. zIndex: ++o.zIndex //TODO: Don't modify option
  19790. } );
  19791. this.helper
  19792. .appendTo( "body" )
  19793. .disableSelection();
  19794. } else {
  19795. this.helper = this.element;
  19796. }
  19797. },
  19798. _change: {
  19799. e: function( event, dx ) {
  19800. return { width: this.originalSize.width + dx };
  19801. },
  19802. w: function( event, dx ) {
  19803. var cs = this.originalSize, sp = this.originalPosition;
  19804. return { left: sp.left + dx, width: cs.width - dx };
  19805. },
  19806. n: function( event, dx, dy ) {
  19807. var cs = this.originalSize, sp = this.originalPosition;
  19808. return { top: sp.top + dy, height: cs.height - dy };
  19809. },
  19810. s: function( event, dx, dy ) {
  19811. return { height: this.originalSize.height + dy };
  19812. },
  19813. se: function( event, dx, dy ) {
  19814. return $.extend( this._change.s.apply( this, arguments ),
  19815. this._change.e.apply( this, [ event, dx, dy ] ) );
  19816. },
  19817. sw: function( event, dx, dy ) {
  19818. return $.extend( this._change.s.apply( this, arguments ),
  19819. this._change.w.apply( this, [ event, dx, dy ] ) );
  19820. },
  19821. ne: function( event, dx, dy ) {
  19822. return $.extend( this._change.n.apply( this, arguments ),
  19823. this._change.e.apply( this, [ event, dx, dy ] ) );
  19824. },
  19825. nw: function( event, dx, dy ) {
  19826. return $.extend( this._change.n.apply( this, arguments ),
  19827. this._change.w.apply( this, [ event, dx, dy ] ) );
  19828. }
  19829. },
  19830. _propagate: function( n, event ) {
  19831. $.ui.plugin.call( this, n, [ event, this.ui() ] );
  19832. ( n !== "resize" && this._trigger( n, event, this.ui() ) );
  19833. },
  19834. plugins: {},
  19835. ui: function() {
  19836. return {
  19837. originalElement: this.originalElement,
  19838. element: this.element,
  19839. helper: this.helper,
  19840. position: this.position,
  19841. size: this.size,
  19842. originalSize: this.originalSize,
  19843. originalPosition: this.originalPosition
  19844. };
  19845. }
  19846. } );
  19847. /*
  19848. * Resizable Extensions
  19849. */
  19850. $.ui.plugin.add( "resizable", "animate", {
  19851. stop: function( event ) {
  19852. var that = $( this ).resizable( "instance" ),
  19853. o = that.options,
  19854. pr = that._proportionallyResizeElements,
  19855. ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName ),
  19856. soffseth = ista && that._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height,
  19857. soffsetw = ista ? 0 : that.sizeDiff.width,
  19858. style = {
  19859. width: ( that.size.width - soffsetw ),
  19860. height: ( that.size.height - soffseth )
  19861. },
  19862. left = ( parseFloat( that.element.css( "left" ) ) +
  19863. ( that.position.left - that.originalPosition.left ) ) || null,
  19864. top = ( parseFloat( that.element.css( "top" ) ) +
  19865. ( that.position.top - that.originalPosition.top ) ) || null;
  19866. that.element.animate(
  19867. $.extend( style, top && left ? { top: top, left: left } : {} ), {
  19868. duration: o.animateDuration,
  19869. easing: o.animateEasing,
  19870. step: function() {
  19871. var data = {
  19872. width: parseFloat( that.element.css( "width" ) ),
  19873. height: parseFloat( that.element.css( "height" ) ),
  19874. top: parseFloat( that.element.css( "top" ) ),
  19875. left: parseFloat( that.element.css( "left" ) )
  19876. };
  19877. if ( pr && pr.length ) {
  19878. $( pr[ 0 ] ).css( { width: data.width, height: data.height } );
  19879. }
  19880. // Propagating resize, and updating values for each animation step
  19881. that._updateCache( data );
  19882. that._propagate( "resize", event );
  19883. }
  19884. }
  19885. );
  19886. }
  19887. } );
  19888. $.ui.plugin.add( "resizable", "containment", {
  19889. start: function() {
  19890. var element, p, co, ch, cw, width, height,
  19891. that = $( this ).resizable( "instance" ),
  19892. o = that.options,
  19893. el = that.element,
  19894. oc = o.containment,
  19895. ce = ( oc instanceof $ ) ?
  19896. oc.get( 0 ) :
  19897. ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
  19898. if ( !ce ) {
  19899. return;
  19900. }
  19901. that.containerElement = $( ce );
  19902. if ( /document/.test( oc ) || oc === document ) {
  19903. that.containerOffset = {
  19904. left: 0,
  19905. top: 0
  19906. };
  19907. that.containerPosition = {
  19908. left: 0,
  19909. top: 0
  19910. };
  19911. that.parentData = {
  19912. element: $( document ),
  19913. left: 0,
  19914. top: 0,
  19915. width: $( document ).width(),
  19916. height: $( document ).height() || document.body.parentNode.scrollHeight
  19917. };
  19918. } else {
  19919. element = $( ce );
  19920. p = [];
  19921. $( [ "Top", "Right", "Left", "Bottom" ] ).each( function( i, name ) {
  19922. p[ i ] = that._num( element.css( "padding" + name ) );
  19923. } );
  19924. that.containerOffset = element.offset();
  19925. that.containerPosition = element.position();
  19926. that.containerSize = {
  19927. height: ( element.innerHeight() - p[ 3 ] ),
  19928. width: ( element.innerWidth() - p[ 1 ] )
  19929. };
  19930. co = that.containerOffset;
  19931. ch = that.containerSize.height;
  19932. cw = that.containerSize.width;
  19933. width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw );
  19934. height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ;
  19935. that.parentData = {
  19936. element: ce,
  19937. left: co.left,
  19938. top: co.top,
  19939. width: width,
  19940. height: height
  19941. };
  19942. }
  19943. },
  19944. resize: function( event ) {
  19945. var woset, hoset, isParent, isOffsetRelative,
  19946. that = $( this ).resizable( "instance" ),
  19947. o = that.options,
  19948. co = that.containerOffset,
  19949. cp = that.position,
  19950. pRatio = that._aspectRatio || event.shiftKey,
  19951. cop = {
  19952. top: 0,
  19953. left: 0
  19954. },
  19955. ce = that.containerElement,
  19956. continueResize = true;
  19957. if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
  19958. cop = co;
  19959. }
  19960. if ( cp.left < ( that._helper ? co.left : 0 ) ) {
  19961. that.size.width = that.size.width +
  19962. ( that._helper ?
  19963. ( that.position.left - co.left ) :
  19964. ( that.position.left - cop.left ) );
  19965. if ( pRatio ) {
  19966. that.size.height = that.size.width / that.aspectRatio;
  19967. continueResize = false;
  19968. }
  19969. that.position.left = o.helper ? co.left : 0;
  19970. }
  19971. if ( cp.top < ( that._helper ? co.top : 0 ) ) {
  19972. that.size.height = that.size.height +
  19973. ( that._helper ?
  19974. ( that.position.top - co.top ) :
  19975. that.position.top );
  19976. if ( pRatio ) {
  19977. that.size.width = that.size.height * that.aspectRatio;
  19978. continueResize = false;
  19979. }
  19980. that.position.top = that._helper ? co.top : 0;
  19981. }
  19982. isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
  19983. isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
  19984. if ( isParent && isOffsetRelative ) {
  19985. that.offset.left = that.parentData.left + that.position.left;
  19986. that.offset.top = that.parentData.top + that.position.top;
  19987. } else {
  19988. that.offset.left = that.element.offset().left;
  19989. that.offset.top = that.element.offset().top;
  19990. }
  19991. woset = Math.abs( that.sizeDiff.width +
  19992. ( that._helper ?
  19993. that.offset.left - cop.left :
  19994. ( that.offset.left - co.left ) ) );
  19995. hoset = Math.abs( that.sizeDiff.height +
  19996. ( that._helper ?
  19997. that.offset.top - cop.top :
  19998. ( that.offset.top - co.top ) ) );
  19999. if ( woset + that.size.width >= that.parentData.width ) {
  20000. that.size.width = that.parentData.width - woset;
  20001. if ( pRatio ) {
  20002. that.size.height = that.size.width / that.aspectRatio;
  20003. continueResize = false;
  20004. }
  20005. }
  20006. if ( hoset + that.size.height >= that.parentData.height ) {
  20007. that.size.height = that.parentData.height - hoset;
  20008. if ( pRatio ) {
  20009. that.size.width = that.size.height * that.aspectRatio;
  20010. continueResize = false;
  20011. }
  20012. }
  20013. if ( !continueResize ) {
  20014. that.position.left = that.prevPosition.left;
  20015. that.position.top = that.prevPosition.top;
  20016. that.size.width = that.prevSize.width;
  20017. that.size.height = that.prevSize.height;
  20018. }
  20019. },
  20020. stop: function() {
  20021. var that = $( this ).resizable( "instance" ),
  20022. o = that.options,
  20023. co = that.containerOffset,
  20024. cop = that.containerPosition,
  20025. ce = that.containerElement,
  20026. helper = $( that.helper ),
  20027. ho = helper.offset(),
  20028. w = helper.outerWidth() - that.sizeDiff.width,
  20029. h = helper.outerHeight() - that.sizeDiff.height;
  20030. if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
  20031. $( this ).css( {
  20032. left: ho.left - cop.left - co.left,
  20033. width: w,
  20034. height: h
  20035. } );
  20036. }
  20037. if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
  20038. $( this ).css( {
  20039. left: ho.left - cop.left - co.left,
  20040. width: w,
  20041. height: h
  20042. } );
  20043. }
  20044. }
  20045. } );
  20046. $.ui.plugin.add( "resizable", "alsoResize", {
  20047. start: function() {
  20048. var that = $( this ).resizable( "instance" ),
  20049. o = that.options;
  20050. $( o.alsoResize ).each( function() {
  20051. var el = $( this );
  20052. el.data( "ui-resizable-alsoresize", {
  20053. width: parseFloat( el.width() ), height: parseFloat( el.height() ),
  20054. left: parseFloat( el.css( "left" ) ), top: parseFloat( el.css( "top" ) )
  20055. } );
  20056. } );
  20057. },
  20058. resize: function( event, ui ) {
  20059. var that = $( this ).resizable( "instance" ),
  20060. o = that.options,
  20061. os = that.originalSize,
  20062. op = that.originalPosition,
  20063. delta = {
  20064. height: ( that.size.height - os.height ) || 0,
  20065. width: ( that.size.width - os.width ) || 0,
  20066. top: ( that.position.top - op.top ) || 0,
  20067. left: ( that.position.left - op.left ) || 0
  20068. };
  20069. $( o.alsoResize ).each( function() {
  20070. var el = $( this ), start = $( this ).data( "ui-resizable-alsoresize" ), style = {},
  20071. css = el.parents( ui.originalElement[ 0 ] ).length ?
  20072. [ "width", "height" ] :
  20073. [ "width", "height", "top", "left" ];
  20074. $.each( css, function( i, prop ) {
  20075. var sum = ( start[ prop ] || 0 ) + ( delta[ prop ] || 0 );
  20076. if ( sum && sum >= 0 ) {
  20077. style[ prop ] = sum || null;
  20078. }
  20079. } );
  20080. el.css( style );
  20081. } );
  20082. },
  20083. stop: function() {
  20084. $( this ).removeData( "ui-resizable-alsoresize" );
  20085. }
  20086. } );
  20087. $.ui.plugin.add( "resizable", "ghost", {
  20088. start: function() {
  20089. var that = $( this ).resizable( "instance" ), cs = that.size;
  20090. that.ghost = that.originalElement.clone();
  20091. that.ghost.css( {
  20092. opacity: 0.25,
  20093. display: "block",
  20094. position: "relative",
  20095. height: cs.height,
  20096. width: cs.width,
  20097. margin: 0,
  20098. left: 0,
  20099. top: 0
  20100. } );
  20101. that._addClass( that.ghost, "ui-resizable-ghost" );
  20102. // DEPRECATED
  20103. // TODO: remove after 1.12
  20104. if ( $.uiBackCompat !== false && typeof that.options.ghost === "string" ) {
  20105. // Ghost option
  20106. that.ghost.addClass( this.options.ghost );
  20107. }
  20108. that.ghost.appendTo( that.helper );
  20109. },
  20110. resize: function() {
  20111. var that = $( this ).resizable( "instance" );
  20112. if ( that.ghost ) {
  20113. that.ghost.css( {
  20114. position: "relative",
  20115. height: that.size.height,
  20116. width: that.size.width
  20117. } );
  20118. }
  20119. },
  20120. stop: function() {
  20121. var that = $( this ).resizable( "instance" );
  20122. if ( that.ghost && that.helper ) {
  20123. that.helper.get( 0 ).removeChild( that.ghost.get( 0 ) );
  20124. }
  20125. }
  20126. } );
  20127. $.ui.plugin.add( "resizable", "grid", {
  20128. resize: function() {
  20129. var outerDimensions,
  20130. that = $( this ).resizable( "instance" ),
  20131. o = that.options,
  20132. cs = that.size,
  20133. os = that.originalSize,
  20134. op = that.originalPosition,
  20135. a = that.axis,
  20136. grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid,
  20137. gridX = ( grid[ 0 ] || 1 ),
  20138. gridY = ( grid[ 1 ] || 1 ),
  20139. ox = Math.round( ( cs.width - os.width ) / gridX ) * gridX,
  20140. oy = Math.round( ( cs.height - os.height ) / gridY ) * gridY,
  20141. newWidth = os.width + ox,
  20142. newHeight = os.height + oy,
  20143. isMaxWidth = o.maxWidth && ( o.maxWidth < newWidth ),
  20144. isMaxHeight = o.maxHeight && ( o.maxHeight < newHeight ),
  20145. isMinWidth = o.minWidth && ( o.minWidth > newWidth ),
  20146. isMinHeight = o.minHeight && ( o.minHeight > newHeight );
  20147. o.grid = grid;
  20148. if ( isMinWidth ) {
  20149. newWidth += gridX;
  20150. }
  20151. if ( isMinHeight ) {
  20152. newHeight += gridY;
  20153. }
  20154. if ( isMaxWidth ) {
  20155. newWidth -= gridX;
  20156. }
  20157. if ( isMaxHeight ) {
  20158. newHeight -= gridY;
  20159. }
  20160. if ( /^(se|s|e)$/.test( a ) ) {
  20161. that.size.width = newWidth;
  20162. that.size.height = newHeight;
  20163. } else if ( /^(ne)$/.test( a ) ) {
  20164. that.size.width = newWidth;
  20165. that.size.height = newHeight;
  20166. that.position.top = op.top - oy;
  20167. } else if ( /^(sw)$/.test( a ) ) {
  20168. that.size.width = newWidth;
  20169. that.size.height = newHeight;
  20170. that.position.left = op.left - ox;
  20171. } else {
  20172. if ( newHeight - gridY <= 0 || newWidth - gridX <= 0 ) {
  20173. outerDimensions = that._getPaddingPlusBorderDimensions( this );
  20174. }
  20175. if ( newHeight - gridY > 0 ) {
  20176. that.size.height = newHeight;
  20177. that.position.top = op.top - oy;
  20178. } else {
  20179. newHeight = gridY - outerDimensions.height;
  20180. that.size.height = newHeight;
  20181. that.position.top = op.top + os.height - newHeight;
  20182. }
  20183. if ( newWidth - gridX > 0 ) {
  20184. that.size.width = newWidth;
  20185. that.position.left = op.left - ox;
  20186. } else {
  20187. newWidth = gridX - outerDimensions.width;
  20188. that.size.width = newWidth;
  20189. that.position.left = op.left + os.width - newWidth;
  20190. }
  20191. }
  20192. }
  20193. } );
  20194. var widgetsResizable = $.ui.resizable;
  20195. /*!
  20196. * jQuery UI Dialog 1.12.1
  20197. * http://jqueryui.com
  20198. *
  20199. * Copyright jQuery Foundation and other contributors
  20200. * Released under the MIT license.
  20201. * http://jquery.org/license
  20202. */
  20203. //>>label: Dialog
  20204. //>>group: Widgets
  20205. //>>description: Displays customizable dialog windows.
  20206. //>>docs: http://api.jqueryui.com/dialog/
  20207. //>>demos: http://jqueryui.com/dialog/
  20208. //>>css.structure: ../../themes/base/core.css
  20209. //>>css.structure: ../../themes/base/dialog.css
  20210. //>>css.theme: ../../themes/base/theme.css
  20211. $.widget( "ui.dialog", {
  20212. version: "1.12.1",
  20213. options: {
  20214. appendTo: "body",
  20215. autoOpen: true,
  20216. buttons: [],
  20217. classes: {
  20218. "ui-dialog": "ui-corner-all",
  20219. "ui-dialog-titlebar": "ui-corner-all"
  20220. },
  20221. closeOnEscape: true,
  20222. closeText: "Close",
  20223. draggable: true,
  20224. hide: null,
  20225. height: "auto",
  20226. maxHeight: null,
  20227. maxWidth: null,
  20228. minHeight: 150,
  20229. minWidth: 150,
  20230. modal: false,
  20231. position: {
  20232. my: "center",
  20233. at: "center",
  20234. of: window,
  20235. collision: "fit",
  20236. // Ensure the titlebar is always visible
  20237. using: function( pos ) {
  20238. var topOffset = $( this ).css( pos ).offset().top;
  20239. if ( topOffset < 0 ) {
  20240. $( this ).css( "top", pos.top - topOffset );
  20241. }
  20242. }
  20243. },
  20244. resizable: true,
  20245. show: null,
  20246. title: null,
  20247. width: 300,
  20248. // Callbacks
  20249. beforeClose: null,
  20250. close: null,
  20251. drag: null,
  20252. dragStart: null,
  20253. dragStop: null,
  20254. focus: null,
  20255. open: null,
  20256. resize: null,
  20257. resizeStart: null,
  20258. resizeStop: null
  20259. },
  20260. sizeRelatedOptions: {
  20261. buttons: true,
  20262. height: true,
  20263. maxHeight: true,
  20264. maxWidth: true,
  20265. minHeight: true,
  20266. minWidth: true,
  20267. width: true
  20268. },
  20269. resizableRelatedOptions: {
  20270. maxHeight: true,
  20271. maxWidth: true,
  20272. minHeight: true,
  20273. minWidth: true
  20274. },
  20275. _create: function() {
  20276. this.originalCss = {
  20277. display: this.element[ 0 ].style.display,
  20278. width: this.element[ 0 ].style.width,
  20279. minHeight: this.element[ 0 ].style.minHeight,
  20280. maxHeight: this.element[ 0 ].style.maxHeight,
  20281. height: this.element[ 0 ].style.height
  20282. };
  20283. this.originalPosition = {
  20284. parent: this.element.parent(),
  20285. index: this.element.parent().children().index( this.element )
  20286. };
  20287. this.originalTitle = this.element.attr( "title" );
  20288. if ( this.options.title == null && this.originalTitle != null ) {
  20289. this.options.title = this.originalTitle;
  20290. }
  20291. // Dialogs can't be disabled
  20292. if ( this.options.disabled ) {
  20293. this.options.disabled = false;
  20294. }
  20295. this._createWrapper();
  20296. this.element
  20297. .show()
  20298. .removeAttr( "title" )
  20299. .appendTo( this.uiDialog );
  20300. this._addClass( "ui-dialog-content", "ui-widget-content" );
  20301. this._createTitlebar();
  20302. this._createButtonPane();
  20303. if ( this.options.draggable && $.fn.draggable ) {
  20304. this._makeDraggable();
  20305. }
  20306. if ( this.options.resizable && $.fn.resizable ) {
  20307. this._makeResizable();
  20308. }
  20309. this._isOpen = false;
  20310. this._trackFocus();
  20311. },
  20312. _init: function() {
  20313. if ( this.options.autoOpen ) {
  20314. this.open();
  20315. }
  20316. },
  20317. _appendTo: function() {
  20318. var element = this.options.appendTo;
  20319. if ( element && ( element.jquery || element.nodeType ) ) {
  20320. return $( element );
  20321. }
  20322. return this.document.find( element || "body" ).eq( 0 );
  20323. },
  20324. _destroy: function() {
  20325. var next,
  20326. originalPosition = this.originalPosition;
  20327. this._untrackInstance();
  20328. this._destroyOverlay();
  20329. this.element
  20330. .removeUniqueId()
  20331. .css( this.originalCss )
  20332. // Without detaching first, the following becomes really slow
  20333. .detach();
  20334. this.uiDialog.remove();
  20335. if ( this.originalTitle ) {
  20336. this.element.attr( "title", this.originalTitle );
  20337. }
  20338. next = originalPosition.parent.children().eq( originalPosition.index );
  20339. // Don't try to place the dialog next to itself (#8613)
  20340. if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
  20341. next.before( this.element );
  20342. } else {
  20343. originalPosition.parent.append( this.element );
  20344. }
  20345. },
  20346. widget: function() {
  20347. return this.uiDialog;
  20348. },
  20349. disable: $.noop,
  20350. enable: $.noop,
  20351. close: function( event ) {
  20352. var that = this;
  20353. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  20354. return;
  20355. }
  20356. this._isOpen = false;
  20357. this._focusedElement = null;
  20358. this._destroyOverlay();
  20359. this._untrackInstance();
  20360. if ( !this.opener.filter( ":focusable" ).trigger( "focus" ).length ) {
  20361. // Hiding a focused element doesn't trigger blur in WebKit
  20362. // so in case we have nothing to focus on, explicitly blur the active element
  20363. // https://bugs.webkit.org/show_bug.cgi?id=47182
  20364. $.ui.safeBlur( $.ui.safeActiveElement( this.document[ 0 ] ) );
  20365. }
  20366. this._hide( this.uiDialog, this.options.hide, function() {
  20367. that._trigger( "close", event );
  20368. } );
  20369. },
  20370. isOpen: function() {
  20371. return this._isOpen;
  20372. },
  20373. moveToTop: function() {
  20374. this._moveToTop();
  20375. },
  20376. _moveToTop: function( event, silent ) {
  20377. var moved = false,
  20378. zIndices = this.uiDialog.siblings( ".ui-front:visible" ).map( function() {
  20379. return +$( this ).css( "z-index" );
  20380. } ).get(),
  20381. zIndexMax = Math.max.apply( null, zIndices );
  20382. if ( zIndexMax >= +this.uiDialog.css( "z-index" ) ) {
  20383. this.uiDialog.css( "z-index", zIndexMax + 1 );
  20384. moved = true;
  20385. }
  20386. if ( moved && !silent ) {
  20387. this._trigger( "focus", event );
  20388. }
  20389. return moved;
  20390. },
  20391. open: function() {
  20392. var that = this;
  20393. if ( this._isOpen ) {
  20394. if ( this._moveToTop() ) {
  20395. this._focusTabbable();
  20396. }
  20397. return;
  20398. }
  20399. this._isOpen = true;
  20400. this.opener = $( $.ui.safeActiveElement( this.document[ 0 ] ) );
  20401. this._size();
  20402. this._position();
  20403. this._createOverlay();
  20404. this._moveToTop( null, true );
  20405. // Ensure the overlay is moved to the top with the dialog, but only when
  20406. // opening. The overlay shouldn't move after the dialog is open so that
  20407. // modeless dialogs opened after the modal dialog stack properly.
  20408. if ( this.overlay ) {
  20409. this.overlay.css( "z-index", this.uiDialog.css( "z-index" ) - 1 );
  20410. }
  20411. this._show( this.uiDialog, this.options.show, function() {
  20412. that._focusTabbable();
  20413. that._trigger( "focus" );
  20414. } );
  20415. // Track the dialog immediately upon openening in case a focus event
  20416. // somehow occurs outside of the dialog before an element inside the
  20417. // dialog is focused (#10152)
  20418. this._makeFocusTarget();
  20419. this._trigger( "open" );
  20420. },
  20421. _focusTabbable: function() {
  20422. // Set focus to the first match:
  20423. // 1. An element that was focused previously
  20424. // 2. First element inside the dialog matching [autofocus]
  20425. // 3. Tabbable element inside the content element
  20426. // 4. Tabbable element inside the buttonpane
  20427. // 5. The close button
  20428. // 6. The dialog itself
  20429. var hasFocus = this._focusedElement;
  20430. if ( !hasFocus ) {
  20431. hasFocus = this.element.find( "[autofocus]" );
  20432. }
  20433. if ( !hasFocus.length ) {
  20434. hasFocus = this.element.find( ":tabbable" );
  20435. }
  20436. if ( !hasFocus.length ) {
  20437. hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
  20438. }
  20439. if ( !hasFocus.length ) {
  20440. hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" );
  20441. }
  20442. if ( !hasFocus.length ) {
  20443. hasFocus = this.uiDialog;
  20444. }
  20445. hasFocus.eq( 0 ).trigger( "focus" );
  20446. },
  20447. _keepFocus: function( event ) {
  20448. function checkFocus() {
  20449. var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ),
  20450. isActive = this.uiDialog[ 0 ] === activeElement ||
  20451. $.contains( this.uiDialog[ 0 ], activeElement );
  20452. if ( !isActive ) {
  20453. this._focusTabbable();
  20454. }
  20455. }
  20456. event.preventDefault();
  20457. checkFocus.call( this );
  20458. // support: IE
  20459. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  20460. // so we check again later
  20461. this._delay( checkFocus );
  20462. },
  20463. _createWrapper: function() {
  20464. this.uiDialog = $( "<div>" )
  20465. .hide()
  20466. .attr( {
  20467. // Setting tabIndex makes the div focusable
  20468. tabIndex: -1,
  20469. role: "dialog"
  20470. } )
  20471. .appendTo( this._appendTo() );
  20472. this._addClass( this.uiDialog, "ui-dialog", "ui-widget ui-widget-content ui-front" );
  20473. this._on( this.uiDialog, {
  20474. keydown: function( event ) {
  20475. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  20476. event.keyCode === $.ui.keyCode.ESCAPE ) {
  20477. event.preventDefault();
  20478. this.close( event );
  20479. return;
  20480. }
  20481. // Prevent tabbing out of dialogs
  20482. if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) {
  20483. return;
  20484. }
  20485. var tabbables = this.uiDialog.find( ":tabbable" ),
  20486. first = tabbables.filter( ":first" ),
  20487. last = tabbables.filter( ":last" );
  20488. if ( ( event.target === last[ 0 ] || event.target === this.uiDialog[ 0 ] ) &&
  20489. !event.shiftKey ) {
  20490. this._delay( function() {
  20491. first.trigger( "focus" );
  20492. } );
  20493. event.preventDefault();
  20494. } else if ( ( event.target === first[ 0 ] ||
  20495. event.target === this.uiDialog[ 0 ] ) && event.shiftKey ) {
  20496. this._delay( function() {
  20497. last.trigger( "focus" );
  20498. } );
  20499. event.preventDefault();
  20500. }
  20501. },
  20502. mousedown: function( event ) {
  20503. if ( this._moveToTop( event ) ) {
  20504. this._focusTabbable();
  20505. }
  20506. }
  20507. } );
  20508. // We assume that any existing aria-describedby attribute means
  20509. // that the dialog content is marked up properly
  20510. // otherwise we brute force the content as the description
  20511. if ( !this.element.find( "[aria-describedby]" ).length ) {
  20512. this.uiDialog.attr( {
  20513. "aria-describedby": this.element.uniqueId().attr( "id" )
  20514. } );
  20515. }
  20516. },
  20517. _createTitlebar: function() {
  20518. var uiDialogTitle;
  20519. this.uiDialogTitlebar = $( "<div>" );
  20520. this._addClass( this.uiDialogTitlebar,
  20521. "ui-dialog-titlebar", "ui-widget-header ui-helper-clearfix" );
  20522. this._on( this.uiDialogTitlebar, {
  20523. mousedown: function( event ) {
  20524. // Don't prevent click on close button (#8838)
  20525. // Focusing a dialog that is partially scrolled out of view
  20526. // causes the browser to scroll it into view, preventing the click event
  20527. if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
  20528. // Dialog isn't getting focus when dragging (#8063)
  20529. this.uiDialog.trigger( "focus" );
  20530. }
  20531. }
  20532. } );
  20533. // Support: IE
  20534. // Use type="button" to prevent enter keypresses in textboxes from closing the
  20535. // dialog in IE (#9312)
  20536. this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
  20537. .button( {
  20538. label: $( "<a>" ).text( this.options.closeText ).html(),
  20539. icon: "ui-icon-closethick",
  20540. showLabel: false
  20541. } )
  20542. .appendTo( this.uiDialogTitlebar );
  20543. this._addClass( this.uiDialogTitlebarClose, "ui-dialog-titlebar-close" );
  20544. this._on( this.uiDialogTitlebarClose, {
  20545. click: function( event ) {
  20546. event.preventDefault();
  20547. this.close( event );
  20548. }
  20549. } );
  20550. uiDialogTitle = $( "<span>" ).uniqueId().prependTo( this.uiDialogTitlebar );
  20551. this._addClass( uiDialogTitle, "ui-dialog-title" );
  20552. this._title( uiDialogTitle );
  20553. this.uiDialogTitlebar.prependTo( this.uiDialog );
  20554. this.uiDialog.attr( {
  20555. "aria-labelledby": uiDialogTitle.attr( "id" )
  20556. } );
  20557. },
  20558. _title: function( title ) {
  20559. if ( this.options.title ) {
  20560. title.text( this.options.title );
  20561. } else {
  20562. title.html( "&#160;" );
  20563. }
  20564. },
  20565. _createButtonPane: function() {
  20566. this.uiDialogButtonPane = $( "<div>" );
  20567. this._addClass( this.uiDialogButtonPane, "ui-dialog-buttonpane",
  20568. "ui-widget-content ui-helper-clearfix" );
  20569. this.uiButtonSet = $( "<div>" )
  20570. .appendTo( this.uiDialogButtonPane );
  20571. this._addClass( this.uiButtonSet, "ui-dialog-buttonset" );
  20572. this._createButtons();
  20573. },
  20574. _createButtons: function() {
  20575. var that = this,
  20576. buttons = this.options.buttons;
  20577. // If we already have a button pane, remove it
  20578. this.uiDialogButtonPane.remove();
  20579. this.uiButtonSet.empty();
  20580. if ( $.isEmptyObject( buttons ) || ( $.isArray( buttons ) && !buttons.length ) ) {
  20581. this._removeClass( this.uiDialog, "ui-dialog-buttons" );
  20582. return;
  20583. }
  20584. $.each( buttons, function( name, props ) {
  20585. var click, buttonOptions;
  20586. props = $.isFunction( props ) ?
  20587. { click: props, text: name } :
  20588. props;
  20589. // Default to a non-submitting button
  20590. props = $.extend( { type: "button" }, props );
  20591. // Change the context for the click callback to be the main element
  20592. click = props.click;
  20593. buttonOptions = {
  20594. icon: props.icon,
  20595. iconPosition: props.iconPosition,
  20596. showLabel: props.showLabel,
  20597. // Deprecated options
  20598. icons: props.icons,
  20599. text: props.text
  20600. };
  20601. delete props.click;
  20602. delete props.icon;
  20603. delete props.iconPosition;
  20604. delete props.showLabel;
  20605. // Deprecated options
  20606. delete props.icons;
  20607. if ( typeof props.text === "boolean" ) {
  20608. delete props.text;
  20609. }
  20610. $( "<button></button>", props )
  20611. .button( buttonOptions )
  20612. .appendTo( that.uiButtonSet )
  20613. .on( "click", function() {
  20614. click.apply( that.element[ 0 ], arguments );
  20615. } );
  20616. } );
  20617. this._addClass( this.uiDialog, "ui-dialog-buttons" );
  20618. this.uiDialogButtonPane.appendTo( this.uiDialog );
  20619. },
  20620. _makeDraggable: function() {
  20621. var that = this,
  20622. options = this.options;
  20623. function filteredUi( ui ) {
  20624. return {
  20625. position: ui.position,
  20626. offset: ui.offset
  20627. };
  20628. }
  20629. this.uiDialog.draggable( {
  20630. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  20631. handle: ".ui-dialog-titlebar",
  20632. containment: "document",
  20633. start: function( event, ui ) {
  20634. that._addClass( $( this ), "ui-dialog-dragging" );
  20635. that._blockFrames();
  20636. that._trigger( "dragStart", event, filteredUi( ui ) );
  20637. },
  20638. drag: function( event, ui ) {
  20639. that._trigger( "drag", event, filteredUi( ui ) );
  20640. },
  20641. stop: function( event, ui ) {
  20642. var left = ui.offset.left - that.document.scrollLeft(),
  20643. top = ui.offset.top - that.document.scrollTop();
  20644. options.position = {
  20645. my: "left top",
  20646. at: "left" + ( left >= 0 ? "+" : "" ) + left + " " +
  20647. "top" + ( top >= 0 ? "+" : "" ) + top,
  20648. of: that.window
  20649. };
  20650. that._removeClass( $( this ), "ui-dialog-dragging" );
  20651. that._unblockFrames();
  20652. that._trigger( "dragStop", event, filteredUi( ui ) );
  20653. }
  20654. } );
  20655. },
  20656. _makeResizable: function() {
  20657. var that = this,
  20658. options = this.options,
  20659. handles = options.resizable,
  20660. // .ui-resizable has position: relative defined in the stylesheet
  20661. // but dialogs have to use absolute or fixed positioning
  20662. position = this.uiDialog.css( "position" ),
  20663. resizeHandles = typeof handles === "string" ?
  20664. handles :
  20665. "n,e,s,w,se,sw,ne,nw";
  20666. function filteredUi( ui ) {
  20667. return {
  20668. originalPosition: ui.originalPosition,
  20669. originalSize: ui.originalSize,
  20670. position: ui.position,
  20671. size: ui.size
  20672. };
  20673. }
  20674. this.uiDialog.resizable( {
  20675. cancel: ".ui-dialog-content",
  20676. containment: "document",
  20677. alsoResize: this.element,
  20678. maxWidth: options.maxWidth,
  20679. maxHeight: options.maxHeight,
  20680. minWidth: options.minWidth,
  20681. minHeight: this._minHeight(),
  20682. handles: resizeHandles,
  20683. start: function( event, ui ) {
  20684. that._addClass( $( this ), "ui-dialog-resizing" );
  20685. that._blockFrames();
  20686. that._trigger( "resizeStart", event, filteredUi( ui ) );
  20687. },
  20688. resize: function( event, ui ) {
  20689. that._trigger( "resize", event, filteredUi( ui ) );
  20690. },
  20691. stop: function( event, ui ) {
  20692. var offset = that.uiDialog.offset(),
  20693. left = offset.left - that.document.scrollLeft(),
  20694. top = offset.top - that.document.scrollTop();
  20695. options.height = that.uiDialog.height();
  20696. options.width = that.uiDialog.width();
  20697. options.position = {
  20698. my: "left top",
  20699. at: "left" + ( left >= 0 ? "+" : "" ) + left + " " +
  20700. "top" + ( top >= 0 ? "+" : "" ) + top,
  20701. of: that.window
  20702. };
  20703. that._removeClass( $( this ), "ui-dialog-resizing" );
  20704. that._unblockFrames();
  20705. that._trigger( "resizeStop", event, filteredUi( ui ) );
  20706. }
  20707. } )
  20708. .css( "position", position );
  20709. },
  20710. _trackFocus: function() {
  20711. this._on( this.widget(), {
  20712. focusin: function( event ) {
  20713. this._makeFocusTarget();
  20714. this._focusedElement = $( event.target );
  20715. }
  20716. } );
  20717. },
  20718. _makeFocusTarget: function() {
  20719. this._untrackInstance();
  20720. this._trackingInstances().unshift( this );
  20721. },
  20722. _untrackInstance: function() {
  20723. var instances = this._trackingInstances(),
  20724. exists = $.inArray( this, instances );
  20725. if ( exists !== -1 ) {
  20726. instances.splice( exists, 1 );
  20727. }
  20728. },
  20729. _trackingInstances: function() {
  20730. var instances = this.document.data( "ui-dialog-instances" );
  20731. if ( !instances ) {
  20732. instances = [];
  20733. this.document.data( "ui-dialog-instances", instances );
  20734. }
  20735. return instances;
  20736. },
  20737. _minHeight: function() {
  20738. var options = this.options;
  20739. return options.height === "auto" ?
  20740. options.minHeight :
  20741. Math.min( options.minHeight, options.height );
  20742. },
  20743. _position: function() {
  20744. // Need to show the dialog to get the actual offset in the position plugin
  20745. var isVisible = this.uiDialog.is( ":visible" );
  20746. if ( !isVisible ) {
  20747. this.uiDialog.show();
  20748. }
  20749. this.uiDialog.position( this.options.position );
  20750. if ( !isVisible ) {
  20751. this.uiDialog.hide();
  20752. }
  20753. },
  20754. _setOptions: function( options ) {
  20755. var that = this,
  20756. resize = false,
  20757. resizableOptions = {};
  20758. $.each( options, function( key, value ) {
  20759. that._setOption( key, value );
  20760. if ( key in that.sizeRelatedOptions ) {
  20761. resize = true;
  20762. }
  20763. if ( key in that.resizableRelatedOptions ) {
  20764. resizableOptions[ key ] = value;
  20765. }
  20766. } );
  20767. if ( resize ) {
  20768. this._size();
  20769. this._position();
  20770. }
  20771. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  20772. this.uiDialog.resizable( "option", resizableOptions );
  20773. }
  20774. },
  20775. _setOption: function( key, value ) {
  20776. var isDraggable, isResizable,
  20777. uiDialog = this.uiDialog;
  20778. if ( key === "disabled" ) {
  20779. return;
  20780. }
  20781. this._super( key, value );
  20782. if ( key === "appendTo" ) {
  20783. this.uiDialog.appendTo( this._appendTo() );
  20784. }
  20785. if ( key === "buttons" ) {
  20786. this._createButtons();
  20787. }
  20788. if ( key === "closeText" ) {
  20789. this.uiDialogTitlebarClose.button( {
  20790. // Ensure that we always pass a string
  20791. label: $( "<a>" ).text( "" + this.options.closeText ).html()
  20792. } );
  20793. }
  20794. if ( key === "draggable" ) {
  20795. isDraggable = uiDialog.is( ":data(ui-draggable)" );
  20796. if ( isDraggable && !value ) {
  20797. uiDialog.draggable( "destroy" );
  20798. }
  20799. if ( !isDraggable && value ) {
  20800. this._makeDraggable();
  20801. }
  20802. }
  20803. if ( key === "position" ) {
  20804. this._position();
  20805. }
  20806. if ( key === "resizable" ) {
  20807. // currently resizable, becoming non-resizable
  20808. isResizable = uiDialog.is( ":data(ui-resizable)" );
  20809. if ( isResizable && !value ) {
  20810. uiDialog.resizable( "destroy" );
  20811. }
  20812. // Currently resizable, changing handles
  20813. if ( isResizable && typeof value === "string" ) {
  20814. uiDialog.resizable( "option", "handles", value );
  20815. }
  20816. // Currently non-resizable, becoming resizable
  20817. if ( !isResizable && value !== false ) {
  20818. this._makeResizable();
  20819. }
  20820. }
  20821. if ( key === "title" ) {
  20822. this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) );
  20823. }
  20824. },
  20825. _size: function() {
  20826. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  20827. // divs will both have width and height set, so we need to reset them
  20828. var nonContentHeight, minContentHeight, maxContentHeight,
  20829. options = this.options;
  20830. // Reset content sizing
  20831. this.element.show().css( {
  20832. width: "auto",
  20833. minHeight: 0,
  20834. maxHeight: "none",
  20835. height: 0
  20836. } );
  20837. if ( options.minWidth > options.width ) {
  20838. options.width = options.minWidth;
  20839. }
  20840. // Reset wrapper sizing
  20841. // determine the height of all the non-content elements
  20842. nonContentHeight = this.uiDialog.css( {
  20843. height: "auto",
  20844. width: options.width
  20845. } )
  20846. .outerHeight();
  20847. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  20848. maxContentHeight = typeof options.maxHeight === "number" ?
  20849. Math.max( 0, options.maxHeight - nonContentHeight ) :
  20850. "none";
  20851. if ( options.height === "auto" ) {
  20852. this.element.css( {
  20853. minHeight: minContentHeight,
  20854. maxHeight: maxContentHeight,
  20855. height: "auto"
  20856. } );
  20857. } else {
  20858. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  20859. }
  20860. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  20861. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  20862. }
  20863. },
  20864. _blockFrames: function() {
  20865. this.iframeBlocks = this.document.find( "iframe" ).map( function() {
  20866. var iframe = $( this );
  20867. return $( "<div>" )
  20868. .css( {
  20869. position: "absolute",
  20870. width: iframe.outerWidth(),
  20871. height: iframe.outerHeight()
  20872. } )
  20873. .appendTo( iframe.parent() )
  20874. .offset( iframe.offset() )[ 0 ];
  20875. } );
  20876. },
  20877. _unblockFrames: function() {
  20878. if ( this.iframeBlocks ) {
  20879. this.iframeBlocks.remove();
  20880. delete this.iframeBlocks;
  20881. }
  20882. },
  20883. _allowInteraction: function( event ) {
  20884. if ( $( event.target ).closest( ".ui-dialog" ).length ) {
  20885. return true;
  20886. }
  20887. // TODO: Remove hack when datepicker implements
  20888. // the .ui-front logic (#8989)
  20889. return !!$( event.target ).closest( ".ui-datepicker" ).length;
  20890. },
  20891. _createOverlay: function() {
  20892. if ( !this.options.modal ) {
  20893. return;
  20894. }
  20895. // We use a delay in case the overlay is created from an
  20896. // event that we're going to be cancelling (#2804)
  20897. var isOpening = true;
  20898. this._delay( function() {
  20899. isOpening = false;
  20900. } );
  20901. if ( !this.document.data( "ui-dialog-overlays" ) ) {
  20902. // Prevent use of anchors and inputs
  20903. // Using _on() for an event handler shared across many instances is
  20904. // safe because the dialogs stack and must be closed in reverse order
  20905. this._on( this.document, {
  20906. focusin: function( event ) {
  20907. if ( isOpening ) {
  20908. return;
  20909. }
  20910. if ( !this._allowInteraction( event ) ) {
  20911. event.preventDefault();
  20912. this._trackingInstances()[ 0 ]._focusTabbable();
  20913. }
  20914. }
  20915. } );
  20916. }
  20917. this.overlay = $( "<div>" )
  20918. .appendTo( this._appendTo() );
  20919. this._addClass( this.overlay, null, "ui-widget-overlay ui-front" );
  20920. this._on( this.overlay, {
  20921. mousedown: "_keepFocus"
  20922. } );
  20923. this.document.data( "ui-dialog-overlays",
  20924. ( this.document.data( "ui-dialog-overlays" ) || 0 ) + 1 );
  20925. },
  20926. _destroyOverlay: function() {
  20927. if ( !this.options.modal ) {
  20928. return;
  20929. }
  20930. if ( this.overlay ) {
  20931. var overlays = this.document.data( "ui-dialog-overlays" ) - 1;
  20932. if ( !overlays ) {
  20933. this._off( this.document, "focusin" );
  20934. this.document.removeData( "ui-dialog-overlays" );
  20935. } else {
  20936. this.document.data( "ui-dialog-overlays", overlays );
  20937. }
  20938. this.overlay.remove();
  20939. this.overlay = null;
  20940. }
  20941. }
  20942. } );
  20943. // DEPRECATED
  20944. // TODO: switch return back to widget declaration at top of file when this is removed
  20945. if ( $.uiBackCompat !== false ) {
  20946. // Backcompat for dialogClass option
  20947. $.widget( "ui.dialog", $.ui.dialog, {
  20948. options: {
  20949. dialogClass: ""
  20950. },
  20951. _createWrapper: function() {
  20952. this._super();
  20953. this.uiDialog.addClass( this.options.dialogClass );
  20954. },
  20955. _setOption: function( key, value ) {
  20956. if ( key === "dialogClass" ) {
  20957. this.uiDialog
  20958. .removeClass( this.options.dialogClass )
  20959. .addClass( value );
  20960. }
  20961. this._superApply( arguments );
  20962. }
  20963. } );
  20964. }
  20965. var widgetsDialog = $.ui.dialog;
  20966. /*!
  20967. * jQuery UI Droppable 1.12.1
  20968. * http://jqueryui.com
  20969. *
  20970. * Copyright jQuery Foundation and other contributors
  20971. * Released under the MIT license.
  20972. * http://jquery.org/license
  20973. */
  20974. //>>label: Droppable
  20975. //>>group: Interactions
  20976. //>>description: Enables drop targets for draggable elements.
  20977. //>>docs: http://api.jqueryui.com/droppable/
  20978. //>>demos: http://jqueryui.com/droppable/
  20979. $.widget( "ui.droppable", {
  20980. version: "1.12.1",
  20981. widgetEventPrefix: "drop",
  20982. options: {
  20983. accept: "*",
  20984. addClasses: true,
  20985. greedy: false,
  20986. scope: "default",
  20987. tolerance: "intersect",
  20988. // Callbacks
  20989. activate: null,
  20990. deactivate: null,
  20991. drop: null,
  20992. out: null,
  20993. over: null
  20994. },
  20995. _create: function() {
  20996. var proportions,
  20997. o = this.options,
  20998. accept = o.accept;
  20999. this.isover = false;
  21000. this.isout = true;
  21001. this.accept = $.isFunction( accept ) ? accept : function( d ) {
  21002. return d.is( accept );
  21003. };
  21004. this.proportions = function( /* valueToWrite */ ) {
  21005. if ( arguments.length ) {
  21006. // Store the droppable's proportions
  21007. proportions = arguments[ 0 ];
  21008. } else {
  21009. // Retrieve or derive the droppable's proportions
  21010. return proportions ?
  21011. proportions :
  21012. proportions = {
  21013. width: this.element[ 0 ].offsetWidth,
  21014. height: this.element[ 0 ].offsetHeight
  21015. };
  21016. }
  21017. };
  21018. this._addToManager( o.scope );
  21019. o.addClasses && this._addClass( "ui-droppable" );
  21020. },
  21021. _addToManager: function( scope ) {
  21022. // Add the reference and positions to the manager
  21023. $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
  21024. $.ui.ddmanager.droppables[ scope ].push( this );
  21025. },
  21026. _splice: function( drop ) {
  21027. var i = 0;
  21028. for ( ; i < drop.length; i++ ) {
  21029. if ( drop[ i ] === this ) {
  21030. drop.splice( i, 1 );
  21031. }
  21032. }
  21033. },
  21034. _destroy: function() {
  21035. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  21036. this._splice( drop );
  21037. },
  21038. _setOption: function( key, value ) {
  21039. if ( key === "accept" ) {
  21040. this.accept = $.isFunction( value ) ? value : function( d ) {
  21041. return d.is( value );
  21042. };
  21043. } else if ( key === "scope" ) {
  21044. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  21045. this._splice( drop );
  21046. this._addToManager( value );
  21047. }
  21048. this._super( key, value );
  21049. },
  21050. _activate: function( event ) {
  21051. var draggable = $.ui.ddmanager.current;
  21052. this._addActiveClass();
  21053. if ( draggable ) {
  21054. this._trigger( "activate", event, this.ui( draggable ) );
  21055. }
  21056. },
  21057. _deactivate: function( event ) {
  21058. var draggable = $.ui.ddmanager.current;
  21059. this._removeActiveClass();
  21060. if ( draggable ) {
  21061. this._trigger( "deactivate", event, this.ui( draggable ) );
  21062. }
  21063. },
  21064. _over: function( event ) {
  21065. var draggable = $.ui.ddmanager.current;
  21066. // Bail if draggable and droppable are same element
  21067. if ( !draggable || ( draggable.currentItem ||
  21068. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  21069. return;
  21070. }
  21071. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem ||
  21072. draggable.element ) ) ) {
  21073. this._addHoverClass();
  21074. this._trigger( "over", event, this.ui( draggable ) );
  21075. }
  21076. },
  21077. _out: function( event ) {
  21078. var draggable = $.ui.ddmanager.current;
  21079. // Bail if draggable and droppable are same element
  21080. if ( !draggable || ( draggable.currentItem ||
  21081. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  21082. return;
  21083. }
  21084. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem ||
  21085. draggable.element ) ) ) {
  21086. this._removeHoverClass();
  21087. this._trigger( "out", event, this.ui( draggable ) );
  21088. }
  21089. },
  21090. _drop: function( event, custom ) {
  21091. var draggable = custom || $.ui.ddmanager.current,
  21092. childrenIntersection = false;
  21093. // Bail if draggable and droppable are same element
  21094. if ( !draggable || ( draggable.currentItem ||
  21095. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  21096. return false;
  21097. }
  21098. this.element
  21099. .find( ":data(ui-droppable)" )
  21100. .not( ".ui-draggable-dragging" )
  21101. .each( function() {
  21102. var inst = $( this ).droppable( "instance" );
  21103. if (
  21104. inst.options.greedy &&
  21105. !inst.options.disabled &&
  21106. inst.options.scope === draggable.options.scope &&
  21107. inst.accept.call(
  21108. inst.element[ 0 ], ( draggable.currentItem || draggable.element )
  21109. ) &&
  21110. intersect(
  21111. draggable,
  21112. $.extend( inst, { offset: inst.element.offset() } ),
  21113. inst.options.tolerance, event
  21114. )
  21115. ) {
  21116. childrenIntersection = true;
  21117. return false; }
  21118. } );
  21119. if ( childrenIntersection ) {
  21120. return false;
  21121. }
  21122. if ( this.accept.call( this.element[ 0 ],
  21123. ( draggable.currentItem || draggable.element ) ) ) {
  21124. this._removeActiveClass();
  21125. this._removeHoverClass();
  21126. this._trigger( "drop", event, this.ui( draggable ) );
  21127. return this.element;
  21128. }
  21129. return false;
  21130. },
  21131. ui: function( c ) {
  21132. return {
  21133. draggable: ( c.currentItem || c.element ),
  21134. helper: c.helper,
  21135. position: c.position,
  21136. offset: c.positionAbs
  21137. };
  21138. },
  21139. // Extension points just to make backcompat sane and avoid duplicating logic
  21140. // TODO: Remove in 1.13 along with call to it below
  21141. _addHoverClass: function() {
  21142. this._addClass( "ui-droppable-hover" );
  21143. },
  21144. _removeHoverClass: function() {
  21145. this._removeClass( "ui-droppable-hover" );
  21146. },
  21147. _addActiveClass: function() {
  21148. this._addClass( "ui-droppable-active" );
  21149. },
  21150. _removeActiveClass: function() {
  21151. this._removeClass( "ui-droppable-active" );
  21152. }
  21153. } );
  21154. var intersect = $.ui.intersect = ( function() {
  21155. function isOverAxis( x, reference, size ) {
  21156. return ( x >= reference ) && ( x < ( reference + size ) );
  21157. }
  21158. return function( draggable, droppable, toleranceMode, event ) {
  21159. if ( !droppable.offset ) {
  21160. return false;
  21161. }
  21162. var x1 = ( draggable.positionAbs ||
  21163. draggable.position.absolute ).left + draggable.margins.left,
  21164. y1 = ( draggable.positionAbs ||
  21165. draggable.position.absolute ).top + draggable.margins.top,
  21166. x2 = x1 + draggable.helperProportions.width,
  21167. y2 = y1 + draggable.helperProportions.height,
  21168. l = droppable.offset.left,
  21169. t = droppable.offset.top,
  21170. r = l + droppable.proportions().width,
  21171. b = t + droppable.proportions().height;
  21172. switch ( toleranceMode ) {
  21173. case "fit":
  21174. return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
  21175. case "intersect":
  21176. return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
  21177. x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
  21178. t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
  21179. y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
  21180. case "pointer":
  21181. return isOverAxis( event.pageY, t, droppable.proportions().height ) &&
  21182. isOverAxis( event.pageX, l, droppable.proportions().width );
  21183. case "touch":
  21184. return (
  21185. ( y1 >= t && y1 <= b ) || // Top edge touching
  21186. ( y2 >= t && y2 <= b ) || // Bottom edge touching
  21187. ( y1 < t && y2 > b ) // Surrounded vertically
  21188. ) && (
  21189. ( x1 >= l && x1 <= r ) || // Left edge touching
  21190. ( x2 >= l && x2 <= r ) || // Right edge touching
  21191. ( x1 < l && x2 > r ) // Surrounded horizontally
  21192. );
  21193. default:
  21194. return false;
  21195. }
  21196. };
  21197. } )();
  21198. /*
  21199. This manager tracks offsets of draggables and droppables
  21200. */
  21201. $.ui.ddmanager = {
  21202. current: null,
  21203. droppables: { "default": [] },
  21204. prepareOffsets: function( t, event ) {
  21205. var i, j,
  21206. m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
  21207. type = event ? event.type : null, // workaround for #2317
  21208. list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
  21209. droppablesLoop: for ( i = 0; i < m.length; i++ ) {
  21210. // No disabled and non-accepted
  21211. if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ],
  21212. ( t.currentItem || t.element ) ) ) ) {
  21213. continue;
  21214. }
  21215. // Filter out elements in the current dragged item
  21216. for ( j = 0; j < list.length; j++ ) {
  21217. if ( list[ j ] === m[ i ].element[ 0 ] ) {
  21218. m[ i ].proportions().height = 0;
  21219. continue droppablesLoop;
  21220. }
  21221. }
  21222. m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
  21223. if ( !m[ i ].visible ) {
  21224. continue;
  21225. }
  21226. // Activate the droppable if used directly from draggables
  21227. if ( type === "mousedown" ) {
  21228. m[ i ]._activate.call( m[ i ], event );
  21229. }
  21230. m[ i ].offset = m[ i ].element.offset();
  21231. m[ i ].proportions( {
  21232. width: m[ i ].element[ 0 ].offsetWidth,
  21233. height: m[ i ].element[ 0 ].offsetHeight
  21234. } );
  21235. }
  21236. },
  21237. drop: function( draggable, event ) {
  21238. var dropped = false;
  21239. // Create a copy of the droppables in case the list changes during the drop (#9116)
  21240. $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
  21241. if ( !this.options ) {
  21242. return;
  21243. }
  21244. if ( !this.options.disabled && this.visible &&
  21245. intersect( draggable, this, this.options.tolerance, event ) ) {
  21246. dropped = this._drop.call( this, event ) || dropped;
  21247. }
  21248. if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ],
  21249. ( draggable.currentItem || draggable.element ) ) ) {
  21250. this.isout = true;
  21251. this.isover = false;
  21252. this._deactivate.call( this, event );
  21253. }
  21254. } );
  21255. return dropped;
  21256. },
  21257. dragStart: function( draggable, event ) {
  21258. // Listen for scrolling so that if the dragging causes scrolling the position of the
  21259. // droppables can be recalculated (see #5003)
  21260. draggable.element.parentsUntil( "body" ).on( "scroll.droppable", function() {
  21261. if ( !draggable.options.refreshPositions ) {
  21262. $.ui.ddmanager.prepareOffsets( draggable, event );
  21263. }
  21264. } );
  21265. },
  21266. drag: function( draggable, event ) {
  21267. // If you have a highly dynamic page, you might try this option. It renders positions
  21268. // every time you move the mouse.
  21269. if ( draggable.options.refreshPositions ) {
  21270. $.ui.ddmanager.prepareOffsets( draggable, event );
  21271. }
  21272. // Run through all droppables and check their positions based on specific tolerance options
  21273. $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
  21274. if ( this.options.disabled || this.greedyChild || !this.visible ) {
  21275. return;
  21276. }
  21277. var parentInstance, scope, parent,
  21278. intersects = intersect( draggable, this, this.options.tolerance, event ),
  21279. c = !intersects && this.isover ?
  21280. "isout" :
  21281. ( intersects && !this.isover ? "isover" : null );
  21282. if ( !c ) {
  21283. return;
  21284. }
  21285. if ( this.options.greedy ) {
  21286. // find droppable parents with same scope
  21287. scope = this.options.scope;
  21288. parent = this.element.parents( ":data(ui-droppable)" ).filter( function() {
  21289. return $( this ).droppable( "instance" ).options.scope === scope;
  21290. } );
  21291. if ( parent.length ) {
  21292. parentInstance = $( parent[ 0 ] ).droppable( "instance" );
  21293. parentInstance.greedyChild = ( c === "isover" );
  21294. }
  21295. }
  21296. // We just moved into a greedy child
  21297. if ( parentInstance && c === "isover" ) {
  21298. parentInstance.isover = false;
  21299. parentInstance.isout = true;
  21300. parentInstance._out.call( parentInstance, event );
  21301. }
  21302. this[ c ] = true;
  21303. this[ c === "isout" ? "isover" : "isout" ] = false;
  21304. this[ c === "isover" ? "_over" : "_out" ].call( this, event );
  21305. // We just moved out of a greedy child
  21306. if ( parentInstance && c === "isout" ) {
  21307. parentInstance.isout = false;
  21308. parentInstance.isover = true;
  21309. parentInstance._over.call( parentInstance, event );
  21310. }
  21311. } );
  21312. },
  21313. dragStop: function( draggable, event ) {
  21314. draggable.element.parentsUntil( "body" ).off( "scroll.droppable" );
  21315. // Call prepareOffsets one final time since IE does not fire return scroll events when
  21316. // overflow was caused by drag (see #5003)
  21317. if ( !draggable.options.refreshPositions ) {
  21318. $.ui.ddmanager.prepareOffsets( draggable, event );
  21319. }
  21320. }
  21321. };
  21322. // DEPRECATED
  21323. // TODO: switch return back to widget declaration at top of file when this is removed
  21324. if ( $.uiBackCompat !== false ) {
  21325. // Backcompat for activeClass and hoverClass options
  21326. $.widget( "ui.droppable", $.ui.droppable, {
  21327. options: {
  21328. hoverClass: false,
  21329. activeClass: false
  21330. },
  21331. _addActiveClass: function() {
  21332. this._super();
  21333. if ( this.options.activeClass ) {
  21334. this.element.addClass( this.options.activeClass );
  21335. }
  21336. },
  21337. _removeActiveClass: function() {
  21338. this._super();
  21339. if ( this.options.activeClass ) {
  21340. this.element.removeClass( this.options.activeClass );
  21341. }
  21342. },
  21343. _addHoverClass: function() {
  21344. this._super();
  21345. if ( this.options.hoverClass ) {
  21346. this.element.addClass( this.options.hoverClass );
  21347. }
  21348. },
  21349. _removeHoverClass: function() {
  21350. this._super();
  21351. if ( this.options.hoverClass ) {
  21352. this.element.removeClass( this.options.hoverClass );
  21353. }
  21354. }
  21355. } );
  21356. }
  21357. var widgetsDroppable = $.ui.droppable;
  21358. /*!
  21359. * jQuery UI Progressbar 1.12.1
  21360. * http://jqueryui.com
  21361. *
  21362. * Copyright jQuery Foundation and other contributors
  21363. * Released under the MIT license.
  21364. * http://jquery.org/license
  21365. */
  21366. //>>label: Progressbar
  21367. //>>group: Widgets
  21368. // jscs:disable maximumLineLength
  21369. //>>description: Displays a status indicator for loading state, standard percentage, and other progress indicators.
  21370. // jscs:enable maximumLineLength
  21371. //>>docs: http://api.jqueryui.com/progressbar/
  21372. //>>demos: http://jqueryui.com/progressbar/
  21373. //>>css.structure: ../../themes/base/core.css
  21374. //>>css.structure: ../../themes/base/progressbar.css
  21375. //>>css.theme: ../../themes/base/theme.css
  21376. var widgetsProgressbar = $.widget( "ui.progressbar", {
  21377. version: "1.12.1",
  21378. options: {
  21379. classes: {
  21380. "ui-progressbar": "ui-corner-all",
  21381. "ui-progressbar-value": "ui-corner-left",
  21382. "ui-progressbar-complete": "ui-corner-right"
  21383. },
  21384. max: 100,
  21385. value: 0,
  21386. change: null,
  21387. complete: null
  21388. },
  21389. min: 0,
  21390. _create: function() {
  21391. // Constrain initial value
  21392. this.oldValue = this.options.value = this._constrainedValue();
  21393. this.element.attr( {
  21394. // Only set static values; aria-valuenow and aria-valuemax are
  21395. // set inside _refreshValue()
  21396. role: "progressbar",
  21397. "aria-valuemin": this.min
  21398. } );
  21399. this._addClass( "ui-progressbar", "ui-widget ui-widget-content" );
  21400. this.valueDiv = $( "<div>" ).appendTo( this.element );
  21401. this._addClass( this.valueDiv, "ui-progressbar-value", "ui-widget-header" );
  21402. this._refreshValue();
  21403. },
  21404. _destroy: function() {
  21405. this.element.removeAttr( "role aria-valuemin aria-valuemax aria-valuenow" );
  21406. this.valueDiv.remove();
  21407. },
  21408. value: function( newValue ) {
  21409. if ( newValue === undefined ) {
  21410. return this.options.value;
  21411. }
  21412. this.options.value = this._constrainedValue( newValue );
  21413. this._refreshValue();
  21414. },
  21415. _constrainedValue: function( newValue ) {
  21416. if ( newValue === undefined ) {
  21417. newValue = this.options.value;
  21418. }
  21419. this.indeterminate = newValue === false;
  21420. // Sanitize value
  21421. if ( typeof newValue !== "number" ) {
  21422. newValue = 0;
  21423. }
  21424. return this.indeterminate ? false :
  21425. Math.min( this.options.max, Math.max( this.min, newValue ) );
  21426. },
  21427. _setOptions: function( options ) {
  21428. // Ensure "value" option is set after other values (like max)
  21429. var value = options.value;
  21430. delete options.value;
  21431. this._super( options );
  21432. this.options.value = this._constrainedValue( value );
  21433. this._refreshValue();
  21434. },
  21435. _setOption: function( key, value ) {
  21436. if ( key === "max" ) {
  21437. // Don't allow a max less than min
  21438. value = Math.max( this.min, value );
  21439. }
  21440. this._super( key, value );
  21441. },
  21442. _setOptionDisabled: function( value ) {
  21443. this._super( value );
  21444. this.element.attr( "aria-disabled", value );
  21445. this._toggleClass( null, "ui-state-disabled", !!value );
  21446. },
  21447. _percentage: function() {
  21448. return this.indeterminate ?
  21449. 100 :
  21450. 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  21451. },
  21452. _refreshValue: function() {
  21453. var value = this.options.value,
  21454. percentage = this._percentage();
  21455. this.valueDiv
  21456. .toggle( this.indeterminate || value > this.min )
  21457. .width( percentage.toFixed( 0 ) + "%" );
  21458. this
  21459. ._toggleClass( this.valueDiv, "ui-progressbar-complete", null,
  21460. value === this.options.max )
  21461. ._toggleClass( "ui-progressbar-indeterminate", null, this.indeterminate );
  21462. if ( this.indeterminate ) {
  21463. this.element.removeAttr( "aria-valuenow" );
  21464. if ( !this.overlayDiv ) {
  21465. this.overlayDiv = $( "<div>" ).appendTo( this.valueDiv );
  21466. this._addClass( this.overlayDiv, "ui-progressbar-overlay" );
  21467. }
  21468. } else {
  21469. this.element.attr( {
  21470. "aria-valuemax": this.options.max,
  21471. "aria-valuenow": value
  21472. } );
  21473. if ( this.overlayDiv ) {
  21474. this.overlayDiv.remove();
  21475. this.overlayDiv = null;
  21476. }
  21477. }
  21478. if ( this.oldValue !== value ) {
  21479. this.oldValue = value;
  21480. this._trigger( "change" );
  21481. }
  21482. if ( value === this.options.max ) {
  21483. this._trigger( "complete" );
  21484. }
  21485. }
  21486. } );
  21487. /*!
  21488. * jQuery UI Selectable 1.12.1
  21489. * http://jqueryui.com
  21490. *
  21491. * Copyright jQuery Foundation and other contributors
  21492. * Released under the MIT license.
  21493. * http://jquery.org/license
  21494. */
  21495. //>>label: Selectable
  21496. //>>group: Interactions
  21497. //>>description: Allows groups of elements to be selected with the mouse.
  21498. //>>docs: http://api.jqueryui.com/selectable/
  21499. //>>demos: http://jqueryui.com/selectable/
  21500. //>>css.structure: ../../themes/base/selectable.css
  21501. var widgetsSelectable = $.widget( "ui.selectable", $.ui.mouse, {
  21502. version: "1.12.1",
  21503. options: {
  21504. appendTo: "body",
  21505. autoRefresh: true,
  21506. distance: 0,
  21507. filter: "*",
  21508. tolerance: "touch",
  21509. // Callbacks
  21510. selected: null,
  21511. selecting: null,
  21512. start: null,
  21513. stop: null,
  21514. unselected: null,
  21515. unselecting: null
  21516. },
  21517. _create: function() {
  21518. var that = this;
  21519. this._addClass( "ui-selectable" );
  21520. this.dragged = false;
  21521. // Cache selectee children based on filter
  21522. this.refresh = function() {
  21523. that.elementPos = $( that.element[ 0 ] ).offset();
  21524. that.selectees = $( that.options.filter, that.element[ 0 ] );
  21525. that._addClass( that.selectees, "ui-selectee" );
  21526. that.selectees.each( function() {
  21527. var $this = $( this ),
  21528. selecteeOffset = $this.offset(),
  21529. pos = {
  21530. left: selecteeOffset.left - that.elementPos.left,
  21531. top: selecteeOffset.top - that.elementPos.top
  21532. };
  21533. $.data( this, "selectable-item", {
  21534. element: this,
  21535. $element: $this,
  21536. left: pos.left,
  21537. top: pos.top,
  21538. right: pos.left + $this.outerWidth(),
  21539. bottom: pos.top + $this.outerHeight(),
  21540. startselected: false,
  21541. selected: $this.hasClass( "ui-selected" ),
  21542. selecting: $this.hasClass( "ui-selecting" ),
  21543. unselecting: $this.hasClass( "ui-unselecting" )
  21544. } );
  21545. } );
  21546. };
  21547. this.refresh();
  21548. this._mouseInit();
  21549. this.helper = $( "<div>" );
  21550. this._addClass( this.helper, "ui-selectable-helper" );
  21551. },
  21552. _destroy: function() {
  21553. this.selectees.removeData( "selectable-item" );
  21554. this._mouseDestroy();
  21555. },
  21556. _mouseStart: function( event ) {
  21557. var that = this,
  21558. options = this.options;
  21559. this.opos = [ event.pageX, event.pageY ];
  21560. this.elementPos = $( this.element[ 0 ] ).offset();
  21561. if ( this.options.disabled ) {
  21562. return;
  21563. }
  21564. this.selectees = $( options.filter, this.element[ 0 ] );
  21565. this._trigger( "start", event );
  21566. $( options.appendTo ).append( this.helper );
  21567. // position helper (lasso)
  21568. this.helper.css( {
  21569. "left": event.pageX,
  21570. "top": event.pageY,
  21571. "width": 0,
  21572. "height": 0
  21573. } );
  21574. if ( options.autoRefresh ) {
  21575. this.refresh();
  21576. }
  21577. this.selectees.filter( ".ui-selected" ).each( function() {
  21578. var selectee = $.data( this, "selectable-item" );
  21579. selectee.startselected = true;
  21580. if ( !event.metaKey && !event.ctrlKey ) {
  21581. that._removeClass( selectee.$element, "ui-selected" );
  21582. selectee.selected = false;
  21583. that._addClass( selectee.$element, "ui-unselecting" );
  21584. selectee.unselecting = true;
  21585. // selectable UNSELECTING callback
  21586. that._trigger( "unselecting", event, {
  21587. unselecting: selectee.element
  21588. } );
  21589. }
  21590. } );
  21591. $( event.target ).parents().addBack().each( function() {
  21592. var doSelect,
  21593. selectee = $.data( this, "selectable-item" );
  21594. if ( selectee ) {
  21595. doSelect = ( !event.metaKey && !event.ctrlKey ) ||
  21596. !selectee.$element.hasClass( "ui-selected" );
  21597. that._removeClass( selectee.$element, doSelect ? "ui-unselecting" : "ui-selected" )
  21598. ._addClass( selectee.$element, doSelect ? "ui-selecting" : "ui-unselecting" );
  21599. selectee.unselecting = !doSelect;
  21600. selectee.selecting = doSelect;
  21601. selectee.selected = doSelect;
  21602. // selectable (UN)SELECTING callback
  21603. if ( doSelect ) {
  21604. that._trigger( "selecting", event, {
  21605. selecting: selectee.element
  21606. } );
  21607. } else {
  21608. that._trigger( "unselecting", event, {
  21609. unselecting: selectee.element
  21610. } );
  21611. }
  21612. return false;
  21613. }
  21614. } );
  21615. },
  21616. _mouseDrag: function( event ) {
  21617. this.dragged = true;
  21618. if ( this.options.disabled ) {
  21619. return;
  21620. }
  21621. var tmp,
  21622. that = this,
  21623. options = this.options,
  21624. x1 = this.opos[ 0 ],
  21625. y1 = this.opos[ 1 ],
  21626. x2 = event.pageX,
  21627. y2 = event.pageY;
  21628. if ( x1 > x2 ) { tmp = x2; x2 = x1; x1 = tmp; }
  21629. if ( y1 > y2 ) { tmp = y2; y2 = y1; y1 = tmp; }
  21630. this.helper.css( { left: x1, top: y1, width: x2 - x1, height: y2 - y1 } );
  21631. this.selectees.each( function() {
  21632. var selectee = $.data( this, "selectable-item" ),
  21633. hit = false,
  21634. offset = {};
  21635. //prevent helper from being selected if appendTo: selectable
  21636. if ( !selectee || selectee.element === that.element[ 0 ] ) {
  21637. return;
  21638. }
  21639. offset.left = selectee.left + that.elementPos.left;
  21640. offset.right = selectee.right + that.elementPos.left;
  21641. offset.top = selectee.top + that.elementPos.top;
  21642. offset.bottom = selectee.bottom + that.elementPos.top;
  21643. if ( options.tolerance === "touch" ) {
  21644. hit = ( !( offset.left > x2 || offset.right < x1 || offset.top > y2 ||
  21645. offset.bottom < y1 ) );
  21646. } else if ( options.tolerance === "fit" ) {
  21647. hit = ( offset.left > x1 && offset.right < x2 && offset.top > y1 &&
  21648. offset.bottom < y2 );
  21649. }
  21650. if ( hit ) {
  21651. // SELECT
  21652. if ( selectee.selected ) {
  21653. that._removeClass( selectee.$element, "ui-selected" );
  21654. selectee.selected = false;
  21655. }
  21656. if ( selectee.unselecting ) {
  21657. that._removeClass( selectee.$element, "ui-unselecting" );
  21658. selectee.unselecting = false;
  21659. }
  21660. if ( !selectee.selecting ) {
  21661. that._addClass( selectee.$element, "ui-selecting" );
  21662. selectee.selecting = true;
  21663. // selectable SELECTING callback
  21664. that._trigger( "selecting", event, {
  21665. selecting: selectee.element
  21666. } );
  21667. }
  21668. } else {
  21669. // UNSELECT
  21670. if ( selectee.selecting ) {
  21671. if ( ( event.metaKey || event.ctrlKey ) && selectee.startselected ) {
  21672. that._removeClass( selectee.$element, "ui-selecting" );
  21673. selectee.selecting = false;
  21674. that._addClass( selectee.$element, "ui-selected" );
  21675. selectee.selected = true;
  21676. } else {
  21677. that._removeClass( selectee.$element, "ui-selecting" );
  21678. selectee.selecting = false;
  21679. if ( selectee.startselected ) {
  21680. that._addClass( selectee.$element, "ui-unselecting" );
  21681. selectee.unselecting = true;
  21682. }
  21683. // selectable UNSELECTING callback
  21684. that._trigger( "unselecting", event, {
  21685. unselecting: selectee.element
  21686. } );
  21687. }
  21688. }
  21689. if ( selectee.selected ) {
  21690. if ( !event.metaKey && !event.ctrlKey && !selectee.startselected ) {
  21691. that._removeClass( selectee.$element, "ui-selected" );
  21692. selectee.selected = false;
  21693. that._addClass( selectee.$element, "ui-unselecting" );
  21694. selectee.unselecting = true;
  21695. // selectable UNSELECTING callback
  21696. that._trigger( "unselecting", event, {
  21697. unselecting: selectee.element
  21698. } );
  21699. }
  21700. }
  21701. }
  21702. } );
  21703. return false;
  21704. },
  21705. _mouseStop: function( event ) {
  21706. var that = this;
  21707. this.dragged = false;
  21708. $( ".ui-unselecting", this.element[ 0 ] ).each( function() {
  21709. var selectee = $.data( this, "selectable-item" );
  21710. that._removeClass( selectee.$element, "ui-unselecting" );
  21711. selectee.unselecting = false;
  21712. selectee.startselected = false;
  21713. that._trigger( "unselected", event, {
  21714. unselected: selectee.element
  21715. } );
  21716. } );
  21717. $( ".ui-selecting", this.element[ 0 ] ).each( function() {
  21718. var selectee = $.data( this, "selectable-item" );
  21719. that._removeClass( selectee.$element, "ui-selecting" )
  21720. ._addClass( selectee.$element, "ui-selected" );
  21721. selectee.selecting = false;
  21722. selectee.selected = true;
  21723. selectee.startselected = true;
  21724. that._trigger( "selected", event, {
  21725. selected: selectee.element
  21726. } );
  21727. } );
  21728. this._trigger( "stop", event );
  21729. this.helper.remove();
  21730. return false;
  21731. }
  21732. } );
  21733. /*!
  21734. * jQuery UI Selectmenu 1.12.1
  21735. * http://jqueryui.com
  21736. *
  21737. * Copyright jQuery Foundation and other contributors
  21738. * Released under the MIT license.
  21739. * http://jquery.org/license
  21740. */
  21741. //>>label: Selectmenu
  21742. //>>group: Widgets
  21743. // jscs:disable maximumLineLength
  21744. //>>description: Duplicates and extends the functionality of a native HTML select element, allowing it to be customizable in behavior and appearance far beyond the limitations of a native select.
  21745. // jscs:enable maximumLineLength
  21746. //>>docs: http://api.jqueryui.com/selectmenu/
  21747. //>>demos: http://jqueryui.com/selectmenu/
  21748. //>>css.structure: ../../themes/base/core.css
  21749. //>>css.structure: ../../themes/base/selectmenu.css, ../../themes/base/button.css
  21750. //>>css.theme: ../../themes/base/theme.css
  21751. var widgetsSelectmenu = $.widget( "ui.selectmenu", [ $.ui.formResetMixin, {
  21752. version: "1.12.1",
  21753. defaultElement: "<select>",
  21754. options: {
  21755. appendTo: null,
  21756. classes: {
  21757. "ui-selectmenu-button-open": "ui-corner-top",
  21758. "ui-selectmenu-button-closed": "ui-corner-all"
  21759. },
  21760. disabled: null,
  21761. icons: {
  21762. button: "ui-icon-triangle-1-s"
  21763. },
  21764. position: {
  21765. my: "left top",
  21766. at: "left bottom",
  21767. collision: "none"
  21768. },
  21769. width: false,
  21770. // Callbacks
  21771. change: null,
  21772. close: null,
  21773. focus: null,
  21774. open: null,
  21775. select: null
  21776. },
  21777. _create: function() {
  21778. var selectmenuId = this.element.uniqueId().attr( "id" );
  21779. this.ids = {
  21780. element: selectmenuId,
  21781. button: selectmenuId + "-button",
  21782. menu: selectmenuId + "-menu"
  21783. };
  21784. this._drawButton();
  21785. this._drawMenu();
  21786. this._bindFormResetHandler();
  21787. this._rendered = false;
  21788. this.menuItems = $();
  21789. },
  21790. _drawButton: function() {
  21791. var icon,
  21792. that = this,
  21793. item = this._parseOption(
  21794. this.element.find( "option:selected" ),
  21795. this.element[ 0 ].selectedIndex
  21796. );
  21797. // Associate existing label with the new button
  21798. this.labels = this.element.labels().attr( "for", this.ids.button );
  21799. this._on( this.labels, {
  21800. click: function( event ) {
  21801. this.button.focus();
  21802. event.preventDefault();
  21803. }
  21804. } );
  21805. // Hide original select element
  21806. this.element.hide();
  21807. // Create button
  21808. this.button = $( "<span>", {
  21809. tabindex: this.options.disabled ? -1 : 0,
  21810. id: this.ids.button,
  21811. role: "combobox",
  21812. "aria-expanded": "false",
  21813. "aria-autocomplete": "list",
  21814. "aria-owns": this.ids.menu,
  21815. "aria-haspopup": "true",
  21816. title: this.element.attr( "title" )
  21817. } )
  21818. .insertAfter( this.element );
  21819. this._addClass( this.button, "ui-selectmenu-button ui-selectmenu-button-closed",
  21820. "ui-button ui-widget" );
  21821. icon = $( "<span>" ).appendTo( this.button );
  21822. this._addClass( icon, "ui-selectmenu-icon", "ui-icon " + this.options.icons.button );
  21823. this.buttonItem = this._renderButtonItem( item )
  21824. .appendTo( this.button );
  21825. if ( this.options.width !== false ) {
  21826. this._resizeButton();
  21827. }
  21828. this._on( this.button, this._buttonEvents );
  21829. this.button.one( "focusin", function() {
  21830. // Delay rendering the menu items until the button receives focus.
  21831. // The menu may have already been rendered via a programmatic open.
  21832. if ( !that._rendered ) {
  21833. that._refreshMenu();
  21834. }
  21835. } );
  21836. },
  21837. _drawMenu: function() {
  21838. var that = this;
  21839. // Create menu
  21840. this.menu = $( "<ul>", {
  21841. "aria-hidden": "true",
  21842. "aria-labelledby": this.ids.button,
  21843. id: this.ids.menu
  21844. } );
  21845. // Wrap menu
  21846. this.menuWrap = $( "<div>" ).append( this.menu );
  21847. this._addClass( this.menuWrap, "ui-selectmenu-menu", "ui-front" );
  21848. this.menuWrap.appendTo( this._appendTo() );
  21849. // Initialize menu widget
  21850. this.menuInstance = this.menu
  21851. .menu( {
  21852. classes: {
  21853. "ui-menu": "ui-corner-bottom"
  21854. },
  21855. role: "listbox",
  21856. select: function( event, ui ) {
  21857. event.preventDefault();
  21858. // Support: IE8
  21859. // If the item was selected via a click, the text selection
  21860. // will be destroyed in IE
  21861. that._setSelection();
  21862. that._select( ui.item.data( "ui-selectmenu-item" ), event );
  21863. },
  21864. focus: function( event, ui ) {
  21865. var item = ui.item.data( "ui-selectmenu-item" );
  21866. // Prevent inital focus from firing and check if its a newly focused item
  21867. if ( that.focusIndex != null && item.index !== that.focusIndex ) {
  21868. that._trigger( "focus", event, { item: item } );
  21869. if ( !that.isOpen ) {
  21870. that._select( item, event );
  21871. }
  21872. }
  21873. that.focusIndex = item.index;
  21874. that.button.attr( "aria-activedescendant",
  21875. that.menuItems.eq( item.index ).attr( "id" ) );
  21876. }
  21877. } )
  21878. .menu( "instance" );
  21879. // Don't close the menu on mouseleave
  21880. this.menuInstance._off( this.menu, "mouseleave" );
  21881. // Cancel the menu's collapseAll on document click
  21882. this.menuInstance._closeOnDocumentClick = function() {
  21883. return false;
  21884. };
  21885. // Selects often contain empty items, but never contain dividers
  21886. this.menuInstance._isDivider = function() {
  21887. return false;
  21888. };
  21889. },
  21890. refresh: function() {
  21891. this._refreshMenu();
  21892. this.buttonItem.replaceWith(
  21893. this.buttonItem = this._renderButtonItem(
  21894. // Fall back to an empty object in case there are no options
  21895. this._getSelectedItem().data( "ui-selectmenu-item" ) || {}
  21896. )
  21897. );
  21898. if ( this.options.width === null ) {
  21899. this._resizeButton();
  21900. }
  21901. },
  21902. _refreshMenu: function() {
  21903. var item,
  21904. options = this.element.find( "option" );
  21905. this.menu.empty();
  21906. this._parseOptions( options );
  21907. this._renderMenu( this.menu, this.items );
  21908. this.menuInstance.refresh();
  21909. this.menuItems = this.menu.find( "li" )
  21910. .not( ".ui-selectmenu-optgroup" )
  21911. .find( ".ui-menu-item-wrapper" );
  21912. this._rendered = true;
  21913. if ( !options.length ) {
  21914. return;
  21915. }
  21916. item = this._getSelectedItem();
  21917. // Update the menu to have the correct item focused
  21918. this.menuInstance.focus( null, item );
  21919. this._setAria( item.data( "ui-selectmenu-item" ) );
  21920. // Set disabled state
  21921. this._setOption( "disabled", this.element.prop( "disabled" ) );
  21922. },
  21923. open: function( event ) {
  21924. if ( this.options.disabled ) {
  21925. return;
  21926. }
  21927. // If this is the first time the menu is being opened, render the items
  21928. if ( !this._rendered ) {
  21929. this._refreshMenu();
  21930. } else {
  21931. // Menu clears focus on close, reset focus to selected item
  21932. this._removeClass( this.menu.find( ".ui-state-active" ), null, "ui-state-active" );
  21933. this.menuInstance.focus( null, this._getSelectedItem() );
  21934. }
  21935. // If there are no options, don't open the menu
  21936. if ( !this.menuItems.length ) {
  21937. return;
  21938. }
  21939. this.isOpen = true;
  21940. this._toggleAttr();
  21941. this._resizeMenu();
  21942. this._position();
  21943. this._on( this.document, this._documentClick );
  21944. this._trigger( "open", event );
  21945. },
  21946. _position: function() {
  21947. this.menuWrap.position( $.extend( { of: this.button }, this.options.position ) );
  21948. },
  21949. close: function( event ) {
  21950. if ( !this.isOpen ) {
  21951. return;
  21952. }
  21953. this.isOpen = false;
  21954. this._toggleAttr();
  21955. this.range = null;
  21956. this._off( this.document );
  21957. this._trigger( "close", event );
  21958. },
  21959. widget: function() {
  21960. return this.button;
  21961. },
  21962. menuWidget: function() {
  21963. return this.menu;
  21964. },
  21965. _renderButtonItem: function( item ) {
  21966. var buttonItem = $( "<span>" );
  21967. this._setText( buttonItem, item.label );
  21968. this._addClass( buttonItem, "ui-selectmenu-text" );
  21969. return buttonItem;
  21970. },
  21971. _renderMenu: function( ul, items ) {
  21972. var that = this,
  21973. currentOptgroup = "";
  21974. $.each( items, function( index, item ) {
  21975. var li;
  21976. if ( item.optgroup !== currentOptgroup ) {
  21977. li = $( "<li>", {
  21978. text: item.optgroup
  21979. } );
  21980. that._addClass( li, "ui-selectmenu-optgroup", "ui-menu-divider" +
  21981. ( item.element.parent( "optgroup" ).prop( "disabled" ) ?
  21982. " ui-state-disabled" :
  21983. "" ) );
  21984. li.appendTo( ul );
  21985. currentOptgroup = item.optgroup;
  21986. }
  21987. that._renderItemData( ul, item );
  21988. } );
  21989. },
  21990. _renderItemData: function( ul, item ) {
  21991. return this._renderItem( ul, item ).data( "ui-selectmenu-item", item );
  21992. },
  21993. _renderItem: function( ul, item ) {
  21994. var li = $( "<li>" ),
  21995. wrapper = $( "<div>", {
  21996. title: item.element.attr( "title" )
  21997. } );
  21998. if ( item.disabled ) {
  21999. this._addClass( li, null, "ui-state-disabled" );
  22000. }
  22001. this._setText( wrapper, item.label );
  22002. return li.append( wrapper ).appendTo( ul );
  22003. },
  22004. _setText: function( element, value ) {
  22005. if ( value ) {
  22006. element.text( value );
  22007. } else {
  22008. element.html( "&#160;" );
  22009. }
  22010. },
  22011. _move: function( direction, event ) {
  22012. var item, next,
  22013. filter = ".ui-menu-item";
  22014. if ( this.isOpen ) {
  22015. item = this.menuItems.eq( this.focusIndex ).parent( "li" );
  22016. } else {
  22017. item = this.menuItems.eq( this.element[ 0 ].selectedIndex ).parent( "li" );
  22018. filter += ":not(.ui-state-disabled)";
  22019. }
  22020. if ( direction === "first" || direction === "last" ) {
  22021. next = item[ direction === "first" ? "prevAll" : "nextAll" ]( filter ).eq( -1 );
  22022. } else {
  22023. next = item[ direction + "All" ]( filter ).eq( 0 );
  22024. }
  22025. if ( next.length ) {
  22026. this.menuInstance.focus( event, next );
  22027. }
  22028. },
  22029. _getSelectedItem: function() {
  22030. return this.menuItems.eq( this.element[ 0 ].selectedIndex ).parent( "li" );
  22031. },
  22032. _toggle: function( event ) {
  22033. this[ this.isOpen ? "close" : "open" ]( event );
  22034. },
  22035. _setSelection: function() {
  22036. var selection;
  22037. if ( !this.range ) {
  22038. return;
  22039. }
  22040. if ( window.getSelection ) {
  22041. selection = window.getSelection();
  22042. selection.removeAllRanges();
  22043. selection.addRange( this.range );
  22044. // Support: IE8
  22045. } else {
  22046. this.range.select();
  22047. }
  22048. // Support: IE
  22049. // Setting the text selection kills the button focus in IE, but
  22050. // restoring the focus doesn't kill the selection.
  22051. this.button.focus();
  22052. },
  22053. _documentClick: {
  22054. mousedown: function( event ) {
  22055. if ( !this.isOpen ) {
  22056. return;
  22057. }
  22058. if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" +
  22059. $.ui.escapeSelector( this.ids.button ) ).length ) {
  22060. this.close( event );
  22061. }
  22062. }
  22063. },
  22064. _buttonEvents: {
  22065. // Prevent text selection from being reset when interacting with the selectmenu (#10144)
  22066. mousedown: function() {
  22067. var selection;
  22068. if ( window.getSelection ) {
  22069. selection = window.getSelection();
  22070. if ( selection.rangeCount ) {
  22071. this.range = selection.getRangeAt( 0 );
  22072. }
  22073. // Support: IE8
  22074. } else {
  22075. this.range = document.selection.createRange();
  22076. }
  22077. },
  22078. click: function( event ) {
  22079. this._setSelection();
  22080. this._toggle( event );
  22081. },
  22082. keydown: function( event ) {
  22083. var preventDefault = true;
  22084. switch ( event.keyCode ) {
  22085. case $.ui.keyCode.TAB:
  22086. case $.ui.keyCode.ESCAPE:
  22087. this.close( event );
  22088. preventDefault = false;
  22089. break;
  22090. case $.ui.keyCode.ENTER:
  22091. if ( this.isOpen ) {
  22092. this._selectFocusedItem( event );
  22093. }
  22094. break;
  22095. case $.ui.keyCode.UP:
  22096. if ( event.altKey ) {
  22097. this._toggle( event );
  22098. } else {
  22099. this._move( "prev", event );
  22100. }
  22101. break;
  22102. case $.ui.keyCode.DOWN:
  22103. if ( event.altKey ) {
  22104. this._toggle( event );
  22105. } else {
  22106. this._move( "next", event );
  22107. }
  22108. break;
  22109. case $.ui.keyCode.SPACE:
  22110. if ( this.isOpen ) {
  22111. this._selectFocusedItem( event );
  22112. } else {
  22113. this._toggle( event );
  22114. }
  22115. break;
  22116. case $.ui.keyCode.LEFT:
  22117. this._move( "prev", event );
  22118. break;
  22119. case $.ui.keyCode.RIGHT:
  22120. this._move( "next", event );
  22121. break;
  22122. case $.ui.keyCode.HOME:
  22123. case $.ui.keyCode.PAGE_UP:
  22124. this._move( "first", event );
  22125. break;
  22126. case $.ui.keyCode.END:
  22127. case $.ui.keyCode.PAGE_DOWN:
  22128. this._move( "last", event );
  22129. break;
  22130. default:
  22131. this.menu.trigger( event );
  22132. preventDefault = false;
  22133. }
  22134. if ( preventDefault ) {
  22135. event.preventDefault();
  22136. }
  22137. }
  22138. },
  22139. _selectFocusedItem: function( event ) {
  22140. var item = this.menuItems.eq( this.focusIndex ).parent( "li" );
  22141. if ( !item.hasClass( "ui-state-disabled" ) ) {
  22142. this._select( item.data( "ui-selectmenu-item" ), event );
  22143. }
  22144. },
  22145. _select: function( item, event ) {
  22146. var oldIndex = this.element[ 0 ].selectedIndex;
  22147. // Change native select element
  22148. this.element[ 0 ].selectedIndex = item.index;
  22149. this.buttonItem.replaceWith( this.buttonItem = this._renderButtonItem( item ) );
  22150. this._setAria( item );
  22151. this._trigger( "select", event, { item: item } );
  22152. if ( item.index !== oldIndex ) {
  22153. this._trigger( "change", event, { item: item } );
  22154. }
  22155. this.close( event );
  22156. },
  22157. _setAria: function( item ) {
  22158. var id = this.menuItems.eq( item.index ).attr( "id" );
  22159. this.button.attr( {
  22160. "aria-labelledby": id,
  22161. "aria-activedescendant": id
  22162. } );
  22163. this.menu.attr( "aria-activedescendant", id );
  22164. },
  22165. _setOption: function( key, value ) {
  22166. if ( key === "icons" ) {
  22167. var icon = this.button.find( "span.ui-icon" );
  22168. this._removeClass( icon, null, this.options.icons.button )
  22169. ._addClass( icon, null, value.button );
  22170. }
  22171. this._super( key, value );
  22172. if ( key === "appendTo" ) {
  22173. this.menuWrap.appendTo( this._appendTo() );
  22174. }
  22175. if ( key === "width" ) {
  22176. this._resizeButton();
  22177. }
  22178. },
  22179. _setOptionDisabled: function( value ) {
  22180. this._super( value );
  22181. this.menuInstance.option( "disabled", value );
  22182. this.button.attr( "aria-disabled", value );
  22183. this._toggleClass( this.button, null, "ui-state-disabled", value );
  22184. this.element.prop( "disabled", value );
  22185. if ( value ) {
  22186. this.button.attr( "tabindex", -1 );
  22187. this.close();
  22188. } else {
  22189. this.button.attr( "tabindex", 0 );
  22190. }
  22191. },
  22192. _appendTo: function() {
  22193. var element = this.options.appendTo;
  22194. if ( element ) {
  22195. element = element.jquery || element.nodeType ?
  22196. $( element ) :
  22197. this.document.find( element ).eq( 0 );
  22198. }
  22199. if ( !element || !element[ 0 ] ) {
  22200. element = this.element.closest( ".ui-front, dialog" );
  22201. }
  22202. if ( !element.length ) {
  22203. element = this.document[ 0 ].body;
  22204. }
  22205. return element;
  22206. },
  22207. _toggleAttr: function() {
  22208. this.button.attr( "aria-expanded", this.isOpen );
  22209. // We can't use two _toggleClass() calls here, because we need to make sure
  22210. // we always remove classes first and add them second, otherwise if both classes have the
  22211. // same theme class, it will be removed after we add it.
  22212. this._removeClass( this.button, "ui-selectmenu-button-" +
  22213. ( this.isOpen ? "closed" : "open" ) )
  22214. ._addClass( this.button, "ui-selectmenu-button-" +
  22215. ( this.isOpen ? "open" : "closed" ) )
  22216. ._toggleClass( this.menuWrap, "ui-selectmenu-open", null, this.isOpen );
  22217. this.menu.attr( "aria-hidden", !this.isOpen );
  22218. },
  22219. _resizeButton: function() {
  22220. var width = this.options.width;
  22221. // For `width: false`, just remove inline style and stop
  22222. if ( width === false ) {
  22223. this.button.css( "width", "" );
  22224. return;
  22225. }
  22226. // For `width: null`, match the width of the original element
  22227. if ( width === null ) {
  22228. width = this.element.show().outerWidth();
  22229. this.element.hide();
  22230. }
  22231. this.button.outerWidth( width );
  22232. },
  22233. _resizeMenu: function() {
  22234. this.menu.outerWidth( Math.max(
  22235. this.button.outerWidth(),
  22236. // Support: IE10
  22237. // IE10 wraps long text (possibly a rounding bug)
  22238. // so we add 1px to avoid the wrapping
  22239. this.menu.width( "" ).outerWidth() + 1
  22240. ) );
  22241. },
  22242. _getCreateOptions: function() {
  22243. var options = this._super();
  22244. options.disabled = this.element.prop( "disabled" );
  22245. return options;
  22246. },
  22247. _parseOptions: function( options ) {
  22248. var that = this,
  22249. data = [];
  22250. options.each( function( index, item ) {
  22251. data.push( that._parseOption( $( item ), index ) );
  22252. } );
  22253. this.items = data;
  22254. },
  22255. _parseOption: function( option, index ) {
  22256. var optgroup = option.parent( "optgroup" );
  22257. return {
  22258. element: option,
  22259. index: index,
  22260. value: option.val(),
  22261. label: option.text(),
  22262. optgroup: optgroup.attr( "label" ) || "",
  22263. disabled: optgroup.prop( "disabled" ) || option.prop( "disabled" )
  22264. };
  22265. },
  22266. _destroy: function() {
  22267. this._unbindFormResetHandler();
  22268. this.menuWrap.remove();
  22269. this.button.remove();
  22270. this.element.show();
  22271. this.element.removeUniqueId();
  22272. this.labels.attr( "for", this.ids.element );
  22273. }
  22274. } ] );
  22275. /*!
  22276. * jQuery UI Slider 1.12.1
  22277. * http://jqueryui.com
  22278. *
  22279. * Copyright jQuery Foundation and other contributors
  22280. * Released under the MIT license.
  22281. * http://jquery.org/license
  22282. */
  22283. //>>label: Slider
  22284. //>>group: Widgets
  22285. //>>description: Displays a flexible slider with ranges and accessibility via keyboard.
  22286. //>>docs: http://api.jqueryui.com/slider/
  22287. //>>demos: http://jqueryui.com/slider/
  22288. //>>css.structure: ../../themes/base/core.css
  22289. //>>css.structure: ../../themes/base/slider.css
  22290. //>>css.theme: ../../themes/base/theme.css
  22291. var widgetsSlider = $.widget( "ui.slider", $.ui.mouse, {
  22292. version: "1.12.1",
  22293. widgetEventPrefix: "slide",
  22294. options: {
  22295. animate: false,
  22296. classes: {
  22297. "ui-slider": "ui-corner-all",
  22298. "ui-slider-handle": "ui-corner-all",
  22299. // Note: ui-widget-header isn't the most fittingly semantic framework class for this
  22300. // element, but worked best visually with a variety of themes
  22301. "ui-slider-range": "ui-corner-all ui-widget-header"
  22302. },
  22303. distance: 0,
  22304. max: 100,
  22305. min: 0,
  22306. orientation: "horizontal",
  22307. range: false,
  22308. step: 1,
  22309. value: 0,
  22310. values: null,
  22311. // Callbacks
  22312. change: null,
  22313. slide: null,
  22314. start: null,
  22315. stop: null
  22316. },
  22317. // Number of pages in a slider
  22318. // (how many times can you page up/down to go through the whole range)
  22319. numPages: 5,
  22320. _create: function() {
  22321. this._keySliding = false;
  22322. this._mouseSliding = false;
  22323. this._animateOff = true;
  22324. this._handleIndex = null;
  22325. this._detectOrientation();
  22326. this._mouseInit();
  22327. this._calculateNewMax();
  22328. this._addClass( "ui-slider ui-slider-" + this.orientation,
  22329. "ui-widget ui-widget-content" );
  22330. this._refresh();
  22331. this._animateOff = false;
  22332. },
  22333. _refresh: function() {
  22334. this._createRange();
  22335. this._createHandles();
  22336. this._setupEvents();
  22337. this._refreshValue();
  22338. },
  22339. _createHandles: function() {
  22340. var i, handleCount,
  22341. options = this.options,
  22342. existingHandles = this.element.find( ".ui-slider-handle" ),
  22343. handle = "<span tabindex='0'></span>",
  22344. handles = [];
  22345. handleCount = ( options.values && options.values.length ) || 1;
  22346. if ( existingHandles.length > handleCount ) {
  22347. existingHandles.slice( handleCount ).remove();
  22348. existingHandles = existingHandles.slice( 0, handleCount );
  22349. }
  22350. for ( i = existingHandles.length; i < handleCount; i++ ) {
  22351. handles.push( handle );
  22352. }
  22353. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  22354. this._addClass( this.handles, "ui-slider-handle", "ui-state-default" );
  22355. this.handle = this.handles.eq( 0 );
  22356. this.handles.each( function( i ) {
  22357. $( this )
  22358. .data( "ui-slider-handle-index", i )
  22359. .attr( "tabIndex", 0 );
  22360. } );
  22361. },
  22362. _createRange: function() {
  22363. var options = this.options;
  22364. if ( options.range ) {
  22365. if ( options.range === true ) {
  22366. if ( !options.values ) {
  22367. options.values = [ this._valueMin(), this._valueMin() ];
  22368. } else if ( options.values.length && options.values.length !== 2 ) {
  22369. options.values = [ options.values[ 0 ], options.values[ 0 ] ];
  22370. } else if ( $.isArray( options.values ) ) {
  22371. options.values = options.values.slice( 0 );
  22372. }
  22373. }
  22374. if ( !this.range || !this.range.length ) {
  22375. this.range = $( "<div>" )
  22376. .appendTo( this.element );
  22377. this._addClass( this.range, "ui-slider-range" );
  22378. } else {
  22379. this._removeClass( this.range, "ui-slider-range-min ui-slider-range-max" );
  22380. // Handle range switching from true to min/max
  22381. this.range.css( {
  22382. "left": "",
  22383. "bottom": ""
  22384. } );
  22385. }
  22386. if ( options.range === "min" || options.range === "max" ) {
  22387. this._addClass( this.range, "ui-slider-range-" + options.range );
  22388. }
  22389. } else {
  22390. if ( this.range ) {
  22391. this.range.remove();
  22392. }
  22393. this.range = null;
  22394. }
  22395. },
  22396. _setupEvents: function() {
  22397. this._off( this.handles );
  22398. this._on( this.handles, this._handleEvents );
  22399. this._hoverable( this.handles );
  22400. this._focusable( this.handles );
  22401. },
  22402. _destroy: function() {
  22403. this.handles.remove();
  22404. if ( this.range ) {
  22405. this.range.remove();
  22406. }
  22407. this._mouseDestroy();
  22408. },
  22409. _mouseCapture: function( event ) {
  22410. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  22411. that = this,
  22412. o = this.options;
  22413. if ( o.disabled ) {
  22414. return false;
  22415. }
  22416. this.elementSize = {
  22417. width: this.element.outerWidth(),
  22418. height: this.element.outerHeight()
  22419. };
  22420. this.elementOffset = this.element.offset();
  22421. position = { x: event.pageX, y: event.pageY };
  22422. normValue = this._normValueFromMouse( position );
  22423. distance = this._valueMax() - this._valueMin() + 1;
  22424. this.handles.each( function( i ) {
  22425. var thisDistance = Math.abs( normValue - that.values( i ) );
  22426. if ( ( distance > thisDistance ) ||
  22427. ( distance === thisDistance &&
  22428. ( i === that._lastChangedValue || that.values( i ) === o.min ) ) ) {
  22429. distance = thisDistance;
  22430. closestHandle = $( this );
  22431. index = i;
  22432. }
  22433. } );
  22434. allowed = this._start( event, index );
  22435. if ( allowed === false ) {
  22436. return false;
  22437. }
  22438. this._mouseSliding = true;
  22439. this._handleIndex = index;
  22440. this._addClass( closestHandle, null, "ui-state-active" );
  22441. closestHandle.trigger( "focus" );
  22442. offset = closestHandle.offset();
  22443. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  22444. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  22445. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  22446. top: event.pageY - offset.top -
  22447. ( closestHandle.height() / 2 ) -
  22448. ( parseInt( closestHandle.css( "borderTopWidth" ), 10 ) || 0 ) -
  22449. ( parseInt( closestHandle.css( "borderBottomWidth" ), 10 ) || 0 ) +
  22450. ( parseInt( closestHandle.css( "marginTop" ), 10 ) || 0 )
  22451. };
  22452. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  22453. this._slide( event, index, normValue );
  22454. }
  22455. this._animateOff = true;
  22456. return true;
  22457. },
  22458. _mouseStart: function() {
  22459. return true;
  22460. },
  22461. _mouseDrag: function( event ) {
  22462. var position = { x: event.pageX, y: event.pageY },
  22463. normValue = this._normValueFromMouse( position );
  22464. this._slide( event, this._handleIndex, normValue );
  22465. return false;
  22466. },
  22467. _mouseStop: function( event ) {
  22468. this._removeClass( this.handles, null, "ui-state-active" );
  22469. this._mouseSliding = false;
  22470. this._stop( event, this._handleIndex );
  22471. this._change( event, this._handleIndex );
  22472. this._handleIndex = null;
  22473. this._clickOffset = null;
  22474. this._animateOff = false;
  22475. return false;
  22476. },
  22477. _detectOrientation: function() {
  22478. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  22479. },
  22480. _normValueFromMouse: function( position ) {
  22481. var pixelTotal,
  22482. pixelMouse,
  22483. percentMouse,
  22484. valueTotal,
  22485. valueMouse;
  22486. if ( this.orientation === "horizontal" ) {
  22487. pixelTotal = this.elementSize.width;
  22488. pixelMouse = position.x - this.elementOffset.left -
  22489. ( this._clickOffset ? this._clickOffset.left : 0 );
  22490. } else {
  22491. pixelTotal = this.elementSize.height;
  22492. pixelMouse = position.y - this.elementOffset.top -
  22493. ( this._clickOffset ? this._clickOffset.top : 0 );
  22494. }
  22495. percentMouse = ( pixelMouse / pixelTotal );
  22496. if ( percentMouse > 1 ) {
  22497. percentMouse = 1;
  22498. }
  22499. if ( percentMouse < 0 ) {
  22500. percentMouse = 0;
  22501. }
  22502. if ( this.orientation === "vertical" ) {
  22503. percentMouse = 1 - percentMouse;
  22504. }
  22505. valueTotal = this._valueMax() - this._valueMin();
  22506. valueMouse = this._valueMin() + percentMouse * valueTotal;
  22507. return this._trimAlignValue( valueMouse );
  22508. },
  22509. _uiHash: function( index, value, values ) {
  22510. var uiHash = {
  22511. handle: this.handles[ index ],
  22512. handleIndex: index,
  22513. value: value !== undefined ? value : this.value()
  22514. };
  22515. if ( this._hasMultipleValues() ) {
  22516. uiHash.value = value !== undefined ? value : this.values( index );
  22517. uiHash.values = values || this.values();
  22518. }
  22519. return uiHash;
  22520. },
  22521. _hasMultipleValues: function() {
  22522. return this.options.values && this.options.values.length;
  22523. },
  22524. _start: function( event, index ) {
  22525. return this._trigger( "start", event, this._uiHash( index ) );
  22526. },
  22527. _slide: function( event, index, newVal ) {
  22528. var allowed, otherVal,
  22529. currentValue = this.value(),
  22530. newValues = this.values();
  22531. if ( this._hasMultipleValues() ) {
  22532. otherVal = this.values( index ? 0 : 1 );
  22533. currentValue = this.values( index );
  22534. if ( this.options.values.length === 2 && this.options.range === true ) {
  22535. newVal = index === 0 ? Math.min( otherVal, newVal ) : Math.max( otherVal, newVal );
  22536. }
  22537. newValues[ index ] = newVal;
  22538. }
  22539. if ( newVal === currentValue ) {
  22540. return;
  22541. }
  22542. allowed = this._trigger( "slide", event, this._uiHash( index, newVal, newValues ) );
  22543. // A slide can be canceled by returning false from the slide callback
  22544. if ( allowed === false ) {
  22545. return;
  22546. }
  22547. if ( this._hasMultipleValues() ) {
  22548. this.values( index, newVal );
  22549. } else {
  22550. this.value( newVal );
  22551. }
  22552. },
  22553. _stop: function( event, index ) {
  22554. this._trigger( "stop", event, this._uiHash( index ) );
  22555. },
  22556. _change: function( event, index ) {
  22557. if ( !this._keySliding && !this._mouseSliding ) {
  22558. //store the last changed value index for reference when handles overlap
  22559. this._lastChangedValue = index;
  22560. this._trigger( "change", event, this._uiHash( index ) );
  22561. }
  22562. },
  22563. value: function( newValue ) {
  22564. if ( arguments.length ) {
  22565. this.options.value = this._trimAlignValue( newValue );
  22566. this._refreshValue();
  22567. this._change( null, 0 );
  22568. return;
  22569. }
  22570. return this._value();
  22571. },
  22572. values: function( index, newValue ) {
  22573. var vals,
  22574. newValues,
  22575. i;
  22576. if ( arguments.length > 1 ) {
  22577. this.options.values[ index ] = this._trimAlignValue( newValue );
  22578. this._refreshValue();
  22579. this._change( null, index );
  22580. return;
  22581. }
  22582. if ( arguments.length ) {
  22583. if ( $.isArray( arguments[ 0 ] ) ) {
  22584. vals = this.options.values;
  22585. newValues = arguments[ 0 ];
  22586. for ( i = 0; i < vals.length; i += 1 ) {
  22587. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  22588. this._change( null, i );
  22589. }
  22590. this._refreshValue();
  22591. } else {
  22592. if ( this._hasMultipleValues() ) {
  22593. return this._values( index );
  22594. } else {
  22595. return this.value();
  22596. }
  22597. }
  22598. } else {
  22599. return this._values();
  22600. }
  22601. },
  22602. _setOption: function( key, value ) {
  22603. var i,
  22604. valsLength = 0;
  22605. if ( key === "range" && this.options.range === true ) {
  22606. if ( value === "min" ) {
  22607. this.options.value = this._values( 0 );
  22608. this.options.values = null;
  22609. } else if ( value === "max" ) {
  22610. this.options.value = this._values( this.options.values.length - 1 );
  22611. this.options.values = null;
  22612. }
  22613. }
  22614. if ( $.isArray( this.options.values ) ) {
  22615. valsLength = this.options.values.length;
  22616. }
  22617. this._super( key, value );
  22618. switch ( key ) {
  22619. case "orientation":
  22620. this._detectOrientation();
  22621. this._removeClass( "ui-slider-horizontal ui-slider-vertical" )
  22622. ._addClass( "ui-slider-" + this.orientation );
  22623. this._refreshValue();
  22624. if ( this.options.range ) {
  22625. this._refreshRange( value );
  22626. }
  22627. // Reset positioning from previous orientation
  22628. this.handles.css( value === "horizontal" ? "bottom" : "left", "" );
  22629. break;
  22630. case "value":
  22631. this._animateOff = true;
  22632. this._refreshValue();
  22633. this._change( null, 0 );
  22634. this._animateOff = false;
  22635. break;
  22636. case "values":
  22637. this._animateOff = true;
  22638. this._refreshValue();
  22639. // Start from the last handle to prevent unreachable handles (#9046)
  22640. for ( i = valsLength - 1; i >= 0; i-- ) {
  22641. this._change( null, i );
  22642. }
  22643. this._animateOff = false;
  22644. break;
  22645. case "step":
  22646. case "min":
  22647. case "max":
  22648. this._animateOff = true;
  22649. this._calculateNewMax();
  22650. this._refreshValue();
  22651. this._animateOff = false;
  22652. break;
  22653. case "range":
  22654. this._animateOff = true;
  22655. this._refresh();
  22656. this._animateOff = false;
  22657. break;
  22658. }
  22659. },
  22660. _setOptionDisabled: function( value ) {
  22661. this._super( value );
  22662. this._toggleClass( null, "ui-state-disabled", !!value );
  22663. },
  22664. //internal value getter
  22665. // _value() returns value trimmed by min and max, aligned by step
  22666. _value: function() {
  22667. var val = this.options.value;
  22668. val = this._trimAlignValue( val );
  22669. return val;
  22670. },
  22671. //internal values getter
  22672. // _values() returns array of values trimmed by min and max, aligned by step
  22673. // _values( index ) returns single value trimmed by min and max, aligned by step
  22674. _values: function( index ) {
  22675. var val,
  22676. vals,
  22677. i;
  22678. if ( arguments.length ) {
  22679. val = this.options.values[ index ];
  22680. val = this._trimAlignValue( val );
  22681. return val;
  22682. } else if ( this._hasMultipleValues() ) {
  22683. // .slice() creates a copy of the array
  22684. // this copy gets trimmed by min and max and then returned
  22685. vals = this.options.values.slice();
  22686. for ( i = 0; i < vals.length; i += 1 ) {
  22687. vals[ i ] = this._trimAlignValue( vals[ i ] );
  22688. }
  22689. return vals;
  22690. } else {
  22691. return [];
  22692. }
  22693. },
  22694. // Returns the step-aligned value that val is closest to, between (inclusive) min and max
  22695. _trimAlignValue: function( val ) {
  22696. if ( val <= this._valueMin() ) {
  22697. return this._valueMin();
  22698. }
  22699. if ( val >= this._valueMax() ) {
  22700. return this._valueMax();
  22701. }
  22702. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  22703. valModStep = ( val - this._valueMin() ) % step,
  22704. alignValue = val - valModStep;
  22705. if ( Math.abs( valModStep ) * 2 >= step ) {
  22706. alignValue += ( valModStep > 0 ) ? step : ( -step );
  22707. }
  22708. // Since JavaScript has problems with large floats, round
  22709. // the final value to 5 digits after the decimal point (see #4124)
  22710. return parseFloat( alignValue.toFixed( 5 ) );
  22711. },
  22712. _calculateNewMax: function() {
  22713. var max = this.options.max,
  22714. min = this._valueMin(),
  22715. step = this.options.step,
  22716. aboveMin = Math.round( ( max - min ) / step ) * step;
  22717. max = aboveMin + min;
  22718. if ( max > this.options.max ) {
  22719. //If max is not divisible by step, rounding off may increase its value
  22720. max -= step;
  22721. }
  22722. this.max = parseFloat( max.toFixed( this._precision() ) );
  22723. },
  22724. _precision: function() {
  22725. var precision = this._precisionOf( this.options.step );
  22726. if ( this.options.min !== null ) {
  22727. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  22728. }
  22729. return precision;
  22730. },
  22731. _precisionOf: function( num ) {
  22732. var str = num.toString(),
  22733. decimal = str.indexOf( "." );
  22734. return decimal === -1 ? 0 : str.length - decimal - 1;
  22735. },
  22736. _valueMin: function() {
  22737. return this.options.min;
  22738. },
  22739. _valueMax: function() {
  22740. return this.max;
  22741. },
  22742. _refreshRange: function( orientation ) {
  22743. if ( orientation === "vertical" ) {
  22744. this.range.css( { "width": "", "left": "" } );
  22745. }
  22746. if ( orientation === "horizontal" ) {
  22747. this.range.css( { "height": "", "bottom": "" } );
  22748. }
  22749. },
  22750. _refreshValue: function() {
  22751. var lastValPercent, valPercent, value, valueMin, valueMax,
  22752. oRange = this.options.range,
  22753. o = this.options,
  22754. that = this,
  22755. animate = ( !this._animateOff ) ? o.animate : false,
  22756. _set = {};
  22757. if ( this._hasMultipleValues() ) {
  22758. this.handles.each( function( i ) {
  22759. valPercent = ( that.values( i ) - that._valueMin() ) / ( that._valueMax() -
  22760. that._valueMin() ) * 100;
  22761. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  22762. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  22763. if ( that.options.range === true ) {
  22764. if ( that.orientation === "horizontal" ) {
  22765. if ( i === 0 ) {
  22766. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  22767. left: valPercent + "%"
  22768. }, o.animate );
  22769. }
  22770. if ( i === 1 ) {
  22771. that.range[ animate ? "animate" : "css" ]( {
  22772. width: ( valPercent - lastValPercent ) + "%"
  22773. }, {
  22774. queue: false,
  22775. duration: o.animate
  22776. } );
  22777. }
  22778. } else {
  22779. if ( i === 0 ) {
  22780. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  22781. bottom: ( valPercent ) + "%"
  22782. }, o.animate );
  22783. }
  22784. if ( i === 1 ) {
  22785. that.range[ animate ? "animate" : "css" ]( {
  22786. height: ( valPercent - lastValPercent ) + "%"
  22787. }, {
  22788. queue: false,
  22789. duration: o.animate
  22790. } );
  22791. }
  22792. }
  22793. }
  22794. lastValPercent = valPercent;
  22795. } );
  22796. } else {
  22797. value = this.value();
  22798. valueMin = this._valueMin();
  22799. valueMax = this._valueMax();
  22800. valPercent = ( valueMax !== valueMin ) ?
  22801. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  22802. 0;
  22803. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  22804. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  22805. if ( oRange === "min" && this.orientation === "horizontal" ) {
  22806. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  22807. width: valPercent + "%"
  22808. }, o.animate );
  22809. }
  22810. if ( oRange === "max" && this.orientation === "horizontal" ) {
  22811. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  22812. width: ( 100 - valPercent ) + "%"
  22813. }, o.animate );
  22814. }
  22815. if ( oRange === "min" && this.orientation === "vertical" ) {
  22816. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  22817. height: valPercent + "%"
  22818. }, o.animate );
  22819. }
  22820. if ( oRange === "max" && this.orientation === "vertical" ) {
  22821. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  22822. height: ( 100 - valPercent ) + "%"
  22823. }, o.animate );
  22824. }
  22825. }
  22826. },
  22827. _handleEvents: {
  22828. keydown: function( event ) {
  22829. var allowed, curVal, newVal, step,
  22830. index = $( event.target ).data( "ui-slider-handle-index" );
  22831. switch ( event.keyCode ) {
  22832. case $.ui.keyCode.HOME:
  22833. case $.ui.keyCode.END:
  22834. case $.ui.keyCode.PAGE_UP:
  22835. case $.ui.keyCode.PAGE_DOWN:
  22836. case $.ui.keyCode.UP:
  22837. case $.ui.keyCode.RIGHT:
  22838. case $.ui.keyCode.DOWN:
  22839. case $.ui.keyCode.LEFT:
  22840. event.preventDefault();
  22841. if ( !this._keySliding ) {
  22842. this._keySliding = true;
  22843. this._addClass( $( event.target ), null, "ui-state-active" );
  22844. allowed = this._start( event, index );
  22845. if ( allowed === false ) {
  22846. return;
  22847. }
  22848. }
  22849. break;
  22850. }
  22851. step = this.options.step;
  22852. if ( this._hasMultipleValues() ) {
  22853. curVal = newVal = this.values( index );
  22854. } else {
  22855. curVal = newVal = this.value();
  22856. }
  22857. switch ( event.keyCode ) {
  22858. case $.ui.keyCode.HOME:
  22859. newVal = this._valueMin();
  22860. break;
  22861. case $.ui.keyCode.END:
  22862. newVal = this._valueMax();
  22863. break;
  22864. case $.ui.keyCode.PAGE_UP:
  22865. newVal = this._trimAlignValue(
  22866. curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
  22867. );
  22868. break;
  22869. case $.ui.keyCode.PAGE_DOWN:
  22870. newVal = this._trimAlignValue(
  22871. curVal - ( ( this._valueMax() - this._valueMin() ) / this.numPages ) );
  22872. break;
  22873. case $.ui.keyCode.UP:
  22874. case $.ui.keyCode.RIGHT:
  22875. if ( curVal === this._valueMax() ) {
  22876. return;
  22877. }
  22878. newVal = this._trimAlignValue( curVal + step );
  22879. break;
  22880. case $.ui.keyCode.DOWN:
  22881. case $.ui.keyCode.LEFT:
  22882. if ( curVal === this._valueMin() ) {
  22883. return;
  22884. }
  22885. newVal = this._trimAlignValue( curVal - step );
  22886. break;
  22887. }
  22888. this._slide( event, index, newVal );
  22889. },
  22890. keyup: function( event ) {
  22891. var index = $( event.target ).data( "ui-slider-handle-index" );
  22892. if ( this._keySliding ) {
  22893. this._keySliding = false;
  22894. this._stop( event, index );
  22895. this._change( event, index );
  22896. this._removeClass( $( event.target ), null, "ui-state-active" );
  22897. }
  22898. }
  22899. }
  22900. } );
  22901. /*!
  22902. * jQuery UI Sortable 1.12.1
  22903. * http://jqueryui.com
  22904. *
  22905. * Copyright jQuery Foundation and other contributors
  22906. * Released under the MIT license.
  22907. * http://jquery.org/license
  22908. */
  22909. //>>label: Sortable
  22910. //>>group: Interactions
  22911. //>>description: Enables items in a list to be sorted using the mouse.
  22912. //>>docs: http://api.jqueryui.com/sortable/
  22913. //>>demos: http://jqueryui.com/sortable/
  22914. //>>css.structure: ../../themes/base/sortable.css
  22915. var widgetsSortable = $.widget( "ui.sortable", $.ui.mouse, {
  22916. version: "1.12.1",
  22917. widgetEventPrefix: "sort",
  22918. ready: false,
  22919. options: {
  22920. appendTo: "parent",
  22921. axis: false,
  22922. connectWith: false,
  22923. containment: false,
  22924. cursor: "auto",
  22925. cursorAt: false,
  22926. dropOnEmpty: true,
  22927. forcePlaceholderSize: false,
  22928. forceHelperSize: false,
  22929. grid: false,
  22930. handle: false,
  22931. helper: "original",
  22932. items: "> *",
  22933. opacity: false,
  22934. placeholder: false,
  22935. revert: false,
  22936. scroll: true,
  22937. scrollSensitivity: 20,
  22938. scrollSpeed: 20,
  22939. scope: "default",
  22940. tolerance: "intersect",
  22941. zIndex: 1000,
  22942. // Callbacks
  22943. activate: null,
  22944. beforeStop: null,
  22945. change: null,
  22946. deactivate: null,
  22947. out: null,
  22948. over: null,
  22949. receive: null,
  22950. remove: null,
  22951. sort: null,
  22952. start: null,
  22953. stop: null,
  22954. update: null
  22955. },
  22956. _isOverAxis: function( x, reference, size ) {
  22957. return ( x >= reference ) && ( x < ( reference + size ) );
  22958. },
  22959. _isFloating: function( item ) {
  22960. return ( /left|right/ ).test( item.css( "float" ) ) ||
  22961. ( /inline|table-cell/ ).test( item.css( "display" ) );
  22962. },
  22963. _create: function() {
  22964. this.containerCache = {};
  22965. this._addClass( "ui-sortable" );
  22966. //Get the items
  22967. this.refresh();
  22968. //Let's determine the parent's offset
  22969. this.offset = this.element.offset();
  22970. //Initialize mouse events for interaction
  22971. this._mouseInit();
  22972. this._setHandleClassName();
  22973. //We're ready to go
  22974. this.ready = true;
  22975. },
  22976. _setOption: function( key, value ) {
  22977. this._super( key, value );
  22978. if ( key === "handle" ) {
  22979. this._setHandleClassName();
  22980. }
  22981. },
  22982. _setHandleClassName: function() {
  22983. var that = this;
  22984. this._removeClass( this.element.find( ".ui-sortable-handle" ), "ui-sortable-handle" );
  22985. $.each( this.items, function() {
  22986. that._addClass(
  22987. this.instance.options.handle ?
  22988. this.item.find( this.instance.options.handle ) :
  22989. this.item,
  22990. "ui-sortable-handle"
  22991. );
  22992. } );
  22993. },
  22994. _destroy: function() {
  22995. this._mouseDestroy();
  22996. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  22997. this.items[ i ].item.removeData( this.widgetName + "-item" );
  22998. }
  22999. return this;
  23000. },
  23001. _mouseCapture: function( event, overrideHandle ) {
  23002. var currentItem = null,
  23003. validHandle = false,
  23004. that = this;
  23005. if ( this.reverting ) {
  23006. return false;
  23007. }
  23008. if ( this.options.disabled || this.options.type === "static" ) {
  23009. return false;
  23010. }
  23011. //We have to refresh the items data once first
  23012. this._refreshItems( event );
  23013. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  23014. $( event.target ).parents().each( function() {
  23015. if ( $.data( this, that.widgetName + "-item" ) === that ) {
  23016. currentItem = $( this );
  23017. return false;
  23018. }
  23019. } );
  23020. if ( $.data( event.target, that.widgetName + "-item" ) === that ) {
  23021. currentItem = $( event.target );
  23022. }
  23023. if ( !currentItem ) {
  23024. return false;
  23025. }
  23026. if ( this.options.handle && !overrideHandle ) {
  23027. $( this.options.handle, currentItem ).find( "*" ).addBack().each( function() {
  23028. if ( this === event.target ) {
  23029. validHandle = true;
  23030. }
  23031. } );
  23032. if ( !validHandle ) {
  23033. return false;
  23034. }
  23035. }
  23036. this.currentItem = currentItem;
  23037. this._removeCurrentsFromItems();
  23038. return true;
  23039. },
  23040. _mouseStart: function( event, overrideHandle, noActivation ) {
  23041. var i, body,
  23042. o = this.options;
  23043. this.currentContainer = this;
  23044. //We only need to call refreshPositions, because the refreshItems call has been moved to
  23045. // mouseCapture
  23046. this.refreshPositions();
  23047. //Create and append the visible helper
  23048. this.helper = this._createHelper( event );
  23049. //Cache the helper size
  23050. this._cacheHelperProportions();
  23051. /*
  23052. * - Position generation -
  23053. * This block generates everything position related - it's the core of draggables.
  23054. */
  23055. //Cache the margins of the original element
  23056. this._cacheMargins();
  23057. //Get the next scrolling parent
  23058. this.scrollParent = this.helper.scrollParent();
  23059. //The element's absolute position on the page minus margins
  23060. this.offset = this.currentItem.offset();
  23061. this.offset = {
  23062. top: this.offset.top - this.margins.top,
  23063. left: this.offset.left - this.margins.left
  23064. };
  23065. $.extend( this.offset, {
  23066. click: { //Where the click happened, relative to the element
  23067. left: event.pageX - this.offset.left,
  23068. top: event.pageY - this.offset.top
  23069. },
  23070. parent: this._getParentOffset(),
  23071. // This is a relative to absolute position minus the actual position calculation -
  23072. // only used for relative positioned helper
  23073. relative: this._getRelativeOffset()
  23074. } );
  23075. // Only after we got the offset, we can change the helper's position to absolute
  23076. // TODO: Still need to figure out a way to make relative sorting possible
  23077. this.helper.css( "position", "absolute" );
  23078. this.cssPosition = this.helper.css( "position" );
  23079. //Generate the original position
  23080. this.originalPosition = this._generatePosition( event );
  23081. this.originalPageX = event.pageX;
  23082. this.originalPageY = event.pageY;
  23083. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  23084. ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) );
  23085. //Cache the former DOM position
  23086. this.domPosition = {
  23087. prev: this.currentItem.prev()[ 0 ],
  23088. parent: this.currentItem.parent()[ 0 ]
  23089. };
  23090. // If the helper is not the original, hide the original so it's not playing any role during
  23091. // the drag, won't cause anything bad this way
  23092. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  23093. this.currentItem.hide();
  23094. }
  23095. //Create the placeholder
  23096. this._createPlaceholder();
  23097. //Set a containment if given in the options
  23098. if ( o.containment ) {
  23099. this._setContainment();
  23100. }
  23101. if ( o.cursor && o.cursor !== "auto" ) { // cursor option
  23102. body = this.document.find( "body" );
  23103. // Support: IE
  23104. this.storedCursor = body.css( "cursor" );
  23105. body.css( "cursor", o.cursor );
  23106. this.storedStylesheet =
  23107. $( "<style>*{ cursor: " + o.cursor + " !important; }</style>" ).appendTo( body );
  23108. }
  23109. if ( o.opacity ) { // opacity option
  23110. if ( this.helper.css( "opacity" ) ) {
  23111. this._storedOpacity = this.helper.css( "opacity" );
  23112. }
  23113. this.helper.css( "opacity", o.opacity );
  23114. }
  23115. if ( o.zIndex ) { // zIndex option
  23116. if ( this.helper.css( "zIndex" ) ) {
  23117. this._storedZIndex = this.helper.css( "zIndex" );
  23118. }
  23119. this.helper.css( "zIndex", o.zIndex );
  23120. }
  23121. //Prepare scrolling
  23122. if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  23123. this.scrollParent[ 0 ].tagName !== "HTML" ) {
  23124. this.overflowOffset = this.scrollParent.offset();
  23125. }
  23126. //Call callbacks
  23127. this._trigger( "start", event, this._uiHash() );
  23128. //Recache the helper size
  23129. if ( !this._preserveHelperProportions ) {
  23130. this._cacheHelperProportions();
  23131. }
  23132. //Post "activate" events to possible containers
  23133. if ( !noActivation ) {
  23134. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  23135. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  23136. }
  23137. }
  23138. //Prepare possible droppables
  23139. if ( $.ui.ddmanager ) {
  23140. $.ui.ddmanager.current = this;
  23141. }
  23142. if ( $.ui.ddmanager && !o.dropBehaviour ) {
  23143. $.ui.ddmanager.prepareOffsets( this, event );
  23144. }
  23145. this.dragging = true;
  23146. this._addClass( this.helper, "ui-sortable-helper" );
  23147. // Execute the drag once - this causes the helper not to be visiblebefore getting its
  23148. // correct position
  23149. this._mouseDrag( event );
  23150. return true;
  23151. },
  23152. _mouseDrag: function( event ) {
  23153. var i, item, itemElement, intersection,
  23154. o = this.options,
  23155. scrolled = false;
  23156. //Compute the helpers position
  23157. this.position = this._generatePosition( event );
  23158. this.positionAbs = this._convertPositionTo( "absolute" );
  23159. if ( !this.lastPositionAbs ) {
  23160. this.lastPositionAbs = this.positionAbs;
  23161. }
  23162. //Do scrolling
  23163. if ( this.options.scroll ) {
  23164. if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  23165. this.scrollParent[ 0 ].tagName !== "HTML" ) {
  23166. if ( ( this.overflowOffset.top + this.scrollParent[ 0 ].offsetHeight ) -
  23167. event.pageY < o.scrollSensitivity ) {
  23168. this.scrollParent[ 0 ].scrollTop =
  23169. scrolled = this.scrollParent[ 0 ].scrollTop + o.scrollSpeed;
  23170. } else if ( event.pageY - this.overflowOffset.top < o.scrollSensitivity ) {
  23171. this.scrollParent[ 0 ].scrollTop =
  23172. scrolled = this.scrollParent[ 0 ].scrollTop - o.scrollSpeed;
  23173. }
  23174. if ( ( this.overflowOffset.left + this.scrollParent[ 0 ].offsetWidth ) -
  23175. event.pageX < o.scrollSensitivity ) {
  23176. this.scrollParent[ 0 ].scrollLeft = scrolled =
  23177. this.scrollParent[ 0 ].scrollLeft + o.scrollSpeed;
  23178. } else if ( event.pageX - this.overflowOffset.left < o.scrollSensitivity ) {
  23179. this.scrollParent[ 0 ].scrollLeft = scrolled =
  23180. this.scrollParent[ 0 ].scrollLeft - o.scrollSpeed;
  23181. }
  23182. } else {
  23183. if ( event.pageY - this.document.scrollTop() < o.scrollSensitivity ) {
  23184. scrolled = this.document.scrollTop( this.document.scrollTop() - o.scrollSpeed );
  23185. } else if ( this.window.height() - ( event.pageY - this.document.scrollTop() ) <
  23186. o.scrollSensitivity ) {
  23187. scrolled = this.document.scrollTop( this.document.scrollTop() + o.scrollSpeed );
  23188. }
  23189. if ( event.pageX - this.document.scrollLeft() < o.scrollSensitivity ) {
  23190. scrolled = this.document.scrollLeft(
  23191. this.document.scrollLeft() - o.scrollSpeed
  23192. );
  23193. } else if ( this.window.width() - ( event.pageX - this.document.scrollLeft() ) <
  23194. o.scrollSensitivity ) {
  23195. scrolled = this.document.scrollLeft(
  23196. this.document.scrollLeft() + o.scrollSpeed
  23197. );
  23198. }
  23199. }
  23200. if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
  23201. $.ui.ddmanager.prepareOffsets( this, event );
  23202. }
  23203. }
  23204. //Regenerate the absolute position used for position checks
  23205. this.positionAbs = this._convertPositionTo( "absolute" );
  23206. //Set the helper position
  23207. if ( !this.options.axis || this.options.axis !== "y" ) {
  23208. this.helper[ 0 ].style.left = this.position.left + "px";
  23209. }
  23210. if ( !this.options.axis || this.options.axis !== "x" ) {
  23211. this.helper[ 0 ].style.top = this.position.top + "px";
  23212. }
  23213. //Rearrange
  23214. for ( i = this.items.length - 1; i >= 0; i-- ) {
  23215. //Cache variables and intersection, continue if no intersection
  23216. item = this.items[ i ];
  23217. itemElement = item.item[ 0 ];
  23218. intersection = this._intersectsWithPointer( item );
  23219. if ( !intersection ) {
  23220. continue;
  23221. }
  23222. // Only put the placeholder inside the current Container, skip all
  23223. // items from other containers. This works because when moving
  23224. // an item from one container to another the
  23225. // currentContainer is switched before the placeholder is moved.
  23226. //
  23227. // Without this, moving items in "sub-sortables" can cause
  23228. // the placeholder to jitter between the outer and inner container.
  23229. if ( item.instance !== this.currentContainer ) {
  23230. continue;
  23231. }
  23232. // Cannot intersect with itself
  23233. // no useless actions that have been done before
  23234. // no action if the item moved is the parent of the item checked
  23235. if ( itemElement !== this.currentItem[ 0 ] &&
  23236. this.placeholder[ intersection === 1 ? "next" : "prev" ]()[ 0 ] !== itemElement &&
  23237. !$.contains( this.placeholder[ 0 ], itemElement ) &&
  23238. ( this.options.type === "semi-dynamic" ?
  23239. !$.contains( this.element[ 0 ], itemElement ) :
  23240. true
  23241. )
  23242. ) {
  23243. this.direction = intersection === 1 ? "down" : "up";
  23244. if ( this.options.tolerance === "pointer" || this._intersectsWithSides( item ) ) {
  23245. this._rearrange( event, item );
  23246. } else {
  23247. break;
  23248. }
  23249. this._trigger( "change", event, this._uiHash() );
  23250. break;
  23251. }
  23252. }
  23253. //Post events to containers
  23254. this._contactContainers( event );
  23255. //Interconnect with droppables
  23256. if ( $.ui.ddmanager ) {
  23257. $.ui.ddmanager.drag( this, event );
  23258. }
  23259. //Call callbacks
  23260. this._trigger( "sort", event, this._uiHash() );
  23261. this.lastPositionAbs = this.positionAbs;
  23262. return false;
  23263. },
  23264. _mouseStop: function( event, noPropagation ) {
  23265. if ( !event ) {
  23266. return;
  23267. }
  23268. //If we are using droppables, inform the manager about the drop
  23269. if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
  23270. $.ui.ddmanager.drop( this, event );
  23271. }
  23272. if ( this.options.revert ) {
  23273. var that = this,
  23274. cur = this.placeholder.offset(),
  23275. axis = this.options.axis,
  23276. animation = {};
  23277. if ( !axis || axis === "x" ) {
  23278. animation.left = cur.left - this.offset.parent.left - this.margins.left +
  23279. ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
  23280. 0 :
  23281. this.offsetParent[ 0 ].scrollLeft
  23282. );
  23283. }
  23284. if ( !axis || axis === "y" ) {
  23285. animation.top = cur.top - this.offset.parent.top - this.margins.top +
  23286. ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
  23287. 0 :
  23288. this.offsetParent[ 0 ].scrollTop
  23289. );
  23290. }
  23291. this.reverting = true;
  23292. $( this.helper ).animate(
  23293. animation,
  23294. parseInt( this.options.revert, 10 ) || 500,
  23295. function() {
  23296. that._clear( event );
  23297. }
  23298. );
  23299. } else {
  23300. this._clear( event, noPropagation );
  23301. }
  23302. return false;
  23303. },
  23304. cancel: function() {
  23305. if ( this.dragging ) {
  23306. this._mouseUp( new $.Event( "mouseup", { target: null } ) );
  23307. if ( this.options.helper === "original" ) {
  23308. this.currentItem.css( this._storedCSS );
  23309. this._removeClass( this.currentItem, "ui-sortable-helper" );
  23310. } else {
  23311. this.currentItem.show();
  23312. }
  23313. //Post deactivating events to containers
  23314. for ( var i = this.containers.length - 1; i >= 0; i-- ) {
  23315. this.containers[ i ]._trigger( "deactivate", null, this._uiHash( this ) );
  23316. if ( this.containers[ i ].containerCache.over ) {
  23317. this.containers[ i ]._trigger( "out", null, this._uiHash( this ) );
  23318. this.containers[ i ].containerCache.over = 0;
  23319. }
  23320. }
  23321. }
  23322. if ( this.placeholder ) {
  23323. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
  23324. // it unbinds ALL events from the original node!
  23325. if ( this.placeholder[ 0 ].parentNode ) {
  23326. this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
  23327. }
  23328. if ( this.options.helper !== "original" && this.helper &&
  23329. this.helper[ 0 ].parentNode ) {
  23330. this.helper.remove();
  23331. }
  23332. $.extend( this, {
  23333. helper: null,
  23334. dragging: false,
  23335. reverting: false,
  23336. _noFinalSort: null
  23337. } );
  23338. if ( this.domPosition.prev ) {
  23339. $( this.domPosition.prev ).after( this.currentItem );
  23340. } else {
  23341. $( this.domPosition.parent ).prepend( this.currentItem );
  23342. }
  23343. }
  23344. return this;
  23345. },
  23346. serialize: function( o ) {
  23347. var items = this._getItemsAsjQuery( o && o.connected ),
  23348. str = [];
  23349. o = o || {};
  23350. $( items ).each( function() {
  23351. var res = ( $( o.item || this ).attr( o.attribute || "id" ) || "" )
  23352. .match( o.expression || ( /(.+)[\-=_](.+)/ ) );
  23353. if ( res ) {
  23354. str.push(
  23355. ( o.key || res[ 1 ] + "[]" ) +
  23356. "=" + ( o.key && o.expression ? res[ 1 ] : res[ 2 ] ) );
  23357. }
  23358. } );
  23359. if ( !str.length && o.key ) {
  23360. str.push( o.key + "=" );
  23361. }
  23362. return str.join( "&" );
  23363. },
  23364. toArray: function( o ) {
  23365. var items = this._getItemsAsjQuery( o && o.connected ),
  23366. ret = [];
  23367. o = o || {};
  23368. items.each( function() {
  23369. ret.push( $( o.item || this ).attr( o.attribute || "id" ) || "" );
  23370. } );
  23371. return ret;
  23372. },
  23373. /* Be careful with the following core functions */
  23374. _intersectsWith: function( item ) {
  23375. var x1 = this.positionAbs.left,
  23376. x2 = x1 + this.helperProportions.width,
  23377. y1 = this.positionAbs.top,
  23378. y2 = y1 + this.helperProportions.height,
  23379. l = item.left,
  23380. r = l + item.width,
  23381. t = item.top,
  23382. b = t + item.height,
  23383. dyClick = this.offset.click.top,
  23384. dxClick = this.offset.click.left,
  23385. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t &&
  23386. ( y1 + dyClick ) < b ),
  23387. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l &&
  23388. ( x1 + dxClick ) < r ),
  23389. isOverElement = isOverElementHeight && isOverElementWidth;
  23390. if ( this.options.tolerance === "pointer" ||
  23391. this.options.forcePointerForContainers ||
  23392. ( this.options.tolerance !== "pointer" &&
  23393. this.helperProportions[ this.floating ? "width" : "height" ] >
  23394. item[ this.floating ? "width" : "height" ] )
  23395. ) {
  23396. return isOverElement;
  23397. } else {
  23398. return ( l < x1 + ( this.helperProportions.width / 2 ) && // Right Half
  23399. x2 - ( this.helperProportions.width / 2 ) < r && // Left Half
  23400. t < y1 + ( this.helperProportions.height / 2 ) && // Bottom Half
  23401. y2 - ( this.helperProportions.height / 2 ) < b ); // Top Half
  23402. }
  23403. },
  23404. _intersectsWithPointer: function( item ) {
  23405. var verticalDirection, horizontalDirection,
  23406. isOverElementHeight = ( this.options.axis === "x" ) ||
  23407. this._isOverAxis(
  23408. this.positionAbs.top + this.offset.click.top, item.top, item.height ),
  23409. isOverElementWidth = ( this.options.axis === "y" ) ||
  23410. this._isOverAxis(
  23411. this.positionAbs.left + this.offset.click.left, item.left, item.width ),
  23412. isOverElement = isOverElementHeight && isOverElementWidth;
  23413. if ( !isOverElement ) {
  23414. return false;
  23415. }
  23416. verticalDirection = this._getDragVerticalDirection();
  23417. horizontalDirection = this._getDragHorizontalDirection();
  23418. return this.floating ?
  23419. ( ( horizontalDirection === "right" || verticalDirection === "down" ) ? 2 : 1 )
  23420. : ( verticalDirection && ( verticalDirection === "down" ? 2 : 1 ) );
  23421. },
  23422. _intersectsWithSides: function( item ) {
  23423. var isOverBottomHalf = this._isOverAxis( this.positionAbs.top +
  23424. this.offset.click.top, item.top + ( item.height / 2 ), item.height ),
  23425. isOverRightHalf = this._isOverAxis( this.positionAbs.left +
  23426. this.offset.click.left, item.left + ( item.width / 2 ), item.width ),
  23427. verticalDirection = this._getDragVerticalDirection(),
  23428. horizontalDirection = this._getDragHorizontalDirection();
  23429. if ( this.floating && horizontalDirection ) {
  23430. return ( ( horizontalDirection === "right" && isOverRightHalf ) ||
  23431. ( horizontalDirection === "left" && !isOverRightHalf ) );
  23432. } else {
  23433. return verticalDirection && ( ( verticalDirection === "down" && isOverBottomHalf ) ||
  23434. ( verticalDirection === "up" && !isOverBottomHalf ) );
  23435. }
  23436. },
  23437. _getDragVerticalDirection: function() {
  23438. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  23439. return delta !== 0 && ( delta > 0 ? "down" : "up" );
  23440. },
  23441. _getDragHorizontalDirection: function() {
  23442. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  23443. return delta !== 0 && ( delta > 0 ? "right" : "left" );
  23444. },
  23445. refresh: function( event ) {
  23446. this._refreshItems( event );
  23447. this._setHandleClassName();
  23448. this.refreshPositions();
  23449. return this;
  23450. },
  23451. _connectWith: function() {
  23452. var options = this.options;
  23453. return options.connectWith.constructor === String ?
  23454. [ options.connectWith ] :
  23455. options.connectWith;
  23456. },
  23457. _getItemsAsjQuery: function( connected ) {
  23458. var i, j, cur, inst,
  23459. items = [],
  23460. queries = [],
  23461. connectWith = this._connectWith();
  23462. if ( connectWith && connected ) {
  23463. for ( i = connectWith.length - 1; i >= 0; i-- ) {
  23464. cur = $( connectWith[ i ], this.document[ 0 ] );
  23465. for ( j = cur.length - 1; j >= 0; j-- ) {
  23466. inst = $.data( cur[ j ], this.widgetFullName );
  23467. if ( inst && inst !== this && !inst.options.disabled ) {
  23468. queries.push( [ $.isFunction( inst.options.items ) ?
  23469. inst.options.items.call( inst.element ) :
  23470. $( inst.options.items, inst.element )
  23471. .not( ".ui-sortable-helper" )
  23472. .not( ".ui-sortable-placeholder" ), inst ] );
  23473. }
  23474. }
  23475. }
  23476. }
  23477. queries.push( [ $.isFunction( this.options.items ) ?
  23478. this.options.items
  23479. .call( this.element, null, { options: this.options, item: this.currentItem } ) :
  23480. $( this.options.items, this.element )
  23481. .not( ".ui-sortable-helper" )
  23482. .not( ".ui-sortable-placeholder" ), this ] );
  23483. function addItems() {
  23484. items.push( this );
  23485. }
  23486. for ( i = queries.length - 1; i >= 0; i-- ) {
  23487. queries[ i ][ 0 ].each( addItems );
  23488. }
  23489. return $( items );
  23490. },
  23491. _removeCurrentsFromItems: function() {
  23492. var list = this.currentItem.find( ":data(" + this.widgetName + "-item)" );
  23493. this.items = $.grep( this.items, function( item ) {
  23494. for ( var j = 0; j < list.length; j++ ) {
  23495. if ( list[ j ] === item.item[ 0 ] ) {
  23496. return false;
  23497. }
  23498. }
  23499. return true;
  23500. } );
  23501. },
  23502. _refreshItems: function( event ) {
  23503. this.items = [];
  23504. this.containers = [ this ];
  23505. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  23506. items = this.items,
  23507. queries = [ [ $.isFunction( this.options.items ) ?
  23508. this.options.items.call( this.element[ 0 ], event, { item: this.currentItem } ) :
  23509. $( this.options.items, this.element ), this ] ],
  23510. connectWith = this._connectWith();
  23511. //Shouldn't be run the first time through due to massive slow-down
  23512. if ( connectWith && this.ready ) {
  23513. for ( i = connectWith.length - 1; i >= 0; i-- ) {
  23514. cur = $( connectWith[ i ], this.document[ 0 ] );
  23515. for ( j = cur.length - 1; j >= 0; j-- ) {
  23516. inst = $.data( cur[ j ], this.widgetFullName );
  23517. if ( inst && inst !== this && !inst.options.disabled ) {
  23518. queries.push( [ $.isFunction( inst.options.items ) ?
  23519. inst.options.items
  23520. .call( inst.element[ 0 ], event, { item: this.currentItem } ) :
  23521. $( inst.options.items, inst.element ), inst ] );
  23522. this.containers.push( inst );
  23523. }
  23524. }
  23525. }
  23526. }
  23527. for ( i = queries.length - 1; i >= 0; i-- ) {
  23528. targetData = queries[ i ][ 1 ];
  23529. _queries = queries[ i ][ 0 ];
  23530. for ( j = 0, queriesLength = _queries.length; j < queriesLength; j++ ) {
  23531. item = $( _queries[ j ] );
  23532. // Data for target checking (mouse manager)
  23533. item.data( this.widgetName + "-item", targetData );
  23534. items.push( {
  23535. item: item,
  23536. instance: targetData,
  23537. width: 0, height: 0,
  23538. left: 0, top: 0
  23539. } );
  23540. }
  23541. }
  23542. },
  23543. refreshPositions: function( fast ) {
  23544. // Determine whether items are being displayed horizontally
  23545. this.floating = this.items.length ?
  23546. this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) :
  23547. false;
  23548. //This has to be redone because due to the item being moved out/into the offsetParent,
  23549. // the offsetParent's position will change
  23550. if ( this.offsetParent && this.helper ) {
  23551. this.offset.parent = this._getParentOffset();
  23552. }
  23553. var i, item, t, p;
  23554. for ( i = this.items.length - 1; i >= 0; i-- ) {
  23555. item = this.items[ i ];
  23556. //We ignore calculating positions of all connected containers when we're not over them
  23557. if ( item.instance !== this.currentContainer && this.currentContainer &&
  23558. item.item[ 0 ] !== this.currentItem[ 0 ] ) {
  23559. continue;
  23560. }
  23561. t = this.options.toleranceElement ?
  23562. $( this.options.toleranceElement, item.item ) :
  23563. item.item;
  23564. if ( !fast ) {
  23565. item.width = t.outerWidth();
  23566. item.height = t.outerHeight();
  23567. }
  23568. p = t.offset();
  23569. item.left = p.left;
  23570. item.top = p.top;
  23571. }
  23572. if ( this.options.custom && this.options.custom.refreshContainers ) {
  23573. this.options.custom.refreshContainers.call( this );
  23574. } else {
  23575. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  23576. p = this.containers[ i ].element.offset();
  23577. this.containers[ i ].containerCache.left = p.left;
  23578. this.containers[ i ].containerCache.top = p.top;
  23579. this.containers[ i ].containerCache.width =
  23580. this.containers[ i ].element.outerWidth();
  23581. this.containers[ i ].containerCache.height =
  23582. this.containers[ i ].element.outerHeight();
  23583. }
  23584. }
  23585. return this;
  23586. },
  23587. _createPlaceholder: function( that ) {
  23588. that = that || this;
  23589. var className,
  23590. o = that.options;
  23591. if ( !o.placeholder || o.placeholder.constructor === String ) {
  23592. className = o.placeholder;
  23593. o.placeholder = {
  23594. element: function() {
  23595. var nodeName = that.currentItem[ 0 ].nodeName.toLowerCase(),
  23596. element = $( "<" + nodeName + ">", that.document[ 0 ] );
  23597. that._addClass( element, "ui-sortable-placeholder",
  23598. className || that.currentItem[ 0 ].className )
  23599. ._removeClass( element, "ui-sortable-helper" );
  23600. if ( nodeName === "tbody" ) {
  23601. that._createTrPlaceholder(
  23602. that.currentItem.find( "tr" ).eq( 0 ),
  23603. $( "<tr>", that.document[ 0 ] ).appendTo( element )
  23604. );
  23605. } else if ( nodeName === "tr" ) {
  23606. that._createTrPlaceholder( that.currentItem, element );
  23607. } else if ( nodeName === "img" ) {
  23608. element.attr( "src", that.currentItem.attr( "src" ) );
  23609. }
  23610. if ( !className ) {
  23611. element.css( "visibility", "hidden" );
  23612. }
  23613. return element;
  23614. },
  23615. update: function( container, p ) {
  23616. // 1. If a className is set as 'placeholder option, we don't force sizes -
  23617. // the class is responsible for that
  23618. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a
  23619. // class name is specified
  23620. if ( className && !o.forcePlaceholderSize ) {
  23621. return;
  23622. }
  23623. //If the element doesn't have a actual height by itself (without styles coming
  23624. // from a stylesheet), it receives the inline height from the dragged item
  23625. if ( !p.height() ) {
  23626. p.height(
  23627. that.currentItem.innerHeight() -
  23628. parseInt( that.currentItem.css( "paddingTop" ) || 0, 10 ) -
  23629. parseInt( that.currentItem.css( "paddingBottom" ) || 0, 10 ) );
  23630. }
  23631. if ( !p.width() ) {
  23632. p.width(
  23633. that.currentItem.innerWidth() -
  23634. parseInt( that.currentItem.css( "paddingLeft" ) || 0, 10 ) -
  23635. parseInt( that.currentItem.css( "paddingRight" ) || 0, 10 ) );
  23636. }
  23637. }
  23638. };
  23639. }
  23640. //Create the placeholder
  23641. that.placeholder = $( o.placeholder.element.call( that.element, that.currentItem ) );
  23642. //Append it after the actual current item
  23643. that.currentItem.after( that.placeholder );
  23644. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  23645. o.placeholder.update( that, that.placeholder );
  23646. },
  23647. _createTrPlaceholder: function( sourceTr, targetTr ) {
  23648. var that = this;
  23649. sourceTr.children().each( function() {
  23650. $( "<td>&#160;</td>", that.document[ 0 ] )
  23651. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  23652. .appendTo( targetTr );
  23653. } );
  23654. },
  23655. _contactContainers: function( event ) {
  23656. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom,
  23657. floating, axis,
  23658. innermostContainer = null,
  23659. innermostIndex = null;
  23660. // Get innermost container that intersects with item
  23661. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  23662. // Never consider a container that's located within the item itself
  23663. if ( $.contains( this.currentItem[ 0 ], this.containers[ i ].element[ 0 ] ) ) {
  23664. continue;
  23665. }
  23666. if ( this._intersectsWith( this.containers[ i ].containerCache ) ) {
  23667. // If we've already found a container and it's more "inner" than this, then continue
  23668. if ( innermostContainer &&
  23669. $.contains(
  23670. this.containers[ i ].element[ 0 ],
  23671. innermostContainer.element[ 0 ] ) ) {
  23672. continue;
  23673. }
  23674. innermostContainer = this.containers[ i ];
  23675. innermostIndex = i;
  23676. } else {
  23677. // container doesn't intersect. trigger "out" event if necessary
  23678. if ( this.containers[ i ].containerCache.over ) {
  23679. this.containers[ i ]._trigger( "out", event, this._uiHash( this ) );
  23680. this.containers[ i ].containerCache.over = 0;
  23681. }
  23682. }
  23683. }
  23684. // If no intersecting containers found, return
  23685. if ( !innermostContainer ) {
  23686. return;
  23687. }
  23688. // Move the item into the container if it's not there already
  23689. if ( this.containers.length === 1 ) {
  23690. if ( !this.containers[ innermostIndex ].containerCache.over ) {
  23691. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
  23692. this.containers[ innermostIndex ].containerCache.over = 1;
  23693. }
  23694. } else {
  23695. // When entering a new container, we will find the item with the least distance and
  23696. // append our item near it
  23697. dist = 10000;
  23698. itemWithLeastDistance = null;
  23699. floating = innermostContainer.floating || this._isFloating( this.currentItem );
  23700. posProperty = floating ? "left" : "top";
  23701. sizeProperty = floating ? "width" : "height";
  23702. axis = floating ? "pageX" : "pageY";
  23703. for ( j = this.items.length - 1; j >= 0; j-- ) {
  23704. if ( !$.contains(
  23705. this.containers[ innermostIndex ].element[ 0 ], this.items[ j ].item[ 0 ] )
  23706. ) {
  23707. continue;
  23708. }
  23709. if ( this.items[ j ].item[ 0 ] === this.currentItem[ 0 ] ) {
  23710. continue;
  23711. }
  23712. cur = this.items[ j ].item.offset()[ posProperty ];
  23713. nearBottom = false;
  23714. if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
  23715. nearBottom = true;
  23716. }
  23717. if ( Math.abs( event[ axis ] - cur ) < dist ) {
  23718. dist = Math.abs( event[ axis ] - cur );
  23719. itemWithLeastDistance = this.items[ j ];
  23720. this.direction = nearBottom ? "up" : "down";
  23721. }
  23722. }
  23723. //Check if dropOnEmpty is enabled
  23724. if ( !itemWithLeastDistance && !this.options.dropOnEmpty ) {
  23725. return;
  23726. }
  23727. if ( this.currentContainer === this.containers[ innermostIndex ] ) {
  23728. if ( !this.currentContainer.containerCache.over ) {
  23729. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
  23730. this.currentContainer.containerCache.over = 1;
  23731. }
  23732. return;
  23733. }
  23734. itemWithLeastDistance ?
  23735. this._rearrange( event, itemWithLeastDistance, null, true ) :
  23736. this._rearrange( event, null, this.containers[ innermostIndex ].element, true );
  23737. this._trigger( "change", event, this._uiHash() );
  23738. this.containers[ innermostIndex ]._trigger( "change", event, this._uiHash( this ) );
  23739. this.currentContainer = this.containers[ innermostIndex ];
  23740. //Update the placeholder
  23741. this.options.placeholder.update( this.currentContainer, this.placeholder );
  23742. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
  23743. this.containers[ innermostIndex ].containerCache.over = 1;
  23744. }
  23745. },
  23746. _createHelper: function( event ) {
  23747. var o = this.options,
  23748. helper = $.isFunction( o.helper ) ?
  23749. $( o.helper.apply( this.element[ 0 ], [ event, this.currentItem ] ) ) :
  23750. ( o.helper === "clone" ? this.currentItem.clone() : this.currentItem );
  23751. //Add the helper to the DOM if that didn't happen already
  23752. if ( !helper.parents( "body" ).length ) {
  23753. $( o.appendTo !== "parent" ?
  23754. o.appendTo :
  23755. this.currentItem[ 0 ].parentNode )[ 0 ].appendChild( helper[ 0 ] );
  23756. }
  23757. if ( helper[ 0 ] === this.currentItem[ 0 ] ) {
  23758. this._storedCSS = {
  23759. width: this.currentItem[ 0 ].style.width,
  23760. height: this.currentItem[ 0 ].style.height,
  23761. position: this.currentItem.css( "position" ),
  23762. top: this.currentItem.css( "top" ),
  23763. left: this.currentItem.css( "left" )
  23764. };
  23765. }
  23766. if ( !helper[ 0 ].style.width || o.forceHelperSize ) {
  23767. helper.width( this.currentItem.width() );
  23768. }
  23769. if ( !helper[ 0 ].style.height || o.forceHelperSize ) {
  23770. helper.height( this.currentItem.height() );
  23771. }
  23772. return helper;
  23773. },
  23774. _adjustOffsetFromHelper: function( obj ) {
  23775. if ( typeof obj === "string" ) {
  23776. obj = obj.split( " " );
  23777. }
  23778. if ( $.isArray( obj ) ) {
  23779. obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
  23780. }
  23781. if ( "left" in obj ) {
  23782. this.offset.click.left = obj.left + this.margins.left;
  23783. }
  23784. if ( "right" in obj ) {
  23785. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  23786. }
  23787. if ( "top" in obj ) {
  23788. this.offset.click.top = obj.top + this.margins.top;
  23789. }
  23790. if ( "bottom" in obj ) {
  23791. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  23792. }
  23793. },
  23794. _getParentOffset: function() {
  23795. //Get the offsetParent and cache its position
  23796. this.offsetParent = this.helper.offsetParent();
  23797. var po = this.offsetParent.offset();
  23798. // This is a special case where we need to modify a offset calculated on start, since the
  23799. // following happened:
  23800. // 1. The position of the helper is absolute, so it's position is calculated based on the
  23801. // next positioned parent
  23802. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
  23803. // the document, which means that the scroll is included in the initial calculation of the
  23804. // offset of the parent, and never recalculated upon drag
  23805. if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  23806. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
  23807. po.left += this.scrollParent.scrollLeft();
  23808. po.top += this.scrollParent.scrollTop();
  23809. }
  23810. // This needs to be actually done for all browsers, since pageX/pageY includes this
  23811. // information with an ugly IE fix
  23812. if ( this.offsetParent[ 0 ] === this.document[ 0 ].body ||
  23813. ( this.offsetParent[ 0 ].tagName &&
  23814. this.offsetParent[ 0 ].tagName.toLowerCase() === "html" && $.ui.ie ) ) {
  23815. po = { top: 0, left: 0 };
  23816. }
  23817. return {
  23818. top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
  23819. left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
  23820. };
  23821. },
  23822. _getRelativeOffset: function() {
  23823. if ( this.cssPosition === "relative" ) {
  23824. var p = this.currentItem.position();
  23825. return {
  23826. top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
  23827. this.scrollParent.scrollTop(),
  23828. left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
  23829. this.scrollParent.scrollLeft()
  23830. };
  23831. } else {
  23832. return { top: 0, left: 0 };
  23833. }
  23834. },
  23835. _cacheMargins: function() {
  23836. this.margins = {
  23837. left: ( parseInt( this.currentItem.css( "marginLeft" ), 10 ) || 0 ),
  23838. top: ( parseInt( this.currentItem.css( "marginTop" ), 10 ) || 0 )
  23839. };
  23840. },
  23841. _cacheHelperProportions: function() {
  23842. this.helperProportions = {
  23843. width: this.helper.outerWidth(),
  23844. height: this.helper.outerHeight()
  23845. };
  23846. },
  23847. _setContainment: function() {
  23848. var ce, co, over,
  23849. o = this.options;
  23850. if ( o.containment === "parent" ) {
  23851. o.containment = this.helper[ 0 ].parentNode;
  23852. }
  23853. if ( o.containment === "document" || o.containment === "window" ) {
  23854. this.containment = [
  23855. 0 - this.offset.relative.left - this.offset.parent.left,
  23856. 0 - this.offset.relative.top - this.offset.parent.top,
  23857. o.containment === "document" ?
  23858. this.document.width() :
  23859. this.window.width() - this.helperProportions.width - this.margins.left,
  23860. ( o.containment === "document" ?
  23861. ( this.document.height() || document.body.parentNode.scrollHeight ) :
  23862. this.window.height() || this.document[ 0 ].body.parentNode.scrollHeight
  23863. ) - this.helperProportions.height - this.margins.top
  23864. ];
  23865. }
  23866. if ( !( /^(document|window|parent)$/ ).test( o.containment ) ) {
  23867. ce = $( o.containment )[ 0 ];
  23868. co = $( o.containment ).offset();
  23869. over = ( $( ce ).css( "overflow" ) !== "hidden" );
  23870. this.containment = [
  23871. co.left + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) +
  23872. ( parseInt( $( ce ).css( "paddingLeft" ), 10 ) || 0 ) - this.margins.left,
  23873. co.top + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) +
  23874. ( parseInt( $( ce ).css( "paddingTop" ), 10 ) || 0 ) - this.margins.top,
  23875. co.left + ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  23876. ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) -
  23877. ( parseInt( $( ce ).css( "paddingRight" ), 10 ) || 0 ) -
  23878. this.helperProportions.width - this.margins.left,
  23879. co.top + ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  23880. ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) -
  23881. ( parseInt( $( ce ).css( "paddingBottom" ), 10 ) || 0 ) -
  23882. this.helperProportions.height - this.margins.top
  23883. ];
  23884. }
  23885. },
  23886. _convertPositionTo: function( d, pos ) {
  23887. if ( !pos ) {
  23888. pos = this.position;
  23889. }
  23890. var mod = d === "absolute" ? 1 : -1,
  23891. scroll = this.cssPosition === "absolute" &&
  23892. !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  23893. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
  23894. this.offsetParent :
  23895. this.scrollParent,
  23896. scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
  23897. return {
  23898. top: (
  23899. // The absolute mouse position
  23900. pos.top +
  23901. // Only for relative positioned nodes: Relative offset from element to offset parent
  23902. this.offset.relative.top * mod +
  23903. // The offsetParent's offset without borders (offset + border)
  23904. this.offset.parent.top * mod -
  23905. ( ( this.cssPosition === "fixed" ?
  23906. -this.scrollParent.scrollTop() :
  23907. ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod )
  23908. ),
  23909. left: (
  23910. // The absolute mouse position
  23911. pos.left +
  23912. // Only for relative positioned nodes: Relative offset from element to offset parent
  23913. this.offset.relative.left * mod +
  23914. // The offsetParent's offset without borders (offset + border)
  23915. this.offset.parent.left * mod -
  23916. ( ( this.cssPosition === "fixed" ?
  23917. -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 :
  23918. scroll.scrollLeft() ) * mod )
  23919. )
  23920. };
  23921. },
  23922. _generatePosition: function( event ) {
  23923. var top, left,
  23924. o = this.options,
  23925. pageX = event.pageX,
  23926. pageY = event.pageY,
  23927. scroll = this.cssPosition === "absolute" &&
  23928. !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  23929. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
  23930. this.offsetParent :
  23931. this.scrollParent,
  23932. scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
  23933. // This is another very weird special case that only happens for relative elements:
  23934. // 1. If the css position is relative
  23935. // 2. and the scroll parent is the document or similar to the offset parent
  23936. // we have to refresh the relative offset during the scroll so there are no jumps
  23937. if ( this.cssPosition === "relative" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  23938. this.scrollParent[ 0 ] !== this.offsetParent[ 0 ] ) ) {
  23939. this.offset.relative = this._getRelativeOffset();
  23940. }
  23941. /*
  23942. * - Position constraining -
  23943. * Constrain the position to a mix of grid, containment.
  23944. */
  23945. if ( this.originalPosition ) { //If we are not dragging yet, we won't check for options
  23946. if ( this.containment ) {
  23947. if ( event.pageX - this.offset.click.left < this.containment[ 0 ] ) {
  23948. pageX = this.containment[ 0 ] + this.offset.click.left;
  23949. }
  23950. if ( event.pageY - this.offset.click.top < this.containment[ 1 ] ) {
  23951. pageY = this.containment[ 1 ] + this.offset.click.top;
  23952. }
  23953. if ( event.pageX - this.offset.click.left > this.containment[ 2 ] ) {
  23954. pageX = this.containment[ 2 ] + this.offset.click.left;
  23955. }
  23956. if ( event.pageY - this.offset.click.top > this.containment[ 3 ] ) {
  23957. pageY = this.containment[ 3 ] + this.offset.click.top;
  23958. }
  23959. }
  23960. if ( o.grid ) {
  23961. top = this.originalPageY + Math.round( ( pageY - this.originalPageY ) /
  23962. o.grid[ 1 ] ) * o.grid[ 1 ];
  23963. pageY = this.containment ?
  23964. ( ( top - this.offset.click.top >= this.containment[ 1 ] &&
  23965. top - this.offset.click.top <= this.containment[ 3 ] ) ?
  23966. top :
  23967. ( ( top - this.offset.click.top >= this.containment[ 1 ] ) ?
  23968. top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) :
  23969. top;
  23970. left = this.originalPageX + Math.round( ( pageX - this.originalPageX ) /
  23971. o.grid[ 0 ] ) * o.grid[ 0 ];
  23972. pageX = this.containment ?
  23973. ( ( left - this.offset.click.left >= this.containment[ 0 ] &&
  23974. left - this.offset.click.left <= this.containment[ 2 ] ) ?
  23975. left :
  23976. ( ( left - this.offset.click.left >= this.containment[ 0 ] ) ?
  23977. left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) :
  23978. left;
  23979. }
  23980. }
  23981. return {
  23982. top: (
  23983. // The absolute mouse position
  23984. pageY -
  23985. // Click offset (relative to the element)
  23986. this.offset.click.top -
  23987. // Only for relative positioned nodes: Relative offset from element to offset parent
  23988. this.offset.relative.top -
  23989. // The offsetParent's offset without borders (offset + border)
  23990. this.offset.parent.top +
  23991. ( ( this.cssPosition === "fixed" ?
  23992. -this.scrollParent.scrollTop() :
  23993. ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) )
  23994. ),
  23995. left: (
  23996. // The absolute mouse position
  23997. pageX -
  23998. // Click offset (relative to the element)
  23999. this.offset.click.left -
  24000. // Only for relative positioned nodes: Relative offset from element to offset parent
  24001. this.offset.relative.left -
  24002. // The offsetParent's offset without borders (offset + border)
  24003. this.offset.parent.left +
  24004. ( ( this.cssPosition === "fixed" ?
  24005. -this.scrollParent.scrollLeft() :
  24006. scrollIsRootNode ? 0 : scroll.scrollLeft() ) )
  24007. )
  24008. };
  24009. },
  24010. _rearrange: function( event, i, a, hardRefresh ) {
  24011. a ? a[ 0 ].appendChild( this.placeholder[ 0 ] ) :
  24012. i.item[ 0 ].parentNode.insertBefore( this.placeholder[ 0 ],
  24013. ( this.direction === "down" ? i.item[ 0 ] : i.item[ 0 ].nextSibling ) );
  24014. //Various things done here to improve the performance:
  24015. // 1. we create a setTimeout, that calls refreshPositions
  24016. // 2. on the instance, we have a counter variable, that get's higher after every append
  24017. // 3. on the local scope, we copy the counter variable, and check in the timeout,
  24018. // if it's still the same
  24019. // 4. this lets only the last addition to the timeout stack through
  24020. this.counter = this.counter ? ++this.counter : 1;
  24021. var counter = this.counter;
  24022. this._delay( function() {
  24023. if ( counter === this.counter ) {
  24024. //Precompute after each DOM insertion, NOT on mousemove
  24025. this.refreshPositions( !hardRefresh );
  24026. }
  24027. } );
  24028. },
  24029. _clear: function( event, noPropagation ) {
  24030. this.reverting = false;
  24031. // We delay all events that have to be triggered to after the point where the placeholder
  24032. // has been removed and everything else normalized again
  24033. var i,
  24034. delayedTriggers = [];
  24035. // We first have to update the dom position of the actual currentItem
  24036. // Note: don't do it if the current item is already removed (by a user), or it gets
  24037. // reappended (see #4088)
  24038. if ( !this._noFinalSort && this.currentItem.parent().length ) {
  24039. this.placeholder.before( this.currentItem );
  24040. }
  24041. this._noFinalSort = null;
  24042. if ( this.helper[ 0 ] === this.currentItem[ 0 ] ) {
  24043. for ( i in this._storedCSS ) {
  24044. if ( this._storedCSS[ i ] === "auto" || this._storedCSS[ i ] === "static" ) {
  24045. this._storedCSS[ i ] = "";
  24046. }
  24047. }
  24048. this.currentItem.css( this._storedCSS );
  24049. this._removeClass( this.currentItem, "ui-sortable-helper" );
  24050. } else {
  24051. this.currentItem.show();
  24052. }
  24053. if ( this.fromOutside && !noPropagation ) {
  24054. delayedTriggers.push( function( event ) {
  24055. this._trigger( "receive", event, this._uiHash( this.fromOutside ) );
  24056. } );
  24057. }
  24058. if ( ( this.fromOutside ||
  24059. this.domPosition.prev !==
  24060. this.currentItem.prev().not( ".ui-sortable-helper" )[ 0 ] ||
  24061. this.domPosition.parent !== this.currentItem.parent()[ 0 ] ) && !noPropagation ) {
  24062. // Trigger update callback if the DOM position has changed
  24063. delayedTriggers.push( function( event ) {
  24064. this._trigger( "update", event, this._uiHash() );
  24065. } );
  24066. }
  24067. // Check if the items Container has Changed and trigger appropriate
  24068. // events.
  24069. if ( this !== this.currentContainer ) {
  24070. if ( !noPropagation ) {
  24071. delayedTriggers.push( function( event ) {
  24072. this._trigger( "remove", event, this._uiHash() );
  24073. } );
  24074. delayedTriggers.push( ( function( c ) {
  24075. return function( event ) {
  24076. c._trigger( "receive", event, this._uiHash( this ) );
  24077. };
  24078. } ).call( this, this.currentContainer ) );
  24079. delayedTriggers.push( ( function( c ) {
  24080. return function( event ) {
  24081. c._trigger( "update", event, this._uiHash( this ) );
  24082. };
  24083. } ).call( this, this.currentContainer ) );
  24084. }
  24085. }
  24086. //Post events to containers
  24087. function delayEvent( type, instance, container ) {
  24088. return function( event ) {
  24089. container._trigger( type, event, instance._uiHash( instance ) );
  24090. };
  24091. }
  24092. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  24093. if ( !noPropagation ) {
  24094. delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
  24095. }
  24096. if ( this.containers[ i ].containerCache.over ) {
  24097. delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
  24098. this.containers[ i ].containerCache.over = 0;
  24099. }
  24100. }
  24101. //Do what was originally in plugins
  24102. if ( this.storedCursor ) {
  24103. this.document.find( "body" ).css( "cursor", this.storedCursor );
  24104. this.storedStylesheet.remove();
  24105. }
  24106. if ( this._storedOpacity ) {
  24107. this.helper.css( "opacity", this._storedOpacity );
  24108. }
  24109. if ( this._storedZIndex ) {
  24110. this.helper.css( "zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex );
  24111. }
  24112. this.dragging = false;
  24113. if ( !noPropagation ) {
  24114. this._trigger( "beforeStop", event, this._uiHash() );
  24115. }
  24116. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
  24117. // it unbinds ALL events from the original node!
  24118. this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
  24119. if ( !this.cancelHelperRemoval ) {
  24120. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  24121. this.helper.remove();
  24122. }
  24123. this.helper = null;
  24124. }
  24125. if ( !noPropagation ) {
  24126. for ( i = 0; i < delayedTriggers.length; i++ ) {
  24127. // Trigger all delayed events
  24128. delayedTriggers[ i ].call( this, event );
  24129. }
  24130. this._trigger( "stop", event, this._uiHash() );
  24131. }
  24132. this.fromOutside = false;
  24133. return !this.cancelHelperRemoval;
  24134. },
  24135. _trigger: function() {
  24136. if ( $.Widget.prototype._trigger.apply( this, arguments ) === false ) {
  24137. this.cancel();
  24138. }
  24139. },
  24140. _uiHash: function( _inst ) {
  24141. var inst = _inst || this;
  24142. return {
  24143. helper: inst.helper,
  24144. placeholder: inst.placeholder || $( [] ),
  24145. position: inst.position,
  24146. originalPosition: inst.originalPosition,
  24147. offset: inst.positionAbs,
  24148. item: inst.currentItem,
  24149. sender: _inst ? _inst.element : null
  24150. };
  24151. }
  24152. } );
  24153. /*!
  24154. * jQuery UI Spinner 1.12.1
  24155. * http://jqueryui.com
  24156. *
  24157. * Copyright jQuery Foundation and other contributors
  24158. * Released under the MIT license.
  24159. * http://jquery.org/license
  24160. */
  24161. //>>label: Spinner
  24162. //>>group: Widgets
  24163. //>>description: Displays buttons to easily input numbers via the keyboard or mouse.
  24164. //>>docs: http://api.jqueryui.com/spinner/
  24165. //>>demos: http://jqueryui.com/spinner/
  24166. //>>css.structure: ../../themes/base/core.css
  24167. //>>css.structure: ../../themes/base/spinner.css
  24168. //>>css.theme: ../../themes/base/theme.css
  24169. function spinnerModifer( fn ) {
  24170. return function() {
  24171. var previous = this.element.val();
  24172. fn.apply( this, arguments );
  24173. this._refresh();
  24174. if ( previous !== this.element.val() ) {
  24175. this._trigger( "change" );
  24176. }
  24177. };
  24178. }
  24179. $.widget( "ui.spinner", {
  24180. version: "1.12.1",
  24181. defaultElement: "<input>",
  24182. widgetEventPrefix: "spin",
  24183. options: {
  24184. classes: {
  24185. "ui-spinner": "ui-corner-all",
  24186. "ui-spinner-down": "ui-corner-br",
  24187. "ui-spinner-up": "ui-corner-tr"
  24188. },
  24189. culture: null,
  24190. icons: {
  24191. down: "ui-icon-triangle-1-s",
  24192. up: "ui-icon-triangle-1-n"
  24193. },
  24194. incremental: true,
  24195. max: null,
  24196. min: null,
  24197. numberFormat: null,
  24198. page: 10,
  24199. step: 1,
  24200. change: null,
  24201. spin: null,
  24202. start: null,
  24203. stop: null
  24204. },
  24205. _create: function() {
  24206. // handle string values that need to be parsed
  24207. this._setOption( "max", this.options.max );
  24208. this._setOption( "min", this.options.min );
  24209. this._setOption( "step", this.options.step );
  24210. // Only format if there is a value, prevents the field from being marked
  24211. // as invalid in Firefox, see #9573.
  24212. if ( this.value() !== "" ) {
  24213. // Format the value, but don't constrain.
  24214. this._value( this.element.val(), true );
  24215. }
  24216. this._draw();
  24217. this._on( this._events );
  24218. this._refresh();
  24219. // Turning off autocomplete prevents the browser from remembering the
  24220. // value when navigating through history, so we re-enable autocomplete
  24221. // if the page is unloaded before the widget is destroyed. #7790
  24222. this._on( this.window, {
  24223. beforeunload: function() {
  24224. this.element.removeAttr( "autocomplete" );
  24225. }
  24226. } );
  24227. },
  24228. _getCreateOptions: function() {
  24229. var options = this._super();
  24230. var element = this.element;
  24231. $.each( [ "min", "max", "step" ], function( i, option ) {
  24232. var value = element.attr( option );
  24233. if ( value != null && value.length ) {
  24234. options[ option ] = value;
  24235. }
  24236. } );
  24237. return options;
  24238. },
  24239. _events: {
  24240. keydown: function( event ) {
  24241. if ( this._start( event ) && this._keydown( event ) ) {
  24242. event.preventDefault();
  24243. }
  24244. },
  24245. keyup: "_stop",
  24246. focus: function() {
  24247. this.previous = this.element.val();
  24248. },
  24249. blur: function( event ) {
  24250. if ( this.cancelBlur ) {
  24251. delete this.cancelBlur;
  24252. return;
  24253. }
  24254. this._stop();
  24255. this._refresh();
  24256. if ( this.previous !== this.element.val() ) {
  24257. this._trigger( "change", event );
  24258. }
  24259. },
  24260. mousewheel: function( event, delta ) {
  24261. if ( !delta ) {
  24262. return;
  24263. }
  24264. if ( !this.spinning && !this._start( event ) ) {
  24265. return false;
  24266. }
  24267. this._spin( ( delta > 0 ? 1 : -1 ) * this.options.step, event );
  24268. clearTimeout( this.mousewheelTimer );
  24269. this.mousewheelTimer = this._delay( function() {
  24270. if ( this.spinning ) {
  24271. this._stop( event );
  24272. }
  24273. }, 100 );
  24274. event.preventDefault();
  24275. },
  24276. "mousedown .ui-spinner-button": function( event ) {
  24277. var previous;
  24278. // We never want the buttons to have focus; whenever the user is
  24279. // interacting with the spinner, the focus should be on the input.
  24280. // If the input is focused then this.previous is properly set from
  24281. // when the input first received focus. If the input is not focused
  24282. // then we need to set this.previous based on the value before spinning.
  24283. previous = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] ) ?
  24284. this.previous : this.element.val();
  24285. function checkFocus() {
  24286. var isActive = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] );
  24287. if ( !isActive ) {
  24288. this.element.trigger( "focus" );
  24289. this.previous = previous;
  24290. // support: IE
  24291. // IE sets focus asynchronously, so we need to check if focus
  24292. // moved off of the input because the user clicked on the button.
  24293. this._delay( function() {
  24294. this.previous = previous;
  24295. } );
  24296. }
  24297. }
  24298. // Ensure focus is on (or stays on) the text field
  24299. event.preventDefault();
  24300. checkFocus.call( this );
  24301. // Support: IE
  24302. // IE doesn't prevent moving focus even with event.preventDefault()
  24303. // so we set a flag to know when we should ignore the blur event
  24304. // and check (again) if focus moved off of the input.
  24305. this.cancelBlur = true;
  24306. this._delay( function() {
  24307. delete this.cancelBlur;
  24308. checkFocus.call( this );
  24309. } );
  24310. if ( this._start( event ) === false ) {
  24311. return;
  24312. }
  24313. this._repeat( null, $( event.currentTarget )
  24314. .hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  24315. },
  24316. "mouseup .ui-spinner-button": "_stop",
  24317. "mouseenter .ui-spinner-button": function( event ) {
  24318. // button will add ui-state-active if mouse was down while mouseleave and kept down
  24319. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  24320. return;
  24321. }
  24322. if ( this._start( event ) === false ) {
  24323. return false;
  24324. }
  24325. this._repeat( null, $( event.currentTarget )
  24326. .hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  24327. },
  24328. // TODO: do we really want to consider this a stop?
  24329. // shouldn't we just stop the repeater and wait until mouseup before
  24330. // we trigger the stop event?
  24331. "mouseleave .ui-spinner-button": "_stop"
  24332. },
  24333. // Support mobile enhanced option and make backcompat more sane
  24334. _enhance: function() {
  24335. this.uiSpinner = this.element
  24336. .attr( "autocomplete", "off" )
  24337. .wrap( "<span>" )
  24338. .parent()
  24339. // Add buttons
  24340. .append(
  24341. "<a></a><a></a>"
  24342. );
  24343. },
  24344. _draw: function() {
  24345. this._enhance();
  24346. this._addClass( this.uiSpinner, "ui-spinner", "ui-widget ui-widget-content" );
  24347. this._addClass( "ui-spinner-input" );
  24348. this.element.attr( "role", "spinbutton" );
  24349. // Button bindings
  24350. this.buttons = this.uiSpinner.children( "a" )
  24351. .attr( "tabIndex", -1 )
  24352. .attr( "aria-hidden", true )
  24353. .button( {
  24354. classes: {
  24355. "ui-button": ""
  24356. }
  24357. } );
  24358. // TODO: Right now button does not support classes this is already updated in button PR
  24359. this._removeClass( this.buttons, "ui-corner-all" );
  24360. this._addClass( this.buttons.first(), "ui-spinner-button ui-spinner-up" );
  24361. this._addClass( this.buttons.last(), "ui-spinner-button ui-spinner-down" );
  24362. this.buttons.first().button( {
  24363. "icon": this.options.icons.up,
  24364. "showLabel": false
  24365. } );
  24366. this.buttons.last().button( {
  24367. "icon": this.options.icons.down,
  24368. "showLabel": false
  24369. } );
  24370. // IE 6 doesn't understand height: 50% for the buttons
  24371. // unless the wrapper has an explicit height
  24372. if ( this.buttons.height() > Math.ceil( this.uiSpinner.height() * 0.5 ) &&
  24373. this.uiSpinner.height() > 0 ) {
  24374. this.uiSpinner.height( this.uiSpinner.height() );
  24375. }
  24376. },
  24377. _keydown: function( event ) {
  24378. var options = this.options,
  24379. keyCode = $.ui.keyCode;
  24380. switch ( event.keyCode ) {
  24381. case keyCode.UP:
  24382. this._repeat( null, 1, event );
  24383. return true;
  24384. case keyCode.DOWN:
  24385. this._repeat( null, -1, event );
  24386. return true;
  24387. case keyCode.PAGE_UP:
  24388. this._repeat( null, options.page, event );
  24389. return true;
  24390. case keyCode.PAGE_DOWN:
  24391. this._repeat( null, -options.page, event );
  24392. return true;
  24393. }
  24394. return false;
  24395. },
  24396. _start: function( event ) {
  24397. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  24398. return false;
  24399. }
  24400. if ( !this.counter ) {
  24401. this.counter = 1;
  24402. }
  24403. this.spinning = true;
  24404. return true;
  24405. },
  24406. _repeat: function( i, steps, event ) {
  24407. i = i || 500;
  24408. clearTimeout( this.timer );
  24409. this.timer = this._delay( function() {
  24410. this._repeat( 40, steps, event );
  24411. }, i );
  24412. this._spin( steps * this.options.step, event );
  24413. },
  24414. _spin: function( step, event ) {
  24415. var value = this.value() || 0;
  24416. if ( !this.counter ) {
  24417. this.counter = 1;
  24418. }
  24419. value = this._adjustValue( value + step * this._increment( this.counter ) );
  24420. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false ) {
  24421. this._value( value );
  24422. this.counter++;
  24423. }
  24424. },
  24425. _increment: function( i ) {
  24426. var incremental = this.options.incremental;
  24427. if ( incremental ) {
  24428. return $.isFunction( incremental ) ?
  24429. incremental( i ) :
  24430. Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 );
  24431. }
  24432. return 1;
  24433. },
  24434. _precision: function() {
  24435. var precision = this._precisionOf( this.options.step );
  24436. if ( this.options.min !== null ) {
  24437. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  24438. }
  24439. return precision;
  24440. },
  24441. _precisionOf: function( num ) {
  24442. var str = num.toString(),
  24443. decimal = str.indexOf( "." );
  24444. return decimal === -1 ? 0 : str.length - decimal - 1;
  24445. },
  24446. _adjustValue: function( value ) {
  24447. var base, aboveMin,
  24448. options = this.options;
  24449. // Make sure we're at a valid step
  24450. // - find out where we are relative to the base (min or 0)
  24451. base = options.min !== null ? options.min : 0;
  24452. aboveMin = value - base;
  24453. // - round to the nearest step
  24454. aboveMin = Math.round( aboveMin / options.step ) * options.step;
  24455. // - rounding is based on 0, so adjust back to our base
  24456. value = base + aboveMin;
  24457. // Fix precision from bad JS floating point math
  24458. value = parseFloat( value.toFixed( this._precision() ) );
  24459. // Clamp the value
  24460. if ( options.max !== null && value > options.max ) {
  24461. return options.max;
  24462. }
  24463. if ( options.min !== null && value < options.min ) {
  24464. return options.min;
  24465. }
  24466. return value;
  24467. },
  24468. _stop: function( event ) {
  24469. if ( !this.spinning ) {
  24470. return;
  24471. }
  24472. clearTimeout( this.timer );
  24473. clearTimeout( this.mousewheelTimer );
  24474. this.counter = 0;
  24475. this.spinning = false;
  24476. this._trigger( "stop", event );
  24477. },
  24478. _setOption: function( key, value ) {
  24479. var prevValue, first, last;
  24480. if ( key === "culture" || key === "numberFormat" ) {
  24481. prevValue = this._parse( this.element.val() );
  24482. this.options[ key ] = value;
  24483. this.element.val( this._format( prevValue ) );
  24484. return;
  24485. }
  24486. if ( key === "max" || key === "min" || key === "step" ) {
  24487. if ( typeof value === "string" ) {
  24488. value = this._parse( value );
  24489. }
  24490. }
  24491. if ( key === "icons" ) {
  24492. first = this.buttons.first().find( ".ui-icon" );
  24493. this._removeClass( first, null, this.options.icons.up );
  24494. this._addClass( first, null, value.up );
  24495. last = this.buttons.last().find( ".ui-icon" );
  24496. this._removeClass( last, null, this.options.icons.down );
  24497. this._addClass( last, null, value.down );
  24498. }
  24499. this._super( key, value );
  24500. },
  24501. _setOptionDisabled: function( value ) {
  24502. this._super( value );
  24503. this._toggleClass( this.uiSpinner, null, "ui-state-disabled", !!value );
  24504. this.element.prop( "disabled", !!value );
  24505. this.buttons.button( value ? "disable" : "enable" );
  24506. },
  24507. _setOptions: spinnerModifer( function( options ) {
  24508. this._super( options );
  24509. } ),
  24510. _parse: function( val ) {
  24511. if ( typeof val === "string" && val !== "" ) {
  24512. val = window.Globalize && this.options.numberFormat ?
  24513. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  24514. }
  24515. return val === "" || isNaN( val ) ? null : val;
  24516. },
  24517. _format: function( value ) {
  24518. if ( value === "" ) {
  24519. return "";
  24520. }
  24521. return window.Globalize && this.options.numberFormat ?
  24522. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  24523. value;
  24524. },
  24525. _refresh: function() {
  24526. this.element.attr( {
  24527. "aria-valuemin": this.options.min,
  24528. "aria-valuemax": this.options.max,
  24529. // TODO: what should we do with values that can't be parsed?
  24530. "aria-valuenow": this._parse( this.element.val() )
  24531. } );
  24532. },
  24533. isValid: function() {
  24534. var value = this.value();
  24535. // Null is invalid
  24536. if ( value === null ) {
  24537. return false;
  24538. }
  24539. // If value gets adjusted, it's invalid
  24540. return value === this._adjustValue( value );
  24541. },
  24542. // Update the value without triggering change
  24543. _value: function( value, allowAny ) {
  24544. var parsed;
  24545. if ( value !== "" ) {
  24546. parsed = this._parse( value );
  24547. if ( parsed !== null ) {
  24548. if ( !allowAny ) {
  24549. parsed = this._adjustValue( parsed );
  24550. }
  24551. value = this._format( parsed );
  24552. }
  24553. }
  24554. this.element.val( value );
  24555. this._refresh();
  24556. },
  24557. _destroy: function() {
  24558. this.element
  24559. .prop( "disabled", false )
  24560. .removeAttr( "autocomplete role aria-valuemin aria-valuemax aria-valuenow" );
  24561. this.uiSpinner.replaceWith( this.element );
  24562. },
  24563. stepUp: spinnerModifer( function( steps ) {
  24564. this._stepUp( steps );
  24565. } ),
  24566. _stepUp: function( steps ) {
  24567. if ( this._start() ) {
  24568. this._spin( ( steps || 1 ) * this.options.step );
  24569. this._stop();
  24570. }
  24571. },
  24572. stepDown: spinnerModifer( function( steps ) {
  24573. this._stepDown( steps );
  24574. } ),
  24575. _stepDown: function( steps ) {
  24576. if ( this._start() ) {
  24577. this._spin( ( steps || 1 ) * -this.options.step );
  24578. this._stop();
  24579. }
  24580. },
  24581. pageUp: spinnerModifer( function( pages ) {
  24582. this._stepUp( ( pages || 1 ) * this.options.page );
  24583. } ),
  24584. pageDown: spinnerModifer( function( pages ) {
  24585. this._stepDown( ( pages || 1 ) * this.options.page );
  24586. } ),
  24587. value: function( newVal ) {
  24588. if ( !arguments.length ) {
  24589. return this._parse( this.element.val() );
  24590. }
  24591. spinnerModifer( this._value ).call( this, newVal );
  24592. },
  24593. widget: function() {
  24594. return this.uiSpinner;
  24595. }
  24596. } );
  24597. // DEPRECATED
  24598. // TODO: switch return back to widget declaration at top of file when this is removed
  24599. if ( $.uiBackCompat !== false ) {
  24600. // Backcompat for spinner html extension points
  24601. $.widget( "ui.spinner", $.ui.spinner, {
  24602. _enhance: function() {
  24603. this.uiSpinner = this.element
  24604. .attr( "autocomplete", "off" )
  24605. .wrap( this._uiSpinnerHtml() )
  24606. .parent()
  24607. // Add buttons
  24608. .append( this._buttonHtml() );
  24609. },
  24610. _uiSpinnerHtml: function() {
  24611. return "<span>";
  24612. },
  24613. _buttonHtml: function() {
  24614. return "<a></a><a></a>";
  24615. }
  24616. } );
  24617. }
  24618. var widgetsSpinner = $.ui.spinner;
  24619. /*!
  24620. * jQuery UI Tabs 1.12.1
  24621. * http://jqueryui.com
  24622. *
  24623. * Copyright jQuery Foundation and other contributors
  24624. * Released under the MIT license.
  24625. * http://jquery.org/license
  24626. */
  24627. //>>label: Tabs
  24628. //>>group: Widgets
  24629. //>>description: Transforms a set of container elements into a tab structure.
  24630. //>>docs: http://api.jqueryui.com/tabs/
  24631. //>>demos: http://jqueryui.com/tabs/
  24632. //>>css.structure: ../../themes/base/core.css
  24633. //>>css.structure: ../../themes/base/tabs.css
  24634. //>>css.theme: ../../themes/base/theme.css
  24635. $.widget( "ui.tabs", {
  24636. version: "1.12.1",
  24637. delay: 300,
  24638. options: {
  24639. active: null,
  24640. classes: {
  24641. "ui-tabs": "ui-corner-all",
  24642. "ui-tabs-nav": "ui-corner-all",
  24643. "ui-tabs-panel": "ui-corner-bottom",
  24644. "ui-tabs-tab": "ui-corner-top"
  24645. },
  24646. collapsible: false,
  24647. event: "click",
  24648. heightStyle: "content",
  24649. hide: null,
  24650. show: null,
  24651. // Callbacks
  24652. activate: null,
  24653. beforeActivate: null,
  24654. beforeLoad: null,
  24655. load: null
  24656. },
  24657. _isLocal: ( function() {
  24658. var rhash = /#.*$/;
  24659. return function( anchor ) {
  24660. var anchorUrl, locationUrl;
  24661. anchorUrl = anchor.href.replace( rhash, "" );
  24662. locationUrl = location.href.replace( rhash, "" );
  24663. // Decoding may throw an error if the URL isn't UTF-8 (#9518)
  24664. try {
  24665. anchorUrl = decodeURIComponent( anchorUrl );
  24666. } catch ( error ) {}
  24667. try {
  24668. locationUrl = decodeURIComponent( locationUrl );
  24669. } catch ( error ) {}
  24670. return anchor.hash.length > 1 && anchorUrl === locationUrl;
  24671. };
  24672. } )(),
  24673. _create: function() {
  24674. var that = this,
  24675. options = this.options;
  24676. this.running = false;
  24677. this._addClass( "ui-tabs", "ui-widget ui-widget-content" );
  24678. this._toggleClass( "ui-tabs-collapsible", null, options.collapsible );
  24679. this._processTabs();
  24680. options.active = this._initialActive();
  24681. // Take disabling tabs via class attribute from HTML
  24682. // into account and update option properly.
  24683. if ( $.isArray( options.disabled ) ) {
  24684. options.disabled = $.unique( options.disabled.concat(
  24685. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  24686. return that.tabs.index( li );
  24687. } )
  24688. ) ).sort();
  24689. }
  24690. // Check for length avoids error when initializing empty list
  24691. if ( this.options.active !== false && this.anchors.length ) {
  24692. this.active = this._findActive( options.active );
  24693. } else {
  24694. this.active = $();
  24695. }
  24696. this._refresh();
  24697. if ( this.active.length ) {
  24698. this.load( options.active );
  24699. }
  24700. },
  24701. _initialActive: function() {
  24702. var active = this.options.active,
  24703. collapsible = this.options.collapsible,
  24704. locationHash = location.hash.substring( 1 );
  24705. if ( active === null ) {
  24706. // check the fragment identifier in the URL
  24707. if ( locationHash ) {
  24708. this.tabs.each( function( i, tab ) {
  24709. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  24710. active = i;
  24711. return false;
  24712. }
  24713. } );
  24714. }
  24715. // Check for a tab marked active via a class
  24716. if ( active === null ) {
  24717. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  24718. }
  24719. // No active tab, set to false
  24720. if ( active === null || active === -1 ) {
  24721. active = this.tabs.length ? 0 : false;
  24722. }
  24723. }
  24724. // Handle numbers: negative, out of range
  24725. if ( active !== false ) {
  24726. active = this.tabs.index( this.tabs.eq( active ) );
  24727. if ( active === -1 ) {
  24728. active = collapsible ? false : 0;
  24729. }
  24730. }
  24731. // Don't allow collapsible: false and active: false
  24732. if ( !collapsible && active === false && this.anchors.length ) {
  24733. active = 0;
  24734. }
  24735. return active;
  24736. },
  24737. _getCreateEventData: function() {
  24738. return {
  24739. tab: this.active,
  24740. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  24741. };
  24742. },
  24743. _tabKeydown: function( event ) {
  24744. var focusedTab = $( $.ui.safeActiveElement( this.document[ 0 ] ) ).closest( "li" ),
  24745. selectedIndex = this.tabs.index( focusedTab ),
  24746. goingForward = true;
  24747. if ( this._handlePageNav( event ) ) {
  24748. return;
  24749. }
  24750. switch ( event.keyCode ) {
  24751. case $.ui.keyCode.RIGHT:
  24752. case $.ui.keyCode.DOWN:
  24753. selectedIndex++;
  24754. break;
  24755. case $.ui.keyCode.UP:
  24756. case $.ui.keyCode.LEFT:
  24757. goingForward = false;
  24758. selectedIndex--;
  24759. break;
  24760. case $.ui.keyCode.END:
  24761. selectedIndex = this.anchors.length - 1;
  24762. break;
  24763. case $.ui.keyCode.HOME:
  24764. selectedIndex = 0;
  24765. break;
  24766. case $.ui.keyCode.SPACE:
  24767. // Activate only, no collapsing
  24768. event.preventDefault();
  24769. clearTimeout( this.activating );
  24770. this._activate( selectedIndex );
  24771. return;
  24772. case $.ui.keyCode.ENTER:
  24773. // Toggle (cancel delayed activation, allow collapsing)
  24774. event.preventDefault();
  24775. clearTimeout( this.activating );
  24776. // Determine if we should collapse or activate
  24777. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  24778. return;
  24779. default:
  24780. return;
  24781. }
  24782. // Focus the appropriate tab, based on which key was pressed
  24783. event.preventDefault();
  24784. clearTimeout( this.activating );
  24785. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  24786. // Navigating with control/command key will prevent automatic activation
  24787. if ( !event.ctrlKey && !event.metaKey ) {
  24788. // Update aria-selected immediately so that AT think the tab is already selected.
  24789. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  24790. // but the tab will already be activated by the time the announcement finishes.
  24791. focusedTab.attr( "aria-selected", "false" );
  24792. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  24793. this.activating = this._delay( function() {
  24794. this.option( "active", selectedIndex );
  24795. }, this.delay );
  24796. }
  24797. },
  24798. _panelKeydown: function( event ) {
  24799. if ( this._handlePageNav( event ) ) {
  24800. return;
  24801. }
  24802. // Ctrl+up moves focus to the current tab
  24803. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  24804. event.preventDefault();
  24805. this.active.trigger( "focus" );
  24806. }
  24807. },
  24808. // Alt+page up/down moves focus to the previous/next tab (and activates)
  24809. _handlePageNav: function( event ) {
  24810. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  24811. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  24812. return true;
  24813. }
  24814. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  24815. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  24816. return true;
  24817. }
  24818. },
  24819. _findNextTab: function( index, goingForward ) {
  24820. var lastTabIndex = this.tabs.length - 1;
  24821. function constrain() {
  24822. if ( index > lastTabIndex ) {
  24823. index = 0;
  24824. }
  24825. if ( index < 0 ) {
  24826. index = lastTabIndex;
  24827. }
  24828. return index;
  24829. }
  24830. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  24831. index = goingForward ? index + 1 : index - 1;
  24832. }
  24833. return index;
  24834. },
  24835. _focusNextTab: function( index, goingForward ) {
  24836. index = this._findNextTab( index, goingForward );
  24837. this.tabs.eq( index ).trigger( "focus" );
  24838. return index;
  24839. },
  24840. _setOption: function( key, value ) {
  24841. if ( key === "active" ) {
  24842. // _activate() will handle invalid values and update this.options
  24843. this._activate( value );
  24844. return;
  24845. }
  24846. this._super( key, value );
  24847. if ( key === "collapsible" ) {
  24848. this._toggleClass( "ui-tabs-collapsible", null, value );
  24849. // Setting collapsible: false while collapsed; open first panel
  24850. if ( !value && this.options.active === false ) {
  24851. this._activate( 0 );
  24852. }
  24853. }
  24854. if ( key === "event" ) {
  24855. this._setupEvents( value );
  24856. }
  24857. if ( key === "heightStyle" ) {
  24858. this._setupHeightStyle( value );
  24859. }
  24860. },
  24861. _sanitizeSelector: function( hash ) {
  24862. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  24863. },
  24864. refresh: function() {
  24865. var options = this.options,
  24866. lis = this.tablist.children( ":has(a[href])" );
  24867. // Get disabled tabs from class attribute from HTML
  24868. // this will get converted to a boolean if needed in _refresh()
  24869. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  24870. return lis.index( tab );
  24871. } );
  24872. this._processTabs();
  24873. // Was collapsed or no tabs
  24874. if ( options.active === false || !this.anchors.length ) {
  24875. options.active = false;
  24876. this.active = $();
  24877. // was active, but active tab is gone
  24878. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  24879. // all remaining tabs are disabled
  24880. if ( this.tabs.length === options.disabled.length ) {
  24881. options.active = false;
  24882. this.active = $();
  24883. // activate previous tab
  24884. } else {
  24885. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  24886. }
  24887. // was active, active tab still exists
  24888. } else {
  24889. // make sure active index is correct
  24890. options.active = this.tabs.index( this.active );
  24891. }
  24892. this._refresh();
  24893. },
  24894. _refresh: function() {
  24895. this._setOptionDisabled( this.options.disabled );
  24896. this._setupEvents( this.options.event );
  24897. this._setupHeightStyle( this.options.heightStyle );
  24898. this.tabs.not( this.active ).attr( {
  24899. "aria-selected": "false",
  24900. "aria-expanded": "false",
  24901. tabIndex: -1
  24902. } );
  24903. this.panels.not( this._getPanelForTab( this.active ) )
  24904. .hide()
  24905. .attr( {
  24906. "aria-hidden": "true"
  24907. } );
  24908. // Make sure one tab is in the tab order
  24909. if ( !this.active.length ) {
  24910. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  24911. } else {
  24912. this.active
  24913. .attr( {
  24914. "aria-selected": "true",
  24915. "aria-expanded": "true",
  24916. tabIndex: 0
  24917. } );
  24918. this._addClass( this.active, "ui-tabs-active", "ui-state-active" );
  24919. this._getPanelForTab( this.active )
  24920. .show()
  24921. .attr( {
  24922. "aria-hidden": "false"
  24923. } );
  24924. }
  24925. },
  24926. _processTabs: function() {
  24927. var that = this,
  24928. prevTabs = this.tabs,
  24929. prevAnchors = this.anchors,
  24930. prevPanels = this.panels;
  24931. this.tablist = this._getList().attr( "role", "tablist" );
  24932. this._addClass( this.tablist, "ui-tabs-nav",
  24933. "ui-helper-reset ui-helper-clearfix ui-widget-header" );
  24934. // Prevent users from focusing disabled tabs via click
  24935. this.tablist
  24936. .on( "mousedown" + this.eventNamespace, "> li", function( event ) {
  24937. if ( $( this ).is( ".ui-state-disabled" ) ) {
  24938. event.preventDefault();
  24939. }
  24940. } )
  24941. // Support: IE <9
  24942. // Preventing the default action in mousedown doesn't prevent IE
  24943. // from focusing the element, so if the anchor gets focused, blur.
  24944. // We don't have to worry about focusing the previously focused
  24945. // element since clicking on a non-focusable element should focus
  24946. // the body anyway.
  24947. .on( "focus" + this.eventNamespace, ".ui-tabs-anchor", function() {
  24948. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  24949. this.blur();
  24950. }
  24951. } );
  24952. this.tabs = this.tablist.find( "> li:has(a[href])" )
  24953. .attr( {
  24954. role: "tab",
  24955. tabIndex: -1
  24956. } );
  24957. this._addClass( this.tabs, "ui-tabs-tab", "ui-state-default" );
  24958. this.anchors = this.tabs.map( function() {
  24959. return $( "a", this )[ 0 ];
  24960. } )
  24961. .attr( {
  24962. role: "presentation",
  24963. tabIndex: -1
  24964. } );
  24965. this._addClass( this.anchors, "ui-tabs-anchor" );
  24966. this.panels = $();
  24967. this.anchors.each( function( i, anchor ) {
  24968. var selector, panel, panelId,
  24969. anchorId = $( anchor ).uniqueId().attr( "id" ),
  24970. tab = $( anchor ).closest( "li" ),
  24971. originalAriaControls = tab.attr( "aria-controls" );
  24972. // Inline tab
  24973. if ( that._isLocal( anchor ) ) {
  24974. selector = anchor.hash;
  24975. panelId = selector.substring( 1 );
  24976. panel = that.element.find( that._sanitizeSelector( selector ) );
  24977. // remote tab
  24978. } else {
  24979. // If the tab doesn't already have aria-controls,
  24980. // generate an id by using a throw-away element
  24981. panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id;
  24982. selector = "#" + panelId;
  24983. panel = that.element.find( selector );
  24984. if ( !panel.length ) {
  24985. panel = that._createPanel( panelId );
  24986. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  24987. }
  24988. panel.attr( "aria-live", "polite" );
  24989. }
  24990. if ( panel.length ) {
  24991. that.panels = that.panels.add( panel );
  24992. }
  24993. if ( originalAriaControls ) {
  24994. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  24995. }
  24996. tab.attr( {
  24997. "aria-controls": panelId,
  24998. "aria-labelledby": anchorId
  24999. } );
  25000. panel.attr( "aria-labelledby", anchorId );
  25001. } );
  25002. this.panels.attr( "role", "tabpanel" );
  25003. this._addClass( this.panels, "ui-tabs-panel", "ui-widget-content" );
  25004. // Avoid memory leaks (#10056)
  25005. if ( prevTabs ) {
  25006. this._off( prevTabs.not( this.tabs ) );
  25007. this._off( prevAnchors.not( this.anchors ) );
  25008. this._off( prevPanels.not( this.panels ) );
  25009. }
  25010. },
  25011. // Allow overriding how to find the list for rare usage scenarios (#7715)
  25012. _getList: function() {
  25013. return this.tablist || this.element.find( "ol, ul" ).eq( 0 );
  25014. },
  25015. _createPanel: function( id ) {
  25016. return $( "<div>" )
  25017. .attr( "id", id )
  25018. .data( "ui-tabs-destroy", true );
  25019. },
  25020. _setOptionDisabled: function( disabled ) {
  25021. var currentItem, li, i;
  25022. if ( $.isArray( disabled ) ) {
  25023. if ( !disabled.length ) {
  25024. disabled = false;
  25025. } else if ( disabled.length === this.anchors.length ) {
  25026. disabled = true;
  25027. }
  25028. }
  25029. // Disable tabs
  25030. for ( i = 0; ( li = this.tabs[ i ] ); i++ ) {
  25031. currentItem = $( li );
  25032. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  25033. currentItem.attr( "aria-disabled", "true" );
  25034. this._addClass( currentItem, null, "ui-state-disabled" );
  25035. } else {
  25036. currentItem.removeAttr( "aria-disabled" );
  25037. this._removeClass( currentItem, null, "ui-state-disabled" );
  25038. }
  25039. }
  25040. this.options.disabled = disabled;
  25041. this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null,
  25042. disabled === true );
  25043. },
  25044. _setupEvents: function( event ) {
  25045. var events = {};
  25046. if ( event ) {
  25047. $.each( event.split( " " ), function( index, eventName ) {
  25048. events[ eventName ] = "_eventHandler";
  25049. } );
  25050. }
  25051. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  25052. // Always prevent the default action, even when disabled
  25053. this._on( true, this.anchors, {
  25054. click: function( event ) {
  25055. event.preventDefault();
  25056. }
  25057. } );
  25058. this._on( this.anchors, events );
  25059. this._on( this.tabs, { keydown: "_tabKeydown" } );
  25060. this._on( this.panels, { keydown: "_panelKeydown" } );
  25061. this._focusable( this.tabs );
  25062. this._hoverable( this.tabs );
  25063. },
  25064. _setupHeightStyle: function( heightStyle ) {
  25065. var maxHeight,
  25066. parent = this.element.parent();
  25067. if ( heightStyle === "fill" ) {
  25068. maxHeight = parent.height();
  25069. maxHeight -= this.element.outerHeight() - this.element.height();
  25070. this.element.siblings( ":visible" ).each( function() {
  25071. var elem = $( this ),
  25072. position = elem.css( "position" );
  25073. if ( position === "absolute" || position === "fixed" ) {
  25074. return;
  25075. }
  25076. maxHeight -= elem.outerHeight( true );
  25077. } );
  25078. this.element.children().not( this.panels ).each( function() {
  25079. maxHeight -= $( this ).outerHeight( true );
  25080. } );
  25081. this.panels.each( function() {
  25082. $( this ).height( Math.max( 0, maxHeight -
  25083. $( this ).innerHeight() + $( this ).height() ) );
  25084. } )
  25085. .css( "overflow", "auto" );
  25086. } else if ( heightStyle === "auto" ) {
  25087. maxHeight = 0;
  25088. this.panels.each( function() {
  25089. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  25090. } ).height( maxHeight );
  25091. }
  25092. },
  25093. _eventHandler: function( event ) {
  25094. var options = this.options,
  25095. active = this.active,
  25096. anchor = $( event.currentTarget ),
  25097. tab = anchor.closest( "li" ),
  25098. clickedIsActive = tab[ 0 ] === active[ 0 ],
  25099. collapsing = clickedIsActive && options.collapsible,
  25100. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  25101. toHide = !active.length ? $() : this._getPanelForTab( active ),
  25102. eventData = {
  25103. oldTab: active,
  25104. oldPanel: toHide,
  25105. newTab: collapsing ? $() : tab,
  25106. newPanel: toShow
  25107. };
  25108. event.preventDefault();
  25109. if ( tab.hasClass( "ui-state-disabled" ) ||
  25110. // tab is already loading
  25111. tab.hasClass( "ui-tabs-loading" ) ||
  25112. // can't switch durning an animation
  25113. this.running ||
  25114. // click on active header, but not collapsible
  25115. ( clickedIsActive && !options.collapsible ) ||
  25116. // allow canceling activation
  25117. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  25118. return;
  25119. }
  25120. options.active = collapsing ? false : this.tabs.index( tab );
  25121. this.active = clickedIsActive ? $() : tab;
  25122. if ( this.xhr ) {
  25123. this.xhr.abort();
  25124. }
  25125. if ( !toHide.length && !toShow.length ) {
  25126. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  25127. }
  25128. if ( toShow.length ) {
  25129. this.load( this.tabs.index( tab ), event );
  25130. }
  25131. this._toggle( event, eventData );
  25132. },
  25133. // Handles show/hide for selecting tabs
  25134. _toggle: function( event, eventData ) {
  25135. var that = this,
  25136. toShow = eventData.newPanel,
  25137. toHide = eventData.oldPanel;
  25138. this.running = true;
  25139. function complete() {
  25140. that.running = false;
  25141. that._trigger( "activate", event, eventData );
  25142. }
  25143. function show() {
  25144. that._addClass( eventData.newTab.closest( "li" ), "ui-tabs-active", "ui-state-active" );
  25145. if ( toShow.length && that.options.show ) {
  25146. that._show( toShow, that.options.show, complete );
  25147. } else {
  25148. toShow.show();
  25149. complete();
  25150. }
  25151. }
  25152. // Start out by hiding, then showing, then completing
  25153. if ( toHide.length && this.options.hide ) {
  25154. this._hide( toHide, this.options.hide, function() {
  25155. that._removeClass( eventData.oldTab.closest( "li" ),
  25156. "ui-tabs-active", "ui-state-active" );
  25157. show();
  25158. } );
  25159. } else {
  25160. this._removeClass( eventData.oldTab.closest( "li" ),
  25161. "ui-tabs-active", "ui-state-active" );
  25162. toHide.hide();
  25163. show();
  25164. }
  25165. toHide.attr( "aria-hidden", "true" );
  25166. eventData.oldTab.attr( {
  25167. "aria-selected": "false",
  25168. "aria-expanded": "false"
  25169. } );
  25170. // If we're switching tabs, remove the old tab from the tab order.
  25171. // If we're opening from collapsed state, remove the previous tab from the tab order.
  25172. // If we're collapsing, then keep the collapsing tab in the tab order.
  25173. if ( toShow.length && toHide.length ) {
  25174. eventData.oldTab.attr( "tabIndex", -1 );
  25175. } else if ( toShow.length ) {
  25176. this.tabs.filter( function() {
  25177. return $( this ).attr( "tabIndex" ) === 0;
  25178. } )
  25179. .attr( "tabIndex", -1 );
  25180. }
  25181. toShow.attr( "aria-hidden", "false" );
  25182. eventData.newTab.attr( {
  25183. "aria-selected": "true",
  25184. "aria-expanded": "true",
  25185. tabIndex: 0
  25186. } );
  25187. },
  25188. _activate: function( index ) {
  25189. var anchor,
  25190. active = this._findActive( index );
  25191. // Trying to activate the already active panel
  25192. if ( active[ 0 ] === this.active[ 0 ] ) {
  25193. return;
  25194. }
  25195. // Trying to collapse, simulate a click on the current active header
  25196. if ( !active.length ) {
  25197. active = this.active;
  25198. }
  25199. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  25200. this._eventHandler( {
  25201. target: anchor,
  25202. currentTarget: anchor,
  25203. preventDefault: $.noop
  25204. } );
  25205. },
  25206. _findActive: function( index ) {
  25207. return index === false ? $() : this.tabs.eq( index );
  25208. },
  25209. _getIndex: function( index ) {
  25210. // meta-function to give users option to provide a href string instead of a numerical index.
  25211. if ( typeof index === "string" ) {
  25212. index = this.anchors.index( this.anchors.filter( "[href$='" +
  25213. $.ui.escapeSelector( index ) + "']" ) );
  25214. }
  25215. return index;
  25216. },
  25217. _destroy: function() {
  25218. if ( this.xhr ) {
  25219. this.xhr.abort();
  25220. }
  25221. this.tablist
  25222. .removeAttr( "role" )
  25223. .off( this.eventNamespace );
  25224. this.anchors
  25225. .removeAttr( "role tabIndex" )
  25226. .removeUniqueId();
  25227. this.tabs.add( this.panels ).each( function() {
  25228. if ( $.data( this, "ui-tabs-destroy" ) ) {
  25229. $( this ).remove();
  25230. } else {
  25231. $( this ).removeAttr( "role tabIndex " +
  25232. "aria-live aria-busy aria-selected aria-labelledby aria-hidden aria-expanded" );
  25233. }
  25234. } );
  25235. this.tabs.each( function() {
  25236. var li = $( this ),
  25237. prev = li.data( "ui-tabs-aria-controls" );
  25238. if ( prev ) {
  25239. li
  25240. .attr( "aria-controls", prev )
  25241. .removeData( "ui-tabs-aria-controls" );
  25242. } else {
  25243. li.removeAttr( "aria-controls" );
  25244. }
  25245. } );
  25246. this.panels.show();
  25247. if ( this.options.heightStyle !== "content" ) {
  25248. this.panels.css( "height", "" );
  25249. }
  25250. },
  25251. enable: function( index ) {
  25252. var disabled = this.options.disabled;
  25253. if ( disabled === false ) {
  25254. return;
  25255. }
  25256. if ( index === undefined ) {
  25257. disabled = false;
  25258. } else {
  25259. index = this._getIndex( index );
  25260. if ( $.isArray( disabled ) ) {
  25261. disabled = $.map( disabled, function( num ) {
  25262. return num !== index ? num : null;
  25263. } );
  25264. } else {
  25265. disabled = $.map( this.tabs, function( li, num ) {
  25266. return num !== index ? num : null;
  25267. } );
  25268. }
  25269. }
  25270. this._setOptionDisabled( disabled );
  25271. },
  25272. disable: function( index ) {
  25273. var disabled = this.options.disabled;
  25274. if ( disabled === true ) {
  25275. return;
  25276. }
  25277. if ( index === undefined ) {
  25278. disabled = true;
  25279. } else {
  25280. index = this._getIndex( index );
  25281. if ( $.inArray( index, disabled ) !== -1 ) {
  25282. return;
  25283. }
  25284. if ( $.isArray( disabled ) ) {
  25285. disabled = $.merge( [ index ], disabled ).sort();
  25286. } else {
  25287. disabled = [ index ];
  25288. }
  25289. }
  25290. this._setOptionDisabled( disabled );
  25291. },
  25292. load: function( index, event ) {
  25293. index = this._getIndex( index );
  25294. var that = this,
  25295. tab = this.tabs.eq( index ),
  25296. anchor = tab.find( ".ui-tabs-anchor" ),
  25297. panel = this._getPanelForTab( tab ),
  25298. eventData = {
  25299. tab: tab,
  25300. panel: panel
  25301. },
  25302. complete = function( jqXHR, status ) {
  25303. if ( status === "abort" ) {
  25304. that.panels.stop( false, true );
  25305. }
  25306. that._removeClass( tab, "ui-tabs-loading" );
  25307. panel.removeAttr( "aria-busy" );
  25308. if ( jqXHR === that.xhr ) {
  25309. delete that.xhr;
  25310. }
  25311. };
  25312. // Not remote
  25313. if ( this._isLocal( anchor[ 0 ] ) ) {
  25314. return;
  25315. }
  25316. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  25317. // Support: jQuery <1.8
  25318. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  25319. // but as of 1.8, $.ajax() always returns a jqXHR object.
  25320. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  25321. this._addClass( tab, "ui-tabs-loading" );
  25322. panel.attr( "aria-busy", "true" );
  25323. this.xhr
  25324. .done( function( response, status, jqXHR ) {
  25325. // support: jQuery <1.8
  25326. // http://bugs.jquery.com/ticket/11778
  25327. setTimeout( function() {
  25328. panel.html( response );
  25329. that._trigger( "load", event, eventData );
  25330. complete( jqXHR, status );
  25331. }, 1 );
  25332. } )
  25333. .fail( function( jqXHR, status ) {
  25334. // support: jQuery <1.8
  25335. // http://bugs.jquery.com/ticket/11778
  25336. setTimeout( function() {
  25337. complete( jqXHR, status );
  25338. }, 1 );
  25339. } );
  25340. }
  25341. },
  25342. _ajaxSettings: function( anchor, event, eventData ) {
  25343. var that = this;
  25344. return {
  25345. // Support: IE <11 only
  25346. // Strip any hash that exists to prevent errors with the Ajax request
  25347. url: anchor.attr( "href" ).replace( /#.*$/, "" ),
  25348. beforeSend: function( jqXHR, settings ) {
  25349. return that._trigger( "beforeLoad", event,
  25350. $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) );
  25351. }
  25352. };
  25353. },
  25354. _getPanelForTab: function( tab ) {
  25355. var id = $( tab ).attr( "aria-controls" );
  25356. return this.element.find( this._sanitizeSelector( "#" + id ) );
  25357. }
  25358. } );
  25359. // DEPRECATED
  25360. // TODO: Switch return back to widget declaration at top of file when this is removed
  25361. if ( $.uiBackCompat !== false ) {
  25362. // Backcompat for ui-tab class (now ui-tabs-tab)
  25363. $.widget( "ui.tabs", $.ui.tabs, {
  25364. _processTabs: function() {
  25365. this._superApply( arguments );
  25366. this._addClass( this.tabs, "ui-tab" );
  25367. }
  25368. } );
  25369. }
  25370. var widgetsTabs = $.ui.tabs;
  25371. /*!
  25372. * jQuery UI Tooltip 1.12.1
  25373. * http://jqueryui.com
  25374. *
  25375. * Copyright jQuery Foundation and other contributors
  25376. * Released under the MIT license.
  25377. * http://jquery.org/license
  25378. */
  25379. //>>label: Tooltip
  25380. //>>group: Widgets
  25381. //>>description: Shows additional information for any element on hover or focus.
  25382. //>>docs: http://api.jqueryui.com/tooltip/
  25383. //>>demos: http://jqueryui.com/tooltip/
  25384. //>>css.structure: ../../themes/base/core.css
  25385. //>>css.structure: ../../themes/base/tooltip.css
  25386. //>>css.theme: ../../themes/base/theme.css
  25387. $.widget( "ui.tooltip", {
  25388. version: "1.12.1",
  25389. options: {
  25390. classes: {
  25391. "ui-tooltip": "ui-corner-all ui-widget-shadow"
  25392. },
  25393. content: function() {
  25394. // support: IE<9, Opera in jQuery <1.7
  25395. // .text() can't accept undefined, so coerce to a string
  25396. var title = $( this ).attr( "title" ) || "";
  25397. // Escape title, since we're going from an attribute to raw HTML
  25398. return $( "<a>" ).text( title ).html();
  25399. },
  25400. hide: true,
  25401. // Disabled elements have inconsistent behavior across browsers (#8661)
  25402. items: "[title]:not([disabled])",
  25403. position: {
  25404. my: "left top+15",
  25405. at: "left bottom",
  25406. collision: "flipfit flip"
  25407. },
  25408. show: true,
  25409. track: false,
  25410. // Callbacks
  25411. close: null,
  25412. open: null
  25413. },
  25414. _addDescribedBy: function( elem, id ) {
  25415. var describedby = ( elem.attr( "aria-describedby" ) || "" ).split( /\s+/ );
  25416. describedby.push( id );
  25417. elem
  25418. .data( "ui-tooltip-id", id )
  25419. .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
  25420. },
  25421. _removeDescribedBy: function( elem ) {
  25422. var id = elem.data( "ui-tooltip-id" ),
  25423. describedby = ( elem.attr( "aria-describedby" ) || "" ).split( /\s+/ ),
  25424. index = $.inArray( id, describedby );
  25425. if ( index !== -1 ) {
  25426. describedby.splice( index, 1 );
  25427. }
  25428. elem.removeData( "ui-tooltip-id" );
  25429. describedby = $.trim( describedby.join( " " ) );
  25430. if ( describedby ) {
  25431. elem.attr( "aria-describedby", describedby );
  25432. } else {
  25433. elem.removeAttr( "aria-describedby" );
  25434. }
  25435. },
  25436. _create: function() {
  25437. this._on( {
  25438. mouseover: "open",
  25439. focusin: "open"
  25440. } );
  25441. // IDs of generated tooltips, needed for destroy
  25442. this.tooltips = {};
  25443. // IDs of parent tooltips where we removed the title attribute
  25444. this.parents = {};
  25445. // Append the aria-live region so tooltips announce correctly
  25446. this.liveRegion = $( "<div>" )
  25447. .attr( {
  25448. role: "log",
  25449. "aria-live": "assertive",
  25450. "aria-relevant": "additions"
  25451. } )
  25452. .appendTo( this.document[ 0 ].body );
  25453. this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
  25454. this.disabledTitles = $( [] );
  25455. },
  25456. _setOption: function( key, value ) {
  25457. var that = this;
  25458. this._super( key, value );
  25459. if ( key === "content" ) {
  25460. $.each( this.tooltips, function( id, tooltipData ) {
  25461. that._updateContent( tooltipData.element );
  25462. } );
  25463. }
  25464. },
  25465. _setOptionDisabled: function( value ) {
  25466. this[ value ? "_disable" : "_enable" ]();
  25467. },
  25468. _disable: function() {
  25469. var that = this;
  25470. // Close open tooltips
  25471. $.each( this.tooltips, function( id, tooltipData ) {
  25472. var event = $.Event( "blur" );
  25473. event.target = event.currentTarget = tooltipData.element[ 0 ];
  25474. that.close( event, true );
  25475. } );
  25476. // Remove title attributes to prevent native tooltips
  25477. this.disabledTitles = this.disabledTitles.add(
  25478. this.element.find( this.options.items ).addBack()
  25479. .filter( function() {
  25480. var element = $( this );
  25481. if ( element.is( "[title]" ) ) {
  25482. return element
  25483. .data( "ui-tooltip-title", element.attr( "title" ) )
  25484. .removeAttr( "title" );
  25485. }
  25486. } )
  25487. );
  25488. },
  25489. _enable: function() {
  25490. // restore title attributes
  25491. this.disabledTitles.each( function() {
  25492. var element = $( this );
  25493. if ( element.data( "ui-tooltip-title" ) ) {
  25494. element.attr( "title", element.data( "ui-tooltip-title" ) );
  25495. }
  25496. } );
  25497. this.disabledTitles = $( [] );
  25498. },
  25499. open: function( event ) {
  25500. var that = this,
  25501. target = $( event ? event.target : this.element )
  25502. // we need closest here due to mouseover bubbling,
  25503. // but always pointing at the same event target
  25504. .closest( this.options.items );
  25505. // No element to show a tooltip for or the tooltip is already open
  25506. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  25507. return;
  25508. }
  25509. if ( target.attr( "title" ) ) {
  25510. target.data( "ui-tooltip-title", target.attr( "title" ) );
  25511. }
  25512. target.data( "ui-tooltip-open", true );
  25513. // Kill parent tooltips, custom or native, for hover
  25514. if ( event && event.type === "mouseover" ) {
  25515. target.parents().each( function() {
  25516. var parent = $( this ),
  25517. blurEvent;
  25518. if ( parent.data( "ui-tooltip-open" ) ) {
  25519. blurEvent = $.Event( "blur" );
  25520. blurEvent.target = blurEvent.currentTarget = this;
  25521. that.close( blurEvent, true );
  25522. }
  25523. if ( parent.attr( "title" ) ) {
  25524. parent.uniqueId();
  25525. that.parents[ this.id ] = {
  25526. element: this,
  25527. title: parent.attr( "title" )
  25528. };
  25529. parent.attr( "title", "" );
  25530. }
  25531. } );
  25532. }
  25533. this._registerCloseHandlers( event, target );
  25534. this._updateContent( target, event );
  25535. },
  25536. _updateContent: function( target, event ) {
  25537. var content,
  25538. contentOption = this.options.content,
  25539. that = this,
  25540. eventType = event ? event.type : null;
  25541. if ( typeof contentOption === "string" || contentOption.nodeType ||
  25542. contentOption.jquery ) {
  25543. return this._open( event, target, contentOption );
  25544. }
  25545. content = contentOption.call( target[ 0 ], function( response ) {
  25546. // IE may instantly serve a cached response for ajax requests
  25547. // delay this call to _open so the other call to _open runs first
  25548. that._delay( function() {
  25549. // Ignore async response if tooltip was closed already
  25550. if ( !target.data( "ui-tooltip-open" ) ) {
  25551. return;
  25552. }
  25553. // JQuery creates a special event for focusin when it doesn't
  25554. // exist natively. To improve performance, the native event
  25555. // object is reused and the type is changed. Therefore, we can't
  25556. // rely on the type being correct after the event finished
  25557. // bubbling, so we set it back to the previous value. (#8740)
  25558. if ( event ) {
  25559. event.type = eventType;
  25560. }
  25561. this._open( event, target, response );
  25562. } );
  25563. } );
  25564. if ( content ) {
  25565. this._open( event, target, content );
  25566. }
  25567. },
  25568. _open: function( event, target, content ) {
  25569. var tooltipData, tooltip, delayedShow, a11yContent,
  25570. positionOption = $.extend( {}, this.options.position );
  25571. if ( !content ) {
  25572. return;
  25573. }
  25574. // Content can be updated multiple times. If the tooltip already
  25575. // exists, then just update the content and bail.
  25576. tooltipData = this._find( target );
  25577. if ( tooltipData ) {
  25578. tooltipData.tooltip.find( ".ui-tooltip-content" ).html( content );
  25579. return;
  25580. }
  25581. // If we have a title, clear it to prevent the native tooltip
  25582. // we have to check first to avoid defining a title if none exists
  25583. // (we don't want to cause an element to start matching [title])
  25584. //
  25585. // We use removeAttr only for key events, to allow IE to export the correct
  25586. // accessible attributes. For mouse events, set to empty string to avoid
  25587. // native tooltip showing up (happens only when removing inside mouseover).
  25588. if ( target.is( "[title]" ) ) {
  25589. if ( event && event.type === "mouseover" ) {
  25590. target.attr( "title", "" );
  25591. } else {
  25592. target.removeAttr( "title" );
  25593. }
  25594. }
  25595. tooltipData = this._tooltip( target );
  25596. tooltip = tooltipData.tooltip;
  25597. this._addDescribedBy( target, tooltip.attr( "id" ) );
  25598. tooltip.find( ".ui-tooltip-content" ).html( content );
  25599. // Support: Voiceover on OS X, JAWS on IE <= 9
  25600. // JAWS announces deletions even when aria-relevant="additions"
  25601. // Voiceover will sometimes re-read the entire log region's contents from the beginning
  25602. this.liveRegion.children().hide();
  25603. a11yContent = $( "<div>" ).html( tooltip.find( ".ui-tooltip-content" ).html() );
  25604. a11yContent.removeAttr( "name" ).find( "[name]" ).removeAttr( "name" );
  25605. a11yContent.removeAttr( "id" ).find( "[id]" ).removeAttr( "id" );
  25606. a11yContent.appendTo( this.liveRegion );
  25607. function position( event ) {
  25608. positionOption.of = event;
  25609. if ( tooltip.is( ":hidden" ) ) {
  25610. return;
  25611. }
  25612. tooltip.position( positionOption );
  25613. }
  25614. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  25615. this._on( this.document, {
  25616. mousemove: position
  25617. } );
  25618. // trigger once to override element-relative positioning
  25619. position( event );
  25620. } else {
  25621. tooltip.position( $.extend( {
  25622. of: target
  25623. }, this.options.position ) );
  25624. }
  25625. tooltip.hide();
  25626. this._show( tooltip, this.options.show );
  25627. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  25628. // as the tooltip is visible, position the tooltip using the most recent
  25629. // event.
  25630. // Adds the check to add the timers only when both delay and track options are set (#14682)
  25631. if ( this.options.track && this.options.show && this.options.show.delay ) {
  25632. delayedShow = this.delayedShow = setInterval( function() {
  25633. if ( tooltip.is( ":visible" ) ) {
  25634. position( positionOption.of );
  25635. clearInterval( delayedShow );
  25636. }
  25637. }, $.fx.interval );
  25638. }
  25639. this._trigger( "open", event, { tooltip: tooltip } );
  25640. },
  25641. _registerCloseHandlers: function( event, target ) {
  25642. var events = {
  25643. keyup: function( event ) {
  25644. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  25645. var fakeEvent = $.Event( event );
  25646. fakeEvent.currentTarget = target[ 0 ];
  25647. this.close( fakeEvent, true );
  25648. }
  25649. }
  25650. };
  25651. // Only bind remove handler for delegated targets. Non-delegated
  25652. // tooltips will handle this in destroy.
  25653. if ( target[ 0 ] !== this.element[ 0 ] ) {
  25654. events.remove = function() {
  25655. this._removeTooltip( this._find( target ).tooltip );
  25656. };
  25657. }
  25658. if ( !event || event.type === "mouseover" ) {
  25659. events.mouseleave = "close";
  25660. }
  25661. if ( !event || event.type === "focusin" ) {
  25662. events.focusout = "close";
  25663. }
  25664. this._on( true, target, events );
  25665. },
  25666. close: function( event ) {
  25667. var tooltip,
  25668. that = this,
  25669. target = $( event ? event.currentTarget : this.element ),
  25670. tooltipData = this._find( target );
  25671. // The tooltip may already be closed
  25672. if ( !tooltipData ) {
  25673. // We set ui-tooltip-open immediately upon open (in open()), but only set the
  25674. // additional data once there's actually content to show (in _open()). So even if the
  25675. // tooltip doesn't have full data, we always remove ui-tooltip-open in case we're in
  25676. // the period between open() and _open().
  25677. target.removeData( "ui-tooltip-open" );
  25678. return;
  25679. }
  25680. tooltip = tooltipData.tooltip;
  25681. // Disabling closes the tooltip, so we need to track when we're closing
  25682. // to avoid an infinite loop in case the tooltip becomes disabled on close
  25683. if ( tooltipData.closing ) {
  25684. return;
  25685. }
  25686. // Clear the interval for delayed tracking tooltips
  25687. clearInterval( this.delayedShow );
  25688. // Only set title if we had one before (see comment in _open())
  25689. // If the title attribute has changed since open(), don't restore
  25690. if ( target.data( "ui-tooltip-title" ) && !target.attr( "title" ) ) {
  25691. target.attr( "title", target.data( "ui-tooltip-title" ) );
  25692. }
  25693. this._removeDescribedBy( target );
  25694. tooltipData.hiding = true;
  25695. tooltip.stop( true );
  25696. this._hide( tooltip, this.options.hide, function() {
  25697. that._removeTooltip( $( this ) );
  25698. } );
  25699. target.removeData( "ui-tooltip-open" );
  25700. this._off( target, "mouseleave focusout keyup" );
  25701. // Remove 'remove' binding only on delegated targets
  25702. if ( target[ 0 ] !== this.element[ 0 ] ) {
  25703. this._off( target, "remove" );
  25704. }
  25705. this._off( this.document, "mousemove" );
  25706. if ( event && event.type === "mouseleave" ) {
  25707. $.each( this.parents, function( id, parent ) {
  25708. $( parent.element ).attr( "title", parent.title );
  25709. delete that.parents[ id ];
  25710. } );
  25711. }
  25712. tooltipData.closing = true;
  25713. this._trigger( "close", event, { tooltip: tooltip } );
  25714. if ( !tooltipData.hiding ) {
  25715. tooltipData.closing = false;
  25716. }
  25717. },
  25718. _tooltip: function( element ) {
  25719. var tooltip = $( "<div>" ).attr( "role", "tooltip" ),
  25720. content = $( "<div>" ).appendTo( tooltip ),
  25721. id = tooltip.uniqueId().attr( "id" );
  25722. this._addClass( content, "ui-tooltip-content" );
  25723. this._addClass( tooltip, "ui-tooltip", "ui-widget ui-widget-content" );
  25724. tooltip.appendTo( this._appendTo( element ) );
  25725. return this.tooltips[ id ] = {
  25726. element: element,
  25727. tooltip: tooltip
  25728. };
  25729. },
  25730. _find: function( target ) {
  25731. var id = target.data( "ui-tooltip-id" );
  25732. return id ? this.tooltips[ id ] : null;
  25733. },
  25734. _removeTooltip: function( tooltip ) {
  25735. tooltip.remove();
  25736. delete this.tooltips[ tooltip.attr( "id" ) ];
  25737. },
  25738. _appendTo: function( target ) {
  25739. var element = target.closest( ".ui-front, dialog" );
  25740. if ( !element.length ) {
  25741. element = this.document[ 0 ].body;
  25742. }
  25743. return element;
  25744. },
  25745. _destroy: function() {
  25746. var that = this;
  25747. // Close open tooltips
  25748. $.each( this.tooltips, function( id, tooltipData ) {
  25749. // Delegate to close method to handle common cleanup
  25750. var event = $.Event( "blur" ),
  25751. element = tooltipData.element;
  25752. event.target = event.currentTarget = element[ 0 ];
  25753. that.close( event, true );
  25754. // Remove immediately; destroying an open tooltip doesn't use the
  25755. // hide animation
  25756. $( "#" + id ).remove();
  25757. // Restore the title
  25758. if ( element.data( "ui-tooltip-title" ) ) {
  25759. // If the title attribute has changed since open(), don't restore
  25760. if ( !element.attr( "title" ) ) {
  25761. element.attr( "title", element.data( "ui-tooltip-title" ) );
  25762. }
  25763. element.removeData( "ui-tooltip-title" );
  25764. }
  25765. } );
  25766. this.liveRegion.remove();
  25767. }
  25768. } );
  25769. // DEPRECATED
  25770. // TODO: Switch return back to widget declaration at top of file when this is removed
  25771. if ( $.uiBackCompat !== false ) {
  25772. // Backcompat for tooltipClass option
  25773. $.widget( "ui.tooltip", $.ui.tooltip, {
  25774. options: {
  25775. tooltipClass: null
  25776. },
  25777. _tooltip: function() {
  25778. var tooltipData = this._superApply( arguments );
  25779. if ( this.options.tooltipClass ) {
  25780. tooltipData.tooltip.addClass( this.options.tooltipClass );
  25781. }
  25782. return tooltipData;
  25783. }
  25784. } );
  25785. }
  25786. var widgetsTooltip = $.ui.tooltip;
  25787. }));
  25788. });