jquery-ui-1.9.0.custom.js 435 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709
  1. /*! jQuery UI - v1.9.0 - 2012-10-05
  2. * http://jqueryui.com
  3. * Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.position.js, jquery.ui.accordion.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.datepicker.js, jquery.ui.dialog.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.effect.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.progressbar.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.slider.js, jquery.ui.sortable.js, jquery.ui.spinner.js, jquery.ui.tabs.js, jquery.ui.tooltip.js
  4. * Copyright (c) 2012 jQuery Foundation and other contributors Licensed MIT */
  5. (function( $, undefined ) {
  6. var uuid = 0,
  7. runiqueId = /^ui-id-\d+$/;
  8. // prevent duplicate loading
  9. // this is only a problem because we proxy existing functions
  10. // and we don't want to double proxy them
  11. $.ui = $.ui || {};
  12. if ( $.ui.version ) {
  13. return;
  14. }
  15. $.extend( $.ui, {
  16. version: "1.9.0",
  17. keyCode: {
  18. BACKSPACE: 8,
  19. COMMA: 188,
  20. DELETE: 46,
  21. DOWN: 40,
  22. END: 35,
  23. ENTER: 13,
  24. ESCAPE: 27,
  25. HOME: 36,
  26. LEFT: 37,
  27. NUMPAD_ADD: 107,
  28. NUMPAD_DECIMAL: 110,
  29. NUMPAD_DIVIDE: 111,
  30. NUMPAD_ENTER: 108,
  31. NUMPAD_MULTIPLY: 106,
  32. NUMPAD_SUBTRACT: 109,
  33. PAGE_DOWN: 34,
  34. PAGE_UP: 33,
  35. PERIOD: 190,
  36. RIGHT: 39,
  37. SPACE: 32,
  38. TAB: 9,
  39. UP: 38
  40. }
  41. });
  42. // plugins
  43. $.fn.extend({
  44. _focus: $.fn.focus,
  45. focus: function( delay, fn ) {
  46. return typeof delay === "number" ?
  47. this.each(function() {
  48. var elem = this;
  49. setTimeout(function() {
  50. $( elem ).focus();
  51. if ( fn ) {
  52. fn.call( elem );
  53. }
  54. }, delay );
  55. }) :
  56. this._focus.apply( this, arguments );
  57. },
  58. scrollParent: function() {
  59. var scrollParent;
  60. if (($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
  61. scrollParent = this.parents().filter(function() {
  62. return (/(relative|absolute|fixed)/).test($.css(this,'position')) && (/(auto|scroll)/).test($.css(this,'overflow')+$.css(this,'overflow-y')+$.css(this,'overflow-x'));
  63. }).eq(0);
  64. } else {
  65. scrollParent = this.parents().filter(function() {
  66. return (/(auto|scroll)/).test($.css(this,'overflow')+$.css(this,'overflow-y')+$.css(this,'overflow-x'));
  67. }).eq(0);
  68. }
  69. return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
  70. },
  71. zIndex: function( zIndex ) {
  72. if ( zIndex !== undefined ) {
  73. return this.css( "zIndex", zIndex );
  74. }
  75. if ( this.length ) {
  76. var elem = $( this[ 0 ] ), position, value;
  77. while ( elem.length && elem[ 0 ] !== document ) {
  78. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  79. // This makes behavior of this function consistent across browsers
  80. // WebKit always returns auto if the element is positioned
  81. position = elem.css( "position" );
  82. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  83. // IE returns 0 when zIndex is not specified
  84. // other browsers return a string
  85. // we ignore the case of nested elements with an explicit value of 0
  86. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  87. value = parseInt( elem.css( "zIndex" ), 10 );
  88. if ( !isNaN( value ) && value !== 0 ) {
  89. return value;
  90. }
  91. }
  92. elem = elem.parent();
  93. }
  94. }
  95. return 0;
  96. },
  97. uniqueId: function() {
  98. return this.each(function() {
  99. if ( !this.id ) {
  100. this.id = "ui-id-" + (++uuid);
  101. }
  102. });
  103. },
  104. removeUniqueId: function() {
  105. return this.each(function() {
  106. if ( runiqueId.test( this.id ) ) {
  107. $( this ).removeAttr( "id" );
  108. }
  109. });
  110. }
  111. });
  112. // support: jQuery <1.8
  113. if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
  114. $.each( [ "Width", "Height" ], function( i, name ) {
  115. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  116. type = name.toLowerCase(),
  117. orig = {
  118. innerWidth: $.fn.innerWidth,
  119. innerHeight: $.fn.innerHeight,
  120. outerWidth: $.fn.outerWidth,
  121. outerHeight: $.fn.outerHeight
  122. };
  123. function reduce( elem, size, border, margin ) {
  124. $.each( side, function() {
  125. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  126. if ( border ) {
  127. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  128. }
  129. if ( margin ) {
  130. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  131. }
  132. });
  133. return size;
  134. }
  135. $.fn[ "inner" + name ] = function( size ) {
  136. if ( size === undefined ) {
  137. return orig[ "inner" + name ].call( this );
  138. }
  139. return this.each(function() {
  140. $( this ).css( type, reduce( this, size ) + "px" );
  141. });
  142. };
  143. $.fn[ "outer" + name] = function( size, margin ) {
  144. if ( typeof size !== "number" ) {
  145. return orig[ "outer" + name ].call( this, size );
  146. }
  147. return this.each(function() {
  148. $( this).css( type, reduce( this, size, true, margin ) + "px" );
  149. });
  150. };
  151. });
  152. }
  153. // selectors
  154. function focusable( element, isTabIndexNotNaN ) {
  155. var map, mapName, img,
  156. nodeName = element.nodeName.toLowerCase();
  157. if ( "area" === nodeName ) {
  158. map = element.parentNode;
  159. mapName = map.name;
  160. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  161. return false;
  162. }
  163. img = $( "img[usemap=#" + mapName + "]" )[0];
  164. return !!img && visible( img );
  165. }
  166. return ( /input|select|textarea|button|object/.test( nodeName ) ?
  167. !element.disabled :
  168. "a" === nodeName ?
  169. element.href || isTabIndexNotNaN :
  170. isTabIndexNotNaN) &&
  171. // the element and all of its ancestors must be visible
  172. visible( element );
  173. }
  174. function visible( element ) {
  175. return !$( element ).parents().andSelf().filter(function() {
  176. return $.css( this, "visibility" ) === "hidden" ||
  177. $.expr.filters.hidden( this );
  178. }).length;
  179. }
  180. $.extend( $.expr[ ":" ], {
  181. data: $.expr.createPseudo ?
  182. $.expr.createPseudo(function( dataName ) {
  183. return function( elem ) {
  184. return !!$.data( elem, dataName );
  185. };
  186. }) :
  187. // support: jQuery <1.8
  188. function( elem, i, match ) {
  189. return !!$.data( elem, match[ 3 ] );
  190. },
  191. focusable: function( element ) {
  192. return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
  193. },
  194. tabbable: function( element ) {
  195. var tabIndex = $.attr( element, "tabindex" ),
  196. isTabIndexNaN = isNaN( tabIndex );
  197. return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
  198. }
  199. });
  200. // support
  201. $(function() {
  202. var body = document.body,
  203. div = body.appendChild( div = document.createElement( "div" ) );
  204. // access offsetHeight before setting the style to prevent a layout bug
  205. // in IE 9 which causes the element to continue to take up space even
  206. // after it is removed from the DOM (#8026)
  207. div.offsetHeight;
  208. $.extend( div.style, {
  209. minHeight: "100px",
  210. height: "auto",
  211. padding: 0,
  212. borderWidth: 0
  213. });
  214. $.support.minHeight = div.offsetHeight === 100;
  215. $.support.selectstart = "onselectstart" in div;
  216. // set display to none to avoid a layout bug in IE
  217. // http://dev.jquery.com/ticket/4014
  218. body.removeChild( div ).style.display = "none";
  219. });
  220. // deprecated
  221. $.fn.extend({
  222. disableSelection: function() {
  223. return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
  224. ".ui-disableSelection", function( event ) {
  225. event.preventDefault();
  226. });
  227. },
  228. enableSelection: function() {
  229. return this.unbind( ".ui-disableSelection" );
  230. }
  231. });
  232. $.extend( $.ui, {
  233. // $.ui.plugin is deprecated. Use the proxy pattern instead.
  234. plugin: {
  235. add: function( module, option, set ) {
  236. var i,
  237. proto = $.ui[ module ].prototype;
  238. for ( i in set ) {
  239. proto.plugins[ i ] = proto.plugins[ i ] || [];
  240. proto.plugins[ i ].push( [ option, set[ i ] ] );
  241. }
  242. },
  243. call: function( instance, name, args ) {
  244. var i,
  245. set = instance.plugins[ name ];
  246. if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
  247. return;
  248. }
  249. for ( i = 0; i < set.length; i++ ) {
  250. if ( instance.options[ set[ i ][ 0 ] ] ) {
  251. set[ i ][ 1 ].apply( instance.element, args );
  252. }
  253. }
  254. }
  255. },
  256. contains: $.contains,
  257. // only used by resizable
  258. hasScroll: function( el, a ) {
  259. //If overflow is hidden, the element might have extra content, but the user wants to hide it
  260. if ( $( el ).css( "overflow" ) === "hidden") {
  261. return false;
  262. }
  263. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  264. has = false;
  265. if ( el[ scroll ] > 0 ) {
  266. return true;
  267. }
  268. // TODO: determine which cases actually cause this to happen
  269. // if the element doesn't have the scroll set, see if it's possible to
  270. // set the scroll
  271. el[ scroll ] = 1;
  272. has = ( el[ scroll ] > 0 );
  273. el[ scroll ] = 0;
  274. return has;
  275. },
  276. // these are odd functions, fix the API or move into individual plugins
  277. isOverAxis: function( x, reference, size ) {
  278. //Determines when x coordinate is over "b" element axis
  279. return ( x > reference ) && ( x < ( reference + size ) );
  280. },
  281. isOver: function( y, x, top, left, height, width ) {
  282. //Determines when x, y coordinates is over "b" element
  283. return $.ui.isOverAxis( y, top, height ) && $.ui.isOverAxis( x, left, width );
  284. }
  285. });
  286. })( jQuery );
  287. (function( $, undefined ) {
  288. var uuid = 0,
  289. slice = Array.prototype.slice,
  290. _cleanData = $.cleanData;
  291. $.cleanData = function( elems ) {
  292. for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
  293. try {
  294. $( elem ).triggerHandler( "remove" );
  295. // http://bugs.jquery.com/ticket/8235
  296. } catch( e ) {}
  297. }
  298. _cleanData( elems );
  299. };
  300. $.widget = function( name, base, prototype ) {
  301. var fullName, existingConstructor, constructor, basePrototype,
  302. namespace = name.split( "." )[ 0 ];
  303. name = name.split( "." )[ 1 ];
  304. fullName = namespace + "-" + name;
  305. if ( !prototype ) {
  306. prototype = base;
  307. base = $.Widget;
  308. }
  309. // create selector for plugin
  310. $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
  311. return !!$.data( elem, fullName );
  312. };
  313. $[ namespace ] = $[ namespace ] || {};
  314. existingConstructor = $[ namespace ][ name ];
  315. constructor = $[ namespace ][ name ] = function( options, element ) {
  316. // allow instantiation without "new" keyword
  317. if ( !this._createWidget ) {
  318. return new constructor( options, element );
  319. }
  320. // allow instantiation without initializing for simple inheritance
  321. // must use "new" keyword (the code above always passes args)
  322. if ( arguments.length ) {
  323. this._createWidget( options, element );
  324. }
  325. };
  326. // extend with the existing constructor to carry over any static properties
  327. $.extend( constructor, existingConstructor, {
  328. version: prototype.version,
  329. // copy the object used to create the prototype in case we need to
  330. // redefine the widget later
  331. _proto: $.extend( {}, prototype ),
  332. // track widgets that inherit from this widget in case this widget is
  333. // redefined after a widget inherits from it
  334. _childConstructors: []
  335. });
  336. basePrototype = new base();
  337. // we need to make the options hash a property directly on the new instance
  338. // otherwise we'll modify the options hash on the prototype that we're
  339. // inheriting from
  340. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  341. $.each( prototype, function( prop, value ) {
  342. if ( $.isFunction( value ) ) {
  343. prototype[ prop ] = (function() {
  344. var _super = function() {
  345. return base.prototype[ prop ].apply( this, arguments );
  346. },
  347. _superApply = function( args ) {
  348. return base.prototype[ prop ].apply( this, args );
  349. };
  350. return function() {
  351. var __super = this._super,
  352. __superApply = this._superApply,
  353. returnValue;
  354. this._super = _super;
  355. this._superApply = _superApply;
  356. returnValue = value.apply( this, arguments );
  357. this._super = __super;
  358. this._superApply = __superApply;
  359. return returnValue;
  360. };
  361. })();
  362. }
  363. });
  364. constructor.prototype = $.widget.extend( basePrototype, {
  365. // TODO: remove support for widgetEventPrefix
  366. // always use the name + a colon as the prefix, e.g., draggable:start
  367. // don't prefix for widgets that aren't DOM-based
  368. widgetEventPrefix: name
  369. }, prototype, {
  370. constructor: constructor,
  371. namespace: namespace,
  372. widgetName: name,
  373. // TODO remove widgetBaseClass, see #8155
  374. widgetBaseClass: fullName,
  375. widgetFullName: fullName
  376. });
  377. // If this widget is being redefined then we need to find all widgets that
  378. // are inheriting from it and redefine all of them so that they inherit from
  379. // the new version of this widget. We're essentially trying to replace one
  380. // level in the prototype chain.
  381. if ( existingConstructor ) {
  382. $.each( existingConstructor._childConstructors, function( i, child ) {
  383. var childPrototype = child.prototype;
  384. // redefine the child widget using the same prototype that was
  385. // originally used, but inherit from the new version of the base
  386. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
  387. });
  388. // remove the list of existing child constructors from the old constructor
  389. // so the old child constructors can be garbage collected
  390. delete existingConstructor._childConstructors;
  391. } else {
  392. base._childConstructors.push( constructor );
  393. }
  394. $.widget.bridge( name, constructor );
  395. };
  396. $.widget.extend = function( target ) {
  397. var input = slice.call( arguments, 1 ),
  398. inputIndex = 0,
  399. inputLength = input.length,
  400. key,
  401. value;
  402. for ( ; inputIndex < inputLength; inputIndex++ ) {
  403. for ( key in input[ inputIndex ] ) {
  404. value = input[ inputIndex ][ key ];
  405. if (input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
  406. target[ key ] = $.isPlainObject( value ) ? $.widget.extend( {}, target[ key ], value ) : value;
  407. }
  408. }
  409. }
  410. return target;
  411. };
  412. $.widget.bridge = function( name, object ) {
  413. var fullName = object.prototype.widgetFullName;
  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. 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. // 1.9 BC for #7810
  479. // TODO remove dual storage
  480. $.data( element, this.widgetName, this );
  481. $.data( element, this.widgetFullName, this );
  482. this._on({ remove: "destroy" });
  483. this.document = $( element.style ?
  484. // element within the document
  485. element.ownerDocument :
  486. // element is window or document
  487. element.document || element );
  488. this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
  489. }
  490. this._create();
  491. this._trigger( "create", null, this._getCreateEventData() );
  492. this._init();
  493. },
  494. _getCreateOptions: $.noop,
  495. _getCreateEventData: $.noop,
  496. _create: $.noop,
  497. _init: $.noop,
  498. destroy: function() {
  499. this._destroy();
  500. // we can probably remove the unbind calls in 2.0
  501. // all event bindings should go through this._on()
  502. this.element
  503. .unbind( this.eventNamespace )
  504. // 1.9 BC for #7810
  505. // TODO remove dual storage
  506. .removeData( this.widgetName )
  507. .removeData( this.widgetFullName )
  508. // support: jquery <1.6.3
  509. // http://bugs.jquery.com/ticket/9413
  510. .removeData( $.camelCase( this.widgetFullName ) );
  511. this.widget()
  512. .unbind( this.eventNamespace )
  513. .removeAttr( "aria-disabled" )
  514. .removeClass(
  515. this.widgetFullName + "-disabled " +
  516. "ui-state-disabled" );
  517. // clean up events and states
  518. this.bindings.unbind( this.eventNamespace );
  519. this.hoverable.removeClass( "ui-state-hover" );
  520. this.focusable.removeClass( "ui-state-focus" );
  521. },
  522. _destroy: $.noop,
  523. widget: function() {
  524. return this.element;
  525. },
  526. option: function( key, value ) {
  527. var options = key,
  528. parts,
  529. curOption,
  530. i;
  531. if ( arguments.length === 0 ) {
  532. // don't return a reference to the internal hash
  533. return $.widget.extend( {}, this.options );
  534. }
  535. if ( typeof key === "string" ) {
  536. // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  537. options = {};
  538. parts = key.split( "." );
  539. key = parts.shift();
  540. if ( parts.length ) {
  541. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  542. for ( i = 0; i < parts.length - 1; i++ ) {
  543. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  544. curOption = curOption[ parts[ i ] ];
  545. }
  546. key = parts.pop();
  547. if ( value === undefined ) {
  548. return curOption[ key ] === undefined ? null : curOption[ key ];
  549. }
  550. curOption[ key ] = value;
  551. } else {
  552. if ( value === undefined ) {
  553. return this.options[ key ] === undefined ? null : this.options[ key ];
  554. }
  555. options[ key ] = value;
  556. }
  557. }
  558. this._setOptions( options );
  559. return this;
  560. },
  561. _setOptions: function( options ) {
  562. var key;
  563. for ( key in options ) {
  564. this._setOption( key, options[ key ] );
  565. }
  566. return this;
  567. },
  568. _setOption: function( key, value ) {
  569. this.options[ key ] = value;
  570. if ( key === "disabled" ) {
  571. this.widget()
  572. .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value )
  573. .attr( "aria-disabled", value );
  574. this.hoverable.removeClass( "ui-state-hover" );
  575. this.focusable.removeClass( "ui-state-focus" );
  576. }
  577. return this;
  578. },
  579. enable: function() {
  580. return this._setOption( "disabled", false );
  581. },
  582. disable: function() {
  583. return this._setOption( "disabled", true );
  584. },
  585. _on: function( element, handlers ) {
  586. // no element argument, shuffle and use this.element
  587. if ( !handlers ) {
  588. handlers = element;
  589. element = this.element;
  590. } else {
  591. // accept selectors, DOM elements
  592. element = $( element );
  593. this.bindings = this.bindings.add( element );
  594. }
  595. var instance = this;
  596. $.each( handlers, function( event, handler ) {
  597. function handlerProxy() {
  598. // allow widgets to customize the disabled handling
  599. // - disabled as an array instead of boolean
  600. // - disabled class as method for disabling individual parts
  601. if ( instance.options.disabled === true ||
  602. $( this ).hasClass( "ui-state-disabled" ) ) {
  603. return;
  604. }
  605. return ( typeof handler === "string" ? instance[ handler ] : handler )
  606. .apply( instance, arguments );
  607. }
  608. // copy the guid so direct unbinding works
  609. if ( typeof handler !== "string" ) {
  610. handlerProxy.guid = handler.guid =
  611. handler.guid || handlerProxy.guid || $.guid++;
  612. }
  613. var match = event.match( /^(\w+)\s*(.*)$/ ),
  614. eventName = match[1] + instance.eventNamespace,
  615. selector = match[2];
  616. if ( selector ) {
  617. instance.widget().delegate( selector, eventName, handlerProxy );
  618. } else {
  619. element.bind( eventName, handlerProxy );
  620. }
  621. });
  622. },
  623. _off: function( element, eventName ) {
  624. eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
  625. element.unbind( eventName ).undelegate( eventName );
  626. },
  627. _delay: function( handler, delay ) {
  628. function handlerProxy() {
  629. return ( typeof handler === "string" ? instance[ handler ] : handler )
  630. .apply( instance, arguments );
  631. }
  632. var instance = this;
  633. return setTimeout( handlerProxy, delay || 0 );
  634. },
  635. _hoverable: function( element ) {
  636. this.hoverable = this.hoverable.add( element );
  637. this._on( element, {
  638. mouseenter: function( event ) {
  639. $( event.currentTarget ).addClass( "ui-state-hover" );
  640. },
  641. mouseleave: function( event ) {
  642. $( event.currentTarget ).removeClass( "ui-state-hover" );
  643. }
  644. });
  645. },
  646. _focusable: function( element ) {
  647. this.focusable = this.focusable.add( element );
  648. this._on( element, {
  649. focusin: function( event ) {
  650. $( event.currentTarget ).addClass( "ui-state-focus" );
  651. },
  652. focusout: function( event ) {
  653. $( event.currentTarget ).removeClass( "ui-state-focus" );
  654. }
  655. });
  656. },
  657. _trigger: function( type, event, data ) {
  658. var prop, orig,
  659. callback = this.options[ type ];
  660. data = data || {};
  661. event = $.Event( event );
  662. event.type = ( type === this.widgetEventPrefix ?
  663. type :
  664. this.widgetEventPrefix + type ).toLowerCase();
  665. // the original event may come from any element
  666. // so we need to reset the target on the new event
  667. event.target = this.element[ 0 ];
  668. // copy original event properties over to the new event
  669. orig = event.originalEvent;
  670. if ( orig ) {
  671. for ( prop in orig ) {
  672. if ( !( prop in event ) ) {
  673. event[ prop ] = orig[ prop ];
  674. }
  675. }
  676. }
  677. this.element.trigger( event, data );
  678. return !( $.isFunction( callback ) &&
  679. callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
  680. event.isDefaultPrevented() );
  681. }
  682. };
  683. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  684. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  685. if ( typeof options === "string" ) {
  686. options = { effect: options };
  687. }
  688. var hasOptions,
  689. effectName = !options ?
  690. method :
  691. options === true || typeof options === "number" ?
  692. defaultEffect :
  693. options.effect || defaultEffect;
  694. options = options || {};
  695. if ( typeof options === "number" ) {
  696. options = { duration: options };
  697. }
  698. hasOptions = !$.isEmptyObject( options );
  699. options.complete = callback;
  700. if ( options.delay ) {
  701. element.delay( options.delay );
  702. }
  703. if ( hasOptions && $.effects && ( $.effects.effect[ effectName ] || $.uiBackCompat !== false && $.effects[ effectName ] ) ) {
  704. element[ method ]( options );
  705. } else if ( effectName !== method && element[ effectName ] ) {
  706. element[ effectName ]( options.duration, options.easing, callback );
  707. } else {
  708. element.queue(function( next ) {
  709. $( this )[ method ]();
  710. if ( callback ) {
  711. callback.call( element[ 0 ] );
  712. }
  713. next();
  714. });
  715. }
  716. };
  717. });
  718. // DEPRECATED
  719. if ( $.uiBackCompat !== false ) {
  720. $.Widget.prototype._getCreateOptions = function() {
  721. return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ];
  722. };
  723. }
  724. })( jQuery );
  725. (function( $, undefined ) {
  726. var mouseHandled = false;
  727. $( document ).mouseup( function( e ) {
  728. mouseHandled = false;
  729. });
  730. $.widget("ui.mouse", {
  731. version: "1.9.0",
  732. options: {
  733. cancel: 'input,textarea,button,select,option',
  734. distance: 1,
  735. delay: 0
  736. },
  737. _mouseInit: function() {
  738. var that = this;
  739. this.element
  740. .bind('mousedown.'+this.widgetName, function(event) {
  741. return that._mouseDown(event);
  742. })
  743. .bind('click.'+this.widgetName, function(event) {
  744. if (true === $.data(event.target, that.widgetName + '.preventClickEvent')) {
  745. $.removeData(event.target, that.widgetName + '.preventClickEvent');
  746. event.stopImmediatePropagation();
  747. return false;
  748. }
  749. });
  750. this.started = false;
  751. },
  752. // TODO: make sure destroying one instance of mouse doesn't mess with
  753. // other instances of mouse
  754. _mouseDestroy: function() {
  755. this.element.unbind('.'+this.widgetName);
  756. if ( this._mouseMoveDelegate ) {
  757. $(document)
  758. .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
  759. .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
  760. }
  761. },
  762. _mouseDown: function(event) {
  763. // don't let more than one widget handle mouseStart
  764. if( mouseHandled ) { return; }
  765. // we may have missed mouseup (out of window)
  766. (this._mouseStarted && this._mouseUp(event));
  767. this._mouseDownEvent = event;
  768. var that = this,
  769. btnIsLeft = (event.which === 1),
  770. // event.target.nodeName works around a bug in IE 8 with
  771. // disabled inputs (#7620)
  772. elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
  773. if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
  774. return true;
  775. }
  776. this.mouseDelayMet = !this.options.delay;
  777. if (!this.mouseDelayMet) {
  778. this._mouseDelayTimer = setTimeout(function() {
  779. that.mouseDelayMet = true;
  780. }, this.options.delay);
  781. }
  782. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  783. this._mouseStarted = (this._mouseStart(event) !== false);
  784. if (!this._mouseStarted) {
  785. event.preventDefault();
  786. return true;
  787. }
  788. }
  789. // Click event may never have fired (Gecko & Opera)
  790. if (true === $.data(event.target, this.widgetName + '.preventClickEvent')) {
  791. $.removeData(event.target, this.widgetName + '.preventClickEvent');
  792. }
  793. // these delegates are required to keep context
  794. this._mouseMoveDelegate = function(event) {
  795. return that._mouseMove(event);
  796. };
  797. this._mouseUpDelegate = function(event) {
  798. return that._mouseUp(event);
  799. };
  800. $(document)
  801. .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
  802. .bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
  803. event.preventDefault();
  804. mouseHandled = true;
  805. return true;
  806. },
  807. _mouseMove: function(event) {
  808. // IE mouseup check - mouseup happened when mouse was out of window
  809. if ($.browser.msie && !(document.documentMode >= 9) && !event.button) {
  810. return this._mouseUp(event);
  811. }
  812. if (this._mouseStarted) {
  813. this._mouseDrag(event);
  814. return event.preventDefault();
  815. }
  816. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  817. this._mouseStarted =
  818. (this._mouseStart(this._mouseDownEvent, event) !== false);
  819. (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
  820. }
  821. return !this._mouseStarted;
  822. },
  823. _mouseUp: function(event) {
  824. $(document)
  825. .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
  826. .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
  827. if (this._mouseStarted) {
  828. this._mouseStarted = false;
  829. if (event.target === this._mouseDownEvent.target) {
  830. $.data(event.target, this.widgetName + '.preventClickEvent', true);
  831. }
  832. this._mouseStop(event);
  833. }
  834. return false;
  835. },
  836. _mouseDistanceMet: function(event) {
  837. return (Math.max(
  838. Math.abs(this._mouseDownEvent.pageX - event.pageX),
  839. Math.abs(this._mouseDownEvent.pageY - event.pageY)
  840. ) >= this.options.distance
  841. );
  842. },
  843. _mouseDelayMet: function(event) {
  844. return this.mouseDelayMet;
  845. },
  846. // These are placeholder methods, to be overriden by extending plugin
  847. _mouseStart: function(event) {},
  848. _mouseDrag: function(event) {},
  849. _mouseStop: function(event) {},
  850. _mouseCapture: function(event) { return true; }
  851. });
  852. })(jQuery);
  853. (function( $, undefined ) {
  854. $.ui = $.ui || {};
  855. var cachedScrollbarWidth,
  856. max = Math.max,
  857. abs = Math.abs,
  858. round = Math.round,
  859. rhorizontal = /left|center|right/,
  860. rvertical = /top|center|bottom/,
  861. roffset = /[\+\-]\d+%?/,
  862. rposition = /^\w+/,
  863. rpercent = /%$/,
  864. _position = $.fn.position;
  865. function getOffsets( offsets, width, height ) {
  866. return [
  867. parseInt( offsets[ 0 ], 10 ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  868. parseInt( offsets[ 1 ], 10 ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  869. ];
  870. }
  871. function parseCss( element, property ) {
  872. return parseInt( $.css( element, property ), 10 ) || 0;
  873. }
  874. $.position = {
  875. scrollbarWidth: function() {
  876. if ( cachedScrollbarWidth !== undefined ) {
  877. return cachedScrollbarWidth;
  878. }
  879. var w1, w2,
  880. div = $( "<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
  881. innerDiv = div.children()[0];
  882. $( "body" ).append( div );
  883. w1 = innerDiv.offsetWidth;
  884. div.css( "overflow", "scroll" );
  885. w2 = innerDiv.offsetWidth;
  886. if ( w1 === w2 ) {
  887. w2 = div[0].clientWidth;
  888. }
  889. div.remove();
  890. return (cachedScrollbarWidth = w1 - w2);
  891. },
  892. getScrollInfo: function( within ) {
  893. var overflowX = within.isWindow ? "" : within.element.css( "overflow-x" ),
  894. overflowY = within.isWindow ? "" : within.element.css( "overflow-y" ),
  895. hasOverflowX = overflowX === "scroll" ||
  896. ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
  897. hasOverflowY = overflowY === "scroll" ||
  898. ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
  899. return {
  900. width: hasOverflowX ? $.position.scrollbarWidth() : 0,
  901. height: hasOverflowY ? $.position.scrollbarWidth() : 0
  902. };
  903. },
  904. getWithinInfo: function( element ) {
  905. var withinElement = $( element || window ),
  906. isWindow = $.isWindow( withinElement[0] );
  907. return {
  908. element: withinElement,
  909. isWindow: isWindow,
  910. offset: withinElement.offset() || { left: 0, top: 0 },
  911. scrollLeft: withinElement.scrollLeft(),
  912. scrollTop: withinElement.scrollTop(),
  913. width: isWindow ? withinElement.width() : withinElement.outerWidth(),
  914. height: isWindow ? withinElement.height() : withinElement.outerHeight()
  915. };
  916. }
  917. };
  918. $.fn.position = function( options ) {
  919. if ( !options || !options.of ) {
  920. return _position.apply( this, arguments );
  921. }
  922. // make a copy, we don't want to modify arguments
  923. options = $.extend( {}, options );
  924. var atOffset, targetWidth, targetHeight, targetOffset, basePosition,
  925. target = $( options.of ),
  926. within = $.position.getWithinInfo( options.within ),
  927. scrollInfo = $.position.getScrollInfo( within ),
  928. targetElem = target[0],
  929. collision = ( options.collision || "flip" ).split( " " ),
  930. offsets = {};
  931. if ( targetElem.nodeType === 9 ) {
  932. targetWidth = target.width();
  933. targetHeight = target.height();
  934. targetOffset = { top: 0, left: 0 };
  935. } else if ( $.isWindow( targetElem ) ) {
  936. targetWidth = target.width();
  937. targetHeight = target.height();
  938. targetOffset = { top: target.scrollTop(), left: target.scrollLeft() };
  939. } else if ( targetElem.preventDefault ) {
  940. // force left top to allow flipping
  941. options.at = "left top";
  942. targetWidth = targetHeight = 0;
  943. targetOffset = { top: targetElem.pageY, left: targetElem.pageX };
  944. } else {
  945. targetWidth = target.outerWidth();
  946. targetHeight = target.outerHeight();
  947. targetOffset = target.offset();
  948. }
  949. // clone to reuse original targetOffset later
  950. basePosition = $.extend( {}, targetOffset );
  951. // force my and at to have valid horizontal and vertical positions
  952. // if a value is missing or invalid, it will be converted to center
  953. $.each( [ "my", "at" ], function() {
  954. var pos = ( options[ this ] || "" ).split( " " ),
  955. horizontalOffset,
  956. verticalOffset;
  957. if ( pos.length === 1) {
  958. pos = rhorizontal.test( pos[ 0 ] ) ?
  959. pos.concat( [ "center" ] ) :
  960. rvertical.test( pos[ 0 ] ) ?
  961. [ "center" ].concat( pos ) :
  962. [ "center", "center" ];
  963. }
  964. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  965. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  966. // calculate offsets
  967. horizontalOffset = roffset.exec( pos[ 0 ] );
  968. verticalOffset = roffset.exec( pos[ 1 ] );
  969. offsets[ this ] = [
  970. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  971. verticalOffset ? verticalOffset[ 0 ] : 0
  972. ];
  973. // reduce to just the positions without the offsets
  974. options[ this ] = [
  975. rposition.exec( pos[ 0 ] )[ 0 ],
  976. rposition.exec( pos[ 1 ] )[ 0 ]
  977. ];
  978. });
  979. // normalize collision option
  980. if ( collision.length === 1 ) {
  981. collision[ 1 ] = collision[ 0 ];
  982. }
  983. if ( options.at[ 0 ] === "right" ) {
  984. basePosition.left += targetWidth;
  985. } else if ( options.at[ 0 ] === "center" ) {
  986. basePosition.left += targetWidth / 2;
  987. }
  988. if ( options.at[ 1 ] === "bottom" ) {
  989. basePosition.top += targetHeight;
  990. } else if ( options.at[ 1 ] === "center" ) {
  991. basePosition.top += targetHeight / 2;
  992. }
  993. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  994. basePosition.left += atOffset[ 0 ];
  995. basePosition.top += atOffset[ 1 ];
  996. return this.each(function() {
  997. var collisionPosition, using,
  998. elem = $( this ),
  999. elemWidth = elem.outerWidth(),
  1000. elemHeight = elem.outerHeight(),
  1001. marginLeft = parseCss( this, "marginLeft" ),
  1002. marginTop = parseCss( this, "marginTop" ),
  1003. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
  1004. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
  1005. position = $.extend( {}, basePosition ),
  1006. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  1007. if ( options.my[ 0 ] === "right" ) {
  1008. position.left -= elemWidth;
  1009. } else if ( options.my[ 0 ] === "center" ) {
  1010. position.left -= elemWidth / 2;
  1011. }
  1012. if ( options.my[ 1 ] === "bottom" ) {
  1013. position.top -= elemHeight;
  1014. } else if ( options.my[ 1 ] === "center" ) {
  1015. position.top -= elemHeight / 2;
  1016. }
  1017. position.left += myOffset[ 0 ];
  1018. position.top += myOffset[ 1 ];
  1019. // if the browser doesn't support fractions, then round for consistent results
  1020. if ( !$.support.offsetFractions ) {
  1021. position.left = round( position.left );
  1022. position.top = round( position.top );
  1023. }
  1024. collisionPosition = {
  1025. marginLeft: marginLeft,
  1026. marginTop: marginTop
  1027. };
  1028. $.each( [ "left", "top" ], function( i, dir ) {
  1029. if ( $.ui.position[ collision[ i ] ] ) {
  1030. $.ui.position[ collision[ i ] ][ dir ]( position, {
  1031. targetWidth: targetWidth,
  1032. targetHeight: targetHeight,
  1033. elemWidth: elemWidth,
  1034. elemHeight: elemHeight,
  1035. collisionPosition: collisionPosition,
  1036. collisionWidth: collisionWidth,
  1037. collisionHeight: collisionHeight,
  1038. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  1039. my: options.my,
  1040. at: options.at,
  1041. within: within,
  1042. elem : elem
  1043. });
  1044. }
  1045. });
  1046. if ( $.fn.bgiframe ) {
  1047. elem.bgiframe();
  1048. }
  1049. if ( options.using ) {
  1050. // adds feedback as second argument to using callback, if present
  1051. using = function( props ) {
  1052. var left = targetOffset.left - position.left,
  1053. right = left + targetWidth - elemWidth,
  1054. top = targetOffset.top - position.top,
  1055. bottom = top + targetHeight - elemHeight,
  1056. feedback = {
  1057. target: {
  1058. element: target,
  1059. left: targetOffset.left,
  1060. top: targetOffset.top,
  1061. width: targetWidth,
  1062. height: targetHeight
  1063. },
  1064. element: {
  1065. element: elem,
  1066. left: position.left,
  1067. top: position.top,
  1068. width: elemWidth,
  1069. height: elemHeight
  1070. },
  1071. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  1072. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  1073. };
  1074. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  1075. feedback.horizontal = "center";
  1076. }
  1077. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  1078. feedback.vertical = "middle";
  1079. }
  1080. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  1081. feedback.important = "horizontal";
  1082. } else {
  1083. feedback.important = "vertical";
  1084. }
  1085. options.using.call( this, props, feedback );
  1086. };
  1087. }
  1088. elem.offset( $.extend( position, { using: using } ) );
  1089. });
  1090. };
  1091. $.ui.position = {
  1092. fit: {
  1093. left: function( position, data ) {
  1094. var within = data.within,
  1095. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  1096. outerWidth = within.width,
  1097. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1098. overLeft = withinOffset - collisionPosLeft,
  1099. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  1100. newOverRight;
  1101. // element is wider than within
  1102. if ( data.collisionWidth > outerWidth ) {
  1103. // element is initially over the left side of within
  1104. if ( overLeft > 0 && overRight <= 0 ) {
  1105. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
  1106. position.left += overLeft - newOverRight;
  1107. // element is initially over right side of within
  1108. } else if ( overRight > 0 && overLeft <= 0 ) {
  1109. position.left = withinOffset;
  1110. // element is initially over both left and right sides of within
  1111. } else {
  1112. if ( overLeft > overRight ) {
  1113. position.left = withinOffset + outerWidth - data.collisionWidth;
  1114. } else {
  1115. position.left = withinOffset;
  1116. }
  1117. }
  1118. // too far left -> align with left edge
  1119. } else if ( overLeft > 0 ) {
  1120. position.left += overLeft;
  1121. // too far right -> align with right edge
  1122. } else if ( overRight > 0 ) {
  1123. position.left -= overRight;
  1124. // adjust based on position and margin
  1125. } else {
  1126. position.left = max( position.left - collisionPosLeft, position.left );
  1127. }
  1128. },
  1129. top: function( position, data ) {
  1130. var within = data.within,
  1131. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  1132. outerHeight = data.within.height,
  1133. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1134. overTop = withinOffset - collisionPosTop,
  1135. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  1136. newOverBottom;
  1137. // element is taller than within
  1138. if ( data.collisionHeight > outerHeight ) {
  1139. // element is initially over the top of within
  1140. if ( overTop > 0 && overBottom <= 0 ) {
  1141. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
  1142. position.top += overTop - newOverBottom;
  1143. // element is initially over bottom of within
  1144. } else if ( overBottom > 0 && overTop <= 0 ) {
  1145. position.top = withinOffset;
  1146. // element is initially over both top and bottom of within
  1147. } else {
  1148. if ( overTop > overBottom ) {
  1149. position.top = withinOffset + outerHeight - data.collisionHeight;
  1150. } else {
  1151. position.top = withinOffset;
  1152. }
  1153. }
  1154. // too far up -> align with top
  1155. } else if ( overTop > 0 ) {
  1156. position.top += overTop;
  1157. // too far down -> align with bottom edge
  1158. } else if ( overBottom > 0 ) {
  1159. position.top -= overBottom;
  1160. // adjust based on position and margin
  1161. } else {
  1162. position.top = max( position.top - collisionPosTop, position.top );
  1163. }
  1164. }
  1165. },
  1166. flip: {
  1167. left: function( position, data ) {
  1168. var within = data.within,
  1169. withinOffset = within.offset.left + within.scrollLeft,
  1170. outerWidth = within.width,
  1171. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  1172. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1173. overLeft = collisionPosLeft - offsetLeft,
  1174. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  1175. myOffset = data.my[ 0 ] === "left" ?
  1176. -data.elemWidth :
  1177. data.my[ 0 ] === "right" ?
  1178. data.elemWidth :
  1179. 0,
  1180. atOffset = data.at[ 0 ] === "left" ?
  1181. data.targetWidth :
  1182. data.at[ 0 ] === "right" ?
  1183. -data.targetWidth :
  1184. 0,
  1185. offset = -2 * data.offset[ 0 ],
  1186. newOverRight,
  1187. newOverLeft;
  1188. if ( overLeft < 0 ) {
  1189. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
  1190. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  1191. position.left += myOffset + atOffset + offset;
  1192. }
  1193. }
  1194. else if ( overRight > 0 ) {
  1195. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
  1196. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  1197. position.left += myOffset + atOffset + offset;
  1198. }
  1199. }
  1200. },
  1201. top: function( position, data ) {
  1202. var within = data.within,
  1203. withinOffset = within.offset.top + within.scrollTop,
  1204. outerHeight = within.height,
  1205. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  1206. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1207. overTop = collisionPosTop - offsetTop,
  1208. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  1209. top = data.my[ 1 ] === "top",
  1210. myOffset = top ?
  1211. -data.elemHeight :
  1212. data.my[ 1 ] === "bottom" ?
  1213. data.elemHeight :
  1214. 0,
  1215. atOffset = data.at[ 1 ] === "top" ?
  1216. data.targetHeight :
  1217. data.at[ 1 ] === "bottom" ?
  1218. -data.targetHeight :
  1219. 0,
  1220. offset = -2 * data.offset[ 1 ],
  1221. newOverTop,
  1222. newOverBottom;
  1223. if ( overTop < 0 ) {
  1224. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
  1225. if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
  1226. position.top += myOffset + atOffset + offset;
  1227. }
  1228. }
  1229. else if ( overBottom > 0 ) {
  1230. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
  1231. if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
  1232. position.top += myOffset + atOffset + offset;
  1233. }
  1234. }
  1235. }
  1236. },
  1237. flipfit: {
  1238. left: function() {
  1239. $.ui.position.flip.left.apply( this, arguments );
  1240. $.ui.position.fit.left.apply( this, arguments );
  1241. },
  1242. top: function() {
  1243. $.ui.position.flip.top.apply( this, arguments );
  1244. $.ui.position.fit.top.apply( this, arguments );
  1245. }
  1246. }
  1247. };
  1248. // fraction support test
  1249. (function () {
  1250. var testElement, testElementParent, testElementStyle, offsetLeft, i,
  1251. body = document.getElementsByTagName( "body" )[ 0 ],
  1252. div = document.createElement( "div" );
  1253. //Create a "fake body" for testing based on method used in jQuery.support
  1254. testElement = document.createElement( body ? "div" : "body" );
  1255. testElementStyle = {
  1256. visibility: "hidden",
  1257. width: 0,
  1258. height: 0,
  1259. border: 0,
  1260. margin: 0,
  1261. background: "none"
  1262. };
  1263. if ( body ) {
  1264. $.extend( testElementStyle, {
  1265. position: "absolute",
  1266. left: "-1000px",
  1267. top: "-1000px"
  1268. });
  1269. }
  1270. for ( i in testElementStyle ) {
  1271. testElement.style[ i ] = testElementStyle[ i ];
  1272. }
  1273. testElement.appendChild( div );
  1274. testElementParent = body || document.documentElement;
  1275. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  1276. div.style.cssText = "position: absolute; left: 10.7432222px;";
  1277. offsetLeft = $( div ).offset().left;
  1278. $.support.offsetFractions = offsetLeft > 10 && offsetLeft < 11;
  1279. testElement.innerHTML = "";
  1280. testElementParent.removeChild( testElement );
  1281. })();
  1282. // DEPRECATED
  1283. if ( $.uiBackCompat !== false ) {
  1284. // offset option
  1285. (function( $ ) {
  1286. var _position = $.fn.position;
  1287. $.fn.position = function( options ) {
  1288. if ( !options || !options.offset ) {
  1289. return _position.call( this, options );
  1290. }
  1291. var offset = options.offset.split( " " ),
  1292. at = options.at.split( " " );
  1293. if ( offset.length === 1 ) {
  1294. offset[ 1 ] = offset[ 0 ];
  1295. }
  1296. if ( /^\d/.test( offset[ 0 ] ) ) {
  1297. offset[ 0 ] = "+" + offset[ 0 ];
  1298. }
  1299. if ( /^\d/.test( offset[ 1 ] ) ) {
  1300. offset[ 1 ] = "+" + offset[ 1 ];
  1301. }
  1302. if ( at.length === 1 ) {
  1303. if ( /left|center|right/.test( at[ 0 ] ) ) {
  1304. at[ 1 ] = "center";
  1305. } else {
  1306. at[ 1 ] = at[ 0 ];
  1307. at[ 0 ] = "center";
  1308. }
  1309. }
  1310. return _position.call( this, $.extend( options, {
  1311. at: at[ 0 ] + offset[ 0 ] + " " + at[ 1 ] + offset[ 1 ],
  1312. offset: undefined
  1313. } ) );
  1314. };
  1315. }( jQuery ) );
  1316. }
  1317. }( jQuery ) );
  1318. (function( $, undefined ) {
  1319. var uid = 0,
  1320. hideProps = {},
  1321. showProps = {};
  1322. hideProps.height = hideProps.paddingTop = hideProps.paddingBottom =
  1323. hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide";
  1324. showProps.height = showProps.paddingTop = showProps.paddingBottom =
  1325. showProps.borderTopWidth = showProps.borderBottomWidth = "show";
  1326. $.widget( "ui.accordion", {
  1327. version: "1.9.0",
  1328. options: {
  1329. active: 0,
  1330. animate: {},
  1331. collapsible: false,
  1332. event: "click",
  1333. header: "> li > :first-child,> :not(li):even",
  1334. heightStyle: "auto",
  1335. icons: {
  1336. activeHeader: "ui-icon-triangle-1-s",
  1337. header: "ui-icon-triangle-1-e"
  1338. },
  1339. // callbacks
  1340. activate: null,
  1341. beforeActivate: null
  1342. },
  1343. _create: function() {
  1344. var accordionId = this.accordionId = "ui-accordion-" +
  1345. (this.element.attr( "id" ) || ++uid),
  1346. options = this.options;
  1347. this.prevShow = this.prevHide = $();
  1348. this.element.addClass( "ui-accordion ui-widget ui-helper-reset" );
  1349. this.headers = this.element.find( options.header )
  1350. .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" );
  1351. this._hoverable( this.headers );
  1352. this._focusable( this.headers );
  1353. this.headers.next()
  1354. .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
  1355. .hide();
  1356. // don't allow collapsible: false and active: false
  1357. if ( !options.collapsible && options.active === false ) {
  1358. options.active = 0;
  1359. }
  1360. // handle negative values
  1361. if ( options.active < 0 ) {
  1362. options.active += this.headers.length;
  1363. }
  1364. this.active = this._findActive( options.active )
  1365. .addClass( "ui-accordion-header-active ui-state-active" )
  1366. .toggleClass( "ui-corner-all ui-corner-top" );
  1367. this.active.next()
  1368. .addClass( "ui-accordion-content-active" )
  1369. .show();
  1370. this._createIcons();
  1371. this.originalHeight = this.element[0].style.height;
  1372. this.refresh();
  1373. // ARIA
  1374. this.element.attr( "role", "tablist" );
  1375. this.headers
  1376. .attr( "role", "tab" )
  1377. .each(function( i ) {
  1378. var header = $( this ),
  1379. headerId = header.attr( "id" ),
  1380. panel = header.next(),
  1381. panelId = panel.attr( "id" );
  1382. if ( !headerId ) {
  1383. headerId = accordionId + "-header-" + i;
  1384. header.attr( "id", headerId );
  1385. }
  1386. if ( !panelId ) {
  1387. panelId = accordionId + "-panel-" + i;
  1388. panel.attr( "id", panelId );
  1389. }
  1390. header.attr( "aria-controls", panelId );
  1391. panel.attr( "aria-labelledby", headerId );
  1392. })
  1393. .next()
  1394. .attr( "role", "tabpanel" );
  1395. this.headers
  1396. .not( this.active )
  1397. .attr({
  1398. "aria-selected": "false",
  1399. tabIndex: -1
  1400. })
  1401. .next()
  1402. .attr({
  1403. "aria-expanded": "false",
  1404. "aria-hidden": "true"
  1405. })
  1406. .hide();
  1407. // make sure at least one header is in the tab order
  1408. if ( !this.active.length ) {
  1409. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  1410. } else {
  1411. this.active.attr({
  1412. "aria-selected": "true",
  1413. tabIndex: 0
  1414. })
  1415. .next()
  1416. .attr({
  1417. "aria-expanded": "true",
  1418. "aria-hidden": "false"
  1419. });
  1420. }
  1421. this._on( this.headers, { keydown: "_keydown" });
  1422. this._on( this.headers.next(), { keydown: "_panelKeyDown" });
  1423. this._setupEvents( options.event );
  1424. },
  1425. _getCreateEventData: function() {
  1426. return {
  1427. header: this.active,
  1428. content: !this.active.length ? $() : this.active.next()
  1429. };
  1430. },
  1431. _createIcons: function() {
  1432. var icons = this.options.icons;
  1433. if ( icons ) {
  1434. $( "<span>" )
  1435. .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
  1436. .prependTo( this.headers );
  1437. this.active.children( ".ui-accordion-header-icon" )
  1438. .removeClass( icons.header )
  1439. .addClass( icons.activeHeader );
  1440. this.headers.addClass( "ui-accordion-icons" );
  1441. }
  1442. },
  1443. _destroyIcons: function() {
  1444. this.headers
  1445. .removeClass( "ui-accordion-icons" )
  1446. .children( ".ui-accordion-header-icon" )
  1447. .remove();
  1448. },
  1449. _destroy: function() {
  1450. var contents;
  1451. // clean up main element
  1452. this.element
  1453. .removeClass( "ui-accordion ui-widget ui-helper-reset" )
  1454. .removeAttr( "role" );
  1455. // clean up headers
  1456. this.headers
  1457. .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" )
  1458. .removeAttr( "role" )
  1459. .removeAttr( "aria-selected" )
  1460. .removeAttr( "aria-controls" )
  1461. .removeAttr( "tabIndex" )
  1462. .each(function() {
  1463. if ( /^ui-accordion/.test( this.id ) ) {
  1464. this.removeAttribute( "id" );
  1465. }
  1466. });
  1467. this._destroyIcons();
  1468. // clean up content panels
  1469. contents = this.headers.next()
  1470. .css( "display", "" )
  1471. .removeAttr( "role" )
  1472. .removeAttr( "aria-expanded" )
  1473. .removeAttr( "aria-hidden" )
  1474. .removeAttr( "aria-labelledby" )
  1475. .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled" )
  1476. .each(function() {
  1477. if ( /^ui-accordion/.test( this.id ) ) {
  1478. this.removeAttribute( "id" );
  1479. }
  1480. });
  1481. if ( this.options.heightStyle !== "content" ) {
  1482. this.element.css( "height", this.originalHeight );
  1483. contents.css( "height", "" );
  1484. }
  1485. },
  1486. _setOption: function( key, value ) {
  1487. if ( key === "active" ) {
  1488. // _activate() will handle invalid values and update this.options
  1489. this._activate( value );
  1490. return;
  1491. }
  1492. if ( key === "event" ) {
  1493. if ( this.options.event ) {
  1494. this._off( this.headers, this.options.event );
  1495. }
  1496. this._setupEvents( value );
  1497. }
  1498. this._super( key, value );
  1499. // setting collapsible: false while collapsed; open first panel
  1500. if ( key === "collapsible" && !value && this.options.active === false ) {
  1501. this._activate( 0 );
  1502. }
  1503. if ( key === "icons" ) {
  1504. this._destroyIcons();
  1505. if ( value ) {
  1506. this._createIcons();
  1507. }
  1508. }
  1509. // #5332 - opacity doesn't cascade to positioned elements in IE
  1510. // so we need to add the disabled class to the headers and panels
  1511. if ( key === "disabled" ) {
  1512. this.headers.add( this.headers.next() )
  1513. .toggleClass( "ui-state-disabled", !!value );
  1514. }
  1515. },
  1516. _keydown: function( event ) {
  1517. if ( event.altKey || event.ctrlKey ) {
  1518. return;
  1519. }
  1520. var keyCode = $.ui.keyCode,
  1521. length = this.headers.length,
  1522. currentIndex = this.headers.index( event.target ),
  1523. toFocus = false;
  1524. switch ( event.keyCode ) {
  1525. case keyCode.RIGHT:
  1526. case keyCode.DOWN:
  1527. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  1528. break;
  1529. case keyCode.LEFT:
  1530. case keyCode.UP:
  1531. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  1532. break;
  1533. case keyCode.SPACE:
  1534. case keyCode.ENTER:
  1535. this._eventHandler( event );
  1536. break;
  1537. case keyCode.HOME:
  1538. toFocus = this.headers[ 0 ];
  1539. break;
  1540. case keyCode.END:
  1541. toFocus = this.headers[ length - 1 ];
  1542. break;
  1543. }
  1544. if ( toFocus ) {
  1545. $( event.target ).attr( "tabIndex", -1 );
  1546. $( toFocus ).attr( "tabIndex", 0 );
  1547. toFocus.focus();
  1548. event.preventDefault();
  1549. }
  1550. },
  1551. _panelKeyDown : function( event ) {
  1552. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  1553. $( event.currentTarget ).prev().focus();
  1554. }
  1555. },
  1556. refresh: function() {
  1557. var maxHeight, overflow,
  1558. heightStyle = this.options.heightStyle,
  1559. parent = this.element.parent();
  1560. this.element.css( "height", this.originalHeight );
  1561. if ( heightStyle === "fill" ) {
  1562. // IE 6 treats height like minHeight, so we need to turn off overflow
  1563. // in order to get a reliable height
  1564. // we use the minHeight support test because we assume that only
  1565. // browsers that don't support minHeight will treat height as minHeight
  1566. if ( !$.support.minHeight ) {
  1567. overflow = parent.css( "overflow" );
  1568. parent.css( "overflow", "hidden");
  1569. }
  1570. maxHeight = parent.height();
  1571. this.element.siblings( ":visible" ).each(function() {
  1572. var elem = $( this ),
  1573. position = elem.css( "position" );
  1574. if ( position === "absolute" || position === "fixed" ) {
  1575. return;
  1576. }
  1577. maxHeight -= elem.outerHeight( true );
  1578. });
  1579. if ( overflow ) {
  1580. parent.css( "overflow", overflow );
  1581. }
  1582. this.headers.each(function() {
  1583. maxHeight -= $( this ).outerHeight( true );
  1584. });
  1585. this.headers.next()
  1586. .each(function() {
  1587. $( this ).height( Math.max( 0, maxHeight -
  1588. $( this ).innerHeight() + $( this ).height() ) );
  1589. })
  1590. .css( "overflow", "auto" );
  1591. } else if ( heightStyle === "auto" ) {
  1592. maxHeight = 0;
  1593. this.headers.next()
  1594. .each(function() {
  1595. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  1596. })
  1597. .height( maxHeight );
  1598. }
  1599. if ( heightStyle !== "content" ) {
  1600. this.element.height( this.element.height() );
  1601. }
  1602. },
  1603. _activate: function( index ) {
  1604. var active = this._findActive( index )[ 0 ];
  1605. // trying to activate the already active panel
  1606. if ( active === this.active[ 0 ] ) {
  1607. return;
  1608. }
  1609. // trying to collapse, simulate a click on the currently active header
  1610. active = active || this.active[ 0 ];
  1611. this._eventHandler({
  1612. target: active,
  1613. currentTarget: active,
  1614. preventDefault: $.noop
  1615. });
  1616. },
  1617. _findActive: function( selector ) {
  1618. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  1619. },
  1620. _setupEvents: function( event ) {
  1621. var events = {};
  1622. if ( !event ) {
  1623. return;
  1624. }
  1625. $.each( event.split(" "), function( index, eventName ) {
  1626. events[ eventName ] = "_eventHandler";
  1627. });
  1628. this._on( this.headers, events );
  1629. },
  1630. _eventHandler: function( event ) {
  1631. var options = this.options,
  1632. active = this.active,
  1633. clicked = $( event.currentTarget ),
  1634. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  1635. collapsing = clickedIsActive && options.collapsible,
  1636. toShow = collapsing ? $() : clicked.next(),
  1637. toHide = active.next(),
  1638. eventData = {
  1639. oldHeader: active,
  1640. oldPanel: toHide,
  1641. newHeader: collapsing ? $() : clicked,
  1642. newPanel: toShow
  1643. };
  1644. event.preventDefault();
  1645. if (
  1646. // click on active header, but not collapsible
  1647. ( clickedIsActive && !options.collapsible ) ||
  1648. // allow canceling activation
  1649. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  1650. return;
  1651. }
  1652. options.active = collapsing ? false : this.headers.index( clicked );
  1653. // when the call to ._toggle() comes after the class changes
  1654. // it causes a very odd bug in IE 8 (see #6720)
  1655. this.active = clickedIsActive ? $() : clicked;
  1656. this._toggle( eventData );
  1657. // switch classes
  1658. // corner classes on the previously active header stay after the animation
  1659. active.removeClass( "ui-accordion-header-active ui-state-active" );
  1660. if ( options.icons ) {
  1661. active.children( ".ui-accordion-header-icon" )
  1662. .removeClass( options.icons.activeHeader )
  1663. .addClass( options.icons.header );
  1664. }
  1665. if ( !clickedIsActive ) {
  1666. clicked
  1667. .removeClass( "ui-corner-all" )
  1668. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
  1669. if ( options.icons ) {
  1670. clicked.children( ".ui-accordion-header-icon" )
  1671. .removeClass( options.icons.header )
  1672. .addClass( options.icons.activeHeader );
  1673. }
  1674. clicked
  1675. .next()
  1676. .addClass( "ui-accordion-content-active" );
  1677. }
  1678. },
  1679. _toggle: function( data ) {
  1680. var toShow = data.newPanel,
  1681. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  1682. // handle activating a panel during the animation for another activation
  1683. this.prevShow.add( this.prevHide ).stop( true, true );
  1684. this.prevShow = toShow;
  1685. this.prevHide = toHide;
  1686. if ( this.options.animate ) {
  1687. this._animate( toShow, toHide, data );
  1688. } else {
  1689. toHide.hide();
  1690. toShow.show();
  1691. this._toggleComplete( data );
  1692. }
  1693. toHide.attr({
  1694. "aria-expanded": "false",
  1695. "aria-hidden": "true"
  1696. });
  1697. toHide.prev().attr( "aria-selected", "false" );
  1698. // if we're switching panels, remove the old header from the tab order
  1699. // if we're opening from collapsed state, remove the previous header from the tab order
  1700. // if we're collapsing, then keep the collapsing header in the tab order
  1701. if ( toShow.length && toHide.length ) {
  1702. toHide.prev().attr( "tabIndex", -1 );
  1703. } else if ( toShow.length ) {
  1704. this.headers.filter(function() {
  1705. return $( this ).attr( "tabIndex" ) === 0;
  1706. })
  1707. .attr( "tabIndex", -1 );
  1708. }
  1709. toShow
  1710. .attr({
  1711. "aria-expanded": "true",
  1712. "aria-hidden": "false"
  1713. })
  1714. .prev()
  1715. .attr({
  1716. "aria-selected": "true",
  1717. tabIndex: 0
  1718. });
  1719. },
  1720. _animate: function( toShow, toHide, data ) {
  1721. var total, easing, duration,
  1722. that = this,
  1723. adjust = 0,
  1724. down = toShow.length &&
  1725. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  1726. animate = this.options.animate || {},
  1727. options = down && animate.down || animate,
  1728. complete = function() {
  1729. that._toggleComplete( data );
  1730. };
  1731. if ( typeof options === "number" ) {
  1732. duration = options;
  1733. }
  1734. if ( typeof options === "string" ) {
  1735. easing = options;
  1736. }
  1737. // fall back from options to animation in case of partial down settings
  1738. easing = easing || options.easing || animate.easing;
  1739. duration = duration || options.duration || animate.duration;
  1740. if ( !toHide.length ) {
  1741. return toShow.animate( showProps, duration, easing, complete );
  1742. }
  1743. if ( !toShow.length ) {
  1744. return toHide.animate( hideProps, duration, easing, complete );
  1745. }
  1746. total = toShow.show().outerHeight();
  1747. toHide.animate( hideProps, {
  1748. duration: duration,
  1749. easing: easing,
  1750. step: function( now, fx ) {
  1751. fx.now = Math.round( now );
  1752. }
  1753. });
  1754. toShow
  1755. .hide()
  1756. .animate( showProps, {
  1757. duration: duration,
  1758. easing: easing,
  1759. complete: complete,
  1760. step: function( now, fx ) {
  1761. fx.now = Math.round( now );
  1762. if ( fx.prop !== "height" ) {
  1763. adjust += fx.now;
  1764. } else if ( that.options.heightStyle !== "content" ) {
  1765. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  1766. adjust = 0;
  1767. }
  1768. }
  1769. });
  1770. },
  1771. _toggleComplete: function( data ) {
  1772. var toHide = data.oldPanel;
  1773. toHide
  1774. .removeClass( "ui-accordion-content-active" )
  1775. .prev()
  1776. .removeClass( "ui-corner-top" )
  1777. .addClass( "ui-corner-all" );
  1778. // Work around for rendering bug in IE (#5421)
  1779. if ( toHide.length ) {
  1780. toHide.parent()[0].className = toHide.parent()[0].className;
  1781. }
  1782. this._trigger( "activate", null, data );
  1783. }
  1784. });
  1785. // DEPRECATED
  1786. if ( $.uiBackCompat !== false ) {
  1787. // navigation options
  1788. (function( $, prototype ) {
  1789. $.extend( prototype.options, {
  1790. navigation: false,
  1791. navigationFilter: function() {
  1792. return this.href.toLowerCase() === location.href.toLowerCase();
  1793. }
  1794. });
  1795. var _create = prototype._create;
  1796. prototype._create = function() {
  1797. if ( this.options.navigation ) {
  1798. var that = this,
  1799. headers = this.element.find( this.options.header ),
  1800. content = headers.next(),
  1801. current = headers.add( content )
  1802. .find( "a" )
  1803. .filter( this.options.navigationFilter )
  1804. [ 0 ];
  1805. if ( current ) {
  1806. headers.add( content ).each( function( index ) {
  1807. if ( $.contains( this, current ) ) {
  1808. that.options.active = Math.floor( index / 2 );
  1809. return false;
  1810. }
  1811. });
  1812. }
  1813. }
  1814. _create.call( this );
  1815. };
  1816. }( jQuery, jQuery.ui.accordion.prototype ) );
  1817. // height options
  1818. (function( $, prototype ) {
  1819. $.extend( prototype.options, {
  1820. heightStyle: null, // remove default so we fall back to old values
  1821. autoHeight: true, // use heightStyle: "auto"
  1822. clearStyle: false, // use heightStyle: "content"
  1823. fillSpace: false // use heightStyle: "fill"
  1824. });
  1825. var _create = prototype._create,
  1826. _setOption = prototype._setOption;
  1827. $.extend( prototype, {
  1828. _create: function() {
  1829. this.options.heightStyle = this.options.heightStyle ||
  1830. this._mergeHeightStyle();
  1831. _create.call( this );
  1832. },
  1833. _setOption: function( key, value ) {
  1834. if ( key === "autoHeight" || key === "clearStyle" || key === "fillSpace" ) {
  1835. this.options.heightStyle = this._mergeHeightStyle();
  1836. }
  1837. _setOption.apply( this, arguments );
  1838. },
  1839. _mergeHeightStyle: function() {
  1840. var options = this.options;
  1841. if ( options.fillSpace ) {
  1842. return "fill";
  1843. }
  1844. if ( options.clearStyle ) {
  1845. return "content";
  1846. }
  1847. if ( options.autoHeight ) {
  1848. return "auto";
  1849. }
  1850. }
  1851. });
  1852. }( jQuery, jQuery.ui.accordion.prototype ) );
  1853. // icon options
  1854. (function( $, prototype ) {
  1855. $.extend( prototype.options.icons, {
  1856. activeHeader: null, // remove default so we fall back to old values
  1857. headerSelected: "ui-icon-triangle-1-s"
  1858. });
  1859. var _createIcons = prototype._createIcons;
  1860. prototype._createIcons = function() {
  1861. if ( this.options.icons ) {
  1862. this.options.icons.activeHeader = this.options.icons.activeHeader ||
  1863. this.options.icons.headerSelected;
  1864. }
  1865. _createIcons.call( this );
  1866. };
  1867. }( jQuery, jQuery.ui.accordion.prototype ) );
  1868. // expanded active option, activate method
  1869. (function( $, prototype ) {
  1870. prototype.activate = prototype._activate;
  1871. var _findActive = prototype._findActive;
  1872. prototype._findActive = function( index ) {
  1873. if ( index === -1 ) {
  1874. index = false;
  1875. }
  1876. if ( index && typeof index !== "number" ) {
  1877. index = this.headers.index( this.headers.filter( index ) );
  1878. if ( index === -1 ) {
  1879. index = false;
  1880. }
  1881. }
  1882. return _findActive.call( this, index );
  1883. };
  1884. }( jQuery, jQuery.ui.accordion.prototype ) );
  1885. // resize method
  1886. jQuery.ui.accordion.prototype.resize = jQuery.ui.accordion.prototype.refresh;
  1887. // change events
  1888. (function( $, prototype ) {
  1889. $.extend( prototype.options, {
  1890. change: null,
  1891. changestart: null
  1892. });
  1893. var _trigger = prototype._trigger;
  1894. prototype._trigger = function( type, event, data ) {
  1895. var ret = _trigger.apply( this, arguments );
  1896. if ( !ret ) {
  1897. return false;
  1898. }
  1899. if ( type === "beforeActivate" ) {
  1900. ret = _trigger.call( this, "changestart", event, {
  1901. oldHeader: data.oldHeader,
  1902. oldContent: data.oldPanel,
  1903. newHeader: data.newHeader,
  1904. newContent: data.newPanel
  1905. });
  1906. } else if ( type === "activate" ) {
  1907. ret = _trigger.call( this, "change", event, {
  1908. oldHeader: data.oldHeader,
  1909. oldContent: data.oldPanel,
  1910. newHeader: data.newHeader,
  1911. newContent: data.newPanel
  1912. });
  1913. }
  1914. return ret;
  1915. };
  1916. }( jQuery, jQuery.ui.accordion.prototype ) );
  1917. // animated option
  1918. // NOTE: this only provides support for "slide", "bounceslide", and easings
  1919. // not the full $.ui.accordion.animations API
  1920. (function( $, prototype ) {
  1921. $.extend( prototype.options, {
  1922. animate: null,
  1923. animated: "slide"
  1924. });
  1925. var _create = prototype._create;
  1926. prototype._create = function() {
  1927. var options = this.options;
  1928. if ( options.animate === null ) {
  1929. if ( !options.animated ) {
  1930. options.animate = false;
  1931. } else if ( options.animated === "slide" ) {
  1932. options.animate = 300;
  1933. } else if ( options.animated === "bounceslide" ) {
  1934. options.animate = {
  1935. duration: 200,
  1936. down: {
  1937. easing: "easeOutBounce",
  1938. duration: 1000
  1939. }
  1940. };
  1941. } else {
  1942. options.animate = options.animated;
  1943. }
  1944. }
  1945. _create.call( this );
  1946. };
  1947. }( jQuery, jQuery.ui.accordion.prototype ) );
  1948. }
  1949. })( jQuery );
  1950. (function( $, undefined ) {
  1951. // used to prevent race conditions with remote data sources
  1952. var requestIndex = 0;
  1953. $.widget( "ui.autocomplete", {
  1954. version: "1.9.0",
  1955. defaultElement: "<input>",
  1956. options: {
  1957. appendTo: "body",
  1958. autoFocus: false,
  1959. delay: 300,
  1960. minLength: 1,
  1961. position: {
  1962. my: "left top",
  1963. at: "left bottom",
  1964. collision: "none"
  1965. },
  1966. source: null,
  1967. // callbacks
  1968. change: null,
  1969. close: null,
  1970. focus: null,
  1971. open: null,
  1972. response: null,
  1973. search: null,
  1974. select: null
  1975. },
  1976. pending: 0,
  1977. _create: function() {
  1978. // Some browsers only repeat keydown events, not keypress events,
  1979. // so we use the suppressKeyPress flag to determine if we've already
  1980. // handled the keydown event. #7269
  1981. // Unfortunately the code for & in keypress is the same as the up arrow,
  1982. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  1983. // events when we know the keydown event was used to modify the
  1984. // search term. #7799
  1985. var suppressKeyPress, suppressKeyPressRepeat, suppressInput;
  1986. this.isMultiLine = this._isMultiLine();
  1987. this.valueMethod = this.element[ this.element.is( "input,textarea" ) ? "val" : "text" ];
  1988. this.isNewMenu = true;
  1989. this.element
  1990. .addClass( "ui-autocomplete-input" )
  1991. .attr( "autocomplete", "off" );
  1992. this._on({
  1993. keydown: function( event ) {
  1994. if ( this.element.prop( "readOnly" ) ) {
  1995. suppressKeyPress = true;
  1996. suppressInput = true;
  1997. suppressKeyPressRepeat = true;
  1998. return;
  1999. }
  2000. suppressKeyPress = false;
  2001. suppressInput = false;
  2002. suppressKeyPressRepeat = false;
  2003. var keyCode = $.ui.keyCode;
  2004. switch( event.keyCode ) {
  2005. case keyCode.PAGE_UP:
  2006. suppressKeyPress = true;
  2007. this._move( "previousPage", event );
  2008. break;
  2009. case keyCode.PAGE_DOWN:
  2010. suppressKeyPress = true;
  2011. this._move( "nextPage", event );
  2012. break;
  2013. case keyCode.UP:
  2014. suppressKeyPress = true;
  2015. this._keyEvent( "previous", event );
  2016. break;
  2017. case keyCode.DOWN:
  2018. suppressKeyPress = true;
  2019. this._keyEvent( "next", event );
  2020. break;
  2021. case keyCode.ENTER:
  2022. case keyCode.NUMPAD_ENTER:
  2023. // when menu is open and has focus
  2024. if ( this.menu.active ) {
  2025. // #6055 - Opera still allows the keypress to occur
  2026. // which causes forms to submit
  2027. suppressKeyPress = true;
  2028. event.preventDefault();
  2029. this.menu.select( event );
  2030. }
  2031. break;
  2032. case keyCode.TAB:
  2033. if ( this.menu.active ) {
  2034. this.menu.select( event );
  2035. }
  2036. break;
  2037. case keyCode.ESCAPE:
  2038. if ( this.menu.element.is( ":visible" ) ) {
  2039. this._value( this.term );
  2040. this.close( event );
  2041. // Different browsers have different default behavior for escape
  2042. // Single press can mean undo or clear
  2043. // Double press in IE means clear the whole form
  2044. event.preventDefault();
  2045. }
  2046. break;
  2047. default:
  2048. suppressKeyPressRepeat = true;
  2049. // search timeout should be triggered before the input value is changed
  2050. this._searchTimeout( event );
  2051. break;
  2052. }
  2053. },
  2054. keypress: function( event ) {
  2055. if ( suppressKeyPress ) {
  2056. suppressKeyPress = false;
  2057. event.preventDefault();
  2058. return;
  2059. }
  2060. if ( suppressKeyPressRepeat ) {
  2061. return;
  2062. }
  2063. // replicate some key handlers to allow them to repeat in Firefox and Opera
  2064. var keyCode = $.ui.keyCode;
  2065. switch( event.keyCode ) {
  2066. case keyCode.PAGE_UP:
  2067. this._move( "previousPage", event );
  2068. break;
  2069. case keyCode.PAGE_DOWN:
  2070. this._move( "nextPage", event );
  2071. break;
  2072. case keyCode.UP:
  2073. this._keyEvent( "previous", event );
  2074. break;
  2075. case keyCode.DOWN:
  2076. this._keyEvent( "next", event );
  2077. break;
  2078. }
  2079. },
  2080. input: function( event ) {
  2081. if ( suppressInput ) {
  2082. suppressInput = false;
  2083. event.preventDefault();
  2084. return;
  2085. }
  2086. this._searchTimeout( event );
  2087. },
  2088. focus: function() {
  2089. this.selectedItem = null;
  2090. this.previous = this._value();
  2091. },
  2092. blur: function( event ) {
  2093. if ( this.cancelBlur ) {
  2094. delete this.cancelBlur;
  2095. return;
  2096. }
  2097. clearTimeout( this.searching );
  2098. this.close( event );
  2099. this._change( event );
  2100. }
  2101. });
  2102. this._initSource();
  2103. this.menu = $( "<ul>" )
  2104. .addClass( "ui-autocomplete" )
  2105. .appendTo( this.document.find( this.options.appendTo || "body" )[ 0 ] )
  2106. .menu({
  2107. // custom key handling for now
  2108. input: $(),
  2109. // disable ARIA support, the live region takes care of that
  2110. role: null
  2111. })
  2112. .zIndex( this.element.zIndex() + 1 )
  2113. .hide()
  2114. .data( "menu" );
  2115. this._on( this.menu.element, {
  2116. mousedown: function( event ) {
  2117. // prevent moving focus out of the text field
  2118. event.preventDefault();
  2119. // IE doesn't prevent moving focus even with event.preventDefault()
  2120. // so we set a flag to know when we should ignore the blur event
  2121. this.cancelBlur = true;
  2122. this._delay(function() {
  2123. delete this.cancelBlur;
  2124. });
  2125. // clicking on the scrollbar causes focus to shift to the body
  2126. // but we can't detect a mouseup or a click immediately afterward
  2127. // so we have to track the next mousedown and close the menu if
  2128. // the user clicks somewhere outside of the autocomplete
  2129. var menuElement = this.menu.element[ 0 ];
  2130. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  2131. this._delay(function() {
  2132. var that = this;
  2133. this.document.one( "mousedown", function( event ) {
  2134. if ( event.target !== that.element[ 0 ] &&
  2135. event.target !== menuElement &&
  2136. !$.contains( menuElement, event.target ) ) {
  2137. that.close();
  2138. }
  2139. });
  2140. });
  2141. }
  2142. },
  2143. menufocus: function( event, ui ) {
  2144. // #7024 - Prevent accidental activation of menu items in Firefox
  2145. if ( this.isNewMenu ) {
  2146. this.isNewMenu = false;
  2147. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  2148. this.menu.blur();
  2149. this.document.one( "mousemove", function() {
  2150. $( event.target ).trigger( event.originalEvent );
  2151. });
  2152. return;
  2153. }
  2154. }
  2155. // back compat for _renderItem using item.autocomplete, via #7810
  2156. // TODO remove the fallback, see #8156
  2157. var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" );
  2158. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  2159. // use value to match what will end up in the input, if it was a key event
  2160. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  2161. this._value( item.value );
  2162. }
  2163. } else {
  2164. // Normally the input is populated with the item's value as the
  2165. // menu is navigated, causing screen readers to notice a change and
  2166. // announce the item. Since the focus event was canceled, this doesn't
  2167. // happen, so we update the live region so that screen readers can
  2168. // still notice the change and announce it.
  2169. this.liveRegion.text( item.value );
  2170. }
  2171. },
  2172. menuselect: function( event, ui ) {
  2173. // back compat for _renderItem using item.autocomplete, via #7810
  2174. // TODO remove the fallback, see #8156
  2175. var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" ),
  2176. previous = this.previous;
  2177. // only trigger when focus was lost (click on menu)
  2178. if ( this.element[0] !== this.document[0].activeElement ) {
  2179. this.element.focus();
  2180. this.previous = previous;
  2181. // #6109 - IE triggers two focus events and the second
  2182. // is asynchronous, so we need to reset the previous
  2183. // term synchronously and asynchronously :-(
  2184. this._delay(function() {
  2185. this.previous = previous;
  2186. this.selectedItem = item;
  2187. });
  2188. }
  2189. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  2190. this._value( item.value );
  2191. }
  2192. // reset the term after the select event
  2193. // this allows custom select handling to work properly
  2194. this.term = this._value();
  2195. this.close( event );
  2196. this.selectedItem = item;
  2197. }
  2198. });
  2199. this.liveRegion = $( "<span>", {
  2200. role: "status",
  2201. "aria-live": "polite"
  2202. })
  2203. .addClass( "ui-helper-hidden-accessible" )
  2204. .insertAfter( this.element );
  2205. if ( $.fn.bgiframe ) {
  2206. this.menu.element.bgiframe();
  2207. }
  2208. // turning off autocomplete prevents the browser from remembering the
  2209. // value when navigating through history, so we re-enable autocomplete
  2210. // if the page is unloaded before the widget is destroyed. #7790
  2211. this._on( this.window, {
  2212. beforeunload: function() {
  2213. this.element.removeAttr( "autocomplete" );
  2214. }
  2215. });
  2216. },
  2217. _destroy: function() {
  2218. clearTimeout( this.searching );
  2219. this.element
  2220. .removeClass( "ui-autocomplete-input" )
  2221. .removeAttr( "autocomplete" );
  2222. this.menu.element.remove();
  2223. this.liveRegion.remove();
  2224. },
  2225. _setOption: function( key, value ) {
  2226. this._super( key, value );
  2227. if ( key === "source" ) {
  2228. this._initSource();
  2229. }
  2230. if ( key === "appendTo" ) {
  2231. this.menu.element.appendTo( this.document.find( value || "body" )[0] );
  2232. }
  2233. if ( key === "disabled" && value && this.xhr ) {
  2234. this.xhr.abort();
  2235. }
  2236. },
  2237. _isMultiLine: function() {
  2238. // Textareas are always multi-line
  2239. if ( this.element.is( "textarea" ) ) {
  2240. return true;
  2241. }
  2242. // Inputs are always single-line, even if inside a contentEditable element
  2243. // IE also treats inputs as contentEditable
  2244. if ( this.element.is( "input" ) ) {
  2245. return false;
  2246. }
  2247. // All other element types are determined by whether or not they're contentEditable
  2248. return this.element.prop( "isContentEditable" );
  2249. },
  2250. _initSource: function() {
  2251. var array, url,
  2252. that = this;
  2253. if ( $.isArray(this.options.source) ) {
  2254. array = this.options.source;
  2255. this.source = function( request, response ) {
  2256. response( $.ui.autocomplete.filter( array, request.term ) );
  2257. };
  2258. } else if ( typeof this.options.source === "string" ) {
  2259. url = this.options.source;
  2260. this.source = function( request, response ) {
  2261. if ( that.xhr ) {
  2262. that.xhr.abort();
  2263. }
  2264. that.xhr = $.ajax({
  2265. url: url,
  2266. data: request,
  2267. dataType: "json",
  2268. success: function( data, status ) {
  2269. response( data );
  2270. },
  2271. error: function() {
  2272. response( [] );
  2273. }
  2274. });
  2275. };
  2276. } else {
  2277. this.source = this.options.source;
  2278. }
  2279. },
  2280. _searchTimeout: function( event ) {
  2281. clearTimeout( this.searching );
  2282. this.searching = this._delay(function() {
  2283. // only search if the value has changed
  2284. if ( this.term !== this._value() ) {
  2285. this.selectedItem = null;
  2286. this.search( null, event );
  2287. }
  2288. }, this.options.delay );
  2289. },
  2290. search: function( value, event ) {
  2291. value = value != null ? value : this._value();
  2292. // always save the actual value, not the one passed as an argument
  2293. this.term = this._value();
  2294. if ( value.length < this.options.minLength ) {
  2295. return this.close( event );
  2296. }
  2297. if ( this._trigger( "search", event ) === false ) {
  2298. return;
  2299. }
  2300. return this._search( value );
  2301. },
  2302. _search: function( value ) {
  2303. this.pending++;
  2304. this.element.addClass( "ui-autocomplete-loading" );
  2305. this.cancelSearch = false;
  2306. this.source( { term: value }, this._response() );
  2307. },
  2308. _response: function() {
  2309. var that = this,
  2310. index = ++requestIndex;
  2311. return function( content ) {
  2312. if ( index === requestIndex ) {
  2313. that.__response( content );
  2314. }
  2315. that.pending--;
  2316. if ( !that.pending ) {
  2317. that.element.removeClass( "ui-autocomplete-loading" );
  2318. }
  2319. };
  2320. },
  2321. __response: function( content ) {
  2322. if ( content ) {
  2323. content = this._normalize( content );
  2324. }
  2325. this._trigger( "response", null, { content: content } );
  2326. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  2327. this._suggest( content );
  2328. this._trigger( "open" );
  2329. } else {
  2330. // use ._close() instead of .close() so we don't cancel future searches
  2331. this._close();
  2332. }
  2333. },
  2334. close: function( event ) {
  2335. this.cancelSearch = true;
  2336. this._close( event );
  2337. },
  2338. _close: function( event ) {
  2339. if ( this.menu.element.is( ":visible" ) ) {
  2340. this.menu.element.hide();
  2341. this.menu.blur();
  2342. this.isNewMenu = true;
  2343. this._trigger( "close", event );
  2344. }
  2345. },
  2346. _change: function( event ) {
  2347. if ( this.previous !== this._value() ) {
  2348. this._trigger( "change", event, { item: this.selectedItem } );
  2349. }
  2350. },
  2351. _normalize: function( items ) {
  2352. // assume all items have the right format when the first item is complete
  2353. if ( items.length && items[0].label && items[0].value ) {
  2354. return items;
  2355. }
  2356. return $.map( items, function( item ) {
  2357. if ( typeof item === "string" ) {
  2358. return {
  2359. label: item,
  2360. value: item
  2361. };
  2362. }
  2363. return $.extend({
  2364. label: item.label || item.value,
  2365. value: item.value || item.label
  2366. }, item );
  2367. });
  2368. },
  2369. _suggest: function( items ) {
  2370. var ul = this.menu.element
  2371. .empty()
  2372. .zIndex( this.element.zIndex() + 1 );
  2373. this._renderMenu( ul, items );
  2374. this.menu.refresh();
  2375. // size and position menu
  2376. ul.show();
  2377. this._resizeMenu();
  2378. ul.position( $.extend({
  2379. of: this.element
  2380. }, this.options.position ));
  2381. if ( this.options.autoFocus ) {
  2382. this.menu.next();
  2383. }
  2384. },
  2385. _resizeMenu: function() {
  2386. var ul = this.menu.element;
  2387. ul.outerWidth( Math.max(
  2388. // Firefox wraps long text (possibly a rounding bug)
  2389. // so we add 1px to avoid the wrapping (#7513)
  2390. ul.width( "" ).outerWidth() + 1,
  2391. this.element.outerWidth()
  2392. ) );
  2393. },
  2394. _renderMenu: function( ul, items ) {
  2395. var that = this;
  2396. $.each( items, function( index, item ) {
  2397. that._renderItemData( ul, item );
  2398. });
  2399. },
  2400. _renderItemData: function( ul, item ) {
  2401. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  2402. },
  2403. _renderItem: function( ul, item ) {
  2404. return $( "<li>" )
  2405. .append( $( "<a>" ).text( item.label ) )
  2406. .appendTo( ul );
  2407. },
  2408. _move: function( direction, event ) {
  2409. if ( !this.menu.element.is( ":visible" ) ) {
  2410. this.search( null, event );
  2411. return;
  2412. }
  2413. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  2414. this.menu.isLastItem() && /^next/.test( direction ) ) {
  2415. this._value( this.term );
  2416. this.menu.blur();
  2417. return;
  2418. }
  2419. this.menu[ direction ]( event );
  2420. },
  2421. widget: function() {
  2422. return this.menu.element;
  2423. },
  2424. _value: function( value ) {
  2425. return this.valueMethod.apply( this.element, arguments );
  2426. },
  2427. _keyEvent: function( keyEvent, event ) {
  2428. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  2429. this._move( keyEvent, event );
  2430. // prevents moving cursor to beginning/end of the text field in some browsers
  2431. event.preventDefault();
  2432. }
  2433. }
  2434. });
  2435. $.extend( $.ui.autocomplete, {
  2436. escapeRegex: function( value ) {
  2437. return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
  2438. },
  2439. filter: function(array, term) {
  2440. var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
  2441. return $.grep( array, function(value) {
  2442. return matcher.test( value.label || value.value || value );
  2443. });
  2444. }
  2445. });
  2446. // live region extension, adding a `messages` option
  2447. // NOTE: This is an experimental API. We are still investigating
  2448. // a full solution for string manipulation and internationalization.
  2449. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  2450. options: {
  2451. messages: {
  2452. noResults: "No search results.",
  2453. results: function( amount ) {
  2454. return amount + ( amount > 1 ? " results are" : " result is" ) +
  2455. " available, use up and down arrow keys to navigate.";
  2456. }
  2457. }
  2458. },
  2459. __response: function( content ) {
  2460. var message;
  2461. this._superApply( arguments );
  2462. if ( this.options.disabled || this.cancelSearch ) {
  2463. return;
  2464. }
  2465. if ( content && content.length ) {
  2466. message = this.options.messages.results( content.length );
  2467. } else {
  2468. message = this.options.messages.noResults;
  2469. }
  2470. this.liveRegion.text( message );
  2471. }
  2472. });
  2473. }( jQuery ));
  2474. (function( $, undefined ) {
  2475. var lastActive, startXPos, startYPos, clickDragged,
  2476. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  2477. stateClasses = "ui-state-hover ui-state-active ",
  2478. 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",
  2479. formResetHandler = function() {
  2480. var buttons = $( this ).find( ":ui-button" );
  2481. setTimeout(function() {
  2482. buttons.button( "refresh" );
  2483. }, 1 );
  2484. },
  2485. radioGroup = function( radio ) {
  2486. var name = radio.name,
  2487. form = radio.form,
  2488. radios = $( [] );
  2489. if ( name ) {
  2490. if ( form ) {
  2491. radios = $( form ).find( "[name='" + name + "']" );
  2492. } else {
  2493. radios = $( "[name='" + name + "']", radio.ownerDocument )
  2494. .filter(function() {
  2495. return !this.form;
  2496. });
  2497. }
  2498. }
  2499. return radios;
  2500. };
  2501. $.widget( "ui.button", {
  2502. version: "1.9.0",
  2503. defaultElement: "<button>",
  2504. options: {
  2505. disabled: null,
  2506. text: true,
  2507. label: null,
  2508. icons: {
  2509. primary: null,
  2510. secondary: null
  2511. }
  2512. },
  2513. _create: function() {
  2514. this.element.closest( "form" )
  2515. .unbind( "reset" + this.eventNamespace )
  2516. .bind( "reset" + this.eventNamespace, formResetHandler );
  2517. if ( typeof this.options.disabled !== "boolean" ) {
  2518. this.options.disabled = !!this.element.prop( "disabled" );
  2519. } else {
  2520. this.element.prop( "disabled", this.options.disabled );
  2521. }
  2522. this._determineButtonType();
  2523. this.hasTitle = !!this.buttonElement.attr( "title" );
  2524. var that = this,
  2525. options = this.options,
  2526. toggleButton = this.type === "checkbox" || this.type === "radio",
  2527. hoverClass = "ui-state-hover" + ( !toggleButton ? " ui-state-active" : "" ),
  2528. focusClass = "ui-state-focus";
  2529. if ( options.label === null ) {
  2530. options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
  2531. }
  2532. this.buttonElement
  2533. .addClass( baseClasses )
  2534. .attr( "role", "button" )
  2535. .bind( "mouseenter" + this.eventNamespace, function() {
  2536. if ( options.disabled ) {
  2537. return;
  2538. }
  2539. $( this ).addClass( "ui-state-hover" );
  2540. if ( this === lastActive ) {
  2541. $( this ).addClass( "ui-state-active" );
  2542. }
  2543. })
  2544. .bind( "mouseleave" + this.eventNamespace, function() {
  2545. if ( options.disabled ) {
  2546. return;
  2547. }
  2548. $( this ).removeClass( hoverClass );
  2549. })
  2550. .bind( "click" + this.eventNamespace, function( event ) {
  2551. if ( options.disabled ) {
  2552. event.preventDefault();
  2553. event.stopImmediatePropagation();
  2554. }
  2555. });
  2556. this.element
  2557. .bind( "focus" + this.eventNamespace, function() {
  2558. // no need to check disabled, focus won't be triggered anyway
  2559. that.buttonElement.addClass( focusClass );
  2560. })
  2561. .bind( "blur" + this.eventNamespace, function() {
  2562. that.buttonElement.removeClass( focusClass );
  2563. });
  2564. if ( toggleButton ) {
  2565. this.element.bind( "change" + this.eventNamespace, function() {
  2566. if ( clickDragged ) {
  2567. return;
  2568. }
  2569. that.refresh();
  2570. });
  2571. // if mouse moves between mousedown and mouseup (drag) set clickDragged flag
  2572. // prevents issue where button state changes but checkbox/radio checked state
  2573. // does not in Firefox (see ticket #6970)
  2574. this.buttonElement
  2575. .bind( "mousedown" + this.eventNamespace, function( event ) {
  2576. if ( options.disabled ) {
  2577. return;
  2578. }
  2579. clickDragged = false;
  2580. startXPos = event.pageX;
  2581. startYPos = event.pageY;
  2582. })
  2583. .bind( "mouseup" + this.eventNamespace, function( event ) {
  2584. if ( options.disabled ) {
  2585. return;
  2586. }
  2587. if ( startXPos !== event.pageX || startYPos !== event.pageY ) {
  2588. clickDragged = true;
  2589. }
  2590. });
  2591. }
  2592. if ( this.type === "checkbox" ) {
  2593. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  2594. if ( options.disabled || clickDragged ) {
  2595. return false;
  2596. }
  2597. $( this ).toggleClass( "ui-state-active" );
  2598. that.buttonElement.attr( "aria-pressed", that.element[0].checked );
  2599. });
  2600. } else if ( this.type === "radio" ) {
  2601. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  2602. if ( options.disabled || clickDragged ) {
  2603. return false;
  2604. }
  2605. $( this ).addClass( "ui-state-active" );
  2606. that.buttonElement.attr( "aria-pressed", "true" );
  2607. var radio = that.element[ 0 ];
  2608. radioGroup( radio )
  2609. .not( radio )
  2610. .map(function() {
  2611. return $( this ).button( "widget" )[ 0 ];
  2612. })
  2613. .removeClass( "ui-state-active" )
  2614. .attr( "aria-pressed", "false" );
  2615. });
  2616. } else {
  2617. this.buttonElement
  2618. .bind( "mousedown" + this.eventNamespace, function() {
  2619. if ( options.disabled ) {
  2620. return false;
  2621. }
  2622. $( this ).addClass( "ui-state-active" );
  2623. lastActive = this;
  2624. that.document.one( "mouseup", function() {
  2625. lastActive = null;
  2626. });
  2627. })
  2628. .bind( "mouseup" + this.eventNamespace, function() {
  2629. if ( options.disabled ) {
  2630. return false;
  2631. }
  2632. $( this ).removeClass( "ui-state-active" );
  2633. })
  2634. .bind( "keydown" + this.eventNamespace, function(event) {
  2635. if ( options.disabled ) {
  2636. return false;
  2637. }
  2638. if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
  2639. $( this ).addClass( "ui-state-active" );
  2640. }
  2641. })
  2642. .bind( "keyup" + this.eventNamespace, function() {
  2643. $( this ).removeClass( "ui-state-active" );
  2644. });
  2645. if ( this.buttonElement.is("a") ) {
  2646. this.buttonElement.keyup(function(event) {
  2647. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  2648. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  2649. $( this ).click();
  2650. }
  2651. });
  2652. }
  2653. }
  2654. // TODO: pull out $.Widget's handling for the disabled option into
  2655. // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
  2656. // be overridden by individual plugins
  2657. this._setOption( "disabled", options.disabled );
  2658. this._resetButton();
  2659. },
  2660. _determineButtonType: function() {
  2661. var ancestor, labelSelector, checked;
  2662. if ( this.element.is("[type=checkbox]") ) {
  2663. this.type = "checkbox";
  2664. } else if ( this.element.is("[type=radio]") ) {
  2665. this.type = "radio";
  2666. } else if ( this.element.is("input") ) {
  2667. this.type = "input";
  2668. } else {
  2669. this.type = "button";
  2670. }
  2671. if ( this.type === "checkbox" || this.type === "radio" ) {
  2672. // we don't search against the document in case the element
  2673. // is disconnected from the DOM
  2674. ancestor = this.element.parents().last();
  2675. labelSelector = "label[for='" + this.element.attr("id") + "']";
  2676. this.buttonElement = ancestor.find( labelSelector );
  2677. if ( !this.buttonElement.length ) {
  2678. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  2679. this.buttonElement = ancestor.filter( labelSelector );
  2680. if ( !this.buttonElement.length ) {
  2681. this.buttonElement = ancestor.find( labelSelector );
  2682. }
  2683. }
  2684. this.element.addClass( "ui-helper-hidden-accessible" );
  2685. checked = this.element.is( ":checked" );
  2686. if ( checked ) {
  2687. this.buttonElement.addClass( "ui-state-active" );
  2688. }
  2689. this.buttonElement.prop( "aria-pressed", checked );
  2690. } else {
  2691. this.buttonElement = this.element;
  2692. }
  2693. },
  2694. widget: function() {
  2695. return this.buttonElement;
  2696. },
  2697. _destroy: function() {
  2698. this.element
  2699. .removeClass( "ui-helper-hidden-accessible" );
  2700. this.buttonElement
  2701. .removeClass( baseClasses + " " + stateClasses + " " + typeClasses )
  2702. .removeAttr( "role" )
  2703. .removeAttr( "aria-pressed" )
  2704. .html( this.buttonElement.find(".ui-button-text").html() );
  2705. if ( !this.hasTitle ) {
  2706. this.buttonElement.removeAttr( "title" );
  2707. }
  2708. },
  2709. _setOption: function( key, value ) {
  2710. this._super( key, value );
  2711. if ( key === "disabled" ) {
  2712. if ( value ) {
  2713. this.element.prop( "disabled", true );
  2714. } else {
  2715. this.element.prop( "disabled", false );
  2716. }
  2717. return;
  2718. }
  2719. this._resetButton();
  2720. },
  2721. refresh: function() {
  2722. var isDisabled = this.element.is( ":disabled" );
  2723. if ( isDisabled !== this.options.disabled ) {
  2724. this._setOption( "disabled", isDisabled );
  2725. }
  2726. if ( this.type === "radio" ) {
  2727. radioGroup( this.element[0] ).each(function() {
  2728. if ( $( this ).is( ":checked" ) ) {
  2729. $( this ).button( "widget" )
  2730. .addClass( "ui-state-active" )
  2731. .attr( "aria-pressed", "true" );
  2732. } else {
  2733. $( this ).button( "widget" )
  2734. .removeClass( "ui-state-active" )
  2735. .attr( "aria-pressed", "false" );
  2736. }
  2737. });
  2738. } else if ( this.type === "checkbox" ) {
  2739. if ( this.element.is( ":checked" ) ) {
  2740. this.buttonElement
  2741. .addClass( "ui-state-active" )
  2742. .attr( "aria-pressed", "true" );
  2743. } else {
  2744. this.buttonElement
  2745. .removeClass( "ui-state-active" )
  2746. .attr( "aria-pressed", "false" );
  2747. }
  2748. }
  2749. },
  2750. _resetButton: function() {
  2751. if ( this.type === "input" ) {
  2752. if ( this.options.label ) {
  2753. this.element.val( this.options.label );
  2754. }
  2755. return;
  2756. }
  2757. var buttonElement = this.buttonElement.removeClass( typeClasses ),
  2758. buttonText = $( "<span></span>", this.document[0] )
  2759. .addClass( "ui-button-text" )
  2760. .html( this.options.label )
  2761. .appendTo( buttonElement.empty() )
  2762. .text(),
  2763. icons = this.options.icons,
  2764. multipleIcons = icons.primary && icons.secondary,
  2765. buttonClasses = [];
  2766. if ( icons.primary || icons.secondary ) {
  2767. if ( this.options.text ) {
  2768. buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
  2769. }
  2770. if ( icons.primary ) {
  2771. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  2772. }
  2773. if ( icons.secondary ) {
  2774. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  2775. }
  2776. if ( !this.options.text ) {
  2777. buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
  2778. if ( !this.hasTitle ) {
  2779. buttonElement.attr( "title", $.trim( buttonText ) );
  2780. }
  2781. }
  2782. } else {
  2783. buttonClasses.push( "ui-button-text-only" );
  2784. }
  2785. buttonElement.addClass( buttonClasses.join( " " ) );
  2786. }
  2787. });
  2788. $.widget( "ui.buttonset", {
  2789. version: "1.9.0",
  2790. options: {
  2791. items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(button)"
  2792. },
  2793. _create: function() {
  2794. this.element.addClass( "ui-buttonset" );
  2795. },
  2796. _init: function() {
  2797. this.refresh();
  2798. },
  2799. _setOption: function( key, value ) {
  2800. if ( key === "disabled" ) {
  2801. this.buttons.button( "option", key, value );
  2802. }
  2803. this._super( key, value );
  2804. },
  2805. refresh: function() {
  2806. var rtl = this.element.css( "direction" ) === "rtl";
  2807. this.buttons = this.element.find( this.options.items )
  2808. .filter( ":ui-button" )
  2809. .button( "refresh" )
  2810. .end()
  2811. .not( ":ui-button" )
  2812. .button()
  2813. .end()
  2814. .map(function() {
  2815. return $( this ).button( "widget" )[ 0 ];
  2816. })
  2817. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  2818. .filter( ":first" )
  2819. .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
  2820. .end()
  2821. .filter( ":last" )
  2822. .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
  2823. .end()
  2824. .end();
  2825. },
  2826. _destroy: function() {
  2827. this.element.removeClass( "ui-buttonset" );
  2828. this.buttons
  2829. .map(function() {
  2830. return $( this ).button( "widget" )[ 0 ];
  2831. })
  2832. .removeClass( "ui-corner-left ui-corner-right" )
  2833. .end()
  2834. .button( "destroy" );
  2835. }
  2836. });
  2837. }( jQuery ) );
  2838. (function( $, undefined ) {
  2839. $.extend($.ui, { datepicker: { version: "1.9.0" } });
  2840. var PROP_NAME = 'datepicker';
  2841. var dpuuid = new Date().getTime();
  2842. var instActive;
  2843. /* Date picker manager.
  2844. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  2845. Settings for (groups of) date pickers are maintained in an instance object,
  2846. allowing multiple different settings on the same page. */
  2847. function Datepicker() {
  2848. this.debug = false; // Change this to true to start debugging
  2849. this._curInst = null; // The current instance in use
  2850. this._keyEvent = false; // If the last event was a key event
  2851. this._disabledInputs = []; // List of date picker inputs that have been disabled
  2852. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  2853. this._inDialog = false; // True if showing within a "dialog", false if not
  2854. this._mainDivId = 'ui-datepicker-div'; // The ID of the main datepicker division
  2855. this._inlineClass = 'ui-datepicker-inline'; // The name of the inline marker class
  2856. this._appendClass = 'ui-datepicker-append'; // The name of the append marker class
  2857. this._triggerClass = 'ui-datepicker-trigger'; // The name of the trigger marker class
  2858. this._dialogClass = 'ui-datepicker-dialog'; // The name of the dialog marker class
  2859. this._disableClass = 'ui-datepicker-disabled'; // The name of the disabled covering marker class
  2860. this._unselectableClass = 'ui-datepicker-unselectable'; // The name of the unselectable cell marker class
  2861. this._currentClass = 'ui-datepicker-current-day'; // The name of the current day marker class
  2862. this._dayOverClass = 'ui-datepicker-days-cell-over'; // The name of the day hover marker class
  2863. this.regional = []; // Available regional settings, indexed by language code
  2864. this.regional[''] = { // Default regional settings
  2865. closeText: 'Done', // Display text for close link
  2866. prevText: 'Prev', // Display text for previous month link
  2867. nextText: 'Next', // Display text for next month link
  2868. currentText: 'Today', // Display text for current month link
  2869. monthNames: ['January','February','March','April','May','June',
  2870. 'July','August','September','October','November','December'], // Names of months for drop-down and formatting
  2871. monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting
  2872. dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting
  2873. dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting
  2874. dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday
  2875. weekHeader: 'Wk', // Column header for week of the year
  2876. dateFormat: 'mm/dd/yy', // See format options on parseDate
  2877. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  2878. isRTL: false, // True if right-to-left language, false if left-to-right
  2879. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  2880. yearSuffix: '' // Additional text to append to the year in the month headers
  2881. };
  2882. this._defaults = { // Global defaults for all the date picker instances
  2883. showOn: 'focus', // 'focus' for popup on focus,
  2884. // 'button' for trigger button, or 'both' for either
  2885. showAnim: 'fadeIn', // Name of jQuery animation for popup
  2886. showOptions: {}, // Options for enhanced animations
  2887. defaultDate: null, // Used when field is blank: actual date,
  2888. // +/-number for offset from today, null for today
  2889. appendText: '', // Display text following the input box, e.g. showing the format
  2890. buttonText: '...', // Text for trigger button
  2891. buttonImage: '', // URL for trigger button image
  2892. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  2893. hideIfNoPrevNext: false, // True to hide next/previous month links
  2894. // if not applicable, false to just disable them
  2895. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  2896. gotoCurrent: false, // True if today link goes back to current selection instead
  2897. changeMonth: false, // True if month can be selected directly, false if only prev/next
  2898. changeYear: false, // True if year can be selected directly, false if only prev/next
  2899. yearRange: 'c-10:c+10', // Range of years to display in drop-down,
  2900. // either relative to today's year (-nn:+nn), relative to currently displayed year
  2901. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  2902. showOtherMonths: false, // True to show dates in other months, false to leave blank
  2903. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  2904. showWeek: false, // True to show week of the year, false to not show it
  2905. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  2906. // takes a Date and returns the number of the week for it
  2907. shortYearCutoff: '+10', // Short year values < this are in the current century,
  2908. // > this are in the previous century,
  2909. // string value starting with '+' for current year + value
  2910. minDate: null, // The earliest selectable date, or null for no limit
  2911. maxDate: null, // The latest selectable date, or null for no limit
  2912. duration: 'fast', // Duration of display/closure
  2913. beforeShowDay: null, // Function that takes a date and returns an array with
  2914. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or '',
  2915. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  2916. beforeShow: null, // Function that takes an input field and
  2917. // returns a set of custom settings for the date picker
  2918. onSelect: null, // Define a callback function when a date is selected
  2919. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  2920. onClose: null, // Define a callback function when the datepicker is closed
  2921. numberOfMonths: 1, // Number of months to show at a time
  2922. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  2923. stepMonths: 1, // Number of months to step back/forward
  2924. stepBigMonths: 12, // Number of months to step back/forward for the big links
  2925. altField: '', // Selector for an alternate field to store selected dates into
  2926. altFormat: '', // The date format to use for the alternate field
  2927. constrainInput: true, // The input is constrained by the current date format
  2928. showButtonPanel: false, // True to show button panel, false to not show it
  2929. autoSize: false, // True to size the input for the date format, false to leave as is
  2930. disabled: false // The initial disabled state
  2931. };
  2932. $.extend(this._defaults, this.regional['']);
  2933. this.dpDiv = bindHover($('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'));
  2934. }
  2935. $.extend(Datepicker.prototype, {
  2936. /* Class name added to elements to indicate already configured with a date picker. */
  2937. markerClassName: 'hasDatepicker',
  2938. //Keep track of the maximum number of rows displayed (see #7043)
  2939. maxRows: 4,
  2940. /* Debug logging (if enabled). */
  2941. log: function () {
  2942. if (this.debug)
  2943. console.log.apply('', arguments);
  2944. },
  2945. // TODO rename to "widget" when switching to widget factory
  2946. _widgetDatepicker: function() {
  2947. return this.dpDiv;
  2948. },
  2949. /* Override the default settings for all instances of the date picker.
  2950. @param settings object - the new settings to use as defaults (anonymous object)
  2951. @return the manager object */
  2952. setDefaults: function(settings) {
  2953. extendRemove(this._defaults, settings || {});
  2954. return this;
  2955. },
  2956. /* Attach the date picker to a jQuery selection.
  2957. @param target element - the target input field or division or span
  2958. @param settings object - the new settings to use for this date picker instance (anonymous) */
  2959. _attachDatepicker: function(target, settings) {
  2960. // check for settings on the control itself - in namespace 'date:'
  2961. var inlineSettings = null;
  2962. for (var attrName in this._defaults) {
  2963. var attrValue = target.getAttribute('date:' + attrName);
  2964. if (attrValue) {
  2965. inlineSettings = inlineSettings || {};
  2966. try {
  2967. inlineSettings[attrName] = eval(attrValue);
  2968. } catch (err) {
  2969. inlineSettings[attrName] = attrValue;
  2970. }
  2971. }
  2972. }
  2973. var nodeName = target.nodeName.toLowerCase();
  2974. var inline = (nodeName == 'div' || nodeName == 'span');
  2975. if (!target.id) {
  2976. this.uuid += 1;
  2977. target.id = 'dp' + this.uuid;
  2978. }
  2979. var inst = this._newInst($(target), inline);
  2980. inst.settings = $.extend({}, settings || {}, inlineSettings || {});
  2981. if (nodeName == 'input') {
  2982. this._connectDatepicker(target, inst);
  2983. } else if (inline) {
  2984. this._inlineDatepicker(target, inst);
  2985. }
  2986. },
  2987. /* Create a new instance object. */
  2988. _newInst: function(target, inline) {
  2989. var id = target[0].id.replace(/([^A-Za-z0-9_-])/g, '\\\\$1'); // escape jQuery meta chars
  2990. return {id: id, input: target, // associated target
  2991. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  2992. drawMonth: 0, drawYear: 0, // month being drawn
  2993. inline: inline, // is datepicker inline or not
  2994. dpDiv: (!inline ? this.dpDiv : // presentation div
  2995. bindHover($('<div class="' + this._inlineClass + ' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>')))};
  2996. },
  2997. /* Attach the date picker to an input field. */
  2998. _connectDatepicker: function(target, inst) {
  2999. var input = $(target);
  3000. inst.append = $([]);
  3001. inst.trigger = $([]);
  3002. if (input.hasClass(this.markerClassName))
  3003. return;
  3004. this._attachments(input, inst);
  3005. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  3006. keypress(this._doKeyPress).keyup(this._doKeyUp).
  3007. bind("setData.datepicker", function(event, key, value) {
  3008. inst.settings[key] = value;
  3009. }).bind("getData.datepicker", function(event, key) {
  3010. return this._get(inst, key);
  3011. });
  3012. this._autoSize(inst);
  3013. $.data(target, PROP_NAME, inst);
  3014. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  3015. if( inst.settings.disabled ) {
  3016. this._disableDatepicker( target );
  3017. }
  3018. },
  3019. /* Make attachments based on settings. */
  3020. _attachments: function(input, inst) {
  3021. var appendText = this._get(inst, 'appendText');
  3022. var isRTL = this._get(inst, 'isRTL');
  3023. if (inst.append)
  3024. inst.append.remove();
  3025. if (appendText) {
  3026. inst.append = $('<span class="' + this._appendClass + '">' + appendText + '</span>');
  3027. input[isRTL ? 'before' : 'after'](inst.append);
  3028. }
  3029. input.unbind('focus', this._showDatepicker);
  3030. if (inst.trigger)
  3031. inst.trigger.remove();
  3032. var showOn = this._get(inst, 'showOn');
  3033. if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field
  3034. input.focus(this._showDatepicker);
  3035. if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked
  3036. var buttonText = this._get(inst, 'buttonText');
  3037. var buttonImage = this._get(inst, 'buttonImage');
  3038. inst.trigger = $(this._get(inst, 'buttonImageOnly') ?
  3039. $('<img/>').addClass(this._triggerClass).
  3040. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  3041. $('<button type="button"></button>').addClass(this._triggerClass).
  3042. html(buttonImage == '' ? buttonText : $('<img/>').attr(
  3043. { src:buttonImage, alt:buttonText, title:buttonText })));
  3044. input[isRTL ? 'before' : 'after'](inst.trigger);
  3045. inst.trigger.click(function() {
  3046. if ($.datepicker._datepickerShowing && $.datepicker._lastInput == input[0])
  3047. $.datepicker._hideDatepicker();
  3048. else if ($.datepicker._datepickerShowing && $.datepicker._lastInput != input[0]) {
  3049. $.datepicker._hideDatepicker();
  3050. $.datepicker._showDatepicker(input[0]);
  3051. } else
  3052. $.datepicker._showDatepicker(input[0]);
  3053. return false;
  3054. });
  3055. }
  3056. },
  3057. /* Apply the maximum length for the date format. */
  3058. _autoSize: function(inst) {
  3059. if (this._get(inst, 'autoSize') && !inst.inline) {
  3060. var date = new Date(2009, 12 - 1, 20); // Ensure double digits
  3061. var dateFormat = this._get(inst, 'dateFormat');
  3062. if (dateFormat.match(/[DM]/)) {
  3063. var findMax = function(names) {
  3064. var max = 0;
  3065. var maxI = 0;
  3066. for (var i = 0; i < names.length; i++) {
  3067. if (names[i].length > max) {
  3068. max = names[i].length;
  3069. maxI = i;
  3070. }
  3071. }
  3072. return maxI;
  3073. };
  3074. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  3075. 'monthNames' : 'monthNamesShort'))));
  3076. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  3077. 'dayNames' : 'dayNamesShort'))) + 20 - date.getDay());
  3078. }
  3079. inst.input.attr('size', this._formatDate(inst, date).length);
  3080. }
  3081. },
  3082. /* Attach an inline date picker to a div. */
  3083. _inlineDatepicker: function(target, inst) {
  3084. var divSpan = $(target);
  3085. if (divSpan.hasClass(this.markerClassName))
  3086. return;
  3087. divSpan.addClass(this.markerClassName).append(inst.dpDiv).
  3088. bind("setData.datepicker", function(event, key, value){
  3089. inst.settings[key] = value;
  3090. }).bind("getData.datepicker", function(event, key){
  3091. return this._get(inst, key);
  3092. });
  3093. $.data(target, PROP_NAME, inst);
  3094. this._setDate(inst, this._getDefaultDate(inst), true);
  3095. this._updateDatepicker(inst);
  3096. this._updateAlternate(inst);
  3097. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  3098. if( inst.settings.disabled ) {
  3099. this._disableDatepicker( target );
  3100. }
  3101. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  3102. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  3103. inst.dpDiv.css( "display", "block" );
  3104. },
  3105. /* Pop-up the date picker in a "dialog" box.
  3106. @param input element - ignored
  3107. @param date string or Date - the initial date to display
  3108. @param onSelect function - the function to call when a date is selected
  3109. @param settings object - update the dialog date picker instance's settings (anonymous object)
  3110. @param pos int[2] - coordinates for the dialog's position within the screen or
  3111. event - with x/y coordinates or
  3112. leave empty for default (screen centre)
  3113. @return the manager object */
  3114. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  3115. var inst = this._dialogInst; // internal instance
  3116. if (!inst) {
  3117. this.uuid += 1;
  3118. var id = 'dp' + this.uuid;
  3119. this._dialogInput = $('<input type="text" id="' + id +
  3120. '" style="position: absolute; top: -100px; width: 0px;"/>');
  3121. this._dialogInput.keydown(this._doKeyDown);
  3122. $('body').append(this._dialogInput);
  3123. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  3124. inst.settings = {};
  3125. $.data(this._dialogInput[0], PROP_NAME, inst);
  3126. }
  3127. extendRemove(inst.settings, settings || {});
  3128. date = (date && date.constructor == Date ? this._formatDate(inst, date) : date);
  3129. this._dialogInput.val(date);
  3130. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  3131. if (!this._pos) {
  3132. var browserWidth = document.documentElement.clientWidth;
  3133. var browserHeight = document.documentElement.clientHeight;
  3134. var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  3135. var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  3136. this._pos = // should use actual width/height below
  3137. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  3138. }
  3139. // move input on screen for focus, but hidden behind dialog
  3140. this._dialogInput.css('left', (this._pos[0] + 20) + 'px').css('top', this._pos[1] + 'px');
  3141. inst.settings.onSelect = onSelect;
  3142. this._inDialog = true;
  3143. this.dpDiv.addClass(this._dialogClass);
  3144. this._showDatepicker(this._dialogInput[0]);
  3145. if ($.blockUI)
  3146. $.blockUI(this.dpDiv);
  3147. $.data(this._dialogInput[0], PROP_NAME, inst);
  3148. return this;
  3149. },
  3150. /* Detach a datepicker from its control.
  3151. @param target element - the target input field or division or span */
  3152. _destroyDatepicker: function(target) {
  3153. var $target = $(target);
  3154. var inst = $.data(target, PROP_NAME);
  3155. if (!$target.hasClass(this.markerClassName)) {
  3156. return;
  3157. }
  3158. var nodeName = target.nodeName.toLowerCase();
  3159. $.removeData(target, PROP_NAME);
  3160. if (nodeName == 'input') {
  3161. inst.append.remove();
  3162. inst.trigger.remove();
  3163. $target.removeClass(this.markerClassName).
  3164. unbind('focus', this._showDatepicker).
  3165. unbind('keydown', this._doKeyDown).
  3166. unbind('keypress', this._doKeyPress).
  3167. unbind('keyup', this._doKeyUp);
  3168. } else if (nodeName == 'div' || nodeName == 'span')
  3169. $target.removeClass(this.markerClassName).empty();
  3170. },
  3171. /* Enable the date picker to a jQuery selection.
  3172. @param target element - the target input field or division or span */
  3173. _enableDatepicker: function(target) {
  3174. var $target = $(target);
  3175. var inst = $.data(target, PROP_NAME);
  3176. if (!$target.hasClass(this.markerClassName)) {
  3177. return;
  3178. }
  3179. var nodeName = target.nodeName.toLowerCase();
  3180. if (nodeName == 'input') {
  3181. target.disabled = false;
  3182. inst.trigger.filter('button').
  3183. each(function() { this.disabled = false; }).end().
  3184. filter('img').css({opacity: '1.0', cursor: ''});
  3185. }
  3186. else if (nodeName == 'div' || nodeName == 'span') {
  3187. var inline = $target.children('.' + this._inlineClass);
  3188. inline.children().removeClass('ui-state-disabled');
  3189. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  3190. prop("disabled", false);
  3191. }
  3192. this._disabledInputs = $.map(this._disabledInputs,
  3193. function(value) { return (value == target ? null : value); }); // delete entry
  3194. },
  3195. /* Disable the date picker to a jQuery selection.
  3196. @param target element - the target input field or division or span */
  3197. _disableDatepicker: function(target) {
  3198. var $target = $(target);
  3199. var inst = $.data(target, PROP_NAME);
  3200. if (!$target.hasClass(this.markerClassName)) {
  3201. return;
  3202. }
  3203. var nodeName = target.nodeName.toLowerCase();
  3204. if (nodeName == 'input') {
  3205. target.disabled = true;
  3206. inst.trigger.filter('button').
  3207. each(function() { this.disabled = true; }).end().
  3208. filter('img').css({opacity: '0.5', cursor: 'default'});
  3209. }
  3210. else if (nodeName == 'div' || nodeName == 'span') {
  3211. var inline = $target.children('.' + this._inlineClass);
  3212. inline.children().addClass('ui-state-disabled');
  3213. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  3214. prop("disabled", true);
  3215. }
  3216. this._disabledInputs = $.map(this._disabledInputs,
  3217. function(value) { return (value == target ? null : value); }); // delete entry
  3218. this._disabledInputs[this._disabledInputs.length] = target;
  3219. },
  3220. /* Is the first field in a jQuery collection disabled as a datepicker?
  3221. @param target element - the target input field or division or span
  3222. @return boolean - true if disabled, false if enabled */
  3223. _isDisabledDatepicker: function(target) {
  3224. if (!target) {
  3225. return false;
  3226. }
  3227. for (var i = 0; i < this._disabledInputs.length; i++) {
  3228. if (this._disabledInputs[i] == target)
  3229. return true;
  3230. }
  3231. return false;
  3232. },
  3233. /* Retrieve the instance data for the target control.
  3234. @param target element - the target input field or division or span
  3235. @return object - the associated instance data
  3236. @throws error if a jQuery problem getting data */
  3237. _getInst: function(target) {
  3238. try {
  3239. return $.data(target, PROP_NAME);
  3240. }
  3241. catch (err) {
  3242. throw 'Missing instance data for this datepicker';
  3243. }
  3244. },
  3245. /* Update or retrieve the settings for a date picker attached to an input field or division.
  3246. @param target element - the target input field or division or span
  3247. @param name object - the new settings to update or
  3248. string - the name of the setting to change or retrieve,
  3249. when retrieving also 'all' for all instance settings or
  3250. 'defaults' for all global defaults
  3251. @param value any - the new value for the setting
  3252. (omit if above is an object or to retrieve a value) */
  3253. _optionDatepicker: function(target, name, value) {
  3254. var inst = this._getInst(target);
  3255. if (arguments.length == 2 && typeof name == 'string') {
  3256. return (name == 'defaults' ? $.extend({}, $.datepicker._defaults) :
  3257. (inst ? (name == 'all' ? $.extend({}, inst.settings) :
  3258. this._get(inst, name)) : null));
  3259. }
  3260. var settings = name || {};
  3261. if (typeof name == 'string') {
  3262. settings = {};
  3263. settings[name] = value;
  3264. }
  3265. if (inst) {
  3266. if (this._curInst == inst) {
  3267. this._hideDatepicker();
  3268. }
  3269. var date = this._getDateDatepicker(target, true);
  3270. var minDate = this._getMinMaxDate(inst, 'min');
  3271. var maxDate = this._getMinMaxDate(inst, 'max');
  3272. extendRemove(inst.settings, settings);
  3273. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  3274. if (minDate !== null && settings['dateFormat'] !== undefined && settings['minDate'] === undefined)
  3275. inst.settings.minDate = this._formatDate(inst, minDate);
  3276. if (maxDate !== null && settings['dateFormat'] !== undefined && settings['maxDate'] === undefined)
  3277. inst.settings.maxDate = this._formatDate(inst, maxDate);
  3278. this._attachments($(target), inst);
  3279. this._autoSize(inst);
  3280. this._setDate(inst, date);
  3281. this._updateAlternate(inst);
  3282. this._updateDatepicker(inst);
  3283. }
  3284. },
  3285. // change method deprecated
  3286. _changeDatepicker: function(target, name, value) {
  3287. this._optionDatepicker(target, name, value);
  3288. },
  3289. /* Redraw the date picker attached to an input field or division.
  3290. @param target element - the target input field or division or span */
  3291. _refreshDatepicker: function(target) {
  3292. var inst = this._getInst(target);
  3293. if (inst) {
  3294. this._updateDatepicker(inst);
  3295. }
  3296. },
  3297. /* Set the dates for a jQuery selection.
  3298. @param target element - the target input field or division or span
  3299. @param date Date - the new date */
  3300. _setDateDatepicker: function(target, date) {
  3301. var inst = this._getInst(target);
  3302. if (inst) {
  3303. this._setDate(inst, date);
  3304. this._updateDatepicker(inst);
  3305. this._updateAlternate(inst);
  3306. }
  3307. },
  3308. /* Get the date(s) for the first entry in a jQuery selection.
  3309. @param target element - the target input field or division or span
  3310. @param noDefault boolean - true if no default date is to be used
  3311. @return Date - the current date */
  3312. _getDateDatepicker: function(target, noDefault) {
  3313. var inst = this._getInst(target);
  3314. if (inst && !inst.inline)
  3315. this._setDateFromField(inst, noDefault);
  3316. return (inst ? this._getDate(inst) : null);
  3317. },
  3318. /* Handle keystrokes. */
  3319. _doKeyDown: function(event) {
  3320. var inst = $.datepicker._getInst(event.target);
  3321. var handled = true;
  3322. var isRTL = inst.dpDiv.is('.ui-datepicker-rtl');
  3323. inst._keyEvent = true;
  3324. if ($.datepicker._datepickerShowing)
  3325. switch (event.keyCode) {
  3326. case 9: $.datepicker._hideDatepicker();
  3327. handled = false;
  3328. break; // hide on tab out
  3329. case 13: var sel = $('td.' + $.datepicker._dayOverClass + ':not(.' +
  3330. $.datepicker._currentClass + ')', inst.dpDiv);
  3331. if (sel[0])
  3332. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  3333. var onSelect = $.datepicker._get(inst, 'onSelect');
  3334. if (onSelect) {
  3335. var dateStr = $.datepicker._formatDate(inst);
  3336. // trigger custom callback
  3337. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  3338. }
  3339. else
  3340. $.datepicker._hideDatepicker();
  3341. return false; // don't submit the form
  3342. break; // select the value on enter
  3343. case 27: $.datepicker._hideDatepicker();
  3344. break; // hide on escape
  3345. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3346. -$.datepicker._get(inst, 'stepBigMonths') :
  3347. -$.datepicker._get(inst, 'stepMonths')), 'M');
  3348. break; // previous month/year on page up/+ ctrl
  3349. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3350. +$.datepicker._get(inst, 'stepBigMonths') :
  3351. +$.datepicker._get(inst, 'stepMonths')), 'M');
  3352. break; // next month/year on page down/+ ctrl
  3353. case 35: if (event.ctrlKey || event.metaKey) $.datepicker._clearDate(event.target);
  3354. handled = event.ctrlKey || event.metaKey;
  3355. break; // clear on ctrl or command +end
  3356. case 36: if (event.ctrlKey || event.metaKey) $.datepicker._gotoToday(event.target);
  3357. handled = event.ctrlKey || event.metaKey;
  3358. break; // current on ctrl or command +home
  3359. case 37: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), 'D');
  3360. handled = event.ctrlKey || event.metaKey;
  3361. // -1 day on ctrl or command +left
  3362. if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3363. -$.datepicker._get(inst, 'stepBigMonths') :
  3364. -$.datepicker._get(inst, 'stepMonths')), 'M');
  3365. // next month/year on alt +left on Mac
  3366. break;
  3367. case 38: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, -7, 'D');
  3368. handled = event.ctrlKey || event.metaKey;
  3369. break; // -1 week on ctrl or command +up
  3370. case 39: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), 'D');
  3371. handled = event.ctrlKey || event.metaKey;
  3372. // +1 day on ctrl or command +right
  3373. if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3374. +$.datepicker._get(inst, 'stepBigMonths') :
  3375. +$.datepicker._get(inst, 'stepMonths')), 'M');
  3376. // next month/year on alt +right
  3377. break;
  3378. case 40: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, +7, 'D');
  3379. handled = event.ctrlKey || event.metaKey;
  3380. break; // +1 week on ctrl or command +down
  3381. default: handled = false;
  3382. }
  3383. else if (event.keyCode == 36 && event.ctrlKey) // display the date picker on ctrl+home
  3384. $.datepicker._showDatepicker(this);
  3385. else {
  3386. handled = false;
  3387. }
  3388. if (handled) {
  3389. event.preventDefault();
  3390. event.stopPropagation();
  3391. }
  3392. },
  3393. /* Filter entered characters - based on date format. */
  3394. _doKeyPress: function(event) {
  3395. var inst = $.datepicker._getInst(event.target);
  3396. if ($.datepicker._get(inst, 'constrainInput')) {
  3397. var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat'));
  3398. var chr = String.fromCharCode(event.charCode == undefined ? event.keyCode : event.charCode);
  3399. return event.ctrlKey || event.metaKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1);
  3400. }
  3401. },
  3402. /* Synchronise manual entry and field/alternate field. */
  3403. _doKeyUp: function(event) {
  3404. var inst = $.datepicker._getInst(event.target);
  3405. if (inst.input.val() != inst.lastVal) {
  3406. try {
  3407. var date = $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
  3408. (inst.input ? inst.input.val() : null),
  3409. $.datepicker._getFormatConfig(inst));
  3410. if (date) { // only if valid
  3411. $.datepicker._setDateFromField(inst);
  3412. $.datepicker._updateAlternate(inst);
  3413. $.datepicker._updateDatepicker(inst);
  3414. }
  3415. }
  3416. catch (err) {
  3417. $.datepicker.log(err);
  3418. }
  3419. }
  3420. return true;
  3421. },
  3422. /* Pop-up the date picker for a given input field.
  3423. If false returned from beforeShow event handler do not show.
  3424. @param input element - the input field attached to the date picker or
  3425. event - if triggered by focus */
  3426. _showDatepicker: function(input) {
  3427. input = input.target || input;
  3428. if (input.nodeName.toLowerCase() != 'input') // find from button/image trigger
  3429. input = $('input', input.parentNode)[0];
  3430. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput == input) // already here
  3431. return;
  3432. var inst = $.datepicker._getInst(input);
  3433. if ($.datepicker._curInst && $.datepicker._curInst != inst) {
  3434. $.datepicker._curInst.dpDiv.stop(true, true);
  3435. if ( inst && $.datepicker._datepickerShowing ) {
  3436. $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
  3437. }
  3438. }
  3439. var beforeShow = $.datepicker._get(inst, 'beforeShow');
  3440. var beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  3441. if(beforeShowSettings === false){
  3442. //false
  3443. return;
  3444. }
  3445. extendRemove(inst.settings, beforeShowSettings);
  3446. inst.lastVal = null;
  3447. $.datepicker._lastInput = input;
  3448. $.datepicker._setDateFromField(inst);
  3449. if ($.datepicker._inDialog) // hide cursor
  3450. input.value = '';
  3451. if (!$.datepicker._pos) { // position below input
  3452. $.datepicker._pos = $.datepicker._findPos(input);
  3453. $.datepicker._pos[1] += input.offsetHeight; // add the height
  3454. }
  3455. var isFixed = false;
  3456. $(input).parents().each(function() {
  3457. isFixed |= $(this).css('position') == 'fixed';
  3458. return !isFixed;
  3459. });
  3460. var offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  3461. $.datepicker._pos = null;
  3462. //to avoid flashes on Firefox
  3463. inst.dpDiv.empty();
  3464. // determine sizing offscreen
  3465. inst.dpDiv.css({position: 'absolute', display: 'block', top: '-1000px'});
  3466. $.datepicker._updateDatepicker(inst);
  3467. // fix width for dynamic number of date pickers
  3468. // and adjust position before showing
  3469. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  3470. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  3471. 'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none',
  3472. left: offset.left + 'px', top: offset.top + 'px'});
  3473. if (!inst.inline) {
  3474. var showAnim = $.datepicker._get(inst, 'showAnim');
  3475. var duration = $.datepicker._get(inst, 'duration');
  3476. var postProcess = function() {
  3477. var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only
  3478. if( !! cover.length ){
  3479. var borders = $.datepicker._getBorders(inst.dpDiv);
  3480. cover.css({left: -borders[0], top: -borders[1],
  3481. width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()});
  3482. }
  3483. };
  3484. inst.dpDiv.zIndex($(input).zIndex()+1);
  3485. $.datepicker._datepickerShowing = true;
  3486. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  3487. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) )
  3488. inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
  3489. else
  3490. inst.dpDiv[showAnim || 'show']((showAnim ? duration : null), postProcess);
  3491. if (!showAnim || !duration)
  3492. postProcess();
  3493. if (inst.input.is(':visible') && !inst.input.is(':disabled'))
  3494. inst.input.focus();
  3495. $.datepicker._curInst = inst;
  3496. }
  3497. },
  3498. /* Generate the date picker content. */
  3499. _updateDatepicker: function(inst) {
  3500. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  3501. var borders = $.datepicker._getBorders(inst.dpDiv);
  3502. instActive = inst; // for delegate hover events
  3503. inst.dpDiv.empty().append(this._generateHTML(inst));
  3504. this._attachHandlers(inst);
  3505. var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only
  3506. if( !!cover.length ){ //avoid call to outerXXXX() when not in IE6
  3507. cover.css({left: -borders[0], top: -borders[1], width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()})
  3508. }
  3509. inst.dpDiv.find('.' + this._dayOverClass + ' a').mouseover();
  3510. var numMonths = this._getNumberOfMonths(inst);
  3511. var cols = numMonths[1];
  3512. var width = 17;
  3513. inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width('');
  3514. if (cols > 1)
  3515. inst.dpDiv.addClass('ui-datepicker-multi-' + cols).css('width', (width * cols) + 'em');
  3516. inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') +
  3517. 'Class']('ui-datepicker-multi');
  3518. inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') +
  3519. 'Class']('ui-datepicker-rtl');
  3520. if (inst == $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input &&
  3521. // #6694 - don't focus the input if it's already focused
  3522. // this breaks the change event in IE
  3523. inst.input.is(':visible') && !inst.input.is(':disabled') && inst.input[0] != document.activeElement)
  3524. inst.input.focus();
  3525. // deffered render of the years select (to avoid flashes on Firefox)
  3526. if( inst.yearshtml ){
  3527. var origyearshtml = inst.yearshtml;
  3528. setTimeout(function(){
  3529. //assure that inst.yearshtml didn't change.
  3530. if( origyearshtml === inst.yearshtml && inst.yearshtml ){
  3531. inst.dpDiv.find('select.ui-datepicker-year:first').replaceWith(inst.yearshtml);
  3532. }
  3533. origyearshtml = inst.yearshtml = null;
  3534. }, 0);
  3535. }
  3536. },
  3537. /* Retrieve the size of left and top borders for an element.
  3538. @param elem (jQuery object) the element of interest
  3539. @return (number[2]) the left and top borders */
  3540. _getBorders: function(elem) {
  3541. var convert = function(value) {
  3542. return {thin: 1, medium: 2, thick: 3}[value] || value;
  3543. };
  3544. return [parseFloat(convert(elem.css('border-left-width'))),
  3545. parseFloat(convert(elem.css('border-top-width')))];
  3546. },
  3547. /* Check positioning to remain on screen. */
  3548. _checkOffset: function(inst, offset, isFixed) {
  3549. var dpWidth = inst.dpDiv.outerWidth();
  3550. var dpHeight = inst.dpDiv.outerHeight();
  3551. var inputWidth = inst.input ? inst.input.outerWidth() : 0;
  3552. var inputHeight = inst.input ? inst.input.outerHeight() : 0;
  3553. var viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft());
  3554. var viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  3555. offset.left -= (this._get(inst, 'isRTL') ? (dpWidth - inputWidth) : 0);
  3556. offset.left -= (isFixed && offset.left == inst.input.offset().left) ? $(document).scrollLeft() : 0;
  3557. offset.top -= (isFixed && offset.top == (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  3558. // now check if datepicker is showing outside window viewport - move to a better place if so.
  3559. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  3560. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  3561. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  3562. Math.abs(dpHeight + inputHeight) : 0);
  3563. return offset;
  3564. },
  3565. /* Find an object's position on the screen. */
  3566. _findPos: function(obj) {
  3567. var inst = this._getInst(obj);
  3568. var isRTL = this._get(inst, 'isRTL');
  3569. while (obj && (obj.type == 'hidden' || obj.nodeType != 1 || $.expr.filters.hidden(obj))) {
  3570. obj = obj[isRTL ? 'previousSibling' : 'nextSibling'];
  3571. }
  3572. var position = $(obj).offset();
  3573. return [position.left, position.top];
  3574. },
  3575. /* Hide the date picker from view.
  3576. @param input element - the input field attached to the date picker */
  3577. _hideDatepicker: function(input) {
  3578. var inst = this._curInst;
  3579. if (!inst || (input && inst != $.data(input, PROP_NAME)))
  3580. return;
  3581. if (this._datepickerShowing) {
  3582. var showAnim = this._get(inst, 'showAnim');
  3583. var duration = this._get(inst, 'duration');
  3584. var postProcess = function() {
  3585. $.datepicker._tidyDialog(inst);
  3586. };
  3587. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  3588. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) )
  3589. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
  3590. else
  3591. inst.dpDiv[(showAnim == 'slideDown' ? 'slideUp' :
  3592. (showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess);
  3593. if (!showAnim)
  3594. postProcess();
  3595. this._datepickerShowing = false;
  3596. var onClose = this._get(inst, 'onClose');
  3597. if (onClose)
  3598. onClose.apply((inst.input ? inst.input[0] : null),
  3599. [(inst.input ? inst.input.val() : ''), inst]);
  3600. this._lastInput = null;
  3601. if (this._inDialog) {
  3602. this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
  3603. if ($.blockUI) {
  3604. $.unblockUI();
  3605. $('body').append(this.dpDiv);
  3606. }
  3607. }
  3608. this._inDialog = false;
  3609. }
  3610. },
  3611. /* Tidy up after a dialog display. */
  3612. _tidyDialog: function(inst) {
  3613. inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker-calendar');
  3614. },
  3615. /* Close date picker if clicked elsewhere. */
  3616. _checkExternalClick: function(event) {
  3617. if (!$.datepicker._curInst)
  3618. return;
  3619. var $target = $(event.target),
  3620. inst = $.datepicker._getInst($target[0]);
  3621. if ( ( ( $target[0].id != $.datepicker._mainDivId &&
  3622. $target.parents('#' + $.datepicker._mainDivId).length == 0 &&
  3623. !$target.hasClass($.datepicker.markerClassName) &&
  3624. !$target.closest("." + $.datepicker._triggerClass).length &&
  3625. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
  3626. ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst != inst ) )
  3627. $.datepicker._hideDatepicker();
  3628. },
  3629. /* Adjust one of the date sub-fields. */
  3630. _adjustDate: function(id, offset, period) {
  3631. var target = $(id);
  3632. var inst = this._getInst(target[0]);
  3633. if (this._isDisabledDatepicker(target[0])) {
  3634. return;
  3635. }
  3636. this._adjustInstDate(inst, offset +
  3637. (period == 'M' ? this._get(inst, 'showCurrentAtPos') : 0), // undo positioning
  3638. period);
  3639. this._updateDatepicker(inst);
  3640. },
  3641. /* Action for current link. */
  3642. _gotoToday: function(id) {
  3643. var target = $(id);
  3644. var inst = this._getInst(target[0]);
  3645. if (this._get(inst, 'gotoCurrent') && inst.currentDay) {
  3646. inst.selectedDay = inst.currentDay;
  3647. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  3648. inst.drawYear = inst.selectedYear = inst.currentYear;
  3649. }
  3650. else {
  3651. var date = new Date();
  3652. inst.selectedDay = date.getDate();
  3653. inst.drawMonth = inst.selectedMonth = date.getMonth();
  3654. inst.drawYear = inst.selectedYear = date.getFullYear();
  3655. }
  3656. this._notifyChange(inst);
  3657. this._adjustDate(target);
  3658. },
  3659. /* Action for selecting a new month/year. */
  3660. _selectMonthYear: function(id, select, period) {
  3661. var target = $(id);
  3662. var inst = this._getInst(target[0]);
  3663. inst['selected' + (period == 'M' ? 'Month' : 'Year')] =
  3664. inst['draw' + (period == 'M' ? 'Month' : 'Year')] =
  3665. parseInt(select.options[select.selectedIndex].value,10);
  3666. this._notifyChange(inst);
  3667. this._adjustDate(target);
  3668. },
  3669. /* Action for selecting a day. */
  3670. _selectDay: function(id, month, year, td) {
  3671. var target = $(id);
  3672. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  3673. return;
  3674. }
  3675. var inst = this._getInst(target[0]);
  3676. inst.selectedDay = inst.currentDay = $('a', td).html();
  3677. inst.selectedMonth = inst.currentMonth = month;
  3678. inst.selectedYear = inst.currentYear = year;
  3679. this._selectDate(id, this._formatDate(inst,
  3680. inst.currentDay, inst.currentMonth, inst.currentYear));
  3681. },
  3682. /* Erase the input field and hide the date picker. */
  3683. _clearDate: function(id) {
  3684. var target = $(id);
  3685. var inst = this._getInst(target[0]);
  3686. this._selectDate(target, '');
  3687. },
  3688. /* Update the input field with the selected date. */
  3689. _selectDate: function(id, dateStr) {
  3690. var target = $(id);
  3691. var inst = this._getInst(target[0]);
  3692. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  3693. if (inst.input)
  3694. inst.input.val(dateStr);
  3695. this._updateAlternate(inst);
  3696. var onSelect = this._get(inst, 'onSelect');
  3697. if (onSelect)
  3698. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  3699. else if (inst.input)
  3700. inst.input.trigger('change'); // fire the change event
  3701. if (inst.inline)
  3702. this._updateDatepicker(inst);
  3703. else {
  3704. this._hideDatepicker();
  3705. this._lastInput = inst.input[0];
  3706. if (typeof(inst.input[0]) != 'object')
  3707. inst.input.focus(); // restore focus
  3708. this._lastInput = null;
  3709. }
  3710. },
  3711. /* Update any alternate field to synchronise with the main field. */
  3712. _updateAlternate: function(inst) {
  3713. var altField = this._get(inst, 'altField');
  3714. if (altField) { // update alternate field too
  3715. var altFormat = this._get(inst, 'altFormat') || this._get(inst, 'dateFormat');
  3716. var date = this._getDate(inst);
  3717. var dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  3718. $(altField).each(function() { $(this).val(dateStr); });
  3719. }
  3720. },
  3721. /* Set as beforeShowDay function to prevent selection of weekends.
  3722. @param date Date - the date to customise
  3723. @return [boolean, string] - is this date selectable?, what is its CSS class? */
  3724. noWeekends: function(date) {
  3725. var day = date.getDay();
  3726. return [(day > 0 && day < 6), ''];
  3727. },
  3728. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  3729. @param date Date - the date to get the week for
  3730. @return number - the number of the week within the year that contains this date */
  3731. iso8601Week: function(date) {
  3732. var checkDate = new Date(date.getTime());
  3733. // Find Thursday of this week starting on Monday
  3734. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  3735. var time = checkDate.getTime();
  3736. checkDate.setMonth(0); // Compare with Jan 1
  3737. checkDate.setDate(1);
  3738. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  3739. },
  3740. /* Parse a string value into a date object.
  3741. See formatDate below for the possible formats.
  3742. @param format string - the expected format of the date
  3743. @param value string - the date in the above format
  3744. @param settings Object - attributes include:
  3745. shortYearCutoff number - the cutoff year for determining the century (optional)
  3746. dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  3747. dayNames string[7] - names of the days from Sunday (optional)
  3748. monthNamesShort string[12] - abbreviated names of the months (optional)
  3749. monthNames string[12] - names of the months (optional)
  3750. @return Date - the extracted date value or null if value is blank */
  3751. parseDate: function (format, value, settings) {
  3752. if (format == null || value == null)
  3753. throw 'Invalid arguments';
  3754. value = (typeof value == 'object' ? value.toString() : value + '');
  3755. if (value == '')
  3756. return null;
  3757. var shortYearCutoff = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff;
  3758. shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
  3759. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  3760. var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
  3761. var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
  3762. var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
  3763. var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
  3764. var year = -1;
  3765. var month = -1;
  3766. var day = -1;
  3767. var doy = -1;
  3768. var literal = false;
  3769. // Check whether a format character is doubled
  3770. var lookAhead = function(match) {
  3771. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
  3772. if (matches)
  3773. iFormat++;
  3774. return matches;
  3775. };
  3776. // Extract a number from the string value
  3777. var getNumber = function(match) {
  3778. var isDoubled = lookAhead(match);
  3779. var size = (match == '@' ? 14 : (match == '!' ? 20 :
  3780. (match == 'y' && isDoubled ? 4 : (match == 'o' ? 3 : 2))));
  3781. var digits = new RegExp('^\\d{1,' + size + '}');
  3782. var num = value.substring(iValue).match(digits);
  3783. if (!num)
  3784. throw 'Missing number at position ' + iValue;
  3785. iValue += num[0].length;
  3786. return parseInt(num[0], 10);
  3787. };
  3788. // Extract a name from the string value and convert to an index
  3789. var getName = function(match, shortNames, longNames) {
  3790. var names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  3791. return [ [k, v] ];
  3792. }).sort(function (a, b) {
  3793. return -(a[1].length - b[1].length);
  3794. });
  3795. var index = -1;
  3796. $.each(names, function (i, pair) {
  3797. var name = pair[1];
  3798. if (value.substr(iValue, name.length).toLowerCase() == name.toLowerCase()) {
  3799. index = pair[0];
  3800. iValue += name.length;
  3801. return false;
  3802. }
  3803. });
  3804. if (index != -1)
  3805. return index + 1;
  3806. else
  3807. throw 'Unknown name at position ' + iValue;
  3808. };
  3809. // Confirm that a literal character matches the string value
  3810. var checkLiteral = function() {
  3811. if (value.charAt(iValue) != format.charAt(iFormat))
  3812. throw 'Unexpected literal at position ' + iValue;
  3813. iValue++;
  3814. };
  3815. var iValue = 0;
  3816. for (var iFormat = 0; iFormat < format.length; iFormat++) {
  3817. if (literal)
  3818. if (format.charAt(iFormat) == "'" && !lookAhead("'"))
  3819. literal = false;
  3820. else
  3821. checkLiteral();
  3822. else
  3823. switch (format.charAt(iFormat)) {
  3824. case 'd':
  3825. day = getNumber('d');
  3826. break;
  3827. case 'D':
  3828. getName('D', dayNamesShort, dayNames);
  3829. break;
  3830. case 'o':
  3831. doy = getNumber('o');
  3832. break;
  3833. case 'm':
  3834. month = getNumber('m');
  3835. break;
  3836. case 'M':
  3837. month = getName('M', monthNamesShort, monthNames);
  3838. break;
  3839. case 'y':
  3840. year = getNumber('y');
  3841. break;
  3842. case '@':
  3843. var date = new Date(getNumber('@'));
  3844. year = date.getFullYear();
  3845. month = date.getMonth() + 1;
  3846. day = date.getDate();
  3847. break;
  3848. case '!':
  3849. var date = new Date((getNumber('!') - this._ticksTo1970) / 10000);
  3850. year = date.getFullYear();
  3851. month = date.getMonth() + 1;
  3852. day = date.getDate();
  3853. break;
  3854. case "'":
  3855. if (lookAhead("'"))
  3856. checkLiteral();
  3857. else
  3858. literal = true;
  3859. break;
  3860. default:
  3861. checkLiteral();
  3862. }
  3863. }
  3864. if (iValue < value.length){
  3865. var extra = value.substr(iValue);
  3866. if (!/^\s+/.test(extra)) {
  3867. throw "Extra/unparsed characters found in date: " + extra;
  3868. }
  3869. }
  3870. if (year == -1)
  3871. year = new Date().getFullYear();
  3872. else if (year < 100)
  3873. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  3874. (year <= shortYearCutoff ? 0 : -100);
  3875. if (doy > -1) {
  3876. month = 1;
  3877. day = doy;
  3878. do {
  3879. var dim = this._getDaysInMonth(year, month - 1);
  3880. if (day <= dim)
  3881. break;
  3882. month++;
  3883. day -= dim;
  3884. } while (true);
  3885. }
  3886. var date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  3887. if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day)
  3888. throw 'Invalid date'; // E.g. 31/02/00
  3889. return date;
  3890. },
  3891. /* Standard date formats. */
  3892. ATOM: 'yy-mm-dd', // RFC 3339 (ISO 8601)
  3893. COOKIE: 'D, dd M yy',
  3894. ISO_8601: 'yy-mm-dd',
  3895. RFC_822: 'D, d M y',
  3896. RFC_850: 'DD, dd-M-y',
  3897. RFC_1036: 'D, d M y',
  3898. RFC_1123: 'D, d M yy',
  3899. RFC_2822: 'D, d M yy',
  3900. RSS: 'D, d M y', // RFC 822
  3901. TICKS: '!',
  3902. TIMESTAMP: '@',
  3903. W3C: 'yy-mm-dd', // ISO 8601
  3904. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  3905. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  3906. /* Format a date object into a string value.
  3907. The format can be combinations of the following:
  3908. d - day of month (no leading zero)
  3909. dd - day of month (two digit)
  3910. o - day of year (no leading zeros)
  3911. oo - day of year (three digit)
  3912. D - day name short
  3913. DD - day name long
  3914. m - month of year (no leading zero)
  3915. mm - month of year (two digit)
  3916. M - month name short
  3917. MM - month name long
  3918. y - year (two digit)
  3919. yy - year (four digit)
  3920. @ - Unix timestamp (ms since 01/01/1970)
  3921. ! - Windows ticks (100ns since 01/01/0001)
  3922. '...' - literal text
  3923. '' - single quote
  3924. @param format string - the desired format of the date
  3925. @param date Date - the date value to format
  3926. @param settings Object - attributes include:
  3927. dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  3928. dayNames string[7] - names of the days from Sunday (optional)
  3929. monthNamesShort string[12] - abbreviated names of the months (optional)
  3930. monthNames string[12] - names of the months (optional)
  3931. @return string - the date in the above format */
  3932. formatDate: function (format, date, settings) {
  3933. if (!date)
  3934. return '';
  3935. var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
  3936. var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
  3937. var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
  3938. var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
  3939. // Check whether a format character is doubled
  3940. var lookAhead = function(match) {
  3941. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
  3942. if (matches)
  3943. iFormat++;
  3944. return matches;
  3945. };
  3946. // Format a number, with leading zero if necessary
  3947. var formatNumber = function(match, value, len) {
  3948. var num = '' + value;
  3949. if (lookAhead(match))
  3950. while (num.length < len)
  3951. num = '0' + num;
  3952. return num;
  3953. };
  3954. // Format a name, short or long as requested
  3955. var formatName = function(match, value, shortNames, longNames) {
  3956. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  3957. };
  3958. var output = '';
  3959. var literal = false;
  3960. if (date)
  3961. for (var iFormat = 0; iFormat < format.length; iFormat++) {
  3962. if (literal)
  3963. if (format.charAt(iFormat) == "'" && !lookAhead("'"))
  3964. literal = false;
  3965. else
  3966. output += format.charAt(iFormat);
  3967. else
  3968. switch (format.charAt(iFormat)) {
  3969. case 'd':
  3970. output += formatNumber('d', date.getDate(), 2);
  3971. break;
  3972. case 'D':
  3973. output += formatName('D', date.getDay(), dayNamesShort, dayNames);
  3974. break;
  3975. case 'o':
  3976. output += formatNumber('o',
  3977. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  3978. break;
  3979. case 'm':
  3980. output += formatNumber('m', date.getMonth() + 1, 2);
  3981. break;
  3982. case 'M':
  3983. output += formatName('M', date.getMonth(), monthNamesShort, monthNames);
  3984. break;
  3985. case 'y':
  3986. output += (lookAhead('y') ? date.getFullYear() :
  3987. (date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100);
  3988. break;
  3989. case '@':
  3990. output += date.getTime();
  3991. break;
  3992. case '!':
  3993. output += date.getTime() * 10000 + this._ticksTo1970;
  3994. break;
  3995. case "'":
  3996. if (lookAhead("'"))
  3997. output += "'";
  3998. else
  3999. literal = true;
  4000. break;
  4001. default:
  4002. output += format.charAt(iFormat);
  4003. }
  4004. }
  4005. return output;
  4006. },
  4007. /* Extract all possible characters from the date format. */
  4008. _possibleChars: function (format) {
  4009. var chars = '';
  4010. var literal = false;
  4011. // Check whether a format character is doubled
  4012. var lookAhead = function(match) {
  4013. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
  4014. if (matches)
  4015. iFormat++;
  4016. return matches;
  4017. };
  4018. for (var iFormat = 0; iFormat < format.length; iFormat++)
  4019. if (literal)
  4020. if (format.charAt(iFormat) == "'" && !lookAhead("'"))
  4021. literal = false;
  4022. else
  4023. chars += format.charAt(iFormat);
  4024. else
  4025. switch (format.charAt(iFormat)) {
  4026. case 'd': case 'm': case 'y': case '@':
  4027. chars += '0123456789';
  4028. break;
  4029. case 'D': case 'M':
  4030. return null; // Accept anything
  4031. case "'":
  4032. if (lookAhead("'"))
  4033. chars += "'";
  4034. else
  4035. literal = true;
  4036. break;
  4037. default:
  4038. chars += format.charAt(iFormat);
  4039. }
  4040. return chars;
  4041. },
  4042. /* Get a setting value, defaulting if necessary. */
  4043. _get: function(inst, name) {
  4044. return inst.settings[name] !== undefined ?
  4045. inst.settings[name] : this._defaults[name];
  4046. },
  4047. /* Parse existing date and initialise date picker. */
  4048. _setDateFromField: function(inst, noDefault) {
  4049. if (inst.input.val() == inst.lastVal) {
  4050. return;
  4051. }
  4052. var dateFormat = this._get(inst, 'dateFormat');
  4053. var dates = inst.lastVal = inst.input ? inst.input.val() : null;
  4054. var date, defaultDate;
  4055. date = defaultDate = this._getDefaultDate(inst);
  4056. var settings = this._getFormatConfig(inst);
  4057. try {
  4058. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  4059. } catch (event) {
  4060. this.log(event);
  4061. dates = (noDefault ? '' : dates);
  4062. }
  4063. inst.selectedDay = date.getDate();
  4064. inst.drawMonth = inst.selectedMonth = date.getMonth();
  4065. inst.drawYear = inst.selectedYear = date.getFullYear();
  4066. inst.currentDay = (dates ? date.getDate() : 0);
  4067. inst.currentMonth = (dates ? date.getMonth() : 0);
  4068. inst.currentYear = (dates ? date.getFullYear() : 0);
  4069. this._adjustInstDate(inst);
  4070. },
  4071. /* Retrieve the default date shown on opening. */
  4072. _getDefaultDate: function(inst) {
  4073. return this._restrictMinMax(inst,
  4074. this._determineDate(inst, this._get(inst, 'defaultDate'), new Date()));
  4075. },
  4076. /* A date may be specified as an exact value or a relative one. */
  4077. _determineDate: function(inst, date, defaultDate) {
  4078. var offsetNumeric = function(offset) {
  4079. var date = new Date();
  4080. date.setDate(date.getDate() + offset);
  4081. return date;
  4082. };
  4083. var offsetString = function(offset) {
  4084. try {
  4085. return $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
  4086. offset, $.datepicker._getFormatConfig(inst));
  4087. }
  4088. catch (e) {
  4089. // Ignore
  4090. }
  4091. var date = (offset.toLowerCase().match(/^c/) ?
  4092. $.datepicker._getDate(inst) : null) || new Date();
  4093. var year = date.getFullYear();
  4094. var month = date.getMonth();
  4095. var day = date.getDate();
  4096. var pattern = /([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g;
  4097. var matches = pattern.exec(offset);
  4098. while (matches) {
  4099. switch (matches[2] || 'd') {
  4100. case 'd' : case 'D' :
  4101. day += parseInt(matches[1],10); break;
  4102. case 'w' : case 'W' :
  4103. day += parseInt(matches[1],10) * 7; break;
  4104. case 'm' : case 'M' :
  4105. month += parseInt(matches[1],10);
  4106. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  4107. break;
  4108. case 'y': case 'Y' :
  4109. year += parseInt(matches[1],10);
  4110. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  4111. break;
  4112. }
  4113. matches = pattern.exec(offset);
  4114. }
  4115. return new Date(year, month, day);
  4116. };
  4117. var newDate = (date == null || date === '' ? defaultDate : (typeof date == 'string' ? offsetString(date) :
  4118. (typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  4119. newDate = (newDate && newDate.toString() == 'Invalid Date' ? defaultDate : newDate);
  4120. if (newDate) {
  4121. newDate.setHours(0);
  4122. newDate.setMinutes(0);
  4123. newDate.setSeconds(0);
  4124. newDate.setMilliseconds(0);
  4125. }
  4126. return this._daylightSavingAdjust(newDate);
  4127. },
  4128. /* Handle switch to/from daylight saving.
  4129. Hours may be non-zero on daylight saving cut-over:
  4130. > 12 when midnight changeover, but then cannot generate
  4131. midnight datetime, so jump to 1AM, otherwise reset.
  4132. @param date (Date) the date to check
  4133. @return (Date) the corrected date */
  4134. _daylightSavingAdjust: function(date) {
  4135. if (!date) return null;
  4136. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  4137. return date;
  4138. },
  4139. /* Set the date(s) directly. */
  4140. _setDate: function(inst, date, noChange) {
  4141. var clear = !date;
  4142. var origMonth = inst.selectedMonth;
  4143. var origYear = inst.selectedYear;
  4144. var newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  4145. inst.selectedDay = inst.currentDay = newDate.getDate();
  4146. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  4147. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  4148. if ((origMonth != inst.selectedMonth || origYear != inst.selectedYear) && !noChange)
  4149. this._notifyChange(inst);
  4150. this._adjustInstDate(inst);
  4151. if (inst.input) {
  4152. inst.input.val(clear ? '' : this._formatDate(inst));
  4153. }
  4154. },
  4155. /* Retrieve the date(s) directly. */
  4156. _getDate: function(inst) {
  4157. var startDate = (!inst.currentYear || (inst.input && inst.input.val() == '') ? null :
  4158. this._daylightSavingAdjust(new Date(
  4159. inst.currentYear, inst.currentMonth, inst.currentDay)));
  4160. return startDate;
  4161. },
  4162. /* Attach the onxxx handlers. These are declared statically so
  4163. * they work with static code transformers like Caja.
  4164. */
  4165. _attachHandlers: function(inst) {
  4166. var stepMonths = this._get(inst, 'stepMonths');
  4167. var id = '#' + inst.id.replace( /\\\\/g, "\\" );
  4168. inst.dpDiv.find('[data-handler]').map(function () {
  4169. var handler = {
  4170. prev: function () {
  4171. window['DP_jQuery_' + dpuuid].datepicker._adjustDate(id, -stepMonths, 'M');
  4172. },
  4173. next: function () {
  4174. window['DP_jQuery_' + dpuuid].datepicker._adjustDate(id, +stepMonths, 'M');
  4175. },
  4176. hide: function () {
  4177. window['DP_jQuery_' + dpuuid].datepicker._hideDatepicker();
  4178. },
  4179. today: function () {
  4180. window['DP_jQuery_' + dpuuid].datepicker._gotoToday(id);
  4181. },
  4182. selectDay: function () {
  4183. window['DP_jQuery_' + dpuuid].datepicker._selectDay(id, +this.getAttribute('data-month'), +this.getAttribute('data-year'), this);
  4184. return false;
  4185. },
  4186. selectMonth: function () {
  4187. window['DP_jQuery_' + dpuuid].datepicker._selectMonthYear(id, this, 'M');
  4188. return false;
  4189. },
  4190. selectYear: function () {
  4191. window['DP_jQuery_' + dpuuid].datepicker._selectMonthYear(id, this, 'Y');
  4192. return false;
  4193. }
  4194. };
  4195. $(this).bind(this.getAttribute('data-event'), handler[this.getAttribute('data-handler')]);
  4196. });
  4197. },
  4198. /* Generate the HTML for the current state of the date picker. */
  4199. _generateHTML: function(inst) {
  4200. var today = new Date();
  4201. today = this._daylightSavingAdjust(
  4202. new Date(today.getFullYear(), today.getMonth(), today.getDate())); // clear time
  4203. var isRTL = this._get(inst, 'isRTL');
  4204. var showButtonPanel = this._get(inst, 'showButtonPanel');
  4205. var hideIfNoPrevNext = this._get(inst, 'hideIfNoPrevNext');
  4206. var navigationAsDateFormat = this._get(inst, 'navigationAsDateFormat');
  4207. var numMonths = this._getNumberOfMonths(inst);
  4208. var showCurrentAtPos = this._get(inst, 'showCurrentAtPos');
  4209. var stepMonths = this._get(inst, 'stepMonths');
  4210. var isMultiMonth = (numMonths[0] != 1 || numMonths[1] != 1);
  4211. var currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  4212. new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  4213. var minDate = this._getMinMaxDate(inst, 'min');
  4214. var maxDate = this._getMinMaxDate(inst, 'max');
  4215. var drawMonth = inst.drawMonth - showCurrentAtPos;
  4216. var drawYear = inst.drawYear;
  4217. if (drawMonth < 0) {
  4218. drawMonth += 12;
  4219. drawYear--;
  4220. }
  4221. if (maxDate) {
  4222. var maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  4223. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  4224. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  4225. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  4226. drawMonth--;
  4227. if (drawMonth < 0) {
  4228. drawMonth = 11;
  4229. drawYear--;
  4230. }
  4231. }
  4232. }
  4233. inst.drawMonth = drawMonth;
  4234. inst.drawYear = drawYear;
  4235. var prevText = this._get(inst, 'prevText');
  4236. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  4237. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  4238. this._getFormatConfig(inst)));
  4239. var prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  4240. '<a class="ui-datepicker-prev ui-corner-all" data-handler="prev" data-event="click"' +
  4241. ' title="' + prevText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>' :
  4242. (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>'));
  4243. var nextText = this._get(inst, 'nextText');
  4244. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  4245. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  4246. this._getFormatConfig(inst)));
  4247. var next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  4248. '<a class="ui-datepicker-next ui-corner-all" data-handler="next" data-event="click"' +
  4249. ' title="' + nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>' :
  4250. (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>'));
  4251. var currentText = this._get(inst, 'currentText');
  4252. var gotoDate = (this._get(inst, 'gotoCurrent') && inst.currentDay ? currentDate : today);
  4253. currentText = (!navigationAsDateFormat ? currentText :
  4254. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  4255. var 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">' +
  4256. this._get(inst, 'closeText') + '</button>' : '');
  4257. var buttonPanel = (showButtonPanel) ? '<div class="ui-datepicker-buttonpane ui-widget-content">' + (isRTL ? controls : '') +
  4258. (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"' +
  4259. '>' + currentText + '</button>' : '') + (isRTL ? '' : controls) + '</div>' : '';
  4260. var firstDay = parseInt(this._get(inst, 'firstDay'),10);
  4261. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  4262. var showWeek = this._get(inst, 'showWeek');
  4263. var dayNames = this._get(inst, 'dayNames');
  4264. var dayNamesShort = this._get(inst, 'dayNamesShort');
  4265. var dayNamesMin = this._get(inst, 'dayNamesMin');
  4266. var monthNames = this._get(inst, 'monthNames');
  4267. var monthNamesShort = this._get(inst, 'monthNamesShort');
  4268. var beforeShowDay = this._get(inst, 'beforeShowDay');
  4269. var showOtherMonths = this._get(inst, 'showOtherMonths');
  4270. var selectOtherMonths = this._get(inst, 'selectOtherMonths');
  4271. var calculateWeek = this._get(inst, 'calculateWeek') || this.iso8601Week;
  4272. var defaultDate = this._getDefaultDate(inst);
  4273. var html = '';
  4274. for (var row = 0; row < numMonths[0]; row++) {
  4275. var group = '';
  4276. this.maxRows = 4;
  4277. for (var col = 0; col < numMonths[1]; col++) {
  4278. var selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  4279. var cornerClass = ' ui-corner-all';
  4280. var calender = '';
  4281. if (isMultiMonth) {
  4282. calender += '<div class="ui-datepicker-group';
  4283. if (numMonths[1] > 1)
  4284. switch (col) {
  4285. case 0: calender += ' ui-datepicker-group-first';
  4286. cornerClass = ' ui-corner-' + (isRTL ? 'right' : 'left'); break;
  4287. case numMonths[1]-1: calender += ' ui-datepicker-group-last';
  4288. cornerClass = ' ui-corner-' + (isRTL ? 'left' : 'right'); break;
  4289. default: calender += ' ui-datepicker-group-middle'; cornerClass = ''; break;
  4290. }
  4291. calender += '">';
  4292. }
  4293. calender += '<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix' + cornerClass + '">' +
  4294. (/all|left/.test(cornerClass) && row == 0 ? (isRTL ? next : prev) : '') +
  4295. (/all|right/.test(cornerClass) && row == 0 ? (isRTL ? prev : next) : '') +
  4296. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  4297. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  4298. '</div><table class="ui-datepicker-calendar"><thead>' +
  4299. '<tr>';
  4300. var thead = (showWeek ? '<th class="ui-datepicker-week-col">' + this._get(inst, 'weekHeader') + '</th>' : '');
  4301. for (var dow = 0; dow < 7; dow++) { // days of the week
  4302. var day = (dow + firstDay) % 7;
  4303. thead += '<th' + ((dow + firstDay + 6) % 7 >= 5 ? ' class="ui-datepicker-week-end"' : '') + '>' +
  4304. '<span title="' + dayNames[day] + '">' + dayNamesMin[day] + '</span></th>';
  4305. }
  4306. calender += thead + '</tr></thead><tbody>';
  4307. var daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  4308. if (drawYear == inst.selectedYear && drawMonth == inst.selectedMonth)
  4309. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  4310. var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  4311. var curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  4312. var numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  4313. this.maxRows = numRows;
  4314. var printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  4315. for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  4316. calender += '<tr>';
  4317. var tbody = (!showWeek ? '' : '<td class="ui-datepicker-week-col">' +
  4318. this._get(inst, 'calculateWeek')(printDate) + '</td>');
  4319. for (var dow = 0; dow < 7; dow++) { // create date picker days
  4320. var daySettings = (beforeShowDay ?
  4321. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, '']);
  4322. var otherMonth = (printDate.getMonth() != drawMonth);
  4323. var unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  4324. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  4325. tbody += '<td class="' +
  4326. ((dow + firstDay + 6) % 7 >= 5 ? ' ui-datepicker-week-end' : '') + // highlight weekends
  4327. (otherMonth ? ' ui-datepicker-other-month' : '') + // highlight days from other months
  4328. ((printDate.getTime() == selectedDate.getTime() && drawMonth == inst.selectedMonth && inst._keyEvent) || // user pressed key
  4329. (defaultDate.getTime() == printDate.getTime() && defaultDate.getTime() == selectedDate.getTime()) ?
  4330. // or defaultDate is current printedDate and defaultDate is selectedDate
  4331. ' ' + this._dayOverClass : '') + // highlight selected day
  4332. (unselectable ? ' ' + this._unselectableClass + ' ui-state-disabled': '') + // highlight unselectable days
  4333. (otherMonth && !showOtherMonths ? '' : ' ' + daySettings[1] + // highlight custom dates
  4334. (printDate.getTime() == currentDate.getTime() ? ' ' + this._currentClass : '') + // highlight selected day
  4335. (printDate.getTime() == today.getTime() ? ' ui-datepicker-today' : '')) + '"' + // highlight today (if different)
  4336. ((!otherMonth || showOtherMonths) && daySettings[2] ? ' title="' + daySettings[2] + '"' : '') + // cell title
  4337. (unselectable ? '' : ' data-handler="selectDay" data-event="click" data-month="' + printDate.getMonth() + '" data-year="' + printDate.getFullYear() + '"') + '>' + // actions
  4338. (otherMonth && !showOtherMonths ? '&#xa0;' : // display for other months
  4339. (unselectable ? '<span class="ui-state-default">' + printDate.getDate() + '</span>' : '<a class="ui-state-default' +
  4340. (printDate.getTime() == today.getTime() ? ' ui-state-highlight' : '') +
  4341. (printDate.getTime() == currentDate.getTime() ? ' ui-state-active' : '') + // highlight selected day
  4342. (otherMonth ? ' ui-priority-secondary' : '') + // distinguish dates from other months
  4343. '" href="#">' + printDate.getDate() + '</a>')) + '</td>'; // display selectable date
  4344. printDate.setDate(printDate.getDate() + 1);
  4345. printDate = this._daylightSavingAdjust(printDate);
  4346. }
  4347. calender += tbody + '</tr>';
  4348. }
  4349. drawMonth++;
  4350. if (drawMonth > 11) {
  4351. drawMonth = 0;
  4352. drawYear++;
  4353. }
  4354. calender += '</tbody></table>' + (isMultiMonth ? '</div>' +
  4355. ((numMonths[0] > 0 && col == numMonths[1]-1) ? '<div class="ui-datepicker-row-break"></div>' : '') : '');
  4356. group += calender;
  4357. }
  4358. html += group;
  4359. }
  4360. html += buttonPanel + ($.browser.msie && parseInt($.browser.version,10) < 7 && !inst.inline ?
  4361. '<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>' : '');
  4362. inst._keyEvent = false;
  4363. return html;
  4364. },
  4365. /* Generate the month and year header. */
  4366. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  4367. secondary, monthNames, monthNamesShort) {
  4368. var changeMonth = this._get(inst, 'changeMonth');
  4369. var changeYear = this._get(inst, 'changeYear');
  4370. var showMonthAfterYear = this._get(inst, 'showMonthAfterYear');
  4371. var html = '<div class="ui-datepicker-title">';
  4372. var monthHtml = '';
  4373. // month selection
  4374. if (secondary || !changeMonth)
  4375. monthHtml += '<span class="ui-datepicker-month">' + monthNames[drawMonth] + '</span>';
  4376. else {
  4377. var inMinYear = (minDate && minDate.getFullYear() == drawYear);
  4378. var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear);
  4379. monthHtml += '<select class="ui-datepicker-month" data-handler="selectMonth" data-event="change">';
  4380. for (var month = 0; month < 12; month++) {
  4381. if ((!inMinYear || month >= minDate.getMonth()) &&
  4382. (!inMaxYear || month <= maxDate.getMonth()))
  4383. monthHtml += '<option value="' + month + '"' +
  4384. (month == drawMonth ? ' selected="selected"' : '') +
  4385. '>' + monthNamesShort[month] + '</option>';
  4386. }
  4387. monthHtml += '</select>';
  4388. }
  4389. if (!showMonthAfterYear)
  4390. html += monthHtml + (secondary || !(changeMonth && changeYear) ? '&#xa0;' : '');
  4391. // year selection
  4392. if ( !inst.yearshtml ) {
  4393. inst.yearshtml = '';
  4394. if (secondary || !changeYear)
  4395. html += '<span class="ui-datepicker-year">' + drawYear + '</span>';
  4396. else {
  4397. // determine range of years to display
  4398. var years = this._get(inst, 'yearRange').split(':');
  4399. var thisYear = new Date().getFullYear();
  4400. var determineYear = function(value) {
  4401. var year = (value.match(/c[+-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  4402. (value.match(/[+-].*/) ? thisYear + parseInt(value, 10) :
  4403. parseInt(value, 10)));
  4404. return (isNaN(year) ? thisYear : year);
  4405. };
  4406. var year = determineYear(years[0]);
  4407. var endYear = Math.max(year, determineYear(years[1] || ''));
  4408. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  4409. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  4410. inst.yearshtml += '<select class="ui-datepicker-year" data-handler="selectYear" data-event="change">';
  4411. for (; year <= endYear; year++) {
  4412. inst.yearshtml += '<option value="' + year + '"' +
  4413. (year == drawYear ? ' selected="selected"' : '') +
  4414. '>' + year + '</option>';
  4415. }
  4416. inst.yearshtml += '</select>';
  4417. html += inst.yearshtml;
  4418. inst.yearshtml = null;
  4419. }
  4420. }
  4421. html += this._get(inst, 'yearSuffix');
  4422. if (showMonthAfterYear)
  4423. html += (secondary || !(changeMonth && changeYear) ? '&#xa0;' : '') + monthHtml;
  4424. html += '</div>'; // Close datepicker_header
  4425. return html;
  4426. },
  4427. /* Adjust one of the date sub-fields. */
  4428. _adjustInstDate: function(inst, offset, period) {
  4429. var year = inst.drawYear + (period == 'Y' ? offset : 0);
  4430. var month = inst.drawMonth + (period == 'M' ? offset : 0);
  4431. var day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) +
  4432. (period == 'D' ? offset : 0);
  4433. var date = this._restrictMinMax(inst,
  4434. this._daylightSavingAdjust(new Date(year, month, day)));
  4435. inst.selectedDay = date.getDate();
  4436. inst.drawMonth = inst.selectedMonth = date.getMonth();
  4437. inst.drawYear = inst.selectedYear = date.getFullYear();
  4438. if (period == 'M' || period == 'Y')
  4439. this._notifyChange(inst);
  4440. },
  4441. /* Ensure a date is within any min/max bounds. */
  4442. _restrictMinMax: function(inst, date) {
  4443. var minDate = this._getMinMaxDate(inst, 'min');
  4444. var maxDate = this._getMinMaxDate(inst, 'max');
  4445. var newDate = (minDate && date < minDate ? minDate : date);
  4446. newDate = (maxDate && newDate > maxDate ? maxDate : newDate);
  4447. return newDate;
  4448. },
  4449. /* Notify change of month/year. */
  4450. _notifyChange: function(inst) {
  4451. var onChange = this._get(inst, 'onChangeMonthYear');
  4452. if (onChange)
  4453. onChange.apply((inst.input ? inst.input[0] : null),
  4454. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  4455. },
  4456. /* Determine the number of months to show. */
  4457. _getNumberOfMonths: function(inst) {
  4458. var numMonths = this._get(inst, 'numberOfMonths');
  4459. return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths));
  4460. },
  4461. /* Determine the current maximum date - ensure no time components are set. */
  4462. _getMinMaxDate: function(inst, minMax) {
  4463. return this._determineDate(inst, this._get(inst, minMax + 'Date'), null);
  4464. },
  4465. /* Find the number of days in a given month. */
  4466. _getDaysInMonth: function(year, month) {
  4467. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  4468. },
  4469. /* Find the day of the week of the first of a month. */
  4470. _getFirstDayOfMonth: function(year, month) {
  4471. return new Date(year, month, 1).getDay();
  4472. },
  4473. /* Determines if we should allow a "next/prev" month display change. */
  4474. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  4475. var numMonths = this._getNumberOfMonths(inst);
  4476. var date = this._daylightSavingAdjust(new Date(curYear,
  4477. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  4478. if (offset < 0)
  4479. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  4480. return this._isInRange(inst, date);
  4481. },
  4482. /* Is the given date in the accepted range? */
  4483. _isInRange: function(inst, date) {
  4484. var minDate = this._getMinMaxDate(inst, 'min');
  4485. var maxDate = this._getMinMaxDate(inst, 'max');
  4486. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  4487. (!maxDate || date.getTime() <= maxDate.getTime()));
  4488. },
  4489. /* Provide the configuration settings for formatting/parsing. */
  4490. _getFormatConfig: function(inst) {
  4491. var shortYearCutoff = this._get(inst, 'shortYearCutoff');
  4492. shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
  4493. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  4494. return {shortYearCutoff: shortYearCutoff,
  4495. dayNamesShort: this._get(inst, 'dayNamesShort'), dayNames: this._get(inst, 'dayNames'),
  4496. monthNamesShort: this._get(inst, 'monthNamesShort'), monthNames: this._get(inst, 'monthNames')};
  4497. },
  4498. /* Format the given date for display. */
  4499. _formatDate: function(inst, day, month, year) {
  4500. if (!day) {
  4501. inst.currentDay = inst.selectedDay;
  4502. inst.currentMonth = inst.selectedMonth;
  4503. inst.currentYear = inst.selectedYear;
  4504. }
  4505. var date = (day ? (typeof day == 'object' ? day :
  4506. this._daylightSavingAdjust(new Date(year, month, day))) :
  4507. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  4508. return this.formatDate(this._get(inst, 'dateFormat'), date, this._getFormatConfig(inst));
  4509. }
  4510. });
  4511. /*
  4512. * Bind hover events for datepicker elements.
  4513. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  4514. * Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  4515. */
  4516. function bindHover(dpDiv) {
  4517. var selector = 'button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a';
  4518. return dpDiv.delegate(selector, 'mouseout', function() {
  4519. $(this).removeClass('ui-state-hover');
  4520. if (this.className.indexOf('ui-datepicker-prev') != -1) $(this).removeClass('ui-datepicker-prev-hover');
  4521. if (this.className.indexOf('ui-datepicker-next') != -1) $(this).removeClass('ui-datepicker-next-hover');
  4522. })
  4523. .delegate(selector, 'mouseover', function(){
  4524. if (!$.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0])) {
  4525. $(this).parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover');
  4526. $(this).addClass('ui-state-hover');
  4527. if (this.className.indexOf('ui-datepicker-prev') != -1) $(this).addClass('ui-datepicker-prev-hover');
  4528. if (this.className.indexOf('ui-datepicker-next') != -1) $(this).addClass('ui-datepicker-next-hover');
  4529. }
  4530. });
  4531. }
  4532. /* jQuery extend now ignores nulls! */
  4533. function extendRemove(target, props) {
  4534. $.extend(target, props);
  4535. for (var name in props)
  4536. if (props[name] == null || props[name] == undefined)
  4537. target[name] = props[name];
  4538. return target;
  4539. };
  4540. /* Invoke the datepicker functionality.
  4541. @param options string - a command, optionally followed by additional parameters or
  4542. Object - settings for attaching new datepicker functionality
  4543. @return jQuery object */
  4544. $.fn.datepicker = function(options){
  4545. /* Verify an empty collection wasn't passed - Fixes #6976 */
  4546. if ( !this.length ) {
  4547. return this;
  4548. }
  4549. /* Initialise the date picker. */
  4550. if (!$.datepicker.initialized) {
  4551. $(document).mousedown($.datepicker._checkExternalClick).
  4552. find(document.body).append($.datepicker.dpDiv);
  4553. $.datepicker.initialized = true;
  4554. }
  4555. var otherArgs = Array.prototype.slice.call(arguments, 1);
  4556. if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate' || options == 'widget'))
  4557. return $.datepicker['_' + options + 'Datepicker'].
  4558. apply($.datepicker, [this[0]].concat(otherArgs));
  4559. if (options == 'option' && arguments.length == 2 && typeof arguments[1] == 'string')
  4560. return $.datepicker['_' + options + 'Datepicker'].
  4561. apply($.datepicker, [this[0]].concat(otherArgs));
  4562. return this.each(function() {
  4563. typeof options == 'string' ?
  4564. $.datepicker['_' + options + 'Datepicker'].
  4565. apply($.datepicker, [this].concat(otherArgs)) :
  4566. $.datepicker._attachDatepicker(this, options);
  4567. });
  4568. };
  4569. $.datepicker = new Datepicker(); // singleton instance
  4570. $.datepicker.initialized = false;
  4571. $.datepicker.uuid = new Date().getTime();
  4572. $.datepicker.version = "1.9.0";
  4573. // Workaround for #4055
  4574. // Add another global to avoid noConflict issues with inline event handlers
  4575. window['DP_jQuery_' + dpuuid] = $;
  4576. })(jQuery);
  4577. (function( $, undefined ) {
  4578. var uiDialogClasses = "ui-dialog ui-widget ui-widget-content ui-corner-all ",
  4579. sizeRelatedOptions = {
  4580. buttons: true,
  4581. height: true,
  4582. maxHeight: true,
  4583. maxWidth: true,
  4584. minHeight: true,
  4585. minWidth: true,
  4586. width: true
  4587. },
  4588. resizableRelatedOptions = {
  4589. maxHeight: true,
  4590. maxWidth: true,
  4591. minHeight: true,
  4592. minWidth: true
  4593. };
  4594. $.widget("ui.dialog", {
  4595. version: "1.9.0",
  4596. options: {
  4597. autoOpen: true,
  4598. buttons: {},
  4599. closeOnEscape: true,
  4600. closeText: "close",
  4601. dialogClass: "",
  4602. draggable: true,
  4603. hide: null,
  4604. height: "auto",
  4605. maxHeight: false,
  4606. maxWidth: false,
  4607. minHeight: 150,
  4608. minWidth: 150,
  4609. modal: false,
  4610. position: {
  4611. my: "center",
  4612. at: "center",
  4613. of: window,
  4614. collision: "fit",
  4615. // ensure that the titlebar is never outside the document
  4616. using: function( pos ) {
  4617. var topOffset = $( this ).css( pos ).offset().top;
  4618. if ( topOffset < 0 ) {
  4619. $( this ).css( "top", pos.top - topOffset );
  4620. }
  4621. }
  4622. },
  4623. resizable: true,
  4624. show: null,
  4625. stack: true,
  4626. title: "",
  4627. width: 300,
  4628. zIndex: 1000
  4629. },
  4630. _create: function() {
  4631. this.originalTitle = this.element.attr( "title" );
  4632. // #5742 - .attr() might return a DOMElement
  4633. if ( typeof this.originalTitle !== "string" ) {
  4634. this.originalTitle = "";
  4635. }
  4636. this.oldPosition = {
  4637. parent: this.element.parent(),
  4638. index: this.element.parent().children().index( this.element )
  4639. };
  4640. this.options.title = this.options.title || this.originalTitle;
  4641. var that = this,
  4642. options = this.options,
  4643. title = options.title || "&#160;",
  4644. uiDialog = ( this.uiDialog = $( "<div>" ) )
  4645. .addClass( uiDialogClasses + options.dialogClass )
  4646. .css({
  4647. display: "none",
  4648. outline: 0, // TODO: move to stylesheet
  4649. zIndex: options.zIndex
  4650. })
  4651. // setting tabIndex makes the div focusable
  4652. .attr( "tabIndex", -1)
  4653. .keydown(function( event ) {
  4654. if ( options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  4655. event.keyCode === $.ui.keyCode.ESCAPE ) {
  4656. that.close( event );
  4657. event.preventDefault();
  4658. }
  4659. })
  4660. .mousedown(function( event ) {
  4661. that.moveToTop( false, event );
  4662. })
  4663. .appendTo( "body" ),
  4664. uiDialogContent = this.element
  4665. .show()
  4666. .removeAttr( "title" )
  4667. .addClass( "ui-dialog-content ui-widget-content" )
  4668. .appendTo( uiDialog ),
  4669. uiDialogTitlebar = ( this.uiDialogTitlebar = $( "<div>" ) )
  4670. .addClass( "ui-dialog-titlebar ui-widget-header " +
  4671. "ui-corner-all ui-helper-clearfix" )
  4672. .prependTo( uiDialog ),
  4673. uiDialogTitlebarClose = $( "<a href='#'></a>" )
  4674. .addClass( "ui-dialog-titlebar-close ui-corner-all" )
  4675. .attr( "role", "button" )
  4676. .click(function( event ) {
  4677. event.preventDefault();
  4678. that.close( event );
  4679. })
  4680. .appendTo( uiDialogTitlebar ),
  4681. uiDialogTitlebarCloseText = ( this.uiDialogTitlebarCloseText = $( "<span>" ) )
  4682. .addClass( "ui-icon ui-icon-closethick" )
  4683. .text( options.closeText )
  4684. .appendTo( uiDialogTitlebarClose ),
  4685. uiDialogTitle = $( "<span>" )
  4686. .uniqueId()
  4687. .addClass( "ui-dialog-title" )
  4688. .html( title )
  4689. .prependTo( uiDialogTitlebar ),
  4690. uiDialogButtonPane = ( this.uiDialogButtonPane = $( "<div>" ) )
  4691. .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" ),
  4692. uiButtonSet = ( this.uiButtonSet = $( "<div>" ) )
  4693. .addClass( "ui-dialog-buttonset" )
  4694. .appendTo( uiDialogButtonPane );
  4695. uiDialog.attr({
  4696. role: "dialog",
  4697. "aria-labelledby": uiDialogTitle.attr( "id" )
  4698. });
  4699. uiDialogTitlebar.find( "*" ).add( uiDialogTitlebar ).disableSelection();
  4700. this._hoverable( uiDialogTitlebarClose );
  4701. this._focusable( uiDialogTitlebarClose );
  4702. if ( options.draggable && $.fn.draggable ) {
  4703. this._makeDraggable();
  4704. }
  4705. if ( options.resizable && $.fn.resizable ) {
  4706. this._makeResizable();
  4707. }
  4708. this._createButtons( options.buttons );
  4709. this._isOpen = false;
  4710. if ( $.fn.bgiframe ) {
  4711. uiDialog.bgiframe();
  4712. }
  4713. // prevent tabbing out of modal dialogs
  4714. this._on( uiDialog, { keydown: function( event ) {
  4715. if ( !options.modal || event.keyCode !== $.ui.keyCode.TAB ) {
  4716. return;
  4717. }
  4718. var tabbables = $( ":tabbable", uiDialog ),
  4719. first = tabbables.filter( ":first" ),
  4720. last = tabbables.filter( ":last" );
  4721. if ( event.target === last[0] && !event.shiftKey ) {
  4722. first.focus( 1 );
  4723. return false;
  4724. } else if ( event.target === first[0] && event.shiftKey ) {
  4725. last.focus( 1 );
  4726. return false;
  4727. }
  4728. }});
  4729. },
  4730. _init: function() {
  4731. if ( this.options.autoOpen ) {
  4732. this.open();
  4733. }
  4734. },
  4735. _destroy: function() {
  4736. var next,
  4737. oldPosition = this.oldPosition;
  4738. if ( this.overlay ) {
  4739. this.overlay.destroy();
  4740. }
  4741. this.uiDialog.hide();
  4742. this.element
  4743. .removeClass( "ui-dialog-content ui-widget-content" )
  4744. .hide()
  4745. .appendTo( "body" );
  4746. this.uiDialog.remove();
  4747. if ( this.originalTitle ) {
  4748. this.element.attr( "title", this.originalTitle );
  4749. }
  4750. next = oldPosition.parent.children().eq( oldPosition.index );
  4751. // Don't try to place the dialog next to itself (#8613)
  4752. if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
  4753. next.before( this.element );
  4754. } else {
  4755. oldPosition.parent.append( this.element );
  4756. }
  4757. },
  4758. widget: function() {
  4759. return this.uiDialog;
  4760. },
  4761. close: function( event ) {
  4762. var that = this,
  4763. maxZ, thisZ;
  4764. if ( !this._isOpen ) {
  4765. return;
  4766. }
  4767. if ( false === this._trigger( "beforeClose", event ) ) {
  4768. return;
  4769. }
  4770. this._isOpen = false;
  4771. if ( this.overlay ) {
  4772. this.overlay.destroy();
  4773. }
  4774. if ( this.options.hide ) {
  4775. this.uiDialog.hide( this.options.hide, function() {
  4776. that._trigger( "close", event );
  4777. });
  4778. } else {
  4779. this.uiDialog.hide();
  4780. this._trigger( "close", event );
  4781. }
  4782. $.ui.dialog.overlay.resize();
  4783. // adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
  4784. if ( this.options.modal ) {
  4785. maxZ = 0;
  4786. $( ".ui-dialog" ).each(function() {
  4787. if ( this !== that.uiDialog[0] ) {
  4788. thisZ = $( this ).css( "z-index" );
  4789. if ( !isNaN( thisZ ) ) {
  4790. maxZ = Math.max( maxZ, thisZ );
  4791. }
  4792. }
  4793. });
  4794. $.ui.dialog.maxZ = maxZ;
  4795. }
  4796. return this;
  4797. },
  4798. isOpen: function() {
  4799. return this._isOpen;
  4800. },
  4801. // the force parameter allows us to move modal dialogs to their correct
  4802. // position on open
  4803. moveToTop: function( force, event ) {
  4804. var options = this.options,
  4805. saveScroll;
  4806. if ( ( options.modal && !force ) ||
  4807. ( !options.stack && !options.modal ) ) {
  4808. return this._trigger( "focus", event );
  4809. }
  4810. if ( options.zIndex > $.ui.dialog.maxZ ) {
  4811. $.ui.dialog.maxZ = options.zIndex;
  4812. }
  4813. if ( this.overlay ) {
  4814. $.ui.dialog.maxZ += 1;
  4815. $.ui.dialog.overlay.maxZ = $.ui.dialog.maxZ;
  4816. this.overlay.$el.css( "z-index", $.ui.dialog.overlay.maxZ );
  4817. }
  4818. // Save and then restore scroll
  4819. // Opera 9.5+ resets when parent z-index is changed.
  4820. // http://bugs.jqueryui.com/ticket/3193
  4821. saveScroll = {
  4822. scrollTop: this.element.scrollTop(),
  4823. scrollLeft: this.element.scrollLeft()
  4824. };
  4825. $.ui.dialog.maxZ += 1;
  4826. this.uiDialog.css( "z-index", $.ui.dialog.maxZ );
  4827. this.element.attr( saveScroll );
  4828. this._trigger( "focus", event );
  4829. return this;
  4830. },
  4831. open: function() {
  4832. if ( this._isOpen ) {
  4833. return;
  4834. }
  4835. var hasFocus,
  4836. options = this.options,
  4837. uiDialog = this.uiDialog;
  4838. this._size();
  4839. this._position( options.position );
  4840. uiDialog.show( options.show );
  4841. this.overlay = options.modal ? new $.ui.dialog.overlay( this ) : null;
  4842. this.moveToTop( true );
  4843. // set focus to the first tabbable element in the content area or the first button
  4844. // if there are no tabbable elements, set focus on the dialog itself
  4845. hasFocus = this.element.find( ":tabbable" );
  4846. if ( !hasFocus.length ) {
  4847. hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
  4848. if ( !hasFocus.length ) {
  4849. hasFocus = uiDialog;
  4850. }
  4851. }
  4852. hasFocus.eq( 0 ).focus();
  4853. this._isOpen = true;
  4854. this._trigger( "open" );
  4855. return this;
  4856. },
  4857. _createButtons: function( buttons ) {
  4858. var uiDialogButtonPane, uiButtonSet,
  4859. that = this,
  4860. hasButtons = false;
  4861. // if we already have a button pane, remove it
  4862. this.uiDialogButtonPane.remove();
  4863. this.uiButtonSet.empty();
  4864. if ( typeof buttons === "object" && buttons !== null ) {
  4865. $.each( buttons, function() {
  4866. return !(hasButtons = true);
  4867. });
  4868. }
  4869. if ( hasButtons ) {
  4870. $.each( buttons, function( name, props ) {
  4871. props = $.isFunction( props ) ?
  4872. { click: props, text: name } :
  4873. props;
  4874. var button = $( "<button type='button'>" )
  4875. .attr( props, true )
  4876. .unbind( "click" )
  4877. .click(function() {
  4878. props.click.apply( that.element[0], arguments );
  4879. })
  4880. .appendTo( that.uiButtonSet );
  4881. if ( $.fn.button ) {
  4882. button.button();
  4883. }
  4884. });
  4885. this.uiDialog.addClass( "ui-dialog-buttons" );
  4886. this.uiDialogButtonPane.appendTo( this.uiDialog );
  4887. } else {
  4888. this.uiDialog.removeClass( "ui-dialog-buttons" );
  4889. }
  4890. },
  4891. _makeDraggable: function() {
  4892. var that = this,
  4893. options = this.options;
  4894. function filteredUi( ui ) {
  4895. return {
  4896. position: ui.position,
  4897. offset: ui.offset
  4898. };
  4899. }
  4900. this.uiDialog.draggable({
  4901. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  4902. handle: ".ui-dialog-titlebar",
  4903. containment: "document",
  4904. start: function( event, ui ) {
  4905. $( this )
  4906. .addClass( "ui-dialog-dragging" );
  4907. that._trigger( "dragStart", event, filteredUi( ui ) );
  4908. },
  4909. drag: function( event, ui ) {
  4910. that._trigger( "drag", event, filteredUi( ui ) );
  4911. },
  4912. stop: function( event, ui ) {
  4913. options.position = [
  4914. ui.position.left - that.document.scrollLeft(),
  4915. ui.position.top - that.document.scrollTop()
  4916. ];
  4917. $( this )
  4918. .removeClass( "ui-dialog-dragging" );
  4919. that._trigger( "dragStop", event, filteredUi( ui ) );
  4920. $.ui.dialog.overlay.resize();
  4921. }
  4922. });
  4923. },
  4924. _makeResizable: function( handles ) {
  4925. handles = (handles === undefined ? this.options.resizable : handles);
  4926. var that = this,
  4927. options = this.options,
  4928. // .ui-resizable has position: relative defined in the stylesheet
  4929. // but dialogs have to use absolute or fixed positioning
  4930. position = this.uiDialog.css( "position" ),
  4931. resizeHandles = typeof handles === 'string' ?
  4932. handles :
  4933. "n,e,s,w,se,sw,ne,nw";
  4934. function filteredUi( ui ) {
  4935. return {
  4936. originalPosition: ui.originalPosition,
  4937. originalSize: ui.originalSize,
  4938. position: ui.position,
  4939. size: ui.size
  4940. };
  4941. }
  4942. this.uiDialog.resizable({
  4943. cancel: ".ui-dialog-content",
  4944. containment: "document",
  4945. alsoResize: this.element,
  4946. maxWidth: options.maxWidth,
  4947. maxHeight: options.maxHeight,
  4948. minWidth: options.minWidth,
  4949. minHeight: this._minHeight(),
  4950. handles: resizeHandles,
  4951. start: function( event, ui ) {
  4952. $( this ).addClass( "ui-dialog-resizing" );
  4953. that._trigger( "resizeStart", event, filteredUi( ui ) );
  4954. },
  4955. resize: function( event, ui ) {
  4956. that._trigger( "resize", event, filteredUi( ui ) );
  4957. },
  4958. stop: function( event, ui ) {
  4959. $( this ).removeClass( "ui-dialog-resizing" );
  4960. options.height = $( this ).height();
  4961. options.width = $( this ).width();
  4962. that._trigger( "resizeStop", event, filteredUi( ui ) );
  4963. $.ui.dialog.overlay.resize();
  4964. }
  4965. })
  4966. .css( "position", position )
  4967. .find( ".ui-resizable-se" )
  4968. .addClass( "ui-icon ui-icon-grip-diagonal-se" );
  4969. },
  4970. _minHeight: function() {
  4971. var options = this.options;
  4972. if ( options.height === "auto" ) {
  4973. return options.minHeight;
  4974. } else {
  4975. return Math.min( options.minHeight, options.height );
  4976. }
  4977. },
  4978. _position: function( position ) {
  4979. var myAt = [],
  4980. offset = [ 0, 0 ],
  4981. isVisible;
  4982. if ( position ) {
  4983. // deep extending converts arrays to objects in jQuery <= 1.3.2 :-(
  4984. // if (typeof position == 'string' || $.isArray(position)) {
  4985. // myAt = $.isArray(position) ? position : position.split(' ');
  4986. if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) {
  4987. myAt = position.split ? position.split( " " ) : [ position[ 0 ], position[ 1 ] ];
  4988. if ( myAt.length === 1 ) {
  4989. myAt[ 1 ] = myAt[ 0 ];
  4990. }
  4991. $.each( [ "left", "top" ], function( i, offsetPosition ) {
  4992. if ( +myAt[ i ] === myAt[ i ] ) {
  4993. offset[ i ] = myAt[ i ];
  4994. myAt[ i ] = offsetPosition;
  4995. }
  4996. });
  4997. position = {
  4998. my: myAt.join( " " ),
  4999. at: myAt.join( " " ),
  5000. offset: offset.join( " " )
  5001. };
  5002. }
  5003. position = $.extend( {}, $.ui.dialog.prototype.options.position, position );
  5004. } else {
  5005. position = $.ui.dialog.prototype.options.position;
  5006. }
  5007. // need to show the dialog to get the actual offset in the position plugin
  5008. isVisible = this.uiDialog.is( ":visible" );
  5009. if ( !isVisible ) {
  5010. this.uiDialog.show();
  5011. }
  5012. this.uiDialog.position( position );
  5013. if ( !isVisible ) {
  5014. this.uiDialog.hide();
  5015. }
  5016. },
  5017. _setOptions: function( options ) {
  5018. var that = this,
  5019. resizableOptions = {},
  5020. resize = false;
  5021. $.each( options, function( key, value ) {
  5022. that._setOption( key, value );
  5023. if ( key in sizeRelatedOptions ) {
  5024. resize = true;
  5025. }
  5026. if ( key in resizableRelatedOptions ) {
  5027. resizableOptions[ key ] = value;
  5028. }
  5029. });
  5030. if ( resize ) {
  5031. this._size();
  5032. }
  5033. if ( this.uiDialog.is( ":data(resizable)" ) ) {
  5034. this.uiDialog.resizable( "option", resizableOptions );
  5035. }
  5036. },
  5037. _setOption: function( key, value ) {
  5038. var isDraggable, isResizable,
  5039. uiDialog = this.uiDialog;
  5040. switch ( key ) {
  5041. case "buttons":
  5042. this._createButtons( value );
  5043. break;
  5044. case "closeText":
  5045. // ensure that we always pass a string
  5046. this.uiDialogTitlebarCloseText.text( "" + value );
  5047. break;
  5048. case "dialogClass":
  5049. uiDialog
  5050. .removeClass( this.options.dialogClass )
  5051. .addClass( uiDialogClasses + value );
  5052. break;
  5053. case "disabled":
  5054. if ( value ) {
  5055. uiDialog.addClass( "ui-dialog-disabled" );
  5056. } else {
  5057. uiDialog.removeClass( "ui-dialog-disabled" );
  5058. }
  5059. break;
  5060. case "draggable":
  5061. isDraggable = uiDialog.is( ":data(draggable)" );
  5062. if ( isDraggable && !value ) {
  5063. uiDialog.draggable( "destroy" );
  5064. }
  5065. if ( !isDraggable && value ) {
  5066. this._makeDraggable();
  5067. }
  5068. break;
  5069. case "position":
  5070. this._position( value );
  5071. break;
  5072. case "resizable":
  5073. // currently resizable, becoming non-resizable
  5074. isResizable = uiDialog.is( ":data(resizable)" );
  5075. if ( isResizable && !value ) {
  5076. uiDialog.resizable( "destroy" );
  5077. }
  5078. // currently resizable, changing handles
  5079. if ( isResizable && typeof value === "string" ) {
  5080. uiDialog.resizable( "option", "handles", value );
  5081. }
  5082. // currently non-resizable, becoming resizable
  5083. if ( !isResizable && value !== false ) {
  5084. this._makeResizable( value );
  5085. }
  5086. break;
  5087. case "title":
  5088. // convert whatever was passed in o a string, for html() to not throw up
  5089. $( ".ui-dialog-title", this.uiDialogTitlebar )
  5090. .html( "" + ( value || "&#160;" ) );
  5091. break;
  5092. }
  5093. this._super( key, value );
  5094. },
  5095. _size: function() {
  5096. /* If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  5097. * divs will both have width and height set, so we need to reset them
  5098. */
  5099. var nonContentHeight, minContentHeight, autoHeight,
  5100. options = this.options,
  5101. isVisible = this.uiDialog.is( ":visible" );
  5102. // reset content sizing
  5103. this.element.show().css({
  5104. width: "auto",
  5105. minHeight: 0,
  5106. height: 0
  5107. });
  5108. if ( options.minWidth > options.width ) {
  5109. options.width = options.minWidth;
  5110. }
  5111. // reset wrapper sizing
  5112. // determine the height of all the non-content elements
  5113. nonContentHeight = this.uiDialog.css({
  5114. height: "auto",
  5115. width: options.width
  5116. })
  5117. .outerHeight();
  5118. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  5119. if ( options.height === "auto" ) {
  5120. // only needed for IE6 support
  5121. if ( $.support.minHeight ) {
  5122. this.element.css({
  5123. minHeight: minContentHeight,
  5124. height: "auto"
  5125. });
  5126. } else {
  5127. this.uiDialog.show();
  5128. autoHeight = this.element.css( "height", "auto" ).height();
  5129. if ( !isVisible ) {
  5130. this.uiDialog.hide();
  5131. }
  5132. this.element.height( Math.max( autoHeight, minContentHeight ) );
  5133. }
  5134. } else {
  5135. this.element.height( Math.max( options.height - nonContentHeight, 0 ) );
  5136. }
  5137. if (this.uiDialog.is( ":data(resizable)" ) ) {
  5138. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  5139. }
  5140. }
  5141. });
  5142. $.extend($.ui.dialog, {
  5143. uuid: 0,
  5144. maxZ: 0,
  5145. getTitleId: function($el) {
  5146. var id = $el.attr( "id" );
  5147. if ( !id ) {
  5148. this.uuid += 1;
  5149. id = this.uuid;
  5150. }
  5151. return "ui-dialog-title-" + id;
  5152. },
  5153. overlay: function( dialog ) {
  5154. this.$el = $.ui.dialog.overlay.create( dialog );
  5155. }
  5156. });
  5157. $.extend( $.ui.dialog.overlay, {
  5158. instances: [],
  5159. // reuse old instances due to IE memory leak with alpha transparency (see #5185)
  5160. oldInstances: [],
  5161. maxZ: 0,
  5162. events: $.map(
  5163. "focus,mousedown,mouseup,keydown,keypress,click".split( "," ),
  5164. function( event ) {
  5165. return event + ".dialog-overlay";
  5166. }
  5167. ).join( " " ),
  5168. create: function( dialog ) {
  5169. if ( this.instances.length === 0 ) {
  5170. // prevent use of anchors and inputs
  5171. // we use a setTimeout in case the overlay is created from an
  5172. // event that we're going to be cancelling (see #2804)
  5173. setTimeout(function() {
  5174. // handle $(el).dialog().dialog('close') (see #4065)
  5175. if ( $.ui.dialog.overlay.instances.length ) {
  5176. $( document ).bind( $.ui.dialog.overlay.events, function( event ) {
  5177. // stop events if the z-index of the target is < the z-index of the overlay
  5178. // we cannot return true when we don't want to cancel the event (#3523)
  5179. if ( $( event.target ).zIndex() < $.ui.dialog.overlay.maxZ ) {
  5180. return false;
  5181. }
  5182. });
  5183. }
  5184. }, 1 );
  5185. // handle window resize
  5186. $( window ).bind( "resize.dialog-overlay", $.ui.dialog.overlay.resize );
  5187. }
  5188. var $el = ( this.oldInstances.pop() || $( "<div>" ).addClass( "ui-widget-overlay" ) );
  5189. // allow closing by pressing the escape key
  5190. $( document ).bind( "keydown.dialog-overlay", function( event ) {
  5191. var instances = $.ui.dialog.overlay.instances;
  5192. // only react to the event if we're the top overlay
  5193. if ( instances.length !== 0 && instances[ instances.length - 1 ] === $el &&
  5194. dialog.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  5195. event.keyCode === $.ui.keyCode.ESCAPE ) {
  5196. dialog.close( event );
  5197. event.preventDefault();
  5198. }
  5199. });
  5200. $el.appendTo( document.body ).css({
  5201. width: this.width(),
  5202. height: this.height()
  5203. });
  5204. if ( $.fn.bgiframe ) {
  5205. $el.bgiframe();
  5206. }
  5207. this.instances.push( $el );
  5208. return $el;
  5209. },
  5210. destroy: function( $el ) {
  5211. var indexOf = $.inArray( $el, this.instances ),
  5212. maxZ = 0;
  5213. if ( indexOf !== -1 ) {
  5214. this.oldInstances.push( this.instances.splice( indexOf, 1 )[ 0 ] );
  5215. }
  5216. if ( this.instances.length === 0 ) {
  5217. $( [ document, window ] ).unbind( ".dialog-overlay" );
  5218. }
  5219. $el.height( 0 ).width( 0 ).remove();
  5220. // adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
  5221. $.each( this.instances, function() {
  5222. maxZ = Math.max( maxZ, this.css( "z-index" ) );
  5223. });
  5224. this.maxZ = maxZ;
  5225. },
  5226. height: function() {
  5227. var scrollHeight,
  5228. offsetHeight;
  5229. // handle IE
  5230. if ( $.browser.msie ) {
  5231. scrollHeight = Math.max(
  5232. document.documentElement.scrollHeight,
  5233. document.body.scrollHeight
  5234. );
  5235. offsetHeight = Math.max(
  5236. document.documentElement.offsetHeight,
  5237. document.body.offsetHeight
  5238. );
  5239. if ( scrollHeight < offsetHeight ) {
  5240. return $( window ).height() + "px";
  5241. } else {
  5242. return scrollHeight + "px";
  5243. }
  5244. // handle "good" browsers
  5245. } else {
  5246. return $( document ).height() + "px";
  5247. }
  5248. },
  5249. width: function() {
  5250. var scrollWidth,
  5251. offsetWidth;
  5252. // handle IE
  5253. if ( $.browser.msie ) {
  5254. scrollWidth = Math.max(
  5255. document.documentElement.scrollWidth,
  5256. document.body.scrollWidth
  5257. );
  5258. offsetWidth = Math.max(
  5259. document.documentElement.offsetWidth,
  5260. document.body.offsetWidth
  5261. );
  5262. if ( scrollWidth < offsetWidth ) {
  5263. return $( window ).width() + "px";
  5264. } else {
  5265. return scrollWidth + "px";
  5266. }
  5267. // handle "good" browsers
  5268. } else {
  5269. return $( document ).width() + "px";
  5270. }
  5271. },
  5272. resize: function() {
  5273. /* If the dialog is draggable and the user drags it past the
  5274. * right edge of the window, the document becomes wider so we
  5275. * need to stretch the overlay. If the user then drags the
  5276. * dialog back to the left, the document will become narrower,
  5277. * so we need to shrink the overlay to the appropriate size.
  5278. * This is handled by shrinking the overlay before setting it
  5279. * to the full document size.
  5280. */
  5281. var $overlays = $( [] );
  5282. $.each( $.ui.dialog.overlay.instances, function() {
  5283. $overlays = $overlays.add( this );
  5284. });
  5285. $overlays.css({
  5286. width: 0,
  5287. height: 0
  5288. }).css({
  5289. width: $.ui.dialog.overlay.width(),
  5290. height: $.ui.dialog.overlay.height()
  5291. });
  5292. }
  5293. });
  5294. $.extend( $.ui.dialog.overlay.prototype, {
  5295. destroy: function() {
  5296. $.ui.dialog.overlay.destroy( this.$el );
  5297. }
  5298. });
  5299. }( jQuery ) );
  5300. (function( $, undefined ) {
  5301. $.widget("ui.draggable", $.ui.mouse, {
  5302. version: "1.9.0",
  5303. widgetEventPrefix: "drag",
  5304. options: {
  5305. addClasses: true,
  5306. appendTo: "parent",
  5307. axis: false,
  5308. connectToSortable: false,
  5309. containment: false,
  5310. cursor: "auto",
  5311. cursorAt: false,
  5312. grid: false,
  5313. handle: false,
  5314. helper: "original",
  5315. iframeFix: false,
  5316. opacity: false,
  5317. refreshPositions: false,
  5318. revert: false,
  5319. revertDuration: 500,
  5320. scope: "default",
  5321. scroll: true,
  5322. scrollSensitivity: 20,
  5323. scrollSpeed: 20,
  5324. snap: false,
  5325. snapMode: "both",
  5326. snapTolerance: 20,
  5327. stack: false,
  5328. zIndex: false
  5329. },
  5330. _create: function() {
  5331. if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position")))
  5332. this.element[0].style.position = 'relative';
  5333. (this.options.addClasses && this.element.addClass("ui-draggable"));
  5334. (this.options.disabled && this.element.addClass("ui-draggable-disabled"));
  5335. this._mouseInit();
  5336. },
  5337. _destroy: function() {
  5338. this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
  5339. this._mouseDestroy();
  5340. },
  5341. _mouseCapture: function(event) {
  5342. var o = this.options;
  5343. // among others, prevent a drag on a resizable-handle
  5344. if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle'))
  5345. return false;
  5346. //Quit if we're not on a valid handle
  5347. this.handle = this._getHandle(event);
  5348. if (!this.handle)
  5349. return false;
  5350. $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
  5351. $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')
  5352. .css({
  5353. width: this.offsetWidth+"px", height: this.offsetHeight+"px",
  5354. position: "absolute", opacity: "0.001", zIndex: 1000
  5355. })
  5356. .css($(this).offset())
  5357. .appendTo("body");
  5358. });
  5359. return true;
  5360. },
  5361. _mouseStart: function(event) {
  5362. var o = this.options;
  5363. //Create and append the visible helper
  5364. this.helper = this._createHelper(event);
  5365. this.helper.addClass("ui-draggable-dragging");
  5366. //Cache the helper size
  5367. this._cacheHelperProportions();
  5368. //If ddmanager is used for droppables, set the global draggable
  5369. if($.ui.ddmanager)
  5370. $.ui.ddmanager.current = this;
  5371. /*
  5372. * - Position generation -
  5373. * This block generates everything position related - it's the core of draggables.
  5374. */
  5375. //Cache the margins of the original element
  5376. this._cacheMargins();
  5377. //Store the helper's css position
  5378. this.cssPosition = this.helper.css("position");
  5379. this.scrollParent = this.helper.scrollParent();
  5380. //The element's absolute position on the page minus margins
  5381. this.offset = this.positionAbs = this.element.offset();
  5382. this.offset = {
  5383. top: this.offset.top - this.margins.top,
  5384. left: this.offset.left - this.margins.left
  5385. };
  5386. $.extend(this.offset, {
  5387. click: { //Where the click happened, relative to the element
  5388. left: event.pageX - this.offset.left,
  5389. top: event.pageY - this.offset.top
  5390. },
  5391. parent: this._getParentOffset(),
  5392. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  5393. });
  5394. //Generate the original position
  5395. this.originalPosition = this.position = this._generatePosition(event);
  5396. this.originalPageX = event.pageX;
  5397. this.originalPageY = event.pageY;
  5398. //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
  5399. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  5400. //Set a containment if given in the options
  5401. if(o.containment)
  5402. this._setContainment();
  5403. //Trigger event + callbacks
  5404. if(this._trigger("start", event) === false) {
  5405. this._clear();
  5406. return false;
  5407. }
  5408. //Recache the helper size
  5409. this._cacheHelperProportions();
  5410. //Prepare the droppable offsets
  5411. if ($.ui.ddmanager && !o.dropBehaviour)
  5412. $.ui.ddmanager.prepareOffsets(this, event);
  5413. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  5414. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  5415. if ( $.ui.ddmanager ) $.ui.ddmanager.dragStart(this, event);
  5416. return true;
  5417. },
  5418. _mouseDrag: function(event, noPropagation) {
  5419. //Compute the helpers position
  5420. this.position = this._generatePosition(event);
  5421. this.positionAbs = this._convertPositionTo("absolute");
  5422. //Call plugins and callbacks and use the resulting position if something is returned
  5423. if (!noPropagation) {
  5424. var ui = this._uiHash();
  5425. if(this._trigger('drag', event, ui) === false) {
  5426. this._mouseUp({});
  5427. return false;
  5428. }
  5429. this.position = ui.position;
  5430. }
  5431. if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
  5432. if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
  5433. if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
  5434. return false;
  5435. },
  5436. _mouseStop: function(event) {
  5437. //If we are using droppables, inform the manager about the drop
  5438. var dropped = false;
  5439. if ($.ui.ddmanager && !this.options.dropBehaviour)
  5440. dropped = $.ui.ddmanager.drop(this, event);
  5441. //if a drop comes from outside (a sortable)
  5442. if(this.dropped) {
  5443. dropped = this.dropped;
  5444. this.dropped = false;
  5445. }
  5446. //if the original element is no longer in the DOM don't bother to continue (see #8269)
  5447. var element = this.element[0], elementInDom = false;
  5448. while ( element && (element = element.parentNode) ) {
  5449. if (element == document ) {
  5450. elementInDom = true;
  5451. }
  5452. }
  5453. if ( !elementInDom && this.options.helper === "original" )
  5454. return false;
  5455. 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))) {
  5456. var that = this;
  5457. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  5458. if(that._trigger("stop", event) !== false) {
  5459. that._clear();
  5460. }
  5461. });
  5462. } else {
  5463. if(this._trigger("stop", event) !== false) {
  5464. this._clear();
  5465. }
  5466. }
  5467. return false;
  5468. },
  5469. _mouseUp: function(event) {
  5470. //Remove frame helpers
  5471. $("div.ui-draggable-iframeFix").each(function() {
  5472. this.parentNode.removeChild(this);
  5473. });
  5474. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  5475. if( $.ui.ddmanager ) $.ui.ddmanager.dragStop(this, event);
  5476. return $.ui.mouse.prototype._mouseUp.call(this, event);
  5477. },
  5478. cancel: function() {
  5479. if(this.helper.is(".ui-draggable-dragging")) {
  5480. this._mouseUp({});
  5481. } else {
  5482. this._clear();
  5483. }
  5484. return this;
  5485. },
  5486. _getHandle: function(event) {
  5487. var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
  5488. $(this.options.handle, this.element)
  5489. .find("*")
  5490. .andSelf()
  5491. .each(function() {
  5492. if(this == event.target) handle = true;
  5493. });
  5494. return handle;
  5495. },
  5496. _createHelper: function(event) {
  5497. var o = this.options;
  5498. var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone().removeAttr('id') : this.element);
  5499. if(!helper.parents('body').length)
  5500. helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));
  5501. if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position")))
  5502. helper.css("position", "absolute");
  5503. return helper;
  5504. },
  5505. _adjustOffsetFromHelper: function(obj) {
  5506. if (typeof obj == 'string') {
  5507. obj = obj.split(' ');
  5508. }
  5509. if ($.isArray(obj)) {
  5510. obj = {left: +obj[0], top: +obj[1] || 0};
  5511. }
  5512. if ('left' in obj) {
  5513. this.offset.click.left = obj.left + this.margins.left;
  5514. }
  5515. if ('right' in obj) {
  5516. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  5517. }
  5518. if ('top' in obj) {
  5519. this.offset.click.top = obj.top + this.margins.top;
  5520. }
  5521. if ('bottom' in obj) {
  5522. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  5523. }
  5524. },
  5525. _getParentOffset: function() {
  5526. //Get the offsetParent and cache its position
  5527. this.offsetParent = this.helper.offsetParent();
  5528. var po = this.offsetParent.offset();
  5529. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  5530. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  5531. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  5532. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  5533. if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  5534. po.left += this.scrollParent.scrollLeft();
  5535. po.top += this.scrollParent.scrollTop();
  5536. }
  5537. if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
  5538. || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
  5539. po = { top: 0, left: 0 };
  5540. return {
  5541. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  5542. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  5543. };
  5544. },
  5545. _getRelativeOffset: function() {
  5546. if(this.cssPosition == "relative") {
  5547. var p = this.element.position();
  5548. return {
  5549. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  5550. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  5551. };
  5552. } else {
  5553. return { top: 0, left: 0 };
  5554. }
  5555. },
  5556. _cacheMargins: function() {
  5557. this.margins = {
  5558. left: (parseInt(this.element.css("marginLeft"),10) || 0),
  5559. top: (parseInt(this.element.css("marginTop"),10) || 0),
  5560. right: (parseInt(this.element.css("marginRight"),10) || 0),
  5561. bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
  5562. };
  5563. },
  5564. _cacheHelperProportions: function() {
  5565. this.helperProportions = {
  5566. width: this.helper.outerWidth(),
  5567. height: this.helper.outerHeight()
  5568. };
  5569. },
  5570. _setContainment: function() {
  5571. var o = this.options;
  5572. if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
  5573. if(o.containment == 'document' || o.containment == 'window') this.containment = [
  5574. o.containment == 'document' ? 0 : $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  5575. o.containment == 'document' ? 0 : $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  5576. (o.containment == 'document' ? 0 : $(window).scrollLeft()) + $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
  5577. (o.containment == 'document' ? 0 : $(window).scrollTop()) + ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  5578. ];
  5579. if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) {
  5580. var c = $(o.containment);
  5581. var ce = c[0]; if(!ce) return;
  5582. var co = c.offset();
  5583. var over = ($(ce).css("overflow") != 'hidden');
  5584. this.containment = [
  5585. (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0),
  5586. (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0),
  5587. (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 - this.margins.right,
  5588. (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 - this.margins.bottom
  5589. ];
  5590. this.relative_container = c;
  5591. } else if(o.containment.constructor == Array) {
  5592. this.containment = o.containment;
  5593. }
  5594. },
  5595. _convertPositionTo: function(d, pos) {
  5596. if(!pos) pos = this.position;
  5597. var mod = d == "absolute" ? 1 : -1;
  5598. var o = this.options, 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);
  5599. return {
  5600. top: (
  5601. pos.top // The absolute mouse position
  5602. + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent
  5603. + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
  5604. - ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  5605. ),
  5606. left: (
  5607. pos.left // The absolute mouse position
  5608. + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent
  5609. + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
  5610. - ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  5611. )
  5612. };
  5613. },
  5614. _generatePosition: function(event) {
  5615. var o = this.options, 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);
  5616. var pageX = event.pageX;
  5617. var pageY = event.pageY;
  5618. /*
  5619. * - Position constraining -
  5620. * Constrain the position to a mix of grid, containment.
  5621. */
  5622. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  5623. var containment;
  5624. if(this.containment) {
  5625. if (this.relative_container){
  5626. var co = this.relative_container.offset();
  5627. containment = [ this.containment[0] + co.left,
  5628. this.containment[1] + co.top,
  5629. this.containment[2] + co.left,
  5630. this.containment[3] + co.top ];
  5631. }
  5632. else {
  5633. containment = this.containment;
  5634. }
  5635. if(event.pageX - this.offset.click.left < containment[0]) pageX = containment[0] + this.offset.click.left;
  5636. if(event.pageY - this.offset.click.top < containment[1]) pageY = containment[1] + this.offset.click.top;
  5637. if(event.pageX - this.offset.click.left > containment[2]) pageX = containment[2] + this.offset.click.left;
  5638. if(event.pageY - this.offset.click.top > containment[3]) pageY = containment[3] + this.offset.click.top;
  5639. }
  5640. if(o.grid) {
  5641. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  5642. var top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  5643. 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;
  5644. var left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  5645. 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;
  5646. }
  5647. }
  5648. return {
  5649. top: (
  5650. pageY // The absolute mouse position
  5651. - this.offset.click.top // Click offset (relative to the element)
  5652. - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent
  5653. - this.offset.parent.top // The offsetParent's offset without borders (offset + border)
  5654. + ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  5655. ),
  5656. left: (
  5657. pageX // The absolute mouse position
  5658. - this.offset.click.left // Click offset (relative to the element)
  5659. - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent
  5660. - this.offset.parent.left // The offsetParent's offset without borders (offset + border)
  5661. + ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  5662. )
  5663. };
  5664. },
  5665. _clear: function() {
  5666. this.helper.removeClass("ui-draggable-dragging");
  5667. if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove();
  5668. //if($.ui.ddmanager) $.ui.ddmanager.current = null;
  5669. this.helper = null;
  5670. this.cancelHelperRemoval = false;
  5671. },
  5672. // From now on bulk stuff - mainly helpers
  5673. _trigger: function(type, event, ui) {
  5674. ui = ui || this._uiHash();
  5675. $.ui.plugin.call(this, type, [event, ui]);
  5676. if(type == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins
  5677. return $.Widget.prototype._trigger.call(this, type, event, ui);
  5678. },
  5679. plugins: {},
  5680. _uiHash: function(event) {
  5681. return {
  5682. helper: this.helper,
  5683. position: this.position,
  5684. originalPosition: this.originalPosition,
  5685. offset: this.positionAbs
  5686. };
  5687. }
  5688. });
  5689. $.ui.plugin.add("draggable", "connectToSortable", {
  5690. start: function(event, ui) {
  5691. var inst = $(this).data("draggable"), o = inst.options,
  5692. uiSortable = $.extend({}, ui, { item: inst.element });
  5693. inst.sortables = [];
  5694. $(o.connectToSortable).each(function() {
  5695. var sortable = $.data(this, 'sortable');
  5696. if (sortable && !sortable.options.disabled) {
  5697. inst.sortables.push({
  5698. instance: sortable,
  5699. shouldRevert: sortable.options.revert
  5700. });
  5701. 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).
  5702. sortable._trigger("activate", event, uiSortable);
  5703. }
  5704. });
  5705. },
  5706. stop: function(event, ui) {
  5707. //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
  5708. var inst = $(this).data("draggable"),
  5709. uiSortable = $.extend({}, ui, { item: inst.element });
  5710. $.each(inst.sortables, function() {
  5711. if(this.instance.isOver) {
  5712. this.instance.isOver = 0;
  5713. inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
  5714. this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
  5715. //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: 'valid/invalid'
  5716. if(this.shouldRevert) this.instance.options.revert = true;
  5717. //Trigger the stop of the sortable
  5718. this.instance._mouseStop(event);
  5719. this.instance.options.helper = this.instance.options._helper;
  5720. //If the helper has been the original item, restore properties in the sortable
  5721. if(inst.options.helper == 'original')
  5722. this.instance.currentItem.css({ top: 'auto', left: 'auto' });
  5723. } else {
  5724. this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
  5725. this.instance._trigger("deactivate", event, uiSortable);
  5726. }
  5727. });
  5728. },
  5729. drag: function(event, ui) {
  5730. var inst = $(this).data("draggable"), that = this;
  5731. var checkPos = function(o) {
  5732. var dyClick = this.offset.click.top, dxClick = this.offset.click.left;
  5733. var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left;
  5734. var itemHeight = o.height, itemWidth = o.width;
  5735. var itemTop = o.top, itemLeft = o.left;
  5736. return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth);
  5737. };
  5738. $.each(inst.sortables, function(i) {
  5739. //Copy over some variables to allow calling the sortable's native _intersectsWith
  5740. this.instance.positionAbs = inst.positionAbs;
  5741. this.instance.helperProportions = inst.helperProportions;
  5742. this.instance.offset.click = inst.offset.click;
  5743. if(this.instance._intersectsWith(this.instance.containerCache)) {
  5744. //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
  5745. if(!this.instance.isOver) {
  5746. this.instance.isOver = 1;
  5747. //Now we fake the start of dragging for the sortable instance,
  5748. //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
  5749. //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)
  5750. this.instance.currentItem = $(that).clone().removeAttr('id').appendTo(this.instance.element).data("sortable-item", true);
  5751. this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
  5752. this.instance.options.helper = function() { return ui.helper[0]; };
  5753. event.target = this.instance.currentItem[0];
  5754. this.instance._mouseCapture(event, true);
  5755. this.instance._mouseStart(event, true, true);
  5756. //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
  5757. this.instance.offset.click.top = inst.offset.click.top;
  5758. this.instance.offset.click.left = inst.offset.click.left;
  5759. this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
  5760. this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
  5761. inst._trigger("toSortable", event);
  5762. inst.dropped = this.instance.element; //draggable revert needs that
  5763. //hack so receive/update callbacks work (mostly)
  5764. inst.currentItem = inst.element;
  5765. this.instance.fromOutside = inst;
  5766. }
  5767. //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
  5768. if(this.instance.currentItem) this.instance._mouseDrag(event);
  5769. } else {
  5770. //If it doesn't intersect with the sortable, and it intersected before,
  5771. //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
  5772. if(this.instance.isOver) {
  5773. this.instance.isOver = 0;
  5774. this.instance.cancelHelperRemoval = true;
  5775. //Prevent reverting on this forced stop
  5776. this.instance.options.revert = false;
  5777. // The out event needs to be triggered independently
  5778. this.instance._trigger('out', event, this.instance._uiHash(this.instance));
  5779. this.instance._mouseStop(event, true);
  5780. this.instance.options.helper = this.instance.options._helper;
  5781. //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
  5782. this.instance.currentItem.remove();
  5783. if(this.instance.placeholder) this.instance.placeholder.remove();
  5784. inst._trigger("fromSortable", event);
  5785. inst.dropped = false; //draggable revert needs that
  5786. }
  5787. };
  5788. });
  5789. }
  5790. });
  5791. $.ui.plugin.add("draggable", "cursor", {
  5792. start: function(event, ui) {
  5793. var t = $('body'), o = $(this).data('draggable').options;
  5794. if (t.css("cursor")) o._cursor = t.css("cursor");
  5795. t.css("cursor", o.cursor);
  5796. },
  5797. stop: function(event, ui) {
  5798. var o = $(this).data('draggable').options;
  5799. if (o._cursor) $('body').css("cursor", o._cursor);
  5800. }
  5801. });
  5802. $.ui.plugin.add("draggable", "opacity", {
  5803. start: function(event, ui) {
  5804. var t = $(ui.helper), o = $(this).data('draggable').options;
  5805. if(t.css("opacity")) o._opacity = t.css("opacity");
  5806. t.css('opacity', o.opacity);
  5807. },
  5808. stop: function(event, ui) {
  5809. var o = $(this).data('draggable').options;
  5810. if(o._opacity) $(ui.helper).css('opacity', o._opacity);
  5811. }
  5812. });
  5813. $.ui.plugin.add("draggable", "scroll", {
  5814. start: function(event, ui) {
  5815. var i = $(this).data("draggable");
  5816. if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') i.overflowOffset = i.scrollParent.offset();
  5817. },
  5818. drag: function(event, ui) {
  5819. var i = $(this).data("draggable"), o = i.options, scrolled = false;
  5820. if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') {
  5821. if(!o.axis || o.axis != 'x') {
  5822. if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
  5823. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
  5824. else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity)
  5825. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
  5826. }
  5827. if(!o.axis || o.axis != 'y') {
  5828. if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
  5829. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
  5830. else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity)
  5831. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
  5832. }
  5833. } else {
  5834. if(!o.axis || o.axis != 'x') {
  5835. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
  5836. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  5837. else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
  5838. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  5839. }
  5840. if(!o.axis || o.axis != 'y') {
  5841. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
  5842. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  5843. else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
  5844. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  5845. }
  5846. }
  5847. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
  5848. $.ui.ddmanager.prepareOffsets(i, event);
  5849. }
  5850. });
  5851. $.ui.plugin.add("draggable", "snap", {
  5852. start: function(event, ui) {
  5853. var i = $(this).data("draggable"), o = i.options;
  5854. i.snapElements = [];
  5855. $(o.snap.constructor != String ? ( o.snap.items || ':data(draggable)' ) : o.snap).each(function() {
  5856. var $t = $(this); var $o = $t.offset();
  5857. if(this != i.element[0]) i.snapElements.push({
  5858. item: this,
  5859. width: $t.outerWidth(), height: $t.outerHeight(),
  5860. top: $o.top, left: $o.left
  5861. });
  5862. });
  5863. },
  5864. drag: function(event, ui) {
  5865. var inst = $(this).data("draggable"), o = inst.options;
  5866. var d = o.snapTolerance;
  5867. var x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  5868. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  5869. for (var i = inst.snapElements.length - 1; i >= 0; i--){
  5870. var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width,
  5871. t = inst.snapElements[i].top, b = t + inst.snapElements[i].height;
  5872. //Yes, I know, this is insane ;)
  5873. if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) {
  5874. if(inst.snapElements[i].snapping) (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  5875. inst.snapElements[i].snapping = false;
  5876. continue;
  5877. }
  5878. if(o.snapMode != 'inner') {
  5879. var ts = Math.abs(t - y2) <= d;
  5880. var bs = Math.abs(b - y1) <= d;
  5881. var ls = Math.abs(l - x2) <= d;
  5882. var rs = Math.abs(r - x1) <= d;
  5883. if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  5884. if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
  5885. if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
  5886. if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
  5887. }
  5888. var first = (ts || bs || ls || rs);
  5889. if(o.snapMode != 'outer') {
  5890. var ts = Math.abs(t - y1) <= d;
  5891. var bs = Math.abs(b - y2) <= d;
  5892. var ls = Math.abs(l - x1) <= d;
  5893. var rs = Math.abs(r - x2) <= d;
  5894. if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
  5895. if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  5896. if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
  5897. if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
  5898. }
  5899. if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first))
  5900. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  5901. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  5902. };
  5903. }
  5904. });
  5905. $.ui.plugin.add("draggable", "stack", {
  5906. start: function(event, ui) {
  5907. var o = $(this).data("draggable").options;
  5908. var group = $.makeArray($(o.stack)).sort(function(a,b) {
  5909. return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
  5910. });
  5911. if (!group.length) { return; }
  5912. var min = parseInt(group[0].style.zIndex) || 0;
  5913. $(group).each(function(i) {
  5914. this.style.zIndex = min + i;
  5915. });
  5916. this[0].style.zIndex = min + group.length;
  5917. }
  5918. });
  5919. $.ui.plugin.add("draggable", "zIndex", {
  5920. start: function(event, ui) {
  5921. var t = $(ui.helper), o = $(this).data("draggable").options;
  5922. if(t.css("zIndex")) o._zIndex = t.css("zIndex");
  5923. t.css('zIndex', o.zIndex);
  5924. },
  5925. stop: function(event, ui) {
  5926. var o = $(this).data("draggable").options;
  5927. if(o._zIndex) $(ui.helper).css('zIndex', o._zIndex);
  5928. }
  5929. });
  5930. })(jQuery);
  5931. (function( $, undefined ) {
  5932. $.widget("ui.droppable", {
  5933. version: "1.9.0",
  5934. widgetEventPrefix: "drop",
  5935. options: {
  5936. accept: '*',
  5937. activeClass: false,
  5938. addClasses: true,
  5939. greedy: false,
  5940. hoverClass: false,
  5941. scope: 'default',
  5942. tolerance: 'intersect'
  5943. },
  5944. _create: function() {
  5945. var o = this.options, accept = o.accept;
  5946. this.isover = 0; this.isout = 1;
  5947. this.accept = $.isFunction(accept) ? accept : function(d) {
  5948. return d.is(accept);
  5949. };
  5950. //Store the droppable's proportions
  5951. this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
  5952. // Add the reference and positions to the manager
  5953. $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
  5954. $.ui.ddmanager.droppables[o.scope].push(this);
  5955. (o.addClasses && this.element.addClass("ui-droppable"));
  5956. },
  5957. _destroy: function() {
  5958. var drop = $.ui.ddmanager.droppables[this.options.scope];
  5959. for ( var i = 0; i < drop.length; i++ )
  5960. if ( drop[i] == this )
  5961. drop.splice(i, 1);
  5962. this.element.removeClass("ui-droppable ui-droppable-disabled");
  5963. },
  5964. _setOption: function(key, value) {
  5965. if(key == 'accept') {
  5966. this.accept = $.isFunction(value) ? value : function(d) {
  5967. return d.is(value);
  5968. };
  5969. }
  5970. $.Widget.prototype._setOption.apply(this, arguments);
  5971. },
  5972. _activate: function(event) {
  5973. var draggable = $.ui.ddmanager.current;
  5974. if(this.options.activeClass) this.element.addClass(this.options.activeClass);
  5975. (draggable && this._trigger('activate', event, this.ui(draggable)));
  5976. },
  5977. _deactivate: function(event) {
  5978. var draggable = $.ui.ddmanager.current;
  5979. if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
  5980. (draggable && this._trigger('deactivate', event, this.ui(draggable)));
  5981. },
  5982. _over: function(event) {
  5983. var draggable = $.ui.ddmanager.current;
  5984. if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
  5985. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  5986. if(this.options.hoverClass) this.element.addClass(this.options.hoverClass);
  5987. this._trigger('over', event, this.ui(draggable));
  5988. }
  5989. },
  5990. _out: function(event) {
  5991. var draggable = $.ui.ddmanager.current;
  5992. if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
  5993. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  5994. if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
  5995. this._trigger('out', event, this.ui(draggable));
  5996. }
  5997. },
  5998. _drop: function(event,custom) {
  5999. var draggable = custom || $.ui.ddmanager.current;
  6000. if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false; // Bail if draggable and droppable are same element
  6001. var childrenIntersection = false;
  6002. this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function() {
  6003. var inst = $.data(this, 'droppable');
  6004. if(
  6005. inst.options.greedy
  6006. && !inst.options.disabled
  6007. && inst.options.scope == draggable.options.scope
  6008. && inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element))
  6009. && $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
  6010. ) { childrenIntersection = true; return false; }
  6011. });
  6012. if(childrenIntersection) return false;
  6013. if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  6014. if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
  6015. if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
  6016. this._trigger('drop', event, this.ui(draggable));
  6017. return this.element;
  6018. }
  6019. return false;
  6020. },
  6021. ui: function(c) {
  6022. return {
  6023. draggable: (c.currentItem || c.element),
  6024. helper: c.helper,
  6025. position: c.position,
  6026. offset: c.positionAbs
  6027. };
  6028. }
  6029. });
  6030. $.ui.intersect = function(draggable, droppable, toleranceMode) {
  6031. if (!droppable.offset) return false;
  6032. var x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
  6033. y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height;
  6034. var l = droppable.offset.left, r = l + droppable.proportions.width,
  6035. t = droppable.offset.top, b = t + droppable.proportions.height;
  6036. switch (toleranceMode) {
  6037. case 'fit':
  6038. return (l <= x1 && x2 <= r
  6039. && t <= y1 && y2 <= b);
  6040. break;
  6041. case 'intersect':
  6042. return (l < x1 + (draggable.helperProportions.width / 2) // Right Half
  6043. && x2 - (draggable.helperProportions.width / 2) < r // Left Half
  6044. && t < y1 + (draggable.helperProportions.height / 2) // Bottom Half
  6045. && y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
  6046. break;
  6047. case 'pointer':
  6048. var draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left),
  6049. draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top),
  6050. isOver = $.ui.isOver(draggableTop, draggableLeft, t, l, droppable.proportions.height, droppable.proportions.width);
  6051. return isOver;
  6052. break;
  6053. case 'touch':
  6054. return (
  6055. (y1 >= t && y1 <= b) || // Top edge touching
  6056. (y2 >= t && y2 <= b) || // Bottom edge touching
  6057. (y1 < t && y2 > b) // Surrounded vertically
  6058. ) && (
  6059. (x1 >= l && x1 <= r) || // Left edge touching
  6060. (x2 >= l && x2 <= r) || // Right edge touching
  6061. (x1 < l && x2 > r) // Surrounded horizontally
  6062. );
  6063. break;
  6064. default:
  6065. return false;
  6066. break;
  6067. }
  6068. };
  6069. /*
  6070. This manager tracks offsets of draggables and droppables
  6071. */
  6072. $.ui.ddmanager = {
  6073. current: null,
  6074. droppables: { 'default': [] },
  6075. prepareOffsets: function(t, event) {
  6076. var m = $.ui.ddmanager.droppables[t.options.scope] || [];
  6077. var type = event ? event.type : null; // workaround for #2317
  6078. var list = (t.currentItem || t.element).find(":data(droppable)").andSelf();
  6079. droppablesLoop: for (var i = 0; i < m.length; i++) {
  6080. if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) continue; //No disabled and non-accepted
  6081. for (var j=0; j < list.length; j++) { if(list[j] == m[i].element[0]) { m[i].proportions.height = 0; continue droppablesLoop; } }; //Filter out elements in the current dragged item
  6082. m[i].visible = m[i].element.css("display") != "none"; if(!m[i].visible) continue; //If the element is not visible, continue
  6083. if(type == "mousedown") m[i]._activate.call(m[i], event); //Activate the droppable if used directly from draggables
  6084. m[i].offset = m[i].element.offset();
  6085. m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
  6086. }
  6087. },
  6088. drop: function(draggable, event) {
  6089. var dropped = false;
  6090. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  6091. if(!this.options) return;
  6092. if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance))
  6093. dropped = this._drop.call(this, event) || dropped;
  6094. if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  6095. this.isout = 1; this.isover = 0;
  6096. this._deactivate.call(this, event);
  6097. }
  6098. });
  6099. return dropped;
  6100. },
  6101. dragStart: function( draggable, event ) {
  6102. //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  6103. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  6104. if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
  6105. });
  6106. },
  6107. drag: function(draggable, event) {
  6108. //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  6109. if(draggable.options.refreshPositions) $.ui.ddmanager.prepareOffsets(draggable, event);
  6110. //Run through all droppables and check their positions based on specific tolerance options
  6111. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  6112. if(this.options.disabled || this.greedyChild || !this.visible) return;
  6113. var intersects = $.ui.intersect(draggable, this, this.options.tolerance);
  6114. var c = !intersects && this.isover == 1 ? 'isout' : (intersects && this.isover == 0 ? 'isover' : null);
  6115. if(!c) return;
  6116. var parentInstance;
  6117. if (this.options.greedy) {
  6118. // find droppable parents with same scope
  6119. var scope = this.options.scope;
  6120. var parent = this.element.parents(':data(droppable)').filter(function () {
  6121. return $.data(this, 'droppable').options.scope === scope;
  6122. });
  6123. if (parent.length) {
  6124. parentInstance = $.data(parent[0], 'droppable');
  6125. parentInstance.greedyChild = (c == 'isover' ? 1 : 0);
  6126. }
  6127. }
  6128. // we just moved into a greedy child
  6129. if (parentInstance && c == 'isover') {
  6130. parentInstance['isover'] = 0;
  6131. parentInstance['isout'] = 1;
  6132. parentInstance._out.call(parentInstance, event);
  6133. }
  6134. this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0;
  6135. this[c == "isover" ? "_over" : "_out"].call(this, event);
  6136. // we just moved out of a greedy child
  6137. if (parentInstance && c == 'isout') {
  6138. parentInstance['isout'] = 0;
  6139. parentInstance['isover'] = 1;
  6140. parentInstance._over.call(parentInstance, event);
  6141. }
  6142. });
  6143. },
  6144. dragStop: function( draggable, event ) {
  6145. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  6146. //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  6147. if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
  6148. }
  6149. };
  6150. })(jQuery);
  6151. ;(jQuery.effects || (function($, undefined) {
  6152. var backCompat = $.uiBackCompat !== false,
  6153. // prefix used for storing data on .data()
  6154. dataSpace = "ui-effects-";
  6155. $.effects = {
  6156. effect: {}
  6157. };
  6158. /*!
  6159. * jQuery Color Animations v2.0.0
  6160. * http://jquery.com/
  6161. *
  6162. * Copyright 2012 jQuery Foundation and other contributors
  6163. * Released under the MIT license.
  6164. * http://jquery.org/license
  6165. *
  6166. * Date: Mon Aug 13 13:41:02 2012 -0500
  6167. */
  6168. (function( jQuery, undefined ) {
  6169. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor".split(" "),
  6170. // plusequals test for += 100 -= 100
  6171. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  6172. // a set of RE's that can match strings and generate color tuples.
  6173. stringParsers = [{
  6174. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
  6175. parse: function( execResult ) {
  6176. return [
  6177. execResult[ 1 ],
  6178. execResult[ 2 ],
  6179. execResult[ 3 ],
  6180. execResult[ 4 ]
  6181. ];
  6182. }
  6183. }, {
  6184. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
  6185. parse: function( execResult ) {
  6186. return [
  6187. execResult[ 1 ] * 2.55,
  6188. execResult[ 2 ] * 2.55,
  6189. execResult[ 3 ] * 2.55,
  6190. execResult[ 4 ]
  6191. ];
  6192. }
  6193. }, {
  6194. // this regex ignores A-F because it's compared against an already lowercased string
  6195. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  6196. parse: function( execResult ) {
  6197. return [
  6198. parseInt( execResult[ 1 ], 16 ),
  6199. parseInt( execResult[ 2 ], 16 ),
  6200. parseInt( execResult[ 3 ], 16 )
  6201. ];
  6202. }
  6203. }, {
  6204. // this regex ignores A-F because it's compared against an already lowercased string
  6205. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  6206. parse: function( execResult ) {
  6207. return [
  6208. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  6209. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  6210. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  6211. ];
  6212. }
  6213. }, {
  6214. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
  6215. space: "hsla",
  6216. parse: function( execResult ) {
  6217. return [
  6218. execResult[ 1 ],
  6219. execResult[ 2 ] / 100,
  6220. execResult[ 3 ] / 100,
  6221. execResult[ 4 ]
  6222. ];
  6223. }
  6224. }],
  6225. // jQuery.Color( )
  6226. color = jQuery.Color = function( color, green, blue, alpha ) {
  6227. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  6228. },
  6229. spaces = {
  6230. rgba: {
  6231. props: {
  6232. red: {
  6233. idx: 0,
  6234. type: "byte"
  6235. },
  6236. green: {
  6237. idx: 1,
  6238. type: "byte"
  6239. },
  6240. blue: {
  6241. idx: 2,
  6242. type: "byte"
  6243. }
  6244. }
  6245. },
  6246. hsla: {
  6247. props: {
  6248. hue: {
  6249. idx: 0,
  6250. type: "degrees"
  6251. },
  6252. saturation: {
  6253. idx: 1,
  6254. type: "percent"
  6255. },
  6256. lightness: {
  6257. idx: 2,
  6258. type: "percent"
  6259. }
  6260. }
  6261. }
  6262. },
  6263. propTypes = {
  6264. "byte": {
  6265. floor: true,
  6266. max: 255
  6267. },
  6268. "percent": {
  6269. max: 1
  6270. },
  6271. "degrees": {
  6272. mod: 360,
  6273. floor: true
  6274. }
  6275. },
  6276. support = color.support = {},
  6277. // element for support tests
  6278. supportElem = jQuery( "<p>" )[ 0 ],
  6279. // colors = jQuery.Color.names
  6280. colors,
  6281. // local aliases of functions called often
  6282. each = jQuery.each;
  6283. // determine rgba support immediately
  6284. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  6285. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  6286. // define cache name and alpha properties
  6287. // for rgba and hsla spaces
  6288. each( spaces, function( spaceName, space ) {
  6289. space.cache = "_" + spaceName;
  6290. space.props.alpha = {
  6291. idx: 3,
  6292. type: "percent",
  6293. def: 1
  6294. };
  6295. });
  6296. function clamp( value, prop, allowEmpty ) {
  6297. var type = propTypes[ prop.type ] || {};
  6298. if ( value == null ) {
  6299. return (allowEmpty || !prop.def) ? null : prop.def;
  6300. }
  6301. // ~~ is an short way of doing floor for positive numbers
  6302. value = type.floor ? ~~value : parseFloat( value );
  6303. // IE will pass in empty strings as value for alpha,
  6304. // which will hit this case
  6305. if ( isNaN( value ) ) {
  6306. return prop.def;
  6307. }
  6308. if ( type.mod ) {
  6309. // we add mod before modding to make sure that negatives values
  6310. // get converted properly: -10 -> 350
  6311. return (value + type.mod) % type.mod;
  6312. }
  6313. // for now all property types without mod have min and max
  6314. return 0 > value ? 0 : type.max < value ? type.max : value;
  6315. }
  6316. function stringParse( string ) {
  6317. var inst = color(),
  6318. rgba = inst._rgba = [];
  6319. string = string.toLowerCase();
  6320. each( stringParsers, function( i, parser ) {
  6321. var parsed,
  6322. match = parser.re.exec( string ),
  6323. values = match && parser.parse( match ),
  6324. spaceName = parser.space || "rgba";
  6325. if ( values ) {
  6326. parsed = inst[ spaceName ]( values );
  6327. // if this was an rgba parse the assignment might happen twice
  6328. // oh well....
  6329. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  6330. rgba = inst._rgba = parsed._rgba;
  6331. // exit each( stringParsers ) here because we matched
  6332. return false;
  6333. }
  6334. });
  6335. // Found a stringParser that handled it
  6336. if ( rgba.length ) {
  6337. // if this came from a parsed string, force "transparent" when alpha is 0
  6338. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  6339. if ( rgba.join() === "0,0,0,0" ) {
  6340. jQuery.extend( rgba, colors.transparent );
  6341. }
  6342. return inst;
  6343. }
  6344. // named colors
  6345. return colors[ string ];
  6346. }
  6347. color.fn = jQuery.extend( color.prototype, {
  6348. parse: function( red, green, blue, alpha ) {
  6349. if ( red === undefined ) {
  6350. this._rgba = [ null, null, null, null ];
  6351. return this;
  6352. }
  6353. if ( red.jquery || red.nodeType ) {
  6354. red = jQuery( red ).css( green );
  6355. green = undefined;
  6356. }
  6357. var inst = this,
  6358. type = jQuery.type( red ),
  6359. rgba = this._rgba = [],
  6360. source;
  6361. // more than 1 argument specified - assume ( red, green, blue, alpha )
  6362. if ( green !== undefined ) {
  6363. red = [ red, green, blue, alpha ];
  6364. type = "array";
  6365. }
  6366. if ( type === "string" ) {
  6367. return this.parse( stringParse( red ) || colors._default );
  6368. }
  6369. if ( type === "array" ) {
  6370. each( spaces.rgba.props, function( key, prop ) {
  6371. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  6372. });
  6373. return this;
  6374. }
  6375. if ( type === "object" ) {
  6376. if ( red instanceof color ) {
  6377. each( spaces, function( spaceName, space ) {
  6378. if ( red[ space.cache ] ) {
  6379. inst[ space.cache ] = red[ space.cache ].slice();
  6380. }
  6381. });
  6382. } else {
  6383. each( spaces, function( spaceName, space ) {
  6384. var cache = space.cache;
  6385. each( space.props, function( key, prop ) {
  6386. // if the cache doesn't exist, and we know how to convert
  6387. if ( !inst[ cache ] && space.to ) {
  6388. // if the value was null, we don't need to copy it
  6389. // if the key was alpha, we don't need to copy it either
  6390. if ( key === "alpha" || red[ key ] == null ) {
  6391. return;
  6392. }
  6393. inst[ cache ] = space.to( inst._rgba );
  6394. }
  6395. // this is the only case where we allow nulls for ALL properties.
  6396. // call clamp with alwaysAllowEmpty
  6397. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  6398. });
  6399. // everything defined but alpha?
  6400. if ( inst[ cache ] && $.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  6401. // use the default of 1
  6402. inst[ cache ][ 3 ] = 1;
  6403. if ( space.from ) {
  6404. inst._rgba = space.from( inst[ cache ] );
  6405. }
  6406. }
  6407. });
  6408. }
  6409. return this;
  6410. }
  6411. },
  6412. is: function( compare ) {
  6413. var is = color( compare ),
  6414. same = true,
  6415. inst = this;
  6416. each( spaces, function( _, space ) {
  6417. var localCache,
  6418. isCache = is[ space.cache ];
  6419. if (isCache) {
  6420. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  6421. each( space.props, function( _, prop ) {
  6422. if ( isCache[ prop.idx ] != null ) {
  6423. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  6424. return same;
  6425. }
  6426. });
  6427. }
  6428. return same;
  6429. });
  6430. return same;
  6431. },
  6432. _space: function() {
  6433. var used = [],
  6434. inst = this;
  6435. each( spaces, function( spaceName, space ) {
  6436. if ( inst[ space.cache ] ) {
  6437. used.push( spaceName );
  6438. }
  6439. });
  6440. return used.pop();
  6441. },
  6442. transition: function( other, distance ) {
  6443. var end = color( other ),
  6444. spaceName = end._space(),
  6445. space = spaces[ spaceName ],
  6446. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  6447. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  6448. result = start.slice();
  6449. end = end[ space.cache ];
  6450. each( space.props, function( key, prop ) {
  6451. var index = prop.idx,
  6452. startValue = start[ index ],
  6453. endValue = end[ index ],
  6454. type = propTypes[ prop.type ] || {};
  6455. // if null, don't override start value
  6456. if ( endValue === null ) {
  6457. return;
  6458. }
  6459. // if null - use end
  6460. if ( startValue === null ) {
  6461. result[ index ] = endValue;
  6462. } else {
  6463. if ( type.mod ) {
  6464. if ( endValue - startValue > type.mod / 2 ) {
  6465. startValue += type.mod;
  6466. } else if ( startValue - endValue > type.mod / 2 ) {
  6467. startValue -= type.mod;
  6468. }
  6469. }
  6470. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  6471. }
  6472. });
  6473. return this[ spaceName ]( result );
  6474. },
  6475. blend: function( opaque ) {
  6476. // if we are already opaque - return ourself
  6477. if ( this._rgba[ 3 ] === 1 ) {
  6478. return this;
  6479. }
  6480. var rgb = this._rgba.slice(),
  6481. a = rgb.pop(),
  6482. blend = color( opaque )._rgba;
  6483. return color( jQuery.map( rgb, function( v, i ) {
  6484. return ( 1 - a ) * blend[ i ] + a * v;
  6485. }));
  6486. },
  6487. toRgbaString: function() {
  6488. var prefix = "rgba(",
  6489. rgba = jQuery.map( this._rgba, function( v, i ) {
  6490. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  6491. });
  6492. if ( rgba[ 3 ] === 1 ) {
  6493. rgba.pop();
  6494. prefix = "rgb(";
  6495. }
  6496. return prefix + rgba.join() + ")";
  6497. },
  6498. toHslaString: function() {
  6499. var prefix = "hsla(",
  6500. hsla = jQuery.map( this.hsla(), function( v, i ) {
  6501. if ( v == null ) {
  6502. v = i > 2 ? 1 : 0;
  6503. }
  6504. // catch 1 and 2
  6505. if ( i && i < 3 ) {
  6506. v = Math.round( v * 100 ) + "%";
  6507. }
  6508. return v;
  6509. });
  6510. if ( hsla[ 3 ] === 1 ) {
  6511. hsla.pop();
  6512. prefix = "hsl(";
  6513. }
  6514. return prefix + hsla.join() + ")";
  6515. },
  6516. toHexString: function( includeAlpha ) {
  6517. var rgba = this._rgba.slice(),
  6518. alpha = rgba.pop();
  6519. if ( includeAlpha ) {
  6520. rgba.push( ~~( alpha * 255 ) );
  6521. }
  6522. return "#" + jQuery.map( rgba, function( v, i ) {
  6523. // default to 0 when nulls exist
  6524. v = ( v || 0 ).toString( 16 );
  6525. return v.length === 1 ? "0" + v : v;
  6526. }).join("");
  6527. },
  6528. toString: function() {
  6529. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  6530. }
  6531. });
  6532. color.fn.parse.prototype = color.fn;
  6533. // hsla conversions adapted from:
  6534. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  6535. function hue2rgb( p, q, h ) {
  6536. h = ( h + 1 ) % 1;
  6537. if ( h * 6 < 1 ) {
  6538. return p + (q - p) * h * 6;
  6539. }
  6540. if ( h * 2 < 1) {
  6541. return q;
  6542. }
  6543. if ( h * 3 < 2 ) {
  6544. return p + (q - p) * ((2/3) - h) * 6;
  6545. }
  6546. return p;
  6547. }
  6548. spaces.hsla.to = function ( rgba ) {
  6549. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  6550. return [ null, null, null, rgba[ 3 ] ];
  6551. }
  6552. var r = rgba[ 0 ] / 255,
  6553. g = rgba[ 1 ] / 255,
  6554. b = rgba[ 2 ] / 255,
  6555. a = rgba[ 3 ],
  6556. max = Math.max( r, g, b ),
  6557. min = Math.min( r, g, b ),
  6558. diff = max - min,
  6559. add = max + min,
  6560. l = add * 0.5,
  6561. h, s;
  6562. if ( min === max ) {
  6563. h = 0;
  6564. } else if ( r === max ) {
  6565. h = ( 60 * ( g - b ) / diff ) + 360;
  6566. } else if ( g === max ) {
  6567. h = ( 60 * ( b - r ) / diff ) + 120;
  6568. } else {
  6569. h = ( 60 * ( r - g ) / diff ) + 240;
  6570. }
  6571. if ( l === 0 || l === 1 ) {
  6572. s = l;
  6573. } else if ( l <= 0.5 ) {
  6574. s = diff / add;
  6575. } else {
  6576. s = diff / ( 2 - add );
  6577. }
  6578. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  6579. };
  6580. spaces.hsla.from = function ( hsla ) {
  6581. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  6582. return [ null, null, null, hsla[ 3 ] ];
  6583. }
  6584. var h = hsla[ 0 ] / 360,
  6585. s = hsla[ 1 ],
  6586. l = hsla[ 2 ],
  6587. a = hsla[ 3 ],
  6588. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  6589. p = 2 * l - q,
  6590. r, g, b;
  6591. return [
  6592. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  6593. Math.round( hue2rgb( p, q, h ) * 255 ),
  6594. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  6595. a
  6596. ];
  6597. };
  6598. each( spaces, function( spaceName, space ) {
  6599. var props = space.props,
  6600. cache = space.cache,
  6601. to = space.to,
  6602. from = space.from;
  6603. // makes rgba() and hsla()
  6604. color.fn[ spaceName ] = function( value ) {
  6605. // generate a cache for this space if it doesn't exist
  6606. if ( to && !this[ cache ] ) {
  6607. this[ cache ] = to( this._rgba );
  6608. }
  6609. if ( value === undefined ) {
  6610. return this[ cache ].slice();
  6611. }
  6612. var ret,
  6613. type = jQuery.type( value ),
  6614. arr = ( type === "array" || type === "object" ) ? value : arguments,
  6615. local = this[ cache ].slice();
  6616. each( props, function( key, prop ) {
  6617. var val = arr[ type === "object" ? key : prop.idx ];
  6618. if ( val == null ) {
  6619. val = local[ prop.idx ];
  6620. }
  6621. local[ prop.idx ] = clamp( val, prop );
  6622. });
  6623. if ( from ) {
  6624. ret = color( from( local ) );
  6625. ret[ cache ] = local;
  6626. return ret;
  6627. } else {
  6628. return color( local );
  6629. }
  6630. };
  6631. // makes red() green() blue() alpha() hue() saturation() lightness()
  6632. each( props, function( key, prop ) {
  6633. // alpha is included in more than one space
  6634. if ( color.fn[ key ] ) {
  6635. return;
  6636. }
  6637. color.fn[ key ] = function( value ) {
  6638. var vtype = jQuery.type( value ),
  6639. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  6640. local = this[ fn ](),
  6641. cur = local[ prop.idx ],
  6642. match;
  6643. if ( vtype === "undefined" ) {
  6644. return cur;
  6645. }
  6646. if ( vtype === "function" ) {
  6647. value = value.call( this, cur );
  6648. vtype = jQuery.type( value );
  6649. }
  6650. if ( value == null && prop.empty ) {
  6651. return this;
  6652. }
  6653. if ( vtype === "string" ) {
  6654. match = rplusequals.exec( value );
  6655. if ( match ) {
  6656. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  6657. }
  6658. }
  6659. local[ prop.idx ] = value;
  6660. return this[ fn ]( local );
  6661. };
  6662. });
  6663. });
  6664. // add .fx.step functions
  6665. each( stepHooks, function( i, hook ) {
  6666. jQuery.cssHooks[ hook ] = {
  6667. set: function( elem, value ) {
  6668. var parsed, curElem,
  6669. backgroundColor = "";
  6670. if ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) {
  6671. value = color( parsed || value );
  6672. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  6673. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  6674. while (
  6675. (backgroundColor === "" || backgroundColor === "transparent") &&
  6676. curElem && curElem.style
  6677. ) {
  6678. try {
  6679. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  6680. curElem = curElem.parentNode;
  6681. } catch ( e ) {
  6682. }
  6683. }
  6684. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  6685. backgroundColor :
  6686. "_default" );
  6687. }
  6688. value = value.toRgbaString();
  6689. }
  6690. try {
  6691. elem.style[ hook ] = value;
  6692. } catch( value ) {
  6693. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  6694. }
  6695. }
  6696. };
  6697. jQuery.fx.step[ hook ] = function( fx ) {
  6698. if ( !fx.colorInit ) {
  6699. fx.start = color( fx.elem, hook );
  6700. fx.end = color( fx.end );
  6701. fx.colorInit = true;
  6702. }
  6703. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  6704. };
  6705. });
  6706. jQuery.cssHooks.borderColor = {
  6707. expand: function( value ) {
  6708. var expanded = {};
  6709. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  6710. expanded[ "border" + part + "Color" ] = value;
  6711. });
  6712. return expanded;
  6713. }
  6714. };
  6715. // Basic color names only.
  6716. // Usage of any of the other color names requires adding yourself or including
  6717. // jquery.color.svg-names.js.
  6718. colors = jQuery.Color.names = {
  6719. // 4.1. Basic color keywords
  6720. aqua: "#00ffff",
  6721. black: "#000000",
  6722. blue: "#0000ff",
  6723. fuchsia: "#ff00ff",
  6724. gray: "#808080",
  6725. green: "#008000",
  6726. lime: "#00ff00",
  6727. maroon: "#800000",
  6728. navy: "#000080",
  6729. olive: "#808000",
  6730. purple: "#800080",
  6731. red: "#ff0000",
  6732. silver: "#c0c0c0",
  6733. teal: "#008080",
  6734. white: "#ffffff",
  6735. yellow: "#ffff00",
  6736. // 4.2.3. "transparent" color keyword
  6737. transparent: [ null, null, null, 0 ],
  6738. _default: "#ffffff"
  6739. };
  6740. })( jQuery );
  6741. /******************************************************************************/
  6742. /****************************** CLASS ANIMATIONS ******************************/
  6743. /******************************************************************************/
  6744. (function() {
  6745. var classAnimationActions = [ "add", "remove", "toggle" ],
  6746. shorthandStyles = {
  6747. border: 1,
  6748. borderBottom: 1,
  6749. borderColor: 1,
  6750. borderLeft: 1,
  6751. borderRight: 1,
  6752. borderTop: 1,
  6753. borderWidth: 1,
  6754. margin: 1,
  6755. padding: 1
  6756. };
  6757. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  6758. $.fx.step[ prop ] = function( fx ) {
  6759. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  6760. jQuery.style( fx.elem, prop, fx.end );
  6761. fx.setAttr = true;
  6762. }
  6763. };
  6764. });
  6765. function getElementStyles() {
  6766. var style = this.ownerDocument.defaultView ?
  6767. this.ownerDocument.defaultView.getComputedStyle( this, null ) :
  6768. this.currentStyle,
  6769. newStyle = {},
  6770. key,
  6771. camelCase,
  6772. len;
  6773. // webkit enumerates style porperties
  6774. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  6775. len = style.length;
  6776. while ( len-- ) {
  6777. key = style[ len ];
  6778. if ( typeof style[ key ] === "string" ) {
  6779. newStyle[ $.camelCase( key ) ] = style[ key ];
  6780. }
  6781. }
  6782. } else {
  6783. for ( key in style ) {
  6784. if ( typeof style[ key ] === "string" ) {
  6785. newStyle[ key ] = style[ key ];
  6786. }
  6787. }
  6788. }
  6789. return newStyle;
  6790. }
  6791. function styleDifference( oldStyle, newStyle ) {
  6792. var diff = {},
  6793. name, value;
  6794. for ( name in newStyle ) {
  6795. value = newStyle[ name ];
  6796. if ( oldStyle[ name ] !== value ) {
  6797. if ( !shorthandStyles[ name ] ) {
  6798. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  6799. diff[ name ] = value;
  6800. }
  6801. }
  6802. }
  6803. }
  6804. return diff;
  6805. }
  6806. $.effects.animateClass = function( value, duration, easing, callback ) {
  6807. var o = $.speed( duration, easing, callback );
  6808. return this.queue( function() {
  6809. var animated = $( this ),
  6810. baseClass = animated.attr( "class" ) || "",
  6811. applyClassChange,
  6812. allAnimations = o.children ? animated.find( "*" ).andSelf() : animated;
  6813. // map the animated objects to store the original styles.
  6814. allAnimations = allAnimations.map(function() {
  6815. var el = $( this );
  6816. return {
  6817. el: el,
  6818. start: getElementStyles.call( this )
  6819. };
  6820. });
  6821. // apply class change
  6822. applyClassChange = function() {
  6823. $.each( classAnimationActions, function(i, action) {
  6824. if ( value[ action ] ) {
  6825. animated[ action + "Class" ]( value[ action ] );
  6826. }
  6827. });
  6828. };
  6829. applyClassChange();
  6830. // map all animated objects again - calculate new styles and diff
  6831. allAnimations = allAnimations.map(function() {
  6832. this.end = getElementStyles.call( this.el[ 0 ] );
  6833. this.diff = styleDifference( this.start, this.end );
  6834. return this;
  6835. });
  6836. // apply original class
  6837. animated.attr( "class", baseClass );
  6838. // map all animated objects again - this time collecting a promise
  6839. allAnimations = allAnimations.map(function() {
  6840. var styleInfo = this,
  6841. dfd = $.Deferred(),
  6842. opts = jQuery.extend({}, o, {
  6843. queue: false,
  6844. complete: function() {
  6845. dfd.resolve( styleInfo );
  6846. }
  6847. });
  6848. this.el.animate( this.diff, opts );
  6849. return dfd.promise();
  6850. });
  6851. // once all animations have completed:
  6852. $.when.apply( $, allAnimations.get() ).done(function() {
  6853. // set the final class
  6854. applyClassChange();
  6855. // for each animated element,
  6856. // clear all css properties that were animated
  6857. $.each( arguments, function() {
  6858. var el = this.el;
  6859. $.each( this.diff, function(key) {
  6860. el.css( key, '' );
  6861. });
  6862. });
  6863. // this is guarnteed to be there if you use jQuery.speed()
  6864. // it also handles dequeuing the next anim...
  6865. o.complete.call( animated[ 0 ] );
  6866. });
  6867. });
  6868. };
  6869. $.fn.extend({
  6870. _addClass: $.fn.addClass,
  6871. addClass: function( classNames, speed, easing, callback ) {
  6872. return speed ?
  6873. $.effects.animateClass.call( this,
  6874. { add: classNames }, speed, easing, callback ) :
  6875. this._addClass( classNames );
  6876. },
  6877. _removeClass: $.fn.removeClass,
  6878. removeClass: function( classNames, speed, easing, callback ) {
  6879. return speed ?
  6880. $.effects.animateClass.call( this,
  6881. { remove: classNames }, speed, easing, callback ) :
  6882. this._removeClass( classNames );
  6883. },
  6884. _toggleClass: $.fn.toggleClass,
  6885. toggleClass: function( classNames, force, speed, easing, callback ) {
  6886. if ( typeof force === "boolean" || force === undefined ) {
  6887. if ( !speed ) {
  6888. // without speed parameter
  6889. return this._toggleClass( classNames, force );
  6890. } else {
  6891. return $.effects.animateClass.call( this,
  6892. (force ? { add: classNames } : { remove: classNames }),
  6893. speed, easing, callback );
  6894. }
  6895. } else {
  6896. // without force parameter
  6897. return $.effects.animateClass.call( this,
  6898. { toggle: classNames }, force, speed, easing );
  6899. }
  6900. },
  6901. switchClass: function( remove, add, speed, easing, callback) {
  6902. return $.effects.animateClass.call( this, {
  6903. add: add,
  6904. remove: remove
  6905. }, speed, easing, callback );
  6906. }
  6907. });
  6908. })();
  6909. /******************************************************************************/
  6910. /*********************************** EFFECTS **********************************/
  6911. /******************************************************************************/
  6912. (function() {
  6913. $.extend( $.effects, {
  6914. version: "1.9.0",
  6915. // Saves a set of properties in a data storage
  6916. save: function( element, set ) {
  6917. for( var i=0; i < set.length; i++ ) {
  6918. if ( set[ i ] !== null ) {
  6919. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  6920. }
  6921. }
  6922. },
  6923. // Restores a set of previously saved properties from a data storage
  6924. restore: function( element, set ) {
  6925. var val, i;
  6926. for( i=0; i < set.length; i++ ) {
  6927. if ( set[ i ] !== null ) {
  6928. val = element.data( dataSpace + set[ i ] );
  6929. // support: jQuery 1.6.2
  6930. // http://bugs.jquery.com/ticket/9917
  6931. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  6932. // We can't differentiate between "" and 0 here, so we just assume
  6933. // empty string since it's likely to be a more common value...
  6934. if ( val === undefined ) {
  6935. val = "";
  6936. }
  6937. element.css( set[ i ], val );
  6938. }
  6939. }
  6940. },
  6941. setMode: function( el, mode ) {
  6942. if (mode === "toggle") {
  6943. mode = el.is( ":hidden" ) ? "show" : "hide";
  6944. }
  6945. return mode;
  6946. },
  6947. // Translates a [top,left] array into a baseline value
  6948. // this should be a little more flexible in the future to handle a string & hash
  6949. getBaseline: function( origin, original ) {
  6950. var y, x;
  6951. switch ( origin[ 0 ] ) {
  6952. case "top": y = 0; break;
  6953. case "middle": y = 0.5; break;
  6954. case "bottom": y = 1; break;
  6955. default: y = origin[ 0 ] / original.height;
  6956. }
  6957. switch ( origin[ 1 ] ) {
  6958. case "left": x = 0; break;
  6959. case "center": x = 0.5; break;
  6960. case "right": x = 1; break;
  6961. default: x = origin[ 1 ] / original.width;
  6962. }
  6963. return {
  6964. x: x,
  6965. y: y
  6966. };
  6967. },
  6968. // Wraps the element around a wrapper that copies position properties
  6969. createWrapper: function( element ) {
  6970. // if the element is already wrapped, return it
  6971. if ( element.parent().is( ".ui-effects-wrapper" )) {
  6972. return element.parent();
  6973. }
  6974. // wrap the element
  6975. var props = {
  6976. width: element.outerWidth(true),
  6977. height: element.outerHeight(true),
  6978. "float": element.css( "float" )
  6979. },
  6980. wrapper = $( "<div></div>" )
  6981. .addClass( "ui-effects-wrapper" )
  6982. .css({
  6983. fontSize: "100%",
  6984. background: "transparent",
  6985. border: "none",
  6986. margin: 0,
  6987. padding: 0
  6988. }),
  6989. // Store the size in case width/height are defined in % - Fixes #5245
  6990. size = {
  6991. width: element.width(),
  6992. height: element.height()
  6993. },
  6994. active = document.activeElement;
  6995. // support: Firefox
  6996. // Firefox incorrectly exposes anonymous content
  6997. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  6998. try {
  6999. active.id;
  7000. } catch( e ) {
  7001. active = document.body;
  7002. }
  7003. element.wrap( wrapper );
  7004. // Fixes #7595 - Elements lose focus when wrapped.
  7005. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  7006. $( active ).focus();
  7007. }
  7008. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  7009. // transfer positioning properties to the wrapper
  7010. if ( element.css( "position" ) === "static" ) {
  7011. wrapper.css({ position: "relative" });
  7012. element.css({ position: "relative" });
  7013. } else {
  7014. $.extend( props, {
  7015. position: element.css( "position" ),
  7016. zIndex: element.css( "z-index" )
  7017. });
  7018. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  7019. props[ pos ] = element.css( pos );
  7020. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  7021. props[ pos ] = "auto";
  7022. }
  7023. });
  7024. element.css({
  7025. position: "relative",
  7026. top: 0,
  7027. left: 0,
  7028. right: "auto",
  7029. bottom: "auto"
  7030. });
  7031. }
  7032. element.css(size);
  7033. return wrapper.css( props ).show();
  7034. },
  7035. removeWrapper: function( element ) {
  7036. var active = document.activeElement;
  7037. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  7038. element.parent().replaceWith( element );
  7039. // Fixes #7595 - Elements lose focus when wrapped.
  7040. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  7041. $( active ).focus();
  7042. }
  7043. }
  7044. return element;
  7045. },
  7046. setTransition: function( element, list, factor, value ) {
  7047. value = value || {};
  7048. $.each( list, function( i, x ) {
  7049. var unit = element.cssUnit( x );
  7050. if ( unit[ 0 ] > 0 ) {
  7051. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  7052. }
  7053. });
  7054. return value;
  7055. }
  7056. });
  7057. // return an effect options object for the given parameters:
  7058. function _normalizeArguments( effect, options, speed, callback ) {
  7059. // allow passing all optinos as the first parameter
  7060. if ( $.isPlainObject( effect ) ) {
  7061. options = effect;
  7062. effect = effect.effect;
  7063. }
  7064. // convert to an object
  7065. effect = { effect: effect };
  7066. // catch (effect)
  7067. if ( options === undefined ) {
  7068. options = {};
  7069. }
  7070. // catch (effect, callback)
  7071. if ( $.isFunction( options ) ) {
  7072. callback = options;
  7073. speed = null;
  7074. options = {};
  7075. }
  7076. // catch (effect, speed, ?)
  7077. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  7078. callback = speed;
  7079. speed = options;
  7080. options = {};
  7081. }
  7082. // catch (effect, options, callback)
  7083. if ( $.isFunction( speed ) ) {
  7084. callback = speed;
  7085. speed = null;
  7086. }
  7087. // add options to effect
  7088. if ( options ) {
  7089. $.extend( effect, options );
  7090. }
  7091. speed = speed || options.duration;
  7092. effect.duration = $.fx.off ? 0 :
  7093. typeof speed === "number" ? speed :
  7094. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  7095. $.fx.speeds._default;
  7096. effect.complete = callback || options.complete;
  7097. return effect;
  7098. }
  7099. function standardSpeed( speed ) {
  7100. // valid standard speeds
  7101. if ( !speed || typeof speed === "number" || $.fx.speeds[ speed ] ) {
  7102. return true;
  7103. }
  7104. // invalid strings - treat as "normal" speed
  7105. if ( typeof speed === "string" && !$.effects.effect[ speed ] ) {
  7106. // TODO: remove in 2.0 (#7115)
  7107. if ( backCompat && $.effects[ speed ] ) {
  7108. return false;
  7109. }
  7110. return true;
  7111. }
  7112. return false;
  7113. }
  7114. $.fn.extend({
  7115. effect: function( effect, options, speed, callback ) {
  7116. var args = _normalizeArguments.apply( this, arguments ),
  7117. mode = args.mode,
  7118. queue = args.queue,
  7119. effectMethod = $.effects.effect[ args.effect ],
  7120. // DEPRECATED: remove in 2.0 (#7115)
  7121. oldEffectMethod = !effectMethod && backCompat && $.effects[ args.effect ];
  7122. if ( $.fx.off || !( effectMethod || oldEffectMethod ) ) {
  7123. // delegate to the original method (e.g., .show()) if possible
  7124. if ( mode ) {
  7125. return this[ mode ]( args.duration, args.complete );
  7126. } else {
  7127. return this.each( function() {
  7128. if ( args.complete ) {
  7129. args.complete.call( this );
  7130. }
  7131. });
  7132. }
  7133. }
  7134. function run( next ) {
  7135. var elem = $( this ),
  7136. complete = args.complete,
  7137. mode = args.mode;
  7138. function done() {
  7139. if ( $.isFunction( complete ) ) {
  7140. complete.call( elem[0] );
  7141. }
  7142. if ( $.isFunction( next ) ) {
  7143. next();
  7144. }
  7145. }
  7146. // if the element is hiddden and mode is hide,
  7147. // or element is visible and mode is show
  7148. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  7149. done();
  7150. } else {
  7151. effectMethod.call( elem[0], args, done );
  7152. }
  7153. }
  7154. // TODO: remove this check in 2.0, effectMethod will always be true
  7155. if ( effectMethod ) {
  7156. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  7157. } else {
  7158. // DEPRECATED: remove in 2.0 (#7115)
  7159. return oldEffectMethod.call(this, {
  7160. options: args,
  7161. duration: args.duration,
  7162. callback: args.complete,
  7163. mode: args.mode
  7164. });
  7165. }
  7166. },
  7167. _show: $.fn.show,
  7168. show: function( speed ) {
  7169. if ( standardSpeed( speed ) ) {
  7170. return this._show.apply( this, arguments );
  7171. } else {
  7172. var args = _normalizeArguments.apply( this, arguments );
  7173. args.mode = "show";
  7174. return this.effect.call( this, args );
  7175. }
  7176. },
  7177. _hide: $.fn.hide,
  7178. hide: function( speed ) {
  7179. if ( standardSpeed( speed ) ) {
  7180. return this._hide.apply( this, arguments );
  7181. } else {
  7182. var args = _normalizeArguments.apply( this, arguments );
  7183. args.mode = "hide";
  7184. return this.effect.call( this, args );
  7185. }
  7186. },
  7187. // jQuery core overloads toggle and creates _toggle
  7188. __toggle: $.fn.toggle,
  7189. toggle: function( speed ) {
  7190. if ( standardSpeed( speed ) || typeof speed === "boolean" || $.isFunction( speed ) ) {
  7191. return this.__toggle.apply( this, arguments );
  7192. } else {
  7193. var args = _normalizeArguments.apply( this, arguments );
  7194. args.mode = "toggle";
  7195. return this.effect.call( this, args );
  7196. }
  7197. },
  7198. // helper functions
  7199. cssUnit: function(key) {
  7200. var style = this.css( key ),
  7201. val = [];
  7202. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  7203. if ( style.indexOf( unit ) > 0 ) {
  7204. val = [ parseFloat( style ), unit ];
  7205. }
  7206. });
  7207. return val;
  7208. }
  7209. });
  7210. })();
  7211. /******************************************************************************/
  7212. /*********************************** EASING ***********************************/
  7213. /******************************************************************************/
  7214. (function() {
  7215. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  7216. var baseEasings = {};
  7217. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  7218. baseEasings[ name ] = function( p ) {
  7219. return Math.pow( p, i + 2 );
  7220. };
  7221. });
  7222. $.extend( baseEasings, {
  7223. Sine: function ( p ) {
  7224. return 1 - Math.cos( p * Math.PI / 2 );
  7225. },
  7226. Circ: function ( p ) {
  7227. return 1 - Math.sqrt( 1 - p * p );
  7228. },
  7229. Elastic: function( p ) {
  7230. return p === 0 || p === 1 ? p :
  7231. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  7232. },
  7233. Back: function( p ) {
  7234. return p * p * ( 3 * p - 2 );
  7235. },
  7236. Bounce: function ( p ) {
  7237. var pow2,
  7238. bounce = 4;
  7239. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  7240. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  7241. }
  7242. });
  7243. $.each( baseEasings, function( name, easeIn ) {
  7244. $.easing[ "easeIn" + name ] = easeIn;
  7245. $.easing[ "easeOut" + name ] = function( p ) {
  7246. return 1 - easeIn( 1 - p );
  7247. };
  7248. $.easing[ "easeInOut" + name ] = function( p ) {
  7249. return p < 0.5 ?
  7250. easeIn( p * 2 ) / 2 :
  7251. 1 - easeIn( p * -2 + 2 ) / 2;
  7252. };
  7253. });
  7254. })();
  7255. })(jQuery));
  7256. (function( $, undefined ) {
  7257. var rvertical = /up|down|vertical/,
  7258. rpositivemotion = /up|left|vertical|horizontal/;
  7259. $.effects.effect.blind = function( o, done ) {
  7260. // Create element
  7261. var el = $( this ),
  7262. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  7263. mode = $.effects.setMode( el, o.mode || "hide" ),
  7264. direction = o.direction || "up",
  7265. vertical = rvertical.test( direction ),
  7266. ref = vertical ? "height" : "width",
  7267. ref2 = vertical ? "top" : "left",
  7268. motion = rpositivemotion.test( direction ),
  7269. animation = {},
  7270. show = mode === "show",
  7271. wrapper, distance, margin;
  7272. // if already wrapped, the wrapper's properties are my property. #6245
  7273. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  7274. $.effects.save( el.parent(), props );
  7275. } else {
  7276. $.effects.save( el, props );
  7277. }
  7278. el.show();
  7279. wrapper = $.effects.createWrapper( el ).css({
  7280. overflow: "hidden"
  7281. });
  7282. distance = wrapper[ ref ]();
  7283. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  7284. animation[ ref ] = show ? distance : 0;
  7285. if ( !motion ) {
  7286. el
  7287. .css( vertical ? "bottom" : "right", 0 )
  7288. .css( vertical ? "top" : "left", "auto" )
  7289. .css({ position: "absolute" });
  7290. animation[ ref2 ] = show ? margin : distance + margin;
  7291. }
  7292. // start at 0 if we are showing
  7293. if ( show ) {
  7294. wrapper.css( ref, 0 );
  7295. if ( ! motion ) {
  7296. wrapper.css( ref2, margin + distance );
  7297. }
  7298. }
  7299. // Animate
  7300. wrapper.animate( animation, {
  7301. duration: o.duration,
  7302. easing: o.easing,
  7303. queue: false,
  7304. complete: function() {
  7305. if ( mode === "hide" ) {
  7306. el.hide();
  7307. }
  7308. $.effects.restore( el, props );
  7309. $.effects.removeWrapper( el );
  7310. done();
  7311. }
  7312. });
  7313. };
  7314. })(jQuery);
  7315. (function( $, undefined ) {
  7316. $.effects.effect.bounce = function( o, done ) {
  7317. var el = $( this ),
  7318. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  7319. // defaults:
  7320. mode = $.effects.setMode( el, o.mode || "effect" ),
  7321. hide = mode === "hide",
  7322. show = mode === "show",
  7323. direction = o.direction || "up",
  7324. distance = o.distance,
  7325. times = o.times || 5,
  7326. // number of internal animations
  7327. anims = times * 2 + ( show || hide ? 1 : 0 ),
  7328. speed = o.duration / anims,
  7329. easing = o.easing,
  7330. // utility:
  7331. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  7332. motion = ( direction === "up" || direction === "left" ),
  7333. i,
  7334. upAnim,
  7335. downAnim,
  7336. // we will need to re-assemble the queue to stack our animations in place
  7337. queue = el.queue(),
  7338. queuelen = queue.length;
  7339. // Avoid touching opacity to prevent clearType and PNG issues in IE
  7340. if ( show || hide ) {
  7341. props.push( "opacity" );
  7342. }
  7343. $.effects.save( el, props );
  7344. el.show();
  7345. $.effects.createWrapper( el ); // Create Wrapper
  7346. // default distance for the BIGGEST bounce is the outer Distance / 3
  7347. if ( !distance ) {
  7348. distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  7349. }
  7350. if ( show ) {
  7351. downAnim = { opacity: 1 };
  7352. downAnim[ ref ] = 0;
  7353. // if we are showing, force opacity 0 and set the initial position
  7354. // then do the "first" animation
  7355. el.css( "opacity", 0 )
  7356. .css( ref, motion ? -distance * 2 : distance * 2 )
  7357. .animate( downAnim, speed, easing );
  7358. }
  7359. // start at the smallest distance if we are hiding
  7360. if ( hide ) {
  7361. distance = distance / Math.pow( 2, times - 1 );
  7362. }
  7363. downAnim = {};
  7364. downAnim[ ref ] = 0;
  7365. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  7366. for ( i = 0; i < times; i++ ) {
  7367. upAnim = {};
  7368. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  7369. el.animate( upAnim, speed, easing )
  7370. .animate( downAnim, speed, easing );
  7371. distance = hide ? distance * 2 : distance / 2;
  7372. }
  7373. // Last Bounce when Hiding
  7374. if ( hide ) {
  7375. upAnim = { opacity: 0 };
  7376. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  7377. el.animate( upAnim, speed, easing );
  7378. }
  7379. el.queue(function() {
  7380. if ( hide ) {
  7381. el.hide();
  7382. }
  7383. $.effects.restore( el, props );
  7384. $.effects.removeWrapper( el );
  7385. done();
  7386. });
  7387. // inject all the animations we just queued to be first in line (after "inprogress")
  7388. if ( queuelen > 1) {
  7389. queue.splice.apply( queue,
  7390. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  7391. }
  7392. el.dequeue();
  7393. };
  7394. })(jQuery);
  7395. (function( $, undefined ) {
  7396. $.effects.effect.clip = function( o, done ) {
  7397. // Create element
  7398. var el = $( this ),
  7399. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  7400. mode = $.effects.setMode( el, o.mode || "hide" ),
  7401. show = mode === "show",
  7402. direction = o.direction || "vertical",
  7403. vert = direction === "vertical",
  7404. size = vert ? "height" : "width",
  7405. position = vert ? "top" : "left",
  7406. animation = {},
  7407. wrapper, animate, distance;
  7408. // Save & Show
  7409. $.effects.save( el, props );
  7410. el.show();
  7411. // Create Wrapper
  7412. wrapper = $.effects.createWrapper( el ).css({
  7413. overflow: "hidden"
  7414. });
  7415. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  7416. distance = animate[ size ]();
  7417. // Shift
  7418. if ( show ) {
  7419. animate.css( size, 0 );
  7420. animate.css( position, distance / 2 );
  7421. }
  7422. // Create Animation Object:
  7423. animation[ size ] = show ? distance : 0;
  7424. animation[ position ] = show ? 0 : distance / 2;
  7425. // Animate
  7426. animate.animate( animation, {
  7427. queue: false,
  7428. duration: o.duration,
  7429. easing: o.easing,
  7430. complete: function() {
  7431. if ( !show ) {
  7432. el.hide();
  7433. }
  7434. $.effects.restore( el, props );
  7435. $.effects.removeWrapper( el );
  7436. done();
  7437. }
  7438. });
  7439. };
  7440. })(jQuery);
  7441. (function( $, undefined ) {
  7442. $.effects.effect.drop = function( o, done ) {
  7443. var el = $( this ),
  7444. props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
  7445. mode = $.effects.setMode( el, o.mode || "hide" ),
  7446. show = mode === "show",
  7447. direction = o.direction || "left",
  7448. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  7449. motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
  7450. animation = {
  7451. opacity: show ? 1 : 0
  7452. },
  7453. distance;
  7454. // Adjust
  7455. $.effects.save( el, props );
  7456. el.show();
  7457. $.effects.createWrapper( el );
  7458. distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]( true ) / 2;
  7459. if ( show ) {
  7460. el
  7461. .css( "opacity", 0 )
  7462. .css( ref, motion === "pos" ? -distance : distance );
  7463. }
  7464. // Animation
  7465. animation[ ref ] = ( show ?
  7466. ( motion === "pos" ? "+=" : "-=" ) :
  7467. ( motion === "pos" ? "-=" : "+=" ) ) +
  7468. distance;
  7469. // Animate
  7470. el.animate( animation, {
  7471. queue: false,
  7472. duration: o.duration,
  7473. easing: o.easing,
  7474. complete: function() {
  7475. if ( mode === "hide" ) {
  7476. el.hide();
  7477. }
  7478. $.effects.restore( el, props );
  7479. $.effects.removeWrapper( el );
  7480. done();
  7481. }
  7482. });
  7483. };
  7484. })(jQuery);
  7485. (function( $, undefined ) {
  7486. $.effects.effect.explode = function( o, done ) {
  7487. var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
  7488. cells = rows,
  7489. el = $( this ),
  7490. mode = $.effects.setMode( el, o.mode || "hide" ),
  7491. show = mode === "show",
  7492. // show and then visibility:hidden the element before calculating offset
  7493. offset = el.show().css( "visibility", "hidden" ).offset(),
  7494. // width and height of a piece
  7495. width = Math.ceil( el.outerWidth() / cells ),
  7496. height = Math.ceil( el.outerHeight() / rows ),
  7497. pieces = [],
  7498. // loop
  7499. i, j, left, top, mx, my;
  7500. // children animate complete:
  7501. function childComplete() {
  7502. pieces.push( this );
  7503. if ( pieces.length === rows * cells ) {
  7504. animComplete();
  7505. }
  7506. }
  7507. // clone the element for each row and cell.
  7508. for( i = 0; i < rows ; i++ ) { // ===>
  7509. top = offset.top + i * height;
  7510. my = i - ( rows - 1 ) / 2 ;
  7511. for( j = 0; j < cells ; j++ ) { // |||
  7512. left = offset.left + j * width;
  7513. mx = j - ( cells - 1 ) / 2 ;
  7514. // Create a clone of the now hidden main element that will be absolute positioned
  7515. // within a wrapper div off the -left and -top equal to size of our pieces
  7516. el
  7517. .clone()
  7518. .appendTo( "body" )
  7519. .wrap( "<div></div>" )
  7520. .css({
  7521. position: "absolute",
  7522. visibility: "visible",
  7523. left: -j * width,
  7524. top: -i * height
  7525. })
  7526. // select the wrapper - make it overflow: hidden and absolute positioned based on
  7527. // where the original was located +left and +top equal to the size of pieces
  7528. .parent()
  7529. .addClass( "ui-effects-explode" )
  7530. .css({
  7531. position: "absolute",
  7532. overflow: "hidden",
  7533. width: width,
  7534. height: height,
  7535. left: left + ( show ? mx * width : 0 ),
  7536. top: top + ( show ? my * height : 0 ),
  7537. opacity: show ? 0 : 1
  7538. }).animate({
  7539. left: left + ( show ? 0 : mx * width ),
  7540. top: top + ( show ? 0 : my * height ),
  7541. opacity: show ? 1 : 0
  7542. }, o.duration || 500, o.easing, childComplete );
  7543. }
  7544. }
  7545. function animComplete() {
  7546. el.css({
  7547. visibility: "visible"
  7548. });
  7549. $( pieces ).remove();
  7550. if ( !show ) {
  7551. el.hide();
  7552. }
  7553. done();
  7554. }
  7555. };
  7556. })(jQuery);
  7557. (function( $, undefined ) {
  7558. $.effects.effect.fade = function( o, done ) {
  7559. var el = $( this ),
  7560. mode = $.effects.setMode( el, o.mode || "toggle" );
  7561. el.animate({
  7562. opacity: mode
  7563. }, {
  7564. queue: false,
  7565. duration: o.duration,
  7566. easing: o.easing,
  7567. complete: done
  7568. });
  7569. };
  7570. })( jQuery );
  7571. (function( $, undefined ) {
  7572. $.effects.effect.fold = function( o, done ) {
  7573. // Create element
  7574. var el = $( this ),
  7575. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  7576. mode = $.effects.setMode( el, o.mode || "hide" ),
  7577. show = mode === "show",
  7578. hide = mode === "hide",
  7579. size = o.size || 15,
  7580. percent = /([0-9]+)%/.exec( size ),
  7581. horizFirst = !!o.horizFirst,
  7582. widthFirst = show !== horizFirst,
  7583. ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
  7584. duration = o.duration / 2,
  7585. wrapper, distance,
  7586. animation1 = {},
  7587. animation2 = {};
  7588. $.effects.save( el, props );
  7589. el.show();
  7590. // Create Wrapper
  7591. wrapper = $.effects.createWrapper( el ).css({
  7592. overflow: "hidden"
  7593. });
  7594. distance = widthFirst ?
  7595. [ wrapper.width(), wrapper.height() ] :
  7596. [ wrapper.height(), wrapper.width() ];
  7597. if ( percent ) {
  7598. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  7599. }
  7600. if ( show ) {
  7601. wrapper.css( horizFirst ? {
  7602. height: 0,
  7603. width: size
  7604. } : {
  7605. height: size,
  7606. width: 0
  7607. });
  7608. }
  7609. // Animation
  7610. animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
  7611. animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
  7612. // Animate
  7613. wrapper
  7614. .animate( animation1, duration, o.easing )
  7615. .animate( animation2, duration, o.easing, function() {
  7616. if ( hide ) {
  7617. el.hide();
  7618. }
  7619. $.effects.restore( el, props );
  7620. $.effects.removeWrapper( el );
  7621. done();
  7622. });
  7623. };
  7624. })(jQuery);
  7625. (function( $, undefined ) {
  7626. $.effects.effect.highlight = function( o, done ) {
  7627. var elem = $( this ),
  7628. props = [ "backgroundImage", "backgroundColor", "opacity" ],
  7629. mode = $.effects.setMode( elem, o.mode || "show" ),
  7630. animation = {
  7631. backgroundColor: elem.css( "backgroundColor" )
  7632. };
  7633. if (mode === "hide") {
  7634. animation.opacity = 0;
  7635. }
  7636. $.effects.save( elem, props );
  7637. elem
  7638. .show()
  7639. .css({
  7640. backgroundImage: "none",
  7641. backgroundColor: o.color || "#ffff99"
  7642. })
  7643. .animate( animation, {
  7644. queue: false,
  7645. duration: o.duration,
  7646. easing: o.easing,
  7647. complete: function() {
  7648. if ( mode === "hide" ) {
  7649. elem.hide();
  7650. }
  7651. $.effects.restore( elem, props );
  7652. done();
  7653. }
  7654. });
  7655. };
  7656. })(jQuery);
  7657. (function( $, undefined ) {
  7658. $.effects.effect.pulsate = function( o, done ) {
  7659. var elem = $( this ),
  7660. mode = $.effects.setMode( elem, o.mode || "show" ),
  7661. show = mode === "show",
  7662. hide = mode === "hide",
  7663. showhide = ( show || mode === "hide" ),
  7664. // showing or hiding leaves of the "last" animation
  7665. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  7666. duration = o.duration / anims,
  7667. animateTo = 0,
  7668. queue = elem.queue(),
  7669. queuelen = queue.length,
  7670. i;
  7671. if ( show || !elem.is(":visible")) {
  7672. elem.css( "opacity", 0 ).show();
  7673. animateTo = 1;
  7674. }
  7675. // anims - 1 opacity "toggles"
  7676. for ( i = 1; i < anims; i++ ) {
  7677. elem.animate({
  7678. opacity: animateTo
  7679. }, duration, o.easing );
  7680. animateTo = 1 - animateTo;
  7681. }
  7682. elem.animate({
  7683. opacity: animateTo
  7684. }, duration, o.easing);
  7685. elem.queue(function() {
  7686. if ( hide ) {
  7687. elem.hide();
  7688. }
  7689. done();
  7690. });
  7691. // We just queued up "anims" animations, we need to put them next in the queue
  7692. if ( queuelen > 1 ) {
  7693. queue.splice.apply( queue,
  7694. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  7695. }
  7696. elem.dequeue();
  7697. };
  7698. })(jQuery);
  7699. (function( $, undefined ) {
  7700. $.effects.effect.puff = function( o, done ) {
  7701. var elem = $( this ),
  7702. mode = $.effects.setMode( elem, o.mode || "hide" ),
  7703. hide = mode === "hide",
  7704. percent = parseInt( o.percent, 10 ) || 150,
  7705. factor = percent / 100,
  7706. original = {
  7707. height: elem.height(),
  7708. width: elem.width()
  7709. };
  7710. $.extend( o, {
  7711. effect: "scale",
  7712. queue: false,
  7713. fade: true,
  7714. mode: mode,
  7715. complete: done,
  7716. percent: hide ? percent : 100,
  7717. from: hide ?
  7718. original :
  7719. {
  7720. height: original.height * factor,
  7721. width: original.width * factor
  7722. }
  7723. });
  7724. elem.effect( o );
  7725. };
  7726. $.effects.effect.scale = function( o, done ) {
  7727. // Create element
  7728. var el = $( this ),
  7729. options = $.extend( true, {}, o ),
  7730. mode = $.effects.setMode( el, o.mode || "effect" ),
  7731. percent = parseInt( o.percent, 10 ) ||
  7732. ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
  7733. direction = o.direction || "both",
  7734. origin = o.origin,
  7735. original = {
  7736. height: el.height(),
  7737. width: el.width(),
  7738. outerHeight: el.outerHeight(),
  7739. outerWidth: el.outerWidth()
  7740. },
  7741. factor = {
  7742. y: direction !== "horizontal" ? (percent / 100) : 1,
  7743. x: direction !== "vertical" ? (percent / 100) : 1
  7744. };
  7745. // We are going to pass this effect to the size effect:
  7746. options.effect = "size";
  7747. options.queue = false;
  7748. options.complete = done;
  7749. // Set default origin and restore for show/hide
  7750. if ( mode !== "effect" ) {
  7751. options.origin = origin || ["middle","center"];
  7752. options.restore = true;
  7753. }
  7754. options.from = o.from || ( mode === "show" ? { height: 0, width: 0 } : original );
  7755. options.to = {
  7756. height: original.height * factor.y,
  7757. width: original.width * factor.x,
  7758. outerHeight: original.outerHeight * factor.y,
  7759. outerWidth: original.outerWidth * factor.x
  7760. };
  7761. // Fade option to support puff
  7762. if ( options.fade ) {
  7763. if ( mode === "show" ) {
  7764. options.from.opacity = 0;
  7765. options.to.opacity = 1;
  7766. }
  7767. if ( mode === "hide" ) {
  7768. options.from.opacity = 1;
  7769. options.to.opacity = 0;
  7770. }
  7771. }
  7772. // Animate
  7773. el.effect( options );
  7774. };
  7775. $.effects.effect.size = function( o, done ) {
  7776. // Create element
  7777. var el = $( this ),
  7778. props = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
  7779. // Always restore
  7780. props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
  7781. // Copy for children
  7782. props2 = [ "width", "height", "overflow" ],
  7783. cProps = [ "fontSize" ],
  7784. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  7785. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  7786. // Set options
  7787. mode = $.effects.setMode( el, o.mode || "effect" ),
  7788. restore = o.restore || mode !== "effect",
  7789. scale = o.scale || "both",
  7790. origin = o.origin || [ "middle", "center" ],
  7791. original, baseline, factor,
  7792. position = el.css( "position" );
  7793. if ( mode === "show" ) {
  7794. el.show();
  7795. }
  7796. original = {
  7797. height: el.height(),
  7798. width: el.width(),
  7799. outerHeight: el.outerHeight(),
  7800. outerWidth: el.outerWidth()
  7801. };
  7802. el.from = o.from || original;
  7803. el.to = o.to || original;
  7804. // Set scaling factor
  7805. factor = {
  7806. from: {
  7807. y: el.from.height / original.height,
  7808. x: el.from.width / original.width
  7809. },
  7810. to: {
  7811. y: el.to.height / original.height,
  7812. x: el.to.width / original.width
  7813. }
  7814. };
  7815. // Scale the css box
  7816. if ( scale === "box" || scale === "both" ) {
  7817. // Vertical props scaling
  7818. if ( factor.from.y !== factor.to.y ) {
  7819. props = props.concat( vProps );
  7820. el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
  7821. el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
  7822. }
  7823. // Horizontal props scaling
  7824. if ( factor.from.x !== factor.to.x ) {
  7825. props = props.concat( hProps );
  7826. el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
  7827. el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
  7828. }
  7829. }
  7830. // Scale the content
  7831. if ( scale === "content" || scale === "both" ) {
  7832. // Vertical props scaling
  7833. if ( factor.from.y !== factor.to.y ) {
  7834. props = props.concat( cProps );
  7835. el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
  7836. el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
  7837. }
  7838. }
  7839. $.effects.save( el, restore ? props : props1 );
  7840. el.show();
  7841. $.effects.createWrapper( el );
  7842. el.css( "overflow", "hidden" ).css( el.from );
  7843. // Adjust
  7844. if (origin) { // Calculate baseline shifts
  7845. baseline = $.effects.getBaseline( origin, original );
  7846. el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
  7847. el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
  7848. el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
  7849. el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
  7850. }
  7851. el.css( el.from ); // set top & left
  7852. // Animate
  7853. if ( scale === "content" || scale === "both" ) { // Scale the children
  7854. // Add margins/font-size
  7855. vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
  7856. hProps = hProps.concat([ "marginLeft", "marginRight" ]);
  7857. props2 = props.concat(vProps).concat(hProps);
  7858. el.find( "*[width]" ).each( function(){
  7859. var child = $( this ),
  7860. c_original = {
  7861. height: child.height(),
  7862. width: child.width()
  7863. };
  7864. if (restore) {
  7865. $.effects.save(child, props2);
  7866. }
  7867. child.from = {
  7868. height: c_original.height * factor.from.y,
  7869. width: c_original.width * factor.from.x
  7870. };
  7871. child.to = {
  7872. height: c_original.height * factor.to.y,
  7873. width: c_original.width * factor.to.x
  7874. };
  7875. // Vertical props scaling
  7876. if ( factor.from.y !== factor.to.y ) {
  7877. child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
  7878. child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
  7879. }
  7880. // Horizontal props scaling
  7881. if ( factor.from.x !== factor.to.x ) {
  7882. child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
  7883. child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
  7884. }
  7885. // Animate children
  7886. child.css( child.from );
  7887. child.animate( child.to, o.duration, o.easing, function() {
  7888. // Restore children
  7889. if ( restore ) {
  7890. $.effects.restore( child, props2 );
  7891. }
  7892. });
  7893. });
  7894. }
  7895. // Animate
  7896. el.animate( el.to, {
  7897. queue: false,
  7898. duration: o.duration,
  7899. easing: o.easing,
  7900. complete: function() {
  7901. if ( el.to.opacity === 0 ) {
  7902. el.css( "opacity", el.from.opacity );
  7903. }
  7904. if( mode === "hide" ) {
  7905. el.hide();
  7906. }
  7907. $.effects.restore( el, restore ? props : props1 );
  7908. if ( !restore ) {
  7909. // we need to calculate our new positioning based on the scaling
  7910. if ( position === "static" ) {
  7911. el.css({
  7912. position: "relative",
  7913. top: el.to.top,
  7914. left: el.to.left
  7915. });
  7916. } else {
  7917. $.each([ "top", "left" ], function( idx, pos ) {
  7918. el.css( pos, function( _, str ) {
  7919. var val = parseInt( str, 10 ),
  7920. toRef = idx ? el.to.left : el.to.top;
  7921. // if original was "auto", recalculate the new value from wrapper
  7922. if ( str === "auto" ) {
  7923. return toRef + "px";
  7924. }
  7925. return val + toRef + "px";
  7926. });
  7927. });
  7928. }
  7929. }
  7930. $.effects.removeWrapper( el );
  7931. done();
  7932. }
  7933. });
  7934. };
  7935. })(jQuery);
  7936. (function( $, undefined ) {
  7937. $.effects.effect.shake = function( o, done ) {
  7938. var el = $( this ),
  7939. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  7940. mode = $.effects.setMode( el, o.mode || "effect" ),
  7941. direction = o.direction || "left",
  7942. distance = o.distance || 20,
  7943. times = o.times || 3,
  7944. anims = times * 2 + 1,
  7945. speed = Math.round(o.duration/anims),
  7946. ref = (direction === "up" || direction === "down") ? "top" : "left",
  7947. positiveMotion = (direction === "up" || direction === "left"),
  7948. animation = {},
  7949. animation1 = {},
  7950. animation2 = {},
  7951. i,
  7952. // we will need to re-assemble the queue to stack our animations in place
  7953. queue = el.queue(),
  7954. queuelen = queue.length;
  7955. $.effects.save( el, props );
  7956. el.show();
  7957. $.effects.createWrapper( el );
  7958. // Animation
  7959. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  7960. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  7961. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  7962. // Animate
  7963. el.animate( animation, speed, o.easing );
  7964. // Shakes
  7965. for ( i = 1; i < times; i++ ) {
  7966. el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
  7967. }
  7968. el
  7969. .animate( animation1, speed, o.easing )
  7970. .animate( animation, speed / 2, o.easing )
  7971. .queue(function() {
  7972. if ( mode === "hide" ) {
  7973. el.hide();
  7974. }
  7975. $.effects.restore( el, props );
  7976. $.effects.removeWrapper( el );
  7977. done();
  7978. });
  7979. // inject all the animations we just queued to be first in line (after "inprogress")
  7980. if ( queuelen > 1) {
  7981. queue.splice.apply( queue,
  7982. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  7983. }
  7984. el.dequeue();
  7985. };
  7986. })(jQuery);
  7987. (function( $, undefined ) {
  7988. $.effects.effect.slide = function( o, done ) {
  7989. // Create element
  7990. var el = $( this ),
  7991. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  7992. mode = $.effects.setMode( el, o.mode || "show" ),
  7993. show = mode === "show",
  7994. direction = o.direction || "left",
  7995. ref = (direction === "up" || direction === "down") ? "top" : "left",
  7996. positiveMotion = (direction === "up" || direction === "left"),
  7997. distance,
  7998. animation = {};
  7999. // Adjust
  8000. $.effects.save( el, props );
  8001. el.show();
  8002. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  8003. $.effects.createWrapper( el ).css({
  8004. overflow: "hidden"
  8005. });
  8006. if ( show ) {
  8007. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  8008. }
  8009. // Animation
  8010. animation[ ref ] = ( show ?
  8011. ( positiveMotion ? "+=" : "-=") :
  8012. ( positiveMotion ? "-=" : "+=")) +
  8013. distance;
  8014. // Animate
  8015. el.animate( animation, {
  8016. queue: false,
  8017. duration: o.duration,
  8018. easing: o.easing,
  8019. complete: function() {
  8020. if ( mode === "hide" ) {
  8021. el.hide();
  8022. }
  8023. $.effects.restore( el, props );
  8024. $.effects.removeWrapper( el );
  8025. done();
  8026. }
  8027. });
  8028. };
  8029. })(jQuery);
  8030. (function( $, undefined ) {
  8031. $.effects.effect.transfer = function( o, done ) {
  8032. var elem = $( this ),
  8033. target = $( o.to ),
  8034. targetFixed = target.css( "position" ) === "fixed",
  8035. body = $("body"),
  8036. fixTop = targetFixed ? body.scrollTop() : 0,
  8037. fixLeft = targetFixed ? body.scrollLeft() : 0,
  8038. endPosition = target.offset(),
  8039. animation = {
  8040. top: endPosition.top - fixTop ,
  8041. left: endPosition.left - fixLeft ,
  8042. height: target.innerHeight(),
  8043. width: target.innerWidth()
  8044. },
  8045. startPosition = elem.offset(),
  8046. transfer = $( '<div class="ui-effects-transfer"></div>' )
  8047. .appendTo( document.body )
  8048. .addClass( o.className )
  8049. .css({
  8050. top: startPosition.top - fixTop ,
  8051. left: startPosition.left - fixLeft ,
  8052. height: elem.innerHeight(),
  8053. width: elem.innerWidth(),
  8054. position: targetFixed ? "fixed" : "absolute"
  8055. })
  8056. .animate( animation, o.duration, o.easing, function() {
  8057. transfer.remove();
  8058. done();
  8059. });
  8060. };
  8061. })(jQuery);
  8062. (function( $, undefined ) {
  8063. var mouseHandled = false;
  8064. $.widget( "ui.menu", {
  8065. version: "1.9.0",
  8066. defaultElement: "<ul>",
  8067. delay: 300,
  8068. options: {
  8069. icons: {
  8070. submenu: "ui-icon-carat-1-e"
  8071. },
  8072. menus: "ul",
  8073. position: {
  8074. my: "left top",
  8075. at: "right top"
  8076. },
  8077. role: "menu",
  8078. // callbacks
  8079. blur: null,
  8080. focus: null,
  8081. select: null
  8082. },
  8083. _create: function() {
  8084. this.activeMenu = this.element;
  8085. this.element
  8086. .uniqueId()
  8087. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  8088. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  8089. .attr({
  8090. role: this.options.role,
  8091. tabIndex: 0
  8092. })
  8093. // need to catch all clicks on disabled menu
  8094. // not possible through _on
  8095. .bind( "click" + this.eventNamespace, $.proxy(function( event ) {
  8096. if ( this.options.disabled ) {
  8097. event.preventDefault();
  8098. }
  8099. }, this ));
  8100. if ( this.options.disabled ) {
  8101. this.element
  8102. .addClass( "ui-state-disabled" )
  8103. .attr( "aria-disabled", "true" );
  8104. }
  8105. this._on({
  8106. // Prevent focus from sticking to links inside menu after clicking
  8107. // them (focus should always stay on UL during navigation).
  8108. "mousedown .ui-menu-item > a": function( event ) {
  8109. event.preventDefault();
  8110. },
  8111. "click .ui-state-disabled > a": function( event ) {
  8112. event.preventDefault();
  8113. },
  8114. "click .ui-menu-item:has(a)": function( event ) {
  8115. var target = $( event.target ).closest( ".ui-menu-item" );
  8116. if ( !mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  8117. mouseHandled = true;
  8118. this.select( event );
  8119. // Open submenu on click
  8120. if ( target.has( ".ui-menu" ).length ) {
  8121. this.expand( event );
  8122. } else if ( !this.element.is( ":focus" ) ) {
  8123. // Redirect focus to the menu
  8124. this.element.trigger( "focus", [ true ] );
  8125. // If the active item is on the top level, let it stay active.
  8126. // Otherwise, blur the active item since it is no longer visible.
  8127. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  8128. clearTimeout( this.timer );
  8129. }
  8130. }
  8131. }
  8132. },
  8133. "mouseenter .ui-menu-item": function( event ) {
  8134. var target = $( event.currentTarget );
  8135. // Remove ui-state-active class from siblings of the newly focused menu item
  8136. // to avoid a jump caused by adjacent elements both having a class with a border
  8137. target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
  8138. this.focus( event, target );
  8139. },
  8140. mouseleave: "collapseAll",
  8141. "mouseleave .ui-menu": "collapseAll",
  8142. focus: function( event, keepActiveItem ) {
  8143. // If there's already an active item, keep it active
  8144. // If not, activate the first item
  8145. var item = this.active || this.element.children( ".ui-menu-item" ).eq( 0 );
  8146. if ( !keepActiveItem ) {
  8147. this.focus( event, item );
  8148. }
  8149. },
  8150. blur: function( event ) {
  8151. this._delay(function() {
  8152. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  8153. this.collapseAll( event );
  8154. }
  8155. });
  8156. },
  8157. keydown: "_keydown"
  8158. });
  8159. this.refresh();
  8160. // Clicks outside of a menu collapse any open menus
  8161. this._on( this.document, {
  8162. click: function( event ) {
  8163. if ( !$( event.target ).closest( ".ui-menu" ).length ) {
  8164. this.collapseAll( event );
  8165. }
  8166. // Reset the mouseHandled flag
  8167. mouseHandled = false;
  8168. }
  8169. });
  8170. },
  8171. _destroy: function() {
  8172. // Destroy (sub)menus
  8173. this.element
  8174. .removeAttr( "aria-activedescendant" )
  8175. .find( ".ui-menu" ).andSelf()
  8176. .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
  8177. .removeAttr( "role" )
  8178. .removeAttr( "tabIndex" )
  8179. .removeAttr( "aria-labelledby" )
  8180. .removeAttr( "aria-expanded" )
  8181. .removeAttr( "aria-hidden" )
  8182. .removeAttr( "aria-disabled" )
  8183. .removeUniqueId()
  8184. .show();
  8185. // Destroy menu items
  8186. this.element.find( ".ui-menu-item" )
  8187. .removeClass( "ui-menu-item" )
  8188. .removeAttr( "role" )
  8189. .removeAttr( "aria-disabled" )
  8190. .children( "a" )
  8191. .removeUniqueId()
  8192. .removeClass( "ui-corner-all ui-state-hover" )
  8193. .removeAttr( "tabIndex" )
  8194. .removeAttr( "role" )
  8195. .removeAttr( "aria-haspopup" )
  8196. .children().each( function() {
  8197. var elem = $( this );
  8198. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  8199. elem.remove();
  8200. }
  8201. });
  8202. // Destroy menu dividers
  8203. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  8204. },
  8205. _keydown: function( event ) {
  8206. var match, prev, character, skip, regex,
  8207. preventDefault = true;
  8208. function escape( value ) {
  8209. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  8210. }
  8211. switch ( event.keyCode ) {
  8212. case $.ui.keyCode.PAGE_UP:
  8213. this.previousPage( event );
  8214. break;
  8215. case $.ui.keyCode.PAGE_DOWN:
  8216. this.nextPage( event );
  8217. break;
  8218. case $.ui.keyCode.HOME:
  8219. this._move( "first", "first", event );
  8220. break;
  8221. case $.ui.keyCode.END:
  8222. this._move( "last", "last", event );
  8223. break;
  8224. case $.ui.keyCode.UP:
  8225. this.previous( event );
  8226. break;
  8227. case $.ui.keyCode.DOWN:
  8228. this.next( event );
  8229. break;
  8230. case $.ui.keyCode.LEFT:
  8231. this.collapse( event );
  8232. break;
  8233. case $.ui.keyCode.RIGHT:
  8234. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  8235. this.expand( event );
  8236. }
  8237. break;
  8238. case $.ui.keyCode.ENTER:
  8239. case $.ui.keyCode.SPACE:
  8240. this._activate( event );
  8241. break;
  8242. case $.ui.keyCode.ESCAPE:
  8243. this.collapse( event );
  8244. break;
  8245. default:
  8246. preventDefault = false;
  8247. prev = this.previousFilter || "";
  8248. character = String.fromCharCode( event.keyCode );
  8249. skip = false;
  8250. clearTimeout( this.filterTimer );
  8251. if ( character === prev ) {
  8252. skip = true;
  8253. } else {
  8254. character = prev + character;
  8255. }
  8256. regex = new RegExp( "^" + escape( character ), "i" );
  8257. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  8258. return regex.test( $( this ).children( "a" ).text() );
  8259. });
  8260. match = skip && match.index( this.active.next() ) !== -1 ?
  8261. this.active.nextAll( ".ui-menu-item" ) :
  8262. match;
  8263. // If no matches on the current filter, reset to the last character pressed
  8264. // to move down the menu to the first item that starts with that character
  8265. if ( !match.length ) {
  8266. character = String.fromCharCode( event.keyCode );
  8267. regex = new RegExp( "^" + escape( character ), "i" );
  8268. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  8269. return regex.test( $( this ).children( "a" ).text() );
  8270. });
  8271. }
  8272. if ( match.length ) {
  8273. this.focus( event, match );
  8274. if ( match.length > 1 ) {
  8275. this.previousFilter = character;
  8276. this.filterTimer = this._delay(function() {
  8277. delete this.previousFilter;
  8278. }, 1000 );
  8279. } else {
  8280. delete this.previousFilter;
  8281. }
  8282. } else {
  8283. delete this.previousFilter;
  8284. }
  8285. }
  8286. if ( preventDefault ) {
  8287. event.preventDefault();
  8288. }
  8289. },
  8290. _activate: function( event ) {
  8291. if ( !this.active.is( ".ui-state-disabled" ) ) {
  8292. if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
  8293. this.expand( event );
  8294. } else {
  8295. this.select( event );
  8296. }
  8297. }
  8298. },
  8299. refresh: function() {
  8300. // Initialize nested menus
  8301. var menus,
  8302. icon = this.options.icons.submenu,
  8303. submenus = this.element.find( this.options.menus + ":not(.ui-menu)" )
  8304. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  8305. .hide()
  8306. .attr({
  8307. role: this.options.role,
  8308. "aria-hidden": "true",
  8309. "aria-expanded": "false"
  8310. });
  8311. // Don't refresh list items that are already adapted
  8312. menus = submenus.add( this.element );
  8313. menus.children( ":not(.ui-menu-item):has(a)" )
  8314. .addClass( "ui-menu-item" )
  8315. .attr( "role", "presentation" )
  8316. .children( "a" )
  8317. .uniqueId()
  8318. .addClass( "ui-corner-all" )
  8319. .attr({
  8320. tabIndex: -1,
  8321. role: this._itemRole()
  8322. });
  8323. // Initialize unlinked menu-items containing spaces and/or dashes only as dividers
  8324. menus.children( ":not(.ui-menu-item)" ).each(function() {
  8325. var item = $( this );
  8326. // hyphen, em dash, en dash
  8327. if ( !/[^\-—–\s]/.test( item.text() ) ) {
  8328. item.addClass( "ui-widget-content ui-menu-divider" );
  8329. }
  8330. });
  8331. // Add aria-disabled attribute to any disabled menu item
  8332. menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  8333. submenus.each(function() {
  8334. var menu = $( this ),
  8335. item = menu.prev( "a" ),
  8336. submenuCarat = $( "<span>" )
  8337. .addClass( "ui-menu-icon ui-icon " + icon )
  8338. .data( "ui-menu-submenu-carat", true );
  8339. item
  8340. .attr( "aria-haspopup", "true" )
  8341. .prepend( submenuCarat );
  8342. menu.attr( "aria-labelledby", item.attr( "id" ) );
  8343. });
  8344. // If the active item has been removed, blur the menu
  8345. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  8346. this.blur();
  8347. }
  8348. },
  8349. _itemRole: function() {
  8350. return {
  8351. menu: "menuitem",
  8352. listbox: "option"
  8353. }[ this.options.role ];
  8354. },
  8355. focus: function( event, item ) {
  8356. var nested, focused;
  8357. this.blur( event, event && event.type === "focus" );
  8358. this._scrollIntoView( item );
  8359. this.active = item.first();
  8360. focused = this.active.children( "a" ).addClass( "ui-state-focus" );
  8361. // Only update aria-activedescendant if there's a role
  8362. // otherwise we assume focus is managed elsewhere
  8363. if ( this.options.role ) {
  8364. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  8365. }
  8366. // Highlight active parent menu item, if any
  8367. this.active
  8368. .parent()
  8369. .closest( ".ui-menu-item" )
  8370. .children( "a:first" )
  8371. .addClass( "ui-state-active" );
  8372. if ( event && event.type === "keydown" ) {
  8373. this._close();
  8374. } else {
  8375. this.timer = this._delay(function() {
  8376. this._close();
  8377. }, this.delay );
  8378. }
  8379. nested = item.children( ".ui-menu" );
  8380. if ( nested.length && ( /^mouse/.test( event.type ) ) ) {
  8381. this._startOpening(nested);
  8382. }
  8383. this.activeMenu = item.parent();
  8384. this._trigger( "focus", event, { item: item } );
  8385. },
  8386. _scrollIntoView: function( item ) {
  8387. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  8388. if ( this._hasScroll() ) {
  8389. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  8390. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  8391. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  8392. scroll = this.activeMenu.scrollTop();
  8393. elementHeight = this.activeMenu.height();
  8394. itemHeight = item.height();
  8395. if ( offset < 0 ) {
  8396. this.activeMenu.scrollTop( scroll + offset );
  8397. } else if ( offset + itemHeight > elementHeight ) {
  8398. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  8399. }
  8400. }
  8401. },
  8402. blur: function( event, fromFocus ) {
  8403. if ( !fromFocus ) {
  8404. clearTimeout( this.timer );
  8405. }
  8406. if ( !this.active ) {
  8407. return;
  8408. }
  8409. this.active.children( "a" ).removeClass( "ui-state-focus" );
  8410. this.active = null;
  8411. this._trigger( "blur", event, { item: this.active } );
  8412. },
  8413. _startOpening: function( submenu ) {
  8414. clearTimeout( this.timer );
  8415. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  8416. // shift in the submenu position when mousing over the carat icon
  8417. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  8418. return;
  8419. }
  8420. this.timer = this._delay(function() {
  8421. this._close();
  8422. this._open( submenu );
  8423. }, this.delay );
  8424. },
  8425. _open: function( submenu ) {
  8426. var position = $.extend({
  8427. of: this.active
  8428. }, this.options.position );
  8429. clearTimeout( this.timer );
  8430. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  8431. .hide()
  8432. .attr( "aria-hidden", "true" );
  8433. submenu
  8434. .show()
  8435. .removeAttr( "aria-hidden" )
  8436. .attr( "aria-expanded", "true" )
  8437. .position( position );
  8438. },
  8439. collapseAll: function( event, all ) {
  8440. clearTimeout( this.timer );
  8441. this.timer = this._delay(function() {
  8442. // If we were passed an event, look for the submenu that contains the event
  8443. var currentMenu = all ? this.element :
  8444. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  8445. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  8446. if ( !currentMenu.length ) {
  8447. currentMenu = this.element;
  8448. }
  8449. this._close( currentMenu );
  8450. this.blur( event );
  8451. this.activeMenu = currentMenu;
  8452. }, this.delay );
  8453. },
  8454. // With no arguments, closes the currently active menu - if nothing is active
  8455. // it closes all menus. If passed an argument, it will search for menus BELOW
  8456. _close: function( startMenu ) {
  8457. if ( !startMenu ) {
  8458. startMenu = this.active ? this.active.parent() : this.element;
  8459. }
  8460. startMenu
  8461. .find( ".ui-menu" )
  8462. .hide()
  8463. .attr( "aria-hidden", "true" )
  8464. .attr( "aria-expanded", "false" )
  8465. .end()
  8466. .find( "a.ui-state-active" )
  8467. .removeClass( "ui-state-active" );
  8468. },
  8469. collapse: function( event ) {
  8470. var newItem = this.active &&
  8471. this.active.parent().closest( ".ui-menu-item", this.element );
  8472. if ( newItem && newItem.length ) {
  8473. this._close();
  8474. this.focus( event, newItem );
  8475. }
  8476. },
  8477. expand: function( event ) {
  8478. var newItem = this.active &&
  8479. this.active
  8480. .children( ".ui-menu " )
  8481. .children( ".ui-menu-item" )
  8482. .first();
  8483. if ( newItem && newItem.length ) {
  8484. this._open( newItem.parent() );
  8485. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  8486. this._delay(function() {
  8487. this.focus( event, newItem );
  8488. });
  8489. }
  8490. },
  8491. next: function( event ) {
  8492. this._move( "next", "first", event );
  8493. },
  8494. previous: function( event ) {
  8495. this._move( "prev", "last", event );
  8496. },
  8497. isFirstItem: function() {
  8498. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  8499. },
  8500. isLastItem: function() {
  8501. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  8502. },
  8503. _move: function( direction, filter, event ) {
  8504. var next;
  8505. if ( this.active ) {
  8506. if ( direction === "first" || direction === "last" ) {
  8507. next = this.active
  8508. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  8509. .eq( -1 );
  8510. } else {
  8511. next = this.active
  8512. [ direction + "All" ]( ".ui-menu-item" )
  8513. .eq( 0 );
  8514. }
  8515. }
  8516. if ( !next || !next.length || !this.active ) {
  8517. next = this.activeMenu.children( ".ui-menu-item" )[ filter ]();
  8518. }
  8519. this.focus( event, next );
  8520. },
  8521. nextPage: function( event ) {
  8522. var item, base, height;
  8523. if ( !this.active ) {
  8524. this.next( event );
  8525. return;
  8526. }
  8527. if ( this.isLastItem() ) {
  8528. return;
  8529. }
  8530. if ( this._hasScroll() ) {
  8531. base = this.active.offset().top;
  8532. height = this.element.height();
  8533. this.active.nextAll( ".ui-menu-item" ).each(function() {
  8534. item = $( this );
  8535. return item.offset().top - base - height < 0;
  8536. });
  8537. this.focus( event, item );
  8538. } else {
  8539. this.focus( event, this.activeMenu.children( ".ui-menu-item" )
  8540. [ !this.active ? "first" : "last" ]() );
  8541. }
  8542. },
  8543. previousPage: function( event ) {
  8544. var item, base, height;
  8545. if ( !this.active ) {
  8546. this.next( event );
  8547. return;
  8548. }
  8549. if ( this.isFirstItem() ) {
  8550. return;
  8551. }
  8552. if ( this._hasScroll() ) {
  8553. base = this.active.offset().top;
  8554. height = this.element.height();
  8555. this.active.prevAll( ".ui-menu-item" ).each(function() {
  8556. item = $( this );
  8557. return item.offset().top - base + height > 0;
  8558. });
  8559. this.focus( event, item );
  8560. } else {
  8561. this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
  8562. }
  8563. },
  8564. _hasScroll: function() {
  8565. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  8566. },
  8567. select: function( event ) {
  8568. // TODO: It should never be possible to not have an active item at this
  8569. // point, but the tests don't trigger mouseenter before click.
  8570. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  8571. var ui = { item: this.active };
  8572. if ( !this.active.has( ".ui-menu" ).length ) {
  8573. this.collapseAll( event, true );
  8574. }
  8575. this._trigger( "select", event, ui );
  8576. }
  8577. });
  8578. }( jQuery ));
  8579. (function( $, undefined ) {
  8580. $.widget( "ui.progressbar", {
  8581. version: "1.9.0",
  8582. options: {
  8583. value: 0,
  8584. max: 100
  8585. },
  8586. min: 0,
  8587. _create: function() {
  8588. this.element
  8589. .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  8590. .attr({
  8591. role: "progressbar",
  8592. "aria-valuemin": this.min,
  8593. "aria-valuemax": this.options.max,
  8594. "aria-valuenow": this._value()
  8595. });
  8596. this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
  8597. .appendTo( this.element );
  8598. this.oldValue = this._value();
  8599. this._refreshValue();
  8600. },
  8601. _destroy: function() {
  8602. this.element
  8603. .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  8604. .removeAttr( "role" )
  8605. .removeAttr( "aria-valuemin" )
  8606. .removeAttr( "aria-valuemax" )
  8607. .removeAttr( "aria-valuenow" );
  8608. this.valueDiv.remove();
  8609. },
  8610. value: function( newValue ) {
  8611. if ( newValue === undefined ) {
  8612. return this._value();
  8613. }
  8614. this._setOption( "value", newValue );
  8615. return this;
  8616. },
  8617. _setOption: function( key, value ) {
  8618. if ( key === "value" ) {
  8619. this.options.value = value;
  8620. this._refreshValue();
  8621. if ( this._value() === this.options.max ) {
  8622. this._trigger( "complete" );
  8623. }
  8624. }
  8625. this._super( key, value );
  8626. },
  8627. _value: function() {
  8628. var val = this.options.value;
  8629. // normalize invalid value
  8630. if ( typeof val !== "number" ) {
  8631. val = 0;
  8632. }
  8633. return Math.min( this.options.max, Math.max( this.min, val ) );
  8634. },
  8635. _percentage: function() {
  8636. return 100 * this._value() / this.options.max;
  8637. },
  8638. _refreshValue: function() {
  8639. var value = this.value(),
  8640. percentage = this._percentage();
  8641. if ( this.oldValue !== value ) {
  8642. this.oldValue = value;
  8643. this._trigger( "change" );
  8644. }
  8645. this.valueDiv
  8646. .toggle( value > this.min )
  8647. .toggleClass( "ui-corner-right", value === this.options.max )
  8648. .width( percentage.toFixed(0) + "%" );
  8649. this.element.attr( "aria-valuenow", value );
  8650. }
  8651. });
  8652. })( jQuery );
  8653. (function( $, undefined ) {
  8654. $.widget("ui.resizable", $.ui.mouse, {
  8655. version: "1.9.0",
  8656. widgetEventPrefix: "resize",
  8657. options: {
  8658. alsoResize: false,
  8659. animate: false,
  8660. animateDuration: "slow",
  8661. animateEasing: "swing",
  8662. aspectRatio: false,
  8663. autoHide: false,
  8664. containment: false,
  8665. ghost: false,
  8666. grid: false,
  8667. handles: "e,s,se",
  8668. helper: false,
  8669. maxHeight: null,
  8670. maxWidth: null,
  8671. minHeight: 10,
  8672. minWidth: 10,
  8673. zIndex: 1000
  8674. },
  8675. _create: function() {
  8676. var that = this, o = this.options;
  8677. this.element.addClass("ui-resizable");
  8678. $.extend(this, {
  8679. _aspectRatio: !!(o.aspectRatio),
  8680. aspectRatio: o.aspectRatio,
  8681. originalElement: this.element,
  8682. _proportionallyResizeElements: [],
  8683. _helper: o.helper || o.ghost || o.animate ? o.helper || 'ui-resizable-helper' : null
  8684. });
  8685. //Wrap the element if it cannot hold child nodes
  8686. if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
  8687. //Create a wrapper element and set the wrapper to the new current internal element
  8688. this.element.wrap(
  8689. $('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({
  8690. position: this.element.css('position'),
  8691. width: this.element.outerWidth(),
  8692. height: this.element.outerHeight(),
  8693. top: this.element.css('top'),
  8694. left: this.element.css('left')
  8695. })
  8696. );
  8697. //Overwrite the original this.element
  8698. this.element = this.element.parent().data(
  8699. "resizable", this.element.data('resizable')
  8700. );
  8701. this.elementIsWrapper = true;
  8702. //Move margins to the wrapper
  8703. this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
  8704. this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
  8705. //Prevent Safari textarea resize
  8706. this.originalResizeStyle = this.originalElement.css('resize');
  8707. this.originalElement.css('resize', 'none');
  8708. //Push the actual element to our proportionallyResize internal array
  8709. this._proportionallyResizeElements.push(this.originalElement.css({ position: 'static', zoom: 1, display: 'block' }));
  8710. // avoid IE jump (hard set the margin)
  8711. this.originalElement.css({ margin: this.originalElement.css('margin') });
  8712. // fix handlers offset
  8713. this._proportionallyResize();
  8714. }
  8715. 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' });
  8716. if(this.handles.constructor == String) {
  8717. if(this.handles == 'all') this.handles = 'n,e,s,w,se,sw,ne,nw';
  8718. var n = this.handles.split(","); this.handles = {};
  8719. for(var i = 0; i < n.length; i++) {
  8720. var handle = $.trim(n[i]), hname = 'ui-resizable-'+handle;
  8721. var axis = $('<div class="ui-resizable-handle ' + hname + '"></div>');
  8722. // Apply zIndex to all handles - see #7960
  8723. axis.css({ zIndex: o.zIndex });
  8724. //TODO : What's going on here?
  8725. if ('se' == handle) {
  8726. axis.addClass('ui-icon ui-icon-gripsmall-diagonal-se');
  8727. };
  8728. //Insert into internal handles object and append to element
  8729. this.handles[handle] = '.ui-resizable-'+handle;
  8730. this.element.append(axis);
  8731. }
  8732. }
  8733. this._renderAxis = function(target) {
  8734. target = target || this.element;
  8735. for(var i in this.handles) {
  8736. if(this.handles[i].constructor == String)
  8737. this.handles[i] = $(this.handles[i], this.element).show();
  8738. //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
  8739. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
  8740. var axis = $(this.handles[i], this.element), padWrapper = 0;
  8741. //Checking the correct pad and border
  8742. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  8743. //The padding type i have to apply...
  8744. var padPos = [ 'padding',
  8745. /ne|nw|n/.test(i) ? 'Top' :
  8746. /se|sw|s/.test(i) ? 'Bottom' :
  8747. /^e$/.test(i) ? 'Right' : 'Left' ].join("");
  8748. target.css(padPos, padWrapper);
  8749. this._proportionallyResize();
  8750. }
  8751. //TODO: What's that good for? There's not anything to be executed left
  8752. if(!$(this.handles[i]).length)
  8753. continue;
  8754. }
  8755. };
  8756. //TODO: make renderAxis a prototype function
  8757. this._renderAxis(this.element);
  8758. this._handles = $('.ui-resizable-handle', this.element)
  8759. .disableSelection();
  8760. //Matching axis name
  8761. this._handles.mouseover(function() {
  8762. if (!that.resizing) {
  8763. if (this.className)
  8764. var axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  8765. //Axis, default = se
  8766. that.axis = axis && axis[1] ? axis[1] : 'se';
  8767. }
  8768. });
  8769. //If we want to auto hide the elements
  8770. if (o.autoHide) {
  8771. this._handles.hide();
  8772. $(this.element)
  8773. .addClass("ui-resizable-autohide")
  8774. .mouseenter(function() {
  8775. if (o.disabled) return;
  8776. $(this).removeClass("ui-resizable-autohide");
  8777. that._handles.show();
  8778. })
  8779. .mouseleave(function(){
  8780. if (o.disabled) return;
  8781. if (!that.resizing) {
  8782. $(this).addClass("ui-resizable-autohide");
  8783. that._handles.hide();
  8784. }
  8785. });
  8786. }
  8787. //Initialize the mouse interaction
  8788. this._mouseInit();
  8789. },
  8790. _destroy: function() {
  8791. this._mouseDestroy();
  8792. var _destroy = function(exp) {
  8793. $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  8794. .removeData("resizable").removeData("ui-resizable").unbind(".resizable").find('.ui-resizable-handle').remove();
  8795. };
  8796. //TODO: Unwrap at same DOM position
  8797. if (this.elementIsWrapper) {
  8798. _destroy(this.element);
  8799. var wrapper = this.element;
  8800. wrapper.after(
  8801. this.originalElement.css({
  8802. position: wrapper.css('position'),
  8803. width: wrapper.outerWidth(),
  8804. height: wrapper.outerHeight(),
  8805. top: wrapper.css('top'),
  8806. left: wrapper.css('left')
  8807. })
  8808. ).remove();
  8809. }
  8810. this.originalElement.css('resize', this.originalResizeStyle);
  8811. _destroy(this.originalElement);
  8812. return this;
  8813. },
  8814. _mouseCapture: function(event) {
  8815. var handle = false;
  8816. for (var i in this.handles) {
  8817. if ($(this.handles[i])[0] == event.target) {
  8818. handle = true;
  8819. }
  8820. }
  8821. return !this.options.disabled && handle;
  8822. },
  8823. _mouseStart: function(event) {
  8824. var o = this.options, iniPos = this.element.position(), el = this.element;
  8825. this.resizing = true;
  8826. this.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() };
  8827. // bugfix for http://dev.jquery.com/ticket/1749
  8828. if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) {
  8829. el.css({ position: 'absolute', top: iniPos.top, left: iniPos.left });
  8830. }
  8831. this._renderProxy();
  8832. var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top'));
  8833. if (o.containment) {
  8834. curleft += $(o.containment).scrollLeft() || 0;
  8835. curtop += $(o.containment).scrollTop() || 0;
  8836. }
  8837. //Store needed variables
  8838. this.offset = this.helper.offset();
  8839. this.position = { left: curleft, top: curtop };
  8840. this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  8841. this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  8842. this.originalPosition = { left: curleft, top: curtop };
  8843. this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
  8844. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  8845. //Aspect Ratio
  8846. this.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
  8847. var cursor = $('.ui-resizable-' + this.axis).css('cursor');
  8848. $('body').css('cursor', cursor == 'auto' ? this.axis + '-resize' : cursor);
  8849. el.addClass("ui-resizable-resizing");
  8850. this._propagate("start", event);
  8851. return true;
  8852. },
  8853. _mouseDrag: function(event) {
  8854. //Increase performance, avoid regex
  8855. var el = this.helper, o = this.options, props = {},
  8856. that = this, smp = this.originalMousePosition, a = this.axis;
  8857. var dx = (event.pageX-smp.left)||0, dy = (event.pageY-smp.top)||0;
  8858. var trigger = this._change[a];
  8859. if (!trigger) return false;
  8860. // Calculate the attrs that will be change
  8861. var data = trigger.apply(this, [event, dx, dy]);
  8862. // Put this in the mouseDrag handler since the user can start pressing shift while resizing
  8863. this._updateVirtualBoundaries(event.shiftKey);
  8864. if (this._aspectRatio || event.shiftKey)
  8865. data = this._updateRatio(data, event);
  8866. data = this._respectSize(data, event);
  8867. // plugins callbacks need to be called first
  8868. this._propagate("resize", event);
  8869. el.css({
  8870. top: this.position.top + "px", left: this.position.left + "px",
  8871. width: this.size.width + "px", height: this.size.height + "px"
  8872. });
  8873. if (!this._helper && this._proportionallyResizeElements.length)
  8874. this._proportionallyResize();
  8875. this._updateCache(data);
  8876. // calling the user callback at the end
  8877. this._trigger('resize', event, this.ui());
  8878. return false;
  8879. },
  8880. _mouseStop: function(event) {
  8881. this.resizing = false;
  8882. var o = this.options, that = this;
  8883. if(this._helper) {
  8884. var pr = this._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  8885. soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : that.sizeDiff.height,
  8886. soffsetw = ista ? 0 : that.sizeDiff.width;
  8887. var s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) },
  8888. left = (parseInt(that.element.css('left'), 10) + (that.position.left - that.originalPosition.left)) || null,
  8889. top = (parseInt(that.element.css('top'), 10) + (that.position.top - that.originalPosition.top)) || null;
  8890. if (!o.animate)
  8891. this.element.css($.extend(s, { top: top, left: left }));
  8892. that.helper.height(that.size.height);
  8893. that.helper.width(that.size.width);
  8894. if (this._helper && !o.animate) this._proportionallyResize();
  8895. }
  8896. $('body').css('cursor', 'auto');
  8897. this.element.removeClass("ui-resizable-resizing");
  8898. this._propagate("stop", event);
  8899. if (this._helper) this.helper.remove();
  8900. return false;
  8901. },
  8902. _updateVirtualBoundaries: function(forceAspectRatio) {
  8903. var o = this.options, pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b;
  8904. b = {
  8905. minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
  8906. maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  8907. minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
  8908. maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
  8909. };
  8910. if(this._aspectRatio || forceAspectRatio) {
  8911. // We want to create an enclosing box whose aspect ration is the requested one
  8912. // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
  8913. pMinWidth = b.minHeight * this.aspectRatio;
  8914. pMinHeight = b.minWidth / this.aspectRatio;
  8915. pMaxWidth = b.maxHeight * this.aspectRatio;
  8916. pMaxHeight = b.maxWidth / this.aspectRatio;
  8917. if(pMinWidth > b.minWidth) b.minWidth = pMinWidth;
  8918. if(pMinHeight > b.minHeight) b.minHeight = pMinHeight;
  8919. if(pMaxWidth < b.maxWidth) b.maxWidth = pMaxWidth;
  8920. if(pMaxHeight < b.maxHeight) b.maxHeight = pMaxHeight;
  8921. }
  8922. this._vBoundaries = b;
  8923. },
  8924. _updateCache: function(data) {
  8925. var o = this.options;
  8926. this.offset = this.helper.offset();
  8927. if (isNumber(data.left)) this.position.left = data.left;
  8928. if (isNumber(data.top)) this.position.top = data.top;
  8929. if (isNumber(data.height)) this.size.height = data.height;
  8930. if (isNumber(data.width)) this.size.width = data.width;
  8931. },
  8932. _updateRatio: function(data, event) {
  8933. var o = this.options, cpos = this.position, csize = this.size, a = this.axis;
  8934. if (isNumber(data.height)) data.width = (data.height * this.aspectRatio);
  8935. else if (isNumber(data.width)) data.height = (data.width / this.aspectRatio);
  8936. if (a == 'sw') {
  8937. data.left = cpos.left + (csize.width - data.width);
  8938. data.top = null;
  8939. }
  8940. if (a == 'nw') {
  8941. data.top = cpos.top + (csize.height - data.height);
  8942. data.left = cpos.left + (csize.width - data.width);
  8943. }
  8944. return data;
  8945. },
  8946. _respectSize: function(data, event) {
  8947. var el = this.helper, o = this._vBoundaries, pRatio = this._aspectRatio || event.shiftKey, a = this.axis,
  8948. ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  8949. isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height);
  8950. if (isminw) data.width = o.minWidth;
  8951. if (isminh) data.height = o.minHeight;
  8952. if (ismaxw) data.width = o.maxWidth;
  8953. if (ismaxh) data.height = o.maxHeight;
  8954. var dw = this.originalPosition.left + this.originalSize.width, dh = this.position.top + this.size.height;
  8955. var cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  8956. if (isminw && cw) data.left = dw - o.minWidth;
  8957. if (ismaxw && cw) data.left = dw - o.maxWidth;
  8958. if (isminh && ch) data.top = dh - o.minHeight;
  8959. if (ismaxh && ch) data.top = dh - o.maxHeight;
  8960. // fixing jump error on top/left - bug #2330
  8961. var isNotwh = !data.width && !data.height;
  8962. if (isNotwh && !data.left && data.top) data.top = null;
  8963. else if (isNotwh && !data.top && data.left) data.left = null;
  8964. return data;
  8965. },
  8966. _proportionallyResize: function() {
  8967. var o = this.options;
  8968. if (!this._proportionallyResizeElements.length) return;
  8969. var element = this.helper || this.element;
  8970. for (var i=0; i < this._proportionallyResizeElements.length; i++) {
  8971. var prel = this._proportionallyResizeElements[i];
  8972. if (!this.borderDif) {
  8973. var b = [prel.css('borderTopWidth'), prel.css('borderRightWidth'), prel.css('borderBottomWidth'), prel.css('borderLeftWidth')],
  8974. p = [prel.css('paddingTop'), prel.css('paddingRight'), prel.css('paddingBottom'), prel.css('paddingLeft')];
  8975. this.borderDif = $.map(b, function(v, i) {
  8976. var border = parseInt(v,10)||0, padding = parseInt(p[i],10)||0;
  8977. return border + padding;
  8978. });
  8979. }
  8980. prel.css({
  8981. height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
  8982. width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
  8983. });
  8984. };
  8985. },
  8986. _renderProxy: function() {
  8987. var el = this.element, o = this.options;
  8988. this.elementOffset = el.offset();
  8989. if(this._helper) {
  8990. this.helper = this.helper || $('<div style="overflow:hidden;"></div>');
  8991. // fix ie6 offset TODO: This seems broken
  8992. var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0),
  8993. pxyoffset = ( ie6 ? 2 : -1 );
  8994. this.helper.addClass(this._helper).css({
  8995. width: this.element.outerWidth() + pxyoffset,
  8996. height: this.element.outerHeight() + pxyoffset,
  8997. position: 'absolute',
  8998. left: this.elementOffset.left - ie6offset +'px',
  8999. top: this.elementOffset.top - ie6offset +'px',
  9000. zIndex: ++o.zIndex //TODO: Don't modify option
  9001. });
  9002. this.helper
  9003. .appendTo("body")
  9004. .disableSelection();
  9005. } else {
  9006. this.helper = this.element;
  9007. }
  9008. },
  9009. _change: {
  9010. e: function(event, dx, dy) {
  9011. return { width: this.originalSize.width + dx };
  9012. },
  9013. w: function(event, dx, dy) {
  9014. var o = this.options, cs = this.originalSize, sp = this.originalPosition;
  9015. return { left: sp.left + dx, width: cs.width - dx };
  9016. },
  9017. n: function(event, dx, dy) {
  9018. var o = this.options, cs = this.originalSize, sp = this.originalPosition;
  9019. return { top: sp.top + dy, height: cs.height - dy };
  9020. },
  9021. s: function(event, dx, dy) {
  9022. return { height: this.originalSize.height + dy };
  9023. },
  9024. se: function(event, dx, dy) {
  9025. return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  9026. },
  9027. sw: function(event, dx, dy) {
  9028. return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  9029. },
  9030. ne: function(event, dx, dy) {
  9031. return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  9032. },
  9033. nw: function(event, dx, dy) {
  9034. return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  9035. }
  9036. },
  9037. _propagate: function(n, event) {
  9038. $.ui.plugin.call(this, n, [event, this.ui()]);
  9039. (n != "resize" && this._trigger(n, event, this.ui()));
  9040. },
  9041. plugins: {},
  9042. ui: function() {
  9043. return {
  9044. originalElement: this.originalElement,
  9045. element: this.element,
  9046. helper: this.helper,
  9047. position: this.position,
  9048. size: this.size,
  9049. originalSize: this.originalSize,
  9050. originalPosition: this.originalPosition
  9051. };
  9052. }
  9053. });
  9054. /*
  9055. * Resizable Extensions
  9056. */
  9057. $.ui.plugin.add("resizable", "alsoResize", {
  9058. start: function (event, ui) {
  9059. var that = $(this).data("resizable"), o = that.options;
  9060. var _store = function (exp) {
  9061. $(exp).each(function() {
  9062. var el = $(this);
  9063. el.data("resizable-alsoresize", {
  9064. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  9065. left: parseInt(el.css('left'), 10), top: parseInt(el.css('top'), 10)
  9066. });
  9067. });
  9068. };
  9069. if (typeof(o.alsoResize) == 'object' && !o.alsoResize.parentNode) {
  9070. if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
  9071. else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
  9072. }else{
  9073. _store(o.alsoResize);
  9074. }
  9075. },
  9076. resize: function (event, ui) {
  9077. var that = $(this).data("resizable"), o = that.options, os = that.originalSize, op = that.originalPosition;
  9078. var delta = {
  9079. height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
  9080. top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
  9081. },
  9082. _alsoResize = function (exp, c) {
  9083. $(exp).each(function() {
  9084. var el = $(this), start = $(this).data("resizable-alsoresize"), style = {},
  9085. css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ['width', 'height'] : ['width', 'height', 'top', 'left'];
  9086. $.each(css, function (i, prop) {
  9087. var sum = (start[prop]||0) + (delta[prop]||0);
  9088. if (sum && sum >= 0)
  9089. style[prop] = sum || null;
  9090. });
  9091. el.css(style);
  9092. });
  9093. };
  9094. if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) {
  9095. $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
  9096. }else{
  9097. _alsoResize(o.alsoResize);
  9098. }
  9099. },
  9100. stop: function (event, ui) {
  9101. $(this).removeData("resizable-alsoresize");
  9102. }
  9103. });
  9104. $.ui.plugin.add("resizable", "animate", {
  9105. stop: function(event, ui) {
  9106. var that = $(this).data("resizable"), o = that.options;
  9107. var pr = that._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  9108. soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : that.sizeDiff.height,
  9109. soffsetw = ista ? 0 : that.sizeDiff.width;
  9110. var style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  9111. left = (parseInt(that.element.css('left'), 10) + (that.position.left - that.originalPosition.left)) || null,
  9112. top = (parseInt(that.element.css('top'), 10) + (that.position.top - that.originalPosition.top)) || null;
  9113. that.element.animate(
  9114. $.extend(style, top && left ? { top: top, left: left } : {}), {
  9115. duration: o.animateDuration,
  9116. easing: o.animateEasing,
  9117. step: function() {
  9118. var data = {
  9119. width: parseInt(that.element.css('width'), 10),
  9120. height: parseInt(that.element.css('height'), 10),
  9121. top: parseInt(that.element.css('top'), 10),
  9122. left: parseInt(that.element.css('left'), 10)
  9123. };
  9124. if (pr && pr.length) $(pr[0]).css({ width: data.width, height: data.height });
  9125. // propagating resize, and updating values for each animation step
  9126. that._updateCache(data);
  9127. that._propagate("resize", event);
  9128. }
  9129. }
  9130. );
  9131. }
  9132. });
  9133. $.ui.plugin.add("resizable", "containment", {
  9134. start: function(event, ui) {
  9135. var that = $(this).data("resizable"), o = that.options, el = that.element;
  9136. var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
  9137. if (!ce) return;
  9138. that.containerElement = $(ce);
  9139. if (/document/.test(oc) || oc == document) {
  9140. that.containerOffset = { left: 0, top: 0 };
  9141. that.containerPosition = { left: 0, top: 0 };
  9142. that.parentData = {
  9143. element: $(document), left: 0, top: 0,
  9144. width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
  9145. };
  9146. }
  9147. // i'm a node, so compute top, left, right, bottom
  9148. else {
  9149. var element = $(ce), p = [];
  9150. $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
  9151. that.containerOffset = element.offset();
  9152. that.containerPosition = element.position();
  9153. that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
  9154. var co = that.containerOffset, ch = that.containerSize.height, cw = that.containerSize.width,
  9155. width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
  9156. that.parentData = {
  9157. element: ce, left: co.left, top: co.top, width: width, height: height
  9158. };
  9159. }
  9160. },
  9161. resize: function(event, ui) {
  9162. var that = $(this).data("resizable"), o = that.options,
  9163. ps = that.containerSize, co = that.containerOffset, cs = that.size, cp = that.position,
  9164. pRatio = that._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = that.containerElement;
  9165. if (ce[0] != document && (/static/).test(ce.css('position'))) cop = co;
  9166. if (cp.left < (that._helper ? co.left : 0)) {
  9167. that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left));
  9168. if (pRatio) that.size.height = that.size.width / that.aspectRatio;
  9169. that.position.left = o.helper ? co.left : 0;
  9170. }
  9171. if (cp.top < (that._helper ? co.top : 0)) {
  9172. that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top);
  9173. if (pRatio) that.size.width = that.size.height * that.aspectRatio;
  9174. that.position.top = that._helper ? co.top : 0;
  9175. }
  9176. that.offset.left = that.parentData.left+that.position.left;
  9177. that.offset.top = that.parentData.top+that.position.top;
  9178. var woset = Math.abs( (that._helper ? that.offset.left - cop.left : (that.offset.left - cop.left)) + that.sizeDiff.width ),
  9179. hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height );
  9180. var isParent = that.containerElement.get(0) == that.element.parent().get(0),
  9181. isOffsetRelative = /relative|absolute/.test(that.containerElement.css('position'));
  9182. if(isParent && isOffsetRelative) woset -= that.parentData.left;
  9183. if (woset + that.size.width >= that.parentData.width) {
  9184. that.size.width = that.parentData.width - woset;
  9185. if (pRatio) that.size.height = that.size.width / that.aspectRatio;
  9186. }
  9187. if (hoset + that.size.height >= that.parentData.height) {
  9188. that.size.height = that.parentData.height - hoset;
  9189. if (pRatio) that.size.width = that.size.height * that.aspectRatio;
  9190. }
  9191. },
  9192. stop: function(event, ui){
  9193. var that = $(this).data("resizable"), o = that.options, cp = that.position,
  9194. co = that.containerOffset, cop = that.containerPosition, ce = that.containerElement;
  9195. var helper = $(that.helper), ho = helper.offset(), w = helper.outerWidth() - that.sizeDiff.width, h = helper.outerHeight() - that.sizeDiff.height;
  9196. if (that._helper && !o.animate && (/relative/).test(ce.css('position')))
  9197. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  9198. if (that._helper && !o.animate && (/static/).test(ce.css('position')))
  9199. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  9200. }
  9201. });
  9202. $.ui.plugin.add("resizable", "ghost", {
  9203. start: function(event, ui) {
  9204. var that = $(this).data("resizable"), o = that.options, cs = that.size;
  9205. that.ghost = that.originalElement.clone();
  9206. that.ghost
  9207. .css({ opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
  9208. .addClass('ui-resizable-ghost')
  9209. .addClass(typeof o.ghost == 'string' ? o.ghost : '');
  9210. that.ghost.appendTo(that.helper);
  9211. },
  9212. resize: function(event, ui){
  9213. var that = $(this).data("resizable"), o = that.options;
  9214. if (that.ghost) that.ghost.css({ position: 'relative', height: that.size.height, width: that.size.width });
  9215. },
  9216. stop: function(event, ui){
  9217. var that = $(this).data("resizable"), o = that.options;
  9218. if (that.ghost && that.helper) that.helper.get(0).removeChild(that.ghost.get(0));
  9219. }
  9220. });
  9221. $.ui.plugin.add("resizable", "grid", {
  9222. resize: function(event, ui) {
  9223. var that = $(this).data("resizable"), o = that.options, cs = that.size, os = that.originalSize, op = that.originalPosition, a = that.axis, ratio = o._aspectRatio || event.shiftKey;
  9224. o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid;
  9225. var ox = Math.round((cs.width - os.width) / (o.grid[0]||1)) * (o.grid[0]||1), oy = Math.round((cs.height - os.height) / (o.grid[1]||1)) * (o.grid[1]||1);
  9226. if (/^(se|s|e)$/.test(a)) {
  9227. that.size.width = os.width + ox;
  9228. that.size.height = os.height + oy;
  9229. }
  9230. else if (/^(ne)$/.test(a)) {
  9231. that.size.width = os.width + ox;
  9232. that.size.height = os.height + oy;
  9233. that.position.top = op.top - oy;
  9234. }
  9235. else if (/^(sw)$/.test(a)) {
  9236. that.size.width = os.width + ox;
  9237. that.size.height = os.height + oy;
  9238. that.position.left = op.left - ox;
  9239. }
  9240. else {
  9241. that.size.width = os.width + ox;
  9242. that.size.height = os.height + oy;
  9243. that.position.top = op.top - oy;
  9244. that.position.left = op.left - ox;
  9245. }
  9246. }
  9247. });
  9248. var num = function(v) {
  9249. return parseInt(v, 10) || 0;
  9250. };
  9251. var isNumber = function(value) {
  9252. return !isNaN(parseInt(value, 10));
  9253. };
  9254. })(jQuery);
  9255. (function( $, undefined ) {
  9256. $.widget("ui.selectable", $.ui.mouse, {
  9257. version: "1.9.0",
  9258. options: {
  9259. appendTo: 'body',
  9260. autoRefresh: true,
  9261. distance: 0,
  9262. filter: '*',
  9263. tolerance: 'touch'
  9264. },
  9265. _create: function() {
  9266. var that = this;
  9267. this.element.addClass("ui-selectable");
  9268. this.dragged = false;
  9269. // cache selectee children based on filter
  9270. var selectees;
  9271. this.refresh = function() {
  9272. selectees = $(that.options.filter, that.element[0]);
  9273. selectees.addClass("ui-selectee");
  9274. selectees.each(function() {
  9275. var $this = $(this);
  9276. var pos = $this.offset();
  9277. $.data(this, "selectable-item", {
  9278. element: this,
  9279. $element: $this,
  9280. left: pos.left,
  9281. top: pos.top,
  9282. right: pos.left + $this.outerWidth(),
  9283. bottom: pos.top + $this.outerHeight(),
  9284. startselected: false,
  9285. selected: $this.hasClass('ui-selected'),
  9286. selecting: $this.hasClass('ui-selecting'),
  9287. unselecting: $this.hasClass('ui-unselecting')
  9288. });
  9289. });
  9290. };
  9291. this.refresh();
  9292. this.selectees = selectees.addClass("ui-selectee");
  9293. this._mouseInit();
  9294. this.helper = $("<div class='ui-selectable-helper'></div>");
  9295. },
  9296. _destroy: function() {
  9297. this.selectees
  9298. .removeClass("ui-selectee")
  9299. .removeData("selectable-item");
  9300. this.element
  9301. .removeClass("ui-selectable ui-selectable-disabled");
  9302. this._mouseDestroy();
  9303. },
  9304. _mouseStart: function(event) {
  9305. var that = this;
  9306. this.opos = [event.pageX, event.pageY];
  9307. if (this.options.disabled)
  9308. return;
  9309. var options = this.options;
  9310. this.selectees = $(options.filter, this.element[0]);
  9311. this._trigger("start", event);
  9312. $(options.appendTo).append(this.helper);
  9313. // position helper (lasso)
  9314. this.helper.css({
  9315. "left": event.clientX,
  9316. "top": event.clientY,
  9317. "width": 0,
  9318. "height": 0
  9319. });
  9320. if (options.autoRefresh) {
  9321. this.refresh();
  9322. }
  9323. this.selectees.filter('.ui-selected').each(function() {
  9324. var selectee = $.data(this, "selectable-item");
  9325. selectee.startselected = true;
  9326. if (!event.metaKey && !event.ctrlKey) {
  9327. selectee.$element.removeClass('ui-selected');
  9328. selectee.selected = false;
  9329. selectee.$element.addClass('ui-unselecting');
  9330. selectee.unselecting = true;
  9331. // selectable UNSELECTING callback
  9332. that._trigger("unselecting", event, {
  9333. unselecting: selectee.element
  9334. });
  9335. }
  9336. });
  9337. $(event.target).parents().andSelf().each(function() {
  9338. var selectee = $.data(this, "selectable-item");
  9339. if (selectee) {
  9340. var doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass('ui-selected');
  9341. selectee.$element
  9342. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  9343. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  9344. selectee.unselecting = !doSelect;
  9345. selectee.selecting = doSelect;
  9346. selectee.selected = doSelect;
  9347. // selectable (UN)SELECTING callback
  9348. if (doSelect) {
  9349. that._trigger("selecting", event, {
  9350. selecting: selectee.element
  9351. });
  9352. } else {
  9353. that._trigger("unselecting", event, {
  9354. unselecting: selectee.element
  9355. });
  9356. }
  9357. return false;
  9358. }
  9359. });
  9360. },
  9361. _mouseDrag: function(event) {
  9362. var that = this;
  9363. this.dragged = true;
  9364. if (this.options.disabled)
  9365. return;
  9366. var options = this.options;
  9367. var x1 = this.opos[0], y1 = this.opos[1], x2 = event.pageX, y2 = event.pageY;
  9368. if (x1 > x2) { var tmp = x2; x2 = x1; x1 = tmp; }
  9369. if (y1 > y2) { var tmp = y2; y2 = y1; y1 = tmp; }
  9370. this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
  9371. this.selectees.each(function() {
  9372. var selectee = $.data(this, "selectable-item");
  9373. //prevent helper from being selected if appendTo: selectable
  9374. if (!selectee || selectee.element == that.element[0])
  9375. return;
  9376. var hit = false;
  9377. if (options.tolerance == 'touch') {
  9378. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  9379. } else if (options.tolerance == 'fit') {
  9380. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  9381. }
  9382. if (hit) {
  9383. // SELECT
  9384. if (selectee.selected) {
  9385. selectee.$element.removeClass('ui-selected');
  9386. selectee.selected = false;
  9387. }
  9388. if (selectee.unselecting) {
  9389. selectee.$element.removeClass('ui-unselecting');
  9390. selectee.unselecting = false;
  9391. }
  9392. if (!selectee.selecting) {
  9393. selectee.$element.addClass('ui-selecting');
  9394. selectee.selecting = true;
  9395. // selectable SELECTING callback
  9396. that._trigger("selecting", event, {
  9397. selecting: selectee.element
  9398. });
  9399. }
  9400. } else {
  9401. // UNSELECT
  9402. if (selectee.selecting) {
  9403. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  9404. selectee.$element.removeClass('ui-selecting');
  9405. selectee.selecting = false;
  9406. selectee.$element.addClass('ui-selected');
  9407. selectee.selected = true;
  9408. } else {
  9409. selectee.$element.removeClass('ui-selecting');
  9410. selectee.selecting = false;
  9411. if (selectee.startselected) {
  9412. selectee.$element.addClass('ui-unselecting');
  9413. selectee.unselecting = true;
  9414. }
  9415. // selectable UNSELECTING callback
  9416. that._trigger("unselecting", event, {
  9417. unselecting: selectee.element
  9418. });
  9419. }
  9420. }
  9421. if (selectee.selected) {
  9422. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  9423. selectee.$element.removeClass('ui-selected');
  9424. selectee.selected = false;
  9425. selectee.$element.addClass('ui-unselecting');
  9426. selectee.unselecting = true;
  9427. // selectable UNSELECTING callback
  9428. that._trigger("unselecting", event, {
  9429. unselecting: selectee.element
  9430. });
  9431. }
  9432. }
  9433. }
  9434. });
  9435. return false;
  9436. },
  9437. _mouseStop: function(event) {
  9438. var that = this;
  9439. this.dragged = false;
  9440. var options = this.options;
  9441. $('.ui-unselecting', this.element[0]).each(function() {
  9442. var selectee = $.data(this, "selectable-item");
  9443. selectee.$element.removeClass('ui-unselecting');
  9444. selectee.unselecting = false;
  9445. selectee.startselected = false;
  9446. that._trigger("unselected", event, {
  9447. unselected: selectee.element
  9448. });
  9449. });
  9450. $('.ui-selecting', this.element[0]).each(function() {
  9451. var selectee = $.data(this, "selectable-item");
  9452. selectee.$element.removeClass('ui-selecting').addClass('ui-selected');
  9453. selectee.selecting = false;
  9454. selectee.selected = true;
  9455. selectee.startselected = true;
  9456. that._trigger("selected", event, {
  9457. selected: selectee.element
  9458. });
  9459. });
  9460. this._trigger("stop", event);
  9461. this.helper.remove();
  9462. return false;
  9463. }
  9464. });
  9465. })(jQuery);
  9466. (function( $, undefined ) {
  9467. // number of pages in a slider
  9468. // (how many times can you page up/down to go through the whole range)
  9469. var numPages = 5;
  9470. $.widget( "ui.slider", $.ui.mouse, {
  9471. version: "1.9.0",
  9472. widgetEventPrefix: "slide",
  9473. options: {
  9474. animate: false,
  9475. distance: 0,
  9476. max: 100,
  9477. min: 0,
  9478. orientation: "horizontal",
  9479. range: false,
  9480. step: 1,
  9481. value: 0,
  9482. values: null
  9483. },
  9484. _create: function() {
  9485. var i,
  9486. o = this.options,
  9487. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  9488. handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
  9489. handleCount = ( o.values && o.values.length ) || 1,
  9490. handles = [];
  9491. this._keySliding = false;
  9492. this._mouseSliding = false;
  9493. this._animateOff = true;
  9494. this._handleIndex = null;
  9495. this._detectOrientation();
  9496. this._mouseInit();
  9497. this.element
  9498. .addClass( "ui-slider" +
  9499. " ui-slider-" + this.orientation +
  9500. " ui-widget" +
  9501. " ui-widget-content" +
  9502. " ui-corner-all" +
  9503. ( o.disabled ? " ui-slider-disabled ui-disabled" : "" ) );
  9504. this.range = $([]);
  9505. if ( o.range ) {
  9506. if ( o.range === true ) {
  9507. if ( !o.values ) {
  9508. o.values = [ this._valueMin(), this._valueMin() ];
  9509. }
  9510. if ( o.values.length && o.values.length !== 2 ) {
  9511. o.values = [ o.values[0], o.values[0] ];
  9512. }
  9513. }
  9514. this.range = $( "<div></div>" )
  9515. .appendTo( this.element )
  9516. .addClass( "ui-slider-range" +
  9517. // note: this isn't the most fittingly semantic framework class for this element,
  9518. // but worked best visually with a variety of themes
  9519. " ui-widget-header" +
  9520. ( ( o.range === "min" || o.range === "max" ) ? " ui-slider-range-" + o.range : "" ) );
  9521. }
  9522. for ( i = existingHandles.length; i < handleCount; i++ ) {
  9523. handles.push( handle );
  9524. }
  9525. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  9526. this.handle = this.handles.eq( 0 );
  9527. this.handles.add( this.range ).filter( "a" )
  9528. .click(function( event ) {
  9529. event.preventDefault();
  9530. })
  9531. .mouseenter(function() {
  9532. if ( !o.disabled ) {
  9533. $( this ).addClass( "ui-state-hover" );
  9534. }
  9535. })
  9536. .mouseleave(function() {
  9537. $( this ).removeClass( "ui-state-hover" );
  9538. })
  9539. .focus(function() {
  9540. if ( !o.disabled ) {
  9541. $( ".ui-slider .ui-state-focus" ).removeClass( "ui-state-focus" );
  9542. $( this ).addClass( "ui-state-focus" );
  9543. } else {
  9544. $( this ).blur();
  9545. }
  9546. })
  9547. .blur(function() {
  9548. $( this ).removeClass( "ui-state-focus" );
  9549. });
  9550. this.handles.each(function( i ) {
  9551. $( this ).data( "ui-slider-handle-index", i );
  9552. });
  9553. this._on( this.handles, {
  9554. keydown: function( event ) {
  9555. var allowed, curVal, newVal, step,
  9556. index = $( event.target ).data( "ui-slider-handle-index" );
  9557. switch ( event.keyCode ) {
  9558. case $.ui.keyCode.HOME:
  9559. case $.ui.keyCode.END:
  9560. case $.ui.keyCode.PAGE_UP:
  9561. case $.ui.keyCode.PAGE_DOWN:
  9562. case $.ui.keyCode.UP:
  9563. case $.ui.keyCode.RIGHT:
  9564. case $.ui.keyCode.DOWN:
  9565. case $.ui.keyCode.LEFT:
  9566. event.preventDefault();
  9567. if ( !this._keySliding ) {
  9568. this._keySliding = true;
  9569. $( event.target ).addClass( "ui-state-active" );
  9570. allowed = this._start( event, index );
  9571. if ( allowed === false ) {
  9572. return;
  9573. }
  9574. }
  9575. break;
  9576. }
  9577. step = this.options.step;
  9578. if ( this.options.values && this.options.values.length ) {
  9579. curVal = newVal = this.values( index );
  9580. } else {
  9581. curVal = newVal = this.value();
  9582. }
  9583. switch ( event.keyCode ) {
  9584. case $.ui.keyCode.HOME:
  9585. newVal = this._valueMin();
  9586. break;
  9587. case $.ui.keyCode.END:
  9588. newVal = this._valueMax();
  9589. break;
  9590. case $.ui.keyCode.PAGE_UP:
  9591. newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) );
  9592. break;
  9593. case $.ui.keyCode.PAGE_DOWN:
  9594. newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) );
  9595. break;
  9596. case $.ui.keyCode.UP:
  9597. case $.ui.keyCode.RIGHT:
  9598. if ( curVal === this._valueMax() ) {
  9599. return;
  9600. }
  9601. newVal = this._trimAlignValue( curVal + step );
  9602. break;
  9603. case $.ui.keyCode.DOWN:
  9604. case $.ui.keyCode.LEFT:
  9605. if ( curVal === this._valueMin() ) {
  9606. return;
  9607. }
  9608. newVal = this._trimAlignValue( curVal - step );
  9609. break;
  9610. }
  9611. this._slide( event, index, newVal );
  9612. },
  9613. keyup: function( event ) {
  9614. var index = $( event.target ).data( "ui-slider-handle-index" );
  9615. if ( this._keySliding ) {
  9616. this._keySliding = false;
  9617. this._stop( event, index );
  9618. this._change( event, index );
  9619. $( event.target ).removeClass( "ui-state-active" );
  9620. }
  9621. }
  9622. });
  9623. this._refreshValue();
  9624. this._animateOff = false;
  9625. },
  9626. _destroy: function() {
  9627. this.handles.remove();
  9628. this.range.remove();
  9629. this.element
  9630. .removeClass( "ui-slider" +
  9631. " ui-slider-horizontal" +
  9632. " ui-slider-vertical" +
  9633. " ui-slider-disabled" +
  9634. " ui-widget" +
  9635. " ui-widget-content" +
  9636. " ui-corner-all" );
  9637. this._mouseDestroy();
  9638. },
  9639. _mouseCapture: function( event ) {
  9640. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  9641. that = this,
  9642. o = this.options;
  9643. if ( o.disabled ) {
  9644. return false;
  9645. }
  9646. this.elementSize = {
  9647. width: this.element.outerWidth(),
  9648. height: this.element.outerHeight()
  9649. };
  9650. this.elementOffset = this.element.offset();
  9651. position = { x: event.pageX, y: event.pageY };
  9652. normValue = this._normValueFromMouse( position );
  9653. distance = this._valueMax() - this._valueMin() + 1;
  9654. this.handles.each(function( i ) {
  9655. var thisDistance = Math.abs( normValue - that.values(i) );
  9656. if ( distance > thisDistance ) {
  9657. distance = thisDistance;
  9658. closestHandle = $( this );
  9659. index = i;
  9660. }
  9661. });
  9662. // workaround for bug #3736 (if both handles of a range are at 0,
  9663. // the first is always used as the one with least distance,
  9664. // and moving it is obviously prevented by preventing negative ranges)
  9665. if( o.range === true && this.values(1) === o.min ) {
  9666. index += 1;
  9667. closestHandle = $( this.handles[index] );
  9668. }
  9669. allowed = this._start( event, index );
  9670. if ( allowed === false ) {
  9671. return false;
  9672. }
  9673. this._mouseSliding = true;
  9674. this._handleIndex = index;
  9675. closestHandle
  9676. .addClass( "ui-state-active" )
  9677. .focus();
  9678. offset = closestHandle.offset();
  9679. mouseOverHandle = !$( event.target ).parents().andSelf().is( ".ui-slider-handle" );
  9680. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  9681. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  9682. top: event.pageY - offset.top -
  9683. ( closestHandle.height() / 2 ) -
  9684. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  9685. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  9686. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  9687. };
  9688. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  9689. this._slide( event, index, normValue );
  9690. }
  9691. this._animateOff = true;
  9692. return true;
  9693. },
  9694. _mouseStart: function( event ) {
  9695. return true;
  9696. },
  9697. _mouseDrag: function( event ) {
  9698. var position = { x: event.pageX, y: event.pageY },
  9699. normValue = this._normValueFromMouse( position );
  9700. this._slide( event, this._handleIndex, normValue );
  9701. return false;
  9702. },
  9703. _mouseStop: function( event ) {
  9704. this.handles.removeClass( "ui-state-active" );
  9705. this._mouseSliding = false;
  9706. this._stop( event, this._handleIndex );
  9707. this._change( event, this._handleIndex );
  9708. this._handleIndex = null;
  9709. this._clickOffset = null;
  9710. this._animateOff = false;
  9711. return false;
  9712. },
  9713. _detectOrientation: function() {
  9714. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  9715. },
  9716. _normValueFromMouse: function( position ) {
  9717. var pixelTotal,
  9718. pixelMouse,
  9719. percentMouse,
  9720. valueTotal,
  9721. valueMouse;
  9722. if ( this.orientation === "horizontal" ) {
  9723. pixelTotal = this.elementSize.width;
  9724. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  9725. } else {
  9726. pixelTotal = this.elementSize.height;
  9727. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  9728. }
  9729. percentMouse = ( pixelMouse / pixelTotal );
  9730. if ( percentMouse > 1 ) {
  9731. percentMouse = 1;
  9732. }
  9733. if ( percentMouse < 0 ) {
  9734. percentMouse = 0;
  9735. }
  9736. if ( this.orientation === "vertical" ) {
  9737. percentMouse = 1 - percentMouse;
  9738. }
  9739. valueTotal = this._valueMax() - this._valueMin();
  9740. valueMouse = this._valueMin() + percentMouse * valueTotal;
  9741. return this._trimAlignValue( valueMouse );
  9742. },
  9743. _start: function( event, index ) {
  9744. var uiHash = {
  9745. handle: this.handles[ index ],
  9746. value: this.value()
  9747. };
  9748. if ( this.options.values && this.options.values.length ) {
  9749. uiHash.value = this.values( index );
  9750. uiHash.values = this.values();
  9751. }
  9752. return this._trigger( "start", event, uiHash );
  9753. },
  9754. _slide: function( event, index, newVal ) {
  9755. var otherVal,
  9756. newValues,
  9757. allowed;
  9758. if ( this.options.values && this.options.values.length ) {
  9759. otherVal = this.values( index ? 0 : 1 );
  9760. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  9761. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  9762. ) {
  9763. newVal = otherVal;
  9764. }
  9765. if ( newVal !== this.values( index ) ) {
  9766. newValues = this.values();
  9767. newValues[ index ] = newVal;
  9768. // A slide can be canceled by returning false from the slide callback
  9769. allowed = this._trigger( "slide", event, {
  9770. handle: this.handles[ index ],
  9771. value: newVal,
  9772. values: newValues
  9773. } );
  9774. otherVal = this.values( index ? 0 : 1 );
  9775. if ( allowed !== false ) {
  9776. this.values( index, newVal, true );
  9777. }
  9778. }
  9779. } else {
  9780. if ( newVal !== this.value() ) {
  9781. // A slide can be canceled by returning false from the slide callback
  9782. allowed = this._trigger( "slide", event, {
  9783. handle: this.handles[ index ],
  9784. value: newVal
  9785. } );
  9786. if ( allowed !== false ) {
  9787. this.value( newVal );
  9788. }
  9789. }
  9790. }
  9791. },
  9792. _stop: function( event, index ) {
  9793. var uiHash = {
  9794. handle: this.handles[ index ],
  9795. value: this.value()
  9796. };
  9797. if ( this.options.values && this.options.values.length ) {
  9798. uiHash.value = this.values( index );
  9799. uiHash.values = this.values();
  9800. }
  9801. this._trigger( "stop", event, uiHash );
  9802. },
  9803. _change: function( event, index ) {
  9804. if ( !this._keySliding && !this._mouseSliding ) {
  9805. var uiHash = {
  9806. handle: this.handles[ index ],
  9807. value: this.value()
  9808. };
  9809. if ( this.options.values && this.options.values.length ) {
  9810. uiHash.value = this.values( index );
  9811. uiHash.values = this.values();
  9812. }
  9813. this._trigger( "change", event, uiHash );
  9814. }
  9815. },
  9816. value: function( newValue ) {
  9817. if ( arguments.length ) {
  9818. this.options.value = this._trimAlignValue( newValue );
  9819. this._refreshValue();
  9820. this._change( null, 0 );
  9821. return;
  9822. }
  9823. return this._value();
  9824. },
  9825. values: function( index, newValue ) {
  9826. var vals,
  9827. newValues,
  9828. i;
  9829. if ( arguments.length > 1 ) {
  9830. this.options.values[ index ] = this._trimAlignValue( newValue );
  9831. this._refreshValue();
  9832. this._change( null, index );
  9833. return;
  9834. }
  9835. if ( arguments.length ) {
  9836. if ( $.isArray( arguments[ 0 ] ) ) {
  9837. vals = this.options.values;
  9838. newValues = arguments[ 0 ];
  9839. for ( i = 0; i < vals.length; i += 1 ) {
  9840. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  9841. this._change( null, i );
  9842. }
  9843. this._refreshValue();
  9844. } else {
  9845. if ( this.options.values && this.options.values.length ) {
  9846. return this._values( index );
  9847. } else {
  9848. return this.value();
  9849. }
  9850. }
  9851. } else {
  9852. return this._values();
  9853. }
  9854. },
  9855. _setOption: function( key, value ) {
  9856. var i,
  9857. valsLength = 0;
  9858. if ( $.isArray( this.options.values ) ) {
  9859. valsLength = this.options.values.length;
  9860. }
  9861. $.Widget.prototype._setOption.apply( this, arguments );
  9862. switch ( key ) {
  9863. case "disabled":
  9864. if ( value ) {
  9865. this.handles.filter( ".ui-state-focus" ).blur();
  9866. this.handles.removeClass( "ui-state-hover" );
  9867. this.handles.prop( "disabled", true );
  9868. this.element.addClass( "ui-disabled" );
  9869. } else {
  9870. this.handles.prop( "disabled", false );
  9871. this.element.removeClass( "ui-disabled" );
  9872. }
  9873. break;
  9874. case "orientation":
  9875. this._detectOrientation();
  9876. this.element
  9877. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  9878. .addClass( "ui-slider-" + this.orientation );
  9879. this._refreshValue();
  9880. break;
  9881. case "value":
  9882. this._animateOff = true;
  9883. this._refreshValue();
  9884. this._change( null, 0 );
  9885. this._animateOff = false;
  9886. break;
  9887. case "values":
  9888. this._animateOff = true;
  9889. this._refreshValue();
  9890. for ( i = 0; i < valsLength; i += 1 ) {
  9891. this._change( null, i );
  9892. }
  9893. this._animateOff = false;
  9894. break;
  9895. }
  9896. },
  9897. //internal value getter
  9898. // _value() returns value trimmed by min and max, aligned by step
  9899. _value: function() {
  9900. var val = this.options.value;
  9901. val = this._trimAlignValue( val );
  9902. return val;
  9903. },
  9904. //internal values getter
  9905. // _values() returns array of values trimmed by min and max, aligned by step
  9906. // _values( index ) returns single value trimmed by min and max, aligned by step
  9907. _values: function( index ) {
  9908. var val,
  9909. vals,
  9910. i;
  9911. if ( arguments.length ) {
  9912. val = this.options.values[ index ];
  9913. val = this._trimAlignValue( val );
  9914. return val;
  9915. } else {
  9916. // .slice() creates a copy of the array
  9917. // this copy gets trimmed by min and max and then returned
  9918. vals = this.options.values.slice();
  9919. for ( i = 0; i < vals.length; i+= 1) {
  9920. vals[ i ] = this._trimAlignValue( vals[ i ] );
  9921. }
  9922. return vals;
  9923. }
  9924. },
  9925. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  9926. _trimAlignValue: function( val ) {
  9927. if ( val <= this._valueMin() ) {
  9928. return this._valueMin();
  9929. }
  9930. if ( val >= this._valueMax() ) {
  9931. return this._valueMax();
  9932. }
  9933. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  9934. valModStep = (val - this._valueMin()) % step,
  9935. alignValue = val - valModStep;
  9936. if ( Math.abs(valModStep) * 2 >= step ) {
  9937. alignValue += ( valModStep > 0 ) ? step : ( -step );
  9938. }
  9939. // Since JavaScript has problems with large floats, round
  9940. // the final value to 5 digits after the decimal point (see #4124)
  9941. return parseFloat( alignValue.toFixed(5) );
  9942. },
  9943. _valueMin: function() {
  9944. return this.options.min;
  9945. },
  9946. _valueMax: function() {
  9947. return this.options.max;
  9948. },
  9949. _refreshValue: function() {
  9950. var lastValPercent, valPercent, value, valueMin, valueMax,
  9951. oRange = this.options.range,
  9952. o = this.options,
  9953. that = this,
  9954. animate = ( !this._animateOff ) ? o.animate : false,
  9955. _set = {};
  9956. if ( this.options.values && this.options.values.length ) {
  9957. this.handles.each(function( i, j ) {
  9958. valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
  9959. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  9960. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  9961. if ( that.options.range === true ) {
  9962. if ( that.orientation === "horizontal" ) {
  9963. if ( i === 0 ) {
  9964. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  9965. }
  9966. if ( i === 1 ) {
  9967. that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  9968. }
  9969. } else {
  9970. if ( i === 0 ) {
  9971. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  9972. }
  9973. if ( i === 1 ) {
  9974. that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  9975. }
  9976. }
  9977. }
  9978. lastValPercent = valPercent;
  9979. });
  9980. } else {
  9981. value = this.value();
  9982. valueMin = this._valueMin();
  9983. valueMax = this._valueMax();
  9984. valPercent = ( valueMax !== valueMin ) ?
  9985. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  9986. 0;
  9987. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  9988. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  9989. if ( oRange === "min" && this.orientation === "horizontal" ) {
  9990. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  9991. }
  9992. if ( oRange === "max" && this.orientation === "horizontal" ) {
  9993. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  9994. }
  9995. if ( oRange === "min" && this.orientation === "vertical" ) {
  9996. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  9997. }
  9998. if ( oRange === "max" && this.orientation === "vertical" ) {
  9999. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  10000. }
  10001. }
  10002. }
  10003. });
  10004. }(jQuery));
  10005. (function( $, undefined ) {
  10006. $.widget("ui.sortable", $.ui.mouse, {
  10007. version: "1.9.0",
  10008. widgetEventPrefix: "sort",
  10009. ready: false,
  10010. options: {
  10011. appendTo: "parent",
  10012. axis: false,
  10013. connectWith: false,
  10014. containment: false,
  10015. cursor: 'auto',
  10016. cursorAt: false,
  10017. dropOnEmpty: true,
  10018. forcePlaceholderSize: false,
  10019. forceHelperSize: false,
  10020. grid: false,
  10021. handle: false,
  10022. helper: "original",
  10023. items: '> *',
  10024. opacity: false,
  10025. placeholder: false,
  10026. revert: false,
  10027. scroll: true,
  10028. scrollSensitivity: 20,
  10029. scrollSpeed: 20,
  10030. scope: "default",
  10031. tolerance: "intersect",
  10032. zIndex: 1000
  10033. },
  10034. _create: function() {
  10035. var o = this.options;
  10036. this.containerCache = {};
  10037. this.element.addClass("ui-sortable");
  10038. //Get the items
  10039. this.refresh();
  10040. //Let's determine if the items are being displayed horizontally
  10041. this.floating = this.items.length ? o.axis === 'x' || (/left|right/).test(this.items[0].item.css('float')) || (/inline|table-cell/).test(this.items[0].item.css('display')) : false;
  10042. //Let's determine the parent's offset
  10043. this.offset = this.element.offset();
  10044. //Initialize mouse events for interaction
  10045. this._mouseInit();
  10046. //We're ready to go
  10047. this.ready = true
  10048. },
  10049. _destroy: function() {
  10050. this.element
  10051. .removeClass("ui-sortable ui-sortable-disabled");
  10052. this._mouseDestroy();
  10053. for ( var i = this.items.length - 1; i >= 0; i-- )
  10054. this.items[i].item.removeData(this.widgetName + "-item");
  10055. return this;
  10056. },
  10057. _setOption: function(key, value){
  10058. if ( key === "disabled" ) {
  10059. this.options[ key ] = value;
  10060. this.widget().toggleClass( "ui-sortable-disabled", !!value );
  10061. } else {
  10062. // Don't call widget base _setOption for disable as it adds ui-state-disabled class
  10063. $.Widget.prototype._setOption.apply(this, arguments);
  10064. }
  10065. },
  10066. _mouseCapture: function(event, overrideHandle) {
  10067. var that = this;
  10068. if (this.reverting) {
  10069. return false;
  10070. }
  10071. if(this.options.disabled || this.options.type == 'static') return false;
  10072. //We have to refresh the items data once first
  10073. this._refreshItems(event);
  10074. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  10075. var currentItem = null, nodes = $(event.target).parents().each(function() {
  10076. if($.data(this, that.widgetName + '-item') == that) {
  10077. currentItem = $(this);
  10078. return false;
  10079. }
  10080. });
  10081. if($.data(event.target, that.widgetName + '-item') == that) currentItem = $(event.target);
  10082. if(!currentItem) return false;
  10083. if(this.options.handle && !overrideHandle) {
  10084. var validHandle = false;
  10085. $(this.options.handle, currentItem).find("*").andSelf().each(function() { if(this == event.target) validHandle = true; });
  10086. if(!validHandle) return false;
  10087. }
  10088. this.currentItem = currentItem;
  10089. this._removeCurrentsFromItems();
  10090. return true;
  10091. },
  10092. _mouseStart: function(event, overrideHandle, noActivation) {
  10093. var o = this.options;
  10094. this.currentContainer = this;
  10095. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  10096. this.refreshPositions();
  10097. //Create and append the visible helper
  10098. this.helper = this._createHelper(event);
  10099. //Cache the helper size
  10100. this._cacheHelperProportions();
  10101. /*
  10102. * - Position generation -
  10103. * This block generates everything position related - it's the core of draggables.
  10104. */
  10105. //Cache the margins of the original element
  10106. this._cacheMargins();
  10107. //Get the next scrolling parent
  10108. this.scrollParent = this.helper.scrollParent();
  10109. //The element's absolute position on the page minus margins
  10110. this.offset = this.currentItem.offset();
  10111. this.offset = {
  10112. top: this.offset.top - this.margins.top,
  10113. left: this.offset.left - this.margins.left
  10114. };
  10115. $.extend(this.offset, {
  10116. click: { //Where the click happened, relative to the element
  10117. left: event.pageX - this.offset.left,
  10118. top: event.pageY - this.offset.top
  10119. },
  10120. parent: this._getParentOffset(),
  10121. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  10122. });
  10123. // Only after we got the offset, we can change the helper's position to absolute
  10124. // TODO: Still need to figure out a way to make relative sorting possible
  10125. this.helper.css("position", "absolute");
  10126. this.cssPosition = this.helper.css("position");
  10127. //Generate the original position
  10128. this.originalPosition = this._generatePosition(event);
  10129. this.originalPageX = event.pageX;
  10130. this.originalPageY = event.pageY;
  10131. //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
  10132. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  10133. //Cache the former DOM position
  10134. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  10135. //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
  10136. if(this.helper[0] != this.currentItem[0]) {
  10137. this.currentItem.hide();
  10138. }
  10139. //Create the placeholder
  10140. this._createPlaceholder();
  10141. //Set a containment if given in the options
  10142. if(o.containment)
  10143. this._setContainment();
  10144. if(o.cursor) { // cursor option
  10145. if ($('body').css("cursor")) this._storedCursor = $('body').css("cursor");
  10146. $('body').css("cursor", o.cursor);
  10147. }
  10148. if(o.opacity) { // opacity option
  10149. if (this.helper.css("opacity")) this._storedOpacity = this.helper.css("opacity");
  10150. this.helper.css("opacity", o.opacity);
  10151. }
  10152. if(o.zIndex) { // zIndex option
  10153. if (this.helper.css("zIndex")) this._storedZIndex = this.helper.css("zIndex");
  10154. this.helper.css("zIndex", o.zIndex);
  10155. }
  10156. //Prepare scrolling
  10157. if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML')
  10158. this.overflowOffset = this.scrollParent.offset();
  10159. //Call callbacks
  10160. this._trigger("start", event, this._uiHash());
  10161. //Recache the helper size
  10162. if(!this._preserveHelperProportions)
  10163. this._cacheHelperProportions();
  10164. //Post 'activate' events to possible containers
  10165. if(!noActivation) {
  10166. for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._trigger("activate", event, this._uiHash(this)); }
  10167. }
  10168. //Prepare possible droppables
  10169. if($.ui.ddmanager)
  10170. $.ui.ddmanager.current = this;
  10171. if ($.ui.ddmanager && !o.dropBehaviour)
  10172. $.ui.ddmanager.prepareOffsets(this, event);
  10173. this.dragging = true;
  10174. this.helper.addClass("ui-sortable-helper");
  10175. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  10176. return true;
  10177. },
  10178. _mouseDrag: function(event) {
  10179. //Compute the helpers position
  10180. this.position = this._generatePosition(event);
  10181. this.positionAbs = this._convertPositionTo("absolute");
  10182. if (!this.lastPositionAbs) {
  10183. this.lastPositionAbs = this.positionAbs;
  10184. }
  10185. //Do scrolling
  10186. if(this.options.scroll) {
  10187. var o = this.options, scrolled = false;
  10188. if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
  10189. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
  10190. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  10191. else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
  10192. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  10193. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
  10194. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  10195. else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
  10196. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  10197. } else {
  10198. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
  10199. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  10200. else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
  10201. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  10202. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
  10203. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  10204. else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
  10205. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  10206. }
  10207. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
  10208. $.ui.ddmanager.prepareOffsets(this, event);
  10209. }
  10210. //Regenerate the absolute position used for position checks
  10211. this.positionAbs = this._convertPositionTo("absolute");
  10212. //Set the helper position
  10213. if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
  10214. if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
  10215. //Rearrange
  10216. for (var i = this.items.length - 1; i >= 0; i--) {
  10217. //Cache variables and intersection, continue if no intersection
  10218. var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item);
  10219. if (!intersection) continue;
  10220. // Only put the placeholder inside the current Container, skip all
  10221. // items form other containers. This works because when moving
  10222. // an item from one container to another the
  10223. // currentContainer is switched before the placeholder is moved.
  10224. //
  10225. // Without this moving items in "sub-sortables" can cause the placeholder to jitter
  10226. // beetween the outer and inner container.
  10227. if (item.instance !== this.currentContainer) continue;
  10228. if (itemElement != this.currentItem[0] //cannot intersect with itself
  10229. && this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
  10230. && !$.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
  10231. && (this.options.type == 'semi-dynamic' ? !$.contains(this.element[0], itemElement) : true)
  10232. //&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container
  10233. ) {
  10234. this.direction = intersection == 1 ? "down" : "up";
  10235. if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) {
  10236. this._rearrange(event, item);
  10237. } else {
  10238. break;
  10239. }
  10240. this._trigger("change", event, this._uiHash());
  10241. break;
  10242. }
  10243. }
  10244. //Post events to containers
  10245. this._contactContainers(event);
  10246. //Interconnect with droppables
  10247. if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
  10248. //Call callbacks
  10249. this._trigger('sort', event, this._uiHash());
  10250. this.lastPositionAbs = this.positionAbs;
  10251. return false;
  10252. },
  10253. _mouseStop: function(event, noPropagation) {
  10254. if(!event) return;
  10255. //If we are using droppables, inform the manager about the drop
  10256. if ($.ui.ddmanager && !this.options.dropBehaviour)
  10257. $.ui.ddmanager.drop(this, event);
  10258. if(this.options.revert) {
  10259. var that = this;
  10260. var cur = this.placeholder.offset();
  10261. this.reverting = true;
  10262. $(this.helper).animate({
  10263. left: cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
  10264. top: cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
  10265. }, parseInt(this.options.revert, 10) || 500, function() {
  10266. that._clear(event);
  10267. });
  10268. } else {
  10269. this._clear(event, noPropagation);
  10270. }
  10271. return false;
  10272. },
  10273. cancel: function() {
  10274. if(this.dragging) {
  10275. this._mouseUp({ target: null });
  10276. if(this.options.helper == "original")
  10277. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  10278. else
  10279. this.currentItem.show();
  10280. //Post deactivating events to containers
  10281. for (var i = this.containers.length - 1; i >= 0; i--){
  10282. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  10283. if(this.containers[i].containerCache.over) {
  10284. this.containers[i]._trigger("out", null, this._uiHash(this));
  10285. this.containers[i].containerCache.over = 0;
  10286. }
  10287. }
  10288. }
  10289. if (this.placeholder) {
  10290. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  10291. if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  10292. if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove();
  10293. $.extend(this, {
  10294. helper: null,
  10295. dragging: false,
  10296. reverting: false,
  10297. _noFinalSort: null
  10298. });
  10299. if(this.domPosition.prev) {
  10300. $(this.domPosition.prev).after(this.currentItem);
  10301. } else {
  10302. $(this.domPosition.parent).prepend(this.currentItem);
  10303. }
  10304. }
  10305. return this;
  10306. },
  10307. serialize: function(o) {
  10308. var items = this._getItemsAsjQuery(o && o.connected);
  10309. var str = []; o = o || {};
  10310. $(items).each(function() {
  10311. var res = ($(o.item || this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
  10312. if(res) str.push((o.key || res[1]+'[]')+'='+(o.key && o.expression ? res[1] : res[2]));
  10313. });
  10314. if(!str.length && o.key) {
  10315. str.push(o.key + '=');
  10316. }
  10317. return str.join('&');
  10318. },
  10319. toArray: function(o) {
  10320. var items = this._getItemsAsjQuery(o && o.connected);
  10321. var ret = []; o = o || {};
  10322. items.each(function() { ret.push($(o.item || this).attr(o.attribute || 'id') || ''); });
  10323. return ret;
  10324. },
  10325. /* Be careful with the following core functions */
  10326. _intersectsWith: function(item) {
  10327. var x1 = this.positionAbs.left,
  10328. x2 = x1 + this.helperProportions.width,
  10329. y1 = this.positionAbs.top,
  10330. y2 = y1 + this.helperProportions.height;
  10331. var l = item.left,
  10332. r = l + item.width,
  10333. t = item.top,
  10334. b = t + item.height;
  10335. var dyClick = this.offset.click.top,
  10336. dxClick = this.offset.click.left;
  10337. var isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r;
  10338. if( this.options.tolerance == "pointer"
  10339. || this.options.forcePointerForContainers
  10340. || (this.options.tolerance != "pointer" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])
  10341. ) {
  10342. return isOverElement;
  10343. } else {
  10344. return (l < x1 + (this.helperProportions.width / 2) // Right Half
  10345. && x2 - (this.helperProportions.width / 2) < r // Left Half
  10346. && t < y1 + (this.helperProportions.height / 2) // Bottom Half
  10347. && y2 - (this.helperProportions.height / 2) < b ); // Top Half
  10348. }
  10349. },
  10350. _intersectsWithPointer: function(item) {
  10351. var isOverElementHeight = (this.options.axis === 'x') || $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  10352. isOverElementWidth = (this.options.axis === 'y') || $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  10353. isOverElement = isOverElementHeight && isOverElementWidth,
  10354. verticalDirection = this._getDragVerticalDirection(),
  10355. horizontalDirection = this._getDragHorizontalDirection();
  10356. if (!isOverElement)
  10357. return false;
  10358. return this.floating ?
  10359. ( ((horizontalDirection && horizontalDirection == "right") || verticalDirection == "down") ? 2 : 1 )
  10360. : ( verticalDirection && (verticalDirection == "down" ? 2 : 1) );
  10361. },
  10362. _intersectsWithSides: function(item) {
  10363. var isOverBottomHalf = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  10364. isOverRightHalf = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  10365. verticalDirection = this._getDragVerticalDirection(),
  10366. horizontalDirection = this._getDragHorizontalDirection();
  10367. if (this.floating && horizontalDirection) {
  10368. return ((horizontalDirection == "right" && isOverRightHalf) || (horizontalDirection == "left" && !isOverRightHalf));
  10369. } else {
  10370. return verticalDirection && ((verticalDirection == "down" && isOverBottomHalf) || (verticalDirection == "up" && !isOverBottomHalf));
  10371. }
  10372. },
  10373. _getDragVerticalDirection: function() {
  10374. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  10375. return delta != 0 && (delta > 0 ? "down" : "up");
  10376. },
  10377. _getDragHorizontalDirection: function() {
  10378. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  10379. return delta != 0 && (delta > 0 ? "right" : "left");
  10380. },
  10381. refresh: function(event) {
  10382. this._refreshItems(event);
  10383. this.refreshPositions();
  10384. return this;
  10385. },
  10386. _connectWith: function() {
  10387. var options = this.options;
  10388. return options.connectWith.constructor == String
  10389. ? [options.connectWith]
  10390. : options.connectWith;
  10391. },
  10392. _getItemsAsjQuery: function(connected) {
  10393. var items = [];
  10394. var queries = [];
  10395. var connectWith = this._connectWith();
  10396. if(connectWith && connected) {
  10397. for (var i = connectWith.length - 1; i >= 0; i--){
  10398. var cur = $(connectWith[i]);
  10399. for (var j = cur.length - 1; j >= 0; j--){
  10400. var inst = $.data(cur[j], this.widgetName);
  10401. if(inst && inst != this && !inst.options.disabled) {
  10402. 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]);
  10403. }
  10404. };
  10405. };
  10406. }
  10407. 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]);
  10408. for (var i = queries.length - 1; i >= 0; i--){
  10409. queries[i][0].each(function() {
  10410. items.push(this);
  10411. });
  10412. };
  10413. return $(items);
  10414. },
  10415. _removeCurrentsFromItems: function() {
  10416. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  10417. for (var i=0; i < this.items.length; i++) {
  10418. for (var j=0; j < list.length; j++) {
  10419. if(list[j] == this.items[i].item[0])
  10420. this.items.splice(i,1);
  10421. };
  10422. };
  10423. },
  10424. _refreshItems: function(event) {
  10425. this.items = [];
  10426. this.containers = [this];
  10427. var items = this.items;
  10428. var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]];
  10429. var connectWith = this._connectWith();
  10430. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  10431. for (var i = connectWith.length - 1; i >= 0; i--){
  10432. var cur = $(connectWith[i]);
  10433. for (var j = cur.length - 1; j >= 0; j--){
  10434. var inst = $.data(cur[j], this.widgetName);
  10435. if(inst && inst != this && !inst.options.disabled) {
  10436. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  10437. this.containers.push(inst);
  10438. }
  10439. };
  10440. };
  10441. }
  10442. for (var i = queries.length - 1; i >= 0; i--) {
  10443. var targetData = queries[i][1];
  10444. var _queries = queries[i][0];
  10445. for (var j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  10446. var item = $(_queries[j]);
  10447. item.data(this.widgetName + '-item', targetData); // Data for target checking (mouse manager)
  10448. items.push({
  10449. item: item,
  10450. instance: targetData,
  10451. width: 0, height: 0,
  10452. left: 0, top: 0
  10453. });
  10454. };
  10455. };
  10456. },
  10457. refreshPositions: function(fast) {
  10458. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  10459. if(this.offsetParent && this.helper) {
  10460. this.offset.parent = this._getParentOffset();
  10461. }
  10462. for (var i = this.items.length - 1; i >= 0; i--){
  10463. var item = this.items[i];
  10464. //We ignore calculating positions of all connected containers when we're not over them
  10465. if(item.instance != this.currentContainer && this.currentContainer && item.item[0] != this.currentItem[0])
  10466. continue;
  10467. var t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  10468. if (!fast) {
  10469. item.width = t.outerWidth();
  10470. item.height = t.outerHeight();
  10471. }
  10472. var p = t.offset();
  10473. item.left = p.left;
  10474. item.top = p.top;
  10475. };
  10476. if(this.options.custom && this.options.custom.refreshContainers) {
  10477. this.options.custom.refreshContainers.call(this);
  10478. } else {
  10479. for (var i = this.containers.length - 1; i >= 0; i--){
  10480. var p = this.containers[i].element.offset();
  10481. this.containers[i].containerCache.left = p.left;
  10482. this.containers[i].containerCache.top = p.top;
  10483. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  10484. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  10485. };
  10486. }
  10487. return this;
  10488. },
  10489. _createPlaceholder: function(that) {
  10490. that = that || this;
  10491. var o = that.options;
  10492. if(!o.placeholder || o.placeholder.constructor == String) {
  10493. var className = o.placeholder;
  10494. o.placeholder = {
  10495. element: function() {
  10496. var el = $(document.createElement(that.currentItem[0].nodeName))
  10497. .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
  10498. .removeClass("ui-sortable-helper")[0];
  10499. if(!className)
  10500. el.style.visibility = "hidden";
  10501. return el;
  10502. },
  10503. update: function(container, p) {
  10504. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  10505. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  10506. if(className && !o.forcePlaceholderSize) return;
  10507. //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
  10508. if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css('paddingTop')||0, 10) - parseInt(that.currentItem.css('paddingBottom')||0, 10)); };
  10509. if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css('paddingLeft')||0, 10) - parseInt(that.currentItem.css('paddingRight')||0, 10)); };
  10510. }
  10511. };
  10512. }
  10513. //Create the placeholder
  10514. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  10515. //Append it after the actual current item
  10516. that.currentItem.after(that.placeholder);
  10517. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  10518. o.placeholder.update(that, that.placeholder);
  10519. },
  10520. _contactContainers: function(event) {
  10521. // get innermost container that intersects with item
  10522. var innermostContainer = null, innermostIndex = null;
  10523. for (var i = this.containers.length - 1; i >= 0; i--){
  10524. // never consider a container that's located within the item itself
  10525. if($.contains(this.currentItem[0], this.containers[i].element[0]))
  10526. continue;
  10527. if(this._intersectsWith(this.containers[i].containerCache)) {
  10528. // if we've already found a container and it's more "inner" than this, then continue
  10529. if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0]))
  10530. continue;
  10531. innermostContainer = this.containers[i];
  10532. innermostIndex = i;
  10533. } else {
  10534. // container doesn't intersect. trigger "out" event if necessary
  10535. if(this.containers[i].containerCache.over) {
  10536. this.containers[i]._trigger("out", event, this._uiHash(this));
  10537. this.containers[i].containerCache.over = 0;
  10538. }
  10539. }
  10540. }
  10541. // if no intersecting containers found, return
  10542. if(!innermostContainer) return;
  10543. // move the item into the container if it's not there already
  10544. if(this.containers.length === 1) {
  10545. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  10546. this.containers[innermostIndex].containerCache.over = 1;
  10547. } else if(this.currentContainer != this.containers[innermostIndex]) {
  10548. //When entering a new container, we will find the item with the least distance and append our item near it
  10549. var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[innermostIndex].floating ? 'left' : 'top'];
  10550. for (var j = this.items.length - 1; j >= 0; j--) {
  10551. if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue;
  10552. var cur = this.containers[innermostIndex].floating ? this.items[j].item.offset().left : this.items[j].item.offset().top;
  10553. if(Math.abs(cur - base) < dist) {
  10554. dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
  10555. this.direction = (cur - base > 0) ? 'down' : 'up';
  10556. }
  10557. }
  10558. if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled
  10559. return;
  10560. this.currentContainer = this.containers[innermostIndex];
  10561. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  10562. this._trigger("change", event, this._uiHash());
  10563. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  10564. //Update the placeholder
  10565. this.options.placeholder.update(this.currentContainer, this.placeholder);
  10566. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  10567. this.containers[innermostIndex].containerCache.over = 1;
  10568. }
  10569. },
  10570. _createHelper: function(event) {
  10571. var o = this.options;
  10572. var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper == 'clone' ? this.currentItem.clone() : this.currentItem);
  10573. if(!helper.parents('body').length) //Add the helper to the DOM if that didn't happen already
  10574. $(o.appendTo != 'parent' ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  10575. if(helper[0] == this.currentItem[0])
  10576. 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") };
  10577. if(helper[0].style.width == '' || o.forceHelperSize) helper.width(this.currentItem.width());
  10578. if(helper[0].style.height == '' || o.forceHelperSize) helper.height(this.currentItem.height());
  10579. return helper;
  10580. },
  10581. _adjustOffsetFromHelper: function(obj) {
  10582. if (typeof obj == 'string') {
  10583. obj = obj.split(' ');
  10584. }
  10585. if ($.isArray(obj)) {
  10586. obj = {left: +obj[0], top: +obj[1] || 0};
  10587. }
  10588. if ('left' in obj) {
  10589. this.offset.click.left = obj.left + this.margins.left;
  10590. }
  10591. if ('right' in obj) {
  10592. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  10593. }
  10594. if ('top' in obj) {
  10595. this.offset.click.top = obj.top + this.margins.top;
  10596. }
  10597. if ('bottom' in obj) {
  10598. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  10599. }
  10600. },
  10601. _getParentOffset: function() {
  10602. //Get the offsetParent and cache its position
  10603. this.offsetParent = this.helper.offsetParent();
  10604. var po = this.offsetParent.offset();
  10605. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  10606. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  10607. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  10608. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  10609. if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  10610. po.left += this.scrollParent.scrollLeft();
  10611. po.top += this.scrollParent.scrollTop();
  10612. }
  10613. if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
  10614. || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
  10615. po = { top: 0, left: 0 };
  10616. return {
  10617. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  10618. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  10619. };
  10620. },
  10621. _getRelativeOffset: function() {
  10622. if(this.cssPosition == "relative") {
  10623. var p = this.currentItem.position();
  10624. return {
  10625. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  10626. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  10627. };
  10628. } else {
  10629. return { top: 0, left: 0 };
  10630. }
  10631. },
  10632. _cacheMargins: function() {
  10633. this.margins = {
  10634. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  10635. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  10636. };
  10637. },
  10638. _cacheHelperProportions: function() {
  10639. this.helperProportions = {
  10640. width: this.helper.outerWidth(),
  10641. height: this.helper.outerHeight()
  10642. };
  10643. },
  10644. _setContainment: function() {
  10645. var o = this.options;
  10646. if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
  10647. if(o.containment == 'document' || o.containment == 'window') this.containment = [
  10648. 0 - this.offset.relative.left - this.offset.parent.left,
  10649. 0 - this.offset.relative.top - this.offset.parent.top,
  10650. $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
  10651. ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  10652. ];
  10653. if(!(/^(document|window|parent)$/).test(o.containment)) {
  10654. var ce = $(o.containment)[0];
  10655. var co = $(o.containment).offset();
  10656. var over = ($(ce).css("overflow") != 'hidden');
  10657. this.containment = [
  10658. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  10659. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  10660. 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,
  10661. 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
  10662. ];
  10663. }
  10664. },
  10665. _convertPositionTo: function(d, pos) {
  10666. if(!pos) pos = this.position;
  10667. var mod = d == "absolute" ? 1 : -1;
  10668. var o = this.options, 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);
  10669. return {
  10670. top: (
  10671. pos.top // The absolute mouse position
  10672. + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent
  10673. + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
  10674. - ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  10675. ),
  10676. left: (
  10677. pos.left // The absolute mouse position
  10678. + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent
  10679. + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
  10680. - ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  10681. )
  10682. };
  10683. },
  10684. _generatePosition: function(event) {
  10685. var o = this.options, 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);
  10686. // This is another very weird special case that only happens for relative elements:
  10687. // 1. If the css position is relative
  10688. // 2. and the scroll parent is the document or similar to the offset parent
  10689. // we have to refresh the relative offset during the scroll so there are no jumps
  10690. if(this.cssPosition == 'relative' && !(this.scrollParent[0] != document && this.scrollParent[0] != this.offsetParent[0])) {
  10691. this.offset.relative = this._getRelativeOffset();
  10692. }
  10693. var pageX = event.pageX;
  10694. var pageY = event.pageY;
  10695. /*
  10696. * - Position constraining -
  10697. * Constrain the position to a mix of grid, containment.
  10698. */
  10699. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  10700. if(this.containment) {
  10701. if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left;
  10702. if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top;
  10703. if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left;
  10704. if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top;
  10705. }
  10706. if(o.grid) {
  10707. var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  10708. 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;
  10709. var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  10710. 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;
  10711. }
  10712. }
  10713. return {
  10714. top: (
  10715. pageY // The absolute mouse position
  10716. - this.offset.click.top // Click offset (relative to the element)
  10717. - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent
  10718. - this.offset.parent.top // The offsetParent's offset without borders (offset + border)
  10719. + ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  10720. ),
  10721. left: (
  10722. pageX // The absolute mouse position
  10723. - this.offset.click.left // Click offset (relative to the element)
  10724. - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent
  10725. - this.offset.parent.left // The offsetParent's offset without borders (offset + border)
  10726. + ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  10727. )
  10728. };
  10729. },
  10730. _rearrange: function(event, i, a, hardRefresh) {
  10731. 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));
  10732. //Various things done here to improve the performance:
  10733. // 1. we create a setTimeout, that calls refreshPositions
  10734. // 2. on the instance, we have a counter variable, that get's higher after every append
  10735. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  10736. // 4. this lets only the last addition to the timeout stack through
  10737. this.counter = this.counter ? ++this.counter : 1;
  10738. var counter = this.counter;
  10739. this._delay(function() {
  10740. if(counter == this.counter) this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  10741. });
  10742. },
  10743. _clear: function(event, noPropagation) {
  10744. this.reverting = false;
  10745. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  10746. // everything else normalized again
  10747. var delayedTriggers = [];
  10748. // We first have to update the dom position of the actual currentItem
  10749. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  10750. if(!this._noFinalSort && this.currentItem.parent().length) this.placeholder.before(this.currentItem);
  10751. this._noFinalSort = null;
  10752. if(this.helper[0] == this.currentItem[0]) {
  10753. for(var i in this._storedCSS) {
  10754. if(this._storedCSS[i] == 'auto' || this._storedCSS[i] == 'static') this._storedCSS[i] = '';
  10755. }
  10756. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  10757. } else {
  10758. this.currentItem.show();
  10759. }
  10760. if(this.fromOutside && !noPropagation) delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  10761. if((this.fromOutside || this.domPosition.prev != this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) && !noPropagation) delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  10762. // Check if the items Container has Changed and trigger appropriate
  10763. // events.
  10764. if (this !== this.currentContainer) {
  10765. if(!noPropagation) {
  10766. delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  10767. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  10768. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  10769. }
  10770. }
  10771. //Post events to containers
  10772. for (var i = this.containers.length - 1; i >= 0; i--){
  10773. if(!noPropagation) delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  10774. if(this.containers[i].containerCache.over) {
  10775. delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  10776. this.containers[i].containerCache.over = 0;
  10777. }
  10778. }
  10779. //Do what was originally in plugins
  10780. if(this._storedCursor) $('body').css("cursor", this._storedCursor); //Reset cursor
  10781. if(this._storedOpacity) this.helper.css("opacity", this._storedOpacity); //Reset opacity
  10782. if(this._storedZIndex) this.helper.css("zIndex", this._storedZIndex == 'auto' ? '' : this._storedZIndex); //Reset z-index
  10783. this.dragging = false;
  10784. if(this.cancelHelperRemoval) {
  10785. if(!noPropagation) {
  10786. this._trigger("beforeStop", event, this._uiHash());
  10787. for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
  10788. this._trigger("stop", event, this._uiHash());
  10789. }
  10790. this.fromOutside = false;
  10791. return false;
  10792. }
  10793. if(!noPropagation) this._trigger("beforeStop", event, this._uiHash());
  10794. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  10795. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  10796. if(this.helper[0] != this.currentItem[0]) this.helper.remove(); this.helper = null;
  10797. if(!noPropagation) {
  10798. for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
  10799. this._trigger("stop", event, this._uiHash());
  10800. }
  10801. this.fromOutside = false;
  10802. return true;
  10803. },
  10804. _trigger: function() {
  10805. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  10806. this.cancel();
  10807. }
  10808. },
  10809. _uiHash: function(_inst) {
  10810. var inst = _inst || this;
  10811. return {
  10812. helper: inst.helper,
  10813. placeholder: inst.placeholder || $([]),
  10814. position: inst.position,
  10815. originalPosition: inst.originalPosition,
  10816. offset: inst.positionAbs,
  10817. item: inst.currentItem,
  10818. sender: _inst ? _inst.element : null
  10819. };
  10820. }
  10821. });
  10822. })(jQuery);
  10823. (function( $ ) {
  10824. function modifier( fn ) {
  10825. return function() {
  10826. var previous = this.element.val();
  10827. fn.apply( this, arguments );
  10828. this._refresh();
  10829. if ( previous !== this.element.val() ) {
  10830. this._trigger( "change" );
  10831. }
  10832. };
  10833. }
  10834. $.widget( "ui.spinner", {
  10835. version: "1.9.0",
  10836. defaultElement: "<input>",
  10837. widgetEventPrefix: "spin",
  10838. options: {
  10839. culture: null,
  10840. icons: {
  10841. down: "ui-icon-triangle-1-s",
  10842. up: "ui-icon-triangle-1-n"
  10843. },
  10844. incremental: true,
  10845. max: null,
  10846. min: null,
  10847. numberFormat: null,
  10848. page: 10,
  10849. step: 1,
  10850. change: null,
  10851. spin: null,
  10852. start: null,
  10853. stop: null
  10854. },
  10855. _create: function() {
  10856. // handle string values that need to be parsed
  10857. this._setOption( "max", this.options.max );
  10858. this._setOption( "min", this.options.min );
  10859. this._setOption( "step", this.options.step );
  10860. // format the value, but don't constrain
  10861. this._value( this.element.val(), true );
  10862. this._draw();
  10863. this._on( this._events );
  10864. this._refresh();
  10865. // turning off autocomplete prevents the browser from remembering the
  10866. // value when navigating through history, so we re-enable autocomplete
  10867. // if the page is unloaded before the widget is destroyed. #7790
  10868. this._on( this.window, {
  10869. beforeunload: function() {
  10870. this.element.removeAttr( "autocomplete" );
  10871. }
  10872. });
  10873. },
  10874. _getCreateOptions: function() {
  10875. var options = {},
  10876. element = this.element;
  10877. $.each( [ "min", "max", "step" ], function( i, option ) {
  10878. var value = element.attr( option );
  10879. if ( value !== undefined && value.length ) {
  10880. options[ option ] = value;
  10881. }
  10882. });
  10883. return options;
  10884. },
  10885. _events: {
  10886. keydown: function( event ) {
  10887. if ( this._start( event ) && this._keydown( event ) ) {
  10888. event.preventDefault();
  10889. }
  10890. },
  10891. keyup: "_stop",
  10892. focus: function() {
  10893. this.uiSpinner.addClass( "ui-state-active" );
  10894. this.previous = this.element.val();
  10895. },
  10896. blur: function( event ) {
  10897. if ( this.cancelBlur ) {
  10898. delete this.cancelBlur;
  10899. return;
  10900. }
  10901. this._refresh();
  10902. this.uiSpinner.removeClass( "ui-state-active" );
  10903. if ( this.previous !== this.element.val() ) {
  10904. this._trigger( "change", event );
  10905. }
  10906. },
  10907. mousewheel: function( event, delta ) {
  10908. if ( !delta ) {
  10909. return;
  10910. }
  10911. if ( !this.spinning && !this._start( event ) ) {
  10912. return false;
  10913. }
  10914. this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
  10915. clearTimeout( this.mousewheelTimer );
  10916. this.mousewheelTimer = this._delay(function() {
  10917. if ( this.spinning ) {
  10918. this._stop( event );
  10919. }
  10920. }, 100 );
  10921. event.preventDefault();
  10922. },
  10923. "mousedown .ui-spinner-button": function( event ) {
  10924. var previous;
  10925. // We never want the buttons to have focus; whenever the user is
  10926. // interacting with the spinner, the focus should be on the input.
  10927. // If the input is focused then this.previous is properly set from
  10928. // when the input first received focus. If the input is not focused
  10929. // then we need to set this.previous based on the value before spinning.
  10930. previous = this.element[0] === this.document[0].activeElement ?
  10931. this.previous : this.element.val();
  10932. function checkFocus() {
  10933. var isActive = this.element[0] === this.document[0].activeElement;
  10934. if ( !isActive ) {
  10935. this.element.focus();
  10936. this.previous = previous;
  10937. // support: IE
  10938. // IE sets focus asynchronously, so we need to check if focus
  10939. // moved off of the input because the user clicked on the button.
  10940. this._delay(function() {
  10941. this.previous = previous;
  10942. });
  10943. }
  10944. }
  10945. // ensure focus is on (or stays on) the text field
  10946. event.preventDefault();
  10947. checkFocus.call( this );
  10948. // support: IE
  10949. // IE doesn't prevent moving focus even with event.preventDefault()
  10950. // so we set a flag to know when we should ignore the blur event
  10951. // and check (again) if focus moved off of the input.
  10952. this.cancelBlur = true;
  10953. this._delay(function() {
  10954. delete this.cancelBlur;
  10955. checkFocus.call( this );
  10956. });
  10957. if ( this._start( event ) === false ) {
  10958. return;
  10959. }
  10960. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  10961. },
  10962. "mouseup .ui-spinner-button": "_stop",
  10963. "mouseenter .ui-spinner-button": function( event ) {
  10964. // button will add ui-state-active if mouse was down while mouseleave and kept down
  10965. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  10966. return;
  10967. }
  10968. if ( this._start( event ) === false ) {
  10969. return false;
  10970. }
  10971. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  10972. },
  10973. // TODO: do we really want to consider this a stop?
  10974. // shouldn't we just stop the repeater and wait until mouseup before
  10975. // we trigger the stop event?
  10976. "mouseleave .ui-spinner-button": "_stop"
  10977. },
  10978. _draw: function() {
  10979. var uiSpinner = this.uiSpinner = this.element
  10980. .addClass( "ui-spinner-input" )
  10981. .attr( "autocomplete", "off" )
  10982. .wrap( this._uiSpinnerHtml() )
  10983. .parent()
  10984. // add buttons
  10985. .append( this._buttonHtml() );
  10986. this._hoverable( uiSpinner );
  10987. this.element.attr( "role", "spinbutton" );
  10988. // button bindings
  10989. this.buttons = uiSpinner.find( ".ui-spinner-button" )
  10990. .attr( "tabIndex", -1 )
  10991. .button()
  10992. .removeClass( "ui-corner-all" );
  10993. // IE 6 doesn't understand height: 50% for the buttons
  10994. // unless the wrapper has an explicit height
  10995. if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
  10996. uiSpinner.height() > 0 ) {
  10997. uiSpinner.height( uiSpinner.height() );
  10998. }
  10999. // disable spinner if element was already disabled
  11000. if ( this.options.disabled ) {
  11001. this.disable();
  11002. }
  11003. },
  11004. _keydown: function( event ) {
  11005. var options = this.options,
  11006. keyCode = $.ui.keyCode;
  11007. switch ( event.keyCode ) {
  11008. case keyCode.UP:
  11009. this._repeat( null, 1, event );
  11010. return true;
  11011. case keyCode.DOWN:
  11012. this._repeat( null, -1, event );
  11013. return true;
  11014. case keyCode.PAGE_UP:
  11015. this._repeat( null, options.page, event );
  11016. return true;
  11017. case keyCode.PAGE_DOWN:
  11018. this._repeat( null, -options.page, event );
  11019. return true;
  11020. }
  11021. return false;
  11022. },
  11023. _uiSpinnerHtml: function() {
  11024. return "<span class='ui-spinner ui-state-default ui-widget ui-widget-content ui-corner-all'></span>";
  11025. },
  11026. _buttonHtml: function() {
  11027. return "" +
  11028. "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
  11029. "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
  11030. "</a>" +
  11031. "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
  11032. "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
  11033. "</a>";
  11034. },
  11035. _start: function( event ) {
  11036. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  11037. return false;
  11038. }
  11039. if ( !this.counter ) {
  11040. this.counter = 1;
  11041. }
  11042. this.spinning = true;
  11043. return true;
  11044. },
  11045. _repeat: function( i, steps, event ) {
  11046. i = i || 500;
  11047. clearTimeout( this.timer );
  11048. this.timer = this._delay(function() {
  11049. this._repeat( 40, steps, event );
  11050. }, i );
  11051. this._spin( steps * this.options.step, event );
  11052. },
  11053. _spin: function( step, event ) {
  11054. var value = this.value() || 0;
  11055. if ( !this.counter ) {
  11056. this.counter = 1;
  11057. }
  11058. value = this._adjustValue( value + step * this._increment( this.counter ) );
  11059. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
  11060. this._value( value );
  11061. this.counter++;
  11062. }
  11063. },
  11064. _increment: function( i ) {
  11065. var incremental = this.options.incremental;
  11066. if ( incremental ) {
  11067. return $.isFunction( incremental ) ?
  11068. incremental( i ) :
  11069. Math.floor( i*i*i/50000 - i*i/500 + 17*i/200 + 1 );
  11070. }
  11071. return 1;
  11072. },
  11073. _precision: function() {
  11074. var precision = this._precisionOf( this.options.step );
  11075. if ( this.options.min !== null ) {
  11076. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  11077. }
  11078. return precision;
  11079. },
  11080. _precisionOf: function( num ) {
  11081. var str = num.toString(),
  11082. decimal = str.indexOf( "." );
  11083. return decimal === -1 ? 0 : str.length - decimal - 1;
  11084. },
  11085. _adjustValue: function( value ) {
  11086. var base, aboveMin,
  11087. options = this.options;
  11088. // make sure we're at a valid step
  11089. // - find out where we are relative to the base (min or 0)
  11090. base = options.min !== null ? options.min : 0;
  11091. aboveMin = value - base;
  11092. // - round to the nearest step
  11093. aboveMin = Math.round(aboveMin / options.step) * options.step;
  11094. // - rounding is based on 0, so adjust back to our base
  11095. value = base + aboveMin;
  11096. // fix precision from bad JS floating point math
  11097. value = parseFloat( value.toFixed( this._precision() ) );
  11098. // clamp the value
  11099. if ( options.max !== null && value > options.max) {
  11100. return options.max;
  11101. }
  11102. if ( options.min !== null && value < options.min ) {
  11103. return options.min;
  11104. }
  11105. return value;
  11106. },
  11107. _stop: function( event ) {
  11108. if ( !this.spinning ) {
  11109. return;
  11110. }
  11111. clearTimeout( this.timer );
  11112. clearTimeout( this.mousewheelTimer );
  11113. this.counter = 0;
  11114. this.spinning = false;
  11115. this._trigger( "stop", event );
  11116. },
  11117. _setOption: function( key, value ) {
  11118. if ( key === "culture" || key === "numberFormat" ) {
  11119. var prevValue = this._parse( this.element.val() );
  11120. this.options[ key ] = value;
  11121. this.element.val( this._format( prevValue ) );
  11122. return;
  11123. }
  11124. if ( key === "max" || key === "min" || key === "step" ) {
  11125. if ( typeof value === "string" ) {
  11126. value = this._parse( value );
  11127. }
  11128. }
  11129. this._super( key, value );
  11130. if ( key === "disabled" ) {
  11131. if ( value ) {
  11132. this.element.prop( "disabled", true );
  11133. this.buttons.button( "disable" );
  11134. } else {
  11135. this.element.prop( "disabled", false );
  11136. this.buttons.button( "enable" );
  11137. }
  11138. }
  11139. },
  11140. _setOptions: modifier(function( options ) {
  11141. this._super( options );
  11142. this._value( this.element.val() );
  11143. }),
  11144. _parse: function( val ) {
  11145. if ( typeof val === "string" && val !== "" ) {
  11146. val = window.Globalize && this.options.numberFormat ?
  11147. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  11148. }
  11149. return val === "" || isNaN( val ) ? null : val;
  11150. },
  11151. _format: function( value ) {
  11152. if ( value === "" ) {
  11153. return "";
  11154. }
  11155. return window.Globalize && this.options.numberFormat ?
  11156. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  11157. value;
  11158. },
  11159. _refresh: function() {
  11160. this.element.attr({
  11161. "aria-valuemin": this.options.min,
  11162. "aria-valuemax": this.options.max,
  11163. // TODO: what should we do with values that can't be parsed?
  11164. "aria-valuenow": this._parse( this.element.val() )
  11165. });
  11166. },
  11167. // update the value without triggering change
  11168. _value: function( value, allowAny ) {
  11169. var parsed;
  11170. if ( value !== "" ) {
  11171. parsed = this._parse( value );
  11172. if ( parsed !== null ) {
  11173. if ( !allowAny ) {
  11174. parsed = this._adjustValue( parsed );
  11175. }
  11176. value = this._format( parsed );
  11177. }
  11178. }
  11179. this.element.val( value );
  11180. this._refresh();
  11181. },
  11182. _destroy: function() {
  11183. this.element
  11184. .removeClass( "ui-spinner-input" )
  11185. .prop( "disabled", false )
  11186. .removeAttr( "autocomplete" )
  11187. .removeAttr( "role" )
  11188. .removeAttr( "aria-valuemin" )
  11189. .removeAttr( "aria-valuemax" )
  11190. .removeAttr( "aria-valuenow" );
  11191. this.uiSpinner.replaceWith( this.element );
  11192. },
  11193. stepUp: modifier(function( steps ) {
  11194. this._stepUp( steps );
  11195. }),
  11196. _stepUp: function( steps ) {
  11197. this._spin( (steps || 1) * this.options.step );
  11198. },
  11199. stepDown: modifier(function( steps ) {
  11200. this._stepDown( steps );
  11201. }),
  11202. _stepDown: function( steps ) {
  11203. this._spin( (steps || 1) * -this.options.step );
  11204. },
  11205. pageUp: modifier(function( pages ) {
  11206. this._stepUp( (pages || 1) * this.options.page );
  11207. }),
  11208. pageDown: modifier(function( pages ) {
  11209. this._stepDown( (pages || 1) * this.options.page );
  11210. }),
  11211. value: function( newVal ) {
  11212. if ( !arguments.length ) {
  11213. return this._parse( this.element.val() );
  11214. }
  11215. modifier( this._value ).call( this, newVal );
  11216. },
  11217. widget: function() {
  11218. return this.uiSpinner;
  11219. }
  11220. });
  11221. }( jQuery ) );
  11222. (function( $, undefined ) {
  11223. var tabId = 0,
  11224. rhash = /#.*$/;
  11225. function getNextTabId() {
  11226. return ++tabId;
  11227. }
  11228. function isLocal( anchor ) {
  11229. // clone the node to work around IE 6 not normalizing the href property
  11230. // if it's manually set, i.e., a.href = "#foo" kills the normalization
  11231. anchor = anchor.cloneNode( false );
  11232. return anchor.hash.length > 1 &&
  11233. anchor.href.replace( rhash, "" ) === location.href.replace( rhash, "" );
  11234. }
  11235. $.widget( "ui.tabs", {
  11236. version: "1.9.0",
  11237. delay: 300,
  11238. options: {
  11239. active: null,
  11240. collapsible: false,
  11241. event: "click",
  11242. heightStyle: "content",
  11243. hide: null,
  11244. show: null,
  11245. // callbacks
  11246. activate: null,
  11247. beforeActivate: null,
  11248. beforeLoad: null,
  11249. load: null
  11250. },
  11251. _create: function() {
  11252. var panel,
  11253. that = this,
  11254. options = this.options,
  11255. active = options.active;
  11256. this.running = false;
  11257. this.element
  11258. .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
  11259. .toggleClass( "ui-tabs-collapsible", options.collapsible )
  11260. // Prevent users from focusing disabled tabs via click
  11261. .delegate( ".ui-tabs-nav > li", "mousedown" + this.eventNamespace, function( event ) {
  11262. if ( $( this ).is( ".ui-state-disabled" ) ) {
  11263. event.preventDefault();
  11264. }
  11265. })
  11266. // support: IE <9
  11267. // Preventing the default action in mousedown doesn't prevent IE
  11268. // from focusing the element, so if the anchor gets focused, blur.
  11269. // We don't have to worry about focusing the previously focused
  11270. // element since clicking on a non-focusable element should focus
  11271. // the body anyway.
  11272. .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
  11273. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  11274. this.blur();
  11275. }
  11276. });
  11277. this._processTabs();
  11278. if ( active === null ) {
  11279. // check the fragment identifier in the URL
  11280. if ( location.hash ) {
  11281. this.anchors.each(function( i, anchor ) {
  11282. if ( anchor.hash === location.hash ) {
  11283. active = i;
  11284. return false;
  11285. }
  11286. });
  11287. }
  11288. // check for a tab marked active via a class
  11289. if ( active === null ) {
  11290. active = this.tabs.filter( ".ui-tabs-active" ).index();
  11291. }
  11292. // no active tab, set to false
  11293. if ( active === null || active === -1 ) {
  11294. active = this.tabs.length ? 0 : false;
  11295. }
  11296. }
  11297. // handle numbers: negative, out of range
  11298. if ( active !== false ) {
  11299. active = this.tabs.index( this.tabs.eq( active ) );
  11300. if ( active === -1 ) {
  11301. active = options.collapsible ? false : 0;
  11302. }
  11303. }
  11304. options.active = active;
  11305. // don't allow collapsible: false and active: false
  11306. if ( !options.collapsible && options.active === false && this.anchors.length ) {
  11307. options.active = 0;
  11308. }
  11309. // Take disabling tabs via class attribute from HTML
  11310. // into account and update option properly.
  11311. if ( $.isArray( options.disabled ) ) {
  11312. options.disabled = $.unique( options.disabled.concat(
  11313. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  11314. return that.tabs.index( li );
  11315. })
  11316. ) ).sort();
  11317. }
  11318. // check for length avoids error when initializing empty list
  11319. if ( this.options.active !== false && this.anchors.length ) {
  11320. this.active = this._findActive( this.options.active );
  11321. } else {
  11322. this.active = $();
  11323. }
  11324. this._refresh();
  11325. if ( this.active.length ) {
  11326. this.load( options.active );
  11327. }
  11328. },
  11329. _getCreateEventData: function() {
  11330. return {
  11331. tab: this.active,
  11332. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  11333. };
  11334. },
  11335. _tabKeydown: function( event ) {
  11336. var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
  11337. selectedIndex = this.tabs.index( focusedTab ),
  11338. goingForward = true;
  11339. if ( this._handlePageNav( event ) ) {
  11340. return;
  11341. }
  11342. switch ( event.keyCode ) {
  11343. case $.ui.keyCode.RIGHT:
  11344. case $.ui.keyCode.DOWN:
  11345. selectedIndex++;
  11346. break;
  11347. case $.ui.keyCode.UP:
  11348. case $.ui.keyCode.LEFT:
  11349. goingForward = false;
  11350. selectedIndex--;
  11351. break;
  11352. case $.ui.keyCode.END:
  11353. selectedIndex = this.anchors.length - 1;
  11354. break;
  11355. case $.ui.keyCode.HOME:
  11356. selectedIndex = 0;
  11357. break;
  11358. case $.ui.keyCode.SPACE:
  11359. // Activate only, no collapsing
  11360. event.preventDefault();
  11361. clearTimeout( this.activating );
  11362. this._activate( selectedIndex );
  11363. return;
  11364. case $.ui.keyCode.ENTER:
  11365. // Toggle (cancel delayed activation, allow collapsing)
  11366. event.preventDefault();
  11367. clearTimeout( this.activating );
  11368. // Determine if we should collapse or activate
  11369. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  11370. return;
  11371. default:
  11372. return;
  11373. }
  11374. // Focus the appropriate tab, based on which key was pressed
  11375. event.preventDefault();
  11376. clearTimeout( this.activating );
  11377. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  11378. // Navigating with control key will prevent automatic activation
  11379. if ( !event.ctrlKey ) {
  11380. // Update aria-selected immediately so that AT think the tab is already selected.
  11381. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  11382. // but the tab will already be activated by the time the announcement finishes.
  11383. focusedTab.attr( "aria-selected", "false" );
  11384. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  11385. this.activating = this._delay(function() {
  11386. this.option( "active", selectedIndex );
  11387. }, this.delay );
  11388. }
  11389. },
  11390. _panelKeydown: function( event ) {
  11391. if ( this._handlePageNav( event ) ) {
  11392. return;
  11393. }
  11394. // Ctrl+up moves focus to the current tab
  11395. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  11396. event.preventDefault();
  11397. this.active.focus();
  11398. }
  11399. },
  11400. // Alt+page up/down moves focus to the previous/next tab (and activates)
  11401. _handlePageNav: function( event ) {
  11402. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  11403. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  11404. return true;
  11405. }
  11406. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  11407. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  11408. return true;
  11409. }
  11410. },
  11411. _findNextTab: function( index, goingForward ) {
  11412. var lastTabIndex = this.tabs.length - 1;
  11413. function constrain() {
  11414. if ( index > lastTabIndex ) {
  11415. index = 0;
  11416. }
  11417. if ( index < 0 ) {
  11418. index = lastTabIndex;
  11419. }
  11420. return index;
  11421. }
  11422. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  11423. index = goingForward ? index + 1 : index - 1;
  11424. }
  11425. return index;
  11426. },
  11427. _focusNextTab: function( index, goingForward ) {
  11428. index = this._findNextTab( index, goingForward );
  11429. this.tabs.eq( index ).focus();
  11430. return index;
  11431. },
  11432. _setOption: function( key, value ) {
  11433. if ( key === "active" ) {
  11434. // _activate() will handle invalid values and update this.options
  11435. this._activate( value );
  11436. return;
  11437. }
  11438. if ( key === "disabled" ) {
  11439. // don't use the widget factory's disabled handling
  11440. this._setupDisabled( value );
  11441. return;
  11442. }
  11443. this._super( key, value);
  11444. if ( key === "collapsible" ) {
  11445. this.element.toggleClass( "ui-tabs-collapsible", value );
  11446. // Setting collapsible: false while collapsed; open first panel
  11447. if ( !value && this.options.active === false ) {
  11448. this._activate( 0 );
  11449. }
  11450. }
  11451. if ( key === "event" ) {
  11452. this._setupEvents( value );
  11453. }
  11454. if ( key === "heightStyle" ) {
  11455. this._setupHeightStyle( value );
  11456. }
  11457. },
  11458. _tabId: function( tab ) {
  11459. return tab.attr( "aria-controls" ) || "ui-tabs-" + getNextTabId();
  11460. },
  11461. _sanitizeSelector: function( hash ) {
  11462. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  11463. },
  11464. refresh: function() {
  11465. var next,
  11466. options = this.options,
  11467. lis = this.tablist.children( ":has(a[href])" );
  11468. // get disabled tabs from class attribute from HTML
  11469. // this will get converted to a boolean if needed in _refresh()
  11470. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  11471. return lis.index( tab );
  11472. });
  11473. this._processTabs();
  11474. // was collapsed or no tabs
  11475. if ( options.active === false || !this.anchors.length ) {
  11476. options.active = false;
  11477. this.active = $();
  11478. // was active, but active tab is gone
  11479. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  11480. // all remaining tabs are disabled
  11481. if ( this.tabs.length === options.disabled.length ) {
  11482. options.active = false;
  11483. this.active = $();
  11484. // activate previous tab
  11485. } else {
  11486. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  11487. }
  11488. // was active, active tab still exists
  11489. } else {
  11490. // make sure active index is correct
  11491. options.active = this.tabs.index( this.active );
  11492. }
  11493. this._refresh();
  11494. },
  11495. _refresh: function() {
  11496. this._setupDisabled( this.options.disabled );
  11497. this._setupEvents( this.options.event );
  11498. this._setupHeightStyle( this.options.heightStyle );
  11499. this.tabs.not( this.active ).attr({
  11500. "aria-selected": "false",
  11501. tabIndex: -1
  11502. });
  11503. this.panels.not( this._getPanelForTab( this.active ) )
  11504. .hide()
  11505. .attr({
  11506. "aria-expanded": "false",
  11507. "aria-hidden": "true"
  11508. });
  11509. // Make sure one tab is in the tab order
  11510. if ( !this.active.length ) {
  11511. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  11512. } else {
  11513. this.active
  11514. .addClass( "ui-tabs-active ui-state-active" )
  11515. .attr({
  11516. "aria-selected": "true",
  11517. tabIndex: 0
  11518. });
  11519. this._getPanelForTab( this.active )
  11520. .show()
  11521. .attr({
  11522. "aria-expanded": "true",
  11523. "aria-hidden": "false"
  11524. });
  11525. }
  11526. },
  11527. _processTabs: function() {
  11528. var that = this;
  11529. this.tablist = this._getList()
  11530. .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  11531. .attr( "role", "tablist" );
  11532. this.tabs = this.tablist.find( "> li:has(a[href])" )
  11533. .addClass( "ui-state-default ui-corner-top" )
  11534. .attr({
  11535. role: "tab",
  11536. tabIndex: -1
  11537. });
  11538. this.anchors = this.tabs.map(function() {
  11539. return $( "a", this )[ 0 ];
  11540. })
  11541. .addClass( "ui-tabs-anchor" )
  11542. .attr({
  11543. role: "presentation",
  11544. tabIndex: -1
  11545. });
  11546. this.panels = $();
  11547. this.anchors.each(function( i, anchor ) {
  11548. var selector, panel, panelId,
  11549. anchorId = $( anchor ).uniqueId().attr( "id" ),
  11550. tab = $( anchor ).closest( "li" ),
  11551. originalAriaControls = tab.attr( "aria-controls" );
  11552. // inline tab
  11553. if ( isLocal( anchor ) ) {
  11554. selector = anchor.hash;
  11555. panel = that.element.find( that._sanitizeSelector( selector ) );
  11556. // remote tab
  11557. } else {
  11558. panelId = that._tabId( tab );
  11559. selector = "#" + panelId;
  11560. panel = that.element.find( selector );
  11561. if ( !panel.length ) {
  11562. panel = that._createPanel( panelId );
  11563. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  11564. }
  11565. panel.attr( "aria-live", "polite" );
  11566. }
  11567. if ( panel.length) {
  11568. that.panels = that.panels.add( panel );
  11569. }
  11570. if ( originalAriaControls ) {
  11571. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  11572. }
  11573. tab.attr({
  11574. "aria-controls": selector.substring( 1 ),
  11575. "aria-labelledby": anchorId
  11576. });
  11577. panel.attr( "aria-labelledby", anchorId );
  11578. });
  11579. this.panels
  11580. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  11581. .attr( "role", "tabpanel" );
  11582. },
  11583. // allow overriding how to find the list for rare usage scenarios (#7715)
  11584. _getList: function() {
  11585. return this.element.find( "ol,ul" ).eq( 0 );
  11586. },
  11587. _createPanel: function( id ) {
  11588. return $( "<div>" )
  11589. .attr( "id", id )
  11590. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  11591. .data( "ui-tabs-destroy", true );
  11592. },
  11593. _setupDisabled: function( disabled ) {
  11594. if ( $.isArray( disabled ) ) {
  11595. if ( !disabled.length ) {
  11596. disabled = false;
  11597. } else if ( disabled.length === this.anchors.length ) {
  11598. disabled = true;
  11599. }
  11600. }
  11601. // disable tabs
  11602. for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
  11603. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  11604. $( li )
  11605. .addClass( "ui-state-disabled" )
  11606. .attr( "aria-disabled", "true" );
  11607. } else {
  11608. $( li )
  11609. .removeClass( "ui-state-disabled" )
  11610. .removeAttr( "aria-disabled" );
  11611. }
  11612. }
  11613. this.options.disabled = disabled;
  11614. },
  11615. _setupEvents: function( event ) {
  11616. var events = {
  11617. click: function( event ) {
  11618. event.preventDefault();
  11619. }
  11620. };
  11621. if ( event ) {
  11622. $.each( event.split(" "), function( index, eventName ) {
  11623. events[ eventName ] = "_eventHandler";
  11624. });
  11625. }
  11626. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  11627. this._on( this.anchors, events );
  11628. this._on( this.tabs, { keydown: "_tabKeydown" } );
  11629. this._on( this.panels, { keydown: "_panelKeydown" } );
  11630. this._focusable( this.tabs );
  11631. this._hoverable( this.tabs );
  11632. },
  11633. _setupHeightStyle: function( heightStyle ) {
  11634. var maxHeight, overflow,
  11635. parent = this.element.parent();
  11636. if ( heightStyle === "fill" ) {
  11637. // IE 6 treats height like minHeight, so we need to turn off overflow
  11638. // in order to get a reliable height
  11639. // we use the minHeight support test because we assume that only
  11640. // browsers that don't support minHeight will treat height as minHeight
  11641. if ( !$.support.minHeight ) {
  11642. overflow = parent.css( "overflow" );
  11643. parent.css( "overflow", "hidden");
  11644. }
  11645. maxHeight = parent.height();
  11646. this.element.siblings( ":visible" ).each(function() {
  11647. var elem = $( this ),
  11648. position = elem.css( "position" );
  11649. if ( position === "absolute" || position === "fixed" ) {
  11650. return;
  11651. }
  11652. maxHeight -= elem.outerHeight( true );
  11653. });
  11654. if ( overflow ) {
  11655. parent.css( "overflow", overflow );
  11656. }
  11657. this.element.children().not( this.panels ).each(function() {
  11658. maxHeight -= $( this ).outerHeight( true );
  11659. });
  11660. this.panels.each(function() {
  11661. $( this ).height( Math.max( 0, maxHeight -
  11662. $( this ).innerHeight() + $( this ).height() ) );
  11663. })
  11664. .css( "overflow", "auto" );
  11665. } else if ( heightStyle === "auto" ) {
  11666. maxHeight = 0;
  11667. this.panels.each(function() {
  11668. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  11669. }).height( maxHeight );
  11670. }
  11671. },
  11672. _eventHandler: function( event ) {
  11673. var options = this.options,
  11674. active = this.active,
  11675. anchor = $( event.currentTarget ),
  11676. tab = anchor.closest( "li" ),
  11677. clickedIsActive = tab[ 0 ] === active[ 0 ],
  11678. collapsing = clickedIsActive && options.collapsible,
  11679. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  11680. toHide = !active.length ? $() : this._getPanelForTab( active ),
  11681. eventData = {
  11682. oldTab: active,
  11683. oldPanel: toHide,
  11684. newTab: collapsing ? $() : tab,
  11685. newPanel: toShow
  11686. };
  11687. event.preventDefault();
  11688. if ( tab.hasClass( "ui-state-disabled" ) ||
  11689. // tab is already loading
  11690. tab.hasClass( "ui-tabs-loading" ) ||
  11691. // can't switch durning an animation
  11692. this.running ||
  11693. // click on active header, but not collapsible
  11694. ( clickedIsActive && !options.collapsible ) ||
  11695. // allow canceling activation
  11696. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  11697. return;
  11698. }
  11699. options.active = collapsing ? false : this.tabs.index( tab );
  11700. this.active = clickedIsActive ? $() : tab;
  11701. if ( this.xhr ) {
  11702. this.xhr.abort();
  11703. }
  11704. if ( !toHide.length && !toShow.length ) {
  11705. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  11706. }
  11707. if ( toShow.length ) {
  11708. this.load( this.tabs.index( tab ), event );
  11709. }
  11710. this._toggle( event, eventData );
  11711. },
  11712. // handles show/hide for selecting tabs
  11713. _toggle: function( event, eventData ) {
  11714. var that = this,
  11715. toShow = eventData.newPanel,
  11716. toHide = eventData.oldPanel;
  11717. this.running = true;
  11718. function complete() {
  11719. that.running = false;
  11720. that._trigger( "activate", event, eventData );
  11721. }
  11722. function show() {
  11723. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  11724. if ( toShow.length && that.options.show ) {
  11725. that._show( toShow, that.options.show, complete );
  11726. } else {
  11727. toShow.show();
  11728. complete();
  11729. }
  11730. }
  11731. // start out by hiding, then showing, then completing
  11732. if ( toHide.length && this.options.hide ) {
  11733. this._hide( toHide, this.options.hide, function() {
  11734. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  11735. show();
  11736. });
  11737. } else {
  11738. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  11739. toHide.hide();
  11740. show();
  11741. }
  11742. toHide.attr({
  11743. "aria-expanded": "false",
  11744. "aria-hidden": "true"
  11745. });
  11746. eventData.oldTab.attr( "aria-selected", "false" );
  11747. // If we're switching tabs, remove the old tab from the tab order.
  11748. // If we're opening from collapsed state, remove the previous tab from the tab order.
  11749. // If we're collapsing, then keep the collapsing tab in the tab order.
  11750. if ( toShow.length && toHide.length ) {
  11751. eventData.oldTab.attr( "tabIndex", -1 );
  11752. } else if ( toShow.length ) {
  11753. this.tabs.filter(function() {
  11754. return $( this ).attr( "tabIndex" ) === 0;
  11755. })
  11756. .attr( "tabIndex", -1 );
  11757. }
  11758. toShow.attr({
  11759. "aria-expanded": "true",
  11760. "aria-hidden": "false"
  11761. });
  11762. eventData.newTab.attr({
  11763. "aria-selected": "true",
  11764. tabIndex: 0
  11765. });
  11766. },
  11767. _activate: function( index ) {
  11768. var anchor,
  11769. active = this._findActive( index );
  11770. // trying to activate the already active panel
  11771. if ( active[ 0 ] === this.active[ 0 ] ) {
  11772. return;
  11773. }
  11774. // trying to collapse, simulate a click on the current active header
  11775. if ( !active.length ) {
  11776. active = this.active;
  11777. }
  11778. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  11779. this._eventHandler({
  11780. target: anchor,
  11781. currentTarget: anchor,
  11782. preventDefault: $.noop
  11783. });
  11784. },
  11785. _findActive: function( index ) {
  11786. return index === false ? $() : this.tabs.eq( index );
  11787. },
  11788. _getIndex: function( index ) {
  11789. // meta-function to give users option to provide a href string instead of a numerical index.
  11790. if ( typeof index === "string" ) {
  11791. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  11792. }
  11793. return index;
  11794. },
  11795. _destroy: function() {
  11796. if ( this.xhr ) {
  11797. this.xhr.abort();
  11798. }
  11799. this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
  11800. this.tablist
  11801. .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  11802. .removeAttr( "role" );
  11803. this.anchors
  11804. .removeClass( "ui-tabs-anchor" )
  11805. .removeAttr( "role" )
  11806. .removeAttr( "tabIndex" )
  11807. .removeData( "href.tabs" )
  11808. .removeData( "load.tabs" )
  11809. .removeUniqueId();
  11810. this.tabs.add( this.panels ).each(function() {
  11811. if ( $.data( this, "ui-tabs-destroy" ) ) {
  11812. $( this ).remove();
  11813. } else {
  11814. $( this )
  11815. .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
  11816. "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
  11817. .removeAttr( "tabIndex" )
  11818. .removeAttr( "aria-live" )
  11819. .removeAttr( "aria-busy" )
  11820. .removeAttr( "aria-selected" )
  11821. .removeAttr( "aria-labelledby" )
  11822. .removeAttr( "aria-hidden" )
  11823. .removeAttr( "aria-expanded" )
  11824. .removeAttr( "role" );
  11825. }
  11826. });
  11827. this.tabs.each(function() {
  11828. var li = $( this ),
  11829. prev = li.data( "ui-tabs-aria-controls" );
  11830. if ( prev ) {
  11831. li.attr( "aria-controls", prev );
  11832. } else {
  11833. li.removeAttr( "aria-controls" );
  11834. }
  11835. });
  11836. if ( this.options.heightStyle !== "content" ) {
  11837. this.panels.css( "height", "" );
  11838. }
  11839. },
  11840. enable: function( index ) {
  11841. var disabled = this.options.disabled;
  11842. if ( disabled === false ) {
  11843. return;
  11844. }
  11845. if ( index === undefined ) {
  11846. disabled = false;
  11847. } else {
  11848. index = this._getIndex( index );
  11849. if ( $.isArray( disabled ) ) {
  11850. disabled = $.map( disabled, function( num ) {
  11851. return num !== index ? num : null;
  11852. });
  11853. } else {
  11854. disabled = $.map( this.tabs, function( li, num ) {
  11855. return num !== index ? num : null;
  11856. });
  11857. }
  11858. }
  11859. this._setupDisabled( disabled );
  11860. },
  11861. disable: function( index ) {
  11862. var disabled = this.options.disabled;
  11863. if ( disabled === true ) {
  11864. return;
  11865. }
  11866. if ( index === undefined ) {
  11867. disabled = true;
  11868. } else {
  11869. index = this._getIndex( index );
  11870. if ( $.inArray( index, disabled ) !== -1 ) {
  11871. return;
  11872. }
  11873. if ( $.isArray( disabled ) ) {
  11874. disabled = $.merge( [ index ], disabled ).sort();
  11875. } else {
  11876. disabled = [ index ];
  11877. }
  11878. }
  11879. this._setupDisabled( disabled );
  11880. },
  11881. load: function( index, event ) {
  11882. index = this._getIndex( index );
  11883. var that = this,
  11884. tab = this.tabs.eq( index ),
  11885. anchor = tab.find( ".ui-tabs-anchor" ),
  11886. panel = this._getPanelForTab( tab ),
  11887. eventData = {
  11888. tab: tab,
  11889. panel: panel
  11890. };
  11891. // not remote
  11892. if ( isLocal( anchor[ 0 ] ) ) {
  11893. return;
  11894. }
  11895. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  11896. // support: jQuery <1.8
  11897. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  11898. // but as of 1.8, $.ajax() always returns a jqXHR object.
  11899. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  11900. tab.addClass( "ui-tabs-loading" );
  11901. panel.attr( "aria-busy", "true" );
  11902. this.xhr
  11903. .success(function( response ) {
  11904. // support: jQuery <1.8
  11905. // http://bugs.jquery.com/ticket/11778
  11906. setTimeout(function() {
  11907. panel.html( response );
  11908. that._trigger( "load", event, eventData );
  11909. }, 1 );
  11910. })
  11911. .complete(function( jqXHR, status ) {
  11912. // support: jQuery <1.8
  11913. // http://bugs.jquery.com/ticket/11778
  11914. setTimeout(function() {
  11915. if ( status === "abort" ) {
  11916. that.panels.stop( false, true );
  11917. }
  11918. tab.removeClass( "ui-tabs-loading" );
  11919. panel.removeAttr( "aria-busy" );
  11920. if ( jqXHR === that.xhr ) {
  11921. delete that.xhr;
  11922. }
  11923. }, 1 );
  11924. });
  11925. }
  11926. },
  11927. // TODO: Remove this function in 1.10 when ajaxOptions is removed
  11928. _ajaxSettings: function( anchor, event, eventData ) {
  11929. var that = this;
  11930. return {
  11931. url: anchor.attr( "href" ),
  11932. beforeSend: function( jqXHR, settings ) {
  11933. return that._trigger( "beforeLoad", event,
  11934. $.extend( { jqXHR : jqXHR, ajaxSettings: settings }, eventData ) );
  11935. }
  11936. };
  11937. },
  11938. _getPanelForTab: function( tab ) {
  11939. var id = $( tab ).attr( "aria-controls" );
  11940. return this.element.find( this._sanitizeSelector( "#" + id ) );
  11941. }
  11942. });
  11943. // DEPRECATED
  11944. if ( $.uiBackCompat !== false ) {
  11945. // helper method for a lot of the back compat extensions
  11946. $.ui.tabs.prototype._ui = function( tab, panel ) {
  11947. return {
  11948. tab: tab,
  11949. panel: panel,
  11950. index: this.anchors.index( tab )
  11951. };
  11952. };
  11953. // url method
  11954. $.widget( "ui.tabs", $.ui.tabs, {
  11955. url: function( index, url ) {
  11956. this.anchors.eq( index ).attr( "href", url );
  11957. }
  11958. });
  11959. // TODO: Remove _ajaxSettings() method when removing this extension
  11960. // ajaxOptions and cache options
  11961. $.widget( "ui.tabs", $.ui.tabs, {
  11962. options: {
  11963. ajaxOptions: null,
  11964. cache: false
  11965. },
  11966. _create: function() {
  11967. this._super();
  11968. var that = this;
  11969. this._on({ tabsbeforeload: function( event, ui ) {
  11970. // tab is already cached
  11971. if ( $.data( ui.tab[ 0 ], "cache.tabs" ) ) {
  11972. event.preventDefault();
  11973. return;
  11974. }
  11975. ui.jqXHR.success(function() {
  11976. if ( that.options.cache ) {
  11977. $.data( ui.tab[ 0 ], "cache.tabs", true );
  11978. }
  11979. });
  11980. }});
  11981. },
  11982. _ajaxSettings: function( anchor, event, ui ) {
  11983. var ajaxOptions = this.options.ajaxOptions;
  11984. return $.extend( {}, ajaxOptions, {
  11985. error: function( xhr, s, e ) {
  11986. try {
  11987. // Passing index avoid a race condition when this method is
  11988. // called after the user has selected another tab.
  11989. // Pass the anchor that initiated this request allows
  11990. // loadError to manipulate the tab content panel via $(a.hash)
  11991. ajaxOptions.error(
  11992. xhr, s, ui.tab.closest( "li" ).index(), ui.tab[ 0 ] );
  11993. }
  11994. catch ( e ) {}
  11995. }
  11996. }, this._superApply( arguments ) );
  11997. },
  11998. _setOption: function( key, value ) {
  11999. // reset cache if switching from cached to not cached
  12000. if ( key === "cache" && value === false ) {
  12001. this.anchors.removeData( "cache.tabs" );
  12002. }
  12003. this._super( key, value );
  12004. },
  12005. _destroy: function() {
  12006. this.anchors.removeData( "cache.tabs" );
  12007. this._super();
  12008. },
  12009. url: function( index, url ){
  12010. this.anchors.eq( index ).removeData( "cache.tabs" );
  12011. this._superApply( arguments );
  12012. }
  12013. });
  12014. // abort method
  12015. $.widget( "ui.tabs", $.ui.tabs, {
  12016. abort: function() {
  12017. if ( this.xhr ) {
  12018. this.xhr.abort();
  12019. }
  12020. }
  12021. });
  12022. // spinner
  12023. $.widget( "ui.tabs", $.ui.tabs, {
  12024. options: {
  12025. spinner: "<em>Loading&#8230;</em>"
  12026. },
  12027. _create: function() {
  12028. this._super();
  12029. this._on({
  12030. tabsbeforeload: function( event, ui ) {
  12031. // Don't react to nested tabs or tabs that don't use a spinner
  12032. if ( event.target !== this.element[ 0 ] ||
  12033. !this.options.spinner ) {
  12034. return;
  12035. }
  12036. var span = ui.tab.find( "span" ),
  12037. html = span.html();
  12038. span.html( this.options.spinner );
  12039. ui.jqXHR.complete(function() {
  12040. span.html( html );
  12041. });
  12042. }
  12043. });
  12044. }
  12045. });
  12046. // enable/disable events
  12047. $.widget( "ui.tabs", $.ui.tabs, {
  12048. options: {
  12049. enable: null,
  12050. disable: null
  12051. },
  12052. enable: function( index ) {
  12053. var options = this.options,
  12054. trigger;
  12055. if ( index && options.disabled === true ||
  12056. ( $.isArray( options.disabled ) && $.inArray( index, options.disabled ) !== -1 ) ) {
  12057. trigger = true;
  12058. }
  12059. this._superApply( arguments );
  12060. if ( trigger ) {
  12061. this._trigger( "enable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
  12062. }
  12063. },
  12064. disable: function( index ) {
  12065. var options = this.options,
  12066. trigger;
  12067. if ( index && options.disabled === false ||
  12068. ( $.isArray( options.disabled ) && $.inArray( index, options.disabled ) === -1 ) ) {
  12069. trigger = true;
  12070. }
  12071. this._superApply( arguments );
  12072. if ( trigger ) {
  12073. this._trigger( "disable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
  12074. }
  12075. }
  12076. });
  12077. // add/remove methods and events
  12078. $.widget( "ui.tabs", $.ui.tabs, {
  12079. options: {
  12080. add: null,
  12081. remove: null,
  12082. tabTemplate: "<li><a href='#{href}'><span>#{label}</span></a></li>"
  12083. },
  12084. add: function( url, label, index ) {
  12085. if ( index === undefined ) {
  12086. index = this.anchors.length;
  12087. }
  12088. var doInsertAfter, panel,
  12089. options = this.options,
  12090. li = $( options.tabTemplate
  12091. .replace( /#\{href\}/g, url )
  12092. .replace( /#\{label\}/g, label ) ),
  12093. id = !url.indexOf( "#" ) ?
  12094. url.replace( "#", "" ) :
  12095. this._tabId( li );
  12096. li.addClass( "ui-state-default ui-corner-top" ).data( "ui-tabs-destroy", true );
  12097. li.attr( "aria-controls", id );
  12098. doInsertAfter = index >= this.tabs.length;
  12099. // try to find an existing element before creating a new one
  12100. panel = this.element.find( "#" + id );
  12101. if ( !panel.length ) {
  12102. panel = this._createPanel( id );
  12103. if ( doInsertAfter ) {
  12104. if ( index > 0 ) {
  12105. panel.insertAfter( this.panels.eq( -1 ) );
  12106. } else {
  12107. panel.appendTo( this.element );
  12108. }
  12109. } else {
  12110. panel.insertBefore( this.panels[ index ] );
  12111. }
  12112. }
  12113. panel.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" ).hide();
  12114. if ( doInsertAfter ) {
  12115. li.appendTo( this.tablist );
  12116. } else {
  12117. li.insertBefore( this.tabs[ index ] );
  12118. }
  12119. options.disabled = $.map( options.disabled, function( n ) {
  12120. return n >= index ? ++n : n;
  12121. });
  12122. this.refresh();
  12123. if ( this.tabs.length === 1 && options.active === false ) {
  12124. this.option( "active", 0 );
  12125. }
  12126. this._trigger( "add", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
  12127. return this;
  12128. },
  12129. remove: function( index ) {
  12130. index = this._getIndex( index );
  12131. var options = this.options,
  12132. tab = this.tabs.eq( index ).remove(),
  12133. panel = this._getPanelForTab( tab ).remove();
  12134. // If selected tab was removed focus tab to the right or
  12135. // in case the last tab was removed the tab to the left.
  12136. // We check for more than 2 tabs, because if there are only 2,
  12137. // then when we remove this tab, there will only be one tab left
  12138. // so we don't need to detect which tab to activate.
  12139. if ( tab.hasClass( "ui-tabs-active" ) && this.anchors.length > 2 ) {
  12140. this._activate( index + ( index + 1 < this.anchors.length ? 1 : -1 ) );
  12141. }
  12142. options.disabled = $.map(
  12143. $.grep( options.disabled, function( n ) {
  12144. return n !== index;
  12145. }),
  12146. function( n ) {
  12147. return n >= index ? --n : n;
  12148. });
  12149. this.refresh();
  12150. this._trigger( "remove", null, this._ui( tab.find( "a" )[ 0 ], panel[ 0 ] ) );
  12151. return this;
  12152. }
  12153. });
  12154. // length method
  12155. $.widget( "ui.tabs", $.ui.tabs, {
  12156. length: function() {
  12157. return this.anchors.length;
  12158. }
  12159. });
  12160. // panel ids (idPrefix option + title attribute)
  12161. $.widget( "ui.tabs", $.ui.tabs, {
  12162. options: {
  12163. idPrefix: "ui-tabs-"
  12164. },
  12165. _tabId: function( tab ) {
  12166. var a = tab.is( "li" ) ? tab.find( "a[href]" ) : tab;
  12167. a = a[0];
  12168. return $( a ).closest( "li" ).attr( "aria-controls" ) ||
  12169. a.title && a.title.replace( /\s/g, "_" ).replace( /[^\w\u00c0-\uFFFF\-]/g, "" ) ||
  12170. this.options.idPrefix + getNextTabId();
  12171. }
  12172. });
  12173. // _createPanel method
  12174. $.widget( "ui.tabs", $.ui.tabs, {
  12175. options: {
  12176. panelTemplate: "<div></div>"
  12177. },
  12178. _createPanel: function( id ) {
  12179. return $( this.options.panelTemplate )
  12180. .attr( "id", id )
  12181. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  12182. .data( "ui-tabs-destroy", true );
  12183. }
  12184. });
  12185. // selected option
  12186. $.widget( "ui.tabs", $.ui.tabs, {
  12187. _create: function() {
  12188. var options = this.options;
  12189. if ( options.active === null && options.selected !== undefined ) {
  12190. options.active = options.selected === -1 ? false : options.selected;
  12191. }
  12192. this._super();
  12193. options.selected = options.active;
  12194. if ( options.selected === false ) {
  12195. options.selected = -1;
  12196. }
  12197. },
  12198. _setOption: function( key, value ) {
  12199. if ( key !== "selected" ) {
  12200. return this._super( key, value );
  12201. }
  12202. var options = this.options;
  12203. this._super( "active", value === -1 ? false : value );
  12204. options.selected = options.active;
  12205. if ( options.selected === false ) {
  12206. options.selected = -1;
  12207. }
  12208. },
  12209. _eventHandler: function( event ) {
  12210. this._superApply( arguments );
  12211. this.options.selected = this.options.active;
  12212. if ( this.options.selected === false ) {
  12213. this.options.selected = -1;
  12214. }
  12215. }
  12216. });
  12217. // show and select event
  12218. $.widget( "ui.tabs", $.ui.tabs, {
  12219. options: {
  12220. show: null,
  12221. select: null
  12222. },
  12223. _create: function() {
  12224. this._super();
  12225. if ( this.options.active !== false ) {
  12226. this._trigger( "show", null, this._ui(
  12227. this.active.find( ".ui-tabs-anchor" )[ 0 ],
  12228. this._getPanelForTab( this.active )[ 0 ] ) );
  12229. }
  12230. },
  12231. _trigger: function( type, event, data ) {
  12232. var ret = this._superApply( arguments );
  12233. if ( !ret ) {
  12234. return false;
  12235. }
  12236. if ( type === "beforeActivate" && data.newTab.length ) {
  12237. ret = this._super( "select", event, {
  12238. tab: data.newTab.find( ".ui-tabs-anchor" )[ 0],
  12239. panel: data.newPanel[ 0 ],
  12240. index: data.newTab.closest( "li" ).index()
  12241. });
  12242. } else if ( type === "activate" && data.newTab.length ) {
  12243. ret = this._super( "show", event, {
  12244. tab: data.newTab.find( ".ui-tabs-anchor" )[ 0 ],
  12245. panel: data.newPanel[ 0 ],
  12246. index: data.newTab.closest( "li" ).index()
  12247. });
  12248. }
  12249. return ret;
  12250. }
  12251. });
  12252. // select method
  12253. $.widget( "ui.tabs", $.ui.tabs, {
  12254. select: function( index ) {
  12255. index = this._getIndex( index );
  12256. if ( index === -1 ) {
  12257. if ( this.options.collapsible && this.options.selected !== -1 ) {
  12258. index = this.options.selected;
  12259. } else {
  12260. return;
  12261. }
  12262. }
  12263. this.anchors.eq( index ).trigger( this.options.event + this.eventNamespace );
  12264. }
  12265. });
  12266. // cookie option
  12267. (function() {
  12268. var listId = 0;
  12269. $.widget( "ui.tabs", $.ui.tabs, {
  12270. options: {
  12271. cookie: null // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }
  12272. },
  12273. _create: function() {
  12274. var options = this.options,
  12275. active;
  12276. if ( options.active == null && options.cookie ) {
  12277. active = parseInt( this._cookie(), 10 );
  12278. if ( active === -1 ) {
  12279. active = false;
  12280. }
  12281. options.active = active;
  12282. }
  12283. this._super();
  12284. },
  12285. _cookie: function( active ) {
  12286. var cookie = [ this.cookie ||
  12287. ( this.cookie = this.options.cookie.name || "ui-tabs-" + (++listId) ) ];
  12288. if ( arguments.length ) {
  12289. cookie.push( active === false ? -1 : active );
  12290. cookie.push( this.options.cookie );
  12291. }
  12292. return $.cookie.apply( null, cookie );
  12293. },
  12294. _refresh: function() {
  12295. this._super();
  12296. if ( this.options.cookie ) {
  12297. this._cookie( this.options.active, this.options.cookie );
  12298. }
  12299. },
  12300. _eventHandler: function( event ) {
  12301. this._superApply( arguments );
  12302. if ( this.options.cookie ) {
  12303. this._cookie( this.options.active, this.options.cookie );
  12304. }
  12305. },
  12306. _destroy: function() {
  12307. this._super();
  12308. if ( this.options.cookie ) {
  12309. this._cookie( null, this.options.cookie );
  12310. }
  12311. }
  12312. });
  12313. })();
  12314. // load event
  12315. $.widget( "ui.tabs", $.ui.tabs, {
  12316. _trigger: function( type, event, data ) {
  12317. var _data = $.extend( {}, data );
  12318. if ( type === "load" ) {
  12319. _data.panel = _data.panel[ 0 ];
  12320. _data.tab = _data.tab.find( ".ui-tabs-anchor" )[ 0 ];
  12321. }
  12322. return this._super( type, event, _data );
  12323. }
  12324. });
  12325. // fx option
  12326. // The new animation options (show, hide) conflict with the old show callback.
  12327. // The old fx option wins over show/hide anyway (always favor back-compat).
  12328. // If a user wants to use the new animation API, they must give up the old API.
  12329. $.widget( "ui.tabs", $.ui.tabs, {
  12330. options: {
  12331. fx: null // e.g. { height: "toggle", opacity: "toggle", duration: 200 }
  12332. },
  12333. _getFx: function() {
  12334. var hide, show,
  12335. fx = this.options.fx;
  12336. if ( fx ) {
  12337. if ( $.isArray( fx ) ) {
  12338. hide = fx[ 0 ];
  12339. show = fx[ 1 ];
  12340. } else {
  12341. hide = show = fx;
  12342. }
  12343. }
  12344. return fx ? { show: show, hide: hide } : null;
  12345. },
  12346. _toggle: function( event, eventData ) {
  12347. var that = this,
  12348. toShow = eventData.newPanel,
  12349. toHide = eventData.oldPanel,
  12350. fx = this._getFx();
  12351. if ( !fx ) {
  12352. return this._super( event, eventData );
  12353. }
  12354. that.running = true;
  12355. function complete() {
  12356. that.running = false;
  12357. that._trigger( "activate", event, eventData );
  12358. }
  12359. function show() {
  12360. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  12361. if ( toShow.length && fx.show ) {
  12362. toShow
  12363. .animate( fx.show, fx.show.duration, function() {
  12364. complete();
  12365. });
  12366. } else {
  12367. toShow.show();
  12368. complete();
  12369. }
  12370. }
  12371. // start out by hiding, then showing, then completing
  12372. if ( toHide.length && fx.hide ) {
  12373. toHide.animate( fx.hide, fx.hide.duration, function() {
  12374. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  12375. show();
  12376. });
  12377. } else {
  12378. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  12379. toHide.hide();
  12380. show();
  12381. }
  12382. }
  12383. });
  12384. }
  12385. })( jQuery );
  12386. (function( $ ) {
  12387. var increments = 0;
  12388. function addDescribedBy( elem, id ) {
  12389. var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
  12390. describedby.push( id );
  12391. elem
  12392. .data( "ui-tooltip-id", id )
  12393. .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
  12394. }
  12395. function removeDescribedBy( elem ) {
  12396. var id = elem.data( "ui-tooltip-id" ),
  12397. describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
  12398. index = $.inArray( id, describedby );
  12399. if ( index !== -1 ) {
  12400. describedby.splice( index, 1 );
  12401. }
  12402. elem.removeData( "ui-tooltip-id" );
  12403. describedby = $.trim( describedby.join( " " ) );
  12404. if ( describedby ) {
  12405. elem.attr( "aria-describedby", describedby );
  12406. } else {
  12407. elem.removeAttr( "aria-describedby" );
  12408. }
  12409. }
  12410. $.widget( "ui.tooltip", {
  12411. version: "1.9.0",
  12412. options: {
  12413. content: function() {
  12414. return $( this ).attr( "title" );
  12415. },
  12416. hide: true,
  12417. items: "[title]",
  12418. position: {
  12419. my: "left+15 center",
  12420. at: "right center",
  12421. collision: "flipfit flipfit"
  12422. },
  12423. show: true,
  12424. tooltipClass: null,
  12425. track: false,
  12426. // callbacks
  12427. close: null,
  12428. open: null
  12429. },
  12430. _create: function() {
  12431. this._on({
  12432. mouseover: "open",
  12433. focusin: "open"
  12434. });
  12435. // IDs of generated tooltips, needed for destroy
  12436. this.tooltips = {};
  12437. },
  12438. _setOption: function( key, value ) {
  12439. var that = this;
  12440. if ( key === "disabled" ) {
  12441. this[ value ? "_disable" : "_enable" ]();
  12442. this.options[ key ] = value;
  12443. // disable element style changes
  12444. return;
  12445. }
  12446. this._super( key, value );
  12447. if ( key === "content" ) {
  12448. $.each( this.tooltips, function( id, element ) {
  12449. that._updateContent( element );
  12450. });
  12451. }
  12452. },
  12453. _disable: function() {
  12454. var that = this;
  12455. // close open tooltips
  12456. $.each( this.tooltips, function( id, element ) {
  12457. var event = $.Event( "blur" );
  12458. event.target = event.currentTarget = element[0];
  12459. that.close( event, true );
  12460. });
  12461. // remove title attributes to prevent native tooltips
  12462. this.element.find( this.options.items ).andSelf().each(function() {
  12463. var element = $( this );
  12464. if ( element.is( "[title]" ) ) {
  12465. element
  12466. .data( "ui-tooltip-title", element.attr( "title" ) )
  12467. .attr( "title", "" );
  12468. }
  12469. });
  12470. },
  12471. _enable: function() {
  12472. // restore title attributes
  12473. this.element.find( this.options.items ).andSelf().each(function() {
  12474. var element = $( this );
  12475. if ( element.data( "ui-tooltip-title" ) ) {
  12476. element.attr( "title", element.data( "ui-tooltip-title" ) );
  12477. }
  12478. });
  12479. },
  12480. open: function( event ) {
  12481. var target = $( event ? event.target : this.element )
  12482. .closest( this.options.items );
  12483. // No element to show a tooltip for
  12484. if ( !target.length ) {
  12485. return;
  12486. }
  12487. // If the tooltip is open and we're tracking then reposition the tooltip.
  12488. // This makes sure that a tracking tooltip doesn't obscure a focused element
  12489. // if the user was hovering when the element gained focused.
  12490. if ( this.options.track && target.data( "ui-tooltip-id" ) ) {
  12491. this._find( target ).position( $.extend({
  12492. of: target
  12493. }, this.options.position ) );
  12494. // Stop tracking (#8622)
  12495. this._off( this.document, "mousemove" );
  12496. return;
  12497. }
  12498. if ( target.attr( "title" ) ) {
  12499. target.data( "ui-tooltip-title", target.attr( "title" ) );
  12500. }
  12501. target.data( "tooltip-open", true );
  12502. this._updateContent( target, event );
  12503. },
  12504. _updateContent: function( target, event ) {
  12505. var content,
  12506. contentOption = this.options.content,
  12507. that = this;
  12508. if ( typeof contentOption === "string" ) {
  12509. return this._open( event, target, contentOption );
  12510. }
  12511. content = contentOption.call( target[0], function( response ) {
  12512. // ignore async response if tooltip was closed already
  12513. if ( !target.data( "tooltip-open" ) ) {
  12514. return;
  12515. }
  12516. // IE may instantly serve a cached response for ajax requests
  12517. // delay this call to _open so the other call to _open runs first
  12518. that._delay(function() {
  12519. this._open( event, target, response );
  12520. });
  12521. });
  12522. if ( content ) {
  12523. this._open( event, target, content );
  12524. }
  12525. },
  12526. _open: function( event, target, content ) {
  12527. var tooltip, positionOption;
  12528. if ( !content ) {
  12529. return;
  12530. }
  12531. // Content can be updated multiple times. If the tooltip already
  12532. // exists, then just update the content and bail.
  12533. tooltip = this._find( target );
  12534. if ( tooltip.length ) {
  12535. tooltip.find( ".ui-tooltip-content" ).html( content );
  12536. return;
  12537. }
  12538. // if we have a title, clear it to prevent the native tooltip
  12539. // we have to check first to avoid defining a title if none exists
  12540. // (we don't want to cause an element to start matching [title])
  12541. //
  12542. // We use removeAttr only for key events, to allow IE to export the correct
  12543. // accessible attributes. For mouse events, set to empty string to avoid
  12544. // native tooltip showing up (happens only when removing inside mouseover).
  12545. if ( target.is( "[title]" ) ) {
  12546. if ( event && event.type === "mouseover" ) {
  12547. target.attr( "title", "" );
  12548. } else {
  12549. target.removeAttr( "title" );
  12550. }
  12551. }
  12552. tooltip = this._tooltip( target );
  12553. addDescribedBy( target, tooltip.attr( "id" ) );
  12554. tooltip.find( ".ui-tooltip-content" ).html( content );
  12555. function position( event ) {
  12556. positionOption.of = event;
  12557. tooltip.position( positionOption );
  12558. }
  12559. if ( this.options.track && event && /^mouse/.test( event.originalEvent.type ) ) {
  12560. positionOption = $.extend( {}, this.options.position );
  12561. this._on( this.document, {
  12562. mousemove: position
  12563. });
  12564. // trigger once to override element-relative positioning
  12565. position( event );
  12566. } else {
  12567. tooltip.position( $.extend({
  12568. of: target
  12569. }, this.options.position ) );
  12570. }
  12571. tooltip.hide();
  12572. this._show( tooltip, this.options.show );
  12573. this._trigger( "open", event, { tooltip: tooltip } );
  12574. this._on( target, {
  12575. mouseleave: "close",
  12576. focusout: "close",
  12577. keyup: function( event ) {
  12578. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  12579. var fakeEvent = $.Event(event);
  12580. fakeEvent.currentTarget = target[0];
  12581. this.close( fakeEvent, true );
  12582. }
  12583. }
  12584. });
  12585. },
  12586. close: function( event, force ) {
  12587. var that = this,
  12588. target = $( event ? event.currentTarget : this.element ),
  12589. tooltip = this._find( target );
  12590. // disabling closes the tooltip, so we need to track when we're closing
  12591. // to avoid an infinite loop in case the tooltip becomes disabled on close
  12592. if ( this.closing ) {
  12593. return;
  12594. }
  12595. // don't close if the element has focus
  12596. // this prevents the tooltip from closing if you hover while focused
  12597. //
  12598. // we have to check the event type because tabbing out of the document
  12599. // may leave the element as the activeElement
  12600. if ( !force && event && event.type !== "focusout" &&
  12601. this.document[0].activeElement === target[0] ) {
  12602. return;
  12603. }
  12604. // only set title if we had one before (see comment in _open())
  12605. if ( target.data( "ui-tooltip-title" ) ) {
  12606. target.attr( "title", target.data( "ui-tooltip-title" ) );
  12607. }
  12608. removeDescribedBy( target );
  12609. tooltip.stop( true );
  12610. this._hide( tooltip, this.options.hide, function() {
  12611. $( this ).remove();
  12612. delete that.tooltips[ this.id ];
  12613. });
  12614. target.removeData( "tooltip-open" );
  12615. this._off( target, "mouseleave focusout keyup" );
  12616. this._off( this.document, "mousemove" );
  12617. this.closing = true;
  12618. this._trigger( "close", event, { tooltip: tooltip } );
  12619. this.closing = false;
  12620. },
  12621. _tooltip: function( element ) {
  12622. var id = "ui-tooltip-" + increments++,
  12623. tooltip = $( "<div>" )
  12624. .attr({
  12625. id: id,
  12626. role: "tooltip"
  12627. })
  12628. .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
  12629. ( this.options.tooltipClass || "" ) );
  12630. $( "<div>" )
  12631. .addClass( "ui-tooltip-content" )
  12632. .appendTo( tooltip );
  12633. tooltip.appendTo( this.document[0].body );
  12634. if ( $.fn.bgiframe ) {
  12635. tooltip.bgiframe();
  12636. }
  12637. this.tooltips[ id ] = element;
  12638. return tooltip;
  12639. },
  12640. _find: function( target ) {
  12641. var id = target.data( "ui-tooltip-id" );
  12642. return id ? $( "#" + id ) : $();
  12643. },
  12644. _destroy: function() {
  12645. var that = this;
  12646. // close open tooltips
  12647. $.each( this.tooltips, function( id, element ) {
  12648. // Delegate to close method to handle common cleanup
  12649. var event = $.Event( "blur" );
  12650. event.target = event.currentTarget = element[0];
  12651. that.close( event, true );
  12652. // Remove immediately; destroying an open tooltip doesn't use the
  12653. // hide animation
  12654. $( "#" + id ).remove();
  12655. // Restore the title
  12656. if ( element.data( "ui-tooltip-title" ) ) {
  12657. element.attr( "title", element.data( "ui-tooltip-title" ) );
  12658. element.removeData( "ui-tooltip-title" );
  12659. }
  12660. });
  12661. }
  12662. });
  12663. }( jQuery ) );