sonata_jqueryui_js.js 201 KB

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