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. }
  2479. }
  2480. };
  2481. //TODO: make renderAxis a prototype function
  2482. this._renderAxis(this.element);
  2483. this._handles = $(".ui-resizable-handle", this.element)
  2484. .disableSelection();
  2485. //Matching axis name
  2486. this._handles.mouseover(function() {
  2487. if (!that.resizing) {
  2488. if (this.className) {
  2489. axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  2490. }
  2491. //Axis, default = se
  2492. that.axis = axis && axis[1] ? axis[1] : "se";
  2493. }
  2494. });
  2495. //If we want to auto hide the elements
  2496. if (o.autoHide) {
  2497. this._handles.hide();
  2498. $(this.element)
  2499. .addClass("ui-resizable-autohide")
  2500. .mouseenter(function() {
  2501. if (o.disabled) {
  2502. return;
  2503. }
  2504. $(this).removeClass("ui-resizable-autohide");
  2505. that._handles.show();
  2506. })
  2507. .mouseleave(function(){
  2508. if (o.disabled) {
  2509. return;
  2510. }
  2511. if (!that.resizing) {
  2512. $(this).addClass("ui-resizable-autohide");
  2513. that._handles.hide();
  2514. }
  2515. });
  2516. }
  2517. //Initialize the mouse interaction
  2518. this._mouseInit();
  2519. },
  2520. _destroy: function() {
  2521. this._mouseDestroy();
  2522. var wrapper,
  2523. _destroy = function(exp) {
  2524. $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  2525. .removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove();
  2526. };
  2527. //TODO: Unwrap at same DOM position
  2528. if (this.elementIsWrapper) {
  2529. _destroy(this.element);
  2530. wrapper = this.element;
  2531. this.originalElement.css({
  2532. position: wrapper.css("position"),
  2533. width: wrapper.outerWidth(),
  2534. height: wrapper.outerHeight(),
  2535. top: wrapper.css("top"),
  2536. left: wrapper.css("left")
  2537. }).insertAfter( wrapper );
  2538. wrapper.remove();
  2539. }
  2540. this.originalElement.css("resize", this.originalResizeStyle);
  2541. _destroy(this.originalElement);
  2542. return this;
  2543. },
  2544. _mouseCapture: function(event) {
  2545. var i, handle,
  2546. capture = false;
  2547. for (i in this.handles) {
  2548. handle = $(this.handles[i])[0];
  2549. if (handle === event.target || $.contains(handle, event.target)) {
  2550. capture = true;
  2551. }
  2552. }
  2553. return !this.options.disabled && capture;
  2554. },
  2555. _mouseStart: function(event) {
  2556. var curleft, curtop, cursor,
  2557. o = this.options,
  2558. iniPos = this.element.position(),
  2559. el = this.element;
  2560. this.resizing = true;
  2561. // bugfix for http://dev.jquery.com/ticket/1749
  2562. if ( (/absolute/).test( el.css("position") ) ) {
  2563. el.css({ position: "absolute", top: el.css("top"), left: el.css("left") });
  2564. } else if (el.is(".ui-draggable")) {
  2565. el.css({ position: "absolute", top: iniPos.top, left: iniPos.left });
  2566. }
  2567. this._renderProxy();
  2568. curleft = num(this.helper.css("left"));
  2569. curtop = num(this.helper.css("top"));
  2570. if (o.containment) {
  2571. curleft += $(o.containment).scrollLeft() || 0;
  2572. curtop += $(o.containment).scrollTop() || 0;
  2573. }
  2574. //Store needed variables
  2575. this.offset = this.helper.offset();
  2576. this.position = { left: curleft, top: curtop };
  2577. this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  2578. this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  2579. this.originalPosition = { left: curleft, top: curtop };
  2580. this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
  2581. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  2582. //Aspect Ratio
  2583. this.aspectRatio = (typeof o.aspectRatio === "number") ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
  2584. cursor = $(".ui-resizable-" + this.axis).css("cursor");
  2585. $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
  2586. el.addClass("ui-resizable-resizing");
  2587. this._propagate("start", event);
  2588. return true;
  2589. },
  2590. _mouseDrag: function(event) {
  2591. //Increase performance, avoid regex
  2592. var data,
  2593. el = this.helper, props = {},
  2594. smp = this.originalMousePosition,
  2595. a = this.axis,
  2596. prevTop = this.position.top,
  2597. prevLeft = this.position.left,
  2598. prevWidth = this.size.width,
  2599. prevHeight = this.size.height,
  2600. dx = (event.pageX-smp.left)||0,
  2601. dy = (event.pageY-smp.top)||0,
  2602. trigger = this._change[a];
  2603. if (!trigger) {
  2604. return false;
  2605. }
  2606. // Calculate the attrs that will be change
  2607. data = trigger.apply(this, [event, dx, dy]);
  2608. // Put this in the mouseDrag handler since the user can start pressing shift while resizing
  2609. this._updateVirtualBoundaries(event.shiftKey);
  2610. if (this._aspectRatio || event.shiftKey) {
  2611. data = this._updateRatio(data, event);
  2612. }
  2613. data = this._respectSize(data, event);
  2614. this._updateCache(data);
  2615. // plugins callbacks need to be called first
  2616. this._propagate("resize", event);
  2617. if (this.position.top !== prevTop) {
  2618. props.top = this.position.top + "px";
  2619. }
  2620. if (this.position.left !== prevLeft) {
  2621. props.left = this.position.left + "px";
  2622. }
  2623. if (this.size.width !== prevWidth) {
  2624. props.width = this.size.width + "px";
  2625. }
  2626. if (this.size.height !== prevHeight) {
  2627. props.height = this.size.height + "px";
  2628. }
  2629. el.css(props);
  2630. if (!this._helper && this._proportionallyResizeElements.length) {
  2631. this._proportionallyResize();
  2632. }
  2633. // Call the user callback if the element was resized
  2634. if ( ! $.isEmptyObject(props) ) {
  2635. this._trigger("resize", event, this.ui());
  2636. }
  2637. return false;
  2638. },
  2639. _mouseStop: function(event) {
  2640. this.resizing = false;
  2641. var pr, ista, soffseth, soffsetw, s, left, top,
  2642. o = this.options, that = this;
  2643. if(this._helper) {
  2644. pr = this._proportionallyResizeElements;
  2645. ista = pr.length && (/textarea/i).test(pr[0].nodeName);
  2646. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height;
  2647. soffsetw = ista ? 0 : that.sizeDiff.width;
  2648. s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) };
  2649. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null;
  2650. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  2651. if (!o.animate) {
  2652. this.element.css($.extend(s, { top: top, left: left }));
  2653. }
  2654. that.helper.height(that.size.height);
  2655. that.helper.width(that.size.width);
  2656. if (this._helper && !o.animate) {
  2657. this._proportionallyResize();
  2658. }
  2659. }
  2660. $("body").css("cursor", "auto");
  2661. this.element.removeClass("ui-resizable-resizing");
  2662. this._propagate("stop", event);
  2663. if (this._helper) {
  2664. this.helper.remove();
  2665. }
  2666. return false;
  2667. },
  2668. _updateVirtualBoundaries: function(forceAspectRatio) {
  2669. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  2670. o = this.options;
  2671. b = {
  2672. minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
  2673. maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  2674. minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
  2675. maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
  2676. };
  2677. if(this._aspectRatio || forceAspectRatio) {
  2678. // We want to create an enclosing box whose aspect ration is the requested one
  2679. // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
  2680. pMinWidth = b.minHeight * this.aspectRatio;
  2681. pMinHeight = b.minWidth / this.aspectRatio;
  2682. pMaxWidth = b.maxHeight * this.aspectRatio;
  2683. pMaxHeight = b.maxWidth / this.aspectRatio;
  2684. if(pMinWidth > b.minWidth) {
  2685. b.minWidth = pMinWidth;
  2686. }
  2687. if(pMinHeight > b.minHeight) {
  2688. b.minHeight = pMinHeight;
  2689. }
  2690. if(pMaxWidth < b.maxWidth) {
  2691. b.maxWidth = pMaxWidth;
  2692. }
  2693. if(pMaxHeight < b.maxHeight) {
  2694. b.maxHeight = pMaxHeight;
  2695. }
  2696. }
  2697. this._vBoundaries = b;
  2698. },
  2699. _updateCache: function(data) {
  2700. this.offset = this.helper.offset();
  2701. if (isNumber(data.left)) {
  2702. this.position.left = data.left;
  2703. }
  2704. if (isNumber(data.top)) {
  2705. this.position.top = data.top;
  2706. }
  2707. if (isNumber(data.height)) {
  2708. this.size.height = data.height;
  2709. }
  2710. if (isNumber(data.width)) {
  2711. this.size.width = data.width;
  2712. }
  2713. },
  2714. _updateRatio: function( data ) {
  2715. var cpos = this.position,
  2716. csize = this.size,
  2717. a = this.axis;
  2718. if (isNumber(data.height)) {
  2719. data.width = (data.height * this.aspectRatio);
  2720. } else if (isNumber(data.width)) {
  2721. data.height = (data.width / this.aspectRatio);
  2722. }
  2723. if (a === "sw") {
  2724. data.left = cpos.left + (csize.width - data.width);
  2725. data.top = null;
  2726. }
  2727. if (a === "nw") {
  2728. data.top = cpos.top + (csize.height - data.height);
  2729. data.left = cpos.left + (csize.width - data.width);
  2730. }
  2731. return data;
  2732. },
  2733. _respectSize: function( data ) {
  2734. var o = this._vBoundaries,
  2735. a = this.axis,
  2736. ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  2737. isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
  2738. dw = this.originalPosition.left + this.originalSize.width,
  2739. dh = this.position.top + this.size.height,
  2740. cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  2741. if (isminw) {
  2742. data.width = o.minWidth;
  2743. }
  2744. if (isminh) {
  2745. data.height = o.minHeight;
  2746. }
  2747. if (ismaxw) {
  2748. data.width = o.maxWidth;
  2749. }
  2750. if (ismaxh) {
  2751. data.height = o.maxHeight;
  2752. }
  2753. if (isminw && cw) {
  2754. data.left = dw - o.minWidth;
  2755. }
  2756. if (ismaxw && cw) {
  2757. data.left = dw - o.maxWidth;
  2758. }
  2759. if (isminh && ch) {
  2760. data.top = dh - o.minHeight;
  2761. }
  2762. if (ismaxh && ch) {
  2763. data.top = dh - o.maxHeight;
  2764. }
  2765. // fixing jump error on top/left - bug #2330
  2766. if (!data.width && !data.height && !data.left && data.top) {
  2767. data.top = null;
  2768. } else if (!data.width && !data.height && !data.top && data.left) {
  2769. data.left = null;
  2770. }
  2771. return data;
  2772. },
  2773. _proportionallyResize: function() {
  2774. if (!this._proportionallyResizeElements.length) {
  2775. return;
  2776. }
  2777. var i, j, borders, paddings, prel,
  2778. element = this.helper || this.element;
  2779. for ( i=0; i < this._proportionallyResizeElements.length; i++) {
  2780. prel = this._proportionallyResizeElements[i];
  2781. if (!this.borderDif) {
  2782. this.borderDif = [];
  2783. borders = [prel.css("borderTopWidth"), prel.css("borderRightWidth"), prel.css("borderBottomWidth"), prel.css("borderLeftWidth")];
  2784. paddings = [prel.css("paddingTop"), prel.css("paddingRight"), prel.css("paddingBottom"), prel.css("paddingLeft")];
  2785. for ( j = 0; j < borders.length; j++ ) {
  2786. this.borderDif[ j ] = ( parseInt( borders[ j ], 10 ) || 0 ) + ( parseInt( paddings[ j ], 10 ) || 0 );
  2787. }
  2788. }
  2789. prel.css({
  2790. height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
  2791. width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
  2792. });
  2793. }
  2794. },
  2795. _renderProxy: function() {
  2796. var el = this.element, o = this.options;
  2797. this.elementOffset = el.offset();
  2798. if(this._helper) {
  2799. this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
  2800. this.helper.addClass(this._helper).css({
  2801. width: this.element.outerWidth() - 1,
  2802. height: this.element.outerHeight() - 1,
  2803. position: "absolute",
  2804. left: this.elementOffset.left +"px",
  2805. top: this.elementOffset.top +"px",
  2806. zIndex: ++o.zIndex //TODO: Don't modify option
  2807. });
  2808. this.helper
  2809. .appendTo("body")
  2810. .disableSelection();
  2811. } else {
  2812. this.helper = this.element;
  2813. }
  2814. },
  2815. _change: {
  2816. e: function(event, dx) {
  2817. return { width: this.originalSize.width + dx };
  2818. },
  2819. w: function(event, dx) {
  2820. var cs = this.originalSize, sp = this.originalPosition;
  2821. return { left: sp.left + dx, width: cs.width - dx };
  2822. },
  2823. n: function(event, dx, dy) {
  2824. var cs = this.originalSize, sp = this.originalPosition;
  2825. return { top: sp.top + dy, height: cs.height - dy };
  2826. },
  2827. s: function(event, dx, dy) {
  2828. return { height: this.originalSize.height + dy };
  2829. },
  2830. se: function(event, dx, dy) {
  2831. return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  2832. },
  2833. sw: function(event, dx, dy) {
  2834. return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  2835. },
  2836. ne: function(event, dx, dy) {
  2837. return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  2838. },
  2839. nw: function(event, dx, dy) {
  2840. return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  2841. }
  2842. },
  2843. _propagate: function(n, event) {
  2844. $.ui.plugin.call(this, n, [event, this.ui()]);
  2845. (n !== "resize" && this._trigger(n, event, this.ui()));
  2846. },
  2847. plugins: {},
  2848. ui: function() {
  2849. return {
  2850. originalElement: this.originalElement,
  2851. element: this.element,
  2852. helper: this.helper,
  2853. position: this.position,
  2854. size: this.size,
  2855. originalSize: this.originalSize,
  2856. originalPosition: this.originalPosition
  2857. };
  2858. }
  2859. });
  2860. /*
  2861. * Resizable Extensions
  2862. */
  2863. $.ui.plugin.add("resizable", "animate", {
  2864. stop: function( event ) {
  2865. var that = $(this).data("ui-resizable"),
  2866. o = that.options,
  2867. pr = that._proportionallyResizeElements,
  2868. ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  2869. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height,
  2870. soffsetw = ista ? 0 : that.sizeDiff.width,
  2871. style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  2872. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null,
  2873. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  2874. that.element.animate(
  2875. $.extend(style, top && left ? { top: top, left: left } : {}), {
  2876. duration: o.animateDuration,
  2877. easing: o.animateEasing,
  2878. step: function() {
  2879. var data = {
  2880. width: parseInt(that.element.css("width"), 10),
  2881. height: parseInt(that.element.css("height"), 10),
  2882. top: parseInt(that.element.css("top"), 10),
  2883. left: parseInt(that.element.css("left"), 10)
  2884. };
  2885. if (pr && pr.length) {
  2886. $(pr[0]).css({ width: data.width, height: data.height });
  2887. }
  2888. // propagating resize, and updating values for each animation step
  2889. that._updateCache(data);
  2890. that._propagate("resize", event);
  2891. }
  2892. }
  2893. );
  2894. }
  2895. });
  2896. $.ui.plugin.add("resizable", "containment", {
  2897. start: function() {
  2898. var element, p, co, ch, cw, width, height,
  2899. that = $(this).data("ui-resizable"),
  2900. o = that.options,
  2901. el = that.element,
  2902. oc = o.containment,
  2903. ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
  2904. if (!ce) {
  2905. return;
  2906. }
  2907. that.containerElement = $(ce);
  2908. if (/document/.test(oc) || oc === document) {
  2909. that.containerOffset = { left: 0, top: 0 };
  2910. that.containerPosition = { left: 0, top: 0 };
  2911. that.parentData = {
  2912. element: $(document), left: 0, top: 0,
  2913. width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
  2914. };
  2915. }
  2916. // i'm a node, so compute top, left, right, bottom
  2917. else {
  2918. element = $(ce);
  2919. p = [];
  2920. $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
  2921. that.containerOffset = element.offset();
  2922. that.containerPosition = element.position();
  2923. that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
  2924. co = that.containerOffset;
  2925. ch = that.containerSize.height;
  2926. cw = that.containerSize.width;
  2927. width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw );
  2928. height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
  2929. that.parentData = {
  2930. element: ce, left: co.left, top: co.top, width: width, height: height
  2931. };
  2932. }
  2933. },
  2934. resize: function( event ) {
  2935. var woset, hoset, isParent, isOffsetRelative,
  2936. that = $(this).data("ui-resizable"),
  2937. o = that.options,
  2938. co = that.containerOffset, cp = that.position,
  2939. pRatio = that._aspectRatio || event.shiftKey,
  2940. cop = { top:0, left:0 }, ce = that.containerElement;
  2941. if (ce[0] !== document && (/static/).test(ce.css("position"))) {
  2942. cop = co;
  2943. }
  2944. if (cp.left < (that._helper ? co.left : 0)) {
  2945. that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left));
  2946. if (pRatio) {
  2947. that.size.height = that.size.width / that.aspectRatio;
  2948. }
  2949. that.position.left = o.helper ? co.left : 0;
  2950. }
  2951. if (cp.top < (that._helper ? co.top : 0)) {
  2952. that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top);
  2953. if (pRatio) {
  2954. that.size.width = that.size.height * that.aspectRatio;
  2955. }
  2956. that.position.top = that._helper ? co.top : 0;
  2957. }
  2958. that.offset.left = that.parentData.left+that.position.left;
  2959. that.offset.top = that.parentData.top+that.position.top;
  2960. woset = Math.abs( (that._helper ? that.offset.left - cop.left : (that.offset.left - cop.left)) + that.sizeDiff.width );
  2961. hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height );
  2962. isParent = that.containerElement.get(0) === that.element.parent().get(0);
  2963. isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position"));
  2964. if(isParent && isOffsetRelative) {
  2965. woset -= that.parentData.left;
  2966. }
  2967. if (woset + that.size.width >= that.parentData.width) {
  2968. that.size.width = that.parentData.width - woset;
  2969. if (pRatio) {
  2970. that.size.height = that.size.width / that.aspectRatio;
  2971. }
  2972. }
  2973. if (hoset + that.size.height >= that.parentData.height) {
  2974. that.size.height = that.parentData.height - hoset;
  2975. if (pRatio) {
  2976. that.size.width = that.size.height * that.aspectRatio;
  2977. }
  2978. }
  2979. },
  2980. stop: function(){
  2981. var that = $(this).data("ui-resizable"),
  2982. o = that.options,
  2983. co = that.containerOffset,
  2984. cop = that.containerPosition,
  2985. ce = that.containerElement,
  2986. helper = $(that.helper),
  2987. ho = helper.offset(),
  2988. w = helper.outerWidth() - that.sizeDiff.width,
  2989. h = helper.outerHeight() - that.sizeDiff.height;
  2990. if (that._helper && !o.animate && (/relative/).test(ce.css("position"))) {
  2991. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2992. }
  2993. if (that._helper && !o.animate && (/static/).test(ce.css("position"))) {
  2994. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2995. }
  2996. }
  2997. });
  2998. $.ui.plugin.add("resizable", "alsoResize", {
  2999. start: function () {
  3000. var that = $(this).data("ui-resizable"),
  3001. o = that.options,
  3002. _store = function (exp) {
  3003. $(exp).each(function() {
  3004. var el = $(this);
  3005. el.data("ui-resizable-alsoresize", {
  3006. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  3007. left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
  3008. });
  3009. });
  3010. };
  3011. if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) {
  3012. if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
  3013. else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
  3014. }else{
  3015. _store(o.alsoResize);
  3016. }
  3017. },
  3018. resize: function (event, ui) {
  3019. var that = $(this).data("ui-resizable"),
  3020. o = that.options,
  3021. os = that.originalSize,
  3022. op = that.originalPosition,
  3023. delta = {
  3024. height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
  3025. top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
  3026. },
  3027. _alsoResize = function (exp, c) {
  3028. $(exp).each(function() {
  3029. var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
  3030. css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ["width", "height"] : ["width", "height", "top", "left"];
  3031. $.each(css, function (i, prop) {
  3032. var sum = (start[prop]||0) + (delta[prop]||0);
  3033. if (sum && sum >= 0) {
  3034. style[prop] = sum || null;
  3035. }
  3036. });
  3037. el.css(style);
  3038. });
  3039. };
  3040. if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) {
  3041. $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
  3042. }else{
  3043. _alsoResize(o.alsoResize);
  3044. }
  3045. },
  3046. stop: function () {
  3047. $(this).removeData("resizable-alsoresize");
  3048. }
  3049. });
  3050. $.ui.plugin.add("resizable", "ghost", {
  3051. start: function() {
  3052. var that = $(this).data("ui-resizable"), o = that.options, cs = that.size;
  3053. that.ghost = that.originalElement.clone();
  3054. that.ghost
  3055. .css({ opacity: 0.25, display: "block", position: "relative", height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
  3056. .addClass("ui-resizable-ghost")
  3057. .addClass(typeof o.ghost === "string" ? o.ghost : "");
  3058. that.ghost.appendTo(that.helper);
  3059. },
  3060. resize: function(){
  3061. var that = $(this).data("ui-resizable");
  3062. if (that.ghost) {
  3063. that.ghost.css({ position: "relative", height: that.size.height, width: that.size.width });
  3064. }
  3065. },
  3066. stop: function() {
  3067. var that = $(this).data("ui-resizable");
  3068. if (that.ghost && that.helper) {
  3069. that.helper.get(0).removeChild(that.ghost.get(0));
  3070. }
  3071. }
  3072. });
  3073. $.ui.plugin.add("resizable", "grid", {
  3074. resize: function() {
  3075. var that = $(this).data("ui-resizable"),
  3076. o = that.options,
  3077. cs = that.size,
  3078. os = that.originalSize,
  3079. op = that.originalPosition,
  3080. a = that.axis,
  3081. grid = typeof o.grid === "number" ? [o.grid, o.grid] : o.grid,
  3082. gridX = (grid[0]||1),
  3083. gridY = (grid[1]||1),
  3084. ox = Math.round((cs.width - os.width) / gridX) * gridX,
  3085. oy = Math.round((cs.height - os.height) / gridY) * gridY,
  3086. newWidth = os.width + ox,
  3087. newHeight = os.height + oy,
  3088. isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
  3089. isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
  3090. isMinWidth = o.minWidth && (o.minWidth > newWidth),
  3091. isMinHeight = o.minHeight && (o.minHeight > newHeight);
  3092. o.grid = grid;
  3093. if (isMinWidth) {
  3094. newWidth = newWidth + gridX;
  3095. }
  3096. if (isMinHeight) {
  3097. newHeight = newHeight + gridY;
  3098. }
  3099. if (isMaxWidth) {
  3100. newWidth = newWidth - gridX;
  3101. }
  3102. if (isMaxHeight) {
  3103. newHeight = newHeight - gridY;
  3104. }
  3105. if (/^(se|s|e)$/.test(a)) {
  3106. that.size.width = newWidth;
  3107. that.size.height = newHeight;
  3108. } else if (/^(ne)$/.test(a)) {
  3109. that.size.width = newWidth;
  3110. that.size.height = newHeight;
  3111. that.position.top = op.top - oy;
  3112. } else if (/^(sw)$/.test(a)) {
  3113. that.size.width = newWidth;
  3114. that.size.height = newHeight;
  3115. that.position.left = op.left - ox;
  3116. } else {
  3117. that.size.width = newWidth;
  3118. that.size.height = newHeight;
  3119. that.position.top = op.top - oy;
  3120. that.position.left = op.left - ox;
  3121. }
  3122. }
  3123. });
  3124. })(jQuery);
  3125. (function( $, undefined ) {
  3126. $.widget("ui.selectable", $.ui.mouse, {
  3127. version: "1.10.3",
  3128. options: {
  3129. appendTo: "body",
  3130. autoRefresh: true,
  3131. distance: 0,
  3132. filter: "*",
  3133. tolerance: "touch",
  3134. // callbacks
  3135. selected: null,
  3136. selecting: null,
  3137. start: null,
  3138. stop: null,
  3139. unselected: null,
  3140. unselecting: null
  3141. },
  3142. _create: function() {
  3143. var selectees,
  3144. that = this;
  3145. this.element.addClass("ui-selectable");
  3146. this.dragged = false;
  3147. // cache selectee children based on filter
  3148. this.refresh = function() {
  3149. selectees = $(that.options.filter, that.element[0]);
  3150. selectees.addClass("ui-selectee");
  3151. selectees.each(function() {
  3152. var $this = $(this),
  3153. pos = $this.offset();
  3154. $.data(this, "selectable-item", {
  3155. element: this,
  3156. $element: $this,
  3157. left: pos.left,
  3158. top: pos.top,
  3159. right: pos.left + $this.outerWidth(),
  3160. bottom: pos.top + $this.outerHeight(),
  3161. startselected: false,
  3162. selected: $this.hasClass("ui-selected"),
  3163. selecting: $this.hasClass("ui-selecting"),
  3164. unselecting: $this.hasClass("ui-unselecting")
  3165. });
  3166. });
  3167. };
  3168. this.refresh();
  3169. this.selectees = selectees.addClass("ui-selectee");
  3170. this._mouseInit();
  3171. this.helper = $("<div class='ui-selectable-helper'></div>");
  3172. },
  3173. _destroy: function() {
  3174. this.selectees
  3175. .removeClass("ui-selectee")
  3176. .removeData("selectable-item");
  3177. this.element
  3178. .removeClass("ui-selectable ui-selectable-disabled");
  3179. this._mouseDestroy();
  3180. },
  3181. _mouseStart: function(event) {
  3182. var that = this,
  3183. options = this.options;
  3184. this.opos = [event.pageX, event.pageY];
  3185. if (this.options.disabled) {
  3186. return;
  3187. }
  3188. this.selectees = $(options.filter, this.element[0]);
  3189. this._trigger("start", event);
  3190. $(options.appendTo).append(this.helper);
  3191. // position helper (lasso)
  3192. this.helper.css({
  3193. "left": event.pageX,
  3194. "top": event.pageY,
  3195. "width": 0,
  3196. "height": 0
  3197. });
  3198. if (options.autoRefresh) {
  3199. this.refresh();
  3200. }
  3201. this.selectees.filter(".ui-selected").each(function() {
  3202. var selectee = $.data(this, "selectable-item");
  3203. selectee.startselected = true;
  3204. if (!event.metaKey && !event.ctrlKey) {
  3205. selectee.$element.removeClass("ui-selected");
  3206. selectee.selected = false;
  3207. selectee.$element.addClass("ui-unselecting");
  3208. selectee.unselecting = true;
  3209. // selectable UNSELECTING callback
  3210. that._trigger("unselecting", event, {
  3211. unselecting: selectee.element
  3212. });
  3213. }
  3214. });
  3215. $(event.target).parents().addBack().each(function() {
  3216. var doSelect,
  3217. selectee = $.data(this, "selectable-item");
  3218. if (selectee) {
  3219. doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
  3220. selectee.$element
  3221. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  3222. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  3223. selectee.unselecting = !doSelect;
  3224. selectee.selecting = doSelect;
  3225. selectee.selected = doSelect;
  3226. // selectable (UN)SELECTING callback
  3227. if (doSelect) {
  3228. that._trigger("selecting", event, {
  3229. selecting: selectee.element
  3230. });
  3231. } else {
  3232. that._trigger("unselecting", event, {
  3233. unselecting: selectee.element
  3234. });
  3235. }
  3236. return false;
  3237. }
  3238. });
  3239. },
  3240. _mouseDrag: function(event) {
  3241. this.dragged = true;
  3242. if (this.options.disabled) {
  3243. return;
  3244. }
  3245. var tmp,
  3246. that = this,
  3247. options = this.options,
  3248. x1 = this.opos[0],
  3249. y1 = this.opos[1],
  3250. x2 = event.pageX,
  3251. y2 = event.pageY;
  3252. if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
  3253. if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
  3254. this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
  3255. this.selectees.each(function() {
  3256. var selectee = $.data(this, "selectable-item"),
  3257. hit = false;
  3258. //prevent helper from being selected if appendTo: selectable
  3259. if (!selectee || selectee.element === that.element[0]) {
  3260. return;
  3261. }
  3262. if (options.tolerance === "touch") {
  3263. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  3264. } else if (options.tolerance === "fit") {
  3265. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  3266. }
  3267. if (hit) {
  3268. // SELECT
  3269. if (selectee.selected) {
  3270. selectee.$element.removeClass("ui-selected");
  3271. selectee.selected = false;
  3272. }
  3273. if (selectee.unselecting) {
  3274. selectee.$element.removeClass("ui-unselecting");
  3275. selectee.unselecting = false;
  3276. }
  3277. if (!selectee.selecting) {
  3278. selectee.$element.addClass("ui-selecting");
  3279. selectee.selecting = true;
  3280. // selectable SELECTING callback
  3281. that._trigger("selecting", event, {
  3282. selecting: selectee.element
  3283. });
  3284. }
  3285. } else {
  3286. // UNSELECT
  3287. if (selectee.selecting) {
  3288. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  3289. selectee.$element.removeClass("ui-selecting");
  3290. selectee.selecting = false;
  3291. selectee.$element.addClass("ui-selected");
  3292. selectee.selected = true;
  3293. } else {
  3294. selectee.$element.removeClass("ui-selecting");
  3295. selectee.selecting = false;
  3296. if (selectee.startselected) {
  3297. selectee.$element.addClass("ui-unselecting");
  3298. selectee.unselecting = true;
  3299. }
  3300. // selectable UNSELECTING callback
  3301. that._trigger("unselecting", event, {
  3302. unselecting: selectee.element
  3303. });
  3304. }
  3305. }
  3306. if (selectee.selected) {
  3307. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  3308. selectee.$element.removeClass("ui-selected");
  3309. selectee.selected = false;
  3310. selectee.$element.addClass("ui-unselecting");
  3311. selectee.unselecting = true;
  3312. // selectable UNSELECTING callback
  3313. that._trigger("unselecting", event, {
  3314. unselecting: selectee.element
  3315. });
  3316. }
  3317. }
  3318. }
  3319. });
  3320. return false;
  3321. },
  3322. _mouseStop: function(event) {
  3323. var that = this;
  3324. this.dragged = false;
  3325. $(".ui-unselecting", this.element[0]).each(function() {
  3326. var selectee = $.data(this, "selectable-item");
  3327. selectee.$element.removeClass("ui-unselecting");
  3328. selectee.unselecting = false;
  3329. selectee.startselected = false;
  3330. that._trigger("unselected", event, {
  3331. unselected: selectee.element
  3332. });
  3333. });
  3334. $(".ui-selecting", this.element[0]).each(function() {
  3335. var selectee = $.data(this, "selectable-item");
  3336. selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
  3337. selectee.selecting = false;
  3338. selectee.selected = true;
  3339. selectee.startselected = true;
  3340. that._trigger("selected", event, {
  3341. selected: selectee.element
  3342. });
  3343. });
  3344. this._trigger("stop", event);
  3345. this.helper.remove();
  3346. return false;
  3347. }
  3348. });
  3349. })(jQuery);
  3350. (function( $, undefined ) {
  3351. /*jshint loopfunc: true */
  3352. function isOverAxis( x, reference, size ) {
  3353. return ( x > reference ) && ( x < ( reference + size ) );
  3354. }
  3355. function isFloating(item) {
  3356. return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
  3357. }
  3358. $.widget("ui.sortable", $.ui.mouse, {
  3359. version: "1.10.3",
  3360. widgetEventPrefix: "sort",
  3361. ready: false,
  3362. options: {
  3363. appendTo: "parent",
  3364. axis: false,
  3365. connectWith: false,
  3366. containment: false,
  3367. cursor: "auto",
  3368. cursorAt: false,
  3369. dropOnEmpty: true,
  3370. forcePlaceholderSize: false,
  3371. forceHelperSize: false,
  3372. grid: false,
  3373. handle: false,
  3374. helper: "original",
  3375. items: "> *",
  3376. opacity: false,
  3377. placeholder: false,
  3378. revert: false,
  3379. scroll: true,
  3380. scrollSensitivity: 20,
  3381. scrollSpeed: 20,
  3382. scope: "default",
  3383. tolerance: "intersect",
  3384. zIndex: 1000,
  3385. // callbacks
  3386. activate: null,
  3387. beforeStop: null,
  3388. change: null,
  3389. deactivate: null,
  3390. out: null,
  3391. over: null,
  3392. receive: null,
  3393. remove: null,
  3394. sort: null,
  3395. start: null,
  3396. stop: null,
  3397. update: null
  3398. },
  3399. _create: function() {
  3400. var o = this.options;
  3401. this.containerCache = {};
  3402. this.element.addClass("ui-sortable");
  3403. //Get the items
  3404. this.refresh();
  3405. //Let's determine if the items are being displayed horizontally
  3406. this.floating = this.items.length ? o.axis === "x" || isFloating(this.items[0].item) : false;
  3407. //Let's determine the parent's offset
  3408. this.offset = this.element.offset();
  3409. //Initialize mouse events for interaction
  3410. this._mouseInit();
  3411. //We're ready to go
  3412. this.ready = true;
  3413. },
  3414. _destroy: function() {
  3415. this.element
  3416. .removeClass("ui-sortable ui-sortable-disabled");
  3417. this._mouseDestroy();
  3418. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  3419. this.items[i].item.removeData(this.widgetName + "-item");
  3420. }
  3421. return this;
  3422. },
  3423. _setOption: function(key, value){
  3424. if ( key === "disabled" ) {
  3425. this.options[ key ] = value;
  3426. this.widget().toggleClass( "ui-sortable-disabled", !!value );
  3427. } else {
  3428. // Don't call widget base _setOption for disable as it adds ui-state-disabled class
  3429. $.Widget.prototype._setOption.apply(this, arguments);
  3430. }
  3431. },
  3432. _mouseCapture: function(event, overrideHandle) {
  3433. var currentItem = null,
  3434. validHandle = false,
  3435. that = this;
  3436. if (this.reverting) {
  3437. return false;
  3438. }
  3439. if(this.options.disabled || this.options.type === "static") {
  3440. return false;
  3441. }
  3442. //We have to refresh the items data once first
  3443. this._refreshItems(event);
  3444. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  3445. $(event.target).parents().each(function() {
  3446. if($.data(this, that.widgetName + "-item") === that) {
  3447. currentItem = $(this);
  3448. return false;
  3449. }
  3450. });
  3451. if($.data(event.target, that.widgetName + "-item") === that) {
  3452. currentItem = $(event.target);
  3453. }
  3454. if(!currentItem) {
  3455. return false;
  3456. }
  3457. if(this.options.handle && !overrideHandle) {
  3458. $(this.options.handle, currentItem).find("*").addBack().each(function() {
  3459. if(this === event.target) {
  3460. validHandle = true;
  3461. }
  3462. });
  3463. if(!validHandle) {
  3464. return false;
  3465. }
  3466. }
  3467. this.currentItem = currentItem;
  3468. this._removeCurrentsFromItems();
  3469. return true;
  3470. },
  3471. _mouseStart: function(event, overrideHandle, noActivation) {
  3472. var i, body,
  3473. o = this.options;
  3474. this.currentContainer = this;
  3475. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  3476. this.refreshPositions();
  3477. //Create and append the visible helper
  3478. this.helper = this._createHelper(event);
  3479. //Cache the helper size
  3480. this._cacheHelperProportions();
  3481. /*
  3482. * - Position generation -
  3483. * This block generates everything position related - it's the core of draggables.
  3484. */
  3485. //Cache the margins of the original element
  3486. this._cacheMargins();
  3487. //Get the next scrolling parent
  3488. this.scrollParent = this.helper.scrollParent();
  3489. //The element's absolute position on the page minus margins
  3490. this.offset = this.currentItem.offset();
  3491. this.offset = {
  3492. top: this.offset.top - this.margins.top,
  3493. left: this.offset.left - this.margins.left
  3494. };
  3495. $.extend(this.offset, {
  3496. click: { //Where the click happened, relative to the element
  3497. left: event.pageX - this.offset.left,
  3498. top: event.pageY - this.offset.top
  3499. },
  3500. parent: this._getParentOffset(),
  3501. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  3502. });
  3503. // Only after we got the offset, we can change the helper's position to absolute
  3504. // TODO: Still need to figure out a way to make relative sorting possible
  3505. this.helper.css("position", "absolute");
  3506. this.cssPosition = this.helper.css("position");
  3507. //Generate the original position
  3508. this.originalPosition = this._generatePosition(event);
  3509. this.originalPageX = event.pageX;
  3510. this.originalPageY = event.pageY;
  3511. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  3512. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  3513. //Cache the former DOM position
  3514. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  3515. //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
  3516. if(this.helper[0] !== this.currentItem[0]) {
  3517. this.currentItem.hide();
  3518. }
  3519. //Create the placeholder
  3520. this._createPlaceholder();
  3521. //Set a containment if given in the options
  3522. if(o.containment) {
  3523. this._setContainment();
  3524. }
  3525. if( o.cursor && o.cursor !== "auto" ) { // cursor option
  3526. body = this.document.find( "body" );
  3527. // support: IE
  3528. this.storedCursor = body.css( "cursor" );
  3529. body.css( "cursor", o.cursor );
  3530. this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
  3531. }
  3532. if(o.opacity) { // opacity option
  3533. if (this.helper.css("opacity")) {
  3534. this._storedOpacity = this.helper.css("opacity");
  3535. }
  3536. this.helper.css("opacity", o.opacity);
  3537. }
  3538. if(o.zIndex) { // zIndex option
  3539. if (this.helper.css("zIndex")) {
  3540. this._storedZIndex = this.helper.css("zIndex");
  3541. }
  3542. this.helper.css("zIndex", o.zIndex);
  3543. }
  3544. //Prepare scrolling
  3545. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  3546. this.overflowOffset = this.scrollParent.offset();
  3547. }
  3548. //Call callbacks
  3549. this._trigger("start", event, this._uiHash());
  3550. //Recache the helper size
  3551. if(!this._preserveHelperProportions) {
  3552. this._cacheHelperProportions();
  3553. }
  3554. //Post "activate" events to possible containers
  3555. if( !noActivation ) {
  3556. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  3557. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  3558. }
  3559. }
  3560. //Prepare possible droppables
  3561. if($.ui.ddmanager) {
  3562. $.ui.ddmanager.current = this;
  3563. }
  3564. if ($.ui.ddmanager && !o.dropBehaviour) {
  3565. $.ui.ddmanager.prepareOffsets(this, event);
  3566. }
  3567. this.dragging = true;
  3568. this.helper.addClass("ui-sortable-helper");
  3569. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  3570. return true;
  3571. },
  3572. _mouseDrag: function(event) {
  3573. var i, item, itemElement, intersection,
  3574. o = this.options,
  3575. scrolled = false;
  3576. //Compute the helpers position
  3577. this.position = this._generatePosition(event);
  3578. this.positionAbs = this._convertPositionTo("absolute");
  3579. if (!this.lastPositionAbs) {
  3580. this.lastPositionAbs = this.positionAbs;
  3581. }
  3582. //Do scrolling
  3583. if(this.options.scroll) {
  3584. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  3585. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  3586. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  3587. } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
  3588. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  3589. }
  3590. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  3591. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  3592. } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
  3593. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  3594. }
  3595. } else {
  3596. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  3597. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  3598. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  3599. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  3600. }
  3601. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  3602. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  3603. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  3604. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  3605. }
  3606. }
  3607. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  3608. $.ui.ddmanager.prepareOffsets(this, event);
  3609. }
  3610. }
  3611. //Regenerate the absolute position used for position checks
  3612. this.positionAbs = this._convertPositionTo("absolute");
  3613. //Set the helper position
  3614. if(!this.options.axis || this.options.axis !== "y") {
  3615. this.helper[0].style.left = this.position.left+"px";
  3616. }
  3617. if(!this.options.axis || this.options.axis !== "x") {
  3618. this.helper[0].style.top = this.position.top+"px";
  3619. }
  3620. //Rearrange
  3621. for (i = this.items.length - 1; i >= 0; i--) {
  3622. //Cache variables and intersection, continue if no intersection
  3623. item = this.items[i];
  3624. itemElement = item.item[0];
  3625. intersection = this._intersectsWithPointer(item);
  3626. if (!intersection) {
  3627. continue;
  3628. }
  3629. // Only put the placeholder inside the current Container, skip all
  3630. // items form other containers. This works because when moving
  3631. // an item from one container to another the
  3632. // currentContainer is switched before the placeholder is moved.
  3633. //
  3634. // Without this moving items in "sub-sortables" can cause the placeholder to jitter
  3635. // beetween the outer and inner container.
  3636. if (item.instance !== this.currentContainer) {
  3637. continue;
  3638. }
  3639. // cannot intersect with itself
  3640. // no useless actions that have been done before
  3641. // no action if the item moved is the parent of the item checked
  3642. if (itemElement !== this.currentItem[0] &&
  3643. this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
  3644. !$.contains(this.placeholder[0], itemElement) &&
  3645. (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
  3646. ) {
  3647. this.direction = intersection === 1 ? "down" : "up";
  3648. if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
  3649. this._rearrange(event, item);
  3650. } else {
  3651. break;
  3652. }
  3653. this._trigger("change", event, this._uiHash());
  3654. break;
  3655. }
  3656. }
  3657. //Post events to containers
  3658. this._contactContainers(event);
  3659. //Interconnect with droppables
  3660. if($.ui.ddmanager) {
  3661. $.ui.ddmanager.drag(this, event);
  3662. }
  3663. //Call callbacks
  3664. this._trigger("sort", event, this._uiHash());
  3665. this.lastPositionAbs = this.positionAbs;
  3666. return false;
  3667. },
  3668. _mouseStop: function(event, noPropagation) {
  3669. if(!event) {
  3670. return;
  3671. }
  3672. //If we are using droppables, inform the manager about the drop
  3673. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  3674. $.ui.ddmanager.drop(this, event);
  3675. }
  3676. if(this.options.revert) {
  3677. var that = this,
  3678. cur = this.placeholder.offset(),
  3679. axis = this.options.axis,
  3680. animation = {};
  3681. if ( !axis || axis === "x" ) {
  3682. animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
  3683. }
  3684. if ( !axis || axis === "y" ) {
  3685. animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
  3686. }
  3687. this.reverting = true;
  3688. $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
  3689. that._clear(event);
  3690. });
  3691. } else {
  3692. this._clear(event, noPropagation);
  3693. }
  3694. return false;
  3695. },
  3696. cancel: function() {
  3697. if(this.dragging) {
  3698. this._mouseUp({ target: null });
  3699. if(this.options.helper === "original") {
  3700. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  3701. } else {
  3702. this.currentItem.show();
  3703. }
  3704. //Post deactivating events to containers
  3705. for (var i = this.containers.length - 1; i >= 0; i--){
  3706. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  3707. if(this.containers[i].containerCache.over) {
  3708. this.containers[i]._trigger("out", null, this._uiHash(this));
  3709. this.containers[i].containerCache.over = 0;
  3710. }
  3711. }
  3712. }
  3713. if (this.placeholder) {
  3714. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  3715. if(this.placeholder[0].parentNode) {
  3716. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  3717. }
  3718. if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
  3719. this.helper.remove();
  3720. }
  3721. $.extend(this, {
  3722. helper: null,
  3723. dragging: false,
  3724. reverting: false,
  3725. _noFinalSort: null
  3726. });
  3727. if(this.domPosition.prev) {
  3728. $(this.domPosition.prev).after(this.currentItem);
  3729. } else {
  3730. $(this.domPosition.parent).prepend(this.currentItem);
  3731. }
  3732. }
  3733. return this;
  3734. },
  3735. serialize: function(o) {
  3736. var items = this._getItemsAsjQuery(o && o.connected),
  3737. str = [];
  3738. o = o || {};
  3739. $(items).each(function() {
  3740. var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
  3741. if (res) {
  3742. str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
  3743. }
  3744. });
  3745. if(!str.length && o.key) {
  3746. str.push(o.key + "=");
  3747. }
  3748. return str.join("&");
  3749. },
  3750. toArray: function(o) {
  3751. var items = this._getItemsAsjQuery(o && o.connected),
  3752. ret = [];
  3753. o = o || {};
  3754. items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
  3755. return ret;
  3756. },
  3757. /* Be careful with the following core functions */
  3758. _intersectsWith: function(item) {
  3759. var x1 = this.positionAbs.left,
  3760. x2 = x1 + this.helperProportions.width,
  3761. y1 = this.positionAbs.top,
  3762. y2 = y1 + this.helperProportions.height,
  3763. l = item.left,
  3764. r = l + item.width,
  3765. t = item.top,
  3766. b = t + item.height,
  3767. dyClick = this.offset.click.top,
  3768. dxClick = this.offset.click.left,
  3769. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
  3770. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
  3771. isOverElement = isOverElementHeight && isOverElementWidth;
  3772. if ( this.options.tolerance === "pointer" ||
  3773. this.options.forcePointerForContainers ||
  3774. (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
  3775. ) {
  3776. return isOverElement;
  3777. } else {
  3778. return (l < x1 + (this.helperProportions.width / 2) && // Right Half
  3779. x2 - (this.helperProportions.width / 2) < r && // Left Half
  3780. t < y1 + (this.helperProportions.height / 2) && // Bottom Half
  3781. y2 - (this.helperProportions.height / 2) < b ); // Top Half
  3782. }
  3783. },
  3784. _intersectsWithPointer: function(item) {
  3785. var isOverElementHeight = (this.options.axis === "x") || isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  3786. isOverElementWidth = (this.options.axis === "y") || isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  3787. isOverElement = isOverElementHeight && isOverElementWidth,
  3788. verticalDirection = this._getDragVerticalDirection(),
  3789. horizontalDirection = this._getDragHorizontalDirection();
  3790. if (!isOverElement) {
  3791. return false;
  3792. }
  3793. return this.floating ?
  3794. ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
  3795. : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
  3796. },
  3797. _intersectsWithSides: function(item) {
  3798. var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  3799. isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  3800. verticalDirection = this._getDragVerticalDirection(),
  3801. horizontalDirection = this._getDragHorizontalDirection();
  3802. if (this.floating && horizontalDirection) {
  3803. return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
  3804. } else {
  3805. return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
  3806. }
  3807. },
  3808. _getDragVerticalDirection: function() {
  3809. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  3810. return delta !== 0 && (delta > 0 ? "down" : "up");
  3811. },
  3812. _getDragHorizontalDirection: function() {
  3813. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  3814. return delta !== 0 && (delta > 0 ? "right" : "left");
  3815. },
  3816. refresh: function(event) {
  3817. this._refreshItems(event);
  3818. this.refreshPositions();
  3819. return this;
  3820. },
  3821. _connectWith: function() {
  3822. var options = this.options;
  3823. return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
  3824. },
  3825. _getItemsAsjQuery: function(connected) {
  3826. var i, j, cur, inst,
  3827. items = [],
  3828. queries = [],
  3829. connectWith = this._connectWith();
  3830. if(connectWith && connected) {
  3831. for (i = connectWith.length - 1; i >= 0; i--){
  3832. cur = $(connectWith[i]);
  3833. for ( j = cur.length - 1; j >= 0; j--){
  3834. inst = $.data(cur[j], this.widgetFullName);
  3835. if(inst && inst !== this && !inst.options.disabled) {
  3836. 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]);
  3837. }
  3838. }
  3839. }
  3840. }
  3841. 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]);
  3842. for (i = queries.length - 1; i >= 0; i--){
  3843. queries[i][0].each(function() {
  3844. items.push(this);
  3845. });
  3846. }
  3847. return $(items);
  3848. },
  3849. _removeCurrentsFromItems: function() {
  3850. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  3851. this.items = $.grep(this.items, function (item) {
  3852. for (var j=0; j < list.length; j++) {
  3853. if(list[j] === item.item[0]) {
  3854. return false;
  3855. }
  3856. }
  3857. return true;
  3858. });
  3859. },
  3860. _refreshItems: function(event) {
  3861. this.items = [];
  3862. this.containers = [this];
  3863. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  3864. items = this.items,
  3865. queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
  3866. connectWith = this._connectWith();
  3867. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  3868. for (i = connectWith.length - 1; i >= 0; i--){
  3869. cur = $(connectWith[i]);
  3870. for (j = cur.length - 1; j >= 0; j--){
  3871. inst = $.data(cur[j], this.widgetFullName);
  3872. if(inst && inst !== this && !inst.options.disabled) {
  3873. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  3874. this.containers.push(inst);
  3875. }
  3876. }
  3877. }
  3878. }
  3879. for (i = queries.length - 1; i >= 0; i--) {
  3880. targetData = queries[i][1];
  3881. _queries = queries[i][0];
  3882. for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  3883. item = $(_queries[j]);
  3884. item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
  3885. items.push({
  3886. item: item,
  3887. instance: targetData,
  3888. width: 0, height: 0,
  3889. left: 0, top: 0
  3890. });
  3891. }
  3892. }
  3893. },
  3894. refreshPositions: function(fast) {
  3895. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  3896. if(this.offsetParent && this.helper) {
  3897. this.offset.parent = this._getParentOffset();
  3898. }
  3899. var i, item, t, p;
  3900. for (i = this.items.length - 1; i >= 0; i--){
  3901. item = this.items[i];
  3902. //We ignore calculating positions of all connected containers when we're not over them
  3903. if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
  3904. continue;
  3905. }
  3906. t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  3907. if (!fast) {
  3908. item.width = t.outerWidth();
  3909. item.height = t.outerHeight();
  3910. }
  3911. p = t.offset();
  3912. item.left = p.left;
  3913. item.top = p.top;
  3914. }
  3915. if(this.options.custom && this.options.custom.refreshContainers) {
  3916. this.options.custom.refreshContainers.call(this);
  3917. } else {
  3918. for (i = this.containers.length - 1; i >= 0; i--){
  3919. p = this.containers[i].element.offset();
  3920. this.containers[i].containerCache.left = p.left;
  3921. this.containers[i].containerCache.top = p.top;
  3922. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  3923. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  3924. }
  3925. }
  3926. return this;
  3927. },
  3928. _createPlaceholder: function(that) {
  3929. that = that || this;
  3930. var className,
  3931. o = that.options;
  3932. if(!o.placeholder || o.placeholder.constructor === String) {
  3933. className = o.placeholder;
  3934. o.placeholder = {
  3935. element: function() {
  3936. var nodeName = that.currentItem[0].nodeName.toLowerCase(),
  3937. element = $( "<" + nodeName + ">", that.document[0] )
  3938. .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
  3939. .removeClass("ui-sortable-helper");
  3940. if ( nodeName === "tr" ) {
  3941. that.currentItem.children().each(function() {
  3942. $( "<td>&#160;</td>", that.document[0] )
  3943. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  3944. .appendTo( element );
  3945. });
  3946. } else if ( nodeName === "img" ) {
  3947. element.attr( "src", that.currentItem.attr( "src" ) );
  3948. }
  3949. if ( !className ) {
  3950. element.css( "visibility", "hidden" );
  3951. }
  3952. return element;
  3953. },
  3954. update: function(container, p) {
  3955. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  3956. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  3957. if(className && !o.forcePlaceholderSize) {
  3958. return;
  3959. }
  3960. //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
  3961. if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
  3962. if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
  3963. }
  3964. };
  3965. }
  3966. //Create the placeholder
  3967. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  3968. //Append it after the actual current item
  3969. that.currentItem.after(that.placeholder);
  3970. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  3971. o.placeholder.update(that, that.placeholder);
  3972. },
  3973. _contactContainers: function(event) {
  3974. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, floating,
  3975. innermostContainer = null,
  3976. innermostIndex = null;
  3977. // get innermost container that intersects with item
  3978. for (i = this.containers.length - 1; i >= 0; i--) {
  3979. // never consider a container that's located within the item itself
  3980. if($.contains(this.currentItem[0], this.containers[i].element[0])) {
  3981. continue;
  3982. }
  3983. if(this._intersectsWith(this.containers[i].containerCache)) {
  3984. // if we've already found a container and it's more "inner" than this, then continue
  3985. if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
  3986. continue;
  3987. }
  3988. innermostContainer = this.containers[i];
  3989. innermostIndex = i;
  3990. } else {
  3991. // container doesn't intersect. trigger "out" event if necessary
  3992. if(this.containers[i].containerCache.over) {
  3993. this.containers[i]._trigger("out", event, this._uiHash(this));
  3994. this.containers[i].containerCache.over = 0;
  3995. }
  3996. }
  3997. }
  3998. // if no intersecting containers found, return
  3999. if(!innermostContainer) {
  4000. return;
  4001. }
  4002. // move the item into the container if it's not there already
  4003. if(this.containers.length === 1) {
  4004. if (!this.containers[innermostIndex].containerCache.over) {
  4005. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  4006. this.containers[innermostIndex].containerCache.over = 1;
  4007. }
  4008. } else {
  4009. //When entering a new container, we will find the item with the least distance and append our item near it
  4010. dist = 10000;
  4011. itemWithLeastDistance = null;
  4012. floating = innermostContainer.floating || isFloating(this.currentItem);
  4013. posProperty = floating ? "left" : "top";
  4014. sizeProperty = floating ? "width" : "height";
  4015. base = this.positionAbs[posProperty] + this.offset.click[posProperty];
  4016. for (j = this.items.length - 1; j >= 0; j--) {
  4017. if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
  4018. continue;
  4019. }
  4020. if(this.items[j].item[0] === this.currentItem[0]) {
  4021. continue;
  4022. }
  4023. if (floating && !isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) {
  4024. continue;
  4025. }
  4026. cur = this.items[j].item.offset()[posProperty];
  4027. nearBottom = false;
  4028. if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){
  4029. nearBottom = true;
  4030. cur += this.items[j][sizeProperty];
  4031. }
  4032. if(Math.abs(cur - base) < dist) {
  4033. dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
  4034. this.direction = nearBottom ? "up": "down";
  4035. }
  4036. }
  4037. //Check if dropOnEmpty is enabled
  4038. if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
  4039. return;
  4040. }
  4041. if(this.currentContainer === this.containers[innermostIndex]) {
  4042. return;
  4043. }
  4044. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  4045. this._trigger("change", event, this._uiHash());
  4046. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  4047. this.currentContainer = this.containers[innermostIndex];
  4048. //Update the placeholder
  4049. this.options.placeholder.update(this.currentContainer, this.placeholder);
  4050. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  4051. this.containers[innermostIndex].containerCache.over = 1;
  4052. }
  4053. },
  4054. _createHelper: function(event) {
  4055. var o = this.options,
  4056. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
  4057. //Add the helper to the DOM if that didn't happen already
  4058. if(!helper.parents("body").length) {
  4059. $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  4060. }
  4061. if(helper[0] === this.currentItem[0]) {
  4062. 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") };
  4063. }
  4064. if(!helper[0].style.width || o.forceHelperSize) {
  4065. helper.width(this.currentItem.width());
  4066. }
  4067. if(!helper[0].style.height || o.forceHelperSize) {
  4068. helper.height(this.currentItem.height());
  4069. }
  4070. return helper;
  4071. },
  4072. _adjustOffsetFromHelper: function(obj) {
  4073. if (typeof obj === "string") {
  4074. obj = obj.split(" ");
  4075. }
  4076. if ($.isArray(obj)) {
  4077. obj = {left: +obj[0], top: +obj[1] || 0};
  4078. }
  4079. if ("left" in obj) {
  4080. this.offset.click.left = obj.left + this.margins.left;
  4081. }
  4082. if ("right" in obj) {
  4083. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  4084. }
  4085. if ("top" in obj) {
  4086. this.offset.click.top = obj.top + this.margins.top;
  4087. }
  4088. if ("bottom" in obj) {
  4089. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  4090. }
  4091. },
  4092. _getParentOffset: function() {
  4093. //Get the offsetParent and cache its position
  4094. this.offsetParent = this.helper.offsetParent();
  4095. var po = this.offsetParent.offset();
  4096. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  4097. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  4098. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  4099. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  4100. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  4101. po.left += this.scrollParent.scrollLeft();
  4102. po.top += this.scrollParent.scrollTop();
  4103. }
  4104. // This needs to be actually done for all browsers, since pageX/pageY includes this information
  4105. // with an ugly IE fix
  4106. if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  4107. po = { top: 0, left: 0 };
  4108. }
  4109. return {
  4110. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  4111. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  4112. };
  4113. },
  4114. _getRelativeOffset: function() {
  4115. if(this.cssPosition === "relative") {
  4116. var p = this.currentItem.position();
  4117. return {
  4118. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  4119. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  4120. };
  4121. } else {
  4122. return { top: 0, left: 0 };
  4123. }
  4124. },
  4125. _cacheMargins: function() {
  4126. this.margins = {
  4127. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  4128. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  4129. };
  4130. },
  4131. _cacheHelperProportions: function() {
  4132. this.helperProportions = {
  4133. width: this.helper.outerWidth(),
  4134. height: this.helper.outerHeight()
  4135. };
  4136. },
  4137. _setContainment: function() {
  4138. var ce, co, over,
  4139. o = this.options;
  4140. if(o.containment === "parent") {
  4141. o.containment = this.helper[0].parentNode;
  4142. }
  4143. if(o.containment === "document" || o.containment === "window") {
  4144. this.containment = [
  4145. 0 - this.offset.relative.left - this.offset.parent.left,
  4146. 0 - this.offset.relative.top - this.offset.parent.top,
  4147. $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
  4148. ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  4149. ];
  4150. }
  4151. if(!(/^(document|window|parent)$/).test(o.containment)) {
  4152. ce = $(o.containment)[0];
  4153. co = $(o.containment).offset();
  4154. over = ($(ce).css("overflow") !== "hidden");
  4155. this.containment = [
  4156. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  4157. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  4158. 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,
  4159. 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
  4160. ];
  4161. }
  4162. },
  4163. _convertPositionTo: function(d, pos) {
  4164. if(!pos) {
  4165. pos = this.position;
  4166. }
  4167. var mod = d === "absolute" ? 1 : -1,
  4168. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  4169. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  4170. return {
  4171. top: (
  4172. pos.top + // The absolute mouse position
  4173. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  4174. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  4175. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  4176. ),
  4177. left: (
  4178. pos.left + // The absolute mouse position
  4179. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  4180. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  4181. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  4182. )
  4183. };
  4184. },
  4185. _generatePosition: function(event) {
  4186. var top, left,
  4187. o = this.options,
  4188. pageX = event.pageX,
  4189. pageY = event.pageY,
  4190. 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);
  4191. // This is another very weird special case that only happens for relative elements:
  4192. // 1. If the css position is relative
  4193. // 2. and the scroll parent is the document or similar to the offset parent
  4194. // we have to refresh the relative offset during the scroll so there are no jumps
  4195. if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
  4196. this.offset.relative = this._getRelativeOffset();
  4197. }
  4198. /*
  4199. * - Position constraining -
  4200. * Constrain the position to a mix of grid, containment.
  4201. */
  4202. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  4203. if(this.containment) {
  4204. if(event.pageX - this.offset.click.left < this.containment[0]) {
  4205. pageX = this.containment[0] + this.offset.click.left;
  4206. }
  4207. if(event.pageY - this.offset.click.top < this.containment[1]) {
  4208. pageY = this.containment[1] + this.offset.click.top;
  4209. }
  4210. if(event.pageX - this.offset.click.left > this.containment[2]) {
  4211. pageX = this.containment[2] + this.offset.click.left;
  4212. }
  4213. if(event.pageY - this.offset.click.top > this.containment[3]) {
  4214. pageY = this.containment[3] + this.offset.click.top;
  4215. }
  4216. }
  4217. if(o.grid) {
  4218. top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  4219. 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;
  4220. left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  4221. 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;
  4222. }
  4223. }
  4224. return {
  4225. top: (
  4226. pageY - // The absolute mouse position
  4227. this.offset.click.top - // Click offset (relative to the element)
  4228. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  4229. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  4230. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  4231. ),
  4232. left: (
  4233. pageX - // The absolute mouse position
  4234. this.offset.click.left - // Click offset (relative to the element)
  4235. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  4236. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  4237. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  4238. )
  4239. };
  4240. },
  4241. _rearrange: function(event, i, a, hardRefresh) {
  4242. 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));
  4243. //Various things done here to improve the performance:
  4244. // 1. we create a setTimeout, that calls refreshPositions
  4245. // 2. on the instance, we have a counter variable, that get's higher after every append
  4246. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  4247. // 4. this lets only the last addition to the timeout stack through
  4248. this.counter = this.counter ? ++this.counter : 1;
  4249. var counter = this.counter;
  4250. this._delay(function() {
  4251. if(counter === this.counter) {
  4252. this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  4253. }
  4254. });
  4255. },
  4256. _clear: function(event, noPropagation) {
  4257. this.reverting = false;
  4258. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  4259. // everything else normalized again
  4260. var i,
  4261. delayedTriggers = [];
  4262. // We first have to update the dom position of the actual currentItem
  4263. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  4264. if(!this._noFinalSort && this.currentItem.parent().length) {
  4265. this.placeholder.before(this.currentItem);
  4266. }
  4267. this._noFinalSort = null;
  4268. if(this.helper[0] === this.currentItem[0]) {
  4269. for(i in this._storedCSS) {
  4270. if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
  4271. this._storedCSS[i] = "";
  4272. }
  4273. }
  4274. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  4275. } else {
  4276. this.currentItem.show();
  4277. }
  4278. if(this.fromOutside && !noPropagation) {
  4279. delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  4280. }
  4281. if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
  4282. delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  4283. }
  4284. // Check if the items Container has Changed and trigger appropriate
  4285. // events.
  4286. if (this !== this.currentContainer) {
  4287. if(!noPropagation) {
  4288. delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  4289. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  4290. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  4291. }
  4292. }
  4293. //Post events to containers
  4294. for (i = this.containers.length - 1; i >= 0; i--){
  4295. if(!noPropagation) {
  4296. delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  4297. }
  4298. if(this.containers[i].containerCache.over) {
  4299. delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  4300. this.containers[i].containerCache.over = 0;
  4301. }
  4302. }
  4303. //Do what was originally in plugins
  4304. if ( this.storedCursor ) {
  4305. this.document.find( "body" ).css( "cursor", this.storedCursor );
  4306. this.storedStylesheet.remove();
  4307. }
  4308. if(this._storedOpacity) {
  4309. this.helper.css("opacity", this._storedOpacity);
  4310. }
  4311. if(this._storedZIndex) {
  4312. this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
  4313. }
  4314. this.dragging = false;
  4315. if(this.cancelHelperRemoval) {
  4316. if(!noPropagation) {
  4317. this._trigger("beforeStop", event, this._uiHash());
  4318. for (i=0; i < delayedTriggers.length; i++) {
  4319. delayedTriggers[i].call(this, event);
  4320. } //Trigger all delayed events
  4321. this._trigger("stop", event, this._uiHash());
  4322. }
  4323. this.fromOutside = false;
  4324. return false;
  4325. }
  4326. if(!noPropagation) {
  4327. this._trigger("beforeStop", event, this._uiHash());
  4328. }
  4329. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  4330. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  4331. if(this.helper[0] !== this.currentItem[0]) {
  4332. this.helper.remove();
  4333. }
  4334. this.helper = null;
  4335. if(!noPropagation) {
  4336. for (i=0; i < delayedTriggers.length; i++) {
  4337. delayedTriggers[i].call(this, event);
  4338. } //Trigger all delayed events
  4339. this._trigger("stop", event, this._uiHash());
  4340. }
  4341. this.fromOutside = false;
  4342. return true;
  4343. },
  4344. _trigger: function() {
  4345. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  4346. this.cancel();
  4347. }
  4348. },
  4349. _uiHash: function(_inst) {
  4350. var inst = _inst || this;
  4351. return {
  4352. helper: inst.helper,
  4353. placeholder: inst.placeholder || $([]),
  4354. position: inst.position,
  4355. originalPosition: inst.originalPosition,
  4356. offset: inst.positionAbs,
  4357. item: inst.currentItem,
  4358. sender: _inst ? _inst.element : null
  4359. };
  4360. }
  4361. });
  4362. })(jQuery);
  4363. (function( $, undefined ) {
  4364. // used to prevent race conditions with remote data sources
  4365. var requestIndex = 0;
  4366. $.widget( "ui.autocomplete", {
  4367. version: "1.10.3",
  4368. defaultElement: "<input>",
  4369. options: {
  4370. appendTo: null,
  4371. autoFocus: false,
  4372. delay: 300,
  4373. minLength: 1,
  4374. position: {
  4375. my: "left top",
  4376. at: "left bottom",
  4377. collision: "none"
  4378. },
  4379. source: null,
  4380. // callbacks
  4381. change: null,
  4382. close: null,
  4383. focus: null,
  4384. open: null,
  4385. response: null,
  4386. search: null,
  4387. select: null
  4388. },
  4389. pending: 0,
  4390. _create: function() {
  4391. // Some browsers only repeat keydown events, not keypress events,
  4392. // so we use the suppressKeyPress flag to determine if we've already
  4393. // handled the keydown event. #7269
  4394. // Unfortunately the code for & in keypress is the same as the up arrow,
  4395. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  4396. // events when we know the keydown event was used to modify the
  4397. // search term. #7799
  4398. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  4399. nodeName = this.element[0].nodeName.toLowerCase(),
  4400. isTextarea = nodeName === "textarea",
  4401. isInput = nodeName === "input";
  4402. this.isMultiLine =
  4403. // Textareas are always multi-line
  4404. isTextarea ? true :
  4405. // Inputs are always single-line, even if inside a contentEditable element
  4406. // IE also treats inputs as contentEditable
  4407. isInput ? false :
  4408. // All other element types are determined by whether or not they're contentEditable
  4409. this.element.prop( "isContentEditable" );
  4410. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  4411. this.isNewMenu = true;
  4412. this.element
  4413. .addClass( "ui-autocomplete-input" )
  4414. .attr( "autocomplete", "off" );
  4415. this._on( this.element, {
  4416. keydown: function( event ) {
  4417. /*jshint maxcomplexity:15*/
  4418. if ( this.element.prop( "readOnly" ) ) {
  4419. suppressKeyPress = true;
  4420. suppressInput = true;
  4421. suppressKeyPressRepeat = true;
  4422. return;
  4423. }
  4424. suppressKeyPress = false;
  4425. suppressInput = false;
  4426. suppressKeyPressRepeat = false;
  4427. var keyCode = $.ui.keyCode;
  4428. switch( event.keyCode ) {
  4429. case keyCode.PAGE_UP:
  4430. suppressKeyPress = true;
  4431. this._move( "previousPage", event );
  4432. break;
  4433. case keyCode.PAGE_DOWN:
  4434. suppressKeyPress = true;
  4435. this._move( "nextPage", event );
  4436. break;
  4437. case keyCode.UP:
  4438. suppressKeyPress = true;
  4439. this._keyEvent( "previous", event );
  4440. break;
  4441. case keyCode.DOWN:
  4442. suppressKeyPress = true;
  4443. this._keyEvent( "next", event );
  4444. break;
  4445. case keyCode.ENTER:
  4446. case keyCode.NUMPAD_ENTER:
  4447. // when menu is open and has focus
  4448. if ( this.menu.active ) {
  4449. // #6055 - Opera still allows the keypress to occur
  4450. // which causes forms to submit
  4451. suppressKeyPress = true;
  4452. event.preventDefault();
  4453. this.menu.select( event );
  4454. }
  4455. break;
  4456. case keyCode.TAB:
  4457. if ( this.menu.active ) {
  4458. this.menu.select( event );
  4459. }
  4460. break;
  4461. case keyCode.ESCAPE:
  4462. if ( this.menu.element.is( ":visible" ) ) {
  4463. this._value( this.term );
  4464. this.close( event );
  4465. // Different browsers have different default behavior for escape
  4466. // Single press can mean undo or clear
  4467. // Double press in IE means clear the whole form
  4468. event.preventDefault();
  4469. }
  4470. break;
  4471. default:
  4472. suppressKeyPressRepeat = true;
  4473. // search timeout should be triggered before the input value is changed
  4474. this._searchTimeout( event );
  4475. break;
  4476. }
  4477. },
  4478. keypress: function( event ) {
  4479. if ( suppressKeyPress ) {
  4480. suppressKeyPress = false;
  4481. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  4482. event.preventDefault();
  4483. }
  4484. return;
  4485. }
  4486. if ( suppressKeyPressRepeat ) {
  4487. return;
  4488. }
  4489. // replicate some key handlers to allow them to repeat in Firefox and Opera
  4490. var keyCode = $.ui.keyCode;
  4491. switch( event.keyCode ) {
  4492. case keyCode.PAGE_UP:
  4493. this._move( "previousPage", event );
  4494. break;
  4495. case keyCode.PAGE_DOWN:
  4496. this._move( "nextPage", event );
  4497. break;
  4498. case keyCode.UP:
  4499. this._keyEvent( "previous", event );
  4500. break;
  4501. case keyCode.DOWN:
  4502. this._keyEvent( "next", event );
  4503. break;
  4504. }
  4505. },
  4506. input: function( event ) {
  4507. if ( suppressInput ) {
  4508. suppressInput = false;
  4509. event.preventDefault();
  4510. return;
  4511. }
  4512. this._searchTimeout( event );
  4513. },
  4514. focus: function() {
  4515. this.selectedItem = null;
  4516. this.previous = this._value();
  4517. },
  4518. blur: function( event ) {
  4519. if ( this.cancelBlur ) {
  4520. delete this.cancelBlur;
  4521. return;
  4522. }
  4523. clearTimeout( this.searching );
  4524. this.close( event );
  4525. this._change( event );
  4526. }
  4527. });
  4528. this._initSource();
  4529. this.menu = $( "<ul>" )
  4530. .addClass( "ui-autocomplete ui-front" )
  4531. .appendTo( this._appendTo() )
  4532. .menu({
  4533. // disable ARIA support, the live region takes care of that
  4534. role: null
  4535. })
  4536. .hide()
  4537. .data( "ui-menu" );
  4538. this._on( this.menu.element, {
  4539. mousedown: function( event ) {
  4540. // prevent moving focus out of the text field
  4541. event.preventDefault();
  4542. // IE doesn't prevent moving focus even with event.preventDefault()
  4543. // so we set a flag to know when we should ignore the blur event
  4544. this.cancelBlur = true;
  4545. this._delay(function() {
  4546. delete this.cancelBlur;
  4547. });
  4548. // clicking on the scrollbar causes focus to shift to the body
  4549. // but we can't detect a mouseup or a click immediately afterward
  4550. // so we have to track the next mousedown and close the menu if
  4551. // the user clicks somewhere outside of the autocomplete
  4552. var menuElement = this.menu.element[ 0 ];
  4553. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  4554. this._delay(function() {
  4555. var that = this;
  4556. this.document.one( "mousedown", function( event ) {
  4557. if ( event.target !== that.element[ 0 ] &&
  4558. event.target !== menuElement &&
  4559. !$.contains( menuElement, event.target ) ) {
  4560. that.close();
  4561. }
  4562. });
  4563. });
  4564. }
  4565. },
  4566. menufocus: function( event, ui ) {
  4567. // support: Firefox
  4568. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  4569. if ( this.isNewMenu ) {
  4570. this.isNewMenu = false;
  4571. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  4572. this.menu.blur();
  4573. this.document.one( "mousemove", function() {
  4574. $( event.target ).trigger( event.originalEvent );
  4575. });
  4576. return;
  4577. }
  4578. }
  4579. var item = ui.item.data( "ui-autocomplete-item" );
  4580. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  4581. // use value to match what will end up in the input, if it was a key event
  4582. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  4583. this._value( item.value );
  4584. }
  4585. } else {
  4586. // Normally the input is populated with the item's value as the
  4587. // menu is navigated, causing screen readers to notice a change and
  4588. // announce the item. Since the focus event was canceled, this doesn't
  4589. // happen, so we update the live region so that screen readers can
  4590. // still notice the change and announce it.
  4591. this.liveRegion.text( item.value );
  4592. }
  4593. },
  4594. menuselect: function( event, ui ) {
  4595. var item = ui.item.data( "ui-autocomplete-item" ),
  4596. previous = this.previous;
  4597. // only trigger when focus was lost (click on menu)
  4598. if ( this.element[0] !== this.document[0].activeElement ) {
  4599. this.element.focus();
  4600. this.previous = previous;
  4601. // #6109 - IE triggers two focus events and the second
  4602. // is asynchronous, so we need to reset the previous
  4603. // term synchronously and asynchronously :-(
  4604. this._delay(function() {
  4605. this.previous = previous;
  4606. this.selectedItem = item;
  4607. });
  4608. }
  4609. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  4610. this._value( item.value );
  4611. }
  4612. // reset the term after the select event
  4613. // this allows custom select handling to work properly
  4614. this.term = this._value();
  4615. this.close( event );
  4616. this.selectedItem = item;
  4617. }
  4618. });
  4619. this.liveRegion = $( "<span>", {
  4620. role: "status",
  4621. "aria-live": "polite"
  4622. })
  4623. .addClass( "ui-helper-hidden-accessible" )
  4624. .insertBefore( this.element );
  4625. // turning off autocomplete prevents the browser from remembering the
  4626. // value when navigating through history, so we re-enable autocomplete
  4627. // if the page is unloaded before the widget is destroyed. #7790
  4628. this._on( this.window, {
  4629. beforeunload: function() {
  4630. this.element.removeAttr( "autocomplete" );
  4631. }
  4632. });
  4633. },
  4634. _destroy: function() {
  4635. clearTimeout( this.searching );
  4636. this.element
  4637. .removeClass( "ui-autocomplete-input" )
  4638. .removeAttr( "autocomplete" );
  4639. this.menu.element.remove();
  4640. this.liveRegion.remove();
  4641. },
  4642. _setOption: function( key, value ) {
  4643. this._super( key, value );
  4644. if ( key === "source" ) {
  4645. this._initSource();
  4646. }
  4647. if ( key === "appendTo" ) {
  4648. this.menu.element.appendTo( this._appendTo() );
  4649. }
  4650. if ( key === "disabled" && value && this.xhr ) {
  4651. this.xhr.abort();
  4652. }
  4653. },
  4654. _appendTo: function() {
  4655. var element = this.options.appendTo;
  4656. if ( element ) {
  4657. element = element.jquery || element.nodeType ?
  4658. $( element ) :
  4659. this.document.find( element ).eq( 0 );
  4660. }
  4661. if ( !element ) {
  4662. element = this.element.closest( ".ui-front" );
  4663. }
  4664. if ( !element.length ) {
  4665. element = this.document[0].body;
  4666. }
  4667. return element;
  4668. },
  4669. _initSource: function() {
  4670. var array, url,
  4671. that = this;
  4672. if ( $.isArray(this.options.source) ) {
  4673. array = this.options.source;
  4674. this.source = function( request, response ) {
  4675. response( $.ui.autocomplete.filter( array, request.term ) );
  4676. };
  4677. } else if ( typeof this.options.source === "string" ) {
  4678. url = this.options.source;
  4679. this.source = function( request, response ) {
  4680. if ( that.xhr ) {
  4681. that.xhr.abort();
  4682. }
  4683. that.xhr = $.ajax({
  4684. url: url,
  4685. data: request,
  4686. dataType: "json",
  4687. success: function( data ) {
  4688. response( data );
  4689. },
  4690. error: function() {
  4691. response( [] );
  4692. }
  4693. });
  4694. };
  4695. } else {
  4696. this.source = this.options.source;
  4697. }
  4698. },
  4699. _searchTimeout: function( event ) {
  4700. clearTimeout( this.searching );
  4701. this.searching = this._delay(function() {
  4702. // only search if the value has changed
  4703. if ( this.term !== this._value() ) {
  4704. this.selectedItem = null;
  4705. this.search( null, event );
  4706. }
  4707. }, this.options.delay );
  4708. },
  4709. search: function( value, event ) {
  4710. value = value != null ? value : this._value();
  4711. // always save the actual value, not the one passed as an argument
  4712. this.term = this._value();
  4713. if ( value.length < this.options.minLength ) {
  4714. return this.close( event );
  4715. }
  4716. if ( this._trigger( "search", event ) === false ) {
  4717. return;
  4718. }
  4719. return this._search( value );
  4720. },
  4721. _search: function( value ) {
  4722. this.pending++;
  4723. this.element.addClass( "ui-autocomplete-loading" );
  4724. this.cancelSearch = false;
  4725. this.source( { term: value }, this._response() );
  4726. },
  4727. _response: function() {
  4728. var that = this,
  4729. index = ++requestIndex;
  4730. return function( content ) {
  4731. if ( index === requestIndex ) {
  4732. that.__response( content );
  4733. }
  4734. that.pending--;
  4735. if ( !that.pending ) {
  4736. that.element.removeClass( "ui-autocomplete-loading" );
  4737. }
  4738. };
  4739. },
  4740. __response: function( content ) {
  4741. if ( content ) {
  4742. content = this._normalize( content );
  4743. }
  4744. this._trigger( "response", null, { content: content } );
  4745. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  4746. this._suggest( content );
  4747. this._trigger( "open" );
  4748. } else {
  4749. // use ._close() instead of .close() so we don't cancel future searches
  4750. this._close();
  4751. }
  4752. },
  4753. close: function( event ) {
  4754. this.cancelSearch = true;
  4755. this._close( event );
  4756. },
  4757. _close: function( event ) {
  4758. if ( this.menu.element.is( ":visible" ) ) {
  4759. this.menu.element.hide();
  4760. this.menu.blur();
  4761. this.isNewMenu = true;
  4762. this._trigger( "close", event );
  4763. }
  4764. },
  4765. _change: function( event ) {
  4766. if ( this.previous !== this._value() ) {
  4767. this._trigger( "change", event, { item: this.selectedItem } );
  4768. }
  4769. },
  4770. _normalize: function( items ) {
  4771. // assume all items have the right format when the first item is complete
  4772. if ( items.length && items[0].label && items[0].value ) {
  4773. return items;
  4774. }
  4775. return $.map( items, function( item ) {
  4776. if ( typeof item === "string" ) {
  4777. return {
  4778. label: item,
  4779. value: item
  4780. };
  4781. }
  4782. return $.extend({
  4783. label: item.label || item.value,
  4784. value: item.value || item.label
  4785. }, item );
  4786. });
  4787. },
  4788. _suggest: function( items ) {
  4789. var ul = this.menu.element.empty();
  4790. this._renderMenu( ul, items );
  4791. this.isNewMenu = true;
  4792. this.menu.refresh();
  4793. // size and position menu
  4794. ul.show();
  4795. this._resizeMenu();
  4796. ul.position( $.extend({
  4797. of: this.element
  4798. }, this.options.position ));
  4799. if ( this.options.autoFocus ) {
  4800. this.menu.next();
  4801. }
  4802. },
  4803. _resizeMenu: function() {
  4804. var ul = this.menu.element;
  4805. ul.outerWidth( Math.max(
  4806. // Firefox wraps long text (possibly a rounding bug)
  4807. // so we add 1px to avoid the wrapping (#7513)
  4808. ul.width( "" ).outerWidth() + 1,
  4809. this.element.outerWidth()
  4810. ) );
  4811. },
  4812. _renderMenu: function( ul, items ) {
  4813. var that = this;
  4814. $.each( items, function( index, item ) {
  4815. that._renderItemData( ul, item );
  4816. });
  4817. },
  4818. _renderItemData: function( ul, item ) {
  4819. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  4820. },
  4821. _renderItem: function( ul, item ) {
  4822. return $( "<li>" )
  4823. .append( $( "<a>" ).text( item.label ) )
  4824. .appendTo( ul );
  4825. },
  4826. _move: function( direction, event ) {
  4827. if ( !this.menu.element.is( ":visible" ) ) {
  4828. this.search( null, event );
  4829. return;
  4830. }
  4831. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  4832. this.menu.isLastItem() && /^next/.test( direction ) ) {
  4833. this._value( this.term );
  4834. this.menu.blur();
  4835. return;
  4836. }
  4837. this.menu[ direction ]( event );
  4838. },
  4839. widget: function() {
  4840. return this.menu.element;
  4841. },
  4842. _value: function() {
  4843. return this.valueMethod.apply( this.element, arguments );
  4844. },
  4845. _keyEvent: function( keyEvent, event ) {
  4846. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  4847. this._move( keyEvent, event );
  4848. // prevents moving cursor to beginning/end of the text field in some browsers
  4849. event.preventDefault();
  4850. }
  4851. }
  4852. });
  4853. $.extend( $.ui.autocomplete, {
  4854. escapeRegex: function( value ) {
  4855. return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
  4856. },
  4857. filter: function(array, term) {
  4858. var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
  4859. return $.grep( array, function(value) {
  4860. return matcher.test( value.label || value.value || value );
  4861. });
  4862. }
  4863. });
  4864. // live region extension, adding a `messages` option
  4865. // NOTE: This is an experimental API. We are still investigating
  4866. // a full solution for string manipulation and internationalization.
  4867. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  4868. options: {
  4869. messages: {
  4870. noResults: "No search results.",
  4871. results: function( amount ) {
  4872. return amount + ( amount > 1 ? " results are" : " result is" ) +
  4873. " available, use up and down arrow keys to navigate.";
  4874. }
  4875. }
  4876. },
  4877. __response: function( content ) {
  4878. var message;
  4879. this._superApply( arguments );
  4880. if ( this.options.disabled || this.cancelSearch ) {
  4881. return;
  4882. }
  4883. if ( content && content.length ) {
  4884. message = this.options.messages.results( content.length );
  4885. } else {
  4886. message = this.options.messages.noResults;
  4887. }
  4888. this.liveRegion.text( message );
  4889. }
  4890. });
  4891. }( jQuery ));
  4892. (function( $, undefined ) {
  4893. $.widget( "ui.menu", {
  4894. version: "1.10.3",
  4895. defaultElement: "<ul>",
  4896. delay: 300,
  4897. options: {
  4898. icons: {
  4899. submenu: "ui-icon-carat-1-e"
  4900. },
  4901. menus: "ul",
  4902. position: {
  4903. my: "left top",
  4904. at: "right top"
  4905. },
  4906. role: "menu",
  4907. // callbacks
  4908. blur: null,
  4909. focus: null,
  4910. select: null
  4911. },
  4912. _create: function() {
  4913. this.activeMenu = this.element;
  4914. // flag used to prevent firing of the click handler
  4915. // as the event bubbles up through nested menus
  4916. this.mouseHandled = false;
  4917. this.element
  4918. .uniqueId()
  4919. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  4920. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  4921. .attr({
  4922. role: this.options.role,
  4923. tabIndex: 0
  4924. })
  4925. // need to catch all clicks on disabled menu
  4926. // not possible through _on
  4927. .bind( "click" + this.eventNamespace, $.proxy(function( event ) {
  4928. if ( this.options.disabled ) {
  4929. event.preventDefault();
  4930. }
  4931. }, this ));
  4932. if ( this.options.disabled ) {
  4933. this.element
  4934. .addClass( "ui-state-disabled" )
  4935. .attr( "aria-disabled", "true" );
  4936. }
  4937. this._on({
  4938. // Prevent focus from sticking to links inside menu after clicking
  4939. // them (focus should always stay on UL during navigation).
  4940. "mousedown .ui-menu-item > a": function( event ) {
  4941. event.preventDefault();
  4942. },
  4943. "click .ui-state-disabled > a": function( event ) {
  4944. event.preventDefault();
  4945. },
  4946. "click .ui-menu-item:has(a)": function( event ) {
  4947. var target = $( event.target ).closest( ".ui-menu-item" );
  4948. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  4949. this.mouseHandled = true;
  4950. this.select( event );
  4951. // Open submenu on click
  4952. if ( target.has( ".ui-menu" ).length ) {
  4953. this.expand( event );
  4954. } else if ( !this.element.is( ":focus" ) ) {
  4955. // Redirect focus to the menu
  4956. this.element.trigger( "focus", [ true ] );
  4957. // If the active item is on the top level, let it stay active.
  4958. // Otherwise, blur the active item since it is no longer visible.
  4959. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  4960. clearTimeout( this.timer );
  4961. }
  4962. }
  4963. }
  4964. },
  4965. "mouseenter .ui-menu-item": function( event ) {
  4966. var target = $( event.currentTarget );
  4967. // Remove ui-state-active class from siblings of the newly focused menu item
  4968. // to avoid a jump caused by adjacent elements both having a class with a border
  4969. target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
  4970. this.focus( event, target );
  4971. },
  4972. mouseleave: "collapseAll",
  4973. "mouseleave .ui-menu": "collapseAll",
  4974. focus: function( event, keepActiveItem ) {
  4975. // If there's already an active item, keep it active
  4976. // If not, activate the first item
  4977. var item = this.active || this.element.children( ".ui-menu-item" ).eq( 0 );
  4978. if ( !keepActiveItem ) {
  4979. this.focus( event, item );
  4980. }
  4981. },
  4982. blur: function( event ) {
  4983. this._delay(function() {
  4984. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  4985. this.collapseAll( event );
  4986. }
  4987. });
  4988. },
  4989. keydown: "_keydown"
  4990. });
  4991. this.refresh();
  4992. // Clicks outside of a menu collapse any open menus
  4993. this._on( this.document, {
  4994. click: function( event ) {
  4995. if ( !$( event.target ).closest( ".ui-menu" ).length ) {
  4996. this.collapseAll( event );
  4997. }
  4998. // Reset the mouseHandled flag
  4999. this.mouseHandled = false;
  5000. }
  5001. });
  5002. },
  5003. _destroy: function() {
  5004. // Destroy (sub)menus
  5005. this.element
  5006. .removeAttr( "aria-activedescendant" )
  5007. .find( ".ui-menu" ).addBack()
  5008. .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
  5009. .removeAttr( "role" )
  5010. .removeAttr( "tabIndex" )
  5011. .removeAttr( "aria-labelledby" )
  5012. .removeAttr( "aria-expanded" )
  5013. .removeAttr( "aria-hidden" )
  5014. .removeAttr( "aria-disabled" )
  5015. .removeUniqueId()
  5016. .show();
  5017. // Destroy menu items
  5018. this.element.find( ".ui-menu-item" )
  5019. .removeClass( "ui-menu-item" )
  5020. .removeAttr( "role" )
  5021. .removeAttr( "aria-disabled" )
  5022. .children( "a" )
  5023. .removeUniqueId()
  5024. .removeClass( "ui-corner-all ui-state-hover" )
  5025. .removeAttr( "tabIndex" )
  5026. .removeAttr( "role" )
  5027. .removeAttr( "aria-haspopup" )
  5028. .children().each( function() {
  5029. var elem = $( this );
  5030. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  5031. elem.remove();
  5032. }
  5033. });
  5034. // Destroy menu dividers
  5035. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  5036. },
  5037. _keydown: function( event ) {
  5038. /*jshint maxcomplexity:20*/
  5039. var match, prev, character, skip, regex,
  5040. preventDefault = true;
  5041. function escape( value ) {
  5042. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  5043. }
  5044. switch ( event.keyCode ) {
  5045. case $.ui.keyCode.PAGE_UP:
  5046. this.previousPage( event );
  5047. break;
  5048. case $.ui.keyCode.PAGE_DOWN:
  5049. this.nextPage( event );
  5050. break;
  5051. case $.ui.keyCode.HOME:
  5052. this._move( "first", "first", event );
  5053. break;
  5054. case $.ui.keyCode.END:
  5055. this._move( "last", "last", event );
  5056. break;
  5057. case $.ui.keyCode.UP:
  5058. this.previous( event );
  5059. break;
  5060. case $.ui.keyCode.DOWN:
  5061. this.next( event );
  5062. break;
  5063. case $.ui.keyCode.LEFT:
  5064. this.collapse( event );
  5065. break;
  5066. case $.ui.keyCode.RIGHT:
  5067. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  5068. this.expand( event );
  5069. }
  5070. break;
  5071. case $.ui.keyCode.ENTER:
  5072. case $.ui.keyCode.SPACE:
  5073. this._activate( event );
  5074. break;
  5075. case $.ui.keyCode.ESCAPE:
  5076. this.collapse( event );
  5077. break;
  5078. default:
  5079. preventDefault = false;
  5080. prev = this.previousFilter || "";
  5081. character = String.fromCharCode( event.keyCode );
  5082. skip = false;
  5083. clearTimeout( this.filterTimer );
  5084. if ( character === prev ) {
  5085. skip = true;
  5086. } else {
  5087. character = prev + character;
  5088. }
  5089. regex = new RegExp( "^" + escape( character ), "i" );
  5090. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  5091. return regex.test( $( this ).children( "a" ).text() );
  5092. });
  5093. match = skip && match.index( this.active.next() ) !== -1 ?
  5094. this.active.nextAll( ".ui-menu-item" ) :
  5095. match;
  5096. // If no matches on the current filter, reset to the last character pressed
  5097. // to move down the menu to the first item that starts with that character
  5098. if ( !match.length ) {
  5099. character = String.fromCharCode( event.keyCode );
  5100. regex = new RegExp( "^" + escape( character ), "i" );
  5101. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  5102. return regex.test( $( this ).children( "a" ).text() );
  5103. });
  5104. }
  5105. if ( match.length ) {
  5106. this.focus( event, match );
  5107. if ( match.length > 1 ) {
  5108. this.previousFilter = character;
  5109. this.filterTimer = this._delay(function() {
  5110. delete this.previousFilter;
  5111. }, 1000 );
  5112. } else {
  5113. delete this.previousFilter;
  5114. }
  5115. } else {
  5116. delete this.previousFilter;
  5117. }
  5118. }
  5119. if ( preventDefault ) {
  5120. event.preventDefault();
  5121. }
  5122. },
  5123. _activate: function( event ) {
  5124. if ( !this.active.is( ".ui-state-disabled" ) ) {
  5125. if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
  5126. this.expand( event );
  5127. } else {
  5128. this.select( event );
  5129. }
  5130. }
  5131. },
  5132. refresh: function() {
  5133. var menus,
  5134. icon = this.options.icons.submenu,
  5135. submenus = this.element.find( this.options.menus );
  5136. // Initialize nested menus
  5137. submenus.filter( ":not(.ui-menu)" )
  5138. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  5139. .hide()
  5140. .attr({
  5141. role: this.options.role,
  5142. "aria-hidden": "true",
  5143. "aria-expanded": "false"
  5144. })
  5145. .each(function() {
  5146. var menu = $( this ),
  5147. item = menu.prev( "a" ),
  5148. submenuCarat = $( "<span>" )
  5149. .addClass( "ui-menu-icon ui-icon " + icon )
  5150. .data( "ui-menu-submenu-carat", true );
  5151. item
  5152. .attr( "aria-haspopup", "true" )
  5153. .prepend( submenuCarat );
  5154. menu.attr( "aria-labelledby", item.attr( "id" ) );
  5155. });
  5156. menus = submenus.add( this.element );
  5157. // Don't refresh list items that are already adapted
  5158. menus.children( ":not(.ui-menu-item):has(a)" )
  5159. .addClass( "ui-menu-item" )
  5160. .attr( "role", "presentation" )
  5161. .children( "a" )
  5162. .uniqueId()
  5163. .addClass( "ui-corner-all" )
  5164. .attr({
  5165. tabIndex: -1,
  5166. role: this._itemRole()
  5167. });
  5168. // Initialize unlinked menu-items containing spaces and/or dashes only as dividers
  5169. menus.children( ":not(.ui-menu-item)" ).each(function() {
  5170. var item = $( this );
  5171. // hyphen, em dash, en dash
  5172. if ( !/[^\-\u2014\u2013\s]/.test( item.text() ) ) {
  5173. item.addClass( "ui-widget-content ui-menu-divider" );
  5174. }
  5175. });
  5176. // Add aria-disabled attribute to any disabled menu item
  5177. menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  5178. // If the active item has been removed, blur the menu
  5179. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  5180. this.blur();
  5181. }
  5182. },
  5183. _itemRole: function() {
  5184. return {
  5185. menu: "menuitem",
  5186. listbox: "option"
  5187. }[ this.options.role ];
  5188. },
  5189. _setOption: function( key, value ) {
  5190. if ( key === "icons" ) {
  5191. this.element.find( ".ui-menu-icon" )
  5192. .removeClass( this.options.icons.submenu )
  5193. .addClass( value.submenu );
  5194. }
  5195. this._super( key, value );
  5196. },
  5197. focus: function( event, item ) {
  5198. var nested, focused;
  5199. this.blur( event, event && event.type === "focus" );
  5200. this._scrollIntoView( item );
  5201. this.active = item.first();
  5202. focused = this.active.children( "a" ).addClass( "ui-state-focus" );
  5203. // Only update aria-activedescendant if there's a role
  5204. // otherwise we assume focus is managed elsewhere
  5205. if ( this.options.role ) {
  5206. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  5207. }
  5208. // Highlight active parent menu item, if any
  5209. this.active
  5210. .parent()
  5211. .closest( ".ui-menu-item" )
  5212. .children( "a:first" )
  5213. .addClass( "ui-state-active" );
  5214. if ( event && event.type === "keydown" ) {
  5215. this._close();
  5216. } else {
  5217. this.timer = this._delay(function() {
  5218. this._close();
  5219. }, this.delay );
  5220. }
  5221. nested = item.children( ".ui-menu" );
  5222. if ( nested.length && ( /^mouse/.test( event.type ) ) ) {
  5223. this._startOpening(nested);
  5224. }
  5225. this.activeMenu = item.parent();
  5226. this._trigger( "focus", event, { item: item } );
  5227. },
  5228. _scrollIntoView: function( item ) {
  5229. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  5230. if ( this._hasScroll() ) {
  5231. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  5232. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  5233. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  5234. scroll = this.activeMenu.scrollTop();
  5235. elementHeight = this.activeMenu.height();
  5236. itemHeight = item.height();
  5237. if ( offset < 0 ) {
  5238. this.activeMenu.scrollTop( scroll + offset );
  5239. } else if ( offset + itemHeight > elementHeight ) {
  5240. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  5241. }
  5242. }
  5243. },
  5244. blur: function( event, fromFocus ) {
  5245. if ( !fromFocus ) {
  5246. clearTimeout( this.timer );
  5247. }
  5248. if ( !this.active ) {
  5249. return;
  5250. }
  5251. this.active.children( "a" ).removeClass( "ui-state-focus" );
  5252. this.active = null;
  5253. this._trigger( "blur", event, { item: this.active } );
  5254. },
  5255. _startOpening: function( submenu ) {
  5256. clearTimeout( this.timer );
  5257. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  5258. // shift in the submenu position when mousing over the carat icon
  5259. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  5260. return;
  5261. }
  5262. this.timer = this._delay(function() {
  5263. this._close();
  5264. this._open( submenu );
  5265. }, this.delay );
  5266. },
  5267. _open: function( submenu ) {
  5268. var position = $.extend({
  5269. of: this.active
  5270. }, this.options.position );
  5271. clearTimeout( this.timer );
  5272. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  5273. .hide()
  5274. .attr( "aria-hidden", "true" );
  5275. submenu
  5276. .show()
  5277. .removeAttr( "aria-hidden" )
  5278. .attr( "aria-expanded", "true" )
  5279. .position( position );
  5280. },
  5281. collapseAll: function( event, all ) {
  5282. clearTimeout( this.timer );
  5283. this.timer = this._delay(function() {
  5284. // If we were passed an event, look for the submenu that contains the event
  5285. var currentMenu = all ? this.element :
  5286. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  5287. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  5288. if ( !currentMenu.length ) {
  5289. currentMenu = this.element;
  5290. }
  5291. this._close( currentMenu );
  5292. this.blur( event );
  5293. this.activeMenu = currentMenu;
  5294. }, this.delay );
  5295. },
  5296. // With no arguments, closes the currently active menu - if nothing is active
  5297. // it closes all menus. If passed an argument, it will search for menus BELOW
  5298. _close: function( startMenu ) {
  5299. if ( !startMenu ) {
  5300. startMenu = this.active ? this.active.parent() : this.element;
  5301. }
  5302. startMenu
  5303. .find( ".ui-menu" )
  5304. .hide()
  5305. .attr( "aria-hidden", "true" )
  5306. .attr( "aria-expanded", "false" )
  5307. .end()
  5308. .find( "a.ui-state-active" )
  5309. .removeClass( "ui-state-active" );
  5310. },
  5311. collapse: function( event ) {
  5312. var newItem = this.active &&
  5313. this.active.parent().closest( ".ui-menu-item", this.element );
  5314. if ( newItem && newItem.length ) {
  5315. this._close();
  5316. this.focus( event, newItem );
  5317. }
  5318. },
  5319. expand: function( event ) {
  5320. var newItem = this.active &&
  5321. this.active
  5322. .children( ".ui-menu " )
  5323. .children( ".ui-menu-item" )
  5324. .first();
  5325. if ( newItem && newItem.length ) {
  5326. this._open( newItem.parent() );
  5327. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  5328. this._delay(function() {
  5329. this.focus( event, newItem );
  5330. });
  5331. }
  5332. },
  5333. next: function( event ) {
  5334. this._move( "next", "first", event );
  5335. },
  5336. previous: function( event ) {
  5337. this._move( "prev", "last", event );
  5338. },
  5339. isFirstItem: function() {
  5340. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  5341. },
  5342. isLastItem: function() {
  5343. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  5344. },
  5345. _move: function( direction, filter, event ) {
  5346. var next;
  5347. if ( this.active ) {
  5348. if ( direction === "first" || direction === "last" ) {
  5349. next = this.active
  5350. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  5351. .eq( -1 );
  5352. } else {
  5353. next = this.active
  5354. [ direction + "All" ]( ".ui-menu-item" )
  5355. .eq( 0 );
  5356. }
  5357. }
  5358. if ( !next || !next.length || !this.active ) {
  5359. next = this.activeMenu.children( ".ui-menu-item" )[ filter ]();
  5360. }
  5361. this.focus( event, next );
  5362. },
  5363. nextPage: function( event ) {
  5364. var item, base, height;
  5365. if ( !this.active ) {
  5366. this.next( event );
  5367. return;
  5368. }
  5369. if ( this.isLastItem() ) {
  5370. return;
  5371. }
  5372. if ( this._hasScroll() ) {
  5373. base = this.active.offset().top;
  5374. height = this.element.height();
  5375. this.active.nextAll( ".ui-menu-item" ).each(function() {
  5376. item = $( this );
  5377. return item.offset().top - base - height < 0;
  5378. });
  5379. this.focus( event, item );
  5380. } else {
  5381. this.focus( event, this.activeMenu.children( ".ui-menu-item" )
  5382. [ !this.active ? "first" : "last" ]() );
  5383. }
  5384. },
  5385. previousPage: function( event ) {
  5386. var item, base, height;
  5387. if ( !this.active ) {
  5388. this.next( event );
  5389. return;
  5390. }
  5391. if ( this.isFirstItem() ) {
  5392. return;
  5393. }
  5394. if ( this._hasScroll() ) {
  5395. base = this.active.offset().top;
  5396. height = this.element.height();
  5397. this.active.prevAll( ".ui-menu-item" ).each(function() {
  5398. item = $( this );
  5399. return item.offset().top - base + height > 0;
  5400. });
  5401. this.focus( event, item );
  5402. } else {
  5403. this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
  5404. }
  5405. },
  5406. _hasScroll: function() {
  5407. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  5408. },
  5409. select: function( event ) {
  5410. // TODO: It should never be possible to not have an active item at this
  5411. // point, but the tests don't trigger mouseenter before click.
  5412. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  5413. var ui = { item: this.active };
  5414. if ( !this.active.has( ".ui-menu" ).length ) {
  5415. this.collapseAll( event, true );
  5416. }
  5417. this._trigger( "select", event, ui );
  5418. }
  5419. });
  5420. }( jQuery ));
  5421. (function($, undefined) {
  5422. var dataSpace = "ui-effects-";
  5423. $.effects = {
  5424. effect: {}
  5425. };
  5426. /*!
  5427. * jQuery Color Animations v2.1.2
  5428. * https://github.com/jquery/jquery-color
  5429. *
  5430. * Copyright 2013 jQuery Foundation and other contributors
  5431. * Released under the MIT license.
  5432. * http://jquery.org/license
  5433. *
  5434. * Date: Wed Jan 16 08:47:09 2013 -0600
  5435. */
  5436. (function( jQuery, undefined ) {
  5437. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  5438. // plusequals test for += 100 -= 100
  5439. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  5440. // a set of RE's that can match strings and generate color tuples.
  5441. stringParsers = [{
  5442. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  5443. parse: function( execResult ) {
  5444. return [
  5445. execResult[ 1 ],
  5446. execResult[ 2 ],
  5447. execResult[ 3 ],
  5448. execResult[ 4 ]
  5449. ];
  5450. }
  5451. }, {
  5452. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  5453. parse: function( execResult ) {
  5454. return [
  5455. execResult[ 1 ] * 2.55,
  5456. execResult[ 2 ] * 2.55,
  5457. execResult[ 3 ] * 2.55,
  5458. execResult[ 4 ]
  5459. ];
  5460. }
  5461. }, {
  5462. // this regex ignores A-F because it's compared against an already lowercased string
  5463. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  5464. parse: function( execResult ) {
  5465. return [
  5466. parseInt( execResult[ 1 ], 16 ),
  5467. parseInt( execResult[ 2 ], 16 ),
  5468. parseInt( execResult[ 3 ], 16 )
  5469. ];
  5470. }
  5471. }, {
  5472. // this regex ignores A-F because it's compared against an already lowercased string
  5473. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  5474. parse: function( execResult ) {
  5475. return [
  5476. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  5477. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  5478. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  5479. ];
  5480. }
  5481. }, {
  5482. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  5483. space: "hsla",
  5484. parse: function( execResult ) {
  5485. return [
  5486. execResult[ 1 ],
  5487. execResult[ 2 ] / 100,
  5488. execResult[ 3 ] / 100,
  5489. execResult[ 4 ]
  5490. ];
  5491. }
  5492. }],
  5493. // jQuery.Color( )
  5494. color = jQuery.Color = function( color, green, blue, alpha ) {
  5495. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  5496. },
  5497. spaces = {
  5498. rgba: {
  5499. props: {
  5500. red: {
  5501. idx: 0,
  5502. type: "byte"
  5503. },
  5504. green: {
  5505. idx: 1,
  5506. type: "byte"
  5507. },
  5508. blue: {
  5509. idx: 2,
  5510. type: "byte"
  5511. }
  5512. }
  5513. },
  5514. hsla: {
  5515. props: {
  5516. hue: {
  5517. idx: 0,
  5518. type: "degrees"
  5519. },
  5520. saturation: {
  5521. idx: 1,
  5522. type: "percent"
  5523. },
  5524. lightness: {
  5525. idx: 2,
  5526. type: "percent"
  5527. }
  5528. }
  5529. }
  5530. },
  5531. propTypes = {
  5532. "byte": {
  5533. floor: true,
  5534. max: 255
  5535. },
  5536. "percent": {
  5537. max: 1
  5538. },
  5539. "degrees": {
  5540. mod: 360,
  5541. floor: true
  5542. }
  5543. },
  5544. support = color.support = {},
  5545. // element for support tests
  5546. supportElem = jQuery( "<p>" )[ 0 ],
  5547. // colors = jQuery.Color.names
  5548. colors,
  5549. // local aliases of functions called often
  5550. each = jQuery.each;
  5551. // determine rgba support immediately
  5552. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  5553. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  5554. // define cache name and alpha properties
  5555. // for rgba and hsla spaces
  5556. each( spaces, function( spaceName, space ) {
  5557. space.cache = "_" + spaceName;
  5558. space.props.alpha = {
  5559. idx: 3,
  5560. type: "percent",
  5561. def: 1
  5562. };
  5563. });
  5564. function clamp( value, prop, allowEmpty ) {
  5565. var type = propTypes[ prop.type ] || {};
  5566. if ( value == null ) {
  5567. return (allowEmpty || !prop.def) ? null : prop.def;
  5568. }
  5569. // ~~ is an short way of doing floor for positive numbers
  5570. value = type.floor ? ~~value : parseFloat( value );
  5571. // IE will pass in empty strings as value for alpha,
  5572. // which will hit this case
  5573. if ( isNaN( value ) ) {
  5574. return prop.def;
  5575. }
  5576. if ( type.mod ) {
  5577. // we add mod before modding to make sure that negatives values
  5578. // get converted properly: -10 -> 350
  5579. return (value + type.mod) % type.mod;
  5580. }
  5581. // for now all property types without mod have min and max
  5582. return 0 > value ? 0 : type.max < value ? type.max : value;
  5583. }
  5584. function stringParse( string ) {
  5585. var inst = color(),
  5586. rgba = inst._rgba = [];
  5587. string = string.toLowerCase();
  5588. each( stringParsers, function( i, parser ) {
  5589. var parsed,
  5590. match = parser.re.exec( string ),
  5591. values = match && parser.parse( match ),
  5592. spaceName = parser.space || "rgba";
  5593. if ( values ) {
  5594. parsed = inst[ spaceName ]( values );
  5595. // if this was an rgba parse the assignment might happen twice
  5596. // oh well....
  5597. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  5598. rgba = inst._rgba = parsed._rgba;
  5599. // exit each( stringParsers ) here because we matched
  5600. return false;
  5601. }
  5602. });
  5603. // Found a stringParser that handled it
  5604. if ( rgba.length ) {
  5605. // if this came from a parsed string, force "transparent" when alpha is 0
  5606. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  5607. if ( rgba.join() === "0,0,0,0" ) {
  5608. jQuery.extend( rgba, colors.transparent );
  5609. }
  5610. return inst;
  5611. }
  5612. // named colors
  5613. return colors[ string ];
  5614. }
  5615. color.fn = jQuery.extend( color.prototype, {
  5616. parse: function( red, green, blue, alpha ) {
  5617. if ( red === undefined ) {
  5618. this._rgba = [ null, null, null, null ];
  5619. return this;
  5620. }
  5621. if ( red.jquery || red.nodeType ) {
  5622. red = jQuery( red ).css( green );
  5623. green = undefined;
  5624. }
  5625. var inst = this,
  5626. type = jQuery.type( red ),
  5627. rgba = this._rgba = [];
  5628. // more than 1 argument specified - assume ( red, green, blue, alpha )
  5629. if ( green !== undefined ) {
  5630. red = [ red, green, blue, alpha ];
  5631. type = "array";
  5632. }
  5633. if ( type === "string" ) {
  5634. return this.parse( stringParse( red ) || colors._default );
  5635. }
  5636. if ( type === "array" ) {
  5637. each( spaces.rgba.props, function( key, prop ) {
  5638. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  5639. });
  5640. return this;
  5641. }
  5642. if ( type === "object" ) {
  5643. if ( red instanceof color ) {
  5644. each( spaces, function( spaceName, space ) {
  5645. if ( red[ space.cache ] ) {
  5646. inst[ space.cache ] = red[ space.cache ].slice();
  5647. }
  5648. });
  5649. } else {
  5650. each( spaces, function( spaceName, space ) {
  5651. var cache = space.cache;
  5652. each( space.props, function( key, prop ) {
  5653. // if the cache doesn't exist, and we know how to convert
  5654. if ( !inst[ cache ] && space.to ) {
  5655. // if the value was null, we don't need to copy it
  5656. // if the key was alpha, we don't need to copy it either
  5657. if ( key === "alpha" || red[ key ] == null ) {
  5658. return;
  5659. }
  5660. inst[ cache ] = space.to( inst._rgba );
  5661. }
  5662. // this is the only case where we allow nulls for ALL properties.
  5663. // call clamp with alwaysAllowEmpty
  5664. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  5665. });
  5666. // everything defined but alpha?
  5667. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  5668. // use the default of 1
  5669. inst[ cache ][ 3 ] = 1;
  5670. if ( space.from ) {
  5671. inst._rgba = space.from( inst[ cache ] );
  5672. }
  5673. }
  5674. });
  5675. }
  5676. return this;
  5677. }
  5678. },
  5679. is: function( compare ) {
  5680. var is = color( compare ),
  5681. same = true,
  5682. inst = this;
  5683. each( spaces, function( _, space ) {
  5684. var localCache,
  5685. isCache = is[ space.cache ];
  5686. if (isCache) {
  5687. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  5688. each( space.props, function( _, prop ) {
  5689. if ( isCache[ prop.idx ] != null ) {
  5690. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  5691. return same;
  5692. }
  5693. });
  5694. }
  5695. return same;
  5696. });
  5697. return same;
  5698. },
  5699. _space: function() {
  5700. var used = [],
  5701. inst = this;
  5702. each( spaces, function( spaceName, space ) {
  5703. if ( inst[ space.cache ] ) {
  5704. used.push( spaceName );
  5705. }
  5706. });
  5707. return used.pop();
  5708. },
  5709. transition: function( other, distance ) {
  5710. var end = color( other ),
  5711. spaceName = end._space(),
  5712. space = spaces[ spaceName ],
  5713. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  5714. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  5715. result = start.slice();
  5716. end = end[ space.cache ];
  5717. each( space.props, function( key, prop ) {
  5718. var index = prop.idx,
  5719. startValue = start[ index ],
  5720. endValue = end[ index ],
  5721. type = propTypes[ prop.type ] || {};
  5722. // if null, don't override start value
  5723. if ( endValue === null ) {
  5724. return;
  5725. }
  5726. // if null - use end
  5727. if ( startValue === null ) {
  5728. result[ index ] = endValue;
  5729. } else {
  5730. if ( type.mod ) {
  5731. if ( endValue - startValue > type.mod / 2 ) {
  5732. startValue += type.mod;
  5733. } else if ( startValue - endValue > type.mod / 2 ) {
  5734. startValue -= type.mod;
  5735. }
  5736. }
  5737. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  5738. }
  5739. });
  5740. return this[ spaceName ]( result );
  5741. },
  5742. blend: function( opaque ) {
  5743. // if we are already opaque - return ourself
  5744. if ( this._rgba[ 3 ] === 1 ) {
  5745. return this;
  5746. }
  5747. var rgb = this._rgba.slice(),
  5748. a = rgb.pop(),
  5749. blend = color( opaque )._rgba;
  5750. return color( jQuery.map( rgb, function( v, i ) {
  5751. return ( 1 - a ) * blend[ i ] + a * v;
  5752. }));
  5753. },
  5754. toRgbaString: function() {
  5755. var prefix = "rgba(",
  5756. rgba = jQuery.map( this._rgba, function( v, i ) {
  5757. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  5758. });
  5759. if ( rgba[ 3 ] === 1 ) {
  5760. rgba.pop();
  5761. prefix = "rgb(";
  5762. }
  5763. return prefix + rgba.join() + ")";
  5764. },
  5765. toHslaString: function() {
  5766. var prefix = "hsla(",
  5767. hsla = jQuery.map( this.hsla(), function( v, i ) {
  5768. if ( v == null ) {
  5769. v = i > 2 ? 1 : 0;
  5770. }
  5771. // catch 1 and 2
  5772. if ( i && i < 3 ) {
  5773. v = Math.round( v * 100 ) + "%";
  5774. }
  5775. return v;
  5776. });
  5777. if ( hsla[ 3 ] === 1 ) {
  5778. hsla.pop();
  5779. prefix = "hsl(";
  5780. }
  5781. return prefix + hsla.join() + ")";
  5782. },
  5783. toHexString: function( includeAlpha ) {
  5784. var rgba = this._rgba.slice(),
  5785. alpha = rgba.pop();
  5786. if ( includeAlpha ) {
  5787. rgba.push( ~~( alpha * 255 ) );
  5788. }
  5789. return "#" + jQuery.map( rgba, function( v ) {
  5790. // default to 0 when nulls exist
  5791. v = ( v || 0 ).toString( 16 );
  5792. return v.length === 1 ? "0" + v : v;
  5793. }).join("");
  5794. },
  5795. toString: function() {
  5796. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  5797. }
  5798. });
  5799. color.fn.parse.prototype = color.fn;
  5800. // hsla conversions adapted from:
  5801. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  5802. function hue2rgb( p, q, h ) {
  5803. h = ( h + 1 ) % 1;
  5804. if ( h * 6 < 1 ) {
  5805. return p + (q - p) * h * 6;
  5806. }
  5807. if ( h * 2 < 1) {
  5808. return q;
  5809. }
  5810. if ( h * 3 < 2 ) {
  5811. return p + (q - p) * ((2/3) - h) * 6;
  5812. }
  5813. return p;
  5814. }
  5815. spaces.hsla.to = function ( rgba ) {
  5816. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  5817. return [ null, null, null, rgba[ 3 ] ];
  5818. }
  5819. var r = rgba[ 0 ] / 255,
  5820. g = rgba[ 1 ] / 255,
  5821. b = rgba[ 2 ] / 255,
  5822. a = rgba[ 3 ],
  5823. max = Math.max( r, g, b ),
  5824. min = Math.min( r, g, b ),
  5825. diff = max - min,
  5826. add = max + min,
  5827. l = add * 0.5,
  5828. h, s;
  5829. if ( min === max ) {
  5830. h = 0;
  5831. } else if ( r === max ) {
  5832. h = ( 60 * ( g - b ) / diff ) + 360;
  5833. } else if ( g === max ) {
  5834. h = ( 60 * ( b - r ) / diff ) + 120;
  5835. } else {
  5836. h = ( 60 * ( r - g ) / diff ) + 240;
  5837. }
  5838. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  5839. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  5840. if ( diff === 0 ) {
  5841. s = 0;
  5842. } else if ( l <= 0.5 ) {
  5843. s = diff / add;
  5844. } else {
  5845. s = diff / ( 2 - add );
  5846. }
  5847. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  5848. };
  5849. spaces.hsla.from = function ( hsla ) {
  5850. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  5851. return [ null, null, null, hsla[ 3 ] ];
  5852. }
  5853. var h = hsla[ 0 ] / 360,
  5854. s = hsla[ 1 ],
  5855. l = hsla[ 2 ],
  5856. a = hsla[ 3 ],
  5857. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  5858. p = 2 * l - q;
  5859. return [
  5860. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  5861. Math.round( hue2rgb( p, q, h ) * 255 ),
  5862. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  5863. a
  5864. ];
  5865. };
  5866. each( spaces, function( spaceName, space ) {
  5867. var props = space.props,
  5868. cache = space.cache,
  5869. to = space.to,
  5870. from = space.from;
  5871. // makes rgba() and hsla()
  5872. color.fn[ spaceName ] = function( value ) {
  5873. // generate a cache for this space if it doesn't exist
  5874. if ( to && !this[ cache ] ) {
  5875. this[ cache ] = to( this._rgba );
  5876. }
  5877. if ( value === undefined ) {
  5878. return this[ cache ].slice();
  5879. }
  5880. var ret,
  5881. type = jQuery.type( value ),
  5882. arr = ( type === "array" || type === "object" ) ? value : arguments,
  5883. local = this[ cache ].slice();
  5884. each( props, function( key, prop ) {
  5885. var val = arr[ type === "object" ? key : prop.idx ];
  5886. if ( val == null ) {
  5887. val = local[ prop.idx ];
  5888. }
  5889. local[ prop.idx ] = clamp( val, prop );
  5890. });
  5891. if ( from ) {
  5892. ret = color( from( local ) );
  5893. ret[ cache ] = local;
  5894. return ret;
  5895. } else {
  5896. return color( local );
  5897. }
  5898. };
  5899. // makes red() green() blue() alpha() hue() saturation() lightness()
  5900. each( props, function( key, prop ) {
  5901. // alpha is included in more than one space
  5902. if ( color.fn[ key ] ) {
  5903. return;
  5904. }
  5905. color.fn[ key ] = function( value ) {
  5906. var vtype = jQuery.type( value ),
  5907. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  5908. local = this[ fn ](),
  5909. cur = local[ prop.idx ],
  5910. match;
  5911. if ( vtype === "undefined" ) {
  5912. return cur;
  5913. }
  5914. if ( vtype === "function" ) {
  5915. value = value.call( this, cur );
  5916. vtype = jQuery.type( value );
  5917. }
  5918. if ( value == null && prop.empty ) {
  5919. return this;
  5920. }
  5921. if ( vtype === "string" ) {
  5922. match = rplusequals.exec( value );
  5923. if ( match ) {
  5924. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  5925. }
  5926. }
  5927. local[ prop.idx ] = value;
  5928. return this[ fn ]( local );
  5929. };
  5930. });
  5931. });
  5932. // add cssHook and .fx.step function for each named hook.
  5933. // accept a space separated string of properties
  5934. color.hook = function( hook ) {
  5935. var hooks = hook.split( " " );
  5936. each( hooks, function( i, hook ) {
  5937. jQuery.cssHooks[ hook ] = {
  5938. set: function( elem, value ) {
  5939. var parsed, curElem,
  5940. backgroundColor = "";
  5941. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  5942. value = color( parsed || value );
  5943. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  5944. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  5945. while (
  5946. (backgroundColor === "" || backgroundColor === "transparent") &&
  5947. curElem && curElem.style
  5948. ) {
  5949. try {
  5950. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  5951. curElem = curElem.parentNode;
  5952. } catch ( e ) {
  5953. }
  5954. }
  5955. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  5956. backgroundColor :
  5957. "_default" );
  5958. }
  5959. value = value.toRgbaString();
  5960. }
  5961. try {
  5962. elem.style[ hook ] = value;
  5963. } catch( e ) {
  5964. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  5965. }
  5966. }
  5967. };
  5968. jQuery.fx.step[ hook ] = function( fx ) {
  5969. if ( !fx.colorInit ) {
  5970. fx.start = color( fx.elem, hook );
  5971. fx.end = color( fx.end );
  5972. fx.colorInit = true;
  5973. }
  5974. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  5975. };
  5976. });
  5977. };
  5978. color.hook( stepHooks );
  5979. jQuery.cssHooks.borderColor = {
  5980. expand: function( value ) {
  5981. var expanded = {};
  5982. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  5983. expanded[ "border" + part + "Color" ] = value;
  5984. });
  5985. return expanded;
  5986. }
  5987. };
  5988. // Basic color names only.
  5989. // Usage of any of the other color names requires adding yourself or including
  5990. // jquery.color.svg-names.js.
  5991. colors = jQuery.Color.names = {
  5992. // 4.1. Basic color keywords
  5993. aqua: "#00ffff",
  5994. black: "#000000",
  5995. blue: "#0000ff",
  5996. fuchsia: "#ff00ff",
  5997. gray: "#808080",
  5998. green: "#008000",
  5999. lime: "#00ff00",
  6000. maroon: "#800000",
  6001. navy: "#000080",
  6002. olive: "#808000",
  6003. purple: "#800080",
  6004. red: "#ff0000",
  6005. silver: "#c0c0c0",
  6006. teal: "#008080",
  6007. white: "#ffffff",
  6008. yellow: "#ffff00",
  6009. // 4.2.3. "transparent" color keyword
  6010. transparent: [ null, null, null, 0 ],
  6011. _default: "#ffffff"
  6012. };
  6013. })( jQuery );
  6014. /******************************************************************************/
  6015. /****************************** CLASS ANIMATIONS ******************************/
  6016. /******************************************************************************/
  6017. (function() {
  6018. var classAnimationActions = [ "add", "remove", "toggle" ],
  6019. shorthandStyles = {
  6020. border: 1,
  6021. borderBottom: 1,
  6022. borderColor: 1,
  6023. borderLeft: 1,
  6024. borderRight: 1,
  6025. borderTop: 1,
  6026. borderWidth: 1,
  6027. margin: 1,
  6028. padding: 1
  6029. };
  6030. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  6031. $.fx.step[ prop ] = function( fx ) {
  6032. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  6033. jQuery.style( fx.elem, prop, fx.end );
  6034. fx.setAttr = true;
  6035. }
  6036. };
  6037. });
  6038. function getElementStyles( elem ) {
  6039. var key, len,
  6040. style = elem.ownerDocument.defaultView ?
  6041. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  6042. elem.currentStyle,
  6043. styles = {};
  6044. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  6045. len = style.length;
  6046. while ( len-- ) {
  6047. key = style[ len ];
  6048. if ( typeof style[ key ] === "string" ) {
  6049. styles[ $.camelCase( key ) ] = style[ key ];
  6050. }
  6051. }
  6052. // support: Opera, IE <9
  6053. } else {
  6054. for ( key in style ) {
  6055. if ( typeof style[ key ] === "string" ) {
  6056. styles[ key ] = style[ key ];
  6057. }
  6058. }
  6059. }
  6060. return styles;
  6061. }
  6062. function styleDifference( oldStyle, newStyle ) {
  6063. var diff = {},
  6064. name, value;
  6065. for ( name in newStyle ) {
  6066. value = newStyle[ name ];
  6067. if ( oldStyle[ name ] !== value ) {
  6068. if ( !shorthandStyles[ name ] ) {
  6069. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  6070. diff[ name ] = value;
  6071. }
  6072. }
  6073. }
  6074. }
  6075. return diff;
  6076. }
  6077. // support: jQuery <1.8
  6078. if ( !$.fn.addBack ) {
  6079. $.fn.addBack = function( selector ) {
  6080. return this.add( selector == null ?
  6081. this.prevObject : this.prevObject.filter( selector )
  6082. );
  6083. };
  6084. }
  6085. $.effects.animateClass = function( value, duration, easing, callback ) {
  6086. var o = $.speed( duration, easing, callback );
  6087. return this.queue( function() {
  6088. var animated = $( this ),
  6089. baseClass = animated.attr( "class" ) || "",
  6090. applyClassChange,
  6091. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  6092. // map the animated objects to store the original styles.
  6093. allAnimations = allAnimations.map(function() {
  6094. var el = $( this );
  6095. return {
  6096. el: el,
  6097. start: getElementStyles( this )
  6098. };
  6099. });
  6100. // apply class change
  6101. applyClassChange = function() {
  6102. $.each( classAnimationActions, function(i, action) {
  6103. if ( value[ action ] ) {
  6104. animated[ action + "Class" ]( value[ action ] );
  6105. }
  6106. });
  6107. };
  6108. applyClassChange();
  6109. // map all animated objects again - calculate new styles and diff
  6110. allAnimations = allAnimations.map(function() {
  6111. this.end = getElementStyles( this.el[ 0 ] );
  6112. this.diff = styleDifference( this.start, this.end );
  6113. return this;
  6114. });
  6115. // apply original class
  6116. animated.attr( "class", baseClass );
  6117. // map all animated objects again - this time collecting a promise
  6118. allAnimations = allAnimations.map(function() {
  6119. var styleInfo = this,
  6120. dfd = $.Deferred(),
  6121. opts = $.extend({}, o, {
  6122. queue: false,
  6123. complete: function() {
  6124. dfd.resolve( styleInfo );
  6125. }
  6126. });
  6127. this.el.animate( this.diff, opts );
  6128. return dfd.promise();
  6129. });
  6130. // once all animations have completed:
  6131. $.when.apply( $, allAnimations.get() ).done(function() {
  6132. // set the final class
  6133. applyClassChange();
  6134. // for each animated element,
  6135. // clear all css properties that were animated
  6136. $.each( arguments, function() {
  6137. var el = this.el;
  6138. $.each( this.diff, function(key) {
  6139. el.css( key, "" );
  6140. });
  6141. });
  6142. // this is guarnteed to be there if you use jQuery.speed()
  6143. // it also handles dequeuing the next anim...
  6144. o.complete.call( animated[ 0 ] );
  6145. });
  6146. });
  6147. };
  6148. $.fn.extend({
  6149. addClass: (function( orig ) {
  6150. return function( classNames, speed, easing, callback ) {
  6151. return speed ?
  6152. $.effects.animateClass.call( this,
  6153. { add: classNames }, speed, easing, callback ) :
  6154. orig.apply( this, arguments );
  6155. };
  6156. })( $.fn.addClass ),
  6157. removeClass: (function( orig ) {
  6158. return function( classNames, speed, easing, callback ) {
  6159. return arguments.length > 1 ?
  6160. $.effects.animateClass.call( this,
  6161. { remove: classNames }, speed, easing, callback ) :
  6162. orig.apply( this, arguments );
  6163. };
  6164. })( $.fn.removeClass ),
  6165. toggleClass: (function( orig ) {
  6166. return function( classNames, force, speed, easing, callback ) {
  6167. if ( typeof force === "boolean" || force === undefined ) {
  6168. if ( !speed ) {
  6169. // without speed parameter
  6170. return orig.apply( this, arguments );
  6171. } else {
  6172. return $.effects.animateClass.call( this,
  6173. (force ? { add: classNames } : { remove: classNames }),
  6174. speed, easing, callback );
  6175. }
  6176. } else {
  6177. // without force parameter
  6178. return $.effects.animateClass.call( this,
  6179. { toggle: classNames }, force, speed, easing );
  6180. }
  6181. };
  6182. })( $.fn.toggleClass ),
  6183. switchClass: function( remove, add, speed, easing, callback) {
  6184. return $.effects.animateClass.call( this, {
  6185. add: add,
  6186. remove: remove
  6187. }, speed, easing, callback );
  6188. }
  6189. });
  6190. })();
  6191. /******************************************************************************/
  6192. /*********************************** EFFECTS **********************************/
  6193. /******************************************************************************/
  6194. (function() {
  6195. $.extend( $.effects, {
  6196. version: "1.10.3",
  6197. // Saves a set of properties in a data storage
  6198. save: function( element, set ) {
  6199. for( var i=0; i < set.length; i++ ) {
  6200. if ( set[ i ] !== null ) {
  6201. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  6202. }
  6203. }
  6204. },
  6205. // Restores a set of previously saved properties from a data storage
  6206. restore: function( element, set ) {
  6207. var val, i;
  6208. for( i=0; i < set.length; i++ ) {
  6209. if ( set[ i ] !== null ) {
  6210. val = element.data( dataSpace + set[ i ] );
  6211. // support: jQuery 1.6.2
  6212. // http://bugs.jquery.com/ticket/9917
  6213. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  6214. // We can't differentiate between "" and 0 here, so we just assume
  6215. // empty string since it's likely to be a more common value...
  6216. if ( val === undefined ) {
  6217. val = "";
  6218. }
  6219. element.css( set[ i ], val );
  6220. }
  6221. }
  6222. },
  6223. setMode: function( el, mode ) {
  6224. if (mode === "toggle") {
  6225. mode = el.is( ":hidden" ) ? "show" : "hide";
  6226. }
  6227. return mode;
  6228. },
  6229. // Translates a [top,left] array into a baseline value
  6230. // this should be a little more flexible in the future to handle a string & hash
  6231. getBaseline: function( origin, original ) {
  6232. var y, x;
  6233. switch ( origin[ 0 ] ) {
  6234. case "top": y = 0; break;
  6235. case "middle": y = 0.5; break;
  6236. case "bottom": y = 1; break;
  6237. default: y = origin[ 0 ] / original.height;
  6238. }
  6239. switch ( origin[ 1 ] ) {
  6240. case "left": x = 0; break;
  6241. case "center": x = 0.5; break;
  6242. case "right": x = 1; break;
  6243. default: x = origin[ 1 ] / original.width;
  6244. }
  6245. return {
  6246. x: x,
  6247. y: y
  6248. };
  6249. },
  6250. // Wraps the element around a wrapper that copies position properties
  6251. createWrapper: function( element ) {
  6252. // if the element is already wrapped, return it
  6253. if ( element.parent().is( ".ui-effects-wrapper" )) {
  6254. return element.parent();
  6255. }
  6256. // wrap the element
  6257. var props = {
  6258. width: element.outerWidth(true),
  6259. height: element.outerHeight(true),
  6260. "float": element.css( "float" )
  6261. },
  6262. wrapper = $( "<div></div>" )
  6263. .addClass( "ui-effects-wrapper" )
  6264. .css({
  6265. fontSize: "100%",
  6266. background: "transparent",
  6267. border: "none",
  6268. margin: 0,
  6269. padding: 0
  6270. }),
  6271. // Store the size in case width/height are defined in % - Fixes #5245
  6272. size = {
  6273. width: element.width(),
  6274. height: element.height()
  6275. },
  6276. active = document.activeElement;
  6277. // support: Firefox
  6278. // Firefox incorrectly exposes anonymous content
  6279. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  6280. try {
  6281. active.id;
  6282. } catch( e ) {
  6283. active = document.body;
  6284. }
  6285. element.wrap( wrapper );
  6286. // Fixes #7595 - Elements lose focus when wrapped.
  6287. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  6288. $( active ).focus();
  6289. }
  6290. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  6291. // transfer positioning properties to the wrapper
  6292. if ( element.css( "position" ) === "static" ) {
  6293. wrapper.css({ position: "relative" });
  6294. element.css({ position: "relative" });
  6295. } else {
  6296. $.extend( props, {
  6297. position: element.css( "position" ),
  6298. zIndex: element.css( "z-index" )
  6299. });
  6300. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  6301. props[ pos ] = element.css( pos );
  6302. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  6303. props[ pos ] = "auto";
  6304. }
  6305. });
  6306. element.css({
  6307. position: "relative",
  6308. top: 0,
  6309. left: 0,
  6310. right: "auto",
  6311. bottom: "auto"
  6312. });
  6313. }
  6314. element.css(size);
  6315. return wrapper.css( props ).show();
  6316. },
  6317. removeWrapper: function( element ) {
  6318. var active = document.activeElement;
  6319. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  6320. element.parent().replaceWith( element );
  6321. // Fixes #7595 - Elements lose focus when wrapped.
  6322. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  6323. $( active ).focus();
  6324. }
  6325. }
  6326. return element;
  6327. },
  6328. setTransition: function( element, list, factor, value ) {
  6329. value = value || {};
  6330. $.each( list, function( i, x ) {
  6331. var unit = element.cssUnit( x );
  6332. if ( unit[ 0 ] > 0 ) {
  6333. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  6334. }
  6335. });
  6336. return value;
  6337. }
  6338. });
  6339. // return an effect options object for the given parameters:
  6340. function _normalizeArguments( effect, options, speed, callback ) {
  6341. // allow passing all options as the first parameter
  6342. if ( $.isPlainObject( effect ) ) {
  6343. options = effect;
  6344. effect = effect.effect;
  6345. }
  6346. // convert to an object
  6347. effect = { effect: effect };
  6348. // catch (effect, null, ...)
  6349. if ( options == null ) {
  6350. options = {};
  6351. }
  6352. // catch (effect, callback)
  6353. if ( $.isFunction( options ) ) {
  6354. callback = options;
  6355. speed = null;
  6356. options = {};
  6357. }
  6358. // catch (effect, speed, ?)
  6359. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  6360. callback = speed;
  6361. speed = options;
  6362. options = {};
  6363. }
  6364. // catch (effect, options, callback)
  6365. if ( $.isFunction( speed ) ) {
  6366. callback = speed;
  6367. speed = null;
  6368. }
  6369. // add options to effect
  6370. if ( options ) {
  6371. $.extend( effect, options );
  6372. }
  6373. speed = speed || options.duration;
  6374. effect.duration = $.fx.off ? 0 :
  6375. typeof speed === "number" ? speed :
  6376. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  6377. $.fx.speeds._default;
  6378. effect.complete = callback || options.complete;
  6379. return effect;
  6380. }
  6381. function standardAnimationOption( option ) {
  6382. // Valid standard speeds (nothing, number, named speed)
  6383. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  6384. return true;
  6385. }
  6386. // Invalid strings - treat as "normal" speed
  6387. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  6388. return true;
  6389. }
  6390. // Complete callback
  6391. if ( $.isFunction( option ) ) {
  6392. return true;
  6393. }
  6394. // Options hash (but not naming an effect)
  6395. if ( typeof option === "object" && !option.effect ) {
  6396. return true;
  6397. }
  6398. // Didn't match any standard API
  6399. return false;
  6400. }
  6401. $.fn.extend({
  6402. effect: function( /* effect, options, speed, callback */ ) {
  6403. var args = _normalizeArguments.apply( this, arguments ),
  6404. mode = args.mode,
  6405. queue = args.queue,
  6406. effectMethod = $.effects.effect[ args.effect ];
  6407. if ( $.fx.off || !effectMethod ) {
  6408. // delegate to the original method (e.g., .show()) if possible
  6409. if ( mode ) {
  6410. return this[ mode ]( args.duration, args.complete );
  6411. } else {
  6412. return this.each( function() {
  6413. if ( args.complete ) {
  6414. args.complete.call( this );
  6415. }
  6416. });
  6417. }
  6418. }
  6419. function run( next ) {
  6420. var elem = $( this ),
  6421. complete = args.complete,
  6422. mode = args.mode;
  6423. function done() {
  6424. if ( $.isFunction( complete ) ) {
  6425. complete.call( elem[0] );
  6426. }
  6427. if ( $.isFunction( next ) ) {
  6428. next();
  6429. }
  6430. }
  6431. // If the element already has the correct final state, delegate to
  6432. // the core methods so the internal tracking of "olddisplay" works.
  6433. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  6434. elem[ mode ]();
  6435. done();
  6436. } else {
  6437. effectMethod.call( elem[0], args, done );
  6438. }
  6439. }
  6440. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  6441. },
  6442. show: (function( orig ) {
  6443. return function( option ) {
  6444. if ( standardAnimationOption( option ) ) {
  6445. return orig.apply( this, arguments );
  6446. } else {
  6447. var args = _normalizeArguments.apply( this, arguments );
  6448. args.mode = "show";
  6449. return this.effect.call( this, args );
  6450. }
  6451. };
  6452. })( $.fn.show ),
  6453. hide: (function( orig ) {
  6454. return function( option ) {
  6455. if ( standardAnimationOption( option ) ) {
  6456. return orig.apply( this, arguments );
  6457. } else {
  6458. var args = _normalizeArguments.apply( this, arguments );
  6459. args.mode = "hide";
  6460. return this.effect.call( this, args );
  6461. }
  6462. };
  6463. })( $.fn.hide ),
  6464. toggle: (function( orig ) {
  6465. return function( option ) {
  6466. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  6467. return orig.apply( this, arguments );
  6468. } else {
  6469. var args = _normalizeArguments.apply( this, arguments );
  6470. args.mode = "toggle";
  6471. return this.effect.call( this, args );
  6472. }
  6473. };
  6474. })( $.fn.toggle ),
  6475. // helper functions
  6476. cssUnit: function(key) {
  6477. var style = this.css( key ),
  6478. val = [];
  6479. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  6480. if ( style.indexOf( unit ) > 0 ) {
  6481. val = [ parseFloat( style ), unit ];
  6482. }
  6483. });
  6484. return val;
  6485. }
  6486. });
  6487. })();
  6488. /******************************************************************************/
  6489. /*********************************** EASING ***********************************/
  6490. /******************************************************************************/
  6491. (function() {
  6492. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  6493. var baseEasings = {};
  6494. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  6495. baseEasings[ name ] = function( p ) {
  6496. return Math.pow( p, i + 2 );
  6497. };
  6498. });
  6499. $.extend( baseEasings, {
  6500. Sine: function ( p ) {
  6501. return 1 - Math.cos( p * Math.PI / 2 );
  6502. },
  6503. Circ: function ( p ) {
  6504. return 1 - Math.sqrt( 1 - p * p );
  6505. },
  6506. Elastic: function( p ) {
  6507. return p === 0 || p === 1 ? p :
  6508. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  6509. },
  6510. Back: function( p ) {
  6511. return p * p * ( 3 * p - 2 );
  6512. },
  6513. Bounce: function ( p ) {
  6514. var pow2,
  6515. bounce = 4;
  6516. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  6517. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  6518. }
  6519. });
  6520. $.each( baseEasings, function( name, easeIn ) {
  6521. $.easing[ "easeIn" + name ] = easeIn;
  6522. $.easing[ "easeOut" + name ] = function( p ) {
  6523. return 1 - easeIn( 1 - p );
  6524. };
  6525. $.easing[ "easeInOut" + name ] = function( p ) {
  6526. return p < 0.5 ?
  6527. easeIn( p * 2 ) / 2 :
  6528. 1 - easeIn( p * -2 + 2 ) / 2;
  6529. };
  6530. });
  6531. })();
  6532. })(jQuery);
  6533. (function( $, undefined ) {
  6534. var rvertical = /up|down|vertical/,
  6535. rpositivemotion = /up|left|vertical|horizontal/;
  6536. $.effects.effect.blind = function( o, done ) {
  6537. // Create element
  6538. var el = $( this ),
  6539. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  6540. mode = $.effects.setMode( el, o.mode || "hide" ),
  6541. direction = o.direction || "up",
  6542. vertical = rvertical.test( direction ),
  6543. ref = vertical ? "height" : "width",
  6544. ref2 = vertical ? "top" : "left",
  6545. motion = rpositivemotion.test( direction ),
  6546. animation = {},
  6547. show = mode === "show",
  6548. wrapper, distance, margin;
  6549. // if already wrapped, the wrapper's properties are my property. #6245
  6550. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  6551. $.effects.save( el.parent(), props );
  6552. } else {
  6553. $.effects.save( el, props );
  6554. }
  6555. el.show();
  6556. wrapper = $.effects.createWrapper( el ).css({
  6557. overflow: "hidden"
  6558. });
  6559. distance = wrapper[ ref ]();
  6560. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  6561. animation[ ref ] = show ? distance : 0;
  6562. if ( !motion ) {
  6563. el
  6564. .css( vertical ? "bottom" : "right", 0 )
  6565. .css( vertical ? "top" : "left", "auto" )
  6566. .css({ position: "absolute" });
  6567. animation[ ref2 ] = show ? margin : distance + margin;
  6568. }
  6569. // start at 0 if we are showing
  6570. if ( show ) {
  6571. wrapper.css( ref, 0 );
  6572. if ( ! motion ) {
  6573. wrapper.css( ref2, margin + distance );
  6574. }
  6575. }
  6576. // Animate
  6577. wrapper.animate( animation, {
  6578. duration: o.duration,
  6579. easing: o.easing,
  6580. queue: false,
  6581. complete: function() {
  6582. if ( mode === "hide" ) {
  6583. el.hide();
  6584. }
  6585. $.effects.restore( el, props );
  6586. $.effects.removeWrapper( el );
  6587. done();
  6588. }
  6589. });
  6590. };
  6591. })(jQuery);
  6592. (function( $, undefined ) {
  6593. $.effects.effect.bounce = function( o, done ) {
  6594. var el = $( this ),
  6595. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  6596. // defaults:
  6597. mode = $.effects.setMode( el, o.mode || "effect" ),
  6598. hide = mode === "hide",
  6599. show = mode === "show",
  6600. direction = o.direction || "up",
  6601. distance = o.distance,
  6602. times = o.times || 5,
  6603. // number of internal animations
  6604. anims = times * 2 + ( show || hide ? 1 : 0 ),
  6605. speed = o.duration / anims,
  6606. easing = o.easing,
  6607. // utility:
  6608. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  6609. motion = ( direction === "up" || direction === "left" ),
  6610. i,
  6611. upAnim,
  6612. downAnim,
  6613. // we will need to re-assemble the queue to stack our animations in place
  6614. queue = el.queue(),
  6615. queuelen = queue.length;
  6616. // Avoid touching opacity to prevent clearType and PNG issues in IE
  6617. if ( show || hide ) {
  6618. props.push( "opacity" );
  6619. }
  6620. $.effects.save( el, props );
  6621. el.show();
  6622. $.effects.createWrapper( el ); // Create Wrapper
  6623. // default distance for the BIGGEST bounce is the outer Distance / 3
  6624. if ( !distance ) {
  6625. distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  6626. }
  6627. if ( show ) {
  6628. downAnim = { opacity: 1 };
  6629. downAnim[ ref ] = 0;
  6630. // if we are showing, force opacity 0 and set the initial position
  6631. // then do the "first" animation
  6632. el.css( "opacity", 0 )
  6633. .css( ref, motion ? -distance * 2 : distance * 2 )
  6634. .animate( downAnim, speed, easing );
  6635. }
  6636. // start at the smallest distance if we are hiding
  6637. if ( hide ) {
  6638. distance = distance / Math.pow( 2, times - 1 );
  6639. }
  6640. downAnim = {};
  6641. downAnim[ ref ] = 0;
  6642. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  6643. for ( i = 0; i < times; i++ ) {
  6644. upAnim = {};
  6645. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  6646. el.animate( upAnim, speed, easing )
  6647. .animate( downAnim, speed, easing );
  6648. distance = hide ? distance * 2 : distance / 2;
  6649. }
  6650. // Last Bounce when Hiding
  6651. if ( hide ) {
  6652. upAnim = { opacity: 0 };
  6653. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  6654. el.animate( upAnim, speed, easing );
  6655. }
  6656. el.queue(function() {
  6657. if ( hide ) {
  6658. el.hide();
  6659. }
  6660. $.effects.restore( el, props );
  6661. $.effects.removeWrapper( el );
  6662. done();
  6663. });
  6664. // inject all the animations we just queued to be first in line (after "inprogress")
  6665. if ( queuelen > 1) {
  6666. queue.splice.apply( queue,
  6667. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  6668. }
  6669. el.dequeue();
  6670. };
  6671. })(jQuery);
  6672. (function( $, undefined ) {
  6673. $.effects.effect.clip = function( o, done ) {
  6674. // Create element
  6675. var el = $( this ),
  6676. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  6677. mode = $.effects.setMode( el, o.mode || "hide" ),
  6678. show = mode === "show",
  6679. direction = o.direction || "vertical",
  6680. vert = direction === "vertical",
  6681. size = vert ? "height" : "width",
  6682. position = vert ? "top" : "left",
  6683. animation = {},
  6684. wrapper, animate, distance;
  6685. // Save & Show
  6686. $.effects.save( el, props );
  6687. el.show();
  6688. // Create Wrapper
  6689. wrapper = $.effects.createWrapper( el ).css({
  6690. overflow: "hidden"
  6691. });
  6692. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  6693. distance = animate[ size ]();
  6694. // Shift
  6695. if ( show ) {
  6696. animate.css( size, 0 );
  6697. animate.css( position, distance / 2 );
  6698. }
  6699. // Create Animation Object:
  6700. animation[ size ] = show ? distance : 0;
  6701. animation[ position ] = show ? 0 : distance / 2;
  6702. // Animate
  6703. animate.animate( animation, {
  6704. queue: false,
  6705. duration: o.duration,
  6706. easing: o.easing,
  6707. complete: function() {
  6708. if ( !show ) {
  6709. el.hide();
  6710. }
  6711. $.effects.restore( el, props );
  6712. $.effects.removeWrapper( el );
  6713. done();
  6714. }
  6715. });
  6716. };
  6717. })(jQuery);
  6718. (function( $, undefined ) {
  6719. $.effects.effect.drop = function( o, done ) {
  6720. var el = $( this ),
  6721. props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
  6722. mode = $.effects.setMode( el, o.mode || "hide" ),
  6723. show = mode === "show",
  6724. direction = o.direction || "left",
  6725. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  6726. motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
  6727. animation = {
  6728. opacity: show ? 1 : 0
  6729. },
  6730. distance;
  6731. // Adjust
  6732. $.effects.save( el, props );
  6733. el.show();
  6734. $.effects.createWrapper( el );
  6735. distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]( true ) / 2;
  6736. if ( show ) {
  6737. el
  6738. .css( "opacity", 0 )
  6739. .css( ref, motion === "pos" ? -distance : distance );
  6740. }
  6741. // Animation
  6742. animation[ ref ] = ( show ?
  6743. ( motion === "pos" ? "+=" : "-=" ) :
  6744. ( motion === "pos" ? "-=" : "+=" ) ) +
  6745. distance;
  6746. // Animate
  6747. el.animate( animation, {
  6748. queue: false,
  6749. duration: o.duration,
  6750. easing: o.easing,
  6751. complete: function() {
  6752. if ( mode === "hide" ) {
  6753. el.hide();
  6754. }
  6755. $.effects.restore( el, props );
  6756. $.effects.removeWrapper( el );
  6757. done();
  6758. }
  6759. });
  6760. };
  6761. })(jQuery);
  6762. (function( $, undefined ) {
  6763. $.effects.effect.explode = function( o, done ) {
  6764. var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
  6765. cells = rows,
  6766. el = $( this ),
  6767. mode = $.effects.setMode( el, o.mode || "hide" ),
  6768. show = mode === "show",
  6769. // show and then visibility:hidden the element before calculating offset
  6770. offset = el.show().css( "visibility", "hidden" ).offset(),
  6771. // width and height of a piece
  6772. width = Math.ceil( el.outerWidth() / cells ),
  6773. height = Math.ceil( el.outerHeight() / rows ),
  6774. pieces = [],
  6775. // loop
  6776. i, j, left, top, mx, my;
  6777. // children animate complete:
  6778. function childComplete() {
  6779. pieces.push( this );
  6780. if ( pieces.length === rows * cells ) {
  6781. animComplete();
  6782. }
  6783. }
  6784. // clone the element for each row and cell.
  6785. for( i = 0; i < rows ; i++ ) { // ===>
  6786. top = offset.top + i * height;
  6787. my = i - ( rows - 1 ) / 2 ;
  6788. for( j = 0; j < cells ; j++ ) { // |||
  6789. left = offset.left + j * width;
  6790. mx = j - ( cells - 1 ) / 2 ;
  6791. // Create a clone of the now hidden main element that will be absolute positioned
  6792. // within a wrapper div off the -left and -top equal to size of our pieces
  6793. el
  6794. .clone()
  6795. .appendTo( "body" )
  6796. .wrap( "<div></div>" )
  6797. .css({
  6798. position: "absolute",
  6799. visibility: "visible",
  6800. left: -j * width,
  6801. top: -i * height
  6802. })
  6803. // select the wrapper - make it overflow: hidden and absolute positioned based on
  6804. // where the original was located +left and +top equal to the size of pieces
  6805. .parent()
  6806. .addClass( "ui-effects-explode" )
  6807. .css({
  6808. position: "absolute",
  6809. overflow: "hidden",
  6810. width: width,
  6811. height: height,
  6812. left: left + ( show ? mx * width : 0 ),
  6813. top: top + ( show ? my * height : 0 ),
  6814. opacity: show ? 0 : 1
  6815. }).animate({
  6816. left: left + ( show ? 0 : mx * width ),
  6817. top: top + ( show ? 0 : my * height ),
  6818. opacity: show ? 1 : 0
  6819. }, o.duration || 500, o.easing, childComplete );
  6820. }
  6821. }
  6822. function animComplete() {
  6823. el.css({
  6824. visibility: "visible"
  6825. });
  6826. $( pieces ).remove();
  6827. if ( !show ) {
  6828. el.hide();
  6829. }
  6830. done();
  6831. }
  6832. };
  6833. })(jQuery);
  6834. (function( $, undefined ) {
  6835. $.effects.effect.fade = function( o, done ) {
  6836. var el = $( this ),
  6837. mode = $.effects.setMode( el, o.mode || "toggle" );
  6838. el.animate({
  6839. opacity: mode
  6840. }, {
  6841. queue: false,
  6842. duration: o.duration,
  6843. easing: o.easing,
  6844. complete: done
  6845. });
  6846. };
  6847. })( jQuery );
  6848. (function( $, undefined ) {
  6849. $.effects.effect.fold = function( o, done ) {
  6850. // Create element
  6851. var el = $( this ),
  6852. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  6853. mode = $.effects.setMode( el, o.mode || "hide" ),
  6854. show = mode === "show",
  6855. hide = mode === "hide",
  6856. size = o.size || 15,
  6857. percent = /([0-9]+)%/.exec( size ),
  6858. horizFirst = !!o.horizFirst,
  6859. widthFirst = show !== horizFirst,
  6860. ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
  6861. duration = o.duration / 2,
  6862. wrapper, distance,
  6863. animation1 = {},
  6864. animation2 = {};
  6865. $.effects.save( el, props );
  6866. el.show();
  6867. // Create Wrapper
  6868. wrapper = $.effects.createWrapper( el ).css({
  6869. overflow: "hidden"
  6870. });
  6871. distance = widthFirst ?
  6872. [ wrapper.width(), wrapper.height() ] :
  6873. [ wrapper.height(), wrapper.width() ];
  6874. if ( percent ) {
  6875. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  6876. }
  6877. if ( show ) {
  6878. wrapper.css( horizFirst ? {
  6879. height: 0,
  6880. width: size
  6881. } : {
  6882. height: size,
  6883. width: 0
  6884. });
  6885. }
  6886. // Animation
  6887. animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
  6888. animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
  6889. // Animate
  6890. wrapper
  6891. .animate( animation1, duration, o.easing )
  6892. .animate( animation2, duration, o.easing, function() {
  6893. if ( hide ) {
  6894. el.hide();
  6895. }
  6896. $.effects.restore( el, props );
  6897. $.effects.removeWrapper( el );
  6898. done();
  6899. });
  6900. };
  6901. })(jQuery);
  6902. (function( $, undefined ) {
  6903. $.effects.effect.highlight = function( o, done ) {
  6904. var elem = $( this ),
  6905. props = [ "backgroundImage", "backgroundColor", "opacity" ],
  6906. mode = $.effects.setMode( elem, o.mode || "show" ),
  6907. animation = {
  6908. backgroundColor: elem.css( "backgroundColor" )
  6909. };
  6910. if (mode === "hide") {
  6911. animation.opacity = 0;
  6912. }
  6913. $.effects.save( elem, props );
  6914. elem
  6915. .show()
  6916. .css({
  6917. backgroundImage: "none",
  6918. backgroundColor: o.color || "#ffff99"
  6919. })
  6920. .animate( animation, {
  6921. queue: false,
  6922. duration: o.duration,
  6923. easing: o.easing,
  6924. complete: function() {
  6925. if ( mode === "hide" ) {
  6926. elem.hide();
  6927. }
  6928. $.effects.restore( elem, props );
  6929. done();
  6930. }
  6931. });
  6932. };
  6933. })(jQuery);
  6934. (function( $, undefined ) {
  6935. $.effects.effect.pulsate = function( o, done ) {
  6936. var elem = $( this ),
  6937. mode = $.effects.setMode( elem, o.mode || "show" ),
  6938. show = mode === "show",
  6939. hide = mode === "hide",
  6940. showhide = ( show || mode === "hide" ),
  6941. // showing or hiding leaves of the "last" animation
  6942. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  6943. duration = o.duration / anims,
  6944. animateTo = 0,
  6945. queue = elem.queue(),
  6946. queuelen = queue.length,
  6947. i;
  6948. if ( show || !elem.is(":visible")) {
  6949. elem.css( "opacity", 0 ).show();
  6950. animateTo = 1;
  6951. }
  6952. // anims - 1 opacity "toggles"
  6953. for ( i = 1; i < anims; i++ ) {
  6954. elem.animate({
  6955. opacity: animateTo
  6956. }, duration, o.easing );
  6957. animateTo = 1 - animateTo;
  6958. }
  6959. elem.animate({
  6960. opacity: animateTo
  6961. }, duration, o.easing);
  6962. elem.queue(function() {
  6963. if ( hide ) {
  6964. elem.hide();
  6965. }
  6966. done();
  6967. });
  6968. // We just queued up "anims" animations, we need to put them next in the queue
  6969. if ( queuelen > 1 ) {
  6970. queue.splice.apply( queue,
  6971. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  6972. }
  6973. elem.dequeue();
  6974. };
  6975. })(jQuery);
  6976. (function( $, undefined ) {
  6977. $.effects.effect.puff = function( o, done ) {
  6978. var elem = $( this ),
  6979. mode = $.effects.setMode( elem, o.mode || "hide" ),
  6980. hide = mode === "hide",
  6981. percent = parseInt( o.percent, 10 ) || 150,
  6982. factor = percent / 100,
  6983. original = {
  6984. height: elem.height(),
  6985. width: elem.width(),
  6986. outerHeight: elem.outerHeight(),
  6987. outerWidth: elem.outerWidth()
  6988. };
  6989. $.extend( o, {
  6990. effect: "scale",
  6991. queue: false,
  6992. fade: true,
  6993. mode: mode,
  6994. complete: done,
  6995. percent: hide ? percent : 100,
  6996. from: hide ?
  6997. original :
  6998. {
  6999. height: original.height * factor,
  7000. width: original.width * factor,
  7001. outerHeight: original.outerHeight * factor,
  7002. outerWidth: original.outerWidth * factor
  7003. }
  7004. });
  7005. elem.effect( o );
  7006. };
  7007. $.effects.effect.scale = function( o, done ) {
  7008. // Create element
  7009. var el = $( this ),
  7010. options = $.extend( true, {}, o ),
  7011. mode = $.effects.setMode( el, o.mode || "effect" ),
  7012. percent = parseInt( o.percent, 10 ) ||
  7013. ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
  7014. direction = o.direction || "both",
  7015. origin = o.origin,
  7016. original = {
  7017. height: el.height(),
  7018. width: el.width(),
  7019. outerHeight: el.outerHeight(),
  7020. outerWidth: el.outerWidth()
  7021. },
  7022. factor = {
  7023. y: direction !== "horizontal" ? (percent / 100) : 1,
  7024. x: direction !== "vertical" ? (percent / 100) : 1
  7025. };
  7026. // We are going to pass this effect to the size effect:
  7027. options.effect = "size";
  7028. options.queue = false;
  7029. options.complete = done;
  7030. // Set default origin and restore for show/hide
  7031. if ( mode !== "effect" ) {
  7032. options.origin = origin || ["middle","center"];
  7033. options.restore = true;
  7034. }
  7035. options.from = o.from || ( mode === "show" ? {
  7036. height: 0,
  7037. width: 0,
  7038. outerHeight: 0,
  7039. outerWidth: 0
  7040. } : original );
  7041. options.to = {
  7042. height: original.height * factor.y,
  7043. width: original.width * factor.x,
  7044. outerHeight: original.outerHeight * factor.y,
  7045. outerWidth: original.outerWidth * factor.x
  7046. };
  7047. // Fade option to support puff
  7048. if ( options.fade ) {
  7049. if ( mode === "show" ) {
  7050. options.from.opacity = 0;
  7051. options.to.opacity = 1;
  7052. }
  7053. if ( mode === "hide" ) {
  7054. options.from.opacity = 1;
  7055. options.to.opacity = 0;
  7056. }
  7057. }
  7058. // Animate
  7059. el.effect( options );
  7060. };
  7061. $.effects.effect.size = function( o, done ) {
  7062. // Create element
  7063. var original, baseline, factor,
  7064. el = $( this ),
  7065. props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
  7066. // Always restore
  7067. props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
  7068. // Copy for children
  7069. props2 = [ "width", "height", "overflow" ],
  7070. cProps = [ "fontSize" ],
  7071. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  7072. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  7073. // Set options
  7074. mode = $.effects.setMode( el, o.mode || "effect" ),
  7075. restore = o.restore || mode !== "effect",
  7076. scale = o.scale || "both",
  7077. origin = o.origin || [ "middle", "center" ],
  7078. position = el.css( "position" ),
  7079. props = restore ? props0 : props1,
  7080. zero = {
  7081. height: 0,
  7082. width: 0,
  7083. outerHeight: 0,
  7084. outerWidth: 0
  7085. };
  7086. if ( mode === "show" ) {
  7087. el.show();
  7088. }
  7089. original = {
  7090. height: el.height(),
  7091. width: el.width(),
  7092. outerHeight: el.outerHeight(),
  7093. outerWidth: el.outerWidth()
  7094. };
  7095. if ( o.mode === "toggle" && mode === "show" ) {
  7096. el.from = o.to || zero;
  7097. el.to = o.from || original;
  7098. } else {
  7099. el.from = o.from || ( mode === "show" ? zero : original );
  7100. el.to = o.to || ( mode === "hide" ? zero : original );
  7101. }
  7102. // Set scaling factor
  7103. factor = {
  7104. from: {
  7105. y: el.from.height / original.height,
  7106. x: el.from.width / original.width
  7107. },
  7108. to: {
  7109. y: el.to.height / original.height,
  7110. x: el.to.width / original.width
  7111. }
  7112. };
  7113. // Scale the css box
  7114. if ( scale === "box" || scale === "both" ) {
  7115. // Vertical props scaling
  7116. if ( factor.from.y !== factor.to.y ) {
  7117. props = props.concat( vProps );
  7118. el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
  7119. el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
  7120. }
  7121. // Horizontal props scaling
  7122. if ( factor.from.x !== factor.to.x ) {
  7123. props = props.concat( hProps );
  7124. el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
  7125. el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
  7126. }
  7127. }
  7128. // Scale the content
  7129. if ( scale === "content" || scale === "both" ) {
  7130. // Vertical props scaling
  7131. if ( factor.from.y !== factor.to.y ) {
  7132. props = props.concat( cProps ).concat( props2 );
  7133. el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
  7134. el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
  7135. }
  7136. }
  7137. $.effects.save( el, props );
  7138. el.show();
  7139. $.effects.createWrapper( el );
  7140. el.css( "overflow", "hidden" ).css( el.from );
  7141. // Adjust
  7142. if (origin) { // Calculate baseline shifts
  7143. baseline = $.effects.getBaseline( origin, original );
  7144. el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
  7145. el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
  7146. el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
  7147. el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
  7148. }
  7149. el.css( el.from ); // set top & left
  7150. // Animate
  7151. if ( scale === "content" || scale === "both" ) { // Scale the children
  7152. // Add margins/font-size
  7153. vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
  7154. hProps = hProps.concat([ "marginLeft", "marginRight" ]);
  7155. props2 = props0.concat(vProps).concat(hProps);
  7156. el.find( "*[width]" ).each( function(){
  7157. var child = $( this ),
  7158. c_original = {
  7159. height: child.height(),
  7160. width: child.width(),
  7161. outerHeight: child.outerHeight(),
  7162. outerWidth: child.outerWidth()
  7163. };
  7164. if (restore) {
  7165. $.effects.save(child, props2);
  7166. }
  7167. child.from = {
  7168. height: c_original.height * factor.from.y,
  7169. width: c_original.width * factor.from.x,
  7170. outerHeight: c_original.outerHeight * factor.from.y,
  7171. outerWidth: c_original.outerWidth * factor.from.x
  7172. };
  7173. child.to = {
  7174. height: c_original.height * factor.to.y,
  7175. width: c_original.width * factor.to.x,
  7176. outerHeight: c_original.height * factor.to.y,
  7177. outerWidth: c_original.width * factor.to.x
  7178. };
  7179. // Vertical props scaling
  7180. if ( factor.from.y !== factor.to.y ) {
  7181. child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
  7182. child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
  7183. }
  7184. // Horizontal props scaling
  7185. if ( factor.from.x !== factor.to.x ) {
  7186. child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
  7187. child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
  7188. }
  7189. // Animate children
  7190. child.css( child.from );
  7191. child.animate( child.to, o.duration, o.easing, function() {
  7192. // Restore children
  7193. if ( restore ) {
  7194. $.effects.restore( child, props2 );
  7195. }
  7196. });
  7197. });
  7198. }
  7199. // Animate
  7200. el.animate( el.to, {
  7201. queue: false,
  7202. duration: o.duration,
  7203. easing: o.easing,
  7204. complete: function() {
  7205. if ( el.to.opacity === 0 ) {
  7206. el.css( "opacity", el.from.opacity );
  7207. }
  7208. if( mode === "hide" ) {
  7209. el.hide();
  7210. }
  7211. $.effects.restore( el, props );
  7212. if ( !restore ) {
  7213. // we need to calculate our new positioning based on the scaling
  7214. if ( position === "static" ) {
  7215. el.css({
  7216. position: "relative",
  7217. top: el.to.top,
  7218. left: el.to.left
  7219. });
  7220. } else {
  7221. $.each([ "top", "left" ], function( idx, pos ) {
  7222. el.css( pos, function( _, str ) {
  7223. var val = parseInt( str, 10 ),
  7224. toRef = idx ? el.to.left : el.to.top;
  7225. // if original was "auto", recalculate the new value from wrapper
  7226. if ( str === "auto" ) {
  7227. return toRef + "px";
  7228. }
  7229. return val + toRef + "px";
  7230. });
  7231. });
  7232. }
  7233. }
  7234. $.effects.removeWrapper( el );
  7235. done();
  7236. }
  7237. });
  7238. };
  7239. })(jQuery);
  7240. (function( $, undefined ) {
  7241. $.effects.effect.shake = function( o, done ) {
  7242. var el = $( this ),
  7243. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  7244. mode = $.effects.setMode( el, o.mode || "effect" ),
  7245. direction = o.direction || "left",
  7246. distance = o.distance || 20,
  7247. times = o.times || 3,
  7248. anims = times * 2 + 1,
  7249. speed = Math.round(o.duration/anims),
  7250. ref = (direction === "up" || direction === "down") ? "top" : "left",
  7251. positiveMotion = (direction === "up" || direction === "left"),
  7252. animation = {},
  7253. animation1 = {},
  7254. animation2 = {},
  7255. i,
  7256. // we will need to re-assemble the queue to stack our animations in place
  7257. queue = el.queue(),
  7258. queuelen = queue.length;
  7259. $.effects.save( el, props );
  7260. el.show();
  7261. $.effects.createWrapper( el );
  7262. // Animation
  7263. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  7264. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  7265. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  7266. // Animate
  7267. el.animate( animation, speed, o.easing );
  7268. // Shakes
  7269. for ( i = 1; i < times; i++ ) {
  7270. el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
  7271. }
  7272. el
  7273. .animate( animation1, speed, o.easing )
  7274. .animate( animation, speed / 2, o.easing )
  7275. .queue(function() {
  7276. if ( mode === "hide" ) {
  7277. el.hide();
  7278. }
  7279. $.effects.restore( el, props );
  7280. $.effects.removeWrapper( el );
  7281. done();
  7282. });
  7283. // inject all the animations we just queued to be first in line (after "inprogress")
  7284. if ( queuelen > 1) {
  7285. queue.splice.apply( queue,
  7286. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  7287. }
  7288. el.dequeue();
  7289. };
  7290. })(jQuery);
  7291. (function( $, undefined ) {
  7292. $.effects.effect.slide = function( o, done ) {
  7293. // Create element
  7294. var el = $( this ),
  7295. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  7296. mode = $.effects.setMode( el, o.mode || "show" ),
  7297. show = mode === "show",
  7298. direction = o.direction || "left",
  7299. ref = (direction === "up" || direction === "down") ? "top" : "left",
  7300. positiveMotion = (direction === "up" || direction === "left"),
  7301. distance,
  7302. animation = {};
  7303. // Adjust
  7304. $.effects.save( el, props );
  7305. el.show();
  7306. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  7307. $.effects.createWrapper( el ).css({
  7308. overflow: "hidden"
  7309. });
  7310. if ( show ) {
  7311. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  7312. }
  7313. // Animation
  7314. animation[ ref ] = ( show ?
  7315. ( positiveMotion ? "+=" : "-=") :
  7316. ( positiveMotion ? "-=" : "+=")) +
  7317. distance;
  7318. // Animate
  7319. el.animate( animation, {
  7320. queue: false,
  7321. duration: o.duration,
  7322. easing: o.easing,
  7323. complete: function() {
  7324. if ( mode === "hide" ) {
  7325. el.hide();
  7326. }
  7327. $.effects.restore( el, props );
  7328. $.effects.removeWrapper( el );
  7329. done();
  7330. }
  7331. });
  7332. };
  7333. })(jQuery);
  7334. (function( $, undefined ) {
  7335. $.effects.effect.transfer = function( o, done ) {
  7336. var elem = $( this ),
  7337. target = $( o.to ),
  7338. targetFixed = target.css( "position" ) === "fixed",
  7339. body = $("body"),
  7340. fixTop = targetFixed ? body.scrollTop() : 0,
  7341. fixLeft = targetFixed ? body.scrollLeft() : 0,
  7342. endPosition = target.offset(),
  7343. animation = {
  7344. top: endPosition.top - fixTop ,
  7345. left: endPosition.left - fixLeft ,
  7346. height: target.innerHeight(),
  7347. width: target.innerWidth()
  7348. },
  7349. startPosition = elem.offset(),
  7350. transfer = $( "<div class='ui-effects-transfer'></div>" )
  7351. .appendTo( document.body )
  7352. .addClass( o.className )
  7353. .css({
  7354. top: startPosition.top - fixTop ,
  7355. left: startPosition.left - fixLeft ,
  7356. height: elem.innerHeight(),
  7357. width: elem.innerWidth(),
  7358. position: targetFixed ? "fixed" : "absolute"
  7359. })
  7360. .animate( animation, o.duration, o.easing, function() {
  7361. transfer.remove();
  7362. done();
  7363. });
  7364. };
  7365. })(jQuery);