jquery-ui-1.10.3.min.js 426 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003
  1. /*! jQuery UI - v1.10.3 - 2013-05-03
  2. * http://jqueryui.com
  3. * Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.ui.effect.js, jquery.ui.accordion.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.datepicker.js, jquery.ui.dialog.js, jquery.ui.effect-blind.js, jquery.ui.effect-bounce.js, jquery.ui.effect-clip.js, jquery.ui.effect-drop.js, jquery.ui.effect-explode.js, jquery.ui.effect-fade.js, jquery.ui.effect-fold.js, jquery.ui.effect-highlight.js, jquery.ui.effect-pulsate.js, jquery.ui.effect-scale.js, jquery.ui.effect-shake.js, jquery.ui.effect-slide.js, jquery.ui.effect-transfer.js, jquery.ui.menu.js, jquery.ui.position.js, jquery.ui.progressbar.js, jquery.ui.slider.js, jquery.ui.spinner.js, jquery.ui.tabs.js, jquery.ui.tooltip.js
  4. * Copyright 2013 jQuery Foundation and other contributors; Licensed MIT */
  5. (function( $, undefined ) {
  6. var uuid = 0,
  7. runiqueId = /^ui-id-\d+$/;
  8. // $.ui might exist from components with no dependencies, e.g., $.ui.position
  9. $.ui = $.ui || {};
  10. $.extend( $.ui, {
  11. version: "1.10.3",
  12. keyCode: {
  13. BACKSPACE: 8,
  14. COMMA: 188,
  15. DELETE: 46,
  16. DOWN: 40,
  17. END: 35,
  18. ENTER: 13,
  19. ESCAPE: 27,
  20. HOME: 36,
  21. LEFT: 37,
  22. NUMPAD_ADD: 107,
  23. NUMPAD_DECIMAL: 110,
  24. NUMPAD_DIVIDE: 111,
  25. NUMPAD_ENTER: 108,
  26. NUMPAD_MULTIPLY: 106,
  27. NUMPAD_SUBTRACT: 109,
  28. PAGE_DOWN: 34,
  29. PAGE_UP: 33,
  30. PERIOD: 190,
  31. RIGHT: 39,
  32. SPACE: 32,
  33. TAB: 9,
  34. UP: 38
  35. }
  36. });
  37. // plugins
  38. $.fn.extend({
  39. focus: (function( orig ) {
  40. return function( delay, fn ) {
  41. return typeof delay === "number" ?
  42. this.each(function() {
  43. var elem = this;
  44. setTimeout(function() {
  45. $( elem ).focus();
  46. if ( fn ) {
  47. fn.call( elem );
  48. }
  49. }, delay );
  50. }) :
  51. orig.apply( this, arguments );
  52. };
  53. })( $.fn.focus ),
  54. scrollParent: function() {
  55. var scrollParent;
  56. if (($.ui.ie && (/(static|relative)/).test(this.css("position"))) || (/absolute/).test(this.css("position"))) {
  57. scrollParent = this.parents().filter(function() {
  58. return (/(relative|absolute|fixed)/).test($.css(this,"position")) && (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
  59. }).eq(0);
  60. } else {
  61. scrollParent = this.parents().filter(function() {
  62. return (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
  63. }).eq(0);
  64. }
  65. return (/fixed/).test(this.css("position")) || !scrollParent.length ? $(document) : scrollParent;
  66. },
  67. zIndex: function( zIndex ) {
  68. if ( zIndex !== undefined ) {
  69. return this.css( "zIndex", zIndex );
  70. }
  71. if ( this.length ) {
  72. var elem = $( this[ 0 ] ), position, value;
  73. while ( elem.length && elem[ 0 ] !== document ) {
  74. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  75. // This makes behavior of this function consistent across browsers
  76. // WebKit always returns auto if the element is positioned
  77. position = elem.css( "position" );
  78. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  79. // IE returns 0 when zIndex is not specified
  80. // other browsers return a string
  81. // we ignore the case of nested elements with an explicit value of 0
  82. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  83. value = parseInt( elem.css( "zIndex" ), 10 );
  84. if ( !isNaN( value ) && value !== 0 ) {
  85. return value;
  86. }
  87. }
  88. elem = elem.parent();
  89. }
  90. }
  91. return 0;
  92. },
  93. uniqueId: function() {
  94. return this.each(function() {
  95. if ( !this.id ) {
  96. this.id = "ui-id-" + (++uuid);
  97. }
  98. });
  99. },
  100. removeUniqueId: function() {
  101. return this.each(function() {
  102. if ( runiqueId.test( this.id ) ) {
  103. $( this ).removeAttr( "id" );
  104. }
  105. });
  106. }
  107. });
  108. // selectors
  109. function focusable( element, isTabIndexNotNaN ) {
  110. var map, mapName, img,
  111. nodeName = element.nodeName.toLowerCase();
  112. if ( "area" === nodeName ) {
  113. map = element.parentNode;
  114. mapName = map.name;
  115. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  116. return false;
  117. }
  118. img = $( "img[usemap=#" + mapName + "]" )[0];
  119. return !!img && visible( img );
  120. }
  121. return ( /input|select|textarea|button|object/.test( nodeName ) ?
  122. !element.disabled :
  123. "a" === nodeName ?
  124. element.href || isTabIndexNotNaN :
  125. isTabIndexNotNaN) &&
  126. // the element and all of its ancestors must be visible
  127. visible( element );
  128. }
  129. function visible( element ) {
  130. return $.expr.filters.visible( element ) &&
  131. !$( element ).parents().addBack().filter(function() {
  132. return $.css( this, "visibility" ) === "hidden";
  133. }).length;
  134. }
  135. $.extend( $.expr[ ":" ], {
  136. data: $.expr.createPseudo ?
  137. $.expr.createPseudo(function( dataName ) {
  138. return function( elem ) {
  139. return !!$.data( elem, dataName );
  140. };
  141. }) :
  142. // support: jQuery <1.8
  143. function( elem, i, match ) {
  144. return !!$.data( elem, match[ 3 ] );
  145. },
  146. focusable: function( element ) {
  147. return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
  148. },
  149. tabbable: function( element ) {
  150. var tabIndex = $.attr( element, "tabindex" ),
  151. isTabIndexNaN = isNaN( tabIndex );
  152. return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
  153. }
  154. });
  155. // support: jQuery <1.8
  156. if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
  157. $.each( [ "Width", "Height" ], function( i, name ) {
  158. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  159. type = name.toLowerCase(),
  160. orig = {
  161. innerWidth: $.fn.innerWidth,
  162. innerHeight: $.fn.innerHeight,
  163. outerWidth: $.fn.outerWidth,
  164. outerHeight: $.fn.outerHeight
  165. };
  166. function reduce( elem, size, border, margin ) {
  167. $.each( side, function() {
  168. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  169. if ( border ) {
  170. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  171. }
  172. if ( margin ) {
  173. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  174. }
  175. });
  176. return size;
  177. }
  178. $.fn[ "inner" + name ] = function( size ) {
  179. if ( size === undefined ) {
  180. return orig[ "inner" + name ].call( this );
  181. }
  182. return this.each(function() {
  183. $( this ).css( type, reduce( this, size ) + "px" );
  184. });
  185. };
  186. $.fn[ "outer" + name] = function( size, margin ) {
  187. if ( typeof size !== "number" ) {
  188. return orig[ "outer" + name ].call( this, size );
  189. }
  190. return this.each(function() {
  191. $( this).css( type, reduce( this, size, true, margin ) + "px" );
  192. });
  193. };
  194. });
  195. }
  196. // support: jQuery <1.8
  197. if ( !$.fn.addBack ) {
  198. $.fn.addBack = function( selector ) {
  199. return this.add( selector == null ?
  200. this.prevObject : this.prevObject.filter( selector )
  201. );
  202. };
  203. }
  204. // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
  205. if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
  206. $.fn.removeData = (function( removeData ) {
  207. return function( key ) {
  208. if ( arguments.length ) {
  209. return removeData.call( this, $.camelCase( key ) );
  210. } else {
  211. return removeData.call( this );
  212. }
  213. };
  214. })( $.fn.removeData );
  215. }
  216. // deprecated
  217. $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  218. $.support.selectstart = "onselectstart" in document.createElement( "div" );
  219. $.fn.extend({
  220. disableSelection: function() {
  221. return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
  222. ".ui-disableSelection", function( event ) {
  223. event.preventDefault();
  224. });
  225. },
  226. enableSelection: function() {
  227. return this.unbind( ".ui-disableSelection" );
  228. }
  229. });
  230. $.extend( $.ui, {
  231. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  232. plugin: {
  233. add: function( module, option, set ) {
  234. var i,
  235. proto = $.ui[ module ].prototype;
  236. for ( i in set ) {
  237. proto.plugins[ i ] = proto.plugins[ i ] || [];
  238. proto.plugins[ i ].push( [ option, set[ i ] ] );
  239. }
  240. },
  241. call: function( instance, name, args ) {
  242. var i,
  243. set = instance.plugins[ name ];
  244. if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
  245. return;
  246. }
  247. for ( i = 0; i < set.length; i++ ) {
  248. if ( instance.options[ set[ i ][ 0 ] ] ) {
  249. set[ i ][ 1 ].apply( instance.element, args );
  250. }
  251. }
  252. }
  253. },
  254. // only used by resizable
  255. hasScroll: function( el, a ) {
  256. //If overflow is hidden, the element might have extra content, but the user wants to hide it
  257. if ( $( el ).css( "overflow" ) === "hidden") {
  258. return false;
  259. }
  260. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  261. has = false;
  262. if ( el[ scroll ] > 0 ) {
  263. return true;
  264. }
  265. // TODO: determine which cases actually cause this to happen
  266. // if the element doesn't have the scroll set, see if it's possible to
  267. // set the scroll
  268. el[ scroll ] = 1;
  269. has = ( el[ scroll ] > 0 );
  270. el[ scroll ] = 0;
  271. return has;
  272. }
  273. });
  274. })( jQuery );
  275. (function( $, undefined ) {
  276. var uuid = 0,
  277. slice = Array.prototype.slice,
  278. _cleanData = $.cleanData;
  279. $.cleanData = function( elems ) {
  280. for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
  281. try {
  282. $( elem ).triggerHandler( "remove" );
  283. // http://bugs.jquery.com/ticket/8235
  284. } catch( e ) {}
  285. }
  286. _cleanData( elems );
  287. };
  288. $.widget = function( name, base, prototype ) {
  289. var fullName, existingConstructor, constructor, basePrototype,
  290. // proxiedPrototype allows the provided prototype to remain unmodified
  291. // so that it can be used as a mixin for multiple widgets (#8876)
  292. proxiedPrototype = {},
  293. namespace = name.split( "." )[ 0 ];
  294. name = name.split( "." )[ 1 ];
  295. fullName = namespace + "-" + name;
  296. if ( !prototype ) {
  297. prototype = base;
  298. base = $.Widget;
  299. }
  300. // create selector for plugin
  301. $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
  302. return !!$.data( elem, fullName );
  303. };
  304. $[ namespace ] = $[ namespace ] || {};
  305. existingConstructor = $[ namespace ][ name ];
  306. constructor = $[ namespace ][ name ] = function( options, element ) {
  307. // allow instantiation without "new" keyword
  308. if ( !this._createWidget ) {
  309. return new constructor( options, element );
  310. }
  311. // allow instantiation without initializing for simple inheritance
  312. // must use "new" keyword (the code above always passes args)
  313. if ( arguments.length ) {
  314. this._createWidget( options, element );
  315. }
  316. };
  317. // extend with the existing constructor to carry over any static properties
  318. $.extend( constructor, existingConstructor, {
  319. version: prototype.version,
  320. // copy the object used to create the prototype in case we need to
  321. // redefine the widget later
  322. _proto: $.extend( {}, prototype ),
  323. // track widgets that inherit from this widget in case this widget is
  324. // redefined after a widget inherits from it
  325. _childConstructors: []
  326. });
  327. basePrototype = new base();
  328. // we need to make the options hash a property directly on the new instance
  329. // otherwise we'll modify the options hash on the prototype that we're
  330. // inheriting from
  331. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  332. $.each( prototype, function( prop, value ) {
  333. if ( !$.isFunction( value ) ) {
  334. proxiedPrototype[ prop ] = value;
  335. return;
  336. }
  337. proxiedPrototype[ prop ] = (function() {
  338. var _super = function() {
  339. return base.prototype[ prop ].apply( this, arguments );
  340. },
  341. _superApply = function( args ) {
  342. return base.prototype[ prop ].apply( this, args );
  343. };
  344. return function() {
  345. var __super = this._super,
  346. __superApply = this._superApply,
  347. returnValue;
  348. this._super = _super;
  349. this._superApply = _superApply;
  350. returnValue = value.apply( this, arguments );
  351. this._super = __super;
  352. this._superApply = __superApply;
  353. return returnValue;
  354. };
  355. })();
  356. });
  357. constructor.prototype = $.widget.extend( basePrototype, {
  358. // TODO: remove support for widgetEventPrefix
  359. // always use the name + a colon as the prefix, e.g., draggable:start
  360. // don't prefix for widgets that aren't DOM-based
  361. widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name
  362. }, proxiedPrototype, {
  363. constructor: constructor,
  364. namespace: namespace,
  365. widgetName: name,
  366. widgetFullName: fullName
  367. });
  368. // If this widget is being redefined then we need to find all widgets that
  369. // are inheriting from it and redefine all of them so that they inherit from
  370. // the new version of this widget. We're essentially trying to replace one
  371. // level in the prototype chain.
  372. if ( existingConstructor ) {
  373. $.each( existingConstructor._childConstructors, function( i, child ) {
  374. var childPrototype = child.prototype;
  375. // redefine the child widget using the same prototype that was
  376. // originally used, but inherit from the new version of the base
  377. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
  378. });
  379. // remove the list of existing child constructors from the old constructor
  380. // so the old child constructors can be garbage collected
  381. delete existingConstructor._childConstructors;
  382. } else {
  383. base._childConstructors.push( constructor );
  384. }
  385. $.widget.bridge( name, constructor );
  386. };
  387. $.widget.extend = function( target ) {
  388. var input = slice.call( arguments, 1 ),
  389. inputIndex = 0,
  390. inputLength = input.length,
  391. key,
  392. value;
  393. for ( ; inputIndex < inputLength; inputIndex++ ) {
  394. for ( key in input[ inputIndex ] ) {
  395. value = input[ inputIndex ][ key ];
  396. if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
  397. // Clone objects
  398. if ( $.isPlainObject( value ) ) {
  399. target[ key ] = $.isPlainObject( target[ key ] ) ?
  400. $.widget.extend( {}, target[ key ], value ) :
  401. // Don't extend strings, arrays, etc. with objects
  402. $.widget.extend( {}, value );
  403. // Copy everything else by reference
  404. } else {
  405. target[ key ] = value;
  406. }
  407. }
  408. }
  409. }
  410. return target;
  411. };
  412. $.widget.bridge = function( name, object ) {
  413. var fullName = object.prototype.widgetFullName || name;
  414. $.fn[ name ] = function( options ) {
  415. var isMethodCall = typeof options === "string",
  416. args = slice.call( arguments, 1 ),
  417. returnValue = this;
  418. // allow multiple hashes to be passed on init
  419. options = !isMethodCall && args.length ?
  420. $.widget.extend.apply( null, [ options ].concat(args) ) :
  421. options;
  422. if ( isMethodCall ) {
  423. this.each(function() {
  424. var methodValue,
  425. instance = $.data( this, fullName );
  426. if ( !instance ) {
  427. return $.error( "cannot call methods on " + name + " prior to initialization; " +
  428. "attempted to call method '" + options + "'" );
  429. }
  430. if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
  431. return $.error( "no such method '" + options + "' for " + name + " widget instance" );
  432. }
  433. methodValue = instance[ options ].apply( instance, args );
  434. if ( methodValue !== instance && methodValue !== undefined ) {
  435. returnValue = methodValue && methodValue.jquery ?
  436. returnValue.pushStack( methodValue.get() ) :
  437. methodValue;
  438. return false;
  439. }
  440. });
  441. } else {
  442. this.each(function() {
  443. var instance = $.data( this, fullName );
  444. if ( instance ) {
  445. instance.option( options || {} )._init();
  446. } else {
  447. $.data( this, fullName, new object( options, this ) );
  448. }
  449. });
  450. }
  451. return returnValue;
  452. };
  453. };
  454. $.Widget = function( /* options, element */ ) {};
  455. $.Widget._childConstructors = [];
  456. $.Widget.prototype = {
  457. widgetName: "widget",
  458. widgetEventPrefix: "",
  459. defaultElement: "<div>",
  460. options: {
  461. disabled: false,
  462. // callbacks
  463. create: null
  464. },
  465. _createWidget: function( options, element ) {
  466. element = $( element || this.defaultElement || this )[ 0 ];
  467. this.element = $( element );
  468. this.uuid = uuid++;
  469. this.eventNamespace = "." + this.widgetName + this.uuid;
  470. this.options = $.widget.extend( {},
  471. this.options,
  472. this._getCreateOptions(),
  473. options );
  474. this.bindings = $();
  475. this.hoverable = $();
  476. this.focusable = $();
  477. if ( element !== this ) {
  478. $.data( element, this.widgetFullName, this );
  479. this._on( true, this.element, {
  480. remove: function( event ) {
  481. if ( event.target === element ) {
  482. this.destroy();
  483. }
  484. }
  485. });
  486. this.document = $( element.style ?
  487. // element within the document
  488. element.ownerDocument :
  489. // element is window or document
  490. element.document || element );
  491. this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
  492. }
  493. this._create();
  494. this._trigger( "create", null, this._getCreateEventData() );
  495. this._init();
  496. },
  497. _getCreateOptions: $.noop,
  498. _getCreateEventData: $.noop,
  499. _create: $.noop,
  500. _init: $.noop,
  501. destroy: function() {
  502. this._destroy();
  503. // we can probably remove the unbind calls in 2.0
  504. // all event bindings should go through this._on()
  505. this.element
  506. .unbind( this.eventNamespace )
  507. // 1.9 BC for #7810
  508. // TODO remove dual storage
  509. .removeData( this.widgetName )
  510. .removeData( this.widgetFullName )
  511. // support: jquery <1.6.3
  512. // http://bugs.jquery.com/ticket/9413
  513. .removeData( $.camelCase( this.widgetFullName ) );
  514. this.widget()
  515. .unbind( this.eventNamespace )
  516. .removeAttr( "aria-disabled" )
  517. .removeClass(
  518. this.widgetFullName + "-disabled " +
  519. "ui-state-disabled" );
  520. // clean up events and states
  521. this.bindings.unbind( this.eventNamespace );
  522. this.hoverable.removeClass( "ui-state-hover" );
  523. this.focusable.removeClass( "ui-state-focus" );
  524. },
  525. _destroy: $.noop,
  526. widget: function() {
  527. return this.element;
  528. },
  529. option: function( key, value ) {
  530. var options = key,
  531. parts,
  532. curOption,
  533. i;
  534. if ( arguments.length === 0 ) {
  535. // don't return a reference to the internal hash
  536. return $.widget.extend( {}, this.options );
  537. }
  538. if ( typeof key === "string" ) {
  539. // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  540. options = {};
  541. parts = key.split( "." );
  542. key = parts.shift();
  543. if ( parts.length ) {
  544. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  545. for ( i = 0; i < parts.length - 1; i++ ) {
  546. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  547. curOption = curOption[ parts[ i ] ];
  548. }
  549. key = parts.pop();
  550. if ( value === undefined ) {
  551. return curOption[ key ] === undefined ? null : curOption[ key ];
  552. }
  553. curOption[ key ] = value;
  554. } else {
  555. if ( value === undefined ) {
  556. return this.options[ key ] === undefined ? null : this.options[ key ];
  557. }
  558. options[ key ] = value;
  559. }
  560. }
  561. this._setOptions( options );
  562. return this;
  563. },
  564. _setOptions: function( options ) {
  565. var key;
  566. for ( key in options ) {
  567. this._setOption( key, options[ key ] );
  568. }
  569. return this;
  570. },
  571. _setOption: function( key, value ) {
  572. this.options[ key ] = value;
  573. if ( key === "disabled" ) {
  574. this.widget()
  575. .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value )
  576. .attr( "aria-disabled", value );
  577. this.hoverable.removeClass( "ui-state-hover" );
  578. this.focusable.removeClass( "ui-state-focus" );
  579. }
  580. return this;
  581. },
  582. enable: function() {
  583. return this._setOption( "disabled", false );
  584. },
  585. disable: function() {
  586. return this._setOption( "disabled", true );
  587. },
  588. _on: function( suppressDisabledCheck, element, handlers ) {
  589. var delegateElement,
  590. instance = this;
  591. // no suppressDisabledCheck flag, shuffle arguments
  592. if ( typeof suppressDisabledCheck !== "boolean" ) {
  593. handlers = element;
  594. element = suppressDisabledCheck;
  595. suppressDisabledCheck = false;
  596. }
  597. // no element argument, shuffle and use this.element
  598. if ( !handlers ) {
  599. handlers = element;
  600. element = this.element;
  601. delegateElement = this.widget();
  602. } else {
  603. // accept selectors, DOM elements
  604. element = delegateElement = $( element );
  605. this.bindings = this.bindings.add( element );
  606. }
  607. $.each( handlers, function( event, handler ) {
  608. function handlerProxy() {
  609. // allow widgets to customize the disabled handling
  610. // - disabled as an array instead of boolean
  611. // - disabled class as method for disabling individual parts
  612. if ( !suppressDisabledCheck &&
  613. ( instance.options.disabled === true ||
  614. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  615. return;
  616. }
  617. return ( typeof handler === "string" ? instance[ handler ] : handler )
  618. .apply( instance, arguments );
  619. }
  620. // copy the guid so direct unbinding works
  621. if ( typeof handler !== "string" ) {
  622. handlerProxy.guid = handler.guid =
  623. handler.guid || handlerProxy.guid || $.guid++;
  624. }
  625. var match = event.match( /^(\w+)\s*(.*)$/ ),
  626. eventName = match[1] + instance.eventNamespace,
  627. selector = match[2];
  628. if ( selector ) {
  629. delegateElement.delegate( selector, eventName, handlerProxy );
  630. } else {
  631. element.bind( eventName, handlerProxy );
  632. }
  633. });
  634. },
  635. _off: function( element, eventName ) {
  636. eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
  637. element.unbind( eventName ).undelegate( eventName );
  638. },
  639. _delay: function( handler, delay ) {
  640. function handlerProxy() {
  641. return ( typeof handler === "string" ? instance[ handler ] : handler )
  642. .apply( instance, arguments );
  643. }
  644. var instance = this;
  645. return setTimeout( handlerProxy, delay || 0 );
  646. },
  647. _hoverable: function( element ) {
  648. this.hoverable = this.hoverable.add( element );
  649. this._on( element, {
  650. mouseenter: function( event ) {
  651. $( event.currentTarget ).addClass( "ui-state-hover" );
  652. },
  653. mouseleave: function( event ) {
  654. $( event.currentTarget ).removeClass( "ui-state-hover" );
  655. }
  656. });
  657. },
  658. _focusable: function( element ) {
  659. this.focusable = this.focusable.add( element );
  660. this._on( element, {
  661. focusin: function( event ) {
  662. $( event.currentTarget ).addClass( "ui-state-focus" );
  663. },
  664. focusout: function( event ) {
  665. $( event.currentTarget ).removeClass( "ui-state-focus" );
  666. }
  667. });
  668. },
  669. _trigger: function( type, event, data ) {
  670. var prop, orig,
  671. callback = this.options[ type ];
  672. data = data || {};
  673. event = $.Event( event );
  674. event.type = ( type === this.widgetEventPrefix ?
  675. type :
  676. this.widgetEventPrefix + type ).toLowerCase();
  677. // the original event may come from any element
  678. // so we need to reset the target on the new event
  679. event.target = this.element[ 0 ];
  680. // copy original event properties over to the new event
  681. orig = event.originalEvent;
  682. if ( orig ) {
  683. for ( prop in orig ) {
  684. if ( !( prop in event ) ) {
  685. event[ prop ] = orig[ prop ];
  686. }
  687. }
  688. }
  689. this.element.trigger( event, data );
  690. return !( $.isFunction( callback ) &&
  691. callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
  692. event.isDefaultPrevented() );
  693. }
  694. };
  695. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  696. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  697. if ( typeof options === "string" ) {
  698. options = { effect: options };
  699. }
  700. var hasOptions,
  701. effectName = !options ?
  702. method :
  703. options === true || typeof options === "number" ?
  704. defaultEffect :
  705. options.effect || defaultEffect;
  706. options = options || {};
  707. if ( typeof options === "number" ) {
  708. options = { duration: options };
  709. }
  710. hasOptions = !$.isEmptyObject( options );
  711. options.complete = callback;
  712. if ( options.delay ) {
  713. element.delay( options.delay );
  714. }
  715. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  716. element[ method ]( options );
  717. } else if ( effectName !== method && element[ effectName ] ) {
  718. element[ effectName ]( options.duration, options.easing, callback );
  719. } else {
  720. element.queue(function( next ) {
  721. $( this )[ method ]();
  722. if ( callback ) {
  723. callback.call( element[ 0 ] );
  724. }
  725. next();
  726. });
  727. }
  728. };
  729. });
  730. })( jQuery );
  731. (function( $, undefined ) {
  732. var mouseHandled = false;
  733. $( document ).mouseup( function() {
  734. mouseHandled = false;
  735. });
  736. $.widget("ui.mouse", {
  737. version: "1.10.3",
  738. options: {
  739. cancel: "input,textarea,button,select,option",
  740. distance: 1,
  741. delay: 0
  742. },
  743. _mouseInit: function() {
  744. var that = this;
  745. this.element
  746. .bind("mousedown."+this.widgetName, function(event) {
  747. return that._mouseDown(event);
  748. })
  749. .bind("click."+this.widgetName, function(event) {
  750. if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
  751. $.removeData(event.target, that.widgetName + ".preventClickEvent");
  752. event.stopImmediatePropagation();
  753. return false;
  754. }
  755. });
  756. this.started = false;
  757. },
  758. // TODO: make sure destroying one instance of mouse doesn't mess with
  759. // other instances of mouse
  760. _mouseDestroy: function() {
  761. this.element.unbind("."+this.widgetName);
  762. if ( this._mouseMoveDelegate ) {
  763. $(document)
  764. .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
  765. .unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
  766. }
  767. },
  768. _mouseDown: function(event) {
  769. // don't let more than one widget handle mouseStart
  770. if( mouseHandled ) { return; }
  771. // we may have missed mouseup (out of window)
  772. (this._mouseStarted && this._mouseUp(event));
  773. this._mouseDownEvent = event;
  774. var that = this,
  775. btnIsLeft = (event.which === 1),
  776. // event.target.nodeName works around a bug in IE 8 with
  777. // disabled inputs (#7620)
  778. elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
  779. if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
  780. return true;
  781. }
  782. this.mouseDelayMet = !this.options.delay;
  783. if (!this.mouseDelayMet) {
  784. this._mouseDelayTimer = setTimeout(function() {
  785. that.mouseDelayMet = true;
  786. }, this.options.delay);
  787. }
  788. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  789. this._mouseStarted = (this._mouseStart(event) !== false);
  790. if (!this._mouseStarted) {
  791. event.preventDefault();
  792. return true;
  793. }
  794. }
  795. // Click event may never have fired (Gecko & Opera)
  796. if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
  797. $.removeData(event.target, this.widgetName + ".preventClickEvent");
  798. }
  799. // these delegates are required to keep context
  800. this._mouseMoveDelegate = function(event) {
  801. return that._mouseMove(event);
  802. };
  803. this._mouseUpDelegate = function(event) {
  804. return that._mouseUp(event);
  805. };
  806. $(document)
  807. .bind("mousemove."+this.widgetName, this._mouseMoveDelegate)
  808. .bind("mouseup."+this.widgetName, this._mouseUpDelegate);
  809. event.preventDefault();
  810. mouseHandled = true;
  811. return true;
  812. },
  813. _mouseMove: function(event) {
  814. // IE mouseup check - mouseup happened when mouse was out of window
  815. if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
  816. return this._mouseUp(event);
  817. }
  818. if (this._mouseStarted) {
  819. this._mouseDrag(event);
  820. return event.preventDefault();
  821. }
  822. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  823. this._mouseStarted =
  824. (this._mouseStart(this._mouseDownEvent, event) !== false);
  825. (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
  826. }
  827. return !this._mouseStarted;
  828. },
  829. _mouseUp: function(event) {
  830. $(document)
  831. .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
  832. .unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
  833. if (this._mouseStarted) {
  834. this._mouseStarted = false;
  835. if (event.target === this._mouseDownEvent.target) {
  836. $.data(event.target, this.widgetName + ".preventClickEvent", true);
  837. }
  838. this._mouseStop(event);
  839. }
  840. return false;
  841. },
  842. _mouseDistanceMet: function(event) {
  843. return (Math.max(
  844. Math.abs(this._mouseDownEvent.pageX - event.pageX),
  845. Math.abs(this._mouseDownEvent.pageY - event.pageY)
  846. ) >= this.options.distance
  847. );
  848. },
  849. _mouseDelayMet: function(/* event */) {
  850. return this.mouseDelayMet;
  851. },
  852. // These are placeholder methods, to be overriden by extending plugin
  853. _mouseStart: function(/* event */) {},
  854. _mouseDrag: function(/* event */) {},
  855. _mouseStop: function(/* event */) {},
  856. _mouseCapture: function(/* event */) { return true; }
  857. });
  858. })(jQuery);
  859. (function( $, undefined ) {
  860. $.widget("ui.draggable", $.ui.mouse, {
  861. version: "1.10.3",
  862. widgetEventPrefix: "drag",
  863. options: {
  864. addClasses: true,
  865. appendTo: "parent",
  866. axis: false,
  867. connectToSortable: false,
  868. containment: false,
  869. cursor: "auto",
  870. cursorAt: false,
  871. grid: false,
  872. handle: false,
  873. helper: "original",
  874. iframeFix: false,
  875. opacity: false,
  876. refreshPositions: false,
  877. revert: false,
  878. revertDuration: 500,
  879. scope: "default",
  880. scroll: true,
  881. scrollSensitivity: 20,
  882. scrollSpeed: 20,
  883. snap: false,
  884. snapMode: "both",
  885. snapTolerance: 20,
  886. stack: false,
  887. zIndex: false,
  888. // callbacks
  889. drag: null,
  890. start: null,
  891. stop: null
  892. },
  893. _create: function() {
  894. if (this.options.helper === "original" && !(/^(?:r|a|f)/).test(this.element.css("position"))) {
  895. this.element[0].style.position = "relative";
  896. }
  897. if (this.options.addClasses){
  898. this.element.addClass("ui-draggable");
  899. }
  900. if (this.options.disabled){
  901. this.element.addClass("ui-draggable-disabled");
  902. }
  903. this._mouseInit();
  904. },
  905. _destroy: function() {
  906. this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
  907. this._mouseDestroy();
  908. },
  909. _mouseCapture: function(event) {
  910. var o = this.options;
  911. // among others, prevent a drag on a resizable-handle
  912. if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
  913. return false;
  914. }
  915. //Quit if we're not on a valid handle
  916. this.handle = this._getHandle(event);
  917. if (!this.handle) {
  918. return false;
  919. }
  920. $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
  921. $("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>")
  922. .css({
  923. width: this.offsetWidth+"px", height: this.offsetHeight+"px",
  924. position: "absolute", opacity: "0.001", zIndex: 1000
  925. })
  926. .css($(this).offset())
  927. .appendTo("body");
  928. });
  929. return true;
  930. },
  931. _mouseStart: function(event) {
  932. var o = this.options;
  933. //Create and append the visible helper
  934. this.helper = this._createHelper(event);
  935. this.helper.addClass("ui-draggable-dragging");
  936. //Cache the helper size
  937. this._cacheHelperProportions();
  938. //If ddmanager is used for droppables, set the global draggable
  939. if($.ui.ddmanager) {
  940. $.ui.ddmanager.current = this;
  941. }
  942. /*
  943. * - Position generation -
  944. * This block generates everything position related - it's the core of draggables.
  945. */
  946. //Cache the margins of the original element
  947. this._cacheMargins();
  948. //Store the helper's css position
  949. this.cssPosition = this.helper.css( "position" );
  950. this.scrollParent = this.helper.scrollParent();
  951. this.offsetParent = this.helper.offsetParent();
  952. this.offsetParentCssPosition = this.offsetParent.css( "position" );
  953. //The element's absolute position on the page minus margins
  954. this.offset = this.positionAbs = this.element.offset();
  955. this.offset = {
  956. top: this.offset.top - this.margins.top,
  957. left: this.offset.left - this.margins.left
  958. };
  959. //Reset scroll cache
  960. this.offset.scroll = false;
  961. $.extend(this.offset, {
  962. click: { //Where the click happened, relative to the element
  963. left: event.pageX - this.offset.left,
  964. top: event.pageY - this.offset.top
  965. },
  966. parent: this._getParentOffset(),
  967. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  968. });
  969. //Generate the original position
  970. this.originalPosition = this.position = this._generatePosition(event);
  971. this.originalPageX = event.pageX;
  972. this.originalPageY = event.pageY;
  973. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  974. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  975. //Set a containment if given in the options
  976. this._setContainment();
  977. //Trigger event + callbacks
  978. if(this._trigger("start", event) === false) {
  979. this._clear();
  980. return false;
  981. }
  982. //Recache the helper size
  983. this._cacheHelperProportions();
  984. //Prepare the droppable offsets
  985. if ($.ui.ddmanager && !o.dropBehaviour) {
  986. $.ui.ddmanager.prepareOffsets(this, event);
  987. }
  988. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  989. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  990. if ( $.ui.ddmanager ) {
  991. $.ui.ddmanager.dragStart(this, event);
  992. }
  993. return true;
  994. },
  995. _mouseDrag: function(event, noPropagation) {
  996. // reset any necessary cached properties (see #5009)
  997. if ( this.offsetParentCssPosition === "fixed" ) {
  998. this.offset.parent = this._getParentOffset();
  999. }
  1000. //Compute the helpers position
  1001. this.position = this._generatePosition(event);
  1002. this.positionAbs = this._convertPositionTo("absolute");
  1003. //Call plugins and callbacks and use the resulting position if something is returned
  1004. if (!noPropagation) {
  1005. var ui = this._uiHash();
  1006. if(this._trigger("drag", event, ui) === false) {
  1007. this._mouseUp({});
  1008. return false;
  1009. }
  1010. this.position = ui.position;
  1011. }
  1012. if(!this.options.axis || this.options.axis !== "y") {
  1013. this.helper[0].style.left = this.position.left+"px";
  1014. }
  1015. if(!this.options.axis || this.options.axis !== "x") {
  1016. this.helper[0].style.top = this.position.top+"px";
  1017. }
  1018. if($.ui.ddmanager) {
  1019. $.ui.ddmanager.drag(this, event);
  1020. }
  1021. return false;
  1022. },
  1023. _mouseStop: function(event) {
  1024. //If we are using droppables, inform the manager about the drop
  1025. var that = this,
  1026. dropped = false;
  1027. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  1028. dropped = $.ui.ddmanager.drop(this, event);
  1029. }
  1030. //if a drop comes from outside (a sortable)
  1031. if(this.dropped) {
  1032. dropped = this.dropped;
  1033. this.dropped = false;
  1034. }
  1035. //if the original element is no longer in the DOM don't bother to continue (see #8269)
  1036. if ( this.options.helper === "original" && !$.contains( this.element[ 0 ].ownerDocument, this.element[ 0 ] ) ) {
  1037. return false;
  1038. }
  1039. if((this.options.revert === "invalid" && !dropped) || (this.options.revert === "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
  1040. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  1041. if(that._trigger("stop", event) !== false) {
  1042. that._clear();
  1043. }
  1044. });
  1045. } else {
  1046. if(this._trigger("stop", event) !== false) {
  1047. this._clear();
  1048. }
  1049. }
  1050. return false;
  1051. },
  1052. _mouseUp: function(event) {
  1053. //Remove frame helpers
  1054. $("div.ui-draggable-iframeFix").each(function() {
  1055. this.parentNode.removeChild(this);
  1056. });
  1057. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  1058. if( $.ui.ddmanager ) {
  1059. $.ui.ddmanager.dragStop(this, event);
  1060. }
  1061. return $.ui.mouse.prototype._mouseUp.call(this, event);
  1062. },
  1063. cancel: function() {
  1064. if(this.helper.is(".ui-draggable-dragging")) {
  1065. this._mouseUp({});
  1066. } else {
  1067. this._clear();
  1068. }
  1069. return this;
  1070. },
  1071. _getHandle: function(event) {
  1072. return this.options.handle ?
  1073. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  1074. true;
  1075. },
  1076. _createHelper: function(event) {
  1077. var o = this.options,
  1078. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper === "clone" ? this.element.clone().removeAttr("id") : this.element);
  1079. if(!helper.parents("body").length) {
  1080. helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
  1081. }
  1082. if(helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
  1083. helper.css("position", "absolute");
  1084. }
  1085. return helper;
  1086. },
  1087. _adjustOffsetFromHelper: function(obj) {
  1088. if (typeof obj === "string") {
  1089. obj = obj.split(" ");
  1090. }
  1091. if ($.isArray(obj)) {
  1092. obj = {left: +obj[0], top: +obj[1] || 0};
  1093. }
  1094. if ("left" in obj) {
  1095. this.offset.click.left = obj.left + this.margins.left;
  1096. }
  1097. if ("right" in obj) {
  1098. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  1099. }
  1100. if ("top" in obj) {
  1101. this.offset.click.top = obj.top + this.margins.top;
  1102. }
  1103. if ("bottom" in obj) {
  1104. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  1105. }
  1106. },
  1107. _getParentOffset: function() {
  1108. //Get the offsetParent and cache its position
  1109. var po = this.offsetParent.offset();
  1110. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  1111. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  1112. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  1113. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  1114. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  1115. po.left += this.scrollParent.scrollLeft();
  1116. po.top += this.scrollParent.scrollTop();
  1117. }
  1118. //This needs to be actually done for all browsers, since pageX/pageY includes this information
  1119. //Ugly IE fix
  1120. if((this.offsetParent[0] === document.body) ||
  1121. (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  1122. po = { top: 0, left: 0 };
  1123. }
  1124. return {
  1125. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  1126. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  1127. };
  1128. },
  1129. _getRelativeOffset: function() {
  1130. if(this.cssPosition === "relative") {
  1131. var p = this.element.position();
  1132. return {
  1133. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  1134. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  1135. };
  1136. } else {
  1137. return { top: 0, left: 0 };
  1138. }
  1139. },
  1140. _cacheMargins: function() {
  1141. this.margins = {
  1142. left: (parseInt(this.element.css("marginLeft"),10) || 0),
  1143. top: (parseInt(this.element.css("marginTop"),10) || 0),
  1144. right: (parseInt(this.element.css("marginRight"),10) || 0),
  1145. bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
  1146. };
  1147. },
  1148. _cacheHelperProportions: function() {
  1149. this.helperProportions = {
  1150. width: this.helper.outerWidth(),
  1151. height: this.helper.outerHeight()
  1152. };
  1153. },
  1154. _setContainment: function() {
  1155. var over, c, ce,
  1156. o = this.options;
  1157. if ( !o.containment ) {
  1158. this.containment = null;
  1159. return;
  1160. }
  1161. if ( o.containment === "window" ) {
  1162. this.containment = [
  1163. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  1164. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  1165. $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
  1166. $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1167. ];
  1168. return;
  1169. }
  1170. if ( o.containment === "document") {
  1171. this.containment = [
  1172. 0,
  1173. 0,
  1174. $( document ).width() - this.helperProportions.width - this.margins.left,
  1175. ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1176. ];
  1177. return;
  1178. }
  1179. if ( o.containment.constructor === Array ) {
  1180. this.containment = o.containment;
  1181. return;
  1182. }
  1183. if ( o.containment === "parent" ) {
  1184. o.containment = this.helper[ 0 ].parentNode;
  1185. }
  1186. c = $( o.containment );
  1187. ce = c[ 0 ];
  1188. if( !ce ) {
  1189. return;
  1190. }
  1191. over = c.css( "overflow" ) !== "hidden";
  1192. this.containment = [
  1193. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  1194. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ) ,
  1195. ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) - this.helperProportions.width - this.margins.left - this.margins.right,
  1196. ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) - this.helperProportions.height - this.margins.top - this.margins.bottom
  1197. ];
  1198. this.relative_container = c;
  1199. },
  1200. _convertPositionTo: function(d, pos) {
  1201. if(!pos) {
  1202. pos = this.position;
  1203. }
  1204. var mod = d === "absolute" ? 1 : -1,
  1205. scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent;
  1206. //Cache the scroll
  1207. if (!this.offset.scroll) {
  1208. this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
  1209. }
  1210. return {
  1211. top: (
  1212. pos.top + // The absolute mouse position
  1213. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1214. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  1215. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top ) * mod )
  1216. ),
  1217. left: (
  1218. pos.left + // The absolute mouse position
  1219. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1220. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  1221. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left ) * mod )
  1222. )
  1223. };
  1224. },
  1225. _generatePosition: function(event) {
  1226. var containment, co, top, left,
  1227. o = this.options,
  1228. scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent,
  1229. pageX = event.pageX,
  1230. pageY = event.pageY;
  1231. //Cache the scroll
  1232. if (!this.offset.scroll) {
  1233. this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
  1234. }
  1235. /*
  1236. * - Position constraining -
  1237. * Constrain the position to a mix of grid, containment.
  1238. */
  1239. // If we are not dragging yet, we won't check for options
  1240. if ( this.originalPosition ) {
  1241. if ( this.containment ) {
  1242. if ( this.relative_container ){
  1243. co = this.relative_container.offset();
  1244. containment = [
  1245. this.containment[ 0 ] + co.left,
  1246. this.containment[ 1 ] + co.top,
  1247. this.containment[ 2 ] + co.left,
  1248. this.containment[ 3 ] + co.top
  1249. ];
  1250. }
  1251. else {
  1252. containment = this.containment;
  1253. }
  1254. if(event.pageX - this.offset.click.left < containment[0]) {
  1255. pageX = containment[0] + this.offset.click.left;
  1256. }
  1257. if(event.pageY - this.offset.click.top < containment[1]) {
  1258. pageY = containment[1] + this.offset.click.top;
  1259. }
  1260. if(event.pageX - this.offset.click.left > containment[2]) {
  1261. pageX = containment[2] + this.offset.click.left;
  1262. }
  1263. if(event.pageY - this.offset.click.top > containment[3]) {
  1264. pageY = containment[3] + this.offset.click.top;
  1265. }
  1266. }
  1267. if(o.grid) {
  1268. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  1269. top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  1270. pageY = containment ? ((top - this.offset.click.top >= containment[1] || top - this.offset.click.top > containment[3]) ? top : ((top - this.offset.click.top >= containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
  1271. left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  1272. pageX = containment ? ((left - this.offset.click.left >= containment[0] || left - this.offset.click.left > containment[2]) ? left : ((left - this.offset.click.left >= containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
  1273. }
  1274. }
  1275. return {
  1276. top: (
  1277. pageY - // The absolute mouse position
  1278. this.offset.click.top - // Click offset (relative to the element)
  1279. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  1280. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  1281. ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top )
  1282. ),
  1283. left: (
  1284. pageX - // The absolute mouse position
  1285. this.offset.click.left - // Click offset (relative to the element)
  1286. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  1287. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  1288. ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left )
  1289. )
  1290. };
  1291. },
  1292. _clear: function() {
  1293. this.helper.removeClass("ui-draggable-dragging");
  1294. if(this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
  1295. this.helper.remove();
  1296. }
  1297. this.helper = null;
  1298. this.cancelHelperRemoval = false;
  1299. },
  1300. // From now on bulk stuff - mainly helpers
  1301. _trigger: function(type, event, ui) {
  1302. ui = ui || this._uiHash();
  1303. $.ui.plugin.call(this, type, [event, ui]);
  1304. //The absolute position has to be recalculated after plugins
  1305. if(type === "drag") {
  1306. this.positionAbs = this._convertPositionTo("absolute");
  1307. }
  1308. return $.Widget.prototype._trigger.call(this, type, event, ui);
  1309. },
  1310. plugins: {},
  1311. _uiHash: function() {
  1312. return {
  1313. helper: this.helper,
  1314. position: this.position,
  1315. originalPosition: this.originalPosition,
  1316. offset: this.positionAbs
  1317. };
  1318. }
  1319. });
  1320. $.ui.plugin.add("draggable", "connectToSortable", {
  1321. start: function(event, ui) {
  1322. var inst = $(this).data("ui-draggable"), o = inst.options,
  1323. uiSortable = $.extend({}, ui, { item: inst.element });
  1324. inst.sortables = [];
  1325. $(o.connectToSortable).each(function() {
  1326. var sortable = $.data(this, "ui-sortable");
  1327. if (sortable && !sortable.options.disabled) {
  1328. inst.sortables.push({
  1329. instance: sortable,
  1330. shouldRevert: sortable.options.revert
  1331. });
  1332. sortable.refreshPositions(); // Call the sortable's refreshPositions at drag start to refresh the containerCache since the sortable container cache is used in drag and needs to be up to date (this will ensure it's initialised as well as being kept in step with any changes that might have happened on the page).
  1333. sortable._trigger("activate", event, uiSortable);
  1334. }
  1335. });
  1336. },
  1337. stop: function(event, ui) {
  1338. //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
  1339. var inst = $(this).data("ui-draggable"),
  1340. uiSortable = $.extend({}, ui, { item: inst.element });
  1341. $.each(inst.sortables, function() {
  1342. if(this.instance.isOver) {
  1343. this.instance.isOver = 0;
  1344. inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
  1345. this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
  1346. //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid"
  1347. if(this.shouldRevert) {
  1348. this.instance.options.revert = this.shouldRevert;
  1349. }
  1350. //Trigger the stop of the sortable
  1351. this.instance._mouseStop(event);
  1352. this.instance.options.helper = this.instance.options._helper;
  1353. //If the helper has been the original item, restore properties in the sortable
  1354. if(inst.options.helper === "original") {
  1355. this.instance.currentItem.css({ top: "auto", left: "auto" });
  1356. }
  1357. } else {
  1358. this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
  1359. this.instance._trigger("deactivate", event, uiSortable);
  1360. }
  1361. });
  1362. },
  1363. drag: function(event, ui) {
  1364. var inst = $(this).data("ui-draggable"), that = this;
  1365. $.each(inst.sortables, function() {
  1366. var innermostIntersecting = false,
  1367. thisSortable = this;
  1368. //Copy over some variables to allow calling the sortable's native _intersectsWith
  1369. this.instance.positionAbs = inst.positionAbs;
  1370. this.instance.helperProportions = inst.helperProportions;
  1371. this.instance.offset.click = inst.offset.click;
  1372. if(this.instance._intersectsWith(this.instance.containerCache)) {
  1373. innermostIntersecting = true;
  1374. $.each(inst.sortables, function () {
  1375. this.instance.positionAbs = inst.positionAbs;
  1376. this.instance.helperProportions = inst.helperProportions;
  1377. this.instance.offset.click = inst.offset.click;
  1378. if (this !== thisSortable &&
  1379. this.instance._intersectsWith(this.instance.containerCache) &&
  1380. $.contains(thisSortable.instance.element[0], this.instance.element[0])
  1381. ) {
  1382. innermostIntersecting = false;
  1383. }
  1384. return innermostIntersecting;
  1385. });
  1386. }
  1387. if(innermostIntersecting) {
  1388. //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
  1389. if(!this.instance.isOver) {
  1390. this.instance.isOver = 1;
  1391. //Now we fake the start of dragging for the sortable instance,
  1392. //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
  1393. //We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one)
  1394. this.instance.currentItem = $(that).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item", true);
  1395. this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
  1396. this.instance.options.helper = function() { return ui.helper[0]; };
  1397. event.target = this.instance.currentItem[0];
  1398. this.instance._mouseCapture(event, true);
  1399. this.instance._mouseStart(event, true, true);
  1400. //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
  1401. this.instance.offset.click.top = inst.offset.click.top;
  1402. this.instance.offset.click.left = inst.offset.click.left;
  1403. this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
  1404. this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
  1405. inst._trigger("toSortable", event);
  1406. inst.dropped = this.instance.element; //draggable revert needs that
  1407. //hack so receive/update callbacks work (mostly)
  1408. inst.currentItem = inst.element;
  1409. this.instance.fromOutside = inst;
  1410. }
  1411. //Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable
  1412. if(this.instance.currentItem) {
  1413. this.instance._mouseDrag(event);
  1414. }
  1415. } else {
  1416. //If it doesn't intersect with the sortable, and it intersected before,
  1417. //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
  1418. if(this.instance.isOver) {
  1419. this.instance.isOver = 0;
  1420. this.instance.cancelHelperRemoval = true;
  1421. //Prevent reverting on this forced stop
  1422. this.instance.options.revert = false;
  1423. // The out event needs to be triggered independently
  1424. this.instance._trigger("out", event, this.instance._uiHash(this.instance));
  1425. this.instance._mouseStop(event, true);
  1426. this.instance.options.helper = this.instance.options._helper;
  1427. //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
  1428. this.instance.currentItem.remove();
  1429. if(this.instance.placeholder) {
  1430. this.instance.placeholder.remove();
  1431. }
  1432. inst._trigger("fromSortable", event);
  1433. inst.dropped = false; //draggable revert needs that
  1434. }
  1435. }
  1436. });
  1437. }
  1438. });
  1439. $.ui.plugin.add("draggable", "cursor", {
  1440. start: function() {
  1441. var t = $("body"), o = $(this).data("ui-draggable").options;
  1442. if (t.css("cursor")) {
  1443. o._cursor = t.css("cursor");
  1444. }
  1445. t.css("cursor", o.cursor);
  1446. },
  1447. stop: function() {
  1448. var o = $(this).data("ui-draggable").options;
  1449. if (o._cursor) {
  1450. $("body").css("cursor", o._cursor);
  1451. }
  1452. }
  1453. });
  1454. $.ui.plugin.add("draggable", "opacity", {
  1455. start: function(event, ui) {
  1456. var t = $(ui.helper), o = $(this).data("ui-draggable").options;
  1457. if(t.css("opacity")) {
  1458. o._opacity = t.css("opacity");
  1459. }
  1460. t.css("opacity", o.opacity);
  1461. },
  1462. stop: function(event, ui) {
  1463. var o = $(this).data("ui-draggable").options;
  1464. if(o._opacity) {
  1465. $(ui.helper).css("opacity", o._opacity);
  1466. }
  1467. }
  1468. });
  1469. $.ui.plugin.add("draggable", "scroll", {
  1470. start: function() {
  1471. var i = $(this).data("ui-draggable");
  1472. if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
  1473. i.overflowOffset = i.scrollParent.offset();
  1474. }
  1475. },
  1476. drag: function( event ) {
  1477. var i = $(this).data("ui-draggable"), o = i.options, scrolled = false;
  1478. if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
  1479. if(!o.axis || o.axis !== "x") {
  1480. if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  1481. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
  1482. } else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity) {
  1483. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
  1484. }
  1485. }
  1486. if(!o.axis || o.axis !== "y") {
  1487. if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  1488. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
  1489. } else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity) {
  1490. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
  1491. }
  1492. }
  1493. } else {
  1494. if(!o.axis || o.axis !== "x") {
  1495. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  1496. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  1497. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  1498. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  1499. }
  1500. }
  1501. if(!o.axis || o.axis !== "y") {
  1502. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  1503. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  1504. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  1505. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  1506. }
  1507. }
  1508. }
  1509. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  1510. $.ui.ddmanager.prepareOffsets(i, event);
  1511. }
  1512. }
  1513. });
  1514. $.ui.plugin.add("draggable", "snap", {
  1515. start: function() {
  1516. var i = $(this).data("ui-draggable"),
  1517. o = i.options;
  1518. i.snapElements = [];
  1519. $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
  1520. var $t = $(this),
  1521. $o = $t.offset();
  1522. if(this !== i.element[0]) {
  1523. i.snapElements.push({
  1524. item: this,
  1525. width: $t.outerWidth(), height: $t.outerHeight(),
  1526. top: $o.top, left: $o.left
  1527. });
  1528. }
  1529. });
  1530. },
  1531. drag: function(event, ui) {
  1532. var ts, bs, ls, rs, l, r, t, b, i, first,
  1533. inst = $(this).data("ui-draggable"),
  1534. o = inst.options,
  1535. d = o.snapTolerance,
  1536. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  1537. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  1538. for (i = inst.snapElements.length - 1; i >= 0; i--){
  1539. l = inst.snapElements[i].left;
  1540. r = l + inst.snapElements[i].width;
  1541. t = inst.snapElements[i].top;
  1542. b = t + inst.snapElements[i].height;
  1543. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
  1544. if(inst.snapElements[i].snapping) {
  1545. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  1546. }
  1547. inst.snapElements[i].snapping = false;
  1548. continue;
  1549. }
  1550. if(o.snapMode !== "inner") {
  1551. ts = Math.abs(t - y2) <= d;
  1552. bs = Math.abs(b - y1) <= d;
  1553. ls = Math.abs(l - x2) <= d;
  1554. rs = Math.abs(r - x1) <= d;
  1555. if(ts) {
  1556. ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  1557. }
  1558. if(bs) {
  1559. ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
  1560. }
  1561. if(ls) {
  1562. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
  1563. }
  1564. if(rs) {
  1565. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
  1566. }
  1567. }
  1568. first = (ts || bs || ls || rs);
  1569. if(o.snapMode !== "outer") {
  1570. ts = Math.abs(t - y1) <= d;
  1571. bs = Math.abs(b - y2) <= d;
  1572. ls = Math.abs(l - x1) <= d;
  1573. rs = Math.abs(r - x2) <= d;
  1574. if(ts) {
  1575. ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
  1576. }
  1577. if(bs) {
  1578. ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  1579. }
  1580. if(ls) {
  1581. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
  1582. }
  1583. if(rs) {
  1584. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
  1585. }
  1586. }
  1587. if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  1588. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  1589. }
  1590. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  1591. }
  1592. }
  1593. });
  1594. $.ui.plugin.add("draggable", "stack", {
  1595. start: function() {
  1596. var min,
  1597. o = this.data("ui-draggable").options,
  1598. group = $.makeArray($(o.stack)).sort(function(a,b) {
  1599. return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
  1600. });
  1601. if (!group.length) { return; }
  1602. min = parseInt($(group[0]).css("zIndex"), 10) || 0;
  1603. $(group).each(function(i) {
  1604. $(this).css("zIndex", min + i);
  1605. });
  1606. this.css("zIndex", (min + group.length));
  1607. }
  1608. });
  1609. $.ui.plugin.add("draggable", "zIndex", {
  1610. start: function(event, ui) {
  1611. var t = $(ui.helper), o = $(this).data("ui-draggable").options;
  1612. if(t.css("zIndex")) {
  1613. o._zIndex = t.css("zIndex");
  1614. }
  1615. t.css("zIndex", o.zIndex);
  1616. },
  1617. stop: function(event, ui) {
  1618. var o = $(this).data("ui-draggable").options;
  1619. if(o._zIndex) {
  1620. $(ui.helper).css("zIndex", o._zIndex);
  1621. }
  1622. }
  1623. });
  1624. })(jQuery);
  1625. (function( $, undefined ) {
  1626. function isOverAxis( x, reference, size ) {
  1627. return ( x > reference ) && ( x < ( reference + size ) );
  1628. }
  1629. $.widget("ui.droppable", {
  1630. version: "1.10.3",
  1631. widgetEventPrefix: "drop",
  1632. options: {
  1633. accept: "*",
  1634. activeClass: false,
  1635. addClasses: true,
  1636. greedy: false,
  1637. hoverClass: false,
  1638. scope: "default",
  1639. tolerance: "intersect",
  1640. // callbacks
  1641. activate: null,
  1642. deactivate: null,
  1643. drop: null,
  1644. out: null,
  1645. over: null
  1646. },
  1647. _create: function() {
  1648. var o = this.options,
  1649. accept = o.accept;
  1650. this.isover = false;
  1651. this.isout = true;
  1652. this.accept = $.isFunction(accept) ? accept : function(d) {
  1653. return d.is(accept);
  1654. };
  1655. //Store the droppable's proportions
  1656. this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
  1657. // Add the reference and positions to the manager
  1658. $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
  1659. $.ui.ddmanager.droppables[o.scope].push(this);
  1660. (o.addClasses && this.element.addClass("ui-droppable"));
  1661. },
  1662. _destroy: function() {
  1663. var i = 0,
  1664. drop = $.ui.ddmanager.droppables[this.options.scope];
  1665. for ( ; i < drop.length; i++ ) {
  1666. if ( drop[i] === this ) {
  1667. drop.splice(i, 1);
  1668. }
  1669. }
  1670. this.element.removeClass("ui-droppable ui-droppable-disabled");
  1671. },
  1672. _setOption: function(key, value) {
  1673. if(key === "accept") {
  1674. this.accept = $.isFunction(value) ? value : function(d) {
  1675. return d.is(value);
  1676. };
  1677. }
  1678. $.Widget.prototype._setOption.apply(this, arguments);
  1679. },
  1680. _activate: function(event) {
  1681. var draggable = $.ui.ddmanager.current;
  1682. if(this.options.activeClass) {
  1683. this.element.addClass(this.options.activeClass);
  1684. }
  1685. if(draggable){
  1686. this._trigger("activate", event, this.ui(draggable));
  1687. }
  1688. },
  1689. _deactivate: function(event) {
  1690. var draggable = $.ui.ddmanager.current;
  1691. if(this.options.activeClass) {
  1692. this.element.removeClass(this.options.activeClass);
  1693. }
  1694. if(draggable){
  1695. this._trigger("deactivate", event, this.ui(draggable));
  1696. }
  1697. },
  1698. _over: function(event) {
  1699. var draggable = $.ui.ddmanager.current;
  1700. // Bail if draggable and droppable are same element
  1701. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  1702. return;
  1703. }
  1704. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1705. if(this.options.hoverClass) {
  1706. this.element.addClass(this.options.hoverClass);
  1707. }
  1708. this._trigger("over", event, this.ui(draggable));
  1709. }
  1710. },
  1711. _out: function(event) {
  1712. var draggable = $.ui.ddmanager.current;
  1713. // Bail if draggable and droppable are same element
  1714. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  1715. return;
  1716. }
  1717. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1718. if(this.options.hoverClass) {
  1719. this.element.removeClass(this.options.hoverClass);
  1720. }
  1721. this._trigger("out", event, this.ui(draggable));
  1722. }
  1723. },
  1724. _drop: function(event,custom) {
  1725. var draggable = custom || $.ui.ddmanager.current,
  1726. childrenIntersection = false;
  1727. // Bail if draggable and droppable are same element
  1728. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  1729. return false;
  1730. }
  1731. this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function() {
  1732. var inst = $.data(this, "ui-droppable");
  1733. if(
  1734. inst.options.greedy &&
  1735. !inst.options.disabled &&
  1736. inst.options.scope === draggable.options.scope &&
  1737. inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element)) &&
  1738. $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
  1739. ) { childrenIntersection = true; return false; }
  1740. });
  1741. if(childrenIntersection) {
  1742. return false;
  1743. }
  1744. if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1745. if(this.options.activeClass) {
  1746. this.element.removeClass(this.options.activeClass);
  1747. }
  1748. if(this.options.hoverClass) {
  1749. this.element.removeClass(this.options.hoverClass);
  1750. }
  1751. this._trigger("drop", event, this.ui(draggable));
  1752. return this.element;
  1753. }
  1754. return false;
  1755. },
  1756. ui: function(c) {
  1757. return {
  1758. draggable: (c.currentItem || c.element),
  1759. helper: c.helper,
  1760. position: c.position,
  1761. offset: c.positionAbs
  1762. };
  1763. }
  1764. });
  1765. $.ui.intersect = function(draggable, droppable, toleranceMode) {
  1766. if (!droppable.offset) {
  1767. return false;
  1768. }
  1769. var draggableLeft, draggableTop,
  1770. x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
  1771. y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height,
  1772. l = droppable.offset.left, r = l + droppable.proportions.width,
  1773. t = droppable.offset.top, b = t + droppable.proportions.height;
  1774. switch (toleranceMode) {
  1775. case "fit":
  1776. return (l <= x1 && x2 <= r && t <= y1 && y2 <= b);
  1777. case "intersect":
  1778. return (l < x1 + (draggable.helperProportions.width / 2) && // Right Half
  1779. x2 - (draggable.helperProportions.width / 2) < r && // Left Half
  1780. t < y1 + (draggable.helperProportions.height / 2) && // Bottom Half
  1781. y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
  1782. case "pointer":
  1783. draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left);
  1784. draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top);
  1785. return isOverAxis( draggableTop, t, droppable.proportions.height ) && isOverAxis( draggableLeft, l, droppable.proportions.width );
  1786. case "touch":
  1787. return (
  1788. (y1 >= t && y1 <= b) || // Top edge touching
  1789. (y2 >= t && y2 <= b) || // Bottom edge touching
  1790. (y1 < t && y2 > b) // Surrounded vertically
  1791. ) && (
  1792. (x1 >= l && x1 <= r) || // Left edge touching
  1793. (x2 >= l && x2 <= r) || // Right edge touching
  1794. (x1 < l && x2 > r) // Surrounded horizontally
  1795. );
  1796. default:
  1797. return false;
  1798. }
  1799. };
  1800. /*
  1801. This manager tracks offsets of draggables and droppables
  1802. */
  1803. $.ui.ddmanager = {
  1804. current: null,
  1805. droppables: { "default": [] },
  1806. prepareOffsets: function(t, event) {
  1807. var i, j,
  1808. m = $.ui.ddmanager.droppables[t.options.scope] || [],
  1809. type = event ? event.type : null, // workaround for #2317
  1810. list = (t.currentItem || t.element).find(":data(ui-droppable)").addBack();
  1811. droppablesLoop: for (i = 0; i < m.length; i++) {
  1812. //No disabled and non-accepted
  1813. if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) {
  1814. continue;
  1815. }
  1816. // Filter out elements in the current dragged item
  1817. for (j=0; j < list.length; j++) {
  1818. if(list[j] === m[i].element[0]) {
  1819. m[i].proportions.height = 0;
  1820. continue droppablesLoop;
  1821. }
  1822. }
  1823. m[i].visible = m[i].element.css("display") !== "none";
  1824. if(!m[i].visible) {
  1825. continue;
  1826. }
  1827. //Activate the droppable if used directly from draggables
  1828. if(type === "mousedown") {
  1829. m[i]._activate.call(m[i], event);
  1830. }
  1831. m[i].offset = m[i].element.offset();
  1832. m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
  1833. }
  1834. },
  1835. drop: function(draggable, event) {
  1836. var dropped = false;
  1837. // Create a copy of the droppables in case the list changes during the drop (#9116)
  1838. $.each(($.ui.ddmanager.droppables[draggable.options.scope] || []).slice(), function() {
  1839. if(!this.options) {
  1840. return;
  1841. }
  1842. if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance)) {
  1843. dropped = this._drop.call(this, event) || dropped;
  1844. }
  1845. if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1846. this.isout = true;
  1847. this.isover = false;
  1848. this._deactivate.call(this, event);
  1849. }
  1850. });
  1851. return dropped;
  1852. },
  1853. dragStart: function( draggable, event ) {
  1854. //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  1855. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  1856. if( !draggable.options.refreshPositions ) {
  1857. $.ui.ddmanager.prepareOffsets( draggable, event );
  1858. }
  1859. });
  1860. },
  1861. drag: function(draggable, event) {
  1862. //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  1863. if(draggable.options.refreshPositions) {
  1864. $.ui.ddmanager.prepareOffsets(draggable, event);
  1865. }
  1866. //Run through all droppables and check their positions based on specific tolerance options
  1867. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  1868. if(this.options.disabled || this.greedyChild || !this.visible) {
  1869. return;
  1870. }
  1871. var parentInstance, scope, parent,
  1872. intersects = $.ui.intersect(draggable, this, this.options.tolerance),
  1873. c = !intersects && this.isover ? "isout" : (intersects && !this.isover ? "isover" : null);
  1874. if(!c) {
  1875. return;
  1876. }
  1877. if (this.options.greedy) {
  1878. // find droppable parents with same scope
  1879. scope = this.options.scope;
  1880. parent = this.element.parents(":data(ui-droppable)").filter(function () {
  1881. return $.data(this, "ui-droppable").options.scope === scope;
  1882. });
  1883. if (parent.length) {
  1884. parentInstance = $.data(parent[0], "ui-droppable");
  1885. parentInstance.greedyChild = (c === "isover");
  1886. }
  1887. }
  1888. // we just moved into a greedy child
  1889. if (parentInstance && c === "isover") {
  1890. parentInstance.isover = false;
  1891. parentInstance.isout = true;
  1892. parentInstance._out.call(parentInstance, event);
  1893. }
  1894. this[c] = true;
  1895. this[c === "isout" ? "isover" : "isout"] = false;
  1896. this[c === "isover" ? "_over" : "_out"].call(this, event);
  1897. // we just moved out of a greedy child
  1898. if (parentInstance && c === "isout") {
  1899. parentInstance.isout = false;
  1900. parentInstance.isover = true;
  1901. parentInstance._over.call(parentInstance, event);
  1902. }
  1903. });
  1904. },
  1905. dragStop: function( draggable, event ) {
  1906. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  1907. //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  1908. if( !draggable.options.refreshPositions ) {
  1909. $.ui.ddmanager.prepareOffsets( draggable, event );
  1910. }
  1911. }
  1912. };
  1913. })(jQuery);
  1914. (function( $, undefined ) {
  1915. function num(v) {
  1916. return parseInt(v, 10) || 0;
  1917. }
  1918. function isNumber(value) {
  1919. return !isNaN(parseInt(value, 10));
  1920. }
  1921. $.widget("ui.resizable", $.ui.mouse, {
  1922. version: "1.10.3",
  1923. widgetEventPrefix: "resize",
  1924. options: {
  1925. alsoResize: false,
  1926. animate: false,
  1927. animateDuration: "slow",
  1928. animateEasing: "swing",
  1929. aspectRatio: false,
  1930. autoHide: false,
  1931. containment: false,
  1932. ghost: false,
  1933. grid: false,
  1934. handles: "e,s,se",
  1935. helper: false,
  1936. maxHeight: null,
  1937. maxWidth: null,
  1938. minHeight: 10,
  1939. minWidth: 10,
  1940. // See #7960
  1941. zIndex: 90,
  1942. // callbacks
  1943. resize: null,
  1944. start: null,
  1945. stop: null
  1946. },
  1947. _create: function() {
  1948. var n, i, handle, axis, hname,
  1949. that = this,
  1950. o = this.options;
  1951. this.element.addClass("ui-resizable");
  1952. $.extend(this, {
  1953. _aspectRatio: !!(o.aspectRatio),
  1954. aspectRatio: o.aspectRatio,
  1955. originalElement: this.element,
  1956. _proportionallyResizeElements: [],
  1957. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  1958. });
  1959. //Wrap the element if it cannot hold child nodes
  1960. if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
  1961. //Create a wrapper element and set the wrapper to the new current internal element
  1962. this.element.wrap(
  1963. $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
  1964. position: this.element.css("position"),
  1965. width: this.element.outerWidth(),
  1966. height: this.element.outerHeight(),
  1967. top: this.element.css("top"),
  1968. left: this.element.css("left")
  1969. })
  1970. );
  1971. //Overwrite the original this.element
  1972. this.element = this.element.parent().data(
  1973. "ui-resizable", this.element.data("ui-resizable")
  1974. );
  1975. this.elementIsWrapper = true;
  1976. //Move margins to the wrapper
  1977. this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
  1978. this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
  1979. //Prevent Safari textarea resize
  1980. this.originalResizeStyle = this.originalElement.css("resize");
  1981. this.originalElement.css("resize", "none");
  1982. //Push the actual element to our proportionallyResize internal array
  1983. this._proportionallyResizeElements.push(this.originalElement.css({ position: "static", zoom: 1, display: "block" }));
  1984. // avoid IE jump (hard set the margin)
  1985. this.originalElement.css({ margin: this.originalElement.css("margin") });
  1986. // fix handlers offset
  1987. this._proportionallyResize();
  1988. }
  1989. this.handles = o.handles || (!$(".ui-resizable-handle", this.element).length ? "e,s,se" : { n: ".ui-resizable-n", e: ".ui-resizable-e", s: ".ui-resizable-s", w: ".ui-resizable-w", se: ".ui-resizable-se", sw: ".ui-resizable-sw", ne: ".ui-resizable-ne", nw: ".ui-resizable-nw" });
  1990. if(this.handles.constructor === String) {
  1991. if ( this.handles === "all") {
  1992. this.handles = "n,e,s,w,se,sw,ne,nw";
  1993. }
  1994. n = this.handles.split(",");
  1995. this.handles = {};
  1996. for(i = 0; i < n.length; i++) {
  1997. handle = $.trim(n[i]);
  1998. hname = "ui-resizable-"+handle;
  1999. axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
  2000. // Apply zIndex to all handles - see #7960
  2001. axis.css({ zIndex: o.zIndex });
  2002. //TODO : What's going on here?
  2003. if ("se" === handle) {
  2004. axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
  2005. }
  2006. //Insert into internal handles object and append to element
  2007. this.handles[handle] = ".ui-resizable-"+handle;
  2008. this.element.append(axis);
  2009. }
  2010. }
  2011. this._renderAxis = function(target) {
  2012. var i, axis, padPos, padWrapper;
  2013. target = target || this.element;
  2014. for(i in this.handles) {
  2015. if(this.handles[i].constructor === String) {
  2016. this.handles[i] = $(this.handles[i], this.element).show();
  2017. }
  2018. //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
  2019. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
  2020. axis = $(this.handles[i], this.element);
  2021. //Checking the correct pad and border
  2022. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  2023. //The padding type i have to apply...
  2024. padPos = [ "padding",
  2025. /ne|nw|n/.test(i) ? "Top" :
  2026. /se|sw|s/.test(i) ? "Bottom" :
  2027. /^e$/.test(i) ? "Right" : "Left" ].join("");
  2028. target.css(padPos, padWrapper);
  2029. this._proportionallyResize();
  2030. }
  2031. //TODO: What's that good for? There's not anything to be executed left
  2032. if(!$(this.handles[i]).length) {
  2033. continue;
  2034. }
  2035. }
  2036. };
  2037. //TODO: make renderAxis a prototype function
  2038. this._renderAxis(this.element);
  2039. this._handles = $(".ui-resizable-handle", this.element)
  2040. .disableSelection();
  2041. //Matching axis name
  2042. this._handles.mouseover(function() {
  2043. if (!that.resizing) {
  2044. if (this.className) {
  2045. axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  2046. }
  2047. //Axis, default = se
  2048. that.axis = axis && axis[1] ? axis[1] : "se";
  2049. }
  2050. });
  2051. //If we want to auto hide the elements
  2052. if (o.autoHide) {
  2053. this._handles.hide();
  2054. $(this.element)
  2055. .addClass("ui-resizable-autohide")
  2056. .mouseenter(function() {
  2057. if (o.disabled) {
  2058. return;
  2059. }
  2060. $(this).removeClass("ui-resizable-autohide");
  2061. that._handles.show();
  2062. })
  2063. .mouseleave(function(){
  2064. if (o.disabled) {
  2065. return;
  2066. }
  2067. if (!that.resizing) {
  2068. $(this).addClass("ui-resizable-autohide");
  2069. that._handles.hide();
  2070. }
  2071. });
  2072. }
  2073. //Initialize the mouse interaction
  2074. this._mouseInit();
  2075. },
  2076. _destroy: function() {
  2077. this._mouseDestroy();
  2078. var wrapper,
  2079. _destroy = function(exp) {
  2080. $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  2081. .removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove();
  2082. };
  2083. //TODO: Unwrap at same DOM position
  2084. if (this.elementIsWrapper) {
  2085. _destroy(this.element);
  2086. wrapper = this.element;
  2087. this.originalElement.css({
  2088. position: wrapper.css("position"),
  2089. width: wrapper.outerWidth(),
  2090. height: wrapper.outerHeight(),
  2091. top: wrapper.css("top"),
  2092. left: wrapper.css("left")
  2093. }).insertAfter( wrapper );
  2094. wrapper.remove();
  2095. }
  2096. this.originalElement.css("resize", this.originalResizeStyle);
  2097. _destroy(this.originalElement);
  2098. return this;
  2099. },
  2100. _mouseCapture: function(event) {
  2101. var i, handle,
  2102. capture = false;
  2103. for (i in this.handles) {
  2104. handle = $(this.handles[i])[0];
  2105. if (handle === event.target || $.contains(handle, event.target)) {
  2106. capture = true;
  2107. }
  2108. }
  2109. return !this.options.disabled && capture;
  2110. },
  2111. _mouseStart: function(event) {
  2112. var curleft, curtop, cursor,
  2113. o = this.options,
  2114. iniPos = this.element.position(),
  2115. el = this.element;
  2116. this.resizing = true;
  2117. // bugfix for http://dev.jquery.com/ticket/1749
  2118. if ( (/absolute/).test( el.css("position") ) ) {
  2119. el.css({ position: "absolute", top: el.css("top"), left: el.css("left") });
  2120. } else if (el.is(".ui-draggable")) {
  2121. el.css({ position: "absolute", top: iniPos.top, left: iniPos.left });
  2122. }
  2123. this._renderProxy();
  2124. curleft = num(this.helper.css("left"));
  2125. curtop = num(this.helper.css("top"));
  2126. if (o.containment) {
  2127. curleft += $(o.containment).scrollLeft() || 0;
  2128. curtop += $(o.containment).scrollTop() || 0;
  2129. }
  2130. //Store needed variables
  2131. this.offset = this.helper.offset();
  2132. this.position = { left: curleft, top: curtop };
  2133. this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  2134. this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  2135. this.originalPosition = { left: curleft, top: curtop };
  2136. this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
  2137. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  2138. //Aspect Ratio
  2139. this.aspectRatio = (typeof o.aspectRatio === "number") ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
  2140. cursor = $(".ui-resizable-" + this.axis).css("cursor");
  2141. $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
  2142. el.addClass("ui-resizable-resizing");
  2143. this._propagate("start", event);
  2144. return true;
  2145. },
  2146. _mouseDrag: function(event) {
  2147. //Increase performance, avoid regex
  2148. var data,
  2149. el = this.helper, props = {},
  2150. smp = this.originalMousePosition,
  2151. a = this.axis,
  2152. prevTop = this.position.top,
  2153. prevLeft = this.position.left,
  2154. prevWidth = this.size.width,
  2155. prevHeight = this.size.height,
  2156. dx = (event.pageX-smp.left)||0,
  2157. dy = (event.pageY-smp.top)||0,
  2158. trigger = this._change[a];
  2159. if (!trigger) {
  2160. return false;
  2161. }
  2162. // Calculate the attrs that will be change
  2163. data = trigger.apply(this, [event, dx, dy]);
  2164. // Put this in the mouseDrag handler since the user can start pressing shift while resizing
  2165. this._updateVirtualBoundaries(event.shiftKey);
  2166. if (this._aspectRatio || event.shiftKey) {
  2167. data = this._updateRatio(data, event);
  2168. }
  2169. data = this._respectSize(data, event);
  2170. this._updateCache(data);
  2171. // plugins callbacks need to be called first
  2172. this._propagate("resize", event);
  2173. if (this.position.top !== prevTop) {
  2174. props.top = this.position.top + "px";
  2175. }
  2176. if (this.position.left !== prevLeft) {
  2177. props.left = this.position.left + "px";
  2178. }
  2179. if (this.size.width !== prevWidth) {
  2180. props.width = this.size.width + "px";
  2181. }
  2182. if (this.size.height !== prevHeight) {
  2183. props.height = this.size.height + "px";
  2184. }
  2185. el.css(props);
  2186. if (!this._helper && this._proportionallyResizeElements.length) {
  2187. this._proportionallyResize();
  2188. }
  2189. // Call the user callback if the element was resized
  2190. if ( ! $.isEmptyObject(props) ) {
  2191. this._trigger("resize", event, this.ui());
  2192. }
  2193. return false;
  2194. },
  2195. _mouseStop: function(event) {
  2196. this.resizing = false;
  2197. var pr, ista, soffseth, soffsetw, s, left, top,
  2198. o = this.options, that = this;
  2199. if(this._helper) {
  2200. pr = this._proportionallyResizeElements;
  2201. ista = pr.length && (/textarea/i).test(pr[0].nodeName);
  2202. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height;
  2203. soffsetw = ista ? 0 : that.sizeDiff.width;
  2204. s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) };
  2205. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null;
  2206. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  2207. if (!o.animate) {
  2208. this.element.css($.extend(s, { top: top, left: left }));
  2209. }
  2210. that.helper.height(that.size.height);
  2211. that.helper.width(that.size.width);
  2212. if (this._helper && !o.animate) {
  2213. this._proportionallyResize();
  2214. }
  2215. }
  2216. $("body").css("cursor", "auto");
  2217. this.element.removeClass("ui-resizable-resizing");
  2218. this._propagate("stop", event);
  2219. if (this._helper) {
  2220. this.helper.remove();
  2221. }
  2222. return false;
  2223. },
  2224. _updateVirtualBoundaries: function(forceAspectRatio) {
  2225. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  2226. o = this.options;
  2227. b = {
  2228. minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
  2229. maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  2230. minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
  2231. maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
  2232. };
  2233. if(this._aspectRatio || forceAspectRatio) {
  2234. // We want to create an enclosing box whose aspect ration is the requested one
  2235. // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
  2236. pMinWidth = b.minHeight * this.aspectRatio;
  2237. pMinHeight = b.minWidth / this.aspectRatio;
  2238. pMaxWidth = b.maxHeight * this.aspectRatio;
  2239. pMaxHeight = b.maxWidth / this.aspectRatio;
  2240. if(pMinWidth > b.minWidth) {
  2241. b.minWidth = pMinWidth;
  2242. }
  2243. if(pMinHeight > b.minHeight) {
  2244. b.minHeight = pMinHeight;
  2245. }
  2246. if(pMaxWidth < b.maxWidth) {
  2247. b.maxWidth = pMaxWidth;
  2248. }
  2249. if(pMaxHeight < b.maxHeight) {
  2250. b.maxHeight = pMaxHeight;
  2251. }
  2252. }
  2253. this._vBoundaries = b;
  2254. },
  2255. _updateCache: function(data) {
  2256. this.offset = this.helper.offset();
  2257. if (isNumber(data.left)) {
  2258. this.position.left = data.left;
  2259. }
  2260. if (isNumber(data.top)) {
  2261. this.position.top = data.top;
  2262. }
  2263. if (isNumber(data.height)) {
  2264. this.size.height = data.height;
  2265. }
  2266. if (isNumber(data.width)) {
  2267. this.size.width = data.width;
  2268. }
  2269. },
  2270. _updateRatio: function( data ) {
  2271. var cpos = this.position,
  2272. csize = this.size,
  2273. a = this.axis;
  2274. if (isNumber(data.height)) {
  2275. data.width = (data.height * this.aspectRatio);
  2276. } else if (isNumber(data.width)) {
  2277. data.height = (data.width / this.aspectRatio);
  2278. }
  2279. if (a === "sw") {
  2280. data.left = cpos.left + (csize.width - data.width);
  2281. data.top = null;
  2282. }
  2283. if (a === "nw") {
  2284. data.top = cpos.top + (csize.height - data.height);
  2285. data.left = cpos.left + (csize.width - data.width);
  2286. }
  2287. return data;
  2288. },
  2289. _respectSize: function( data ) {
  2290. var o = this._vBoundaries,
  2291. a = this.axis,
  2292. ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  2293. isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
  2294. dw = this.originalPosition.left + this.originalSize.width,
  2295. dh = this.position.top + this.size.height,
  2296. cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  2297. if (isminw) {
  2298. data.width = o.minWidth;
  2299. }
  2300. if (isminh) {
  2301. data.height = o.minHeight;
  2302. }
  2303. if (ismaxw) {
  2304. data.width = o.maxWidth;
  2305. }
  2306. if (ismaxh) {
  2307. data.height = o.maxHeight;
  2308. }
  2309. if (isminw && cw) {
  2310. data.left = dw - o.minWidth;
  2311. }
  2312. if (ismaxw && cw) {
  2313. data.left = dw - o.maxWidth;
  2314. }
  2315. if (isminh && ch) {
  2316. data.top = dh - o.minHeight;
  2317. }
  2318. if (ismaxh && ch) {
  2319. data.top = dh - o.maxHeight;
  2320. }
  2321. // fixing jump error on top/left - bug #2330
  2322. if (!data.width && !data.height && !data.left && data.top) {
  2323. data.top = null;
  2324. } else if (!data.width && !data.height && !data.top && data.left) {
  2325. data.left = null;
  2326. }
  2327. return data;
  2328. },
  2329. _proportionallyResize: function() {
  2330. if (!this._proportionallyResizeElements.length) {
  2331. return;
  2332. }
  2333. var i, j, borders, paddings, prel,
  2334. element = this.helper || this.element;
  2335. for ( i=0; i < this._proportionallyResizeElements.length; i++) {
  2336. prel = this._proportionallyResizeElements[i];
  2337. if (!this.borderDif) {
  2338. this.borderDif = [];
  2339. borders = [prel.css("borderTopWidth"), prel.css("borderRightWidth"), prel.css("borderBottomWidth"), prel.css("borderLeftWidth")];
  2340. paddings = [prel.css("paddingTop"), prel.css("paddingRight"), prel.css("paddingBottom"), prel.css("paddingLeft")];
  2341. for ( j = 0; j < borders.length; j++ ) {
  2342. this.borderDif[ j ] = ( parseInt( borders[ j ], 10 ) || 0 ) + ( parseInt( paddings[ j ], 10 ) || 0 );
  2343. }
  2344. }
  2345. prel.css({
  2346. height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
  2347. width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
  2348. });
  2349. }
  2350. },
  2351. _renderProxy: function() {
  2352. var el = this.element, o = this.options;
  2353. this.elementOffset = el.offset();
  2354. if(this._helper) {
  2355. this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
  2356. this.helper.addClass(this._helper).css({
  2357. width: this.element.outerWidth() - 1,
  2358. height: this.element.outerHeight() - 1,
  2359. position: "absolute",
  2360. left: this.elementOffset.left +"px",
  2361. top: this.elementOffset.top +"px",
  2362. zIndex: ++o.zIndex //TODO: Don't modify option
  2363. });
  2364. this.helper
  2365. .appendTo("body")
  2366. .disableSelection();
  2367. } else {
  2368. this.helper = this.element;
  2369. }
  2370. },
  2371. _change: {
  2372. e: function(event, dx) {
  2373. return { width: this.originalSize.width + dx };
  2374. },
  2375. w: function(event, dx) {
  2376. var cs = this.originalSize, sp = this.originalPosition;
  2377. return { left: sp.left + dx, width: cs.width - dx };
  2378. },
  2379. n: function(event, dx, dy) {
  2380. var cs = this.originalSize, sp = this.originalPosition;
  2381. return { top: sp.top + dy, height: cs.height - dy };
  2382. },
  2383. s: function(event, dx, dy) {
  2384. return { height: this.originalSize.height + dy };
  2385. },
  2386. se: function(event, dx, dy) {
  2387. return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  2388. },
  2389. sw: function(event, dx, dy) {
  2390. return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  2391. },
  2392. ne: function(event, dx, dy) {
  2393. return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  2394. },
  2395. nw: function(event, dx, dy) {
  2396. return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  2397. }
  2398. },
  2399. _propagate: function(n, event) {
  2400. $.ui.plugin.call(this, n, [event, this.ui()]);
  2401. (n !== "resize" && this._trigger(n, event, this.ui()));
  2402. },
  2403. plugins: {},
  2404. ui: function() {
  2405. return {
  2406. originalElement: this.originalElement,
  2407. element: this.element,
  2408. helper: this.helper,
  2409. position: this.position,
  2410. size: this.size,
  2411. originalSize: this.originalSize,
  2412. originalPosition: this.originalPosition
  2413. };
  2414. }
  2415. });
  2416. /*
  2417. * Resizable Extensions
  2418. */
  2419. $.ui.plugin.add("resizable", "animate", {
  2420. stop: function( event ) {
  2421. var that = $(this).data("ui-resizable"),
  2422. o = that.options,
  2423. pr = that._proportionallyResizeElements,
  2424. ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  2425. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height,
  2426. soffsetw = ista ? 0 : that.sizeDiff.width,
  2427. style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  2428. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null,
  2429. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  2430. that.element.animate(
  2431. $.extend(style, top && left ? { top: top, left: left } : {}), {
  2432. duration: o.animateDuration,
  2433. easing: o.animateEasing,
  2434. step: function() {
  2435. var data = {
  2436. width: parseInt(that.element.css("width"), 10),
  2437. height: parseInt(that.element.css("height"), 10),
  2438. top: parseInt(that.element.css("top"), 10),
  2439. left: parseInt(that.element.css("left"), 10)
  2440. };
  2441. if (pr && pr.length) {
  2442. $(pr[0]).css({ width: data.width, height: data.height });
  2443. }
  2444. // propagating resize, and updating values for each animation step
  2445. that._updateCache(data);
  2446. that._propagate("resize", event);
  2447. }
  2448. }
  2449. );
  2450. }
  2451. });
  2452. $.ui.plugin.add("resizable", "containment", {
  2453. start: function() {
  2454. var element, p, co, ch, cw, width, height,
  2455. that = $(this).data("ui-resizable"),
  2456. o = that.options,
  2457. el = that.element,
  2458. oc = o.containment,
  2459. ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
  2460. if (!ce) {
  2461. return;
  2462. }
  2463. that.containerElement = $(ce);
  2464. if (/document/.test(oc) || oc === document) {
  2465. that.containerOffset = { left: 0, top: 0 };
  2466. that.containerPosition = { left: 0, top: 0 };
  2467. that.parentData = {
  2468. element: $(document), left: 0, top: 0,
  2469. width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
  2470. };
  2471. }
  2472. // i'm a node, so compute top, left, right, bottom
  2473. else {
  2474. element = $(ce);
  2475. p = [];
  2476. $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
  2477. that.containerOffset = element.offset();
  2478. that.containerPosition = element.position();
  2479. that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
  2480. co = that.containerOffset;
  2481. ch = that.containerSize.height;
  2482. cw = that.containerSize.width;
  2483. width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw );
  2484. height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
  2485. that.parentData = {
  2486. element: ce, left: co.left, top: co.top, width: width, height: height
  2487. };
  2488. }
  2489. },
  2490. resize: function( event ) {
  2491. var woset, hoset, isParent, isOffsetRelative,
  2492. that = $(this).data("ui-resizable"),
  2493. o = that.options,
  2494. co = that.containerOffset, cp = that.position,
  2495. pRatio = that._aspectRatio || event.shiftKey,
  2496. cop = { top:0, left:0 }, ce = that.containerElement;
  2497. if (ce[0] !== document && (/static/).test(ce.css("position"))) {
  2498. cop = co;
  2499. }
  2500. if (cp.left < (that._helper ? co.left : 0)) {
  2501. that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left));
  2502. if (pRatio) {
  2503. that.size.height = that.size.width / that.aspectRatio;
  2504. }
  2505. that.position.left = o.helper ? co.left : 0;
  2506. }
  2507. if (cp.top < (that._helper ? co.top : 0)) {
  2508. that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top);
  2509. if (pRatio) {
  2510. that.size.width = that.size.height * that.aspectRatio;
  2511. }
  2512. that.position.top = that._helper ? co.top : 0;
  2513. }
  2514. that.offset.left = that.parentData.left+that.position.left;
  2515. that.offset.top = that.parentData.top+that.position.top;
  2516. woset = Math.abs( (that._helper ? that.offset.left - cop.left : (that.offset.left - cop.left)) + that.sizeDiff.width );
  2517. hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height );
  2518. isParent = that.containerElement.get(0) === that.element.parent().get(0);
  2519. isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position"));
  2520. if(isParent && isOffsetRelative) {
  2521. woset -= that.parentData.left;
  2522. }
  2523. if (woset + that.size.width >= that.parentData.width) {
  2524. that.size.width = that.parentData.width - woset;
  2525. if (pRatio) {
  2526. that.size.height = that.size.width / that.aspectRatio;
  2527. }
  2528. }
  2529. if (hoset + that.size.height >= that.parentData.height) {
  2530. that.size.height = that.parentData.height - hoset;
  2531. if (pRatio) {
  2532. that.size.width = that.size.height * that.aspectRatio;
  2533. }
  2534. }
  2535. },
  2536. stop: function(){
  2537. var that = $(this).data("ui-resizable"),
  2538. o = that.options,
  2539. co = that.containerOffset,
  2540. cop = that.containerPosition,
  2541. ce = that.containerElement,
  2542. helper = $(that.helper),
  2543. ho = helper.offset(),
  2544. w = helper.outerWidth() - that.sizeDiff.width,
  2545. h = helper.outerHeight() - that.sizeDiff.height;
  2546. if (that._helper && !o.animate && (/relative/).test(ce.css("position"))) {
  2547. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2548. }
  2549. if (that._helper && !o.animate && (/static/).test(ce.css("position"))) {
  2550. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2551. }
  2552. }
  2553. });
  2554. $.ui.plugin.add("resizable", "alsoResize", {
  2555. start: function () {
  2556. var that = $(this).data("ui-resizable"),
  2557. o = that.options,
  2558. _store = function (exp) {
  2559. $(exp).each(function() {
  2560. var el = $(this);
  2561. el.data("ui-resizable-alsoresize", {
  2562. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  2563. left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
  2564. });
  2565. });
  2566. };
  2567. if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) {
  2568. if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
  2569. else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
  2570. }else{
  2571. _store(o.alsoResize);
  2572. }
  2573. },
  2574. resize: function (event, ui) {
  2575. var that = $(this).data("ui-resizable"),
  2576. o = that.options,
  2577. os = that.originalSize,
  2578. op = that.originalPosition,
  2579. delta = {
  2580. height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
  2581. top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
  2582. },
  2583. _alsoResize = function (exp, c) {
  2584. $(exp).each(function() {
  2585. var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
  2586. css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ["width", "height"] : ["width", "height", "top", "left"];
  2587. $.each(css, function (i, prop) {
  2588. var sum = (start[prop]||0) + (delta[prop]||0);
  2589. if (sum && sum >= 0) {
  2590. style[prop] = sum || null;
  2591. }
  2592. });
  2593. el.css(style);
  2594. });
  2595. };
  2596. if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) {
  2597. $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
  2598. }else{
  2599. _alsoResize(o.alsoResize);
  2600. }
  2601. },
  2602. stop: function () {
  2603. $(this).removeData("resizable-alsoresize");
  2604. }
  2605. });
  2606. $.ui.plugin.add("resizable", "ghost", {
  2607. start: function() {
  2608. var that = $(this).data("ui-resizable"), o = that.options, cs = that.size;
  2609. that.ghost = that.originalElement.clone();
  2610. that.ghost
  2611. .css({ opacity: 0.25, display: "block", position: "relative", height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
  2612. .addClass("ui-resizable-ghost")
  2613. .addClass(typeof o.ghost === "string" ? o.ghost : "");
  2614. that.ghost.appendTo(that.helper);
  2615. },
  2616. resize: function(){
  2617. var that = $(this).data("ui-resizable");
  2618. if (that.ghost) {
  2619. that.ghost.css({ position: "relative", height: that.size.height, width: that.size.width });
  2620. }
  2621. },
  2622. stop: function() {
  2623. var that = $(this).data("ui-resizable");
  2624. if (that.ghost && that.helper) {
  2625. that.helper.get(0).removeChild(that.ghost.get(0));
  2626. }
  2627. }
  2628. });
  2629. $.ui.plugin.add("resizable", "grid", {
  2630. resize: function() {
  2631. var that = $(this).data("ui-resizable"),
  2632. o = that.options,
  2633. cs = that.size,
  2634. os = that.originalSize,
  2635. op = that.originalPosition,
  2636. a = that.axis,
  2637. grid = typeof o.grid === "number" ? [o.grid, o.grid] : o.grid,
  2638. gridX = (grid[0]||1),
  2639. gridY = (grid[1]||1),
  2640. ox = Math.round((cs.width - os.width) / gridX) * gridX,
  2641. oy = Math.round((cs.height - os.height) / gridY) * gridY,
  2642. newWidth = os.width + ox,
  2643. newHeight = os.height + oy,
  2644. isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
  2645. isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
  2646. isMinWidth = o.minWidth && (o.minWidth > newWidth),
  2647. isMinHeight = o.minHeight && (o.minHeight > newHeight);
  2648. o.grid = grid;
  2649. if (isMinWidth) {
  2650. newWidth = newWidth + gridX;
  2651. }
  2652. if (isMinHeight) {
  2653. newHeight = newHeight + gridY;
  2654. }
  2655. if (isMaxWidth) {
  2656. newWidth = newWidth - gridX;
  2657. }
  2658. if (isMaxHeight) {
  2659. newHeight = newHeight - gridY;
  2660. }
  2661. if (/^(se|s|e)$/.test(a)) {
  2662. that.size.width = newWidth;
  2663. that.size.height = newHeight;
  2664. } else if (/^(ne)$/.test(a)) {
  2665. that.size.width = newWidth;
  2666. that.size.height = newHeight;
  2667. that.position.top = op.top - oy;
  2668. } else if (/^(sw)$/.test(a)) {
  2669. that.size.width = newWidth;
  2670. that.size.height = newHeight;
  2671. that.position.left = op.left - ox;
  2672. } else {
  2673. that.size.width = newWidth;
  2674. that.size.height = newHeight;
  2675. that.position.top = op.top - oy;
  2676. that.position.left = op.left - ox;
  2677. }
  2678. }
  2679. });
  2680. })(jQuery);
  2681. (function( $, undefined ) {
  2682. $.widget("ui.selectable", $.ui.mouse, {
  2683. version: "1.10.3",
  2684. options: {
  2685. appendTo: "body",
  2686. autoRefresh: true,
  2687. distance: 0,
  2688. filter: "*",
  2689. tolerance: "touch",
  2690. // callbacks
  2691. selected: null,
  2692. selecting: null,
  2693. start: null,
  2694. stop: null,
  2695. unselected: null,
  2696. unselecting: null
  2697. },
  2698. _create: function() {
  2699. var selectees,
  2700. that = this;
  2701. this.element.addClass("ui-selectable");
  2702. this.dragged = false;
  2703. // cache selectee children based on filter
  2704. this.refresh = function() {
  2705. selectees = $(that.options.filter, that.element[0]);
  2706. selectees.addClass("ui-selectee");
  2707. selectees.each(function() {
  2708. var $this = $(this),
  2709. pos = $this.offset();
  2710. $.data(this, "selectable-item", {
  2711. element: this,
  2712. $element: $this,
  2713. left: pos.left,
  2714. top: pos.top,
  2715. right: pos.left + $this.outerWidth(),
  2716. bottom: pos.top + $this.outerHeight(),
  2717. startselected: false,
  2718. selected: $this.hasClass("ui-selected"),
  2719. selecting: $this.hasClass("ui-selecting"),
  2720. unselecting: $this.hasClass("ui-unselecting")
  2721. });
  2722. });
  2723. };
  2724. this.refresh();
  2725. this.selectees = selectees.addClass("ui-selectee");
  2726. this._mouseInit();
  2727. this.helper = $("<div class='ui-selectable-helper'></div>");
  2728. },
  2729. _destroy: function() {
  2730. this.selectees
  2731. .removeClass("ui-selectee")
  2732. .removeData("selectable-item");
  2733. this.element
  2734. .removeClass("ui-selectable ui-selectable-disabled");
  2735. this._mouseDestroy();
  2736. },
  2737. _mouseStart: function(event) {
  2738. var that = this,
  2739. options = this.options;
  2740. this.opos = [event.pageX, event.pageY];
  2741. if (this.options.disabled) {
  2742. return;
  2743. }
  2744. this.selectees = $(options.filter, this.element[0]);
  2745. this._trigger("start", event);
  2746. $(options.appendTo).append(this.helper);
  2747. // position helper (lasso)
  2748. this.helper.css({
  2749. "left": event.pageX,
  2750. "top": event.pageY,
  2751. "width": 0,
  2752. "height": 0
  2753. });
  2754. if (options.autoRefresh) {
  2755. this.refresh();
  2756. }
  2757. this.selectees.filter(".ui-selected").each(function() {
  2758. var selectee = $.data(this, "selectable-item");
  2759. selectee.startselected = true;
  2760. if (!event.metaKey && !event.ctrlKey) {
  2761. selectee.$element.removeClass("ui-selected");
  2762. selectee.selected = false;
  2763. selectee.$element.addClass("ui-unselecting");
  2764. selectee.unselecting = true;
  2765. // selectable UNSELECTING callback
  2766. that._trigger("unselecting", event, {
  2767. unselecting: selectee.element
  2768. });
  2769. }
  2770. });
  2771. $(event.target).parents().addBack().each(function() {
  2772. var doSelect,
  2773. selectee = $.data(this, "selectable-item");
  2774. if (selectee) {
  2775. doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
  2776. selectee.$element
  2777. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  2778. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  2779. selectee.unselecting = !doSelect;
  2780. selectee.selecting = doSelect;
  2781. selectee.selected = doSelect;
  2782. // selectable (UN)SELECTING callback
  2783. if (doSelect) {
  2784. that._trigger("selecting", event, {
  2785. selecting: selectee.element
  2786. });
  2787. } else {
  2788. that._trigger("unselecting", event, {
  2789. unselecting: selectee.element
  2790. });
  2791. }
  2792. return false;
  2793. }
  2794. });
  2795. },
  2796. _mouseDrag: function(event) {
  2797. this.dragged = true;
  2798. if (this.options.disabled) {
  2799. return;
  2800. }
  2801. var tmp,
  2802. that = this,
  2803. options = this.options,
  2804. x1 = this.opos[0],
  2805. y1 = this.opos[1],
  2806. x2 = event.pageX,
  2807. y2 = event.pageY;
  2808. if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
  2809. if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
  2810. this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
  2811. this.selectees.each(function() {
  2812. var selectee = $.data(this, "selectable-item"),
  2813. hit = false;
  2814. //prevent helper from being selected if appendTo: selectable
  2815. if (!selectee || selectee.element === that.element[0]) {
  2816. return;
  2817. }
  2818. if (options.tolerance === "touch") {
  2819. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  2820. } else if (options.tolerance === "fit") {
  2821. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  2822. }
  2823. if (hit) {
  2824. // SELECT
  2825. if (selectee.selected) {
  2826. selectee.$element.removeClass("ui-selected");
  2827. selectee.selected = false;
  2828. }
  2829. if (selectee.unselecting) {
  2830. selectee.$element.removeClass("ui-unselecting");
  2831. selectee.unselecting = false;
  2832. }
  2833. if (!selectee.selecting) {
  2834. selectee.$element.addClass("ui-selecting");
  2835. selectee.selecting = true;
  2836. // selectable SELECTING callback
  2837. that._trigger("selecting", event, {
  2838. selecting: selectee.element
  2839. });
  2840. }
  2841. } else {
  2842. // UNSELECT
  2843. if (selectee.selecting) {
  2844. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  2845. selectee.$element.removeClass("ui-selecting");
  2846. selectee.selecting = false;
  2847. selectee.$element.addClass("ui-selected");
  2848. selectee.selected = true;
  2849. } else {
  2850. selectee.$element.removeClass("ui-selecting");
  2851. selectee.selecting = false;
  2852. if (selectee.startselected) {
  2853. selectee.$element.addClass("ui-unselecting");
  2854. selectee.unselecting = true;
  2855. }
  2856. // selectable UNSELECTING callback
  2857. that._trigger("unselecting", event, {
  2858. unselecting: selectee.element
  2859. });
  2860. }
  2861. }
  2862. if (selectee.selected) {
  2863. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  2864. selectee.$element.removeClass("ui-selected");
  2865. selectee.selected = false;
  2866. selectee.$element.addClass("ui-unselecting");
  2867. selectee.unselecting = true;
  2868. // selectable UNSELECTING callback
  2869. that._trigger("unselecting", event, {
  2870. unselecting: selectee.element
  2871. });
  2872. }
  2873. }
  2874. }
  2875. });
  2876. return false;
  2877. },
  2878. _mouseStop: function(event) {
  2879. var that = this;
  2880. this.dragged = false;
  2881. $(".ui-unselecting", this.element[0]).each(function() {
  2882. var selectee = $.data(this, "selectable-item");
  2883. selectee.$element.removeClass("ui-unselecting");
  2884. selectee.unselecting = false;
  2885. selectee.startselected = false;
  2886. that._trigger("unselected", event, {
  2887. unselected: selectee.element
  2888. });
  2889. });
  2890. $(".ui-selecting", this.element[0]).each(function() {
  2891. var selectee = $.data(this, "selectable-item");
  2892. selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
  2893. selectee.selecting = false;
  2894. selectee.selected = true;
  2895. selectee.startselected = true;
  2896. that._trigger("selected", event, {
  2897. selected: selectee.element
  2898. });
  2899. });
  2900. this._trigger("stop", event);
  2901. this.helper.remove();
  2902. return false;
  2903. }
  2904. });
  2905. })(jQuery);
  2906. (function( $, undefined ) {
  2907. /*jshint loopfunc: true */
  2908. function isOverAxis( x, reference, size ) {
  2909. return ( x > reference ) && ( x < ( reference + size ) );
  2910. }
  2911. function isFloating(item) {
  2912. return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
  2913. }
  2914. $.widget("ui.sortable", $.ui.mouse, {
  2915. version: "1.10.3",
  2916. widgetEventPrefix: "sort",
  2917. ready: false,
  2918. options: {
  2919. appendTo: "parent",
  2920. axis: false,
  2921. connectWith: false,
  2922. containment: false,
  2923. cursor: "auto",
  2924. cursorAt: false,
  2925. dropOnEmpty: true,
  2926. forcePlaceholderSize: false,
  2927. forceHelperSize: false,
  2928. grid: false,
  2929. handle: false,
  2930. helper: "original",
  2931. items: "> *",
  2932. opacity: false,
  2933. placeholder: false,
  2934. revert: false,
  2935. scroll: true,
  2936. scrollSensitivity: 20,
  2937. scrollSpeed: 20,
  2938. scope: "default",
  2939. tolerance: "intersect",
  2940. zIndex: 1000,
  2941. // callbacks
  2942. activate: null,
  2943. beforeStop: null,
  2944. change: null,
  2945. deactivate: null,
  2946. out: null,
  2947. over: null,
  2948. receive: null,
  2949. remove: null,
  2950. sort: null,
  2951. start: null,
  2952. stop: null,
  2953. update: null
  2954. },
  2955. _create: function() {
  2956. var o = this.options;
  2957. this.containerCache = {};
  2958. this.element.addClass("ui-sortable");
  2959. //Get the items
  2960. this.refresh();
  2961. //Let's determine if the items are being displayed horizontally
  2962. this.floating = this.items.length ? o.axis === "x" || isFloating(this.items[0].item) : false;
  2963. //Let's determine the parent's offset
  2964. this.offset = this.element.offset();
  2965. //Initialize mouse events for interaction
  2966. this._mouseInit();
  2967. //We're ready to go
  2968. this.ready = true;
  2969. },
  2970. _destroy: function() {
  2971. this.element
  2972. .removeClass("ui-sortable ui-sortable-disabled");
  2973. this._mouseDestroy();
  2974. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  2975. this.items[i].item.removeData(this.widgetName + "-item");
  2976. }
  2977. return this;
  2978. },
  2979. _setOption: function(key, value){
  2980. if ( key === "disabled" ) {
  2981. this.options[ key ] = value;
  2982. this.widget().toggleClass( "ui-sortable-disabled", !!value );
  2983. } else {
  2984. // Don't call widget base _setOption for disable as it adds ui-state-disabled class
  2985. $.Widget.prototype._setOption.apply(this, arguments);
  2986. }
  2987. },
  2988. _mouseCapture: function(event, overrideHandle) {
  2989. var currentItem = null,
  2990. validHandle = false,
  2991. that = this;
  2992. if (this.reverting) {
  2993. return false;
  2994. }
  2995. if(this.options.disabled || this.options.type === "static") {
  2996. return false;
  2997. }
  2998. //We have to refresh the items data once first
  2999. this._refreshItems(event);
  3000. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  3001. $(event.target).parents().each(function() {
  3002. if($.data(this, that.widgetName + "-item") === that) {
  3003. currentItem = $(this);
  3004. return false;
  3005. }
  3006. });
  3007. if($.data(event.target, that.widgetName + "-item") === that) {
  3008. currentItem = $(event.target);
  3009. }
  3010. if(!currentItem) {
  3011. return false;
  3012. }
  3013. if(this.options.handle && !overrideHandle) {
  3014. $(this.options.handle, currentItem).find("*").addBack().each(function() {
  3015. if(this === event.target) {
  3016. validHandle = true;
  3017. }
  3018. });
  3019. if(!validHandle) {
  3020. return false;
  3021. }
  3022. }
  3023. this.currentItem = currentItem;
  3024. this._removeCurrentsFromItems();
  3025. return true;
  3026. },
  3027. _mouseStart: function(event, overrideHandle, noActivation) {
  3028. var i, body,
  3029. o = this.options;
  3030. this.currentContainer = this;
  3031. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  3032. this.refreshPositions();
  3033. //Create and append the visible helper
  3034. this.helper = this._createHelper(event);
  3035. //Cache the helper size
  3036. this._cacheHelperProportions();
  3037. /*
  3038. * - Position generation -
  3039. * This block generates everything position related - it's the core of draggables.
  3040. */
  3041. //Cache the margins of the original element
  3042. this._cacheMargins();
  3043. //Get the next scrolling parent
  3044. this.scrollParent = this.helper.scrollParent();
  3045. //The element's absolute position on the page minus margins
  3046. this.offset = this.currentItem.offset();
  3047. this.offset = {
  3048. top: this.offset.top - this.margins.top,
  3049. left: this.offset.left - this.margins.left
  3050. };
  3051. $.extend(this.offset, {
  3052. click: { //Where the click happened, relative to the element
  3053. left: event.pageX - this.offset.left,
  3054. top: event.pageY - this.offset.top
  3055. },
  3056. parent: this._getParentOffset(),
  3057. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  3058. });
  3059. // Only after we got the offset, we can change the helper's position to absolute
  3060. // TODO: Still need to figure out a way to make relative sorting possible
  3061. this.helper.css("position", "absolute");
  3062. this.cssPosition = this.helper.css("position");
  3063. //Generate the original position
  3064. this.originalPosition = this._generatePosition(event);
  3065. this.originalPageX = event.pageX;
  3066. this.originalPageY = event.pageY;
  3067. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  3068. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  3069. //Cache the former DOM position
  3070. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  3071. //If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way
  3072. if(this.helper[0] !== this.currentItem[0]) {
  3073. this.currentItem.hide();
  3074. }
  3075. //Create the placeholder
  3076. this._createPlaceholder();
  3077. //Set a containment if given in the options
  3078. if(o.containment) {
  3079. this._setContainment();
  3080. }
  3081. if( o.cursor && o.cursor !== "auto" ) { // cursor option
  3082. body = this.document.find( "body" );
  3083. // support: IE
  3084. this.storedCursor = body.css( "cursor" );
  3085. body.css( "cursor", o.cursor );
  3086. this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
  3087. }
  3088. if(o.opacity) { // opacity option
  3089. if (this.helper.css("opacity")) {
  3090. this._storedOpacity = this.helper.css("opacity");
  3091. }
  3092. this.helper.css("opacity", o.opacity);
  3093. }
  3094. if(o.zIndex) { // zIndex option
  3095. if (this.helper.css("zIndex")) {
  3096. this._storedZIndex = this.helper.css("zIndex");
  3097. }
  3098. this.helper.css("zIndex", o.zIndex);
  3099. }
  3100. //Prepare scrolling
  3101. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  3102. this.overflowOffset = this.scrollParent.offset();
  3103. }
  3104. //Call callbacks
  3105. this._trigger("start", event, this._uiHash());
  3106. //Recache the helper size
  3107. if(!this._preserveHelperProportions) {
  3108. this._cacheHelperProportions();
  3109. }
  3110. //Post "activate" events to possible containers
  3111. if( !noActivation ) {
  3112. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  3113. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  3114. }
  3115. }
  3116. //Prepare possible droppables
  3117. if($.ui.ddmanager) {
  3118. $.ui.ddmanager.current = this;
  3119. }
  3120. if ($.ui.ddmanager && !o.dropBehaviour) {
  3121. $.ui.ddmanager.prepareOffsets(this, event);
  3122. }
  3123. this.dragging = true;
  3124. this.helper.addClass("ui-sortable-helper");
  3125. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  3126. return true;
  3127. },
  3128. _mouseDrag: function(event) {
  3129. var i, item, itemElement, intersection,
  3130. o = this.options,
  3131. scrolled = false;
  3132. //Compute the helpers position
  3133. this.position = this._generatePosition(event);
  3134. this.positionAbs = this._convertPositionTo("absolute");
  3135. if (!this.lastPositionAbs) {
  3136. this.lastPositionAbs = this.positionAbs;
  3137. }
  3138. //Do scrolling
  3139. if(this.options.scroll) {
  3140. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  3141. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  3142. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  3143. } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
  3144. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  3145. }
  3146. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  3147. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  3148. } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
  3149. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  3150. }
  3151. } else {
  3152. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  3153. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  3154. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  3155. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  3156. }
  3157. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  3158. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  3159. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  3160. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  3161. }
  3162. }
  3163. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  3164. $.ui.ddmanager.prepareOffsets(this, event);
  3165. }
  3166. }
  3167. //Regenerate the absolute position used for position checks
  3168. this.positionAbs = this._convertPositionTo("absolute");
  3169. //Set the helper position
  3170. if(!this.options.axis || this.options.axis !== "y") {
  3171. this.helper[0].style.left = this.position.left+"px";
  3172. }
  3173. if(!this.options.axis || this.options.axis !== "x") {
  3174. this.helper[0].style.top = this.position.top+"px";
  3175. }
  3176. //Rearrange
  3177. for (i = this.items.length - 1; i >= 0; i--) {
  3178. //Cache variables and intersection, continue if no intersection
  3179. item = this.items[i];
  3180. itemElement = item.item[0];
  3181. intersection = this._intersectsWithPointer(item);
  3182. if (!intersection) {
  3183. continue;
  3184. }
  3185. // Only put the placeholder inside the current Container, skip all
  3186. // items form other containers. This works because when moving
  3187. // an item from one container to another the
  3188. // currentContainer is switched before the placeholder is moved.
  3189. //
  3190. // Without this moving items in "sub-sortables" can cause the placeholder to jitter
  3191. // beetween the outer and inner container.
  3192. if (item.instance !== this.currentContainer) {
  3193. continue;
  3194. }
  3195. // cannot intersect with itself
  3196. // no useless actions that have been done before
  3197. // no action if the item moved is the parent of the item checked
  3198. if (itemElement !== this.currentItem[0] &&
  3199. this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
  3200. !$.contains(this.placeholder[0], itemElement) &&
  3201. (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
  3202. ) {
  3203. this.direction = intersection === 1 ? "down" : "up";
  3204. if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
  3205. this._rearrange(event, item);
  3206. } else {
  3207. break;
  3208. }
  3209. this._trigger("change", event, this._uiHash());
  3210. break;
  3211. }
  3212. }
  3213. //Post events to containers
  3214. this._contactContainers(event);
  3215. //Interconnect with droppables
  3216. if($.ui.ddmanager) {
  3217. $.ui.ddmanager.drag(this, event);
  3218. }
  3219. //Call callbacks
  3220. this._trigger("sort", event, this._uiHash());
  3221. this.lastPositionAbs = this.positionAbs;
  3222. return false;
  3223. },
  3224. _mouseStop: function(event, noPropagation) {
  3225. if(!event) {
  3226. return;
  3227. }
  3228. //If we are using droppables, inform the manager about the drop
  3229. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  3230. $.ui.ddmanager.drop(this, event);
  3231. }
  3232. if(this.options.revert) {
  3233. var that = this,
  3234. cur = this.placeholder.offset(),
  3235. axis = this.options.axis,
  3236. animation = {};
  3237. if ( !axis || axis === "x" ) {
  3238. animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
  3239. }
  3240. if ( !axis || axis === "y" ) {
  3241. animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
  3242. }
  3243. this.reverting = true;
  3244. $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
  3245. that._clear(event);
  3246. });
  3247. } else {
  3248. this._clear(event, noPropagation);
  3249. }
  3250. return false;
  3251. },
  3252. cancel: function() {
  3253. if(this.dragging) {
  3254. this._mouseUp({ target: null });
  3255. if(this.options.helper === "original") {
  3256. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  3257. } else {
  3258. this.currentItem.show();
  3259. }
  3260. //Post deactivating events to containers
  3261. for (var i = this.containers.length - 1; i >= 0; i--){
  3262. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  3263. if(this.containers[i].containerCache.over) {
  3264. this.containers[i]._trigger("out", null, this._uiHash(this));
  3265. this.containers[i].containerCache.over = 0;
  3266. }
  3267. }
  3268. }
  3269. if (this.placeholder) {
  3270. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  3271. if(this.placeholder[0].parentNode) {
  3272. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  3273. }
  3274. if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
  3275. this.helper.remove();
  3276. }
  3277. $.extend(this, {
  3278. helper: null,
  3279. dragging: false,
  3280. reverting: false,
  3281. _noFinalSort: null
  3282. });
  3283. if(this.domPosition.prev) {
  3284. $(this.domPosition.prev).after(this.currentItem);
  3285. } else {
  3286. $(this.domPosition.parent).prepend(this.currentItem);
  3287. }
  3288. }
  3289. return this;
  3290. },
  3291. serialize: function(o) {
  3292. var items = this._getItemsAsjQuery(o && o.connected),
  3293. str = [];
  3294. o = o || {};
  3295. $(items).each(function() {
  3296. var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
  3297. if (res) {
  3298. str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
  3299. }
  3300. });
  3301. if(!str.length && o.key) {
  3302. str.push(o.key + "=");
  3303. }
  3304. return str.join("&");
  3305. },
  3306. toArray: function(o) {
  3307. var items = this._getItemsAsjQuery(o && o.connected),
  3308. ret = [];
  3309. o = o || {};
  3310. items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
  3311. return ret;
  3312. },
  3313. /* Be careful with the following core functions */
  3314. _intersectsWith: function(item) {
  3315. var x1 = this.positionAbs.left,
  3316. x2 = x1 + this.helperProportions.width,
  3317. y1 = this.positionAbs.top,
  3318. y2 = y1 + this.helperProportions.height,
  3319. l = item.left,
  3320. r = l + item.width,
  3321. t = item.top,
  3322. b = t + item.height,
  3323. dyClick = this.offset.click.top,
  3324. dxClick = this.offset.click.left,
  3325. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
  3326. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
  3327. isOverElement = isOverElementHeight && isOverElementWidth;
  3328. if ( this.options.tolerance === "pointer" ||
  3329. this.options.forcePointerForContainers ||
  3330. (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
  3331. ) {
  3332. return isOverElement;
  3333. } else {
  3334. return (l < x1 + (this.helperProportions.width / 2) && // Right Half
  3335. x2 - (this.helperProportions.width / 2) < r && // Left Half
  3336. t < y1 + (this.helperProportions.height / 2) && // Bottom Half
  3337. y2 - (this.helperProportions.height / 2) < b ); // Top Half
  3338. }
  3339. },
  3340. _intersectsWithPointer: function(item) {
  3341. var isOverElementHeight = (this.options.axis === "x") || isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  3342. isOverElementWidth = (this.options.axis === "y") || isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  3343. isOverElement = isOverElementHeight && isOverElementWidth,
  3344. verticalDirection = this._getDragVerticalDirection(),
  3345. horizontalDirection = this._getDragHorizontalDirection();
  3346. if (!isOverElement) {
  3347. return false;
  3348. }
  3349. return this.floating ?
  3350. ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
  3351. : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
  3352. },
  3353. _intersectsWithSides: function(item) {
  3354. var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  3355. isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  3356. verticalDirection = this._getDragVerticalDirection(),
  3357. horizontalDirection = this._getDragHorizontalDirection();
  3358. if (this.floating && horizontalDirection) {
  3359. return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
  3360. } else {
  3361. return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
  3362. }
  3363. },
  3364. _getDragVerticalDirection: function() {
  3365. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  3366. return delta !== 0 && (delta > 0 ? "down" : "up");
  3367. },
  3368. _getDragHorizontalDirection: function() {
  3369. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  3370. return delta !== 0 && (delta > 0 ? "right" : "left");
  3371. },
  3372. refresh: function(event) {
  3373. this._refreshItems(event);
  3374. this.refreshPositions();
  3375. return this;
  3376. },
  3377. _connectWith: function() {
  3378. var options = this.options;
  3379. return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
  3380. },
  3381. _getItemsAsjQuery: function(connected) {
  3382. var i, j, cur, inst,
  3383. items = [],
  3384. queries = [],
  3385. connectWith = this._connectWith();
  3386. if(connectWith && connected) {
  3387. for (i = connectWith.length - 1; i >= 0; i--){
  3388. cur = $(connectWith[i]);
  3389. for ( j = cur.length - 1; j >= 0; j--){
  3390. inst = $.data(cur[j], this.widgetFullName);
  3391. if(inst && inst !== this && !inst.options.disabled) {
  3392. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), inst]);
  3393. }
  3394. }
  3395. }
  3396. }
  3397. queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), this]);
  3398. for (i = queries.length - 1; i >= 0; i--){
  3399. queries[i][0].each(function() {
  3400. items.push(this);
  3401. });
  3402. }
  3403. return $(items);
  3404. },
  3405. _removeCurrentsFromItems: function() {
  3406. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  3407. this.items = $.grep(this.items, function (item) {
  3408. for (var j=0; j < list.length; j++) {
  3409. if(list[j] === item.item[0]) {
  3410. return false;
  3411. }
  3412. }
  3413. return true;
  3414. });
  3415. },
  3416. _refreshItems: function(event) {
  3417. this.items = [];
  3418. this.containers = [this];
  3419. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  3420. items = this.items,
  3421. queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
  3422. connectWith = this._connectWith();
  3423. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  3424. for (i = connectWith.length - 1; i >= 0; i--){
  3425. cur = $(connectWith[i]);
  3426. for (j = cur.length - 1; j >= 0; j--){
  3427. inst = $.data(cur[j], this.widgetFullName);
  3428. if(inst && inst !== this && !inst.options.disabled) {
  3429. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  3430. this.containers.push(inst);
  3431. }
  3432. }
  3433. }
  3434. }
  3435. for (i = queries.length - 1; i >= 0; i--) {
  3436. targetData = queries[i][1];
  3437. _queries = queries[i][0];
  3438. for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  3439. item = $(_queries[j]);
  3440. item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
  3441. items.push({
  3442. item: item,
  3443. instance: targetData,
  3444. width: 0, height: 0,
  3445. left: 0, top: 0
  3446. });
  3447. }
  3448. }
  3449. },
  3450. refreshPositions: function(fast) {
  3451. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  3452. if(this.offsetParent && this.helper) {
  3453. this.offset.parent = this._getParentOffset();
  3454. }
  3455. var i, item, t, p;
  3456. for (i = this.items.length - 1; i >= 0; i--){
  3457. item = this.items[i];
  3458. //We ignore calculating positions of all connected containers when we're not over them
  3459. if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
  3460. continue;
  3461. }
  3462. t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  3463. if (!fast) {
  3464. item.width = t.outerWidth();
  3465. item.height = t.outerHeight();
  3466. }
  3467. p = t.offset();
  3468. item.left = p.left;
  3469. item.top = p.top;
  3470. }
  3471. if(this.options.custom && this.options.custom.refreshContainers) {
  3472. this.options.custom.refreshContainers.call(this);
  3473. } else {
  3474. for (i = this.containers.length - 1; i >= 0; i--){
  3475. p = this.containers[i].element.offset();
  3476. this.containers[i].containerCache.left = p.left;
  3477. this.containers[i].containerCache.top = p.top;
  3478. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  3479. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  3480. }
  3481. }
  3482. return this;
  3483. },
  3484. _createPlaceholder: function(that) {
  3485. that = that || this;
  3486. var className,
  3487. o = that.options;
  3488. if(!o.placeholder || o.placeholder.constructor === String) {
  3489. className = o.placeholder;
  3490. o.placeholder = {
  3491. element: function() {
  3492. var nodeName = that.currentItem[0].nodeName.toLowerCase(),
  3493. element = $( "<" + nodeName + ">", that.document[0] )
  3494. .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
  3495. .removeClass("ui-sortable-helper");
  3496. if ( nodeName === "tr" ) {
  3497. that.currentItem.children().each(function() {
  3498. $( "<td>&#160;</td>", that.document[0] )
  3499. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  3500. .appendTo( element );
  3501. });
  3502. } else if ( nodeName === "img" ) {
  3503. element.attr( "src", that.currentItem.attr( "src" ) );
  3504. }
  3505. if ( !className ) {
  3506. element.css( "visibility", "hidden" );
  3507. }
  3508. return element;
  3509. },
  3510. update: function(container, p) {
  3511. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  3512. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  3513. if(className && !o.forcePlaceholderSize) {
  3514. return;
  3515. }
  3516. //If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item
  3517. if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
  3518. if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
  3519. }
  3520. };
  3521. }
  3522. //Create the placeholder
  3523. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  3524. //Append it after the actual current item
  3525. that.currentItem.after(that.placeholder);
  3526. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  3527. o.placeholder.update(that, that.placeholder);
  3528. },
  3529. _contactContainers: function(event) {
  3530. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, floating,
  3531. innermostContainer = null,
  3532. innermostIndex = null;
  3533. // get innermost container that intersects with item
  3534. for (i = this.containers.length - 1; i >= 0; i--) {
  3535. // never consider a container that's located within the item itself
  3536. if($.contains(this.currentItem[0], this.containers[i].element[0])) {
  3537. continue;
  3538. }
  3539. if(this._intersectsWith(this.containers[i].containerCache)) {
  3540. // if we've already found a container and it's more "inner" than this, then continue
  3541. if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
  3542. continue;
  3543. }
  3544. innermostContainer = this.containers[i];
  3545. innermostIndex = i;
  3546. } else {
  3547. // container doesn't intersect. trigger "out" event if necessary
  3548. if(this.containers[i].containerCache.over) {
  3549. this.containers[i]._trigger("out", event, this._uiHash(this));
  3550. this.containers[i].containerCache.over = 0;
  3551. }
  3552. }
  3553. }
  3554. // if no intersecting containers found, return
  3555. if(!innermostContainer) {
  3556. return;
  3557. }
  3558. // move the item into the container if it's not there already
  3559. if(this.containers.length === 1) {
  3560. if (!this.containers[innermostIndex].containerCache.over) {
  3561. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  3562. this.containers[innermostIndex].containerCache.over = 1;
  3563. }
  3564. } else {
  3565. //When entering a new container, we will find the item with the least distance and append our item near it
  3566. dist = 10000;
  3567. itemWithLeastDistance = null;
  3568. floating = innermostContainer.floating || isFloating(this.currentItem);
  3569. posProperty = floating ? "left" : "top";
  3570. sizeProperty = floating ? "width" : "height";
  3571. base = this.positionAbs[posProperty] + this.offset.click[posProperty];
  3572. for (j = this.items.length - 1; j >= 0; j--) {
  3573. if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
  3574. continue;
  3575. }
  3576. if(this.items[j].item[0] === this.currentItem[0]) {
  3577. continue;
  3578. }
  3579. if (floating && !isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) {
  3580. continue;
  3581. }
  3582. cur = this.items[j].item.offset()[posProperty];
  3583. nearBottom = false;
  3584. if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){
  3585. nearBottom = true;
  3586. cur += this.items[j][sizeProperty];
  3587. }
  3588. if(Math.abs(cur - base) < dist) {
  3589. dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
  3590. this.direction = nearBottom ? "up": "down";
  3591. }
  3592. }
  3593. //Check if dropOnEmpty is enabled
  3594. if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
  3595. return;
  3596. }
  3597. if(this.currentContainer === this.containers[innermostIndex]) {
  3598. return;
  3599. }
  3600. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  3601. this._trigger("change", event, this._uiHash());
  3602. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  3603. this.currentContainer = this.containers[innermostIndex];
  3604. //Update the placeholder
  3605. this.options.placeholder.update(this.currentContainer, this.placeholder);
  3606. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  3607. this.containers[innermostIndex].containerCache.over = 1;
  3608. }
  3609. },
  3610. _createHelper: function(event) {
  3611. var o = this.options,
  3612. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
  3613. //Add the helper to the DOM if that didn't happen already
  3614. if(!helper.parents("body").length) {
  3615. $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  3616. }
  3617. if(helper[0] === this.currentItem[0]) {
  3618. this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left") };
  3619. }
  3620. if(!helper[0].style.width || o.forceHelperSize) {
  3621. helper.width(this.currentItem.width());
  3622. }
  3623. if(!helper[0].style.height || o.forceHelperSize) {
  3624. helper.height(this.currentItem.height());
  3625. }
  3626. return helper;
  3627. },
  3628. _adjustOffsetFromHelper: function(obj) {
  3629. if (typeof obj === "string") {
  3630. obj = obj.split(" ");
  3631. }
  3632. if ($.isArray(obj)) {
  3633. obj = {left: +obj[0], top: +obj[1] || 0};
  3634. }
  3635. if ("left" in obj) {
  3636. this.offset.click.left = obj.left + this.margins.left;
  3637. }
  3638. if ("right" in obj) {
  3639. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  3640. }
  3641. if ("top" in obj) {
  3642. this.offset.click.top = obj.top + this.margins.top;
  3643. }
  3644. if ("bottom" in obj) {
  3645. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  3646. }
  3647. },
  3648. _getParentOffset: function() {
  3649. //Get the offsetParent and cache its position
  3650. this.offsetParent = this.helper.offsetParent();
  3651. var po = this.offsetParent.offset();
  3652. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  3653. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  3654. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  3655. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  3656. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  3657. po.left += this.scrollParent.scrollLeft();
  3658. po.top += this.scrollParent.scrollTop();
  3659. }
  3660. // This needs to be actually done for all browsers, since pageX/pageY includes this information
  3661. // with an ugly IE fix
  3662. if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  3663. po = { top: 0, left: 0 };
  3664. }
  3665. return {
  3666. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  3667. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  3668. };
  3669. },
  3670. _getRelativeOffset: function() {
  3671. if(this.cssPosition === "relative") {
  3672. var p = this.currentItem.position();
  3673. return {
  3674. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  3675. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  3676. };
  3677. } else {
  3678. return { top: 0, left: 0 };
  3679. }
  3680. },
  3681. _cacheMargins: function() {
  3682. this.margins = {
  3683. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  3684. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  3685. };
  3686. },
  3687. _cacheHelperProportions: function() {
  3688. this.helperProportions = {
  3689. width: this.helper.outerWidth(),
  3690. height: this.helper.outerHeight()
  3691. };
  3692. },
  3693. _setContainment: function() {
  3694. var ce, co, over,
  3695. o = this.options;
  3696. if(o.containment === "parent") {
  3697. o.containment = this.helper[0].parentNode;
  3698. }
  3699. if(o.containment === "document" || o.containment === "window") {
  3700. this.containment = [
  3701. 0 - this.offset.relative.left - this.offset.parent.left,
  3702. 0 - this.offset.relative.top - this.offset.parent.top,
  3703. $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
  3704. ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  3705. ];
  3706. }
  3707. if(!(/^(document|window|parent)$/).test(o.containment)) {
  3708. ce = $(o.containment)[0];
  3709. co = $(o.containment).offset();
  3710. over = ($(ce).css("overflow") !== "hidden");
  3711. this.containment = [
  3712. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  3713. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  3714. co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
  3715. co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
  3716. ];
  3717. }
  3718. },
  3719. _convertPositionTo: function(d, pos) {
  3720. if(!pos) {
  3721. pos = this.position;
  3722. }
  3723. var mod = d === "absolute" ? 1 : -1,
  3724. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  3725. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  3726. return {
  3727. top: (
  3728. pos.top + // The absolute mouse position
  3729. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  3730. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  3731. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  3732. ),
  3733. left: (
  3734. pos.left + // The absolute mouse position
  3735. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  3736. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  3737. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  3738. )
  3739. };
  3740. },
  3741. _generatePosition: function(event) {
  3742. var top, left,
  3743. o = this.options,
  3744. pageX = event.pageX,
  3745. pageY = event.pageY,
  3746. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  3747. // This is another very weird special case that only happens for relative elements:
  3748. // 1. If the css position is relative
  3749. // 2. and the scroll parent is the document or similar to the offset parent
  3750. // we have to refresh the relative offset during the scroll so there are no jumps
  3751. if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
  3752. this.offset.relative = this._getRelativeOffset();
  3753. }
  3754. /*
  3755. * - Position constraining -
  3756. * Constrain the position to a mix of grid, containment.
  3757. */
  3758. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  3759. if(this.containment) {
  3760. if(event.pageX - this.offset.click.left < this.containment[0]) {
  3761. pageX = this.containment[0] + this.offset.click.left;
  3762. }
  3763. if(event.pageY - this.offset.click.top < this.containment[1]) {
  3764. pageY = this.containment[1] + this.offset.click.top;
  3765. }
  3766. if(event.pageX - this.offset.click.left > this.containment[2]) {
  3767. pageX = this.containment[2] + this.offset.click.left;
  3768. }
  3769. if(event.pageY - this.offset.click.top > this.containment[3]) {
  3770. pageY = this.containment[3] + this.offset.click.top;
  3771. }
  3772. }
  3773. if(o.grid) {
  3774. top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  3775. pageY = this.containment ? ( (top - this.offset.click.top >= this.containment[1] && top - this.offset.click.top <= this.containment[3]) ? top : ((top - this.offset.click.top >= this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
  3776. left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  3777. pageX = this.containment ? ( (left - this.offset.click.left >= this.containment[0] && left - this.offset.click.left <= this.containment[2]) ? left : ((left - this.offset.click.left >= this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
  3778. }
  3779. }
  3780. return {
  3781. top: (
  3782. pageY - // The absolute mouse position
  3783. this.offset.click.top - // Click offset (relative to the element)
  3784. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  3785. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  3786. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  3787. ),
  3788. left: (
  3789. pageX - // The absolute mouse position
  3790. this.offset.click.left - // Click offset (relative to the element)
  3791. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  3792. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  3793. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  3794. )
  3795. };
  3796. },
  3797. _rearrange: function(event, i, a, hardRefresh) {
  3798. a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction === "down" ? i.item[0] : i.item[0].nextSibling));
  3799. //Various things done here to improve the performance:
  3800. // 1. we create a setTimeout, that calls refreshPositions
  3801. // 2. on the instance, we have a counter variable, that get's higher after every append
  3802. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  3803. // 4. this lets only the last addition to the timeout stack through
  3804. this.counter = this.counter ? ++this.counter : 1;
  3805. var counter = this.counter;
  3806. this._delay(function() {
  3807. if(counter === this.counter) {
  3808. this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  3809. }
  3810. });
  3811. },
  3812. _clear: function(event, noPropagation) {
  3813. this.reverting = false;
  3814. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  3815. // everything else normalized again
  3816. var i,
  3817. delayedTriggers = [];
  3818. // We first have to update the dom position of the actual currentItem
  3819. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  3820. if(!this._noFinalSort && this.currentItem.parent().length) {
  3821. this.placeholder.before(this.currentItem);
  3822. }
  3823. this._noFinalSort = null;
  3824. if(this.helper[0] === this.currentItem[0]) {
  3825. for(i in this._storedCSS) {
  3826. if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
  3827. this._storedCSS[i] = "";
  3828. }
  3829. }
  3830. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  3831. } else {
  3832. this.currentItem.show();
  3833. }
  3834. if(this.fromOutside && !noPropagation) {
  3835. delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  3836. }
  3837. if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
  3838. delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  3839. }
  3840. // Check if the items Container has Changed and trigger appropriate
  3841. // events.
  3842. if (this !== this.currentContainer) {
  3843. if(!noPropagation) {
  3844. delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  3845. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  3846. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  3847. }
  3848. }
  3849. //Post events to containers
  3850. for (i = this.containers.length - 1; i >= 0; i--){
  3851. if(!noPropagation) {
  3852. delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  3853. }
  3854. if(this.containers[i].containerCache.over) {
  3855. delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  3856. this.containers[i].containerCache.over = 0;
  3857. }
  3858. }
  3859. //Do what was originally in plugins
  3860. if ( this.storedCursor ) {
  3861. this.document.find( "body" ).css( "cursor", this.storedCursor );
  3862. this.storedStylesheet.remove();
  3863. }
  3864. if(this._storedOpacity) {
  3865. this.helper.css("opacity", this._storedOpacity);
  3866. }
  3867. if(this._storedZIndex) {
  3868. this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
  3869. }
  3870. this.dragging = false;
  3871. if(this.cancelHelperRemoval) {
  3872. if(!noPropagation) {
  3873. this._trigger("beforeStop", event, this._uiHash());
  3874. for (i=0; i < delayedTriggers.length; i++) {
  3875. delayedTriggers[i].call(this, event);
  3876. } //Trigger all delayed events
  3877. this._trigger("stop", event, this._uiHash());
  3878. }
  3879. this.fromOutside = false;
  3880. return false;
  3881. }
  3882. if(!noPropagation) {
  3883. this._trigger("beforeStop", event, this._uiHash());
  3884. }
  3885. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  3886. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  3887. if(this.helper[0] !== this.currentItem[0]) {
  3888. this.helper.remove();
  3889. }
  3890. this.helper = null;
  3891. if(!noPropagation) {
  3892. for (i=0; i < delayedTriggers.length; i++) {
  3893. delayedTriggers[i].call(this, event);
  3894. } //Trigger all delayed events
  3895. this._trigger("stop", event, this._uiHash());
  3896. }
  3897. this.fromOutside = false;
  3898. return true;
  3899. },
  3900. _trigger: function() {
  3901. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  3902. this.cancel();
  3903. }
  3904. },
  3905. _uiHash: function(_inst) {
  3906. var inst = _inst || this;
  3907. return {
  3908. helper: inst.helper,
  3909. placeholder: inst.placeholder || $([]),
  3910. position: inst.position,
  3911. originalPosition: inst.originalPosition,
  3912. offset: inst.positionAbs,
  3913. item: inst.currentItem,
  3914. sender: _inst ? _inst.element : null
  3915. };
  3916. }
  3917. });
  3918. })(jQuery);
  3919. (function($, undefined) {
  3920. var dataSpace = "ui-effects-";
  3921. $.effects = {
  3922. effect: {}
  3923. };
  3924. /*!
  3925. * jQuery Color Animations v2.1.2
  3926. * https://github.com/jquery/jquery-color
  3927. *
  3928. * Copyright 2013 jQuery Foundation and other contributors
  3929. * Released under the MIT license.
  3930. * http://jquery.org/license
  3931. *
  3932. * Date: Wed Jan 16 08:47:09 2013 -0600
  3933. */
  3934. (function( jQuery, undefined ) {
  3935. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  3936. // plusequals test for += 100 -= 100
  3937. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  3938. // a set of RE's that can match strings and generate color tuples.
  3939. stringParsers = [{
  3940. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  3941. parse: function( execResult ) {
  3942. return [
  3943. execResult[ 1 ],
  3944. execResult[ 2 ],
  3945. execResult[ 3 ],
  3946. execResult[ 4 ]
  3947. ];
  3948. }
  3949. }, {
  3950. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  3951. parse: function( execResult ) {
  3952. return [
  3953. execResult[ 1 ] * 2.55,
  3954. execResult[ 2 ] * 2.55,
  3955. execResult[ 3 ] * 2.55,
  3956. execResult[ 4 ]
  3957. ];
  3958. }
  3959. }, {
  3960. // this regex ignores A-F because it's compared against an already lowercased string
  3961. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  3962. parse: function( execResult ) {
  3963. return [
  3964. parseInt( execResult[ 1 ], 16 ),
  3965. parseInt( execResult[ 2 ], 16 ),
  3966. parseInt( execResult[ 3 ], 16 )
  3967. ];
  3968. }
  3969. }, {
  3970. // this regex ignores A-F because it's compared against an already lowercased string
  3971. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  3972. parse: function( execResult ) {
  3973. return [
  3974. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  3975. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  3976. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  3977. ];
  3978. }
  3979. }, {
  3980. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  3981. space: "hsla",
  3982. parse: function( execResult ) {
  3983. return [
  3984. execResult[ 1 ],
  3985. execResult[ 2 ] / 100,
  3986. execResult[ 3 ] / 100,
  3987. execResult[ 4 ]
  3988. ];
  3989. }
  3990. }],
  3991. // jQuery.Color( )
  3992. color = jQuery.Color = function( color, green, blue, alpha ) {
  3993. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  3994. },
  3995. spaces = {
  3996. rgba: {
  3997. props: {
  3998. red: {
  3999. idx: 0,
  4000. type: "byte"
  4001. },
  4002. green: {
  4003. idx: 1,
  4004. type: "byte"
  4005. },
  4006. blue: {
  4007. idx: 2,
  4008. type: "byte"
  4009. }
  4010. }
  4011. },
  4012. hsla: {
  4013. props: {
  4014. hue: {
  4015. idx: 0,
  4016. type: "degrees"
  4017. },
  4018. saturation: {
  4019. idx: 1,
  4020. type: "percent"
  4021. },
  4022. lightness: {
  4023. idx: 2,
  4024. type: "percent"
  4025. }
  4026. }
  4027. }
  4028. },
  4029. propTypes = {
  4030. "byte": {
  4031. floor: true,
  4032. max: 255
  4033. },
  4034. "percent": {
  4035. max: 1
  4036. },
  4037. "degrees": {
  4038. mod: 360,
  4039. floor: true
  4040. }
  4041. },
  4042. support = color.support = {},
  4043. // element for support tests
  4044. supportElem = jQuery( "<p>" )[ 0 ],
  4045. // colors = jQuery.Color.names
  4046. colors,
  4047. // local aliases of functions called often
  4048. each = jQuery.each;
  4049. // determine rgba support immediately
  4050. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  4051. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  4052. // define cache name and alpha properties
  4053. // for rgba and hsla spaces
  4054. each( spaces, function( spaceName, space ) {
  4055. space.cache = "_" + spaceName;
  4056. space.props.alpha = {
  4057. idx: 3,
  4058. type: "percent",
  4059. def: 1
  4060. };
  4061. });
  4062. function clamp( value, prop, allowEmpty ) {
  4063. var type = propTypes[ prop.type ] || {};
  4064. if ( value == null ) {
  4065. return (allowEmpty || !prop.def) ? null : prop.def;
  4066. }
  4067. // ~~ is an short way of doing floor for positive numbers
  4068. value = type.floor ? ~~value : parseFloat( value );
  4069. // IE will pass in empty strings as value for alpha,
  4070. // which will hit this case
  4071. if ( isNaN( value ) ) {
  4072. return prop.def;
  4073. }
  4074. if ( type.mod ) {
  4075. // we add mod before modding to make sure that negatives values
  4076. // get converted properly: -10 -> 350
  4077. return (value + type.mod) % type.mod;
  4078. }
  4079. // for now all property types without mod have min and max
  4080. return 0 > value ? 0 : type.max < value ? type.max : value;
  4081. }
  4082. function stringParse( string ) {
  4083. var inst = color(),
  4084. rgba = inst._rgba = [];
  4085. string = string.toLowerCase();
  4086. each( stringParsers, function( i, parser ) {
  4087. var parsed,
  4088. match = parser.re.exec( string ),
  4089. values = match && parser.parse( match ),
  4090. spaceName = parser.space || "rgba";
  4091. if ( values ) {
  4092. parsed = inst[ spaceName ]( values );
  4093. // if this was an rgba parse the assignment might happen twice
  4094. // oh well....
  4095. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  4096. rgba = inst._rgba = parsed._rgba;
  4097. // exit each( stringParsers ) here because we matched
  4098. return false;
  4099. }
  4100. });
  4101. // Found a stringParser that handled it
  4102. if ( rgba.length ) {
  4103. // if this came from a parsed string, force "transparent" when alpha is 0
  4104. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  4105. if ( rgba.join() === "0,0,0,0" ) {
  4106. jQuery.extend( rgba, colors.transparent );
  4107. }
  4108. return inst;
  4109. }
  4110. // named colors
  4111. return colors[ string ];
  4112. }
  4113. color.fn = jQuery.extend( color.prototype, {
  4114. parse: function( red, green, blue, alpha ) {
  4115. if ( red === undefined ) {
  4116. this._rgba = [ null, null, null, null ];
  4117. return this;
  4118. }
  4119. if ( red.jquery || red.nodeType ) {
  4120. red = jQuery( red ).css( green );
  4121. green = undefined;
  4122. }
  4123. var inst = this,
  4124. type = jQuery.type( red ),
  4125. rgba = this._rgba = [];
  4126. // more than 1 argument specified - assume ( red, green, blue, alpha )
  4127. if ( green !== undefined ) {
  4128. red = [ red, green, blue, alpha ];
  4129. type = "array";
  4130. }
  4131. if ( type === "string" ) {
  4132. return this.parse( stringParse( red ) || colors._default );
  4133. }
  4134. if ( type === "array" ) {
  4135. each( spaces.rgba.props, function( key, prop ) {
  4136. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  4137. });
  4138. return this;
  4139. }
  4140. if ( type === "object" ) {
  4141. if ( red instanceof color ) {
  4142. each( spaces, function( spaceName, space ) {
  4143. if ( red[ space.cache ] ) {
  4144. inst[ space.cache ] = red[ space.cache ].slice();
  4145. }
  4146. });
  4147. } else {
  4148. each( spaces, function( spaceName, space ) {
  4149. var cache = space.cache;
  4150. each( space.props, function( key, prop ) {
  4151. // if the cache doesn't exist, and we know how to convert
  4152. if ( !inst[ cache ] && space.to ) {
  4153. // if the value was null, we don't need to copy it
  4154. // if the key was alpha, we don't need to copy it either
  4155. if ( key === "alpha" || red[ key ] == null ) {
  4156. return;
  4157. }
  4158. inst[ cache ] = space.to( inst._rgba );
  4159. }
  4160. // this is the only case where we allow nulls for ALL properties.
  4161. // call clamp with alwaysAllowEmpty
  4162. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  4163. });
  4164. // everything defined but alpha?
  4165. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  4166. // use the default of 1
  4167. inst[ cache ][ 3 ] = 1;
  4168. if ( space.from ) {
  4169. inst._rgba = space.from( inst[ cache ] );
  4170. }
  4171. }
  4172. });
  4173. }
  4174. return this;
  4175. }
  4176. },
  4177. is: function( compare ) {
  4178. var is = color( compare ),
  4179. same = true,
  4180. inst = this;
  4181. each( spaces, function( _, space ) {
  4182. var localCache,
  4183. isCache = is[ space.cache ];
  4184. if (isCache) {
  4185. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  4186. each( space.props, function( _, prop ) {
  4187. if ( isCache[ prop.idx ] != null ) {
  4188. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  4189. return same;
  4190. }
  4191. });
  4192. }
  4193. return same;
  4194. });
  4195. return same;
  4196. },
  4197. _space: function() {
  4198. var used = [],
  4199. inst = this;
  4200. each( spaces, function( spaceName, space ) {
  4201. if ( inst[ space.cache ] ) {
  4202. used.push( spaceName );
  4203. }
  4204. });
  4205. return used.pop();
  4206. },
  4207. transition: function( other, distance ) {
  4208. var end = color( other ),
  4209. spaceName = end._space(),
  4210. space = spaces[ spaceName ],
  4211. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  4212. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  4213. result = start.slice();
  4214. end = end[ space.cache ];
  4215. each( space.props, function( key, prop ) {
  4216. var index = prop.idx,
  4217. startValue = start[ index ],
  4218. endValue = end[ index ],
  4219. type = propTypes[ prop.type ] || {};
  4220. // if null, don't override start value
  4221. if ( endValue === null ) {
  4222. return;
  4223. }
  4224. // if null - use end
  4225. if ( startValue === null ) {
  4226. result[ index ] = endValue;
  4227. } else {
  4228. if ( type.mod ) {
  4229. if ( endValue - startValue > type.mod / 2 ) {
  4230. startValue += type.mod;
  4231. } else if ( startValue - endValue > type.mod / 2 ) {
  4232. startValue -= type.mod;
  4233. }
  4234. }
  4235. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  4236. }
  4237. });
  4238. return this[ spaceName ]( result );
  4239. },
  4240. blend: function( opaque ) {
  4241. // if we are already opaque - return ourself
  4242. if ( this._rgba[ 3 ] === 1 ) {
  4243. return this;
  4244. }
  4245. var rgb = this._rgba.slice(),
  4246. a = rgb.pop(),
  4247. blend = color( opaque )._rgba;
  4248. return color( jQuery.map( rgb, function( v, i ) {
  4249. return ( 1 - a ) * blend[ i ] + a * v;
  4250. }));
  4251. },
  4252. toRgbaString: function() {
  4253. var prefix = "rgba(",
  4254. rgba = jQuery.map( this._rgba, function( v, i ) {
  4255. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  4256. });
  4257. if ( rgba[ 3 ] === 1 ) {
  4258. rgba.pop();
  4259. prefix = "rgb(";
  4260. }
  4261. return prefix + rgba.join() + ")";
  4262. },
  4263. toHslaString: function() {
  4264. var prefix = "hsla(",
  4265. hsla = jQuery.map( this.hsla(), function( v, i ) {
  4266. if ( v == null ) {
  4267. v = i > 2 ? 1 : 0;
  4268. }
  4269. // catch 1 and 2
  4270. if ( i && i < 3 ) {
  4271. v = Math.round( v * 100 ) + "%";
  4272. }
  4273. return v;
  4274. });
  4275. if ( hsla[ 3 ] === 1 ) {
  4276. hsla.pop();
  4277. prefix = "hsl(";
  4278. }
  4279. return prefix + hsla.join() + ")";
  4280. },
  4281. toHexString: function( includeAlpha ) {
  4282. var rgba = this._rgba.slice(),
  4283. alpha = rgba.pop();
  4284. if ( includeAlpha ) {
  4285. rgba.push( ~~( alpha * 255 ) );
  4286. }
  4287. return "#" + jQuery.map( rgba, function( v ) {
  4288. // default to 0 when nulls exist
  4289. v = ( v || 0 ).toString( 16 );
  4290. return v.length === 1 ? "0" + v : v;
  4291. }).join("");
  4292. },
  4293. toString: function() {
  4294. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  4295. }
  4296. });
  4297. color.fn.parse.prototype = color.fn;
  4298. // hsla conversions adapted from:
  4299. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  4300. function hue2rgb( p, q, h ) {
  4301. h = ( h + 1 ) % 1;
  4302. if ( h * 6 < 1 ) {
  4303. return p + (q - p) * h * 6;
  4304. }
  4305. if ( h * 2 < 1) {
  4306. return q;
  4307. }
  4308. if ( h * 3 < 2 ) {
  4309. return p + (q - p) * ((2/3) - h) * 6;
  4310. }
  4311. return p;
  4312. }
  4313. spaces.hsla.to = function ( rgba ) {
  4314. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  4315. return [ null, null, null, rgba[ 3 ] ];
  4316. }
  4317. var r = rgba[ 0 ] / 255,
  4318. g = rgba[ 1 ] / 255,
  4319. b = rgba[ 2 ] / 255,
  4320. a = rgba[ 3 ],
  4321. max = Math.max( r, g, b ),
  4322. min = Math.min( r, g, b ),
  4323. diff = max - min,
  4324. add = max + min,
  4325. l = add * 0.5,
  4326. h, s;
  4327. if ( min === max ) {
  4328. h = 0;
  4329. } else if ( r === max ) {
  4330. h = ( 60 * ( g - b ) / diff ) + 360;
  4331. } else if ( g === max ) {
  4332. h = ( 60 * ( b - r ) / diff ) + 120;
  4333. } else {
  4334. h = ( 60 * ( r - g ) / diff ) + 240;
  4335. }
  4336. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  4337. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  4338. if ( diff === 0 ) {
  4339. s = 0;
  4340. } else if ( l <= 0.5 ) {
  4341. s = diff / add;
  4342. } else {
  4343. s = diff / ( 2 - add );
  4344. }
  4345. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  4346. };
  4347. spaces.hsla.from = function ( hsla ) {
  4348. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  4349. return [ null, null, null, hsla[ 3 ] ];
  4350. }
  4351. var h = hsla[ 0 ] / 360,
  4352. s = hsla[ 1 ],
  4353. l = hsla[ 2 ],
  4354. a = hsla[ 3 ],
  4355. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  4356. p = 2 * l - q;
  4357. return [
  4358. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  4359. Math.round( hue2rgb( p, q, h ) * 255 ),
  4360. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  4361. a
  4362. ];
  4363. };
  4364. each( spaces, function( spaceName, space ) {
  4365. var props = space.props,
  4366. cache = space.cache,
  4367. to = space.to,
  4368. from = space.from;
  4369. // makes rgba() and hsla()
  4370. color.fn[ spaceName ] = function( value ) {
  4371. // generate a cache for this space if it doesn't exist
  4372. if ( to && !this[ cache ] ) {
  4373. this[ cache ] = to( this._rgba );
  4374. }
  4375. if ( value === undefined ) {
  4376. return this[ cache ].slice();
  4377. }
  4378. var ret,
  4379. type = jQuery.type( value ),
  4380. arr = ( type === "array" || type === "object" ) ? value : arguments,
  4381. local = this[ cache ].slice();
  4382. each( props, function( key, prop ) {
  4383. var val = arr[ type === "object" ? key : prop.idx ];
  4384. if ( val == null ) {
  4385. val = local[ prop.idx ];
  4386. }
  4387. local[ prop.idx ] = clamp( val, prop );
  4388. });
  4389. if ( from ) {
  4390. ret = color( from( local ) );
  4391. ret[ cache ] = local;
  4392. return ret;
  4393. } else {
  4394. return color( local );
  4395. }
  4396. };
  4397. // makes red() green() blue() alpha() hue() saturation() lightness()
  4398. each( props, function( key, prop ) {
  4399. // alpha is included in more than one space
  4400. if ( color.fn[ key ] ) {
  4401. return;
  4402. }
  4403. color.fn[ key ] = function( value ) {
  4404. var vtype = jQuery.type( value ),
  4405. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  4406. local = this[ fn ](),
  4407. cur = local[ prop.idx ],
  4408. match;
  4409. if ( vtype === "undefined" ) {
  4410. return cur;
  4411. }
  4412. if ( vtype === "function" ) {
  4413. value = value.call( this, cur );
  4414. vtype = jQuery.type( value );
  4415. }
  4416. if ( value == null && prop.empty ) {
  4417. return this;
  4418. }
  4419. if ( vtype === "string" ) {
  4420. match = rplusequals.exec( value );
  4421. if ( match ) {
  4422. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  4423. }
  4424. }
  4425. local[ prop.idx ] = value;
  4426. return this[ fn ]( local );
  4427. };
  4428. });
  4429. });
  4430. // add cssHook and .fx.step function for each named hook.
  4431. // accept a space separated string of properties
  4432. color.hook = function( hook ) {
  4433. var hooks = hook.split( " " );
  4434. each( hooks, function( i, hook ) {
  4435. jQuery.cssHooks[ hook ] = {
  4436. set: function( elem, value ) {
  4437. var parsed, curElem,
  4438. backgroundColor = "";
  4439. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  4440. value = color( parsed || value );
  4441. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  4442. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  4443. while (
  4444. (backgroundColor === "" || backgroundColor === "transparent") &&
  4445. curElem && curElem.style
  4446. ) {
  4447. try {
  4448. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  4449. curElem = curElem.parentNode;
  4450. } catch ( e ) {
  4451. }
  4452. }
  4453. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  4454. backgroundColor :
  4455. "_default" );
  4456. }
  4457. value = value.toRgbaString();
  4458. }
  4459. try {
  4460. elem.style[ hook ] = value;
  4461. } catch( e ) {
  4462. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  4463. }
  4464. }
  4465. };
  4466. jQuery.fx.step[ hook ] = function( fx ) {
  4467. if ( !fx.colorInit ) {
  4468. fx.start = color( fx.elem, hook );
  4469. fx.end = color( fx.end );
  4470. fx.colorInit = true;
  4471. }
  4472. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  4473. };
  4474. });
  4475. };
  4476. color.hook( stepHooks );
  4477. jQuery.cssHooks.borderColor = {
  4478. expand: function( value ) {
  4479. var expanded = {};
  4480. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  4481. expanded[ "border" + part + "Color" ] = value;
  4482. });
  4483. return expanded;
  4484. }
  4485. };
  4486. // Basic color names only.
  4487. // Usage of any of the other color names requires adding yourself or including
  4488. // jquery.color.svg-names.js.
  4489. colors = jQuery.Color.names = {
  4490. // 4.1. Basic color keywords
  4491. aqua: "#00ffff",
  4492. black: "#000000",
  4493. blue: "#0000ff",
  4494. fuchsia: "#ff00ff",
  4495. gray: "#808080",
  4496. green: "#008000",
  4497. lime: "#00ff00",
  4498. maroon: "#800000",
  4499. navy: "#000080",
  4500. olive: "#808000",
  4501. purple: "#800080",
  4502. red: "#ff0000",
  4503. silver: "#c0c0c0",
  4504. teal: "#008080",
  4505. white: "#ffffff",
  4506. yellow: "#ffff00",
  4507. // 4.2.3. "transparent" color keyword
  4508. transparent: [ null, null, null, 0 ],
  4509. _default: "#ffffff"
  4510. };
  4511. })( jQuery );
  4512. /******************************************************************************/
  4513. /****************************** CLASS ANIMATIONS ******************************/
  4514. /******************************************************************************/
  4515. (function() {
  4516. var classAnimationActions = [ "add", "remove", "toggle" ],
  4517. shorthandStyles = {
  4518. border: 1,
  4519. borderBottom: 1,
  4520. borderColor: 1,
  4521. borderLeft: 1,
  4522. borderRight: 1,
  4523. borderTop: 1,
  4524. borderWidth: 1,
  4525. margin: 1,
  4526. padding: 1
  4527. };
  4528. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  4529. $.fx.step[ prop ] = function( fx ) {
  4530. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  4531. jQuery.style( fx.elem, prop, fx.end );
  4532. fx.setAttr = true;
  4533. }
  4534. };
  4535. });
  4536. function getElementStyles( elem ) {
  4537. var key, len,
  4538. style = elem.ownerDocument.defaultView ?
  4539. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  4540. elem.currentStyle,
  4541. styles = {};
  4542. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  4543. len = style.length;
  4544. while ( len-- ) {
  4545. key = style[ len ];
  4546. if ( typeof style[ key ] === "string" ) {
  4547. styles[ $.camelCase( key ) ] = style[ key ];
  4548. }
  4549. }
  4550. // support: Opera, IE <9
  4551. } else {
  4552. for ( key in style ) {
  4553. if ( typeof style[ key ] === "string" ) {
  4554. styles[ key ] = style[ key ];
  4555. }
  4556. }
  4557. }
  4558. return styles;
  4559. }
  4560. function styleDifference( oldStyle, newStyle ) {
  4561. var diff = {},
  4562. name, value;
  4563. for ( name in newStyle ) {
  4564. value = newStyle[ name ];
  4565. if ( oldStyle[ name ] !== value ) {
  4566. if ( !shorthandStyles[ name ] ) {
  4567. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  4568. diff[ name ] = value;
  4569. }
  4570. }
  4571. }
  4572. }
  4573. return diff;
  4574. }
  4575. // support: jQuery <1.8
  4576. if ( !$.fn.addBack ) {
  4577. $.fn.addBack = function( selector ) {
  4578. return this.add( selector == null ?
  4579. this.prevObject : this.prevObject.filter( selector )
  4580. );
  4581. };
  4582. }
  4583. $.effects.animateClass = function( value, duration, easing, callback ) {
  4584. var o = $.speed( duration, easing, callback );
  4585. return this.queue( function() {
  4586. var animated = $( this ),
  4587. baseClass = animated.attr( "class" ) || "",
  4588. applyClassChange,
  4589. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  4590. // map the animated objects to store the original styles.
  4591. allAnimations = allAnimations.map(function() {
  4592. var el = $( this );
  4593. return {
  4594. el: el,
  4595. start: getElementStyles( this )
  4596. };
  4597. });
  4598. // apply class change
  4599. applyClassChange = function() {
  4600. $.each( classAnimationActions, function(i, action) {
  4601. if ( value[ action ] ) {
  4602. animated[ action + "Class" ]( value[ action ] );
  4603. }
  4604. });
  4605. };
  4606. applyClassChange();
  4607. // map all animated objects again - calculate new styles and diff
  4608. allAnimations = allAnimations.map(function() {
  4609. this.end = getElementStyles( this.el[ 0 ] );
  4610. this.diff = styleDifference( this.start, this.end );
  4611. return this;
  4612. });
  4613. // apply original class
  4614. animated.attr( "class", baseClass );
  4615. // map all animated objects again - this time collecting a promise
  4616. allAnimations = allAnimations.map(function() {
  4617. var styleInfo = this,
  4618. dfd = $.Deferred(),
  4619. opts = $.extend({}, o, {
  4620. queue: false,
  4621. complete: function() {
  4622. dfd.resolve( styleInfo );
  4623. }
  4624. });
  4625. this.el.animate( this.diff, opts );
  4626. return dfd.promise();
  4627. });
  4628. // once all animations have completed:
  4629. $.when.apply( $, allAnimations.get() ).done(function() {
  4630. // set the final class
  4631. applyClassChange();
  4632. // for each animated element,
  4633. // clear all css properties that were animated
  4634. $.each( arguments, function() {
  4635. var el = this.el;
  4636. $.each( this.diff, function(key) {
  4637. el.css( key, "" );
  4638. });
  4639. });
  4640. // this is guarnteed to be there if you use jQuery.speed()
  4641. // it also handles dequeuing the next anim...
  4642. o.complete.call( animated[ 0 ] );
  4643. });
  4644. });
  4645. };
  4646. $.fn.extend({
  4647. addClass: (function( orig ) {
  4648. return function( classNames, speed, easing, callback ) {
  4649. return speed ?
  4650. $.effects.animateClass.call( this,
  4651. { add: classNames }, speed, easing, callback ) :
  4652. orig.apply( this, arguments );
  4653. };
  4654. })( $.fn.addClass ),
  4655. removeClass: (function( orig ) {
  4656. return function( classNames, speed, easing, callback ) {
  4657. return arguments.length > 1 ?
  4658. $.effects.animateClass.call( this,
  4659. { remove: classNames }, speed, easing, callback ) :
  4660. orig.apply( this, arguments );
  4661. };
  4662. })( $.fn.removeClass ),
  4663. toggleClass: (function( orig ) {
  4664. return function( classNames, force, speed, easing, callback ) {
  4665. if ( typeof force === "boolean" || force === undefined ) {
  4666. if ( !speed ) {
  4667. // without speed parameter
  4668. return orig.apply( this, arguments );
  4669. } else {
  4670. return $.effects.animateClass.call( this,
  4671. (force ? { add: classNames } : { remove: classNames }),
  4672. speed, easing, callback );
  4673. }
  4674. } else {
  4675. // without force parameter
  4676. return $.effects.animateClass.call( this,
  4677. { toggle: classNames }, force, speed, easing );
  4678. }
  4679. };
  4680. })( $.fn.toggleClass ),
  4681. switchClass: function( remove, add, speed, easing, callback) {
  4682. return $.effects.animateClass.call( this, {
  4683. add: add,
  4684. remove: remove
  4685. }, speed, easing, callback );
  4686. }
  4687. });
  4688. })();
  4689. /******************************************************************************/
  4690. /*********************************** EFFECTS **********************************/
  4691. /******************************************************************************/
  4692. (function() {
  4693. $.extend( $.effects, {
  4694. version: "1.10.3",
  4695. // Saves a set of properties in a data storage
  4696. save: function( element, set ) {
  4697. for( var i=0; i < set.length; i++ ) {
  4698. if ( set[ i ] !== null ) {
  4699. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  4700. }
  4701. }
  4702. },
  4703. // Restores a set of previously saved properties from a data storage
  4704. restore: function( element, set ) {
  4705. var val, i;
  4706. for( i=0; i < set.length; i++ ) {
  4707. if ( set[ i ] !== null ) {
  4708. val = element.data( dataSpace + set[ i ] );
  4709. // support: jQuery 1.6.2
  4710. // http://bugs.jquery.com/ticket/9917
  4711. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  4712. // We can't differentiate between "" and 0 here, so we just assume
  4713. // empty string since it's likely to be a more common value...
  4714. if ( val === undefined ) {
  4715. val = "";
  4716. }
  4717. element.css( set[ i ], val );
  4718. }
  4719. }
  4720. },
  4721. setMode: function( el, mode ) {
  4722. if (mode === "toggle") {
  4723. mode = el.is( ":hidden" ) ? "show" : "hide";
  4724. }
  4725. return mode;
  4726. },
  4727. // Translates a [top,left] array into a baseline value
  4728. // this should be a little more flexible in the future to handle a string & hash
  4729. getBaseline: function( origin, original ) {
  4730. var y, x;
  4731. switch ( origin[ 0 ] ) {
  4732. case "top": y = 0; break;
  4733. case "middle": y = 0.5; break;
  4734. case "bottom": y = 1; break;
  4735. default: y = origin[ 0 ] / original.height;
  4736. }
  4737. switch ( origin[ 1 ] ) {
  4738. case "left": x = 0; break;
  4739. case "center": x = 0.5; break;
  4740. case "right": x = 1; break;
  4741. default: x = origin[ 1 ] / original.width;
  4742. }
  4743. return {
  4744. x: x,
  4745. y: y
  4746. };
  4747. },
  4748. // Wraps the element around a wrapper that copies position properties
  4749. createWrapper: function( element ) {
  4750. // if the element is already wrapped, return it
  4751. if ( element.parent().is( ".ui-effects-wrapper" )) {
  4752. return element.parent();
  4753. }
  4754. // wrap the element
  4755. var props = {
  4756. width: element.outerWidth(true),
  4757. height: element.outerHeight(true),
  4758. "float": element.css( "float" )
  4759. },
  4760. wrapper = $( "<div></div>" )
  4761. .addClass( "ui-effects-wrapper" )
  4762. .css({
  4763. fontSize: "100%",
  4764. background: "transparent",
  4765. border: "none",
  4766. margin: 0,
  4767. padding: 0
  4768. }),
  4769. // Store the size in case width/height are defined in % - Fixes #5245
  4770. size = {
  4771. width: element.width(),
  4772. height: element.height()
  4773. },
  4774. active = document.activeElement;
  4775. // support: Firefox
  4776. // Firefox incorrectly exposes anonymous content
  4777. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  4778. try {
  4779. active.id;
  4780. } catch( e ) {
  4781. active = document.body;
  4782. }
  4783. element.wrap( wrapper );
  4784. // Fixes #7595 - Elements lose focus when wrapped.
  4785. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  4786. $( active ).focus();
  4787. }
  4788. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  4789. // transfer positioning properties to the wrapper
  4790. if ( element.css( "position" ) === "static" ) {
  4791. wrapper.css({ position: "relative" });
  4792. element.css({ position: "relative" });
  4793. } else {
  4794. $.extend( props, {
  4795. position: element.css( "position" ),
  4796. zIndex: element.css( "z-index" )
  4797. });
  4798. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  4799. props[ pos ] = element.css( pos );
  4800. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  4801. props[ pos ] = "auto";
  4802. }
  4803. });
  4804. element.css({
  4805. position: "relative",
  4806. top: 0,
  4807. left: 0,
  4808. right: "auto",
  4809. bottom: "auto"
  4810. });
  4811. }
  4812. element.css(size);
  4813. return wrapper.css( props ).show();
  4814. },
  4815. removeWrapper: function( element ) {
  4816. var active = document.activeElement;
  4817. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  4818. element.parent().replaceWith( element );
  4819. // Fixes #7595 - Elements lose focus when wrapped.
  4820. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  4821. $( active ).focus();
  4822. }
  4823. }
  4824. return element;
  4825. },
  4826. setTransition: function( element, list, factor, value ) {
  4827. value = value || {};
  4828. $.each( list, function( i, x ) {
  4829. var unit = element.cssUnit( x );
  4830. if ( unit[ 0 ] > 0 ) {
  4831. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  4832. }
  4833. });
  4834. return value;
  4835. }
  4836. });
  4837. // return an effect options object for the given parameters:
  4838. function _normalizeArguments( effect, options, speed, callback ) {
  4839. // allow passing all options as the first parameter
  4840. if ( $.isPlainObject( effect ) ) {
  4841. options = effect;
  4842. effect = effect.effect;
  4843. }
  4844. // convert to an object
  4845. effect = { effect: effect };
  4846. // catch (effect, null, ...)
  4847. if ( options == null ) {
  4848. options = {};
  4849. }
  4850. // catch (effect, callback)
  4851. if ( $.isFunction( options ) ) {
  4852. callback = options;
  4853. speed = null;
  4854. options = {};
  4855. }
  4856. // catch (effect, speed, ?)
  4857. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  4858. callback = speed;
  4859. speed = options;
  4860. options = {};
  4861. }
  4862. // catch (effect, options, callback)
  4863. if ( $.isFunction( speed ) ) {
  4864. callback = speed;
  4865. speed = null;
  4866. }
  4867. // add options to effect
  4868. if ( options ) {
  4869. $.extend( effect, options );
  4870. }
  4871. speed = speed || options.duration;
  4872. effect.duration = $.fx.off ? 0 :
  4873. typeof speed === "number" ? speed :
  4874. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  4875. $.fx.speeds._default;
  4876. effect.complete = callback || options.complete;
  4877. return effect;
  4878. }
  4879. function standardAnimationOption( option ) {
  4880. // Valid standard speeds (nothing, number, named speed)
  4881. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  4882. return true;
  4883. }
  4884. // Invalid strings - treat as "normal" speed
  4885. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  4886. return true;
  4887. }
  4888. // Complete callback
  4889. if ( $.isFunction( option ) ) {
  4890. return true;
  4891. }
  4892. // Options hash (but not naming an effect)
  4893. if ( typeof option === "object" && !option.effect ) {
  4894. return true;
  4895. }
  4896. // Didn't match any standard API
  4897. return false;
  4898. }
  4899. $.fn.extend({
  4900. effect: function( /* effect, options, speed, callback */ ) {
  4901. var args = _normalizeArguments.apply( this, arguments ),
  4902. mode = args.mode,
  4903. queue = args.queue,
  4904. effectMethod = $.effects.effect[ args.effect ];
  4905. if ( $.fx.off || !effectMethod ) {
  4906. // delegate to the original method (e.g., .show()) if possible
  4907. if ( mode ) {
  4908. return this[ mode ]( args.duration, args.complete );
  4909. } else {
  4910. return this.each( function() {
  4911. if ( args.complete ) {
  4912. args.complete.call( this );
  4913. }
  4914. });
  4915. }
  4916. }
  4917. function run( next ) {
  4918. var elem = $( this ),
  4919. complete = args.complete,
  4920. mode = args.mode;
  4921. function done() {
  4922. if ( $.isFunction( complete ) ) {
  4923. complete.call( elem[0] );
  4924. }
  4925. if ( $.isFunction( next ) ) {
  4926. next();
  4927. }
  4928. }
  4929. // If the element already has the correct final state, delegate to
  4930. // the core methods so the internal tracking of "olddisplay" works.
  4931. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  4932. elem[ mode ]();
  4933. done();
  4934. } else {
  4935. effectMethod.call( elem[0], args, done );
  4936. }
  4937. }
  4938. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  4939. },
  4940. show: (function( orig ) {
  4941. return function( option ) {
  4942. if ( standardAnimationOption( option ) ) {
  4943. return orig.apply( this, arguments );
  4944. } else {
  4945. var args = _normalizeArguments.apply( this, arguments );
  4946. args.mode = "show";
  4947. return this.effect.call( this, args );
  4948. }
  4949. };
  4950. })( $.fn.show ),
  4951. hide: (function( orig ) {
  4952. return function( option ) {
  4953. if ( standardAnimationOption( option ) ) {
  4954. return orig.apply( this, arguments );
  4955. } else {
  4956. var args = _normalizeArguments.apply( this, arguments );
  4957. args.mode = "hide";
  4958. return this.effect.call( this, args );
  4959. }
  4960. };
  4961. })( $.fn.hide ),
  4962. toggle: (function( orig ) {
  4963. return function( option ) {
  4964. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  4965. return orig.apply( this, arguments );
  4966. } else {
  4967. var args = _normalizeArguments.apply( this, arguments );
  4968. args.mode = "toggle";
  4969. return this.effect.call( this, args );
  4970. }
  4971. };
  4972. })( $.fn.toggle ),
  4973. // helper functions
  4974. cssUnit: function(key) {
  4975. var style = this.css( key ),
  4976. val = [];
  4977. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  4978. if ( style.indexOf( unit ) > 0 ) {
  4979. val = [ parseFloat( style ), unit ];
  4980. }
  4981. });
  4982. return val;
  4983. }
  4984. });
  4985. })();
  4986. /******************************************************************************/
  4987. /*********************************** EASING ***********************************/
  4988. /******************************************************************************/
  4989. (function() {
  4990. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  4991. var baseEasings = {};
  4992. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  4993. baseEasings[ name ] = function( p ) {
  4994. return Math.pow( p, i + 2 );
  4995. };
  4996. });
  4997. $.extend( baseEasings, {
  4998. Sine: function ( p ) {
  4999. return 1 - Math.cos( p * Math.PI / 2 );
  5000. },
  5001. Circ: function ( p ) {
  5002. return 1 - Math.sqrt( 1 - p * p );
  5003. },
  5004. Elastic: function( p ) {
  5005. return p === 0 || p === 1 ? p :
  5006. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  5007. },
  5008. Back: function( p ) {
  5009. return p * p * ( 3 * p - 2 );
  5010. },
  5011. Bounce: function ( p ) {
  5012. var pow2,
  5013. bounce = 4;
  5014. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  5015. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  5016. }
  5017. });
  5018. $.each( baseEasings, function( name, easeIn ) {
  5019. $.easing[ "easeIn" + name ] = easeIn;
  5020. $.easing[ "easeOut" + name ] = function( p ) {
  5021. return 1 - easeIn( 1 - p );
  5022. };
  5023. $.easing[ "easeInOut" + name ] = function( p ) {
  5024. return p < 0.5 ?
  5025. easeIn( p * 2 ) / 2 :
  5026. 1 - easeIn( p * -2 + 2 ) / 2;
  5027. };
  5028. });
  5029. })();
  5030. })(jQuery);
  5031. (function( $, undefined ) {
  5032. var uid = 0,
  5033. hideProps = {},
  5034. showProps = {};
  5035. hideProps.height = hideProps.paddingTop = hideProps.paddingBottom =
  5036. hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide";
  5037. showProps.height = showProps.paddingTop = showProps.paddingBottom =
  5038. showProps.borderTopWidth = showProps.borderBottomWidth = "show";
  5039. $.widget( "ui.accordion", {
  5040. version: "1.10.3",
  5041. options: {
  5042. active: 0,
  5043. animate: {},
  5044. collapsible: false,
  5045. event: "click",
  5046. header: "> li > :first-child,> :not(li):even",
  5047. heightStyle: "auto",
  5048. icons: {
  5049. activeHeader: "ui-icon-triangle-1-s",
  5050. header: "ui-icon-triangle-1-e"
  5051. },
  5052. // callbacks
  5053. activate: null,
  5054. beforeActivate: null
  5055. },
  5056. _create: function() {
  5057. var options = this.options;
  5058. this.prevShow = this.prevHide = $();
  5059. this.element.addClass( "ui-accordion ui-widget ui-helper-reset" )
  5060. // ARIA
  5061. .attr( "role", "tablist" );
  5062. // don't allow collapsible: false and active: false / null
  5063. if ( !options.collapsible && (options.active === false || options.active == null) ) {
  5064. options.active = 0;
  5065. }
  5066. this._processPanels();
  5067. // handle negative values
  5068. if ( options.active < 0 ) {
  5069. options.active += this.headers.length;
  5070. }
  5071. this._refresh();
  5072. },
  5073. _getCreateEventData: function() {
  5074. return {
  5075. header: this.active,
  5076. panel: !this.active.length ? $() : this.active.next(),
  5077. content: !this.active.length ? $() : this.active.next()
  5078. };
  5079. },
  5080. _createIcons: function() {
  5081. var icons = this.options.icons;
  5082. if ( icons ) {
  5083. $( "<span>" )
  5084. .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
  5085. .prependTo( this.headers );
  5086. this.active.children( ".ui-accordion-header-icon" )
  5087. .removeClass( icons.header )
  5088. .addClass( icons.activeHeader );
  5089. this.headers.addClass( "ui-accordion-icons" );
  5090. }
  5091. },
  5092. _destroyIcons: function() {
  5093. this.headers
  5094. .removeClass( "ui-accordion-icons" )
  5095. .children( ".ui-accordion-header-icon" )
  5096. .remove();
  5097. },
  5098. _destroy: function() {
  5099. var contents;
  5100. // clean up main element
  5101. this.element
  5102. .removeClass( "ui-accordion ui-widget ui-helper-reset" )
  5103. .removeAttr( "role" );
  5104. // clean up headers
  5105. this.headers
  5106. .removeClass( "ui-accordion-header ui-accordion-header-active ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
  5107. .removeAttr( "role" )
  5108. .removeAttr( "aria-selected" )
  5109. .removeAttr( "aria-controls" )
  5110. .removeAttr( "tabIndex" )
  5111. .each(function() {
  5112. if ( /^ui-accordion/.test( this.id ) ) {
  5113. this.removeAttribute( "id" );
  5114. }
  5115. });
  5116. this._destroyIcons();
  5117. // clean up content panels
  5118. contents = this.headers.next()
  5119. .css( "display", "" )
  5120. .removeAttr( "role" )
  5121. .removeAttr( "aria-expanded" )
  5122. .removeAttr( "aria-hidden" )
  5123. .removeAttr( "aria-labelledby" )
  5124. .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled" )
  5125. .each(function() {
  5126. if ( /^ui-accordion/.test( this.id ) ) {
  5127. this.removeAttribute( "id" );
  5128. }
  5129. });
  5130. if ( this.options.heightStyle !== "content" ) {
  5131. contents.css( "height", "" );
  5132. }
  5133. },
  5134. _setOption: function( key, value ) {
  5135. if ( key === "active" ) {
  5136. // _activate() will handle invalid values and update this.options
  5137. this._activate( value );
  5138. return;
  5139. }
  5140. if ( key === "event" ) {
  5141. if ( this.options.event ) {
  5142. this._off( this.headers, this.options.event );
  5143. }
  5144. this._setupEvents( value );
  5145. }
  5146. this._super( key, value );
  5147. // setting collapsible: false while collapsed; open first panel
  5148. if ( key === "collapsible" && !value && this.options.active === false ) {
  5149. this._activate( 0 );
  5150. }
  5151. if ( key === "icons" ) {
  5152. this._destroyIcons();
  5153. if ( value ) {
  5154. this._createIcons();
  5155. }
  5156. }
  5157. // #5332 - opacity doesn't cascade to positioned elements in IE
  5158. // so we need to add the disabled class to the headers and panels
  5159. if ( key === "disabled" ) {
  5160. this.headers.add( this.headers.next() )
  5161. .toggleClass( "ui-state-disabled", !!value );
  5162. }
  5163. },
  5164. _keydown: function( event ) {
  5165. /*jshint maxcomplexity:15*/
  5166. if ( event.altKey || event.ctrlKey ) {
  5167. return;
  5168. }
  5169. var keyCode = $.ui.keyCode,
  5170. length = this.headers.length,
  5171. currentIndex = this.headers.index( event.target ),
  5172. toFocus = false;
  5173. switch ( event.keyCode ) {
  5174. case keyCode.RIGHT:
  5175. case keyCode.DOWN:
  5176. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  5177. break;
  5178. case keyCode.LEFT:
  5179. case keyCode.UP:
  5180. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  5181. break;
  5182. case keyCode.SPACE:
  5183. case keyCode.ENTER:
  5184. this._eventHandler( event );
  5185. break;
  5186. case keyCode.HOME:
  5187. toFocus = this.headers[ 0 ];
  5188. break;
  5189. case keyCode.END:
  5190. toFocus = this.headers[ length - 1 ];
  5191. break;
  5192. }
  5193. if ( toFocus ) {
  5194. $( event.target ).attr( "tabIndex", -1 );
  5195. $( toFocus ).attr( "tabIndex", 0 );
  5196. toFocus.focus();
  5197. event.preventDefault();
  5198. }
  5199. },
  5200. _panelKeyDown : function( event ) {
  5201. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  5202. $( event.currentTarget ).prev().focus();
  5203. }
  5204. },
  5205. refresh: function() {
  5206. var options = this.options;
  5207. this._processPanels();
  5208. // was collapsed or no panel
  5209. if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) {
  5210. options.active = false;
  5211. this.active = $();
  5212. // active false only when collapsible is true
  5213. } else if ( options.active === false ) {
  5214. this._activate( 0 );
  5215. // was active, but active panel is gone
  5216. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  5217. // all remaining panel are disabled
  5218. if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) {
  5219. options.active = false;
  5220. this.active = $();
  5221. // activate previous panel
  5222. } else {
  5223. this._activate( Math.max( 0, options.active - 1 ) );
  5224. }
  5225. // was active, active panel still exists
  5226. } else {
  5227. // make sure active index is correct
  5228. options.active = this.headers.index( this.active );
  5229. }
  5230. this._destroyIcons();
  5231. this._refresh();
  5232. },
  5233. _processPanels: function() {
  5234. this.headers = this.element.find( this.options.header )
  5235. .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" );
  5236. this.headers.next()
  5237. .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
  5238. .filter(":not(.ui-accordion-content-active)")
  5239. .hide();
  5240. },
  5241. _refresh: function() {
  5242. var maxHeight,
  5243. options = this.options,
  5244. heightStyle = options.heightStyle,
  5245. parent = this.element.parent(),
  5246. accordionId = this.accordionId = "ui-accordion-" +
  5247. (this.element.attr( "id" ) || ++uid);
  5248. this.active = this._findActive( options.active )
  5249. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
  5250. .removeClass( "ui-corner-all" );
  5251. this.active.next()
  5252. .addClass( "ui-accordion-content-active" )
  5253. .show();
  5254. this.headers
  5255. .attr( "role", "tab" )
  5256. .each(function( i ) {
  5257. var header = $( this ),
  5258. headerId = header.attr( "id" ),
  5259. panel = header.next(),
  5260. panelId = panel.attr( "id" );
  5261. if ( !headerId ) {
  5262. headerId = accordionId + "-header-" + i;
  5263. header.attr( "id", headerId );
  5264. }
  5265. if ( !panelId ) {
  5266. panelId = accordionId + "-panel-" + i;
  5267. panel.attr( "id", panelId );
  5268. }
  5269. header.attr( "aria-controls", panelId );
  5270. panel.attr( "aria-labelledby", headerId );
  5271. })
  5272. .next()
  5273. .attr( "role", "tabpanel" );
  5274. this.headers
  5275. .not( this.active )
  5276. .attr({
  5277. "aria-selected": "false",
  5278. tabIndex: -1
  5279. })
  5280. .next()
  5281. .attr({
  5282. "aria-expanded": "false",
  5283. "aria-hidden": "true"
  5284. })
  5285. .hide();
  5286. // make sure at least one header is in the tab order
  5287. if ( !this.active.length ) {
  5288. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  5289. } else {
  5290. this.active.attr({
  5291. "aria-selected": "true",
  5292. tabIndex: 0
  5293. })
  5294. .next()
  5295. .attr({
  5296. "aria-expanded": "true",
  5297. "aria-hidden": "false"
  5298. });
  5299. }
  5300. this._createIcons();
  5301. this._setupEvents( options.event );
  5302. if ( heightStyle === "fill" ) {
  5303. maxHeight = parent.height();
  5304. this.element.siblings( ":visible" ).each(function() {
  5305. var elem = $( this ),
  5306. position = elem.css( "position" );
  5307. if ( position === "absolute" || position === "fixed" ) {
  5308. return;
  5309. }
  5310. maxHeight -= elem.outerHeight( true );
  5311. });
  5312. this.headers.each(function() {
  5313. maxHeight -= $( this ).outerHeight( true );
  5314. });
  5315. this.headers.next()
  5316. .each(function() {
  5317. $( this ).height( Math.max( 0, maxHeight -
  5318. $( this ).innerHeight() + $( this ).height() ) );
  5319. })
  5320. .css( "overflow", "auto" );
  5321. } else if ( heightStyle === "auto" ) {
  5322. maxHeight = 0;
  5323. this.headers.next()
  5324. .each(function() {
  5325. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  5326. })
  5327. .height( maxHeight );
  5328. }
  5329. },
  5330. _activate: function( index ) {
  5331. var active = this._findActive( index )[ 0 ];
  5332. // trying to activate the already active panel
  5333. if ( active === this.active[ 0 ] ) {
  5334. return;
  5335. }
  5336. // trying to collapse, simulate a click on the currently active header
  5337. active = active || this.active[ 0 ];
  5338. this._eventHandler({
  5339. target: active,
  5340. currentTarget: active,
  5341. preventDefault: $.noop
  5342. });
  5343. },
  5344. _findActive: function( selector ) {
  5345. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  5346. },
  5347. _setupEvents: function( event ) {
  5348. var events = {
  5349. keydown: "_keydown"
  5350. };
  5351. if ( event ) {
  5352. $.each( event.split(" "), function( index, eventName ) {
  5353. events[ eventName ] = "_eventHandler";
  5354. });
  5355. }
  5356. this._off( this.headers.add( this.headers.next() ) );
  5357. this._on( this.headers, events );
  5358. this._on( this.headers.next(), { keydown: "_panelKeyDown" });
  5359. this._hoverable( this.headers );
  5360. this._focusable( this.headers );
  5361. },
  5362. _eventHandler: function( event ) {
  5363. var options = this.options,
  5364. active = this.active,
  5365. clicked = $( event.currentTarget ),
  5366. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  5367. collapsing = clickedIsActive && options.collapsible,
  5368. toShow = collapsing ? $() : clicked.next(),
  5369. toHide = active.next(),
  5370. eventData = {
  5371. oldHeader: active,
  5372. oldPanel: toHide,
  5373. newHeader: collapsing ? $() : clicked,
  5374. newPanel: toShow
  5375. };
  5376. event.preventDefault();
  5377. if (
  5378. // click on active header, but not collapsible
  5379. ( clickedIsActive && !options.collapsible ) ||
  5380. // allow canceling activation
  5381. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  5382. return;
  5383. }
  5384. options.active = collapsing ? false : this.headers.index( clicked );
  5385. // when the call to ._toggle() comes after the class changes
  5386. // it causes a very odd bug in IE 8 (see #6720)
  5387. this.active = clickedIsActive ? $() : clicked;
  5388. this._toggle( eventData );
  5389. // switch classes
  5390. // corner classes on the previously active header stay after the animation
  5391. active.removeClass( "ui-accordion-header-active ui-state-active" );
  5392. if ( options.icons ) {
  5393. active.children( ".ui-accordion-header-icon" )
  5394. .removeClass( options.icons.activeHeader )
  5395. .addClass( options.icons.header );
  5396. }
  5397. if ( !clickedIsActive ) {
  5398. clicked
  5399. .removeClass( "ui-corner-all" )
  5400. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
  5401. if ( options.icons ) {
  5402. clicked.children( ".ui-accordion-header-icon" )
  5403. .removeClass( options.icons.header )
  5404. .addClass( options.icons.activeHeader );
  5405. }
  5406. clicked
  5407. .next()
  5408. .addClass( "ui-accordion-content-active" );
  5409. }
  5410. },
  5411. _toggle: function( data ) {
  5412. var toShow = data.newPanel,
  5413. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  5414. // handle activating a panel during the animation for another activation
  5415. this.prevShow.add( this.prevHide ).stop( true, true );
  5416. this.prevShow = toShow;
  5417. this.prevHide = toHide;
  5418. if ( this.options.animate ) {
  5419. this._animate( toShow, toHide, data );
  5420. } else {
  5421. toHide.hide();
  5422. toShow.show();
  5423. this._toggleComplete( data );
  5424. }
  5425. toHide.attr({
  5426. "aria-expanded": "false",
  5427. "aria-hidden": "true"
  5428. });
  5429. toHide.prev().attr( "aria-selected", "false" );
  5430. // if we're switching panels, remove the old header from the tab order
  5431. // if we're opening from collapsed state, remove the previous header from the tab order
  5432. // if we're collapsing, then keep the collapsing header in the tab order
  5433. if ( toShow.length && toHide.length ) {
  5434. toHide.prev().attr( "tabIndex", -1 );
  5435. } else if ( toShow.length ) {
  5436. this.headers.filter(function() {
  5437. return $( this ).attr( "tabIndex" ) === 0;
  5438. })
  5439. .attr( "tabIndex", -1 );
  5440. }
  5441. toShow
  5442. .attr({
  5443. "aria-expanded": "true",
  5444. "aria-hidden": "false"
  5445. })
  5446. .prev()
  5447. .attr({
  5448. "aria-selected": "true",
  5449. tabIndex: 0
  5450. });
  5451. },
  5452. _animate: function( toShow, toHide, data ) {
  5453. var total, easing, duration,
  5454. that = this,
  5455. adjust = 0,
  5456. down = toShow.length &&
  5457. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  5458. animate = this.options.animate || {},
  5459. options = down && animate.down || animate,
  5460. complete = function() {
  5461. that._toggleComplete( data );
  5462. };
  5463. if ( typeof options === "number" ) {
  5464. duration = options;
  5465. }
  5466. if ( typeof options === "string" ) {
  5467. easing = options;
  5468. }
  5469. // fall back from options to animation in case of partial down settings
  5470. easing = easing || options.easing || animate.easing;
  5471. duration = duration || options.duration || animate.duration;
  5472. if ( !toHide.length ) {
  5473. return toShow.animate( showProps, duration, easing, complete );
  5474. }
  5475. if ( !toShow.length ) {
  5476. return toHide.animate( hideProps, duration, easing, complete );
  5477. }
  5478. total = toShow.show().outerHeight();
  5479. toHide.animate( hideProps, {
  5480. duration: duration,
  5481. easing: easing,
  5482. step: function( now, fx ) {
  5483. fx.now = Math.round( now );
  5484. }
  5485. });
  5486. toShow
  5487. .hide()
  5488. .animate( showProps, {
  5489. duration: duration,
  5490. easing: easing,
  5491. complete: complete,
  5492. step: function( now, fx ) {
  5493. fx.now = Math.round( now );
  5494. if ( fx.prop !== "height" ) {
  5495. adjust += fx.now;
  5496. } else if ( that.options.heightStyle !== "content" ) {
  5497. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  5498. adjust = 0;
  5499. }
  5500. }
  5501. });
  5502. },
  5503. _toggleComplete: function( data ) {
  5504. var toHide = data.oldPanel;
  5505. toHide
  5506. .removeClass( "ui-accordion-content-active" )
  5507. .prev()
  5508. .removeClass( "ui-corner-top" )
  5509. .addClass( "ui-corner-all" );
  5510. // Work around for rendering bug in IE (#5421)
  5511. if ( toHide.length ) {
  5512. toHide.parent()[0].className = toHide.parent()[0].className;
  5513. }
  5514. this._trigger( "activate", null, data );
  5515. }
  5516. });
  5517. })( jQuery );
  5518. (function( $, undefined ) {
  5519. // used to prevent race conditions with remote data sources
  5520. var requestIndex = 0;
  5521. $.widget( "ui.autocomplete", {
  5522. version: "1.10.3",
  5523. defaultElement: "<input>",
  5524. options: {
  5525. appendTo: null,
  5526. autoFocus: false,
  5527. delay: 300,
  5528. minLength: 1,
  5529. position: {
  5530. my: "left top",
  5531. at: "left bottom",
  5532. collision: "none"
  5533. },
  5534. source: null,
  5535. // callbacks
  5536. change: null,
  5537. close: null,
  5538. focus: null,
  5539. open: null,
  5540. response: null,
  5541. search: null,
  5542. select: null
  5543. },
  5544. pending: 0,
  5545. _create: function() {
  5546. // Some browsers only repeat keydown events, not keypress events,
  5547. // so we use the suppressKeyPress flag to determine if we've already
  5548. // handled the keydown event. #7269
  5549. // Unfortunately the code for & in keypress is the same as the up arrow,
  5550. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  5551. // events when we know the keydown event was used to modify the
  5552. // search term. #7799
  5553. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  5554. nodeName = this.element[0].nodeName.toLowerCase(),
  5555. isTextarea = nodeName === "textarea",
  5556. isInput = nodeName === "input";
  5557. this.isMultiLine =
  5558. // Textareas are always multi-line
  5559. isTextarea ? true :
  5560. // Inputs are always single-line, even if inside a contentEditable element
  5561. // IE also treats inputs as contentEditable
  5562. isInput ? false :
  5563. // All other element types are determined by whether or not they're contentEditable
  5564. this.element.prop( "isContentEditable" );
  5565. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  5566. this.isNewMenu = true;
  5567. this.element
  5568. .addClass( "ui-autocomplete-input" )
  5569. .attr( "autocomplete", "off" );
  5570. this._on( this.element, {
  5571. keydown: function( event ) {
  5572. /*jshint maxcomplexity:15*/
  5573. if ( this.element.prop( "readOnly" ) ) {
  5574. suppressKeyPress = true;
  5575. suppressInput = true;
  5576. suppressKeyPressRepeat = true;
  5577. return;
  5578. }
  5579. suppressKeyPress = false;
  5580. suppressInput = false;
  5581. suppressKeyPressRepeat = false;
  5582. var keyCode = $.ui.keyCode;
  5583. switch( event.keyCode ) {
  5584. case keyCode.PAGE_UP:
  5585. suppressKeyPress = true;
  5586. this._move( "previousPage", event );
  5587. break;
  5588. case keyCode.PAGE_DOWN:
  5589. suppressKeyPress = true;
  5590. this._move( "nextPage", event );
  5591. break;
  5592. case keyCode.UP:
  5593. suppressKeyPress = true;
  5594. this._keyEvent( "previous", event );
  5595. break;
  5596. case keyCode.DOWN:
  5597. suppressKeyPress = true;
  5598. this._keyEvent( "next", event );
  5599. break;
  5600. case keyCode.ENTER:
  5601. case keyCode.NUMPAD_ENTER:
  5602. // when menu is open and has focus
  5603. if ( this.menu.active ) {
  5604. // #6055 - Opera still allows the keypress to occur
  5605. // which causes forms to submit
  5606. suppressKeyPress = true;
  5607. event.preventDefault();
  5608. this.menu.select( event );
  5609. }
  5610. break;
  5611. case keyCode.TAB:
  5612. if ( this.menu.active ) {
  5613. this.menu.select( event );
  5614. }
  5615. break;
  5616. case keyCode.ESCAPE:
  5617. if ( this.menu.element.is( ":visible" ) ) {
  5618. this._value( this.term );
  5619. this.close( event );
  5620. // Different browsers have different default behavior for escape
  5621. // Single press can mean undo or clear
  5622. // Double press in IE means clear the whole form
  5623. event.preventDefault();
  5624. }
  5625. break;
  5626. default:
  5627. suppressKeyPressRepeat = true;
  5628. // search timeout should be triggered before the input value is changed
  5629. this._searchTimeout( event );
  5630. break;
  5631. }
  5632. },
  5633. keypress: function( event ) {
  5634. if ( suppressKeyPress ) {
  5635. suppressKeyPress = false;
  5636. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  5637. event.preventDefault();
  5638. }
  5639. return;
  5640. }
  5641. if ( suppressKeyPressRepeat ) {
  5642. return;
  5643. }
  5644. // replicate some key handlers to allow them to repeat in Firefox and Opera
  5645. var keyCode = $.ui.keyCode;
  5646. switch( event.keyCode ) {
  5647. case keyCode.PAGE_UP:
  5648. this._move( "previousPage", event );
  5649. break;
  5650. case keyCode.PAGE_DOWN:
  5651. this._move( "nextPage", event );
  5652. break;
  5653. case keyCode.UP:
  5654. this._keyEvent( "previous", event );
  5655. break;
  5656. case keyCode.DOWN:
  5657. this._keyEvent( "next", event );
  5658. break;
  5659. }
  5660. },
  5661. input: function( event ) {
  5662. if ( suppressInput ) {
  5663. suppressInput = false;
  5664. event.preventDefault();
  5665. return;
  5666. }
  5667. this._searchTimeout( event );
  5668. },
  5669. focus: function() {
  5670. this.selectedItem = null;
  5671. this.previous = this._value();
  5672. },
  5673. blur: function( event ) {
  5674. if ( this.cancelBlur ) {
  5675. delete this.cancelBlur;
  5676. return;
  5677. }
  5678. clearTimeout( this.searching );
  5679. this.close( event );
  5680. this._change( event );
  5681. }
  5682. });
  5683. this._initSource();
  5684. this.menu = $( "<ul>" )
  5685. .addClass( "ui-autocomplete ui-front" )
  5686. .appendTo( this._appendTo() )
  5687. .menu({
  5688. // disable ARIA support, the live region takes care of that
  5689. role: null
  5690. })
  5691. .hide()
  5692. .data( "ui-menu" );
  5693. this._on( this.menu.element, {
  5694. mousedown: function( event ) {
  5695. // prevent moving focus out of the text field
  5696. event.preventDefault();
  5697. // IE doesn't prevent moving focus even with event.preventDefault()
  5698. // so we set a flag to know when we should ignore the blur event
  5699. this.cancelBlur = true;
  5700. this._delay(function() {
  5701. delete this.cancelBlur;
  5702. });
  5703. // clicking on the scrollbar causes focus to shift to the body
  5704. // but we can't detect a mouseup or a click immediately afterward
  5705. // so we have to track the next mousedown and close the menu if
  5706. // the user clicks somewhere outside of the autocomplete
  5707. var menuElement = this.menu.element[ 0 ];
  5708. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  5709. this._delay(function() {
  5710. var that = this;
  5711. this.document.one( "mousedown", function( event ) {
  5712. if ( event.target !== that.element[ 0 ] &&
  5713. event.target !== menuElement &&
  5714. !$.contains( menuElement, event.target ) ) {
  5715. that.close();
  5716. }
  5717. });
  5718. });
  5719. }
  5720. },
  5721. menufocus: function( event, ui ) {
  5722. // support: Firefox
  5723. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  5724. if ( this.isNewMenu ) {
  5725. this.isNewMenu = false;
  5726. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  5727. this.menu.blur();
  5728. this.document.one( "mousemove", function() {
  5729. $( event.target ).trigger( event.originalEvent );
  5730. });
  5731. return;
  5732. }
  5733. }
  5734. var item = ui.item.data( "ui-autocomplete-item" );
  5735. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  5736. // use value to match what will end up in the input, if it was a key event
  5737. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  5738. this._value( item.value );
  5739. }
  5740. } else {
  5741. // Normally the input is populated with the item's value as the
  5742. // menu is navigated, causing screen readers to notice a change and
  5743. // announce the item. Since the focus event was canceled, this doesn't
  5744. // happen, so we update the live region so that screen readers can
  5745. // still notice the change and announce it.
  5746. this.liveRegion.text( item.value );
  5747. }
  5748. },
  5749. menuselect: function( event, ui ) {
  5750. var item = ui.item.data( "ui-autocomplete-item" ),
  5751. previous = this.previous;
  5752. // only trigger when focus was lost (click on menu)
  5753. if ( this.element[0] !== this.document[0].activeElement ) {
  5754. this.element.focus();
  5755. this.previous = previous;
  5756. // #6109 - IE triggers two focus events and the second
  5757. // is asynchronous, so we need to reset the previous
  5758. // term synchronously and asynchronously :-(
  5759. this._delay(function() {
  5760. this.previous = previous;
  5761. this.selectedItem = item;
  5762. });
  5763. }
  5764. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  5765. this._value( item.value );
  5766. }
  5767. // reset the term after the select event
  5768. // this allows custom select handling to work properly
  5769. this.term = this._value();
  5770. this.close( event );
  5771. this.selectedItem = item;
  5772. }
  5773. });
  5774. this.liveRegion = $( "<span>", {
  5775. role: "status",
  5776. "aria-live": "polite"
  5777. })
  5778. .addClass( "ui-helper-hidden-accessible" )
  5779. .insertBefore( this.element );
  5780. // turning off autocomplete prevents the browser from remembering the
  5781. // value when navigating through history, so we re-enable autocomplete
  5782. // if the page is unloaded before the widget is destroyed. #7790
  5783. this._on( this.window, {
  5784. beforeunload: function() {
  5785. this.element.removeAttr( "autocomplete" );
  5786. }
  5787. });
  5788. },
  5789. _destroy: function() {
  5790. clearTimeout( this.searching );
  5791. this.element
  5792. .removeClass( "ui-autocomplete-input" )
  5793. .removeAttr( "autocomplete" );
  5794. this.menu.element.remove();
  5795. this.liveRegion.remove();
  5796. },
  5797. _setOption: function( key, value ) {
  5798. this._super( key, value );
  5799. if ( key === "source" ) {
  5800. this._initSource();
  5801. }
  5802. if ( key === "appendTo" ) {
  5803. this.menu.element.appendTo( this._appendTo() );
  5804. }
  5805. if ( key === "disabled" && value && this.xhr ) {
  5806. this.xhr.abort();
  5807. }
  5808. },
  5809. _appendTo: function() {
  5810. var element = this.options.appendTo;
  5811. if ( element ) {
  5812. element = element.jquery || element.nodeType ?
  5813. $( element ) :
  5814. this.document.find( element ).eq( 0 );
  5815. }
  5816. if ( !element ) {
  5817. element = this.element.closest( ".ui-front" );
  5818. }
  5819. if ( !element.length ) {
  5820. element = this.document[0].body;
  5821. }
  5822. return element;
  5823. },
  5824. _initSource: function() {
  5825. var array, url,
  5826. that = this;
  5827. if ( $.isArray(this.options.source) ) {
  5828. array = this.options.source;
  5829. this.source = function( request, response ) {
  5830. response( $.ui.autocomplete.filter( array, request.term ) );
  5831. };
  5832. } else if ( typeof this.options.source === "string" ) {
  5833. url = this.options.source;
  5834. this.source = function( request, response ) {
  5835. if ( that.xhr ) {
  5836. that.xhr.abort();
  5837. }
  5838. that.xhr = $.ajax({
  5839. url: url,
  5840. data: request,
  5841. dataType: "json",
  5842. success: function( data ) {
  5843. response( data );
  5844. },
  5845. error: function() {
  5846. response( [] );
  5847. }
  5848. });
  5849. };
  5850. } else {
  5851. this.source = this.options.source;
  5852. }
  5853. },
  5854. _searchTimeout: function( event ) {
  5855. clearTimeout( this.searching );
  5856. this.searching = this._delay(function() {
  5857. // only search if the value has changed
  5858. if ( this.term !== this._value() ) {
  5859. this.selectedItem = null;
  5860. this.search( null, event );
  5861. }
  5862. }, this.options.delay );
  5863. },
  5864. search: function( value, event ) {
  5865. value = value != null ? value : this._value();
  5866. // always save the actual value, not the one passed as an argument
  5867. this.term = this._value();
  5868. if ( value.length < this.options.minLength ) {
  5869. return this.close( event );
  5870. }
  5871. if ( this._trigger( "search", event ) === false ) {
  5872. return;
  5873. }
  5874. return this._search( value );
  5875. },
  5876. _search: function( value ) {
  5877. this.pending++;
  5878. this.element.addClass( "ui-autocomplete-loading" );
  5879. this.cancelSearch = false;
  5880. this.source( { term: value }, this._response() );
  5881. },
  5882. _response: function() {
  5883. var that = this,
  5884. index = ++requestIndex;
  5885. return function( content ) {
  5886. if ( index === requestIndex ) {
  5887. that.__response( content );
  5888. }
  5889. that.pending--;
  5890. if ( !that.pending ) {
  5891. that.element.removeClass( "ui-autocomplete-loading" );
  5892. }
  5893. };
  5894. },
  5895. __response: function( content ) {
  5896. if ( content ) {
  5897. content = this._normalize( content );
  5898. }
  5899. this._trigger( "response", null, { content: content } );
  5900. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  5901. this._suggest( content );
  5902. this._trigger( "open" );
  5903. } else {
  5904. // use ._close() instead of .close() so we don't cancel future searches
  5905. this._close();
  5906. }
  5907. },
  5908. close: function( event ) {
  5909. this.cancelSearch = true;
  5910. this._close( event );
  5911. },
  5912. _close: function( event ) {
  5913. if ( this.menu.element.is( ":visible" ) ) {
  5914. this.menu.element.hide();
  5915. this.menu.blur();
  5916. this.isNewMenu = true;
  5917. this._trigger( "close", event );
  5918. }
  5919. },
  5920. _change: function( event ) {
  5921. if ( this.previous !== this._value() ) {
  5922. this._trigger( "change", event, { item: this.selectedItem } );
  5923. }
  5924. },
  5925. _normalize: function( items ) {
  5926. // assume all items have the right format when the first item is complete
  5927. if ( items.length && items[0].label && items[0].value ) {
  5928. return items;
  5929. }
  5930. return $.map( items, function( item ) {
  5931. if ( typeof item === "string" ) {
  5932. return {
  5933. label: item,
  5934. value: item
  5935. };
  5936. }
  5937. return $.extend({
  5938. label: item.label || item.value,
  5939. value: item.value || item.label
  5940. }, item );
  5941. });
  5942. },
  5943. _suggest: function( items ) {
  5944. var ul = this.menu.element.empty();
  5945. this._renderMenu( ul, items );
  5946. this.isNewMenu = true;
  5947. this.menu.refresh();
  5948. // size and position menu
  5949. ul.show();
  5950. this._resizeMenu();
  5951. ul.position( $.extend({
  5952. of: this.element
  5953. }, this.options.position ));
  5954. if ( this.options.autoFocus ) {
  5955. this.menu.next();
  5956. }
  5957. },
  5958. _resizeMenu: function() {
  5959. var ul = this.menu.element;
  5960. ul.outerWidth( Math.max(
  5961. // Firefox wraps long text (possibly a rounding bug)
  5962. // so we add 1px to avoid the wrapping (#7513)
  5963. ul.width( "" ).outerWidth() + 1,
  5964. this.element.outerWidth()
  5965. ) );
  5966. },
  5967. _renderMenu: function( ul, items ) {
  5968. var that = this;
  5969. $.each( items, function( index, item ) {
  5970. that._renderItemData( ul, item );
  5971. });
  5972. },
  5973. _renderItemData: function( ul, item ) {
  5974. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  5975. },
  5976. _renderItem: function( ul, item ) {
  5977. return $( "<li>" )
  5978. .append( $( "<a>" ).text( item.label ) )
  5979. .appendTo( ul );
  5980. },
  5981. _move: function( direction, event ) {
  5982. if ( !this.menu.element.is( ":visible" ) ) {
  5983. this.search( null, event );
  5984. return;
  5985. }
  5986. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  5987. this.menu.isLastItem() && /^next/.test( direction ) ) {
  5988. this._value( this.term );
  5989. this.menu.blur();
  5990. return;
  5991. }
  5992. this.menu[ direction ]( event );
  5993. },
  5994. widget: function() {
  5995. return this.menu.element;
  5996. },
  5997. _value: function() {
  5998. return this.valueMethod.apply( this.element, arguments );
  5999. },
  6000. _keyEvent: function( keyEvent, event ) {
  6001. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  6002. this._move( keyEvent, event );
  6003. // prevents moving cursor to beginning/end of the text field in some browsers
  6004. event.preventDefault();
  6005. }
  6006. }
  6007. });
  6008. $.extend( $.ui.autocomplete, {
  6009. escapeRegex: function( value ) {
  6010. return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
  6011. },
  6012. filter: function(array, term) {
  6013. var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
  6014. return $.grep( array, function(value) {
  6015. return matcher.test( value.label || value.value || value );
  6016. });
  6017. }
  6018. });
  6019. // live region extension, adding a `messages` option
  6020. // NOTE: This is an experimental API. We are still investigating
  6021. // a full solution for string manipulation and internationalization.
  6022. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  6023. options: {
  6024. messages: {
  6025. noResults: "No search results.",
  6026. results: function( amount ) {
  6027. return amount + ( amount > 1 ? " results are" : " result is" ) +
  6028. " available, use up and down arrow keys to navigate.";
  6029. }
  6030. }
  6031. },
  6032. __response: function( content ) {
  6033. var message;
  6034. this._superApply( arguments );
  6035. if ( this.options.disabled || this.cancelSearch ) {
  6036. return;
  6037. }
  6038. if ( content && content.length ) {
  6039. message = this.options.messages.results( content.length );
  6040. } else {
  6041. message = this.options.messages.noResults;
  6042. }
  6043. this.liveRegion.text( message );
  6044. }
  6045. });
  6046. }( jQuery ));
  6047. (function( $, undefined ) {
  6048. var lastActive, startXPos, startYPos, clickDragged,
  6049. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  6050. stateClasses = "ui-state-hover ui-state-active ",
  6051. typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
  6052. formResetHandler = function() {
  6053. var form = $( this );
  6054. setTimeout(function() {
  6055. form.find( ":ui-button" ).button( "refresh" );
  6056. }, 1 );
  6057. },
  6058. radioGroup = function( radio ) {
  6059. var name = radio.name,
  6060. form = radio.form,
  6061. radios = $( [] );
  6062. if ( name ) {
  6063. name = name.replace( /'/g, "\\'" );
  6064. if ( form ) {
  6065. radios = $( form ).find( "[name='" + name + "']" );
  6066. } else {
  6067. radios = $( "[name='" + name + "']", radio.ownerDocument )
  6068. .filter(function() {
  6069. return !this.form;
  6070. });
  6071. }
  6072. }
  6073. return radios;
  6074. };
  6075. $.widget( "ui.button", {
  6076. version: "1.10.3",
  6077. defaultElement: "<button>",
  6078. options: {
  6079. disabled: null,
  6080. text: true,
  6081. label: null,
  6082. icons: {
  6083. primary: null,
  6084. secondary: null
  6085. }
  6086. },
  6087. _create: function() {
  6088. this.element.closest( "form" )
  6089. .unbind( "reset" + this.eventNamespace )
  6090. .bind( "reset" + this.eventNamespace, formResetHandler );
  6091. if ( typeof this.options.disabled !== "boolean" ) {
  6092. this.options.disabled = !!this.element.prop( "disabled" );
  6093. } else {
  6094. this.element.prop( "disabled", this.options.disabled );
  6095. }
  6096. this._determineButtonType();
  6097. this.hasTitle = !!this.buttonElement.attr( "title" );
  6098. var that = this,
  6099. options = this.options,
  6100. toggleButton = this.type === "checkbox" || this.type === "radio",
  6101. activeClass = !toggleButton ? "ui-state-active" : "",
  6102. focusClass = "ui-state-focus";
  6103. if ( options.label === null ) {
  6104. options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
  6105. }
  6106. this._hoverable( this.buttonElement );
  6107. this.buttonElement
  6108. .addClass( baseClasses )
  6109. .attr( "role", "button" )
  6110. .bind( "mouseenter" + this.eventNamespace, function() {
  6111. if ( options.disabled ) {
  6112. return;
  6113. }
  6114. if ( this === lastActive ) {
  6115. $( this ).addClass( "ui-state-active" );
  6116. }
  6117. })
  6118. .bind( "mouseleave" + this.eventNamespace, function() {
  6119. if ( options.disabled ) {
  6120. return;
  6121. }
  6122. $( this ).removeClass( activeClass );
  6123. })
  6124. .bind( "click" + this.eventNamespace, function( event ) {
  6125. if ( options.disabled ) {
  6126. event.preventDefault();
  6127. event.stopImmediatePropagation();
  6128. }
  6129. });
  6130. this.element
  6131. .bind( "focus" + this.eventNamespace, function() {
  6132. // no need to check disabled, focus won't be triggered anyway
  6133. that.buttonElement.addClass( focusClass );
  6134. })
  6135. .bind( "blur" + this.eventNamespace, function() {
  6136. that.buttonElement.removeClass( focusClass );
  6137. });
  6138. if ( toggleButton ) {
  6139. this.element.bind( "change" + this.eventNamespace, function() {
  6140. if ( clickDragged ) {
  6141. return;
  6142. }
  6143. that.refresh();
  6144. });
  6145. // if mouse moves between mousedown and mouseup (drag) set clickDragged flag
  6146. // prevents issue where button state changes but checkbox/radio checked state
  6147. // does not in Firefox (see ticket #6970)
  6148. this.buttonElement
  6149. .bind( "mousedown" + this.eventNamespace, function( event ) {
  6150. if ( options.disabled ) {
  6151. return;
  6152. }
  6153. clickDragged = false;
  6154. startXPos = event.pageX;
  6155. startYPos = event.pageY;
  6156. })
  6157. .bind( "mouseup" + this.eventNamespace, function( event ) {
  6158. if ( options.disabled ) {
  6159. return;
  6160. }
  6161. if ( startXPos !== event.pageX || startYPos !== event.pageY ) {
  6162. clickDragged = true;
  6163. }
  6164. });
  6165. }
  6166. if ( this.type === "checkbox" ) {
  6167. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  6168. if ( options.disabled || clickDragged ) {
  6169. return false;
  6170. }
  6171. });
  6172. } else if ( this.type === "radio" ) {
  6173. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  6174. if ( options.disabled || clickDragged ) {
  6175. return false;
  6176. }
  6177. $( this ).addClass( "ui-state-active" );
  6178. that.buttonElement.attr( "aria-pressed", "true" );
  6179. var radio = that.element[ 0 ];
  6180. radioGroup( radio )
  6181. .not( radio )
  6182. .map(function() {
  6183. return $( this ).button( "widget" )[ 0 ];
  6184. })
  6185. .removeClass( "ui-state-active" )
  6186. .attr( "aria-pressed", "false" );
  6187. });
  6188. } else {
  6189. this.buttonElement
  6190. .bind( "mousedown" + this.eventNamespace, function() {
  6191. if ( options.disabled ) {
  6192. return false;
  6193. }
  6194. $( this ).addClass( "ui-state-active" );
  6195. lastActive = this;
  6196. that.document.one( "mouseup", function() {
  6197. lastActive = null;
  6198. });
  6199. })
  6200. .bind( "mouseup" + this.eventNamespace, function() {
  6201. if ( options.disabled ) {
  6202. return false;
  6203. }
  6204. $( this ).removeClass( "ui-state-active" );
  6205. })
  6206. .bind( "keydown" + this.eventNamespace, function(event) {
  6207. if ( options.disabled ) {
  6208. return false;
  6209. }
  6210. if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
  6211. $( this ).addClass( "ui-state-active" );
  6212. }
  6213. })
  6214. // see #8559, we bind to blur here in case the button element loses
  6215. // focus between keydown and keyup, it would be left in an "active" state
  6216. .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
  6217. $( this ).removeClass( "ui-state-active" );
  6218. });
  6219. if ( this.buttonElement.is("a") ) {
  6220. this.buttonElement.keyup(function(event) {
  6221. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  6222. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  6223. $( this ).click();
  6224. }
  6225. });
  6226. }
  6227. }
  6228. // TODO: pull out $.Widget's handling for the disabled option into
  6229. // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
  6230. // be overridden by individual plugins
  6231. this._setOption( "disabled", options.disabled );
  6232. this._resetButton();
  6233. },
  6234. _determineButtonType: function() {
  6235. var ancestor, labelSelector, checked;
  6236. if ( this.element.is("[type=checkbox]") ) {
  6237. this.type = "checkbox";
  6238. } else if ( this.element.is("[type=radio]") ) {
  6239. this.type = "radio";
  6240. } else if ( this.element.is("input") ) {
  6241. this.type = "input";
  6242. } else {
  6243. this.type = "button";
  6244. }
  6245. if ( this.type === "checkbox" || this.type === "radio" ) {
  6246. // we don't search against the document in case the element
  6247. // is disconnected from the DOM
  6248. ancestor = this.element.parents().last();
  6249. labelSelector = "label[for='" + this.element.attr("id") + "']";
  6250. this.buttonElement = ancestor.find( labelSelector );
  6251. if ( !this.buttonElement.length ) {
  6252. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  6253. this.buttonElement = ancestor.filter( labelSelector );
  6254. if ( !this.buttonElement.length ) {
  6255. this.buttonElement = ancestor.find( labelSelector );
  6256. }
  6257. }
  6258. this.element.addClass( "ui-helper-hidden-accessible" );
  6259. checked = this.element.is( ":checked" );
  6260. if ( checked ) {
  6261. this.buttonElement.addClass( "ui-state-active" );
  6262. }
  6263. this.buttonElement.prop( "aria-pressed", checked );
  6264. } else {
  6265. this.buttonElement = this.element;
  6266. }
  6267. },
  6268. widget: function() {
  6269. return this.buttonElement;
  6270. },
  6271. _destroy: function() {
  6272. this.element
  6273. .removeClass( "ui-helper-hidden-accessible" );
  6274. this.buttonElement
  6275. .removeClass( baseClasses + " " + stateClasses + " " + typeClasses )
  6276. .removeAttr( "role" )
  6277. .removeAttr( "aria-pressed" )
  6278. .html( this.buttonElement.find(".ui-button-text").html() );
  6279. if ( !this.hasTitle ) {
  6280. this.buttonElement.removeAttr( "title" );
  6281. }
  6282. },
  6283. _setOption: function( key, value ) {
  6284. this._super( key, value );
  6285. if ( key === "disabled" ) {
  6286. if ( value ) {
  6287. this.element.prop( "disabled", true );
  6288. } else {
  6289. this.element.prop( "disabled", false );
  6290. }
  6291. return;
  6292. }
  6293. this._resetButton();
  6294. },
  6295. refresh: function() {
  6296. //See #8237 & #8828
  6297. var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
  6298. if ( isDisabled !== this.options.disabled ) {
  6299. this._setOption( "disabled", isDisabled );
  6300. }
  6301. if ( this.type === "radio" ) {
  6302. radioGroup( this.element[0] ).each(function() {
  6303. if ( $( this ).is( ":checked" ) ) {
  6304. $( this ).button( "widget" )
  6305. .addClass( "ui-state-active" )
  6306. .attr( "aria-pressed", "true" );
  6307. } else {
  6308. $( this ).button( "widget" )
  6309. .removeClass( "ui-state-active" )
  6310. .attr( "aria-pressed", "false" );
  6311. }
  6312. });
  6313. } else if ( this.type === "checkbox" ) {
  6314. if ( this.element.is( ":checked" ) ) {
  6315. this.buttonElement
  6316. .addClass( "ui-state-active" )
  6317. .attr( "aria-pressed", "true" );
  6318. } else {
  6319. this.buttonElement
  6320. .removeClass( "ui-state-active" )
  6321. .attr( "aria-pressed", "false" );
  6322. }
  6323. }
  6324. },
  6325. _resetButton: function() {
  6326. if ( this.type === "input" ) {
  6327. if ( this.options.label ) {
  6328. this.element.val( this.options.label );
  6329. }
  6330. return;
  6331. }
  6332. var buttonElement = this.buttonElement.removeClass( typeClasses ),
  6333. buttonText = $( "<span></span>", this.document[0] )
  6334. .addClass( "ui-button-text" )
  6335. .html( this.options.label )
  6336. .appendTo( buttonElement.empty() )
  6337. .text(),
  6338. icons = this.options.icons,
  6339. multipleIcons = icons.primary && icons.secondary,
  6340. buttonClasses = [];
  6341. if ( icons.primary || icons.secondary ) {
  6342. if ( this.options.text ) {
  6343. buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
  6344. }
  6345. if ( icons.primary ) {
  6346. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  6347. }
  6348. if ( icons.secondary ) {
  6349. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  6350. }
  6351. if ( !this.options.text ) {
  6352. buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
  6353. if ( !this.hasTitle ) {
  6354. buttonElement.attr( "title", $.trim( buttonText ) );
  6355. }
  6356. }
  6357. } else {
  6358. buttonClasses.push( "ui-button-text-only" );
  6359. }
  6360. buttonElement.addClass( buttonClasses.join( " " ) );
  6361. }
  6362. });
  6363. $.widget( "ui.buttonset", {
  6364. version: "1.10.3",
  6365. options: {
  6366. items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
  6367. },
  6368. _create: function() {
  6369. this.element.addClass( "ui-buttonset" );
  6370. },
  6371. _init: function() {
  6372. this.refresh();
  6373. },
  6374. _setOption: function( key, value ) {
  6375. if ( key === "disabled" ) {
  6376. this.buttons.button( "option", key, value );
  6377. }
  6378. this._super( key, value );
  6379. },
  6380. refresh: function() {
  6381. var rtl = this.element.css( "direction" ) === "rtl";
  6382. this.buttons = this.element.find( this.options.items )
  6383. .filter( ":ui-button" )
  6384. .button( "refresh" )
  6385. .end()
  6386. .not( ":ui-button" )
  6387. .button()
  6388. .end()
  6389. .map(function() {
  6390. return $( this ).button( "widget" )[ 0 ];
  6391. })
  6392. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  6393. .filter( ":first" )
  6394. .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
  6395. .end()
  6396. .filter( ":last" )
  6397. .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
  6398. .end()
  6399. .end();
  6400. },
  6401. _destroy: function() {
  6402. this.element.removeClass( "ui-buttonset" );
  6403. this.buttons
  6404. .map(function() {
  6405. return $( this ).button( "widget" )[ 0 ];
  6406. })
  6407. .removeClass( "ui-corner-left ui-corner-right" )
  6408. .end()
  6409. .button( "destroy" );
  6410. }
  6411. });
  6412. }( jQuery ) );
  6413. (function( $, undefined ) {
  6414. $.extend($.ui, { datepicker: { version: "1.10.3" } });
  6415. var PROP_NAME = "datepicker",
  6416. instActive;
  6417. /* Date picker manager.
  6418. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  6419. Settings for (groups of) date pickers are maintained in an instance object,
  6420. allowing multiple different settings on the same page. */
  6421. function Datepicker() {
  6422. this._curInst = null; // The current instance in use
  6423. this._keyEvent = false; // If the last event was a key event
  6424. this._disabledInputs = []; // List of date picker inputs that have been disabled
  6425. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  6426. this._inDialog = false; // True if showing within a "dialog", false if not
  6427. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  6428. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  6429. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  6430. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  6431. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  6432. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  6433. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  6434. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  6435. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  6436. this.regional = []; // Available regional settings, indexed by language code
  6437. this.regional[""] = { // Default regional settings
  6438. closeText: "Done", // Display text for close link
  6439. prevText: "Prev", // Display text for previous month link
  6440. nextText: "Next", // Display text for next month link
  6441. currentText: "Today", // Display text for current month link
  6442. monthNames: ["January","February","March","April","May","June",
  6443. "July","August","September","October","November","December"], // Names of months for drop-down and formatting
  6444. monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
  6445. dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
  6446. dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
  6447. dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
  6448. weekHeader: "Wk", // Column header for week of the year
  6449. dateFormat: "mm/dd/yy", // See format options on parseDate
  6450. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  6451. isRTL: false, // True if right-to-left language, false if left-to-right
  6452. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  6453. yearSuffix: "" // Additional text to append to the year in the month headers
  6454. };
  6455. this._defaults = { // Global defaults for all the date picker instances
  6456. showOn: "focus", // "focus" for popup on focus,
  6457. // "button" for trigger button, or "both" for either
  6458. showAnim: "fadeIn", // Name of jQuery animation for popup
  6459. showOptions: {}, // Options for enhanced animations
  6460. defaultDate: null, // Used when field is blank: actual date,
  6461. // +/-number for offset from today, null for today
  6462. appendText: "", // Display text following the input box, e.g. showing the format
  6463. buttonText: "...", // Text for trigger button
  6464. buttonImage: "", // URL for trigger button image
  6465. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  6466. hideIfNoPrevNext: false, // True to hide next/previous month links
  6467. // if not applicable, false to just disable them
  6468. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  6469. gotoCurrent: false, // True if today link goes back to current selection instead
  6470. changeMonth: false, // True if month can be selected directly, false if only prev/next
  6471. changeYear: false, // True if year can be selected directly, false if only prev/next
  6472. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  6473. // either relative to today's year (-nn:+nn), relative to currently displayed year
  6474. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  6475. showOtherMonths: false, // True to show dates in other months, false to leave blank
  6476. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  6477. showWeek: false, // True to show week of the year, false to not show it
  6478. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  6479. // takes a Date and returns the number of the week for it
  6480. shortYearCutoff: "+10", // Short year values < this are in the current century,
  6481. // > this are in the previous century,
  6482. // string value starting with "+" for current year + value
  6483. minDate: null, // The earliest selectable date, or null for no limit
  6484. maxDate: null, // The latest selectable date, or null for no limit
  6485. duration: "fast", // Duration of display/closure
  6486. beforeShowDay: null, // Function that takes a date and returns an array with
  6487. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  6488. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  6489. beforeShow: null, // Function that takes an input field and
  6490. // returns a set of custom settings for the date picker
  6491. onSelect: null, // Define a callback function when a date is selected
  6492. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  6493. onClose: null, // Define a callback function when the datepicker is closed
  6494. numberOfMonths: 1, // Number of months to show at a time
  6495. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  6496. stepMonths: 1, // Number of months to step back/forward
  6497. stepBigMonths: 12, // Number of months to step back/forward for the big links
  6498. altField: "", // Selector for an alternate field to store selected dates into
  6499. altFormat: "", // The date format to use for the alternate field
  6500. constrainInput: true, // The input is constrained by the current date format
  6501. showButtonPanel: false, // True to show button panel, false to not show it
  6502. autoSize: false, // True to size the input for the date format, false to leave as is
  6503. disabled: false // The initial disabled state
  6504. };
  6505. $.extend(this._defaults, this.regional[""]);
  6506. this.dpDiv = bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
  6507. }
  6508. $.extend(Datepicker.prototype, {
  6509. /* Class name added to elements to indicate already configured with a date picker. */
  6510. markerClassName: "hasDatepicker",
  6511. //Keep track of the maximum number of rows displayed (see #7043)
  6512. maxRows: 4,
  6513. // TODO rename to "widget" when switching to widget factory
  6514. _widgetDatepicker: function() {
  6515. return this.dpDiv;
  6516. },
  6517. /* Override the default settings for all instances of the date picker.
  6518. * @param settings object - the new settings to use as defaults (anonymous object)
  6519. * @return the manager object
  6520. */
  6521. setDefaults: function(settings) {
  6522. extendRemove(this._defaults, settings || {});
  6523. return this;
  6524. },
  6525. /* Attach the date picker to a jQuery selection.
  6526. * @param target element - the target input field or division or span
  6527. * @param settings object - the new settings to use for this date picker instance (anonymous)
  6528. */
  6529. _attachDatepicker: function(target, settings) {
  6530. var nodeName, inline, inst;
  6531. nodeName = target.nodeName.toLowerCase();
  6532. inline = (nodeName === "div" || nodeName === "span");
  6533. if (!target.id) {
  6534. this.uuid += 1;
  6535. target.id = "dp" + this.uuid;
  6536. }
  6537. inst = this._newInst($(target), inline);
  6538. inst.settings = $.extend({}, settings || {});
  6539. if (nodeName === "input") {
  6540. this._connectDatepicker(target, inst);
  6541. } else if (inline) {
  6542. this._inlineDatepicker(target, inst);
  6543. }
  6544. },
  6545. /* Create a new instance object. */
  6546. _newInst: function(target, inline) {
  6547. var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
  6548. return {id: id, input: target, // associated target
  6549. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  6550. drawMonth: 0, drawYear: 0, // month being drawn
  6551. inline: inline, // is datepicker inline or not
  6552. dpDiv: (!inline ? this.dpDiv : // presentation div
  6553. bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
  6554. },
  6555. /* Attach the date picker to an input field. */
  6556. _connectDatepicker: function(target, inst) {
  6557. var input = $(target);
  6558. inst.append = $([]);
  6559. inst.trigger = $([]);
  6560. if (input.hasClass(this.markerClassName)) {
  6561. return;
  6562. }
  6563. this._attachments(input, inst);
  6564. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  6565. keypress(this._doKeyPress).keyup(this._doKeyUp);
  6566. this._autoSize(inst);
  6567. $.data(target, PROP_NAME, inst);
  6568. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  6569. if( inst.settings.disabled ) {
  6570. this._disableDatepicker( target );
  6571. }
  6572. },
  6573. /* Make attachments based on settings. */
  6574. _attachments: function(input, inst) {
  6575. var showOn, buttonText, buttonImage,
  6576. appendText = this._get(inst, "appendText"),
  6577. isRTL = this._get(inst, "isRTL");
  6578. if (inst.append) {
  6579. inst.append.remove();
  6580. }
  6581. if (appendText) {
  6582. inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
  6583. input[isRTL ? "before" : "after"](inst.append);
  6584. }
  6585. input.unbind("focus", this._showDatepicker);
  6586. if (inst.trigger) {
  6587. inst.trigger.remove();
  6588. }
  6589. showOn = this._get(inst, "showOn");
  6590. if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
  6591. input.focus(this._showDatepicker);
  6592. }
  6593. if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
  6594. buttonText = this._get(inst, "buttonText");
  6595. buttonImage = this._get(inst, "buttonImage");
  6596. inst.trigger = $(this._get(inst, "buttonImageOnly") ?
  6597. $("<img/>").addClass(this._triggerClass).
  6598. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  6599. $("<button type='button'></button>").addClass(this._triggerClass).
  6600. html(!buttonImage ? buttonText : $("<img/>").attr(
  6601. { src:buttonImage, alt:buttonText, title:buttonText })));
  6602. input[isRTL ? "before" : "after"](inst.trigger);
  6603. inst.trigger.click(function() {
  6604. if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
  6605. $.datepicker._hideDatepicker();
  6606. } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
  6607. $.datepicker._hideDatepicker();
  6608. $.datepicker._showDatepicker(input[0]);
  6609. } else {
  6610. $.datepicker._showDatepicker(input[0]);
  6611. }
  6612. return false;
  6613. });
  6614. }
  6615. },
  6616. /* Apply the maximum length for the date format. */
  6617. _autoSize: function(inst) {
  6618. if (this._get(inst, "autoSize") && !inst.inline) {
  6619. var findMax, max, maxI, i,
  6620. date = new Date(2009, 12 - 1, 20), // Ensure double digits
  6621. dateFormat = this._get(inst, "dateFormat");
  6622. if (dateFormat.match(/[DM]/)) {
  6623. findMax = function(names) {
  6624. max = 0;
  6625. maxI = 0;
  6626. for (i = 0; i < names.length; i++) {
  6627. if (names[i].length > max) {
  6628. max = names[i].length;
  6629. maxI = i;
  6630. }
  6631. }
  6632. return maxI;
  6633. };
  6634. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  6635. "monthNames" : "monthNamesShort"))));
  6636. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  6637. "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
  6638. }
  6639. inst.input.attr("size", this._formatDate(inst, date).length);
  6640. }
  6641. },
  6642. /* Attach an inline date picker to a div. */
  6643. _inlineDatepicker: function(target, inst) {
  6644. var divSpan = $(target);
  6645. if (divSpan.hasClass(this.markerClassName)) {
  6646. return;
  6647. }
  6648. divSpan.addClass(this.markerClassName).append(inst.dpDiv);
  6649. $.data(target, PROP_NAME, inst);
  6650. this._setDate(inst, this._getDefaultDate(inst), true);
  6651. this._updateDatepicker(inst);
  6652. this._updateAlternate(inst);
  6653. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  6654. if( inst.settings.disabled ) {
  6655. this._disableDatepicker( target );
  6656. }
  6657. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  6658. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  6659. inst.dpDiv.css( "display", "block" );
  6660. },
  6661. /* Pop-up the date picker in a "dialog" box.
  6662. * @param input element - ignored
  6663. * @param date string or Date - the initial date to display
  6664. * @param onSelect function - the function to call when a date is selected
  6665. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  6666. * @param pos int[2] - coordinates for the dialog's position within the screen or
  6667. * event - with x/y coordinates or
  6668. * leave empty for default (screen centre)
  6669. * @return the manager object
  6670. */
  6671. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  6672. var id, browserWidth, browserHeight, scrollX, scrollY,
  6673. inst = this._dialogInst; // internal instance
  6674. if (!inst) {
  6675. this.uuid += 1;
  6676. id = "dp" + this.uuid;
  6677. this._dialogInput = $("<input type='text' id='" + id +
  6678. "' style='position: absolute; top: -100px; width: 0px;'/>");
  6679. this._dialogInput.keydown(this._doKeyDown);
  6680. $("body").append(this._dialogInput);
  6681. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  6682. inst.settings = {};
  6683. $.data(this._dialogInput[0], PROP_NAME, inst);
  6684. }
  6685. extendRemove(inst.settings, settings || {});
  6686. date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
  6687. this._dialogInput.val(date);
  6688. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  6689. if (!this._pos) {
  6690. browserWidth = document.documentElement.clientWidth;
  6691. browserHeight = document.documentElement.clientHeight;
  6692. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  6693. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  6694. this._pos = // should use actual width/height below
  6695. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  6696. }
  6697. // move input on screen for focus, but hidden behind dialog
  6698. this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
  6699. inst.settings.onSelect = onSelect;
  6700. this._inDialog = true;
  6701. this.dpDiv.addClass(this._dialogClass);
  6702. this._showDatepicker(this._dialogInput[0]);
  6703. if ($.blockUI) {
  6704. $.blockUI(this.dpDiv);
  6705. }
  6706. $.data(this._dialogInput[0], PROP_NAME, inst);
  6707. return this;
  6708. },
  6709. /* Detach a datepicker from its control.
  6710. * @param target element - the target input field or division or span
  6711. */
  6712. _destroyDatepicker: function(target) {
  6713. var nodeName,
  6714. $target = $(target),
  6715. inst = $.data(target, PROP_NAME);
  6716. if (!$target.hasClass(this.markerClassName)) {
  6717. return;
  6718. }
  6719. nodeName = target.nodeName.toLowerCase();
  6720. $.removeData(target, PROP_NAME);
  6721. if (nodeName === "input") {
  6722. inst.append.remove();
  6723. inst.trigger.remove();
  6724. $target.removeClass(this.markerClassName).
  6725. unbind("focus", this._showDatepicker).
  6726. unbind("keydown", this._doKeyDown).
  6727. unbind("keypress", this._doKeyPress).
  6728. unbind("keyup", this._doKeyUp);
  6729. } else if (nodeName === "div" || nodeName === "span") {
  6730. $target.removeClass(this.markerClassName).empty();
  6731. }
  6732. },
  6733. /* Enable the date picker to a jQuery selection.
  6734. * @param target element - the target input field or division or span
  6735. */
  6736. _enableDatepicker: function(target) {
  6737. var nodeName, inline,
  6738. $target = $(target),
  6739. inst = $.data(target, PROP_NAME);
  6740. if (!$target.hasClass(this.markerClassName)) {
  6741. return;
  6742. }
  6743. nodeName = target.nodeName.toLowerCase();
  6744. if (nodeName === "input") {
  6745. target.disabled = false;
  6746. inst.trigger.filter("button").
  6747. each(function() { this.disabled = false; }).end().
  6748. filter("img").css({opacity: "1.0", cursor: ""});
  6749. } else if (nodeName === "div" || nodeName === "span") {
  6750. inline = $target.children("." + this._inlineClass);
  6751. inline.children().removeClass("ui-state-disabled");
  6752. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  6753. prop("disabled", false);
  6754. }
  6755. this._disabledInputs = $.map(this._disabledInputs,
  6756. function(value) { return (value === target ? null : value); }); // delete entry
  6757. },
  6758. /* Disable the date picker to a jQuery selection.
  6759. * @param target element - the target input field or division or span
  6760. */
  6761. _disableDatepicker: function(target) {
  6762. var nodeName, inline,
  6763. $target = $(target),
  6764. inst = $.data(target, PROP_NAME);
  6765. if (!$target.hasClass(this.markerClassName)) {
  6766. return;
  6767. }
  6768. nodeName = target.nodeName.toLowerCase();
  6769. if (nodeName === "input") {
  6770. target.disabled = true;
  6771. inst.trigger.filter("button").
  6772. each(function() { this.disabled = true; }).end().
  6773. filter("img").css({opacity: "0.5", cursor: "default"});
  6774. } else if (nodeName === "div" || nodeName === "span") {
  6775. inline = $target.children("." + this._inlineClass);
  6776. inline.children().addClass("ui-state-disabled");
  6777. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  6778. prop("disabled", true);
  6779. }
  6780. this._disabledInputs = $.map(this._disabledInputs,
  6781. function(value) { return (value === target ? null : value); }); // delete entry
  6782. this._disabledInputs[this._disabledInputs.length] = target;
  6783. },
  6784. /* Is the first field in a jQuery collection disabled as a datepicker?
  6785. * @param target element - the target input field or division or span
  6786. * @return boolean - true if disabled, false if enabled
  6787. */
  6788. _isDisabledDatepicker: function(target) {
  6789. if (!target) {
  6790. return false;
  6791. }
  6792. for (var i = 0; i < this._disabledInputs.length; i++) {
  6793. if (this._disabledInputs[i] === target) {
  6794. return true;
  6795. }
  6796. }
  6797. return false;
  6798. },
  6799. /* Retrieve the instance data for the target control.
  6800. * @param target element - the target input field or division or span
  6801. * @return object - the associated instance data
  6802. * @throws error if a jQuery problem getting data
  6803. */
  6804. _getInst: function(target) {
  6805. try {
  6806. return $.data(target, PROP_NAME);
  6807. }
  6808. catch (err) {
  6809. throw "Missing instance data for this datepicker";
  6810. }
  6811. },
  6812. /* Update or retrieve the settings for a date picker attached to an input field or division.
  6813. * @param target element - the target input field or division or span
  6814. * @param name object - the new settings to update or
  6815. * string - the name of the setting to change or retrieve,
  6816. * when retrieving also "all" for all instance settings or
  6817. * "defaults" for all global defaults
  6818. * @param value any - the new value for the setting
  6819. * (omit if above is an object or to retrieve a value)
  6820. */
  6821. _optionDatepicker: function(target, name, value) {
  6822. var settings, date, minDate, maxDate,
  6823. inst = this._getInst(target);
  6824. if (arguments.length === 2 && typeof name === "string") {
  6825. return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
  6826. (inst ? (name === "all" ? $.extend({}, inst.settings) :
  6827. this._get(inst, name)) : null));
  6828. }
  6829. settings = name || {};
  6830. if (typeof name === "string") {
  6831. settings = {};
  6832. settings[name] = value;
  6833. }
  6834. if (inst) {
  6835. if (this._curInst === inst) {
  6836. this._hideDatepicker();
  6837. }
  6838. date = this._getDateDatepicker(target, true);
  6839. minDate = this._getMinMaxDate(inst, "min");
  6840. maxDate = this._getMinMaxDate(inst, "max");
  6841. extendRemove(inst.settings, settings);
  6842. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  6843. if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
  6844. inst.settings.minDate = this._formatDate(inst, minDate);
  6845. }
  6846. if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
  6847. inst.settings.maxDate = this._formatDate(inst, maxDate);
  6848. }
  6849. if ( "disabled" in settings ) {
  6850. if ( settings.disabled ) {
  6851. this._disableDatepicker(target);
  6852. } else {
  6853. this._enableDatepicker(target);
  6854. }
  6855. }
  6856. this._attachments($(target), inst);
  6857. this._autoSize(inst);
  6858. this._setDate(inst, date);
  6859. this._updateAlternate(inst);
  6860. this._updateDatepicker(inst);
  6861. }
  6862. },
  6863. // change method deprecated
  6864. _changeDatepicker: function(target, name, value) {
  6865. this._optionDatepicker(target, name, value);
  6866. },
  6867. /* Redraw the date picker attached to an input field or division.
  6868. * @param target element - the target input field or division or span
  6869. */
  6870. _refreshDatepicker: function(target) {
  6871. var inst = this._getInst(target);
  6872. if (inst) {
  6873. this._updateDatepicker(inst);
  6874. }
  6875. },
  6876. /* Set the dates for a jQuery selection.
  6877. * @param target element - the target input field or division or span
  6878. * @param date Date - the new date
  6879. */
  6880. _setDateDatepicker: function(target, date) {
  6881. var inst = this._getInst(target);
  6882. if (inst) {
  6883. this._setDate(inst, date);
  6884. this._updateDatepicker(inst);
  6885. this._updateAlternate(inst);
  6886. }
  6887. },
  6888. /* Get the date(s) for the first entry in a jQuery selection.
  6889. * @param target element - the target input field or division or span
  6890. * @param noDefault boolean - true if no default date is to be used
  6891. * @return Date - the current date
  6892. */
  6893. _getDateDatepicker: function(target, noDefault) {
  6894. var inst = this._getInst(target);
  6895. if (inst && !inst.inline) {
  6896. this._setDateFromField(inst, noDefault);
  6897. }
  6898. return (inst ? this._getDate(inst) : null);
  6899. },
  6900. /* Handle keystrokes. */
  6901. _doKeyDown: function(event) {
  6902. var onSelect, dateStr, sel,
  6903. inst = $.datepicker._getInst(event.target),
  6904. handled = true,
  6905. isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
  6906. inst._keyEvent = true;
  6907. if ($.datepicker._datepickerShowing) {
  6908. switch (event.keyCode) {
  6909. case 9: $.datepicker._hideDatepicker();
  6910. handled = false;
  6911. break; // hide on tab out
  6912. case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
  6913. $.datepicker._currentClass + ")", inst.dpDiv);
  6914. if (sel[0]) {
  6915. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  6916. }
  6917. onSelect = $.datepicker._get(inst, "onSelect");
  6918. if (onSelect) {
  6919. dateStr = $.datepicker._formatDate(inst);
  6920. // trigger custom callback
  6921. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  6922. } else {
  6923. $.datepicker._hideDatepicker();
  6924. }
  6925. return false; // don't submit the form
  6926. case 27: $.datepicker._hideDatepicker();
  6927. break; // hide on escape
  6928. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6929. -$.datepicker._get(inst, "stepBigMonths") :
  6930. -$.datepicker._get(inst, "stepMonths")), "M");
  6931. break; // previous month/year on page up/+ ctrl
  6932. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6933. +$.datepicker._get(inst, "stepBigMonths") :
  6934. +$.datepicker._get(inst, "stepMonths")), "M");
  6935. break; // next month/year on page down/+ ctrl
  6936. case 35: if (event.ctrlKey || event.metaKey) {
  6937. $.datepicker._clearDate(event.target);
  6938. }
  6939. handled = event.ctrlKey || event.metaKey;
  6940. break; // clear on ctrl or command +end
  6941. case 36: if (event.ctrlKey || event.metaKey) {
  6942. $.datepicker._gotoToday(event.target);
  6943. }
  6944. handled = event.ctrlKey || event.metaKey;
  6945. break; // current on ctrl or command +home
  6946. case 37: if (event.ctrlKey || event.metaKey) {
  6947. $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
  6948. }
  6949. handled = event.ctrlKey || event.metaKey;
  6950. // -1 day on ctrl or command +left
  6951. if (event.originalEvent.altKey) {
  6952. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6953. -$.datepicker._get(inst, "stepBigMonths") :
  6954. -$.datepicker._get(inst, "stepMonths")), "M");
  6955. }
  6956. // next month/year on alt +left on Mac
  6957. break;
  6958. case 38: if (event.ctrlKey || event.metaKey) {
  6959. $.datepicker._adjustDate(event.target, -7, "D");
  6960. }
  6961. handled = event.ctrlKey || event.metaKey;
  6962. break; // -1 week on ctrl or command +up
  6963. case 39: if (event.ctrlKey || event.metaKey) {
  6964. $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
  6965. }
  6966. handled = event.ctrlKey || event.metaKey;
  6967. // +1 day on ctrl or command +right
  6968. if (event.originalEvent.altKey) {
  6969. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6970. +$.datepicker._get(inst, "stepBigMonths") :
  6971. +$.datepicker._get(inst, "stepMonths")), "M");
  6972. }
  6973. // next month/year on alt +right
  6974. break;
  6975. case 40: if (event.ctrlKey || event.metaKey) {
  6976. $.datepicker._adjustDate(event.target, +7, "D");
  6977. }
  6978. handled = event.ctrlKey || event.metaKey;
  6979. break; // +1 week on ctrl or command +down
  6980. default: handled = false;
  6981. }
  6982. } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
  6983. $.datepicker._showDatepicker(this);
  6984. } else {
  6985. handled = false;
  6986. }
  6987. if (handled) {
  6988. event.preventDefault();
  6989. event.stopPropagation();
  6990. }
  6991. },
  6992. /* Filter entered characters - based on date format. */
  6993. _doKeyPress: function(event) {
  6994. var chars, chr,
  6995. inst = $.datepicker._getInst(event.target);
  6996. if ($.datepicker._get(inst, "constrainInput")) {
  6997. chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
  6998. chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
  6999. return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
  7000. }
  7001. },
  7002. /* Synchronise manual entry and field/alternate field. */
  7003. _doKeyUp: function(event) {
  7004. var date,
  7005. inst = $.datepicker._getInst(event.target);
  7006. if (inst.input.val() !== inst.lastVal) {
  7007. try {
  7008. date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  7009. (inst.input ? inst.input.val() : null),
  7010. $.datepicker._getFormatConfig(inst));
  7011. if (date) { // only if valid
  7012. $.datepicker._setDateFromField(inst);
  7013. $.datepicker._updateAlternate(inst);
  7014. $.datepicker._updateDatepicker(inst);
  7015. }
  7016. }
  7017. catch (err) {
  7018. }
  7019. }
  7020. return true;
  7021. },
  7022. /* Pop-up the date picker for a given input field.
  7023. * If false returned from beforeShow event handler do not show.
  7024. * @param input element - the input field attached to the date picker or
  7025. * event - if triggered by focus
  7026. */
  7027. _showDatepicker: function(input) {
  7028. input = input.target || input;
  7029. if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
  7030. input = $("input", input.parentNode)[0];
  7031. }
  7032. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
  7033. return;
  7034. }
  7035. var inst, beforeShow, beforeShowSettings, isFixed,
  7036. offset, showAnim, duration;
  7037. inst = $.datepicker._getInst(input);
  7038. if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
  7039. $.datepicker._curInst.dpDiv.stop(true, true);
  7040. if ( inst && $.datepicker._datepickerShowing ) {
  7041. $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
  7042. }
  7043. }
  7044. beforeShow = $.datepicker._get(inst, "beforeShow");
  7045. beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  7046. if(beforeShowSettings === false){
  7047. return;
  7048. }
  7049. extendRemove(inst.settings, beforeShowSettings);
  7050. inst.lastVal = null;
  7051. $.datepicker._lastInput = input;
  7052. $.datepicker._setDateFromField(inst);
  7053. if ($.datepicker._inDialog) { // hide cursor
  7054. input.value = "";
  7055. }
  7056. if (!$.datepicker._pos) { // position below input
  7057. $.datepicker._pos = $.datepicker._findPos(input);
  7058. $.datepicker._pos[1] += input.offsetHeight; // add the height
  7059. }
  7060. isFixed = false;
  7061. $(input).parents().each(function() {
  7062. isFixed |= $(this).css("position") === "fixed";
  7063. return !isFixed;
  7064. });
  7065. offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  7066. $.datepicker._pos = null;
  7067. //to avoid flashes on Firefox
  7068. inst.dpDiv.empty();
  7069. // determine sizing offscreen
  7070. inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
  7071. $.datepicker._updateDatepicker(inst);
  7072. // fix width for dynamic number of date pickers
  7073. // and adjust position before showing
  7074. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  7075. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  7076. "static" : (isFixed ? "fixed" : "absolute")), display: "none",
  7077. left: offset.left + "px", top: offset.top + "px"});
  7078. if (!inst.inline) {
  7079. showAnim = $.datepicker._get(inst, "showAnim");
  7080. duration = $.datepicker._get(inst, "duration");
  7081. inst.dpDiv.zIndex($(input).zIndex()+1);
  7082. $.datepicker._datepickerShowing = true;
  7083. if ( $.effects && $.effects.effect[ showAnim ] ) {
  7084. inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
  7085. } else {
  7086. inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
  7087. }
  7088. if ( $.datepicker._shouldFocusInput( inst ) ) {
  7089. inst.input.focus();
  7090. }
  7091. $.datepicker._curInst = inst;
  7092. }
  7093. },
  7094. /* Generate the date picker content. */
  7095. _updateDatepicker: function(inst) {
  7096. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  7097. instActive = inst; // for delegate hover events
  7098. inst.dpDiv.empty().append(this._generateHTML(inst));
  7099. this._attachHandlers(inst);
  7100. inst.dpDiv.find("." + this._dayOverClass + " a").mouseover();
  7101. var origyearshtml,
  7102. numMonths = this._getNumberOfMonths(inst),
  7103. cols = numMonths[1],
  7104. width = 17;
  7105. inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
  7106. if (cols > 1) {
  7107. inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
  7108. }
  7109. inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
  7110. "Class"]("ui-datepicker-multi");
  7111. inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
  7112. "Class"]("ui-datepicker-rtl");
  7113. if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  7114. inst.input.focus();
  7115. }
  7116. // deffered render of the years select (to avoid flashes on Firefox)
  7117. if( inst.yearshtml ){
  7118. origyearshtml = inst.yearshtml;
  7119. setTimeout(function(){
  7120. //assure that inst.yearshtml didn't change.
  7121. if( origyearshtml === inst.yearshtml && inst.yearshtml ){
  7122. inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
  7123. }
  7124. origyearshtml = inst.yearshtml = null;
  7125. }, 0);
  7126. }
  7127. },
  7128. // #6694 - don't focus the input if it's already focused
  7129. // this breaks the change event in IE
  7130. // Support: IE and jQuery <1.9
  7131. _shouldFocusInput: function( inst ) {
  7132. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  7133. },
  7134. /* Check positioning to remain on screen. */
  7135. _checkOffset: function(inst, offset, isFixed) {
  7136. var dpWidth = inst.dpDiv.outerWidth(),
  7137. dpHeight = inst.dpDiv.outerHeight(),
  7138. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  7139. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  7140. viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
  7141. viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  7142. offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
  7143. offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
  7144. offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  7145. // now check if datepicker is showing outside window viewport - move to a better place if so.
  7146. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  7147. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  7148. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  7149. Math.abs(dpHeight + inputHeight) : 0);
  7150. return offset;
  7151. },
  7152. /* Find an object's position on the screen. */
  7153. _findPos: function(obj) {
  7154. var position,
  7155. inst = this._getInst(obj),
  7156. isRTL = this._get(inst, "isRTL");
  7157. while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
  7158. obj = obj[isRTL ? "previousSibling" : "nextSibling"];
  7159. }
  7160. position = $(obj).offset();
  7161. return [position.left, position.top];
  7162. },
  7163. /* Hide the date picker from view.
  7164. * @param input element - the input field attached to the date picker
  7165. */
  7166. _hideDatepicker: function(input) {
  7167. var showAnim, duration, postProcess, onClose,
  7168. inst = this._curInst;
  7169. if (!inst || (input && inst !== $.data(input, PROP_NAME))) {
  7170. return;
  7171. }
  7172. if (this._datepickerShowing) {
  7173. showAnim = this._get(inst, "showAnim");
  7174. duration = this._get(inst, "duration");
  7175. postProcess = function() {
  7176. $.datepicker._tidyDialog(inst);
  7177. };
  7178. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  7179. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  7180. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
  7181. } else {
  7182. inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
  7183. (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
  7184. }
  7185. if (!showAnim) {
  7186. postProcess();
  7187. }
  7188. this._datepickerShowing = false;
  7189. onClose = this._get(inst, "onClose");
  7190. if (onClose) {
  7191. onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
  7192. }
  7193. this._lastInput = null;
  7194. if (this._inDialog) {
  7195. this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
  7196. if ($.blockUI) {
  7197. $.unblockUI();
  7198. $("body").append(this.dpDiv);
  7199. }
  7200. }
  7201. this._inDialog = false;
  7202. }
  7203. },
  7204. /* Tidy up after a dialog display. */
  7205. _tidyDialog: function(inst) {
  7206. inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
  7207. },
  7208. /* Close date picker if clicked elsewhere. */
  7209. _checkExternalClick: function(event) {
  7210. if (!$.datepicker._curInst) {
  7211. return;
  7212. }
  7213. var $target = $(event.target),
  7214. inst = $.datepicker._getInst($target[0]);
  7215. if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
  7216. $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
  7217. !$target.hasClass($.datepicker.markerClassName) &&
  7218. !$target.closest("." + $.datepicker._triggerClass).length &&
  7219. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
  7220. ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
  7221. $.datepicker._hideDatepicker();
  7222. }
  7223. },
  7224. /* Adjust one of the date sub-fields. */
  7225. _adjustDate: function(id, offset, period) {
  7226. var target = $(id),
  7227. inst = this._getInst(target[0]);
  7228. if (this._isDisabledDatepicker(target[0])) {
  7229. return;
  7230. }
  7231. this._adjustInstDate(inst, offset +
  7232. (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
  7233. period);
  7234. this._updateDatepicker(inst);
  7235. },
  7236. /* Action for current link. */
  7237. _gotoToday: function(id) {
  7238. var date,
  7239. target = $(id),
  7240. inst = this._getInst(target[0]);
  7241. if (this._get(inst, "gotoCurrent") && inst.currentDay) {
  7242. inst.selectedDay = inst.currentDay;
  7243. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  7244. inst.drawYear = inst.selectedYear = inst.currentYear;
  7245. } else {
  7246. date = new Date();
  7247. inst.selectedDay = date.getDate();
  7248. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7249. inst.drawYear = inst.selectedYear = date.getFullYear();
  7250. }
  7251. this._notifyChange(inst);
  7252. this._adjustDate(target);
  7253. },
  7254. /* Action for selecting a new month/year. */
  7255. _selectMonthYear: function(id, select, period) {
  7256. var target = $(id),
  7257. inst = this._getInst(target[0]);
  7258. inst["selected" + (period === "M" ? "Month" : "Year")] =
  7259. inst["draw" + (period === "M" ? "Month" : "Year")] =
  7260. parseInt(select.options[select.selectedIndex].value,10);
  7261. this._notifyChange(inst);
  7262. this._adjustDate(target);
  7263. },
  7264. /* Action for selecting a day. */
  7265. _selectDay: function(id, month, year, td) {
  7266. var inst,
  7267. target = $(id);
  7268. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  7269. return;
  7270. }
  7271. inst = this._getInst(target[0]);
  7272. inst.selectedDay = inst.currentDay = $("a", td).html();
  7273. inst.selectedMonth = inst.currentMonth = month;
  7274. inst.selectedYear = inst.currentYear = year;
  7275. this._selectDate(id, this._formatDate(inst,
  7276. inst.currentDay, inst.currentMonth, inst.currentYear));
  7277. },
  7278. /* Erase the input field and hide the date picker. */
  7279. _clearDate: function(id) {
  7280. var target = $(id);
  7281. this._selectDate(target, "");
  7282. },
  7283. /* Update the input field with the selected date. */
  7284. _selectDate: function(id, dateStr) {
  7285. var onSelect,
  7286. target = $(id),
  7287. inst = this._getInst(target[0]);
  7288. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  7289. if (inst.input) {
  7290. inst.input.val(dateStr);
  7291. }
  7292. this._updateAlternate(inst);
  7293. onSelect = this._get(inst, "onSelect");
  7294. if (onSelect) {
  7295. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  7296. } else if (inst.input) {
  7297. inst.input.trigger("change"); // fire the change event
  7298. }
  7299. if (inst.inline){
  7300. this._updateDatepicker(inst);
  7301. } else {
  7302. this._hideDatepicker();
  7303. this._lastInput = inst.input[0];
  7304. if (typeof(inst.input[0]) !== "object") {
  7305. inst.input.focus(); // restore focus
  7306. }
  7307. this._lastInput = null;
  7308. }
  7309. },
  7310. /* Update any alternate field to synchronise with the main field. */
  7311. _updateAlternate: function(inst) {
  7312. var altFormat, date, dateStr,
  7313. altField = this._get(inst, "altField");
  7314. if (altField) { // update alternate field too
  7315. altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
  7316. date = this._getDate(inst);
  7317. dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  7318. $(altField).each(function() { $(this).val(dateStr); });
  7319. }
  7320. },
  7321. /* Set as beforeShowDay function to prevent selection of weekends.
  7322. * @param date Date - the date to customise
  7323. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  7324. */
  7325. noWeekends: function(date) {
  7326. var day = date.getDay();
  7327. return [(day > 0 && day < 6), ""];
  7328. },
  7329. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  7330. * @param date Date - the date to get the week for
  7331. * @return number - the number of the week within the year that contains this date
  7332. */
  7333. iso8601Week: function(date) {
  7334. var time,
  7335. checkDate = new Date(date.getTime());
  7336. // Find Thursday of this week starting on Monday
  7337. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  7338. time = checkDate.getTime();
  7339. checkDate.setMonth(0); // Compare with Jan 1
  7340. checkDate.setDate(1);
  7341. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  7342. },
  7343. /* Parse a string value into a date object.
  7344. * See formatDate below for the possible formats.
  7345. *
  7346. * @param format string - the expected format of the date
  7347. * @param value string - the date in the above format
  7348. * @param settings Object - attributes include:
  7349. * shortYearCutoff number - the cutoff year for determining the century (optional)
  7350. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7351. * dayNames string[7] - names of the days from Sunday (optional)
  7352. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7353. * monthNames string[12] - names of the months (optional)
  7354. * @return Date - the extracted date value or null if value is blank
  7355. */
  7356. parseDate: function (format, value, settings) {
  7357. if (format == null || value == null) {
  7358. throw "Invalid arguments";
  7359. }
  7360. value = (typeof value === "object" ? value.toString() : value + "");
  7361. if (value === "") {
  7362. return null;
  7363. }
  7364. var iFormat, dim, extra,
  7365. iValue = 0,
  7366. shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
  7367. shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  7368. new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
  7369. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  7370. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  7371. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  7372. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  7373. year = -1,
  7374. month = -1,
  7375. day = -1,
  7376. doy = -1,
  7377. literal = false,
  7378. date,
  7379. // Check whether a format character is doubled
  7380. lookAhead = function(match) {
  7381. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7382. if (matches) {
  7383. iFormat++;
  7384. }
  7385. return matches;
  7386. },
  7387. // Extract a number from the string value
  7388. getNumber = function(match) {
  7389. var isDoubled = lookAhead(match),
  7390. size = (match === "@" ? 14 : (match === "!" ? 20 :
  7391. (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
  7392. digits = new RegExp("^\\d{1," + size + "}"),
  7393. num = value.substring(iValue).match(digits);
  7394. if (!num) {
  7395. throw "Missing number at position " + iValue;
  7396. }
  7397. iValue += num[0].length;
  7398. return parseInt(num[0], 10);
  7399. },
  7400. // Extract a name from the string value and convert to an index
  7401. getName = function(match, shortNames, longNames) {
  7402. var index = -1,
  7403. names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  7404. return [ [k, v] ];
  7405. }).sort(function (a, b) {
  7406. return -(a[1].length - b[1].length);
  7407. });
  7408. $.each(names, function (i, pair) {
  7409. var name = pair[1];
  7410. if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
  7411. index = pair[0];
  7412. iValue += name.length;
  7413. return false;
  7414. }
  7415. });
  7416. if (index !== -1) {
  7417. return index + 1;
  7418. } else {
  7419. throw "Unknown name at position " + iValue;
  7420. }
  7421. },
  7422. // Confirm that a literal character matches the string value
  7423. checkLiteral = function() {
  7424. if (value.charAt(iValue) !== format.charAt(iFormat)) {
  7425. throw "Unexpected literal at position " + iValue;
  7426. }
  7427. iValue++;
  7428. };
  7429. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7430. if (literal) {
  7431. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7432. literal = false;
  7433. } else {
  7434. checkLiteral();
  7435. }
  7436. } else {
  7437. switch (format.charAt(iFormat)) {
  7438. case "d":
  7439. day = getNumber("d");
  7440. break;
  7441. case "D":
  7442. getName("D", dayNamesShort, dayNames);
  7443. break;
  7444. case "o":
  7445. doy = getNumber("o");
  7446. break;
  7447. case "m":
  7448. month = getNumber("m");
  7449. break;
  7450. case "M":
  7451. month = getName("M", monthNamesShort, monthNames);
  7452. break;
  7453. case "y":
  7454. year = getNumber("y");
  7455. break;
  7456. case "@":
  7457. date = new Date(getNumber("@"));
  7458. year = date.getFullYear();
  7459. month = date.getMonth() + 1;
  7460. day = date.getDate();
  7461. break;
  7462. case "!":
  7463. date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
  7464. year = date.getFullYear();
  7465. month = date.getMonth() + 1;
  7466. day = date.getDate();
  7467. break;
  7468. case "'":
  7469. if (lookAhead("'")){
  7470. checkLiteral();
  7471. } else {
  7472. literal = true;
  7473. }
  7474. break;
  7475. default:
  7476. checkLiteral();
  7477. }
  7478. }
  7479. }
  7480. if (iValue < value.length){
  7481. extra = value.substr(iValue);
  7482. if (!/^\s+/.test(extra)) {
  7483. throw "Extra/unparsed characters found in date: " + extra;
  7484. }
  7485. }
  7486. if (year === -1) {
  7487. year = new Date().getFullYear();
  7488. } else if (year < 100) {
  7489. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  7490. (year <= shortYearCutoff ? 0 : -100);
  7491. }
  7492. if (doy > -1) {
  7493. month = 1;
  7494. day = doy;
  7495. do {
  7496. dim = this._getDaysInMonth(year, month - 1);
  7497. if (day <= dim) {
  7498. break;
  7499. }
  7500. month++;
  7501. day -= dim;
  7502. } while (true);
  7503. }
  7504. date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  7505. if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
  7506. throw "Invalid date"; // E.g. 31/02/00
  7507. }
  7508. return date;
  7509. },
  7510. /* Standard date formats. */
  7511. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  7512. COOKIE: "D, dd M yy",
  7513. ISO_8601: "yy-mm-dd",
  7514. RFC_822: "D, d M y",
  7515. RFC_850: "DD, dd-M-y",
  7516. RFC_1036: "D, d M y",
  7517. RFC_1123: "D, d M yy",
  7518. RFC_2822: "D, d M yy",
  7519. RSS: "D, d M y", // RFC 822
  7520. TICKS: "!",
  7521. TIMESTAMP: "@",
  7522. W3C: "yy-mm-dd", // ISO 8601
  7523. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  7524. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  7525. /* Format a date object into a string value.
  7526. * The format can be combinations of the following:
  7527. * d - day of month (no leading zero)
  7528. * dd - day of month (two digit)
  7529. * o - day of year (no leading zeros)
  7530. * oo - day of year (three digit)
  7531. * D - day name short
  7532. * DD - day name long
  7533. * m - month of year (no leading zero)
  7534. * mm - month of year (two digit)
  7535. * M - month name short
  7536. * MM - month name long
  7537. * y - year (two digit)
  7538. * yy - year (four digit)
  7539. * @ - Unix timestamp (ms since 01/01/1970)
  7540. * ! - Windows ticks (100ns since 01/01/0001)
  7541. * "..." - literal text
  7542. * '' - single quote
  7543. *
  7544. * @param format string - the desired format of the date
  7545. * @param date Date - the date value to format
  7546. * @param settings Object - attributes include:
  7547. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7548. * dayNames string[7] - names of the days from Sunday (optional)
  7549. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7550. * monthNames string[12] - names of the months (optional)
  7551. * @return string - the date in the above format
  7552. */
  7553. formatDate: function (format, date, settings) {
  7554. if (!date) {
  7555. return "";
  7556. }
  7557. var iFormat,
  7558. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  7559. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  7560. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  7561. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  7562. // Check whether a format character is doubled
  7563. lookAhead = function(match) {
  7564. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7565. if (matches) {
  7566. iFormat++;
  7567. }
  7568. return matches;
  7569. },
  7570. // Format a number, with leading zero if necessary
  7571. formatNumber = function(match, value, len) {
  7572. var num = "" + value;
  7573. if (lookAhead(match)) {
  7574. while (num.length < len) {
  7575. num = "0" + num;
  7576. }
  7577. }
  7578. return num;
  7579. },
  7580. // Format a name, short or long as requested
  7581. formatName = function(match, value, shortNames, longNames) {
  7582. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  7583. },
  7584. output = "",
  7585. literal = false;
  7586. if (date) {
  7587. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7588. if (literal) {
  7589. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7590. literal = false;
  7591. } else {
  7592. output += format.charAt(iFormat);
  7593. }
  7594. } else {
  7595. switch (format.charAt(iFormat)) {
  7596. case "d":
  7597. output += formatNumber("d", date.getDate(), 2);
  7598. break;
  7599. case "D":
  7600. output += formatName("D", date.getDay(), dayNamesShort, dayNames);
  7601. break;
  7602. case "o":
  7603. output += formatNumber("o",
  7604. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  7605. break;
  7606. case "m":
  7607. output += formatNumber("m", date.getMonth() + 1, 2);
  7608. break;
  7609. case "M":
  7610. output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
  7611. break;
  7612. case "y":
  7613. output += (lookAhead("y") ? date.getFullYear() :
  7614. (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
  7615. break;
  7616. case "@":
  7617. output += date.getTime();
  7618. break;
  7619. case "!":
  7620. output += date.getTime() * 10000 + this._ticksTo1970;
  7621. break;
  7622. case "'":
  7623. if (lookAhead("'")) {
  7624. output += "'";
  7625. } else {
  7626. literal = true;
  7627. }
  7628. break;
  7629. default:
  7630. output += format.charAt(iFormat);
  7631. }
  7632. }
  7633. }
  7634. }
  7635. return output;
  7636. },
  7637. /* Extract all possible characters from the date format. */
  7638. _possibleChars: function (format) {
  7639. var iFormat,
  7640. chars = "",
  7641. literal = false,
  7642. // Check whether a format character is doubled
  7643. lookAhead = function(match) {
  7644. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7645. if (matches) {
  7646. iFormat++;
  7647. }
  7648. return matches;
  7649. };
  7650. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7651. if (literal) {
  7652. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7653. literal = false;
  7654. } else {
  7655. chars += format.charAt(iFormat);
  7656. }
  7657. } else {
  7658. switch (format.charAt(iFormat)) {
  7659. case "d": case "m": case "y": case "@":
  7660. chars += "0123456789";
  7661. break;
  7662. case "D": case "M":
  7663. return null; // Accept anything
  7664. case "'":
  7665. if (lookAhead("'")) {
  7666. chars += "'";
  7667. } else {
  7668. literal = true;
  7669. }
  7670. break;
  7671. default:
  7672. chars += format.charAt(iFormat);
  7673. }
  7674. }
  7675. }
  7676. return chars;
  7677. },
  7678. /* Get a setting value, defaulting if necessary. */
  7679. _get: function(inst, name) {
  7680. return inst.settings[name] !== undefined ?
  7681. inst.settings[name] : this._defaults[name];
  7682. },
  7683. /* Parse existing date and initialise date picker. */
  7684. _setDateFromField: function(inst, noDefault) {
  7685. if (inst.input.val() === inst.lastVal) {
  7686. return;
  7687. }
  7688. var dateFormat = this._get(inst, "dateFormat"),
  7689. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  7690. defaultDate = this._getDefaultDate(inst),
  7691. date = defaultDate,
  7692. settings = this._getFormatConfig(inst);
  7693. try {
  7694. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  7695. } catch (event) {
  7696. dates = (noDefault ? "" : dates);
  7697. }
  7698. inst.selectedDay = date.getDate();
  7699. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7700. inst.drawYear = inst.selectedYear = date.getFullYear();
  7701. inst.currentDay = (dates ? date.getDate() : 0);
  7702. inst.currentMonth = (dates ? date.getMonth() : 0);
  7703. inst.currentYear = (dates ? date.getFullYear() : 0);
  7704. this._adjustInstDate(inst);
  7705. },
  7706. /* Retrieve the default date shown on opening. */
  7707. _getDefaultDate: function(inst) {
  7708. return this._restrictMinMax(inst,
  7709. this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
  7710. },
  7711. /* A date may be specified as an exact value or a relative one. */
  7712. _determineDate: function(inst, date, defaultDate) {
  7713. var offsetNumeric = function(offset) {
  7714. var date = new Date();
  7715. date.setDate(date.getDate() + offset);
  7716. return date;
  7717. },
  7718. offsetString = function(offset) {
  7719. try {
  7720. return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  7721. offset, $.datepicker._getFormatConfig(inst));
  7722. }
  7723. catch (e) {
  7724. // Ignore
  7725. }
  7726. var date = (offset.toLowerCase().match(/^c/) ?
  7727. $.datepicker._getDate(inst) : null) || new Date(),
  7728. year = date.getFullYear(),
  7729. month = date.getMonth(),
  7730. day = date.getDate(),
  7731. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  7732. matches = pattern.exec(offset);
  7733. while (matches) {
  7734. switch (matches[2] || "d") {
  7735. case "d" : case "D" :
  7736. day += parseInt(matches[1],10); break;
  7737. case "w" : case "W" :
  7738. day += parseInt(matches[1],10) * 7; break;
  7739. case "m" : case "M" :
  7740. month += parseInt(matches[1],10);
  7741. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  7742. break;
  7743. case "y": case "Y" :
  7744. year += parseInt(matches[1],10);
  7745. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  7746. break;
  7747. }
  7748. matches = pattern.exec(offset);
  7749. }
  7750. return new Date(year, month, day);
  7751. },
  7752. newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
  7753. (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  7754. newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
  7755. if (newDate) {
  7756. newDate.setHours(0);
  7757. newDate.setMinutes(0);
  7758. newDate.setSeconds(0);
  7759. newDate.setMilliseconds(0);
  7760. }
  7761. return this._daylightSavingAdjust(newDate);
  7762. },
  7763. /* Handle switch to/from daylight saving.
  7764. * Hours may be non-zero on daylight saving cut-over:
  7765. * > 12 when midnight changeover, but then cannot generate
  7766. * midnight datetime, so jump to 1AM, otherwise reset.
  7767. * @param date (Date) the date to check
  7768. * @return (Date) the corrected date
  7769. */
  7770. _daylightSavingAdjust: function(date) {
  7771. if (!date) {
  7772. return null;
  7773. }
  7774. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  7775. return date;
  7776. },
  7777. /* Set the date(s) directly. */
  7778. _setDate: function(inst, date, noChange) {
  7779. var clear = !date,
  7780. origMonth = inst.selectedMonth,
  7781. origYear = inst.selectedYear,
  7782. newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  7783. inst.selectedDay = inst.currentDay = newDate.getDate();
  7784. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  7785. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  7786. if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
  7787. this._notifyChange(inst);
  7788. }
  7789. this._adjustInstDate(inst);
  7790. if (inst.input) {
  7791. inst.input.val(clear ? "" : this._formatDate(inst));
  7792. }
  7793. },
  7794. /* Retrieve the date(s) directly. */
  7795. _getDate: function(inst) {
  7796. var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
  7797. this._daylightSavingAdjust(new Date(
  7798. inst.currentYear, inst.currentMonth, inst.currentDay)));
  7799. return startDate;
  7800. },
  7801. /* Attach the onxxx handlers. These are declared statically so
  7802. * they work with static code transformers like Caja.
  7803. */
  7804. _attachHandlers: function(inst) {
  7805. var stepMonths = this._get(inst, "stepMonths"),
  7806. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  7807. inst.dpDiv.find("[data-handler]").map(function () {
  7808. var handler = {
  7809. prev: function () {
  7810. $.datepicker._adjustDate(id, -stepMonths, "M");
  7811. },
  7812. next: function () {
  7813. $.datepicker._adjustDate(id, +stepMonths, "M");
  7814. },
  7815. hide: function () {
  7816. $.datepicker._hideDatepicker();
  7817. },
  7818. today: function () {
  7819. $.datepicker._gotoToday(id);
  7820. },
  7821. selectDay: function () {
  7822. $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
  7823. return false;
  7824. },
  7825. selectMonth: function () {
  7826. $.datepicker._selectMonthYear(id, this, "M");
  7827. return false;
  7828. },
  7829. selectYear: function () {
  7830. $.datepicker._selectMonthYear(id, this, "Y");
  7831. return false;
  7832. }
  7833. };
  7834. $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
  7835. });
  7836. },
  7837. /* Generate the HTML for the current state of the date picker. */
  7838. _generateHTML: function(inst) {
  7839. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  7840. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  7841. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  7842. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  7843. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  7844. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  7845. tempDate = new Date(),
  7846. today = this._daylightSavingAdjust(
  7847. new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
  7848. isRTL = this._get(inst, "isRTL"),
  7849. showButtonPanel = this._get(inst, "showButtonPanel"),
  7850. hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
  7851. navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
  7852. numMonths = this._getNumberOfMonths(inst),
  7853. showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
  7854. stepMonths = this._get(inst, "stepMonths"),
  7855. isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
  7856. currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  7857. new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
  7858. minDate = this._getMinMaxDate(inst, "min"),
  7859. maxDate = this._getMinMaxDate(inst, "max"),
  7860. drawMonth = inst.drawMonth - showCurrentAtPos,
  7861. drawYear = inst.drawYear;
  7862. if (drawMonth < 0) {
  7863. drawMonth += 12;
  7864. drawYear--;
  7865. }
  7866. if (maxDate) {
  7867. maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  7868. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  7869. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  7870. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  7871. drawMonth--;
  7872. if (drawMonth < 0) {
  7873. drawMonth = 11;
  7874. drawYear--;
  7875. }
  7876. }
  7877. }
  7878. inst.drawMonth = drawMonth;
  7879. inst.drawYear = drawYear;
  7880. prevText = this._get(inst, "prevText");
  7881. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  7882. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  7883. this._getFormatConfig(inst)));
  7884. prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  7885. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  7886. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
  7887. (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>"));
  7888. nextText = this._get(inst, "nextText");
  7889. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  7890. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  7891. this._getFormatConfig(inst)));
  7892. next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  7893. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  7894. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
  7895. (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>"));
  7896. currentText = this._get(inst, "currentText");
  7897. gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
  7898. currentText = (!navigationAsDateFormat ? currentText :
  7899. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  7900. 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'>" +
  7901. this._get(inst, "closeText") + "</button>" : "");
  7902. buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
  7903. (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'" +
  7904. ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
  7905. firstDay = parseInt(this._get(inst, "firstDay"),10);
  7906. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  7907. showWeek = this._get(inst, "showWeek");
  7908. dayNames = this._get(inst, "dayNames");
  7909. dayNamesMin = this._get(inst, "dayNamesMin");
  7910. monthNames = this._get(inst, "monthNames");
  7911. monthNamesShort = this._get(inst, "monthNamesShort");
  7912. beforeShowDay = this._get(inst, "beforeShowDay");
  7913. showOtherMonths = this._get(inst, "showOtherMonths");
  7914. selectOtherMonths = this._get(inst, "selectOtherMonths");
  7915. defaultDate = this._getDefaultDate(inst);
  7916. html = "";
  7917. dow;
  7918. for (row = 0; row < numMonths[0]; row++) {
  7919. group = "";
  7920. this.maxRows = 4;
  7921. for (col = 0; col < numMonths[1]; col++) {
  7922. selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  7923. cornerClass = " ui-corner-all";
  7924. calender = "";
  7925. if (isMultiMonth) {
  7926. calender += "<div class='ui-datepicker-group";
  7927. if (numMonths[1] > 1) {
  7928. switch (col) {
  7929. case 0: calender += " ui-datepicker-group-first";
  7930. cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
  7931. case numMonths[1]-1: calender += " ui-datepicker-group-last";
  7932. cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
  7933. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  7934. }
  7935. }
  7936. calender += "'>";
  7937. }
  7938. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  7939. (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
  7940. (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
  7941. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  7942. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  7943. "</div><table class='ui-datepicker-calendar'><thead>" +
  7944. "<tr>";
  7945. thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
  7946. for (dow = 0; dow < 7; dow++) { // days of the week
  7947. day = (dow + firstDay) % 7;
  7948. thead += "<th" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
  7949. "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
  7950. }
  7951. calender += thead + "</tr></thead><tbody>";
  7952. daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  7953. if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
  7954. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  7955. }
  7956. leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  7957. curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  7958. numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  7959. this.maxRows = numRows;
  7960. printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  7961. for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  7962. calender += "<tr>";
  7963. tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  7964. this._get(inst, "calculateWeek")(printDate) + "</td>");
  7965. for (dow = 0; dow < 7; dow++) { // create date picker days
  7966. daySettings = (beforeShowDay ?
  7967. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
  7968. otherMonth = (printDate.getMonth() !== drawMonth);
  7969. unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  7970. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  7971. tbody += "<td class='" +
  7972. ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
  7973. (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
  7974. ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
  7975. (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
  7976. // or defaultDate is current printedDate and defaultDate is selectedDate
  7977. " " + this._dayOverClass : "") + // highlight selected day
  7978. (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days
  7979. (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
  7980. (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
  7981. (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
  7982. ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
  7983. (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
  7984. (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  7985. (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  7986. (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
  7987. (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
  7988. (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
  7989. "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
  7990. printDate.setDate(printDate.getDate() + 1);
  7991. printDate = this._daylightSavingAdjust(printDate);
  7992. }
  7993. calender += tbody + "</tr>";
  7994. }
  7995. drawMonth++;
  7996. if (drawMonth > 11) {
  7997. drawMonth = 0;
  7998. drawYear++;
  7999. }
  8000. calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
  8001. ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
  8002. group += calender;
  8003. }
  8004. html += group;
  8005. }
  8006. html += buttonPanel;
  8007. inst._keyEvent = false;
  8008. return html;
  8009. },
  8010. /* Generate the month and year header. */
  8011. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  8012. secondary, monthNames, monthNamesShort) {
  8013. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  8014. changeMonth = this._get(inst, "changeMonth"),
  8015. changeYear = this._get(inst, "changeYear"),
  8016. showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
  8017. html = "<div class='ui-datepicker-title'>",
  8018. monthHtml = "";
  8019. // month selection
  8020. if (secondary || !changeMonth) {
  8021. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
  8022. } else {
  8023. inMinYear = (minDate && minDate.getFullYear() === drawYear);
  8024. inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
  8025. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  8026. for ( month = 0; month < 12; month++) {
  8027. if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
  8028. monthHtml += "<option value='" + month + "'" +
  8029. (month === drawMonth ? " selected='selected'" : "") +
  8030. ">" + monthNamesShort[month] + "</option>";
  8031. }
  8032. }
  8033. monthHtml += "</select>";
  8034. }
  8035. if (!showMonthAfterYear) {
  8036. html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
  8037. }
  8038. // year selection
  8039. if ( !inst.yearshtml ) {
  8040. inst.yearshtml = "";
  8041. if (secondary || !changeYear) {
  8042. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  8043. } else {
  8044. // determine range of years to display
  8045. years = this._get(inst, "yearRange").split(":");
  8046. thisYear = new Date().getFullYear();
  8047. determineYear = function(value) {
  8048. var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  8049. (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
  8050. parseInt(value, 10)));
  8051. return (isNaN(year) ? thisYear : year);
  8052. };
  8053. year = determineYear(years[0]);
  8054. endYear = Math.max(year, determineYear(years[1] || ""));
  8055. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  8056. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  8057. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  8058. for (; year <= endYear; year++) {
  8059. inst.yearshtml += "<option value='" + year + "'" +
  8060. (year === drawYear ? " selected='selected'" : "") +
  8061. ">" + year + "</option>";
  8062. }
  8063. inst.yearshtml += "</select>";
  8064. html += inst.yearshtml;
  8065. inst.yearshtml = null;
  8066. }
  8067. }
  8068. html += this._get(inst, "yearSuffix");
  8069. if (showMonthAfterYear) {
  8070. html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
  8071. }
  8072. html += "</div>"; // Close datepicker_header
  8073. return html;
  8074. },
  8075. /* Adjust one of the date sub-fields. */
  8076. _adjustInstDate: function(inst, offset, period) {
  8077. var year = inst.drawYear + (period === "Y" ? offset : 0),
  8078. month = inst.drawMonth + (period === "M" ? offset : 0),
  8079. day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
  8080. date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
  8081. inst.selectedDay = date.getDate();
  8082. inst.drawMonth = inst.selectedMonth = date.getMonth();
  8083. inst.drawYear = inst.selectedYear = date.getFullYear();
  8084. if (period === "M" || period === "Y") {
  8085. this._notifyChange(inst);
  8086. }
  8087. },
  8088. /* Ensure a date is within any min/max bounds. */
  8089. _restrictMinMax: function(inst, date) {
  8090. var minDate = this._getMinMaxDate(inst, "min"),
  8091. maxDate = this._getMinMaxDate(inst, "max"),
  8092. newDate = (minDate && date < minDate ? minDate : date);
  8093. return (maxDate && newDate > maxDate ? maxDate : newDate);
  8094. },
  8095. /* Notify change of month/year. */
  8096. _notifyChange: function(inst) {
  8097. var onChange = this._get(inst, "onChangeMonthYear");
  8098. if (onChange) {
  8099. onChange.apply((inst.input ? inst.input[0] : null),
  8100. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  8101. }
  8102. },
  8103. /* Determine the number of months to show. */
  8104. _getNumberOfMonths: function(inst) {
  8105. var numMonths = this._get(inst, "numberOfMonths");
  8106. return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
  8107. },
  8108. /* Determine the current maximum date - ensure no time components are set. */
  8109. _getMinMaxDate: function(inst, minMax) {
  8110. return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
  8111. },
  8112. /* Find the number of days in a given month. */
  8113. _getDaysInMonth: function(year, month) {
  8114. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  8115. },
  8116. /* Find the day of the week of the first of a month. */
  8117. _getFirstDayOfMonth: function(year, month) {
  8118. return new Date(year, month, 1).getDay();
  8119. },
  8120. /* Determines if we should allow a "next/prev" month display change. */
  8121. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  8122. var numMonths = this._getNumberOfMonths(inst),
  8123. date = this._daylightSavingAdjust(new Date(curYear,
  8124. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  8125. if (offset < 0) {
  8126. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  8127. }
  8128. return this._isInRange(inst, date);
  8129. },
  8130. /* Is the given date in the accepted range? */
  8131. _isInRange: function(inst, date) {
  8132. var yearSplit, currentYear,
  8133. minDate = this._getMinMaxDate(inst, "min"),
  8134. maxDate = this._getMinMaxDate(inst, "max"),
  8135. minYear = null,
  8136. maxYear = null,
  8137. years = this._get(inst, "yearRange");
  8138. if (years){
  8139. yearSplit = years.split(":");
  8140. currentYear = new Date().getFullYear();
  8141. minYear = parseInt(yearSplit[0], 10);
  8142. maxYear = parseInt(yearSplit[1], 10);
  8143. if ( yearSplit[0].match(/[+\-].*/) ) {
  8144. minYear += currentYear;
  8145. }
  8146. if ( yearSplit[1].match(/[+\-].*/) ) {
  8147. maxYear += currentYear;
  8148. }
  8149. }
  8150. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  8151. (!maxDate || date.getTime() <= maxDate.getTime()) &&
  8152. (!minYear || date.getFullYear() >= minYear) &&
  8153. (!maxYear || date.getFullYear() <= maxYear));
  8154. },
  8155. /* Provide the configuration settings for formatting/parsing. */
  8156. _getFormatConfig: function(inst) {
  8157. var shortYearCutoff = this._get(inst, "shortYearCutoff");
  8158. shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
  8159. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  8160. return {shortYearCutoff: shortYearCutoff,
  8161. dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
  8162. monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
  8163. },
  8164. /* Format the given date for display. */
  8165. _formatDate: function(inst, day, month, year) {
  8166. if (!day) {
  8167. inst.currentDay = inst.selectedDay;
  8168. inst.currentMonth = inst.selectedMonth;
  8169. inst.currentYear = inst.selectedYear;
  8170. }
  8171. var date = (day ? (typeof day === "object" ? day :
  8172. this._daylightSavingAdjust(new Date(year, month, day))) :
  8173. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  8174. return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
  8175. }
  8176. });
  8177. /*
  8178. * Bind hover events for datepicker elements.
  8179. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  8180. * Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  8181. */
  8182. function bindHover(dpDiv) {
  8183. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  8184. return dpDiv.delegate(selector, "mouseout", function() {
  8185. $(this).removeClass("ui-state-hover");
  8186. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  8187. $(this).removeClass("ui-datepicker-prev-hover");
  8188. }
  8189. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  8190. $(this).removeClass("ui-datepicker-next-hover");
  8191. }
  8192. })
  8193. .delegate(selector, "mouseover", function(){
  8194. if (!$.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0])) {
  8195. $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
  8196. $(this).addClass("ui-state-hover");
  8197. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  8198. $(this).addClass("ui-datepicker-prev-hover");
  8199. }
  8200. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  8201. $(this).addClass("ui-datepicker-next-hover");
  8202. }
  8203. }
  8204. });
  8205. }
  8206. /* jQuery extend now ignores nulls! */
  8207. function extendRemove(target, props) {
  8208. $.extend(target, props);
  8209. for (var name in props) {
  8210. if (props[name] == null) {
  8211. target[name] = props[name];
  8212. }
  8213. }
  8214. return target;
  8215. }
  8216. /* Invoke the datepicker functionality.
  8217. @param options string - a command, optionally followed by additional parameters or
  8218. Object - settings for attaching new datepicker functionality
  8219. @return jQuery object */
  8220. $.fn.datepicker = function(options){
  8221. /* Verify an empty collection wasn't passed - Fixes #6976 */
  8222. if ( !this.length ) {
  8223. return this;
  8224. }
  8225. /* Initialise the date picker. */
  8226. if (!$.datepicker.initialized) {
  8227. $(document).mousedown($.datepicker._checkExternalClick);
  8228. $.datepicker.initialized = true;
  8229. }
  8230. /* Append datepicker main container to body if not exist. */
  8231. if ($("#"+$.datepicker._mainDivId).length === 0) {
  8232. $("body").append($.datepicker.dpDiv);
  8233. }
  8234. var otherArgs = Array.prototype.slice.call(arguments, 1);
  8235. if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
  8236. return $.datepicker["_" + options + "Datepicker"].
  8237. apply($.datepicker, [this[0]].concat(otherArgs));
  8238. }
  8239. if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
  8240. return $.datepicker["_" + options + "Datepicker"].
  8241. apply($.datepicker, [this[0]].concat(otherArgs));
  8242. }
  8243. return this.each(function() {
  8244. typeof options === "string" ?
  8245. $.datepicker["_" + options + "Datepicker"].
  8246. apply($.datepicker, [this].concat(otherArgs)) :
  8247. $.datepicker._attachDatepicker(this, options);
  8248. });
  8249. };
  8250. $.datepicker = new Datepicker(); // singleton instance
  8251. $.datepicker.initialized = false;
  8252. $.datepicker.uuid = new Date().getTime();
  8253. $.datepicker.version = "1.10.3";
  8254. })(jQuery);
  8255. (function( $, undefined ) {
  8256. var sizeRelatedOptions = {
  8257. buttons: true,
  8258. height: true,
  8259. maxHeight: true,
  8260. maxWidth: true,
  8261. minHeight: true,
  8262. minWidth: true,
  8263. width: true
  8264. },
  8265. resizableRelatedOptions = {
  8266. maxHeight: true,
  8267. maxWidth: true,
  8268. minHeight: true,
  8269. minWidth: true
  8270. };
  8271. $.widget( "ui.dialog", {
  8272. version: "1.10.3",
  8273. options: {
  8274. appendTo: "body",
  8275. autoOpen: true,
  8276. buttons: [],
  8277. closeOnEscape: true,
  8278. closeText: "close",
  8279. dialogClass: "",
  8280. draggable: true,
  8281. hide: null,
  8282. height: "auto",
  8283. maxHeight: null,
  8284. maxWidth: null,
  8285. minHeight: 150,
  8286. minWidth: 150,
  8287. modal: false,
  8288. position: {
  8289. my: "center",
  8290. at: "center",
  8291. of: window,
  8292. collision: "fit",
  8293. // Ensure the titlebar is always visible
  8294. using: function( pos ) {
  8295. var topOffset = $( this ).css( pos ).offset().top;
  8296. if ( topOffset < 0 ) {
  8297. $( this ).css( "top", pos.top - topOffset );
  8298. }
  8299. }
  8300. },
  8301. resizable: true,
  8302. show: null,
  8303. title: null,
  8304. width: 300,
  8305. // callbacks
  8306. beforeClose: null,
  8307. close: null,
  8308. drag: null,
  8309. dragStart: null,
  8310. dragStop: null,
  8311. focus: null,
  8312. open: null,
  8313. resize: null,
  8314. resizeStart: null,
  8315. resizeStop: null
  8316. },
  8317. _create: function() {
  8318. this.originalCss = {
  8319. display: this.element[0].style.display,
  8320. width: this.element[0].style.width,
  8321. minHeight: this.element[0].style.minHeight,
  8322. maxHeight: this.element[0].style.maxHeight,
  8323. height: this.element[0].style.height
  8324. };
  8325. this.originalPosition = {
  8326. parent: this.element.parent(),
  8327. index: this.element.parent().children().index( this.element )
  8328. };
  8329. this.originalTitle = this.element.attr("title");
  8330. this.options.title = this.options.title || this.originalTitle;
  8331. this._createWrapper();
  8332. this.element
  8333. .show()
  8334. .removeAttr("title")
  8335. .addClass("ui-dialog-content ui-widget-content")
  8336. .appendTo( this.uiDialog );
  8337. this._createTitlebar();
  8338. this._createButtonPane();
  8339. if ( this.options.draggable && $.fn.draggable ) {
  8340. this._makeDraggable();
  8341. }
  8342. if ( this.options.resizable && $.fn.resizable ) {
  8343. this._makeResizable();
  8344. }
  8345. this._isOpen = false;
  8346. },
  8347. _init: function() {
  8348. if ( this.options.autoOpen ) {
  8349. this.open();
  8350. }
  8351. },
  8352. _appendTo: function() {
  8353. var element = this.options.appendTo;
  8354. if ( element && (element.jquery || element.nodeType) ) {
  8355. return $( element );
  8356. }
  8357. return this.document.find( element || "body" ).eq( 0 );
  8358. },
  8359. _destroy: function() {
  8360. var next,
  8361. originalPosition = this.originalPosition;
  8362. this._destroyOverlay();
  8363. this.element
  8364. .removeUniqueId()
  8365. .removeClass("ui-dialog-content ui-widget-content")
  8366. .css( this.originalCss )
  8367. // Without detaching first, the following becomes really slow
  8368. .detach();
  8369. this.uiDialog.stop( true, true ).remove();
  8370. if ( this.originalTitle ) {
  8371. this.element.attr( "title", this.originalTitle );
  8372. }
  8373. next = originalPosition.parent.children().eq( originalPosition.index );
  8374. // Don't try to place the dialog next to itself (#8613)
  8375. if ( next.length && next[0] !== this.element[0] ) {
  8376. next.before( this.element );
  8377. } else {
  8378. originalPosition.parent.append( this.element );
  8379. }
  8380. },
  8381. widget: function() {
  8382. return this.uiDialog;
  8383. },
  8384. disable: $.noop,
  8385. enable: $.noop,
  8386. close: function( event ) {
  8387. var that = this;
  8388. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  8389. return;
  8390. }
  8391. this._isOpen = false;
  8392. this._destroyOverlay();
  8393. if ( !this.opener.filter(":focusable").focus().length ) {
  8394. // Hiding a focused element doesn't trigger blur in WebKit
  8395. // so in case we have nothing to focus on, explicitly blur the active element
  8396. // https://bugs.webkit.org/show_bug.cgi?id=47182
  8397. $( this.document[0].activeElement ).blur();
  8398. }
  8399. this._hide( this.uiDialog, this.options.hide, function() {
  8400. that._trigger( "close", event );
  8401. });
  8402. },
  8403. isOpen: function() {
  8404. return this._isOpen;
  8405. },
  8406. moveToTop: function() {
  8407. this._moveToTop();
  8408. },
  8409. _moveToTop: function( event, silent ) {
  8410. var moved = !!this.uiDialog.nextAll(":visible").insertBefore( this.uiDialog ).length;
  8411. if ( moved && !silent ) {
  8412. this._trigger( "focus", event );
  8413. }
  8414. return moved;
  8415. },
  8416. open: function() {
  8417. var that = this;
  8418. if ( this._isOpen ) {
  8419. if ( this._moveToTop() ) {
  8420. this._focusTabbable();
  8421. }
  8422. return;
  8423. }
  8424. this._isOpen = true;
  8425. this.opener = $( this.document[0].activeElement );
  8426. this._size();
  8427. this._position();
  8428. this._createOverlay();
  8429. this._moveToTop( null, true );
  8430. this._show( this.uiDialog, this.options.show, function() {
  8431. that._focusTabbable();
  8432. that._trigger("focus");
  8433. });
  8434. this._trigger("open");
  8435. },
  8436. _focusTabbable: function() {
  8437. // Set focus to the first match:
  8438. // 1. First element inside the dialog matching [autofocus]
  8439. // 2. Tabbable element inside the content element
  8440. // 3. Tabbable element inside the buttonpane
  8441. // 4. The close button
  8442. // 5. The dialog itself
  8443. var hasFocus = this.element.find("[autofocus]");
  8444. if ( !hasFocus.length ) {
  8445. hasFocus = this.element.find(":tabbable");
  8446. }
  8447. if ( !hasFocus.length ) {
  8448. hasFocus = this.uiDialogButtonPane.find(":tabbable");
  8449. }
  8450. if ( !hasFocus.length ) {
  8451. hasFocus = this.uiDialogTitlebarClose.filter(":tabbable");
  8452. }
  8453. if ( !hasFocus.length ) {
  8454. hasFocus = this.uiDialog;
  8455. }
  8456. hasFocus.eq( 0 ).focus();
  8457. },
  8458. _keepFocus: function( event ) {
  8459. function checkFocus() {
  8460. var activeElement = this.document[0].activeElement,
  8461. isActive = this.uiDialog[0] === activeElement ||
  8462. $.contains( this.uiDialog[0], activeElement );
  8463. if ( !isActive ) {
  8464. this._focusTabbable();
  8465. }
  8466. }
  8467. event.preventDefault();
  8468. checkFocus.call( this );
  8469. // support: IE
  8470. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  8471. // so we check again later
  8472. this._delay( checkFocus );
  8473. },
  8474. _createWrapper: function() {
  8475. this.uiDialog = $("<div>")
  8476. .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
  8477. this.options.dialogClass )
  8478. .hide()
  8479. .attr({
  8480. // Setting tabIndex makes the div focusable
  8481. tabIndex: -1,
  8482. role: "dialog"
  8483. })
  8484. .appendTo( this._appendTo() );
  8485. this._on( this.uiDialog, {
  8486. keydown: function( event ) {
  8487. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  8488. event.keyCode === $.ui.keyCode.ESCAPE ) {
  8489. event.preventDefault();
  8490. this.close( event );
  8491. return;
  8492. }
  8493. // prevent tabbing out of dialogs
  8494. if ( event.keyCode !== $.ui.keyCode.TAB ) {
  8495. return;
  8496. }
  8497. var tabbables = this.uiDialog.find(":tabbable"),
  8498. first = tabbables.filter(":first"),
  8499. last = tabbables.filter(":last");
  8500. if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) {
  8501. first.focus( 1 );
  8502. event.preventDefault();
  8503. } else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
  8504. last.focus( 1 );
  8505. event.preventDefault();
  8506. }
  8507. },
  8508. mousedown: function( event ) {
  8509. if ( this._moveToTop( event ) ) {
  8510. this._focusTabbable();
  8511. }
  8512. }
  8513. });
  8514. // We assume that any existing aria-describedby attribute means
  8515. // that the dialog content is marked up properly
  8516. // otherwise we brute force the content as the description
  8517. if ( !this.element.find("[aria-describedby]").length ) {
  8518. this.uiDialog.attr({
  8519. "aria-describedby": this.element.uniqueId().attr("id")
  8520. });
  8521. }
  8522. },
  8523. _createTitlebar: function() {
  8524. var uiDialogTitle;
  8525. this.uiDialogTitlebar = $("<div>")
  8526. .addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix")
  8527. .prependTo( this.uiDialog );
  8528. this._on( this.uiDialogTitlebar, {
  8529. mousedown: function( event ) {
  8530. // Don't prevent click on close button (#8838)
  8531. // Focusing a dialog that is partially scrolled out of view
  8532. // causes the browser to scroll it into view, preventing the click event
  8533. if ( !$( event.target ).closest(".ui-dialog-titlebar-close") ) {
  8534. // Dialog isn't getting focus when dragging (#8063)
  8535. this.uiDialog.focus();
  8536. }
  8537. }
  8538. });
  8539. this.uiDialogTitlebarClose = $("<button></button>")
  8540. .button({
  8541. label: this.options.closeText,
  8542. icons: {
  8543. primary: "ui-icon-closethick"
  8544. },
  8545. text: false
  8546. })
  8547. .addClass("ui-dialog-titlebar-close")
  8548. .appendTo( this.uiDialogTitlebar );
  8549. this._on( this.uiDialogTitlebarClose, {
  8550. click: function( event ) {
  8551. event.preventDefault();
  8552. this.close( event );
  8553. }
  8554. });
  8555. uiDialogTitle = $("<span>")
  8556. .uniqueId()
  8557. .addClass("ui-dialog-title")
  8558. .prependTo( this.uiDialogTitlebar );
  8559. this._title( uiDialogTitle );
  8560. this.uiDialog.attr({
  8561. "aria-labelledby": uiDialogTitle.attr("id")
  8562. });
  8563. },
  8564. _title: function( title ) {
  8565. if ( !this.options.title ) {
  8566. title.html("&#160;");
  8567. }
  8568. title.text( this.options.title );
  8569. },
  8570. _createButtonPane: function() {
  8571. this.uiDialogButtonPane = $("<div>")
  8572. .addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix");
  8573. this.uiButtonSet = $("<div>")
  8574. .addClass("ui-dialog-buttonset")
  8575. .appendTo( this.uiDialogButtonPane );
  8576. this._createButtons();
  8577. },
  8578. _createButtons: function() {
  8579. var that = this,
  8580. buttons = this.options.buttons;
  8581. // if we already have a button pane, remove it
  8582. this.uiDialogButtonPane.remove();
  8583. this.uiButtonSet.empty();
  8584. if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
  8585. this.uiDialog.removeClass("ui-dialog-buttons");
  8586. return;
  8587. }
  8588. $.each( buttons, function( name, props ) {
  8589. var click, buttonOptions;
  8590. props = $.isFunction( props ) ?
  8591. { click: props, text: name } :
  8592. props;
  8593. // Default to a non-submitting button
  8594. props = $.extend( { type: "button" }, props );
  8595. // Change the context for the click callback to be the main element
  8596. click = props.click;
  8597. props.click = function() {
  8598. click.apply( that.element[0], arguments );
  8599. };
  8600. buttonOptions = {
  8601. icons: props.icons,
  8602. text: props.showText
  8603. };
  8604. delete props.icons;
  8605. delete props.showText;
  8606. $( "<button></button>", props )
  8607. .button( buttonOptions )
  8608. .appendTo( that.uiButtonSet );
  8609. });
  8610. this.uiDialog.addClass("ui-dialog-buttons");
  8611. this.uiDialogButtonPane.appendTo( this.uiDialog );
  8612. },
  8613. _makeDraggable: function() {
  8614. var that = this,
  8615. options = this.options;
  8616. function filteredUi( ui ) {
  8617. return {
  8618. position: ui.position,
  8619. offset: ui.offset
  8620. };
  8621. }
  8622. this.uiDialog.draggable({
  8623. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  8624. handle: ".ui-dialog-titlebar",
  8625. containment: "document",
  8626. start: function( event, ui ) {
  8627. $( this ).addClass("ui-dialog-dragging");
  8628. that._blockFrames();
  8629. that._trigger( "dragStart", event, filteredUi( ui ) );
  8630. },
  8631. drag: function( event, ui ) {
  8632. that._trigger( "drag", event, filteredUi( ui ) );
  8633. },
  8634. stop: function( event, ui ) {
  8635. options.position = [
  8636. ui.position.left - that.document.scrollLeft(),
  8637. ui.position.top - that.document.scrollTop()
  8638. ];
  8639. $( this ).removeClass("ui-dialog-dragging");
  8640. that._unblockFrames();
  8641. that._trigger( "dragStop", event, filteredUi( ui ) );
  8642. }
  8643. });
  8644. },
  8645. _makeResizable: function() {
  8646. var that = this,
  8647. options = this.options,
  8648. handles = options.resizable,
  8649. // .ui-resizable has position: relative defined in the stylesheet
  8650. // but dialogs have to use absolute or fixed positioning
  8651. position = this.uiDialog.css("position"),
  8652. resizeHandles = typeof handles === "string" ?
  8653. handles :
  8654. "n,e,s,w,se,sw,ne,nw";
  8655. function filteredUi( ui ) {
  8656. return {
  8657. originalPosition: ui.originalPosition,
  8658. originalSize: ui.originalSize,
  8659. position: ui.position,
  8660. size: ui.size
  8661. };
  8662. }
  8663. this.uiDialog.resizable({
  8664. cancel: ".ui-dialog-content",
  8665. containment: "document",
  8666. alsoResize: this.element,
  8667. maxWidth: options.maxWidth,
  8668. maxHeight: options.maxHeight,
  8669. minWidth: options.minWidth,
  8670. minHeight: this._minHeight(),
  8671. handles: resizeHandles,
  8672. start: function( event, ui ) {
  8673. $( this ).addClass("ui-dialog-resizing");
  8674. that._blockFrames();
  8675. that._trigger( "resizeStart", event, filteredUi( ui ) );
  8676. },
  8677. resize: function( event, ui ) {
  8678. that._trigger( "resize", event, filteredUi( ui ) );
  8679. },
  8680. stop: function( event, ui ) {
  8681. options.height = $( this ).height();
  8682. options.width = $( this ).width();
  8683. $( this ).removeClass("ui-dialog-resizing");
  8684. that._unblockFrames();
  8685. that._trigger( "resizeStop", event, filteredUi( ui ) );
  8686. }
  8687. })
  8688. .css( "position", position );
  8689. },
  8690. _minHeight: function() {
  8691. var options = this.options;
  8692. return options.height === "auto" ?
  8693. options.minHeight :
  8694. Math.min( options.minHeight, options.height );
  8695. },
  8696. _position: function() {
  8697. // Need to show the dialog to get the actual offset in the position plugin
  8698. var isVisible = this.uiDialog.is(":visible");
  8699. if ( !isVisible ) {
  8700. this.uiDialog.show();
  8701. }
  8702. this.uiDialog.position( this.options.position );
  8703. if ( !isVisible ) {
  8704. this.uiDialog.hide();
  8705. }
  8706. },
  8707. _setOptions: function( options ) {
  8708. var that = this,
  8709. resize = false,
  8710. resizableOptions = {};
  8711. $.each( options, function( key, value ) {
  8712. that._setOption( key, value );
  8713. if ( key in sizeRelatedOptions ) {
  8714. resize = true;
  8715. }
  8716. if ( key in resizableRelatedOptions ) {
  8717. resizableOptions[ key ] = value;
  8718. }
  8719. });
  8720. if ( resize ) {
  8721. this._size();
  8722. this._position();
  8723. }
  8724. if ( this.uiDialog.is(":data(ui-resizable)") ) {
  8725. this.uiDialog.resizable( "option", resizableOptions );
  8726. }
  8727. },
  8728. _setOption: function( key, value ) {
  8729. /*jshint maxcomplexity:15*/
  8730. var isDraggable, isResizable,
  8731. uiDialog = this.uiDialog;
  8732. if ( key === "dialogClass" ) {
  8733. uiDialog
  8734. .removeClass( this.options.dialogClass )
  8735. .addClass( value );
  8736. }
  8737. if ( key === "disabled" ) {
  8738. return;
  8739. }
  8740. this._super( key, value );
  8741. if ( key === "appendTo" ) {
  8742. this.uiDialog.appendTo( this._appendTo() );
  8743. }
  8744. if ( key === "buttons" ) {
  8745. this._createButtons();
  8746. }
  8747. if ( key === "closeText" ) {
  8748. this.uiDialogTitlebarClose.button({
  8749. // Ensure that we always pass a string
  8750. label: "" + value
  8751. });
  8752. }
  8753. if ( key === "draggable" ) {
  8754. isDraggable = uiDialog.is(":data(ui-draggable)");
  8755. if ( isDraggable && !value ) {
  8756. uiDialog.draggable("destroy");
  8757. }
  8758. if ( !isDraggable && value ) {
  8759. this._makeDraggable();
  8760. }
  8761. }
  8762. if ( key === "position" ) {
  8763. this._position();
  8764. }
  8765. if ( key === "resizable" ) {
  8766. // currently resizable, becoming non-resizable
  8767. isResizable = uiDialog.is(":data(ui-resizable)");
  8768. if ( isResizable && !value ) {
  8769. uiDialog.resizable("destroy");
  8770. }
  8771. // currently resizable, changing handles
  8772. if ( isResizable && typeof value === "string" ) {
  8773. uiDialog.resizable( "option", "handles", value );
  8774. }
  8775. // currently non-resizable, becoming resizable
  8776. if ( !isResizable && value !== false ) {
  8777. this._makeResizable();
  8778. }
  8779. }
  8780. if ( key === "title" ) {
  8781. this._title( this.uiDialogTitlebar.find(".ui-dialog-title") );
  8782. }
  8783. },
  8784. _size: function() {
  8785. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  8786. // divs will both have width and height set, so we need to reset them
  8787. var nonContentHeight, minContentHeight, maxContentHeight,
  8788. options = this.options;
  8789. // Reset content sizing
  8790. this.element.show().css({
  8791. width: "auto",
  8792. minHeight: 0,
  8793. maxHeight: "none",
  8794. height: 0
  8795. });
  8796. if ( options.minWidth > options.width ) {
  8797. options.width = options.minWidth;
  8798. }
  8799. // reset wrapper sizing
  8800. // determine the height of all the non-content elements
  8801. nonContentHeight = this.uiDialog.css({
  8802. height: "auto",
  8803. width: options.width
  8804. })
  8805. .outerHeight();
  8806. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  8807. maxContentHeight = typeof options.maxHeight === "number" ?
  8808. Math.max( 0, options.maxHeight - nonContentHeight ) :
  8809. "none";
  8810. if ( options.height === "auto" ) {
  8811. this.element.css({
  8812. minHeight: minContentHeight,
  8813. maxHeight: maxContentHeight,
  8814. height: "auto"
  8815. });
  8816. } else {
  8817. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  8818. }
  8819. if (this.uiDialog.is(":data(ui-resizable)") ) {
  8820. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  8821. }
  8822. },
  8823. _blockFrames: function() {
  8824. this.iframeBlocks = this.document.find( "iframe" ).map(function() {
  8825. var iframe = $( this );
  8826. return $( "<div>" )
  8827. .css({
  8828. position: "absolute",
  8829. width: iframe.outerWidth(),
  8830. height: iframe.outerHeight()
  8831. })
  8832. .appendTo( iframe.parent() )
  8833. .offset( iframe.offset() )[0];
  8834. });
  8835. },
  8836. _unblockFrames: function() {
  8837. if ( this.iframeBlocks ) {
  8838. this.iframeBlocks.remove();
  8839. delete this.iframeBlocks;
  8840. }
  8841. },
  8842. _allowInteraction: function( event ) {
  8843. if ( $( event.target ).closest(".ui-dialog").length ) {
  8844. return true;
  8845. }
  8846. // TODO: Remove hack when datepicker implements
  8847. // the .ui-front logic (#8989)
  8848. return !!$( event.target ).closest(".ui-datepicker").length;
  8849. },
  8850. _createOverlay: function() {
  8851. if ( !this.options.modal ) {
  8852. return;
  8853. }
  8854. var that = this,
  8855. widgetFullName = this.widgetFullName;
  8856. if ( !$.ui.dialog.overlayInstances ) {
  8857. // Prevent use of anchors and inputs.
  8858. // We use a delay in case the overlay is created from an
  8859. // event that we're going to be cancelling. (#2804)
  8860. this._delay(function() {
  8861. // Handle .dialog().dialog("close") (#4065)
  8862. if ( $.ui.dialog.overlayInstances ) {
  8863. this.document.bind( "focusin.dialog", function( event ) {
  8864. if ( !that._allowInteraction( event ) ) {
  8865. event.preventDefault();
  8866. $(".ui-dialog:visible:last .ui-dialog-content")
  8867. .data( widgetFullName )._focusTabbable();
  8868. }
  8869. });
  8870. }
  8871. });
  8872. }
  8873. this.overlay = $("<div>")
  8874. .addClass("ui-widget-overlay ui-front")
  8875. .appendTo( this._appendTo() );
  8876. this._on( this.overlay, {
  8877. mousedown: "_keepFocus"
  8878. });
  8879. $.ui.dialog.overlayInstances++;
  8880. },
  8881. _destroyOverlay: function() {
  8882. if ( !this.options.modal ) {
  8883. return;
  8884. }
  8885. if ( this.overlay ) {
  8886. $.ui.dialog.overlayInstances--;
  8887. if ( !$.ui.dialog.overlayInstances ) {
  8888. this.document.unbind( "focusin.dialog" );
  8889. }
  8890. this.overlay.remove();
  8891. this.overlay = null;
  8892. }
  8893. }
  8894. });
  8895. $.ui.dialog.overlayInstances = 0;
  8896. // DEPRECATED
  8897. if ( $.uiBackCompat !== false ) {
  8898. // position option with array notation
  8899. // just override with old implementation
  8900. $.widget( "ui.dialog", $.ui.dialog, {
  8901. _position: function() {
  8902. var position = this.options.position,
  8903. myAt = [],
  8904. offset = [ 0, 0 ],
  8905. isVisible;
  8906. if ( position ) {
  8907. if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) {
  8908. myAt = position.split ? position.split(" ") : [ position[0], position[1] ];
  8909. if ( myAt.length === 1 ) {
  8910. myAt[1] = myAt[0];
  8911. }
  8912. $.each( [ "left", "top" ], function( i, offsetPosition ) {
  8913. if ( +myAt[ i ] === myAt[ i ] ) {
  8914. offset[ i ] = myAt[ i ];
  8915. myAt[ i ] = offsetPosition;
  8916. }
  8917. });
  8918. position = {
  8919. my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " +
  8920. myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]),
  8921. at: myAt.join(" ")
  8922. };
  8923. }
  8924. position = $.extend( {}, $.ui.dialog.prototype.options.position, position );
  8925. } else {
  8926. position = $.ui.dialog.prototype.options.position;
  8927. }
  8928. // need to show the dialog to get the actual offset in the position plugin
  8929. isVisible = this.uiDialog.is(":visible");
  8930. if ( !isVisible ) {
  8931. this.uiDialog.show();
  8932. }
  8933. this.uiDialog.position( position );
  8934. if ( !isVisible ) {
  8935. this.uiDialog.hide();
  8936. }
  8937. }
  8938. });
  8939. }
  8940. }( jQuery ) );
  8941. (function( $, undefined ) {
  8942. var rvertical = /up|down|vertical/,
  8943. rpositivemotion = /up|left|vertical|horizontal/;
  8944. $.effects.effect.blind = function( o, done ) {
  8945. // Create element
  8946. var el = $( this ),
  8947. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  8948. mode = $.effects.setMode( el, o.mode || "hide" ),
  8949. direction = o.direction || "up",
  8950. vertical = rvertical.test( direction ),
  8951. ref = vertical ? "height" : "width",
  8952. ref2 = vertical ? "top" : "left",
  8953. motion = rpositivemotion.test( direction ),
  8954. animation = {},
  8955. show = mode === "show",
  8956. wrapper, distance, margin;
  8957. // if already wrapped, the wrapper's properties are my property. #6245
  8958. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  8959. $.effects.save( el.parent(), props );
  8960. } else {
  8961. $.effects.save( el, props );
  8962. }
  8963. el.show();
  8964. wrapper = $.effects.createWrapper( el ).css({
  8965. overflow: "hidden"
  8966. });
  8967. distance = wrapper[ ref ]();
  8968. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  8969. animation[ ref ] = show ? distance : 0;
  8970. if ( !motion ) {
  8971. el
  8972. .css( vertical ? "bottom" : "right", 0 )
  8973. .css( vertical ? "top" : "left", "auto" )
  8974. .css({ position: "absolute" });
  8975. animation[ ref2 ] = show ? margin : distance + margin;
  8976. }
  8977. // start at 0 if we are showing
  8978. if ( show ) {
  8979. wrapper.css( ref, 0 );
  8980. if ( ! motion ) {
  8981. wrapper.css( ref2, margin + distance );
  8982. }
  8983. }
  8984. // Animate
  8985. wrapper.animate( animation, {
  8986. duration: o.duration,
  8987. easing: o.easing,
  8988. queue: false,
  8989. complete: function() {
  8990. if ( mode === "hide" ) {
  8991. el.hide();
  8992. }
  8993. $.effects.restore( el, props );
  8994. $.effects.removeWrapper( el );
  8995. done();
  8996. }
  8997. });
  8998. };
  8999. })(jQuery);
  9000. (function( $, undefined ) {
  9001. $.effects.effect.bounce = function( o, done ) {
  9002. var el = $( this ),
  9003. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9004. // defaults:
  9005. mode = $.effects.setMode( el, o.mode || "effect" ),
  9006. hide = mode === "hide",
  9007. show = mode === "show",
  9008. direction = o.direction || "up",
  9009. distance = o.distance,
  9010. times = o.times || 5,
  9011. // number of internal animations
  9012. anims = times * 2 + ( show || hide ? 1 : 0 ),
  9013. speed = o.duration / anims,
  9014. easing = o.easing,
  9015. // utility:
  9016. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  9017. motion = ( direction === "up" || direction === "left" ),
  9018. i,
  9019. upAnim,
  9020. downAnim,
  9021. // we will need to re-assemble the queue to stack our animations in place
  9022. queue = el.queue(),
  9023. queuelen = queue.length;
  9024. // Avoid touching opacity to prevent clearType and PNG issues in IE
  9025. if ( show || hide ) {
  9026. props.push( "opacity" );
  9027. }
  9028. $.effects.save( el, props );
  9029. el.show();
  9030. $.effects.createWrapper( el ); // Create Wrapper
  9031. // default distance for the BIGGEST bounce is the outer Distance / 3
  9032. if ( !distance ) {
  9033. distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  9034. }
  9035. if ( show ) {
  9036. downAnim = { opacity: 1 };
  9037. downAnim[ ref ] = 0;
  9038. // if we are showing, force opacity 0 and set the initial position
  9039. // then do the "first" animation
  9040. el.css( "opacity", 0 )
  9041. .css( ref, motion ? -distance * 2 : distance * 2 )
  9042. .animate( downAnim, speed, easing );
  9043. }
  9044. // start at the smallest distance if we are hiding
  9045. if ( hide ) {
  9046. distance = distance / Math.pow( 2, times - 1 );
  9047. }
  9048. downAnim = {};
  9049. downAnim[ ref ] = 0;
  9050. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  9051. for ( i = 0; i < times; i++ ) {
  9052. upAnim = {};
  9053. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  9054. el.animate( upAnim, speed, easing )
  9055. .animate( downAnim, speed, easing );
  9056. distance = hide ? distance * 2 : distance / 2;
  9057. }
  9058. // Last Bounce when Hiding
  9059. if ( hide ) {
  9060. upAnim = { opacity: 0 };
  9061. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  9062. el.animate( upAnim, speed, easing );
  9063. }
  9064. el.queue(function() {
  9065. if ( hide ) {
  9066. el.hide();
  9067. }
  9068. $.effects.restore( el, props );
  9069. $.effects.removeWrapper( el );
  9070. done();
  9071. });
  9072. // inject all the animations we just queued to be first in line (after "inprogress")
  9073. if ( queuelen > 1) {
  9074. queue.splice.apply( queue,
  9075. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9076. }
  9077. el.dequeue();
  9078. };
  9079. })(jQuery);
  9080. (function( $, undefined ) {
  9081. $.effects.effect.clip = function( o, done ) {
  9082. // Create element
  9083. var el = $( this ),
  9084. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9085. mode = $.effects.setMode( el, o.mode || "hide" ),
  9086. show = mode === "show",
  9087. direction = o.direction || "vertical",
  9088. vert = direction === "vertical",
  9089. size = vert ? "height" : "width",
  9090. position = vert ? "top" : "left",
  9091. animation = {},
  9092. wrapper, animate, distance;
  9093. // Save & Show
  9094. $.effects.save( el, props );
  9095. el.show();
  9096. // Create Wrapper
  9097. wrapper = $.effects.createWrapper( el ).css({
  9098. overflow: "hidden"
  9099. });
  9100. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  9101. distance = animate[ size ]();
  9102. // Shift
  9103. if ( show ) {
  9104. animate.css( size, 0 );
  9105. animate.css( position, distance / 2 );
  9106. }
  9107. // Create Animation Object:
  9108. animation[ size ] = show ? distance : 0;
  9109. animation[ position ] = show ? 0 : distance / 2;
  9110. // Animate
  9111. animate.animate( animation, {
  9112. queue: false,
  9113. duration: o.duration,
  9114. easing: o.easing,
  9115. complete: function() {
  9116. if ( !show ) {
  9117. el.hide();
  9118. }
  9119. $.effects.restore( el, props );
  9120. $.effects.removeWrapper( el );
  9121. done();
  9122. }
  9123. });
  9124. };
  9125. })(jQuery);
  9126. (function( $, undefined ) {
  9127. $.effects.effect.drop = function( o, done ) {
  9128. var el = $( this ),
  9129. props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
  9130. mode = $.effects.setMode( el, o.mode || "hide" ),
  9131. show = mode === "show",
  9132. direction = o.direction || "left",
  9133. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  9134. motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
  9135. animation = {
  9136. opacity: show ? 1 : 0
  9137. },
  9138. distance;
  9139. // Adjust
  9140. $.effects.save( el, props );
  9141. el.show();
  9142. $.effects.createWrapper( el );
  9143. distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]( true ) / 2;
  9144. if ( show ) {
  9145. el
  9146. .css( "opacity", 0 )
  9147. .css( ref, motion === "pos" ? -distance : distance );
  9148. }
  9149. // Animation
  9150. animation[ ref ] = ( show ?
  9151. ( motion === "pos" ? "+=" : "-=" ) :
  9152. ( motion === "pos" ? "-=" : "+=" ) ) +
  9153. distance;
  9154. // Animate
  9155. el.animate( animation, {
  9156. queue: false,
  9157. duration: o.duration,
  9158. easing: o.easing,
  9159. complete: function() {
  9160. if ( mode === "hide" ) {
  9161. el.hide();
  9162. }
  9163. $.effects.restore( el, props );
  9164. $.effects.removeWrapper( el );
  9165. done();
  9166. }
  9167. });
  9168. };
  9169. })(jQuery);
  9170. (function( $, undefined ) {
  9171. $.effects.effect.explode = function( o, done ) {
  9172. var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
  9173. cells = rows,
  9174. el = $( this ),
  9175. mode = $.effects.setMode( el, o.mode || "hide" ),
  9176. show = mode === "show",
  9177. // show and then visibility:hidden the element before calculating offset
  9178. offset = el.show().css( "visibility", "hidden" ).offset(),
  9179. // width and height of a piece
  9180. width = Math.ceil( el.outerWidth() / cells ),
  9181. height = Math.ceil( el.outerHeight() / rows ),
  9182. pieces = [],
  9183. // loop
  9184. i, j, left, top, mx, my;
  9185. // children animate complete:
  9186. function childComplete() {
  9187. pieces.push( this );
  9188. if ( pieces.length === rows * cells ) {
  9189. animComplete();
  9190. }
  9191. }
  9192. // clone the element for each row and cell.
  9193. for( i = 0; i < rows ; i++ ) { // ===>
  9194. top = offset.top + i * height;
  9195. my = i - ( rows - 1 ) / 2 ;
  9196. for( j = 0; j < cells ; j++ ) { // |||
  9197. left = offset.left + j * width;
  9198. mx = j - ( cells - 1 ) / 2 ;
  9199. // Create a clone of the now hidden main element that will be absolute positioned
  9200. // within a wrapper div off the -left and -top equal to size of our pieces
  9201. el
  9202. .clone()
  9203. .appendTo( "body" )
  9204. .wrap( "<div></div>" )
  9205. .css({
  9206. position: "absolute",
  9207. visibility: "visible",
  9208. left: -j * width,
  9209. top: -i * height
  9210. })
  9211. // select the wrapper - make it overflow: hidden and absolute positioned based on
  9212. // where the original was located +left and +top equal to the size of pieces
  9213. .parent()
  9214. .addClass( "ui-effects-explode" )
  9215. .css({
  9216. position: "absolute",
  9217. overflow: "hidden",
  9218. width: width,
  9219. height: height,
  9220. left: left + ( show ? mx * width : 0 ),
  9221. top: top + ( show ? my * height : 0 ),
  9222. opacity: show ? 0 : 1
  9223. }).animate({
  9224. left: left + ( show ? 0 : mx * width ),
  9225. top: top + ( show ? 0 : my * height ),
  9226. opacity: show ? 1 : 0
  9227. }, o.duration || 500, o.easing, childComplete );
  9228. }
  9229. }
  9230. function animComplete() {
  9231. el.css({
  9232. visibility: "visible"
  9233. });
  9234. $( pieces ).remove();
  9235. if ( !show ) {
  9236. el.hide();
  9237. }
  9238. done();
  9239. }
  9240. };
  9241. })(jQuery);
  9242. (function( $, undefined ) {
  9243. $.effects.effect.fade = function( o, done ) {
  9244. var el = $( this ),
  9245. mode = $.effects.setMode( el, o.mode || "toggle" );
  9246. el.animate({
  9247. opacity: mode
  9248. }, {
  9249. queue: false,
  9250. duration: o.duration,
  9251. easing: o.easing,
  9252. complete: done
  9253. });
  9254. };
  9255. })( jQuery );
  9256. (function( $, undefined ) {
  9257. $.effects.effect.fold = function( o, done ) {
  9258. // Create element
  9259. var el = $( this ),
  9260. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9261. mode = $.effects.setMode( el, o.mode || "hide" ),
  9262. show = mode === "show",
  9263. hide = mode === "hide",
  9264. size = o.size || 15,
  9265. percent = /([0-9]+)%/.exec( size ),
  9266. horizFirst = !!o.horizFirst,
  9267. widthFirst = show !== horizFirst,
  9268. ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
  9269. duration = o.duration / 2,
  9270. wrapper, distance,
  9271. animation1 = {},
  9272. animation2 = {};
  9273. $.effects.save( el, props );
  9274. el.show();
  9275. // Create Wrapper
  9276. wrapper = $.effects.createWrapper( el ).css({
  9277. overflow: "hidden"
  9278. });
  9279. distance = widthFirst ?
  9280. [ wrapper.width(), wrapper.height() ] :
  9281. [ wrapper.height(), wrapper.width() ];
  9282. if ( percent ) {
  9283. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  9284. }
  9285. if ( show ) {
  9286. wrapper.css( horizFirst ? {
  9287. height: 0,
  9288. width: size
  9289. } : {
  9290. height: size,
  9291. width: 0
  9292. });
  9293. }
  9294. // Animation
  9295. animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
  9296. animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
  9297. // Animate
  9298. wrapper
  9299. .animate( animation1, duration, o.easing )
  9300. .animate( animation2, duration, o.easing, function() {
  9301. if ( hide ) {
  9302. el.hide();
  9303. }
  9304. $.effects.restore( el, props );
  9305. $.effects.removeWrapper( el );
  9306. done();
  9307. });
  9308. };
  9309. })(jQuery);
  9310. (function( $, undefined ) {
  9311. $.effects.effect.highlight = function( o, done ) {
  9312. var elem = $( this ),
  9313. props = [ "backgroundImage", "backgroundColor", "opacity" ],
  9314. mode = $.effects.setMode( elem, o.mode || "show" ),
  9315. animation = {
  9316. backgroundColor: elem.css( "backgroundColor" )
  9317. };
  9318. if (mode === "hide") {
  9319. animation.opacity = 0;
  9320. }
  9321. $.effects.save( elem, props );
  9322. elem
  9323. .show()
  9324. .css({
  9325. backgroundImage: "none",
  9326. backgroundColor: o.color || "#ffff99"
  9327. })
  9328. .animate( animation, {
  9329. queue: false,
  9330. duration: o.duration,
  9331. easing: o.easing,
  9332. complete: function() {
  9333. if ( mode === "hide" ) {
  9334. elem.hide();
  9335. }
  9336. $.effects.restore( elem, props );
  9337. done();
  9338. }
  9339. });
  9340. };
  9341. })(jQuery);
  9342. (function( $, undefined ) {
  9343. $.effects.effect.pulsate = function( o, done ) {
  9344. var elem = $( this ),
  9345. mode = $.effects.setMode( elem, o.mode || "show" ),
  9346. show = mode === "show",
  9347. hide = mode === "hide",
  9348. showhide = ( show || mode === "hide" ),
  9349. // showing or hiding leaves of the "last" animation
  9350. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  9351. duration = o.duration / anims,
  9352. animateTo = 0,
  9353. queue = elem.queue(),
  9354. queuelen = queue.length,
  9355. i;
  9356. if ( show || !elem.is(":visible")) {
  9357. elem.css( "opacity", 0 ).show();
  9358. animateTo = 1;
  9359. }
  9360. // anims - 1 opacity "toggles"
  9361. for ( i = 1; i < anims; i++ ) {
  9362. elem.animate({
  9363. opacity: animateTo
  9364. }, duration, o.easing );
  9365. animateTo = 1 - animateTo;
  9366. }
  9367. elem.animate({
  9368. opacity: animateTo
  9369. }, duration, o.easing);
  9370. elem.queue(function() {
  9371. if ( hide ) {
  9372. elem.hide();
  9373. }
  9374. done();
  9375. });
  9376. // We just queued up "anims" animations, we need to put them next in the queue
  9377. if ( queuelen > 1 ) {
  9378. queue.splice.apply( queue,
  9379. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9380. }
  9381. elem.dequeue();
  9382. };
  9383. })(jQuery);
  9384. (function( $, undefined ) {
  9385. $.effects.effect.puff = function( o, done ) {
  9386. var elem = $( this ),
  9387. mode = $.effects.setMode( elem, o.mode || "hide" ),
  9388. hide = mode === "hide",
  9389. percent = parseInt( o.percent, 10 ) || 150,
  9390. factor = percent / 100,
  9391. original = {
  9392. height: elem.height(),
  9393. width: elem.width(),
  9394. outerHeight: elem.outerHeight(),
  9395. outerWidth: elem.outerWidth()
  9396. };
  9397. $.extend( o, {
  9398. effect: "scale",
  9399. queue: false,
  9400. fade: true,
  9401. mode: mode,
  9402. complete: done,
  9403. percent: hide ? percent : 100,
  9404. from: hide ?
  9405. original :
  9406. {
  9407. height: original.height * factor,
  9408. width: original.width * factor,
  9409. outerHeight: original.outerHeight * factor,
  9410. outerWidth: original.outerWidth * factor
  9411. }
  9412. });
  9413. elem.effect( o );
  9414. };
  9415. $.effects.effect.scale = function( o, done ) {
  9416. // Create element
  9417. var el = $( this ),
  9418. options = $.extend( true, {}, o ),
  9419. mode = $.effects.setMode( el, o.mode || "effect" ),
  9420. percent = parseInt( o.percent, 10 ) ||
  9421. ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
  9422. direction = o.direction || "both",
  9423. origin = o.origin,
  9424. original = {
  9425. height: el.height(),
  9426. width: el.width(),
  9427. outerHeight: el.outerHeight(),
  9428. outerWidth: el.outerWidth()
  9429. },
  9430. factor = {
  9431. y: direction !== "horizontal" ? (percent / 100) : 1,
  9432. x: direction !== "vertical" ? (percent / 100) : 1
  9433. };
  9434. // We are going to pass this effect to the size effect:
  9435. options.effect = "size";
  9436. options.queue = false;
  9437. options.complete = done;
  9438. // Set default origin and restore for show/hide
  9439. if ( mode !== "effect" ) {
  9440. options.origin = origin || ["middle","center"];
  9441. options.restore = true;
  9442. }
  9443. options.from = o.from || ( mode === "show" ? {
  9444. height: 0,
  9445. width: 0,
  9446. outerHeight: 0,
  9447. outerWidth: 0
  9448. } : original );
  9449. options.to = {
  9450. height: original.height * factor.y,
  9451. width: original.width * factor.x,
  9452. outerHeight: original.outerHeight * factor.y,
  9453. outerWidth: original.outerWidth * factor.x
  9454. };
  9455. // Fade option to support puff
  9456. if ( options.fade ) {
  9457. if ( mode === "show" ) {
  9458. options.from.opacity = 0;
  9459. options.to.opacity = 1;
  9460. }
  9461. if ( mode === "hide" ) {
  9462. options.from.opacity = 1;
  9463. options.to.opacity = 0;
  9464. }
  9465. }
  9466. // Animate
  9467. el.effect( options );
  9468. };
  9469. $.effects.effect.size = function( o, done ) {
  9470. // Create element
  9471. var original, baseline, factor,
  9472. el = $( this ),
  9473. props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
  9474. // Always restore
  9475. props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
  9476. // Copy for children
  9477. props2 = [ "width", "height", "overflow" ],
  9478. cProps = [ "fontSize" ],
  9479. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  9480. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  9481. // Set options
  9482. mode = $.effects.setMode( el, o.mode || "effect" ),
  9483. restore = o.restore || mode !== "effect",
  9484. scale = o.scale || "both",
  9485. origin = o.origin || [ "middle", "center" ],
  9486. position = el.css( "position" ),
  9487. props = restore ? props0 : props1,
  9488. zero = {
  9489. height: 0,
  9490. width: 0,
  9491. outerHeight: 0,
  9492. outerWidth: 0
  9493. };
  9494. if ( mode === "show" ) {
  9495. el.show();
  9496. }
  9497. original = {
  9498. height: el.height(),
  9499. width: el.width(),
  9500. outerHeight: el.outerHeight(),
  9501. outerWidth: el.outerWidth()
  9502. };
  9503. if ( o.mode === "toggle" && mode === "show" ) {
  9504. el.from = o.to || zero;
  9505. el.to = o.from || original;
  9506. } else {
  9507. el.from = o.from || ( mode === "show" ? zero : original );
  9508. el.to = o.to || ( mode === "hide" ? zero : original );
  9509. }
  9510. // Set scaling factor
  9511. factor = {
  9512. from: {
  9513. y: el.from.height / original.height,
  9514. x: el.from.width / original.width
  9515. },
  9516. to: {
  9517. y: el.to.height / original.height,
  9518. x: el.to.width / original.width
  9519. }
  9520. };
  9521. // Scale the css box
  9522. if ( scale === "box" || scale === "both" ) {
  9523. // Vertical props scaling
  9524. if ( factor.from.y !== factor.to.y ) {
  9525. props = props.concat( vProps );
  9526. el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
  9527. el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
  9528. }
  9529. // Horizontal props scaling
  9530. if ( factor.from.x !== factor.to.x ) {
  9531. props = props.concat( hProps );
  9532. el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
  9533. el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
  9534. }
  9535. }
  9536. // Scale the content
  9537. if ( scale === "content" || scale === "both" ) {
  9538. // Vertical props scaling
  9539. if ( factor.from.y !== factor.to.y ) {
  9540. props = props.concat( cProps ).concat( props2 );
  9541. el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
  9542. el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
  9543. }
  9544. }
  9545. $.effects.save( el, props );
  9546. el.show();
  9547. $.effects.createWrapper( el );
  9548. el.css( "overflow", "hidden" ).css( el.from );
  9549. // Adjust
  9550. if (origin) { // Calculate baseline shifts
  9551. baseline = $.effects.getBaseline( origin, original );
  9552. el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
  9553. el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
  9554. el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
  9555. el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
  9556. }
  9557. el.css( el.from ); // set top & left
  9558. // Animate
  9559. if ( scale === "content" || scale === "both" ) { // Scale the children
  9560. // Add margins/font-size
  9561. vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
  9562. hProps = hProps.concat([ "marginLeft", "marginRight" ]);
  9563. props2 = props0.concat(vProps).concat(hProps);
  9564. el.find( "*[width]" ).each( function(){
  9565. var child = $( this ),
  9566. c_original = {
  9567. height: child.height(),
  9568. width: child.width(),
  9569. outerHeight: child.outerHeight(),
  9570. outerWidth: child.outerWidth()
  9571. };
  9572. if (restore) {
  9573. $.effects.save(child, props2);
  9574. }
  9575. child.from = {
  9576. height: c_original.height * factor.from.y,
  9577. width: c_original.width * factor.from.x,
  9578. outerHeight: c_original.outerHeight * factor.from.y,
  9579. outerWidth: c_original.outerWidth * factor.from.x
  9580. };
  9581. child.to = {
  9582. height: c_original.height * factor.to.y,
  9583. width: c_original.width * factor.to.x,
  9584. outerHeight: c_original.height * factor.to.y,
  9585. outerWidth: c_original.width * factor.to.x
  9586. };
  9587. // Vertical props scaling
  9588. if ( factor.from.y !== factor.to.y ) {
  9589. child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
  9590. child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
  9591. }
  9592. // Horizontal props scaling
  9593. if ( factor.from.x !== factor.to.x ) {
  9594. child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
  9595. child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
  9596. }
  9597. // Animate children
  9598. child.css( child.from );
  9599. child.animate( child.to, o.duration, o.easing, function() {
  9600. // Restore children
  9601. if ( restore ) {
  9602. $.effects.restore( child, props2 );
  9603. }
  9604. });
  9605. });
  9606. }
  9607. // Animate
  9608. el.animate( el.to, {
  9609. queue: false,
  9610. duration: o.duration,
  9611. easing: o.easing,
  9612. complete: function() {
  9613. if ( el.to.opacity === 0 ) {
  9614. el.css( "opacity", el.from.opacity );
  9615. }
  9616. if( mode === "hide" ) {
  9617. el.hide();
  9618. }
  9619. $.effects.restore( el, props );
  9620. if ( !restore ) {
  9621. // we need to calculate our new positioning based on the scaling
  9622. if ( position === "static" ) {
  9623. el.css({
  9624. position: "relative",
  9625. top: el.to.top,
  9626. left: el.to.left
  9627. });
  9628. } else {
  9629. $.each([ "top", "left" ], function( idx, pos ) {
  9630. el.css( pos, function( _, str ) {
  9631. var val = parseInt( str, 10 ),
  9632. toRef = idx ? el.to.left : el.to.top;
  9633. // if original was "auto", recalculate the new value from wrapper
  9634. if ( str === "auto" ) {
  9635. return toRef + "px";
  9636. }
  9637. return val + toRef + "px";
  9638. });
  9639. });
  9640. }
  9641. }
  9642. $.effects.removeWrapper( el );
  9643. done();
  9644. }
  9645. });
  9646. };
  9647. })(jQuery);
  9648. (function( $, undefined ) {
  9649. $.effects.effect.shake = function( o, done ) {
  9650. var el = $( this ),
  9651. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9652. mode = $.effects.setMode( el, o.mode || "effect" ),
  9653. direction = o.direction || "left",
  9654. distance = o.distance || 20,
  9655. times = o.times || 3,
  9656. anims = times * 2 + 1,
  9657. speed = Math.round(o.duration/anims),
  9658. ref = (direction === "up" || direction === "down") ? "top" : "left",
  9659. positiveMotion = (direction === "up" || direction === "left"),
  9660. animation = {},
  9661. animation1 = {},
  9662. animation2 = {},
  9663. i,
  9664. // we will need to re-assemble the queue to stack our animations in place
  9665. queue = el.queue(),
  9666. queuelen = queue.length;
  9667. $.effects.save( el, props );
  9668. el.show();
  9669. $.effects.createWrapper( el );
  9670. // Animation
  9671. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  9672. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  9673. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  9674. // Animate
  9675. el.animate( animation, speed, o.easing );
  9676. // Shakes
  9677. for ( i = 1; i < times; i++ ) {
  9678. el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
  9679. }
  9680. el
  9681. .animate( animation1, speed, o.easing )
  9682. .animate( animation, speed / 2, o.easing )
  9683. .queue(function() {
  9684. if ( mode === "hide" ) {
  9685. el.hide();
  9686. }
  9687. $.effects.restore( el, props );
  9688. $.effects.removeWrapper( el );
  9689. done();
  9690. });
  9691. // inject all the animations we just queued to be first in line (after "inprogress")
  9692. if ( queuelen > 1) {
  9693. queue.splice.apply( queue,
  9694. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9695. }
  9696. el.dequeue();
  9697. };
  9698. })(jQuery);
  9699. (function( $, undefined ) {
  9700. $.effects.effect.slide = function( o, done ) {
  9701. // Create element
  9702. var el = $( this ),
  9703. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  9704. mode = $.effects.setMode( el, o.mode || "show" ),
  9705. show = mode === "show",
  9706. direction = o.direction || "left",
  9707. ref = (direction === "up" || direction === "down") ? "top" : "left",
  9708. positiveMotion = (direction === "up" || direction === "left"),
  9709. distance,
  9710. animation = {};
  9711. // Adjust
  9712. $.effects.save( el, props );
  9713. el.show();
  9714. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  9715. $.effects.createWrapper( el ).css({
  9716. overflow: "hidden"
  9717. });
  9718. if ( show ) {
  9719. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  9720. }
  9721. // Animation
  9722. animation[ ref ] = ( show ?
  9723. ( positiveMotion ? "+=" : "-=") :
  9724. ( positiveMotion ? "-=" : "+=")) +
  9725. distance;
  9726. // Animate
  9727. el.animate( animation, {
  9728. queue: false,
  9729. duration: o.duration,
  9730. easing: o.easing,
  9731. complete: function() {
  9732. if ( mode === "hide" ) {
  9733. el.hide();
  9734. }
  9735. $.effects.restore( el, props );
  9736. $.effects.removeWrapper( el );
  9737. done();
  9738. }
  9739. });
  9740. };
  9741. })(jQuery);
  9742. (function( $, undefined ) {
  9743. $.effects.effect.transfer = function( o, done ) {
  9744. var elem = $( this ),
  9745. target = $( o.to ),
  9746. targetFixed = target.css( "position" ) === "fixed",
  9747. body = $("body"),
  9748. fixTop = targetFixed ? body.scrollTop() : 0,
  9749. fixLeft = targetFixed ? body.scrollLeft() : 0,
  9750. endPosition = target.offset(),
  9751. animation = {
  9752. top: endPosition.top - fixTop ,
  9753. left: endPosition.left - fixLeft ,
  9754. height: target.innerHeight(),
  9755. width: target.innerWidth()
  9756. },
  9757. startPosition = elem.offset(),
  9758. transfer = $( "<div class='ui-effects-transfer'></div>" )
  9759. .appendTo( document.body )
  9760. .addClass( o.className )
  9761. .css({
  9762. top: startPosition.top - fixTop ,
  9763. left: startPosition.left - fixLeft ,
  9764. height: elem.innerHeight(),
  9765. width: elem.innerWidth(),
  9766. position: targetFixed ? "fixed" : "absolute"
  9767. })
  9768. .animate( animation, o.duration, o.easing, function() {
  9769. transfer.remove();
  9770. done();
  9771. });
  9772. };
  9773. })(jQuery);
  9774. (function( $, undefined ) {
  9775. $.widget( "ui.menu", {
  9776. version: "1.10.3",
  9777. defaultElement: "<ul>",
  9778. delay: 300,
  9779. options: {
  9780. icons: {
  9781. submenu: "ui-icon-carat-1-e"
  9782. },
  9783. menus: "ul",
  9784. position: {
  9785. my: "left top",
  9786. at: "right top"
  9787. },
  9788. role: "menu",
  9789. // callbacks
  9790. blur: null,
  9791. focus: null,
  9792. select: null
  9793. },
  9794. _create: function() {
  9795. this.activeMenu = this.element;
  9796. // flag used to prevent firing of the click handler
  9797. // as the event bubbles up through nested menus
  9798. this.mouseHandled = false;
  9799. this.element
  9800. .uniqueId()
  9801. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  9802. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  9803. .attr({
  9804. role: this.options.role,
  9805. tabIndex: 0
  9806. })
  9807. // need to catch all clicks on disabled menu
  9808. // not possible through _on
  9809. .bind( "click" + this.eventNamespace, $.proxy(function( event ) {
  9810. if ( this.options.disabled ) {
  9811. event.preventDefault();
  9812. }
  9813. }, this ));
  9814. if ( this.options.disabled ) {
  9815. this.element
  9816. .addClass( "ui-state-disabled" )
  9817. .attr( "aria-disabled", "true" );
  9818. }
  9819. this._on({
  9820. // Prevent focus from sticking to links inside menu after clicking
  9821. // them (focus should always stay on UL during navigation).
  9822. "mousedown .ui-menu-item > a": function( event ) {
  9823. event.preventDefault();
  9824. },
  9825. "click .ui-state-disabled > a": function( event ) {
  9826. event.preventDefault();
  9827. },
  9828. "click .ui-menu-item:has(a)": function( event ) {
  9829. var target = $( event.target ).closest( ".ui-menu-item" );
  9830. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  9831. this.mouseHandled = true;
  9832. this.select( event );
  9833. // Open submenu on click
  9834. if ( target.has( ".ui-menu" ).length ) {
  9835. this.expand( event );
  9836. } else if ( !this.element.is( ":focus" ) ) {
  9837. // Redirect focus to the menu
  9838. this.element.trigger( "focus", [ true ] );
  9839. // If the active item is on the top level, let it stay active.
  9840. // Otherwise, blur the active item since it is no longer visible.
  9841. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  9842. clearTimeout( this.timer );
  9843. }
  9844. }
  9845. }
  9846. },
  9847. "mouseenter .ui-menu-item": function( event ) {
  9848. var target = $( event.currentTarget );
  9849. // Remove ui-state-active class from siblings of the newly focused menu item
  9850. // to avoid a jump caused by adjacent elements both having a class with a border
  9851. target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
  9852. this.focus( event, target );
  9853. },
  9854. mouseleave: "collapseAll",
  9855. "mouseleave .ui-menu": "collapseAll",
  9856. focus: function( event, keepActiveItem ) {
  9857. // If there's already an active item, keep it active
  9858. // If not, activate the first item
  9859. var item = this.active || this.element.children( ".ui-menu-item" ).eq( 0 );
  9860. if ( !keepActiveItem ) {
  9861. this.focus( event, item );
  9862. }
  9863. },
  9864. blur: function( event ) {
  9865. this._delay(function() {
  9866. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  9867. this.collapseAll( event );
  9868. }
  9869. });
  9870. },
  9871. keydown: "_keydown"
  9872. });
  9873. this.refresh();
  9874. // Clicks outside of a menu collapse any open menus
  9875. this._on( this.document, {
  9876. click: function( event ) {
  9877. if ( !$( event.target ).closest( ".ui-menu" ).length ) {
  9878. this.collapseAll( event );
  9879. }
  9880. // Reset the mouseHandled flag
  9881. this.mouseHandled = false;
  9882. }
  9883. });
  9884. },
  9885. _destroy: function() {
  9886. // Destroy (sub)menus
  9887. this.element
  9888. .removeAttr( "aria-activedescendant" )
  9889. .find( ".ui-menu" ).addBack()
  9890. .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
  9891. .removeAttr( "role" )
  9892. .removeAttr( "tabIndex" )
  9893. .removeAttr( "aria-labelledby" )
  9894. .removeAttr( "aria-expanded" )
  9895. .removeAttr( "aria-hidden" )
  9896. .removeAttr( "aria-disabled" )
  9897. .removeUniqueId()
  9898. .show();
  9899. // Destroy menu items
  9900. this.element.find( ".ui-menu-item" )
  9901. .removeClass( "ui-menu-item" )
  9902. .removeAttr( "role" )
  9903. .removeAttr( "aria-disabled" )
  9904. .children( "a" )
  9905. .removeUniqueId()
  9906. .removeClass( "ui-corner-all ui-state-hover" )
  9907. .removeAttr( "tabIndex" )
  9908. .removeAttr( "role" )
  9909. .removeAttr( "aria-haspopup" )
  9910. .children().each( function() {
  9911. var elem = $( this );
  9912. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  9913. elem.remove();
  9914. }
  9915. });
  9916. // Destroy menu dividers
  9917. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  9918. },
  9919. _keydown: function( event ) {
  9920. /*jshint maxcomplexity:20*/
  9921. var match, prev, character, skip, regex,
  9922. preventDefault = true;
  9923. function escape( value ) {
  9924. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  9925. }
  9926. switch ( event.keyCode ) {
  9927. case $.ui.keyCode.PAGE_UP:
  9928. this.previousPage( event );
  9929. break;
  9930. case $.ui.keyCode.PAGE_DOWN:
  9931. this.nextPage( event );
  9932. break;
  9933. case $.ui.keyCode.HOME:
  9934. this._move( "first", "first", event );
  9935. break;
  9936. case $.ui.keyCode.END:
  9937. this._move( "last", "last", event );
  9938. break;
  9939. case $.ui.keyCode.UP:
  9940. this.previous( event );
  9941. break;
  9942. case $.ui.keyCode.DOWN:
  9943. this.next( event );
  9944. break;
  9945. case $.ui.keyCode.LEFT:
  9946. this.collapse( event );
  9947. break;
  9948. case $.ui.keyCode.RIGHT:
  9949. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  9950. this.expand( event );
  9951. }
  9952. break;
  9953. case $.ui.keyCode.ENTER:
  9954. case $.ui.keyCode.SPACE:
  9955. this._activate( event );
  9956. break;
  9957. case $.ui.keyCode.ESCAPE:
  9958. this.collapse( event );
  9959. break;
  9960. default:
  9961. preventDefault = false;
  9962. prev = this.previousFilter || "";
  9963. character = String.fromCharCode( event.keyCode );
  9964. skip = false;
  9965. clearTimeout( this.filterTimer );
  9966. if ( character === prev ) {
  9967. skip = true;
  9968. } else {
  9969. character = prev + character;
  9970. }
  9971. regex = new RegExp( "^" + escape( character ), "i" );
  9972. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  9973. return regex.test( $( this ).children( "a" ).text() );
  9974. });
  9975. match = skip && match.index( this.active.next() ) !== -1 ?
  9976. this.active.nextAll( ".ui-menu-item" ) :
  9977. match;
  9978. // If no matches on the current filter, reset to the last character pressed
  9979. // to move down the menu to the first item that starts with that character
  9980. if ( !match.length ) {
  9981. character = String.fromCharCode( event.keyCode );
  9982. regex = new RegExp( "^" + escape( character ), "i" );
  9983. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  9984. return regex.test( $( this ).children( "a" ).text() );
  9985. });
  9986. }
  9987. if ( match.length ) {
  9988. this.focus( event, match );
  9989. if ( match.length > 1 ) {
  9990. this.previousFilter = character;
  9991. this.filterTimer = this._delay(function() {
  9992. delete this.previousFilter;
  9993. }, 1000 );
  9994. } else {
  9995. delete this.previousFilter;
  9996. }
  9997. } else {
  9998. delete this.previousFilter;
  9999. }
  10000. }
  10001. if ( preventDefault ) {
  10002. event.preventDefault();
  10003. }
  10004. },
  10005. _activate: function( event ) {
  10006. if ( !this.active.is( ".ui-state-disabled" ) ) {
  10007. if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
  10008. this.expand( event );
  10009. } else {
  10010. this.select( event );
  10011. }
  10012. }
  10013. },
  10014. refresh: function() {
  10015. var menus,
  10016. icon = this.options.icons.submenu,
  10017. submenus = this.element.find( this.options.menus );
  10018. // Initialize nested menus
  10019. submenus.filter( ":not(.ui-menu)" )
  10020. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  10021. .hide()
  10022. .attr({
  10023. role: this.options.role,
  10024. "aria-hidden": "true",
  10025. "aria-expanded": "false"
  10026. })
  10027. .each(function() {
  10028. var menu = $( this ),
  10029. item = menu.prev( "a" ),
  10030. submenuCarat = $( "<span>" )
  10031. .addClass( "ui-menu-icon ui-icon " + icon )
  10032. .data( "ui-menu-submenu-carat", true );
  10033. item
  10034. .attr( "aria-haspopup", "true" )
  10035. .prepend( submenuCarat );
  10036. menu.attr( "aria-labelledby", item.attr( "id" ) );
  10037. });
  10038. menus = submenus.add( this.element );
  10039. // Don't refresh list items that are already adapted
  10040. menus.children( ":not(.ui-menu-item):has(a)" )
  10041. .addClass( "ui-menu-item" )
  10042. .attr( "role", "presentation" )
  10043. .children( "a" )
  10044. .uniqueId()
  10045. .addClass( "ui-corner-all" )
  10046. .attr({
  10047. tabIndex: -1,
  10048. role: this._itemRole()
  10049. });
  10050. // Initialize unlinked menu-items containing spaces and/or dashes only as dividers
  10051. menus.children( ":not(.ui-menu-item)" ).each(function() {
  10052. var item = $( this );
  10053. // hyphen, em dash, en dash
  10054. if ( !/[^\-\u2014\u2013\s]/.test( item.text() ) ) {
  10055. item.addClass( "ui-widget-content ui-menu-divider" );
  10056. }
  10057. });
  10058. // Add aria-disabled attribute to any disabled menu item
  10059. menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  10060. // If the active item has been removed, blur the menu
  10061. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  10062. this.blur();
  10063. }
  10064. },
  10065. _itemRole: function() {
  10066. return {
  10067. menu: "menuitem",
  10068. listbox: "option"
  10069. }[ this.options.role ];
  10070. },
  10071. _setOption: function( key, value ) {
  10072. if ( key === "icons" ) {
  10073. this.element.find( ".ui-menu-icon" )
  10074. .removeClass( this.options.icons.submenu )
  10075. .addClass( value.submenu );
  10076. }
  10077. this._super( key, value );
  10078. },
  10079. focus: function( event, item ) {
  10080. var nested, focused;
  10081. this.blur( event, event && event.type === "focus" );
  10082. this._scrollIntoView( item );
  10083. this.active = item.first();
  10084. focused = this.active.children( "a" ).addClass( "ui-state-focus" );
  10085. // Only update aria-activedescendant if there's a role
  10086. // otherwise we assume focus is managed elsewhere
  10087. if ( this.options.role ) {
  10088. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  10089. }
  10090. // Highlight active parent menu item, if any
  10091. this.active
  10092. .parent()
  10093. .closest( ".ui-menu-item" )
  10094. .children( "a:first" )
  10095. .addClass( "ui-state-active" );
  10096. if ( event && event.type === "keydown" ) {
  10097. this._close();
  10098. } else {
  10099. this.timer = this._delay(function() {
  10100. this._close();
  10101. }, this.delay );
  10102. }
  10103. nested = item.children( ".ui-menu" );
  10104. if ( nested.length && ( /^mouse/.test( event.type ) ) ) {
  10105. this._startOpening(nested);
  10106. }
  10107. this.activeMenu = item.parent();
  10108. this._trigger( "focus", event, { item: item } );
  10109. },
  10110. _scrollIntoView: function( item ) {
  10111. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  10112. if ( this._hasScroll() ) {
  10113. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  10114. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  10115. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  10116. scroll = this.activeMenu.scrollTop();
  10117. elementHeight = this.activeMenu.height();
  10118. itemHeight = item.height();
  10119. if ( offset < 0 ) {
  10120. this.activeMenu.scrollTop( scroll + offset );
  10121. } else if ( offset + itemHeight > elementHeight ) {
  10122. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  10123. }
  10124. }
  10125. },
  10126. blur: function( event, fromFocus ) {
  10127. if ( !fromFocus ) {
  10128. clearTimeout( this.timer );
  10129. }
  10130. if ( !this.active ) {
  10131. return;
  10132. }
  10133. this.active.children( "a" ).removeClass( "ui-state-focus" );
  10134. this.active = null;
  10135. this._trigger( "blur", event, { item: this.active } );
  10136. },
  10137. _startOpening: function( submenu ) {
  10138. clearTimeout( this.timer );
  10139. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  10140. // shift in the submenu position when mousing over the carat icon
  10141. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  10142. return;
  10143. }
  10144. this.timer = this._delay(function() {
  10145. this._close();
  10146. this._open( submenu );
  10147. }, this.delay );
  10148. },
  10149. _open: function( submenu ) {
  10150. var position = $.extend({
  10151. of: this.active
  10152. }, this.options.position );
  10153. clearTimeout( this.timer );
  10154. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  10155. .hide()
  10156. .attr( "aria-hidden", "true" );
  10157. submenu
  10158. .show()
  10159. .removeAttr( "aria-hidden" )
  10160. .attr( "aria-expanded", "true" )
  10161. .position( position );
  10162. },
  10163. collapseAll: function( event, all ) {
  10164. clearTimeout( this.timer );
  10165. this.timer = this._delay(function() {
  10166. // If we were passed an event, look for the submenu that contains the event
  10167. var currentMenu = all ? this.element :
  10168. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  10169. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  10170. if ( !currentMenu.length ) {
  10171. currentMenu = this.element;
  10172. }
  10173. this._close( currentMenu );
  10174. this.blur( event );
  10175. this.activeMenu = currentMenu;
  10176. }, this.delay );
  10177. },
  10178. // With no arguments, closes the currently active menu - if nothing is active
  10179. // it closes all menus. If passed an argument, it will search for menus BELOW
  10180. _close: function( startMenu ) {
  10181. if ( !startMenu ) {
  10182. startMenu = this.active ? this.active.parent() : this.element;
  10183. }
  10184. startMenu
  10185. .find( ".ui-menu" )
  10186. .hide()
  10187. .attr( "aria-hidden", "true" )
  10188. .attr( "aria-expanded", "false" )
  10189. .end()
  10190. .find( "a.ui-state-active" )
  10191. .removeClass( "ui-state-active" );
  10192. },
  10193. collapse: function( event ) {
  10194. var newItem = this.active &&
  10195. this.active.parent().closest( ".ui-menu-item", this.element );
  10196. if ( newItem && newItem.length ) {
  10197. this._close();
  10198. this.focus( event, newItem );
  10199. }
  10200. },
  10201. expand: function( event ) {
  10202. var newItem = this.active &&
  10203. this.active
  10204. .children( ".ui-menu " )
  10205. .children( ".ui-menu-item" )
  10206. .first();
  10207. if ( newItem && newItem.length ) {
  10208. this._open( newItem.parent() );
  10209. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  10210. this._delay(function() {
  10211. this.focus( event, newItem );
  10212. });
  10213. }
  10214. },
  10215. next: function( event ) {
  10216. this._move( "next", "first", event );
  10217. },
  10218. previous: function( event ) {
  10219. this._move( "prev", "last", event );
  10220. },
  10221. isFirstItem: function() {
  10222. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  10223. },
  10224. isLastItem: function() {
  10225. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  10226. },
  10227. _move: function( direction, filter, event ) {
  10228. var next;
  10229. if ( this.active ) {
  10230. if ( direction === "first" || direction === "last" ) {
  10231. next = this.active
  10232. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  10233. .eq( -1 );
  10234. } else {
  10235. next = this.active
  10236. [ direction + "All" ]( ".ui-menu-item" )
  10237. .eq( 0 );
  10238. }
  10239. }
  10240. if ( !next || !next.length || !this.active ) {
  10241. next = this.activeMenu.children( ".ui-menu-item" )[ filter ]();
  10242. }
  10243. this.focus( event, next );
  10244. },
  10245. nextPage: function( event ) {
  10246. var item, base, height;
  10247. if ( !this.active ) {
  10248. this.next( event );
  10249. return;
  10250. }
  10251. if ( this.isLastItem() ) {
  10252. return;
  10253. }
  10254. if ( this._hasScroll() ) {
  10255. base = this.active.offset().top;
  10256. height = this.element.height();
  10257. this.active.nextAll( ".ui-menu-item" ).each(function() {
  10258. item = $( this );
  10259. return item.offset().top - base - height < 0;
  10260. });
  10261. this.focus( event, item );
  10262. } else {
  10263. this.focus( event, this.activeMenu.children( ".ui-menu-item" )
  10264. [ !this.active ? "first" : "last" ]() );
  10265. }
  10266. },
  10267. previousPage: function( event ) {
  10268. var item, base, height;
  10269. if ( !this.active ) {
  10270. this.next( event );
  10271. return;
  10272. }
  10273. if ( this.isFirstItem() ) {
  10274. return;
  10275. }
  10276. if ( this._hasScroll() ) {
  10277. base = this.active.offset().top;
  10278. height = this.element.height();
  10279. this.active.prevAll( ".ui-menu-item" ).each(function() {
  10280. item = $( this );
  10281. return item.offset().top - base + height > 0;
  10282. });
  10283. this.focus( event, item );
  10284. } else {
  10285. this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
  10286. }
  10287. },
  10288. _hasScroll: function() {
  10289. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  10290. },
  10291. select: function( event ) {
  10292. // TODO: It should never be possible to not have an active item at this
  10293. // point, but the tests don't trigger mouseenter before click.
  10294. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  10295. var ui = { item: this.active };
  10296. if ( !this.active.has( ".ui-menu" ).length ) {
  10297. this.collapseAll( event, true );
  10298. }
  10299. this._trigger( "select", event, ui );
  10300. }
  10301. });
  10302. }( jQuery ));
  10303. (function( $, undefined ) {
  10304. $.ui = $.ui || {};
  10305. var cachedScrollbarWidth,
  10306. max = Math.max,
  10307. abs = Math.abs,
  10308. round = Math.round,
  10309. rhorizontal = /left|center|right/,
  10310. rvertical = /top|center|bottom/,
  10311. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  10312. rposition = /^\w+/,
  10313. rpercent = /%$/,
  10314. _position = $.fn.position;
  10315. function getOffsets( offsets, width, height ) {
  10316. return [
  10317. parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  10318. parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  10319. ];
  10320. }
  10321. function parseCss( element, property ) {
  10322. return parseInt( $.css( element, property ), 10 ) || 0;
  10323. }
  10324. function getDimensions( elem ) {
  10325. var raw = elem[0];
  10326. if ( raw.nodeType === 9 ) {
  10327. return {
  10328. width: elem.width(),
  10329. height: elem.height(),
  10330. offset: { top: 0, left: 0 }
  10331. };
  10332. }
  10333. if ( $.isWindow( raw ) ) {
  10334. return {
  10335. width: elem.width(),
  10336. height: elem.height(),
  10337. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  10338. };
  10339. }
  10340. if ( raw.preventDefault ) {
  10341. return {
  10342. width: 0,
  10343. height: 0,
  10344. offset: { top: raw.pageY, left: raw.pageX }
  10345. };
  10346. }
  10347. return {
  10348. width: elem.outerWidth(),
  10349. height: elem.outerHeight(),
  10350. offset: elem.offset()
  10351. };
  10352. }
  10353. $.position = {
  10354. scrollbarWidth: function() {
  10355. if ( cachedScrollbarWidth !== undefined ) {
  10356. return cachedScrollbarWidth;
  10357. }
  10358. var w1, w2,
  10359. div = $( "<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
  10360. innerDiv = div.children()[0];
  10361. $( "body" ).append( div );
  10362. w1 = innerDiv.offsetWidth;
  10363. div.css( "overflow", "scroll" );
  10364. w2 = innerDiv.offsetWidth;
  10365. if ( w1 === w2 ) {
  10366. w2 = div[0].clientWidth;
  10367. }
  10368. div.remove();
  10369. return (cachedScrollbarWidth = w1 - w2);
  10370. },
  10371. getScrollInfo: function( within ) {
  10372. var overflowX = within.isWindow ? "" : within.element.css( "overflow-x" ),
  10373. overflowY = within.isWindow ? "" : within.element.css( "overflow-y" ),
  10374. hasOverflowX = overflowX === "scroll" ||
  10375. ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
  10376. hasOverflowY = overflowY === "scroll" ||
  10377. ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
  10378. return {
  10379. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  10380. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  10381. };
  10382. },
  10383. getWithinInfo: function( element ) {
  10384. var withinElement = $( element || window ),
  10385. isWindow = $.isWindow( withinElement[0] );
  10386. return {
  10387. element: withinElement,
  10388. isWindow: isWindow,
  10389. offset: withinElement.offset() || { left: 0, top: 0 },
  10390. scrollLeft: withinElement.scrollLeft(),
  10391. scrollTop: withinElement.scrollTop(),
  10392. width: isWindow ? withinElement.width() : withinElement.outerWidth(),
  10393. height: isWindow ? withinElement.height() : withinElement.outerHeight()
  10394. };
  10395. }
  10396. };
  10397. $.fn.position = function( options ) {
  10398. if ( !options || !options.of ) {
  10399. return _position.apply( this, arguments );
  10400. }
  10401. // make a copy, we don't want to modify arguments
  10402. options = $.extend( {}, options );
  10403. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  10404. target = $( options.of ),
  10405. within = $.position.getWithinInfo( options.within ),
  10406. scrollInfo = $.position.getScrollInfo( within ),
  10407. collision = ( options.collision || "flip" ).split( " " ),
  10408. offsets = {};
  10409. dimensions = getDimensions( target );
  10410. if ( target[0].preventDefault ) {
  10411. // force left top to allow flipping
  10412. options.at = "left top";
  10413. }
  10414. targetWidth = dimensions.width;
  10415. targetHeight = dimensions.height;
  10416. targetOffset = dimensions.offset;
  10417. // clone to reuse original targetOffset later
  10418. basePosition = $.extend( {}, targetOffset );
  10419. // force my and at to have valid horizontal and vertical positions
  10420. // if a value is missing or invalid, it will be converted to center
  10421. $.each( [ "my", "at" ], function() {
  10422. var pos = ( options[ this ] || "" ).split( " " ),
  10423. horizontalOffset,
  10424. verticalOffset;
  10425. if ( pos.length === 1) {
  10426. pos = rhorizontal.test( pos[ 0 ] ) ?
  10427. pos.concat( [ "center" ] ) :
  10428. rvertical.test( pos[ 0 ] ) ?
  10429. [ "center" ].concat( pos ) :
  10430. [ "center", "center" ];
  10431. }
  10432. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  10433. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  10434. // calculate offsets
  10435. horizontalOffset = roffset.exec( pos[ 0 ] );
  10436. verticalOffset = roffset.exec( pos[ 1 ] );
  10437. offsets[ this ] = [
  10438. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  10439. verticalOffset ? verticalOffset[ 0 ] : 0
  10440. ];
  10441. // reduce to just the positions without the offsets
  10442. options[ this ] = [
  10443. rposition.exec( pos[ 0 ] )[ 0 ],
  10444. rposition.exec( pos[ 1 ] )[ 0 ]
  10445. ];
  10446. });
  10447. // normalize collision option
  10448. if ( collision.length === 1 ) {
  10449. collision[ 1 ] = collision[ 0 ];
  10450. }
  10451. if ( options.at[ 0 ] === "right" ) {
  10452. basePosition.left += targetWidth;
  10453. } else if ( options.at[ 0 ] === "center" ) {
  10454. basePosition.left += targetWidth / 2;
  10455. }
  10456. if ( options.at[ 1 ] === "bottom" ) {
  10457. basePosition.top += targetHeight;
  10458. } else if ( options.at[ 1 ] === "center" ) {
  10459. basePosition.top += targetHeight / 2;
  10460. }
  10461. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  10462. basePosition.left += atOffset[ 0 ];
  10463. basePosition.top += atOffset[ 1 ];
  10464. return this.each(function() {
  10465. var collisionPosition, using,
  10466. elem = $( this ),
  10467. elemWidth = elem.outerWidth(),
  10468. elemHeight = elem.outerHeight(),
  10469. marginLeft = parseCss( this, "marginLeft" ),
  10470. marginTop = parseCss( this, "marginTop" ),
  10471. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
  10472. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
  10473. position = $.extend( {}, basePosition ),
  10474. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  10475. if ( options.my[ 0 ] === "right" ) {
  10476. position.left -= elemWidth;
  10477. } else if ( options.my[ 0 ] === "center" ) {
  10478. position.left -= elemWidth / 2;
  10479. }
  10480. if ( options.my[ 1 ] === "bottom" ) {
  10481. position.top -= elemHeight;
  10482. } else if ( options.my[ 1 ] === "center" ) {
  10483. position.top -= elemHeight / 2;
  10484. }
  10485. position.left += myOffset[ 0 ];
  10486. position.top += myOffset[ 1 ];
  10487. // if the browser doesn't support fractions, then round for consistent results
  10488. if ( !$.support.offsetFractions ) {
  10489. position.left = round( position.left );
  10490. position.top = round( position.top );
  10491. }
  10492. collisionPosition = {
  10493. marginLeft: marginLeft,
  10494. marginTop: marginTop
  10495. };
  10496. $.each( [ "left", "top" ], function( i, dir ) {
  10497. if ( $.ui.position[ collision[ i ] ] ) {
  10498. $.ui.position[ collision[ i ] ][ dir ]( position, {
  10499. targetWidth: targetWidth,
  10500. targetHeight: targetHeight,
  10501. elemWidth: elemWidth,
  10502. elemHeight: elemHeight,
  10503. collisionPosition: collisionPosition,
  10504. collisionWidth: collisionWidth,
  10505. collisionHeight: collisionHeight,
  10506. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  10507. my: options.my,
  10508. at: options.at,
  10509. within: within,
  10510. elem : elem
  10511. });
  10512. }
  10513. });
  10514. if ( options.using ) {
  10515. // adds feedback as second argument to using callback, if present
  10516. using = function( props ) {
  10517. var left = targetOffset.left - position.left,
  10518. right = left + targetWidth - elemWidth,
  10519. top = targetOffset.top - position.top,
  10520. bottom = top + targetHeight - elemHeight,
  10521. feedback = {
  10522. target: {
  10523. element: target,
  10524. left: targetOffset.left,
  10525. top: targetOffset.top,
  10526. width: targetWidth,
  10527. height: targetHeight
  10528. },
  10529. element: {
  10530. element: elem,
  10531. left: position.left,
  10532. top: position.top,
  10533. width: elemWidth,
  10534. height: elemHeight
  10535. },
  10536. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  10537. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  10538. };
  10539. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  10540. feedback.horizontal = "center";
  10541. }
  10542. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  10543. feedback.vertical = "middle";
  10544. }
  10545. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  10546. feedback.important = "horizontal";
  10547. } else {
  10548. feedback.important = "vertical";
  10549. }
  10550. options.using.call( this, props, feedback );
  10551. };
  10552. }
  10553. elem.offset( $.extend( position, { using: using } ) );
  10554. });
  10555. };
  10556. $.ui.position = {
  10557. fit: {
  10558. left: function( position, data ) {
  10559. var within = data.within,
  10560. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  10561. outerWidth = within.width,
  10562. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  10563. overLeft = withinOffset - collisionPosLeft,
  10564. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  10565. newOverRight;
  10566. // element is wider than within
  10567. if ( data.collisionWidth > outerWidth ) {
  10568. // element is initially over the left side of within
  10569. if ( overLeft > 0 && overRight <= 0 ) {
  10570. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
  10571. position.left += overLeft - newOverRight;
  10572. // element is initially over right side of within
  10573. } else if ( overRight > 0 && overLeft <= 0 ) {
  10574. position.left = withinOffset;
  10575. // element is initially over both left and right sides of within
  10576. } else {
  10577. if ( overLeft > overRight ) {
  10578. position.left = withinOffset + outerWidth - data.collisionWidth;
  10579. } else {
  10580. position.left = withinOffset;
  10581. }
  10582. }
  10583. // too far left -> align with left edge
  10584. } else if ( overLeft > 0 ) {
  10585. position.left += overLeft;
  10586. // too far right -> align with right edge
  10587. } else if ( overRight > 0 ) {
  10588. position.left -= overRight;
  10589. // adjust based on position and margin
  10590. } else {
  10591. position.left = max( position.left - collisionPosLeft, position.left );
  10592. }
  10593. },
  10594. top: function( position, data ) {
  10595. var within = data.within,
  10596. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  10597. outerHeight = data.within.height,
  10598. collisionPosTop = position.top - data.collisionPosition.marginTop,
  10599. overTop = withinOffset - collisionPosTop,
  10600. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  10601. newOverBottom;
  10602. // element is taller than within
  10603. if ( data.collisionHeight > outerHeight ) {
  10604. // element is initially over the top of within
  10605. if ( overTop > 0 && overBottom <= 0 ) {
  10606. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
  10607. position.top += overTop - newOverBottom;
  10608. // element is initially over bottom of within
  10609. } else if ( overBottom > 0 && overTop <= 0 ) {
  10610. position.top = withinOffset;
  10611. // element is initially over both top and bottom of within
  10612. } else {
  10613. if ( overTop > overBottom ) {
  10614. position.top = withinOffset + outerHeight - data.collisionHeight;
  10615. } else {
  10616. position.top = withinOffset;
  10617. }
  10618. }
  10619. // too far up -> align with top
  10620. } else if ( overTop > 0 ) {
  10621. position.top += overTop;
  10622. // too far down -> align with bottom edge
  10623. } else if ( overBottom > 0 ) {
  10624. position.top -= overBottom;
  10625. // adjust based on position and margin
  10626. } else {
  10627. position.top = max( position.top - collisionPosTop, position.top );
  10628. }
  10629. }
  10630. },
  10631. flip: {
  10632. left: function( position, data ) {
  10633. var within = data.within,
  10634. withinOffset = within.offset.left + within.scrollLeft,
  10635. outerWidth = within.width,
  10636. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  10637. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  10638. overLeft = collisionPosLeft - offsetLeft,
  10639. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  10640. myOffset = data.my[ 0 ] === "left" ?
  10641. -data.elemWidth :
  10642. data.my[ 0 ] === "right" ?
  10643. data.elemWidth :
  10644. 0,
  10645. atOffset = data.at[ 0 ] === "left" ?
  10646. data.targetWidth :
  10647. data.at[ 0 ] === "right" ?
  10648. -data.targetWidth :
  10649. 0,
  10650. offset = -2 * data.offset[ 0 ],
  10651. newOverRight,
  10652. newOverLeft;
  10653. if ( overLeft < 0 ) {
  10654. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
  10655. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  10656. position.left += myOffset + atOffset + offset;
  10657. }
  10658. }
  10659. else if ( overRight > 0 ) {
  10660. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
  10661. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  10662. position.left += myOffset + atOffset + offset;
  10663. }
  10664. }
  10665. },
  10666. top: function( position, data ) {
  10667. var within = data.within,
  10668. withinOffset = within.offset.top + within.scrollTop,
  10669. outerHeight = within.height,
  10670. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  10671. collisionPosTop = position.top - data.collisionPosition.marginTop,
  10672. overTop = collisionPosTop - offsetTop,
  10673. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  10674. top = data.my[ 1 ] === "top",
  10675. myOffset = top ?
  10676. -data.elemHeight :
  10677. data.my[ 1 ] === "bottom" ?
  10678. data.elemHeight :
  10679. 0,
  10680. atOffset = data.at[ 1 ] === "top" ?
  10681. data.targetHeight :
  10682. data.at[ 1 ] === "bottom" ?
  10683. -data.targetHeight :
  10684. 0,
  10685. offset = -2 * data.offset[ 1 ],
  10686. newOverTop,
  10687. newOverBottom;
  10688. if ( overTop < 0 ) {
  10689. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
  10690. if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
  10691. position.top += myOffset + atOffset + offset;
  10692. }
  10693. }
  10694. else if ( overBottom > 0 ) {
  10695. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
  10696. if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
  10697. position.top += myOffset + atOffset + offset;
  10698. }
  10699. }
  10700. }
  10701. },
  10702. flipfit: {
  10703. left: function() {
  10704. $.ui.position.flip.left.apply( this, arguments );
  10705. $.ui.position.fit.left.apply( this, arguments );
  10706. },
  10707. top: function() {
  10708. $.ui.position.flip.top.apply( this, arguments );
  10709. $.ui.position.fit.top.apply( this, arguments );
  10710. }
  10711. }
  10712. };
  10713. // fraction support test
  10714. (function () {
  10715. var testElement, testElementParent, testElementStyle, offsetLeft, i,
  10716. body = document.getElementsByTagName( "body" )[ 0 ],
  10717. div = document.createElement( "div" );
  10718. //Create a "fake body" for testing based on method used in jQuery.support
  10719. testElement = document.createElement( body ? "div" : "body" );
  10720. testElementStyle = {
  10721. visibility: "hidden",
  10722. width: 0,
  10723. height: 0,
  10724. border: 0,
  10725. margin: 0,
  10726. background: "none"
  10727. };
  10728. if ( body ) {
  10729. $.extend( testElementStyle, {
  10730. position: "absolute",
  10731. left: "-1000px",
  10732. top: "-1000px"
  10733. });
  10734. }
  10735. for ( i in testElementStyle ) {
  10736. testElement.style[ i ] = testElementStyle[ i ];
  10737. }
  10738. testElement.appendChild( div );
  10739. testElementParent = body || document.documentElement;
  10740. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  10741. div.style.cssText = "position: absolute; left: 10.7432222px;";
  10742. offsetLeft = $( div ).offset().left;
  10743. $.support.offsetFractions = offsetLeft > 10 && offsetLeft < 11;
  10744. testElement.innerHTML = "";
  10745. testElementParent.removeChild( testElement );
  10746. })();
  10747. }( jQuery ) );
  10748. (function( $, undefined ) {
  10749. $.widget( "ui.progressbar", {
  10750. version: "1.10.3",
  10751. options: {
  10752. max: 100,
  10753. value: 0,
  10754. change: null,
  10755. complete: null
  10756. },
  10757. min: 0,
  10758. _create: function() {
  10759. // Constrain initial value
  10760. this.oldValue = this.options.value = this._constrainedValue();
  10761. this.element
  10762. .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  10763. .attr({
  10764. // Only set static values, aria-valuenow and aria-valuemax are
  10765. // set inside _refreshValue()
  10766. role: "progressbar",
  10767. "aria-valuemin": this.min
  10768. });
  10769. this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
  10770. .appendTo( this.element );
  10771. this._refreshValue();
  10772. },
  10773. _destroy: function() {
  10774. this.element
  10775. .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  10776. .removeAttr( "role" )
  10777. .removeAttr( "aria-valuemin" )
  10778. .removeAttr( "aria-valuemax" )
  10779. .removeAttr( "aria-valuenow" );
  10780. this.valueDiv.remove();
  10781. },
  10782. value: function( newValue ) {
  10783. if ( newValue === undefined ) {
  10784. return this.options.value;
  10785. }
  10786. this.options.value = this._constrainedValue( newValue );
  10787. this._refreshValue();
  10788. },
  10789. _constrainedValue: function( newValue ) {
  10790. if ( newValue === undefined ) {
  10791. newValue = this.options.value;
  10792. }
  10793. this.indeterminate = newValue === false;
  10794. // sanitize value
  10795. if ( typeof newValue !== "number" ) {
  10796. newValue = 0;
  10797. }
  10798. return this.indeterminate ? false :
  10799. Math.min( this.options.max, Math.max( this.min, newValue ) );
  10800. },
  10801. _setOptions: function( options ) {
  10802. // Ensure "value" option is set after other values (like max)
  10803. var value = options.value;
  10804. delete options.value;
  10805. this._super( options );
  10806. this.options.value = this._constrainedValue( value );
  10807. this._refreshValue();
  10808. },
  10809. _setOption: function( key, value ) {
  10810. if ( key === "max" ) {
  10811. // Don't allow a max less than min
  10812. value = Math.max( this.min, value );
  10813. }
  10814. this._super( key, value );
  10815. },
  10816. _percentage: function() {
  10817. return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  10818. },
  10819. _refreshValue: function() {
  10820. var value = this.options.value,
  10821. percentage = this._percentage();
  10822. this.valueDiv
  10823. .toggle( this.indeterminate || value > this.min )
  10824. .toggleClass( "ui-corner-right", value === this.options.max )
  10825. .width( percentage.toFixed(0) + "%" );
  10826. this.element.toggleClass( "ui-progressbar-indeterminate", this.indeterminate );
  10827. if ( this.indeterminate ) {
  10828. this.element.removeAttr( "aria-valuenow" );
  10829. if ( !this.overlayDiv ) {
  10830. this.overlayDiv = $( "<div class='ui-progressbar-overlay'></div>" ).appendTo( this.valueDiv );
  10831. }
  10832. } else {
  10833. this.element.attr({
  10834. "aria-valuemax": this.options.max,
  10835. "aria-valuenow": value
  10836. });
  10837. if ( this.overlayDiv ) {
  10838. this.overlayDiv.remove();
  10839. this.overlayDiv = null;
  10840. }
  10841. }
  10842. if ( this.oldValue !== value ) {
  10843. this.oldValue = value;
  10844. this._trigger( "change" );
  10845. }
  10846. if ( value === this.options.max ) {
  10847. this._trigger( "complete" );
  10848. }
  10849. }
  10850. });
  10851. })( jQuery );
  10852. (function( $, undefined ) {
  10853. // number of pages in a slider
  10854. // (how many times can you page up/down to go through the whole range)
  10855. var numPages = 5;
  10856. $.widget( "ui.slider", $.ui.mouse, {
  10857. version: "1.10.3",
  10858. widgetEventPrefix: "slide",
  10859. options: {
  10860. animate: false,
  10861. distance: 0,
  10862. max: 100,
  10863. min: 0,
  10864. orientation: "horizontal",
  10865. range: false,
  10866. step: 1,
  10867. value: 0,
  10868. values: null,
  10869. // callbacks
  10870. change: null,
  10871. slide: null,
  10872. start: null,
  10873. stop: null
  10874. },
  10875. _create: function() {
  10876. this._keySliding = false;
  10877. this._mouseSliding = false;
  10878. this._animateOff = true;
  10879. this._handleIndex = null;
  10880. this._detectOrientation();
  10881. this._mouseInit();
  10882. this.element
  10883. .addClass( "ui-slider" +
  10884. " ui-slider-" + this.orientation +
  10885. " ui-widget" +
  10886. " ui-widget-content" +
  10887. " ui-corner-all");
  10888. this._refresh();
  10889. this._setOption( "disabled", this.options.disabled );
  10890. this._animateOff = false;
  10891. },
  10892. _refresh: function() {
  10893. this._createRange();
  10894. this._createHandles();
  10895. this._setupEvents();
  10896. this._refreshValue();
  10897. },
  10898. _createHandles: function() {
  10899. var i, handleCount,
  10900. options = this.options,
  10901. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  10902. handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
  10903. handles = [];
  10904. handleCount = ( options.values && options.values.length ) || 1;
  10905. if ( existingHandles.length > handleCount ) {
  10906. existingHandles.slice( handleCount ).remove();
  10907. existingHandles = existingHandles.slice( 0, handleCount );
  10908. }
  10909. for ( i = existingHandles.length; i < handleCount; i++ ) {
  10910. handles.push( handle );
  10911. }
  10912. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  10913. this.handle = this.handles.eq( 0 );
  10914. this.handles.each(function( i ) {
  10915. $( this ).data( "ui-slider-handle-index", i );
  10916. });
  10917. },
  10918. _createRange: function() {
  10919. var options = this.options,
  10920. classes = "";
  10921. if ( options.range ) {
  10922. if ( options.range === true ) {
  10923. if ( !options.values ) {
  10924. options.values = [ this._valueMin(), this._valueMin() ];
  10925. } else if ( options.values.length && options.values.length !== 2 ) {
  10926. options.values = [ options.values[0], options.values[0] ];
  10927. } else if ( $.isArray( options.values ) ) {
  10928. options.values = options.values.slice(0);
  10929. }
  10930. }
  10931. if ( !this.range || !this.range.length ) {
  10932. this.range = $( "<div></div>" )
  10933. .appendTo( this.element );
  10934. classes = "ui-slider-range" +
  10935. // note: this isn't the most fittingly semantic framework class for this element,
  10936. // but worked best visually with a variety of themes
  10937. " ui-widget-header ui-corner-all";
  10938. } else {
  10939. this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
  10940. // Handle range switching from true to min/max
  10941. .css({
  10942. "left": "",
  10943. "bottom": ""
  10944. });
  10945. }
  10946. this.range.addClass( classes +
  10947. ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
  10948. } else {
  10949. this.range = $([]);
  10950. }
  10951. },
  10952. _setupEvents: function() {
  10953. var elements = this.handles.add( this.range ).filter( "a" );
  10954. this._off( elements );
  10955. this._on( elements, this._handleEvents );
  10956. this._hoverable( elements );
  10957. this._focusable( elements );
  10958. },
  10959. _destroy: function() {
  10960. this.handles.remove();
  10961. this.range.remove();
  10962. this.element
  10963. .removeClass( "ui-slider" +
  10964. " ui-slider-horizontal" +
  10965. " ui-slider-vertical" +
  10966. " ui-widget" +
  10967. " ui-widget-content" +
  10968. " ui-corner-all" );
  10969. this._mouseDestroy();
  10970. },
  10971. _mouseCapture: function( event ) {
  10972. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  10973. that = this,
  10974. o = this.options;
  10975. if ( o.disabled ) {
  10976. return false;
  10977. }
  10978. this.elementSize = {
  10979. width: this.element.outerWidth(),
  10980. height: this.element.outerHeight()
  10981. };
  10982. this.elementOffset = this.element.offset();
  10983. position = { x: event.pageX, y: event.pageY };
  10984. normValue = this._normValueFromMouse( position );
  10985. distance = this._valueMax() - this._valueMin() + 1;
  10986. this.handles.each(function( i ) {
  10987. var thisDistance = Math.abs( normValue - that.values(i) );
  10988. if (( distance > thisDistance ) ||
  10989. ( distance === thisDistance &&
  10990. (i === that._lastChangedValue || that.values(i) === o.min ))) {
  10991. distance = thisDistance;
  10992. closestHandle = $( this );
  10993. index = i;
  10994. }
  10995. });
  10996. allowed = this._start( event, index );
  10997. if ( allowed === false ) {
  10998. return false;
  10999. }
  11000. this._mouseSliding = true;
  11001. this._handleIndex = index;
  11002. closestHandle
  11003. .addClass( "ui-state-active" )
  11004. .focus();
  11005. offset = closestHandle.offset();
  11006. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  11007. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  11008. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  11009. top: event.pageY - offset.top -
  11010. ( closestHandle.height() / 2 ) -
  11011. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  11012. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  11013. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  11014. };
  11015. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  11016. this._slide( event, index, normValue );
  11017. }
  11018. this._animateOff = true;
  11019. return true;
  11020. },
  11021. _mouseStart: function() {
  11022. return true;
  11023. },
  11024. _mouseDrag: function( event ) {
  11025. var position = { x: event.pageX, y: event.pageY },
  11026. normValue = this._normValueFromMouse( position );
  11027. this._slide( event, this._handleIndex, normValue );
  11028. return false;
  11029. },
  11030. _mouseStop: function( event ) {
  11031. this.handles.removeClass( "ui-state-active" );
  11032. this._mouseSliding = false;
  11033. this._stop( event, this._handleIndex );
  11034. this._change( event, this._handleIndex );
  11035. this._handleIndex = null;
  11036. this._clickOffset = null;
  11037. this._animateOff = false;
  11038. return false;
  11039. },
  11040. _detectOrientation: function() {
  11041. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  11042. },
  11043. _normValueFromMouse: function( position ) {
  11044. var pixelTotal,
  11045. pixelMouse,
  11046. percentMouse,
  11047. valueTotal,
  11048. valueMouse;
  11049. if ( this.orientation === "horizontal" ) {
  11050. pixelTotal = this.elementSize.width;
  11051. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  11052. } else {
  11053. pixelTotal = this.elementSize.height;
  11054. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  11055. }
  11056. percentMouse = ( pixelMouse / pixelTotal );
  11057. if ( percentMouse > 1 ) {
  11058. percentMouse = 1;
  11059. }
  11060. if ( percentMouse < 0 ) {
  11061. percentMouse = 0;
  11062. }
  11063. if ( this.orientation === "vertical" ) {
  11064. percentMouse = 1 - percentMouse;
  11065. }
  11066. valueTotal = this._valueMax() - this._valueMin();
  11067. valueMouse = this._valueMin() + percentMouse * valueTotal;
  11068. return this._trimAlignValue( valueMouse );
  11069. },
  11070. _start: function( event, index ) {
  11071. var uiHash = {
  11072. handle: this.handles[ index ],
  11073. value: this.value()
  11074. };
  11075. if ( this.options.values && this.options.values.length ) {
  11076. uiHash.value = this.values( index );
  11077. uiHash.values = this.values();
  11078. }
  11079. return this._trigger( "start", event, uiHash );
  11080. },
  11081. _slide: function( event, index, newVal ) {
  11082. var otherVal,
  11083. newValues,
  11084. allowed;
  11085. if ( this.options.values && this.options.values.length ) {
  11086. otherVal = this.values( index ? 0 : 1 );
  11087. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  11088. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  11089. ) {
  11090. newVal = otherVal;
  11091. }
  11092. if ( newVal !== this.values( index ) ) {
  11093. newValues = this.values();
  11094. newValues[ index ] = newVal;
  11095. // A slide can be canceled by returning false from the slide callback
  11096. allowed = this._trigger( "slide", event, {
  11097. handle: this.handles[ index ],
  11098. value: newVal,
  11099. values: newValues
  11100. } );
  11101. otherVal = this.values( index ? 0 : 1 );
  11102. if ( allowed !== false ) {
  11103. this.values( index, newVal, true );
  11104. }
  11105. }
  11106. } else {
  11107. if ( newVal !== this.value() ) {
  11108. // A slide can be canceled by returning false from the slide callback
  11109. allowed = this._trigger( "slide", event, {
  11110. handle: this.handles[ index ],
  11111. value: newVal
  11112. } );
  11113. if ( allowed !== false ) {
  11114. this.value( newVal );
  11115. }
  11116. }
  11117. }
  11118. },
  11119. _stop: function( event, index ) {
  11120. var uiHash = {
  11121. handle: this.handles[ index ],
  11122. value: this.value()
  11123. };
  11124. if ( this.options.values && this.options.values.length ) {
  11125. uiHash.value = this.values( index );
  11126. uiHash.values = this.values();
  11127. }
  11128. this._trigger( "stop", event, uiHash );
  11129. },
  11130. _change: function( event, index ) {
  11131. if ( !this._keySliding && !this._mouseSliding ) {
  11132. var uiHash = {
  11133. handle: this.handles[ index ],
  11134. value: this.value()
  11135. };
  11136. if ( this.options.values && this.options.values.length ) {
  11137. uiHash.value = this.values( index );
  11138. uiHash.values = this.values();
  11139. }
  11140. //store the last changed value index for reference when handles overlap
  11141. this._lastChangedValue = index;
  11142. this._trigger( "change", event, uiHash );
  11143. }
  11144. },
  11145. value: function( newValue ) {
  11146. if ( arguments.length ) {
  11147. this.options.value = this._trimAlignValue( newValue );
  11148. this._refreshValue();
  11149. this._change( null, 0 );
  11150. return;
  11151. }
  11152. return this._value();
  11153. },
  11154. values: function( index, newValue ) {
  11155. var vals,
  11156. newValues,
  11157. i;
  11158. if ( arguments.length > 1 ) {
  11159. this.options.values[ index ] = this._trimAlignValue( newValue );
  11160. this._refreshValue();
  11161. this._change( null, index );
  11162. return;
  11163. }
  11164. if ( arguments.length ) {
  11165. if ( $.isArray( arguments[ 0 ] ) ) {
  11166. vals = this.options.values;
  11167. newValues = arguments[ 0 ];
  11168. for ( i = 0; i < vals.length; i += 1 ) {
  11169. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  11170. this._change( null, i );
  11171. }
  11172. this._refreshValue();
  11173. } else {
  11174. if ( this.options.values && this.options.values.length ) {
  11175. return this._values( index );
  11176. } else {
  11177. return this.value();
  11178. }
  11179. }
  11180. } else {
  11181. return this._values();
  11182. }
  11183. },
  11184. _setOption: function( key, value ) {
  11185. var i,
  11186. valsLength = 0;
  11187. if ( key === "range" && this.options.range === true ) {
  11188. if ( value === "min" ) {
  11189. this.options.value = this._values( 0 );
  11190. this.options.values = null;
  11191. } else if ( value === "max" ) {
  11192. this.options.value = this._values( this.options.values.length-1 );
  11193. this.options.values = null;
  11194. }
  11195. }
  11196. if ( $.isArray( this.options.values ) ) {
  11197. valsLength = this.options.values.length;
  11198. }
  11199. $.Widget.prototype._setOption.apply( this, arguments );
  11200. switch ( key ) {
  11201. case "orientation":
  11202. this._detectOrientation();
  11203. this.element
  11204. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  11205. .addClass( "ui-slider-" + this.orientation );
  11206. this._refreshValue();
  11207. break;
  11208. case "value":
  11209. this._animateOff = true;
  11210. this._refreshValue();
  11211. this._change( null, 0 );
  11212. this._animateOff = false;
  11213. break;
  11214. case "values":
  11215. this._animateOff = true;
  11216. this._refreshValue();
  11217. for ( i = 0; i < valsLength; i += 1 ) {
  11218. this._change( null, i );
  11219. }
  11220. this._animateOff = false;
  11221. break;
  11222. case "min":
  11223. case "max":
  11224. this._animateOff = true;
  11225. this._refreshValue();
  11226. this._animateOff = false;
  11227. break;
  11228. case "range":
  11229. this._animateOff = true;
  11230. this._refresh();
  11231. this._animateOff = false;
  11232. break;
  11233. }
  11234. },
  11235. //internal value getter
  11236. // _value() returns value trimmed by min and max, aligned by step
  11237. _value: function() {
  11238. var val = this.options.value;
  11239. val = this._trimAlignValue( val );
  11240. return val;
  11241. },
  11242. //internal values getter
  11243. // _values() returns array of values trimmed by min and max, aligned by step
  11244. // _values( index ) returns single value trimmed by min and max, aligned by step
  11245. _values: function( index ) {
  11246. var val,
  11247. vals,
  11248. i;
  11249. if ( arguments.length ) {
  11250. val = this.options.values[ index ];
  11251. val = this._trimAlignValue( val );
  11252. return val;
  11253. } else if ( this.options.values && this.options.values.length ) {
  11254. // .slice() creates a copy of the array
  11255. // this copy gets trimmed by min and max and then returned
  11256. vals = this.options.values.slice();
  11257. for ( i = 0; i < vals.length; i+= 1) {
  11258. vals[ i ] = this._trimAlignValue( vals[ i ] );
  11259. }
  11260. return vals;
  11261. } else {
  11262. return [];
  11263. }
  11264. },
  11265. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  11266. _trimAlignValue: function( val ) {
  11267. if ( val <= this._valueMin() ) {
  11268. return this._valueMin();
  11269. }
  11270. if ( val >= this._valueMax() ) {
  11271. return this._valueMax();
  11272. }
  11273. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  11274. valModStep = (val - this._valueMin()) % step,
  11275. alignValue = val - valModStep;
  11276. if ( Math.abs(valModStep) * 2 >= step ) {
  11277. alignValue += ( valModStep > 0 ) ? step : ( -step );
  11278. }
  11279. // Since JavaScript has problems with large floats, round
  11280. // the final value to 5 digits after the decimal point (see #4124)
  11281. return parseFloat( alignValue.toFixed(5) );
  11282. },
  11283. _valueMin: function() {
  11284. return this.options.min;
  11285. },
  11286. _valueMax: function() {
  11287. return this.options.max;
  11288. },
  11289. _refreshValue: function() {
  11290. var lastValPercent, valPercent, value, valueMin, valueMax,
  11291. oRange = this.options.range,
  11292. o = this.options,
  11293. that = this,
  11294. animate = ( !this._animateOff ) ? o.animate : false,
  11295. _set = {};
  11296. if ( this.options.values && this.options.values.length ) {
  11297. this.handles.each(function( i ) {
  11298. valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
  11299. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  11300. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  11301. if ( that.options.range === true ) {
  11302. if ( that.orientation === "horizontal" ) {
  11303. if ( i === 0 ) {
  11304. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  11305. }
  11306. if ( i === 1 ) {
  11307. that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  11308. }
  11309. } else {
  11310. if ( i === 0 ) {
  11311. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  11312. }
  11313. if ( i === 1 ) {
  11314. that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  11315. }
  11316. }
  11317. }
  11318. lastValPercent = valPercent;
  11319. });
  11320. } else {
  11321. value = this.value();
  11322. valueMin = this._valueMin();
  11323. valueMax = this._valueMax();
  11324. valPercent = ( valueMax !== valueMin ) ?
  11325. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  11326. 0;
  11327. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  11328. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  11329. if ( oRange === "min" && this.orientation === "horizontal" ) {
  11330. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  11331. }
  11332. if ( oRange === "max" && this.orientation === "horizontal" ) {
  11333. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  11334. }
  11335. if ( oRange === "min" && this.orientation === "vertical" ) {
  11336. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  11337. }
  11338. if ( oRange === "max" && this.orientation === "vertical" ) {
  11339. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  11340. }
  11341. }
  11342. },
  11343. _handleEvents: {
  11344. keydown: function( event ) {
  11345. /*jshint maxcomplexity:25*/
  11346. var allowed, curVal, newVal, step,
  11347. index = $( event.target ).data( "ui-slider-handle-index" );
  11348. switch ( event.keyCode ) {
  11349. case $.ui.keyCode.HOME:
  11350. case $.ui.keyCode.END:
  11351. case $.ui.keyCode.PAGE_UP:
  11352. case $.ui.keyCode.PAGE_DOWN:
  11353. case $.ui.keyCode.UP:
  11354. case $.ui.keyCode.RIGHT:
  11355. case $.ui.keyCode.DOWN:
  11356. case $.ui.keyCode.LEFT:
  11357. event.preventDefault();
  11358. if ( !this._keySliding ) {
  11359. this._keySliding = true;
  11360. $( event.target ).addClass( "ui-state-active" );
  11361. allowed = this._start( event, index );
  11362. if ( allowed === false ) {
  11363. return;
  11364. }
  11365. }
  11366. break;
  11367. }
  11368. step = this.options.step;
  11369. if ( this.options.values && this.options.values.length ) {
  11370. curVal = newVal = this.values( index );
  11371. } else {
  11372. curVal = newVal = this.value();
  11373. }
  11374. switch ( event.keyCode ) {
  11375. case $.ui.keyCode.HOME:
  11376. newVal = this._valueMin();
  11377. break;
  11378. case $.ui.keyCode.END:
  11379. newVal = this._valueMax();
  11380. break;
  11381. case $.ui.keyCode.PAGE_UP:
  11382. newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) );
  11383. break;
  11384. case $.ui.keyCode.PAGE_DOWN:
  11385. newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) );
  11386. break;
  11387. case $.ui.keyCode.UP:
  11388. case $.ui.keyCode.RIGHT:
  11389. if ( curVal === this._valueMax() ) {
  11390. return;
  11391. }
  11392. newVal = this._trimAlignValue( curVal + step );
  11393. break;
  11394. case $.ui.keyCode.DOWN:
  11395. case $.ui.keyCode.LEFT:
  11396. if ( curVal === this._valueMin() ) {
  11397. return;
  11398. }
  11399. newVal = this._trimAlignValue( curVal - step );
  11400. break;
  11401. }
  11402. this._slide( event, index, newVal );
  11403. },
  11404. click: function( event ) {
  11405. event.preventDefault();
  11406. },
  11407. keyup: function( event ) {
  11408. var index = $( event.target ).data( "ui-slider-handle-index" );
  11409. if ( this._keySliding ) {
  11410. this._keySliding = false;
  11411. this._stop( event, index );
  11412. this._change( event, index );
  11413. $( event.target ).removeClass( "ui-state-active" );
  11414. }
  11415. }
  11416. }
  11417. });
  11418. }(jQuery));
  11419. (function( $ ) {
  11420. function modifier( fn ) {
  11421. return function() {
  11422. var previous = this.element.val();
  11423. fn.apply( this, arguments );
  11424. this._refresh();
  11425. if ( previous !== this.element.val() ) {
  11426. this._trigger( "change" );
  11427. }
  11428. };
  11429. }
  11430. $.widget( "ui.spinner", {
  11431. version: "1.10.3",
  11432. defaultElement: "<input>",
  11433. widgetEventPrefix: "spin",
  11434. options: {
  11435. culture: null,
  11436. icons: {
  11437. down: "ui-icon-triangle-1-s",
  11438. up: "ui-icon-triangle-1-n"
  11439. },
  11440. incremental: true,
  11441. max: null,
  11442. min: null,
  11443. numberFormat: null,
  11444. page: 10,
  11445. step: 1,
  11446. change: null,
  11447. spin: null,
  11448. start: null,
  11449. stop: null
  11450. },
  11451. _create: function() {
  11452. // handle string values that need to be parsed
  11453. this._setOption( "max", this.options.max );
  11454. this._setOption( "min", this.options.min );
  11455. this._setOption( "step", this.options.step );
  11456. // format the value, but don't constrain
  11457. this._value( this.element.val(), true );
  11458. this._draw();
  11459. this._on( this._events );
  11460. this._refresh();
  11461. // turning off autocomplete prevents the browser from remembering the
  11462. // value when navigating through history, so we re-enable autocomplete
  11463. // if the page is unloaded before the widget is destroyed. #7790
  11464. this._on( this.window, {
  11465. beforeunload: function() {
  11466. this.element.removeAttr( "autocomplete" );
  11467. }
  11468. });
  11469. },
  11470. _getCreateOptions: function() {
  11471. var options = {},
  11472. element = this.element;
  11473. $.each( [ "min", "max", "step" ], function( i, option ) {
  11474. var value = element.attr( option );
  11475. if ( value !== undefined && value.length ) {
  11476. options[ option ] = value;
  11477. }
  11478. });
  11479. return options;
  11480. },
  11481. _events: {
  11482. keydown: function( event ) {
  11483. if ( this._start( event ) && this._keydown( event ) ) {
  11484. event.preventDefault();
  11485. }
  11486. },
  11487. keyup: "_stop",
  11488. focus: function() {
  11489. this.previous = this.element.val();
  11490. },
  11491. blur: function( event ) {
  11492. if ( this.cancelBlur ) {
  11493. delete this.cancelBlur;
  11494. return;
  11495. }
  11496. this._stop();
  11497. this._refresh();
  11498. if ( this.previous !== this.element.val() ) {
  11499. this._trigger( "change", event );
  11500. }
  11501. },
  11502. mousewheel: function( event, delta ) {
  11503. if ( !delta ) {
  11504. return;
  11505. }
  11506. if ( !this.spinning && !this._start( event ) ) {
  11507. return false;
  11508. }
  11509. this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
  11510. clearTimeout( this.mousewheelTimer );
  11511. this.mousewheelTimer = this._delay(function() {
  11512. if ( this.spinning ) {
  11513. this._stop( event );
  11514. }
  11515. }, 100 );
  11516. event.preventDefault();
  11517. },
  11518. "mousedown .ui-spinner-button": function( event ) {
  11519. var previous;
  11520. // We never want the buttons to have focus; whenever the user is
  11521. // interacting with the spinner, the focus should be on the input.
  11522. // If the input is focused then this.previous is properly set from
  11523. // when the input first received focus. If the input is not focused
  11524. // then we need to set this.previous based on the value before spinning.
  11525. previous = this.element[0] === this.document[0].activeElement ?
  11526. this.previous : this.element.val();
  11527. function checkFocus() {
  11528. var isActive = this.element[0] === this.document[0].activeElement;
  11529. if ( !isActive ) {
  11530. this.element.focus();
  11531. this.previous = previous;
  11532. // support: IE
  11533. // IE sets focus asynchronously, so we need to check if focus
  11534. // moved off of the input because the user clicked on the button.
  11535. this._delay(function() {
  11536. this.previous = previous;
  11537. });
  11538. }
  11539. }
  11540. // ensure focus is on (or stays on) the text field
  11541. event.preventDefault();
  11542. checkFocus.call( this );
  11543. // support: IE
  11544. // IE doesn't prevent moving focus even with event.preventDefault()
  11545. // so we set a flag to know when we should ignore the blur event
  11546. // and check (again) if focus moved off of the input.
  11547. this.cancelBlur = true;
  11548. this._delay(function() {
  11549. delete this.cancelBlur;
  11550. checkFocus.call( this );
  11551. });
  11552. if ( this._start( event ) === false ) {
  11553. return;
  11554. }
  11555. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  11556. },
  11557. "mouseup .ui-spinner-button": "_stop",
  11558. "mouseenter .ui-spinner-button": function( event ) {
  11559. // button will add ui-state-active if mouse was down while mouseleave and kept down
  11560. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  11561. return;
  11562. }
  11563. if ( this._start( event ) === false ) {
  11564. return false;
  11565. }
  11566. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  11567. },
  11568. // TODO: do we really want to consider this a stop?
  11569. // shouldn't we just stop the repeater and wait until mouseup before
  11570. // we trigger the stop event?
  11571. "mouseleave .ui-spinner-button": "_stop"
  11572. },
  11573. _draw: function() {
  11574. var uiSpinner = this.uiSpinner = this.element
  11575. .addClass( "ui-spinner-input" )
  11576. .attr( "autocomplete", "off" )
  11577. .wrap( this._uiSpinnerHtml() )
  11578. .parent()
  11579. // add buttons
  11580. .append( this._buttonHtml() );
  11581. this.element.attr( "role", "spinbutton" );
  11582. // button bindings
  11583. this.buttons = uiSpinner.find( ".ui-spinner-button" )
  11584. .attr( "tabIndex", -1 )
  11585. .button()
  11586. .removeClass( "ui-corner-all" );
  11587. // IE 6 doesn't understand height: 50% for the buttons
  11588. // unless the wrapper has an explicit height
  11589. if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
  11590. uiSpinner.height() > 0 ) {
  11591. uiSpinner.height( uiSpinner.height() );
  11592. }
  11593. // disable spinner if element was already disabled
  11594. if ( this.options.disabled ) {
  11595. this.disable();
  11596. }
  11597. },
  11598. _keydown: function( event ) {
  11599. var options = this.options,
  11600. keyCode = $.ui.keyCode;
  11601. switch ( event.keyCode ) {
  11602. case keyCode.UP:
  11603. this._repeat( null, 1, event );
  11604. return true;
  11605. case keyCode.DOWN:
  11606. this._repeat( null, -1, event );
  11607. return true;
  11608. case keyCode.PAGE_UP:
  11609. this._repeat( null, options.page, event );
  11610. return true;
  11611. case keyCode.PAGE_DOWN:
  11612. this._repeat( null, -options.page, event );
  11613. return true;
  11614. }
  11615. return false;
  11616. },
  11617. _uiSpinnerHtml: function() {
  11618. return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
  11619. },
  11620. _buttonHtml: function() {
  11621. return "" +
  11622. "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
  11623. "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
  11624. "</a>" +
  11625. "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
  11626. "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
  11627. "</a>";
  11628. },
  11629. _start: function( event ) {
  11630. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  11631. return false;
  11632. }
  11633. if ( !this.counter ) {
  11634. this.counter = 1;
  11635. }
  11636. this.spinning = true;
  11637. return true;
  11638. },
  11639. _repeat: function( i, steps, event ) {
  11640. i = i || 500;
  11641. clearTimeout( this.timer );
  11642. this.timer = this._delay(function() {
  11643. this._repeat( 40, steps, event );
  11644. }, i );
  11645. this._spin( steps * this.options.step, event );
  11646. },
  11647. _spin: function( step, event ) {
  11648. var value = this.value() || 0;
  11649. if ( !this.counter ) {
  11650. this.counter = 1;
  11651. }
  11652. value = this._adjustValue( value + step * this._increment( this.counter ) );
  11653. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
  11654. this._value( value );
  11655. this.counter++;
  11656. }
  11657. },
  11658. _increment: function( i ) {
  11659. var incremental = this.options.incremental;
  11660. if ( incremental ) {
  11661. return $.isFunction( incremental ) ?
  11662. incremental( i ) :
  11663. Math.floor( i*i*i/50000 - i*i/500 + 17*i/200 + 1 );
  11664. }
  11665. return 1;
  11666. },
  11667. _precision: function() {
  11668. var precision = this._precisionOf( this.options.step );
  11669. if ( this.options.min !== null ) {
  11670. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  11671. }
  11672. return precision;
  11673. },
  11674. _precisionOf: function( num ) {
  11675. var str = num.toString(),
  11676. decimal = str.indexOf( "." );
  11677. return decimal === -1 ? 0 : str.length - decimal - 1;
  11678. },
  11679. _adjustValue: function( value ) {
  11680. var base, aboveMin,
  11681. options = this.options;
  11682. // make sure we're at a valid step
  11683. // - find out where we are relative to the base (min or 0)
  11684. base = options.min !== null ? options.min : 0;
  11685. aboveMin = value - base;
  11686. // - round to the nearest step
  11687. aboveMin = Math.round(aboveMin / options.step) * options.step;
  11688. // - rounding is based on 0, so adjust back to our base
  11689. value = base + aboveMin;
  11690. // fix precision from bad JS floating point math
  11691. value = parseFloat( value.toFixed( this._precision() ) );
  11692. // clamp the value
  11693. if ( options.max !== null && value > options.max) {
  11694. return options.max;
  11695. }
  11696. if ( options.min !== null && value < options.min ) {
  11697. return options.min;
  11698. }
  11699. return value;
  11700. },
  11701. _stop: function( event ) {
  11702. if ( !this.spinning ) {
  11703. return;
  11704. }
  11705. clearTimeout( this.timer );
  11706. clearTimeout( this.mousewheelTimer );
  11707. this.counter = 0;
  11708. this.spinning = false;
  11709. this._trigger( "stop", event );
  11710. },
  11711. _setOption: function( key, value ) {
  11712. if ( key === "culture" || key === "numberFormat" ) {
  11713. var prevValue = this._parse( this.element.val() );
  11714. this.options[ key ] = value;
  11715. this.element.val( this._format( prevValue ) );
  11716. return;
  11717. }
  11718. if ( key === "max" || key === "min" || key === "step" ) {
  11719. if ( typeof value === "string" ) {
  11720. value = this._parse( value );
  11721. }
  11722. }
  11723. if ( key === "icons" ) {
  11724. this.buttons.first().find( ".ui-icon" )
  11725. .removeClass( this.options.icons.up )
  11726. .addClass( value.up );
  11727. this.buttons.last().find( ".ui-icon" )
  11728. .removeClass( this.options.icons.down )
  11729. .addClass( value.down );
  11730. }
  11731. this._super( key, value );
  11732. if ( key === "disabled" ) {
  11733. if ( value ) {
  11734. this.element.prop( "disabled", true );
  11735. this.buttons.button( "disable" );
  11736. } else {
  11737. this.element.prop( "disabled", false );
  11738. this.buttons.button( "enable" );
  11739. }
  11740. }
  11741. },
  11742. _setOptions: modifier(function( options ) {
  11743. this._super( options );
  11744. this._value( this.element.val() );
  11745. }),
  11746. _parse: function( val ) {
  11747. if ( typeof val === "string" && val !== "" ) {
  11748. val = window.Globalize && this.options.numberFormat ?
  11749. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  11750. }
  11751. return val === "" || isNaN( val ) ? null : val;
  11752. },
  11753. _format: function( value ) {
  11754. if ( value === "" ) {
  11755. return "";
  11756. }
  11757. return window.Globalize && this.options.numberFormat ?
  11758. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  11759. value;
  11760. },
  11761. _refresh: function() {
  11762. this.element.attr({
  11763. "aria-valuemin": this.options.min,
  11764. "aria-valuemax": this.options.max,
  11765. // TODO: what should we do with values that can't be parsed?
  11766. "aria-valuenow": this._parse( this.element.val() )
  11767. });
  11768. },
  11769. // update the value without triggering change
  11770. _value: function( value, allowAny ) {
  11771. var parsed;
  11772. if ( value !== "" ) {
  11773. parsed = this._parse( value );
  11774. if ( parsed !== null ) {
  11775. if ( !allowAny ) {
  11776. parsed = this._adjustValue( parsed );
  11777. }
  11778. value = this._format( parsed );
  11779. }
  11780. }
  11781. this.element.val( value );
  11782. this._refresh();
  11783. },
  11784. _destroy: function() {
  11785. this.element
  11786. .removeClass( "ui-spinner-input" )
  11787. .prop( "disabled", false )
  11788. .removeAttr( "autocomplete" )
  11789. .removeAttr( "role" )
  11790. .removeAttr( "aria-valuemin" )
  11791. .removeAttr( "aria-valuemax" )
  11792. .removeAttr( "aria-valuenow" );
  11793. this.uiSpinner.replaceWith( this.element );
  11794. },
  11795. stepUp: modifier(function( steps ) {
  11796. this._stepUp( steps );
  11797. }),
  11798. _stepUp: function( steps ) {
  11799. if ( this._start() ) {
  11800. this._spin( (steps || 1) * this.options.step );
  11801. this._stop();
  11802. }
  11803. },
  11804. stepDown: modifier(function( steps ) {
  11805. this._stepDown( steps );
  11806. }),
  11807. _stepDown: function( steps ) {
  11808. if ( this._start() ) {
  11809. this._spin( (steps || 1) * -this.options.step );
  11810. this._stop();
  11811. }
  11812. },
  11813. pageUp: modifier(function( pages ) {
  11814. this._stepUp( (pages || 1) * this.options.page );
  11815. }),
  11816. pageDown: modifier(function( pages ) {
  11817. this._stepDown( (pages || 1) * this.options.page );
  11818. }),
  11819. value: function( newVal ) {
  11820. if ( !arguments.length ) {
  11821. return this._parse( this.element.val() );
  11822. }
  11823. modifier( this._value ).call( this, newVal );
  11824. },
  11825. widget: function() {
  11826. return this.uiSpinner;
  11827. }
  11828. });
  11829. }( jQuery ) );
  11830. (function( $, undefined ) {
  11831. var tabId = 0,
  11832. rhash = /#.*$/;
  11833. function getNextTabId() {
  11834. return ++tabId;
  11835. }
  11836. function isLocal( anchor ) {
  11837. return anchor.hash.length > 1 &&
  11838. decodeURIComponent( anchor.href.replace( rhash, "" ) ) ===
  11839. decodeURIComponent( location.href.replace( rhash, "" ) );
  11840. }
  11841. $.widget( "ui.tabs", {
  11842. version: "1.10.3",
  11843. delay: 300,
  11844. options: {
  11845. active: null,
  11846. collapsible: false,
  11847. event: "click",
  11848. heightStyle: "content",
  11849. hide: null,
  11850. show: null,
  11851. // callbacks
  11852. activate: null,
  11853. beforeActivate: null,
  11854. beforeLoad: null,
  11855. load: null
  11856. },
  11857. _create: function() {
  11858. var that = this,
  11859. options = this.options;
  11860. this.running = false;
  11861. this.element
  11862. .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
  11863. .toggleClass( "ui-tabs-collapsible", options.collapsible )
  11864. // Prevent users from focusing disabled tabs via click
  11865. .delegate( ".ui-tabs-nav > li", "mousedown" + this.eventNamespace, function( event ) {
  11866. if ( $( this ).is( ".ui-state-disabled" ) ) {
  11867. event.preventDefault();
  11868. }
  11869. })
  11870. // support: IE <9
  11871. // Preventing the default action in mousedown doesn't prevent IE
  11872. // from focusing the element, so if the anchor gets focused, blur.
  11873. // We don't have to worry about focusing the previously focused
  11874. // element since clicking on a non-focusable element should focus
  11875. // the body anyway.
  11876. .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
  11877. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  11878. this.blur();
  11879. }
  11880. });
  11881. this._processTabs();
  11882. options.active = this._initialActive();
  11883. // Take disabling tabs via class attribute from HTML
  11884. // into account and update option properly.
  11885. if ( $.isArray( options.disabled ) ) {
  11886. options.disabled = $.unique( options.disabled.concat(
  11887. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  11888. return that.tabs.index( li );
  11889. })
  11890. ) ).sort();
  11891. }
  11892. // check for length avoids error when initializing empty list
  11893. if ( this.options.active !== false && this.anchors.length ) {
  11894. this.active = this._findActive( options.active );
  11895. } else {
  11896. this.active = $();
  11897. }
  11898. this._refresh();
  11899. if ( this.active.length ) {
  11900. this.load( options.active );
  11901. }
  11902. },
  11903. _initialActive: function() {
  11904. var active = this.options.active,
  11905. collapsible = this.options.collapsible,
  11906. locationHash = location.hash.substring( 1 );
  11907. if ( active === null ) {
  11908. // check the fragment identifier in the URL
  11909. if ( locationHash ) {
  11910. this.tabs.each(function( i, tab ) {
  11911. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  11912. active = i;
  11913. return false;
  11914. }
  11915. });
  11916. }
  11917. // check for a tab marked active via a class
  11918. if ( active === null ) {
  11919. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  11920. }
  11921. // no active tab, set to false
  11922. if ( active === null || active === -1 ) {
  11923. active = this.tabs.length ? 0 : false;
  11924. }
  11925. }
  11926. // handle numbers: negative, out of range
  11927. if ( active !== false ) {
  11928. active = this.tabs.index( this.tabs.eq( active ) );
  11929. if ( active === -1 ) {
  11930. active = collapsible ? false : 0;
  11931. }
  11932. }
  11933. // don't allow collapsible: false and active: false
  11934. if ( !collapsible && active === false && this.anchors.length ) {
  11935. active = 0;
  11936. }
  11937. return active;
  11938. },
  11939. _getCreateEventData: function() {
  11940. return {
  11941. tab: this.active,
  11942. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  11943. };
  11944. },
  11945. _tabKeydown: function( event ) {
  11946. /*jshint maxcomplexity:15*/
  11947. var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
  11948. selectedIndex = this.tabs.index( focusedTab ),
  11949. goingForward = true;
  11950. if ( this._handlePageNav( event ) ) {
  11951. return;
  11952. }
  11953. switch ( event.keyCode ) {
  11954. case $.ui.keyCode.RIGHT:
  11955. case $.ui.keyCode.DOWN:
  11956. selectedIndex++;
  11957. break;
  11958. case $.ui.keyCode.UP:
  11959. case $.ui.keyCode.LEFT:
  11960. goingForward = false;
  11961. selectedIndex--;
  11962. break;
  11963. case $.ui.keyCode.END:
  11964. selectedIndex = this.anchors.length - 1;
  11965. break;
  11966. case $.ui.keyCode.HOME:
  11967. selectedIndex = 0;
  11968. break;
  11969. case $.ui.keyCode.SPACE:
  11970. // Activate only, no collapsing
  11971. event.preventDefault();
  11972. clearTimeout( this.activating );
  11973. this._activate( selectedIndex );
  11974. return;
  11975. case $.ui.keyCode.ENTER:
  11976. // Toggle (cancel delayed activation, allow collapsing)
  11977. event.preventDefault();
  11978. clearTimeout( this.activating );
  11979. // Determine if we should collapse or activate
  11980. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  11981. return;
  11982. default:
  11983. return;
  11984. }
  11985. // Focus the appropriate tab, based on which key was pressed
  11986. event.preventDefault();
  11987. clearTimeout( this.activating );
  11988. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  11989. // Navigating with control key will prevent automatic activation
  11990. if ( !event.ctrlKey ) {
  11991. // Update aria-selected immediately so that AT think the tab is already selected.
  11992. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  11993. // but the tab will already be activated by the time the announcement finishes.
  11994. focusedTab.attr( "aria-selected", "false" );
  11995. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  11996. this.activating = this._delay(function() {
  11997. this.option( "active", selectedIndex );
  11998. }, this.delay );
  11999. }
  12000. },
  12001. _panelKeydown: function( event ) {
  12002. if ( this._handlePageNav( event ) ) {
  12003. return;
  12004. }
  12005. // Ctrl+up moves focus to the current tab
  12006. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  12007. event.preventDefault();
  12008. this.active.focus();
  12009. }
  12010. },
  12011. // Alt+page up/down moves focus to the previous/next tab (and activates)
  12012. _handlePageNav: function( event ) {
  12013. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  12014. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  12015. return true;
  12016. }
  12017. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  12018. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  12019. return true;
  12020. }
  12021. },
  12022. _findNextTab: function( index, goingForward ) {
  12023. var lastTabIndex = this.tabs.length - 1;
  12024. function constrain() {
  12025. if ( index > lastTabIndex ) {
  12026. index = 0;
  12027. }
  12028. if ( index < 0 ) {
  12029. index = lastTabIndex;
  12030. }
  12031. return index;
  12032. }
  12033. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  12034. index = goingForward ? index + 1 : index - 1;
  12035. }
  12036. return index;
  12037. },
  12038. _focusNextTab: function( index, goingForward ) {
  12039. index = this._findNextTab( index, goingForward );
  12040. this.tabs.eq( index ).focus();
  12041. return index;
  12042. },
  12043. _setOption: function( key, value ) {
  12044. if ( key === "active" ) {
  12045. // _activate() will handle invalid values and update this.options
  12046. this._activate( value );
  12047. return;
  12048. }
  12049. if ( key === "disabled" ) {
  12050. // don't use the widget factory's disabled handling
  12051. this._setupDisabled( value );
  12052. return;
  12053. }
  12054. this._super( key, value);
  12055. if ( key === "collapsible" ) {
  12056. this.element.toggleClass( "ui-tabs-collapsible", value );
  12057. // Setting collapsible: false while collapsed; open first panel
  12058. if ( !value && this.options.active === false ) {
  12059. this._activate( 0 );
  12060. }
  12061. }
  12062. if ( key === "event" ) {
  12063. this._setupEvents( value );
  12064. }
  12065. if ( key === "heightStyle" ) {
  12066. this._setupHeightStyle( value );
  12067. }
  12068. },
  12069. _tabId: function( tab ) {
  12070. return tab.attr( "aria-controls" ) || "ui-tabs-" + getNextTabId();
  12071. },
  12072. _sanitizeSelector: function( hash ) {
  12073. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  12074. },
  12075. refresh: function() {
  12076. var options = this.options,
  12077. lis = this.tablist.children( ":has(a[href])" );
  12078. // get disabled tabs from class attribute from HTML
  12079. // this will get converted to a boolean if needed in _refresh()
  12080. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  12081. return lis.index( tab );
  12082. });
  12083. this._processTabs();
  12084. // was collapsed or no tabs
  12085. if ( options.active === false || !this.anchors.length ) {
  12086. options.active = false;
  12087. this.active = $();
  12088. // was active, but active tab is gone
  12089. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  12090. // all remaining tabs are disabled
  12091. if ( this.tabs.length === options.disabled.length ) {
  12092. options.active = false;
  12093. this.active = $();
  12094. // activate previous tab
  12095. } else {
  12096. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  12097. }
  12098. // was active, active tab still exists
  12099. } else {
  12100. // make sure active index is correct
  12101. options.active = this.tabs.index( this.active );
  12102. }
  12103. this._refresh();
  12104. },
  12105. _refresh: function() {
  12106. this._setupDisabled( this.options.disabled );
  12107. this._setupEvents( this.options.event );
  12108. this._setupHeightStyle( this.options.heightStyle );
  12109. this.tabs.not( this.active ).attr({
  12110. "aria-selected": "false",
  12111. tabIndex: -1
  12112. });
  12113. this.panels.not( this._getPanelForTab( this.active ) )
  12114. .hide()
  12115. .attr({
  12116. "aria-expanded": "false",
  12117. "aria-hidden": "true"
  12118. });
  12119. // Make sure one tab is in the tab order
  12120. if ( !this.active.length ) {
  12121. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  12122. } else {
  12123. this.active
  12124. .addClass( "ui-tabs-active ui-state-active" )
  12125. .attr({
  12126. "aria-selected": "true",
  12127. tabIndex: 0
  12128. });
  12129. this._getPanelForTab( this.active )
  12130. .show()
  12131. .attr({
  12132. "aria-expanded": "true",
  12133. "aria-hidden": "false"
  12134. });
  12135. }
  12136. },
  12137. _processTabs: function() {
  12138. var that = this;
  12139. this.tablist = this._getList()
  12140. .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  12141. .attr( "role", "tablist" );
  12142. this.tabs = this.tablist.find( "> li:has(a[href])" )
  12143. .addClass( "ui-state-default ui-corner-top" )
  12144. .attr({
  12145. role: "tab",
  12146. tabIndex: -1
  12147. });
  12148. this.anchors = this.tabs.map(function() {
  12149. return $( "a", this )[ 0 ];
  12150. })
  12151. .addClass( "ui-tabs-anchor" )
  12152. .attr({
  12153. role: "presentation",
  12154. tabIndex: -1
  12155. });
  12156. this.panels = $();
  12157. this.anchors.each(function( i, anchor ) {
  12158. var selector, panel, panelId,
  12159. anchorId = $( anchor ).uniqueId().attr( "id" ),
  12160. tab = $( anchor ).closest( "li" ),
  12161. originalAriaControls = tab.attr( "aria-controls" );
  12162. // inline tab
  12163. if ( isLocal( anchor ) ) {
  12164. selector = anchor.hash;
  12165. panel = that.element.find( that._sanitizeSelector( selector ) );
  12166. // remote tab
  12167. } else {
  12168. panelId = that._tabId( tab );
  12169. selector = "#" + panelId;
  12170. panel = that.element.find( selector );
  12171. if ( !panel.length ) {
  12172. panel = that._createPanel( panelId );
  12173. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  12174. }
  12175. panel.attr( "aria-live", "polite" );
  12176. }
  12177. if ( panel.length) {
  12178. that.panels = that.panels.add( panel );
  12179. }
  12180. if ( originalAriaControls ) {
  12181. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  12182. }
  12183. tab.attr({
  12184. "aria-controls": selector.substring( 1 ),
  12185. "aria-labelledby": anchorId
  12186. });
  12187. panel.attr( "aria-labelledby", anchorId );
  12188. });
  12189. this.panels
  12190. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  12191. .attr( "role", "tabpanel" );
  12192. },
  12193. // allow overriding how to find the list for rare usage scenarios (#7715)
  12194. _getList: function() {
  12195. return this.element.find( "ol,ul" ).eq( 0 );
  12196. },
  12197. _createPanel: function( id ) {
  12198. return $( "<div>" )
  12199. .attr( "id", id )
  12200. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  12201. .data( "ui-tabs-destroy", true );
  12202. },
  12203. _setupDisabled: function( disabled ) {
  12204. if ( $.isArray( disabled ) ) {
  12205. if ( !disabled.length ) {
  12206. disabled = false;
  12207. } else if ( disabled.length === this.anchors.length ) {
  12208. disabled = true;
  12209. }
  12210. }
  12211. // disable tabs
  12212. for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
  12213. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  12214. $( li )
  12215. .addClass( "ui-state-disabled" )
  12216. .attr( "aria-disabled", "true" );
  12217. } else {
  12218. $( li )
  12219. .removeClass( "ui-state-disabled" )
  12220. .removeAttr( "aria-disabled" );
  12221. }
  12222. }
  12223. this.options.disabled = disabled;
  12224. },
  12225. _setupEvents: function( event ) {
  12226. var events = {
  12227. click: function( event ) {
  12228. event.preventDefault();
  12229. }
  12230. };
  12231. if ( event ) {
  12232. $.each( event.split(" "), function( index, eventName ) {
  12233. events[ eventName ] = "_eventHandler";
  12234. });
  12235. }
  12236. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  12237. this._on( this.anchors, events );
  12238. this._on( this.tabs, { keydown: "_tabKeydown" } );
  12239. this._on( this.panels, { keydown: "_panelKeydown" } );
  12240. this._focusable( this.tabs );
  12241. this._hoverable( this.tabs );
  12242. },
  12243. _setupHeightStyle: function( heightStyle ) {
  12244. var maxHeight,
  12245. parent = this.element.parent();
  12246. if ( heightStyle === "fill" ) {
  12247. maxHeight = parent.height();
  12248. maxHeight -= this.element.outerHeight() - this.element.height();
  12249. this.element.siblings( ":visible" ).each(function() {
  12250. var elem = $( this ),
  12251. position = elem.css( "position" );
  12252. if ( position === "absolute" || position === "fixed" ) {
  12253. return;
  12254. }
  12255. maxHeight -= elem.outerHeight( true );
  12256. });
  12257. this.element.children().not( this.panels ).each(function() {
  12258. maxHeight -= $( this ).outerHeight( true );
  12259. });
  12260. this.panels.each(function() {
  12261. $( this ).height( Math.max( 0, maxHeight -
  12262. $( this ).innerHeight() + $( this ).height() ) );
  12263. })
  12264. .css( "overflow", "auto" );
  12265. } else if ( heightStyle === "auto" ) {
  12266. maxHeight = 0;
  12267. this.panels.each(function() {
  12268. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  12269. }).height( maxHeight );
  12270. }
  12271. },
  12272. _eventHandler: function( event ) {
  12273. var options = this.options,
  12274. active = this.active,
  12275. anchor = $( event.currentTarget ),
  12276. tab = anchor.closest( "li" ),
  12277. clickedIsActive = tab[ 0 ] === active[ 0 ],
  12278. collapsing = clickedIsActive && options.collapsible,
  12279. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  12280. toHide = !active.length ? $() : this._getPanelForTab( active ),
  12281. eventData = {
  12282. oldTab: active,
  12283. oldPanel: toHide,
  12284. newTab: collapsing ? $() : tab,
  12285. newPanel: toShow
  12286. };
  12287. event.preventDefault();
  12288. if ( tab.hasClass( "ui-state-disabled" ) ||
  12289. // tab is already loading
  12290. tab.hasClass( "ui-tabs-loading" ) ||
  12291. // can't switch durning an animation
  12292. this.running ||
  12293. // click on active header, but not collapsible
  12294. ( clickedIsActive && !options.collapsible ) ||
  12295. // allow canceling activation
  12296. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  12297. return;
  12298. }
  12299. options.active = collapsing ? false : this.tabs.index( tab );
  12300. this.active = clickedIsActive ? $() : tab;
  12301. if ( this.xhr ) {
  12302. this.xhr.abort();
  12303. }
  12304. if ( !toHide.length && !toShow.length ) {
  12305. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  12306. }
  12307. if ( toShow.length ) {
  12308. this.load( this.tabs.index( tab ), event );
  12309. }
  12310. this._toggle( event, eventData );
  12311. },
  12312. // handles show/hide for selecting tabs
  12313. _toggle: function( event, eventData ) {
  12314. var that = this,
  12315. toShow = eventData.newPanel,
  12316. toHide = eventData.oldPanel;
  12317. this.running = true;
  12318. function complete() {
  12319. that.running = false;
  12320. that._trigger( "activate", event, eventData );
  12321. }
  12322. function show() {
  12323. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  12324. if ( toShow.length && that.options.show ) {
  12325. that._show( toShow, that.options.show, complete );
  12326. } else {
  12327. toShow.show();
  12328. complete();
  12329. }
  12330. }
  12331. // start out by hiding, then showing, then completing
  12332. if ( toHide.length && this.options.hide ) {
  12333. this._hide( toHide, this.options.hide, function() {
  12334. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  12335. show();
  12336. });
  12337. } else {
  12338. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  12339. toHide.hide();
  12340. show();
  12341. }
  12342. toHide.attr({
  12343. "aria-expanded": "false",
  12344. "aria-hidden": "true"
  12345. });
  12346. eventData.oldTab.attr( "aria-selected", "false" );
  12347. // If we're switching tabs, remove the old tab from the tab order.
  12348. // If we're opening from collapsed state, remove the previous tab from the tab order.
  12349. // If we're collapsing, then keep the collapsing tab in the tab order.
  12350. if ( toShow.length && toHide.length ) {
  12351. eventData.oldTab.attr( "tabIndex", -1 );
  12352. } else if ( toShow.length ) {
  12353. this.tabs.filter(function() {
  12354. return $( this ).attr( "tabIndex" ) === 0;
  12355. })
  12356. .attr( "tabIndex", -1 );
  12357. }
  12358. toShow.attr({
  12359. "aria-expanded": "true",
  12360. "aria-hidden": "false"
  12361. });
  12362. eventData.newTab.attr({
  12363. "aria-selected": "true",
  12364. tabIndex: 0
  12365. });
  12366. },
  12367. _activate: function( index ) {
  12368. var anchor,
  12369. active = this._findActive( index );
  12370. // trying to activate the already active panel
  12371. if ( active[ 0 ] === this.active[ 0 ] ) {
  12372. return;
  12373. }
  12374. // trying to collapse, simulate a click on the current active header
  12375. if ( !active.length ) {
  12376. active = this.active;
  12377. }
  12378. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  12379. this._eventHandler({
  12380. target: anchor,
  12381. currentTarget: anchor,
  12382. preventDefault: $.noop
  12383. });
  12384. },
  12385. _findActive: function( index ) {
  12386. return index === false ? $() : this.tabs.eq( index );
  12387. },
  12388. _getIndex: function( index ) {
  12389. // meta-function to give users option to provide a href string instead of a numerical index.
  12390. if ( typeof index === "string" ) {
  12391. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  12392. }
  12393. return index;
  12394. },
  12395. _destroy: function() {
  12396. if ( this.xhr ) {
  12397. this.xhr.abort();
  12398. }
  12399. this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
  12400. this.tablist
  12401. .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  12402. .removeAttr( "role" );
  12403. this.anchors
  12404. .removeClass( "ui-tabs-anchor" )
  12405. .removeAttr( "role" )
  12406. .removeAttr( "tabIndex" )
  12407. .removeUniqueId();
  12408. this.tabs.add( this.panels ).each(function() {
  12409. if ( $.data( this, "ui-tabs-destroy" ) ) {
  12410. $( this ).remove();
  12411. } else {
  12412. $( this )
  12413. .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
  12414. "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
  12415. .removeAttr( "tabIndex" )
  12416. .removeAttr( "aria-live" )
  12417. .removeAttr( "aria-busy" )
  12418. .removeAttr( "aria-selected" )
  12419. .removeAttr( "aria-labelledby" )
  12420. .removeAttr( "aria-hidden" )
  12421. .removeAttr( "aria-expanded" )
  12422. .removeAttr( "role" );
  12423. }
  12424. });
  12425. this.tabs.each(function() {
  12426. var li = $( this ),
  12427. prev = li.data( "ui-tabs-aria-controls" );
  12428. if ( prev ) {
  12429. li
  12430. .attr( "aria-controls", prev )
  12431. .removeData( "ui-tabs-aria-controls" );
  12432. } else {
  12433. li.removeAttr( "aria-controls" );
  12434. }
  12435. });
  12436. this.panels.show();
  12437. if ( this.options.heightStyle !== "content" ) {
  12438. this.panels.css( "height", "" );
  12439. }
  12440. },
  12441. enable: function( index ) {
  12442. var disabled = this.options.disabled;
  12443. if ( disabled === false ) {
  12444. return;
  12445. }
  12446. if ( index === undefined ) {
  12447. disabled = false;
  12448. } else {
  12449. index = this._getIndex( index );
  12450. if ( $.isArray( disabled ) ) {
  12451. disabled = $.map( disabled, function( num ) {
  12452. return num !== index ? num : null;
  12453. });
  12454. } else {
  12455. disabled = $.map( this.tabs, function( li, num ) {
  12456. return num !== index ? num : null;
  12457. });
  12458. }
  12459. }
  12460. this._setupDisabled( disabled );
  12461. },
  12462. disable: function( index ) {
  12463. var disabled = this.options.disabled;
  12464. if ( disabled === true ) {
  12465. return;
  12466. }
  12467. if ( index === undefined ) {
  12468. disabled = true;
  12469. } else {
  12470. index = this._getIndex( index );
  12471. if ( $.inArray( index, disabled ) !== -1 ) {
  12472. return;
  12473. }
  12474. if ( $.isArray( disabled ) ) {
  12475. disabled = $.merge( [ index ], disabled ).sort();
  12476. } else {
  12477. disabled = [ index ];
  12478. }
  12479. }
  12480. this._setupDisabled( disabled );
  12481. },
  12482. load: function( index, event ) {
  12483. index = this._getIndex( index );
  12484. var that = this,
  12485. tab = this.tabs.eq( index ),
  12486. anchor = tab.find( ".ui-tabs-anchor" ),
  12487. panel = this._getPanelForTab( tab ),
  12488. eventData = {
  12489. tab: tab,
  12490. panel: panel
  12491. };
  12492. // not remote
  12493. if ( isLocal( anchor[ 0 ] ) ) {
  12494. return;
  12495. }
  12496. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  12497. // support: jQuery <1.8
  12498. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  12499. // but as of 1.8, $.ajax() always returns a jqXHR object.
  12500. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  12501. tab.addClass( "ui-tabs-loading" );
  12502. panel.attr( "aria-busy", "true" );
  12503. this.xhr
  12504. .success(function( response ) {
  12505. // support: jQuery <1.8
  12506. // http://bugs.jquery.com/ticket/11778
  12507. setTimeout(function() {
  12508. panel.html( response );
  12509. that._trigger( "load", event, eventData );
  12510. }, 1 );
  12511. })
  12512. .complete(function( jqXHR, status ) {
  12513. // support: jQuery <1.8
  12514. // http://bugs.jquery.com/ticket/11778
  12515. setTimeout(function() {
  12516. if ( status === "abort" ) {
  12517. that.panels.stop( false, true );
  12518. }
  12519. tab.removeClass( "ui-tabs-loading" );
  12520. panel.removeAttr( "aria-busy" );
  12521. if ( jqXHR === that.xhr ) {
  12522. delete that.xhr;
  12523. }
  12524. }, 1 );
  12525. });
  12526. }
  12527. },
  12528. _ajaxSettings: function( anchor, event, eventData ) {
  12529. var that = this;
  12530. return {
  12531. url: anchor.attr( "href" ),
  12532. beforeSend: function( jqXHR, settings ) {
  12533. return that._trigger( "beforeLoad", event,
  12534. $.extend( { jqXHR : jqXHR, ajaxSettings: settings }, eventData ) );
  12535. }
  12536. };
  12537. },
  12538. _getPanelForTab: function( tab ) {
  12539. var id = $( tab ).attr( "aria-controls" );
  12540. return this.element.find( this._sanitizeSelector( "#" + id ) );
  12541. }
  12542. });
  12543. })( jQuery );
  12544. (function( $ ) {
  12545. var increments = 0;
  12546. function addDescribedBy( elem, id ) {
  12547. var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
  12548. describedby.push( id );
  12549. elem
  12550. .data( "ui-tooltip-id", id )
  12551. .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
  12552. }
  12553. function removeDescribedBy( elem ) {
  12554. var id = elem.data( "ui-tooltip-id" ),
  12555. describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
  12556. index = $.inArray( id, describedby );
  12557. if ( index !== -1 ) {
  12558. describedby.splice( index, 1 );
  12559. }
  12560. elem.removeData( "ui-tooltip-id" );
  12561. describedby = $.trim( describedby.join( " " ) );
  12562. if ( describedby ) {
  12563. elem.attr( "aria-describedby", describedby );
  12564. } else {
  12565. elem.removeAttr( "aria-describedby" );
  12566. }
  12567. }
  12568. $.widget( "ui.tooltip", {
  12569. version: "1.10.3",
  12570. options: {
  12571. content: function() {
  12572. // support: IE<9, Opera in jQuery <1.7
  12573. // .text() can't accept undefined, so coerce to a string
  12574. var title = $( this ).attr( "title" ) || "";
  12575. // Escape title, since we're going from an attribute to raw HTML
  12576. return $( "<a>" ).text( title ).html();
  12577. },
  12578. hide: true,
  12579. // Disabled elements have inconsistent behavior across browsers (#8661)
  12580. items: "[title]:not([disabled])",
  12581. position: {
  12582. my: "left top+15",
  12583. at: "left bottom",
  12584. collision: "flipfit flip"
  12585. },
  12586. show: true,
  12587. tooltipClass: null,
  12588. track: false,
  12589. // callbacks
  12590. close: null,
  12591. open: null
  12592. },
  12593. _create: function() {
  12594. this._on({
  12595. mouseover: "open",
  12596. focusin: "open"
  12597. });
  12598. // IDs of generated tooltips, needed for destroy
  12599. this.tooltips = {};
  12600. // IDs of parent tooltips where we removed the title attribute
  12601. this.parents = {};
  12602. if ( this.options.disabled ) {
  12603. this._disable();
  12604. }
  12605. },
  12606. _setOption: function( key, value ) {
  12607. var that = this;
  12608. if ( key === "disabled" ) {
  12609. this[ value ? "_disable" : "_enable" ]();
  12610. this.options[ key ] = value;
  12611. // disable element style changes
  12612. return;
  12613. }
  12614. this._super( key, value );
  12615. if ( key === "content" ) {
  12616. $.each( this.tooltips, function( id, element ) {
  12617. that._updateContent( element );
  12618. });
  12619. }
  12620. },
  12621. _disable: function() {
  12622. var that = this;
  12623. // close open tooltips
  12624. $.each( this.tooltips, function( id, element ) {
  12625. var event = $.Event( "blur" );
  12626. event.target = event.currentTarget = element[0];
  12627. that.close( event, true );
  12628. });
  12629. // remove title attributes to prevent native tooltips
  12630. this.element.find( this.options.items ).addBack().each(function() {
  12631. var element = $( this );
  12632. if ( element.is( "[title]" ) ) {
  12633. element
  12634. .data( "ui-tooltip-title", element.attr( "title" ) )
  12635. .attr( "title", "" );
  12636. }
  12637. });
  12638. },
  12639. _enable: function() {
  12640. // restore title attributes
  12641. this.element.find( this.options.items ).addBack().each(function() {
  12642. var element = $( this );
  12643. if ( element.data( "ui-tooltip-title" ) ) {
  12644. element.attr( "title", element.data( "ui-tooltip-title" ) );
  12645. }
  12646. });
  12647. },
  12648. open: function( event ) {
  12649. var that = this,
  12650. target = $( event ? event.target : this.element )
  12651. // we need closest here due to mouseover bubbling,
  12652. // but always pointing at the same event target
  12653. .closest( this.options.items );
  12654. // No element to show a tooltip for or the tooltip is already open
  12655. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  12656. return;
  12657. }
  12658. if ( target.attr( "title" ) ) {
  12659. target.data( "ui-tooltip-title", target.attr( "title" ) );
  12660. }
  12661. target.data( "ui-tooltip-open", true );
  12662. // kill parent tooltips, custom or native, for hover
  12663. if ( event && event.type === "mouseover" ) {
  12664. target.parents().each(function() {
  12665. var parent = $( this ),
  12666. blurEvent;
  12667. if ( parent.data( "ui-tooltip-open" ) ) {
  12668. blurEvent = $.Event( "blur" );
  12669. blurEvent.target = blurEvent.currentTarget = this;
  12670. that.close( blurEvent, true );
  12671. }
  12672. if ( parent.attr( "title" ) ) {
  12673. parent.uniqueId();
  12674. that.parents[ this.id ] = {
  12675. element: this,
  12676. title: parent.attr( "title" )
  12677. };
  12678. parent.attr( "title", "" );
  12679. }
  12680. });
  12681. }
  12682. this._updateContent( target, event );
  12683. },
  12684. _updateContent: function( target, event ) {
  12685. var content,
  12686. contentOption = this.options.content,
  12687. that = this,
  12688. eventType = event ? event.type : null;
  12689. if ( typeof contentOption === "string" ) {
  12690. return this._open( event, target, contentOption );
  12691. }
  12692. content = contentOption.call( target[0], function( response ) {
  12693. // ignore async response if tooltip was closed already
  12694. if ( !target.data( "ui-tooltip-open" ) ) {
  12695. return;
  12696. }
  12697. // IE may instantly serve a cached response for ajax requests
  12698. // delay this call to _open so the other call to _open runs first
  12699. that._delay(function() {
  12700. // jQuery creates a special event for focusin when it doesn't
  12701. // exist natively. To improve performance, the native event
  12702. // object is reused and the type is changed. Therefore, we can't
  12703. // rely on the type being correct after the event finished
  12704. // bubbling, so we set it back to the previous value. (#8740)
  12705. if ( event ) {
  12706. event.type = eventType;
  12707. }
  12708. this._open( event, target, response );
  12709. });
  12710. });
  12711. if ( content ) {
  12712. this._open( event, target, content );
  12713. }
  12714. },
  12715. _open: function( event, target, content ) {
  12716. var tooltip, events, delayedShow,
  12717. positionOption = $.extend( {}, this.options.position );
  12718. if ( !content ) {
  12719. return;
  12720. }
  12721. // Content can be updated multiple times. If the tooltip already
  12722. // exists, then just update the content and bail.
  12723. tooltip = this._find( target );
  12724. if ( tooltip.length ) {
  12725. tooltip.find( ".ui-tooltip-content" ).html( content );
  12726. return;
  12727. }
  12728. // if we have a title, clear it to prevent the native tooltip
  12729. // we have to check first to avoid defining a title if none exists
  12730. // (we don't want to cause an element to start matching [title])
  12731. //
  12732. // We use removeAttr only for key events, to allow IE to export the correct
  12733. // accessible attributes. For mouse events, set to empty string to avoid
  12734. // native tooltip showing up (happens only when removing inside mouseover).
  12735. if ( target.is( "[title]" ) ) {
  12736. if ( event && event.type === "mouseover" ) {
  12737. target.attr( "title", "" );
  12738. } else {
  12739. target.removeAttr( "title" );
  12740. }
  12741. }
  12742. tooltip = this._tooltip( target );
  12743. addDescribedBy( target, tooltip.attr( "id" ) );
  12744. tooltip.find( ".ui-tooltip-content" ).html( content );
  12745. function position( event ) {
  12746. positionOption.of = event;
  12747. if ( tooltip.is( ":hidden" ) ) {
  12748. return;
  12749. }
  12750. tooltip.position( positionOption );
  12751. }
  12752. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  12753. this._on( this.document, {
  12754. mousemove: position
  12755. });
  12756. // trigger once to override element-relative positioning
  12757. position( event );
  12758. } else {
  12759. tooltip.position( $.extend({
  12760. of: target
  12761. }, this.options.position ) );
  12762. }
  12763. tooltip.hide();
  12764. this._show( tooltip, this.options.show );
  12765. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  12766. // as the tooltip is visible, position the tooltip using the most recent
  12767. // event.
  12768. if ( this.options.show && this.options.show.delay ) {
  12769. delayedShow = this.delayedShow = setInterval(function() {
  12770. if ( tooltip.is( ":visible" ) ) {
  12771. position( positionOption.of );
  12772. clearInterval( delayedShow );
  12773. }
  12774. }, $.fx.interval );
  12775. }
  12776. this._trigger( "open", event, { tooltip: tooltip } );
  12777. events = {
  12778. keyup: function( event ) {
  12779. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  12780. var fakeEvent = $.Event(event);
  12781. fakeEvent.currentTarget = target[0];
  12782. this.close( fakeEvent, true );
  12783. }
  12784. },
  12785. remove: function() {
  12786. this._removeTooltip( tooltip );
  12787. }
  12788. };
  12789. if ( !event || event.type === "mouseover" ) {
  12790. events.mouseleave = "close";
  12791. }
  12792. if ( !event || event.type === "focusin" ) {
  12793. events.focusout = "close";
  12794. }
  12795. this._on( true, target, events );
  12796. },
  12797. close: function( event ) {
  12798. var that = this,
  12799. target = $( event ? event.currentTarget : this.element ),
  12800. tooltip = this._find( target );
  12801. // disabling closes the tooltip, so we need to track when we're closing
  12802. // to avoid an infinite loop in case the tooltip becomes disabled on close
  12803. if ( this.closing ) {
  12804. return;
  12805. }
  12806. // Clear the interval for delayed tracking tooltips
  12807. clearInterval( this.delayedShow );
  12808. // only set title if we had one before (see comment in _open())
  12809. if ( target.data( "ui-tooltip-title" ) ) {
  12810. target.attr( "title", target.data( "ui-tooltip-title" ) );
  12811. }
  12812. removeDescribedBy( target );
  12813. tooltip.stop( true );
  12814. this._hide( tooltip, this.options.hide, function() {
  12815. that._removeTooltip( $( this ) );
  12816. });
  12817. target.removeData( "ui-tooltip-open" );
  12818. this._off( target, "mouseleave focusout keyup" );
  12819. // Remove 'remove' binding only on delegated targets
  12820. if ( target[0] !== this.element[0] ) {
  12821. this._off( target, "remove" );
  12822. }
  12823. this._off( this.document, "mousemove" );
  12824. if ( event && event.type === "mouseleave" ) {
  12825. $.each( this.parents, function( id, parent ) {
  12826. $( parent.element ).attr( "title", parent.title );
  12827. delete that.parents[ id ];
  12828. });
  12829. }
  12830. this.closing = true;
  12831. this._trigger( "close", event, { tooltip: tooltip } );
  12832. this.closing = false;
  12833. },
  12834. _tooltip: function( element ) {
  12835. var id = "ui-tooltip-" + increments++,
  12836. tooltip = $( "<div>" )
  12837. .attr({
  12838. id: id,
  12839. role: "tooltip"
  12840. })
  12841. .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
  12842. ( this.options.tooltipClass || "" ) );
  12843. $( "<div>" )
  12844. .addClass( "ui-tooltip-content" )
  12845. .appendTo( tooltip );
  12846. tooltip.appendTo( this.document[0].body );
  12847. this.tooltips[ id ] = element;
  12848. return tooltip;
  12849. },
  12850. _find: function( target ) {
  12851. var id = target.data( "ui-tooltip-id" );
  12852. return id ? $( "#" + id ) : $();
  12853. },
  12854. _removeTooltip: function( tooltip ) {
  12855. tooltip.remove();
  12856. delete this.tooltips[ tooltip.attr( "id" ) ];
  12857. },
  12858. _destroy: function() {
  12859. var that = this;
  12860. // close open tooltips
  12861. $.each( this.tooltips, function( id, element ) {
  12862. // Delegate to close method to handle common cleanup
  12863. var event = $.Event( "blur" );
  12864. event.target = event.currentTarget = element[0];
  12865. that.close( event, true );
  12866. // Remove immediately; destroying an open tooltip doesn't use the
  12867. // hide animation
  12868. $( "#" + id ).remove();
  12869. // Restore the title
  12870. if ( element.data( "ui-tooltip-title" ) ) {
  12871. element.attr( "title", element.data( "ui-tooltip-title" ) );
  12872. element.removeData( "ui-tooltip-title" );
  12873. }
  12874. });
  12875. }
  12876. });
  12877. }( jQuery ) );