jquery-ui-1.10.3.js 243 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709
  1. /*! jQuery UI - v1.10.3 - 2013-12-25
  2. * http://jqueryui.com
  3. * Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.position.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.ui.autocomplete.js, jquery.ui.menu.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
  4. * Copyright 2013 jQuery Foundation and other contributors; Licensed MIT */
  5. (function( $, undefined ) {
  6. var uuid = 0,
  7. runiqueId = /^ui-id-\d+$/;
  8. // $.ui might exist from components with no dependencies, e.g., $.ui.position
  9. $.ui = $.ui || {};
  10. $.extend( $.ui, {
  11. version: "1.10.3",
  12. keyCode: {
  13. BACKSPACE: 8,
  14. COMMA: 188,
  15. DELETE: 46,
  16. DOWN: 40,
  17. END: 35,
  18. ENTER: 13,
  19. ESCAPE: 27,
  20. HOME: 36,
  21. LEFT: 37,
  22. NUMPAD_ADD: 107,
  23. NUMPAD_DECIMAL: 110,
  24. NUMPAD_DIVIDE: 111,
  25. NUMPAD_ENTER: 108,
  26. NUMPAD_MULTIPLY: 106,
  27. NUMPAD_SUBTRACT: 109,
  28. PAGE_DOWN: 34,
  29. PAGE_UP: 33,
  30. PERIOD: 190,
  31. RIGHT: 39,
  32. SPACE: 32,
  33. TAB: 9,
  34. UP: 38
  35. }
  36. });
  37. // plugins
  38. $.fn.extend({
  39. focus: (function( orig ) {
  40. return function( delay, fn ) {
  41. return typeof delay === "number" ?
  42. this.each(function() {
  43. var elem = this;
  44. setTimeout(function() {
  45. $( elem ).focus();
  46. if ( fn ) {
  47. fn.call( elem );
  48. }
  49. }, delay );
  50. }) :
  51. orig.apply( this, arguments );
  52. };
  53. })( $.fn.focus ),
  54. scrollParent: function() {
  55. var scrollParent;
  56. if (($.ui.ie && (/(static|relative)/).test(this.css("position"))) || (/absolute/).test(this.css("position"))) {
  57. scrollParent = this.parents().filter(function() {
  58. return (/(relative|absolute|fixed)/).test($.css(this,"position")) && (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
  59. }).eq(0);
  60. } else {
  61. scrollParent = this.parents().filter(function() {
  62. return (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
  63. }).eq(0);
  64. }
  65. return (/fixed/).test(this.css("position")) || !scrollParent.length ? $(document) : scrollParent;
  66. },
  67. zIndex: function( zIndex ) {
  68. if ( zIndex !== undefined ) {
  69. return this.css( "zIndex", zIndex );
  70. }
  71. if ( this.length ) {
  72. var elem = $( this[ 0 ] ), position, value;
  73. while ( elem.length && elem[ 0 ] !== document ) {
  74. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  75. // This makes behavior of this function consistent across browsers
  76. // WebKit always returns auto if the element is positioned
  77. position = elem.css( "position" );
  78. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  79. // IE returns 0 when zIndex is not specified
  80. // other browsers return a string
  81. // we ignore the case of nested elements with an explicit value of 0
  82. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  83. value = parseInt( elem.css( "zIndex" ), 10 );
  84. if ( !isNaN( value ) && value !== 0 ) {
  85. return value;
  86. }
  87. }
  88. elem = elem.parent();
  89. }
  90. }
  91. return 0;
  92. },
  93. uniqueId: function() {
  94. return this.each(function() {
  95. if ( !this.id ) {
  96. this.id = "ui-id-" + (++uuid);
  97. }
  98. });
  99. },
  100. removeUniqueId: function() {
  101. return this.each(function() {
  102. if ( runiqueId.test( this.id ) ) {
  103. $( this ).removeAttr( "id" );
  104. }
  105. });
  106. }
  107. });
  108. // selectors
  109. function focusable( element, isTabIndexNotNaN ) {
  110. var map, mapName, img,
  111. nodeName = element.nodeName.toLowerCase();
  112. if ( "area" === nodeName ) {
  113. map = element.parentNode;
  114. mapName = map.name;
  115. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  116. return false;
  117. }
  118. img = $( "img[usemap=#" + mapName + "]" )[0];
  119. return !!img && visible( img );
  120. }
  121. return ( /input|select|textarea|button|object/.test( nodeName ) ?
  122. !element.disabled :
  123. "a" === nodeName ?
  124. element.href || isTabIndexNotNaN :
  125. isTabIndexNotNaN) &&
  126. // the element and all of its ancestors must be visible
  127. visible( element );
  128. }
  129. function visible( element ) {
  130. return $.expr.filters.visible( element ) &&
  131. !$( element ).parents().addBack().filter(function() {
  132. return $.css( this, "visibility" ) === "hidden";
  133. }).length;
  134. }
  135. $.extend( $.expr[ ":" ], {
  136. data: $.expr.createPseudo ?
  137. $.expr.createPseudo(function( dataName ) {
  138. return function( elem ) {
  139. return !!$.data( elem, dataName );
  140. };
  141. }) :
  142. // support: jQuery <1.8
  143. function( elem, i, match ) {
  144. return !!$.data( elem, match[ 3 ] );
  145. },
  146. focusable: function( element ) {
  147. return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
  148. },
  149. tabbable: function( element ) {
  150. var tabIndex = $.attr( element, "tabindex" ),
  151. isTabIndexNaN = isNaN( tabIndex );
  152. return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
  153. }
  154. });
  155. // support: jQuery <1.8
  156. if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
  157. $.each( [ "Width", "Height" ], function( i, name ) {
  158. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  159. type = name.toLowerCase(),
  160. orig = {
  161. innerWidth: $.fn.innerWidth,
  162. innerHeight: $.fn.innerHeight,
  163. outerWidth: $.fn.outerWidth,
  164. outerHeight: $.fn.outerHeight
  165. };
  166. function reduce( elem, size, border, margin ) {
  167. $.each( side, function() {
  168. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  169. if ( border ) {
  170. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  171. }
  172. if ( margin ) {
  173. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  174. }
  175. });
  176. return size;
  177. }
  178. $.fn[ "inner" + name ] = function( size ) {
  179. if ( size === undefined ) {
  180. return orig[ "inner" + name ].call( this );
  181. }
  182. return this.each(function() {
  183. $( this ).css( type, reduce( this, size ) + "px" );
  184. });
  185. };
  186. $.fn[ "outer" + name] = function( size, margin ) {
  187. if ( typeof size !== "number" ) {
  188. return orig[ "outer" + name ].call( this, size );
  189. }
  190. return this.each(function() {
  191. $( this).css( type, reduce( this, size, true, margin ) + "px" );
  192. });
  193. };
  194. });
  195. }
  196. // support: jQuery <1.8
  197. if ( !$.fn.addBack ) {
  198. $.fn.addBack = function( selector ) {
  199. return this.add( selector == null ?
  200. this.prevObject : this.prevObject.filter( selector )
  201. );
  202. };
  203. }
  204. // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
  205. if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
  206. $.fn.removeData = (function( removeData ) {
  207. return function( key ) {
  208. if ( arguments.length ) {
  209. return removeData.call( this, $.camelCase( key ) );
  210. } else {
  211. return removeData.call( this );
  212. }
  213. };
  214. })( $.fn.removeData );
  215. }
  216. // deprecated
  217. $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  218. $.support.selectstart = "onselectstart" in document.createElement( "div" );
  219. $.fn.extend({
  220. disableSelection: function() {
  221. return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
  222. ".ui-disableSelection", function( event ) {
  223. event.preventDefault();
  224. });
  225. },
  226. enableSelection: function() {
  227. return this.unbind( ".ui-disableSelection" );
  228. }
  229. });
  230. $.extend( $.ui, {
  231. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  232. plugin: {
  233. add: function( module, option, set ) {
  234. var i,
  235. proto = $.ui[ module ].prototype;
  236. for ( i in set ) {
  237. proto.plugins[ i ] = proto.plugins[ i ] || [];
  238. proto.plugins[ i ].push( [ option, set[ i ] ] );
  239. }
  240. },
  241. call: function( instance, name, args ) {
  242. var i,
  243. set = instance.plugins[ name ];
  244. if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
  245. return;
  246. }
  247. for ( i = 0; i < set.length; i++ ) {
  248. if ( instance.options[ set[ i ][ 0 ] ] ) {
  249. set[ i ][ 1 ].apply( instance.element, args );
  250. }
  251. }
  252. }
  253. },
  254. // only used by resizable
  255. hasScroll: function( el, a ) {
  256. //If overflow is hidden, the element might have extra content, but the user wants to hide it
  257. if ( $( el ).css( "overflow" ) === "hidden") {
  258. return false;
  259. }
  260. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  261. has = false;
  262. if ( el[ scroll ] > 0 ) {
  263. return true;
  264. }
  265. // TODO: determine which cases actually cause this to happen
  266. // if the element doesn't have the scroll set, see if it's possible to
  267. // set the scroll
  268. el[ scroll ] = 1;
  269. has = ( el[ scroll ] > 0 );
  270. el[ scroll ] = 0;
  271. return has;
  272. }
  273. });
  274. })( jQuery );
  275. (function( $, undefined ) {
  276. var uuid = 0,
  277. slice = Array.prototype.slice,
  278. _cleanData = $.cleanData;
  279. $.cleanData = function( elems ) {
  280. for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
  281. try {
  282. $( elem ).triggerHandler( "remove" );
  283. // http://bugs.jquery.com/ticket/8235
  284. } catch( e ) {}
  285. }
  286. _cleanData( elems );
  287. };
  288. $.widget = function( name, base, prototype ) {
  289. var fullName, existingConstructor, constructor, basePrototype,
  290. // proxiedPrototype allows the provided prototype to remain unmodified
  291. // so that it can be used as a mixin for multiple widgets (#8876)
  292. proxiedPrototype = {},
  293. namespace = name.split( "." )[ 0 ];
  294. name = name.split( "." )[ 1 ];
  295. fullName = namespace + "-" + name;
  296. if ( !prototype ) {
  297. prototype = base;
  298. base = $.Widget;
  299. }
  300. // create selector for plugin
  301. $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
  302. return !!$.data( elem, fullName );
  303. };
  304. $[ namespace ] = $[ namespace ] || {};
  305. existingConstructor = $[ namespace ][ name ];
  306. constructor = $[ namespace ][ name ] = function( options, element ) {
  307. // allow instantiation without "new" keyword
  308. if ( !this._createWidget ) {
  309. return new constructor( options, element );
  310. }
  311. // allow instantiation without initializing for simple inheritance
  312. // must use "new" keyword (the code above always passes args)
  313. if ( arguments.length ) {
  314. this._createWidget( options, element );
  315. }
  316. };
  317. // extend with the existing constructor to carry over any static properties
  318. $.extend( constructor, existingConstructor, {
  319. version: prototype.version,
  320. // copy the object used to create the prototype in case we need to
  321. // redefine the widget later
  322. _proto: $.extend( {}, prototype ),
  323. // track widgets that inherit from this widget in case this widget is
  324. // redefined after a widget inherits from it
  325. _childConstructors: []
  326. });
  327. basePrototype = new base();
  328. // we need to make the options hash a property directly on the new instance
  329. // otherwise we'll modify the options hash on the prototype that we're
  330. // inheriting from
  331. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  332. $.each( prototype, function( prop, value ) {
  333. if ( !$.isFunction( value ) ) {
  334. proxiedPrototype[ prop ] = value;
  335. return;
  336. }
  337. proxiedPrototype[ prop ] = (function() {
  338. var _super = function() {
  339. return base.prototype[ prop ].apply( this, arguments );
  340. },
  341. _superApply = function( args ) {
  342. return base.prototype[ prop ].apply( this, args );
  343. };
  344. return function() {
  345. var __super = this._super,
  346. __superApply = this._superApply,
  347. returnValue;
  348. this._super = _super;
  349. this._superApply = _superApply;
  350. returnValue = value.apply( this, arguments );
  351. this._super = __super;
  352. this._superApply = __superApply;
  353. return returnValue;
  354. };
  355. })();
  356. });
  357. constructor.prototype = $.widget.extend( basePrototype, {
  358. // TODO: remove support for widgetEventPrefix
  359. // always use the name + a colon as the prefix, e.g., draggable:start
  360. // don't prefix for widgets that aren't DOM-based
  361. widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name
  362. }, proxiedPrototype, {
  363. constructor: constructor,
  364. namespace: namespace,
  365. widgetName: name,
  366. widgetFullName: fullName
  367. });
  368. // If this widget is being redefined then we need to find all widgets that
  369. // are inheriting from it and redefine all of them so that they inherit from
  370. // the new version of this widget. We're essentially trying to replace one
  371. // level in the prototype chain.
  372. if ( existingConstructor ) {
  373. $.each( existingConstructor._childConstructors, function( i, child ) {
  374. var childPrototype = child.prototype;
  375. // redefine the child widget using the same prototype that was
  376. // originally used, but inherit from the new version of the base
  377. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
  378. });
  379. // remove the list of existing child constructors from the old constructor
  380. // so the old child constructors can be garbage collected
  381. delete existingConstructor._childConstructors;
  382. } else {
  383. base._childConstructors.push( constructor );
  384. }
  385. $.widget.bridge( name, constructor );
  386. };
  387. $.widget.extend = function( target ) {
  388. var input = slice.call( arguments, 1 ),
  389. inputIndex = 0,
  390. inputLength = input.length,
  391. key,
  392. value;
  393. for ( ; inputIndex < inputLength; inputIndex++ ) {
  394. for ( key in input[ inputIndex ] ) {
  395. value = input[ inputIndex ][ key ];
  396. if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
  397. // Clone objects
  398. if ( $.isPlainObject( value ) ) {
  399. target[ key ] = $.isPlainObject( target[ key ] ) ?
  400. $.widget.extend( {}, target[ key ], value ) :
  401. // Don't extend strings, arrays, etc. with objects
  402. $.widget.extend( {}, value );
  403. // Copy everything else by reference
  404. } else {
  405. target[ key ] = value;
  406. }
  407. }
  408. }
  409. }
  410. return target;
  411. };
  412. $.widget.bridge = function( name, object ) {
  413. var fullName = object.prototype.widgetFullName || name;
  414. $.fn[ name ] = function( options ) {
  415. var isMethodCall = typeof options === "string",
  416. args = slice.call( arguments, 1 ),
  417. returnValue = this;
  418. // allow multiple hashes to be passed on init
  419. options = !isMethodCall && args.length ?
  420. $.widget.extend.apply( null, [ options ].concat(args) ) :
  421. options;
  422. if ( isMethodCall ) {
  423. this.each(function() {
  424. var methodValue,
  425. instance = $.data( this, fullName );
  426. if ( !instance ) {
  427. return $.error( "cannot call methods on " + name + " prior to initialization; " +
  428. "attempted to call method '" + options + "'" );
  429. }
  430. if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
  431. return $.error( "no such method '" + options + "' for " + name + " widget instance" );
  432. }
  433. methodValue = instance[ options ].apply( instance, args );
  434. if ( methodValue !== instance && methodValue !== undefined ) {
  435. returnValue = methodValue && methodValue.jquery ?
  436. returnValue.pushStack( methodValue.get() ) :
  437. methodValue;
  438. return false;
  439. }
  440. });
  441. } else {
  442. this.each(function() {
  443. var instance = $.data( this, fullName );
  444. if ( instance ) {
  445. instance.option( options || {} )._init();
  446. } else {
  447. $.data( this, fullName, new object( options, this ) );
  448. }
  449. });
  450. }
  451. return returnValue;
  452. };
  453. };
  454. $.Widget = function( /* options, element */ ) {};
  455. $.Widget._childConstructors = [];
  456. $.Widget.prototype = {
  457. widgetName: "widget",
  458. widgetEventPrefix: "",
  459. defaultElement: "<div>",
  460. options: {
  461. disabled: false,
  462. // callbacks
  463. create: null
  464. },
  465. _createWidget: function( options, element ) {
  466. element = $( element || this.defaultElement || this )[ 0 ];
  467. this.element = $( element );
  468. this.uuid = uuid++;
  469. this.eventNamespace = "." + this.widgetName + this.uuid;
  470. this.options = $.widget.extend( {},
  471. this.options,
  472. this._getCreateOptions(),
  473. options );
  474. this.bindings = $();
  475. this.hoverable = $();
  476. this.focusable = $();
  477. if ( element !== this ) {
  478. $.data( element, this.widgetFullName, this );
  479. this._on( true, this.element, {
  480. remove: function( event ) {
  481. if ( event.target === element ) {
  482. this.destroy();
  483. }
  484. }
  485. });
  486. this.document = $( element.style ?
  487. // element within the document
  488. element.ownerDocument :
  489. // element is window or document
  490. element.document || element );
  491. this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
  492. }
  493. this._create();
  494. this._trigger( "create", null, this._getCreateEventData() );
  495. this._init();
  496. },
  497. _getCreateOptions: $.noop,
  498. _getCreateEventData: $.noop,
  499. _create: $.noop,
  500. _init: $.noop,
  501. destroy: function() {
  502. this._destroy();
  503. // we can probably remove the unbind calls in 2.0
  504. // all event bindings should go through this._on()
  505. this.element
  506. .unbind( this.eventNamespace )
  507. // 1.9 BC for #7810
  508. // TODO remove dual storage
  509. .removeData( this.widgetName )
  510. .removeData( this.widgetFullName )
  511. // support: jquery <1.6.3
  512. // http://bugs.jquery.com/ticket/9413
  513. .removeData( $.camelCase( this.widgetFullName ) );
  514. this.widget()
  515. .unbind( this.eventNamespace )
  516. .removeAttr( "aria-disabled" )
  517. .removeClass(
  518. this.widgetFullName + "-disabled " +
  519. "ui-state-disabled" );
  520. // clean up events and states
  521. this.bindings.unbind( this.eventNamespace );
  522. this.hoverable.removeClass( "ui-state-hover" );
  523. this.focusable.removeClass( "ui-state-focus" );
  524. },
  525. _destroy: $.noop,
  526. widget: function() {
  527. return this.element;
  528. },
  529. option: function( key, value ) {
  530. var options = key,
  531. parts,
  532. curOption,
  533. i;
  534. if ( arguments.length === 0 ) {
  535. // don't return a reference to the internal hash
  536. return $.widget.extend( {}, this.options );
  537. }
  538. if ( typeof key === "string" ) {
  539. // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  540. options = {};
  541. parts = key.split( "." );
  542. key = parts.shift();
  543. if ( parts.length ) {
  544. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  545. for ( i = 0; i < parts.length - 1; i++ ) {
  546. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  547. curOption = curOption[ parts[ i ] ];
  548. }
  549. key = parts.pop();
  550. if ( value === undefined ) {
  551. return curOption[ key ] === undefined ? null : curOption[ key ];
  552. }
  553. curOption[ key ] = value;
  554. } else {
  555. if ( value === undefined ) {
  556. return this.options[ key ] === undefined ? null : this.options[ key ];
  557. }
  558. options[ key ] = value;
  559. }
  560. }
  561. this._setOptions( options );
  562. return this;
  563. },
  564. _setOptions: function( options ) {
  565. var key;
  566. for ( key in options ) {
  567. this._setOption( key, options[ key ] );
  568. }
  569. return this;
  570. },
  571. _setOption: function( key, value ) {
  572. this.options[ key ] = value;
  573. if ( key === "disabled" ) {
  574. this.widget()
  575. .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value )
  576. .attr( "aria-disabled", value );
  577. this.hoverable.removeClass( "ui-state-hover" );
  578. this.focusable.removeClass( "ui-state-focus" );
  579. }
  580. return this;
  581. },
  582. enable: function() {
  583. return this._setOption( "disabled", false );
  584. },
  585. disable: function() {
  586. return this._setOption( "disabled", true );
  587. },
  588. _on: function( suppressDisabledCheck, element, handlers ) {
  589. var delegateElement,
  590. instance = this;
  591. // no suppressDisabledCheck flag, shuffle arguments
  592. if ( typeof suppressDisabledCheck !== "boolean" ) {
  593. handlers = element;
  594. element = suppressDisabledCheck;
  595. suppressDisabledCheck = false;
  596. }
  597. // no element argument, shuffle and use this.element
  598. if ( !handlers ) {
  599. handlers = element;
  600. element = this.element;
  601. delegateElement = this.widget();
  602. } else {
  603. // accept selectors, DOM elements
  604. element = delegateElement = $( element );
  605. this.bindings = this.bindings.add( element );
  606. }
  607. $.each( handlers, function( event, handler ) {
  608. function handlerProxy() {
  609. // allow widgets to customize the disabled handling
  610. // - disabled as an array instead of boolean
  611. // - disabled class as method for disabling individual parts
  612. if ( !suppressDisabledCheck &&
  613. ( instance.options.disabled === true ||
  614. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  615. return;
  616. }
  617. return ( typeof handler === "string" ? instance[ handler ] : handler )
  618. .apply( instance, arguments );
  619. }
  620. // copy the guid so direct unbinding works
  621. if ( typeof handler !== "string" ) {
  622. handlerProxy.guid = handler.guid =
  623. handler.guid || handlerProxy.guid || $.guid++;
  624. }
  625. var match = event.match( /^(\w+)\s*(.*)$/ ),
  626. eventName = match[1] + instance.eventNamespace,
  627. selector = match[2];
  628. if ( selector ) {
  629. delegateElement.delegate( selector, eventName, handlerProxy );
  630. } else {
  631. element.bind( eventName, handlerProxy );
  632. }
  633. });
  634. },
  635. _off: function( element, eventName ) {
  636. eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
  637. element.unbind( eventName ).undelegate( eventName );
  638. },
  639. _delay: function( handler, delay ) {
  640. function handlerProxy() {
  641. return ( typeof handler === "string" ? instance[ handler ] : handler )
  642. .apply( instance, arguments );
  643. }
  644. var instance = this;
  645. return setTimeout( handlerProxy, delay || 0 );
  646. },
  647. _hoverable: function( element ) {
  648. this.hoverable = this.hoverable.add( element );
  649. this._on( element, {
  650. mouseenter: function( event ) {
  651. $( event.currentTarget ).addClass( "ui-state-hover" );
  652. },
  653. mouseleave: function( event ) {
  654. $( event.currentTarget ).removeClass( "ui-state-hover" );
  655. }
  656. });
  657. },
  658. _focusable: function( element ) {
  659. this.focusable = this.focusable.add( element );
  660. this._on( element, {
  661. focusin: function( event ) {
  662. $( event.currentTarget ).addClass( "ui-state-focus" );
  663. },
  664. focusout: function( event ) {
  665. $( event.currentTarget ).removeClass( "ui-state-focus" );
  666. }
  667. });
  668. },
  669. _trigger: function( type, event, data ) {
  670. var prop, orig,
  671. callback = this.options[ type ];
  672. data = data || {};
  673. event = $.Event( event );
  674. event.type = ( type === this.widgetEventPrefix ?
  675. type :
  676. this.widgetEventPrefix + type ).toLowerCase();
  677. // the original event may come from any element
  678. // so we need to reset the target on the new event
  679. event.target = this.element[ 0 ];
  680. // copy original event properties over to the new event
  681. orig = event.originalEvent;
  682. if ( orig ) {
  683. for ( prop in orig ) {
  684. if ( !( prop in event ) ) {
  685. event[ prop ] = orig[ prop ];
  686. }
  687. }
  688. }
  689. this.element.trigger( event, data );
  690. return !( $.isFunction( callback ) &&
  691. callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
  692. event.isDefaultPrevented() );
  693. }
  694. };
  695. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  696. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  697. if ( typeof options === "string" ) {
  698. options = { effect: options };
  699. }
  700. var hasOptions,
  701. effectName = !options ?
  702. method :
  703. options === true || typeof options === "number" ?
  704. defaultEffect :
  705. options.effect || defaultEffect;
  706. options = options || {};
  707. if ( typeof options === "number" ) {
  708. options = { duration: options };
  709. }
  710. hasOptions = !$.isEmptyObject( options );
  711. options.complete = callback;
  712. if ( options.delay ) {
  713. element.delay( options.delay );
  714. }
  715. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  716. element[ method ]( options );
  717. } else if ( effectName !== method && element[ effectName ] ) {
  718. element[ effectName ]( options.duration, options.easing, callback );
  719. } else {
  720. element.queue(function( next ) {
  721. $( this )[ method ]();
  722. if ( callback ) {
  723. callback.call( element[ 0 ] );
  724. }
  725. next();
  726. });
  727. }
  728. };
  729. });
  730. })( jQuery );
  731. (function( $, undefined ) {
  732. var mouseHandled = false;
  733. $( document ).mouseup( function() {
  734. mouseHandled = false;
  735. });
  736. $.widget("ui.mouse", {
  737. version: "1.10.3",
  738. options: {
  739. cancel: "input,textarea,button,select,option",
  740. distance: 1,
  741. delay: 0
  742. },
  743. _mouseInit: function() {
  744. var that = this;
  745. this.element
  746. .bind("mousedown."+this.widgetName, function(event) {
  747. return that._mouseDown(event);
  748. })
  749. .bind("click."+this.widgetName, function(event) {
  750. if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
  751. $.removeData(event.target, that.widgetName + ".preventClickEvent");
  752. event.stopImmediatePropagation();
  753. return false;
  754. }
  755. });
  756. this.started = false;
  757. },
  758. // TODO: make sure destroying one instance of mouse doesn't mess with
  759. // other instances of mouse
  760. _mouseDestroy: function() {
  761. this.element.unbind("."+this.widgetName);
  762. if ( this._mouseMoveDelegate ) {
  763. $(document)
  764. .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
  765. .unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
  766. }
  767. },
  768. _mouseDown: function(event) {
  769. // don't let more than one widget handle mouseStart
  770. if( mouseHandled ) { return; }
  771. // we may have missed mouseup (out of window)
  772. (this._mouseStarted && this._mouseUp(event));
  773. this._mouseDownEvent = event;
  774. var that = this,
  775. btnIsLeft = (event.which === 1),
  776. // event.target.nodeName works around a bug in IE 8 with
  777. // disabled inputs (#7620)
  778. elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
  779. if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
  780. return true;
  781. }
  782. this.mouseDelayMet = !this.options.delay;
  783. if (!this.mouseDelayMet) {
  784. this._mouseDelayTimer = setTimeout(function() {
  785. that.mouseDelayMet = true;
  786. }, this.options.delay);
  787. }
  788. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  789. this._mouseStarted = (this._mouseStart(event) !== false);
  790. if (!this._mouseStarted) {
  791. event.preventDefault();
  792. return true;
  793. }
  794. }
  795. // Click event may never have fired (Gecko & Opera)
  796. if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
  797. $.removeData(event.target, this.widgetName + ".preventClickEvent");
  798. }
  799. // these delegates are required to keep context
  800. this._mouseMoveDelegate = function(event) {
  801. return that._mouseMove(event);
  802. };
  803. this._mouseUpDelegate = function(event) {
  804. return that._mouseUp(event);
  805. };
  806. $(document)
  807. .bind("mousemove."+this.widgetName, this._mouseMoveDelegate)
  808. .bind("mouseup."+this.widgetName, this._mouseUpDelegate);
  809. event.preventDefault();
  810. mouseHandled = true;
  811. return true;
  812. },
  813. _mouseMove: function(event) {
  814. // IE mouseup check - mouseup happened when mouse was out of window
  815. if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
  816. return this._mouseUp(event);
  817. }
  818. if (this._mouseStarted) {
  819. this._mouseDrag(event);
  820. return event.preventDefault();
  821. }
  822. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  823. this._mouseStarted =
  824. (this._mouseStart(this._mouseDownEvent, event) !== false);
  825. (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
  826. }
  827. return !this._mouseStarted;
  828. },
  829. _mouseUp: function(event) {
  830. $(document)
  831. .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
  832. .unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
  833. if (this._mouseStarted) {
  834. this._mouseStarted = false;
  835. if (event.target === this._mouseDownEvent.target) {
  836. $.data(event.target, this.widgetName + ".preventClickEvent", true);
  837. }
  838. this._mouseStop(event);
  839. }
  840. return false;
  841. },
  842. _mouseDistanceMet: function(event) {
  843. return (Math.max(
  844. Math.abs(this._mouseDownEvent.pageX - event.pageX),
  845. Math.abs(this._mouseDownEvent.pageY - event.pageY)
  846. ) >= this.options.distance
  847. );
  848. },
  849. _mouseDelayMet: function(/* event */) {
  850. return this.mouseDelayMet;
  851. },
  852. // These are placeholder methods, to be overriden by extending plugin
  853. _mouseStart: function(/* event */) {},
  854. _mouseDrag: function(/* event */) {},
  855. _mouseStop: function(/* event */) {},
  856. _mouseCapture: function(/* event */) { return true; }
  857. });
  858. })(jQuery);
  859. (function( $, undefined ) {
  860. $.ui = $.ui || {};
  861. var cachedScrollbarWidth,
  862. max = Math.max,
  863. abs = Math.abs,
  864. round = Math.round,
  865. rhorizontal = /left|center|right/,
  866. rvertical = /top|center|bottom/,
  867. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  868. rposition = /^\w+/,
  869. rpercent = /%$/,
  870. _position = $.fn.position;
  871. function getOffsets( offsets, width, height ) {
  872. return [
  873. parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  874. parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  875. ];
  876. }
  877. function parseCss( element, property ) {
  878. return parseInt( $.css( element, property ), 10 ) || 0;
  879. }
  880. function getDimensions( elem ) {
  881. var raw = elem[0];
  882. if ( raw.nodeType === 9 ) {
  883. return {
  884. width: elem.width(),
  885. height: elem.height(),
  886. offset: { top: 0, left: 0 }
  887. };
  888. }
  889. if ( $.isWindow( raw ) ) {
  890. return {
  891. width: elem.width(),
  892. height: elem.height(),
  893. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  894. };
  895. }
  896. if ( raw.preventDefault ) {
  897. return {
  898. width: 0,
  899. height: 0,
  900. offset: { top: raw.pageY, left: raw.pageX }
  901. };
  902. }
  903. return {
  904. width: elem.outerWidth(),
  905. height: elem.outerHeight(),
  906. offset: elem.offset()
  907. };
  908. }
  909. $.position = {
  910. scrollbarWidth: function() {
  911. if ( cachedScrollbarWidth !== undefined ) {
  912. return cachedScrollbarWidth;
  913. }
  914. var w1, w2,
  915. div = $( "<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
  916. innerDiv = div.children()[0];
  917. $( "body" ).append( div );
  918. w1 = innerDiv.offsetWidth;
  919. div.css( "overflow", "scroll" );
  920. w2 = innerDiv.offsetWidth;
  921. if ( w1 === w2 ) {
  922. w2 = div[0].clientWidth;
  923. }
  924. div.remove();
  925. return (cachedScrollbarWidth = w1 - w2);
  926. },
  927. getScrollInfo: function( within ) {
  928. var overflowX = within.isWindow ? "" : within.element.css( "overflow-x" ),
  929. overflowY = within.isWindow ? "" : within.element.css( "overflow-y" ),
  930. hasOverflowX = overflowX === "scroll" ||
  931. ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
  932. hasOverflowY = overflowY === "scroll" ||
  933. ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
  934. return {
  935. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  936. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  937. };
  938. },
  939. getWithinInfo: function( element ) {
  940. var withinElement = $( element || window ),
  941. isWindow = $.isWindow( withinElement[0] );
  942. return {
  943. element: withinElement,
  944. isWindow: isWindow,
  945. offset: withinElement.offset() || { left: 0, top: 0 },
  946. scrollLeft: withinElement.scrollLeft(),
  947. scrollTop: withinElement.scrollTop(),
  948. width: isWindow ? withinElement.width() : withinElement.outerWidth(),
  949. height: isWindow ? withinElement.height() : withinElement.outerHeight()
  950. };
  951. }
  952. };
  953. $.fn.position = function( options ) {
  954. if ( !options || !options.of ) {
  955. return _position.apply( this, arguments );
  956. }
  957. // make a copy, we don't want to modify arguments
  958. options = $.extend( {}, options );
  959. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  960. target = $( options.of ),
  961. within = $.position.getWithinInfo( options.within ),
  962. scrollInfo = $.position.getScrollInfo( within ),
  963. collision = ( options.collision || "flip" ).split( " " ),
  964. offsets = {};
  965. dimensions = getDimensions( target );
  966. if ( target[0].preventDefault ) {
  967. // force left top to allow flipping
  968. options.at = "left top";
  969. }
  970. targetWidth = dimensions.width;
  971. targetHeight = dimensions.height;
  972. targetOffset = dimensions.offset;
  973. // clone to reuse original targetOffset later
  974. basePosition = $.extend( {}, targetOffset );
  975. // force my and at to have valid horizontal and vertical positions
  976. // if a value is missing or invalid, it will be converted to center
  977. $.each( [ "my", "at" ], function() {
  978. var pos = ( options[ this ] || "" ).split( " " ),
  979. horizontalOffset,
  980. verticalOffset;
  981. if ( pos.length === 1) {
  982. pos = rhorizontal.test( pos[ 0 ] ) ?
  983. pos.concat( [ "center" ] ) :
  984. rvertical.test( pos[ 0 ] ) ?
  985. [ "center" ].concat( pos ) :
  986. [ "center", "center" ];
  987. }
  988. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  989. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  990. // calculate offsets
  991. horizontalOffset = roffset.exec( pos[ 0 ] );
  992. verticalOffset = roffset.exec( pos[ 1 ] );
  993. offsets[ this ] = [
  994. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  995. verticalOffset ? verticalOffset[ 0 ] : 0
  996. ];
  997. // reduce to just the positions without the offsets
  998. options[ this ] = [
  999. rposition.exec( pos[ 0 ] )[ 0 ],
  1000. rposition.exec( pos[ 1 ] )[ 0 ]
  1001. ];
  1002. });
  1003. // normalize collision option
  1004. if ( collision.length === 1 ) {
  1005. collision[ 1 ] = collision[ 0 ];
  1006. }
  1007. if ( options.at[ 0 ] === "right" ) {
  1008. basePosition.left += targetWidth;
  1009. } else if ( options.at[ 0 ] === "center" ) {
  1010. basePosition.left += targetWidth / 2;
  1011. }
  1012. if ( options.at[ 1 ] === "bottom" ) {
  1013. basePosition.top += targetHeight;
  1014. } else if ( options.at[ 1 ] === "center" ) {
  1015. basePosition.top += targetHeight / 2;
  1016. }
  1017. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  1018. basePosition.left += atOffset[ 0 ];
  1019. basePosition.top += atOffset[ 1 ];
  1020. return this.each(function() {
  1021. var collisionPosition, using,
  1022. elem = $( this ),
  1023. elemWidth = elem.outerWidth(),
  1024. elemHeight = elem.outerHeight(),
  1025. marginLeft = parseCss( this, "marginLeft" ),
  1026. marginTop = parseCss( this, "marginTop" ),
  1027. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
  1028. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
  1029. position = $.extend( {}, basePosition ),
  1030. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  1031. if ( options.my[ 0 ] === "right" ) {
  1032. position.left -= elemWidth;
  1033. } else if ( options.my[ 0 ] === "center" ) {
  1034. position.left -= elemWidth / 2;
  1035. }
  1036. if ( options.my[ 1 ] === "bottom" ) {
  1037. position.top -= elemHeight;
  1038. } else if ( options.my[ 1 ] === "center" ) {
  1039. position.top -= elemHeight / 2;
  1040. }
  1041. position.left += myOffset[ 0 ];
  1042. position.top += myOffset[ 1 ];
  1043. // if the browser doesn't support fractions, then round for consistent results
  1044. if ( !$.support.offsetFractions ) {
  1045. position.left = round( position.left );
  1046. position.top = round( position.top );
  1047. }
  1048. collisionPosition = {
  1049. marginLeft: marginLeft,
  1050. marginTop: marginTop
  1051. };
  1052. $.each( [ "left", "top" ], function( i, dir ) {
  1053. if ( $.ui.position[ collision[ i ] ] ) {
  1054. $.ui.position[ collision[ i ] ][ dir ]( position, {
  1055. targetWidth: targetWidth,
  1056. targetHeight: targetHeight,
  1057. elemWidth: elemWidth,
  1058. elemHeight: elemHeight,
  1059. collisionPosition: collisionPosition,
  1060. collisionWidth: collisionWidth,
  1061. collisionHeight: collisionHeight,
  1062. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  1063. my: options.my,
  1064. at: options.at,
  1065. within: within,
  1066. elem : elem
  1067. });
  1068. }
  1069. });
  1070. if ( options.using ) {
  1071. // adds feedback as second argument to using callback, if present
  1072. using = function( props ) {
  1073. var left = targetOffset.left - position.left,
  1074. right = left + targetWidth - elemWidth,
  1075. top = targetOffset.top - position.top,
  1076. bottom = top + targetHeight - elemHeight,
  1077. feedback = {
  1078. target: {
  1079. element: target,
  1080. left: targetOffset.left,
  1081. top: targetOffset.top,
  1082. width: targetWidth,
  1083. height: targetHeight
  1084. },
  1085. element: {
  1086. element: elem,
  1087. left: position.left,
  1088. top: position.top,
  1089. width: elemWidth,
  1090. height: elemHeight
  1091. },
  1092. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  1093. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  1094. };
  1095. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  1096. feedback.horizontal = "center";
  1097. }
  1098. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  1099. feedback.vertical = "middle";
  1100. }
  1101. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  1102. feedback.important = "horizontal";
  1103. } else {
  1104. feedback.important = "vertical";
  1105. }
  1106. options.using.call( this, props, feedback );
  1107. };
  1108. }
  1109. elem.offset( $.extend( position, { using: using } ) );
  1110. });
  1111. };
  1112. $.ui.position = {
  1113. fit: {
  1114. left: function( position, data ) {
  1115. var within = data.within,
  1116. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  1117. outerWidth = within.width,
  1118. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1119. overLeft = withinOffset - collisionPosLeft,
  1120. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  1121. newOverRight;
  1122. // element is wider than within
  1123. if ( data.collisionWidth > outerWidth ) {
  1124. // element is initially over the left side of within
  1125. if ( overLeft > 0 && overRight <= 0 ) {
  1126. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
  1127. position.left += overLeft - newOverRight;
  1128. // element is initially over right side of within
  1129. } else if ( overRight > 0 && overLeft <= 0 ) {
  1130. position.left = withinOffset;
  1131. // element is initially over both left and right sides of within
  1132. } else {
  1133. if ( overLeft > overRight ) {
  1134. position.left = withinOffset + outerWidth - data.collisionWidth;
  1135. } else {
  1136. position.left = withinOffset;
  1137. }
  1138. }
  1139. // too far left -> align with left edge
  1140. } else if ( overLeft > 0 ) {
  1141. position.left += overLeft;
  1142. // too far right -> align with right edge
  1143. } else if ( overRight > 0 ) {
  1144. position.left -= overRight;
  1145. // adjust based on position and margin
  1146. } else {
  1147. position.left = max( position.left - collisionPosLeft, position.left );
  1148. }
  1149. },
  1150. top: function( position, data ) {
  1151. var within = data.within,
  1152. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  1153. outerHeight = data.within.height,
  1154. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1155. overTop = withinOffset - collisionPosTop,
  1156. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  1157. newOverBottom;
  1158. // element is taller than within
  1159. if ( data.collisionHeight > outerHeight ) {
  1160. // element is initially over the top of within
  1161. if ( overTop > 0 && overBottom <= 0 ) {
  1162. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
  1163. position.top += overTop - newOverBottom;
  1164. // element is initially over bottom of within
  1165. } else if ( overBottom > 0 && overTop <= 0 ) {
  1166. position.top = withinOffset;
  1167. // element is initially over both top and bottom of within
  1168. } else {
  1169. if ( overTop > overBottom ) {
  1170. position.top = withinOffset + outerHeight - data.collisionHeight;
  1171. } else {
  1172. position.top = withinOffset;
  1173. }
  1174. }
  1175. // too far up -> align with top
  1176. } else if ( overTop > 0 ) {
  1177. position.top += overTop;
  1178. // too far down -> align with bottom edge
  1179. } else if ( overBottom > 0 ) {
  1180. position.top -= overBottom;
  1181. // adjust based on position and margin
  1182. } else {
  1183. position.top = max( position.top - collisionPosTop, position.top );
  1184. }
  1185. }
  1186. },
  1187. flip: {
  1188. left: function( position, data ) {
  1189. var within = data.within,
  1190. withinOffset = within.offset.left + within.scrollLeft,
  1191. outerWidth = within.width,
  1192. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  1193. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1194. overLeft = collisionPosLeft - offsetLeft,
  1195. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  1196. myOffset = data.my[ 0 ] === "left" ?
  1197. -data.elemWidth :
  1198. data.my[ 0 ] === "right" ?
  1199. data.elemWidth :
  1200. 0,
  1201. atOffset = data.at[ 0 ] === "left" ?
  1202. data.targetWidth :
  1203. data.at[ 0 ] === "right" ?
  1204. -data.targetWidth :
  1205. 0,
  1206. offset = -2 * data.offset[ 0 ],
  1207. newOverRight,
  1208. newOverLeft;
  1209. if ( overLeft < 0 ) {
  1210. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
  1211. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  1212. position.left += myOffset + atOffset + offset;
  1213. }
  1214. }
  1215. else if ( overRight > 0 ) {
  1216. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
  1217. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  1218. position.left += myOffset + atOffset + offset;
  1219. }
  1220. }
  1221. },
  1222. top: function( position, data ) {
  1223. var within = data.within,
  1224. withinOffset = within.offset.top + within.scrollTop,
  1225. outerHeight = within.height,
  1226. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  1227. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1228. overTop = collisionPosTop - offsetTop,
  1229. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  1230. top = data.my[ 1 ] === "top",
  1231. myOffset = top ?
  1232. -data.elemHeight :
  1233. data.my[ 1 ] === "bottom" ?
  1234. data.elemHeight :
  1235. 0,
  1236. atOffset = data.at[ 1 ] === "top" ?
  1237. data.targetHeight :
  1238. data.at[ 1 ] === "bottom" ?
  1239. -data.targetHeight :
  1240. 0,
  1241. offset = -2 * data.offset[ 1 ],
  1242. newOverTop,
  1243. newOverBottom;
  1244. if ( overTop < 0 ) {
  1245. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
  1246. if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
  1247. position.top += myOffset + atOffset + offset;
  1248. }
  1249. }
  1250. else if ( overBottom > 0 ) {
  1251. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
  1252. if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
  1253. position.top += myOffset + atOffset + offset;
  1254. }
  1255. }
  1256. }
  1257. },
  1258. flipfit: {
  1259. left: function() {
  1260. $.ui.position.flip.left.apply( this, arguments );
  1261. $.ui.position.fit.left.apply( this, arguments );
  1262. },
  1263. top: function() {
  1264. $.ui.position.flip.top.apply( this, arguments );
  1265. $.ui.position.fit.top.apply( this, arguments );
  1266. }
  1267. }
  1268. };
  1269. // fraction support test
  1270. (function () {
  1271. var testElement, testElementParent, testElementStyle, offsetLeft, i,
  1272. body = document.getElementsByTagName( "body" )[ 0 ],
  1273. div = document.createElement( "div" );
  1274. //Create a "fake body" for testing based on method used in jQuery.support
  1275. testElement = document.createElement( body ? "div" : "body" );
  1276. testElementStyle = {
  1277. visibility: "hidden",
  1278. width: 0,
  1279. height: 0,
  1280. border: 0,
  1281. margin: 0,
  1282. background: "none"
  1283. };
  1284. if ( body ) {
  1285. $.extend( testElementStyle, {
  1286. position: "absolute",
  1287. left: "-1000px",
  1288. top: "-1000px"
  1289. });
  1290. }
  1291. for ( i in testElementStyle ) {
  1292. testElement.style[ i ] = testElementStyle[ i ];
  1293. }
  1294. testElement.appendChild( div );
  1295. testElementParent = body || document.documentElement;
  1296. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  1297. div.style.cssText = "position: absolute; left: 10.7432222px;";
  1298. offsetLeft = $( div ).offset().left;
  1299. $.support.offsetFractions = offsetLeft > 10 && offsetLeft < 11;
  1300. testElement.innerHTML = "";
  1301. testElementParent.removeChild( testElement );
  1302. })();
  1303. }( jQuery ) );
  1304. (function( $, undefined ) {
  1305. $.widget("ui.draggable", $.ui.mouse, {
  1306. version: "1.10.3",
  1307. widgetEventPrefix: "drag",
  1308. options: {
  1309. addClasses: true,
  1310. appendTo: "parent",
  1311. axis: false,
  1312. connectToSortable: false,
  1313. containment: false,
  1314. cursor: "auto",
  1315. cursorAt: false,
  1316. grid: false,
  1317. handle: false,
  1318. helper: "original",
  1319. iframeFix: false,
  1320. opacity: false,
  1321. refreshPositions: false,
  1322. revert: false,
  1323. revertDuration: 500,
  1324. scope: "default",
  1325. scroll: true,
  1326. scrollSensitivity: 20,
  1327. scrollSpeed: 20,
  1328. snap: false,
  1329. snapMode: "both",
  1330. snapTolerance: 20,
  1331. stack: false,
  1332. zIndex: false,
  1333. // callbacks
  1334. drag: null,
  1335. start: null,
  1336. stop: null
  1337. },
  1338. _create: function() {
  1339. if (this.options.helper === "original" && !(/^(?:r|a|f)/).test(this.element.css("position"))) {
  1340. this.element[0].style.position = "relative";
  1341. }
  1342. if (this.options.addClasses){
  1343. this.element.addClass("ui-draggable");
  1344. }
  1345. if (this.options.disabled){
  1346. this.element.addClass("ui-draggable-disabled");
  1347. }
  1348. this._mouseInit();
  1349. },
  1350. _destroy: function() {
  1351. this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
  1352. this._mouseDestroy();
  1353. },
  1354. _mouseCapture: function(event) {
  1355. var o = this.options;
  1356. // among others, prevent a drag on a resizable-handle
  1357. if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
  1358. return false;
  1359. }
  1360. //Quit if we're not on a valid handle
  1361. this.handle = this._getHandle(event);
  1362. if (!this.handle) {
  1363. return false;
  1364. }
  1365. $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
  1366. $("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>")
  1367. .css({
  1368. width: this.offsetWidth+"px", height: this.offsetHeight+"px",
  1369. position: "absolute", opacity: "0.001", zIndex: 1000
  1370. })
  1371. .css($(this).offset())
  1372. .appendTo("body");
  1373. });
  1374. return true;
  1375. },
  1376. _mouseStart: function(event) {
  1377. var o = this.options;
  1378. //Create and append the visible helper
  1379. this.helper = this._createHelper(event);
  1380. this.helper.addClass("ui-draggable-dragging");
  1381. //Cache the helper size
  1382. this._cacheHelperProportions();
  1383. //If ddmanager is used for droppables, set the global draggable
  1384. if($.ui.ddmanager) {
  1385. $.ui.ddmanager.current = this;
  1386. }
  1387. /*
  1388. * - Position generation -
  1389. * This block generates everything position related - it's the core of draggables.
  1390. */
  1391. //Cache the margins of the original element
  1392. this._cacheMargins();
  1393. //Store the helper's css position
  1394. this.cssPosition = this.helper.css( "position" );
  1395. this.scrollParent = this.helper.scrollParent();
  1396. this.offsetParent = this.helper.offsetParent();
  1397. this.offsetParentCssPosition = this.offsetParent.css( "position" );
  1398. //The element's absolute position on the page minus margins
  1399. this.offset = this.positionAbs = this.element.offset();
  1400. this.offset = {
  1401. top: this.offset.top - this.margins.top,
  1402. left: this.offset.left - this.margins.left
  1403. };
  1404. //Reset scroll cache
  1405. this.offset.scroll = false;
  1406. $.extend(this.offset, {
  1407. click: { //Where the click happened, relative to the element
  1408. left: event.pageX - this.offset.left,
  1409. top: event.pageY - this.offset.top
  1410. },
  1411. parent: this._getParentOffset(),
  1412. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  1413. });
  1414. //Generate the original position
  1415. this.originalPosition = this.position = this._generatePosition(event);
  1416. this.originalPageX = event.pageX;
  1417. this.originalPageY = event.pageY;
  1418. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  1419. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  1420. //Set a containment if given in the options
  1421. this._setContainment();
  1422. //Trigger event + callbacks
  1423. if(this._trigger("start", event) === false) {
  1424. this._clear();
  1425. return false;
  1426. }
  1427. //Recache the helper size
  1428. this._cacheHelperProportions();
  1429. //Prepare the droppable offsets
  1430. if ($.ui.ddmanager && !o.dropBehaviour) {
  1431. $.ui.ddmanager.prepareOffsets(this, event);
  1432. }
  1433. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  1434. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  1435. if ( $.ui.ddmanager ) {
  1436. $.ui.ddmanager.dragStart(this, event);
  1437. }
  1438. return true;
  1439. },
  1440. _mouseDrag: function(event, noPropagation) {
  1441. // reset any necessary cached properties (see #5009)
  1442. if ( this.offsetParentCssPosition === "fixed" ) {
  1443. this.offset.parent = this._getParentOffset();
  1444. }
  1445. //Compute the helpers position
  1446. this.position = this._generatePosition(event);
  1447. this.positionAbs = this._convertPositionTo("absolute");
  1448. //Call plugins and callbacks and use the resulting position if something is returned
  1449. if (!noPropagation) {
  1450. var ui = this._uiHash();
  1451. if(this._trigger("drag", event, ui) === false) {
  1452. this._mouseUp({});
  1453. return false;
  1454. }
  1455. this.position = ui.position;
  1456. }
  1457. if(!this.options.axis || this.options.axis !== "y") {
  1458. this.helper[0].style.left = this.position.left+"px";
  1459. }
  1460. if(!this.options.axis || this.options.axis !== "x") {
  1461. this.helper[0].style.top = this.position.top+"px";
  1462. }
  1463. if($.ui.ddmanager) {
  1464. $.ui.ddmanager.drag(this, event);
  1465. }
  1466. return false;
  1467. },
  1468. _mouseStop: function(event) {
  1469. //If we are using droppables, inform the manager about the drop
  1470. var that = this,
  1471. dropped = false;
  1472. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  1473. dropped = $.ui.ddmanager.drop(this, event);
  1474. }
  1475. //if a drop comes from outside (a sortable)
  1476. if(this.dropped) {
  1477. dropped = this.dropped;
  1478. this.dropped = false;
  1479. }
  1480. //if the original element is no longer in the DOM don't bother to continue (see #8269)
  1481. if ( this.options.helper === "original" && !$.contains( this.element[ 0 ].ownerDocument, this.element[ 0 ] ) ) {
  1482. return false;
  1483. }
  1484. 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))) {
  1485. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  1486. if(that._trigger("stop", event) !== false) {
  1487. that._clear();
  1488. }
  1489. });
  1490. } else {
  1491. if(this._trigger("stop", event) !== false) {
  1492. this._clear();
  1493. }
  1494. }
  1495. return false;
  1496. },
  1497. _mouseUp: function(event) {
  1498. //Remove frame helpers
  1499. $("div.ui-draggable-iframeFix").each(function() {
  1500. this.parentNode.removeChild(this);
  1501. });
  1502. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  1503. if( $.ui.ddmanager ) {
  1504. $.ui.ddmanager.dragStop(this, event);
  1505. }
  1506. return $.ui.mouse.prototype._mouseUp.call(this, event);
  1507. },
  1508. cancel: function() {
  1509. if(this.helper.is(".ui-draggable-dragging")) {
  1510. this._mouseUp({});
  1511. } else {
  1512. this._clear();
  1513. }
  1514. return this;
  1515. },
  1516. _getHandle: function(event) {
  1517. return this.options.handle ?
  1518. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  1519. true;
  1520. },
  1521. _createHelper: function(event) {
  1522. var o = this.options,
  1523. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper === "clone" ? this.element.clone().removeAttr("id") : this.element);
  1524. if(!helper.parents("body").length) {
  1525. helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
  1526. }
  1527. if(helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
  1528. helper.css("position", "absolute");
  1529. }
  1530. return helper;
  1531. },
  1532. _adjustOffsetFromHelper: function(obj) {
  1533. if (typeof obj === "string") {
  1534. obj = obj.split(" ");
  1535. }
  1536. if ($.isArray(obj)) {
  1537. obj = {left: +obj[0], top: +obj[1] || 0};
  1538. }
  1539. if ("left" in obj) {
  1540. this.offset.click.left = obj.left + this.margins.left;
  1541. }
  1542. if ("right" in obj) {
  1543. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  1544. }
  1545. if ("top" in obj) {
  1546. this.offset.click.top = obj.top + this.margins.top;
  1547. }
  1548. if ("bottom" in obj) {
  1549. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  1550. }
  1551. },
  1552. _getParentOffset: function() {
  1553. //Get the offsetParent and cache its position
  1554. var po = this.offsetParent.offset();
  1555. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  1556. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  1557. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  1558. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  1559. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  1560. po.left += this.scrollParent.scrollLeft();
  1561. po.top += this.scrollParent.scrollTop();
  1562. }
  1563. //This needs to be actually done for all browsers, since pageX/pageY includes this information
  1564. //Ugly IE fix
  1565. if((this.offsetParent[0] === document.body) ||
  1566. (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  1567. po = { top: 0, left: 0 };
  1568. }
  1569. return {
  1570. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  1571. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  1572. };
  1573. },
  1574. _getRelativeOffset: function() {
  1575. if(this.cssPosition === "relative") {
  1576. var p = this.element.position();
  1577. return {
  1578. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  1579. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  1580. };
  1581. } else {
  1582. return { top: 0, left: 0 };
  1583. }
  1584. },
  1585. _cacheMargins: function() {
  1586. this.margins = {
  1587. left: (parseInt(this.element.css("marginLeft"),10) || 0),
  1588. top: (parseInt(this.element.css("marginTop"),10) || 0),
  1589. right: (parseInt(this.element.css("marginRight"),10) || 0),
  1590. bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
  1591. };
  1592. },
  1593. _cacheHelperProportions: function() {
  1594. this.helperProportions = {
  1595. width: this.helper.outerWidth(),
  1596. height: this.helper.outerHeight()
  1597. };
  1598. },
  1599. _setContainment: function() {
  1600. var over, c, ce,
  1601. o = this.options;
  1602. if ( !o.containment ) {
  1603. this.containment = null;
  1604. return;
  1605. }
  1606. if ( o.containment === "window" ) {
  1607. this.containment = [
  1608. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  1609. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  1610. $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
  1611. $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1612. ];
  1613. return;
  1614. }
  1615. if ( o.containment === "document") {
  1616. this.containment = [
  1617. 0,
  1618. 0,
  1619. $( document ).width() - this.helperProportions.width - this.margins.left,
  1620. ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1621. ];
  1622. return;
  1623. }
  1624. if ( o.containment.constructor === Array ) {
  1625. this.containment = o.containment;
  1626. return;
  1627. }
  1628. if ( o.containment === "parent" ) {
  1629. o.containment = this.helper[ 0 ].parentNode;
  1630. }
  1631. c = $( o.containment );
  1632. ce = c[ 0 ];
  1633. if( !ce ) {
  1634. return;
  1635. }
  1636. over = c.css( "overflow" ) !== "hidden";
  1637. this.containment = [
  1638. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  1639. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ) ,
  1640. ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) - this.helperProportions.width - this.margins.left - this.margins.right,
  1641. ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) - this.helperProportions.height - this.margins.top - this.margins.bottom
  1642. ];
  1643. this.relative_container = c;
  1644. },
  1645. _convertPositionTo: function(d, pos) {
  1646. if(!pos) {
  1647. pos = this.position;
  1648. }
  1649. var mod = d === "absolute" ? 1 : -1,
  1650. scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent;
  1651. //Cache the scroll
  1652. if (!this.offset.scroll) {
  1653. this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
  1654. }
  1655. return {
  1656. top: (
  1657. pos.top + // The absolute mouse position
  1658. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1659. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  1660. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top ) * mod )
  1661. ),
  1662. left: (
  1663. pos.left + // The absolute mouse position
  1664. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1665. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  1666. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left ) * mod )
  1667. )
  1668. };
  1669. },
  1670. _generatePosition: function(event) {
  1671. var containment, co, top, left,
  1672. o = this.options,
  1673. scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent,
  1674. pageX = event.pageX,
  1675. pageY = event.pageY;
  1676. //Cache the scroll
  1677. if (!this.offset.scroll) {
  1678. this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
  1679. }
  1680. /*
  1681. * - Position constraining -
  1682. * Constrain the position to a mix of grid, containment.
  1683. */
  1684. // If we are not dragging yet, we won't check for options
  1685. if ( this.originalPosition ) {
  1686. if ( this.containment ) {
  1687. if ( this.relative_container ){
  1688. co = this.relative_container.offset();
  1689. containment = [
  1690. this.containment[ 0 ] + co.left,
  1691. this.containment[ 1 ] + co.top,
  1692. this.containment[ 2 ] + co.left,
  1693. this.containment[ 3 ] + co.top
  1694. ];
  1695. }
  1696. else {
  1697. containment = this.containment;
  1698. }
  1699. if(event.pageX - this.offset.click.left < containment[0]) {
  1700. pageX = containment[0] + this.offset.click.left;
  1701. }
  1702. if(event.pageY - this.offset.click.top < containment[1]) {
  1703. pageY = containment[1] + this.offset.click.top;
  1704. }
  1705. if(event.pageX - this.offset.click.left > containment[2]) {
  1706. pageX = containment[2] + this.offset.click.left;
  1707. }
  1708. if(event.pageY - this.offset.click.top > containment[3]) {
  1709. pageY = containment[3] + this.offset.click.top;
  1710. }
  1711. }
  1712. if(o.grid) {
  1713. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  1714. top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  1715. 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;
  1716. left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  1717. 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;
  1718. }
  1719. }
  1720. return {
  1721. top: (
  1722. pageY - // The absolute mouse position
  1723. this.offset.click.top - // Click offset (relative to the element)
  1724. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  1725. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  1726. ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top )
  1727. ),
  1728. left: (
  1729. pageX - // The absolute mouse position
  1730. this.offset.click.left - // Click offset (relative to the element)
  1731. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  1732. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  1733. ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left )
  1734. )
  1735. };
  1736. },
  1737. _clear: function() {
  1738. this.helper.removeClass("ui-draggable-dragging");
  1739. if(this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
  1740. this.helper.remove();
  1741. }
  1742. this.helper = null;
  1743. this.cancelHelperRemoval = false;
  1744. },
  1745. // From now on bulk stuff - mainly helpers
  1746. _trigger: function(type, event, ui) {
  1747. ui = ui || this._uiHash();
  1748. $.ui.plugin.call(this, type, [event, ui]);
  1749. //The absolute position has to be recalculated after plugins
  1750. if(type === "drag") {
  1751. this.positionAbs = this._convertPositionTo("absolute");
  1752. }
  1753. return $.Widget.prototype._trigger.call(this, type, event, ui);
  1754. },
  1755. plugins: {},
  1756. _uiHash: function() {
  1757. return {
  1758. helper: this.helper,
  1759. position: this.position,
  1760. originalPosition: this.originalPosition,
  1761. offset: this.positionAbs
  1762. };
  1763. }
  1764. });
  1765. $.ui.plugin.add("draggable", "connectToSortable", {
  1766. start: function(event, ui) {
  1767. var inst = $(this).data("ui-draggable"), o = inst.options,
  1768. uiSortable = $.extend({}, ui, { item: inst.element });
  1769. inst.sortables = [];
  1770. $(o.connectToSortable).each(function() {
  1771. var sortable = $.data(this, "ui-sortable");
  1772. if (sortable && !sortable.options.disabled) {
  1773. inst.sortables.push({
  1774. instance: sortable,
  1775. shouldRevert: sortable.options.revert
  1776. });
  1777. 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).
  1778. sortable._trigger("activate", event, uiSortable);
  1779. }
  1780. });
  1781. },
  1782. stop: function(event, ui) {
  1783. //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
  1784. var inst = $(this).data("ui-draggable"),
  1785. uiSortable = $.extend({}, ui, { item: inst.element });
  1786. $.each(inst.sortables, function() {
  1787. if(this.instance.isOver) {
  1788. this.instance.isOver = 0;
  1789. inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
  1790. this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
  1791. //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid"
  1792. if(this.shouldRevert) {
  1793. this.instance.options.revert = this.shouldRevert;
  1794. }
  1795. //Trigger the stop of the sortable
  1796. this.instance._mouseStop(event);
  1797. this.instance.options.helper = this.instance.options._helper;
  1798. //If the helper has been the original item, restore properties in the sortable
  1799. if(inst.options.helper === "original") {
  1800. this.instance.currentItem.css({ top: "auto", left: "auto" });
  1801. }
  1802. } else {
  1803. this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
  1804. this.instance._trigger("deactivate", event, uiSortable);
  1805. }
  1806. });
  1807. },
  1808. drag: function(event, ui) {
  1809. var inst = $(this).data("ui-draggable"), that = this;
  1810. $.each(inst.sortables, function() {
  1811. var innermostIntersecting = false,
  1812. thisSortable = this;
  1813. //Copy over some variables to allow calling the sortable's native _intersectsWith
  1814. this.instance.positionAbs = inst.positionAbs;
  1815. this.instance.helperProportions = inst.helperProportions;
  1816. this.instance.offset.click = inst.offset.click;
  1817. if(this.instance._intersectsWith(this.instance.containerCache)) {
  1818. innermostIntersecting = true;
  1819. $.each(inst.sortables, function () {
  1820. this.instance.positionAbs = inst.positionAbs;
  1821. this.instance.helperProportions = inst.helperProportions;
  1822. this.instance.offset.click = inst.offset.click;
  1823. if (this !== thisSortable &&
  1824. this.instance._intersectsWith(this.instance.containerCache) &&
  1825. $.contains(thisSortable.instance.element[0], this.instance.element[0])
  1826. ) {
  1827. innermostIntersecting = false;
  1828. }
  1829. return innermostIntersecting;
  1830. });
  1831. }
  1832. if(innermostIntersecting) {
  1833. //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
  1834. if(!this.instance.isOver) {
  1835. this.instance.isOver = 1;
  1836. //Now we fake the start of dragging for the sortable instance,
  1837. //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
  1838. //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)
  1839. this.instance.currentItem = $(that).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item", true);
  1840. this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
  1841. this.instance.options.helper = function() { return ui.helper[0]; };
  1842. event.target = this.instance.currentItem[0];
  1843. this.instance._mouseCapture(event, true);
  1844. this.instance._mouseStart(event, true, true);
  1845. //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
  1846. this.instance.offset.click.top = inst.offset.click.top;
  1847. this.instance.offset.click.left = inst.offset.click.left;
  1848. this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
  1849. this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
  1850. inst._trigger("toSortable", event);
  1851. inst.dropped = this.instance.element; //draggable revert needs that
  1852. //hack so receive/update callbacks work (mostly)
  1853. inst.currentItem = inst.element;
  1854. this.instance.fromOutside = inst;
  1855. }
  1856. //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
  1857. if(this.instance.currentItem) {
  1858. this.instance._mouseDrag(event);
  1859. }
  1860. } else {
  1861. //If it doesn't intersect with the sortable, and it intersected before,
  1862. //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
  1863. if(this.instance.isOver) {
  1864. this.instance.isOver = 0;
  1865. this.instance.cancelHelperRemoval = true;
  1866. //Prevent reverting on this forced stop
  1867. this.instance.options.revert = false;
  1868. // The out event needs to be triggered independently
  1869. this.instance._trigger("out", event, this.instance._uiHash(this.instance));
  1870. this.instance._mouseStop(event, true);
  1871. this.instance.options.helper = this.instance.options._helper;
  1872. //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
  1873. this.instance.currentItem.remove();
  1874. if(this.instance.placeholder) {
  1875. this.instance.placeholder.remove();
  1876. }
  1877. inst._trigger("fromSortable", event);
  1878. inst.dropped = false; //draggable revert needs that
  1879. }
  1880. }
  1881. });
  1882. }
  1883. });
  1884. $.ui.plugin.add("draggable", "cursor", {
  1885. start: function() {
  1886. var t = $("body"), o = $(this).data("ui-draggable").options;
  1887. if (t.css("cursor")) {
  1888. o._cursor = t.css("cursor");
  1889. }
  1890. t.css("cursor", o.cursor);
  1891. },
  1892. stop: function() {
  1893. var o = $(this).data("ui-draggable").options;
  1894. if (o._cursor) {
  1895. $("body").css("cursor", o._cursor);
  1896. }
  1897. }
  1898. });
  1899. $.ui.plugin.add("draggable", "opacity", {
  1900. start: function(event, ui) {
  1901. var t = $(ui.helper), o = $(this).data("ui-draggable").options;
  1902. if(t.css("opacity")) {
  1903. o._opacity = t.css("opacity");
  1904. }
  1905. t.css("opacity", o.opacity);
  1906. },
  1907. stop: function(event, ui) {
  1908. var o = $(this).data("ui-draggable").options;
  1909. if(o._opacity) {
  1910. $(ui.helper).css("opacity", o._opacity);
  1911. }
  1912. }
  1913. });
  1914. $.ui.plugin.add("draggable", "scroll", {
  1915. start: function() {
  1916. var i = $(this).data("ui-draggable");
  1917. if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
  1918. i.overflowOffset = i.scrollParent.offset();
  1919. }
  1920. },
  1921. drag: function( event ) {
  1922. var i = $(this).data("ui-draggable"), o = i.options, scrolled = false;
  1923. if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
  1924. if(!o.axis || o.axis !== "x") {
  1925. if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  1926. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
  1927. } else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity) {
  1928. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
  1929. }
  1930. }
  1931. if(!o.axis || o.axis !== "y") {
  1932. if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  1933. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
  1934. } else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity) {
  1935. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
  1936. }
  1937. }
  1938. } else {
  1939. if(!o.axis || o.axis !== "x") {
  1940. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  1941. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  1942. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  1943. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  1944. }
  1945. }
  1946. if(!o.axis || o.axis !== "y") {
  1947. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  1948. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  1949. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  1950. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  1951. }
  1952. }
  1953. }
  1954. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  1955. $.ui.ddmanager.prepareOffsets(i, event);
  1956. }
  1957. }
  1958. });
  1959. $.ui.plugin.add("draggable", "snap", {
  1960. start: function() {
  1961. var i = $(this).data("ui-draggable"),
  1962. o = i.options;
  1963. i.snapElements = [];
  1964. $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
  1965. var $t = $(this),
  1966. $o = $t.offset();
  1967. if(this !== i.element[0]) {
  1968. i.snapElements.push({
  1969. item: this,
  1970. width: $t.outerWidth(), height: $t.outerHeight(),
  1971. top: $o.top, left: $o.left
  1972. });
  1973. }
  1974. });
  1975. },
  1976. drag: function(event, ui) {
  1977. var ts, bs, ls, rs, l, r, t, b, i, first,
  1978. inst = $(this).data("ui-draggable"),
  1979. o = inst.options,
  1980. d = o.snapTolerance,
  1981. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  1982. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  1983. for (i = inst.snapElements.length - 1; i >= 0; i--){
  1984. l = inst.snapElements[i].left;
  1985. r = l + inst.snapElements[i].width;
  1986. t = inst.snapElements[i].top;
  1987. b = t + inst.snapElements[i].height;
  1988. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
  1989. if(inst.snapElements[i].snapping) {
  1990. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  1991. }
  1992. inst.snapElements[i].snapping = false;
  1993. continue;
  1994. }
  1995. if(o.snapMode !== "inner") {
  1996. ts = Math.abs(t - y2) <= d;
  1997. bs = Math.abs(b - y1) <= d;
  1998. ls = Math.abs(l - x2) <= d;
  1999. rs = Math.abs(r - x1) <= d;
  2000. if(ts) {
  2001. ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  2002. }
  2003. if(bs) {
  2004. ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
  2005. }
  2006. if(ls) {
  2007. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
  2008. }
  2009. if(rs) {
  2010. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
  2011. }
  2012. }
  2013. first = (ts || bs || ls || rs);
  2014. if(o.snapMode !== "outer") {
  2015. ts = Math.abs(t - y1) <= d;
  2016. bs = Math.abs(b - y2) <= d;
  2017. ls = Math.abs(l - x1) <= d;
  2018. rs = Math.abs(r - x2) <= d;
  2019. if(ts) {
  2020. ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
  2021. }
  2022. if(bs) {
  2023. ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  2024. }
  2025. if(ls) {
  2026. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
  2027. }
  2028. if(rs) {
  2029. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
  2030. }
  2031. }
  2032. if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  2033. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  2034. }
  2035. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  2036. }
  2037. }
  2038. });
  2039. $.ui.plugin.add("draggable", "stack", {
  2040. start: function() {
  2041. var min,
  2042. o = this.data("ui-draggable").options,
  2043. group = $.makeArray($(o.stack)).sort(function(a,b) {
  2044. return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
  2045. });
  2046. if (!group.length) { return; }
  2047. min = parseInt($(group[0]).css("zIndex"), 10) || 0;
  2048. $(group).each(function(i) {
  2049. $(this).css("zIndex", min + i);
  2050. });
  2051. this.css("zIndex", (min + group.length));
  2052. }
  2053. });
  2054. $.ui.plugin.add("draggable", "zIndex", {
  2055. start: function(event, ui) {
  2056. var t = $(ui.helper), o = $(this).data("ui-draggable").options;
  2057. if(t.css("zIndex")) {
  2058. o._zIndex = t.css("zIndex");
  2059. }
  2060. t.css("zIndex", o.zIndex);
  2061. },
  2062. stop: function(event, ui) {
  2063. var o = $(this).data("ui-draggable").options;
  2064. if(o._zIndex) {
  2065. $(ui.helper).css("zIndex", o._zIndex);
  2066. }
  2067. }
  2068. });
  2069. })(jQuery);
  2070. (function( $, undefined ) {
  2071. function isOverAxis( x, reference, size ) {
  2072. return ( x > reference ) && ( x < ( reference + size ) );
  2073. }
  2074. $.widget("ui.droppable", {
  2075. version: "1.10.3",
  2076. widgetEventPrefix: "drop",
  2077. options: {
  2078. accept: "*",
  2079. activeClass: false,
  2080. addClasses: true,
  2081. greedy: false,
  2082. hoverClass: false,
  2083. scope: "default",
  2084. tolerance: "intersect",
  2085. // callbacks
  2086. activate: null,
  2087. deactivate: null,
  2088. drop: null,
  2089. out: null,
  2090. over: null
  2091. },
  2092. _create: function() {
  2093. var o = this.options,
  2094. accept = o.accept;
  2095. this.isover = false;
  2096. this.isout = true;
  2097. this.accept = $.isFunction(accept) ? accept : function(d) {
  2098. return d.is(accept);
  2099. };
  2100. //Store the droppable's proportions
  2101. this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
  2102. // Add the reference and positions to the manager
  2103. $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
  2104. $.ui.ddmanager.droppables[o.scope].push(this);
  2105. (o.addClasses && this.element.addClass("ui-droppable"));
  2106. },
  2107. _destroy: function() {
  2108. var i = 0,
  2109. drop = $.ui.ddmanager.droppables[this.options.scope];
  2110. for ( ; i < drop.length; i++ ) {
  2111. if ( drop[i] === this ) {
  2112. drop.splice(i, 1);
  2113. }
  2114. }
  2115. this.element.removeClass("ui-droppable ui-droppable-disabled");
  2116. },
  2117. _setOption: function(key, value) {
  2118. if(key === "accept") {
  2119. this.accept = $.isFunction(value) ? value : function(d) {
  2120. return d.is(value);
  2121. };
  2122. }
  2123. $.Widget.prototype._setOption.apply(this, arguments);
  2124. },
  2125. _activate: function(event) {
  2126. var draggable = $.ui.ddmanager.current;
  2127. if(this.options.activeClass) {
  2128. this.element.addClass(this.options.activeClass);
  2129. }
  2130. if(draggable){
  2131. this._trigger("activate", event, this.ui(draggable));
  2132. }
  2133. },
  2134. _deactivate: function(event) {
  2135. var draggable = $.ui.ddmanager.current;
  2136. if(this.options.activeClass) {
  2137. this.element.removeClass(this.options.activeClass);
  2138. }
  2139. if(draggable){
  2140. this._trigger("deactivate", event, this.ui(draggable));
  2141. }
  2142. },
  2143. _over: function(event) {
  2144. var draggable = $.ui.ddmanager.current;
  2145. // Bail if draggable and droppable are same element
  2146. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  2147. return;
  2148. }
  2149. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  2150. if(this.options.hoverClass) {
  2151. this.element.addClass(this.options.hoverClass);
  2152. }
  2153. this._trigger("over", event, this.ui(draggable));
  2154. }
  2155. },
  2156. _out: function(event) {
  2157. var draggable = $.ui.ddmanager.current;
  2158. // Bail if draggable and droppable are same element
  2159. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  2160. return;
  2161. }
  2162. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  2163. if(this.options.hoverClass) {
  2164. this.element.removeClass(this.options.hoverClass);
  2165. }
  2166. this._trigger("out", event, this.ui(draggable));
  2167. }
  2168. },
  2169. _drop: function(event,custom) {
  2170. var draggable = custom || $.ui.ddmanager.current,
  2171. childrenIntersection = false;
  2172. // Bail if draggable and droppable are same element
  2173. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  2174. return false;
  2175. }
  2176. this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function() {
  2177. var inst = $.data(this, "ui-droppable");
  2178. if(
  2179. inst.options.greedy &&
  2180. !inst.options.disabled &&
  2181. inst.options.scope === draggable.options.scope &&
  2182. inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element)) &&
  2183. $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
  2184. ) { childrenIntersection = true; return false; }
  2185. });
  2186. if(childrenIntersection) {
  2187. return false;
  2188. }
  2189. if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  2190. if(this.options.activeClass) {
  2191. this.element.removeClass(this.options.activeClass);
  2192. }
  2193. if(this.options.hoverClass) {
  2194. this.element.removeClass(this.options.hoverClass);
  2195. }
  2196. this._trigger("drop", event, this.ui(draggable));
  2197. return this.element;
  2198. }
  2199. return false;
  2200. },
  2201. ui: function(c) {
  2202. return {
  2203. draggable: (c.currentItem || c.element),
  2204. helper: c.helper,
  2205. position: c.position,
  2206. offset: c.positionAbs
  2207. };
  2208. }
  2209. });
  2210. $.ui.intersect = function(draggable, droppable, toleranceMode) {
  2211. if (!droppable.offset) {
  2212. return false;
  2213. }
  2214. var draggableLeft, draggableTop,
  2215. x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
  2216. y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height,
  2217. l = droppable.offset.left, r = l + droppable.proportions.width,
  2218. t = droppable.offset.top, b = t + droppable.proportions.height;
  2219. switch (toleranceMode) {
  2220. case "fit":
  2221. return (l <= x1 && x2 <= r && t <= y1 && y2 <= b);
  2222. case "intersect":
  2223. return (l < x1 + (draggable.helperProportions.width / 2) && // Right Half
  2224. x2 - (draggable.helperProportions.width / 2) < r && // Left Half
  2225. t < y1 + (draggable.helperProportions.height / 2) && // Bottom Half
  2226. y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
  2227. case "pointer":
  2228. draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left);
  2229. draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top);
  2230. return isOverAxis( draggableTop, t, droppable.proportions.height ) && isOverAxis( draggableLeft, l, droppable.proportions.width );
  2231. case "touch":
  2232. return (
  2233. (y1 >= t && y1 <= b) || // Top edge touching
  2234. (y2 >= t && y2 <= b) || // Bottom edge touching
  2235. (y1 < t && y2 > b) // Surrounded vertically
  2236. ) && (
  2237. (x1 >= l && x1 <= r) || // Left edge touching
  2238. (x2 >= l && x2 <= r) || // Right edge touching
  2239. (x1 < l && x2 > r) // Surrounded horizontally
  2240. );
  2241. default:
  2242. return false;
  2243. }
  2244. };
  2245. /*
  2246. This manager tracks offsets of draggables and droppables
  2247. */
  2248. $.ui.ddmanager = {
  2249. current: null,
  2250. droppables: { "default": [] },
  2251. prepareOffsets: function(t, event) {
  2252. var i, j,
  2253. m = $.ui.ddmanager.droppables[t.options.scope] || [],
  2254. type = event ? event.type : null, // workaround for #2317
  2255. list = (t.currentItem || t.element).find(":data(ui-droppable)").addBack();
  2256. droppablesLoop: for (i = 0; i < m.length; i++) {
  2257. //No disabled and non-accepted
  2258. if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) {
  2259. continue;
  2260. }
  2261. // Filter out elements in the current dragged item
  2262. for (j=0; j < list.length; j++) {
  2263. if(list[j] === m[i].element[0]) {
  2264. m[i].proportions.height = 0;
  2265. continue droppablesLoop;
  2266. }
  2267. }
  2268. m[i].visible = m[i].element.css("display") !== "none";
  2269. if(!m[i].visible) {
  2270. continue;
  2271. }
  2272. //Activate the droppable if used directly from draggables
  2273. if(type === "mousedown") {
  2274. m[i]._activate.call(m[i], event);
  2275. }
  2276. m[i].offset = m[i].element.offset();
  2277. m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
  2278. }
  2279. },
  2280. drop: function(draggable, event) {
  2281. var dropped = false;
  2282. // Create a copy of the droppables in case the list changes during the drop (#9116)
  2283. $.each(($.ui.ddmanager.droppables[draggable.options.scope] || []).slice(), function() {
  2284. if(!this.options) {
  2285. return;
  2286. }
  2287. if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance)) {
  2288. dropped = this._drop.call(this, event) || dropped;
  2289. }
  2290. if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  2291. this.isout = true;
  2292. this.isover = false;
  2293. this._deactivate.call(this, event);
  2294. }
  2295. });
  2296. return dropped;
  2297. },
  2298. dragStart: function( draggable, event ) {
  2299. //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  2300. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  2301. if( !draggable.options.refreshPositions ) {
  2302. $.ui.ddmanager.prepareOffsets( draggable, event );
  2303. }
  2304. });
  2305. },
  2306. drag: function(draggable, event) {
  2307. //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  2308. if(draggable.options.refreshPositions) {
  2309. $.ui.ddmanager.prepareOffsets(draggable, event);
  2310. }
  2311. //Run through all droppables and check their positions based on specific tolerance options
  2312. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  2313. if(this.options.disabled || this.greedyChild || !this.visible) {
  2314. return;
  2315. }
  2316. var parentInstance, scope, parent,
  2317. intersects = $.ui.intersect(draggable, this, this.options.tolerance),
  2318. c = !intersects && this.isover ? "isout" : (intersects && !this.isover ? "isover" : null);
  2319. if(!c) {
  2320. return;
  2321. }
  2322. if (this.options.greedy) {
  2323. // find droppable parents with same scope
  2324. scope = this.options.scope;
  2325. parent = this.element.parents(":data(ui-droppable)").filter(function () {
  2326. return $.data(this, "ui-droppable").options.scope === scope;
  2327. });
  2328. if (parent.length) {
  2329. parentInstance = $.data(parent[0], "ui-droppable");
  2330. parentInstance.greedyChild = (c === "isover");
  2331. }
  2332. }
  2333. // we just moved into a greedy child
  2334. if (parentInstance && c === "isover") {
  2335. parentInstance.isover = false;
  2336. parentInstance.isout = true;
  2337. parentInstance._out.call(parentInstance, event);
  2338. }
  2339. this[c] = true;
  2340. this[c === "isout" ? "isover" : "isout"] = false;
  2341. this[c === "isover" ? "_over" : "_out"].call(this, event);
  2342. // we just moved out of a greedy child
  2343. if (parentInstance && c === "isout") {
  2344. parentInstance.isout = false;
  2345. parentInstance.isover = true;
  2346. parentInstance._over.call(parentInstance, event);
  2347. }
  2348. });
  2349. },
  2350. dragStop: function( draggable, event ) {
  2351. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  2352. //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  2353. if( !draggable.options.refreshPositions ) {
  2354. $.ui.ddmanager.prepareOffsets( draggable, event );
  2355. }
  2356. }
  2357. };
  2358. })(jQuery);
  2359. (function( $, undefined ) {
  2360. function num(v) {
  2361. return parseInt(v, 10) || 0;
  2362. }
  2363. function isNumber(value) {
  2364. return !isNaN(parseInt(value, 10));
  2365. }
  2366. $.widget("ui.resizable", $.ui.mouse, {
  2367. version: "1.10.3",
  2368. widgetEventPrefix: "resize",
  2369. options: {
  2370. alsoResize: false,
  2371. animate: false,
  2372. animateDuration: "slow",
  2373. animateEasing: "swing",
  2374. aspectRatio: false,
  2375. autoHide: false,
  2376. containment: false,
  2377. ghost: false,
  2378. grid: false,
  2379. handles: "e,s,se",
  2380. helper: false,
  2381. maxHeight: null,
  2382. maxWidth: null,
  2383. minHeight: 10,
  2384. minWidth: 10,
  2385. // See #7960
  2386. zIndex: 90,
  2387. // callbacks
  2388. resize: null,
  2389. start: null,
  2390. stop: null
  2391. },
  2392. _create: function() {
  2393. var n, i, handle, axis, hname,
  2394. that = this,
  2395. o = this.options;
  2396. this.element.addClass("ui-resizable");
  2397. $.extend(this, {
  2398. _aspectRatio: !!(o.aspectRatio),
  2399. aspectRatio: o.aspectRatio,
  2400. originalElement: this.element,
  2401. _proportionallyResizeElements: [],
  2402. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  2403. });
  2404. //Wrap the element if it cannot hold child nodes
  2405. if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
  2406. //Create a wrapper element and set the wrapper to the new current internal element
  2407. this.element.wrap(
  2408. $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
  2409. position: this.element.css("position"),
  2410. width: this.element.outerWidth(),
  2411. height: this.element.outerHeight(),
  2412. top: this.element.css("top"),
  2413. left: this.element.css("left")
  2414. })
  2415. );
  2416. //Overwrite the original this.element
  2417. this.element = this.element.parent().data(
  2418. "ui-resizable", this.element.data("ui-resizable")
  2419. );
  2420. this.elementIsWrapper = true;
  2421. //Move margins to the wrapper
  2422. this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
  2423. this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
  2424. //Prevent Safari textarea resize
  2425. this.originalResizeStyle = this.originalElement.css("resize");
  2426. this.originalElement.css("resize", "none");
  2427. //Push the actual element to our proportionallyResize internal array
  2428. this._proportionallyResizeElements.push(this.originalElement.css({ position: "static", zoom: 1, display: "block" }));
  2429. // avoid IE jump (hard set the margin)
  2430. this.originalElement.css({ margin: this.originalElement.css("margin") });
  2431. // fix handlers offset
  2432. this._proportionallyResize();
  2433. }
  2434. 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" });
  2435. if(this.handles.constructor === String) {
  2436. if ( this.handles === "all") {
  2437. this.handles = "n,e,s,w,se,sw,ne,nw";
  2438. }
  2439. n = this.handles.split(",");
  2440. this.handles = {};
  2441. for(i = 0; i < n.length; i++) {
  2442. handle = $.trim(n[i]);
  2443. hname = "ui-resizable-"+handle;
  2444. axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
  2445. // Apply zIndex to all handles - see #7960
  2446. axis.css({ zIndex: o.zIndex });
  2447. //TODO : What's going on here?
  2448. if ("se" === handle) {
  2449. axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
  2450. }
  2451. //Insert into internal handles object and append to element
  2452. this.handles[handle] = ".ui-resizable-"+handle;
  2453. this.element.append(axis);
  2454. }
  2455. }
  2456. this._renderAxis = function(target) {
  2457. var i, axis, padPos, padWrapper;
  2458. target = target || this.element;
  2459. for(i in this.handles) {
  2460. if(this.handles[i].constructor === String) {
  2461. this.handles[i] = $(this.handles[i], this.element).show();
  2462. }
  2463. //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
  2464. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
  2465. axis = $(this.handles[i], this.element);
  2466. //Checking the correct pad and border
  2467. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  2468. //The padding type i have to apply...
  2469. padPos = [ "padding",
  2470. /ne|nw|n/.test(i) ? "Top" :
  2471. /se|sw|s/.test(i) ? "Bottom" :
  2472. /^e$/.test(i) ? "Right" : "Left" ].join("");
  2473. target.css(padPos, padWrapper);
  2474. this._proportionallyResize();
  2475. }
  2476. //TODO: What's that good for? There's not anything to be executed left
  2477. if(!$(this.handles[i]).length) {
  2478. continue;
  2479. }
  2480. }
  2481. };
  2482. //TODO: make renderAxis a prototype function
  2483. this._renderAxis(this.element);
  2484. this._handles = $(".ui-resizable-handle", this.element)
  2485. .disableSelection();
  2486. //Matching axis name
  2487. this._handles.mouseover(function() {
  2488. if (!that.resizing) {
  2489. if (this.className) {
  2490. axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  2491. }
  2492. //Axis, default = se
  2493. that.axis = axis && axis[1] ? axis[1] : "se";
  2494. }
  2495. });
  2496. //If we want to auto hide the elements
  2497. if (o.autoHide) {
  2498. this._handles.hide();
  2499. $(this.element)
  2500. .addClass("ui-resizable-autohide")
  2501. .mouseenter(function() {
  2502. if (o.disabled) {
  2503. return;
  2504. }
  2505. $(this).removeClass("ui-resizable-autohide");
  2506. that._handles.show();
  2507. })
  2508. .mouseleave(function(){
  2509. if (o.disabled) {
  2510. return;
  2511. }
  2512. if (!that.resizing) {
  2513. $(this).addClass("ui-resizable-autohide");
  2514. that._handles.hide();
  2515. }
  2516. });
  2517. }
  2518. //Initialize the mouse interaction
  2519. this._mouseInit();
  2520. },
  2521. _destroy: function() {
  2522. this._mouseDestroy();
  2523. var wrapper,
  2524. _destroy = function(exp) {
  2525. $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  2526. .removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove();
  2527. };
  2528. //TODO: Unwrap at same DOM position
  2529. if (this.elementIsWrapper) {
  2530. _destroy(this.element);
  2531. wrapper = this.element;
  2532. this.originalElement.css({
  2533. position: wrapper.css("position"),
  2534. width: wrapper.outerWidth(),
  2535. height: wrapper.outerHeight(),
  2536. top: wrapper.css("top"),
  2537. left: wrapper.css("left")
  2538. }).insertAfter( wrapper );
  2539. wrapper.remove();
  2540. }
  2541. this.originalElement.css("resize", this.originalResizeStyle);
  2542. _destroy(this.originalElement);
  2543. return this;
  2544. },
  2545. _mouseCapture: function(event) {
  2546. var i, handle,
  2547. capture = false;
  2548. for (i in this.handles) {
  2549. handle = $(this.handles[i])[0];
  2550. if (handle === event.target || $.contains(handle, event.target)) {
  2551. capture = true;
  2552. }
  2553. }
  2554. return !this.options.disabled && capture;
  2555. },
  2556. _mouseStart: function(event) {
  2557. var curleft, curtop, cursor,
  2558. o = this.options,
  2559. iniPos = this.element.position(),
  2560. el = this.element;
  2561. this.resizing = true;
  2562. // bugfix for http://dev.jquery.com/ticket/1749
  2563. if ( (/absolute/).test( el.css("position") ) ) {
  2564. el.css({ position: "absolute", top: el.css("top"), left: el.css("left") });
  2565. } else if (el.is(".ui-draggable")) {
  2566. el.css({ position: "absolute", top: iniPos.top, left: iniPos.left });
  2567. }
  2568. this._renderProxy();
  2569. curleft = num(this.helper.css("left"));
  2570. curtop = num(this.helper.css("top"));
  2571. if (o.containment) {
  2572. curleft += $(o.containment).scrollLeft() || 0;
  2573. curtop += $(o.containment).scrollTop() || 0;
  2574. }
  2575. //Store needed variables
  2576. this.offset = this.helper.offset();
  2577. this.position = { left: curleft, top: curtop };
  2578. this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  2579. this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  2580. this.originalPosition = { left: curleft, top: curtop };
  2581. this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
  2582. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  2583. //Aspect Ratio
  2584. this.aspectRatio = (typeof o.aspectRatio === "number") ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
  2585. cursor = $(".ui-resizable-" + this.axis).css("cursor");
  2586. $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
  2587. el.addClass("ui-resizable-resizing");
  2588. this._propagate("start", event);
  2589. return true;
  2590. },
  2591. _mouseDrag: function(event) {
  2592. //Increase performance, avoid regex
  2593. var data,
  2594. el = this.helper, props = {},
  2595. smp = this.originalMousePosition,
  2596. a = this.axis,
  2597. prevTop = this.position.top,
  2598. prevLeft = this.position.left,
  2599. prevWidth = this.size.width,
  2600. prevHeight = this.size.height,
  2601. dx = (event.pageX-smp.left)||0,
  2602. dy = (event.pageY-smp.top)||0,
  2603. trigger = this._change[a];
  2604. if (!trigger) {
  2605. return false;
  2606. }
  2607. // Calculate the attrs that will be change
  2608. data = trigger.apply(this, [event, dx, dy]);
  2609. // Put this in the mouseDrag handler since the user can start pressing shift while resizing
  2610. this._updateVirtualBoundaries(event.shiftKey);
  2611. if (this._aspectRatio || event.shiftKey) {
  2612. data = this._updateRatio(data, event);
  2613. }
  2614. data = this._respectSize(data, event);
  2615. this._updateCache(data);
  2616. // plugins callbacks need to be called first
  2617. this._propagate("resize", event);
  2618. if (this.position.top !== prevTop) {
  2619. props.top = this.position.top + "px";
  2620. }
  2621. if (this.position.left !== prevLeft) {
  2622. props.left = this.position.left + "px";
  2623. }
  2624. if (this.size.width !== prevWidth) {
  2625. props.width = this.size.width + "px";
  2626. }
  2627. if (this.size.height !== prevHeight) {
  2628. props.height = this.size.height + "px";
  2629. }
  2630. el.css(props);
  2631. if (!this._helper && this._proportionallyResizeElements.length) {
  2632. this._proportionallyResize();
  2633. }
  2634. // Call the user callback if the element was resized
  2635. if ( ! $.isEmptyObject(props) ) {
  2636. this._trigger("resize", event, this.ui());
  2637. }
  2638. return false;
  2639. },
  2640. _mouseStop: function(event) {
  2641. this.resizing = false;
  2642. var pr, ista, soffseth, soffsetw, s, left, top,
  2643. o = this.options, that = this;
  2644. if(this._helper) {
  2645. pr = this._proportionallyResizeElements;
  2646. ista = pr.length && (/textarea/i).test(pr[0].nodeName);
  2647. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height;
  2648. soffsetw = ista ? 0 : that.sizeDiff.width;
  2649. s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) };
  2650. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null;
  2651. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  2652. if (!o.animate) {
  2653. this.element.css($.extend(s, { top: top, left: left }));
  2654. }
  2655. that.helper.height(that.size.height);
  2656. that.helper.width(that.size.width);
  2657. if (this._helper && !o.animate) {
  2658. this._proportionallyResize();
  2659. }
  2660. }
  2661. $("body").css("cursor", "auto");
  2662. this.element.removeClass("ui-resizable-resizing");
  2663. this._propagate("stop", event);
  2664. if (this._helper) {
  2665. this.helper.remove();
  2666. }
  2667. return false;
  2668. },
  2669. _updateVirtualBoundaries: function(forceAspectRatio) {
  2670. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  2671. o = this.options;
  2672. b = {
  2673. minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
  2674. maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  2675. minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
  2676. maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
  2677. };
  2678. if(this._aspectRatio || forceAspectRatio) {
  2679. // We want to create an enclosing box whose aspect ration is the requested one
  2680. // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
  2681. pMinWidth = b.minHeight * this.aspectRatio;
  2682. pMinHeight = b.minWidth / this.aspectRatio;
  2683. pMaxWidth = b.maxHeight * this.aspectRatio;
  2684. pMaxHeight = b.maxWidth / this.aspectRatio;
  2685. if(pMinWidth > b.minWidth) {
  2686. b.minWidth = pMinWidth;
  2687. }
  2688. if(pMinHeight > b.minHeight) {
  2689. b.minHeight = pMinHeight;
  2690. }
  2691. if(pMaxWidth < b.maxWidth) {
  2692. b.maxWidth = pMaxWidth;
  2693. }
  2694. if(pMaxHeight < b.maxHeight) {
  2695. b.maxHeight = pMaxHeight;
  2696. }
  2697. }
  2698. this._vBoundaries = b;
  2699. },
  2700. _updateCache: function(data) {
  2701. this.offset = this.helper.offset();
  2702. if (isNumber(data.left)) {
  2703. this.position.left = data.left;
  2704. }
  2705. if (isNumber(data.top)) {
  2706. this.position.top = data.top;
  2707. }
  2708. if (isNumber(data.height)) {
  2709. this.size.height = data.height;
  2710. }
  2711. if (isNumber(data.width)) {
  2712. this.size.width = data.width;
  2713. }
  2714. },
  2715. _updateRatio: function( data ) {
  2716. var cpos = this.position,
  2717. csize = this.size,
  2718. a = this.axis;
  2719. if (isNumber(data.height)) {
  2720. data.width = (data.height * this.aspectRatio);
  2721. } else if (isNumber(data.width)) {
  2722. data.height = (data.width / this.aspectRatio);
  2723. }
  2724. if (a === "sw") {
  2725. data.left = cpos.left + (csize.width - data.width);
  2726. data.top = null;
  2727. }
  2728. if (a === "nw") {
  2729. data.top = cpos.top + (csize.height - data.height);
  2730. data.left = cpos.left + (csize.width - data.width);
  2731. }
  2732. return data;
  2733. },
  2734. _respectSize: function( data ) {
  2735. var o = this._vBoundaries,
  2736. a = this.axis,
  2737. ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  2738. isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
  2739. dw = this.originalPosition.left + this.originalSize.width,
  2740. dh = this.position.top + this.size.height,
  2741. cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  2742. if (isminw) {
  2743. data.width = o.minWidth;
  2744. }
  2745. if (isminh) {
  2746. data.height = o.minHeight;
  2747. }
  2748. if (ismaxw) {
  2749. data.width = o.maxWidth;
  2750. }
  2751. if (ismaxh) {
  2752. data.height = o.maxHeight;
  2753. }
  2754. if (isminw && cw) {
  2755. data.left = dw - o.minWidth;
  2756. }
  2757. if (ismaxw && cw) {
  2758. data.left = dw - o.maxWidth;
  2759. }
  2760. if (isminh && ch) {
  2761. data.top = dh - o.minHeight;
  2762. }
  2763. if (ismaxh && ch) {
  2764. data.top = dh - o.maxHeight;
  2765. }
  2766. // fixing jump error on top/left - bug #2330
  2767. if (!data.width && !data.height && !data.left && data.top) {
  2768. data.top = null;
  2769. } else if (!data.width && !data.height && !data.top && data.left) {
  2770. data.left = null;
  2771. }
  2772. return data;
  2773. },
  2774. _proportionallyResize: function() {
  2775. if (!this._proportionallyResizeElements.length) {
  2776. return;
  2777. }
  2778. var i, j, borders, paddings, prel,
  2779. element = this.helper || this.element;
  2780. for ( i=0; i < this._proportionallyResizeElements.length; i++) {
  2781. prel = this._proportionallyResizeElements[i];
  2782. if (!this.borderDif) {
  2783. this.borderDif = [];
  2784. borders = [prel.css("borderTopWidth"), prel.css("borderRightWidth"), prel.css("borderBottomWidth"), prel.css("borderLeftWidth")];
  2785. paddings = [prel.css("paddingTop"), prel.css("paddingRight"), prel.css("paddingBottom"), prel.css("paddingLeft")];
  2786. for ( j = 0; j < borders.length; j++ ) {
  2787. this.borderDif[ j ] = ( parseInt( borders[ j ], 10 ) || 0 ) + ( parseInt( paddings[ j ], 10 ) || 0 );
  2788. }
  2789. }
  2790. prel.css({
  2791. height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
  2792. width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
  2793. });
  2794. }
  2795. },
  2796. _renderProxy: function() {
  2797. var el = this.element, o = this.options;
  2798. this.elementOffset = el.offset();
  2799. if(this._helper) {
  2800. this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
  2801. this.helper.addClass(this._helper).css({
  2802. width: this.element.outerWidth() - 1,
  2803. height: this.element.outerHeight() - 1,
  2804. position: "absolute",
  2805. left: this.elementOffset.left +"px",
  2806. top: this.elementOffset.top +"px",
  2807. zIndex: ++o.zIndex //TODO: Don't modify option
  2808. });
  2809. this.helper
  2810. .appendTo("body")
  2811. .disableSelection();
  2812. } else {
  2813. this.helper = this.element;
  2814. }
  2815. },
  2816. _change: {
  2817. e: function(event, dx) {
  2818. return { width: this.originalSize.width + dx };
  2819. },
  2820. w: function(event, dx) {
  2821. var cs = this.originalSize, sp = this.originalPosition;
  2822. return { left: sp.left + dx, width: cs.width - dx };
  2823. },
  2824. n: function(event, dx, dy) {
  2825. var cs = this.originalSize, sp = this.originalPosition;
  2826. return { top: sp.top + dy, height: cs.height - dy };
  2827. },
  2828. s: function(event, dx, dy) {
  2829. return { height: this.originalSize.height + dy };
  2830. },
  2831. se: function(event, dx, dy) {
  2832. return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  2833. },
  2834. sw: function(event, dx, dy) {
  2835. return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  2836. },
  2837. ne: function(event, dx, dy) {
  2838. return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  2839. },
  2840. nw: function(event, dx, dy) {
  2841. return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  2842. }
  2843. },
  2844. _propagate: function(n, event) {
  2845. $.ui.plugin.call(this, n, [event, this.ui()]);
  2846. (n !== "resize" && this._trigger(n, event, this.ui()));
  2847. },
  2848. plugins: {},
  2849. ui: function() {
  2850. return {
  2851. originalElement: this.originalElement,
  2852. element: this.element,
  2853. helper: this.helper,
  2854. position: this.position,
  2855. size: this.size,
  2856. originalSize: this.originalSize,
  2857. originalPosition: this.originalPosition
  2858. };
  2859. }
  2860. });
  2861. /*
  2862. * Resizable Extensions
  2863. */
  2864. $.ui.plugin.add("resizable", "animate", {
  2865. stop: function( event ) {
  2866. var that = $(this).data("ui-resizable"),
  2867. o = that.options,
  2868. pr = that._proportionallyResizeElements,
  2869. ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  2870. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height,
  2871. soffsetw = ista ? 0 : that.sizeDiff.width,
  2872. style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  2873. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null,
  2874. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  2875. that.element.animate(
  2876. $.extend(style, top && left ? { top: top, left: left } : {}), {
  2877. duration: o.animateDuration,
  2878. easing: o.animateEasing,
  2879. step: function() {
  2880. var data = {
  2881. width: parseInt(that.element.css("width"), 10),
  2882. height: parseInt(that.element.css("height"), 10),
  2883. top: parseInt(that.element.css("top"), 10),
  2884. left: parseInt(that.element.css("left"), 10)
  2885. };
  2886. if (pr && pr.length) {
  2887. $(pr[0]).css({ width: data.width, height: data.height });
  2888. }
  2889. // propagating resize, and updating values for each animation step
  2890. that._updateCache(data);
  2891. that._propagate("resize", event);
  2892. }
  2893. }
  2894. );
  2895. }
  2896. });
  2897. $.ui.plugin.add("resizable", "containment", {
  2898. start: function() {
  2899. var element, p, co, ch, cw, width, height,
  2900. that = $(this).data("ui-resizable"),
  2901. o = that.options,
  2902. el = that.element,
  2903. oc = o.containment,
  2904. ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
  2905. if (!ce) {
  2906. return;
  2907. }
  2908. that.containerElement = $(ce);
  2909. if (/document/.test(oc) || oc === document) {
  2910. that.containerOffset = { left: 0, top: 0 };
  2911. that.containerPosition = { left: 0, top: 0 };
  2912. that.parentData = {
  2913. element: $(document), left: 0, top: 0,
  2914. width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
  2915. };
  2916. }
  2917. // i'm a node, so compute top, left, right, bottom
  2918. else {
  2919. element = $(ce);
  2920. p = [];
  2921. $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
  2922. that.containerOffset = element.offset();
  2923. that.containerPosition = element.position();
  2924. that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
  2925. co = that.containerOffset;
  2926. ch = that.containerSize.height;
  2927. cw = that.containerSize.width;
  2928. width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw );
  2929. height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
  2930. that.parentData = {
  2931. element: ce, left: co.left, top: co.top, width: width, height: height
  2932. };
  2933. }
  2934. },
  2935. resize: function( event ) {
  2936. var woset, hoset, isParent, isOffsetRelative,
  2937. that = $(this).data("ui-resizable"),
  2938. o = that.options,
  2939. co = that.containerOffset, cp = that.position,
  2940. pRatio = that._aspectRatio || event.shiftKey,
  2941. cop = { top:0, left:0 }, ce = that.containerElement;
  2942. if (ce[0] !== document && (/static/).test(ce.css("position"))) {
  2943. cop = co;
  2944. }
  2945. if (cp.left < (that._helper ? co.left : 0)) {
  2946. that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left));
  2947. if (pRatio) {
  2948. that.size.height = that.size.width / that.aspectRatio;
  2949. }
  2950. that.position.left = o.helper ? co.left : 0;
  2951. }
  2952. if (cp.top < (that._helper ? co.top : 0)) {
  2953. that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top);
  2954. if (pRatio) {
  2955. that.size.width = that.size.height * that.aspectRatio;
  2956. }
  2957. that.position.top = that._helper ? co.top : 0;
  2958. }
  2959. that.offset.left = that.parentData.left+that.position.left;
  2960. that.offset.top = that.parentData.top+that.position.top;
  2961. woset = Math.abs( (that._helper ? that.offset.left - cop.left : (that.offset.left - cop.left)) + that.sizeDiff.width );
  2962. hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height );
  2963. isParent = that.containerElement.get(0) === that.element.parent().get(0);
  2964. isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position"));
  2965. if(isParent && isOffsetRelative) {
  2966. woset -= that.parentData.left;
  2967. }
  2968. if (woset + that.size.width >= that.parentData.width) {
  2969. that.size.width = that.parentData.width - woset;
  2970. if (pRatio) {
  2971. that.size.height = that.size.width / that.aspectRatio;
  2972. }
  2973. }
  2974. if (hoset + that.size.height >= that.parentData.height) {
  2975. that.size.height = that.parentData.height - hoset;
  2976. if (pRatio) {
  2977. that.size.width = that.size.height * that.aspectRatio;
  2978. }
  2979. }
  2980. },
  2981. stop: function(){
  2982. var that = $(this).data("ui-resizable"),
  2983. o = that.options,
  2984. co = that.containerOffset,
  2985. cop = that.containerPosition,
  2986. ce = that.containerElement,
  2987. helper = $(that.helper),
  2988. ho = helper.offset(),
  2989. w = helper.outerWidth() - that.sizeDiff.width,
  2990. h = helper.outerHeight() - that.sizeDiff.height;
  2991. if (that._helper && !o.animate && (/relative/).test(ce.css("position"))) {
  2992. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2993. }
  2994. if (that._helper && !o.animate && (/static/).test(ce.css("position"))) {
  2995. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2996. }
  2997. }
  2998. });
  2999. $.ui.plugin.add("resizable", "alsoResize", {
  3000. start: function () {
  3001. var that = $(this).data("ui-resizable"),
  3002. o = that.options,
  3003. _store = function (exp) {
  3004. $(exp).each(function() {
  3005. var el = $(this);
  3006. el.data("ui-resizable-alsoresize", {
  3007. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  3008. left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
  3009. });
  3010. });
  3011. };
  3012. if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) {
  3013. if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
  3014. else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
  3015. }else{
  3016. _store(o.alsoResize);
  3017. }
  3018. },
  3019. resize: function (event, ui) {
  3020. var that = $(this).data("ui-resizable"),
  3021. o = that.options,
  3022. os = that.originalSize,
  3023. op = that.originalPosition,
  3024. delta = {
  3025. height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
  3026. top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
  3027. },
  3028. _alsoResize = function (exp, c) {
  3029. $(exp).each(function() {
  3030. var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
  3031. css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ["width", "height"] : ["width", "height", "top", "left"];
  3032. $.each(css, function (i, prop) {
  3033. var sum = (start[prop]||0) + (delta[prop]||0);
  3034. if (sum && sum >= 0) {
  3035. style[prop] = sum || null;
  3036. }
  3037. });
  3038. el.css(style);
  3039. });
  3040. };
  3041. if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) {
  3042. $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
  3043. }else{
  3044. _alsoResize(o.alsoResize);
  3045. }
  3046. },
  3047. stop: function () {
  3048. $(this).removeData("resizable-alsoresize");
  3049. }
  3050. });
  3051. $.ui.plugin.add("resizable", "ghost", {
  3052. start: function() {
  3053. var that = $(this).data("ui-resizable"), o = that.options, cs = that.size;
  3054. that.ghost = that.originalElement.clone();
  3055. that.ghost
  3056. .css({ opacity: 0.25, display: "block", position: "relative", height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
  3057. .addClass("ui-resizable-ghost")
  3058. .addClass(typeof o.ghost === "string" ? o.ghost : "");
  3059. that.ghost.appendTo(that.helper);
  3060. },
  3061. resize: function(){
  3062. var that = $(this).data("ui-resizable");
  3063. if (that.ghost) {
  3064. that.ghost.css({ position: "relative", height: that.size.height, width: that.size.width });
  3065. }
  3066. },
  3067. stop: function() {
  3068. var that = $(this).data("ui-resizable");
  3069. if (that.ghost && that.helper) {
  3070. that.helper.get(0).removeChild(that.ghost.get(0));
  3071. }
  3072. }
  3073. });
  3074. $.ui.plugin.add("resizable", "grid", {
  3075. resize: function() {
  3076. var that = $(this).data("ui-resizable"),
  3077. o = that.options,
  3078. cs = that.size,
  3079. os = that.originalSize,
  3080. op = that.originalPosition,
  3081. a = that.axis,
  3082. grid = typeof o.grid === "number" ? [o.grid, o.grid] : o.grid,
  3083. gridX = (grid[0]||1),
  3084. gridY = (grid[1]||1),
  3085. ox = Math.round((cs.width - os.width) / gridX) * gridX,
  3086. oy = Math.round((cs.height - os.height) / gridY) * gridY,
  3087. newWidth = os.width + ox,
  3088. newHeight = os.height + oy,
  3089. isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
  3090. isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
  3091. isMinWidth = o.minWidth && (o.minWidth > newWidth),
  3092. isMinHeight = o.minHeight && (o.minHeight > newHeight);
  3093. o.grid = grid;
  3094. if (isMinWidth) {
  3095. newWidth = newWidth + gridX;
  3096. }
  3097. if (isMinHeight) {
  3098. newHeight = newHeight + gridY;
  3099. }
  3100. if (isMaxWidth) {
  3101. newWidth = newWidth - gridX;
  3102. }
  3103. if (isMaxHeight) {
  3104. newHeight = newHeight - gridY;
  3105. }
  3106. if (/^(se|s|e)$/.test(a)) {
  3107. that.size.width = newWidth;
  3108. that.size.height = newHeight;
  3109. } else if (/^(ne)$/.test(a)) {
  3110. that.size.width = newWidth;
  3111. that.size.height = newHeight;
  3112. that.position.top = op.top - oy;
  3113. } else if (/^(sw)$/.test(a)) {
  3114. that.size.width = newWidth;
  3115. that.size.height = newHeight;
  3116. that.position.left = op.left - ox;
  3117. } else {
  3118. that.size.width = newWidth;
  3119. that.size.height = newHeight;
  3120. that.position.top = op.top - oy;
  3121. that.position.left = op.left - ox;
  3122. }
  3123. }
  3124. });
  3125. })(jQuery);
  3126. (function( $, undefined ) {
  3127. $.widget("ui.selectable", $.ui.mouse, {
  3128. version: "1.10.3",
  3129. options: {
  3130. appendTo: "body",
  3131. autoRefresh: true,
  3132. distance: 0,
  3133. filter: "*",
  3134. tolerance: "touch",
  3135. // callbacks
  3136. selected: null,
  3137. selecting: null,
  3138. start: null,
  3139. stop: null,
  3140. unselected: null,
  3141. unselecting: null
  3142. },
  3143. _create: function() {
  3144. var selectees,
  3145. that = this;
  3146. this.element.addClass("ui-selectable");
  3147. this.dragged = false;
  3148. // cache selectee children based on filter
  3149. this.refresh = function() {
  3150. selectees = $(that.options.filter, that.element[0]);
  3151. selectees.addClass("ui-selectee");
  3152. selectees.each(function() {
  3153. var $this = $(this),
  3154. pos = $this.offset();
  3155. $.data(this, "selectable-item", {
  3156. element: this,
  3157. $element: $this,
  3158. left: pos.left,
  3159. top: pos.top,
  3160. right: pos.left + $this.outerWidth(),
  3161. bottom: pos.top + $this.outerHeight(),
  3162. startselected: false,
  3163. selected: $this.hasClass("ui-selected"),
  3164. selecting: $this.hasClass("ui-selecting"),
  3165. unselecting: $this.hasClass("ui-unselecting")
  3166. });
  3167. });
  3168. };
  3169. this.refresh();
  3170. this.selectees = selectees.addClass("ui-selectee");
  3171. this._mouseInit();
  3172. this.helper = $("<div class='ui-selectable-helper'></div>");
  3173. },
  3174. _destroy: function() {
  3175. this.selectees
  3176. .removeClass("ui-selectee")
  3177. .removeData("selectable-item");
  3178. this.element
  3179. .removeClass("ui-selectable ui-selectable-disabled");
  3180. this._mouseDestroy();
  3181. },
  3182. _mouseStart: function(event) {
  3183. var that = this,
  3184. options = this.options;
  3185. this.opos = [event.pageX, event.pageY];
  3186. if (this.options.disabled) {
  3187. return;
  3188. }
  3189. this.selectees = $(options.filter, this.element[0]);
  3190. this._trigger("start", event);
  3191. $(options.appendTo).append(this.helper);
  3192. // position helper (lasso)
  3193. this.helper.css({
  3194. "left": event.pageX,
  3195. "top": event.pageY,
  3196. "width": 0,
  3197. "height": 0
  3198. });
  3199. if (options.autoRefresh) {
  3200. this.refresh();
  3201. }
  3202. this.selectees.filter(".ui-selected").each(function() {
  3203. var selectee = $.data(this, "selectable-item");
  3204. selectee.startselected = true;
  3205. if (!event.metaKey && !event.ctrlKey) {
  3206. selectee.$element.removeClass("ui-selected");
  3207. selectee.selected = false;
  3208. selectee.$element.addClass("ui-unselecting");
  3209. selectee.unselecting = true;
  3210. // selectable UNSELECTING callback
  3211. that._trigger("unselecting", event, {
  3212. unselecting: selectee.element
  3213. });
  3214. }
  3215. });
  3216. $(event.target).parents().addBack().each(function() {
  3217. var doSelect,
  3218. selectee = $.data(this, "selectable-item");
  3219. if (selectee) {
  3220. doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
  3221. selectee.$element
  3222. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  3223. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  3224. selectee.unselecting = !doSelect;
  3225. selectee.selecting = doSelect;
  3226. selectee.selected = doSelect;
  3227. // selectable (UN)SELECTING callback
  3228. if (doSelect) {
  3229. that._trigger("selecting", event, {
  3230. selecting: selectee.element
  3231. });
  3232. } else {
  3233. that._trigger("unselecting", event, {
  3234. unselecting: selectee.element
  3235. });
  3236. }
  3237. return false;
  3238. }
  3239. });
  3240. },
  3241. _mouseDrag: function(event) {
  3242. this.dragged = true;
  3243. if (this.options.disabled) {
  3244. return;
  3245. }
  3246. var tmp,
  3247. that = this,
  3248. options = this.options,
  3249. x1 = this.opos[0],
  3250. y1 = this.opos[1],
  3251. x2 = event.pageX,
  3252. y2 = event.pageY;
  3253. if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
  3254. if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
  3255. this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
  3256. this.selectees.each(function() {
  3257. var selectee = $.data(this, "selectable-item"),
  3258. hit = false;
  3259. //prevent helper from being selected if appendTo: selectable
  3260. if (!selectee || selectee.element === that.element[0]) {
  3261. return;
  3262. }
  3263. if (options.tolerance === "touch") {
  3264. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  3265. } else if (options.tolerance === "fit") {
  3266. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  3267. }
  3268. if (hit) {
  3269. // SELECT
  3270. if (selectee.selected) {
  3271. selectee.$element.removeClass("ui-selected");
  3272. selectee.selected = false;
  3273. }
  3274. if (selectee.unselecting) {
  3275. selectee.$element.removeClass("ui-unselecting");
  3276. selectee.unselecting = false;
  3277. }
  3278. if (!selectee.selecting) {
  3279. selectee.$element.addClass("ui-selecting");
  3280. selectee.selecting = true;
  3281. // selectable SELECTING callback
  3282. that._trigger("selecting", event, {
  3283. selecting: selectee.element
  3284. });
  3285. }
  3286. } else {
  3287. // UNSELECT
  3288. if (selectee.selecting) {
  3289. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  3290. selectee.$element.removeClass("ui-selecting");
  3291. selectee.selecting = false;
  3292. selectee.$element.addClass("ui-selected");
  3293. selectee.selected = true;
  3294. } else {
  3295. selectee.$element.removeClass("ui-selecting");
  3296. selectee.selecting = false;
  3297. if (selectee.startselected) {
  3298. selectee.$element.addClass("ui-unselecting");
  3299. selectee.unselecting = true;
  3300. }
  3301. // selectable UNSELECTING callback
  3302. that._trigger("unselecting", event, {
  3303. unselecting: selectee.element
  3304. });
  3305. }
  3306. }
  3307. if (selectee.selected) {
  3308. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  3309. selectee.$element.removeClass("ui-selected");
  3310. selectee.selected = false;
  3311. selectee.$element.addClass("ui-unselecting");
  3312. selectee.unselecting = true;
  3313. // selectable UNSELECTING callback
  3314. that._trigger("unselecting", event, {
  3315. unselecting: selectee.element
  3316. });
  3317. }
  3318. }
  3319. }
  3320. });
  3321. return false;
  3322. },
  3323. _mouseStop: function(event) {
  3324. var that = this;
  3325. this.dragged = false;
  3326. $(".ui-unselecting", this.element[0]).each(function() {
  3327. var selectee = $.data(this, "selectable-item");
  3328. selectee.$element.removeClass("ui-unselecting");
  3329. selectee.unselecting = false;
  3330. selectee.startselected = false;
  3331. that._trigger("unselected", event, {
  3332. unselected: selectee.element
  3333. });
  3334. });
  3335. $(".ui-selecting", this.element[0]).each(function() {
  3336. var selectee = $.data(this, "selectable-item");
  3337. selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
  3338. selectee.selecting = false;
  3339. selectee.selected = true;
  3340. selectee.startselected = true;
  3341. that._trigger("selected", event, {
  3342. selected: selectee.element
  3343. });
  3344. });
  3345. this._trigger("stop", event);
  3346. this.helper.remove();
  3347. return false;
  3348. }
  3349. });
  3350. })(jQuery);
  3351. (function( $, undefined ) {
  3352. /*jshint loopfunc: true */
  3353. function isOverAxis( x, reference, size ) {
  3354. return ( x > reference ) && ( x < ( reference + size ) );
  3355. }
  3356. function isFloating(item) {
  3357. return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
  3358. }
  3359. $.widget("ui.sortable", $.ui.mouse, {
  3360. version: "1.10.3",
  3361. widgetEventPrefix: "sort",
  3362. ready: false,
  3363. options: {
  3364. appendTo: "parent",
  3365. axis: false,
  3366. connectWith: false,
  3367. containment: false,
  3368. cursor: "auto",
  3369. cursorAt: false,
  3370. dropOnEmpty: true,
  3371. forcePlaceholderSize: false,
  3372. forceHelperSize: false,
  3373. grid: false,
  3374. handle: false,
  3375. helper: "original",
  3376. items: "> *",
  3377. opacity: false,
  3378. placeholder: false,
  3379. revert: false,
  3380. scroll: true,
  3381. scrollSensitivity: 20,
  3382. scrollSpeed: 20,
  3383. scope: "default",
  3384. tolerance: "intersect",
  3385. zIndex: 1000,
  3386. // callbacks
  3387. activate: null,
  3388. beforeStop: null,
  3389. change: null,
  3390. deactivate: null,
  3391. out: null,
  3392. over: null,
  3393. receive: null,
  3394. remove: null,
  3395. sort: null,
  3396. start: null,
  3397. stop: null,
  3398. update: null
  3399. },
  3400. _create: function() {
  3401. var o = this.options;
  3402. this.containerCache = {};
  3403. this.element.addClass("ui-sortable");
  3404. //Get the items
  3405. this.refresh();
  3406. //Let's determine if the items are being displayed horizontally
  3407. this.floating = this.items.length ? o.axis === "x" || isFloating(this.items[0].item) : false;
  3408. //Let's determine the parent's offset
  3409. this.offset = this.element.offset();
  3410. //Initialize mouse events for interaction
  3411. this._mouseInit();
  3412. //We're ready to go
  3413. this.ready = true;
  3414. },
  3415. _destroy: function() {
  3416. this.element
  3417. .removeClass("ui-sortable ui-sortable-disabled");
  3418. this._mouseDestroy();
  3419. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  3420. this.items[i].item.removeData(this.widgetName + "-item");
  3421. }
  3422. return this;
  3423. },
  3424. _setOption: function(key, value){
  3425. if ( key === "disabled" ) {
  3426. this.options[ key ] = value;
  3427. this.widget().toggleClass( "ui-sortable-disabled", !!value );
  3428. } else {
  3429. // Don't call widget base _setOption for disable as it adds ui-state-disabled class
  3430. $.Widget.prototype._setOption.apply(this, arguments);
  3431. }
  3432. },
  3433. _mouseCapture: function(event, overrideHandle) {
  3434. var currentItem = null,
  3435. validHandle = false,
  3436. that = this;
  3437. if (this.reverting) {
  3438. return false;
  3439. }
  3440. if(this.options.disabled || this.options.type === "static") {
  3441. return false;
  3442. }
  3443. //We have to refresh the items data once first
  3444. this._refreshItems(event);
  3445. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  3446. $(event.target).parents().each(function() {
  3447. if($.data(this, that.widgetName + "-item") === that) {
  3448. currentItem = $(this);
  3449. return false;
  3450. }
  3451. });
  3452. if($.data(event.target, that.widgetName + "-item") === that) {
  3453. currentItem = $(event.target);
  3454. }
  3455. if(!currentItem) {
  3456. return false;
  3457. }
  3458. if(this.options.handle && !overrideHandle) {
  3459. $(this.options.handle, currentItem).find("*").addBack().each(function() {
  3460. if(this === event.target) {
  3461. validHandle = true;
  3462. }
  3463. });
  3464. if(!validHandle) {
  3465. return false;
  3466. }
  3467. }
  3468. this.currentItem = currentItem;
  3469. this._removeCurrentsFromItems();
  3470. return true;
  3471. },
  3472. _mouseStart: function(event, overrideHandle, noActivation) {
  3473. var i, body,
  3474. o = this.options;
  3475. this.currentContainer = this;
  3476. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  3477. this.refreshPositions();
  3478. //Create and append the visible helper
  3479. this.helper = this._createHelper(event);
  3480. //Cache the helper size
  3481. this._cacheHelperProportions();
  3482. /*
  3483. * - Position generation -
  3484. * This block generates everything position related - it's the core of draggables.
  3485. */
  3486. //Cache the margins of the original element
  3487. this._cacheMargins();
  3488. //Get the next scrolling parent
  3489. this.scrollParent = this.helper.scrollParent();
  3490. //The element's absolute position on the page minus margins
  3491. this.offset = this.currentItem.offset();
  3492. this.offset = {
  3493. top: this.offset.top - this.margins.top,
  3494. left: this.offset.left - this.margins.left
  3495. };
  3496. $.extend(this.offset, {
  3497. click: { //Where the click happened, relative to the element
  3498. left: event.pageX - this.offset.left,
  3499. top: event.pageY - this.offset.top
  3500. },
  3501. parent: this._getParentOffset(),
  3502. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  3503. });
  3504. // Only after we got the offset, we can change the helper's position to absolute
  3505. // TODO: Still need to figure out a way to make relative sorting possible
  3506. this.helper.css("position", "absolute");
  3507. this.cssPosition = this.helper.css("position");
  3508. //Generate the original position
  3509. this.originalPosition = this._generatePosition(event);
  3510. this.originalPageX = event.pageX;
  3511. this.originalPageY = event.pageY;
  3512. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  3513. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  3514. //Cache the former DOM position
  3515. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  3516. //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
  3517. if(this.helper[0] !== this.currentItem[0]) {
  3518. this.currentItem.hide();
  3519. }
  3520. //Create the placeholder
  3521. this._createPlaceholder();
  3522. //Set a containment if given in the options
  3523. if(o.containment) {
  3524. this._setContainment();
  3525. }
  3526. if( o.cursor && o.cursor !== "auto" ) { // cursor option
  3527. body = this.document.find( "body" );
  3528. // support: IE
  3529. this.storedCursor = body.css( "cursor" );
  3530. body.css( "cursor", o.cursor );
  3531. this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
  3532. }
  3533. if(o.opacity) { // opacity option
  3534. if (this.helper.css("opacity")) {
  3535. this._storedOpacity = this.helper.css("opacity");
  3536. }
  3537. this.helper.css("opacity", o.opacity);
  3538. }
  3539. if(o.zIndex) { // zIndex option
  3540. if (this.helper.css("zIndex")) {
  3541. this._storedZIndex = this.helper.css("zIndex");
  3542. }
  3543. this.helper.css("zIndex", o.zIndex);
  3544. }
  3545. //Prepare scrolling
  3546. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  3547. this.overflowOffset = this.scrollParent.offset();
  3548. }
  3549. //Call callbacks
  3550. this._trigger("start", event, this._uiHash());
  3551. //Recache the helper size
  3552. if(!this._preserveHelperProportions) {
  3553. this._cacheHelperProportions();
  3554. }
  3555. //Post "activate" events to possible containers
  3556. if( !noActivation ) {
  3557. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  3558. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  3559. }
  3560. }
  3561. //Prepare possible droppables
  3562. if($.ui.ddmanager) {
  3563. $.ui.ddmanager.current = this;
  3564. }
  3565. if ($.ui.ddmanager && !o.dropBehaviour) {
  3566. $.ui.ddmanager.prepareOffsets(this, event);
  3567. }
  3568. this.dragging = true;
  3569. this.helper.addClass("ui-sortable-helper");
  3570. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  3571. return true;
  3572. },
  3573. _mouseDrag: function(event) {
  3574. var i, item, itemElement, intersection,
  3575. o = this.options,
  3576. scrolled = false;
  3577. //Compute the helpers position
  3578. this.position = this._generatePosition(event);
  3579. this.positionAbs = this._convertPositionTo("absolute");
  3580. if (!this.lastPositionAbs) {
  3581. this.lastPositionAbs = this.positionAbs;
  3582. }
  3583. //Do scrolling
  3584. if(this.options.scroll) {
  3585. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  3586. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  3587. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  3588. } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
  3589. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  3590. }
  3591. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  3592. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  3593. } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
  3594. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  3595. }
  3596. } else {
  3597. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  3598. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  3599. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  3600. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  3601. }
  3602. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  3603. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  3604. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  3605. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  3606. }
  3607. }
  3608. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  3609. $.ui.ddmanager.prepareOffsets(this, event);
  3610. }
  3611. }
  3612. //Regenerate the absolute position used for position checks
  3613. this.positionAbs = this._convertPositionTo("absolute");
  3614. //Set the helper position
  3615. if(!this.options.axis || this.options.axis !== "y") {
  3616. this.helper[0].style.left = this.position.left+"px";
  3617. }
  3618. if(!this.options.axis || this.options.axis !== "x") {
  3619. this.helper[0].style.top = this.position.top+"px";
  3620. }
  3621. //Rearrange
  3622. for (i = this.items.length - 1; i >= 0; i--) {
  3623. //Cache variables and intersection, continue if no intersection
  3624. item = this.items[i];
  3625. itemElement = item.item[0];
  3626. intersection = this._intersectsWithPointer(item);
  3627. if (!intersection) {
  3628. continue;
  3629. }
  3630. // Only put the placeholder inside the current Container, skip all
  3631. // items form other containers. This works because when moving
  3632. // an item from one container to another the
  3633. // currentContainer is switched before the placeholder is moved.
  3634. //
  3635. // Without this moving items in "sub-sortables" can cause the placeholder to jitter
  3636. // beetween the outer and inner container.
  3637. if (item.instance !== this.currentContainer) {
  3638. continue;
  3639. }
  3640. // cannot intersect with itself
  3641. // no useless actions that have been done before
  3642. // no action if the item moved is the parent of the item checked
  3643. if (itemElement !== this.currentItem[0] &&
  3644. this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
  3645. !$.contains(this.placeholder[0], itemElement) &&
  3646. (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
  3647. ) {
  3648. this.direction = intersection === 1 ? "down" : "up";
  3649. if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
  3650. this._rearrange(event, item);
  3651. } else {
  3652. break;
  3653. }
  3654. this._trigger("change", event, this._uiHash());
  3655. break;
  3656. }
  3657. }
  3658. //Post events to containers
  3659. this._contactContainers(event);
  3660. //Interconnect with droppables
  3661. if($.ui.ddmanager) {
  3662. $.ui.ddmanager.drag(this, event);
  3663. }
  3664. //Call callbacks
  3665. this._trigger("sort", event, this._uiHash());
  3666. this.lastPositionAbs = this.positionAbs;
  3667. return false;
  3668. },
  3669. _mouseStop: function(event, noPropagation) {
  3670. if(!event) {
  3671. return;
  3672. }
  3673. //If we are using droppables, inform the manager about the drop
  3674. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  3675. $.ui.ddmanager.drop(this, event);
  3676. }
  3677. if(this.options.revert) {
  3678. var that = this,
  3679. cur = this.placeholder.offset(),
  3680. axis = this.options.axis,
  3681. animation = {};
  3682. if ( !axis || axis === "x" ) {
  3683. animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
  3684. }
  3685. if ( !axis || axis === "y" ) {
  3686. animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
  3687. }
  3688. this.reverting = true;
  3689. $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
  3690. that._clear(event);
  3691. });
  3692. } else {
  3693. this._clear(event, noPropagation);
  3694. }
  3695. return false;
  3696. },
  3697. cancel: function() {
  3698. if(this.dragging) {
  3699. this._mouseUp({ target: null });
  3700. if(this.options.helper === "original") {
  3701. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  3702. } else {
  3703. this.currentItem.show();
  3704. }
  3705. //Post deactivating events to containers
  3706. for (var i = this.containers.length - 1; i >= 0; i--){
  3707. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  3708. if(this.containers[i].containerCache.over) {
  3709. this.containers[i]._trigger("out", null, this._uiHash(this));
  3710. this.containers[i].containerCache.over = 0;
  3711. }
  3712. }
  3713. }
  3714. if (this.placeholder) {
  3715. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  3716. if(this.placeholder[0].parentNode) {
  3717. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  3718. }
  3719. if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
  3720. this.helper.remove();
  3721. }
  3722. $.extend(this, {
  3723. helper: null,
  3724. dragging: false,
  3725. reverting: false,
  3726. _noFinalSort: null
  3727. });
  3728. if(this.domPosition.prev) {
  3729. $(this.domPosition.prev).after(this.currentItem);
  3730. } else {
  3731. $(this.domPosition.parent).prepend(this.currentItem);
  3732. }
  3733. }
  3734. return this;
  3735. },
  3736. serialize: function(o) {
  3737. var items = this._getItemsAsjQuery(o && o.connected),
  3738. str = [];
  3739. o = o || {};
  3740. $(items).each(function() {
  3741. var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
  3742. if (res) {
  3743. str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
  3744. }
  3745. });
  3746. if(!str.length && o.key) {
  3747. str.push(o.key + "=");
  3748. }
  3749. return str.join("&");
  3750. },
  3751. toArray: function(o) {
  3752. var items = this._getItemsAsjQuery(o && o.connected),
  3753. ret = [];
  3754. o = o || {};
  3755. items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
  3756. return ret;
  3757. },
  3758. /* Be careful with the following core functions */
  3759. _intersectsWith: function(item) {
  3760. var x1 = this.positionAbs.left,
  3761. x2 = x1 + this.helperProportions.width,
  3762. y1 = this.positionAbs.top,
  3763. y2 = y1 + this.helperProportions.height,
  3764. l = item.left,
  3765. r = l + item.width,
  3766. t = item.top,
  3767. b = t + item.height,
  3768. dyClick = this.offset.click.top,
  3769. dxClick = this.offset.click.left,
  3770. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
  3771. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
  3772. isOverElement = isOverElementHeight && isOverElementWidth;
  3773. if ( this.options.tolerance === "pointer" ||
  3774. this.options.forcePointerForContainers ||
  3775. (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
  3776. ) {
  3777. return isOverElement;
  3778. } else {
  3779. return (l < x1 + (this.helperProportions.width / 2) && // Right Half
  3780. x2 - (this.helperProportions.width / 2) < r && // Left Half
  3781. t < y1 + (this.helperProportions.height / 2) && // Bottom Half
  3782. y2 - (this.helperProportions.height / 2) < b ); // Top Half
  3783. }
  3784. },
  3785. _intersectsWithPointer: function(item) {
  3786. var isOverElementHeight = (this.options.axis === "x") || isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  3787. isOverElementWidth = (this.options.axis === "y") || isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  3788. isOverElement = isOverElementHeight && isOverElementWidth,
  3789. verticalDirection = this._getDragVerticalDirection(),
  3790. horizontalDirection = this._getDragHorizontalDirection();
  3791. if (!isOverElement) {
  3792. return false;
  3793. }
  3794. return this.floating ?
  3795. ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
  3796. : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
  3797. },
  3798. _intersectsWithSides: function(item) {
  3799. var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  3800. isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  3801. verticalDirection = this._getDragVerticalDirection(),
  3802. horizontalDirection = this._getDragHorizontalDirection();
  3803. if (this.floating && horizontalDirection) {
  3804. return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
  3805. } else {
  3806. return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
  3807. }
  3808. },
  3809. _getDragVerticalDirection: function() {
  3810. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  3811. return delta !== 0 && (delta > 0 ? "down" : "up");
  3812. },
  3813. _getDragHorizontalDirection: function() {
  3814. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  3815. return delta !== 0 && (delta > 0 ? "right" : "left");
  3816. },
  3817. refresh: function(event) {
  3818. this._refreshItems(event);
  3819. this.refreshPositions();
  3820. return this;
  3821. },
  3822. _connectWith: function() {
  3823. var options = this.options;
  3824. return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
  3825. },
  3826. _getItemsAsjQuery: function(connected) {
  3827. var i, j, cur, inst,
  3828. items = [],
  3829. queries = [],
  3830. connectWith = this._connectWith();
  3831. if(connectWith && connected) {
  3832. for (i = connectWith.length - 1; i >= 0; i--){
  3833. cur = $(connectWith[i]);
  3834. for ( j = cur.length - 1; j >= 0; j--){
  3835. inst = $.data(cur[j], this.widgetFullName);
  3836. if(inst && inst !== this && !inst.options.disabled) {
  3837. 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]);
  3838. }
  3839. }
  3840. }
  3841. }
  3842. 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]);
  3843. for (i = queries.length - 1; i >= 0; i--){
  3844. queries[i][0].each(function() {
  3845. items.push(this);
  3846. });
  3847. }
  3848. return $(items);
  3849. },
  3850. _removeCurrentsFromItems: function() {
  3851. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  3852. this.items = $.grep(this.items, function (item) {
  3853. for (var j=0; j < list.length; j++) {
  3854. if(list[j] === item.item[0]) {
  3855. return false;
  3856. }
  3857. }
  3858. return true;
  3859. });
  3860. },
  3861. _refreshItems: function(event) {
  3862. this.items = [];
  3863. this.containers = [this];
  3864. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  3865. items = this.items,
  3866. queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
  3867. connectWith = this._connectWith();
  3868. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  3869. for (i = connectWith.length - 1; i >= 0; i--){
  3870. cur = $(connectWith[i]);
  3871. for (j = cur.length - 1; j >= 0; j--){
  3872. inst = $.data(cur[j], this.widgetFullName);
  3873. if(inst && inst !== this && !inst.options.disabled) {
  3874. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  3875. this.containers.push(inst);
  3876. }
  3877. }
  3878. }
  3879. }
  3880. for (i = queries.length - 1; i >= 0; i--) {
  3881. targetData = queries[i][1];
  3882. _queries = queries[i][0];
  3883. for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  3884. item = $(_queries[j]);
  3885. item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
  3886. items.push({
  3887. item: item,
  3888. instance: targetData,
  3889. width: 0, height: 0,
  3890. left: 0, top: 0
  3891. });
  3892. }
  3893. }
  3894. },
  3895. refreshPositions: function(fast) {
  3896. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  3897. if(this.offsetParent && this.helper) {
  3898. this.offset.parent = this._getParentOffset();
  3899. }
  3900. var i, item, t, p;
  3901. for (i = this.items.length - 1; i >= 0; i--){
  3902. item = this.items[i];
  3903. //We ignore calculating positions of all connected containers when we're not over them
  3904. if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
  3905. continue;
  3906. }
  3907. t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  3908. if (!fast) {
  3909. item.width = t.outerWidth();
  3910. item.height = t.outerHeight();
  3911. }
  3912. p = t.offset();
  3913. item.left = p.left;
  3914. item.top = p.top;
  3915. }
  3916. if(this.options.custom && this.options.custom.refreshContainers) {
  3917. this.options.custom.refreshContainers.call(this);
  3918. } else {
  3919. for (i = this.containers.length - 1; i >= 0; i--){
  3920. p = this.containers[i].element.offset();
  3921. this.containers[i].containerCache.left = p.left;
  3922. this.containers[i].containerCache.top = p.top;
  3923. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  3924. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  3925. }
  3926. }
  3927. return this;
  3928. },
  3929. _createPlaceholder: function(that) {
  3930. that = that || this;
  3931. var className,
  3932. o = that.options;
  3933. if(!o.placeholder || o.placeholder.constructor === String) {
  3934. className = o.placeholder;
  3935. o.placeholder = {
  3936. element: function() {
  3937. var nodeName = that.currentItem[0].nodeName.toLowerCase(),
  3938. element = $( "<" + nodeName + ">", that.document[0] )
  3939. .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
  3940. .removeClass("ui-sortable-helper");
  3941. if ( nodeName === "tr" ) {
  3942. that.currentItem.children().each(function() {
  3943. $( "<td>&#160;</td>", that.document[0] )
  3944. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  3945. .appendTo( element );
  3946. });
  3947. } else if ( nodeName === "img" ) {
  3948. element.attr( "src", that.currentItem.attr( "src" ) );
  3949. }
  3950. if ( !className ) {
  3951. element.css( "visibility", "hidden" );
  3952. }
  3953. return element;
  3954. },
  3955. update: function(container, p) {
  3956. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  3957. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  3958. if(className && !o.forcePlaceholderSize) {
  3959. return;
  3960. }
  3961. //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
  3962. if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
  3963. if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
  3964. }
  3965. };
  3966. }
  3967. //Create the placeholder
  3968. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  3969. //Append it after the actual current item
  3970. that.currentItem.after(that.placeholder);
  3971. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  3972. o.placeholder.update(that, that.placeholder);
  3973. },
  3974. _contactContainers: function(event) {
  3975. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, floating,
  3976. innermostContainer = null,
  3977. innermostIndex = null;
  3978. // get innermost container that intersects with item
  3979. for (i = this.containers.length - 1; i >= 0; i--) {
  3980. // never consider a container that's located within the item itself
  3981. if($.contains(this.currentItem[0], this.containers[i].element[0])) {
  3982. continue;
  3983. }
  3984. if(this._intersectsWith(this.containers[i].containerCache)) {
  3985. // if we've already found a container and it's more "inner" than this, then continue
  3986. if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
  3987. continue;
  3988. }
  3989. innermostContainer = this.containers[i];
  3990. innermostIndex = i;
  3991. } else {
  3992. // container doesn't intersect. trigger "out" event if necessary
  3993. if(this.containers[i].containerCache.over) {
  3994. this.containers[i]._trigger("out", event, this._uiHash(this));
  3995. this.containers[i].containerCache.over = 0;
  3996. }
  3997. }
  3998. }
  3999. // if no intersecting containers found, return
  4000. if(!innermostContainer) {
  4001. return;
  4002. }
  4003. // move the item into the container if it's not there already
  4004. if(this.containers.length === 1) {
  4005. if (!this.containers[innermostIndex].containerCache.over) {
  4006. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  4007. this.containers[innermostIndex].containerCache.over = 1;
  4008. }
  4009. } else {
  4010. //When entering a new container, we will find the item with the least distance and append our item near it
  4011. dist = 10000;
  4012. itemWithLeastDistance = null;
  4013. floating = innermostContainer.floating || isFloating(this.currentItem);
  4014. posProperty = floating ? "left" : "top";
  4015. sizeProperty = floating ? "width" : "height";
  4016. base = this.positionAbs[posProperty] + this.offset.click[posProperty];
  4017. for (j = this.items.length - 1; j >= 0; j--) {
  4018. if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
  4019. continue;
  4020. }
  4021. if(this.items[j].item[0] === this.currentItem[0]) {
  4022. continue;
  4023. }
  4024. if (floating && !isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) {
  4025. continue;
  4026. }
  4027. cur = this.items[j].item.offset()[posProperty];
  4028. nearBottom = false;
  4029. if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){
  4030. nearBottom = true;
  4031. cur += this.items[j][sizeProperty];
  4032. }
  4033. if(Math.abs(cur - base) < dist) {
  4034. dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
  4035. this.direction = nearBottom ? "up": "down";
  4036. }
  4037. }
  4038. //Check if dropOnEmpty is enabled
  4039. if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
  4040. return;
  4041. }
  4042. if(this.currentContainer === this.containers[innermostIndex]) {
  4043. return;
  4044. }
  4045. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  4046. this._trigger("change", event, this._uiHash());
  4047. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  4048. this.currentContainer = this.containers[innermostIndex];
  4049. //Update the placeholder
  4050. this.options.placeholder.update(this.currentContainer, this.placeholder);
  4051. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  4052. this.containers[innermostIndex].containerCache.over = 1;
  4053. }
  4054. },
  4055. _createHelper: function(event) {
  4056. var o = this.options,
  4057. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
  4058. //Add the helper to the DOM if that didn't happen already
  4059. if(!helper.parents("body").length) {
  4060. $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  4061. }
  4062. if(helper[0] === this.currentItem[0]) {
  4063. 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") };
  4064. }
  4065. if(!helper[0].style.width || o.forceHelperSize) {
  4066. helper.width(this.currentItem.width());
  4067. }
  4068. if(!helper[0].style.height || o.forceHelperSize) {
  4069. helper.height(this.currentItem.height());
  4070. }
  4071. return helper;
  4072. },
  4073. _adjustOffsetFromHelper: function(obj) {
  4074. if (typeof obj === "string") {
  4075. obj = obj.split(" ");
  4076. }
  4077. if ($.isArray(obj)) {
  4078. obj = {left: +obj[0], top: +obj[1] || 0};
  4079. }
  4080. if ("left" in obj) {
  4081. this.offset.click.left = obj.left + this.margins.left;
  4082. }
  4083. if ("right" in obj) {
  4084. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  4085. }
  4086. if ("top" in obj) {
  4087. this.offset.click.top = obj.top + this.margins.top;
  4088. }
  4089. if ("bottom" in obj) {
  4090. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  4091. }
  4092. },
  4093. _getParentOffset: function() {
  4094. //Get the offsetParent and cache its position
  4095. this.offsetParent = this.helper.offsetParent();
  4096. var po = this.offsetParent.offset();
  4097. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  4098. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  4099. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  4100. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  4101. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  4102. po.left += this.scrollParent.scrollLeft();
  4103. po.top += this.scrollParent.scrollTop();
  4104. }
  4105. // This needs to be actually done for all browsers, since pageX/pageY includes this information
  4106. // with an ugly IE fix
  4107. if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  4108. po = { top: 0, left: 0 };
  4109. }
  4110. return {
  4111. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  4112. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  4113. };
  4114. },
  4115. _getRelativeOffset: function() {
  4116. if(this.cssPosition === "relative") {
  4117. var p = this.currentItem.position();
  4118. return {
  4119. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  4120. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  4121. };
  4122. } else {
  4123. return { top: 0, left: 0 };
  4124. }
  4125. },
  4126. _cacheMargins: function() {
  4127. this.margins = {
  4128. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  4129. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  4130. };
  4131. },
  4132. _cacheHelperProportions: function() {
  4133. this.helperProportions = {
  4134. width: this.helper.outerWidth(),
  4135. height: this.helper.outerHeight()
  4136. };
  4137. },
  4138. _setContainment: function() {
  4139. var ce, co, over,
  4140. o = this.options;
  4141. if(o.containment === "parent") {
  4142. o.containment = this.helper[0].parentNode;
  4143. }
  4144. if(o.containment === "document" || o.containment === "window") {
  4145. this.containment = [
  4146. 0 - this.offset.relative.left - this.offset.parent.left,
  4147. 0 - this.offset.relative.top - this.offset.parent.top,
  4148. $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
  4149. ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  4150. ];
  4151. }
  4152. if(!(/^(document|window|parent)$/).test(o.containment)) {
  4153. ce = $(o.containment)[0];
  4154. co = $(o.containment).offset();
  4155. over = ($(ce).css("overflow") !== "hidden");
  4156. this.containment = [
  4157. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  4158. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  4159. 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,
  4160. 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
  4161. ];
  4162. }
  4163. },
  4164. _convertPositionTo: function(d, pos) {
  4165. if(!pos) {
  4166. pos = this.position;
  4167. }
  4168. var mod = d === "absolute" ? 1 : -1,
  4169. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  4170. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  4171. return {
  4172. top: (
  4173. pos.top + // The absolute mouse position
  4174. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  4175. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  4176. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  4177. ),
  4178. left: (
  4179. pos.left + // The absolute mouse position
  4180. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  4181. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  4182. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  4183. )
  4184. };
  4185. },
  4186. _generatePosition: function(event) {
  4187. var top, left,
  4188. o = this.options,
  4189. pageX = event.pageX,
  4190. pageY = event.pageY,
  4191. 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);
  4192. // This is another very weird special case that only happens for relative elements:
  4193. // 1. If the css position is relative
  4194. // 2. and the scroll parent is the document or similar to the offset parent
  4195. // we have to refresh the relative offset during the scroll so there are no jumps
  4196. if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
  4197. this.offset.relative = this._getRelativeOffset();
  4198. }
  4199. /*
  4200. * - Position constraining -
  4201. * Constrain the position to a mix of grid, containment.
  4202. */
  4203. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  4204. if(this.containment) {
  4205. if(event.pageX - this.offset.click.left < this.containment[0]) {
  4206. pageX = this.containment[0] + this.offset.click.left;
  4207. }
  4208. if(event.pageY - this.offset.click.top < this.containment[1]) {
  4209. pageY = this.containment[1] + this.offset.click.top;
  4210. }
  4211. if(event.pageX - this.offset.click.left > this.containment[2]) {
  4212. pageX = this.containment[2] + this.offset.click.left;
  4213. }
  4214. if(event.pageY - this.offset.click.top > this.containment[3]) {
  4215. pageY = this.containment[3] + this.offset.click.top;
  4216. }
  4217. }
  4218. if(o.grid) {
  4219. top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  4220. 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;
  4221. left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  4222. 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;
  4223. }
  4224. }
  4225. return {
  4226. top: (
  4227. pageY - // The absolute mouse position
  4228. this.offset.click.top - // Click offset (relative to the element)
  4229. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  4230. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  4231. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  4232. ),
  4233. left: (
  4234. pageX - // The absolute mouse position
  4235. this.offset.click.left - // Click offset (relative to the element)
  4236. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  4237. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  4238. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  4239. )
  4240. };
  4241. },
  4242. _rearrange: function(event, i, a, hardRefresh) {
  4243. 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));
  4244. //Various things done here to improve the performance:
  4245. // 1. we create a setTimeout, that calls refreshPositions
  4246. // 2. on the instance, we have a counter variable, that get's higher after every append
  4247. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  4248. // 4. this lets only the last addition to the timeout stack through
  4249. this.counter = this.counter ? ++this.counter : 1;
  4250. var counter = this.counter;
  4251. this._delay(function() {
  4252. if(counter === this.counter) {
  4253. this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  4254. }
  4255. });
  4256. },
  4257. _clear: function(event, noPropagation) {
  4258. this.reverting = false;
  4259. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  4260. // everything else normalized again
  4261. var i,
  4262. delayedTriggers = [];
  4263. // We first have to update the dom position of the actual currentItem
  4264. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  4265. if(!this._noFinalSort && this.currentItem.parent().length) {
  4266. this.placeholder.before(this.currentItem);
  4267. }
  4268. this._noFinalSort = null;
  4269. if(this.helper[0] === this.currentItem[0]) {
  4270. for(i in this._storedCSS) {
  4271. if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
  4272. this._storedCSS[i] = "";
  4273. }
  4274. }
  4275. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  4276. } else {
  4277. this.currentItem.show();
  4278. }
  4279. if(this.fromOutside && !noPropagation) {
  4280. delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  4281. }
  4282. if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
  4283. delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  4284. }
  4285. // Check if the items Container has Changed and trigger appropriate
  4286. // events.
  4287. if (this !== this.currentContainer) {
  4288. if(!noPropagation) {
  4289. delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  4290. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  4291. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  4292. }
  4293. }
  4294. //Post events to containers
  4295. for (i = this.containers.length - 1; i >= 0; i--){
  4296. if(!noPropagation) {
  4297. delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  4298. }
  4299. if(this.containers[i].containerCache.over) {
  4300. delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  4301. this.containers[i].containerCache.over = 0;
  4302. }
  4303. }
  4304. //Do what was originally in plugins
  4305. if ( this.storedCursor ) {
  4306. this.document.find( "body" ).css( "cursor", this.storedCursor );
  4307. this.storedStylesheet.remove();
  4308. }
  4309. if(this._storedOpacity) {
  4310. this.helper.css("opacity", this._storedOpacity);
  4311. }
  4312. if(this._storedZIndex) {
  4313. this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
  4314. }
  4315. this.dragging = false;
  4316. if(this.cancelHelperRemoval) {
  4317. if(!noPropagation) {
  4318. this._trigger("beforeStop", event, this._uiHash());
  4319. for (i=0; i < delayedTriggers.length; i++) {
  4320. delayedTriggers[i].call(this, event);
  4321. } //Trigger all delayed events
  4322. this._trigger("stop", event, this._uiHash());
  4323. }
  4324. this.fromOutside = false;
  4325. return false;
  4326. }
  4327. if(!noPropagation) {
  4328. this._trigger("beforeStop", event, this._uiHash());
  4329. }
  4330. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  4331. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  4332. if(this.helper[0] !== this.currentItem[0]) {
  4333. this.helper.remove();
  4334. }
  4335. this.helper = null;
  4336. if(!noPropagation) {
  4337. for (i=0; i < delayedTriggers.length; i++) {
  4338. delayedTriggers[i].call(this, event);
  4339. } //Trigger all delayed events
  4340. this._trigger("stop", event, this._uiHash());
  4341. }
  4342. this.fromOutside = false;
  4343. return true;
  4344. },
  4345. _trigger: function() {
  4346. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  4347. this.cancel();
  4348. }
  4349. },
  4350. _uiHash: function(_inst) {
  4351. var inst = _inst || this;
  4352. return {
  4353. helper: inst.helper,
  4354. placeholder: inst.placeholder || $([]),
  4355. position: inst.position,
  4356. originalPosition: inst.originalPosition,
  4357. offset: inst.positionAbs,
  4358. item: inst.currentItem,
  4359. sender: _inst ? _inst.element : null
  4360. };
  4361. }
  4362. });
  4363. })(jQuery);
  4364. (function( $, undefined ) {
  4365. // used to prevent race conditions with remote data sources
  4366. var requestIndex = 0;
  4367. $.widget( "ui.autocomplete", {
  4368. version: "1.10.3",
  4369. defaultElement: "<input>",
  4370. options: {
  4371. appendTo: null,
  4372. autoFocus: false,
  4373. delay: 300,
  4374. minLength: 1,
  4375. position: {
  4376. my: "left top",
  4377. at: "left bottom",
  4378. collision: "none"
  4379. },
  4380. source: null,
  4381. // callbacks
  4382. change: null,
  4383. close: null,
  4384. focus: null,
  4385. open: null,
  4386. response: null,
  4387. search: null,
  4388. select: null
  4389. },
  4390. pending: 0,
  4391. _create: function() {
  4392. // Some browsers only repeat keydown events, not keypress events,
  4393. // so we use the suppressKeyPress flag to determine if we've already
  4394. // handled the keydown event. #7269
  4395. // Unfortunately the code for & in keypress is the same as the up arrow,
  4396. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  4397. // events when we know the keydown event was used to modify the
  4398. // search term. #7799
  4399. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  4400. nodeName = this.element[0].nodeName.toLowerCase(),
  4401. isTextarea = nodeName === "textarea",
  4402. isInput = nodeName === "input";
  4403. this.isMultiLine =
  4404. // Textareas are always multi-line
  4405. isTextarea ? true :
  4406. // Inputs are always single-line, even if inside a contentEditable element
  4407. // IE also treats inputs as contentEditable
  4408. isInput ? false :
  4409. // All other element types are determined by whether or not they're contentEditable
  4410. this.element.prop( "isContentEditable" );
  4411. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  4412. this.isNewMenu = true;
  4413. this.element
  4414. .addClass( "ui-autocomplete-input" )
  4415. .attr( "autocomplete", "off" );
  4416. this._on( this.element, {
  4417. keydown: function( event ) {
  4418. /*jshint maxcomplexity:15*/
  4419. if ( this.element.prop( "readOnly" ) ) {
  4420. suppressKeyPress = true;
  4421. suppressInput = true;
  4422. suppressKeyPressRepeat = true;
  4423. return;
  4424. }
  4425. suppressKeyPress = false;
  4426. suppressInput = false;
  4427. suppressKeyPressRepeat = false;
  4428. var keyCode = $.ui.keyCode;
  4429. switch( event.keyCode ) {
  4430. case keyCode.PAGE_UP:
  4431. suppressKeyPress = true;
  4432. this._move( "previousPage", event );
  4433. break;
  4434. case keyCode.PAGE_DOWN:
  4435. suppressKeyPress = true;
  4436. this._move( "nextPage", event );
  4437. break;
  4438. case keyCode.UP:
  4439. suppressKeyPress = true;
  4440. this._keyEvent( "previous", event );
  4441. break;
  4442. case keyCode.DOWN:
  4443. suppressKeyPress = true;
  4444. this._keyEvent( "next", event );
  4445. break;
  4446. case keyCode.ENTER:
  4447. case keyCode.NUMPAD_ENTER:
  4448. // when menu is open and has focus
  4449. if ( this.menu.active ) {
  4450. // #6055 - Opera still allows the keypress to occur
  4451. // which causes forms to submit
  4452. suppressKeyPress = true;
  4453. event.preventDefault();
  4454. this.menu.select( event );
  4455. }
  4456. break;
  4457. case keyCode.TAB:
  4458. if ( this.menu.active ) {
  4459. this.menu.select( event );
  4460. }
  4461. break;
  4462. case keyCode.ESCAPE:
  4463. if ( this.menu.element.is( ":visible" ) ) {
  4464. this._value( this.term );
  4465. this.close( event );
  4466. // Different browsers have different default behavior for escape
  4467. // Single press can mean undo or clear
  4468. // Double press in IE means clear the whole form
  4469. event.preventDefault();
  4470. }
  4471. break;
  4472. default:
  4473. suppressKeyPressRepeat = true;
  4474. // search timeout should be triggered before the input value is changed
  4475. this._searchTimeout( event );
  4476. break;
  4477. }
  4478. },
  4479. keypress: function( event ) {
  4480. if ( suppressKeyPress ) {
  4481. suppressKeyPress = false;
  4482. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  4483. event.preventDefault();
  4484. }
  4485. return;
  4486. }
  4487. if ( suppressKeyPressRepeat ) {
  4488. return;
  4489. }
  4490. // replicate some key handlers to allow them to repeat in Firefox and Opera
  4491. var keyCode = $.ui.keyCode;
  4492. switch( event.keyCode ) {
  4493. case keyCode.PAGE_UP:
  4494. this._move( "previousPage", event );
  4495. break;
  4496. case keyCode.PAGE_DOWN:
  4497. this._move( "nextPage", event );
  4498. break;
  4499. case keyCode.UP:
  4500. this._keyEvent( "previous", event );
  4501. break;
  4502. case keyCode.DOWN:
  4503. this._keyEvent( "next", event );
  4504. break;
  4505. }
  4506. },
  4507. input: function( event ) {
  4508. if ( suppressInput ) {
  4509. suppressInput = false;
  4510. event.preventDefault();
  4511. return;
  4512. }
  4513. this._searchTimeout( event );
  4514. },
  4515. focus: function() {
  4516. this.selectedItem = null;
  4517. this.previous = this._value();
  4518. },
  4519. blur: function( event ) {
  4520. if ( this.cancelBlur ) {
  4521. delete this.cancelBlur;
  4522. return;
  4523. }
  4524. clearTimeout( this.searching );
  4525. this.close( event );
  4526. this._change( event );
  4527. }
  4528. });
  4529. this._initSource();
  4530. this.menu = $( "<ul>" )
  4531. .addClass( "ui-autocomplete ui-front" )
  4532. .appendTo( this._appendTo() )
  4533. .menu({
  4534. // disable ARIA support, the live region takes care of that
  4535. role: null
  4536. })
  4537. .hide()
  4538. .data( "ui-menu" );
  4539. this._on( this.menu.element, {
  4540. mousedown: function( event ) {
  4541. // prevent moving focus out of the text field
  4542. event.preventDefault();
  4543. // IE doesn't prevent moving focus even with event.preventDefault()
  4544. // so we set a flag to know when we should ignore the blur event
  4545. this.cancelBlur = true;
  4546. this._delay(function() {
  4547. delete this.cancelBlur;
  4548. });
  4549. // clicking on the scrollbar causes focus to shift to the body
  4550. // but we can't detect a mouseup or a click immediately afterward
  4551. // so we have to track the next mousedown and close the menu if
  4552. // the user clicks somewhere outside of the autocomplete
  4553. var menuElement = this.menu.element[ 0 ];
  4554. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  4555. this._delay(function() {
  4556. var that = this;
  4557. this.document.one( "mousedown", function( event ) {
  4558. if ( event.target !== that.element[ 0 ] &&
  4559. event.target !== menuElement &&
  4560. !$.contains( menuElement, event.target ) ) {
  4561. that.close();
  4562. }
  4563. });
  4564. });
  4565. }
  4566. },
  4567. menufocus: function( event, ui ) {
  4568. // support: Firefox
  4569. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  4570. if ( this.isNewMenu ) {
  4571. this.isNewMenu = false;
  4572. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  4573. this.menu.blur();
  4574. this.document.one( "mousemove", function() {
  4575. $( event.target ).trigger( event.originalEvent );
  4576. });
  4577. return;
  4578. }
  4579. }
  4580. var item = ui.item.data( "ui-autocomplete-item" );
  4581. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  4582. // use value to match what will end up in the input, if it was a key event
  4583. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  4584. this._value( item.value );
  4585. }
  4586. } else {
  4587. // Normally the input is populated with the item's value as the
  4588. // menu is navigated, causing screen readers to notice a change and
  4589. // announce the item. Since the focus event was canceled, this doesn't
  4590. // happen, so we update the live region so that screen readers can
  4591. // still notice the change and announce it.
  4592. this.liveRegion.text( item.value );
  4593. }
  4594. },
  4595. menuselect: function( event, ui ) {
  4596. var item = ui.item.data( "ui-autocomplete-item" ),
  4597. previous = this.previous;
  4598. // only trigger when focus was lost (click on menu)
  4599. if ( this.element[0] !== this.document[0].activeElement ) {
  4600. this.element.focus();
  4601. this.previous = previous;
  4602. // #6109 - IE triggers two focus events and the second
  4603. // is asynchronous, so we need to reset the previous
  4604. // term synchronously and asynchronously :-(
  4605. this._delay(function() {
  4606. this.previous = previous;
  4607. this.selectedItem = item;
  4608. });
  4609. }
  4610. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  4611. this._value( item.value );
  4612. }
  4613. // reset the term after the select event
  4614. // this allows custom select handling to work properly
  4615. this.term = this._value();
  4616. this.close( event );
  4617. this.selectedItem = item;
  4618. }
  4619. });
  4620. this.liveRegion = $( "<span>", {
  4621. role: "status",
  4622. "aria-live": "polite"
  4623. })
  4624. .addClass( "ui-helper-hidden-accessible" )
  4625. .insertBefore( this.element );
  4626. // turning off autocomplete prevents the browser from remembering the
  4627. // value when navigating through history, so we re-enable autocomplete
  4628. // if the page is unloaded before the widget is destroyed. #7790
  4629. this._on( this.window, {
  4630. beforeunload: function() {
  4631. this.element.removeAttr( "autocomplete" );
  4632. }
  4633. });
  4634. },
  4635. _destroy: function() {
  4636. clearTimeout( this.searching );
  4637. this.element
  4638. .removeClass( "ui-autocomplete-input" )
  4639. .removeAttr( "autocomplete" );
  4640. this.menu.element.remove();
  4641. this.liveRegion.remove();
  4642. },
  4643. _setOption: function( key, value ) {
  4644. this._super( key, value );
  4645. if ( key === "source" ) {
  4646. this._initSource();
  4647. }
  4648. if ( key === "appendTo" ) {
  4649. this.menu.element.appendTo( this._appendTo() );
  4650. }
  4651. if ( key === "disabled" && value && this.xhr ) {
  4652. this.xhr.abort();
  4653. }
  4654. },
  4655. _appendTo: function() {
  4656. var element = this.options.appendTo;
  4657. if ( element ) {
  4658. element = element.jquery || element.nodeType ?
  4659. $( element ) :
  4660. this.document.find( element ).eq( 0 );
  4661. }
  4662. if ( !element ) {
  4663. element = this.element.closest( ".ui-front" );
  4664. }
  4665. if ( !element.length ) {
  4666. element = this.document[0].body;
  4667. }
  4668. return element;
  4669. },
  4670. _initSource: function() {
  4671. var array, url,
  4672. that = this;
  4673. if ( $.isArray(this.options.source) ) {
  4674. array = this.options.source;
  4675. this.source = function( request, response ) {
  4676. response( $.ui.autocomplete.filter( array, request.term ) );
  4677. };
  4678. } else if ( typeof this.options.source === "string" ) {
  4679. url = this.options.source;
  4680. this.source = function( request, response ) {
  4681. if ( that.xhr ) {
  4682. that.xhr.abort();
  4683. }
  4684. that.xhr = $.ajax({
  4685. url: url,
  4686. data: request,
  4687. dataType: "json",
  4688. success: function( data ) {
  4689. response( data );
  4690. },
  4691. error: function() {
  4692. response( [] );
  4693. }
  4694. });
  4695. };
  4696. } else {
  4697. this.source = this.options.source;
  4698. }
  4699. },
  4700. _searchTimeout: function( event ) {
  4701. clearTimeout( this.searching );
  4702. this.searching = this._delay(function() {
  4703. // only search if the value has changed
  4704. if ( this.term !== this._value() ) {
  4705. this.selectedItem = null;
  4706. this.search( null, event );
  4707. }
  4708. }, this.options.delay );
  4709. },
  4710. search: function( value, event ) {
  4711. value = value != null ? value : this._value();
  4712. // always save the actual value, not the one passed as an argument
  4713. this.term = this._value();
  4714. if ( value.length < this.options.minLength ) {
  4715. return this.close( event );
  4716. }
  4717. if ( this._trigger( "search", event ) === false ) {
  4718. return;
  4719. }
  4720. return this._search( value );
  4721. },
  4722. _search: function( value ) {
  4723. this.pending++;
  4724. this.element.addClass( "ui-autocomplete-loading" );
  4725. this.cancelSearch = false;
  4726. this.source( { term: value }, this._response() );
  4727. },
  4728. _response: function() {
  4729. var that = this,
  4730. index = ++requestIndex;
  4731. return function( content ) {
  4732. if ( index === requestIndex ) {
  4733. that.__response( content );
  4734. }
  4735. that.pending--;
  4736. if ( !that.pending ) {
  4737. that.element.removeClass( "ui-autocomplete-loading" );
  4738. }
  4739. };
  4740. },
  4741. __response: function( content ) {
  4742. if ( content ) {
  4743. content = this._normalize( content );
  4744. }
  4745. this._trigger( "response", null, { content: content } );
  4746. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  4747. this._suggest( content );
  4748. this._trigger( "open" );
  4749. } else {
  4750. // use ._close() instead of .close() so we don't cancel future searches
  4751. this._close();
  4752. }
  4753. },
  4754. close: function( event ) {
  4755. this.cancelSearch = true;
  4756. this._close( event );
  4757. },
  4758. _close: function( event ) {
  4759. if ( this.menu.element.is( ":visible" ) ) {
  4760. this.menu.element.hide();
  4761. this.menu.blur();
  4762. this.isNewMenu = true;
  4763. this._trigger( "close", event );
  4764. }
  4765. },
  4766. _change: function( event ) {
  4767. if ( this.previous !== this._value() ) {
  4768. this._trigger( "change", event, { item: this.selectedItem } );
  4769. }
  4770. },
  4771. _normalize: function( items ) {
  4772. // assume all items have the right format when the first item is complete
  4773. if ( items.length && items[0].label && items[0].value ) {
  4774. return items;
  4775. }
  4776. return $.map( items, function( item ) {
  4777. if ( typeof item === "string" ) {
  4778. return {
  4779. label: item,
  4780. value: item
  4781. };
  4782. }
  4783. return $.extend({
  4784. label: item.label || item.value,
  4785. value: item.value || item.label
  4786. }, item );
  4787. });
  4788. },
  4789. _suggest: function( items ) {
  4790. var ul = this.menu.element.empty();
  4791. this._renderMenu( ul, items );
  4792. this.isNewMenu = true;
  4793. this.menu.refresh();
  4794. // size and position menu
  4795. ul.show();
  4796. this._resizeMenu();
  4797. ul.position( $.extend({
  4798. of: this.element
  4799. }, this.options.position ));
  4800. if ( this.options.autoFocus ) {
  4801. this.menu.next();
  4802. }
  4803. },
  4804. _resizeMenu: function() {
  4805. var ul = this.menu.element;
  4806. ul.outerWidth( Math.max(
  4807. // Firefox wraps long text (possibly a rounding bug)
  4808. // so we add 1px to avoid the wrapping (#7513)
  4809. ul.width( "" ).outerWidth() + 1,
  4810. this.element.outerWidth()
  4811. ) );
  4812. },
  4813. _renderMenu: function( ul, items ) {
  4814. var that = this;
  4815. $.each( items, function( index, item ) {
  4816. that._renderItemData( ul, item );
  4817. });
  4818. },
  4819. _renderItemData: function( ul, item ) {
  4820. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  4821. },
  4822. _renderItem: function( ul, item ) {
  4823. return $( "<li>" )
  4824. .append( $( "<a>" ).text( item.label ) )
  4825. .appendTo( ul );
  4826. },
  4827. _move: function( direction, event ) {
  4828. if ( !this.menu.element.is( ":visible" ) ) {
  4829. this.search( null, event );
  4830. return;
  4831. }
  4832. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  4833. this.menu.isLastItem() && /^next/.test( direction ) ) {
  4834. this._value( this.term );
  4835. this.menu.blur();
  4836. return;
  4837. }
  4838. this.menu[ direction ]( event );
  4839. },
  4840. widget: function() {
  4841. return this.menu.element;
  4842. },
  4843. _value: function() {
  4844. return this.valueMethod.apply( this.element, arguments );
  4845. },
  4846. _keyEvent: function( keyEvent, event ) {
  4847. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  4848. this._move( keyEvent, event );
  4849. // prevents moving cursor to beginning/end of the text field in some browsers
  4850. event.preventDefault();
  4851. }
  4852. }
  4853. });
  4854. $.extend( $.ui.autocomplete, {
  4855. escapeRegex: function( value ) {
  4856. return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
  4857. },
  4858. filter: function(array, term) {
  4859. var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
  4860. return $.grep( array, function(value) {
  4861. return matcher.test( value.label || value.value || value );
  4862. });
  4863. }
  4864. });
  4865. // live region extension, adding a `messages` option
  4866. // NOTE: This is an experimental API. We are still investigating
  4867. // a full solution for string manipulation and internationalization.
  4868. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  4869. options: {
  4870. messages: {
  4871. noResults: "No search results.",
  4872. results: function( amount ) {
  4873. return amount + ( amount > 1 ? " results are" : " result is" ) +
  4874. " available, use up and down arrow keys to navigate.";
  4875. }
  4876. }
  4877. },
  4878. __response: function( content ) {
  4879. var message;
  4880. this._superApply( arguments );
  4881. if ( this.options.disabled || this.cancelSearch ) {
  4882. return;
  4883. }
  4884. if ( content && content.length ) {
  4885. message = this.options.messages.results( content.length );
  4886. } else {
  4887. message = this.options.messages.noResults;
  4888. }
  4889. this.liveRegion.text( message );
  4890. }
  4891. });
  4892. }( jQuery ));
  4893. (function( $, undefined ) {
  4894. $.widget( "ui.menu", {
  4895. version: "1.10.3",
  4896. defaultElement: "<ul>",
  4897. delay: 300,
  4898. options: {
  4899. icons: {
  4900. submenu: "ui-icon-carat-1-e"
  4901. },
  4902. menus: "ul",
  4903. position: {
  4904. my: "left top",
  4905. at: "right top"
  4906. },
  4907. role: "menu",
  4908. // callbacks
  4909. blur: null,
  4910. focus: null,
  4911. select: null
  4912. },
  4913. _create: function() {
  4914. this.activeMenu = this.element;
  4915. // flag used to prevent firing of the click handler
  4916. // as the event bubbles up through nested menus
  4917. this.mouseHandled = false;
  4918. this.element
  4919. .uniqueId()
  4920. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  4921. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  4922. .attr({
  4923. role: this.options.role,
  4924. tabIndex: 0
  4925. })
  4926. // need to catch all clicks on disabled menu
  4927. // not possible through _on
  4928. .bind( "click" + this.eventNamespace, $.proxy(function( event ) {
  4929. if ( this.options.disabled ) {
  4930. event.preventDefault();
  4931. }
  4932. }, this ));
  4933. if ( this.options.disabled ) {
  4934. this.element
  4935. .addClass( "ui-state-disabled" )
  4936. .attr( "aria-disabled", "true" );
  4937. }
  4938. this._on({
  4939. // Prevent focus from sticking to links inside menu after clicking
  4940. // them (focus should always stay on UL during navigation).
  4941. "mousedown .ui-menu-item > a": function( event ) {
  4942. event.preventDefault();
  4943. },
  4944. "click .ui-state-disabled > a": function( event ) {
  4945. event.preventDefault();
  4946. },
  4947. "click .ui-menu-item:has(a)": function( event ) {
  4948. var target = $( event.target ).closest( ".ui-menu-item" );
  4949. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  4950. this.mouseHandled = true;
  4951. this.select( event );
  4952. // Open submenu on click
  4953. if ( target.has( ".ui-menu" ).length ) {
  4954. this.expand( event );
  4955. } else if ( !this.element.is( ":focus" ) ) {
  4956. // Redirect focus to the menu
  4957. this.element.trigger( "focus", [ true ] );
  4958. // If the active item is on the top level, let it stay active.
  4959. // Otherwise, blur the active item since it is no longer visible.
  4960. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  4961. clearTimeout( this.timer );
  4962. }
  4963. }
  4964. }
  4965. },
  4966. "mouseenter .ui-menu-item": function( event ) {
  4967. var target = $( event.currentTarget );
  4968. // Remove ui-state-active class from siblings of the newly focused menu item
  4969. // to avoid a jump caused by adjacent elements both having a class with a border
  4970. target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
  4971. this.focus( event, target );
  4972. },
  4973. mouseleave: "collapseAll",
  4974. "mouseleave .ui-menu": "collapseAll",
  4975. focus: function( event, keepActiveItem ) {
  4976. // If there's already an active item, keep it active
  4977. // If not, activate the first item
  4978. var item = this.active || this.element.children( ".ui-menu-item" ).eq( 0 );
  4979. if ( !keepActiveItem ) {
  4980. this.focus( event, item );
  4981. }
  4982. },
  4983. blur: function( event ) {
  4984. this._delay(function() {
  4985. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  4986. this.collapseAll( event );
  4987. }
  4988. });
  4989. },
  4990. keydown: "_keydown"
  4991. });
  4992. this.refresh();
  4993. // Clicks outside of a menu collapse any open menus
  4994. this._on( this.document, {
  4995. click: function( event ) {
  4996. if ( !$( event.target ).closest( ".ui-menu" ).length ) {
  4997. this.collapseAll( event );
  4998. }
  4999. // Reset the mouseHandled flag
  5000. this.mouseHandled = false;
  5001. }
  5002. });
  5003. },
  5004. _destroy: function() {
  5005. // Destroy (sub)menus
  5006. this.element
  5007. .removeAttr( "aria-activedescendant" )
  5008. .find( ".ui-menu" ).addBack()
  5009. .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
  5010. .removeAttr( "role" )
  5011. .removeAttr( "tabIndex" )
  5012. .removeAttr( "aria-labelledby" )
  5013. .removeAttr( "aria-expanded" )
  5014. .removeAttr( "aria-hidden" )
  5015. .removeAttr( "aria-disabled" )
  5016. .removeUniqueId()
  5017. .show();
  5018. // Destroy menu items
  5019. this.element.find( ".ui-menu-item" )
  5020. .removeClass( "ui-menu-item" )
  5021. .removeAttr( "role" )
  5022. .removeAttr( "aria-disabled" )
  5023. .children( "a" )
  5024. .removeUniqueId()
  5025. .removeClass( "ui-corner-all ui-state-hover" )
  5026. .removeAttr( "tabIndex" )
  5027. .removeAttr( "role" )
  5028. .removeAttr( "aria-haspopup" )
  5029. .children().each( function() {
  5030. var elem = $( this );
  5031. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  5032. elem.remove();
  5033. }
  5034. });
  5035. // Destroy menu dividers
  5036. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  5037. },
  5038. _keydown: function( event ) {
  5039. /*jshint maxcomplexity:20*/
  5040. var match, prev, character, skip, regex,
  5041. preventDefault = true;
  5042. function escape( value ) {
  5043. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  5044. }
  5045. switch ( event.keyCode ) {
  5046. case $.ui.keyCode.PAGE_UP:
  5047. this.previousPage( event );
  5048. break;
  5049. case $.ui.keyCode.PAGE_DOWN:
  5050. this.nextPage( event );
  5051. break;
  5052. case $.ui.keyCode.HOME:
  5053. this._move( "first", "first", event );
  5054. break;
  5055. case $.ui.keyCode.END:
  5056. this._move( "last", "last", event );
  5057. break;
  5058. case $.ui.keyCode.UP:
  5059. this.previous( event );
  5060. break;
  5061. case $.ui.keyCode.DOWN:
  5062. this.next( event );
  5063. break;
  5064. case $.ui.keyCode.LEFT:
  5065. this.collapse( event );
  5066. break;
  5067. case $.ui.keyCode.RIGHT:
  5068. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  5069. this.expand( event );
  5070. }
  5071. break;
  5072. case $.ui.keyCode.ENTER:
  5073. case $.ui.keyCode.SPACE:
  5074. this._activate( event );
  5075. break;
  5076. case $.ui.keyCode.ESCAPE:
  5077. this.collapse( event );
  5078. break;
  5079. default:
  5080. preventDefault = false;
  5081. prev = this.previousFilter || "";
  5082. character = String.fromCharCode( event.keyCode );
  5083. skip = false;
  5084. clearTimeout( this.filterTimer );
  5085. if ( character === prev ) {
  5086. skip = true;
  5087. } else {
  5088. character = prev + character;
  5089. }
  5090. regex = new RegExp( "^" + escape( character ), "i" );
  5091. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  5092. return regex.test( $( this ).children( "a" ).text() );
  5093. });
  5094. match = skip && match.index( this.active.next() ) !== -1 ?
  5095. this.active.nextAll( ".ui-menu-item" ) :
  5096. match;
  5097. // If no matches on the current filter, reset to the last character pressed
  5098. // to move down the menu to the first item that starts with that character
  5099. if ( !match.length ) {
  5100. character = String.fromCharCode( event.keyCode );
  5101. regex = new RegExp( "^" + escape( character ), "i" );
  5102. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  5103. return regex.test( $( this ).children( "a" ).text() );
  5104. });
  5105. }
  5106. if ( match.length ) {
  5107. this.focus( event, match );
  5108. if ( match.length > 1 ) {
  5109. this.previousFilter = character;
  5110. this.filterTimer = this._delay(function() {
  5111. delete this.previousFilter;
  5112. }, 1000 );
  5113. } else {
  5114. delete this.previousFilter;
  5115. }
  5116. } else {
  5117. delete this.previousFilter;
  5118. }
  5119. }
  5120. if ( preventDefault ) {
  5121. event.preventDefault();
  5122. }
  5123. },
  5124. _activate: function( event ) {
  5125. if ( !this.active.is( ".ui-state-disabled" ) ) {
  5126. if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
  5127. this.expand( event );
  5128. } else {
  5129. this.select( event );
  5130. }
  5131. }
  5132. },
  5133. refresh: function() {
  5134. var menus,
  5135. icon = this.options.icons.submenu,
  5136. submenus = this.element.find( this.options.menus );
  5137. // Initialize nested menus
  5138. submenus.filter( ":not(.ui-menu)" )
  5139. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  5140. .hide()
  5141. .attr({
  5142. role: this.options.role,
  5143. "aria-hidden": "true",
  5144. "aria-expanded": "false"
  5145. })
  5146. .each(function() {
  5147. var menu = $( this ),
  5148. item = menu.prev( "a" ),
  5149. submenuCarat = $( "<span>" )
  5150. .addClass( "ui-menu-icon ui-icon " + icon )
  5151. .data( "ui-menu-submenu-carat", true );
  5152. item
  5153. .attr( "aria-haspopup", "true" )
  5154. .prepend( submenuCarat );
  5155. menu.attr( "aria-labelledby", item.attr( "id" ) );
  5156. });
  5157. menus = submenus.add( this.element );
  5158. // Don't refresh list items that are already adapted
  5159. menus.children( ":not(.ui-menu-item):has(a)" )
  5160. .addClass( "ui-menu-item" )
  5161. .attr( "role", "presentation" )
  5162. .children( "a" )
  5163. .uniqueId()
  5164. .addClass( "ui-corner-all" )
  5165. .attr({
  5166. tabIndex: -1,
  5167. role: this._itemRole()
  5168. });
  5169. // Initialize unlinked menu-items containing spaces and/or dashes only as dividers
  5170. menus.children( ":not(.ui-menu-item)" ).each(function() {
  5171. var item = $( this );
  5172. // hyphen, em dash, en dash
  5173. if ( !/[^\-\u2014\u2013\s]/.test( item.text() ) ) {
  5174. item.addClass( "ui-widget-content ui-menu-divider" );
  5175. }
  5176. });
  5177. // Add aria-disabled attribute to any disabled menu item
  5178. menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  5179. // If the active item has been removed, blur the menu
  5180. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  5181. this.blur();
  5182. }
  5183. },
  5184. _itemRole: function() {
  5185. return {
  5186. menu: "menuitem",
  5187. listbox: "option"
  5188. }[ this.options.role ];
  5189. },
  5190. _setOption: function( key, value ) {
  5191. if ( key === "icons" ) {
  5192. this.element.find( ".ui-menu-icon" )
  5193. .removeClass( this.options.icons.submenu )
  5194. .addClass( value.submenu );
  5195. }
  5196. this._super( key, value );
  5197. },
  5198. focus: function( event, item ) {
  5199. var nested, focused;
  5200. this.blur( event, event && event.type === "focus" );
  5201. this._scrollIntoView( item );
  5202. this.active = item.first();
  5203. focused = this.active.children( "a" ).addClass( "ui-state-focus" );
  5204. // Only update aria-activedescendant if there's a role
  5205. // otherwise we assume focus is managed elsewhere
  5206. if ( this.options.role ) {
  5207. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  5208. }
  5209. // Highlight active parent menu item, if any
  5210. this.active
  5211. .parent()
  5212. .closest( ".ui-menu-item" )
  5213. .children( "a:first" )
  5214. .addClass( "ui-state-active" );
  5215. if ( event && event.type === "keydown" ) {
  5216. this._close();
  5217. } else {
  5218. this.timer = this._delay(function() {
  5219. this._close();
  5220. }, this.delay );
  5221. }
  5222. nested = item.children( ".ui-menu" );
  5223. if ( nested.length && ( /^mouse/.test( event.type ) ) ) {
  5224. this._startOpening(nested);
  5225. }
  5226. this.activeMenu = item.parent();
  5227. this._trigger( "focus", event, { item: item } );
  5228. },
  5229. _scrollIntoView: function( item ) {
  5230. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  5231. if ( this._hasScroll() ) {
  5232. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  5233. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  5234. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  5235. scroll = this.activeMenu.scrollTop();
  5236. elementHeight = this.activeMenu.height();
  5237. itemHeight = item.height();
  5238. if ( offset < 0 ) {
  5239. this.activeMenu.scrollTop( scroll + offset );
  5240. } else if ( offset + itemHeight > elementHeight ) {
  5241. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  5242. }
  5243. }
  5244. },
  5245. blur: function( event, fromFocus ) {
  5246. if ( !fromFocus ) {
  5247. clearTimeout( this.timer );
  5248. }
  5249. if ( !this.active ) {
  5250. return;
  5251. }
  5252. this.active.children( "a" ).removeClass( "ui-state-focus" );
  5253. this.active = null;
  5254. this._trigger( "blur", event, { item: this.active } );
  5255. },
  5256. _startOpening: function( submenu ) {
  5257. clearTimeout( this.timer );
  5258. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  5259. // shift in the submenu position when mousing over the carat icon
  5260. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  5261. return;
  5262. }
  5263. this.timer = this._delay(function() {
  5264. this._close();
  5265. this._open( submenu );
  5266. }, this.delay );
  5267. },
  5268. _open: function( submenu ) {
  5269. var position = $.extend({
  5270. of: this.active
  5271. }, this.options.position );
  5272. clearTimeout( this.timer );
  5273. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  5274. .hide()
  5275. .attr( "aria-hidden", "true" );
  5276. submenu
  5277. .show()
  5278. .removeAttr( "aria-hidden" )
  5279. .attr( "aria-expanded", "true" )
  5280. .position( position );
  5281. },
  5282. collapseAll: function( event, all ) {
  5283. clearTimeout( this.timer );
  5284. this.timer = this._delay(function() {
  5285. // If we were passed an event, look for the submenu that contains the event
  5286. var currentMenu = all ? this.element :
  5287. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  5288. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  5289. if ( !currentMenu.length ) {
  5290. currentMenu = this.element;
  5291. }
  5292. this._close( currentMenu );
  5293. this.blur( event );
  5294. this.activeMenu = currentMenu;
  5295. }, this.delay );
  5296. },
  5297. // With no arguments, closes the currently active menu - if nothing is active
  5298. // it closes all menus. If passed an argument, it will search for menus BELOW
  5299. _close: function( startMenu ) {
  5300. if ( !startMenu ) {
  5301. startMenu = this.active ? this.active.parent() : this.element;
  5302. }
  5303. startMenu
  5304. .find( ".ui-menu" )
  5305. .hide()
  5306. .attr( "aria-hidden", "true" )
  5307. .attr( "aria-expanded", "false" )
  5308. .end()
  5309. .find( "a.ui-state-active" )
  5310. .removeClass( "ui-state-active" );
  5311. },
  5312. collapse: function( event ) {
  5313. var newItem = this.active &&
  5314. this.active.parent().closest( ".ui-menu-item", this.element );
  5315. if ( newItem && newItem.length ) {
  5316. this._close();
  5317. this.focus( event, newItem );
  5318. }
  5319. },
  5320. expand: function( event ) {
  5321. var newItem = this.active &&
  5322. this.active
  5323. .children( ".ui-menu " )
  5324. .children( ".ui-menu-item" )
  5325. .first();
  5326. if ( newItem && newItem.length ) {
  5327. this._open( newItem.parent() );
  5328. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  5329. this._delay(function() {
  5330. this.focus( event, newItem );
  5331. });
  5332. }
  5333. },
  5334. next: function( event ) {
  5335. this._move( "next", "first", event );
  5336. },
  5337. previous: function( event ) {
  5338. this._move( "prev", "last", event );
  5339. },
  5340. isFirstItem: function() {
  5341. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  5342. },
  5343. isLastItem: function() {
  5344. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  5345. },
  5346. _move: function( direction, filter, event ) {
  5347. var next;
  5348. if ( this.active ) {
  5349. if ( direction === "first" || direction === "last" ) {
  5350. next = this.active
  5351. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  5352. .eq( -1 );
  5353. } else {
  5354. next = this.active
  5355. [ direction + "All" ]( ".ui-menu-item" )
  5356. .eq( 0 );
  5357. }
  5358. }
  5359. if ( !next || !next.length || !this.active ) {
  5360. next = this.activeMenu.children( ".ui-menu-item" )[ filter ]();
  5361. }
  5362. this.focus( event, next );
  5363. },
  5364. nextPage: function( event ) {
  5365. var item, base, height;
  5366. if ( !this.active ) {
  5367. this.next( event );
  5368. return;
  5369. }
  5370. if ( this.isLastItem() ) {
  5371. return;
  5372. }
  5373. if ( this._hasScroll() ) {
  5374. base = this.active.offset().top;
  5375. height = this.element.height();
  5376. this.active.nextAll( ".ui-menu-item" ).each(function() {
  5377. item = $( this );
  5378. return item.offset().top - base - height < 0;
  5379. });
  5380. this.focus( event, item );
  5381. } else {
  5382. this.focus( event, this.activeMenu.children( ".ui-menu-item" )
  5383. [ !this.active ? "first" : "last" ]() );
  5384. }
  5385. },
  5386. previousPage: function( event ) {
  5387. var item, base, height;
  5388. if ( !this.active ) {
  5389. this.next( event );
  5390. return;
  5391. }
  5392. if ( this.isFirstItem() ) {
  5393. return;
  5394. }
  5395. if ( this._hasScroll() ) {
  5396. base = this.active.offset().top;
  5397. height = this.element.height();
  5398. this.active.prevAll( ".ui-menu-item" ).each(function() {
  5399. item = $( this );
  5400. return item.offset().top - base + height > 0;
  5401. });
  5402. this.focus( event, item );
  5403. } else {
  5404. this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
  5405. }
  5406. },
  5407. _hasScroll: function() {
  5408. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  5409. },
  5410. select: function( event ) {
  5411. // TODO: It should never be possible to not have an active item at this
  5412. // point, but the tests don't trigger mouseenter before click.
  5413. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  5414. var ui = { item: this.active };
  5415. if ( !this.active.has( ".ui-menu" ).length ) {
  5416. this.collapseAll( event, true );
  5417. }
  5418. this._trigger( "select", event, ui );
  5419. }
  5420. });
  5421. }( jQuery ));
  5422. (function($, undefined) {
  5423. var dataSpace = "ui-effects-";
  5424. $.effects = {
  5425. effect: {}
  5426. };
  5427. /*!
  5428. * jQuery Color Animations v2.1.2
  5429. * https://github.com/jquery/jquery-color
  5430. *
  5431. * Copyright 2013 jQuery Foundation and other contributors
  5432. * Released under the MIT license.
  5433. * http://jquery.org/license
  5434. *
  5435. * Date: Wed Jan 16 08:47:09 2013 -0600
  5436. */
  5437. (function( jQuery, undefined ) {
  5438. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  5439. // plusequals test for += 100 -= 100
  5440. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  5441. // a set of RE's that can match strings and generate color tuples.
  5442. stringParsers = [{
  5443. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  5444. parse: function( execResult ) {
  5445. return [
  5446. execResult[ 1 ],
  5447. execResult[ 2 ],
  5448. execResult[ 3 ],
  5449. execResult[ 4 ]
  5450. ];
  5451. }
  5452. }, {
  5453. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  5454. parse: function( execResult ) {
  5455. return [
  5456. execResult[ 1 ] * 2.55,
  5457. execResult[ 2 ] * 2.55,
  5458. execResult[ 3 ] * 2.55,
  5459. execResult[ 4 ]
  5460. ];
  5461. }
  5462. }, {
  5463. // this regex ignores A-F because it's compared against an already lowercased string
  5464. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  5465. parse: function( execResult ) {
  5466. return [
  5467. parseInt( execResult[ 1 ], 16 ),
  5468. parseInt( execResult[ 2 ], 16 ),
  5469. parseInt( execResult[ 3 ], 16 )
  5470. ];
  5471. }
  5472. }, {
  5473. // this regex ignores A-F because it's compared against an already lowercased string
  5474. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  5475. parse: function( execResult ) {
  5476. return [
  5477. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  5478. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  5479. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  5480. ];
  5481. }
  5482. }, {
  5483. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  5484. space: "hsla",
  5485. parse: function( execResult ) {
  5486. return [
  5487. execResult[ 1 ],
  5488. execResult[ 2 ] / 100,
  5489. execResult[ 3 ] / 100,
  5490. execResult[ 4 ]
  5491. ];
  5492. }
  5493. }],
  5494. // jQuery.Color( )
  5495. color = jQuery.Color = function( color, green, blue, alpha ) {
  5496. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  5497. },
  5498. spaces = {
  5499. rgba: {
  5500. props: {
  5501. red: {
  5502. idx: 0,
  5503. type: "byte"
  5504. },
  5505. green: {
  5506. idx: 1,
  5507. type: "byte"
  5508. },
  5509. blue: {
  5510. idx: 2,
  5511. type: "byte"
  5512. }
  5513. }
  5514. },
  5515. hsla: {
  5516. props: {
  5517. hue: {
  5518. idx: 0,
  5519. type: "degrees"
  5520. },
  5521. saturation: {
  5522. idx: 1,
  5523. type: "percent"
  5524. },
  5525. lightness: {
  5526. idx: 2,
  5527. type: "percent"
  5528. }
  5529. }
  5530. }
  5531. },
  5532. propTypes = {
  5533. "byte": {
  5534. floor: true,
  5535. max: 255
  5536. },
  5537. "percent": {
  5538. max: 1
  5539. },
  5540. "degrees": {
  5541. mod: 360,
  5542. floor: true
  5543. }
  5544. },
  5545. support = color.support = {},
  5546. // element for support tests
  5547. supportElem = jQuery( "<p>" )[ 0 ],
  5548. // colors = jQuery.Color.names
  5549. colors,
  5550. // local aliases of functions called often
  5551. each = jQuery.each;
  5552. // determine rgba support immediately
  5553. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  5554. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  5555. // define cache name and alpha properties
  5556. // for rgba and hsla spaces
  5557. each( spaces, function( spaceName, space ) {
  5558. space.cache = "_" + spaceName;
  5559. space.props.alpha = {
  5560. idx: 3,
  5561. type: "percent",
  5562. def: 1
  5563. };
  5564. });
  5565. function clamp( value, prop, allowEmpty ) {
  5566. var type = propTypes[ prop.type ] || {};
  5567. if ( value == null ) {
  5568. return (allowEmpty || !prop.def) ? null : prop.def;
  5569. }
  5570. // ~~ is an short way of doing floor for positive numbers
  5571. value = type.floor ? ~~value : parseFloat( value );
  5572. // IE will pass in empty strings as value for alpha,
  5573. // which will hit this case
  5574. if ( isNaN( value ) ) {
  5575. return prop.def;
  5576. }
  5577. if ( type.mod ) {
  5578. // we add mod before modding to make sure that negatives values
  5579. // get converted properly: -10 -> 350
  5580. return (value + type.mod) % type.mod;
  5581. }
  5582. // for now all property types without mod have min and max
  5583. return 0 > value ? 0 : type.max < value ? type.max : value;
  5584. }
  5585. function stringParse( string ) {
  5586. var inst = color(),
  5587. rgba = inst._rgba = [];
  5588. string = string.toLowerCase();
  5589. each( stringParsers, function( i, parser ) {
  5590. var parsed,
  5591. match = parser.re.exec( string ),
  5592. values = match && parser.parse( match ),
  5593. spaceName = parser.space || "rgba";
  5594. if ( values ) {
  5595. parsed = inst[ spaceName ]( values );
  5596. // if this was an rgba parse the assignment might happen twice
  5597. // oh well....
  5598. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  5599. rgba = inst._rgba = parsed._rgba;
  5600. // exit each( stringParsers ) here because we matched
  5601. return false;
  5602. }
  5603. });
  5604. // Found a stringParser that handled it
  5605. if ( rgba.length ) {
  5606. // if this came from a parsed string, force "transparent" when alpha is 0
  5607. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  5608. if ( rgba.join() === "0,0,0,0" ) {
  5609. jQuery.extend( rgba, colors.transparent );
  5610. }
  5611. return inst;
  5612. }
  5613. // named colors
  5614. return colors[ string ];
  5615. }
  5616. color.fn = jQuery.extend( color.prototype, {
  5617. parse: function( red, green, blue, alpha ) {
  5618. if ( red === undefined ) {
  5619. this._rgba = [ null, null, null, null ];
  5620. return this;
  5621. }
  5622. if ( red.jquery || red.nodeType ) {
  5623. red = jQuery( red ).css( green );
  5624. green = undefined;
  5625. }
  5626. var inst = this,
  5627. type = jQuery.type( red ),
  5628. rgba = this._rgba = [];
  5629. // more than 1 argument specified - assume ( red, green, blue, alpha )
  5630. if ( green !== undefined ) {
  5631. red = [ red, green, blue, alpha ];
  5632. type = "array";
  5633. }
  5634. if ( type === "string" ) {
  5635. return this.parse( stringParse( red ) || colors._default );
  5636. }
  5637. if ( type === "array" ) {
  5638. each( spaces.rgba.props, function( key, prop ) {
  5639. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  5640. });
  5641. return this;
  5642. }
  5643. if ( type === "object" ) {
  5644. if ( red instanceof color ) {
  5645. each( spaces, function( spaceName, space ) {
  5646. if ( red[ space.cache ] ) {
  5647. inst[ space.cache ] = red[ space.cache ].slice();
  5648. }
  5649. });
  5650. } else {
  5651. each( spaces, function( spaceName, space ) {
  5652. var cache = space.cache;
  5653. each( space.props, function( key, prop ) {
  5654. // if the cache doesn't exist, and we know how to convert
  5655. if ( !inst[ cache ] && space.to ) {
  5656. // if the value was null, we don't need to copy it
  5657. // if the key was alpha, we don't need to copy it either
  5658. if ( key === "alpha" || red[ key ] == null ) {
  5659. return;
  5660. }
  5661. inst[ cache ] = space.to( inst._rgba );
  5662. }
  5663. // this is the only case where we allow nulls for ALL properties.
  5664. // call clamp with alwaysAllowEmpty
  5665. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  5666. });
  5667. // everything defined but alpha?
  5668. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  5669. // use the default of 1
  5670. inst[ cache ][ 3 ] = 1;
  5671. if ( space.from ) {
  5672. inst._rgba = space.from( inst[ cache ] );
  5673. }
  5674. }
  5675. });
  5676. }
  5677. return this;
  5678. }
  5679. },
  5680. is: function( compare ) {
  5681. var is = color( compare ),
  5682. same = true,
  5683. inst = this;
  5684. each( spaces, function( _, space ) {
  5685. var localCache,
  5686. isCache = is[ space.cache ];
  5687. if (isCache) {
  5688. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  5689. each( space.props, function( _, prop ) {
  5690. if ( isCache[ prop.idx ] != null ) {
  5691. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  5692. return same;
  5693. }
  5694. });
  5695. }
  5696. return same;
  5697. });
  5698. return same;
  5699. },
  5700. _space: function() {
  5701. var used = [],
  5702. inst = this;
  5703. each( spaces, function( spaceName, space ) {
  5704. if ( inst[ space.cache ] ) {
  5705. used.push( spaceName );
  5706. }
  5707. });
  5708. return used.pop();
  5709. },
  5710. transition: function( other, distance ) {
  5711. var end = color( other ),
  5712. spaceName = end._space(),
  5713. space = spaces[ spaceName ],
  5714. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  5715. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  5716. result = start.slice();
  5717. end = end[ space.cache ];
  5718. each( space.props, function( key, prop ) {
  5719. var index = prop.idx,
  5720. startValue = start[ index ],
  5721. endValue = end[ index ],
  5722. type = propTypes[ prop.type ] || {};
  5723. // if null, don't override start value
  5724. if ( endValue === null ) {
  5725. return;
  5726. }
  5727. // if null - use end
  5728. if ( startValue === null ) {
  5729. result[ index ] = endValue;
  5730. } else {
  5731. if ( type.mod ) {
  5732. if ( endValue - startValue > type.mod / 2 ) {
  5733. startValue += type.mod;
  5734. } else if ( startValue - endValue > type.mod / 2 ) {
  5735. startValue -= type.mod;
  5736. }
  5737. }
  5738. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  5739. }
  5740. });
  5741. return this[ spaceName ]( result );
  5742. },
  5743. blend: function( opaque ) {
  5744. // if we are already opaque - return ourself
  5745. if ( this._rgba[ 3 ] === 1 ) {
  5746. return this;
  5747. }
  5748. var rgb = this._rgba.slice(),
  5749. a = rgb.pop(),
  5750. blend = color( opaque )._rgba;
  5751. return color( jQuery.map( rgb, function( v, i ) {
  5752. return ( 1 - a ) * blend[ i ] + a * v;
  5753. }));
  5754. },
  5755. toRgbaString: function() {
  5756. var prefix = "rgba(",
  5757. rgba = jQuery.map( this._rgba, function( v, i ) {
  5758. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  5759. });
  5760. if ( rgba[ 3 ] === 1 ) {
  5761. rgba.pop();
  5762. prefix = "rgb(";
  5763. }
  5764. return prefix + rgba.join() + ")";
  5765. },
  5766. toHslaString: function() {
  5767. var prefix = "hsla(",
  5768. hsla = jQuery.map( this.hsla(), function( v, i ) {
  5769. if ( v == null ) {
  5770. v = i > 2 ? 1 : 0;
  5771. }
  5772. // catch 1 and 2
  5773. if ( i && i < 3 ) {
  5774. v = Math.round( v * 100 ) + "%";
  5775. }
  5776. return v;
  5777. });
  5778. if ( hsla[ 3 ] === 1 ) {
  5779. hsla.pop();
  5780. prefix = "hsl(";
  5781. }
  5782. return prefix + hsla.join() + ")";
  5783. },
  5784. toHexString: function( includeAlpha ) {
  5785. var rgba = this._rgba.slice(),
  5786. alpha = rgba.pop();
  5787. if ( includeAlpha ) {
  5788. rgba.push( ~~( alpha * 255 ) );
  5789. }
  5790. return "#" + jQuery.map( rgba, function( v ) {
  5791. // default to 0 when nulls exist
  5792. v = ( v || 0 ).toString( 16 );
  5793. return v.length === 1 ? "0" + v : v;
  5794. }).join("");
  5795. },
  5796. toString: function() {
  5797. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  5798. }
  5799. });
  5800. color.fn.parse.prototype = color.fn;
  5801. // hsla conversions adapted from:
  5802. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  5803. function hue2rgb( p, q, h ) {
  5804. h = ( h + 1 ) % 1;
  5805. if ( h * 6 < 1 ) {
  5806. return p + (q - p) * h * 6;
  5807. }
  5808. if ( h * 2 < 1) {
  5809. return q;
  5810. }
  5811. if ( h * 3 < 2 ) {
  5812. return p + (q - p) * ((2/3) - h) * 6;
  5813. }
  5814. return p;
  5815. }
  5816. spaces.hsla.to = function ( rgba ) {
  5817. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  5818. return [ null, null, null, rgba[ 3 ] ];
  5819. }
  5820. var r = rgba[ 0 ] / 255,
  5821. g = rgba[ 1 ] / 255,
  5822. b = rgba[ 2 ] / 255,
  5823. a = rgba[ 3 ],
  5824. max = Math.max( r, g, b ),
  5825. min = Math.min( r, g, b ),
  5826. diff = max - min,
  5827. add = max + min,
  5828. l = add * 0.5,
  5829. h, s;
  5830. if ( min === max ) {
  5831. h = 0;
  5832. } else if ( r === max ) {
  5833. h = ( 60 * ( g - b ) / diff ) + 360;
  5834. } else if ( g === max ) {
  5835. h = ( 60 * ( b - r ) / diff ) + 120;
  5836. } else {
  5837. h = ( 60 * ( r - g ) / diff ) + 240;
  5838. }
  5839. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  5840. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  5841. if ( diff === 0 ) {
  5842. s = 0;
  5843. } else if ( l <= 0.5 ) {
  5844. s = diff / add;
  5845. } else {
  5846. s = diff / ( 2 - add );
  5847. }
  5848. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  5849. };
  5850. spaces.hsla.from = function ( hsla ) {
  5851. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  5852. return [ null, null, null, hsla[ 3 ] ];
  5853. }
  5854. var h = hsla[ 0 ] / 360,
  5855. s = hsla[ 1 ],
  5856. l = hsla[ 2 ],
  5857. a = hsla[ 3 ],
  5858. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  5859. p = 2 * l - q;
  5860. return [
  5861. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  5862. Math.round( hue2rgb( p, q, h ) * 255 ),
  5863. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  5864. a
  5865. ];
  5866. };
  5867. each( spaces, function( spaceName, space ) {
  5868. var props = space.props,
  5869. cache = space.cache,
  5870. to = space.to,
  5871. from = space.from;
  5872. // makes rgba() and hsla()
  5873. color.fn[ spaceName ] = function( value ) {
  5874. // generate a cache for this space if it doesn't exist
  5875. if ( to && !this[ cache ] ) {
  5876. this[ cache ] = to( this._rgba );
  5877. }
  5878. if ( value === undefined ) {
  5879. return this[ cache ].slice();
  5880. }
  5881. var ret,
  5882. type = jQuery.type( value ),
  5883. arr = ( type === "array" || type === "object" ) ? value : arguments,
  5884. local = this[ cache ].slice();
  5885. each( props, function( key, prop ) {
  5886. var val = arr[ type === "object" ? key : prop.idx ];
  5887. if ( val == null ) {
  5888. val = local[ prop.idx ];
  5889. }
  5890. local[ prop.idx ] = clamp( val, prop );
  5891. });
  5892. if ( from ) {
  5893. ret = color( from( local ) );
  5894. ret[ cache ] = local;
  5895. return ret;
  5896. } else {
  5897. return color( local );
  5898. }
  5899. };
  5900. // makes red() green() blue() alpha() hue() saturation() lightness()
  5901. each( props, function( key, prop ) {
  5902. // alpha is included in more than one space
  5903. if ( color.fn[ key ] ) {
  5904. return;
  5905. }
  5906. color.fn[ key ] = function( value ) {
  5907. var vtype = jQuery.type( value ),
  5908. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  5909. local = this[ fn ](),
  5910. cur = local[ prop.idx ],
  5911. match;
  5912. if ( vtype === "undefined" ) {
  5913. return cur;
  5914. }
  5915. if ( vtype === "function" ) {
  5916. value = value.call( this, cur );
  5917. vtype = jQuery.type( value );
  5918. }
  5919. if ( value == null && prop.empty ) {
  5920. return this;
  5921. }
  5922. if ( vtype === "string" ) {
  5923. match = rplusequals.exec( value );
  5924. if ( match ) {
  5925. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  5926. }
  5927. }
  5928. local[ prop.idx ] = value;
  5929. return this[ fn ]( local );
  5930. };
  5931. });
  5932. });
  5933. // add cssHook and .fx.step function for each named hook.
  5934. // accept a space separated string of properties
  5935. color.hook = function( hook ) {
  5936. var hooks = hook.split( " " );
  5937. each( hooks, function( i, hook ) {
  5938. jQuery.cssHooks[ hook ] = {
  5939. set: function( elem, value ) {
  5940. var parsed, curElem,
  5941. backgroundColor = "";
  5942. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  5943. value = color( parsed || value );
  5944. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  5945. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  5946. while (
  5947. (backgroundColor === "" || backgroundColor === "transparent") &&
  5948. curElem && curElem.style
  5949. ) {
  5950. try {
  5951. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  5952. curElem = curElem.parentNode;
  5953. } catch ( e ) {
  5954. }
  5955. }
  5956. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  5957. backgroundColor :
  5958. "_default" );
  5959. }
  5960. value = value.toRgbaString();
  5961. }
  5962. try {
  5963. elem.style[ hook ] = value;
  5964. } catch( e ) {
  5965. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  5966. }
  5967. }
  5968. };
  5969. jQuery.fx.step[ hook ] = function( fx ) {
  5970. if ( !fx.colorInit ) {
  5971. fx.start = color( fx.elem, hook );
  5972. fx.end = color( fx.end );
  5973. fx.colorInit = true;
  5974. }
  5975. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  5976. };
  5977. });
  5978. };
  5979. color.hook( stepHooks );
  5980. jQuery.cssHooks.borderColor = {
  5981. expand: function( value ) {
  5982. var expanded = {};
  5983. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  5984. expanded[ "border" + part + "Color" ] = value;
  5985. });
  5986. return expanded;
  5987. }
  5988. };
  5989. // Basic color names only.
  5990. // Usage of any of the other color names requires adding yourself or including
  5991. // jquery.color.svg-names.js.
  5992. colors = jQuery.Color.names = {
  5993. // 4.1. Basic color keywords
  5994. aqua: "#00ffff",
  5995. black: "#000000",
  5996. blue: "#0000ff",
  5997. fuchsia: "#ff00ff",
  5998. gray: "#808080",
  5999. green: "#008000",
  6000. lime: "#00ff00",
  6001. maroon: "#800000",
  6002. navy: "#000080",
  6003. olive: "#808000",
  6004. purple: "#800080",
  6005. red: "#ff0000",
  6006. silver: "#c0c0c0",
  6007. teal: "#008080",
  6008. white: "#ffffff",
  6009. yellow: "#ffff00",
  6010. // 4.2.3. "transparent" color keyword
  6011. transparent: [ null, null, null, 0 ],
  6012. _default: "#ffffff"
  6013. };
  6014. })( jQuery );
  6015. /******************************************************************************/
  6016. /****************************** CLASS ANIMATIONS ******************************/
  6017. /******************************************************************************/
  6018. (function() {
  6019. var classAnimationActions = [ "add", "remove", "toggle" ],
  6020. shorthandStyles = {
  6021. border: 1,
  6022. borderBottom: 1,
  6023. borderColor: 1,
  6024. borderLeft: 1,
  6025. borderRight: 1,
  6026. borderTop: 1,
  6027. borderWidth: 1,
  6028. margin: 1,
  6029. padding: 1
  6030. };
  6031. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  6032. $.fx.step[ prop ] = function( fx ) {
  6033. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  6034. jQuery.style( fx.elem, prop, fx.end );
  6035. fx.setAttr = true;
  6036. }
  6037. };
  6038. });
  6039. function getElementStyles( elem ) {
  6040. var key, len,
  6041. style = elem.ownerDocument.defaultView ?
  6042. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  6043. elem.currentStyle,
  6044. styles = {};
  6045. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  6046. len = style.length;
  6047. while ( len-- ) {
  6048. key = style[ len ];
  6049. if ( typeof style[ key ] === "string" ) {
  6050. styles[ $.camelCase( key ) ] = style[ key ];
  6051. }
  6052. }
  6053. // support: Opera, IE <9
  6054. } else {
  6055. for ( key in style ) {
  6056. if ( typeof style[ key ] === "string" ) {
  6057. styles[ key ] = style[ key ];
  6058. }
  6059. }
  6060. }
  6061. return styles;
  6062. }
  6063. function styleDifference( oldStyle, newStyle ) {
  6064. var diff = {},
  6065. name, value;
  6066. for ( name in newStyle ) {
  6067. value = newStyle[ name ];
  6068. if ( oldStyle[ name ] !== value ) {
  6069. if ( !shorthandStyles[ name ] ) {
  6070. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  6071. diff[ name ] = value;
  6072. }
  6073. }
  6074. }
  6075. }
  6076. return diff;
  6077. }
  6078. // support: jQuery <1.8
  6079. if ( !$.fn.addBack ) {
  6080. $.fn.addBack = function( selector ) {
  6081. return this.add( selector == null ?
  6082. this.prevObject : this.prevObject.filter( selector )
  6083. );
  6084. };
  6085. }
  6086. $.effects.animateClass = function( value, duration, easing, callback ) {
  6087. var o = $.speed( duration, easing, callback );
  6088. return this.queue( function() {
  6089. var animated = $( this ),
  6090. baseClass = animated.attr( "class" ) || "",
  6091. applyClassChange,
  6092. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  6093. // map the animated objects to store the original styles.
  6094. allAnimations = allAnimations.map(function() {
  6095. var el = $( this );
  6096. return {
  6097. el: el,
  6098. start: getElementStyles( this )
  6099. };
  6100. });
  6101. // apply class change
  6102. applyClassChange = function() {
  6103. $.each( classAnimationActions, function(i, action) {
  6104. if ( value[ action ] ) {
  6105. animated[ action + "Class" ]( value[ action ] );
  6106. }
  6107. });
  6108. };
  6109. applyClassChange();
  6110. // map all animated objects again - calculate new styles and diff
  6111. allAnimations = allAnimations.map(function() {
  6112. this.end = getElementStyles( this.el[ 0 ] );
  6113. this.diff = styleDifference( this.start, this.end );
  6114. return this;
  6115. });
  6116. // apply original class
  6117. animated.attr( "class", baseClass );
  6118. // map all animated objects again - this time collecting a promise
  6119. allAnimations = allAnimations.map(function() {
  6120. var styleInfo = this,
  6121. dfd = $.Deferred(),
  6122. opts = $.extend({}, o, {
  6123. queue: false,
  6124. complete: function() {
  6125. dfd.resolve( styleInfo );
  6126. }
  6127. });
  6128. this.el.animate( this.diff, opts );
  6129. return dfd.promise();
  6130. });
  6131. // once all animations have completed:
  6132. $.when.apply( $, allAnimations.get() ).done(function() {
  6133. // set the final class
  6134. applyClassChange();
  6135. // for each animated element,
  6136. // clear all css properties that were animated
  6137. $.each( arguments, function() {
  6138. var el = this.el;
  6139. $.each( this.diff, function(key) {
  6140. el.css( key, "" );
  6141. });
  6142. });
  6143. // this is guarnteed to be there if you use jQuery.speed()
  6144. // it also handles dequeuing the next anim...
  6145. o.complete.call( animated[ 0 ] );
  6146. });
  6147. });
  6148. };
  6149. $.fn.extend({
  6150. addClass: (function( orig ) {
  6151. return function( classNames, speed, easing, callback ) {
  6152. return speed ?
  6153. $.effects.animateClass.call( this,
  6154. { add: classNames }, speed, easing, callback ) :
  6155. orig.apply( this, arguments );
  6156. };
  6157. })( $.fn.addClass ),
  6158. removeClass: (function( orig ) {
  6159. return function( classNames, speed, easing, callback ) {
  6160. return arguments.length > 1 ?
  6161. $.effects.animateClass.call( this,
  6162. { remove: classNames }, speed, easing, callback ) :
  6163. orig.apply( this, arguments );
  6164. };
  6165. })( $.fn.removeClass ),
  6166. toggleClass: (function( orig ) {
  6167. return function( classNames, force, speed, easing, callback ) {
  6168. if ( typeof force === "boolean" || force === undefined ) {
  6169. if ( !speed ) {
  6170. // without speed parameter
  6171. return orig.apply( this, arguments );
  6172. } else {
  6173. return $.effects.animateClass.call( this,
  6174. (force ? { add: classNames } : { remove: classNames }),
  6175. speed, easing, callback );
  6176. }
  6177. } else {
  6178. // without force parameter
  6179. return $.effects.animateClass.call( this,
  6180. { toggle: classNames }, force, speed, easing );
  6181. }
  6182. };
  6183. })( $.fn.toggleClass ),
  6184. switchClass: function( remove, add, speed, easing, callback) {
  6185. return $.effects.animateClass.call( this, {
  6186. add: add,
  6187. remove: remove
  6188. }, speed, easing, callback );
  6189. }
  6190. });
  6191. })();
  6192. /******************************************************************************/
  6193. /*********************************** EFFECTS **********************************/
  6194. /******************************************************************************/
  6195. (function() {
  6196. $.extend( $.effects, {
  6197. version: "1.10.3",
  6198. // Saves a set of properties in a data storage
  6199. save: function( element, set ) {
  6200. for( var i=0; i < set.length; i++ ) {
  6201. if ( set[ i ] !== null ) {
  6202. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  6203. }
  6204. }
  6205. },
  6206. // Restores a set of previously saved properties from a data storage
  6207. restore: function( element, set ) {
  6208. var val, i;
  6209. for( i=0; i < set.length; i++ ) {
  6210. if ( set[ i ] !== null ) {
  6211. val = element.data( dataSpace + set[ i ] );
  6212. // support: jQuery 1.6.2
  6213. // http://bugs.jquery.com/ticket/9917
  6214. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  6215. // We can't differentiate between "" and 0 here, so we just assume
  6216. // empty string since it's likely to be a more common value...
  6217. if ( val === undefined ) {
  6218. val = "";
  6219. }
  6220. element.css( set[ i ], val );
  6221. }
  6222. }
  6223. },
  6224. setMode: function( el, mode ) {
  6225. if (mode === "toggle") {
  6226. mode = el.is( ":hidden" ) ? "show" : "hide";
  6227. }
  6228. return mode;
  6229. },
  6230. // Translates a [top,left] array into a baseline value
  6231. // this should be a little more flexible in the future to handle a string & hash
  6232. getBaseline: function( origin, original ) {
  6233. var y, x;
  6234. switch ( origin[ 0 ] ) {
  6235. case "top": y = 0; break;
  6236. case "middle": y = 0.5; break;
  6237. case "bottom": y = 1; break;
  6238. default: y = origin[ 0 ] / original.height;
  6239. }
  6240. switch ( origin[ 1 ] ) {
  6241. case "left": x = 0; break;
  6242. case "center": x = 0.5; break;
  6243. case "right": x = 1; break;
  6244. default: x = origin[ 1 ] / original.width;
  6245. }
  6246. return {
  6247. x: x,
  6248. y: y
  6249. };
  6250. },
  6251. // Wraps the element around a wrapper that copies position properties
  6252. createWrapper: function( element ) {
  6253. // if the element is already wrapped, return it
  6254. if ( element.parent().is( ".ui-effects-wrapper" )) {
  6255. return element.parent();
  6256. }
  6257. // wrap the element
  6258. var props = {
  6259. width: element.outerWidth(true),
  6260. height: element.outerHeight(true),
  6261. "float": element.css( "float" )
  6262. },
  6263. wrapper = $( "<div></div>" )
  6264. .addClass( "ui-effects-wrapper" )
  6265. .css({
  6266. fontSize: "100%",
  6267. background: "transparent",
  6268. border: "none",
  6269. margin: 0,
  6270. padding: 0
  6271. }),
  6272. // Store the size in case width/height are defined in % - Fixes #5245
  6273. size = {
  6274. width: element.width(),
  6275. height: element.height()
  6276. },
  6277. active = document.activeElement;
  6278. // support: Firefox
  6279. // Firefox incorrectly exposes anonymous content
  6280. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  6281. try {
  6282. active.id;
  6283. } catch( e ) {
  6284. active = document.body;
  6285. }
  6286. element.wrap( wrapper );
  6287. // Fixes #7595 - Elements lose focus when wrapped.
  6288. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  6289. $( active ).focus();
  6290. }
  6291. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  6292. // transfer positioning properties to the wrapper
  6293. if ( element.css( "position" ) === "static" ) {
  6294. wrapper.css({ position: "relative" });
  6295. element.css({ position: "relative" });
  6296. } else {
  6297. $.extend( props, {
  6298. position: element.css( "position" ),
  6299. zIndex: element.css( "z-index" )
  6300. });
  6301. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  6302. props[ pos ] = element.css( pos );
  6303. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  6304. props[ pos ] = "auto";
  6305. }
  6306. });
  6307. element.css({
  6308. position: "relative",
  6309. top: 0,
  6310. left: 0,
  6311. right: "auto",
  6312. bottom: "auto"
  6313. });
  6314. }
  6315. element.css(size);
  6316. return wrapper.css( props ).show();
  6317. },
  6318. removeWrapper: function( element ) {
  6319. var active = document.activeElement;
  6320. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  6321. element.parent().replaceWith( element );
  6322. // Fixes #7595 - Elements lose focus when wrapped.
  6323. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  6324. $( active ).focus();
  6325. }
  6326. }
  6327. return element;
  6328. },
  6329. setTransition: function( element, list, factor, value ) {
  6330. value = value || {};
  6331. $.each( list, function( i, x ) {
  6332. var unit = element.cssUnit( x );
  6333. if ( unit[ 0 ] > 0 ) {
  6334. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  6335. }
  6336. });
  6337. return value;
  6338. }
  6339. });
  6340. // return an effect options object for the given parameters:
  6341. function _normalizeArguments( effect, options, speed, callback ) {
  6342. // allow passing all options as the first parameter
  6343. if ( $.isPlainObject( effect ) ) {
  6344. options = effect;
  6345. effect = effect.effect;
  6346. }
  6347. // convert to an object
  6348. effect = { effect: effect };
  6349. // catch (effect, null, ...)
  6350. if ( options == null ) {
  6351. options = {};
  6352. }
  6353. // catch (effect, callback)
  6354. if ( $.isFunction( options ) ) {
  6355. callback = options;
  6356. speed = null;
  6357. options = {};
  6358. }
  6359. // catch (effect, speed, ?)
  6360. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  6361. callback = speed;
  6362. speed = options;
  6363. options = {};
  6364. }
  6365. // catch (effect, options, callback)
  6366. if ( $.isFunction( speed ) ) {
  6367. callback = speed;
  6368. speed = null;
  6369. }
  6370. // add options to effect
  6371. if ( options ) {
  6372. $.extend( effect, options );
  6373. }
  6374. speed = speed || options.duration;
  6375. effect.duration = $.fx.off ? 0 :
  6376. typeof speed === "number" ? speed :
  6377. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  6378. $.fx.speeds._default;
  6379. effect.complete = callback || options.complete;
  6380. return effect;
  6381. }
  6382. function standardAnimationOption( option ) {
  6383. // Valid standard speeds (nothing, number, named speed)
  6384. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  6385. return true;
  6386. }
  6387. // Invalid strings - treat as "normal" speed
  6388. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  6389. return true;
  6390. }
  6391. // Complete callback
  6392. if ( $.isFunction( option ) ) {
  6393. return true;
  6394. }
  6395. // Options hash (but not naming an effect)
  6396. if ( typeof option === "object" && !option.effect ) {
  6397. return true;
  6398. }
  6399. // Didn't match any standard API
  6400. return false;
  6401. }
  6402. $.fn.extend({
  6403. effect: function( /* effect, options, speed, callback */ ) {
  6404. var args = _normalizeArguments.apply( this, arguments ),
  6405. mode = args.mode,
  6406. queue = args.queue,
  6407. effectMethod = $.effects.effect[ args.effect ];
  6408. if ( $.fx.off || !effectMethod ) {
  6409. // delegate to the original method (e.g., .show()) if possible
  6410. if ( mode ) {
  6411. return this[ mode ]( args.duration, args.complete );
  6412. } else {
  6413. return this.each( function() {
  6414. if ( args.complete ) {
  6415. args.complete.call( this );
  6416. }
  6417. });
  6418. }
  6419. }
  6420. function run( next ) {
  6421. var elem = $( this ),
  6422. complete = args.complete,
  6423. mode = args.mode;
  6424. function done() {
  6425. if ( $.isFunction( complete ) ) {
  6426. complete.call( elem[0] );
  6427. }
  6428. if ( $.isFunction( next ) ) {
  6429. next();
  6430. }
  6431. }
  6432. // If the element already has the correct final state, delegate to
  6433. // the core methods so the internal tracking of "olddisplay" works.
  6434. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  6435. elem[ mode ]();
  6436. done();
  6437. } else {
  6438. effectMethod.call( elem[0], args, done );
  6439. }
  6440. }
  6441. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  6442. },
  6443. show: (function( orig ) {
  6444. return function( option ) {
  6445. if ( standardAnimationOption( option ) ) {
  6446. return orig.apply( this, arguments );
  6447. } else {
  6448. var args = _normalizeArguments.apply( this, arguments );
  6449. args.mode = "show";
  6450. return this.effect.call( this, args );
  6451. }
  6452. };
  6453. })( $.fn.show ),
  6454. hide: (function( orig ) {
  6455. return function( option ) {
  6456. if ( standardAnimationOption( option ) ) {
  6457. return orig.apply( this, arguments );
  6458. } else {
  6459. var args = _normalizeArguments.apply( this, arguments );
  6460. args.mode = "hide";
  6461. return this.effect.call( this, args );
  6462. }
  6463. };
  6464. })( $.fn.hide ),
  6465. toggle: (function( orig ) {
  6466. return function( option ) {
  6467. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  6468. return orig.apply( this, arguments );
  6469. } else {
  6470. var args = _normalizeArguments.apply( this, arguments );
  6471. args.mode = "toggle";
  6472. return this.effect.call( this, args );
  6473. }
  6474. };
  6475. })( $.fn.toggle ),
  6476. // helper functions
  6477. cssUnit: function(key) {
  6478. var style = this.css( key ),
  6479. val = [];
  6480. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  6481. if ( style.indexOf( unit ) > 0 ) {
  6482. val = [ parseFloat( style ), unit ];
  6483. }
  6484. });
  6485. return val;
  6486. }
  6487. });
  6488. })();
  6489. /******************************************************************************/
  6490. /*********************************** EASING ***********************************/
  6491. /******************************************************************************/
  6492. (function() {
  6493. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  6494. var baseEasings = {};
  6495. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  6496. baseEasings[ name ] = function( p ) {
  6497. return Math.pow( p, i + 2 );
  6498. };
  6499. });
  6500. $.extend( baseEasings, {
  6501. Sine: function ( p ) {
  6502. return 1 - Math.cos( p * Math.PI / 2 );
  6503. },
  6504. Circ: function ( p ) {
  6505. return 1 - Math.sqrt( 1 - p * p );
  6506. },
  6507. Elastic: function( p ) {
  6508. return p === 0 || p === 1 ? p :
  6509. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  6510. },
  6511. Back: function( p ) {
  6512. return p * p * ( 3 * p - 2 );
  6513. },
  6514. Bounce: function ( p ) {
  6515. var pow2,
  6516. bounce = 4;
  6517. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  6518. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  6519. }
  6520. });
  6521. $.each( baseEasings, function( name, easeIn ) {
  6522. $.easing[ "easeIn" + name ] = easeIn;
  6523. $.easing[ "easeOut" + name ] = function( p ) {
  6524. return 1 - easeIn( 1 - p );
  6525. };
  6526. $.easing[ "easeInOut" + name ] = function( p ) {
  6527. return p < 0.5 ?
  6528. easeIn( p * 2 ) / 2 :
  6529. 1 - easeIn( p * -2 + 2 ) / 2;
  6530. };
  6531. });
  6532. })();
  6533. })(jQuery);
  6534. (function( $, undefined ) {
  6535. var rvertical = /up|down|vertical/,
  6536. rpositivemotion = /up|left|vertical|horizontal/;
  6537. $.effects.effect.blind = function( o, done ) {
  6538. // Create element
  6539. var el = $( this ),
  6540. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  6541. mode = $.effects.setMode( el, o.mode || "hide" ),
  6542. direction = o.direction || "up",
  6543. vertical = rvertical.test( direction ),
  6544. ref = vertical ? "height" : "width",
  6545. ref2 = vertical ? "top" : "left",
  6546. motion = rpositivemotion.test( direction ),
  6547. animation = {},
  6548. show = mode === "show",
  6549. wrapper, distance, margin;
  6550. // if already wrapped, the wrapper's properties are my property. #6245
  6551. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  6552. $.effects.save( el.parent(), props );
  6553. } else {
  6554. $.effects.save( el, props );
  6555. }
  6556. el.show();
  6557. wrapper = $.effects.createWrapper( el ).css({
  6558. overflow: "hidden"
  6559. });
  6560. distance = wrapper[ ref ]();
  6561. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  6562. animation[ ref ] = show ? distance : 0;
  6563. if ( !motion ) {
  6564. el
  6565. .css( vertical ? "bottom" : "right", 0 )
  6566. .css( vertical ? "top" : "left", "auto" )
  6567. .css({ position: "absolute" });
  6568. animation[ ref2 ] = show ? margin : distance + margin;
  6569. }
  6570. // start at 0 if we are showing
  6571. if ( show ) {
  6572. wrapper.css( ref, 0 );
  6573. if ( ! motion ) {
  6574. wrapper.css( ref2, margin + distance );
  6575. }
  6576. }
  6577. // Animate
  6578. wrapper.animate( animation, {
  6579. duration: o.duration,
  6580. easing: o.easing,
  6581. queue: false,
  6582. complete: function() {
  6583. if ( mode === "hide" ) {
  6584. el.hide();
  6585. }
  6586. $.effects.restore( el, props );
  6587. $.effects.removeWrapper( el );
  6588. done();
  6589. }
  6590. });
  6591. };
  6592. })(jQuery);
  6593. (function( $, undefined ) {
  6594. $.effects.effect.bounce = function( o, done ) {
  6595. var el = $( this ),
  6596. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  6597. // defaults:
  6598. mode = $.effects.setMode( el, o.mode || "effect" ),
  6599. hide = mode === "hide",
  6600. show = mode === "show",
  6601. direction = o.direction || "up",
  6602. distance = o.distance,
  6603. times = o.times || 5,
  6604. // number of internal animations
  6605. anims = times * 2 + ( show || hide ? 1 : 0 ),
  6606. speed = o.duration / anims,
  6607. easing = o.easing,
  6608. // utility:
  6609. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  6610. motion = ( direction === "up" || direction === "left" ),
  6611. i,
  6612. upAnim,
  6613. downAnim,
  6614. // we will need to re-assemble the queue to stack our animations in place
  6615. queue = el.queue(),
  6616. queuelen = queue.length;
  6617. // Avoid touching opacity to prevent clearType and PNG issues in IE
  6618. if ( show || hide ) {
  6619. props.push( "opacity" );
  6620. }
  6621. $.effects.save( el, props );
  6622. el.show();
  6623. $.effects.createWrapper( el ); // Create Wrapper
  6624. // default distance for the BIGGEST bounce is the outer Distance / 3
  6625. if ( !distance ) {
  6626. distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  6627. }
  6628. if ( show ) {
  6629. downAnim = { opacity: 1 };
  6630. downAnim[ ref ] = 0;
  6631. // if we are showing, force opacity 0 and set the initial position
  6632. // then do the "first" animation
  6633. el.css( "opacity", 0 )
  6634. .css( ref, motion ? -distance * 2 : distance * 2 )
  6635. .animate( downAnim, speed, easing );
  6636. }
  6637. // start at the smallest distance if we are hiding
  6638. if ( hide ) {
  6639. distance = distance / Math.pow( 2, times - 1 );
  6640. }
  6641. downAnim = {};
  6642. downAnim[ ref ] = 0;
  6643. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  6644. for ( i = 0; i < times; i++ ) {
  6645. upAnim = {};
  6646. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  6647. el.animate( upAnim, speed, easing )
  6648. .animate( downAnim, speed, easing );
  6649. distance = hide ? distance * 2 : distance / 2;
  6650. }
  6651. // Last Bounce when Hiding
  6652. if ( hide ) {
  6653. upAnim = { opacity: 0 };
  6654. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  6655. el.animate( upAnim, speed, easing );
  6656. }
  6657. el.queue(function() {
  6658. if ( hide ) {
  6659. el.hide();
  6660. }
  6661. $.effects.restore( el, props );
  6662. $.effects.removeWrapper( el );
  6663. done();
  6664. });
  6665. // inject all the animations we just queued to be first in line (after "inprogress")
  6666. if ( queuelen > 1) {
  6667. queue.splice.apply( queue,
  6668. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  6669. }
  6670. el.dequeue();
  6671. };
  6672. })(jQuery);
  6673. (function( $, undefined ) {
  6674. $.effects.effect.clip = function( o, done ) {
  6675. // Create element
  6676. var el = $( this ),
  6677. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  6678. mode = $.effects.setMode( el, o.mode || "hide" ),
  6679. show = mode === "show",
  6680. direction = o.direction || "vertical",
  6681. vert = direction === "vertical",
  6682. size = vert ? "height" : "width",
  6683. position = vert ? "top" : "left",
  6684. animation = {},
  6685. wrapper, animate, distance;
  6686. // Save & Show
  6687. $.effects.save( el, props );
  6688. el.show();
  6689. // Create Wrapper
  6690. wrapper = $.effects.createWrapper( el ).css({
  6691. overflow: "hidden"
  6692. });
  6693. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  6694. distance = animate[ size ]();
  6695. // Shift
  6696. if ( show ) {
  6697. animate.css( size, 0 );
  6698. animate.css( position, distance / 2 );
  6699. }
  6700. // Create Animation Object:
  6701. animation[ size ] = show ? distance : 0;
  6702. animation[ position ] = show ? 0 : distance / 2;
  6703. // Animate
  6704. animate.animate( animation, {
  6705. queue: false,
  6706. duration: o.duration,
  6707. easing: o.easing,
  6708. complete: function() {
  6709. if ( !show ) {
  6710. el.hide();
  6711. }
  6712. $.effects.restore( el, props );
  6713. $.effects.removeWrapper( el );
  6714. done();
  6715. }
  6716. });
  6717. };
  6718. })(jQuery);
  6719. (function( $, undefined ) {
  6720. $.effects.effect.drop = function( o, done ) {
  6721. var el = $( this ),
  6722. props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
  6723. mode = $.effects.setMode( el, o.mode || "hide" ),
  6724. show = mode === "show",
  6725. direction = o.direction || "left",
  6726. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  6727. motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
  6728. animation = {
  6729. opacity: show ? 1 : 0
  6730. },
  6731. distance;
  6732. // Adjust
  6733. $.effects.save( el, props );
  6734. el.show();
  6735. $.effects.createWrapper( el );
  6736. distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]( true ) / 2;
  6737. if ( show ) {
  6738. el
  6739. .css( "opacity", 0 )
  6740. .css( ref, motion === "pos" ? -distance : distance );
  6741. }
  6742. // Animation
  6743. animation[ ref ] = ( show ?
  6744. ( motion === "pos" ? "+=" : "-=" ) :
  6745. ( motion === "pos" ? "-=" : "+=" ) ) +
  6746. distance;
  6747. // Animate
  6748. el.animate( animation, {
  6749. queue: false,
  6750. duration: o.duration,
  6751. easing: o.easing,
  6752. complete: function() {
  6753. if ( mode === "hide" ) {
  6754. el.hide();
  6755. }
  6756. $.effects.restore( el, props );
  6757. $.effects.removeWrapper( el );
  6758. done();
  6759. }
  6760. });
  6761. };
  6762. })(jQuery);
  6763. (function( $, undefined ) {
  6764. $.effects.effect.explode = function( o, done ) {
  6765. var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
  6766. cells = rows,
  6767. el = $( this ),
  6768. mode = $.effects.setMode( el, o.mode || "hide" ),
  6769. show = mode === "show",
  6770. // show and then visibility:hidden the element before calculating offset
  6771. offset = el.show().css( "visibility", "hidden" ).offset(),
  6772. // width and height of a piece
  6773. width = Math.ceil( el.outerWidth() / cells ),
  6774. height = Math.ceil( el.outerHeight() / rows ),
  6775. pieces = [],
  6776. // loop
  6777. i, j, left, top, mx, my;
  6778. // children animate complete:
  6779. function childComplete() {
  6780. pieces.push( this );
  6781. if ( pieces.length === rows * cells ) {
  6782. animComplete();
  6783. }
  6784. }
  6785. // clone the element for each row and cell.
  6786. for( i = 0; i < rows ; i++ ) { // ===>
  6787. top = offset.top + i * height;
  6788. my = i - ( rows - 1 ) / 2 ;
  6789. for( j = 0; j < cells ; j++ ) { // |||
  6790. left = offset.left + j * width;
  6791. mx = j - ( cells - 1 ) / 2 ;
  6792. // Create a clone of the now hidden main element that will be absolute positioned
  6793. // within a wrapper div off the -left and -top equal to size of our pieces
  6794. el
  6795. .clone()
  6796. .appendTo( "body" )
  6797. .wrap( "<div></div>" )
  6798. .css({
  6799. position: "absolute",
  6800. visibility: "visible",
  6801. left: -j * width,
  6802. top: -i * height
  6803. })
  6804. // select the wrapper - make it overflow: hidden and absolute positioned based on
  6805. // where the original was located +left and +top equal to the size of pieces
  6806. .parent()
  6807. .addClass( "ui-effects-explode" )
  6808. .css({
  6809. position: "absolute",
  6810. overflow: "hidden",
  6811. width: width,
  6812. height: height,
  6813. left: left + ( show ? mx * width : 0 ),
  6814. top: top + ( show ? my * height : 0 ),
  6815. opacity: show ? 0 : 1
  6816. }).animate({
  6817. left: left + ( show ? 0 : mx * width ),
  6818. top: top + ( show ? 0 : my * height ),
  6819. opacity: show ? 1 : 0
  6820. }, o.duration || 500, o.easing, childComplete );
  6821. }
  6822. }
  6823. function animComplete() {
  6824. el.css({
  6825. visibility: "visible"
  6826. });
  6827. $( pieces ).remove();
  6828. if ( !show ) {
  6829. el.hide();
  6830. }
  6831. done();
  6832. }
  6833. };
  6834. })(jQuery);
  6835. (function( $, undefined ) {
  6836. $.effects.effect.fade = function( o, done ) {
  6837. var el = $( this ),
  6838. mode = $.effects.setMode( el, o.mode || "toggle" );
  6839. el.animate({
  6840. opacity: mode
  6841. }, {
  6842. queue: false,
  6843. duration: o.duration,
  6844. easing: o.easing,
  6845. complete: done
  6846. });
  6847. };
  6848. })( jQuery );
  6849. (function( $, undefined ) {
  6850. $.effects.effect.fold = function( o, done ) {
  6851. // Create element
  6852. var el = $( this ),
  6853. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  6854. mode = $.effects.setMode( el, o.mode || "hide" ),
  6855. show = mode === "show",
  6856. hide = mode === "hide",
  6857. size = o.size || 15,
  6858. percent = /([0-9]+)%/.exec( size ),
  6859. horizFirst = !!o.horizFirst,
  6860. widthFirst = show !== horizFirst,
  6861. ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
  6862. duration = o.duration / 2,
  6863. wrapper, distance,
  6864. animation1 = {},
  6865. animation2 = {};
  6866. $.effects.save( el, props );
  6867. el.show();
  6868. // Create Wrapper
  6869. wrapper = $.effects.createWrapper( el ).css({
  6870. overflow: "hidden"
  6871. });
  6872. distance = widthFirst ?
  6873. [ wrapper.width(), wrapper.height() ] :
  6874. [ wrapper.height(), wrapper.width() ];
  6875. if ( percent ) {
  6876. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  6877. }
  6878. if ( show ) {
  6879. wrapper.css( horizFirst ? {
  6880. height: 0,
  6881. width: size
  6882. } : {
  6883. height: size,
  6884. width: 0
  6885. });
  6886. }
  6887. // Animation
  6888. animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
  6889. animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
  6890. // Animate
  6891. wrapper
  6892. .animate( animation1, duration, o.easing )
  6893. .animate( animation2, duration, o.easing, function() {
  6894. if ( hide ) {
  6895. el.hide();
  6896. }
  6897. $.effects.restore( el, props );
  6898. $.effects.removeWrapper( el );
  6899. done();
  6900. });
  6901. };
  6902. })(jQuery);
  6903. (function( $, undefined ) {
  6904. $.effects.effect.highlight = function( o, done ) {
  6905. var elem = $( this ),
  6906. props = [ "backgroundImage", "backgroundColor", "opacity" ],
  6907. mode = $.effects.setMode( elem, o.mode || "show" ),
  6908. animation = {
  6909. backgroundColor: elem.css( "backgroundColor" )
  6910. };
  6911. if (mode === "hide") {
  6912. animation.opacity = 0;
  6913. }
  6914. $.effects.save( elem, props );
  6915. elem
  6916. .show()
  6917. .css({
  6918. backgroundImage: "none",
  6919. backgroundColor: o.color || "#ffff99"
  6920. })
  6921. .animate( animation, {
  6922. queue: false,
  6923. duration: o.duration,
  6924. easing: o.easing,
  6925. complete: function() {
  6926. if ( mode === "hide" ) {
  6927. elem.hide();
  6928. }
  6929. $.effects.restore( elem, props );
  6930. done();
  6931. }
  6932. });
  6933. };
  6934. })(jQuery);
  6935. (function( $, undefined ) {
  6936. $.effects.effect.pulsate = function( o, done ) {
  6937. var elem = $( this ),
  6938. mode = $.effects.setMode( elem, o.mode || "show" ),
  6939. show = mode === "show",
  6940. hide = mode === "hide",
  6941. showhide = ( show || mode === "hide" ),
  6942. // showing or hiding leaves of the "last" animation
  6943. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  6944. duration = o.duration / anims,
  6945. animateTo = 0,
  6946. queue = elem.queue(),
  6947. queuelen = queue.length,
  6948. i;
  6949. if ( show || !elem.is(":visible")) {
  6950. elem.css( "opacity", 0 ).show();
  6951. animateTo = 1;
  6952. }
  6953. // anims - 1 opacity "toggles"
  6954. for ( i = 1; i < anims; i++ ) {
  6955. elem.animate({
  6956. opacity: animateTo
  6957. }, duration, o.easing );
  6958. animateTo = 1 - animateTo;
  6959. }
  6960. elem.animate({
  6961. opacity: animateTo
  6962. }, duration, o.easing);
  6963. elem.queue(function() {
  6964. if ( hide ) {
  6965. elem.hide();
  6966. }
  6967. done();
  6968. });
  6969. // We just queued up "anims" animations, we need to put them next in the queue
  6970. if ( queuelen > 1 ) {
  6971. queue.splice.apply( queue,
  6972. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  6973. }
  6974. elem.dequeue();
  6975. };
  6976. })(jQuery);
  6977. (function( $, undefined ) {
  6978. $.effects.effect.puff = function( o, done ) {
  6979. var elem = $( this ),
  6980. mode = $.effects.setMode( elem, o.mode || "hide" ),
  6981. hide = mode === "hide",
  6982. percent = parseInt( o.percent, 10 ) || 150,
  6983. factor = percent / 100,
  6984. original = {
  6985. height: elem.height(),
  6986. width: elem.width(),
  6987. outerHeight: elem.outerHeight(),
  6988. outerWidth: elem.outerWidth()
  6989. };
  6990. $.extend( o, {
  6991. effect: "scale",
  6992. queue: false,
  6993. fade: true,
  6994. mode: mode,
  6995. complete: done,
  6996. percent: hide ? percent : 100,
  6997. from: hide ?
  6998. original :
  6999. {
  7000. height: original.height * factor,
  7001. width: original.width * factor,
  7002. outerHeight: original.outerHeight * factor,
  7003. outerWidth: original.outerWidth * factor
  7004. }
  7005. });
  7006. elem.effect( o );
  7007. };
  7008. $.effects.effect.scale = function( o, done ) {
  7009. // Create element
  7010. var el = $( this ),
  7011. options = $.extend( true, {}, o ),
  7012. mode = $.effects.setMode( el, o.mode || "effect" ),
  7013. percent = parseInt( o.percent, 10 ) ||
  7014. ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
  7015. direction = o.direction || "both",
  7016. origin = o.origin,
  7017. original = {
  7018. height: el.height(),
  7019. width: el.width(),
  7020. outerHeight: el.outerHeight(),
  7021. outerWidth: el.outerWidth()
  7022. },
  7023. factor = {
  7024. y: direction !== "horizontal" ? (percent / 100) : 1,
  7025. x: direction !== "vertical" ? (percent / 100) : 1
  7026. };
  7027. // We are going to pass this effect to the size effect:
  7028. options.effect = "size";
  7029. options.queue = false;
  7030. options.complete = done;
  7031. // Set default origin and restore for show/hide
  7032. if ( mode !== "effect" ) {
  7033. options.origin = origin || ["middle","center"];
  7034. options.restore = true;
  7035. }
  7036. options.from = o.from || ( mode === "show" ? {
  7037. height: 0,
  7038. width: 0,
  7039. outerHeight: 0,
  7040. outerWidth: 0
  7041. } : original );
  7042. options.to = {
  7043. height: original.height * factor.y,
  7044. width: original.width * factor.x,
  7045. outerHeight: original.outerHeight * factor.y,
  7046. outerWidth: original.outerWidth * factor.x
  7047. };
  7048. // Fade option to support puff
  7049. if ( options.fade ) {
  7050. if ( mode === "show" ) {
  7051. options.from.opacity = 0;
  7052. options.to.opacity = 1;
  7053. }
  7054. if ( mode === "hide" ) {
  7055. options.from.opacity = 1;
  7056. options.to.opacity = 0;
  7057. }
  7058. }
  7059. // Animate
  7060. el.effect( options );
  7061. };
  7062. $.effects.effect.size = function( o, done ) {
  7063. // Create element
  7064. var original, baseline, factor,
  7065. el = $( this ),
  7066. props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
  7067. // Always restore
  7068. props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
  7069. // Copy for children
  7070. props2 = [ "width", "height", "overflow" ],
  7071. cProps = [ "fontSize" ],
  7072. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  7073. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  7074. // Set options
  7075. mode = $.effects.setMode( el, o.mode || "effect" ),
  7076. restore = o.restore || mode !== "effect",
  7077. scale = o.scale || "both",
  7078. origin = o.origin || [ "middle", "center" ],
  7079. position = el.css( "position" ),
  7080. props = restore ? props0 : props1,
  7081. zero = {
  7082. height: 0,
  7083. width: 0,
  7084. outerHeight: 0,
  7085. outerWidth: 0
  7086. };
  7087. if ( mode === "show" ) {
  7088. el.show();
  7089. }
  7090. original = {
  7091. height: el.height(),
  7092. width: el.width(),
  7093. outerHeight: el.outerHeight(),
  7094. outerWidth: el.outerWidth()
  7095. };
  7096. if ( o.mode === "toggle" && mode === "show" ) {
  7097. el.from = o.to || zero;
  7098. el.to = o.from || original;
  7099. } else {
  7100. el.from = o.from || ( mode === "show" ? zero : original );
  7101. el.to = o.to || ( mode === "hide" ? zero : original );
  7102. }
  7103. // Set scaling factor
  7104. factor = {
  7105. from: {
  7106. y: el.from.height / original.height,
  7107. x: el.from.width / original.width
  7108. },
  7109. to: {
  7110. y: el.to.height / original.height,
  7111. x: el.to.width / original.width
  7112. }
  7113. };
  7114. // Scale the css box
  7115. if ( scale === "box" || scale === "both" ) {
  7116. // Vertical props scaling
  7117. if ( factor.from.y !== factor.to.y ) {
  7118. props = props.concat( vProps );
  7119. el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
  7120. el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
  7121. }
  7122. // Horizontal props scaling
  7123. if ( factor.from.x !== factor.to.x ) {
  7124. props = props.concat( hProps );
  7125. el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
  7126. el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
  7127. }
  7128. }
  7129. // Scale the content
  7130. if ( scale === "content" || scale === "both" ) {
  7131. // Vertical props scaling
  7132. if ( factor.from.y !== factor.to.y ) {
  7133. props = props.concat( cProps ).concat( props2 );
  7134. el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
  7135. el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
  7136. }
  7137. }
  7138. $.effects.save( el, props );
  7139. el.show();
  7140. $.effects.createWrapper( el );
  7141. el.css( "overflow", "hidden" ).css( el.from );
  7142. // Adjust
  7143. if (origin) { // Calculate baseline shifts
  7144. baseline = $.effects.getBaseline( origin, original );
  7145. el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
  7146. el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
  7147. el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
  7148. el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
  7149. }
  7150. el.css( el.from ); // set top & left
  7151. // Animate
  7152. if ( scale === "content" || scale === "both" ) { // Scale the children
  7153. // Add margins/font-size
  7154. vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
  7155. hProps = hProps.concat([ "marginLeft", "marginRight" ]);
  7156. props2 = props0.concat(vProps).concat(hProps);
  7157. el.find( "*[width]" ).each( function(){
  7158. var child = $( this ),
  7159. c_original = {
  7160. height: child.height(),
  7161. width: child.width(),
  7162. outerHeight: child.outerHeight(),
  7163. outerWidth: child.outerWidth()
  7164. };
  7165. if (restore) {
  7166. $.effects.save(child, props2);
  7167. }
  7168. child.from = {
  7169. height: c_original.height * factor.from.y,
  7170. width: c_original.width * factor.from.x,
  7171. outerHeight: c_original.outerHeight * factor.from.y,
  7172. outerWidth: c_original.outerWidth * factor.from.x
  7173. };
  7174. child.to = {
  7175. height: c_original.height * factor.to.y,
  7176. width: c_original.width * factor.to.x,
  7177. outerHeight: c_original.height * factor.to.y,
  7178. outerWidth: c_original.width * factor.to.x
  7179. };
  7180. // Vertical props scaling
  7181. if ( factor.from.y !== factor.to.y ) {
  7182. child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
  7183. child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
  7184. }
  7185. // Horizontal props scaling
  7186. if ( factor.from.x !== factor.to.x ) {
  7187. child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
  7188. child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
  7189. }
  7190. // Animate children
  7191. child.css( child.from );
  7192. child.animate( child.to, o.duration, o.easing, function() {
  7193. // Restore children
  7194. if ( restore ) {
  7195. $.effects.restore( child, props2 );
  7196. }
  7197. });
  7198. });
  7199. }
  7200. // Animate
  7201. el.animate( el.to, {
  7202. queue: false,
  7203. duration: o.duration,
  7204. easing: o.easing,
  7205. complete: function() {
  7206. if ( el.to.opacity === 0 ) {
  7207. el.css( "opacity", el.from.opacity );
  7208. }
  7209. if( mode === "hide" ) {
  7210. el.hide();
  7211. }
  7212. $.effects.restore( el, props );
  7213. if ( !restore ) {
  7214. // we need to calculate our new positioning based on the scaling
  7215. if ( position === "static" ) {
  7216. el.css({
  7217. position: "relative",
  7218. top: el.to.top,
  7219. left: el.to.left
  7220. });
  7221. } else {
  7222. $.each([ "top", "left" ], function( idx, pos ) {
  7223. el.css( pos, function( _, str ) {
  7224. var val = parseInt( str, 10 ),
  7225. toRef = idx ? el.to.left : el.to.top;
  7226. // if original was "auto", recalculate the new value from wrapper
  7227. if ( str === "auto" ) {
  7228. return toRef + "px";
  7229. }
  7230. return val + toRef + "px";
  7231. });
  7232. });
  7233. }
  7234. }
  7235. $.effects.removeWrapper( el );
  7236. done();
  7237. }
  7238. });
  7239. };
  7240. })(jQuery);
  7241. (function( $, undefined ) {
  7242. $.effects.effect.shake = function( o, done ) {
  7243. var el = $( this ),
  7244. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  7245. mode = $.effects.setMode( el, o.mode || "effect" ),
  7246. direction = o.direction || "left",
  7247. distance = o.distance || 20,
  7248. times = o.times || 3,
  7249. anims = times * 2 + 1,
  7250. speed = Math.round(o.duration/anims),
  7251. ref = (direction === "up" || direction === "down") ? "top" : "left",
  7252. positiveMotion = (direction === "up" || direction === "left"),
  7253. animation = {},
  7254. animation1 = {},
  7255. animation2 = {},
  7256. i,
  7257. // we will need to re-assemble the queue to stack our animations in place
  7258. queue = el.queue(),
  7259. queuelen = queue.length;
  7260. $.effects.save( el, props );
  7261. el.show();
  7262. $.effects.createWrapper( el );
  7263. // Animation
  7264. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  7265. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  7266. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  7267. // Animate
  7268. el.animate( animation, speed, o.easing );
  7269. // Shakes
  7270. for ( i = 1; i < times; i++ ) {
  7271. el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
  7272. }
  7273. el
  7274. .animate( animation1, speed, o.easing )
  7275. .animate( animation, speed / 2, o.easing )
  7276. .queue(function() {
  7277. if ( mode === "hide" ) {
  7278. el.hide();
  7279. }
  7280. $.effects.restore( el, props );
  7281. $.effects.removeWrapper( el );
  7282. done();
  7283. });
  7284. // inject all the animations we just queued to be first in line (after "inprogress")
  7285. if ( queuelen > 1) {
  7286. queue.splice.apply( queue,
  7287. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  7288. }
  7289. el.dequeue();
  7290. };
  7291. })(jQuery);
  7292. (function( $, undefined ) {
  7293. $.effects.effect.slide = function( o, done ) {
  7294. // Create element
  7295. var el = $( this ),
  7296. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  7297. mode = $.effects.setMode( el, o.mode || "show" ),
  7298. show = mode === "show",
  7299. direction = o.direction || "left",
  7300. ref = (direction === "up" || direction === "down") ? "top" : "left",
  7301. positiveMotion = (direction === "up" || direction === "left"),
  7302. distance,
  7303. animation = {};
  7304. // Adjust
  7305. $.effects.save( el, props );
  7306. el.show();
  7307. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  7308. $.effects.createWrapper( el ).css({
  7309. overflow: "hidden"
  7310. });
  7311. if ( show ) {
  7312. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  7313. }
  7314. // Animation
  7315. animation[ ref ] = ( show ?
  7316. ( positiveMotion ? "+=" : "-=") :
  7317. ( positiveMotion ? "-=" : "+=")) +
  7318. distance;
  7319. // Animate
  7320. el.animate( animation, {
  7321. queue: false,
  7322. duration: o.duration,
  7323. easing: o.easing,
  7324. complete: function() {
  7325. if ( mode === "hide" ) {
  7326. el.hide();
  7327. }
  7328. $.effects.restore( el, props );
  7329. $.effects.removeWrapper( el );
  7330. done();
  7331. }
  7332. });
  7333. };
  7334. })(jQuery);
  7335. (function( $, undefined ) {
  7336. $.effects.effect.transfer = function( o, done ) {
  7337. var elem = $( this ),
  7338. target = $( o.to ),
  7339. targetFixed = target.css( "position" ) === "fixed",
  7340. body = $("body"),
  7341. fixTop = targetFixed ? body.scrollTop() : 0,
  7342. fixLeft = targetFixed ? body.scrollLeft() : 0,
  7343. endPosition = target.offset(),
  7344. animation = {
  7345. top: endPosition.top - fixTop ,
  7346. left: endPosition.left - fixLeft ,
  7347. height: target.innerHeight(),
  7348. width: target.innerWidth()
  7349. },
  7350. startPosition = elem.offset(),
  7351. transfer = $( "<div class='ui-effects-transfer'></div>" )
  7352. .appendTo( document.body )
  7353. .addClass( o.className )
  7354. .css({
  7355. top: startPosition.top - fixTop ,
  7356. left: startPosition.left - fixLeft ,
  7357. height: elem.innerHeight(),
  7358. width: elem.innerWidth(),
  7359. position: targetFixed ? "fixed" : "absolute"
  7360. })
  7361. .animate( animation, o.duration, o.easing, function() {
  7362. transfer.remove();
  7363. done();
  7364. });
  7365. };
  7366. })(jQuery);