jquery.ui.custom.js 200 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161
  1. /*!
  2. * jQuery UI 1.8.21
  3. *
  4. * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
  5. * Dual licensed under the MIT or GPL Version 2 licenses.
  6. * http://jquery.org/license
  7. *
  8. * http://docs.jquery.com/UI
  9. */
  10. (function( $, undefined ) {
  11. // prevent duplicate loading
  12. // this is only a problem because we proxy existing functions
  13. // and we don't want to double proxy them
  14. $.ui = $.ui || {};
  15. if ( $.ui.version ) {
  16. return;
  17. }
  18. $.extend( $.ui, {
  19. version: "1.8.21",
  20. keyCode: {
  21. ALT: 18,
  22. BACKSPACE: 8,
  23. CAPS_LOCK: 20,
  24. COMMA: 188,
  25. COMMAND: 91,
  26. COMMAND_LEFT: 91, // COMMAND
  27. COMMAND_RIGHT: 93,
  28. CONTROL: 17,
  29. DELETE: 46,
  30. DOWN: 40,
  31. END: 35,
  32. ENTER: 13,
  33. ESCAPE: 27,
  34. HOME: 36,
  35. INSERT: 45,
  36. LEFT: 37,
  37. MENU: 93, // COMMAND_RIGHT
  38. NUMPAD_ADD: 107,
  39. NUMPAD_DECIMAL: 110,
  40. NUMPAD_DIVIDE: 111,
  41. NUMPAD_ENTER: 108,
  42. NUMPAD_MULTIPLY: 106,
  43. NUMPAD_SUBTRACT: 109,
  44. PAGE_DOWN: 34,
  45. PAGE_UP: 33,
  46. PERIOD: 190,
  47. RIGHT: 39,
  48. SHIFT: 16,
  49. SPACE: 32,
  50. TAB: 9,
  51. UP: 38,
  52. WINDOWS: 91 // COMMAND
  53. }
  54. });
  55. // plugins
  56. $.fn.extend({
  57. propAttr: $.fn.prop || $.fn.attr,
  58. _focus: $.fn.focus,
  59. focus: function( delay, fn ) {
  60. return typeof delay === "number" ?
  61. this.each(function() {
  62. var elem = this;
  63. setTimeout(function() {
  64. $( elem ).focus();
  65. if ( fn ) {
  66. fn.call( elem );
  67. }
  68. }, delay );
  69. }) :
  70. this._focus.apply( this, arguments );
  71. },
  72. scrollParent: function() {
  73. var scrollParent;
  74. if (($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
  75. scrollParent = this.parents().filter(function() {
  76. return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
  77. }).eq(0);
  78. } else {
  79. scrollParent = this.parents().filter(function() {
  80. return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
  81. }).eq(0);
  82. }
  83. return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
  84. },
  85. zIndex: function( zIndex ) {
  86. if ( zIndex !== undefined ) {
  87. return this.css( "zIndex", zIndex );
  88. }
  89. if ( this.length ) {
  90. var elem = $( this[ 0 ] ), position, value;
  91. while ( elem.length && elem[ 0 ] !== document ) {
  92. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  93. // This makes behavior of this function consistent across browsers
  94. // WebKit always returns auto if the element is positioned
  95. position = elem.css( "position" );
  96. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  97. // IE returns 0 when zIndex is not specified
  98. // other browsers return a string
  99. // we ignore the case of nested elements with an explicit value of 0
  100. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  101. value = parseInt( elem.css( "zIndex" ), 10 );
  102. if ( !isNaN( value ) && value !== 0 ) {
  103. return value;
  104. }
  105. }
  106. elem = elem.parent();
  107. }
  108. }
  109. return 0;
  110. },
  111. disableSelection: function() {
  112. return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
  113. ".ui-disableSelection", function( event ) {
  114. event.preventDefault();
  115. });
  116. },
  117. enableSelection: function() {
  118. return this.unbind( ".ui-disableSelection" );
  119. }
  120. });
  121. $.each( [ "Width", "Height" ], function( i, name ) {
  122. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  123. type = name.toLowerCase(),
  124. orig = {
  125. innerWidth: $.fn.innerWidth,
  126. innerHeight: $.fn.innerHeight,
  127. outerWidth: $.fn.outerWidth,
  128. outerHeight: $.fn.outerHeight
  129. };
  130. function reduce( elem, size, border, margin ) {
  131. $.each( side, function() {
  132. size -= parseFloat( $.curCSS( elem, "padding" + this, true) ) || 0;
  133. if ( border ) {
  134. size -= parseFloat( $.curCSS( elem, "border" + this + "Width", true) ) || 0;
  135. }
  136. if ( margin ) {
  137. size -= parseFloat( $.curCSS( elem, "margin" + this, true) ) || 0;
  138. }
  139. });
  140. return size;
  141. }
  142. $.fn[ "inner" + name ] = function( size ) {
  143. if ( size === undefined ) {
  144. return orig[ "inner" + name ].call( this );
  145. }
  146. return this.each(function() {
  147. $( this ).css( type, reduce( this, size ) + "px" );
  148. });
  149. };
  150. $.fn[ "outer" + name] = function( size, margin ) {
  151. if ( typeof size !== "number" ) {
  152. return orig[ "outer" + name ].call( this, size );
  153. }
  154. return this.each(function() {
  155. $( this).css( type, reduce( this, size, true, margin ) + "px" );
  156. });
  157. };
  158. });
  159. // selectors
  160. function focusable( element, isTabIndexNotNaN ) {
  161. var nodeName = element.nodeName.toLowerCase();
  162. if ( "area" === nodeName ) {
  163. var map = element.parentNode,
  164. mapName = map.name,
  165. img;
  166. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  167. return false;
  168. }
  169. img = $( "img[usemap=#" + mapName + "]" )[0];
  170. return !!img && visible( img );
  171. }
  172. return ( /input|select|textarea|button|object/.test( nodeName )
  173. ? !element.disabled
  174. : "a" == nodeName
  175. ? element.href || isTabIndexNotNaN
  176. : isTabIndexNotNaN)
  177. // the element and all of its ancestors must be visible
  178. && visible( element );
  179. }
  180. function visible( element ) {
  181. return !$( element ).parents().andSelf().filter(function() {
  182. return $.curCSS( this, "visibility" ) === "hidden" ||
  183. $.expr.filters.hidden( this );
  184. }).length;
  185. }
  186. $.extend( $.expr[ ":" ], {
  187. data: function( elem, i, match ) {
  188. return !!$.data( elem, match[ 3 ] );
  189. },
  190. focusable: function( element ) {
  191. return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
  192. },
  193. tabbable: function( element ) {
  194. var tabIndex = $.attr( element, "tabindex" ),
  195. isTabIndexNaN = isNaN( tabIndex );
  196. return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
  197. }
  198. });
  199. // support
  200. $(function() {
  201. var body = document.body,
  202. div = body.appendChild( div = document.createElement( "div" ) );
  203. // access offsetHeight before setting the style to prevent a layout bug
  204. // in IE 9 which causes the elemnt to continue to take up space even
  205. // after it is removed from the DOM (#8026)
  206. div.offsetHeight;
  207. $.extend( div.style, {
  208. minHeight: "100px",
  209. height: "auto",
  210. padding: 0,
  211. borderWidth: 0
  212. });
  213. $.support.minHeight = div.offsetHeight === 100;
  214. $.support.selectstart = "onselectstart" in div;
  215. // set display to none to avoid a layout bug in IE
  216. // http://dev.jquery.com/ticket/4014
  217. body.removeChild( div ).style.display = "none";
  218. });
  219. // deprecated
  220. $.extend( $.ui, {
  221. // $.ui.plugin is deprecated. Use the proxy pattern instead.
  222. plugin: {
  223. add: function( module, option, set ) {
  224. var proto = $.ui[ module ].prototype;
  225. for ( var i in set ) {
  226. proto.plugins[ i ] = proto.plugins[ i ] || [];
  227. proto.plugins[ i ].push( [ option, set[ i ] ] );
  228. }
  229. },
  230. call: function( instance, name, args ) {
  231. var set = instance.plugins[ name ];
  232. if ( !set || !instance.element[ 0 ].parentNode ) {
  233. return;
  234. }
  235. for ( var i = 0; i < set.length; i++ ) {
  236. if ( instance.options[ set[ i ][ 0 ] ] ) {
  237. set[ i ][ 1 ].apply( instance.element, args );
  238. }
  239. }
  240. }
  241. },
  242. // will be deprecated when we switch to jQuery 1.4 - use jQuery.contains()
  243. contains: function( a, b ) {
  244. return document.compareDocumentPosition ?
  245. a.compareDocumentPosition( b ) & 16 :
  246. a !== b && a.contains( b );
  247. },
  248. // only used by resizable
  249. hasScroll: function( el, a ) {
  250. //If overflow is hidden, the element might have extra content, but the user wants to hide it
  251. if ( $( el ).css( "overflow" ) === "hidden") {
  252. return false;
  253. }
  254. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  255. has = false;
  256. if ( el[ scroll ] > 0 ) {
  257. return true;
  258. }
  259. // TODO: determine which cases actually cause this to happen
  260. // if the element doesn't have the scroll set, see if it's possible to
  261. // set the scroll
  262. el[ scroll ] = 1;
  263. has = ( el[ scroll ] > 0 );
  264. el[ scroll ] = 0;
  265. return has;
  266. },
  267. // these are odd functions, fix the API or move into individual plugins
  268. isOverAxis: function( x, reference, size ) {
  269. //Determines when x coordinate is over "b" element axis
  270. return ( x > reference ) && ( x < ( reference + size ) );
  271. },
  272. isOver: function( y, x, top, left, height, width ) {
  273. //Determines when x, y coordinates is over "b" element
  274. return $.ui.isOverAxis( y, top, height ) && $.ui.isOverAxis( x, left, width );
  275. }
  276. });
  277. })( jQuery );
  278. /*!
  279. * jQuery UI Widget 1.8.21
  280. *
  281. * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
  282. * Dual licensed under the MIT or GPL Version 2 licenses.
  283. * http://jquery.org/license
  284. *
  285. * http://docs.jquery.com/UI/Widget
  286. */
  287. (function( $, undefined ) {
  288. // jQuery 1.4+
  289. if ( $.cleanData ) {
  290. var _cleanData = $.cleanData;
  291. $.cleanData = function( elems ) {
  292. for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
  293. try {
  294. $( elem ).triggerHandler( "remove" );
  295. // http://bugs.jquery.com/ticket/8235
  296. } catch( e ) {}
  297. }
  298. _cleanData( elems );
  299. };
  300. } else {
  301. var _remove = $.fn.remove;
  302. $.fn.remove = function( selector, keepData ) {
  303. return this.each(function() {
  304. if ( !keepData ) {
  305. if ( !selector || $.filter( selector, [ this ] ).length ) {
  306. $( "*", this ).add( [ this ] ).each(function() {
  307. try {
  308. $( this ).triggerHandler( "remove" );
  309. // http://bugs.jquery.com/ticket/8235
  310. } catch( e ) {}
  311. });
  312. }
  313. }
  314. return _remove.call( $(this), selector, keepData );
  315. });
  316. };
  317. }
  318. $.widget = function( name, base, prototype ) {
  319. var namespace = name.split( "." )[ 0 ],
  320. fullName;
  321. name = name.split( "." )[ 1 ];
  322. fullName = namespace + "-" + name;
  323. if ( !prototype ) {
  324. prototype = base;
  325. base = $.Widget;
  326. }
  327. // create selector for plugin
  328. $.expr[ ":" ][ fullName ] = function( elem ) {
  329. return !!$.data( elem, name );
  330. };
  331. $[ namespace ] = $[ namespace ] || {};
  332. $[ namespace ][ name ] = function( options, element ) {
  333. // allow instantiation without initializing for simple inheritance
  334. if ( arguments.length ) {
  335. this._createWidget( options, element );
  336. }
  337. };
  338. var basePrototype = new base();
  339. // we need to make the options hash a property directly on the new instance
  340. // otherwise we'll modify the options hash on the prototype that we're
  341. // inheriting from
  342. // $.each( basePrototype, function( key, val ) {
  343. // if ( $.isPlainObject(val) ) {
  344. // basePrototype[ key ] = $.extend( {}, val );
  345. // }
  346. // });
  347. basePrototype.options = $.extend( true, {}, basePrototype.options );
  348. $[ namespace ][ name ].prototype = $.extend( true, basePrototype, {
  349. namespace: namespace,
  350. widgetName: name,
  351. widgetEventPrefix: $[ namespace ][ name ].prototype.widgetEventPrefix || name,
  352. widgetBaseClass: fullName
  353. }, prototype );
  354. $.widget.bridge( name, $[ namespace ][ name ] );
  355. };
  356. $.widget.bridge = function( name, object ) {
  357. $.fn[ name ] = function( options ) {
  358. var isMethodCall = typeof options === "string",
  359. args = Array.prototype.slice.call( arguments, 1 ),
  360. returnValue = this;
  361. // allow multiple hashes to be passed on init
  362. options = !isMethodCall && args.length ?
  363. $.extend.apply( null, [ true, options ].concat(args) ) :
  364. options;
  365. // prevent calls to internal methods
  366. if ( isMethodCall && options.charAt( 0 ) === "_" ) {
  367. return returnValue;
  368. }
  369. if ( isMethodCall ) {
  370. this.each(function() {
  371. var instance = $.data( this, name ),
  372. methodValue = instance && $.isFunction( instance[options] ) ?
  373. instance[ options ].apply( instance, args ) :
  374. instance;
  375. // TODO: add this back in 1.9 and use $.error() (see #5972)
  376. // if ( !instance ) {
  377. // throw "cannot call methods on " + name + " prior to initialization; " +
  378. // "attempted to call method '" + options + "'";
  379. // }
  380. // if ( !$.isFunction( instance[options] ) ) {
  381. // throw "no such method '" + options + "' for " + name + " widget instance";
  382. // }
  383. // var methodValue = instance[ options ].apply( instance, args );
  384. if ( methodValue !== instance && methodValue !== undefined ) {
  385. returnValue = methodValue;
  386. return false;
  387. }
  388. });
  389. } else {
  390. this.each(function() {
  391. var instance = $.data( this, name );
  392. if ( instance ) {
  393. instance.option( options || {} )._init();
  394. } else {
  395. $.data( this, name, new object( options, this ) );
  396. }
  397. });
  398. }
  399. return returnValue;
  400. };
  401. };
  402. $.Widget = function( options, element ) {
  403. // allow instantiation without initializing for simple inheritance
  404. if ( arguments.length ) {
  405. this._createWidget( options, element );
  406. }
  407. };
  408. $.Widget.prototype = {
  409. widgetName: "widget",
  410. widgetEventPrefix: "",
  411. options: {
  412. disabled: false
  413. },
  414. _createWidget: function( options, element ) {
  415. // $.widget.bridge stores the plugin instance, but we do it anyway
  416. // so that it's stored even before the _create function runs
  417. $.data( element, this.widgetName, this );
  418. this.element = $( element );
  419. this.options = $.extend( true, {},
  420. this.options,
  421. this._getCreateOptions(),
  422. options );
  423. var self = this;
  424. this.element.bind( "remove." + this.widgetName, function() {
  425. self.destroy();
  426. });
  427. this._create();
  428. this._trigger( "create" );
  429. this._init();
  430. },
  431. _getCreateOptions: function() {
  432. return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ];
  433. },
  434. _create: function() {},
  435. _init: function() {},
  436. destroy: function() {
  437. this.element
  438. .unbind( "." + this.widgetName )
  439. .removeData( this.widgetName );
  440. this.widget()
  441. .unbind( "." + this.widgetName )
  442. .removeAttr( "aria-disabled" )
  443. .removeClass(
  444. this.widgetBaseClass + "-disabled " +
  445. "ui-state-disabled" );
  446. },
  447. widget: function() {
  448. return this.element;
  449. },
  450. option: function( key, value ) {
  451. var options = key;
  452. if ( arguments.length === 0 ) {
  453. // don't return a reference to the internal hash
  454. return $.extend( {}, this.options );
  455. }
  456. if (typeof key === "string" ) {
  457. if ( value === undefined ) {
  458. return this.options[ key ];
  459. }
  460. options = {};
  461. options[ key ] = value;
  462. }
  463. this._setOptions( options );
  464. return this;
  465. },
  466. _setOptions: function( options ) {
  467. var self = this;
  468. $.each( options, function( key, value ) {
  469. self._setOption( key, value );
  470. });
  471. return this;
  472. },
  473. _setOption: function( key, value ) {
  474. this.options[ key ] = value;
  475. if ( key === "disabled" ) {
  476. this.widget()
  477. [ value ? "addClass" : "removeClass"](
  478. this.widgetBaseClass + "-disabled" + " " +
  479. "ui-state-disabled" )
  480. .attr( "aria-disabled", value );
  481. }
  482. return this;
  483. },
  484. enable: function() {
  485. return this._setOption( "disabled", false );
  486. },
  487. disable: function() {
  488. return this._setOption( "disabled", true );
  489. },
  490. _trigger: function( type, event, data ) {
  491. var prop, orig,
  492. callback = this.options[ type ];
  493. data = data || {};
  494. event = $.Event( event );
  495. event.type = ( type === this.widgetEventPrefix ?
  496. type :
  497. this.widgetEventPrefix + type ).toLowerCase();
  498. // the original event may come from any element
  499. // so we need to reset the target on the new event
  500. event.target = this.element[ 0 ];
  501. // copy original event properties over to the new event
  502. orig = event.originalEvent;
  503. if ( orig ) {
  504. for ( prop in orig ) {
  505. if ( !( prop in event ) ) {
  506. event[ prop ] = orig[ prop ];
  507. }
  508. }
  509. }
  510. this.element.trigger( event, data );
  511. return !( $.isFunction(callback) &&
  512. callback.call( this.element[0], event, data ) === false ||
  513. event.isDefaultPrevented() );
  514. }
  515. };
  516. })( jQuery );
  517. /*!
  518. * jQuery UI Mouse 1.8.21
  519. *
  520. * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
  521. * Dual licensed under the MIT or GPL Version 2 licenses.
  522. * http://jquery.org/license
  523. *
  524. * http://docs.jquery.com/UI/Mouse
  525. *
  526. * Depends:
  527. * jquery.ui.widget.js
  528. */
  529. (function( $, undefined ) {
  530. var mouseHandled = false;
  531. $( document ).mouseup( function( e ) {
  532. mouseHandled = false;
  533. });
  534. $.widget("ui.mouse", {
  535. options: {
  536. cancel: ':input,option',
  537. distance: 1,
  538. delay: 0
  539. },
  540. _mouseInit: function() {
  541. var self = this;
  542. this.element
  543. .bind('mousedown.'+this.widgetName, function(event) {
  544. return self._mouseDown(event);
  545. })
  546. .bind('click.'+this.widgetName, function(event) {
  547. if (true === $.data(event.target, self.widgetName + '.preventClickEvent')) {
  548. $.removeData(event.target, self.widgetName + '.preventClickEvent');
  549. event.stopImmediatePropagation();
  550. return false;
  551. }
  552. });
  553. this.started = false;
  554. },
  555. // TODO: make sure destroying one instance of mouse doesn't mess with
  556. // other instances of mouse
  557. _mouseDestroy: function() {
  558. this.element.unbind('.'+this.widgetName);
  559. $(document)
  560. .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
  561. .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
  562. },
  563. _mouseDown: function(event) {
  564. // don't let more than one widget handle mouseStart
  565. if( mouseHandled ) { return };
  566. // we may have missed mouseup (out of window)
  567. (this._mouseStarted && this._mouseUp(event));
  568. this._mouseDownEvent = event;
  569. var self = this,
  570. btnIsLeft = (event.which == 1),
  571. // event.target.nodeName works around a bug in IE 8 with
  572. // disabled inputs (#7620)
  573. elIsCancel = (typeof this.options.cancel == "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
  574. if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
  575. return true;
  576. }
  577. this.mouseDelayMet = !this.options.delay;
  578. if (!this.mouseDelayMet) {
  579. this._mouseDelayTimer = setTimeout(function() {
  580. self.mouseDelayMet = true;
  581. }, this.options.delay);
  582. }
  583. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  584. this._mouseStarted = (this._mouseStart(event) !== false);
  585. if (!this._mouseStarted) {
  586. event.preventDefault();
  587. return true;
  588. }
  589. }
  590. // Click event may never have fired (Gecko & Opera)
  591. if (true === $.data(event.target, this.widgetName + '.preventClickEvent')) {
  592. $.removeData(event.target, this.widgetName + '.preventClickEvent');
  593. }
  594. // these delegates are required to keep context
  595. this._mouseMoveDelegate = function(event) {
  596. return self._mouseMove(event);
  597. };
  598. this._mouseUpDelegate = function(event) {
  599. return self._mouseUp(event);
  600. };
  601. $(document)
  602. .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
  603. .bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
  604. event.preventDefault();
  605. mouseHandled = true;
  606. return true;
  607. },
  608. _mouseMove: function(event) {
  609. // IE mouseup check - mouseup happened when mouse was out of window
  610. if ($.browser.msie && !(document.documentMode >= 9) && !event.button) {
  611. return this._mouseUp(event);
  612. }
  613. if (this._mouseStarted) {
  614. this._mouseDrag(event);
  615. return event.preventDefault();
  616. }
  617. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  618. this._mouseStarted =
  619. (this._mouseStart(this._mouseDownEvent, event) !== false);
  620. (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
  621. }
  622. return !this._mouseStarted;
  623. },
  624. _mouseUp: function(event) {
  625. $(document)
  626. .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
  627. .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
  628. if (this._mouseStarted) {
  629. this._mouseStarted = false;
  630. if (event.target == this._mouseDownEvent.target) {
  631. $.data(event.target, this.widgetName + '.preventClickEvent', true);
  632. }
  633. this._mouseStop(event);
  634. }
  635. return false;
  636. },
  637. _mouseDistanceMet: function(event) {
  638. return (Math.max(
  639. Math.abs(this._mouseDownEvent.pageX - event.pageX),
  640. Math.abs(this._mouseDownEvent.pageY - event.pageY)
  641. ) >= this.options.distance
  642. );
  643. },
  644. _mouseDelayMet: function(event) {
  645. return this.mouseDelayMet;
  646. },
  647. // These are placeholder methods, to be overriden by extending plugin
  648. _mouseStart: function(event) {},
  649. _mouseDrag: function(event) {},
  650. _mouseStop: function(event) {},
  651. _mouseCapture: function(event) { return true; }
  652. });
  653. })(jQuery);
  654. /*!
  655. * jQuery UI Position 1.8.21
  656. *
  657. * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
  658. * Dual licensed under the MIT or GPL Version 2 licenses.
  659. * http://jquery.org/license
  660. *
  661. * http://docs.jquery.com/UI/Position
  662. */
  663. (function( $, undefined ) {
  664. $.ui = $.ui || {};
  665. var horizontalPositions = /left|center|right/,
  666. verticalPositions = /top|center|bottom/,
  667. center = "center",
  668. support = {},
  669. _position = $.fn.position,
  670. _offset = $.fn.offset;
  671. $.fn.position = function( options ) {
  672. if ( !options || !options.of ) {
  673. return _position.apply( this, arguments );
  674. }
  675. // make a copy, we don't want to modify arguments
  676. options = $.extend( {}, options );
  677. var target = $( options.of ),
  678. targetElem = target[0],
  679. collision = ( options.collision || "flip" ).split( " " ),
  680. offset = options.offset ? options.offset.split( " " ) : [ 0, 0 ],
  681. targetWidth,
  682. targetHeight,
  683. basePosition;
  684. if ( targetElem.nodeType === 9 ) {
  685. targetWidth = target.width();
  686. targetHeight = target.height();
  687. basePosition = { top: 0, left: 0 };
  688. // TODO: use $.isWindow() in 1.9
  689. } else if ( targetElem.setTimeout ) {
  690. targetWidth = target.width();
  691. targetHeight = target.height();
  692. basePosition = { top: target.scrollTop(), left: target.scrollLeft() };
  693. } else if ( targetElem.preventDefault ) {
  694. // force left top to allow flipping
  695. options.at = "left top";
  696. targetWidth = targetHeight = 0;
  697. basePosition = { top: options.of.pageY, left: options.of.pageX };
  698. } else {
  699. targetWidth = target.outerWidth();
  700. targetHeight = target.outerHeight();
  701. basePosition = target.offset();
  702. }
  703. // force my and at to have valid horizontal and veritcal positions
  704. // if a value is missing or invalid, it will be converted to center
  705. $.each( [ "my", "at" ], function() {
  706. var pos = ( options[this] || "" ).split( " " );
  707. if ( pos.length === 1) {
  708. pos = horizontalPositions.test( pos[0] ) ?
  709. pos.concat( [center] ) :
  710. verticalPositions.test( pos[0] ) ?
  711. [ center ].concat( pos ) :
  712. [ center, center ];
  713. }
  714. pos[ 0 ] = horizontalPositions.test( pos[0] ) ? pos[ 0 ] : center;
  715. pos[ 1 ] = verticalPositions.test( pos[1] ) ? pos[ 1 ] : center;
  716. options[ this ] = pos;
  717. });
  718. // normalize collision option
  719. if ( collision.length === 1 ) {
  720. collision[ 1 ] = collision[ 0 ];
  721. }
  722. // normalize offset option
  723. offset[ 0 ] = parseInt( offset[0], 10 ) || 0;
  724. if ( offset.length === 1 ) {
  725. offset[ 1 ] = offset[ 0 ];
  726. }
  727. offset[ 1 ] = parseInt( offset[1], 10 ) || 0;
  728. if ( options.at[0] === "right" ) {
  729. basePosition.left += targetWidth;
  730. } else if ( options.at[0] === center ) {
  731. basePosition.left += targetWidth / 2;
  732. }
  733. if ( options.at[1] === "bottom" ) {
  734. basePosition.top += targetHeight;
  735. } else if ( options.at[1] === center ) {
  736. basePosition.top += targetHeight / 2;
  737. }
  738. basePosition.left += offset[ 0 ];
  739. basePosition.top += offset[ 1 ];
  740. return this.each(function() {
  741. var elem = $( this ),
  742. elemWidth = elem.outerWidth(),
  743. elemHeight = elem.outerHeight(),
  744. marginLeft = parseInt( $.curCSS( this, "marginLeft", true ) ) || 0,
  745. marginTop = parseInt( $.curCSS( this, "marginTop", true ) ) || 0,
  746. collisionWidth = elemWidth + marginLeft +
  747. ( parseInt( $.curCSS( this, "marginRight", true ) ) || 0 ),
  748. collisionHeight = elemHeight + marginTop +
  749. ( parseInt( $.curCSS( this, "marginBottom", true ) ) || 0 ),
  750. position = $.extend( {}, basePosition ),
  751. collisionPosition;
  752. if ( options.my[0] === "right" ) {
  753. position.left -= elemWidth;
  754. } else if ( options.my[0] === center ) {
  755. position.left -= elemWidth / 2;
  756. }
  757. if ( options.my[1] === "bottom" ) {
  758. position.top -= elemHeight;
  759. } else if ( options.my[1] === center ) {
  760. position.top -= elemHeight / 2;
  761. }
  762. // prevent fractions if jQuery version doesn't support them (see #5280)
  763. if ( !support.fractions ) {
  764. position.left = Math.round( position.left );
  765. position.top = Math.round( position.top );
  766. }
  767. collisionPosition = {
  768. left: position.left - marginLeft,
  769. top: position.top - marginTop
  770. };
  771. $.each( [ "left", "top" ], function( i, dir ) {
  772. if ( $.ui.position[ collision[i] ] ) {
  773. $.ui.position[ collision[i] ][ dir ]( position, {
  774. targetWidth: targetWidth,
  775. targetHeight: targetHeight,
  776. elemWidth: elemWidth,
  777. elemHeight: elemHeight,
  778. collisionPosition: collisionPosition,
  779. collisionWidth: collisionWidth,
  780. collisionHeight: collisionHeight,
  781. offset: offset,
  782. my: options.my,
  783. at: options.at
  784. });
  785. }
  786. });
  787. if ( $.fn.bgiframe ) {
  788. elem.bgiframe();
  789. }
  790. elem.offset( $.extend( position, { using: options.using } ) );
  791. });
  792. };
  793. $.ui.position = {
  794. fit: {
  795. left: function( position, data ) {
  796. var win = $( window ),
  797. over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft();
  798. position.left = over > 0 ? position.left - over : Math.max( position.left - data.collisionPosition.left, position.left );
  799. },
  800. top: function( position, data ) {
  801. var win = $( window ),
  802. over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop();
  803. position.top = over > 0 ? position.top - over : Math.max( position.top - data.collisionPosition.top, position.top );
  804. }
  805. },
  806. flip: {
  807. left: function( position, data ) {
  808. if ( data.at[0] === center ) {
  809. return;
  810. }
  811. var win = $( window ),
  812. over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft(),
  813. myOffset = data.my[ 0 ] === "left" ?
  814. -data.elemWidth :
  815. data.my[ 0 ] === "right" ?
  816. data.elemWidth :
  817. 0,
  818. atOffset = data.at[ 0 ] === "left" ?
  819. data.targetWidth :
  820. -data.targetWidth,
  821. offset = -2 * data.offset[ 0 ];
  822. position.left += data.collisionPosition.left < 0 ?
  823. myOffset + atOffset + offset :
  824. over > 0 ?
  825. myOffset + atOffset + offset :
  826. 0;
  827. },
  828. top: function( position, data ) {
  829. if ( data.at[1] === center ) {
  830. return;
  831. }
  832. var win = $( window ),
  833. over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop(),
  834. myOffset = data.my[ 1 ] === "top" ?
  835. -data.elemHeight :
  836. data.my[ 1 ] === "bottom" ?
  837. data.elemHeight :
  838. 0,
  839. atOffset = data.at[ 1 ] === "top" ?
  840. data.targetHeight :
  841. -data.targetHeight,
  842. offset = -2 * data.offset[ 1 ];
  843. position.top += data.collisionPosition.top < 0 ?
  844. myOffset + atOffset + offset :
  845. over > 0 ?
  846. myOffset + atOffset + offset :
  847. 0;
  848. }
  849. }
  850. };
  851. // offset setter from jQuery 1.4
  852. if ( !$.offset.setOffset ) {
  853. $.offset.setOffset = function( elem, options ) {
  854. // set position first, in-case top/left are set even on static elem
  855. if ( /static/.test( $.curCSS( elem, "position" ) ) ) {
  856. elem.style.position = "relative";
  857. }
  858. var curElem = $( elem ),
  859. curOffset = curElem.offset(),
  860. curTop = parseInt( $.curCSS( elem, "top", true ), 10 ) || 0,
  861. curLeft = parseInt( $.curCSS( elem, "left", true ), 10) || 0,
  862. props = {
  863. top: (options.top - curOffset.top) + curTop,
  864. left: (options.left - curOffset.left) + curLeft
  865. };
  866. if ( 'using' in options ) {
  867. options.using.call( elem, props );
  868. } else {
  869. curElem.css( props );
  870. }
  871. };
  872. $.fn.offset = function( options ) {
  873. var elem = this[ 0 ];
  874. if ( !elem || !elem.ownerDocument ) { return null; }
  875. if ( options ) {
  876. if ( $.isFunction( options ) ) {
  877. return this.each(function( i ) {
  878. $( this ).offset( options.call( this, i, $( this ).offset() ) );
  879. });
  880. }
  881. return this.each(function() {
  882. $.offset.setOffset( this, options );
  883. });
  884. }
  885. return _offset.call( this );
  886. };
  887. }
  888. // fraction support test (older versions of jQuery don't support fractions)
  889. (function () {
  890. var body = document.getElementsByTagName( "body" )[ 0 ],
  891. div = document.createElement( "div" ),
  892. testElement, testElementParent, testElementStyle, offset, offsetTotal;
  893. //Create a "fake body" for testing based on method used in jQuery.support
  894. testElement = document.createElement( body ? "div" : "body" );
  895. testElementStyle = {
  896. visibility: "hidden",
  897. width: 0,
  898. height: 0,
  899. border: 0,
  900. margin: 0,
  901. background: "none"
  902. };
  903. if ( body ) {
  904. $.extend( testElementStyle, {
  905. position: "absolute",
  906. left: "-1000px",
  907. top: "-1000px"
  908. });
  909. }
  910. for ( var i in testElementStyle ) {
  911. testElement.style[ i ] = testElementStyle[ i ];
  912. }
  913. testElement.appendChild( div );
  914. testElementParent = body || document.documentElement;
  915. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  916. div.style.cssText = "position: absolute; left: 10.7432222px; top: 10.432325px; height: 30px; width: 201px;";
  917. offset = $( div ).offset( function( _, offset ) {
  918. return offset;
  919. }).offset();
  920. testElement.innerHTML = "";
  921. testElementParent.removeChild( testElement );
  922. offsetTotal = offset.top + offset.left + ( body ? 2000 : 0 );
  923. support.fractions = offsetTotal > 21 && offsetTotal < 22;
  924. })();
  925. }( jQuery ));
  926. /*!
  927. * jQuery UI Draggable 1.8.21
  928. *
  929. * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
  930. * Dual licensed under the MIT or GPL Version 2 licenses.
  931. * http://jquery.org/license
  932. *
  933. * http://docs.jquery.com/UI/Draggables
  934. *
  935. * Depends:
  936. * jquery.ui.core.js
  937. * jquery.ui.mouse.js
  938. * jquery.ui.widget.js
  939. */
  940. (function( $, undefined ) {
  941. $.widget("ui.draggable", $.ui.mouse, {
  942. widgetEventPrefix: "drag",
  943. options: {
  944. addClasses: true,
  945. appendTo: "parent",
  946. axis: false,
  947. connectToSortable: false,
  948. containment: false,
  949. cursor: "auto",
  950. cursorAt: false,
  951. grid: false,
  952. handle: false,
  953. helper: "original",
  954. iframeFix: false,
  955. opacity: false,
  956. refreshPositions: false,
  957. revert: false,
  958. revertDuration: 500,
  959. scope: "default",
  960. scroll: true,
  961. scrollSensitivity: 20,
  962. scrollSpeed: 20,
  963. snap: false,
  964. snapMode: "both",
  965. snapTolerance: 20,
  966. stack: false,
  967. zIndex: false
  968. },
  969. _create: function() {
  970. if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position")))
  971. this.element[0].style.position = 'relative';
  972. (this.options.addClasses && this.element.addClass("ui-draggable"));
  973. (this.options.disabled && this.element.addClass("ui-draggable-disabled"));
  974. this._mouseInit();
  975. },
  976. destroy: function() {
  977. if(!this.element.data('draggable')) return;
  978. this.element
  979. .removeData("draggable")
  980. .unbind(".draggable")
  981. .removeClass("ui-draggable"
  982. + " ui-draggable-dragging"
  983. + " ui-draggable-disabled");
  984. this._mouseDestroy();
  985. return this;
  986. },
  987. _mouseCapture: function(event) {
  988. var o = this.options;
  989. // among others, prevent a drag on a resizable-handle
  990. if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle'))
  991. return false;
  992. //Quit if we're not on a valid handle
  993. this.handle = this._getHandle(event);
  994. if (!this.handle)
  995. return false;
  996. if ( o.iframeFix ) {
  997. $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
  998. $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')
  999. .css({
  1000. width: this.offsetWidth+"px", height: this.offsetHeight+"px",
  1001. position: "absolute", opacity: "0.001", zIndex: 1000
  1002. })
  1003. .css($(this).offset())
  1004. .appendTo("body");
  1005. });
  1006. }
  1007. return true;
  1008. },
  1009. _mouseStart: function(event) {
  1010. var o = this.options;
  1011. //Create and append the visible helper
  1012. this.helper = this._createHelper(event);
  1013. this.helper.addClass("ui-draggable-dragging");
  1014. //Cache the helper size
  1015. this._cacheHelperProportions();
  1016. //If ddmanager is used for droppables, set the global draggable
  1017. if($.ui.ddmanager)
  1018. $.ui.ddmanager.current = this;
  1019. /*
  1020. * - Position generation -
  1021. * This block generates everything position related - it's the core of draggables.
  1022. */
  1023. //Cache the margins of the original element
  1024. this._cacheMargins();
  1025. //Store the helper's css position
  1026. this.cssPosition = this.helper.css("position");
  1027. this.scrollParent = this.helper.scrollParent();
  1028. //The element's absolute position on the page minus margins
  1029. this.offset = this.positionAbs = this.element.offset();
  1030. this.offset = {
  1031. top: this.offset.top - this.margins.top,
  1032. left: this.offset.left - this.margins.left
  1033. };
  1034. $.extend(this.offset, {
  1035. click: { //Where the click happened, relative to the element
  1036. left: event.pageX - this.offset.left,
  1037. top: event.pageY - this.offset.top
  1038. },
  1039. parent: this._getParentOffset(),
  1040. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  1041. });
  1042. //Generate the original position
  1043. this.originalPosition = this.position = this._generatePosition(event);
  1044. this.originalPageX = event.pageX;
  1045. this.originalPageY = event.pageY;
  1046. //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
  1047. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  1048. //Set a containment if given in the options
  1049. if(o.containment)
  1050. this._setContainment();
  1051. //Trigger event + callbacks
  1052. if(this._trigger("start", event) === false) {
  1053. this._clear();
  1054. return false;
  1055. }
  1056. //Recache the helper size
  1057. this._cacheHelperProportions();
  1058. //Prepare the droppable offsets
  1059. if ($.ui.ddmanager && !o.dropBehaviour)
  1060. $.ui.ddmanager.prepareOffsets(this, event);
  1061. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  1062. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  1063. if ( $.ui.ddmanager ) $.ui.ddmanager.dragStart(this, event);
  1064. return true;
  1065. },
  1066. _mouseDrag: function(event, noPropagation) {
  1067. //Compute the helpers position
  1068. this.position = this._generatePosition(event);
  1069. this.positionAbs = this._convertPositionTo("absolute");
  1070. //Call plugins and callbacks and use the resulting position if something is returned
  1071. if (!noPropagation) {
  1072. var ui = this._uiHash();
  1073. if(this._trigger('drag', event, ui) === false) {
  1074. this._mouseUp({});
  1075. return false;
  1076. }
  1077. this.position = ui.position;
  1078. }
  1079. if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
  1080. if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
  1081. if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
  1082. return false;
  1083. },
  1084. _mouseStop: function(event) {
  1085. //If we are using droppables, inform the manager about the drop
  1086. var dropped = false;
  1087. if ($.ui.ddmanager && !this.options.dropBehaviour)
  1088. dropped = $.ui.ddmanager.drop(this, event);
  1089. //if a drop comes from outside (a sortable)
  1090. if(this.dropped) {
  1091. dropped = this.dropped;
  1092. this.dropped = false;
  1093. }
  1094. //if the original element is no longer in the DOM don't bother to continue (see #8269)
  1095. var element = this.element[0], elementInDom = false;
  1096. while ( element && (element = element.parentNode) ) {
  1097. if (element == document ) {
  1098. elementInDom = true;
  1099. }
  1100. }
  1101. if ( !elementInDom && this.options.helper === "original" )
  1102. return false;
  1103. 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))) {
  1104. var self = this;
  1105. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  1106. if(self._trigger("stop", event) !== false) {
  1107. self._clear();
  1108. }
  1109. });
  1110. } else {
  1111. if(this._trigger("stop", event) !== false) {
  1112. this._clear();
  1113. }
  1114. }
  1115. return false;
  1116. },
  1117. _mouseUp: function(event) {
  1118. if (this.options.iframeFix === true) {
  1119. $("div.ui-draggable-iframeFix").each(function() {
  1120. this.parentNode.removeChild(this);
  1121. }); //Remove frame helpers
  1122. }
  1123. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  1124. if( $.ui.ddmanager ) $.ui.ddmanager.dragStop(this, event);
  1125. return $.ui.mouse.prototype._mouseUp.call(this, event);
  1126. },
  1127. cancel: function() {
  1128. if(this.helper.is(".ui-draggable-dragging")) {
  1129. this._mouseUp({});
  1130. } else {
  1131. this._clear();
  1132. }
  1133. return this;
  1134. },
  1135. _getHandle: function(event) {
  1136. var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
  1137. $(this.options.handle, this.element)
  1138. .find("*")
  1139. .andSelf()
  1140. .each(function() {
  1141. if(this == event.target) handle = true;
  1142. });
  1143. return handle;
  1144. },
  1145. _createHelper: function(event) {
  1146. var o = this.options;
  1147. var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone().removeAttr('id') : this.element);
  1148. if(!helper.parents('body').length)
  1149. helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));
  1150. if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position")))
  1151. helper.css("position", "absolute");
  1152. return helper;
  1153. },
  1154. _adjustOffsetFromHelper: function(obj) {
  1155. if (typeof obj == 'string') {
  1156. obj = obj.split(' ');
  1157. }
  1158. if ($.isArray(obj)) {
  1159. obj = {left: +obj[0], top: +obj[1] || 0};
  1160. }
  1161. if ('left' in obj) {
  1162. this.offset.click.left = obj.left + this.margins.left;
  1163. }
  1164. if ('right' in obj) {
  1165. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  1166. }
  1167. if ('top' in obj) {
  1168. this.offset.click.top = obj.top + this.margins.top;
  1169. }
  1170. if ('bottom' in obj) {
  1171. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  1172. }
  1173. },
  1174. _getParentOffset: function() {
  1175. //Get the offsetParent and cache its position
  1176. this.offsetParent = this.helper.offsetParent();
  1177. var po = this.offsetParent.offset();
  1178. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  1179. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  1180. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  1181. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  1182. if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
  1183. po.left += this.scrollParent.scrollLeft();
  1184. po.top += this.scrollParent.scrollTop();
  1185. }
  1186. if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
  1187. || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
  1188. po = { top: 0, left: 0 };
  1189. return {
  1190. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  1191. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  1192. };
  1193. },
  1194. _getRelativeOffset: function() {
  1195. if(this.cssPosition == "relative") {
  1196. var p = this.element.position();
  1197. return {
  1198. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  1199. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  1200. };
  1201. } else {
  1202. return { top: 0, left: 0 };
  1203. }
  1204. },
  1205. _cacheMargins: function() {
  1206. this.margins = {
  1207. left: (parseInt(this.element.css("marginLeft"),10) || 0),
  1208. top: (parseInt(this.element.css("marginTop"),10) || 0),
  1209. right: (parseInt(this.element.css("marginRight"),10) || 0),
  1210. bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
  1211. };
  1212. },
  1213. _cacheHelperProportions: function() {
  1214. this.helperProportions = {
  1215. width: this.helper.outerWidth(),
  1216. height: this.helper.outerHeight()
  1217. };
  1218. },
  1219. _setContainment: function() {
  1220. var o = this.options;
  1221. if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
  1222. if(o.containment == 'document' || o.containment == 'window') this.containment = [
  1223. o.containment == 'document' ? 0 : $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  1224. o.containment == 'document' ? 0 : $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  1225. (o.containment == 'document' ? 0 : $(window).scrollLeft()) + $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
  1226. (o.containment == 'document' ? 0 : $(window).scrollTop()) + ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  1227. ];
  1228. if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) {
  1229. var c = $(o.containment);
  1230. var ce = c[0]; if(!ce) return;
  1231. var co = c.offset();
  1232. var over = ($(ce).css("overflow") != 'hidden');
  1233. this.containment = [
  1234. (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0),
  1235. (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0),
  1236. (over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left - this.margins.right,
  1237. (over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top - this.margins.bottom
  1238. ];
  1239. this.relative_container = c;
  1240. } else if(o.containment.constructor == Array) {
  1241. this.containment = o.containment;
  1242. }
  1243. },
  1244. _convertPositionTo: function(d, pos) {
  1245. if(!pos) pos = this.position;
  1246. var mod = d == "absolute" ? 1 : -1;
  1247. var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  1248. return {
  1249. top: (
  1250. pos.top // The absolute mouse position
  1251. + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent
  1252. + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
  1253. - ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  1254. ),
  1255. left: (
  1256. pos.left // The absolute mouse position
  1257. + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent
  1258. + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
  1259. - ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  1260. )
  1261. };
  1262. },
  1263. _generatePosition: function(event) {
  1264. var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  1265. var pageX = event.pageX;
  1266. var pageY = event.pageY;
  1267. /*
  1268. * - Position constraining -
  1269. * Constrain the position to a mix of grid, containment.
  1270. */
  1271. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  1272. var containment;
  1273. if(this.containment) {
  1274. if (this.relative_container){
  1275. var co = this.relative_container.offset();
  1276. containment = [ this.containment[0] + co.left,
  1277. this.containment[1] + co.top,
  1278. this.containment[2] + co.left,
  1279. this.containment[3] + co.top ];
  1280. }
  1281. else {
  1282. containment = this.containment;
  1283. }
  1284. if(event.pageX - this.offset.click.left < containment[0]) pageX = containment[0] + this.offset.click.left;
  1285. if(event.pageY - this.offset.click.top < containment[1]) pageY = containment[1] + this.offset.click.top;
  1286. if(event.pageX - this.offset.click.left > containment[2]) pageX = containment[2] + this.offset.click.left;
  1287. if(event.pageY - this.offset.click.top > containment[3]) pageY = containment[3] + this.offset.click.top;
  1288. }
  1289. if(o.grid) {
  1290. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  1291. var top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  1292. 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;
  1293. var left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  1294. 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;
  1295. }
  1296. }
  1297. return {
  1298. top: (
  1299. pageY // The absolute mouse position
  1300. - this.offset.click.top // Click offset (relative to the element)
  1301. - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent
  1302. - this.offset.parent.top // The offsetParent's offset without borders (offset + border)
  1303. + ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  1304. ),
  1305. left: (
  1306. pageX // The absolute mouse position
  1307. - this.offset.click.left // Click offset (relative to the element)
  1308. - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent
  1309. - this.offset.parent.left // The offsetParent's offset without borders (offset + border)
  1310. + ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  1311. )
  1312. };
  1313. },
  1314. _clear: function() {
  1315. this.helper.removeClass("ui-draggable-dragging");
  1316. if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove();
  1317. //if($.ui.ddmanager) $.ui.ddmanager.current = null;
  1318. this.helper = null;
  1319. this.cancelHelperRemoval = false;
  1320. },
  1321. // From now on bulk stuff - mainly helpers
  1322. _trigger: function(type, event, ui) {
  1323. ui = ui || this._uiHash();
  1324. $.ui.plugin.call(this, type, [event, ui]);
  1325. if(type == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins
  1326. return $.Widget.prototype._trigger.call(this, type, event, ui);
  1327. },
  1328. plugins: {},
  1329. _uiHash: function(event) {
  1330. return {
  1331. helper: this.helper,
  1332. position: this.position,
  1333. originalPosition: this.originalPosition,
  1334. offset: this.positionAbs
  1335. };
  1336. }
  1337. });
  1338. $.extend($.ui.draggable, {
  1339. version: "1.8.21"
  1340. });
  1341. $.ui.plugin.add("draggable", "connectToSortable", {
  1342. start: function(event, ui) {
  1343. var inst = $(this).data("draggable"), o = inst.options,
  1344. uiSortable = $.extend({}, ui, { item: inst.element });
  1345. inst.sortables = [];
  1346. $(o.connectToSortable).each(function() {
  1347. var sortable = $.data(this, 'sortable');
  1348. if (sortable && !sortable.options.disabled) {
  1349. inst.sortables.push({
  1350. instance: sortable,
  1351. shouldRevert: sortable.options.revert
  1352. });
  1353. 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).
  1354. sortable._trigger("activate", event, uiSortable);
  1355. }
  1356. });
  1357. },
  1358. stop: function(event, ui) {
  1359. //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
  1360. var inst = $(this).data("draggable"),
  1361. uiSortable = $.extend({}, ui, { item: inst.element });
  1362. $.each(inst.sortables, function() {
  1363. if(this.instance.isOver) {
  1364. this.instance.isOver = 0;
  1365. inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
  1366. this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
  1367. //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: 'valid/invalid'
  1368. if(this.shouldRevert) this.instance.options.revert = true;
  1369. //Trigger the stop of the sortable
  1370. this.instance._mouseStop(event);
  1371. this.instance.options.helper = this.instance.options._helper;
  1372. //If the helper has been the original item, restore properties in the sortable
  1373. if(inst.options.helper == 'original')
  1374. this.instance.currentItem.css({ top: 'auto', left: 'auto' });
  1375. } else {
  1376. this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
  1377. this.instance._trigger("deactivate", event, uiSortable);
  1378. }
  1379. });
  1380. },
  1381. drag: function(event, ui) {
  1382. var inst = $(this).data("draggable"), self = this;
  1383. var checkPos = function(o) {
  1384. var dyClick = this.offset.click.top, dxClick = this.offset.click.left;
  1385. var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left;
  1386. var itemHeight = o.height, itemWidth = o.width;
  1387. var itemTop = o.top, itemLeft = o.left;
  1388. return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth);
  1389. };
  1390. $.each(inst.sortables, function(i) {
  1391. //Copy over some variables to allow calling the sortable's native _intersectsWith
  1392. this.instance.positionAbs = inst.positionAbs;
  1393. this.instance.helperProportions = inst.helperProportions;
  1394. this.instance.offset.click = inst.offset.click;
  1395. if(this.instance._intersectsWith(this.instance.containerCache)) {
  1396. //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
  1397. if(!this.instance.isOver) {
  1398. this.instance.isOver = 1;
  1399. //Now we fake the start of dragging for the sortable instance,
  1400. //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
  1401. //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)
  1402. this.instance.currentItem = $(self).clone().removeAttr('id').appendTo(this.instance.element).data("sortable-item", true);
  1403. this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
  1404. this.instance.options.helper = function() { return ui.helper[0]; };
  1405. event.target = this.instance.currentItem[0];
  1406. this.instance._mouseCapture(event, true);
  1407. this.instance._mouseStart(event, true, true);
  1408. //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
  1409. this.instance.offset.click.top = inst.offset.click.top;
  1410. this.instance.offset.click.left = inst.offset.click.left;
  1411. this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
  1412. this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
  1413. inst._trigger("toSortable", event);
  1414. inst.dropped = this.instance.element; //draggable revert needs that
  1415. //hack so receive/update callbacks work (mostly)
  1416. inst.currentItem = inst.element;
  1417. this.instance.fromOutside = inst;
  1418. }
  1419. //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
  1420. if(this.instance.currentItem) this.instance._mouseDrag(event);
  1421. } else {
  1422. //If it doesn't intersect with the sortable, and it intersected before,
  1423. //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
  1424. if(this.instance.isOver) {
  1425. this.instance.isOver = 0;
  1426. this.instance.cancelHelperRemoval = true;
  1427. //Prevent reverting on this forced stop
  1428. this.instance.options.revert = false;
  1429. // The out event needs to be triggered independently
  1430. this.instance._trigger('out', event, this.instance._uiHash(this.instance));
  1431. this.instance._mouseStop(event, true);
  1432. this.instance.options.helper = this.instance.options._helper;
  1433. //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
  1434. this.instance.currentItem.remove();
  1435. if(this.instance.placeholder) this.instance.placeholder.remove();
  1436. inst._trigger("fromSortable", event);
  1437. inst.dropped = false; //draggable revert needs that
  1438. }
  1439. };
  1440. });
  1441. }
  1442. });
  1443. $.ui.plugin.add("draggable", "cursor", {
  1444. start: function(event, ui) {
  1445. var t = $('body'), o = $(this).data('draggable').options;
  1446. if (t.css("cursor")) o._cursor = t.css("cursor");
  1447. t.css("cursor", o.cursor);
  1448. },
  1449. stop: function(event, ui) {
  1450. var o = $(this).data('draggable').options;
  1451. if (o._cursor) $('body').css("cursor", o._cursor);
  1452. }
  1453. });
  1454. $.ui.plugin.add("draggable", "opacity", {
  1455. start: function(event, ui) {
  1456. var t = $(ui.helper), o = $(this).data('draggable').options;
  1457. if(t.css("opacity")) o._opacity = t.css("opacity");
  1458. t.css('opacity', o.opacity);
  1459. },
  1460. stop: function(event, ui) {
  1461. var o = $(this).data('draggable').options;
  1462. if(o._opacity) $(ui.helper).css('opacity', o._opacity);
  1463. }
  1464. });
  1465. $.ui.plugin.add("draggable", "scroll", {
  1466. start: function(event, ui) {
  1467. var i = $(this).data("draggable");
  1468. if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') i.overflowOffset = i.scrollParent.offset();
  1469. },
  1470. drag: function(event, ui) {
  1471. var i = $(this).data("draggable"), o = i.options, scrolled = false;
  1472. if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') {
  1473. if(!o.axis || o.axis != 'x') {
  1474. if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
  1475. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
  1476. else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity)
  1477. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
  1478. }
  1479. if(!o.axis || o.axis != 'y') {
  1480. if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
  1481. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
  1482. else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity)
  1483. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
  1484. }
  1485. } else {
  1486. if(!o.axis || o.axis != 'x') {
  1487. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
  1488. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  1489. else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
  1490. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  1491. }
  1492. if(!o.axis || o.axis != 'y') {
  1493. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
  1494. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  1495. else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
  1496. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  1497. }
  1498. }
  1499. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
  1500. $.ui.ddmanager.prepareOffsets(i, event);
  1501. }
  1502. });
  1503. $.ui.plugin.add("draggable", "snap", {
  1504. start: function(event, ui) {
  1505. var i = $(this).data("draggable"), o = i.options;
  1506. i.snapElements = [];
  1507. $(o.snap.constructor != String ? ( o.snap.items || ':data(draggable)' ) : o.snap).each(function() {
  1508. var $t = $(this); var $o = $t.offset();
  1509. if(this != i.element[0]) i.snapElements.push({
  1510. item: this,
  1511. width: $t.outerWidth(), height: $t.outerHeight(),
  1512. top: $o.top, left: $o.left
  1513. });
  1514. });
  1515. },
  1516. drag: function(event, ui) {
  1517. var inst = $(this).data("draggable"), o = inst.options;
  1518. var d = o.snapTolerance;
  1519. var x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  1520. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  1521. for (var i = inst.snapElements.length - 1; i >= 0; i--){
  1522. var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width,
  1523. t = inst.snapElements[i].top, b = t + inst.snapElements[i].height;
  1524. //Yes, I know, this is insane ;)
  1525. if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) {
  1526. if(inst.snapElements[i].snapping) (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  1527. inst.snapElements[i].snapping = false;
  1528. continue;
  1529. }
  1530. if(o.snapMode != 'inner') {
  1531. var ts = Math.abs(t - y2) <= d;
  1532. var bs = Math.abs(b - y1) <= d;
  1533. var ls = Math.abs(l - x2) <= d;
  1534. var rs = Math.abs(r - x1) <= d;
  1535. if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  1536. if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
  1537. if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
  1538. if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
  1539. }
  1540. var first = (ts || bs || ls || rs);
  1541. if(o.snapMode != 'outer') {
  1542. var ts = Math.abs(t - y1) <= d;
  1543. var bs = Math.abs(b - y2) <= d;
  1544. var ls = Math.abs(l - x1) <= d;
  1545. var rs = Math.abs(r - x2) <= d;
  1546. if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
  1547. if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  1548. if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
  1549. if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
  1550. }
  1551. if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first))
  1552. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  1553. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  1554. };
  1555. }
  1556. });
  1557. $.ui.plugin.add("draggable", "stack", {
  1558. start: function(event, ui) {
  1559. var o = $(this).data("draggable").options;
  1560. var group = $.makeArray($(o.stack)).sort(function(a,b) {
  1561. return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
  1562. });
  1563. if (!group.length) { return; }
  1564. var min = parseInt(group[0].style.zIndex) || 0;
  1565. $(group).each(function(i) {
  1566. this.style.zIndex = min + i;
  1567. });
  1568. this[0].style.zIndex = min + group.length;
  1569. }
  1570. });
  1571. $.ui.plugin.add("draggable", "zIndex", {
  1572. start: function(event, ui) {
  1573. var t = $(ui.helper), o = $(this).data("draggable").options;
  1574. if(t.css("zIndex")) o._zIndex = t.css("zIndex");
  1575. t.css('zIndex', o.zIndex);
  1576. },
  1577. stop: function(event, ui) {
  1578. var o = $(this).data("draggable").options;
  1579. if(o._zIndex) $(ui.helper).css('zIndex', o._zIndex);
  1580. }
  1581. });
  1582. })(jQuery);
  1583. /*!
  1584. * jQuery UI Droppable 1.8.21
  1585. *
  1586. * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
  1587. * Dual licensed under the MIT or GPL Version 2 licenses.
  1588. * http://jquery.org/license
  1589. *
  1590. * http://docs.jquery.com/UI/Droppables
  1591. *
  1592. * Depends:
  1593. * jquery.ui.core.js
  1594. * jquery.ui.widget.js
  1595. * jquery.ui.mouse.js
  1596. * jquery.ui.draggable.js
  1597. */
  1598. (function( $, undefined ) {
  1599. $.widget("ui.droppable", {
  1600. widgetEventPrefix: "drop",
  1601. options: {
  1602. accept: '*',
  1603. activeClass: false,
  1604. addClasses: true,
  1605. greedy: false,
  1606. hoverClass: false,
  1607. scope: 'default',
  1608. tolerance: 'intersect'
  1609. },
  1610. _create: function() {
  1611. var o = this.options, accept = o.accept;
  1612. this.isover = 0; this.isout = 1;
  1613. this.accept = $.isFunction(accept) ? accept : function(d) {
  1614. return d.is(accept);
  1615. };
  1616. //Store the droppable's proportions
  1617. this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
  1618. // Add the reference and positions to the manager
  1619. $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
  1620. $.ui.ddmanager.droppables[o.scope].push(this);
  1621. (o.addClasses && this.element.addClass("ui-droppable"));
  1622. },
  1623. destroy: function() {
  1624. var drop = $.ui.ddmanager.droppables[this.options.scope];
  1625. for ( var i = 0; i < drop.length; i++ )
  1626. if ( drop[i] == this )
  1627. drop.splice(i, 1);
  1628. this.element
  1629. .removeClass("ui-droppable ui-droppable-disabled")
  1630. .removeData("droppable")
  1631. .unbind(".droppable");
  1632. return this;
  1633. },
  1634. _setOption: function(key, value) {
  1635. if(key == 'accept') {
  1636. this.accept = $.isFunction(value) ? value : function(d) {
  1637. return d.is(value);
  1638. };
  1639. }
  1640. $.Widget.prototype._setOption.apply(this, arguments);
  1641. },
  1642. _activate: function(event) {
  1643. var draggable = $.ui.ddmanager.current;
  1644. if(this.options.activeClass) this.element.addClass(this.options.activeClass);
  1645. (draggable && this._trigger('activate', event, this.ui(draggable)));
  1646. },
  1647. _deactivate: function(event) {
  1648. var draggable = $.ui.ddmanager.current;
  1649. if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
  1650. (draggable && this._trigger('deactivate', event, this.ui(draggable)));
  1651. },
  1652. _over: function(event) {
  1653. var draggable = $.ui.ddmanager.current;
  1654. if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
  1655. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1656. if(this.options.hoverClass) this.element.addClass(this.options.hoverClass);
  1657. this._trigger('over', event, this.ui(draggable));
  1658. }
  1659. },
  1660. _out: function(event) {
  1661. var draggable = $.ui.ddmanager.current;
  1662. if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
  1663. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1664. if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
  1665. this._trigger('out', event, this.ui(draggable));
  1666. }
  1667. },
  1668. _drop: function(event,custom) {
  1669. var draggable = custom || $.ui.ddmanager.current;
  1670. if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false; // Bail if draggable and droppable are same element
  1671. var childrenIntersection = false;
  1672. this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function() {
  1673. var inst = $.data(this, 'droppable');
  1674. if(
  1675. inst.options.greedy
  1676. && !inst.options.disabled
  1677. && inst.options.scope == draggable.options.scope
  1678. && inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element))
  1679. && $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
  1680. ) { childrenIntersection = true; return false; }
  1681. });
  1682. if(childrenIntersection) return false;
  1683. if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1684. if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
  1685. if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
  1686. this._trigger('drop', event, this.ui(draggable));
  1687. return this.element;
  1688. }
  1689. return false;
  1690. },
  1691. ui: function(c) {
  1692. return {
  1693. draggable: (c.currentItem || c.element),
  1694. helper: c.helper,
  1695. position: c.position,
  1696. offset: c.positionAbs
  1697. };
  1698. }
  1699. });
  1700. $.extend($.ui.droppable, {
  1701. version: "1.8.21"
  1702. });
  1703. $.ui.intersect = function(draggable, droppable, toleranceMode) {
  1704. if (!droppable.offset) return false;
  1705. var x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
  1706. y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height;
  1707. var l = droppable.offset.left, r = l + droppable.proportions.width,
  1708. t = droppable.offset.top, b = t + droppable.proportions.height;
  1709. switch (toleranceMode) {
  1710. case 'fit':
  1711. return (l <= x1 && x2 <= r
  1712. && t <= y1 && y2 <= b);
  1713. break;
  1714. case 'intersect':
  1715. return (l < x1 + (draggable.helperProportions.width / 2) // Right Half
  1716. && x2 - (draggable.helperProportions.width / 2) < r // Left Half
  1717. && t < y1 + (draggable.helperProportions.height / 2) // Bottom Half
  1718. && y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
  1719. break;
  1720. case 'pointer':
  1721. var draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left),
  1722. draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top),
  1723. isOver = $.ui.isOver(draggableTop, draggableLeft, t, l, droppable.proportions.height, droppable.proportions.width);
  1724. return isOver;
  1725. break;
  1726. case 'touch':
  1727. return (
  1728. (y1 >= t && y1 <= b) || // Top edge touching
  1729. (y2 >= t && y2 <= b) || // Bottom edge touching
  1730. (y1 < t && y2 > b) // Surrounded vertically
  1731. ) && (
  1732. (x1 >= l && x1 <= r) || // Left edge touching
  1733. (x2 >= l && x2 <= r) || // Right edge touching
  1734. (x1 < l && x2 > r) // Surrounded horizontally
  1735. );
  1736. break;
  1737. default:
  1738. return false;
  1739. break;
  1740. }
  1741. };
  1742. /*
  1743. This manager tracks offsets of draggables and droppables
  1744. */
  1745. $.ui.ddmanager = {
  1746. current: null,
  1747. droppables: { 'default': [] },
  1748. prepareOffsets: function(t, event) {
  1749. var m = $.ui.ddmanager.droppables[t.options.scope] || [];
  1750. var type = event ? event.type : null; // workaround for #2317
  1751. var list = (t.currentItem || t.element).find(":data(droppable)").andSelf();
  1752. droppablesLoop: for (var i = 0; i < m.length; i++) {
  1753. if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) continue; //No disabled and non-accepted
  1754. for (var j=0; j < list.length; j++) { if(list[j] == m[i].element[0]) { m[i].proportions.height = 0; continue droppablesLoop; } }; //Filter out elements in the current dragged item
  1755. m[i].visible = m[i].element.css("display") != "none"; if(!m[i].visible) continue; //If the element is not visible, continue
  1756. if(type == "mousedown") m[i]._activate.call(m[i], event); //Activate the droppable if used directly from draggables
  1757. m[i].offset = m[i].element.offset();
  1758. m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
  1759. }
  1760. },
  1761. drop: function(draggable, event) {
  1762. var dropped = false;
  1763. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  1764. if(!this.options) return;
  1765. if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance))
  1766. dropped = this._drop.call(this, event) || dropped;
  1767. if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1768. this.isout = 1; this.isover = 0;
  1769. this._deactivate.call(this, event);
  1770. }
  1771. });
  1772. return dropped;
  1773. },
  1774. dragStart: function( draggable, event ) {
  1775. //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  1776. draggable.element.parents( ":not(body,html)" ).bind( "scroll.droppable", function() {
  1777. if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
  1778. });
  1779. },
  1780. drag: function(draggable, event) {
  1781. //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  1782. if(draggable.options.refreshPositions) $.ui.ddmanager.prepareOffsets(draggable, event);
  1783. //Run through all droppables and check their positions based on specific tolerance options
  1784. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  1785. if(this.options.disabled || this.greedyChild || !this.visible) return;
  1786. var intersects = $.ui.intersect(draggable, this, this.options.tolerance);
  1787. var c = !intersects && this.isover == 1 ? 'isout' : (intersects && this.isover == 0 ? 'isover' : null);
  1788. if(!c) return;
  1789. var parentInstance;
  1790. if (this.options.greedy) {
  1791. var parent = this.element.parents(':data(droppable):eq(0)');
  1792. if (parent.length) {
  1793. parentInstance = $.data(parent[0], 'droppable');
  1794. parentInstance.greedyChild = (c == 'isover' ? 1 : 0);
  1795. }
  1796. }
  1797. // we just moved into a greedy child
  1798. if (parentInstance && c == 'isover') {
  1799. parentInstance['isover'] = 0;
  1800. parentInstance['isout'] = 1;
  1801. parentInstance._out.call(parentInstance, event);
  1802. }
  1803. this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0;
  1804. this[c == "isover" ? "_over" : "_out"].call(this, event);
  1805. // we just moved out of a greedy child
  1806. if (parentInstance && c == 'isout') {
  1807. parentInstance['isout'] = 0;
  1808. parentInstance['isover'] = 1;
  1809. parentInstance._over.call(parentInstance, event);
  1810. }
  1811. });
  1812. },
  1813. dragStop: function( draggable, event ) {
  1814. draggable.element.parents( ":not(body,html)" ).unbind( "scroll.droppable" );
  1815. //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  1816. if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
  1817. }
  1818. };
  1819. })(jQuery);
  1820. /*!
  1821. * jQuery UI Resizable 1.8.21
  1822. *
  1823. * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
  1824. * Dual licensed under the MIT or GPL Version 2 licenses.
  1825. * http://jquery.org/license
  1826. *
  1827. * http://docs.jquery.com/UI/Resizables
  1828. *
  1829. * Depends:
  1830. * jquery.ui.core.js
  1831. * jquery.ui.mouse.js
  1832. * jquery.ui.widget.js
  1833. */
  1834. (function( $, undefined ) {
  1835. $.widget("ui.resizable", $.ui.mouse, {
  1836. widgetEventPrefix: "resize",
  1837. options: {
  1838. alsoResize: false,
  1839. animate: false,
  1840. animateDuration: "slow",
  1841. animateEasing: "swing",
  1842. aspectRatio: false,
  1843. autoHide: false,
  1844. containment: false,
  1845. ghost: false,
  1846. grid: false,
  1847. handles: "e,s,se",
  1848. helper: false,
  1849. maxHeight: null,
  1850. maxWidth: null,
  1851. minHeight: 10,
  1852. minWidth: 10,
  1853. zIndex: 1000
  1854. },
  1855. _create: function() {
  1856. var self = this, o = this.options;
  1857. this.element.addClass("ui-resizable");
  1858. $.extend(this, {
  1859. _aspectRatio: !!(o.aspectRatio),
  1860. aspectRatio: o.aspectRatio,
  1861. originalElement: this.element,
  1862. _proportionallyResizeElements: [],
  1863. _helper: o.helper || o.ghost || o.animate ? o.helper || 'ui-resizable-helper' : null
  1864. });
  1865. //Wrap the element if it cannot hold child nodes
  1866. if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
  1867. //Create a wrapper element and set the wrapper to the new current internal element
  1868. this.element.wrap(
  1869. $('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({
  1870. position: this.element.css('position'),
  1871. width: this.element.outerWidth(),
  1872. height: this.element.outerHeight(),
  1873. top: this.element.css('top'),
  1874. left: this.element.css('left')
  1875. })
  1876. );
  1877. //Overwrite the original this.element
  1878. this.element = this.element.parent().data(
  1879. "resizable", this.element.data('resizable')
  1880. );
  1881. this.elementIsWrapper = true;
  1882. //Move margins to the wrapper
  1883. this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
  1884. this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
  1885. //Prevent Safari textarea resize
  1886. this.originalResizeStyle = this.originalElement.css('resize');
  1887. this.originalElement.css('resize', 'none');
  1888. //Push the actual element to our proportionallyResize internal array
  1889. this._proportionallyResizeElements.push(this.originalElement.css({ position: 'static', zoom: 1, display: 'block' }));
  1890. // avoid IE jump (hard set the margin)
  1891. this.originalElement.css({ margin: this.originalElement.css('margin') });
  1892. // fix handlers offset
  1893. this._proportionallyResize();
  1894. }
  1895. 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' });
  1896. if(this.handles.constructor == String) {
  1897. if(this.handles == 'all') this.handles = 'n,e,s,w,se,sw,ne,nw';
  1898. var n = this.handles.split(","); this.handles = {};
  1899. for(var i = 0; i < n.length; i++) {
  1900. var handle = $.trim(n[i]), hname = 'ui-resizable-'+handle;
  1901. var axis = $('<div class="ui-resizable-handle ' + hname + '"></div>');
  1902. // Apply zIndex to all handles - see #7960
  1903. axis.css({ zIndex: o.zIndex });
  1904. //TODO : What's going on here?
  1905. if ('se' == handle) {
  1906. axis.addClass('ui-icon ui-icon-gripsmall-diagonal-se');
  1907. };
  1908. //Insert into internal handles object and append to element
  1909. this.handles[handle] = '.ui-resizable-'+handle;
  1910. this.element.append(axis);
  1911. }
  1912. }
  1913. this._renderAxis = function(target) {
  1914. target = target || this.element;
  1915. for(var i in this.handles) {
  1916. if(this.handles[i].constructor == String)
  1917. this.handles[i] = $(this.handles[i], this.element).show();
  1918. //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
  1919. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
  1920. var axis = $(this.handles[i], this.element), padWrapper = 0;
  1921. //Checking the correct pad and border
  1922. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  1923. //The padding type i have to apply...
  1924. var padPos = [ 'padding',
  1925. /ne|nw|n/.test(i) ? 'Top' :
  1926. /se|sw|s/.test(i) ? 'Bottom' :
  1927. /^e$/.test(i) ? 'Right' : 'Left' ].join("");
  1928. target.css(padPos, padWrapper);
  1929. this._proportionallyResize();
  1930. }
  1931. //TODO: What's that good for? There's not anything to be executed left
  1932. if(!$(this.handles[i]).length)
  1933. continue;
  1934. }
  1935. };
  1936. //TODO: make renderAxis a prototype function
  1937. this._renderAxis(this.element);
  1938. this._handles = $('.ui-resizable-handle', this.element)
  1939. .disableSelection();
  1940. //Matching axis name
  1941. this._handles.mouseover(function() {
  1942. if (!self.resizing) {
  1943. if (this.className)
  1944. var axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  1945. //Axis, default = se
  1946. self.axis = axis && axis[1] ? axis[1] : 'se';
  1947. }
  1948. });
  1949. //If we want to auto hide the elements
  1950. if (o.autoHide) {
  1951. this._handles.hide();
  1952. $(this.element)
  1953. .addClass("ui-resizable-autohide")
  1954. .hover(function() {
  1955. if (o.disabled) return;
  1956. $(this).removeClass("ui-resizable-autohide");
  1957. self._handles.show();
  1958. },
  1959. function(){
  1960. if (o.disabled) return;
  1961. if (!self.resizing) {
  1962. $(this).addClass("ui-resizable-autohide");
  1963. self._handles.hide();
  1964. }
  1965. });
  1966. }
  1967. //Initialize the mouse interaction
  1968. this._mouseInit();
  1969. },
  1970. destroy: function() {
  1971. this._mouseDestroy();
  1972. var _destroy = function(exp) {
  1973. $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  1974. .removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove();
  1975. };
  1976. //TODO: Unwrap at same DOM position
  1977. if (this.elementIsWrapper) {
  1978. _destroy(this.element);
  1979. var wrapper = this.element;
  1980. wrapper.after(
  1981. this.originalElement.css({
  1982. position: wrapper.css('position'),
  1983. width: wrapper.outerWidth(),
  1984. height: wrapper.outerHeight(),
  1985. top: wrapper.css('top'),
  1986. left: wrapper.css('left')
  1987. })
  1988. ).remove();
  1989. }
  1990. this.originalElement.css('resize', this.originalResizeStyle);
  1991. _destroy(this.originalElement);
  1992. return this;
  1993. },
  1994. _mouseCapture: function(event) {
  1995. var handle = false;
  1996. for (var i in this.handles) {
  1997. if ($(this.handles[i])[0] == event.target) {
  1998. handle = true;
  1999. }
  2000. }
  2001. return !this.options.disabled && handle;
  2002. },
  2003. _mouseStart: function(event) {
  2004. var o = this.options, iniPos = this.element.position(), el = this.element;
  2005. this.resizing = true;
  2006. this.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() };
  2007. // bugfix for http://dev.jquery.com/ticket/1749
  2008. if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) {
  2009. el.css({ position: 'absolute', top: iniPos.top, left: iniPos.left });
  2010. }
  2011. this._renderProxy();
  2012. var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top'));
  2013. if (o.containment) {
  2014. curleft += $(o.containment).scrollLeft() || 0;
  2015. curtop += $(o.containment).scrollTop() || 0;
  2016. }
  2017. //Store needed variables
  2018. this.offset = this.helper.offset();
  2019. this.position = { left: curleft, top: curtop };
  2020. this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  2021. this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  2022. this.originalPosition = { left: curleft, top: curtop };
  2023. this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
  2024. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  2025. //Aspect Ratio
  2026. this.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
  2027. var cursor = $('.ui-resizable-' + this.axis).css('cursor');
  2028. $('body').css('cursor', cursor == 'auto' ? this.axis + '-resize' : cursor);
  2029. el.addClass("ui-resizable-resizing");
  2030. this._propagate("start", event);
  2031. return true;
  2032. },
  2033. _mouseDrag: function(event) {
  2034. //Increase performance, avoid regex
  2035. var el = this.helper, o = this.options, props = {},
  2036. self = this, smp = this.originalMousePosition, a = this.axis;
  2037. var dx = (event.pageX-smp.left)||0, dy = (event.pageY-smp.top)||0;
  2038. var trigger = this._change[a];
  2039. if (!trigger) return false;
  2040. // Calculate the attrs that will be change
  2041. var data = trigger.apply(this, [event, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff;
  2042. // Put this in the mouseDrag handler since the user can start pressing shift while resizing
  2043. this._updateVirtualBoundaries(event.shiftKey);
  2044. if (this._aspectRatio || event.shiftKey)
  2045. data = this._updateRatio(data, event);
  2046. data = this._respectSize(data, event);
  2047. // plugins callbacks need to be called first
  2048. this._propagate("resize", event);
  2049. el.css({
  2050. top: this.position.top + "px", left: this.position.left + "px",
  2051. width: this.size.width + "px", height: this.size.height + "px"
  2052. });
  2053. if (!this._helper && this._proportionallyResizeElements.length)
  2054. this._proportionallyResize();
  2055. this._updateCache(data);
  2056. // calling the user callback at the end
  2057. this._trigger('resize', event, this.ui());
  2058. return false;
  2059. },
  2060. _mouseStop: function(event) {
  2061. this.resizing = false;
  2062. var o = this.options, self = this;
  2063. if(this._helper) {
  2064. var pr = this._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  2065. soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
  2066. soffsetw = ista ? 0 : self.sizeDiff.width;
  2067. var s = { width: (self.helper.width() - soffsetw), height: (self.helper.height() - soffseth) },
  2068. left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
  2069. top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
  2070. if (!o.animate)
  2071. this.element.css($.extend(s, { top: top, left: left }));
  2072. self.helper.height(self.size.height);
  2073. self.helper.width(self.size.width);
  2074. if (this._helper && !o.animate) this._proportionallyResize();
  2075. }
  2076. $('body').css('cursor', 'auto');
  2077. this.element.removeClass("ui-resizable-resizing");
  2078. this._propagate("stop", event);
  2079. if (this._helper) this.helper.remove();
  2080. return false;
  2081. },
  2082. _updateVirtualBoundaries: function(forceAspectRatio) {
  2083. var o = this.options, pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b;
  2084. b = {
  2085. minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
  2086. maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  2087. minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
  2088. maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
  2089. };
  2090. if(this._aspectRatio || forceAspectRatio) {
  2091. // We want to create an enclosing box whose aspect ration is the requested one
  2092. // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
  2093. pMinWidth = b.minHeight * this.aspectRatio;
  2094. pMinHeight = b.minWidth / this.aspectRatio;
  2095. pMaxWidth = b.maxHeight * this.aspectRatio;
  2096. pMaxHeight = b.maxWidth / this.aspectRatio;
  2097. if(pMinWidth > b.minWidth) b.minWidth = pMinWidth;
  2098. if(pMinHeight > b.minHeight) b.minHeight = pMinHeight;
  2099. if(pMaxWidth < b.maxWidth) b.maxWidth = pMaxWidth;
  2100. if(pMaxHeight < b.maxHeight) b.maxHeight = pMaxHeight;
  2101. }
  2102. this._vBoundaries = b;
  2103. },
  2104. _updateCache: function(data) {
  2105. var o = this.options;
  2106. this.offset = this.helper.offset();
  2107. if (isNumber(data.left)) this.position.left = data.left;
  2108. if (isNumber(data.top)) this.position.top = data.top;
  2109. if (isNumber(data.height)) this.size.height = data.height;
  2110. if (isNumber(data.width)) this.size.width = data.width;
  2111. },
  2112. _updateRatio: function(data, event) {
  2113. var o = this.options, cpos = this.position, csize = this.size, a = this.axis;
  2114. if (isNumber(data.height)) data.width = (data.height * this.aspectRatio);
  2115. else if (isNumber(data.width)) data.height = (data.width / this.aspectRatio);
  2116. if (a == 'sw') {
  2117. data.left = cpos.left + (csize.width - data.width);
  2118. data.top = null;
  2119. }
  2120. if (a == 'nw') {
  2121. data.top = cpos.top + (csize.height - data.height);
  2122. data.left = cpos.left + (csize.width - data.width);
  2123. }
  2124. return data;
  2125. },
  2126. _respectSize: function(data, event) {
  2127. var el = this.helper, o = this._vBoundaries, pRatio = this._aspectRatio || event.shiftKey, a = this.axis,
  2128. ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  2129. isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height);
  2130. if (isminw) data.width = o.minWidth;
  2131. if (isminh) data.height = o.minHeight;
  2132. if (ismaxw) data.width = o.maxWidth;
  2133. if (ismaxh) data.height = o.maxHeight;
  2134. var dw = this.originalPosition.left + this.originalSize.width, dh = this.position.top + this.size.height;
  2135. var cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  2136. if (isminw && cw) data.left = dw - o.minWidth;
  2137. if (ismaxw && cw) data.left = dw - o.maxWidth;
  2138. if (isminh && ch) data.top = dh - o.minHeight;
  2139. if (ismaxh && ch) data.top = dh - o.maxHeight;
  2140. // fixing jump error on top/left - bug #2330
  2141. var isNotwh = !data.width && !data.height;
  2142. if (isNotwh && !data.left && data.top) data.top = null;
  2143. else if (isNotwh && !data.top && data.left) data.left = null;
  2144. return data;
  2145. },
  2146. _proportionallyResize: function() {
  2147. var o = this.options;
  2148. if (!this._proportionallyResizeElements.length) return;
  2149. var element = this.helper || this.element;
  2150. for (var i=0; i < this._proportionallyResizeElements.length; i++) {
  2151. var prel = this._proportionallyResizeElements[i];
  2152. if (!this.borderDif) {
  2153. var b = [prel.css('borderTopWidth'), prel.css('borderRightWidth'), prel.css('borderBottomWidth'), prel.css('borderLeftWidth')],
  2154. p = [prel.css('paddingTop'), prel.css('paddingRight'), prel.css('paddingBottom'), prel.css('paddingLeft')];
  2155. this.borderDif = $.map(b, function(v, i) {
  2156. var border = parseInt(v,10)||0, padding = parseInt(p[i],10)||0;
  2157. return border + padding;
  2158. });
  2159. }
  2160. if ($.browser.msie && !(!($(element).is(':hidden') || $(element).parents(':hidden').length)))
  2161. continue;
  2162. prel.css({
  2163. height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
  2164. width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
  2165. });
  2166. };
  2167. },
  2168. _renderProxy: function() {
  2169. var el = this.element, o = this.options;
  2170. this.elementOffset = el.offset();
  2171. if(this._helper) {
  2172. this.helper = this.helper || $('<div style="overflow:hidden;"></div>');
  2173. // fix ie6 offset TODO: This seems broken
  2174. var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0),
  2175. pxyoffset = ( ie6 ? 2 : -1 );
  2176. this.helper.addClass(this._helper).css({
  2177. width: this.element.outerWidth() + pxyoffset,
  2178. height: this.element.outerHeight() + pxyoffset,
  2179. position: 'absolute',
  2180. left: this.elementOffset.left - ie6offset +'px',
  2181. top: this.elementOffset.top - ie6offset +'px',
  2182. zIndex: ++o.zIndex //TODO: Don't modify option
  2183. });
  2184. this.helper
  2185. .appendTo("body")
  2186. .disableSelection();
  2187. } else {
  2188. this.helper = this.element;
  2189. }
  2190. },
  2191. _change: {
  2192. e: function(event, dx, dy) {
  2193. return { width: this.originalSize.width + dx };
  2194. },
  2195. w: function(event, dx, dy) {
  2196. var o = this.options, cs = this.originalSize, sp = this.originalPosition;
  2197. return { left: sp.left + dx, width: cs.width - dx };
  2198. },
  2199. n: function(event, dx, dy) {
  2200. var o = this.options, cs = this.originalSize, sp = this.originalPosition;
  2201. return { top: sp.top + dy, height: cs.height - dy };
  2202. },
  2203. s: function(event, dx, dy) {
  2204. return { height: this.originalSize.height + dy };
  2205. },
  2206. se: function(event, dx, dy) {
  2207. return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  2208. },
  2209. sw: function(event, dx, dy) {
  2210. return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  2211. },
  2212. ne: function(event, dx, dy) {
  2213. return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  2214. },
  2215. nw: function(event, dx, dy) {
  2216. return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  2217. }
  2218. },
  2219. _propagate: function(n, event) {
  2220. $.ui.plugin.call(this, n, [event, this.ui()]);
  2221. (n != "resize" && this._trigger(n, event, this.ui()));
  2222. },
  2223. plugins: {},
  2224. ui: function() {
  2225. return {
  2226. originalElement: this.originalElement,
  2227. element: this.element,
  2228. helper: this.helper,
  2229. position: this.position,
  2230. size: this.size,
  2231. originalSize: this.originalSize,
  2232. originalPosition: this.originalPosition
  2233. };
  2234. }
  2235. });
  2236. $.extend($.ui.resizable, {
  2237. version: "1.8.21"
  2238. });
  2239. /*
  2240. * Resizable Extensions
  2241. */
  2242. $.ui.plugin.add("resizable", "alsoResize", {
  2243. start: function (event, ui) {
  2244. var self = $(this).data("resizable"), o = self.options;
  2245. var _store = function (exp) {
  2246. $(exp).each(function() {
  2247. var el = $(this);
  2248. el.data("resizable-alsoresize", {
  2249. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  2250. left: parseInt(el.css('left'), 10), top: parseInt(el.css('top'), 10)
  2251. });
  2252. });
  2253. };
  2254. if (typeof(o.alsoResize) == 'object' && !o.alsoResize.parentNode) {
  2255. if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
  2256. else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
  2257. }else{
  2258. _store(o.alsoResize);
  2259. }
  2260. },
  2261. resize: function (event, ui) {
  2262. var self = $(this).data("resizable"), o = self.options, os = self.originalSize, op = self.originalPosition;
  2263. var delta = {
  2264. height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0,
  2265. top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0
  2266. },
  2267. _alsoResize = function (exp, c) {
  2268. $(exp).each(function() {
  2269. var el = $(this), start = $(this).data("resizable-alsoresize"), style = {},
  2270. css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ['width', 'height'] : ['width', 'height', 'top', 'left'];
  2271. $.each(css, function (i, prop) {
  2272. var sum = (start[prop]||0) + (delta[prop]||0);
  2273. if (sum && sum >= 0)
  2274. style[prop] = sum || null;
  2275. });
  2276. el.css(style);
  2277. });
  2278. };
  2279. if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) {
  2280. $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
  2281. }else{
  2282. _alsoResize(o.alsoResize);
  2283. }
  2284. },
  2285. stop: function (event, ui) {
  2286. $(this).removeData("resizable-alsoresize");
  2287. }
  2288. });
  2289. $.ui.plugin.add("resizable", "animate", {
  2290. stop: function(event, ui) {
  2291. var self = $(this).data("resizable"), o = self.options;
  2292. var pr = self._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  2293. soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
  2294. soffsetw = ista ? 0 : self.sizeDiff.width;
  2295. var style = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },
  2296. left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
  2297. top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
  2298. self.element.animate(
  2299. $.extend(style, top && left ? { top: top, left: left } : {}), {
  2300. duration: o.animateDuration,
  2301. easing: o.animateEasing,
  2302. step: function() {
  2303. var data = {
  2304. width: parseInt(self.element.css('width'), 10),
  2305. height: parseInt(self.element.css('height'), 10),
  2306. top: parseInt(self.element.css('top'), 10),
  2307. left: parseInt(self.element.css('left'), 10)
  2308. };
  2309. if (pr && pr.length) $(pr[0]).css({ width: data.width, height: data.height });
  2310. // propagating resize, and updating values for each animation step
  2311. self._updateCache(data);
  2312. self._propagate("resize", event);
  2313. }
  2314. }
  2315. );
  2316. }
  2317. });
  2318. $.ui.plugin.add("resizable", "containment", {
  2319. start: function(event, ui) {
  2320. var self = $(this).data("resizable"), o = self.options, el = self.element;
  2321. var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
  2322. if (!ce) return;
  2323. self.containerElement = $(ce);
  2324. if (/document/.test(oc) || oc == document) {
  2325. self.containerOffset = { left: 0, top: 0 };
  2326. self.containerPosition = { left: 0, top: 0 };
  2327. self.parentData = {
  2328. element: $(document), left: 0, top: 0,
  2329. width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
  2330. };
  2331. }
  2332. // i'm a node, so compute top, left, right, bottom
  2333. else {
  2334. var element = $(ce), p = [];
  2335. $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
  2336. self.containerOffset = element.offset();
  2337. self.containerPosition = element.position();
  2338. self.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
  2339. var co = self.containerOffset, ch = self.containerSize.height, cw = self.containerSize.width,
  2340. width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
  2341. self.parentData = {
  2342. element: ce, left: co.left, top: co.top, width: width, height: height
  2343. };
  2344. }
  2345. },
  2346. resize: function(event, ui) {
  2347. var self = $(this).data("resizable"), o = self.options,
  2348. ps = self.containerSize, co = self.containerOffset, cs = self.size, cp = self.position,
  2349. pRatio = self._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = self.containerElement;
  2350. if (ce[0] != document && (/static/).test(ce.css('position'))) cop = co;
  2351. if (cp.left < (self._helper ? co.left : 0)) {
  2352. self.size.width = self.size.width + (self._helper ? (self.position.left - co.left) : (self.position.left - cop.left));
  2353. if (pRatio) self.size.height = self.size.width / self.aspectRatio;
  2354. self.position.left = o.helper ? co.left : 0;
  2355. }
  2356. if (cp.top < (self._helper ? co.top : 0)) {
  2357. self.size.height = self.size.height + (self._helper ? (self.position.top - co.top) : self.position.top);
  2358. if (pRatio) self.size.width = self.size.height * self.aspectRatio;
  2359. self.position.top = self._helper ? co.top : 0;
  2360. }
  2361. self.offset.left = self.parentData.left+self.position.left;
  2362. self.offset.top = self.parentData.top+self.position.top;
  2363. var woset = Math.abs( (self._helper ? self.offset.left - cop.left : (self.offset.left - cop.left)) + self.sizeDiff.width ),
  2364. hoset = Math.abs( (self._helper ? self.offset.top - cop.top : (self.offset.top - co.top)) + self.sizeDiff.height );
  2365. var isParent = self.containerElement.get(0) == self.element.parent().get(0),
  2366. isOffsetRelative = /relative|absolute/.test(self.containerElement.css('position'));
  2367. if(isParent && isOffsetRelative) woset -= self.parentData.left;
  2368. if (woset + self.size.width >= self.parentData.width) {
  2369. self.size.width = self.parentData.width - woset;
  2370. if (pRatio) self.size.height = self.size.width / self.aspectRatio;
  2371. }
  2372. if (hoset + self.size.height >= self.parentData.height) {
  2373. self.size.height = self.parentData.height - hoset;
  2374. if (pRatio) self.size.width = self.size.height * self.aspectRatio;
  2375. }
  2376. },
  2377. stop: function(event, ui){
  2378. var self = $(this).data("resizable"), o = self.options, cp = self.position,
  2379. co = self.containerOffset, cop = self.containerPosition, ce = self.containerElement;
  2380. var helper = $(self.helper), ho = helper.offset(), w = helper.outerWidth() - self.sizeDiff.width, h = helper.outerHeight() - self.sizeDiff.height;
  2381. if (self._helper && !o.animate && (/relative/).test(ce.css('position')))
  2382. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2383. if (self._helper && !o.animate && (/static/).test(ce.css('position')))
  2384. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2385. }
  2386. });
  2387. $.ui.plugin.add("resizable", "ghost", {
  2388. start: function(event, ui) {
  2389. var self = $(this).data("resizable"), o = self.options, cs = self.size;
  2390. self.ghost = self.originalElement.clone();
  2391. self.ghost
  2392. .css({ opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
  2393. .addClass('ui-resizable-ghost')
  2394. .addClass(typeof o.ghost == 'string' ? o.ghost : '');
  2395. self.ghost.appendTo(self.helper);
  2396. },
  2397. resize: function(event, ui){
  2398. var self = $(this).data("resizable"), o = self.options;
  2399. if (self.ghost) self.ghost.css({ position: 'relative', height: self.size.height, width: self.size.width });
  2400. },
  2401. stop: function(event, ui){
  2402. var self = $(this).data("resizable"), o = self.options;
  2403. if (self.ghost && self.helper) self.helper.get(0).removeChild(self.ghost.get(0));
  2404. }
  2405. });
  2406. $.ui.plugin.add("resizable", "grid", {
  2407. resize: function(event, ui) {
  2408. var self = $(this).data("resizable"), o = self.options, cs = self.size, os = self.originalSize, op = self.originalPosition, a = self.axis, ratio = o._aspectRatio || event.shiftKey;
  2409. o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid;
  2410. var ox = Math.round((cs.width - os.width) / (o.grid[0]||1)) * (o.grid[0]||1), oy = Math.round((cs.height - os.height) / (o.grid[1]||1)) * (o.grid[1]||1);
  2411. if (/^(se|s|e)$/.test(a)) {
  2412. self.size.width = os.width + ox;
  2413. self.size.height = os.height + oy;
  2414. }
  2415. else if (/^(ne)$/.test(a)) {
  2416. self.size.width = os.width + ox;
  2417. self.size.height = os.height + oy;
  2418. self.position.top = op.top - oy;
  2419. }
  2420. else if (/^(sw)$/.test(a)) {
  2421. self.size.width = os.width + ox;
  2422. self.size.height = os.height + oy;
  2423. self.position.left = op.left - ox;
  2424. }
  2425. else {
  2426. self.size.width = os.width + ox;
  2427. self.size.height = os.height + oy;
  2428. self.position.top = op.top - oy;
  2429. self.position.left = op.left - ox;
  2430. }
  2431. }
  2432. });
  2433. var num = function(v) {
  2434. return parseInt(v, 10) || 0;
  2435. };
  2436. var isNumber = function(value) {
  2437. return !isNaN(parseInt(value, 10));
  2438. };
  2439. })(jQuery);
  2440. /*!
  2441. * jQuery UI Selectable 1.8.21
  2442. *
  2443. * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
  2444. * Dual licensed under the MIT or GPL Version 2 licenses.
  2445. * http://jquery.org/license
  2446. *
  2447. * http://docs.jquery.com/UI/Selectables
  2448. *
  2449. * Depends:
  2450. * jquery.ui.core.js
  2451. * jquery.ui.mouse.js
  2452. * jquery.ui.widget.js
  2453. */
  2454. (function( $, undefined ) {
  2455. $.widget("ui.selectable", $.ui.mouse, {
  2456. options: {
  2457. appendTo: 'body',
  2458. autoRefresh: true,
  2459. distance: 0,
  2460. filter: '*',
  2461. tolerance: 'touch'
  2462. },
  2463. _create: function() {
  2464. var self = this;
  2465. this.element.addClass("ui-selectable");
  2466. this.dragged = false;
  2467. // cache selectee children based on filter
  2468. var selectees;
  2469. this.refresh = function() {
  2470. selectees = $(self.options.filter, self.element[0]);
  2471. selectees.addClass("ui-selectee");
  2472. selectees.each(function() {
  2473. var $this = $(this);
  2474. var pos = $this.offset();
  2475. $.data(this, "selectable-item", {
  2476. element: this,
  2477. $element: $this,
  2478. left: pos.left,
  2479. top: pos.top,
  2480. right: pos.left + $this.outerWidth(),
  2481. bottom: pos.top + $this.outerHeight(),
  2482. startselected: false,
  2483. selected: $this.hasClass('ui-selected'),
  2484. selecting: $this.hasClass('ui-selecting'),
  2485. unselecting: $this.hasClass('ui-unselecting')
  2486. });
  2487. });
  2488. };
  2489. this.refresh();
  2490. this.selectees = selectees.addClass("ui-selectee");
  2491. this._mouseInit();
  2492. this.helper = $("<div class='ui-selectable-helper'></div>");
  2493. },
  2494. destroy: function() {
  2495. this.selectees
  2496. .removeClass("ui-selectee")
  2497. .removeData("selectable-item");
  2498. this.element
  2499. .removeClass("ui-selectable ui-selectable-disabled")
  2500. .removeData("selectable")
  2501. .unbind(".selectable");
  2502. this._mouseDestroy();
  2503. return this;
  2504. },
  2505. _mouseStart: function(event) {
  2506. var self = this;
  2507. this.opos = [event.pageX, event.pageY];
  2508. if (this.options.disabled)
  2509. return;
  2510. var options = this.options;
  2511. this.selectees = $(options.filter, this.element[0]);
  2512. this._trigger("start", event);
  2513. $(options.appendTo).append(this.helper);
  2514. // position helper (lasso)
  2515. this.helper.css({
  2516. "left": event.clientX,
  2517. "top": event.clientY,
  2518. "width": 0,
  2519. "height": 0
  2520. });
  2521. if (options.autoRefresh) {
  2522. this.refresh();
  2523. }
  2524. this.selectees.filter('.ui-selected').each(function() {
  2525. var selectee = $.data(this, "selectable-item");
  2526. selectee.startselected = true;
  2527. if (!event.metaKey && !event.ctrlKey) {
  2528. selectee.$element.removeClass('ui-selected');
  2529. selectee.selected = false;
  2530. selectee.$element.addClass('ui-unselecting');
  2531. selectee.unselecting = true;
  2532. // selectable UNSELECTING callback
  2533. self._trigger("unselecting", event, {
  2534. unselecting: selectee.element
  2535. });
  2536. }
  2537. });
  2538. $(event.target).parents().andSelf().each(function() {
  2539. var selectee = $.data(this, "selectable-item");
  2540. if (selectee) {
  2541. var doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass('ui-selected');
  2542. selectee.$element
  2543. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  2544. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  2545. selectee.unselecting = !doSelect;
  2546. selectee.selecting = doSelect;
  2547. selectee.selected = doSelect;
  2548. // selectable (UN)SELECTING callback
  2549. if (doSelect) {
  2550. self._trigger("selecting", event, {
  2551. selecting: selectee.element
  2552. });
  2553. } else {
  2554. self._trigger("unselecting", event, {
  2555. unselecting: selectee.element
  2556. });
  2557. }
  2558. return false;
  2559. }
  2560. });
  2561. },
  2562. _mouseDrag: function(event) {
  2563. var self = this;
  2564. this.dragged = true;
  2565. if (this.options.disabled)
  2566. return;
  2567. var options = this.options;
  2568. var x1 = this.opos[0], y1 = this.opos[1], x2 = event.pageX, y2 = event.pageY;
  2569. if (x1 > x2) { var tmp = x2; x2 = x1; x1 = tmp; }
  2570. if (y1 > y2) { var tmp = y2; y2 = y1; y1 = tmp; }
  2571. this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
  2572. this.selectees.each(function() {
  2573. var selectee = $.data(this, "selectable-item");
  2574. //prevent helper from being selected if appendTo: selectable
  2575. if (!selectee || selectee.element == self.element[0])
  2576. return;
  2577. var hit = false;
  2578. if (options.tolerance == 'touch') {
  2579. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  2580. } else if (options.tolerance == 'fit') {
  2581. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  2582. }
  2583. if (hit) {
  2584. // SELECT
  2585. if (selectee.selected) {
  2586. selectee.$element.removeClass('ui-selected');
  2587. selectee.selected = false;
  2588. }
  2589. if (selectee.unselecting) {
  2590. selectee.$element.removeClass('ui-unselecting');
  2591. selectee.unselecting = false;
  2592. }
  2593. if (!selectee.selecting) {
  2594. selectee.$element.addClass('ui-selecting');
  2595. selectee.selecting = true;
  2596. // selectable SELECTING callback
  2597. self._trigger("selecting", event, {
  2598. selecting: selectee.element
  2599. });
  2600. }
  2601. } else {
  2602. // UNSELECT
  2603. if (selectee.selecting) {
  2604. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  2605. selectee.$element.removeClass('ui-selecting');
  2606. selectee.selecting = false;
  2607. selectee.$element.addClass('ui-selected');
  2608. selectee.selected = true;
  2609. } else {
  2610. selectee.$element.removeClass('ui-selecting');
  2611. selectee.selecting = false;
  2612. if (selectee.startselected) {
  2613. selectee.$element.addClass('ui-unselecting');
  2614. selectee.unselecting = true;
  2615. }
  2616. // selectable UNSELECTING callback
  2617. self._trigger("unselecting", event, {
  2618. unselecting: selectee.element
  2619. });
  2620. }
  2621. }
  2622. if (selectee.selected) {
  2623. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  2624. selectee.$element.removeClass('ui-selected');
  2625. selectee.selected = false;
  2626. selectee.$element.addClass('ui-unselecting');
  2627. selectee.unselecting = true;
  2628. // selectable UNSELECTING callback
  2629. self._trigger("unselecting", event, {
  2630. unselecting: selectee.element
  2631. });
  2632. }
  2633. }
  2634. }
  2635. });
  2636. return false;
  2637. },
  2638. _mouseStop: function(event) {
  2639. var self = this;
  2640. this.dragged = false;
  2641. var options = this.options;
  2642. $('.ui-unselecting', this.element[0]).each(function() {
  2643. var selectee = $.data(this, "selectable-item");
  2644. selectee.$element.removeClass('ui-unselecting');
  2645. selectee.unselecting = false;
  2646. selectee.startselected = false;
  2647. self._trigger("unselected", event, {
  2648. unselected: selectee.element
  2649. });
  2650. });
  2651. $('.ui-selecting', this.element[0]).each(function() {
  2652. var selectee = $.data(this, "selectable-item");
  2653. selectee.$element.removeClass('ui-selecting').addClass('ui-selected');
  2654. selectee.selecting = false;
  2655. selectee.selected = true;
  2656. selectee.startselected = true;
  2657. self._trigger("selected", event, {
  2658. selected: selectee.element
  2659. });
  2660. });
  2661. this._trigger("stop", event);
  2662. this.helper.remove();
  2663. return false;
  2664. }
  2665. });
  2666. $.extend($.ui.selectable, {
  2667. version: "1.8.21"
  2668. });
  2669. })(jQuery);
  2670. /*!
  2671. * jQuery UI Sortable 1.8.21
  2672. *
  2673. * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
  2674. * Dual licensed under the MIT or GPL Version 2 licenses.
  2675. * http://jquery.org/license
  2676. *
  2677. * http://docs.jquery.com/UI/Sortables
  2678. *
  2679. * Depends:
  2680. * jquery.ui.core.js
  2681. * jquery.ui.mouse.js
  2682. * jquery.ui.widget.js
  2683. */
  2684. (function( $, undefined ) {
  2685. $.widget("ui.sortable", $.ui.mouse, {
  2686. widgetEventPrefix: "sort",
  2687. ready: false,
  2688. options: {
  2689. appendTo: "parent",
  2690. axis: false,
  2691. connectWith: false,
  2692. containment: false,
  2693. cursor: 'auto',
  2694. cursorAt: false,
  2695. dropOnEmpty: true,
  2696. forcePlaceholderSize: false,
  2697. forceHelperSize: false,
  2698. grid: false,
  2699. handle: false,
  2700. helper: "original",
  2701. items: '> *',
  2702. opacity: false,
  2703. placeholder: false,
  2704. revert: false,
  2705. scroll: true,
  2706. scrollSensitivity: 20,
  2707. scrollSpeed: 20,
  2708. scope: "default",
  2709. tolerance: "intersect",
  2710. zIndex: 1000
  2711. },
  2712. _create: function() {
  2713. var o = this.options;
  2714. this.containerCache = {};
  2715. this.element.addClass("ui-sortable");
  2716. //Get the items
  2717. this.refresh();
  2718. //Let's determine if the items are being displayed horizontally
  2719. this.floating = this.items.length ? o.axis === 'x' || (/left|right/).test(this.items[0].item.css('float')) || (/inline|table-cell/).test(this.items[0].item.css('display')) : false;
  2720. //Let's determine the parent's offset
  2721. this.offset = this.element.offset();
  2722. //Initialize mouse events for interaction
  2723. this._mouseInit();
  2724. //We're ready to go
  2725. this.ready = true
  2726. },
  2727. destroy: function() {
  2728. $.Widget.prototype.destroy.call( this );
  2729. this.element
  2730. .removeClass("ui-sortable ui-sortable-disabled");
  2731. this._mouseDestroy();
  2732. for ( var i = this.items.length - 1; i >= 0; i-- )
  2733. this.items[i].item.removeData(this.widgetName + "-item");
  2734. return this;
  2735. },
  2736. _setOption: function(key, value){
  2737. if ( key === "disabled" ) {
  2738. this.options[ key ] = value;
  2739. this.widget()
  2740. [ value ? "addClass" : "removeClass"]( "ui-sortable-disabled" );
  2741. } else {
  2742. // Don't call widget base _setOption for disable as it adds ui-state-disabled class
  2743. $.Widget.prototype._setOption.apply(this, arguments);
  2744. }
  2745. },
  2746. _mouseCapture: function(event, overrideHandle) {
  2747. var that = this;
  2748. if (this.reverting) {
  2749. return false;
  2750. }
  2751. if(this.options.disabled || this.options.type == 'static') return false;
  2752. //We have to refresh the items data once first
  2753. this._refreshItems(event);
  2754. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  2755. var currentItem = null, self = this, nodes = $(event.target).parents().each(function() {
  2756. if($.data(this, that.widgetName + '-item') == self) {
  2757. currentItem = $(this);
  2758. return false;
  2759. }
  2760. });
  2761. if($.data(event.target, that.widgetName + '-item') == self) currentItem = $(event.target);
  2762. if(!currentItem) return false;
  2763. if(this.options.handle && !overrideHandle) {
  2764. var validHandle = false;
  2765. $(this.options.handle, currentItem).find("*").andSelf().each(function() { if(this == event.target) validHandle = true; });
  2766. if(!validHandle) return false;
  2767. }
  2768. this.currentItem = currentItem;
  2769. this._removeCurrentsFromItems();
  2770. return true;
  2771. },
  2772. _mouseStart: function(event, overrideHandle, noActivation) {
  2773. var o = this.options, self = this;
  2774. this.currentContainer = this;
  2775. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  2776. this.refreshPositions();
  2777. //Create and append the visible helper
  2778. this.helper = this._createHelper(event);
  2779. //Cache the helper size
  2780. this._cacheHelperProportions();
  2781. /*
  2782. * - Position generation -
  2783. * This block generates everything position related - it's the core of draggables.
  2784. */
  2785. //Cache the margins of the original element
  2786. this._cacheMargins();
  2787. //Get the next scrolling parent
  2788. this.scrollParent = this.helper.scrollParent();
  2789. //The element's absolute position on the page minus margins
  2790. this.offset = this.currentItem.offset();
  2791. this.offset = {
  2792. top: this.offset.top - this.margins.top,
  2793. left: this.offset.left - this.margins.left
  2794. };
  2795. $.extend(this.offset, {
  2796. click: { //Where the click happened, relative to the element
  2797. left: event.pageX - this.offset.left,
  2798. top: event.pageY - this.offset.top
  2799. },
  2800. parent: this._getParentOffset(),
  2801. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  2802. });
  2803. // Only after we got the offset, we can change the helper's position to absolute
  2804. // TODO: Still need to figure out a way to make relative sorting possible
  2805. this.helper.css("position", "absolute");
  2806. this.cssPosition = this.helper.css("position");
  2807. //Generate the original position
  2808. this.originalPosition = this._generatePosition(event);
  2809. this.originalPageX = event.pageX;
  2810. this.originalPageY = event.pageY;
  2811. //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
  2812. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  2813. //Cache the former DOM position
  2814. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  2815. //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
  2816. if(this.helper[0] != this.currentItem[0]) {
  2817. this.currentItem.hide();
  2818. }
  2819. //Create the placeholder
  2820. this._createPlaceholder();
  2821. //Set a containment if given in the options
  2822. if(o.containment)
  2823. this._setContainment();
  2824. if(o.cursor) { // cursor option
  2825. if ($('body').css("cursor")) this._storedCursor = $('body').css("cursor");
  2826. $('body').css("cursor", o.cursor);
  2827. }
  2828. if(o.opacity) { // opacity option
  2829. if (this.helper.css("opacity")) this._storedOpacity = this.helper.css("opacity");
  2830. this.helper.css("opacity", o.opacity);
  2831. }
  2832. if(o.zIndex) { // zIndex option
  2833. if (this.helper.css("zIndex")) this._storedZIndex = this.helper.css("zIndex");
  2834. this.helper.css("zIndex", o.zIndex);
  2835. }
  2836. //Prepare scrolling
  2837. if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML')
  2838. this.overflowOffset = this.scrollParent.offset();
  2839. //Call callbacks
  2840. this._trigger("start", event, this._uiHash());
  2841. //Recache the helper size
  2842. if(!this._preserveHelperProportions)
  2843. this._cacheHelperProportions();
  2844. //Post 'activate' events to possible containers
  2845. if(!noActivation) {
  2846. for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._trigger("activate", event, self._uiHash(this)); }
  2847. }
  2848. //Prepare possible droppables
  2849. if($.ui.ddmanager)
  2850. $.ui.ddmanager.current = this;
  2851. if ($.ui.ddmanager && !o.dropBehaviour)
  2852. $.ui.ddmanager.prepareOffsets(this, event);
  2853. this.dragging = true;
  2854. this.helper.addClass("ui-sortable-helper");
  2855. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  2856. return true;
  2857. },
  2858. _mouseDrag: function(event) {
  2859. //Compute the helpers position
  2860. this.position = this._generatePosition(event);
  2861. this.positionAbs = this._convertPositionTo("absolute");
  2862. if (!this.lastPositionAbs) {
  2863. this.lastPositionAbs = this.positionAbs;
  2864. }
  2865. //Do scrolling
  2866. if(this.options.scroll) {
  2867. var o = this.options, scrolled = false;
  2868. if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
  2869. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
  2870. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  2871. else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
  2872. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  2873. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
  2874. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  2875. else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
  2876. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  2877. } else {
  2878. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
  2879. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  2880. else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
  2881. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  2882. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
  2883. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  2884. else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
  2885. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  2886. }
  2887. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
  2888. $.ui.ddmanager.prepareOffsets(this, event);
  2889. }
  2890. //Regenerate the absolute position used for position checks
  2891. this.positionAbs = this._convertPositionTo("absolute");
  2892. //Set the helper position
  2893. if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
  2894. if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
  2895. //Rearrange
  2896. for (var i = this.items.length - 1; i >= 0; i--) {
  2897. //Cache variables and intersection, continue if no intersection
  2898. var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item);
  2899. if (!intersection) continue;
  2900. if(itemElement != this.currentItem[0] //cannot intersect with itself
  2901. && this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
  2902. && !$.ui.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
  2903. && (this.options.type == 'semi-dynamic' ? !$.ui.contains(this.element[0], itemElement) : true)
  2904. //&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container
  2905. ) {
  2906. this.direction = intersection == 1 ? "down" : "up";
  2907. if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) {
  2908. this._rearrange(event, item);
  2909. } else {
  2910. break;
  2911. }
  2912. this._trigger("change", event, this._uiHash());
  2913. break;
  2914. }
  2915. }
  2916. //Post events to containers
  2917. this._contactContainers(event);
  2918. //Interconnect with droppables
  2919. if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
  2920. //Call callbacks
  2921. this._trigger('sort', event, this._uiHash());
  2922. this.lastPositionAbs = this.positionAbs;
  2923. return false;
  2924. },
  2925. _mouseStop: function(event, noPropagation) {
  2926. if(!event) return;
  2927. //If we are using droppables, inform the manager about the drop
  2928. if ($.ui.ddmanager && !this.options.dropBehaviour)
  2929. $.ui.ddmanager.drop(this, event);
  2930. if(this.options.revert) {
  2931. var self = this;
  2932. var cur = self.placeholder.offset();
  2933. self.reverting = true;
  2934. $(this.helper).animate({
  2935. left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
  2936. top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
  2937. }, parseInt(this.options.revert, 10) || 500, function() {
  2938. self._clear(event);
  2939. });
  2940. } else {
  2941. this._clear(event, noPropagation);
  2942. }
  2943. return false;
  2944. },
  2945. cancel: function() {
  2946. var self = this;
  2947. if(this.dragging) {
  2948. this._mouseUp({ target: null });
  2949. if(this.options.helper == "original")
  2950. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  2951. else
  2952. this.currentItem.show();
  2953. //Post deactivating events to containers
  2954. for (var i = this.containers.length - 1; i >= 0; i--){
  2955. this.containers[i]._trigger("deactivate", null, self._uiHash(this));
  2956. if(this.containers[i].containerCache.over) {
  2957. this.containers[i]._trigger("out", null, self._uiHash(this));
  2958. this.containers[i].containerCache.over = 0;
  2959. }
  2960. }
  2961. }
  2962. if (this.placeholder) {
  2963. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  2964. if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  2965. if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove();
  2966. $.extend(this, {
  2967. helper: null,
  2968. dragging: false,
  2969. reverting: false,
  2970. _noFinalSort: null
  2971. });
  2972. if(this.domPosition.prev) {
  2973. $(this.domPosition.prev).after(this.currentItem);
  2974. } else {
  2975. $(this.domPosition.parent).prepend(this.currentItem);
  2976. }
  2977. }
  2978. return this;
  2979. },
  2980. serialize: function(o) {
  2981. var items = this._getItemsAsjQuery(o && o.connected);
  2982. var str = []; o = o || {};
  2983. $(items).each(function() {
  2984. var res = ($(o.item || this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
  2985. if(res) str.push((o.key || res[1]+'[]')+'='+(o.key && o.expression ? res[1] : res[2]));
  2986. });
  2987. if(!str.length && o.key) {
  2988. str.push(o.key + '=');
  2989. }
  2990. return str.join('&');
  2991. },
  2992. toArray: function(o) {
  2993. var items = this._getItemsAsjQuery(o && o.connected);
  2994. var ret = []; o = o || {};
  2995. items.each(function() { ret.push($(o.item || this).attr(o.attribute || 'id') || ''); });
  2996. return ret;
  2997. },
  2998. /* Be careful with the following core functions */
  2999. _intersectsWith: function(item) {
  3000. var x1 = this.positionAbs.left,
  3001. x2 = x1 + this.helperProportions.width,
  3002. y1 = this.positionAbs.top,
  3003. y2 = y1 + this.helperProportions.height;
  3004. var l = item.left,
  3005. r = l + item.width,
  3006. t = item.top,
  3007. b = t + item.height;
  3008. var dyClick = this.offset.click.top,
  3009. dxClick = this.offset.click.left;
  3010. var isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r;
  3011. if( this.options.tolerance == "pointer"
  3012. || this.options.forcePointerForContainers
  3013. || (this.options.tolerance != "pointer" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])
  3014. ) {
  3015. return isOverElement;
  3016. } else {
  3017. return (l < x1 + (this.helperProportions.width / 2) // Right Half
  3018. && x2 - (this.helperProportions.width / 2) < r // Left Half
  3019. && t < y1 + (this.helperProportions.height / 2) // Bottom Half
  3020. && y2 - (this.helperProportions.height / 2) < b ); // Top Half
  3021. }
  3022. },
  3023. _intersectsWithPointer: function(item) {
  3024. var isOverElementHeight = (this.options.axis === 'x') || $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  3025. isOverElementWidth = (this.options.axis === 'y') || $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  3026. isOverElement = isOverElementHeight && isOverElementWidth,
  3027. verticalDirection = this._getDragVerticalDirection(),
  3028. horizontalDirection = this._getDragHorizontalDirection();
  3029. if (!isOverElement)
  3030. return false;
  3031. return this.floating ?
  3032. ( ((horizontalDirection && horizontalDirection == "right") || verticalDirection == "down") ? 2 : 1 )
  3033. : ( verticalDirection && (verticalDirection == "down" ? 2 : 1) );
  3034. },
  3035. _intersectsWithSides: function(item) {
  3036. var isOverBottomHalf = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  3037. isOverRightHalf = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  3038. verticalDirection = this._getDragVerticalDirection(),
  3039. horizontalDirection = this._getDragHorizontalDirection();
  3040. if (this.floating && horizontalDirection) {
  3041. return ((horizontalDirection == "right" && isOverRightHalf) || (horizontalDirection == "left" && !isOverRightHalf));
  3042. } else {
  3043. return verticalDirection && ((verticalDirection == "down" && isOverBottomHalf) || (verticalDirection == "up" && !isOverBottomHalf));
  3044. }
  3045. },
  3046. _getDragVerticalDirection: function() {
  3047. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  3048. return delta != 0 && (delta > 0 ? "down" : "up");
  3049. },
  3050. _getDragHorizontalDirection: function() {
  3051. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  3052. return delta != 0 && (delta > 0 ? "right" : "left");
  3053. },
  3054. refresh: function(event) {
  3055. this._refreshItems(event);
  3056. this.refreshPositions();
  3057. return this;
  3058. },
  3059. _connectWith: function() {
  3060. var options = this.options;
  3061. return options.connectWith.constructor == String
  3062. ? [options.connectWith]
  3063. : options.connectWith;
  3064. },
  3065. _getItemsAsjQuery: function(connected) {
  3066. var self = this;
  3067. var items = [];
  3068. var queries = [];
  3069. var connectWith = this._connectWith();
  3070. if(connectWith && connected) {
  3071. for (var i = connectWith.length - 1; i >= 0; i--){
  3072. var cur = $(connectWith[i]);
  3073. for (var j = cur.length - 1; j >= 0; j--){
  3074. var inst = $.data(cur[j], this.widgetName);
  3075. if(inst && inst != this && !inst.options.disabled) {
  3076. 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]);
  3077. }
  3078. };
  3079. };
  3080. }
  3081. 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]);
  3082. for (var i = queries.length - 1; i >= 0; i--){
  3083. queries[i][0].each(function() {
  3084. items.push(this);
  3085. });
  3086. };
  3087. return $(items);
  3088. },
  3089. _removeCurrentsFromItems: function() {
  3090. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  3091. for (var i=0; i < this.items.length; i++) {
  3092. for (var j=0; j < list.length; j++) {
  3093. if(list[j] == this.items[i].item[0])
  3094. this.items.splice(i,1);
  3095. };
  3096. };
  3097. },
  3098. _refreshItems: function(event) {
  3099. this.items = [];
  3100. this.containers = [this];
  3101. var items = this.items;
  3102. var self = this;
  3103. var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]];
  3104. var connectWith = this._connectWith();
  3105. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  3106. for (var i = connectWith.length - 1; i >= 0; i--){
  3107. var cur = $(connectWith[i]);
  3108. for (var j = cur.length - 1; j >= 0; j--){
  3109. var inst = $.data(cur[j], this.widgetName);
  3110. if(inst && inst != this && !inst.options.disabled) {
  3111. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  3112. this.containers.push(inst);
  3113. }
  3114. };
  3115. };
  3116. }
  3117. for (var i = queries.length - 1; i >= 0; i--) {
  3118. var targetData = queries[i][1];
  3119. var _queries = queries[i][0];
  3120. for (var j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  3121. var item = $(_queries[j]);
  3122. item.data(this.widgetName + '-item', targetData); // Data for target checking (mouse manager)
  3123. items.push({
  3124. item: item,
  3125. instance: targetData,
  3126. width: 0, height: 0,
  3127. left: 0, top: 0
  3128. });
  3129. };
  3130. };
  3131. },
  3132. refreshPositions: function(fast) {
  3133. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  3134. if(this.offsetParent && this.helper) {
  3135. this.offset.parent = this._getParentOffset();
  3136. }
  3137. for (var i = this.items.length - 1; i >= 0; i--){
  3138. var item = this.items[i];
  3139. //We ignore calculating positions of all connected containers when we're not over them
  3140. if(item.instance != this.currentContainer && this.currentContainer && item.item[0] != this.currentItem[0])
  3141. continue;
  3142. var t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  3143. if (!fast) {
  3144. item.width = t.outerWidth();
  3145. item.height = t.outerHeight();
  3146. }
  3147. var p = t.offset();
  3148. item.left = p.left;
  3149. item.top = p.top;
  3150. };
  3151. if(this.options.custom && this.options.custom.refreshContainers) {
  3152. this.options.custom.refreshContainers.call(this);
  3153. } else {
  3154. for (var i = this.containers.length - 1; i >= 0; i--){
  3155. var p = this.containers[i].element.offset();
  3156. this.containers[i].containerCache.left = p.left;
  3157. this.containers[i].containerCache.top = p.top;
  3158. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  3159. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  3160. };
  3161. }
  3162. return this;
  3163. },
  3164. _createPlaceholder: function(that) {
  3165. var self = that || this, o = self.options;
  3166. if(!o.placeholder || o.placeholder.constructor == String) {
  3167. var className = o.placeholder;
  3168. o.placeholder = {
  3169. element: function() {
  3170. var el = $(document.createElement(self.currentItem[0].nodeName))
  3171. .addClass(className || self.currentItem[0].className+" ui-sortable-placeholder")
  3172. .removeClass("ui-sortable-helper")[0];
  3173. if(!className)
  3174. el.style.visibility = "hidden";
  3175. return el;
  3176. },
  3177. update: function(container, p) {
  3178. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  3179. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  3180. if(className && !o.forcePlaceholderSize) return;
  3181. //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
  3182. if(!p.height()) { p.height(self.currentItem.innerHeight() - parseInt(self.currentItem.css('paddingTop')||0, 10) - parseInt(self.currentItem.css('paddingBottom')||0, 10)); };
  3183. if(!p.width()) { p.width(self.currentItem.innerWidth() - parseInt(self.currentItem.css('paddingLeft')||0, 10) - parseInt(self.currentItem.css('paddingRight')||0, 10)); };
  3184. }
  3185. };
  3186. }
  3187. //Create the placeholder
  3188. self.placeholder = $(o.placeholder.element.call(self.element, self.currentItem));
  3189. //Append it after the actual current item
  3190. self.currentItem.after(self.placeholder);
  3191. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  3192. o.placeholder.update(self, self.placeholder);
  3193. },
  3194. _contactContainers: function(event) {
  3195. // get innermost container that intersects with item
  3196. var innermostContainer = null, innermostIndex = null;
  3197. for (var i = this.containers.length - 1; i >= 0; i--){
  3198. // never consider a container that's located within the item itself
  3199. if($.ui.contains(this.currentItem[0], this.containers[i].element[0]))
  3200. continue;
  3201. if(this._intersectsWith(this.containers[i].containerCache)) {
  3202. // if we've already found a container and it's more "inner" than this, then continue
  3203. if(innermostContainer && $.ui.contains(this.containers[i].element[0], innermostContainer.element[0]))
  3204. continue;
  3205. innermostContainer = this.containers[i];
  3206. innermostIndex = i;
  3207. } else {
  3208. // container doesn't intersect. trigger "out" event if necessary
  3209. if(this.containers[i].containerCache.over) {
  3210. this.containers[i]._trigger("out", event, this._uiHash(this));
  3211. this.containers[i].containerCache.over = 0;
  3212. }
  3213. }
  3214. }
  3215. // if no intersecting containers found, return
  3216. if(!innermostContainer) return;
  3217. // move the item into the container if it's not there already
  3218. if(this.containers.length === 1) {
  3219. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  3220. this.containers[innermostIndex].containerCache.over = 1;
  3221. } else if(this.currentContainer != this.containers[innermostIndex]) {
  3222. //When entering a new container, we will find the item with the least distance and append our item near it
  3223. var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[innermostIndex].floating ? 'left' : 'top'];
  3224. for (var j = this.items.length - 1; j >= 0; j--) {
  3225. if(!$.ui.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue;
  3226. var cur = this.containers[innermostIndex].floating ? this.items[j].item.offset().left : this.items[j].item.offset().top;
  3227. if(Math.abs(cur - base) < dist) {
  3228. dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
  3229. this.direction = (cur - base > 0) ? 'down' : 'up';
  3230. }
  3231. }
  3232. if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled
  3233. return;
  3234. this.currentContainer = this.containers[innermostIndex];
  3235. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  3236. this._trigger("change", event, this._uiHash());
  3237. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  3238. //Update the placeholder
  3239. this.options.placeholder.update(this.currentContainer, this.placeholder);
  3240. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  3241. this.containers[innermostIndex].containerCache.over = 1;
  3242. }
  3243. },
  3244. _createHelper: function(event) {
  3245. var o = this.options;
  3246. var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper == 'clone' ? this.currentItem.clone() : this.currentItem);
  3247. if(!helper.parents('body').length) //Add the helper to the DOM if that didn't happen already
  3248. $(o.appendTo != 'parent' ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  3249. if(helper[0] == this.currentItem[0])
  3250. 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") };
  3251. if(helper[0].style.width == '' || o.forceHelperSize) helper.width(this.currentItem.width());
  3252. if(helper[0].style.height == '' || o.forceHelperSize) helper.height(this.currentItem.height());
  3253. return helper;
  3254. },
  3255. _adjustOffsetFromHelper: function(obj) {
  3256. if (typeof obj == 'string') {
  3257. obj = obj.split(' ');
  3258. }
  3259. if ($.isArray(obj)) {
  3260. obj = {left: +obj[0], top: +obj[1] || 0};
  3261. }
  3262. if ('left' in obj) {
  3263. this.offset.click.left = obj.left + this.margins.left;
  3264. }
  3265. if ('right' in obj) {
  3266. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  3267. }
  3268. if ('top' in obj) {
  3269. this.offset.click.top = obj.top + this.margins.top;
  3270. }
  3271. if ('bottom' in obj) {
  3272. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  3273. }
  3274. },
  3275. _getParentOffset: function() {
  3276. //Get the offsetParent and cache its position
  3277. this.offsetParent = this.helper.offsetParent();
  3278. var po = this.offsetParent.offset();
  3279. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  3280. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  3281. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  3282. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  3283. if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
  3284. po.left += this.scrollParent.scrollLeft();
  3285. po.top += this.scrollParent.scrollTop();
  3286. }
  3287. if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
  3288. || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
  3289. po = { top: 0, left: 0 };
  3290. return {
  3291. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  3292. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  3293. };
  3294. },
  3295. _getRelativeOffset: function() {
  3296. if(this.cssPosition == "relative") {
  3297. var p = this.currentItem.position();
  3298. return {
  3299. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  3300. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  3301. };
  3302. } else {
  3303. return { top: 0, left: 0 };
  3304. }
  3305. },
  3306. _cacheMargins: function() {
  3307. this.margins = {
  3308. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  3309. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  3310. };
  3311. },
  3312. _cacheHelperProportions: function() {
  3313. this.helperProportions = {
  3314. width: this.helper.outerWidth(),
  3315. height: this.helper.outerHeight()
  3316. };
  3317. },
  3318. _setContainment: function() {
  3319. var o = this.options;
  3320. if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
  3321. if(o.containment == 'document' || o.containment == 'window') this.containment = [
  3322. 0 - this.offset.relative.left - this.offset.parent.left,
  3323. 0 - this.offset.relative.top - this.offset.parent.top,
  3324. $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
  3325. ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  3326. ];
  3327. if(!(/^(document|window|parent)$/).test(o.containment)) {
  3328. var ce = $(o.containment)[0];
  3329. var co = $(o.containment).offset();
  3330. var over = ($(ce).css("overflow") != 'hidden');
  3331. this.containment = [
  3332. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  3333. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  3334. 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,
  3335. 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
  3336. ];
  3337. }
  3338. },
  3339. _convertPositionTo: function(d, pos) {
  3340. if(!pos) pos = this.position;
  3341. var mod = d == "absolute" ? 1 : -1;
  3342. var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  3343. return {
  3344. top: (
  3345. pos.top // The absolute mouse position
  3346. + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent
  3347. + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
  3348. - ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  3349. ),
  3350. left: (
  3351. pos.left // The absolute mouse position
  3352. + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent
  3353. + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
  3354. - ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  3355. )
  3356. };
  3357. },
  3358. _generatePosition: function(event) {
  3359. var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  3360. // This is another very weird special case that only happens for relative elements:
  3361. // 1. If the css position is relative
  3362. // 2. and the scroll parent is the document or similar to the offset parent
  3363. // we have to refresh the relative offset during the scroll so there are no jumps
  3364. if(this.cssPosition == 'relative' && !(this.scrollParent[0] != document && this.scrollParent[0] != this.offsetParent[0])) {
  3365. this.offset.relative = this._getRelativeOffset();
  3366. }
  3367. var pageX = event.pageX;
  3368. var pageY = event.pageY;
  3369. /*
  3370. * - Position constraining -
  3371. * Constrain the position to a mix of grid, containment.
  3372. */
  3373. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  3374. if(this.containment) {
  3375. if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left;
  3376. if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top;
  3377. if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left;
  3378. if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top;
  3379. }
  3380. if(o.grid) {
  3381. var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  3382. 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;
  3383. var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  3384. 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;
  3385. }
  3386. }
  3387. return {
  3388. top: (
  3389. pageY // The absolute mouse position
  3390. - this.offset.click.top // Click offset (relative to the element)
  3391. - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent
  3392. - this.offset.parent.top // The offsetParent's offset without borders (offset + border)
  3393. + ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  3394. ),
  3395. left: (
  3396. pageX // The absolute mouse position
  3397. - this.offset.click.left // Click offset (relative to the element)
  3398. - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent
  3399. - this.offset.parent.left // The offsetParent's offset without borders (offset + border)
  3400. + ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  3401. )
  3402. };
  3403. },
  3404. _rearrange: function(event, i, a, hardRefresh) {
  3405. 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));
  3406. //Various things done here to improve the performance:
  3407. // 1. we create a setTimeout, that calls refreshPositions
  3408. // 2. on the instance, we have a counter variable, that get's higher after every append
  3409. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  3410. // 4. this lets only the last addition to the timeout stack through
  3411. this.counter = this.counter ? ++this.counter : 1;
  3412. var self = this, counter = this.counter;
  3413. window.setTimeout(function() {
  3414. if(counter == self.counter) self.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  3415. },0);
  3416. },
  3417. _clear: function(event, noPropagation) {
  3418. this.reverting = false;
  3419. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  3420. // everything else normalized again
  3421. var delayedTriggers = [], self = this;
  3422. // We first have to update the dom position of the actual currentItem
  3423. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  3424. if(!this._noFinalSort && this.currentItem.parent().length) this.placeholder.before(this.currentItem);
  3425. this._noFinalSort = null;
  3426. if(this.helper[0] == this.currentItem[0]) {
  3427. for(var i in this._storedCSS) {
  3428. if(this._storedCSS[i] == 'auto' || this._storedCSS[i] == 'static') this._storedCSS[i] = '';
  3429. }
  3430. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  3431. } else {
  3432. this.currentItem.show();
  3433. }
  3434. if(this.fromOutside && !noPropagation) delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  3435. if((this.fromOutside || this.domPosition.prev != this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) && !noPropagation) delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  3436. if(!$.ui.contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element
  3437. if(!noPropagation) delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  3438. for (var i = this.containers.length - 1; i >= 0; i--){
  3439. if($.ui.contains(this.containers[i].element[0], this.currentItem[0]) && !noPropagation) {
  3440. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  3441. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  3442. }
  3443. };
  3444. };
  3445. //Post events to containers
  3446. for (var i = this.containers.length - 1; i >= 0; i--){
  3447. if(!noPropagation) delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  3448. if(this.containers[i].containerCache.over) {
  3449. delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  3450. this.containers[i].containerCache.over = 0;
  3451. }
  3452. }
  3453. //Do what was originally in plugins
  3454. if(this._storedCursor) $('body').css("cursor", this._storedCursor); //Reset cursor
  3455. if(this._storedOpacity) this.helper.css("opacity", this._storedOpacity); //Reset opacity
  3456. if(this._storedZIndex) this.helper.css("zIndex", this._storedZIndex == 'auto' ? '' : this._storedZIndex); //Reset z-index
  3457. this.dragging = false;
  3458. if(this.cancelHelperRemoval) {
  3459. if(!noPropagation) {
  3460. this._trigger("beforeStop", event, this._uiHash());
  3461. for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
  3462. this._trigger("stop", event, this._uiHash());
  3463. }
  3464. return false;
  3465. }
  3466. if(!noPropagation) this._trigger("beforeStop", event, this._uiHash());
  3467. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  3468. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  3469. if(this.helper[0] != this.currentItem[0]) this.helper.remove(); this.helper = null;
  3470. if(!noPropagation) {
  3471. for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
  3472. this._trigger("stop", event, this._uiHash());
  3473. }
  3474. this.fromOutside = false;
  3475. return true;
  3476. },
  3477. _trigger: function() {
  3478. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  3479. this.cancel();
  3480. }
  3481. },
  3482. _uiHash: function(inst) {
  3483. var self = inst || this;
  3484. return {
  3485. helper: self.helper,
  3486. placeholder: self.placeholder || $([]),
  3487. position: self.position,
  3488. originalPosition: self.originalPosition,
  3489. offset: self.positionAbs,
  3490. item: self.currentItem,
  3491. sender: inst ? inst.element : null
  3492. };
  3493. }
  3494. });
  3495. $.extend($.ui.sortable, {
  3496. version: "1.8.21"
  3497. });
  3498. })(jQuery);
  3499. /*!
  3500. * jQuery UI Autocomplete 1.8.21
  3501. *
  3502. * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
  3503. * Dual licensed under the MIT or GPL Version 2 licenses.
  3504. * http://jquery.org/license
  3505. *
  3506. * http://docs.jquery.com/UI/Autocomplete
  3507. *
  3508. * Depends:
  3509. * jquery.ui.core.js
  3510. * jquery.ui.widget.js
  3511. * jquery.ui.position.js
  3512. */
  3513. (function( $, undefined ) {
  3514. // used to prevent race conditions with remote data sources
  3515. var requestIndex = 0;
  3516. $.widget( "ui.autocomplete", {
  3517. options: {
  3518. appendTo: "body",
  3519. autoFocus: false,
  3520. delay: 300,
  3521. minLength: 1,
  3522. position: {
  3523. my: "left top",
  3524. at: "left bottom",
  3525. collision: "none"
  3526. },
  3527. source: null
  3528. },
  3529. pending: 0,
  3530. _create: function() {
  3531. var self = this,
  3532. doc = this.element[ 0 ].ownerDocument,
  3533. suppressKeyPress;
  3534. this.isMultiLine = this.element.is( "textarea" );
  3535. this.element
  3536. .addClass( "ui-autocomplete-input" )
  3537. .attr( "autocomplete", "off" )
  3538. // TODO verify these actually work as intended
  3539. .attr({
  3540. role: "textbox",
  3541. "aria-autocomplete": "list",
  3542. "aria-haspopup": "true"
  3543. })
  3544. .bind( "keydown.autocomplete", function( event ) {
  3545. if ( self.options.disabled || self.element.propAttr( "readOnly" ) ) {
  3546. return;
  3547. }
  3548. suppressKeyPress = false;
  3549. var keyCode = $.ui.keyCode;
  3550. switch( event.keyCode ) {
  3551. case keyCode.PAGE_UP:
  3552. self._move( "previousPage", event );
  3553. break;
  3554. case keyCode.PAGE_DOWN:
  3555. self._move( "nextPage", event );
  3556. break;
  3557. case keyCode.UP:
  3558. self._keyEvent( "previous", event );
  3559. break;
  3560. case keyCode.DOWN:
  3561. self._keyEvent( "next", event );
  3562. break;
  3563. case keyCode.ENTER:
  3564. case keyCode.NUMPAD_ENTER:
  3565. // when menu is open and has focus
  3566. if ( self.menu.active ) {
  3567. // #6055 - Opera still allows the keypress to occur
  3568. // which causes forms to submit
  3569. suppressKeyPress = true;
  3570. event.preventDefault();
  3571. }
  3572. //passthrough - ENTER and TAB both select the current element
  3573. case keyCode.TAB:
  3574. if ( !self.menu.active ) {
  3575. return;
  3576. }
  3577. self.menu.select( event );
  3578. break;
  3579. case keyCode.ESCAPE:
  3580. self.element.val( self.term );
  3581. self.close( event );
  3582. break;
  3583. default:
  3584. // keypress is triggered before the input value is changed
  3585. clearTimeout( self.searching );
  3586. self.searching = setTimeout(function() {
  3587. // only search if the value has changed
  3588. if ( self.term != self.element.val() ) {
  3589. self.selectedItem = null;
  3590. self.search( null, event );
  3591. }
  3592. }, self.options.delay );
  3593. break;
  3594. }
  3595. })
  3596. .bind( "keypress.autocomplete", function( event ) {
  3597. if ( suppressKeyPress ) {
  3598. suppressKeyPress = false;
  3599. event.preventDefault();
  3600. }
  3601. })
  3602. .bind( "focus.autocomplete", function() {
  3603. if ( self.options.disabled ) {
  3604. return;
  3605. }
  3606. self.selectedItem = null;
  3607. self.previous = self.element.val();
  3608. })
  3609. .bind( "blur.autocomplete", function( event ) {
  3610. if ( self.options.disabled ) {
  3611. return;
  3612. }
  3613. clearTimeout( self.searching );
  3614. // clicks on the menu (or a button to trigger a search) will cause a blur event
  3615. self.closing = setTimeout(function() {
  3616. self.close( event );
  3617. self._change( event );
  3618. }, 150 );
  3619. });
  3620. this._initSource();
  3621. this.menu = $( "<ul></ul>" )
  3622. .addClass( "ui-autocomplete" )
  3623. .appendTo( $( this.options.appendTo || "body", doc )[0] )
  3624. // prevent the close-on-blur in case of a "slow" click on the menu (long mousedown)
  3625. .mousedown(function( event ) {
  3626. // clicking on the scrollbar causes focus to shift to the body
  3627. // but we can't detect a mouseup or a click immediately afterward
  3628. // so we have to track the next mousedown and close the menu if
  3629. // the user clicks somewhere outside of the autocomplete
  3630. var menuElement = self.menu.element[ 0 ];
  3631. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  3632. setTimeout(function() {
  3633. $( document ).one( 'mousedown', function( event ) {
  3634. if ( event.target !== self.element[ 0 ] &&
  3635. event.target !== menuElement &&
  3636. !$.ui.contains( menuElement, event.target ) ) {
  3637. self.close();
  3638. }
  3639. });
  3640. }, 1 );
  3641. }
  3642. // use another timeout to make sure the blur-event-handler on the input was already triggered
  3643. setTimeout(function() {
  3644. clearTimeout( self.closing );
  3645. }, 13);
  3646. })
  3647. .menu({
  3648. focus: function( event, ui ) {
  3649. var item = ui.item.data( "item.autocomplete" );
  3650. if ( false !== self._trigger( "focus", event, { item: item } ) ) {
  3651. // use value to match what will end up in the input, if it was a key event
  3652. if ( /^key/.test(event.originalEvent.type) ) {
  3653. self.element.val( item.value );
  3654. }
  3655. }
  3656. },
  3657. selected: function( event, ui ) {
  3658. var item = ui.item.data( "item.autocomplete" ),
  3659. previous = self.previous;
  3660. // only trigger when focus was lost (click on menu)
  3661. if ( self.element[0] !== doc.activeElement ) {
  3662. self.element.focus();
  3663. self.previous = previous;
  3664. // #6109 - IE triggers two focus events and the second
  3665. // is asynchronous, so we need to reset the previous
  3666. // term synchronously and asynchronously :-(
  3667. setTimeout(function() {
  3668. self.previous = previous;
  3669. self.selectedItem = item;
  3670. }, 1);
  3671. }
  3672. if ( false !== self._trigger( "select", event, { item: item } ) ) {
  3673. self.element.val( item.value );
  3674. }
  3675. // reset the term after the select event
  3676. // this allows custom select handling to work properly
  3677. self.term = self.element.val();
  3678. self.close( event );
  3679. self.selectedItem = item;
  3680. },
  3681. blur: function( event, ui ) {
  3682. // don't set the value of the text field if it's already correct
  3683. // this prevents moving the cursor unnecessarily
  3684. if ( self.menu.element.is(":visible") &&
  3685. ( self.element.val() !== self.term ) ) {
  3686. self.element.val( self.term );
  3687. }
  3688. }
  3689. })
  3690. .zIndex( this.element.zIndex() + 1 )
  3691. // workaround for jQuery bug #5781 http://dev.jquery.com/ticket/5781
  3692. .css({ top: 0, left: 0 })
  3693. .hide()
  3694. .data( "menu" );
  3695. if ( $.fn.bgiframe ) {
  3696. this.menu.element.bgiframe();
  3697. }
  3698. // turning off autocomplete prevents the browser from remembering the
  3699. // value when navigating through history, so we re-enable autocomplete
  3700. // if the page is unloaded before the widget is destroyed. #7790
  3701. self.beforeunloadHandler = function() {
  3702. self.element.removeAttr( "autocomplete" );
  3703. };
  3704. $( window ).bind( "beforeunload", self.beforeunloadHandler );
  3705. },
  3706. destroy: function() {
  3707. this.element
  3708. .removeClass( "ui-autocomplete-input" )
  3709. .removeAttr( "autocomplete" )
  3710. .removeAttr( "role" )
  3711. .removeAttr( "aria-autocomplete" )
  3712. .removeAttr( "aria-haspopup" );
  3713. this.menu.element.remove();
  3714. $( window ).unbind( "beforeunload", this.beforeunloadHandler );
  3715. $.Widget.prototype.destroy.call( this );
  3716. },
  3717. _setOption: function( key, value ) {
  3718. $.Widget.prototype._setOption.apply( this, arguments );
  3719. if ( key === "source" ) {
  3720. this._initSource();
  3721. }
  3722. if ( key === "appendTo" ) {
  3723. this.menu.element.appendTo( $( value || "body", this.element[0].ownerDocument )[0] )
  3724. }
  3725. if ( key === "disabled" && value && this.xhr ) {
  3726. this.xhr.abort();
  3727. }
  3728. },
  3729. _initSource: function() {
  3730. var self = this,
  3731. array,
  3732. url;
  3733. if ( $.isArray(this.options.source) ) {
  3734. array = this.options.source;
  3735. this.source = function( request, response ) {
  3736. response( $.ui.autocomplete.filter(array, request.term) );
  3737. };
  3738. } else if ( typeof this.options.source === "string" ) {
  3739. url = this.options.source;
  3740. this.source = function( request, response ) {
  3741. if ( self.xhr ) {
  3742. self.xhr.abort();
  3743. }
  3744. self.xhr = $.ajax({
  3745. url: url,
  3746. data: request,
  3747. dataType: "json",
  3748. success: function( data, status ) {
  3749. response( data );
  3750. },
  3751. error: function() {
  3752. response( [] );
  3753. }
  3754. });
  3755. };
  3756. } else {
  3757. this.source = this.options.source;
  3758. }
  3759. },
  3760. search: function( value, event ) {
  3761. value = value != null ? value : this.element.val();
  3762. // always save the actual value, not the one passed as an argument
  3763. this.term = this.element.val();
  3764. if ( value.length < this.options.minLength ) {
  3765. return this.close( event );
  3766. }
  3767. clearTimeout( this.closing );
  3768. if ( this._trigger( "search", event ) === false ) {
  3769. return;
  3770. }
  3771. return this._search( value );
  3772. },
  3773. _search: function( value ) {
  3774. this.pending++;
  3775. this.element.addClass( "ui-autocomplete-loading" );
  3776. this.source( { term: value }, this._response() );
  3777. },
  3778. _response: function() {
  3779. var that = this,
  3780. index = ++requestIndex;
  3781. return function( content ) {
  3782. if ( index === requestIndex ) {
  3783. that.__response( content );
  3784. }
  3785. that.pending--;
  3786. if ( !that.pending ) {
  3787. that.element.removeClass( "ui-autocomplete-loading" );
  3788. }
  3789. };
  3790. },
  3791. __response: function( content ) {
  3792. if ( !this.options.disabled && content && content.length ) {
  3793. content = this._normalize( content );
  3794. this._suggest( content );
  3795. this._trigger( "open" );
  3796. } else {
  3797. this.close();
  3798. }
  3799. },
  3800. close: function( event ) {
  3801. clearTimeout( this.closing );
  3802. if ( this.menu.element.is(":visible") ) {
  3803. this.menu.element.hide();
  3804. this.menu.deactivate();
  3805. this._trigger( "close", event );
  3806. }
  3807. },
  3808. _change: function( event ) {
  3809. if ( this.previous !== this.element.val() ) {
  3810. this._trigger( "change", event, { item: this.selectedItem } );
  3811. }
  3812. },
  3813. _normalize: function( items ) {
  3814. // assume all items have the right format when the first item is complete
  3815. if ( items.length && items[0].label && items[0].value ) {
  3816. return items;
  3817. }
  3818. return $.map( items, function(item) {
  3819. if ( typeof item === "string" ) {
  3820. return {
  3821. label: item,
  3822. value: item
  3823. };
  3824. }
  3825. return $.extend({
  3826. label: item.label || item.value,
  3827. value: item.value || item.label
  3828. }, item );
  3829. });
  3830. },
  3831. _suggest: function( items ) {
  3832. var ul = this.menu.element
  3833. .empty()
  3834. .zIndex( this.element.zIndex() + 1 );
  3835. this._renderMenu( ul, items );
  3836. // TODO refresh should check if the active item is still in the dom, removing the need for a manual deactivate
  3837. this.menu.deactivate();
  3838. this.menu.refresh();
  3839. // size and position menu
  3840. ul.show();
  3841. this._resizeMenu();
  3842. ul.position( $.extend({
  3843. of: this.element
  3844. }, this.options.position ));
  3845. if ( this.options.autoFocus ) {
  3846. this.menu.next( new $.Event("mouseover") );
  3847. }
  3848. },
  3849. _resizeMenu: function() {
  3850. var ul = this.menu.element;
  3851. ul.outerWidth( Math.max(
  3852. // Firefox wraps long text (possibly a rounding bug)
  3853. // so we add 1px to avoid the wrapping (#7513)
  3854. ul.width( "" ).outerWidth() + 1,
  3855. this.element.outerWidth()
  3856. ) );
  3857. },
  3858. _renderMenu: function( ul, items ) {
  3859. var self = this;
  3860. $.each( items, function( index, item ) {
  3861. self._renderItem( ul, item );
  3862. });
  3863. },
  3864. _renderItem: function( ul, item) {
  3865. return $( "<li></li>" )
  3866. .data( "item.autocomplete", item )
  3867. .append( $( "<a></a>" ).text( item.label ) )
  3868. .appendTo( ul );
  3869. },
  3870. _move: function( direction, event ) {
  3871. if ( !this.menu.element.is(":visible") ) {
  3872. this.search( null, event );
  3873. return;
  3874. }
  3875. if ( this.menu.first() && /^previous/.test(direction) ||
  3876. this.menu.last() && /^next/.test(direction) ) {
  3877. this.element.val( this.term );
  3878. this.menu.deactivate();
  3879. return;
  3880. }
  3881. this.menu[ direction ]( event );
  3882. },
  3883. widget: function() {
  3884. return this.menu.element;
  3885. },
  3886. _keyEvent: function( keyEvent, event ) {
  3887. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  3888. this._move( keyEvent, event );
  3889. // prevents moving cursor to beginning/end of the text field in some browsers
  3890. event.preventDefault();
  3891. }
  3892. }
  3893. });
  3894. $.extend( $.ui.autocomplete, {
  3895. escapeRegex: function( value ) {
  3896. return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
  3897. },
  3898. filter: function(array, term) {
  3899. var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
  3900. return $.grep( array, function(value) {
  3901. return matcher.test( value.label || value.value || value );
  3902. });
  3903. }
  3904. });
  3905. }( jQuery ));
  3906. /*
  3907. * jQuery UI Menu (not officially released)
  3908. *
  3909. * This widget isn't yet finished and the API is subject to change. We plan to finish
  3910. * it for the next release. You're welcome to give it a try anyway and give us feedback,
  3911. * as long as you're okay with migrating your code later on. We can help with that, too.
  3912. *
  3913. * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
  3914. * Dual licensed under the MIT or GPL Version 2 licenses.
  3915. * http://jquery.org/license
  3916. *
  3917. * http://docs.jquery.com/UI/Menu
  3918. *
  3919. * Depends:
  3920. * jquery.ui.core.js
  3921. * jquery.ui.widget.js
  3922. */
  3923. (function($) {
  3924. $.widget("ui.menu", {
  3925. _create: function() {
  3926. var self = this;
  3927. this.element
  3928. .addClass("ui-menu ui-widget ui-widget-content ui-corner-all")
  3929. .attr({
  3930. role: "listbox",
  3931. "aria-activedescendant": "ui-active-menuitem"
  3932. })
  3933. .click(function( event ) {
  3934. if ( !$( event.target ).closest( ".ui-menu-item a" ).length ) {
  3935. return;
  3936. }
  3937. // temporary
  3938. event.preventDefault();
  3939. self.select( event );
  3940. });
  3941. this.refresh();
  3942. },
  3943. refresh: function() {
  3944. var self = this;
  3945. // don't refresh list items that are already adapted
  3946. var items = this.element.children("li:not(.ui-menu-item):has(a)")
  3947. .addClass("ui-menu-item")
  3948. .attr("role", "menuitem");
  3949. items.children("a")
  3950. .addClass("ui-corner-all")
  3951. .attr("tabindex", -1)
  3952. // mouseenter doesn't work with event delegation
  3953. .mouseenter(function( event ) {
  3954. self.activate( event, $(this).parent() );
  3955. })
  3956. .mouseleave(function() {
  3957. self.deactivate();
  3958. });
  3959. },
  3960. activate: function( event, item ) {
  3961. this.deactivate();
  3962. if (this.hasScroll()) {
  3963. var offset = item.offset().top - this.element.offset().top,
  3964. scroll = this.element.scrollTop(),
  3965. elementHeight = this.element.height();
  3966. if (offset < 0) {
  3967. this.element.scrollTop( scroll + offset);
  3968. } else if (offset >= elementHeight) {
  3969. this.element.scrollTop( scroll + offset - elementHeight + item.height());
  3970. }
  3971. }
  3972. this.active = item.eq(0)
  3973. .children("a")
  3974. .addClass("ui-state-hover")
  3975. .attr("id", "ui-active-menuitem")
  3976. .end();
  3977. this._trigger("focus", event, { item: item });
  3978. },
  3979. deactivate: function() {
  3980. if (!this.active) { return; }
  3981. this.active.children("a")
  3982. .removeClass("ui-state-hover")
  3983. .removeAttr("id");
  3984. this._trigger("blur");
  3985. this.active = null;
  3986. },
  3987. next: function(event) {
  3988. this.move("next", ".ui-menu-item:first", event);
  3989. },
  3990. previous: function(event) {
  3991. this.move("prev", ".ui-menu-item:last", event);
  3992. },
  3993. first: function() {
  3994. return this.active && !this.active.prevAll(".ui-menu-item").length;
  3995. },
  3996. last: function() {
  3997. return this.active && !this.active.nextAll(".ui-menu-item").length;
  3998. },
  3999. move: function(direction, edge, event) {
  4000. if (!this.active) {
  4001. this.activate(event, this.element.children(edge));
  4002. return;
  4003. }
  4004. var next = this.active[direction + "All"](".ui-menu-item").eq(0);
  4005. if (next.length) {
  4006. this.activate(event, next);
  4007. } else {
  4008. this.activate(event, this.element.children(edge));
  4009. }
  4010. },
  4011. // TODO merge with previousPage
  4012. nextPage: function(event) {
  4013. if (this.hasScroll()) {
  4014. // TODO merge with no-scroll-else
  4015. if (!this.active || this.last()) {
  4016. this.activate(event, this.element.children(".ui-menu-item:first"));
  4017. return;
  4018. }
  4019. var base = this.active.offset().top,
  4020. height = this.element.height(),
  4021. result = this.element.children(".ui-menu-item").filter(function() {
  4022. var close = $(this).offset().top - base - height + $(this).height();
  4023. // TODO improve approximation
  4024. return close < 10 && close > -10;
  4025. });
  4026. // TODO try to catch this earlier when scrollTop indicates the last page anyway
  4027. if (!result.length) {
  4028. result = this.element.children(".ui-menu-item:last");
  4029. }
  4030. this.activate(event, result);
  4031. } else {
  4032. this.activate(event, this.element.children(".ui-menu-item")
  4033. .filter(!this.active || this.last() ? ":first" : ":last"));
  4034. }
  4035. },
  4036. // TODO merge with nextPage
  4037. previousPage: function(event) {
  4038. if (this.hasScroll()) {
  4039. // TODO merge with no-scroll-else
  4040. if (!this.active || this.first()) {
  4041. this.activate(event, this.element.children(".ui-menu-item:last"));
  4042. return;
  4043. }
  4044. var base = this.active.offset().top,
  4045. height = this.element.height(),
  4046. result = this.element.children(".ui-menu-item").filter(function() {
  4047. var close = $(this).offset().top - base + height - $(this).height();
  4048. // TODO improve approximation
  4049. return close < 10 && close > -10;
  4050. });
  4051. // TODO try to catch this earlier when scrollTop indicates the last page anyway
  4052. if (!result.length) {
  4053. result = this.element.children(".ui-menu-item:first");
  4054. }
  4055. this.activate(event, result);
  4056. } else {
  4057. this.activate(event, this.element.children(".ui-menu-item")
  4058. .filter(!this.active || this.first() ? ":last" : ":first"));
  4059. }
  4060. },
  4061. hasScroll: function() {
  4062. return this.element.height() < this.element[ $.fn.prop ? "prop" : "attr" ]("scrollHeight");
  4063. },
  4064. select: function( event ) {
  4065. this._trigger("selected", event, { item: this.active });
  4066. }
  4067. });
  4068. }(jQuery));
  4069. /*!
  4070. * jQuery UI Button 1.8.21
  4071. *
  4072. * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
  4073. * Dual licensed under the MIT or GPL Version 2 licenses.
  4074. * http://jquery.org/license
  4075. *
  4076. * http://docs.jquery.com/UI/Button
  4077. *
  4078. * Depends:
  4079. * jquery.ui.core.js
  4080. * jquery.ui.widget.js
  4081. */
  4082. (function( $, undefined ) {
  4083. var lastActive, startXPos, startYPos, clickDragged,
  4084. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  4085. stateClasses = "ui-state-hover ui-state-active ",
  4086. typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
  4087. formResetHandler = function() {
  4088. var buttons = $( this ).find( ":ui-button" );
  4089. setTimeout(function() {
  4090. buttons.button( "refresh" );
  4091. }, 1 );
  4092. },
  4093. radioGroup = function( radio ) {
  4094. var name = radio.name,
  4095. form = radio.form,
  4096. radios = $( [] );
  4097. if ( name ) {
  4098. if ( form ) {
  4099. radios = $( form ).find( "[name='" + name + "']" );
  4100. } else {
  4101. radios = $( "[name='" + name + "']", radio.ownerDocument )
  4102. .filter(function() {
  4103. return !this.form;
  4104. });
  4105. }
  4106. }
  4107. return radios;
  4108. };
  4109. $.widget( "ui.button", {
  4110. options: {
  4111. disabled: null,
  4112. text: true,
  4113. label: null,
  4114. icons: {
  4115. primary: null,
  4116. secondary: null
  4117. }
  4118. },
  4119. _create: function() {
  4120. this.element.closest( "form" )
  4121. .unbind( "reset.button" )
  4122. .bind( "reset.button", formResetHandler );
  4123. if ( typeof this.options.disabled !== "boolean" ) {
  4124. this.options.disabled = !!this.element.propAttr( "disabled" );
  4125. } else {
  4126. this.element.propAttr( "disabled", this.options.disabled );
  4127. }
  4128. this._determineButtonType();
  4129. this.hasTitle = !!this.buttonElement.attr( "title" );
  4130. var self = this,
  4131. options = this.options,
  4132. toggleButton = this.type === "checkbox" || this.type === "radio",
  4133. hoverClass = "ui-state-hover" + ( !toggleButton ? " ui-state-active" : "" ),
  4134. focusClass = "ui-state-focus";
  4135. if ( options.label === null ) {
  4136. options.label = this.buttonElement.html();
  4137. }
  4138. this.buttonElement
  4139. .addClass( baseClasses )
  4140. .attr( "role", "button" )
  4141. .bind( "mouseenter.button", function() {
  4142. if ( options.disabled ) {
  4143. return;
  4144. }
  4145. $( this ).addClass( "ui-state-hover" );
  4146. if ( this === lastActive ) {
  4147. $( this ).addClass( "ui-state-active" );
  4148. }
  4149. })
  4150. .bind( "mouseleave.button", function() {
  4151. if ( options.disabled ) {
  4152. return;
  4153. }
  4154. $( this ).removeClass( hoverClass );
  4155. })
  4156. .bind( "click.button", function( event ) {
  4157. if ( options.disabled ) {
  4158. event.preventDefault();
  4159. event.stopImmediatePropagation();
  4160. }
  4161. });
  4162. this.element
  4163. .bind( "focus.button", function() {
  4164. // no need to check disabled, focus won't be triggered anyway
  4165. self.buttonElement.addClass( focusClass );
  4166. })
  4167. .bind( "blur.button", function() {
  4168. self.buttonElement.removeClass( focusClass );
  4169. });
  4170. if ( toggleButton ) {
  4171. this.element.bind( "change.button", function() {
  4172. if ( clickDragged ) {
  4173. return;
  4174. }
  4175. self.refresh();
  4176. });
  4177. // if mouse moves between mousedown and mouseup (drag) set clickDragged flag
  4178. // prevents issue where button state changes but checkbox/radio checked state
  4179. // does not in Firefox (see ticket #6970)
  4180. this.buttonElement
  4181. .bind( "mousedown.button", function( event ) {
  4182. if ( options.disabled ) {
  4183. return;
  4184. }
  4185. clickDragged = false;
  4186. startXPos = event.pageX;
  4187. startYPos = event.pageY;
  4188. })
  4189. .bind( "mouseup.button", function( event ) {
  4190. if ( options.disabled ) {
  4191. return;
  4192. }
  4193. if ( startXPos !== event.pageX || startYPos !== event.pageY ) {
  4194. clickDragged = true;
  4195. }
  4196. });
  4197. }
  4198. if ( this.type === "checkbox" ) {
  4199. this.buttonElement.bind( "click.button", function() {
  4200. if ( options.disabled || clickDragged ) {
  4201. return false;
  4202. }
  4203. $( this ).toggleClass( "ui-state-active" );
  4204. self.buttonElement.attr( "aria-pressed", self.element[0].checked );
  4205. });
  4206. } else if ( this.type === "radio" ) {
  4207. this.buttonElement.bind( "click.button", function() {
  4208. if ( options.disabled || clickDragged ) {
  4209. return false;
  4210. }
  4211. $( this ).addClass( "ui-state-active" );
  4212. self.buttonElement.attr( "aria-pressed", "true" );
  4213. var radio = self.element[ 0 ];
  4214. radioGroup( radio )
  4215. .not( radio )
  4216. .map(function() {
  4217. return $( this ).button( "widget" )[ 0 ];
  4218. })
  4219. .removeClass( "ui-state-active" )
  4220. .attr( "aria-pressed", "false" );
  4221. });
  4222. } else {
  4223. this.buttonElement
  4224. .bind( "mousedown.button", function() {
  4225. if ( options.disabled ) {
  4226. return false;
  4227. }
  4228. $( this ).addClass( "ui-state-active" );
  4229. lastActive = this;
  4230. $( document ).one( "mouseup", function() {
  4231. lastActive = null;
  4232. });
  4233. })
  4234. .bind( "mouseup.button", function() {
  4235. if ( options.disabled ) {
  4236. return false;
  4237. }
  4238. $( this ).removeClass( "ui-state-active" );
  4239. })
  4240. .bind( "keydown.button", function(event) {
  4241. if ( options.disabled ) {
  4242. return false;
  4243. }
  4244. if ( event.keyCode == $.ui.keyCode.SPACE || event.keyCode == $.ui.keyCode.ENTER ) {
  4245. $( this ).addClass( "ui-state-active" );
  4246. }
  4247. })
  4248. .bind( "keyup.button", function() {
  4249. $( this ).removeClass( "ui-state-active" );
  4250. });
  4251. if ( this.buttonElement.is("a") ) {
  4252. this.buttonElement.keyup(function(event) {
  4253. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  4254. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  4255. $( this ).click();
  4256. }
  4257. });
  4258. }
  4259. }
  4260. // TODO: pull out $.Widget's handling for the disabled option into
  4261. // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
  4262. // be overridden by individual plugins
  4263. this._setOption( "disabled", options.disabled );
  4264. this._resetButton();
  4265. },
  4266. _determineButtonType: function() {
  4267. if ( this.element.is(":checkbox") ) {
  4268. this.type = "checkbox";
  4269. } else if ( this.element.is(":radio") ) {
  4270. this.type = "radio";
  4271. } else if ( this.element.is("input") ) {
  4272. this.type = "input";
  4273. } else {
  4274. this.type = "button";
  4275. }
  4276. if ( this.type === "checkbox" || this.type === "radio" ) {
  4277. // we don't search against the document in case the element
  4278. // is disconnected from the DOM
  4279. var ancestor = this.element.parents().filter(":last"),
  4280. labelSelector = "label[for='" + this.element.attr("id") + "']";
  4281. this.buttonElement = ancestor.find( labelSelector );
  4282. if ( !this.buttonElement.length ) {
  4283. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  4284. this.buttonElement = ancestor.filter( labelSelector );
  4285. if ( !this.buttonElement.length ) {
  4286. this.buttonElement = ancestor.find( labelSelector );
  4287. }
  4288. }
  4289. this.element.addClass( "ui-helper-hidden-accessible" );
  4290. var checked = this.element.is( ":checked" );
  4291. if ( checked ) {
  4292. this.buttonElement.addClass( "ui-state-active" );
  4293. }
  4294. this.buttonElement.attr( "aria-pressed", checked );
  4295. } else {
  4296. this.buttonElement = this.element;
  4297. }
  4298. },
  4299. widget: function() {
  4300. return this.buttonElement;
  4301. },
  4302. destroy: function() {
  4303. this.element
  4304. .removeClass( "ui-helper-hidden-accessible" );
  4305. this.buttonElement
  4306. .removeClass( baseClasses + " " + stateClasses + " " + typeClasses )
  4307. .removeAttr( "role" )
  4308. .removeAttr( "aria-pressed" )
  4309. .html( this.buttonElement.find(".ui-button-text").html() );
  4310. if ( !this.hasTitle ) {
  4311. this.buttonElement.removeAttr( "title" );
  4312. }
  4313. $.Widget.prototype.destroy.call( this );
  4314. },
  4315. _setOption: function( key, value ) {
  4316. $.Widget.prototype._setOption.apply( this, arguments );
  4317. if ( key === "disabled" ) {
  4318. if ( value ) {
  4319. this.element.propAttr( "disabled", true );
  4320. } else {
  4321. this.element.propAttr( "disabled", false );
  4322. }
  4323. return;
  4324. }
  4325. this._resetButton();
  4326. },
  4327. refresh: function() {
  4328. var isDisabled = this.element.is( ":disabled" );
  4329. if ( isDisabled !== this.options.disabled ) {
  4330. this._setOption( "disabled", isDisabled );
  4331. }
  4332. if ( this.type === "radio" ) {
  4333. radioGroup( this.element[0] ).each(function() {
  4334. if ( $( this ).is( ":checked" ) ) {
  4335. $( this ).button( "widget" )
  4336. .addClass( "ui-state-active" )
  4337. .attr( "aria-pressed", "true" );
  4338. } else {
  4339. $( this ).button( "widget" )
  4340. .removeClass( "ui-state-active" )
  4341. .attr( "aria-pressed", "false" );
  4342. }
  4343. });
  4344. } else if ( this.type === "checkbox" ) {
  4345. if ( this.element.is( ":checked" ) ) {
  4346. this.buttonElement
  4347. .addClass( "ui-state-active" )
  4348. .attr( "aria-pressed", "true" );
  4349. } else {
  4350. this.buttonElement
  4351. .removeClass( "ui-state-active" )
  4352. .attr( "aria-pressed", "false" );
  4353. }
  4354. }
  4355. },
  4356. _resetButton: function() {
  4357. if ( this.type === "input" ) {
  4358. if ( this.options.label ) {
  4359. this.element.val( this.options.label );
  4360. }
  4361. return;
  4362. }
  4363. var buttonElement = this.buttonElement.removeClass( typeClasses ),
  4364. buttonText = $( "<span></span>", this.element[0].ownerDocument )
  4365. .addClass( "ui-button-text" )
  4366. .html( this.options.label )
  4367. .appendTo( buttonElement.empty() )
  4368. .text(),
  4369. icons = this.options.icons,
  4370. multipleIcons = icons.primary && icons.secondary,
  4371. buttonClasses = [];
  4372. if ( icons.primary || icons.secondary ) {
  4373. if ( this.options.text ) {
  4374. buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
  4375. }
  4376. if ( icons.primary ) {
  4377. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  4378. }
  4379. if ( icons.secondary ) {
  4380. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  4381. }
  4382. if ( !this.options.text ) {
  4383. buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
  4384. if ( !this.hasTitle ) {
  4385. buttonElement.attr( "title", buttonText );
  4386. }
  4387. }
  4388. } else {
  4389. buttonClasses.push( "ui-button-text-only" );
  4390. }
  4391. buttonElement.addClass( buttonClasses.join( " " ) );
  4392. }
  4393. });
  4394. $.widget( "ui.buttonset", {
  4395. options: {
  4396. items: ":button, :submit, :reset, :checkbox, :radio, a, :data(button)"
  4397. },
  4398. _create: function() {
  4399. this.element.addClass( "ui-buttonset" );
  4400. },
  4401. _init: function() {
  4402. this.refresh();
  4403. },
  4404. _setOption: function( key, value ) {
  4405. if ( key === "disabled" ) {
  4406. this.buttons.button( "option", key, value );
  4407. }
  4408. $.Widget.prototype._setOption.apply( this, arguments );
  4409. },
  4410. refresh: function() {
  4411. var rtl = this.element.css( "direction" ) === "rtl";
  4412. this.buttons = this.element.find( this.options.items )
  4413. .filter( ":ui-button" )
  4414. .button( "refresh" )
  4415. .end()
  4416. .not( ":ui-button" )
  4417. .button()
  4418. .end()
  4419. .map(function() {
  4420. return $( this ).button( "widget" )[ 0 ];
  4421. })
  4422. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  4423. .filter( ":first" )
  4424. .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
  4425. .end()
  4426. .filter( ":last" )
  4427. .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
  4428. .end()
  4429. .end();
  4430. },
  4431. destroy: function() {
  4432. this.element.removeClass( "ui-buttonset" );
  4433. this.buttons
  4434. .map(function() {
  4435. return $( this ).button( "widget" )[ 0 ];
  4436. })
  4437. .removeClass( "ui-corner-left ui-corner-right" )
  4438. .end()
  4439. .button( "destroy" );
  4440. $.Widget.prototype.destroy.call( this );
  4441. }
  4442. });
  4443. }( jQuery ) );
  4444. /*!
  4445. * jQuery UI Slider 1.8.21
  4446. *
  4447. * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
  4448. * Dual licensed under the MIT or GPL Version 2 licenses.
  4449. * http://jquery.org/license
  4450. *
  4451. * http://docs.jquery.com/UI/Slider
  4452. *
  4453. * Depends:
  4454. * jquery.ui.core.js
  4455. * jquery.ui.mouse.js
  4456. * jquery.ui.widget.js
  4457. */
  4458. (function( $, undefined ) {
  4459. // number of pages in a slider
  4460. // (how many times can you page up/down to go through the whole range)
  4461. var numPages = 5;
  4462. $.widget( "ui.slider", $.ui.mouse, {
  4463. widgetEventPrefix: "slide",
  4464. options: {
  4465. animate: false,
  4466. distance: 0,
  4467. max: 100,
  4468. min: 0,
  4469. orientation: "horizontal",
  4470. range: false,
  4471. step: 1,
  4472. value: 0,
  4473. values: null
  4474. },
  4475. _create: function() {
  4476. var self = this,
  4477. o = this.options,
  4478. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  4479. handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
  4480. handleCount = ( o.values && o.values.length ) || 1,
  4481. handles = [];
  4482. this._keySliding = false;
  4483. this._mouseSliding = false;
  4484. this._animateOff = true;
  4485. this._handleIndex = null;
  4486. this._detectOrientation();
  4487. this._mouseInit();
  4488. this.element
  4489. .addClass( "ui-slider" +
  4490. " ui-slider-" + this.orientation +
  4491. " ui-widget" +
  4492. " ui-widget-content" +
  4493. " ui-corner-all" +
  4494. ( o.disabled ? " ui-slider-disabled ui-disabled" : "" ) );
  4495. this.range = $([]);
  4496. if ( o.range ) {
  4497. if ( o.range === true ) {
  4498. if ( !o.values ) {
  4499. o.values = [ this._valueMin(), this._valueMin() ];
  4500. }
  4501. if ( o.values.length && o.values.length !== 2 ) {
  4502. o.values = [ o.values[0], o.values[0] ];
  4503. }
  4504. }
  4505. this.range = $( "<div></div>" )
  4506. .appendTo( this.element )
  4507. .addClass( "ui-slider-range" +
  4508. // note: this isn't the most fittingly semantic framework class for this element,
  4509. // but worked best visually with a variety of themes
  4510. " ui-widget-header" +
  4511. ( ( o.range === "min" || o.range === "max" ) ? " ui-slider-range-" + o.range : "" ) );
  4512. }
  4513. for ( var i = existingHandles.length; i < handleCount; i += 1 ) {
  4514. handles.push( handle );
  4515. }
  4516. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( self.element ) );
  4517. this.handle = this.handles.eq( 0 );
  4518. this.handles.add( this.range ).filter( "a" )
  4519. .click(function( event ) {
  4520. event.preventDefault();
  4521. })
  4522. .hover(function() {
  4523. if ( !o.disabled ) {
  4524. $( this ).addClass( "ui-state-hover" );
  4525. }
  4526. }, function() {
  4527. $( this ).removeClass( "ui-state-hover" );
  4528. })
  4529. .focus(function() {
  4530. if ( !o.disabled ) {
  4531. $( ".ui-slider .ui-state-focus" ).removeClass( "ui-state-focus" );
  4532. $( this ).addClass( "ui-state-focus" );
  4533. } else {
  4534. $( this ).blur();
  4535. }
  4536. })
  4537. .blur(function() {
  4538. $( this ).removeClass( "ui-state-focus" );
  4539. });
  4540. this.handles.each(function( i ) {
  4541. $( this ).data( "index.ui-slider-handle", i );
  4542. });
  4543. this.handles
  4544. .keydown(function( event ) {
  4545. var index = $( this ).data( "index.ui-slider-handle" ),
  4546. allowed,
  4547. curVal,
  4548. newVal,
  4549. step;
  4550. if ( self.options.disabled ) {
  4551. return;
  4552. }
  4553. switch ( event.keyCode ) {
  4554. case $.ui.keyCode.HOME:
  4555. case $.ui.keyCode.END:
  4556. case $.ui.keyCode.PAGE_UP:
  4557. case $.ui.keyCode.PAGE_DOWN:
  4558. case $.ui.keyCode.UP:
  4559. case $.ui.keyCode.RIGHT:
  4560. case $.ui.keyCode.DOWN:
  4561. case $.ui.keyCode.LEFT:
  4562. event.preventDefault();
  4563. if ( !self._keySliding ) {
  4564. self._keySliding = true;
  4565. $( this ).addClass( "ui-state-active" );
  4566. allowed = self._start( event, index );
  4567. if ( allowed === false ) {
  4568. return;
  4569. }
  4570. }
  4571. break;
  4572. }
  4573. step = self.options.step;
  4574. if ( self.options.values && self.options.values.length ) {
  4575. curVal = newVal = self.values( index );
  4576. } else {
  4577. curVal = newVal = self.value();
  4578. }
  4579. switch ( event.keyCode ) {
  4580. case $.ui.keyCode.HOME:
  4581. newVal = self._valueMin();
  4582. break;
  4583. case $.ui.keyCode.END:
  4584. newVal = self._valueMax();
  4585. break;
  4586. case $.ui.keyCode.PAGE_UP:
  4587. newVal = self._trimAlignValue( curVal + ( (self._valueMax() - self._valueMin()) / numPages ) );
  4588. break;
  4589. case $.ui.keyCode.PAGE_DOWN:
  4590. newVal = self._trimAlignValue( curVal - ( (self._valueMax() - self._valueMin()) / numPages ) );
  4591. break;
  4592. case $.ui.keyCode.UP:
  4593. case $.ui.keyCode.RIGHT:
  4594. if ( curVal === self._valueMax() ) {
  4595. return;
  4596. }
  4597. newVal = self._trimAlignValue( curVal + step );
  4598. break;
  4599. case $.ui.keyCode.DOWN:
  4600. case $.ui.keyCode.LEFT:
  4601. if ( curVal === self._valueMin() ) {
  4602. return;
  4603. }
  4604. newVal = self._trimAlignValue( curVal - step );
  4605. break;
  4606. }
  4607. self._slide( event, index, newVal );
  4608. })
  4609. .keyup(function( event ) {
  4610. var index = $( this ).data( "index.ui-slider-handle" );
  4611. if ( self._keySliding ) {
  4612. self._keySliding = false;
  4613. self._stop( event, index );
  4614. self._change( event, index );
  4615. $( this ).removeClass( "ui-state-active" );
  4616. }
  4617. });
  4618. this._refreshValue();
  4619. this._animateOff = false;
  4620. },
  4621. destroy: function() {
  4622. this.handles.remove();
  4623. this.range.remove();
  4624. this.element
  4625. .removeClass( "ui-slider" +
  4626. " ui-slider-horizontal" +
  4627. " ui-slider-vertical" +
  4628. " ui-slider-disabled" +
  4629. " ui-widget" +
  4630. " ui-widget-content" +
  4631. " ui-corner-all" )
  4632. .removeData( "slider" )
  4633. .unbind( ".slider" );
  4634. this._mouseDestroy();
  4635. return this;
  4636. },
  4637. _mouseCapture: function( event ) {
  4638. var o = this.options,
  4639. position,
  4640. normValue,
  4641. distance,
  4642. closestHandle,
  4643. self,
  4644. index,
  4645. allowed,
  4646. offset,
  4647. mouseOverHandle;
  4648. if ( o.disabled ) {
  4649. return false;
  4650. }
  4651. this.elementSize = {
  4652. width: this.element.outerWidth(),
  4653. height: this.element.outerHeight()
  4654. };
  4655. this.elementOffset = this.element.offset();
  4656. position = { x: event.pageX, y: event.pageY };
  4657. normValue = this._normValueFromMouse( position );
  4658. distance = this._valueMax() - this._valueMin() + 1;
  4659. self = this;
  4660. this.handles.each(function( i ) {
  4661. var thisDistance = Math.abs( normValue - self.values(i) );
  4662. if ( distance > thisDistance ) {
  4663. distance = thisDistance;
  4664. closestHandle = $( this );
  4665. index = i;
  4666. }
  4667. });
  4668. // workaround for bug #3736 (if both handles of a range are at 0,
  4669. // the first is always used as the one with least distance,
  4670. // and moving it is obviously prevented by preventing negative ranges)
  4671. if( o.range === true && this.values(1) === o.min ) {
  4672. index += 1;
  4673. closestHandle = $( this.handles[index] );
  4674. }
  4675. allowed = this._start( event, index );
  4676. if ( allowed === false ) {
  4677. return false;
  4678. }
  4679. this._mouseSliding = true;
  4680. self._handleIndex = index;
  4681. closestHandle
  4682. .addClass( "ui-state-active" )
  4683. .focus();
  4684. offset = closestHandle.offset();
  4685. mouseOverHandle = !$( event.target ).parents().andSelf().is( ".ui-slider-handle" );
  4686. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  4687. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  4688. top: event.pageY - offset.top -
  4689. ( closestHandle.height() / 2 ) -
  4690. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  4691. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  4692. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  4693. };
  4694. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  4695. this._slide( event, index, normValue );
  4696. }
  4697. this._animateOff = true;
  4698. return true;
  4699. },
  4700. _mouseStart: function( event ) {
  4701. return true;
  4702. },
  4703. _mouseDrag: function( event ) {
  4704. var position = { x: event.pageX, y: event.pageY },
  4705. normValue = this._normValueFromMouse( position );
  4706. this._slide( event, this._handleIndex, normValue );
  4707. return false;
  4708. },
  4709. _mouseStop: function( event ) {
  4710. this.handles.removeClass( "ui-state-active" );
  4711. this._mouseSliding = false;
  4712. this._stop( event, this._handleIndex );
  4713. this._change( event, this._handleIndex );
  4714. this._handleIndex = null;
  4715. this._clickOffset = null;
  4716. this._animateOff = false;
  4717. return false;
  4718. },
  4719. _detectOrientation: function() {
  4720. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  4721. },
  4722. _normValueFromMouse: function( position ) {
  4723. var pixelTotal,
  4724. pixelMouse,
  4725. percentMouse,
  4726. valueTotal,
  4727. valueMouse;
  4728. if ( this.orientation === "horizontal" ) {
  4729. pixelTotal = this.elementSize.width;
  4730. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  4731. } else {
  4732. pixelTotal = this.elementSize.height;
  4733. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  4734. }
  4735. percentMouse = ( pixelMouse / pixelTotal );
  4736. if ( percentMouse > 1 ) {
  4737. percentMouse = 1;
  4738. }
  4739. if ( percentMouse < 0 ) {
  4740. percentMouse = 0;
  4741. }
  4742. if ( this.orientation === "vertical" ) {
  4743. percentMouse = 1 - percentMouse;
  4744. }
  4745. valueTotal = this._valueMax() - this._valueMin();
  4746. valueMouse = this._valueMin() + percentMouse * valueTotal;
  4747. return this._trimAlignValue( valueMouse );
  4748. },
  4749. _start: function( event, index ) {
  4750. var uiHash = {
  4751. handle: this.handles[ index ],
  4752. value: this.value()
  4753. };
  4754. if ( this.options.values && this.options.values.length ) {
  4755. uiHash.value = this.values( index );
  4756. uiHash.values = this.values();
  4757. }
  4758. return this._trigger( "start", event, uiHash );
  4759. },
  4760. _slide: function( event, index, newVal ) {
  4761. var otherVal,
  4762. newValues,
  4763. allowed;
  4764. if ( this.options.values && this.options.values.length ) {
  4765. otherVal = this.values( index ? 0 : 1 );
  4766. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  4767. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  4768. ) {
  4769. newVal = otherVal;
  4770. }
  4771. if ( newVal !== this.values( index ) ) {
  4772. newValues = this.values();
  4773. newValues[ index ] = newVal;
  4774. // A slide can be canceled by returning false from the slide callback
  4775. allowed = this._trigger( "slide", event, {
  4776. handle: this.handles[ index ],
  4777. value: newVal,
  4778. values: newValues
  4779. } );
  4780. otherVal = this.values( index ? 0 : 1 );
  4781. if ( allowed !== false ) {
  4782. this.values( index, newVal, true );
  4783. }
  4784. }
  4785. } else {
  4786. if ( newVal !== this.value() ) {
  4787. // A slide can be canceled by returning false from the slide callback
  4788. allowed = this._trigger( "slide", event, {
  4789. handle: this.handles[ index ],
  4790. value: newVal
  4791. } );
  4792. if ( allowed !== false ) {
  4793. this.value( newVal );
  4794. }
  4795. }
  4796. }
  4797. },
  4798. _stop: function( event, index ) {
  4799. var uiHash = {
  4800. handle: this.handles[ index ],
  4801. value: this.value()
  4802. };
  4803. if ( this.options.values && this.options.values.length ) {
  4804. uiHash.value = this.values( index );
  4805. uiHash.values = this.values();
  4806. }
  4807. this._trigger( "stop", event, uiHash );
  4808. },
  4809. _change: function( event, index ) {
  4810. if ( !this._keySliding && !this._mouseSliding ) {
  4811. var uiHash = {
  4812. handle: this.handles[ index ],
  4813. value: this.value()
  4814. };
  4815. if ( this.options.values && this.options.values.length ) {
  4816. uiHash.value = this.values( index );
  4817. uiHash.values = this.values();
  4818. }
  4819. this._trigger( "change", event, uiHash );
  4820. }
  4821. },
  4822. value: function( newValue ) {
  4823. if ( arguments.length ) {
  4824. this.options.value = this._trimAlignValue( newValue );
  4825. this._refreshValue();
  4826. this._change( null, 0 );
  4827. return;
  4828. }
  4829. return this._value();
  4830. },
  4831. values: function( index, newValue ) {
  4832. var vals,
  4833. newValues,
  4834. i;
  4835. if ( arguments.length > 1 ) {
  4836. this.options.values[ index ] = this._trimAlignValue( newValue );
  4837. this._refreshValue();
  4838. this._change( null, index );
  4839. return;
  4840. }
  4841. if ( arguments.length ) {
  4842. if ( $.isArray( arguments[ 0 ] ) ) {
  4843. vals = this.options.values;
  4844. newValues = arguments[ 0 ];
  4845. for ( i = 0; i < vals.length; i += 1 ) {
  4846. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  4847. this._change( null, i );
  4848. }
  4849. this._refreshValue();
  4850. } else {
  4851. if ( this.options.values && this.options.values.length ) {
  4852. return this._values( index );
  4853. } else {
  4854. return this.value();
  4855. }
  4856. }
  4857. } else {
  4858. return this._values();
  4859. }
  4860. },
  4861. _setOption: function( key, value ) {
  4862. var i,
  4863. valsLength = 0;
  4864. if ( $.isArray( this.options.values ) ) {
  4865. valsLength = this.options.values.length;
  4866. }
  4867. $.Widget.prototype._setOption.apply( this, arguments );
  4868. switch ( key ) {
  4869. case "disabled":
  4870. if ( value ) {
  4871. this.handles.filter( ".ui-state-focus" ).blur();
  4872. this.handles.removeClass( "ui-state-hover" );
  4873. this.handles.propAttr( "disabled", true );
  4874. this.element.addClass( "ui-disabled" );
  4875. } else {
  4876. this.handles.propAttr( "disabled", false );
  4877. this.element.removeClass( "ui-disabled" );
  4878. }
  4879. break;
  4880. case "orientation":
  4881. this._detectOrientation();
  4882. this.element
  4883. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  4884. .addClass( "ui-slider-" + this.orientation );
  4885. this._refreshValue();
  4886. break;
  4887. case "value":
  4888. this._animateOff = true;
  4889. this._refreshValue();
  4890. this._change( null, 0 );
  4891. this._animateOff = false;
  4892. break;
  4893. case "values":
  4894. this._animateOff = true;
  4895. this._refreshValue();
  4896. for ( i = 0; i < valsLength; i += 1 ) {
  4897. this._change( null, i );
  4898. }
  4899. this._animateOff = false;
  4900. break;
  4901. }
  4902. },
  4903. //internal value getter
  4904. // _value() returns value trimmed by min and max, aligned by step
  4905. _value: function() {
  4906. var val = this.options.value;
  4907. val = this._trimAlignValue( val );
  4908. return val;
  4909. },
  4910. //internal values getter
  4911. // _values() returns array of values trimmed by min and max, aligned by step
  4912. // _values( index ) returns single value trimmed by min and max, aligned by step
  4913. _values: function( index ) {
  4914. var val,
  4915. vals,
  4916. i;
  4917. if ( arguments.length ) {
  4918. val = this.options.values[ index ];
  4919. val = this._trimAlignValue( val );
  4920. return val;
  4921. } else {
  4922. // .slice() creates a copy of the array
  4923. // this copy gets trimmed by min and max and then returned
  4924. vals = this.options.values.slice();
  4925. for ( i = 0; i < vals.length; i+= 1) {
  4926. vals[ i ] = this._trimAlignValue( vals[ i ] );
  4927. }
  4928. return vals;
  4929. }
  4930. },
  4931. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  4932. _trimAlignValue: function( val ) {
  4933. if ( val <= this._valueMin() ) {
  4934. return this._valueMin();
  4935. }
  4936. if ( val >= this._valueMax() ) {
  4937. return this._valueMax();
  4938. }
  4939. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  4940. valModStep = (val - this._valueMin()) % step,
  4941. alignValue = val - valModStep;
  4942. if ( Math.abs(valModStep) * 2 >= step ) {
  4943. alignValue += ( valModStep > 0 ) ? step : ( -step );
  4944. }
  4945. // Since JavaScript has problems with large floats, round
  4946. // the final value to 5 digits after the decimal point (see #4124)
  4947. return parseFloat( alignValue.toFixed(5) );
  4948. },
  4949. _valueMin: function() {
  4950. return this.options.min;
  4951. },
  4952. _valueMax: function() {
  4953. return this.options.max;
  4954. },
  4955. _refreshValue: function() {
  4956. var oRange = this.options.range,
  4957. o = this.options,
  4958. self = this,
  4959. animate = ( !this._animateOff ) ? o.animate : false,
  4960. valPercent,
  4961. _set = {},
  4962. lastValPercent,
  4963. value,
  4964. valueMin,
  4965. valueMax;
  4966. if ( this.options.values && this.options.values.length ) {
  4967. this.handles.each(function( i, j ) {
  4968. valPercent = ( self.values(i) - self._valueMin() ) / ( self._valueMax() - self._valueMin() ) * 100;
  4969. _set[ self.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  4970. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  4971. if ( self.options.range === true ) {
  4972. if ( self.orientation === "horizontal" ) {
  4973. if ( i === 0 ) {
  4974. self.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  4975. }
  4976. if ( i === 1 ) {
  4977. self.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  4978. }
  4979. } else {
  4980. if ( i === 0 ) {
  4981. self.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  4982. }
  4983. if ( i === 1 ) {
  4984. self.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  4985. }
  4986. }
  4987. }
  4988. lastValPercent = valPercent;
  4989. });
  4990. } else {
  4991. value = this.value();
  4992. valueMin = this._valueMin();
  4993. valueMax = this._valueMax();
  4994. valPercent = ( valueMax !== valueMin ) ?
  4995. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  4996. 0;
  4997. _set[ self.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  4998. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  4999. if ( oRange === "min" && this.orientation === "horizontal" ) {
  5000. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  5001. }
  5002. if ( oRange === "max" && this.orientation === "horizontal" ) {
  5003. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  5004. }
  5005. if ( oRange === "min" && this.orientation === "vertical" ) {
  5006. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  5007. }
  5008. if ( oRange === "max" && this.orientation === "vertical" ) {
  5009. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  5010. }
  5011. }
  5012. }
  5013. });
  5014. $.extend( $.ui.slider, {
  5015. version: "1.8.21"
  5016. });
  5017. }(jQuery));
  5018. /*!
  5019. * jQuery UI Progressbar 1.8.21
  5020. *
  5021. * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
  5022. * Dual licensed under the MIT or GPL Version 2 licenses.
  5023. * http://jquery.org/license
  5024. *
  5025. * http://docs.jquery.com/UI/Progressbar
  5026. *
  5027. * Depends:
  5028. * jquery.ui.core.js
  5029. * jquery.ui.widget.js
  5030. */
  5031. (function( $, undefined ) {
  5032. $.widget( "ui.progressbar", {
  5033. options: {
  5034. value: 0,
  5035. max: 100
  5036. },
  5037. min: 0,
  5038. _create: function() {
  5039. this.element
  5040. .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  5041. .attr({
  5042. role: "progressbar",
  5043. "aria-valuemin": this.min,
  5044. "aria-valuemax": this.options.max,
  5045. "aria-valuenow": this._value()
  5046. });
  5047. this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
  5048. .appendTo( this.element );
  5049. this.oldValue = this._value();
  5050. this._refreshValue();
  5051. },
  5052. destroy: function() {
  5053. this.element
  5054. .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  5055. .removeAttr( "role" )
  5056. .removeAttr( "aria-valuemin" )
  5057. .removeAttr( "aria-valuemax" )
  5058. .removeAttr( "aria-valuenow" );
  5059. this.valueDiv.remove();
  5060. $.Widget.prototype.destroy.apply( this, arguments );
  5061. },
  5062. value: function( newValue ) {
  5063. if ( newValue === undefined ) {
  5064. return this._value();
  5065. }
  5066. this._setOption( "value", newValue );
  5067. return this;
  5068. },
  5069. _setOption: function( key, value ) {
  5070. if ( key === "value" ) {
  5071. this.options.value = value;
  5072. this._refreshValue();
  5073. if ( this._value() === this.options.max ) {
  5074. this._trigger( "complete" );
  5075. }
  5076. }
  5077. $.Widget.prototype._setOption.apply( this, arguments );
  5078. },
  5079. _value: function() {
  5080. var val = this.options.value;
  5081. // normalize invalid value
  5082. if ( typeof val !== "number" ) {
  5083. val = 0;
  5084. }
  5085. return Math.min( this.options.max, Math.max( this.min, val ) );
  5086. },
  5087. _percentage: function() {
  5088. return 100 * this._value() / this.options.max;
  5089. },
  5090. _refreshValue: function() {
  5091. var value = this.value();
  5092. var percentage = this._percentage();
  5093. if ( this.oldValue !== value ) {
  5094. this.oldValue = value;
  5095. this._trigger( "change" );
  5096. }
  5097. this.valueDiv
  5098. .toggle( value > this.min )
  5099. .toggleClass( "ui-corner-right", value === this.options.max )
  5100. .width( percentage.toFixed(0) + "%" );
  5101. this.element.attr( "aria-valuenow", value );
  5102. }
  5103. });
  5104. $.extend( $.ui.progressbar, {
  5105. version: "1.8.21"
  5106. });
  5107. })( jQuery );