jquery-ui-1.8.20.js 362 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464
  1. /*! jQuery UI - v1.8.20 - 2012-04-30
  2. * https://github.com/jquery/jquery-ui
  3. * Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.effects.core.js, jquery.effects.blind.js, jquery.effects.bounce.js, jquery.effects.clip.js, jquery.effects.drop.js, jquery.effects.explode.js, jquery.effects.fade.js, jquery.effects.fold.js, jquery.effects.highlight.js, jquery.effects.pulsate.js, jquery.effects.scale.js, jquery.effects.shake.js, jquery.effects.slide.js, jquery.effects.transfer.js, jquery.ui.accordion.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.datepicker.js, jquery.ui.dialog.js, jquery.ui.position.js, jquery.ui.progressbar.js, jquery.ui.slider.js, jquery.ui.tabs.js
  4. * Copyright (c) 2012 AUTHORS.txt; Licensed MIT */
  5. (function( $, undefined ) {
  6. // prevent duplicate loading
  7. // this is only a problem because we proxy existing functions
  8. // and we don't want to double proxy them
  9. $.ui = $.ui || {};
  10. if ( $.ui.version ) {
  11. return;
  12. }
  13. $.extend( $.ui, {
  14. version: "1.8.20",
  15. keyCode: {
  16. ALT: 18,
  17. BACKSPACE: 8,
  18. CAPS_LOCK: 20,
  19. COMMA: 188,
  20. COMMAND: 91,
  21. COMMAND_LEFT: 91, // COMMAND
  22. COMMAND_RIGHT: 93,
  23. CONTROL: 17,
  24. DELETE: 46,
  25. DOWN: 40,
  26. END: 35,
  27. ENTER: 13,
  28. ESCAPE: 27,
  29. HOME: 36,
  30. INSERT: 45,
  31. LEFT: 37,
  32. MENU: 93, // COMMAND_RIGHT
  33. NUMPAD_ADD: 107,
  34. NUMPAD_DECIMAL: 110,
  35. NUMPAD_DIVIDE: 111,
  36. NUMPAD_ENTER: 108,
  37. NUMPAD_MULTIPLY: 106,
  38. NUMPAD_SUBTRACT: 109,
  39. PAGE_DOWN: 34,
  40. PAGE_UP: 33,
  41. PERIOD: 190,
  42. RIGHT: 39,
  43. SHIFT: 16,
  44. SPACE: 32,
  45. TAB: 9,
  46. UP: 38,
  47. WINDOWS: 91 // COMMAND
  48. }
  49. });
  50. // plugins
  51. $.fn.extend({
  52. propAttr: $.fn.prop || $.fn.attr,
  53. _focus: $.fn.focus,
  54. focus: function( delay, fn ) {
  55. return typeof delay === "number" ?
  56. this.each(function() {
  57. var elem = this;
  58. setTimeout(function() {
  59. $( elem ).focus();
  60. if ( fn ) {
  61. fn.call( elem );
  62. }
  63. }, delay );
  64. }) :
  65. this._focus.apply( this, arguments );
  66. },
  67. scrollParent: function() {
  68. var scrollParent;
  69. if (($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
  70. scrollParent = this.parents().filter(function() {
  71. 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));
  72. }).eq(0);
  73. } else {
  74. scrollParent = this.parents().filter(function() {
  75. return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
  76. }).eq(0);
  77. }
  78. return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
  79. },
  80. zIndex: function( zIndex ) {
  81. if ( zIndex !== undefined ) {
  82. return this.css( "zIndex", zIndex );
  83. }
  84. if ( this.length ) {
  85. var elem = $( this[ 0 ] ), position, value;
  86. while ( elem.length && elem[ 0 ] !== document ) {
  87. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  88. // This makes behavior of this function consistent across browsers
  89. // WebKit always returns auto if the element is positioned
  90. position = elem.css( "position" );
  91. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  92. // IE returns 0 when zIndex is not specified
  93. // other browsers return a string
  94. // we ignore the case of nested elements with an explicit value of 0
  95. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  96. value = parseInt( elem.css( "zIndex" ), 10 );
  97. if ( !isNaN( value ) && value !== 0 ) {
  98. return value;
  99. }
  100. }
  101. elem = elem.parent();
  102. }
  103. }
  104. return 0;
  105. },
  106. disableSelection: function() {
  107. return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
  108. ".ui-disableSelection", function( event ) {
  109. event.preventDefault();
  110. });
  111. },
  112. enableSelection: function() {
  113. return this.unbind( ".ui-disableSelection" );
  114. }
  115. });
  116. $.each( [ "Width", "Height" ], function( i, name ) {
  117. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  118. type = name.toLowerCase(),
  119. orig = {
  120. innerWidth: $.fn.innerWidth,
  121. innerHeight: $.fn.innerHeight,
  122. outerWidth: $.fn.outerWidth,
  123. outerHeight: $.fn.outerHeight
  124. };
  125. function reduce( elem, size, border, margin ) {
  126. $.each( side, function() {
  127. size -= parseFloat( $.curCSS( elem, "padding" + this, true) ) || 0;
  128. if ( border ) {
  129. size -= parseFloat( $.curCSS( elem, "border" + this + "Width", true) ) || 0;
  130. }
  131. if ( margin ) {
  132. size -= parseFloat( $.curCSS( elem, "margin" + this, true) ) || 0;
  133. }
  134. });
  135. return size;
  136. }
  137. $.fn[ "inner" + name ] = function( size ) {
  138. if ( size === undefined ) {
  139. return orig[ "inner" + name ].call( this );
  140. }
  141. return this.each(function() {
  142. $( this ).css( type, reduce( this, size ) + "px" );
  143. });
  144. };
  145. $.fn[ "outer" + name] = function( size, margin ) {
  146. if ( typeof size !== "number" ) {
  147. return orig[ "outer" + name ].call( this, size );
  148. }
  149. return this.each(function() {
  150. $( this).css( type, reduce( this, size, true, margin ) + "px" );
  151. });
  152. };
  153. });
  154. // selectors
  155. function focusable( element, isTabIndexNotNaN ) {
  156. var nodeName = element.nodeName.toLowerCase();
  157. if ( "area" === nodeName ) {
  158. var map = element.parentNode,
  159. mapName = map.name,
  160. img;
  161. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  162. return false;
  163. }
  164. img = $( "img[usemap=#" + mapName + "]" )[0];
  165. return !!img && visible( img );
  166. }
  167. return ( /input|select|textarea|button|object/.test( nodeName )
  168. ? !element.disabled
  169. : "a" == nodeName
  170. ? element.href || isTabIndexNotNaN
  171. : isTabIndexNotNaN)
  172. // the element and all of its ancestors must be visible
  173. && visible( element );
  174. }
  175. function visible( element ) {
  176. return !$( element ).parents().andSelf().filter(function() {
  177. return $.curCSS( this, "visibility" ) === "hidden" ||
  178. $.expr.filters.hidden( this );
  179. }).length;
  180. }
  181. $.extend( $.expr[ ":" ], {
  182. data: function( elem, i, match ) {
  183. return !!$.data( elem, match[ 3 ] );
  184. },
  185. focusable: function( element ) {
  186. return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
  187. },
  188. tabbable: function( element ) {
  189. var tabIndex = $.attr( element, "tabindex" ),
  190. isTabIndexNaN = isNaN( tabIndex );
  191. return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
  192. }
  193. });
  194. // support
  195. $(function() {
  196. var body = document.body,
  197. div = body.appendChild( div = document.createElement( "div" ) );
  198. // access offsetHeight before setting the style to prevent a layout bug
  199. // in IE 9 which causes the elemnt to continue to take up space even
  200. // after it is removed from the DOM (#8026)
  201. div.offsetHeight;
  202. $.extend( div.style, {
  203. minHeight: "100px",
  204. height: "auto",
  205. padding: 0,
  206. borderWidth: 0
  207. });
  208. $.support.minHeight = div.offsetHeight === 100;
  209. $.support.selectstart = "onselectstart" in div;
  210. // set display to none to avoid a layout bug in IE
  211. // http://dev.jquery.com/ticket/4014
  212. body.removeChild( div ).style.display = "none";
  213. });
  214. // deprecated
  215. $.extend( $.ui, {
  216. // $.ui.plugin is deprecated. Use the proxy pattern instead.
  217. plugin: {
  218. add: function( module, option, set ) {
  219. var proto = $.ui[ module ].prototype;
  220. for ( var i in set ) {
  221. proto.plugins[ i ] = proto.plugins[ i ] || [];
  222. proto.plugins[ i ].push( [ option, set[ i ] ] );
  223. }
  224. },
  225. call: function( instance, name, args ) {
  226. var set = instance.plugins[ name ];
  227. if ( !set || !instance.element[ 0 ].parentNode ) {
  228. return;
  229. }
  230. for ( var i = 0; i < set.length; i++ ) {
  231. if ( instance.options[ set[ i ][ 0 ] ] ) {
  232. set[ i ][ 1 ].apply( instance.element, args );
  233. }
  234. }
  235. }
  236. },
  237. // will be deprecated when we switch to jQuery 1.4 - use jQuery.contains()
  238. contains: function( a, b ) {
  239. return document.compareDocumentPosition ?
  240. a.compareDocumentPosition( b ) & 16 :
  241. a !== b && a.contains( b );
  242. },
  243. // only used by resizable
  244. hasScroll: function( el, a ) {
  245. //If overflow is hidden, the element might have extra content, but the user wants to hide it
  246. if ( $( el ).css( "overflow" ) === "hidden") {
  247. return false;
  248. }
  249. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  250. has = false;
  251. if ( el[ scroll ] > 0 ) {
  252. return true;
  253. }
  254. // TODO: determine which cases actually cause this to happen
  255. // if the element doesn't have the scroll set, see if it's possible to
  256. // set the scroll
  257. el[ scroll ] = 1;
  258. has = ( el[ scroll ] > 0 );
  259. el[ scroll ] = 0;
  260. return has;
  261. },
  262. // these are odd functions, fix the API or move into individual plugins
  263. isOverAxis: function( x, reference, size ) {
  264. //Determines when x coordinate is over "b" element axis
  265. return ( x > reference ) && ( x < ( reference + size ) );
  266. },
  267. isOver: function( y, x, top, left, height, width ) {
  268. //Determines when x, y coordinates is over "b" element
  269. return $.ui.isOverAxis( y, top, height ) && $.ui.isOverAxis( x, left, width );
  270. }
  271. });
  272. })( jQuery );
  273. (function( $, undefined ) {
  274. // jQuery 1.4+
  275. if ( $.cleanData ) {
  276. var _cleanData = $.cleanData;
  277. $.cleanData = function( elems ) {
  278. for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
  279. try {
  280. $( elem ).triggerHandler( "remove" );
  281. // http://bugs.jquery.com/ticket/8235
  282. } catch( e ) {}
  283. }
  284. _cleanData( elems );
  285. };
  286. } else {
  287. var _remove = $.fn.remove;
  288. $.fn.remove = function( selector, keepData ) {
  289. return this.each(function() {
  290. if ( !keepData ) {
  291. if ( !selector || $.filter( selector, [ this ] ).length ) {
  292. $( "*", this ).add( [ this ] ).each(function() {
  293. try {
  294. $( this ).triggerHandler( "remove" );
  295. // http://bugs.jquery.com/ticket/8235
  296. } catch( e ) {}
  297. });
  298. }
  299. }
  300. return _remove.call( $(this), selector, keepData );
  301. });
  302. };
  303. }
  304. $.widget = function( name, base, prototype ) {
  305. var namespace = name.split( "." )[ 0 ],
  306. fullName;
  307. name = name.split( "." )[ 1 ];
  308. fullName = namespace + "-" + name;
  309. if ( !prototype ) {
  310. prototype = base;
  311. base = $.Widget;
  312. }
  313. // create selector for plugin
  314. $.expr[ ":" ][ fullName ] = function( elem ) {
  315. return !!$.data( elem, name );
  316. };
  317. $[ namespace ] = $[ namespace ] || {};
  318. $[ namespace ][ name ] = function( options, element ) {
  319. // allow instantiation without initializing for simple inheritance
  320. if ( arguments.length ) {
  321. this._createWidget( options, element );
  322. }
  323. };
  324. var basePrototype = new base();
  325. // we need to make the options hash a property directly on the new instance
  326. // otherwise we'll modify the options hash on the prototype that we're
  327. // inheriting from
  328. // $.each( basePrototype, function( key, val ) {
  329. // if ( $.isPlainObject(val) ) {
  330. // basePrototype[ key ] = $.extend( {}, val );
  331. // }
  332. // });
  333. basePrototype.options = $.extend( true, {}, basePrototype.options );
  334. $[ namespace ][ name ].prototype = $.extend( true, basePrototype, {
  335. namespace: namespace,
  336. widgetName: name,
  337. widgetEventPrefix: $[ namespace ][ name ].prototype.widgetEventPrefix || name,
  338. widgetBaseClass: fullName
  339. }, prototype );
  340. $.widget.bridge( name, $[ namespace ][ name ] );
  341. };
  342. $.widget.bridge = function( name, object ) {
  343. $.fn[ name ] = function( options ) {
  344. var isMethodCall = typeof options === "string",
  345. args = Array.prototype.slice.call( arguments, 1 ),
  346. returnValue = this;
  347. // allow multiple hashes to be passed on init
  348. options = !isMethodCall && args.length ?
  349. $.extend.apply( null, [ true, options ].concat(args) ) :
  350. options;
  351. // prevent calls to internal methods
  352. if ( isMethodCall && options.charAt( 0 ) === "_" ) {
  353. return returnValue;
  354. }
  355. if ( isMethodCall ) {
  356. this.each(function() {
  357. var instance = $.data( this, name ),
  358. methodValue = instance && $.isFunction( instance[options] ) ?
  359. instance[ options ].apply( instance, args ) :
  360. instance;
  361. // TODO: add this back in 1.9 and use $.error() (see #5972)
  362. // if ( !instance ) {
  363. // throw "cannot call methods on " + name + " prior to initialization; " +
  364. // "attempted to call method '" + options + "'";
  365. // }
  366. // if ( !$.isFunction( instance[options] ) ) {
  367. // throw "no such method '" + options + "' for " + name + " widget instance";
  368. // }
  369. // var methodValue = instance[ options ].apply( instance, args );
  370. if ( methodValue !== instance && methodValue !== undefined ) {
  371. returnValue = methodValue;
  372. return false;
  373. }
  374. });
  375. } else {
  376. this.each(function() {
  377. var instance = $.data( this, name );
  378. if ( instance ) {
  379. instance.option( options || {} )._init();
  380. } else {
  381. $.data( this, name, new object( options, this ) );
  382. }
  383. });
  384. }
  385. return returnValue;
  386. };
  387. };
  388. $.Widget = function( options, element ) {
  389. // allow instantiation without initializing for simple inheritance
  390. if ( arguments.length ) {
  391. this._createWidget( options, element );
  392. }
  393. };
  394. $.Widget.prototype = {
  395. widgetName: "widget",
  396. widgetEventPrefix: "",
  397. options: {
  398. disabled: false
  399. },
  400. _createWidget: function( options, element ) {
  401. // $.widget.bridge stores the plugin instance, but we do it anyway
  402. // so that it's stored even before the _create function runs
  403. $.data( element, this.widgetName, this );
  404. this.element = $( element );
  405. this.options = $.extend( true, {},
  406. this.options,
  407. this._getCreateOptions(),
  408. options );
  409. var self = this;
  410. this.element.bind( "remove." + this.widgetName, function() {
  411. self.destroy();
  412. });
  413. this._create();
  414. this._trigger( "create" );
  415. this._init();
  416. },
  417. _getCreateOptions: function() {
  418. return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ];
  419. },
  420. _create: function() {},
  421. _init: function() {},
  422. destroy: function() {
  423. this.element
  424. .unbind( "." + this.widgetName )
  425. .removeData( this.widgetName );
  426. this.widget()
  427. .unbind( "." + this.widgetName )
  428. .removeAttr( "aria-disabled" )
  429. .removeClass(
  430. this.widgetBaseClass + "-disabled " +
  431. "ui-state-disabled" );
  432. },
  433. widget: function() {
  434. return this.element;
  435. },
  436. option: function( key, value ) {
  437. var options = key;
  438. if ( arguments.length === 0 ) {
  439. // don't return a reference to the internal hash
  440. return $.extend( {}, this.options );
  441. }
  442. if (typeof key === "string" ) {
  443. if ( value === undefined ) {
  444. return this.options[ key ];
  445. }
  446. options = {};
  447. options[ key ] = value;
  448. }
  449. this._setOptions( options );
  450. return this;
  451. },
  452. _setOptions: function( options ) {
  453. var self = this;
  454. $.each( options, function( key, value ) {
  455. self._setOption( key, value );
  456. });
  457. return this;
  458. },
  459. _setOption: function( key, value ) {
  460. this.options[ key ] = value;
  461. if ( key === "disabled" ) {
  462. this.widget()
  463. [ value ? "addClass" : "removeClass"](
  464. this.widgetBaseClass + "-disabled" + " " +
  465. "ui-state-disabled" )
  466. .attr( "aria-disabled", value );
  467. }
  468. return this;
  469. },
  470. enable: function() {
  471. return this._setOption( "disabled", false );
  472. },
  473. disable: function() {
  474. return this._setOption( "disabled", true );
  475. },
  476. _trigger: function( type, event, data ) {
  477. var prop, orig,
  478. callback = this.options[ type ];
  479. data = data || {};
  480. event = $.Event( event );
  481. event.type = ( type === this.widgetEventPrefix ?
  482. type :
  483. this.widgetEventPrefix + type ).toLowerCase();
  484. // the original event may come from any element
  485. // so we need to reset the target on the new event
  486. event.target = this.element[ 0 ];
  487. // copy original event properties over to the new event
  488. orig = event.originalEvent;
  489. if ( orig ) {
  490. for ( prop in orig ) {
  491. if ( !( prop in event ) ) {
  492. event[ prop ] = orig[ prop ];
  493. }
  494. }
  495. }
  496. this.element.trigger( event, data );
  497. return !( $.isFunction(callback) &&
  498. callback.call( this.element[0], event, data ) === false ||
  499. event.isDefaultPrevented() );
  500. }
  501. };
  502. })( jQuery );
  503. (function( $, undefined ) {
  504. var mouseHandled = false;
  505. $( document ).mouseup( function( e ) {
  506. mouseHandled = false;
  507. });
  508. $.widget("ui.mouse", {
  509. options: {
  510. cancel: ':input,option',
  511. distance: 1,
  512. delay: 0
  513. },
  514. _mouseInit: function() {
  515. var self = this;
  516. this.element
  517. .bind('mousedown.'+this.widgetName, function(event) {
  518. return self._mouseDown(event);
  519. })
  520. .bind('click.'+this.widgetName, function(event) {
  521. if (true === $.data(event.target, self.widgetName + '.preventClickEvent')) {
  522. $.removeData(event.target, self.widgetName + '.preventClickEvent');
  523. event.stopImmediatePropagation();
  524. return false;
  525. }
  526. });
  527. this.started = false;
  528. },
  529. // TODO: make sure destroying one instance of mouse doesn't mess with
  530. // other instances of mouse
  531. _mouseDestroy: function() {
  532. this.element.unbind('.'+this.widgetName);
  533. $(document)
  534. .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
  535. .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
  536. },
  537. _mouseDown: function(event) {
  538. // don't let more than one widget handle mouseStart
  539. if( mouseHandled ) { return };
  540. // we may have missed mouseup (out of window)
  541. (this._mouseStarted && this._mouseUp(event));
  542. this._mouseDownEvent = event;
  543. var self = this,
  544. btnIsLeft = (event.which == 1),
  545. // event.target.nodeName works around a bug in IE 8 with
  546. // disabled inputs (#7620)
  547. elIsCancel = (typeof this.options.cancel == "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
  548. if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
  549. return true;
  550. }
  551. this.mouseDelayMet = !this.options.delay;
  552. if (!this.mouseDelayMet) {
  553. this._mouseDelayTimer = setTimeout(function() {
  554. self.mouseDelayMet = true;
  555. }, this.options.delay);
  556. }
  557. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  558. this._mouseStarted = (this._mouseStart(event) !== false);
  559. if (!this._mouseStarted) {
  560. event.preventDefault();
  561. return true;
  562. }
  563. }
  564. // Click event may never have fired (Gecko & Opera)
  565. if (true === $.data(event.target, this.widgetName + '.preventClickEvent')) {
  566. $.removeData(event.target, this.widgetName + '.preventClickEvent');
  567. }
  568. // these delegates are required to keep context
  569. this._mouseMoveDelegate = function(event) {
  570. return self._mouseMove(event);
  571. };
  572. this._mouseUpDelegate = function(event) {
  573. return self._mouseUp(event);
  574. };
  575. $(document)
  576. .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
  577. .bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
  578. event.preventDefault();
  579. mouseHandled = true;
  580. return true;
  581. },
  582. _mouseMove: function(event) {
  583. // IE mouseup check - mouseup happened when mouse was out of window
  584. if ($.browser.msie && !(document.documentMode >= 9) && !event.button) {
  585. return this._mouseUp(event);
  586. }
  587. if (this._mouseStarted) {
  588. this._mouseDrag(event);
  589. return event.preventDefault();
  590. }
  591. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  592. this._mouseStarted =
  593. (this._mouseStart(this._mouseDownEvent, event) !== false);
  594. (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
  595. }
  596. return !this._mouseStarted;
  597. },
  598. _mouseUp: function(event) {
  599. $(document)
  600. .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
  601. .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
  602. if (this._mouseStarted) {
  603. this._mouseStarted = false;
  604. if (event.target == this._mouseDownEvent.target) {
  605. $.data(event.target, this.widgetName + '.preventClickEvent', true);
  606. }
  607. this._mouseStop(event);
  608. }
  609. return false;
  610. },
  611. _mouseDistanceMet: function(event) {
  612. return (Math.max(
  613. Math.abs(this._mouseDownEvent.pageX - event.pageX),
  614. Math.abs(this._mouseDownEvent.pageY - event.pageY)
  615. ) >= this.options.distance
  616. );
  617. },
  618. _mouseDelayMet: function(event) {
  619. return this.mouseDelayMet;
  620. },
  621. // These are placeholder methods, to be overriden by extending plugin
  622. _mouseStart: function(event) {},
  623. _mouseDrag: function(event) {},
  624. _mouseStop: function(event) {},
  625. _mouseCapture: function(event) { return true; }
  626. });
  627. })(jQuery);
  628. (function( $, undefined ) {
  629. $.widget("ui.draggable", $.ui.mouse, {
  630. widgetEventPrefix: "drag",
  631. options: {
  632. addClasses: true,
  633. appendTo: "parent",
  634. axis: false,
  635. connectToSortable: false,
  636. containment: false,
  637. cursor: "auto",
  638. cursorAt: false,
  639. grid: false,
  640. handle: false,
  641. helper: "original",
  642. iframeFix: false,
  643. opacity: false,
  644. refreshPositions: false,
  645. revert: false,
  646. revertDuration: 500,
  647. scope: "default",
  648. scroll: true,
  649. scrollSensitivity: 20,
  650. scrollSpeed: 20,
  651. snap: false,
  652. snapMode: "both",
  653. snapTolerance: 20,
  654. stack: false,
  655. zIndex: false
  656. },
  657. _create: function() {
  658. if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position")))
  659. this.element[0].style.position = 'relative';
  660. (this.options.addClasses && this.element.addClass("ui-draggable"));
  661. (this.options.disabled && this.element.addClass("ui-draggable-disabled"));
  662. this._mouseInit();
  663. },
  664. destroy: function() {
  665. if(!this.element.data('draggable')) return;
  666. this.element
  667. .removeData("draggable")
  668. .unbind(".draggable")
  669. .removeClass("ui-draggable"
  670. + " ui-draggable-dragging"
  671. + " ui-draggable-disabled");
  672. this._mouseDestroy();
  673. return this;
  674. },
  675. _mouseCapture: function(event) {
  676. var o = this.options;
  677. // among others, prevent a drag on a resizable-handle
  678. if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle'))
  679. return false;
  680. //Quit if we're not on a valid handle
  681. this.handle = this._getHandle(event);
  682. if (!this.handle)
  683. return false;
  684. if ( o.iframeFix ) {
  685. $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
  686. $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')
  687. .css({
  688. width: this.offsetWidth+"px", height: this.offsetHeight+"px",
  689. position: "absolute", opacity: "0.001", zIndex: 1000
  690. })
  691. .css($(this).offset())
  692. .appendTo("body");
  693. });
  694. }
  695. return true;
  696. },
  697. _mouseStart: function(event) {
  698. var o = this.options;
  699. //Create and append the visible helper
  700. this.helper = this._createHelper(event);
  701. //Cache the helper size
  702. this._cacheHelperProportions();
  703. //If ddmanager is used for droppables, set the global draggable
  704. if($.ui.ddmanager)
  705. $.ui.ddmanager.current = this;
  706. /*
  707. * - Position generation -
  708. * This block generates everything position related - it's the core of draggables.
  709. */
  710. //Cache the margins of the original element
  711. this._cacheMargins();
  712. //Store the helper's css position
  713. this.cssPosition = this.helper.css("position");
  714. this.scrollParent = this.helper.scrollParent();
  715. //The element's absolute position on the page minus margins
  716. this.offset = this.positionAbs = this.element.offset();
  717. this.offset = {
  718. top: this.offset.top - this.margins.top,
  719. left: this.offset.left - this.margins.left
  720. };
  721. $.extend(this.offset, {
  722. click: { //Where the click happened, relative to the element
  723. left: event.pageX - this.offset.left,
  724. top: event.pageY - this.offset.top
  725. },
  726. parent: this._getParentOffset(),
  727. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  728. });
  729. //Generate the original position
  730. this.originalPosition = this.position = this._generatePosition(event);
  731. this.originalPageX = event.pageX;
  732. this.originalPageY = event.pageY;
  733. //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
  734. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  735. //Set a containment if given in the options
  736. if(o.containment)
  737. this._setContainment();
  738. //Trigger event + callbacks
  739. if(this._trigger("start", event) === false) {
  740. this._clear();
  741. return false;
  742. }
  743. //Recache the helper size
  744. this._cacheHelperProportions();
  745. //Prepare the droppable offsets
  746. if ($.ui.ddmanager && !o.dropBehaviour)
  747. $.ui.ddmanager.prepareOffsets(this, event);
  748. this.helper.addClass("ui-draggable-dragging");
  749. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  750. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  751. if ( $.ui.ddmanager ) $.ui.ddmanager.dragStart(this, event);
  752. return true;
  753. },
  754. _mouseDrag: function(event, noPropagation) {
  755. //Compute the helpers position
  756. this.position = this._generatePosition(event);
  757. this.positionAbs = this._convertPositionTo("absolute");
  758. //Call plugins and callbacks and use the resulting position if something is returned
  759. if (!noPropagation) {
  760. var ui = this._uiHash();
  761. if(this._trigger('drag', event, ui) === false) {
  762. this._mouseUp({});
  763. return false;
  764. }
  765. this.position = ui.position;
  766. }
  767. if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
  768. if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
  769. if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
  770. return false;
  771. },
  772. _mouseStop: function(event) {
  773. //If we are using droppables, inform the manager about the drop
  774. var dropped = false;
  775. if ($.ui.ddmanager && !this.options.dropBehaviour)
  776. dropped = $.ui.ddmanager.drop(this, event);
  777. //if a drop comes from outside (a sortable)
  778. if(this.dropped) {
  779. dropped = this.dropped;
  780. this.dropped = false;
  781. }
  782. //if the original element is no longer in the DOM don't bother to continue (see #8269)
  783. var element = this.element[0], elementInDom = false;
  784. while ( element && (element = element.parentNode) ) {
  785. if (element == document ) {
  786. elementInDom = true;
  787. }
  788. }
  789. if ( !elementInDom && this.options.helper === "original" )
  790. return false;
  791. 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))) {
  792. var self = this;
  793. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  794. if(self._trigger("stop", event) !== false) {
  795. self._clear();
  796. }
  797. });
  798. } else {
  799. if(this._trigger("stop", event) !== false) {
  800. this._clear();
  801. }
  802. }
  803. return false;
  804. },
  805. _mouseUp: function(event) {
  806. if (this.options.iframeFix === true) {
  807. $("div.ui-draggable-iframeFix").each(function() {
  808. this.parentNode.removeChild(this);
  809. }); //Remove frame helpers
  810. }
  811. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  812. if( $.ui.ddmanager ) $.ui.ddmanager.dragStop(this, event);
  813. return $.ui.mouse.prototype._mouseUp.call(this, event);
  814. },
  815. cancel: function() {
  816. if(this.helper.is(".ui-draggable-dragging")) {
  817. this._mouseUp({});
  818. } else {
  819. this._clear();
  820. }
  821. return this;
  822. },
  823. _getHandle: function(event) {
  824. var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
  825. $(this.options.handle, this.element)
  826. .find("*")
  827. .andSelf()
  828. .each(function() {
  829. if(this == event.target) handle = true;
  830. });
  831. return handle;
  832. },
  833. _createHelper: function(event) {
  834. var o = this.options;
  835. var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone().removeAttr('id') : this.element);
  836. if(!helper.parents('body').length)
  837. helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));
  838. if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position")))
  839. helper.css("position", "absolute");
  840. return helper;
  841. },
  842. _adjustOffsetFromHelper: function(obj) {
  843. if (typeof obj == 'string') {
  844. obj = obj.split(' ');
  845. }
  846. if ($.isArray(obj)) {
  847. obj = {left: +obj[0], top: +obj[1] || 0};
  848. }
  849. if ('left' in obj) {
  850. this.offset.click.left = obj.left + this.margins.left;
  851. }
  852. if ('right' in obj) {
  853. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  854. }
  855. if ('top' in obj) {
  856. this.offset.click.top = obj.top + this.margins.top;
  857. }
  858. if ('bottom' in obj) {
  859. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  860. }
  861. },
  862. _getParentOffset: function() {
  863. //Get the offsetParent and cache its position
  864. this.offsetParent = this.helper.offsetParent();
  865. var po = this.offsetParent.offset();
  866. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  867. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  868. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  869. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  870. if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
  871. po.left += this.scrollParent.scrollLeft();
  872. po.top += this.scrollParent.scrollTop();
  873. }
  874. if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
  875. || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
  876. po = { top: 0, left: 0 };
  877. return {
  878. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  879. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  880. };
  881. },
  882. _getRelativeOffset: function() {
  883. if(this.cssPosition == "relative") {
  884. var p = this.element.position();
  885. return {
  886. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  887. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  888. };
  889. } else {
  890. return { top: 0, left: 0 };
  891. }
  892. },
  893. _cacheMargins: function() {
  894. this.margins = {
  895. left: (parseInt(this.element.css("marginLeft"),10) || 0),
  896. top: (parseInt(this.element.css("marginTop"),10) || 0),
  897. right: (parseInt(this.element.css("marginRight"),10) || 0),
  898. bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
  899. };
  900. },
  901. _cacheHelperProportions: function() {
  902. this.helperProportions = {
  903. width: this.helper.outerWidth(),
  904. height: this.helper.outerHeight()
  905. };
  906. },
  907. _setContainment: function() {
  908. var o = this.options;
  909. if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
  910. if(o.containment == 'document' || o.containment == 'window') this.containment = [
  911. o.containment == 'document' ? 0 : $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  912. o.containment == 'document' ? 0 : $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  913. (o.containment == 'document' ? 0 : $(window).scrollLeft()) + $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
  914. (o.containment == 'document' ? 0 : $(window).scrollTop()) + ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  915. ];
  916. if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) {
  917. var c = $(o.containment);
  918. var ce = c[0]; if(!ce) return;
  919. var co = c.offset();
  920. var over = ($(ce).css("overflow") != 'hidden');
  921. this.containment = [
  922. (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0),
  923. (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0),
  924. (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,
  925. (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
  926. ];
  927. this.relative_container = c;
  928. } else if(o.containment.constructor == Array) {
  929. this.containment = o.containment;
  930. }
  931. },
  932. _convertPositionTo: function(d, pos) {
  933. if(!pos) pos = this.position;
  934. var mod = d == "absolute" ? 1 : -1;
  935. 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);
  936. return {
  937. top: (
  938. pos.top // The absolute mouse position
  939. + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent
  940. + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
  941. - ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  942. ),
  943. left: (
  944. pos.left // The absolute mouse position
  945. + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent
  946. + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
  947. - ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  948. )
  949. };
  950. },
  951. _generatePosition: function(event) {
  952. 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);
  953. var pageX = event.pageX;
  954. var pageY = event.pageY;
  955. /*
  956. * - Position constraining -
  957. * Constrain the position to a mix of grid, containment.
  958. */
  959. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  960. var containment;
  961. if(this.containment) {
  962. if (this.relative_container){
  963. var co = this.relative_container.offset();
  964. containment = [ this.containment[0] + co.left,
  965. this.containment[1] + co.top,
  966. this.containment[2] + co.left,
  967. this.containment[3] + co.top ];
  968. }
  969. else {
  970. containment = this.containment;
  971. }
  972. if(event.pageX - this.offset.click.left < containment[0]) pageX = containment[0] + this.offset.click.left;
  973. if(event.pageY - this.offset.click.top < containment[1]) pageY = containment[1] + this.offset.click.top;
  974. if(event.pageX - this.offset.click.left > containment[2]) pageX = containment[2] + this.offset.click.left;
  975. if(event.pageY - this.offset.click.top > containment[3]) pageY = containment[3] + this.offset.click.top;
  976. }
  977. if(o.grid) {
  978. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  979. var top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  980. 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;
  981. var left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  982. 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;
  983. }
  984. }
  985. return {
  986. top: (
  987. pageY // The absolute mouse position
  988. - this.offset.click.top // Click offset (relative to the element)
  989. - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent
  990. - this.offset.parent.top // The offsetParent's offset without borders (offset + border)
  991. + ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  992. ),
  993. left: (
  994. pageX // The absolute mouse position
  995. - this.offset.click.left // Click offset (relative to the element)
  996. - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent
  997. - this.offset.parent.left // The offsetParent's offset without borders (offset + border)
  998. + ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  999. )
  1000. };
  1001. },
  1002. _clear: function() {
  1003. this.helper.removeClass("ui-draggable-dragging");
  1004. if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove();
  1005. //if($.ui.ddmanager) $.ui.ddmanager.current = null;
  1006. this.helper = null;
  1007. this.cancelHelperRemoval = false;
  1008. },
  1009. // From now on bulk stuff - mainly helpers
  1010. _trigger: function(type, event, ui) {
  1011. ui = ui || this._uiHash();
  1012. $.ui.plugin.call(this, type, [event, ui]);
  1013. if(type == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins
  1014. return $.Widget.prototype._trigger.call(this, type, event, ui);
  1015. },
  1016. plugins: {},
  1017. _uiHash: function(event) {
  1018. return {
  1019. helper: this.helper,
  1020. position: this.position,
  1021. originalPosition: this.originalPosition,
  1022. offset: this.positionAbs
  1023. };
  1024. }
  1025. });
  1026. $.extend($.ui.draggable, {
  1027. version: "1.8.20"
  1028. });
  1029. $.ui.plugin.add("draggable", "connectToSortable", {
  1030. start: function(event, ui) {
  1031. var inst = $(this).data("draggable"), o = inst.options,
  1032. uiSortable = $.extend({}, ui, { item: inst.element });
  1033. inst.sortables = [];
  1034. $(o.connectToSortable).each(function() {
  1035. var sortable = $.data(this, 'sortable');
  1036. if (sortable && !sortable.options.disabled) {
  1037. inst.sortables.push({
  1038. instance: sortable,
  1039. shouldRevert: sortable.options.revert
  1040. });
  1041. 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).
  1042. sortable._trigger("activate", event, uiSortable);
  1043. }
  1044. });
  1045. },
  1046. stop: function(event, ui) {
  1047. //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
  1048. var inst = $(this).data("draggable"),
  1049. uiSortable = $.extend({}, ui, { item: inst.element });
  1050. $.each(inst.sortables, function() {
  1051. if(this.instance.isOver) {
  1052. this.instance.isOver = 0;
  1053. inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
  1054. this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
  1055. //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: 'valid/invalid'
  1056. if(this.shouldRevert) this.instance.options.revert = true;
  1057. //Trigger the stop of the sortable
  1058. this.instance._mouseStop(event);
  1059. this.instance.options.helper = this.instance.options._helper;
  1060. //If the helper has been the original item, restore properties in the sortable
  1061. if(inst.options.helper == 'original')
  1062. this.instance.currentItem.css({ top: 'auto', left: 'auto' });
  1063. } else {
  1064. this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
  1065. this.instance._trigger("deactivate", event, uiSortable);
  1066. }
  1067. });
  1068. },
  1069. drag: function(event, ui) {
  1070. var inst = $(this).data("draggable"), self = this;
  1071. var checkPos = function(o) {
  1072. var dyClick = this.offset.click.top, dxClick = this.offset.click.left;
  1073. var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left;
  1074. var itemHeight = o.height, itemWidth = o.width;
  1075. var itemTop = o.top, itemLeft = o.left;
  1076. return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth);
  1077. };
  1078. $.each(inst.sortables, function(i) {
  1079. //Copy over some variables to allow calling the sortable's native _intersectsWith
  1080. this.instance.positionAbs = inst.positionAbs;
  1081. this.instance.helperProportions = inst.helperProportions;
  1082. this.instance.offset.click = inst.offset.click;
  1083. if(this.instance._intersectsWith(this.instance.containerCache)) {
  1084. //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
  1085. if(!this.instance.isOver) {
  1086. this.instance.isOver = 1;
  1087. //Now we fake the start of dragging for the sortable instance,
  1088. //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
  1089. //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)
  1090. this.instance.currentItem = $(self).clone().removeAttr('id').appendTo(this.instance.element).data("sortable-item", true);
  1091. this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
  1092. this.instance.options.helper = function() { return ui.helper[0]; };
  1093. event.target = this.instance.currentItem[0];
  1094. this.instance._mouseCapture(event, true);
  1095. this.instance._mouseStart(event, true, true);
  1096. //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
  1097. this.instance.offset.click.top = inst.offset.click.top;
  1098. this.instance.offset.click.left = inst.offset.click.left;
  1099. this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
  1100. this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
  1101. inst._trigger("toSortable", event);
  1102. inst.dropped = this.instance.element; //draggable revert needs that
  1103. //hack so receive/update callbacks work (mostly)
  1104. inst.currentItem = inst.element;
  1105. this.instance.fromOutside = inst;
  1106. }
  1107. //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
  1108. if(this.instance.currentItem) this.instance._mouseDrag(event);
  1109. } else {
  1110. //If it doesn't intersect with the sortable, and it intersected before,
  1111. //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
  1112. if(this.instance.isOver) {
  1113. this.instance.isOver = 0;
  1114. this.instance.cancelHelperRemoval = true;
  1115. //Prevent reverting on this forced stop
  1116. this.instance.options.revert = false;
  1117. // The out event needs to be triggered independently
  1118. this.instance._trigger('out', event, this.instance._uiHash(this.instance));
  1119. this.instance._mouseStop(event, true);
  1120. this.instance.options.helper = this.instance.options._helper;
  1121. //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
  1122. this.instance.currentItem.remove();
  1123. if(this.instance.placeholder) this.instance.placeholder.remove();
  1124. inst._trigger("fromSortable", event);
  1125. inst.dropped = false; //draggable revert needs that
  1126. }
  1127. };
  1128. });
  1129. }
  1130. });
  1131. $.ui.plugin.add("draggable", "cursor", {
  1132. start: function(event, ui) {
  1133. var t = $('body'), o = $(this).data('draggable').options;
  1134. if (t.css("cursor")) o._cursor = t.css("cursor");
  1135. t.css("cursor", o.cursor);
  1136. },
  1137. stop: function(event, ui) {
  1138. var o = $(this).data('draggable').options;
  1139. if (o._cursor) $('body').css("cursor", o._cursor);
  1140. }
  1141. });
  1142. $.ui.plugin.add("draggable", "opacity", {
  1143. start: function(event, ui) {
  1144. var t = $(ui.helper), o = $(this).data('draggable').options;
  1145. if(t.css("opacity")) o._opacity = t.css("opacity");
  1146. t.css('opacity', o.opacity);
  1147. },
  1148. stop: function(event, ui) {
  1149. var o = $(this).data('draggable').options;
  1150. if(o._opacity) $(ui.helper).css('opacity', o._opacity);
  1151. }
  1152. });
  1153. $.ui.plugin.add("draggable", "scroll", {
  1154. start: function(event, ui) {
  1155. var i = $(this).data("draggable");
  1156. if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') i.overflowOffset = i.scrollParent.offset();
  1157. },
  1158. drag: function(event, ui) {
  1159. var i = $(this).data("draggable"), o = i.options, scrolled = false;
  1160. if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') {
  1161. if(!o.axis || o.axis != 'x') {
  1162. if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
  1163. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
  1164. else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity)
  1165. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
  1166. }
  1167. if(!o.axis || o.axis != 'y') {
  1168. if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
  1169. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
  1170. else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity)
  1171. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
  1172. }
  1173. } else {
  1174. if(!o.axis || o.axis != 'x') {
  1175. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
  1176. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  1177. else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
  1178. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  1179. }
  1180. if(!o.axis || o.axis != 'y') {
  1181. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
  1182. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  1183. else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
  1184. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  1185. }
  1186. }
  1187. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
  1188. $.ui.ddmanager.prepareOffsets(i, event);
  1189. }
  1190. });
  1191. $.ui.plugin.add("draggable", "snap", {
  1192. start: function(event, ui) {
  1193. var i = $(this).data("draggable"), o = i.options;
  1194. i.snapElements = [];
  1195. $(o.snap.constructor != String ? ( o.snap.items || ':data(draggable)' ) : o.snap).each(function() {
  1196. var $t = $(this); var $o = $t.offset();
  1197. if(this != i.element[0]) i.snapElements.push({
  1198. item: this,
  1199. width: $t.outerWidth(), height: $t.outerHeight(),
  1200. top: $o.top, left: $o.left
  1201. });
  1202. });
  1203. },
  1204. drag: function(event, ui) {
  1205. var inst = $(this).data("draggable"), o = inst.options;
  1206. var d = o.snapTolerance;
  1207. var x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  1208. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  1209. for (var i = inst.snapElements.length - 1; i >= 0; i--){
  1210. var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width,
  1211. t = inst.snapElements[i].top, b = t + inst.snapElements[i].height;
  1212. //Yes, I know, this is insane ;)
  1213. 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))) {
  1214. 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 })));
  1215. inst.snapElements[i].snapping = false;
  1216. continue;
  1217. }
  1218. if(o.snapMode != 'inner') {
  1219. var ts = Math.abs(t - y2) <= d;
  1220. var bs = Math.abs(b - y1) <= d;
  1221. var ls = Math.abs(l - x2) <= d;
  1222. var rs = Math.abs(r - x1) <= d;
  1223. if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  1224. if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
  1225. if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
  1226. if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
  1227. }
  1228. var first = (ts || bs || ls || rs);
  1229. if(o.snapMode != 'outer') {
  1230. var ts = Math.abs(t - y1) <= d;
  1231. var bs = Math.abs(b - y2) <= d;
  1232. var ls = Math.abs(l - x1) <= d;
  1233. var rs = Math.abs(r - x2) <= d;
  1234. if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
  1235. if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  1236. if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
  1237. if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
  1238. }
  1239. if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first))
  1240. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  1241. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  1242. };
  1243. }
  1244. });
  1245. $.ui.plugin.add("draggable", "stack", {
  1246. start: function(event, ui) {
  1247. var o = $(this).data("draggable").options;
  1248. var group = $.makeArray($(o.stack)).sort(function(a,b) {
  1249. return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
  1250. });
  1251. if (!group.length) { return; }
  1252. var min = parseInt(group[0].style.zIndex) || 0;
  1253. $(group).each(function(i) {
  1254. this.style.zIndex = min + i;
  1255. });
  1256. this[0].style.zIndex = min + group.length;
  1257. }
  1258. });
  1259. $.ui.plugin.add("draggable", "zIndex", {
  1260. start: function(event, ui) {
  1261. var t = $(ui.helper), o = $(this).data("draggable").options;
  1262. if(t.css("zIndex")) o._zIndex = t.css("zIndex");
  1263. t.css('zIndex', o.zIndex);
  1264. },
  1265. stop: function(event, ui) {
  1266. var o = $(this).data("draggable").options;
  1267. if(o._zIndex) $(ui.helper).css('zIndex', o._zIndex);
  1268. }
  1269. });
  1270. })(jQuery);
  1271. (function( $, undefined ) {
  1272. $.widget("ui.droppable", {
  1273. widgetEventPrefix: "drop",
  1274. options: {
  1275. accept: '*',
  1276. activeClass: false,
  1277. addClasses: true,
  1278. greedy: false,
  1279. hoverClass: false,
  1280. scope: 'default',
  1281. tolerance: 'intersect'
  1282. },
  1283. _create: function() {
  1284. var o = this.options, accept = o.accept;
  1285. this.isover = 0; this.isout = 1;
  1286. this.accept = $.isFunction(accept) ? accept : function(d) {
  1287. return d.is(accept);
  1288. };
  1289. //Store the droppable's proportions
  1290. this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
  1291. // Add the reference and positions to the manager
  1292. $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
  1293. $.ui.ddmanager.droppables[o.scope].push(this);
  1294. (o.addClasses && this.element.addClass("ui-droppable"));
  1295. },
  1296. destroy: function() {
  1297. var drop = $.ui.ddmanager.droppables[this.options.scope];
  1298. for ( var i = 0; i < drop.length; i++ )
  1299. if ( drop[i] == this )
  1300. drop.splice(i, 1);
  1301. this.element
  1302. .removeClass("ui-droppable ui-droppable-disabled")
  1303. .removeData("droppable")
  1304. .unbind(".droppable");
  1305. return this;
  1306. },
  1307. _setOption: function(key, value) {
  1308. if(key == 'accept') {
  1309. this.accept = $.isFunction(value) ? value : function(d) {
  1310. return d.is(value);
  1311. };
  1312. }
  1313. $.Widget.prototype._setOption.apply(this, arguments);
  1314. },
  1315. _activate: function(event) {
  1316. var draggable = $.ui.ddmanager.current;
  1317. if(this.options.activeClass) this.element.addClass(this.options.activeClass);
  1318. (draggable && this._trigger('activate', event, this.ui(draggable)));
  1319. },
  1320. _deactivate: function(event) {
  1321. var draggable = $.ui.ddmanager.current;
  1322. if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
  1323. (draggable && this._trigger('deactivate', event, this.ui(draggable)));
  1324. },
  1325. _over: function(event) {
  1326. var draggable = $.ui.ddmanager.current;
  1327. if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
  1328. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1329. if(this.options.hoverClass) this.element.addClass(this.options.hoverClass);
  1330. this._trigger('over', event, this.ui(draggable));
  1331. }
  1332. },
  1333. _out: function(event) {
  1334. var draggable = $.ui.ddmanager.current;
  1335. if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
  1336. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1337. if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
  1338. this._trigger('out', event, this.ui(draggable));
  1339. }
  1340. },
  1341. _drop: function(event,custom) {
  1342. var draggable = custom || $.ui.ddmanager.current;
  1343. if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false; // Bail if draggable and droppable are same element
  1344. var childrenIntersection = false;
  1345. this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function() {
  1346. var inst = $.data(this, 'droppable');
  1347. if(
  1348. inst.options.greedy
  1349. && !inst.options.disabled
  1350. && inst.options.scope == draggable.options.scope
  1351. && inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element))
  1352. && $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
  1353. ) { childrenIntersection = true; return false; }
  1354. });
  1355. if(childrenIntersection) return false;
  1356. if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1357. if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
  1358. if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
  1359. this._trigger('drop', event, this.ui(draggable));
  1360. return this.element;
  1361. }
  1362. return false;
  1363. },
  1364. ui: function(c) {
  1365. return {
  1366. draggable: (c.currentItem || c.element),
  1367. helper: c.helper,
  1368. position: c.position,
  1369. offset: c.positionAbs
  1370. };
  1371. }
  1372. });
  1373. $.extend($.ui.droppable, {
  1374. version: "1.8.20"
  1375. });
  1376. $.ui.intersect = function(draggable, droppable, toleranceMode) {
  1377. if (!droppable.offset) return false;
  1378. var x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
  1379. y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height;
  1380. var l = droppable.offset.left, r = l + droppable.proportions.width,
  1381. t = droppable.offset.top, b = t + droppable.proportions.height;
  1382. switch (toleranceMode) {
  1383. case 'fit':
  1384. return (l <= x1 && x2 <= r
  1385. && t <= y1 && y2 <= b);
  1386. break;
  1387. case 'intersect':
  1388. return (l < x1 + (draggable.helperProportions.width / 2) // Right Half
  1389. && x2 - (draggable.helperProportions.width / 2) < r // Left Half
  1390. && t < y1 + (draggable.helperProportions.height / 2) // Bottom Half
  1391. && y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
  1392. break;
  1393. case 'pointer':
  1394. var draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left),
  1395. draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top),
  1396. isOver = $.ui.isOver(draggableTop, draggableLeft, t, l, droppable.proportions.height, droppable.proportions.width);
  1397. return isOver;
  1398. break;
  1399. case 'touch':
  1400. return (
  1401. (y1 >= t && y1 <= b) || // Top edge touching
  1402. (y2 >= t && y2 <= b) || // Bottom edge touching
  1403. (y1 < t && y2 > b) // Surrounded vertically
  1404. ) && (
  1405. (x1 >= l && x1 <= r) || // Left edge touching
  1406. (x2 >= l && x2 <= r) || // Right edge touching
  1407. (x1 < l && x2 > r) // Surrounded horizontally
  1408. );
  1409. break;
  1410. default:
  1411. return false;
  1412. break;
  1413. }
  1414. };
  1415. /*
  1416. This manager tracks offsets of draggables and droppables
  1417. */
  1418. $.ui.ddmanager = {
  1419. current: null,
  1420. droppables: { 'default': [] },
  1421. prepareOffsets: function(t, event) {
  1422. var m = $.ui.ddmanager.droppables[t.options.scope] || [];
  1423. var type = event ? event.type : null; // workaround for #2317
  1424. var list = (t.currentItem || t.element).find(":data(droppable)").andSelf();
  1425. droppablesLoop: for (var i = 0; i < m.length; i++) {
  1426. if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) continue; //No disabled and non-accepted
  1427. 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
  1428. m[i].visible = m[i].element.css("display") != "none"; if(!m[i].visible) continue; //If the element is not visible, continue
  1429. if(type == "mousedown") m[i]._activate.call(m[i], event); //Activate the droppable if used directly from draggables
  1430. m[i].offset = m[i].element.offset();
  1431. m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
  1432. }
  1433. },
  1434. drop: function(draggable, event) {
  1435. var dropped = false;
  1436. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  1437. if(!this.options) return;
  1438. if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance))
  1439. dropped = this._drop.call(this, event) || dropped;
  1440. if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1441. this.isout = 1; this.isover = 0;
  1442. this._deactivate.call(this, event);
  1443. }
  1444. });
  1445. return dropped;
  1446. },
  1447. dragStart: function( draggable, event ) {
  1448. //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  1449. draggable.element.parents( ":not(body,html)" ).bind( "scroll.droppable", function() {
  1450. if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
  1451. });
  1452. },
  1453. drag: function(draggable, event) {
  1454. //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  1455. if(draggable.options.refreshPositions) $.ui.ddmanager.prepareOffsets(draggable, event);
  1456. //Run through all droppables and check their positions based on specific tolerance options
  1457. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  1458. if(this.options.disabled || this.greedyChild || !this.visible) return;
  1459. var intersects = $.ui.intersect(draggable, this, this.options.tolerance);
  1460. var c = !intersects && this.isover == 1 ? 'isout' : (intersects && this.isover == 0 ? 'isover' : null);
  1461. if(!c) return;
  1462. var parentInstance;
  1463. if (this.options.greedy) {
  1464. var parent = this.element.parents(':data(droppable):eq(0)');
  1465. if (parent.length) {
  1466. parentInstance = $.data(parent[0], 'droppable');
  1467. parentInstance.greedyChild = (c == 'isover' ? 1 : 0);
  1468. }
  1469. }
  1470. // we just moved into a greedy child
  1471. if (parentInstance && c == 'isover') {
  1472. parentInstance['isover'] = 0;
  1473. parentInstance['isout'] = 1;
  1474. parentInstance._out.call(parentInstance, event);
  1475. }
  1476. this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0;
  1477. this[c == "isover" ? "_over" : "_out"].call(this, event);
  1478. // we just moved out of a greedy child
  1479. if (parentInstance && c == 'isout') {
  1480. parentInstance['isout'] = 0;
  1481. parentInstance['isover'] = 1;
  1482. parentInstance._over.call(parentInstance, event);
  1483. }
  1484. });
  1485. },
  1486. dragStop: function( draggable, event ) {
  1487. draggable.element.parents( ":not(body,html)" ).unbind( "scroll.droppable" );
  1488. //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  1489. if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
  1490. }
  1491. };
  1492. })(jQuery);
  1493. (function( $, undefined ) {
  1494. $.widget("ui.resizable", $.ui.mouse, {
  1495. widgetEventPrefix: "resize",
  1496. options: {
  1497. alsoResize: false,
  1498. animate: false,
  1499. animateDuration: "slow",
  1500. animateEasing: "swing",
  1501. aspectRatio: false,
  1502. autoHide: false,
  1503. containment: false,
  1504. ghost: false,
  1505. grid: false,
  1506. handles: "e,s,se",
  1507. helper: false,
  1508. maxHeight: null,
  1509. maxWidth: null,
  1510. minHeight: 10,
  1511. minWidth: 10,
  1512. zIndex: 1000
  1513. },
  1514. _create: function() {
  1515. var self = this, o = this.options;
  1516. this.element.addClass("ui-resizable");
  1517. $.extend(this, {
  1518. _aspectRatio: !!(o.aspectRatio),
  1519. aspectRatio: o.aspectRatio,
  1520. originalElement: this.element,
  1521. _proportionallyResizeElements: [],
  1522. _helper: o.helper || o.ghost || o.animate ? o.helper || 'ui-resizable-helper' : null
  1523. });
  1524. //Wrap the element if it cannot hold child nodes
  1525. if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
  1526. //Create a wrapper element and set the wrapper to the new current internal element
  1527. this.element.wrap(
  1528. $('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({
  1529. position: this.element.css('position'),
  1530. width: this.element.outerWidth(),
  1531. height: this.element.outerHeight(),
  1532. top: this.element.css('top'),
  1533. left: this.element.css('left')
  1534. })
  1535. );
  1536. //Overwrite the original this.element
  1537. this.element = this.element.parent().data(
  1538. "resizable", this.element.data('resizable')
  1539. );
  1540. this.elementIsWrapper = true;
  1541. //Move margins to the wrapper
  1542. this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
  1543. this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
  1544. //Prevent Safari textarea resize
  1545. this.originalResizeStyle = this.originalElement.css('resize');
  1546. this.originalElement.css('resize', 'none');
  1547. //Push the actual element to our proportionallyResize internal array
  1548. this._proportionallyResizeElements.push(this.originalElement.css({ position: 'static', zoom: 1, display: 'block' }));
  1549. // avoid IE jump (hard set the margin)
  1550. this.originalElement.css({ margin: this.originalElement.css('margin') });
  1551. // fix handlers offset
  1552. this._proportionallyResize();
  1553. }
  1554. 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' });
  1555. if(this.handles.constructor == String) {
  1556. if(this.handles == 'all') this.handles = 'n,e,s,w,se,sw,ne,nw';
  1557. var n = this.handles.split(","); this.handles = {};
  1558. for(var i = 0; i < n.length; i++) {
  1559. var handle = $.trim(n[i]), hname = 'ui-resizable-'+handle;
  1560. var axis = $('<div class="ui-resizable-handle ' + hname + '"></div>');
  1561. // Apply zIndex to all handles - see #7960
  1562. axis.css({ zIndex: o.zIndex });
  1563. //TODO : What's going on here?
  1564. if ('se' == handle) {
  1565. axis.addClass('ui-icon ui-icon-gripsmall-diagonal-se');
  1566. };
  1567. //Insert into internal handles object and append to element
  1568. this.handles[handle] = '.ui-resizable-'+handle;
  1569. this.element.append(axis);
  1570. }
  1571. }
  1572. this._renderAxis = function(target) {
  1573. target = target || this.element;
  1574. for(var i in this.handles) {
  1575. if(this.handles[i].constructor == String)
  1576. this.handles[i] = $(this.handles[i], this.element).show();
  1577. //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
  1578. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
  1579. var axis = $(this.handles[i], this.element), padWrapper = 0;
  1580. //Checking the correct pad and border
  1581. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  1582. //The padding type i have to apply...
  1583. var padPos = [ 'padding',
  1584. /ne|nw|n/.test(i) ? 'Top' :
  1585. /se|sw|s/.test(i) ? 'Bottom' :
  1586. /^e$/.test(i) ? 'Right' : 'Left' ].join("");
  1587. target.css(padPos, padWrapper);
  1588. this._proportionallyResize();
  1589. }
  1590. //TODO: What's that good for? There's not anything to be executed left
  1591. if(!$(this.handles[i]).length)
  1592. continue;
  1593. }
  1594. };
  1595. //TODO: make renderAxis a prototype function
  1596. this._renderAxis(this.element);
  1597. this._handles = $('.ui-resizable-handle', this.element)
  1598. .disableSelection();
  1599. //Matching axis name
  1600. this._handles.mouseover(function() {
  1601. if (!self.resizing) {
  1602. if (this.className)
  1603. var axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  1604. //Axis, default = se
  1605. self.axis = axis && axis[1] ? axis[1] : 'se';
  1606. }
  1607. });
  1608. //If we want to auto hide the elements
  1609. if (o.autoHide) {
  1610. this._handles.hide();
  1611. $(this.element)
  1612. .addClass("ui-resizable-autohide")
  1613. .hover(function() {
  1614. if (o.disabled) return;
  1615. $(this).removeClass("ui-resizable-autohide");
  1616. self._handles.show();
  1617. },
  1618. function(){
  1619. if (o.disabled) return;
  1620. if (!self.resizing) {
  1621. $(this).addClass("ui-resizable-autohide");
  1622. self._handles.hide();
  1623. }
  1624. });
  1625. }
  1626. //Initialize the mouse interaction
  1627. this._mouseInit();
  1628. },
  1629. destroy: function() {
  1630. this._mouseDestroy();
  1631. var _destroy = function(exp) {
  1632. $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  1633. .removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove();
  1634. };
  1635. //TODO: Unwrap at same DOM position
  1636. if (this.elementIsWrapper) {
  1637. _destroy(this.element);
  1638. var wrapper = this.element;
  1639. wrapper.after(
  1640. this.originalElement.css({
  1641. position: wrapper.css('position'),
  1642. width: wrapper.outerWidth(),
  1643. height: wrapper.outerHeight(),
  1644. top: wrapper.css('top'),
  1645. left: wrapper.css('left')
  1646. })
  1647. ).remove();
  1648. }
  1649. this.originalElement.css('resize', this.originalResizeStyle);
  1650. _destroy(this.originalElement);
  1651. return this;
  1652. },
  1653. _mouseCapture: function(event) {
  1654. var handle = false;
  1655. for (var i in this.handles) {
  1656. if ($(this.handles[i])[0] == event.target) {
  1657. handle = true;
  1658. }
  1659. }
  1660. return !this.options.disabled && handle;
  1661. },
  1662. _mouseStart: function(event) {
  1663. var o = this.options, iniPos = this.element.position(), el = this.element;
  1664. this.resizing = true;
  1665. this.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() };
  1666. // bugfix for http://dev.jquery.com/ticket/1749
  1667. if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) {
  1668. el.css({ position: 'absolute', top: iniPos.top, left: iniPos.left });
  1669. }
  1670. this._renderProxy();
  1671. var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top'));
  1672. if (o.containment) {
  1673. curleft += $(o.containment).scrollLeft() || 0;
  1674. curtop += $(o.containment).scrollTop() || 0;
  1675. }
  1676. //Store needed variables
  1677. this.offset = this.helper.offset();
  1678. this.position = { left: curleft, top: curtop };
  1679. this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  1680. this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  1681. this.originalPosition = { left: curleft, top: curtop };
  1682. this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
  1683. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  1684. //Aspect Ratio
  1685. this.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
  1686. var cursor = $('.ui-resizable-' + this.axis).css('cursor');
  1687. $('body').css('cursor', cursor == 'auto' ? this.axis + '-resize' : cursor);
  1688. el.addClass("ui-resizable-resizing");
  1689. this._propagate("start", event);
  1690. return true;
  1691. },
  1692. _mouseDrag: function(event) {
  1693. //Increase performance, avoid regex
  1694. var el = this.helper, o = this.options, props = {},
  1695. self = this, smp = this.originalMousePosition, a = this.axis;
  1696. var dx = (event.pageX-smp.left)||0, dy = (event.pageY-smp.top)||0;
  1697. var trigger = this._change[a];
  1698. if (!trigger) return false;
  1699. // Calculate the attrs that will be change
  1700. var data = trigger.apply(this, [event, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff;
  1701. // Put this in the mouseDrag handler since the user can start pressing shift while resizing
  1702. this._updateVirtualBoundaries(event.shiftKey);
  1703. if (this._aspectRatio || event.shiftKey)
  1704. data = this._updateRatio(data, event);
  1705. data = this._respectSize(data, event);
  1706. // plugins callbacks need to be called first
  1707. this._propagate("resize", event);
  1708. el.css({
  1709. top: this.position.top + "px", left: this.position.left + "px",
  1710. width: this.size.width + "px", height: this.size.height + "px"
  1711. });
  1712. if (!this._helper && this._proportionallyResizeElements.length)
  1713. this._proportionallyResize();
  1714. this._updateCache(data);
  1715. // calling the user callback at the end
  1716. this._trigger('resize', event, this.ui());
  1717. return false;
  1718. },
  1719. _mouseStop: function(event) {
  1720. this.resizing = false;
  1721. var o = this.options, self = this;
  1722. if(this._helper) {
  1723. var pr = this._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  1724. soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
  1725. soffsetw = ista ? 0 : self.sizeDiff.width;
  1726. var s = { width: (self.helper.width() - soffsetw), height: (self.helper.height() - soffseth) },
  1727. left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
  1728. top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
  1729. if (!o.animate)
  1730. this.element.css($.extend(s, { top: top, left: left }));
  1731. self.helper.height(self.size.height);
  1732. self.helper.width(self.size.width);
  1733. if (this._helper && !o.animate) this._proportionallyResize();
  1734. }
  1735. $('body').css('cursor', 'auto');
  1736. this.element.removeClass("ui-resizable-resizing");
  1737. this._propagate("stop", event);
  1738. if (this._helper) this.helper.remove();
  1739. return false;
  1740. },
  1741. _updateVirtualBoundaries: function(forceAspectRatio) {
  1742. var o = this.options, pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b;
  1743. b = {
  1744. minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
  1745. maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  1746. minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
  1747. maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
  1748. };
  1749. if(this._aspectRatio || forceAspectRatio) {
  1750. // We want to create an enclosing box whose aspect ration is the requested one
  1751. // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
  1752. pMinWidth = b.minHeight * this.aspectRatio;
  1753. pMinHeight = b.minWidth / this.aspectRatio;
  1754. pMaxWidth = b.maxHeight * this.aspectRatio;
  1755. pMaxHeight = b.maxWidth / this.aspectRatio;
  1756. if(pMinWidth > b.minWidth) b.minWidth = pMinWidth;
  1757. if(pMinHeight > b.minHeight) b.minHeight = pMinHeight;
  1758. if(pMaxWidth < b.maxWidth) b.maxWidth = pMaxWidth;
  1759. if(pMaxHeight < b.maxHeight) b.maxHeight = pMaxHeight;
  1760. }
  1761. this._vBoundaries = b;
  1762. },
  1763. _updateCache: function(data) {
  1764. var o = this.options;
  1765. this.offset = this.helper.offset();
  1766. if (isNumber(data.left)) this.position.left = data.left;
  1767. if (isNumber(data.top)) this.position.top = data.top;
  1768. if (isNumber(data.height)) this.size.height = data.height;
  1769. if (isNumber(data.width)) this.size.width = data.width;
  1770. },
  1771. _updateRatio: function(data, event) {
  1772. var o = this.options, cpos = this.position, csize = this.size, a = this.axis;
  1773. if (isNumber(data.height)) data.width = (data.height * this.aspectRatio);
  1774. else if (isNumber(data.width)) data.height = (data.width / this.aspectRatio);
  1775. if (a == 'sw') {
  1776. data.left = cpos.left + (csize.width - data.width);
  1777. data.top = null;
  1778. }
  1779. if (a == 'nw') {
  1780. data.top = cpos.top + (csize.height - data.height);
  1781. data.left = cpos.left + (csize.width - data.width);
  1782. }
  1783. return data;
  1784. },
  1785. _respectSize: function(data, event) {
  1786. var el = this.helper, o = this._vBoundaries, pRatio = this._aspectRatio || event.shiftKey, a = this.axis,
  1787. ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  1788. isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height);
  1789. if (isminw) data.width = o.minWidth;
  1790. if (isminh) data.height = o.minHeight;
  1791. if (ismaxw) data.width = o.maxWidth;
  1792. if (ismaxh) data.height = o.maxHeight;
  1793. var dw = this.originalPosition.left + this.originalSize.width, dh = this.position.top + this.size.height;
  1794. var cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  1795. if (isminw && cw) data.left = dw - o.minWidth;
  1796. if (ismaxw && cw) data.left = dw - o.maxWidth;
  1797. if (isminh && ch) data.top = dh - o.minHeight;
  1798. if (ismaxh && ch) data.top = dh - o.maxHeight;
  1799. // fixing jump error on top/left - bug #2330
  1800. var isNotwh = !data.width && !data.height;
  1801. if (isNotwh && !data.left && data.top) data.top = null;
  1802. else if (isNotwh && !data.top && data.left) data.left = null;
  1803. return data;
  1804. },
  1805. _proportionallyResize: function() {
  1806. var o = this.options;
  1807. if (!this._proportionallyResizeElements.length) return;
  1808. var element = this.helper || this.element;
  1809. for (var i=0; i < this._proportionallyResizeElements.length; i++) {
  1810. var prel = this._proportionallyResizeElements[i];
  1811. if (!this.borderDif) {
  1812. var b = [prel.css('borderTopWidth'), prel.css('borderRightWidth'), prel.css('borderBottomWidth'), prel.css('borderLeftWidth')],
  1813. p = [prel.css('paddingTop'), prel.css('paddingRight'), prel.css('paddingBottom'), prel.css('paddingLeft')];
  1814. this.borderDif = $.map(b, function(v, i) {
  1815. var border = parseInt(v,10)||0, padding = parseInt(p[i],10)||0;
  1816. return border + padding;
  1817. });
  1818. }
  1819. if ($.browser.msie && !(!($(element).is(':hidden') || $(element).parents(':hidden').length)))
  1820. continue;
  1821. prel.css({
  1822. height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
  1823. width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
  1824. });
  1825. };
  1826. },
  1827. _renderProxy: function() {
  1828. var el = this.element, o = this.options;
  1829. this.elementOffset = el.offset();
  1830. if(this._helper) {
  1831. this.helper = this.helper || $('<div style="overflow:hidden;"></div>');
  1832. // fix ie6 offset TODO: This seems broken
  1833. var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0),
  1834. pxyoffset = ( ie6 ? 2 : -1 );
  1835. this.helper.addClass(this._helper).css({
  1836. width: this.element.outerWidth() + pxyoffset,
  1837. height: this.element.outerHeight() + pxyoffset,
  1838. position: 'absolute',
  1839. left: this.elementOffset.left - ie6offset +'px',
  1840. top: this.elementOffset.top - ie6offset +'px',
  1841. zIndex: ++o.zIndex //TODO: Don't modify option
  1842. });
  1843. this.helper
  1844. .appendTo("body")
  1845. .disableSelection();
  1846. } else {
  1847. this.helper = this.element;
  1848. }
  1849. },
  1850. _change: {
  1851. e: function(event, dx, dy) {
  1852. return { width: this.originalSize.width + dx };
  1853. },
  1854. w: function(event, dx, dy) {
  1855. var o = this.options, cs = this.originalSize, sp = this.originalPosition;
  1856. return { left: sp.left + dx, width: cs.width - dx };
  1857. },
  1858. n: function(event, dx, dy) {
  1859. var o = this.options, cs = this.originalSize, sp = this.originalPosition;
  1860. return { top: sp.top + dy, height: cs.height - dy };
  1861. },
  1862. s: function(event, dx, dy) {
  1863. return { height: this.originalSize.height + dy };
  1864. },
  1865. se: function(event, dx, dy) {
  1866. return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  1867. },
  1868. sw: function(event, dx, dy) {
  1869. return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  1870. },
  1871. ne: function(event, dx, dy) {
  1872. return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  1873. },
  1874. nw: function(event, dx, dy) {
  1875. return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  1876. }
  1877. },
  1878. _propagate: function(n, event) {
  1879. $.ui.plugin.call(this, n, [event, this.ui()]);
  1880. (n != "resize" && this._trigger(n, event, this.ui()));
  1881. },
  1882. plugins: {},
  1883. ui: function() {
  1884. return {
  1885. originalElement: this.originalElement,
  1886. element: this.element,
  1887. helper: this.helper,
  1888. position: this.position,
  1889. size: this.size,
  1890. originalSize: this.originalSize,
  1891. originalPosition: this.originalPosition
  1892. };
  1893. }
  1894. });
  1895. $.extend($.ui.resizable, {
  1896. version: "1.8.20"
  1897. });
  1898. /*
  1899. * Resizable Extensions
  1900. */
  1901. $.ui.plugin.add("resizable", "alsoResize", {
  1902. start: function (event, ui) {
  1903. var self = $(this).data("resizable"), o = self.options;
  1904. var _store = function (exp) {
  1905. $(exp).each(function() {
  1906. var el = $(this);
  1907. el.data("resizable-alsoresize", {
  1908. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  1909. left: parseInt(el.css('left'), 10), top: parseInt(el.css('top'), 10)
  1910. });
  1911. });
  1912. };
  1913. if (typeof(o.alsoResize) == 'object' && !o.alsoResize.parentNode) {
  1914. if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
  1915. else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
  1916. }else{
  1917. _store(o.alsoResize);
  1918. }
  1919. },
  1920. resize: function (event, ui) {
  1921. var self = $(this).data("resizable"), o = self.options, os = self.originalSize, op = self.originalPosition;
  1922. var delta = {
  1923. height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0,
  1924. top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0
  1925. },
  1926. _alsoResize = function (exp, c) {
  1927. $(exp).each(function() {
  1928. var el = $(this), start = $(this).data("resizable-alsoresize"), style = {},
  1929. css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ['width', 'height'] : ['width', 'height', 'top', 'left'];
  1930. $.each(css, function (i, prop) {
  1931. var sum = (start[prop]||0) + (delta[prop]||0);
  1932. if (sum && sum >= 0)
  1933. style[prop] = sum || null;
  1934. });
  1935. el.css(style);
  1936. });
  1937. };
  1938. if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) {
  1939. $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
  1940. }else{
  1941. _alsoResize(o.alsoResize);
  1942. }
  1943. },
  1944. stop: function (event, ui) {
  1945. $(this).removeData("resizable-alsoresize");
  1946. }
  1947. });
  1948. $.ui.plugin.add("resizable", "animate", {
  1949. stop: function(event, ui) {
  1950. var self = $(this).data("resizable"), o = self.options;
  1951. var pr = self._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  1952. soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
  1953. soffsetw = ista ? 0 : self.sizeDiff.width;
  1954. var style = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },
  1955. left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
  1956. top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
  1957. self.element.animate(
  1958. $.extend(style, top && left ? { top: top, left: left } : {}), {
  1959. duration: o.animateDuration,
  1960. easing: o.animateEasing,
  1961. step: function() {
  1962. var data = {
  1963. width: parseInt(self.element.css('width'), 10),
  1964. height: parseInt(self.element.css('height'), 10),
  1965. top: parseInt(self.element.css('top'), 10),
  1966. left: parseInt(self.element.css('left'), 10)
  1967. };
  1968. if (pr && pr.length) $(pr[0]).css({ width: data.width, height: data.height });
  1969. // propagating resize, and updating values for each animation step
  1970. self._updateCache(data);
  1971. self._propagate("resize", event);
  1972. }
  1973. }
  1974. );
  1975. }
  1976. });
  1977. $.ui.plugin.add("resizable", "containment", {
  1978. start: function(event, ui) {
  1979. var self = $(this).data("resizable"), o = self.options, el = self.element;
  1980. var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
  1981. if (!ce) return;
  1982. self.containerElement = $(ce);
  1983. if (/document/.test(oc) || oc == document) {
  1984. self.containerOffset = { left: 0, top: 0 };
  1985. self.containerPosition = { left: 0, top: 0 };
  1986. self.parentData = {
  1987. element: $(document), left: 0, top: 0,
  1988. width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
  1989. };
  1990. }
  1991. // i'm a node, so compute top, left, right, bottom
  1992. else {
  1993. var element = $(ce), p = [];
  1994. $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
  1995. self.containerOffset = element.offset();
  1996. self.containerPosition = element.position();
  1997. self.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
  1998. var co = self.containerOffset, ch = self.containerSize.height, cw = self.containerSize.width,
  1999. width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
  2000. self.parentData = {
  2001. element: ce, left: co.left, top: co.top, width: width, height: height
  2002. };
  2003. }
  2004. },
  2005. resize: function(event, ui) {
  2006. var self = $(this).data("resizable"), o = self.options,
  2007. ps = self.containerSize, co = self.containerOffset, cs = self.size, cp = self.position,
  2008. pRatio = self._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = self.containerElement;
  2009. if (ce[0] != document && (/static/).test(ce.css('position'))) cop = co;
  2010. if (cp.left < (self._helper ? co.left : 0)) {
  2011. self.size.width = self.size.width + (self._helper ? (self.position.left - co.left) : (self.position.left - cop.left));
  2012. if (pRatio) self.size.height = self.size.width / self.aspectRatio;
  2013. self.position.left = o.helper ? co.left : 0;
  2014. }
  2015. if (cp.top < (self._helper ? co.top : 0)) {
  2016. self.size.height = self.size.height + (self._helper ? (self.position.top - co.top) : self.position.top);
  2017. if (pRatio) self.size.width = self.size.height * self.aspectRatio;
  2018. self.position.top = self._helper ? co.top : 0;
  2019. }
  2020. self.offset.left = self.parentData.left+self.position.left;
  2021. self.offset.top = self.parentData.top+self.position.top;
  2022. var woset = Math.abs( (self._helper ? self.offset.left - cop.left : (self.offset.left - cop.left)) + self.sizeDiff.width ),
  2023. hoset = Math.abs( (self._helper ? self.offset.top - cop.top : (self.offset.top - co.top)) + self.sizeDiff.height );
  2024. var isParent = self.containerElement.get(0) == self.element.parent().get(0),
  2025. isOffsetRelative = /relative|absolute/.test(self.containerElement.css('position'));
  2026. if(isParent && isOffsetRelative) woset -= self.parentData.left;
  2027. if (woset + self.size.width >= self.parentData.width) {
  2028. self.size.width = self.parentData.width - woset;
  2029. if (pRatio) self.size.height = self.size.width / self.aspectRatio;
  2030. }
  2031. if (hoset + self.size.height >= self.parentData.height) {
  2032. self.size.height = self.parentData.height - hoset;
  2033. if (pRatio) self.size.width = self.size.height * self.aspectRatio;
  2034. }
  2035. },
  2036. stop: function(event, ui){
  2037. var self = $(this).data("resizable"), o = self.options, cp = self.position,
  2038. co = self.containerOffset, cop = self.containerPosition, ce = self.containerElement;
  2039. var helper = $(self.helper), ho = helper.offset(), w = helper.outerWidth() - self.sizeDiff.width, h = helper.outerHeight() - self.sizeDiff.height;
  2040. if (self._helper && !o.animate && (/relative/).test(ce.css('position')))
  2041. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2042. if (self._helper && !o.animate && (/static/).test(ce.css('position')))
  2043. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2044. }
  2045. });
  2046. $.ui.plugin.add("resizable", "ghost", {
  2047. start: function(event, ui) {
  2048. var self = $(this).data("resizable"), o = self.options, cs = self.size;
  2049. self.ghost = self.originalElement.clone();
  2050. self.ghost
  2051. .css({ opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
  2052. .addClass('ui-resizable-ghost')
  2053. .addClass(typeof o.ghost == 'string' ? o.ghost : '');
  2054. self.ghost.appendTo(self.helper);
  2055. },
  2056. resize: function(event, ui){
  2057. var self = $(this).data("resizable"), o = self.options;
  2058. if (self.ghost) self.ghost.css({ position: 'relative', height: self.size.height, width: self.size.width });
  2059. },
  2060. stop: function(event, ui){
  2061. var self = $(this).data("resizable"), o = self.options;
  2062. if (self.ghost && self.helper) self.helper.get(0).removeChild(self.ghost.get(0));
  2063. }
  2064. });
  2065. $.ui.plugin.add("resizable", "grid", {
  2066. resize: function(event, ui) {
  2067. 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;
  2068. o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid;
  2069. 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);
  2070. if (/^(se|s|e)$/.test(a)) {
  2071. self.size.width = os.width + ox;
  2072. self.size.height = os.height + oy;
  2073. }
  2074. else if (/^(ne)$/.test(a)) {
  2075. self.size.width = os.width + ox;
  2076. self.size.height = os.height + oy;
  2077. self.position.top = op.top - oy;
  2078. }
  2079. else if (/^(sw)$/.test(a)) {
  2080. self.size.width = os.width + ox;
  2081. self.size.height = os.height + oy;
  2082. self.position.left = op.left - ox;
  2083. }
  2084. else {
  2085. self.size.width = os.width + ox;
  2086. self.size.height = os.height + oy;
  2087. self.position.top = op.top - oy;
  2088. self.position.left = op.left - ox;
  2089. }
  2090. }
  2091. });
  2092. var num = function(v) {
  2093. return parseInt(v, 10) || 0;
  2094. };
  2095. var isNumber = function(value) {
  2096. return !isNaN(parseInt(value, 10));
  2097. };
  2098. })(jQuery);
  2099. (function( $, undefined ) {
  2100. $.widget("ui.selectable", $.ui.mouse, {
  2101. options: {
  2102. appendTo: 'body',
  2103. autoRefresh: true,
  2104. distance: 0,
  2105. filter: '*',
  2106. tolerance: 'touch'
  2107. },
  2108. _create: function() {
  2109. var self = this;
  2110. this.element.addClass("ui-selectable");
  2111. this.dragged = false;
  2112. // cache selectee children based on filter
  2113. var selectees;
  2114. this.refresh = function() {
  2115. selectees = $(self.options.filter, self.element[0]);
  2116. selectees.addClass("ui-selectee");
  2117. selectees.each(function() {
  2118. var $this = $(this);
  2119. var pos = $this.offset();
  2120. $.data(this, "selectable-item", {
  2121. element: this,
  2122. $element: $this,
  2123. left: pos.left,
  2124. top: pos.top,
  2125. right: pos.left + $this.outerWidth(),
  2126. bottom: pos.top + $this.outerHeight(),
  2127. startselected: false,
  2128. selected: $this.hasClass('ui-selected'),
  2129. selecting: $this.hasClass('ui-selecting'),
  2130. unselecting: $this.hasClass('ui-unselecting')
  2131. });
  2132. });
  2133. };
  2134. this.refresh();
  2135. this.selectees = selectees.addClass("ui-selectee");
  2136. this._mouseInit();
  2137. this.helper = $("<div class='ui-selectable-helper'></div>");
  2138. },
  2139. destroy: function() {
  2140. this.selectees
  2141. .removeClass("ui-selectee")
  2142. .removeData("selectable-item");
  2143. this.element
  2144. .removeClass("ui-selectable ui-selectable-disabled")
  2145. .removeData("selectable")
  2146. .unbind(".selectable");
  2147. this._mouseDestroy();
  2148. return this;
  2149. },
  2150. _mouseStart: function(event) {
  2151. var self = this;
  2152. this.opos = [event.pageX, event.pageY];
  2153. if (this.options.disabled)
  2154. return;
  2155. var options = this.options;
  2156. this.selectees = $(options.filter, this.element[0]);
  2157. this._trigger("start", event);
  2158. $(options.appendTo).append(this.helper);
  2159. // position helper (lasso)
  2160. this.helper.css({
  2161. "left": event.clientX,
  2162. "top": event.clientY,
  2163. "width": 0,
  2164. "height": 0
  2165. });
  2166. if (options.autoRefresh) {
  2167. this.refresh();
  2168. }
  2169. this.selectees.filter('.ui-selected').each(function() {
  2170. var selectee = $.data(this, "selectable-item");
  2171. selectee.startselected = true;
  2172. if (!event.metaKey && !event.ctrlKey) {
  2173. selectee.$element.removeClass('ui-selected');
  2174. selectee.selected = false;
  2175. selectee.$element.addClass('ui-unselecting');
  2176. selectee.unselecting = true;
  2177. // selectable UNSELECTING callback
  2178. self._trigger("unselecting", event, {
  2179. unselecting: selectee.element
  2180. });
  2181. }
  2182. });
  2183. $(event.target).parents().andSelf().each(function() {
  2184. var selectee = $.data(this, "selectable-item");
  2185. if (selectee) {
  2186. var doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass('ui-selected');
  2187. selectee.$element
  2188. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  2189. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  2190. selectee.unselecting = !doSelect;
  2191. selectee.selecting = doSelect;
  2192. selectee.selected = doSelect;
  2193. // selectable (UN)SELECTING callback
  2194. if (doSelect) {
  2195. self._trigger("selecting", event, {
  2196. selecting: selectee.element
  2197. });
  2198. } else {
  2199. self._trigger("unselecting", event, {
  2200. unselecting: selectee.element
  2201. });
  2202. }
  2203. return false;
  2204. }
  2205. });
  2206. },
  2207. _mouseDrag: function(event) {
  2208. var self = this;
  2209. this.dragged = true;
  2210. if (this.options.disabled)
  2211. return;
  2212. var options = this.options;
  2213. var x1 = this.opos[0], y1 = this.opos[1], x2 = event.pageX, y2 = event.pageY;
  2214. if (x1 > x2) { var tmp = x2; x2 = x1; x1 = tmp; }
  2215. if (y1 > y2) { var tmp = y2; y2 = y1; y1 = tmp; }
  2216. this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
  2217. this.selectees.each(function() {
  2218. var selectee = $.data(this, "selectable-item");
  2219. //prevent helper from being selected if appendTo: selectable
  2220. if (!selectee || selectee.element == self.element[0])
  2221. return;
  2222. var hit = false;
  2223. if (options.tolerance == 'touch') {
  2224. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  2225. } else if (options.tolerance == 'fit') {
  2226. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  2227. }
  2228. if (hit) {
  2229. // SELECT
  2230. if (selectee.selected) {
  2231. selectee.$element.removeClass('ui-selected');
  2232. selectee.selected = false;
  2233. }
  2234. if (selectee.unselecting) {
  2235. selectee.$element.removeClass('ui-unselecting');
  2236. selectee.unselecting = false;
  2237. }
  2238. if (!selectee.selecting) {
  2239. selectee.$element.addClass('ui-selecting');
  2240. selectee.selecting = true;
  2241. // selectable SELECTING callback
  2242. self._trigger("selecting", event, {
  2243. selecting: selectee.element
  2244. });
  2245. }
  2246. } else {
  2247. // UNSELECT
  2248. if (selectee.selecting) {
  2249. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  2250. selectee.$element.removeClass('ui-selecting');
  2251. selectee.selecting = false;
  2252. selectee.$element.addClass('ui-selected');
  2253. selectee.selected = true;
  2254. } else {
  2255. selectee.$element.removeClass('ui-selecting');
  2256. selectee.selecting = false;
  2257. if (selectee.startselected) {
  2258. selectee.$element.addClass('ui-unselecting');
  2259. selectee.unselecting = true;
  2260. }
  2261. // selectable UNSELECTING callback
  2262. self._trigger("unselecting", event, {
  2263. unselecting: selectee.element
  2264. });
  2265. }
  2266. }
  2267. if (selectee.selected) {
  2268. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  2269. selectee.$element.removeClass('ui-selected');
  2270. selectee.selected = false;
  2271. selectee.$element.addClass('ui-unselecting');
  2272. selectee.unselecting = true;
  2273. // selectable UNSELECTING callback
  2274. self._trigger("unselecting", event, {
  2275. unselecting: selectee.element
  2276. });
  2277. }
  2278. }
  2279. }
  2280. });
  2281. return false;
  2282. },
  2283. _mouseStop: function(event) {
  2284. var self = this;
  2285. this.dragged = false;
  2286. var options = this.options;
  2287. $('.ui-unselecting', this.element[0]).each(function() {
  2288. var selectee = $.data(this, "selectable-item");
  2289. selectee.$element.removeClass('ui-unselecting');
  2290. selectee.unselecting = false;
  2291. selectee.startselected = false;
  2292. self._trigger("unselected", event, {
  2293. unselected: selectee.element
  2294. });
  2295. });
  2296. $('.ui-selecting', this.element[0]).each(function() {
  2297. var selectee = $.data(this, "selectable-item");
  2298. selectee.$element.removeClass('ui-selecting').addClass('ui-selected');
  2299. selectee.selecting = false;
  2300. selectee.selected = true;
  2301. selectee.startselected = true;
  2302. self._trigger("selected", event, {
  2303. selected: selectee.element
  2304. });
  2305. });
  2306. this._trigger("stop", event);
  2307. this.helper.remove();
  2308. return false;
  2309. }
  2310. });
  2311. $.extend($.ui.selectable, {
  2312. version: "1.8.20"
  2313. });
  2314. })(jQuery);
  2315. (function( $, undefined ) {
  2316. $.widget("ui.sortable", $.ui.mouse, {
  2317. widgetEventPrefix: "sort",
  2318. ready: false,
  2319. options: {
  2320. appendTo: "parent",
  2321. axis: false,
  2322. connectWith: false,
  2323. containment: false,
  2324. cursor: 'auto',
  2325. cursorAt: false,
  2326. dropOnEmpty: true,
  2327. forcePlaceholderSize: false,
  2328. forceHelperSize: false,
  2329. grid: false,
  2330. handle: false,
  2331. helper: "original",
  2332. items: '> *',
  2333. opacity: false,
  2334. placeholder: false,
  2335. revert: false,
  2336. scroll: true,
  2337. scrollSensitivity: 20,
  2338. scrollSpeed: 20,
  2339. scope: "default",
  2340. tolerance: "intersect",
  2341. zIndex: 1000
  2342. },
  2343. _create: function() {
  2344. var o = this.options;
  2345. this.containerCache = {};
  2346. this.element.addClass("ui-sortable");
  2347. //Get the items
  2348. this.refresh();
  2349. //Let's determine if the items are being displayed horizontally
  2350. 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;
  2351. //Let's determine the parent's offset
  2352. this.offset = this.element.offset();
  2353. //Initialize mouse events for interaction
  2354. this._mouseInit();
  2355. //We're ready to go
  2356. this.ready = true
  2357. },
  2358. destroy: function() {
  2359. $.Widget.prototype.destroy.call( this );
  2360. this.element
  2361. .removeClass("ui-sortable ui-sortable-disabled");
  2362. this._mouseDestroy();
  2363. for ( var i = this.items.length - 1; i >= 0; i-- )
  2364. this.items[i].item.removeData(this.widgetName + "-item");
  2365. return this;
  2366. },
  2367. _setOption: function(key, value){
  2368. if ( key === "disabled" ) {
  2369. this.options[ key ] = value;
  2370. this.widget()
  2371. [ value ? "addClass" : "removeClass"]( "ui-sortable-disabled" );
  2372. } else {
  2373. // Don't call widget base _setOption for disable as it adds ui-state-disabled class
  2374. $.Widget.prototype._setOption.apply(this, arguments);
  2375. }
  2376. },
  2377. _mouseCapture: function(event, overrideHandle) {
  2378. var that = this;
  2379. if (this.reverting) {
  2380. return false;
  2381. }
  2382. if(this.options.disabled || this.options.type == 'static') return false;
  2383. //We have to refresh the items data once first
  2384. this._refreshItems(event);
  2385. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  2386. var currentItem = null, self = this, nodes = $(event.target).parents().each(function() {
  2387. if($.data(this, that.widgetName + '-item') == self) {
  2388. currentItem = $(this);
  2389. return false;
  2390. }
  2391. });
  2392. if($.data(event.target, that.widgetName + '-item') == self) currentItem = $(event.target);
  2393. if(!currentItem) return false;
  2394. if(this.options.handle && !overrideHandle) {
  2395. var validHandle = false;
  2396. $(this.options.handle, currentItem).find("*").andSelf().each(function() { if(this == event.target) validHandle = true; });
  2397. if(!validHandle) return false;
  2398. }
  2399. this.currentItem = currentItem;
  2400. this._removeCurrentsFromItems();
  2401. return true;
  2402. },
  2403. _mouseStart: function(event, overrideHandle, noActivation) {
  2404. var o = this.options, self = this;
  2405. this.currentContainer = this;
  2406. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  2407. this.refreshPositions();
  2408. //Create and append the visible helper
  2409. this.helper = this._createHelper(event);
  2410. //Cache the helper size
  2411. this._cacheHelperProportions();
  2412. /*
  2413. * - Position generation -
  2414. * This block generates everything position related - it's the core of draggables.
  2415. */
  2416. //Cache the margins of the original element
  2417. this._cacheMargins();
  2418. //Get the next scrolling parent
  2419. this.scrollParent = this.helper.scrollParent();
  2420. //The element's absolute position on the page minus margins
  2421. this.offset = this.currentItem.offset();
  2422. this.offset = {
  2423. top: this.offset.top - this.margins.top,
  2424. left: this.offset.left - this.margins.left
  2425. };
  2426. // Only after we got the offset, we can change the helper's position to absolute
  2427. // TODO: Still need to figure out a way to make relative sorting possible
  2428. this.helper.css("position", "absolute");
  2429. this.cssPosition = this.helper.css("position");
  2430. $.extend(this.offset, {
  2431. click: { //Where the click happened, relative to the element
  2432. left: event.pageX - this.offset.left,
  2433. top: event.pageY - this.offset.top
  2434. },
  2435. parent: this._getParentOffset(),
  2436. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  2437. });
  2438. //Generate the original position
  2439. this.originalPosition = this._generatePosition(event);
  2440. this.originalPageX = event.pageX;
  2441. this.originalPageY = event.pageY;
  2442. //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
  2443. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  2444. //Cache the former DOM position
  2445. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  2446. //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
  2447. if(this.helper[0] != this.currentItem[0]) {
  2448. this.currentItem.hide();
  2449. }
  2450. //Create the placeholder
  2451. this._createPlaceholder();
  2452. //Set a containment if given in the options
  2453. if(o.containment)
  2454. this._setContainment();
  2455. if(o.cursor) { // cursor option
  2456. if ($('body').css("cursor")) this._storedCursor = $('body').css("cursor");
  2457. $('body').css("cursor", o.cursor);
  2458. }
  2459. if(o.opacity) { // opacity option
  2460. if (this.helper.css("opacity")) this._storedOpacity = this.helper.css("opacity");
  2461. this.helper.css("opacity", o.opacity);
  2462. }
  2463. if(o.zIndex) { // zIndex option
  2464. if (this.helper.css("zIndex")) this._storedZIndex = this.helper.css("zIndex");
  2465. this.helper.css("zIndex", o.zIndex);
  2466. }
  2467. //Prepare scrolling
  2468. if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML')
  2469. this.overflowOffset = this.scrollParent.offset();
  2470. //Call callbacks
  2471. this._trigger("start", event, this._uiHash());
  2472. //Recache the helper size
  2473. if(!this._preserveHelperProportions)
  2474. this._cacheHelperProportions();
  2475. //Post 'activate' events to possible containers
  2476. if(!noActivation) {
  2477. for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._trigger("activate", event, self._uiHash(this)); }
  2478. }
  2479. //Prepare possible droppables
  2480. if($.ui.ddmanager)
  2481. $.ui.ddmanager.current = this;
  2482. if ($.ui.ddmanager && !o.dropBehaviour)
  2483. $.ui.ddmanager.prepareOffsets(this, event);
  2484. this.dragging = true;
  2485. this.helper.addClass("ui-sortable-helper");
  2486. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  2487. return true;
  2488. },
  2489. _mouseDrag: function(event) {
  2490. //Compute the helpers position
  2491. this.position = this._generatePosition(event);
  2492. this.positionAbs = this._convertPositionTo("absolute");
  2493. if (!this.lastPositionAbs) {
  2494. this.lastPositionAbs = this.positionAbs;
  2495. }
  2496. //Do scrolling
  2497. if(this.options.scroll) {
  2498. var o = this.options, scrolled = false;
  2499. if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
  2500. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
  2501. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  2502. else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
  2503. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  2504. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
  2505. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  2506. else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
  2507. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  2508. } else {
  2509. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
  2510. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  2511. else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
  2512. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  2513. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
  2514. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  2515. else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
  2516. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  2517. }
  2518. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
  2519. $.ui.ddmanager.prepareOffsets(this, event);
  2520. }
  2521. //Regenerate the absolute position used for position checks
  2522. this.positionAbs = this._convertPositionTo("absolute");
  2523. //Set the helper position
  2524. if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
  2525. if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
  2526. //Rearrange
  2527. for (var i = this.items.length - 1; i >= 0; i--) {
  2528. //Cache variables and intersection, continue if no intersection
  2529. var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item);
  2530. if (!intersection) continue;
  2531. if(itemElement != this.currentItem[0] //cannot intersect with itself
  2532. && this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
  2533. && !$.ui.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
  2534. && (this.options.type == 'semi-dynamic' ? !$.ui.contains(this.element[0], itemElement) : true)
  2535. //&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container
  2536. ) {
  2537. this.direction = intersection == 1 ? "down" : "up";
  2538. if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) {
  2539. this._rearrange(event, item);
  2540. } else {
  2541. break;
  2542. }
  2543. this._trigger("change", event, this._uiHash());
  2544. break;
  2545. }
  2546. }
  2547. //Post events to containers
  2548. this._contactContainers(event);
  2549. //Interconnect with droppables
  2550. if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
  2551. //Call callbacks
  2552. this._trigger('sort', event, this._uiHash());
  2553. this.lastPositionAbs = this.positionAbs;
  2554. return false;
  2555. },
  2556. _mouseStop: function(event, noPropagation) {
  2557. if(!event) return;
  2558. //If we are using droppables, inform the manager about the drop
  2559. if ($.ui.ddmanager && !this.options.dropBehaviour)
  2560. $.ui.ddmanager.drop(this, event);
  2561. if(this.options.revert) {
  2562. var self = this;
  2563. var cur = self.placeholder.offset();
  2564. self.reverting = true;
  2565. $(this.helper).animate({
  2566. left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
  2567. top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
  2568. }, parseInt(this.options.revert, 10) || 500, function() {
  2569. self._clear(event);
  2570. });
  2571. } else {
  2572. this._clear(event, noPropagation);
  2573. }
  2574. return false;
  2575. },
  2576. cancel: function() {
  2577. var self = this;
  2578. if(this.dragging) {
  2579. this._mouseUp({ target: null });
  2580. if(this.options.helper == "original")
  2581. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  2582. else
  2583. this.currentItem.show();
  2584. //Post deactivating events to containers
  2585. for (var i = this.containers.length - 1; i >= 0; i--){
  2586. this.containers[i]._trigger("deactivate", null, self._uiHash(this));
  2587. if(this.containers[i].containerCache.over) {
  2588. this.containers[i]._trigger("out", null, self._uiHash(this));
  2589. this.containers[i].containerCache.over = 0;
  2590. }
  2591. }
  2592. }
  2593. if (this.placeholder) {
  2594. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  2595. if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  2596. if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove();
  2597. $.extend(this, {
  2598. helper: null,
  2599. dragging: false,
  2600. reverting: false,
  2601. _noFinalSort: null
  2602. });
  2603. if(this.domPosition.prev) {
  2604. $(this.domPosition.prev).after(this.currentItem);
  2605. } else {
  2606. $(this.domPosition.parent).prepend(this.currentItem);
  2607. }
  2608. }
  2609. return this;
  2610. },
  2611. serialize: function(o) {
  2612. var items = this._getItemsAsjQuery(o && o.connected);
  2613. var str = []; o = o || {};
  2614. $(items).each(function() {
  2615. var res = ($(o.item || this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
  2616. if(res) str.push((o.key || res[1]+'[]')+'='+(o.key && o.expression ? res[1] : res[2]));
  2617. });
  2618. if(!str.length && o.key) {
  2619. str.push(o.key + '=');
  2620. }
  2621. return str.join('&');
  2622. },
  2623. toArray: function(o) {
  2624. var items = this._getItemsAsjQuery(o && o.connected);
  2625. var ret = []; o = o || {};
  2626. items.each(function() { ret.push($(o.item || this).attr(o.attribute || 'id') || ''); });
  2627. return ret;
  2628. },
  2629. /* Be careful with the following core functions */
  2630. _intersectsWith: function(item) {
  2631. var x1 = this.positionAbs.left,
  2632. x2 = x1 + this.helperProportions.width,
  2633. y1 = this.positionAbs.top,
  2634. y2 = y1 + this.helperProportions.height;
  2635. var l = item.left,
  2636. r = l + item.width,
  2637. t = item.top,
  2638. b = t + item.height;
  2639. var dyClick = this.offset.click.top,
  2640. dxClick = this.offset.click.left;
  2641. var isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r;
  2642. if( this.options.tolerance == "pointer"
  2643. || this.options.forcePointerForContainers
  2644. || (this.options.tolerance != "pointer" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])
  2645. ) {
  2646. return isOverElement;
  2647. } else {
  2648. return (l < x1 + (this.helperProportions.width / 2) // Right Half
  2649. && x2 - (this.helperProportions.width / 2) < r // Left Half
  2650. && t < y1 + (this.helperProportions.height / 2) // Bottom Half
  2651. && y2 - (this.helperProportions.height / 2) < b ); // Top Half
  2652. }
  2653. },
  2654. _intersectsWithPointer: function(item) {
  2655. var isOverElementHeight = (this.options.axis === 'x') || $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  2656. isOverElementWidth = (this.options.axis === 'y') || $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  2657. isOverElement = isOverElementHeight && isOverElementWidth,
  2658. verticalDirection = this._getDragVerticalDirection(),
  2659. horizontalDirection = this._getDragHorizontalDirection();
  2660. if (!isOverElement)
  2661. return false;
  2662. return this.floating ?
  2663. ( ((horizontalDirection && horizontalDirection == "right") || verticalDirection == "down") ? 2 : 1 )
  2664. : ( verticalDirection && (verticalDirection == "down" ? 2 : 1) );
  2665. },
  2666. _intersectsWithSides: function(item) {
  2667. var isOverBottomHalf = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  2668. isOverRightHalf = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  2669. verticalDirection = this._getDragVerticalDirection(),
  2670. horizontalDirection = this._getDragHorizontalDirection();
  2671. if (this.floating && horizontalDirection) {
  2672. return ((horizontalDirection == "right" && isOverRightHalf) || (horizontalDirection == "left" && !isOverRightHalf));
  2673. } else {
  2674. return verticalDirection && ((verticalDirection == "down" && isOverBottomHalf) || (verticalDirection == "up" && !isOverBottomHalf));
  2675. }
  2676. },
  2677. _getDragVerticalDirection: function() {
  2678. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  2679. return delta != 0 && (delta > 0 ? "down" : "up");
  2680. },
  2681. _getDragHorizontalDirection: function() {
  2682. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  2683. return delta != 0 && (delta > 0 ? "right" : "left");
  2684. },
  2685. refresh: function(event) {
  2686. this._refreshItems(event);
  2687. this.refreshPositions();
  2688. return this;
  2689. },
  2690. _connectWith: function() {
  2691. var options = this.options;
  2692. return options.connectWith.constructor == String
  2693. ? [options.connectWith]
  2694. : options.connectWith;
  2695. },
  2696. _getItemsAsjQuery: function(connected) {
  2697. var self = this;
  2698. var items = [];
  2699. var queries = [];
  2700. var connectWith = this._connectWith();
  2701. if(connectWith && connected) {
  2702. for (var i = connectWith.length - 1; i >= 0; i--){
  2703. var cur = $(connectWith[i]);
  2704. for (var j = cur.length - 1; j >= 0; j--){
  2705. var inst = $.data(cur[j], this.widgetName);
  2706. if(inst && inst != this && !inst.options.disabled) {
  2707. 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]);
  2708. }
  2709. };
  2710. };
  2711. }
  2712. 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]);
  2713. for (var i = queries.length - 1; i >= 0; i--){
  2714. queries[i][0].each(function() {
  2715. items.push(this);
  2716. });
  2717. };
  2718. return $(items);
  2719. },
  2720. _removeCurrentsFromItems: function() {
  2721. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  2722. for (var i=0; i < this.items.length; i++) {
  2723. for (var j=0; j < list.length; j++) {
  2724. if(list[j] == this.items[i].item[0])
  2725. this.items.splice(i,1);
  2726. };
  2727. };
  2728. },
  2729. _refreshItems: function(event) {
  2730. this.items = [];
  2731. this.containers = [this];
  2732. var items = this.items;
  2733. var self = this;
  2734. var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]];
  2735. var connectWith = this._connectWith();
  2736. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  2737. for (var i = connectWith.length - 1; i >= 0; i--){
  2738. var cur = $(connectWith[i]);
  2739. for (var j = cur.length - 1; j >= 0; j--){
  2740. var inst = $.data(cur[j], this.widgetName);
  2741. if(inst && inst != this && !inst.options.disabled) {
  2742. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  2743. this.containers.push(inst);
  2744. }
  2745. };
  2746. };
  2747. }
  2748. for (var i = queries.length - 1; i >= 0; i--) {
  2749. var targetData = queries[i][1];
  2750. var _queries = queries[i][0];
  2751. for (var j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  2752. var item = $(_queries[j]);
  2753. item.data(this.widgetName + '-item', targetData); // Data for target checking (mouse manager)
  2754. items.push({
  2755. item: item,
  2756. instance: targetData,
  2757. width: 0, height: 0,
  2758. left: 0, top: 0
  2759. });
  2760. };
  2761. };
  2762. },
  2763. refreshPositions: function(fast) {
  2764. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  2765. if(this.offsetParent && this.helper) {
  2766. this.offset.parent = this._getParentOffset();
  2767. }
  2768. for (var i = this.items.length - 1; i >= 0; i--){
  2769. var item = this.items[i];
  2770. //We ignore calculating positions of all connected containers when we're not over them
  2771. if(item.instance != this.currentContainer && this.currentContainer && item.item[0] != this.currentItem[0])
  2772. continue;
  2773. var t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  2774. if (!fast) {
  2775. item.width = t.outerWidth();
  2776. item.height = t.outerHeight();
  2777. }
  2778. var p = t.offset();
  2779. item.left = p.left;
  2780. item.top = p.top;
  2781. };
  2782. if(this.options.custom && this.options.custom.refreshContainers) {
  2783. this.options.custom.refreshContainers.call(this);
  2784. } else {
  2785. for (var i = this.containers.length - 1; i >= 0; i--){
  2786. var p = this.containers[i].element.offset();
  2787. this.containers[i].containerCache.left = p.left;
  2788. this.containers[i].containerCache.top = p.top;
  2789. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  2790. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  2791. };
  2792. }
  2793. return this;
  2794. },
  2795. _createPlaceholder: function(that) {
  2796. var self = that || this, o = self.options;
  2797. if(!o.placeholder || o.placeholder.constructor == String) {
  2798. var className = o.placeholder;
  2799. o.placeholder = {
  2800. element: function() {
  2801. var el = $(document.createElement(self.currentItem[0].nodeName))
  2802. .addClass(className || self.currentItem[0].className+" ui-sortable-placeholder")
  2803. .removeClass("ui-sortable-helper")[0];
  2804. if(!className)
  2805. el.style.visibility = "hidden";
  2806. return el;
  2807. },
  2808. update: function(container, p) {
  2809. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  2810. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  2811. if(className && !o.forcePlaceholderSize) return;
  2812. //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
  2813. if(!p.height()) { p.height(self.currentItem.innerHeight() - parseInt(self.currentItem.css('paddingTop')||0, 10) - parseInt(self.currentItem.css('paddingBottom')||0, 10)); };
  2814. if(!p.width()) { p.width(self.currentItem.innerWidth() - parseInt(self.currentItem.css('paddingLeft')||0, 10) - parseInt(self.currentItem.css('paddingRight')||0, 10)); };
  2815. }
  2816. };
  2817. }
  2818. //Create the placeholder
  2819. self.placeholder = $(o.placeholder.element.call(self.element, self.currentItem));
  2820. //Append it after the actual current item
  2821. self.currentItem.after(self.placeholder);
  2822. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  2823. o.placeholder.update(self, self.placeholder);
  2824. },
  2825. _contactContainers: function(event) {
  2826. // get innermost container that intersects with item
  2827. var innermostContainer = null, innermostIndex = null;
  2828. for (var i = this.containers.length - 1; i >= 0; i--){
  2829. // never consider a container that's located within the item itself
  2830. if($.ui.contains(this.currentItem[0], this.containers[i].element[0]))
  2831. continue;
  2832. if(this._intersectsWith(this.containers[i].containerCache)) {
  2833. // if we've already found a container and it's more "inner" than this, then continue
  2834. if(innermostContainer && $.ui.contains(this.containers[i].element[0], innermostContainer.element[0]))
  2835. continue;
  2836. innermostContainer = this.containers[i];
  2837. innermostIndex = i;
  2838. } else {
  2839. // container doesn't intersect. trigger "out" event if necessary
  2840. if(this.containers[i].containerCache.over) {
  2841. this.containers[i]._trigger("out", event, this._uiHash(this));
  2842. this.containers[i].containerCache.over = 0;
  2843. }
  2844. }
  2845. }
  2846. // if no intersecting containers found, return
  2847. if(!innermostContainer) return;
  2848. // move the item into the container if it's not there already
  2849. if(this.containers.length === 1) {
  2850. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  2851. this.containers[innermostIndex].containerCache.over = 1;
  2852. } else if(this.currentContainer != this.containers[innermostIndex]) {
  2853. //When entering a new container, we will find the item with the least distance and append our item near it
  2854. var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[innermostIndex].floating ? 'left' : 'top'];
  2855. for (var j = this.items.length - 1; j >= 0; j--) {
  2856. if(!$.ui.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue;
  2857. var cur = this.items[j][this.containers[innermostIndex].floating ? 'left' : 'top'];
  2858. if(Math.abs(cur - base) < dist) {
  2859. dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
  2860. }
  2861. }
  2862. if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled
  2863. return;
  2864. this.currentContainer = this.containers[innermostIndex];
  2865. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  2866. this._trigger("change", event, this._uiHash());
  2867. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  2868. //Update the placeholder
  2869. this.options.placeholder.update(this.currentContainer, this.placeholder);
  2870. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  2871. this.containers[innermostIndex].containerCache.over = 1;
  2872. }
  2873. },
  2874. _createHelper: function(event) {
  2875. var o = this.options;
  2876. var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper == 'clone' ? this.currentItem.clone() : this.currentItem);
  2877. if(!helper.parents('body').length) //Add the helper to the DOM if that didn't happen already
  2878. $(o.appendTo != 'parent' ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  2879. if(helper[0] == this.currentItem[0])
  2880. 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") };
  2881. if(helper[0].style.width == '' || o.forceHelperSize) helper.width(this.currentItem.width());
  2882. if(helper[0].style.height == '' || o.forceHelperSize) helper.height(this.currentItem.height());
  2883. return helper;
  2884. },
  2885. _adjustOffsetFromHelper: function(obj) {
  2886. if (typeof obj == 'string') {
  2887. obj = obj.split(' ');
  2888. }
  2889. if ($.isArray(obj)) {
  2890. obj = {left: +obj[0], top: +obj[1] || 0};
  2891. }
  2892. if ('left' in obj) {
  2893. this.offset.click.left = obj.left + this.margins.left;
  2894. }
  2895. if ('right' in obj) {
  2896. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  2897. }
  2898. if ('top' in obj) {
  2899. this.offset.click.top = obj.top + this.margins.top;
  2900. }
  2901. if ('bottom' in obj) {
  2902. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  2903. }
  2904. },
  2905. _getParentOffset: function() {
  2906. //Get the offsetParent and cache its position
  2907. this.offsetParent = this.helper.offsetParent();
  2908. var po = this.offsetParent.offset();
  2909. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  2910. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  2911. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  2912. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  2913. if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
  2914. po.left += this.scrollParent.scrollLeft();
  2915. po.top += this.scrollParent.scrollTop();
  2916. }
  2917. if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
  2918. || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
  2919. po = { top: 0, left: 0 };
  2920. return {
  2921. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  2922. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  2923. };
  2924. },
  2925. _getRelativeOffset: function() {
  2926. if(this.cssPosition == "relative") {
  2927. var p = this.currentItem.position();
  2928. return {
  2929. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  2930. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  2931. };
  2932. } else {
  2933. return { top: 0, left: 0 };
  2934. }
  2935. },
  2936. _cacheMargins: function() {
  2937. this.margins = {
  2938. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  2939. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  2940. };
  2941. },
  2942. _cacheHelperProportions: function() {
  2943. this.helperProportions = {
  2944. width: this.helper.outerWidth(),
  2945. height: this.helper.outerHeight()
  2946. };
  2947. },
  2948. _setContainment: function() {
  2949. var o = this.options;
  2950. if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
  2951. if(o.containment == 'document' || o.containment == 'window') this.containment = [
  2952. 0 - this.offset.relative.left - this.offset.parent.left,
  2953. 0 - this.offset.relative.top - this.offset.parent.top,
  2954. $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
  2955. ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  2956. ];
  2957. if(!(/^(document|window|parent)$/).test(o.containment)) {
  2958. var ce = $(o.containment)[0];
  2959. var co = $(o.containment).offset();
  2960. var over = ($(ce).css("overflow") != 'hidden');
  2961. this.containment = [
  2962. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  2963. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  2964. 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,
  2965. 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
  2966. ];
  2967. }
  2968. },
  2969. _convertPositionTo: function(d, pos) {
  2970. if(!pos) pos = this.position;
  2971. var mod = d == "absolute" ? 1 : -1;
  2972. 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);
  2973. return {
  2974. top: (
  2975. pos.top // The absolute mouse position
  2976. + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent
  2977. + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
  2978. - ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  2979. ),
  2980. left: (
  2981. pos.left // The absolute mouse position
  2982. + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent
  2983. + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
  2984. - ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  2985. )
  2986. };
  2987. },
  2988. _generatePosition: function(event) {
  2989. 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);
  2990. // This is another very weird special case that only happens for relative elements:
  2991. // 1. If the css position is relative
  2992. // 2. and the scroll parent is the document or similar to the offset parent
  2993. // we have to refresh the relative offset during the scroll so there are no jumps
  2994. if(this.cssPosition == 'relative' && !(this.scrollParent[0] != document && this.scrollParent[0] != this.offsetParent[0])) {
  2995. this.offset.relative = this._getRelativeOffset();
  2996. }
  2997. var pageX = event.pageX;
  2998. var pageY = event.pageY;
  2999. /*
  3000. * - Position constraining -
  3001. * Constrain the position to a mix of grid, containment.
  3002. */
  3003. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  3004. if(this.containment) {
  3005. if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left;
  3006. if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top;
  3007. if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left;
  3008. if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top;
  3009. }
  3010. if(o.grid) {
  3011. var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  3012. 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;
  3013. var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  3014. 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;
  3015. }
  3016. }
  3017. return {
  3018. top: (
  3019. pageY // The absolute mouse position
  3020. - this.offset.click.top // Click offset (relative to the element)
  3021. - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent
  3022. - this.offset.parent.top // The offsetParent's offset without borders (offset + border)
  3023. + ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  3024. ),
  3025. left: (
  3026. pageX // The absolute mouse position
  3027. - this.offset.click.left // Click offset (relative to the element)
  3028. - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent
  3029. - this.offset.parent.left // The offsetParent's offset without borders (offset + border)
  3030. + ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  3031. )
  3032. };
  3033. },
  3034. _rearrange: function(event, i, a, hardRefresh) {
  3035. 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));
  3036. //Various things done here to improve the performance:
  3037. // 1. we create a setTimeout, that calls refreshPositions
  3038. // 2. on the instance, we have a counter variable, that get's higher after every append
  3039. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  3040. // 4. this lets only the last addition to the timeout stack through
  3041. this.counter = this.counter ? ++this.counter : 1;
  3042. var self = this, counter = this.counter;
  3043. window.setTimeout(function() {
  3044. if(counter == self.counter) self.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  3045. },0);
  3046. },
  3047. _clear: function(event, noPropagation) {
  3048. this.reverting = false;
  3049. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  3050. // everything else normalized again
  3051. var delayedTriggers = [], self = this;
  3052. // We first have to update the dom position of the actual currentItem
  3053. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  3054. if(!this._noFinalSort && this.currentItem.parent().length) this.placeholder.before(this.currentItem);
  3055. this._noFinalSort = null;
  3056. if(this.helper[0] == this.currentItem[0]) {
  3057. for(var i in this._storedCSS) {
  3058. if(this._storedCSS[i] == 'auto' || this._storedCSS[i] == 'static') this._storedCSS[i] = '';
  3059. }
  3060. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  3061. } else {
  3062. this.currentItem.show();
  3063. }
  3064. if(this.fromOutside && !noPropagation) delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  3065. 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
  3066. if(!$.ui.contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element
  3067. if(!noPropagation) delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  3068. for (var i = this.containers.length - 1; i >= 0; i--){
  3069. if($.ui.contains(this.containers[i].element[0], this.currentItem[0]) && !noPropagation) {
  3070. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  3071. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  3072. }
  3073. };
  3074. };
  3075. //Post events to containers
  3076. for (var i = this.containers.length - 1; i >= 0; i--){
  3077. if(!noPropagation) delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  3078. if(this.containers[i].containerCache.over) {
  3079. delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  3080. this.containers[i].containerCache.over = 0;
  3081. }
  3082. }
  3083. //Do what was originally in plugins
  3084. if(this._storedCursor) $('body').css("cursor", this._storedCursor); //Reset cursor
  3085. if(this._storedOpacity) this.helper.css("opacity", this._storedOpacity); //Reset opacity
  3086. if(this._storedZIndex) this.helper.css("zIndex", this._storedZIndex == 'auto' ? '' : this._storedZIndex); //Reset z-index
  3087. this.dragging = false;
  3088. if(this.cancelHelperRemoval) {
  3089. if(!noPropagation) {
  3090. this._trigger("beforeStop", event, this._uiHash());
  3091. for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
  3092. this._trigger("stop", event, this._uiHash());
  3093. }
  3094. return false;
  3095. }
  3096. if(!noPropagation) this._trigger("beforeStop", event, this._uiHash());
  3097. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  3098. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  3099. if(this.helper[0] != this.currentItem[0]) this.helper.remove(); this.helper = null;
  3100. if(!noPropagation) {
  3101. for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
  3102. this._trigger("stop", event, this._uiHash());
  3103. }
  3104. this.fromOutside = false;
  3105. return true;
  3106. },
  3107. _trigger: function() {
  3108. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  3109. this.cancel();
  3110. }
  3111. },
  3112. _uiHash: function(inst) {
  3113. var self = inst || this;
  3114. return {
  3115. helper: self.helper,
  3116. placeholder: self.placeholder || $([]),
  3117. position: self.position,
  3118. originalPosition: self.originalPosition,
  3119. offset: self.positionAbs,
  3120. item: self.currentItem,
  3121. sender: inst ? inst.element : null
  3122. };
  3123. }
  3124. });
  3125. $.extend($.ui.sortable, {
  3126. version: "1.8.20"
  3127. });
  3128. })(jQuery);
  3129. ;jQuery.effects || (function($, undefined) {
  3130. $.effects = {};
  3131. /******************************************************************************/
  3132. /****************************** COLOR ANIMATIONS ******************************/
  3133. /******************************************************************************/
  3134. // override the animation for color styles
  3135. $.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor',
  3136. 'borderRightColor', 'borderTopColor', 'borderColor', 'color', 'outlineColor'],
  3137. function(i, attr) {
  3138. $.fx.step[attr] = function(fx) {
  3139. if (!fx.colorInit) {
  3140. fx.start = getColor(fx.elem, attr);
  3141. fx.end = getRGB(fx.end);
  3142. fx.colorInit = true;
  3143. }
  3144. fx.elem.style[attr] = 'rgb(' +
  3145. Math.max(Math.min(parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0], 10), 255), 0) + ',' +
  3146. Math.max(Math.min(parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1], 10), 255), 0) + ',' +
  3147. Math.max(Math.min(parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2], 10), 255), 0) + ')';
  3148. };
  3149. });
  3150. // Color Conversion functions from highlightFade
  3151. // By Blair Mitchelmore
  3152. // http://jquery.offput.ca/highlightFade/
  3153. // Parse strings looking for color tuples [255,255,255]
  3154. function getRGB(color) {
  3155. var result;
  3156. // Check if we're already dealing with an array of colors
  3157. if ( color && color.constructor == Array && color.length == 3 )
  3158. return color;
  3159. // Look for rgb(num,num,num)
  3160. if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
  3161. return [parseInt(result[1],10), parseInt(result[2],10), parseInt(result[3],10)];
  3162. // Look for rgb(num%,num%,num%)
  3163. if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
  3164. return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
  3165. // Look for #a0b1c2
  3166. if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
  3167. return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
  3168. // Look for #fff
  3169. if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
  3170. return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
  3171. // Look for rgba(0, 0, 0, 0) == transparent in Safari 3
  3172. if (result = /rgba\(0, 0, 0, 0\)/.exec(color))
  3173. return colors['transparent'];
  3174. // Otherwise, we're most likely dealing with a named color
  3175. return colors[$.trim(color).toLowerCase()];
  3176. }
  3177. function getColor(elem, attr) {
  3178. var color;
  3179. do {
  3180. color = $.curCSS(elem, attr);
  3181. // Keep going until we find an element that has color, or we hit the body
  3182. if ( color != '' && color != 'transparent' || $.nodeName(elem, "body") )
  3183. break;
  3184. attr = "backgroundColor";
  3185. } while ( elem = elem.parentNode );
  3186. return getRGB(color);
  3187. };
  3188. // Some named colors to work with
  3189. // From Interface by Stefan Petre
  3190. // http://interface.eyecon.ro/
  3191. var colors = {
  3192. aqua:[0,255,255],
  3193. azure:[240,255,255],
  3194. beige:[245,245,220],
  3195. black:[0,0,0],
  3196. blue:[0,0,255],
  3197. brown:[165,42,42],
  3198. cyan:[0,255,255],
  3199. darkblue:[0,0,139],
  3200. darkcyan:[0,139,139],
  3201. darkgrey:[169,169,169],
  3202. darkgreen:[0,100,0],
  3203. darkkhaki:[189,183,107],
  3204. darkmagenta:[139,0,139],
  3205. darkolivegreen:[85,107,47],
  3206. darkorange:[255,140,0],
  3207. darkorchid:[153,50,204],
  3208. darkred:[139,0,0],
  3209. darksalmon:[233,150,122],
  3210. darkviolet:[148,0,211],
  3211. fuchsia:[255,0,255],
  3212. gold:[255,215,0],
  3213. green:[0,128,0],
  3214. indigo:[75,0,130],
  3215. khaki:[240,230,140],
  3216. lightblue:[173,216,230],
  3217. lightcyan:[224,255,255],
  3218. lightgreen:[144,238,144],
  3219. lightgrey:[211,211,211],
  3220. lightpink:[255,182,193],
  3221. lightyellow:[255,255,224],
  3222. lime:[0,255,0],
  3223. magenta:[255,0,255],
  3224. maroon:[128,0,0],
  3225. navy:[0,0,128],
  3226. olive:[128,128,0],
  3227. orange:[255,165,0],
  3228. pink:[255,192,203],
  3229. purple:[128,0,128],
  3230. violet:[128,0,128],
  3231. red:[255,0,0],
  3232. silver:[192,192,192],
  3233. white:[255,255,255],
  3234. yellow:[255,255,0],
  3235. transparent: [255,255,255]
  3236. };
  3237. /******************************************************************************/
  3238. /****************************** CLASS ANIMATIONS ******************************/
  3239. /******************************************************************************/
  3240. var classAnimationActions = ['add', 'remove', 'toggle'],
  3241. shorthandStyles = {
  3242. border: 1,
  3243. borderBottom: 1,
  3244. borderColor: 1,
  3245. borderLeft: 1,
  3246. borderRight: 1,
  3247. borderTop: 1,
  3248. borderWidth: 1,
  3249. margin: 1,
  3250. padding: 1
  3251. };
  3252. function getElementStyles() {
  3253. var style = document.defaultView
  3254. ? document.defaultView.getComputedStyle(this, null)
  3255. : this.currentStyle,
  3256. newStyle = {},
  3257. key,
  3258. camelCase;
  3259. // webkit enumerates style porperties
  3260. if (style && style.length && style[0] && style[style[0]]) {
  3261. var len = style.length;
  3262. while (len--) {
  3263. key = style[len];
  3264. if (typeof style[key] == 'string') {
  3265. camelCase = key.replace(/\-(\w)/g, function(all, letter){
  3266. return letter.toUpperCase();
  3267. });
  3268. newStyle[camelCase] = style[key];
  3269. }
  3270. }
  3271. } else {
  3272. for (key in style) {
  3273. if (typeof style[key] === 'string') {
  3274. newStyle[key] = style[key];
  3275. }
  3276. }
  3277. }
  3278. return newStyle;
  3279. }
  3280. function filterStyles(styles) {
  3281. var name, value;
  3282. for (name in styles) {
  3283. value = styles[name];
  3284. if (
  3285. // ignore null and undefined values
  3286. value == null ||
  3287. // ignore functions (when does this occur?)
  3288. $.isFunction(value) ||
  3289. // shorthand styles that need to be expanded
  3290. name in shorthandStyles ||
  3291. // ignore scrollbars (break in IE)
  3292. (/scrollbar/).test(name) ||
  3293. // only colors or values that can be converted to numbers
  3294. (!(/color/i).test(name) && isNaN(parseFloat(value)))
  3295. ) {
  3296. delete styles[name];
  3297. }
  3298. }
  3299. return styles;
  3300. }
  3301. function styleDifference(oldStyle, newStyle) {
  3302. var diff = { _: 0 }, // http://dev.jquery.com/ticket/5459
  3303. name;
  3304. for (name in newStyle) {
  3305. if (oldStyle[name] != newStyle[name]) {
  3306. diff[name] = newStyle[name];
  3307. }
  3308. }
  3309. return diff;
  3310. }
  3311. $.effects.animateClass = function(value, duration, easing, callback) {
  3312. if ($.isFunction(easing)) {
  3313. callback = easing;
  3314. easing = null;
  3315. }
  3316. return this.queue(function() {
  3317. var that = $(this),
  3318. originalStyleAttr = that.attr('style') || ' ',
  3319. originalStyle = filterStyles(getElementStyles.call(this)),
  3320. newStyle,
  3321. className = that.attr('class') || "";
  3322. $.each(classAnimationActions, function(i, action) {
  3323. if (value[action]) {
  3324. that[action + 'Class'](value[action]);
  3325. }
  3326. });
  3327. newStyle = filterStyles(getElementStyles.call(this));
  3328. that.attr('class', className);
  3329. that.animate(styleDifference(originalStyle, newStyle), {
  3330. queue: false,
  3331. duration: duration,
  3332. easing: easing,
  3333. complete: function() {
  3334. $.each(classAnimationActions, function(i, action) {
  3335. if (value[action]) { that[action + 'Class'](value[action]); }
  3336. });
  3337. // work around bug in IE by clearing the cssText before setting it
  3338. if (typeof that.attr('style') == 'object') {
  3339. that.attr('style').cssText = '';
  3340. that.attr('style').cssText = originalStyleAttr;
  3341. } else {
  3342. that.attr('style', originalStyleAttr);
  3343. }
  3344. if (callback) { callback.apply(this, arguments); }
  3345. $.dequeue( this );
  3346. }
  3347. });
  3348. });
  3349. };
  3350. $.fn.extend({
  3351. _addClass: $.fn.addClass,
  3352. addClass: function(classNames, speed, easing, callback) {
  3353. return speed ? $.effects.animateClass.apply(this, [{ add: classNames },speed,easing,callback]) : this._addClass(classNames);
  3354. },
  3355. _removeClass: $.fn.removeClass,
  3356. removeClass: function(classNames,speed,easing,callback) {
  3357. return speed ? $.effects.animateClass.apply(this, [{ remove: classNames },speed,easing,callback]) : this._removeClass(classNames);
  3358. },
  3359. _toggleClass: $.fn.toggleClass,
  3360. toggleClass: function(classNames, force, speed, easing, callback) {
  3361. if ( typeof force == "boolean" || force === undefined ) {
  3362. if ( !speed ) {
  3363. // without speed parameter;
  3364. return this._toggleClass(classNames, force);
  3365. } else {
  3366. return $.effects.animateClass.apply(this, [(force?{add:classNames}:{remove:classNames}),speed,easing,callback]);
  3367. }
  3368. } else {
  3369. // without switch parameter;
  3370. return $.effects.animateClass.apply(this, [{ toggle: classNames },force,speed,easing]);
  3371. }
  3372. },
  3373. switchClass: function(remove,add,speed,easing,callback) {
  3374. return $.effects.animateClass.apply(this, [{ add: add, remove: remove },speed,easing,callback]);
  3375. }
  3376. });
  3377. /******************************************************************************/
  3378. /*********************************** EFFECTS **********************************/
  3379. /******************************************************************************/
  3380. $.extend($.effects, {
  3381. version: "1.8.20",
  3382. // Saves a set of properties in a data storage
  3383. save: function(element, set) {
  3384. for(var i=0; i < set.length; i++) {
  3385. if(set[i] !== null) element.data("ec.storage."+set[i], element[0].style[set[i]]);
  3386. }
  3387. },
  3388. // Restores a set of previously saved properties from a data storage
  3389. restore: function(element, set) {
  3390. for(var i=0; i < set.length; i++) {
  3391. if(set[i] !== null) element.css(set[i], element.data("ec.storage."+set[i]));
  3392. }
  3393. },
  3394. setMode: function(el, mode) {
  3395. if (mode == 'toggle') mode = el.is(':hidden') ? 'show' : 'hide'; // Set for toggle
  3396. return mode;
  3397. },
  3398. getBaseline: function(origin, original) { // Translates a [top,left] array into a baseline value
  3399. // this should be a little more flexible in the future to handle a string & hash
  3400. var y, x;
  3401. switch (origin[0]) {
  3402. case 'top': y = 0; break;
  3403. case 'middle': y = 0.5; break;
  3404. case 'bottom': y = 1; break;
  3405. default: y = origin[0] / original.height;
  3406. };
  3407. switch (origin[1]) {
  3408. case 'left': x = 0; break;
  3409. case 'center': x = 0.5; break;
  3410. case 'right': x = 1; break;
  3411. default: x = origin[1] / original.width;
  3412. };
  3413. return {x: x, y: y};
  3414. },
  3415. // Wraps the element around a wrapper that copies position properties
  3416. createWrapper: function(element) {
  3417. // if the element is already wrapped, return it
  3418. if (element.parent().is('.ui-effects-wrapper')) {
  3419. return element.parent();
  3420. }
  3421. // wrap the element
  3422. var props = {
  3423. width: element.outerWidth(true),
  3424. height: element.outerHeight(true),
  3425. 'float': element.css('float')
  3426. },
  3427. wrapper = $('<div></div>')
  3428. .addClass('ui-effects-wrapper')
  3429. .css({
  3430. fontSize: '100%',
  3431. background: 'transparent',
  3432. border: 'none',
  3433. margin: 0,
  3434. padding: 0
  3435. }),
  3436. active = document.activeElement;
  3437. element.wrap(wrapper);
  3438. // Fixes #7595 - Elements lose focus when wrapped.
  3439. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  3440. $( active ).focus();
  3441. }
  3442. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually loose the reference to the wrapped element
  3443. // transfer positioning properties to the wrapper
  3444. if (element.css('position') == 'static') {
  3445. wrapper.css({ position: 'relative' });
  3446. element.css({ position: 'relative' });
  3447. } else {
  3448. $.extend(props, {
  3449. position: element.css('position'),
  3450. zIndex: element.css('z-index')
  3451. });
  3452. $.each(['top', 'left', 'bottom', 'right'], function(i, pos) {
  3453. props[pos] = element.css(pos);
  3454. if (isNaN(parseInt(props[pos], 10))) {
  3455. props[pos] = 'auto';
  3456. }
  3457. });
  3458. element.css({position: 'relative', top: 0, left: 0, right: 'auto', bottom: 'auto' });
  3459. }
  3460. return wrapper.css(props).show();
  3461. },
  3462. removeWrapper: function(element) {
  3463. var parent,
  3464. active = document.activeElement;
  3465. if (element.parent().is('.ui-effects-wrapper')) {
  3466. parent = element.parent().replaceWith(element);
  3467. // Fixes #7595 - Elements lose focus when wrapped.
  3468. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  3469. $( active ).focus();
  3470. }
  3471. return parent;
  3472. }
  3473. return element;
  3474. },
  3475. setTransition: function(element, list, factor, value) {
  3476. value = value || {};
  3477. $.each(list, function(i, x){
  3478. var unit = element.cssUnit(x);
  3479. if (unit[0] > 0) value[x] = unit[0] * factor + unit[1];
  3480. });
  3481. return value;
  3482. }
  3483. });
  3484. function _normalizeArguments(effect, options, speed, callback) {
  3485. // shift params for method overloading
  3486. if (typeof effect == 'object') {
  3487. callback = options;
  3488. speed = null;
  3489. options = effect;
  3490. effect = options.effect;
  3491. }
  3492. if ($.isFunction(options)) {
  3493. callback = options;
  3494. speed = null;
  3495. options = {};
  3496. }
  3497. if (typeof options == 'number' || $.fx.speeds[options]) {
  3498. callback = speed;
  3499. speed = options;
  3500. options = {};
  3501. }
  3502. if ($.isFunction(speed)) {
  3503. callback = speed;
  3504. speed = null;
  3505. }
  3506. options = options || {};
  3507. speed = speed || options.duration;
  3508. speed = $.fx.off ? 0 : typeof speed == 'number'
  3509. ? speed : speed in $.fx.speeds ? $.fx.speeds[speed] : $.fx.speeds._default;
  3510. callback = callback || options.complete;
  3511. return [effect, options, speed, callback];
  3512. }
  3513. function standardSpeed( speed ) {
  3514. // valid standard speeds
  3515. if ( !speed || typeof speed === "number" || $.fx.speeds[ speed ] ) {
  3516. return true;
  3517. }
  3518. // invalid strings - treat as "normal" speed
  3519. if ( typeof speed === "string" && !$.effects[ speed ] ) {
  3520. return true;
  3521. }
  3522. return false;
  3523. }
  3524. $.fn.extend({
  3525. effect: function(effect, options, speed, callback) {
  3526. var args = _normalizeArguments.apply(this, arguments),
  3527. // TODO: make effects take actual parameters instead of a hash
  3528. args2 = {
  3529. options: args[1],
  3530. duration: args[2],
  3531. callback: args[3]
  3532. },
  3533. mode = args2.options.mode,
  3534. effectMethod = $.effects[effect];
  3535. if ( $.fx.off || !effectMethod ) {
  3536. // delegate to the original method (e.g., .show()) if possible
  3537. if ( mode ) {
  3538. return this[ mode ]( args2.duration, args2.callback );
  3539. } else {
  3540. return this.each(function() {
  3541. if ( args2.callback ) {
  3542. args2.callback.call( this );
  3543. }
  3544. });
  3545. }
  3546. }
  3547. return effectMethod.call(this, args2);
  3548. },
  3549. _show: $.fn.show,
  3550. show: function(speed) {
  3551. if ( standardSpeed( speed ) ) {
  3552. return this._show.apply(this, arguments);
  3553. } else {
  3554. var args = _normalizeArguments.apply(this, arguments);
  3555. args[1].mode = 'show';
  3556. return this.effect.apply(this, args);
  3557. }
  3558. },
  3559. _hide: $.fn.hide,
  3560. hide: function(speed) {
  3561. if ( standardSpeed( speed ) ) {
  3562. return this._hide.apply(this, arguments);
  3563. } else {
  3564. var args = _normalizeArguments.apply(this, arguments);
  3565. args[1].mode = 'hide';
  3566. return this.effect.apply(this, args);
  3567. }
  3568. },
  3569. // jQuery core overloads toggle and creates _toggle
  3570. __toggle: $.fn.toggle,
  3571. toggle: function(speed) {
  3572. if ( standardSpeed( speed ) || typeof speed === "boolean" || $.isFunction( speed ) ) {
  3573. return this.__toggle.apply(this, arguments);
  3574. } else {
  3575. var args = _normalizeArguments.apply(this, arguments);
  3576. args[1].mode = 'toggle';
  3577. return this.effect.apply(this, args);
  3578. }
  3579. },
  3580. // helper functions
  3581. cssUnit: function(key) {
  3582. var style = this.css(key), val = [];
  3583. $.each( ['em','px','%','pt'], function(i, unit){
  3584. if(style.indexOf(unit) > 0)
  3585. val = [parseFloat(style), unit];
  3586. });
  3587. return val;
  3588. }
  3589. });
  3590. /******************************************************************************/
  3591. /*********************************** EASING ***********************************/
  3592. /******************************************************************************/
  3593. /*
  3594. * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
  3595. *
  3596. * Uses the built in easing capabilities added In jQuery 1.1
  3597. * to offer multiple easing options
  3598. *
  3599. * TERMS OF USE - jQuery Easing
  3600. *
  3601. * Open source under the BSD License.
  3602. *
  3603. * Copyright 2008 George McGinley Smith
  3604. * All rights reserved.
  3605. *
  3606. * Redistribution and use in source and binary forms, with or without modification,
  3607. * are permitted provided that the following conditions are met:
  3608. *
  3609. * Redistributions of source code must retain the above copyright notice, this list of
  3610. * conditions and the following disclaimer.
  3611. * Redistributions in binary form must reproduce the above copyright notice, this list
  3612. * of conditions and the following disclaimer in the documentation and/or other materials
  3613. * provided with the distribution.
  3614. *
  3615. * Neither the name of the author nor the names of contributors may be used to endorse
  3616. * or promote products derived from this software without specific prior written permission.
  3617. *
  3618. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
  3619. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  3620. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  3621. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  3622. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  3623. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  3624. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  3625. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  3626. * OF THE POSSIBILITY OF SUCH DAMAGE.
  3627. *
  3628. */
  3629. // t: current time, b: begInnIng value, c: change In value, d: duration
  3630. $.easing.jswing = $.easing.swing;
  3631. $.extend($.easing,
  3632. {
  3633. def: 'easeOutQuad',
  3634. swing: function (x, t, b, c, d) {
  3635. //alert($.easing.default);
  3636. return $.easing[$.easing.def](x, t, b, c, d);
  3637. },
  3638. easeInQuad: function (x, t, b, c, d) {
  3639. return c*(t/=d)*t + b;
  3640. },
  3641. easeOutQuad: function (x, t, b, c, d) {
  3642. return -c *(t/=d)*(t-2) + b;
  3643. },
  3644. easeInOutQuad: function (x, t, b, c, d) {
  3645. if ((t/=d/2) < 1) return c/2*t*t + b;
  3646. return -c/2 * ((--t)*(t-2) - 1) + b;
  3647. },
  3648. easeInCubic: function (x, t, b, c, d) {
  3649. return c*(t/=d)*t*t + b;
  3650. },
  3651. easeOutCubic: function (x, t, b, c, d) {
  3652. return c*((t=t/d-1)*t*t + 1) + b;
  3653. },
  3654. easeInOutCubic: function (x, t, b, c, d) {
  3655. if ((t/=d/2) < 1) return c/2*t*t*t + b;
  3656. return c/2*((t-=2)*t*t + 2) + b;
  3657. },
  3658. easeInQuart: function (x, t, b, c, d) {
  3659. return c*(t/=d)*t*t*t + b;
  3660. },
  3661. easeOutQuart: function (x, t, b, c, d) {
  3662. return -c * ((t=t/d-1)*t*t*t - 1) + b;
  3663. },
  3664. easeInOutQuart: function (x, t, b, c, d) {
  3665. if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
  3666. return -c/2 * ((t-=2)*t*t*t - 2) + b;
  3667. },
  3668. easeInQuint: function (x, t, b, c, d) {
  3669. return c*(t/=d)*t*t*t*t + b;
  3670. },
  3671. easeOutQuint: function (x, t, b, c, d) {
  3672. return c*((t=t/d-1)*t*t*t*t + 1) + b;
  3673. },
  3674. easeInOutQuint: function (x, t, b, c, d) {
  3675. if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
  3676. return c/2*((t-=2)*t*t*t*t + 2) + b;
  3677. },
  3678. easeInSine: function (x, t, b, c, d) {
  3679. return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
  3680. },
  3681. easeOutSine: function (x, t, b, c, d) {
  3682. return c * Math.sin(t/d * (Math.PI/2)) + b;
  3683. },
  3684. easeInOutSine: function (x, t, b, c, d) {
  3685. return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
  3686. },
  3687. easeInExpo: function (x, t, b, c, d) {
  3688. return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
  3689. },
  3690. easeOutExpo: function (x, t, b, c, d) {
  3691. return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
  3692. },
  3693. easeInOutExpo: function (x, t, b, c, d) {
  3694. if (t==0) return b;
  3695. if (t==d) return b+c;
  3696. if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
  3697. return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
  3698. },
  3699. easeInCirc: function (x, t, b, c, d) {
  3700. return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
  3701. },
  3702. easeOutCirc: function (x, t, b, c, d) {
  3703. return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
  3704. },
  3705. easeInOutCirc: function (x, t, b, c, d) {
  3706. if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
  3707. return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
  3708. },
  3709. easeInElastic: function (x, t, b, c, d) {
  3710. var s=1.70158;var p=0;var a=c;
  3711. if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
  3712. if (a < Math.abs(c)) { a=c; var s=p/4; }
  3713. else var s = p/(2*Math.PI) * Math.asin (c/a);
  3714. return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
  3715. },
  3716. easeOutElastic: function (x, t, b, c, d) {
  3717. var s=1.70158;var p=0;var a=c;
  3718. if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
  3719. if (a < Math.abs(c)) { a=c; var s=p/4; }
  3720. else var s = p/(2*Math.PI) * Math.asin (c/a);
  3721. return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
  3722. },
  3723. easeInOutElastic: function (x, t, b, c, d) {
  3724. var s=1.70158;var p=0;var a=c;
  3725. if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
  3726. if (a < Math.abs(c)) { a=c; var s=p/4; }
  3727. else var s = p/(2*Math.PI) * Math.asin (c/a);
  3728. if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
  3729. return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
  3730. },
  3731. easeInBack: function (x, t, b, c, d, s) {
  3732. if (s == undefined) s = 1.70158;
  3733. return c*(t/=d)*t*((s+1)*t - s) + b;
  3734. },
  3735. easeOutBack: function (x, t, b, c, d, s) {
  3736. if (s == undefined) s = 1.70158;
  3737. return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
  3738. },
  3739. easeInOutBack: function (x, t, b, c, d, s) {
  3740. if (s == undefined) s = 1.70158;
  3741. if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
  3742. return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
  3743. },
  3744. easeInBounce: function (x, t, b, c, d) {
  3745. return c - $.easing.easeOutBounce (x, d-t, 0, c, d) + b;
  3746. },
  3747. easeOutBounce: function (x, t, b, c, d) {
  3748. if ((t/=d) < (1/2.75)) {
  3749. return c*(7.5625*t*t) + b;
  3750. } else if (t < (2/2.75)) {
  3751. return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
  3752. } else if (t < (2.5/2.75)) {
  3753. return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
  3754. } else {
  3755. return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
  3756. }
  3757. },
  3758. easeInOutBounce: function (x, t, b, c, d) {
  3759. if (t < d/2) return $.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
  3760. return $.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
  3761. }
  3762. });
  3763. /*
  3764. *
  3765. * TERMS OF USE - EASING EQUATIONS
  3766. *
  3767. * Open source under the BSD License.
  3768. *
  3769. * Copyright 2001 Robert Penner
  3770. * All rights reserved.
  3771. *
  3772. * Redistribution and use in source and binary forms, with or without modification,
  3773. * are permitted provided that the following conditions are met:
  3774. *
  3775. * Redistributions of source code must retain the above copyright notice, this list of
  3776. * conditions and the following disclaimer.
  3777. * Redistributions in binary form must reproduce the above copyright notice, this list
  3778. * of conditions and the following disclaimer in the documentation and/or other materials
  3779. * provided with the distribution.
  3780. *
  3781. * Neither the name of the author nor the names of contributors may be used to endorse
  3782. * or promote products derived from this software without specific prior written permission.
  3783. *
  3784. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
  3785. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  3786. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  3787. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  3788. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  3789. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  3790. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  3791. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  3792. * OF THE POSSIBILITY OF SUCH DAMAGE.
  3793. *
  3794. */
  3795. })(jQuery);
  3796. (function( $, undefined ) {
  3797. $.effects.blind = function(o) {
  3798. return this.queue(function() {
  3799. // Create element
  3800. var el = $(this), props = ['position','top','bottom','left','right'];
  3801. // Set options
  3802. var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
  3803. var direction = o.options.direction || 'vertical'; // Default direction
  3804. // Adjust
  3805. $.effects.save(el, props); el.show(); // Save & Show
  3806. var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
  3807. var ref = (direction == 'vertical') ? 'height' : 'width';
  3808. var distance = (direction == 'vertical') ? wrapper.height() : wrapper.width();
  3809. if(mode == 'show') wrapper.css(ref, 0); // Shift
  3810. // Animation
  3811. var animation = {};
  3812. animation[ref] = mode == 'show' ? distance : 0;
  3813. // Animate
  3814. wrapper.animate(animation, o.duration, o.options.easing, function() {
  3815. if(mode == 'hide') el.hide(); // Hide
  3816. $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
  3817. if(o.callback) o.callback.apply(el[0], arguments); // Callback
  3818. el.dequeue();
  3819. });
  3820. });
  3821. };
  3822. })(jQuery);
  3823. (function( $, undefined ) {
  3824. $.effects.bounce = function(o) {
  3825. return this.queue(function() {
  3826. // Create element
  3827. var el = $(this), props = ['position','top','bottom','left','right'];
  3828. // Set options
  3829. var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
  3830. var direction = o.options.direction || 'up'; // Default direction
  3831. var distance = o.options.distance || 20; // Default distance
  3832. var times = o.options.times || 5; // Default # of times
  3833. var speed = o.duration || 250; // Default speed per bounce
  3834. if (/show|hide/.test(mode)) props.push('opacity'); // Avoid touching opacity to prevent clearType and PNG issues in IE
  3835. // Adjust
  3836. $.effects.save(el, props); el.show(); // Save & Show
  3837. $.effects.createWrapper(el); // Create Wrapper
  3838. var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
  3839. var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
  3840. var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 3 : el.outerWidth({margin:true}) / 3);
  3841. if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift
  3842. if (mode == 'hide') distance = distance / (times * 2);
  3843. if (mode != 'hide') times--;
  3844. // Animate
  3845. if (mode == 'show') { // Show Bounce
  3846. var animation = {opacity: 1};
  3847. animation[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
  3848. el.animate(animation, speed / 2, o.options.easing);
  3849. distance = distance / 2;
  3850. times--;
  3851. };
  3852. for (var i = 0; i < times; i++) { // Bounces
  3853. var animation1 = {}, animation2 = {};
  3854. animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
  3855. animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
  3856. el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing);
  3857. distance = (mode == 'hide') ? distance * 2 : distance / 2;
  3858. };
  3859. if (mode == 'hide') { // Last Bounce
  3860. var animation = {opacity: 0};
  3861. animation[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
  3862. el.animate(animation, speed / 2, o.options.easing, function(){
  3863. el.hide(); // Hide
  3864. $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
  3865. if(o.callback) o.callback.apply(this, arguments); // Callback
  3866. });
  3867. } else {
  3868. var animation1 = {}, animation2 = {};
  3869. animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
  3870. animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
  3871. el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing, function(){
  3872. $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
  3873. if(o.callback) o.callback.apply(this, arguments); // Callback
  3874. });
  3875. };
  3876. el.queue('fx', function() { el.dequeue(); });
  3877. el.dequeue();
  3878. });
  3879. };
  3880. })(jQuery);
  3881. (function( $, undefined ) {
  3882. $.effects.clip = function(o) {
  3883. return this.queue(function() {
  3884. // Create element
  3885. var el = $(this), props = ['position','top','bottom','left','right','height','width'];
  3886. // Set options
  3887. var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
  3888. var direction = o.options.direction || 'vertical'; // Default direction
  3889. // Adjust
  3890. $.effects.save(el, props); el.show(); // Save & Show
  3891. var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
  3892. var animate = el[0].tagName == 'IMG' ? wrapper : el;
  3893. var ref = {
  3894. size: (direction == 'vertical') ? 'height' : 'width',
  3895. position: (direction == 'vertical') ? 'top' : 'left'
  3896. };
  3897. var distance = (direction == 'vertical') ? animate.height() : animate.width();
  3898. if(mode == 'show') { animate.css(ref.size, 0); animate.css(ref.position, distance / 2); } // Shift
  3899. // Animation
  3900. var animation = {};
  3901. animation[ref.size] = mode == 'show' ? distance : 0;
  3902. animation[ref.position] = mode == 'show' ? 0 : distance / 2;
  3903. // Animate
  3904. animate.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
  3905. if(mode == 'hide') el.hide(); // Hide
  3906. $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
  3907. if(o.callback) o.callback.apply(el[0], arguments); // Callback
  3908. el.dequeue();
  3909. }});
  3910. });
  3911. };
  3912. })(jQuery);
  3913. (function( $, undefined ) {
  3914. $.effects.drop = function(o) {
  3915. return this.queue(function() {
  3916. // Create element
  3917. var el = $(this), props = ['position','top','bottom','left','right','opacity'];
  3918. // Set options
  3919. var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
  3920. var direction = o.options.direction || 'left'; // Default Direction
  3921. // Adjust
  3922. $.effects.save(el, props); el.show(); // Save & Show
  3923. $.effects.createWrapper(el); // Create Wrapper
  3924. var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
  3925. var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
  3926. var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 2 : el.outerWidth({margin:true}) / 2);
  3927. if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift
  3928. // Animation
  3929. var animation = {opacity: mode == 'show' ? 1 : 0};
  3930. animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance;
  3931. // Animate
  3932. el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
  3933. if(mode == 'hide') el.hide(); // Hide
  3934. $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
  3935. if(o.callback) o.callback.apply(this, arguments); // Callback
  3936. el.dequeue();
  3937. }});
  3938. });
  3939. };
  3940. })(jQuery);
  3941. (function( $, undefined ) {
  3942. $.effects.explode = function(o) {
  3943. return this.queue(function() {
  3944. var rows = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3;
  3945. var cells = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3;
  3946. o.options.mode = o.options.mode == 'toggle' ? ($(this).is(':visible') ? 'hide' : 'show') : o.options.mode;
  3947. var el = $(this).show().css('visibility', 'hidden');
  3948. var offset = el.offset();
  3949. //Substract the margins - not fixing the problem yet.
  3950. offset.top -= parseInt(el.css("marginTop"),10) || 0;
  3951. offset.left -= parseInt(el.css("marginLeft"),10) || 0;
  3952. var width = el.outerWidth(true);
  3953. var height = el.outerHeight(true);
  3954. for(var i=0;i<rows;i++) { // =
  3955. for(var j=0;j<cells;j++) { // ||
  3956. el
  3957. .clone()
  3958. .appendTo('body')
  3959. .wrap('<div></div>')
  3960. .css({
  3961. position: 'absolute',
  3962. visibility: 'visible',
  3963. left: -j*(width/cells),
  3964. top: -i*(height/rows)
  3965. })
  3966. .parent()
  3967. .addClass('ui-effects-explode')
  3968. .css({
  3969. position: 'absolute',
  3970. overflow: 'hidden',
  3971. width: width/cells,
  3972. height: height/rows,
  3973. left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? (j-Math.floor(cells/2))*(width/cells) : 0),
  3974. top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? (i-Math.floor(rows/2))*(height/rows) : 0),
  3975. opacity: o.options.mode == 'show' ? 0 : 1
  3976. }).animate({
  3977. left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? 0 : (j-Math.floor(cells/2))*(width/cells)),
  3978. top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? 0 : (i-Math.floor(rows/2))*(height/rows)),
  3979. opacity: o.options.mode == 'show' ? 1 : 0
  3980. }, o.duration || 500);
  3981. }
  3982. }
  3983. // Set a timeout, to call the callback approx. when the other animations have finished
  3984. setTimeout(function() {
  3985. o.options.mode == 'show' ? el.css({ visibility: 'visible' }) : el.css({ visibility: 'visible' }).hide();
  3986. if(o.callback) o.callback.apply(el[0]); // Callback
  3987. el.dequeue();
  3988. $('div.ui-effects-explode').remove();
  3989. }, o.duration || 500);
  3990. });
  3991. };
  3992. })(jQuery);
  3993. (function( $, undefined ) {
  3994. $.effects.fade = function(o) {
  3995. return this.queue(function() {
  3996. var elem = $(this),
  3997. mode = $.effects.setMode(elem, o.options.mode || 'hide');
  3998. elem.animate({ opacity: mode }, {
  3999. queue: false,
  4000. duration: o.duration,
  4001. easing: o.options.easing,
  4002. complete: function() {
  4003. (o.callback && o.callback.apply(this, arguments));
  4004. elem.dequeue();
  4005. }
  4006. });
  4007. });
  4008. };
  4009. })(jQuery);
  4010. (function( $, undefined ) {
  4011. $.effects.fold = function(o) {
  4012. return this.queue(function() {
  4013. // Create element
  4014. var el = $(this), props = ['position','top','bottom','left','right'];
  4015. // Set options
  4016. var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
  4017. var size = o.options.size || 15; // Default fold size
  4018. var horizFirst = !(!o.options.horizFirst); // Ensure a boolean value
  4019. var duration = o.duration ? o.duration / 2 : $.fx.speeds._default / 2;
  4020. // Adjust
  4021. $.effects.save(el, props); el.show(); // Save & Show
  4022. var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
  4023. var widthFirst = ((mode == 'show') != horizFirst);
  4024. var ref = widthFirst ? ['width', 'height'] : ['height', 'width'];
  4025. var distance = widthFirst ? [wrapper.width(), wrapper.height()] : [wrapper.height(), wrapper.width()];
  4026. var percent = /([0-9]+)%/.exec(size);
  4027. if(percent) size = parseInt(percent[1],10) / 100 * distance[mode == 'hide' ? 0 : 1];
  4028. if(mode == 'show') wrapper.css(horizFirst ? {height: 0, width: size} : {height: size, width: 0}); // Shift
  4029. // Animation
  4030. var animation1 = {}, animation2 = {};
  4031. animation1[ref[0]] = mode == 'show' ? distance[0] : size;
  4032. animation2[ref[1]] = mode == 'show' ? distance[1] : 0;
  4033. // Animate
  4034. wrapper.animate(animation1, duration, o.options.easing)
  4035. .animate(animation2, duration, o.options.easing, function() {
  4036. if(mode == 'hide') el.hide(); // Hide
  4037. $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
  4038. if(o.callback) o.callback.apply(el[0], arguments); // Callback
  4039. el.dequeue();
  4040. });
  4041. });
  4042. };
  4043. })(jQuery);
  4044. (function( $, undefined ) {
  4045. $.effects.highlight = function(o) {
  4046. return this.queue(function() {
  4047. var elem = $(this),
  4048. props = ['backgroundImage', 'backgroundColor', 'opacity'],
  4049. mode = $.effects.setMode(elem, o.options.mode || 'show'),
  4050. animation = {
  4051. backgroundColor: elem.css('backgroundColor')
  4052. };
  4053. if (mode == 'hide') {
  4054. animation.opacity = 0;
  4055. }
  4056. $.effects.save(elem, props);
  4057. elem
  4058. .show()
  4059. .css({
  4060. backgroundImage: 'none',
  4061. backgroundColor: o.options.color || '#ffff99'
  4062. })
  4063. .animate(animation, {
  4064. queue: false,
  4065. duration: o.duration,
  4066. easing: o.options.easing,
  4067. complete: function() {
  4068. (mode == 'hide' && elem.hide());
  4069. $.effects.restore(elem, props);
  4070. (mode == 'show' && !$.support.opacity && this.style.removeAttribute('filter'));
  4071. (o.callback && o.callback.apply(this, arguments));
  4072. elem.dequeue();
  4073. }
  4074. });
  4075. });
  4076. };
  4077. })(jQuery);
  4078. (function( $, undefined ) {
  4079. $.effects.pulsate = function(o) {
  4080. return this.queue(function() {
  4081. var elem = $(this),
  4082. mode = $.effects.setMode(elem, o.options.mode || 'show'),
  4083. times = ((o.options.times || 5) * 2) - 1,
  4084. duration = o.duration ? o.duration / 2 : $.fx.speeds._default / 2,
  4085. isVisible = elem.is(':visible'),
  4086. animateTo = 0;
  4087. if (!isVisible) {
  4088. elem.css('opacity', 0).show();
  4089. animateTo = 1;
  4090. }
  4091. if ((mode == 'hide' && isVisible) || (mode == 'show' && !isVisible)) {
  4092. times--;
  4093. }
  4094. for (var i = 0; i < times; i++) {
  4095. elem.animate({ opacity: animateTo }, duration, o.options.easing);
  4096. animateTo = (animateTo + 1) % 2;
  4097. }
  4098. elem.animate({ opacity: animateTo }, duration, o.options.easing, function() {
  4099. if (animateTo == 0) {
  4100. elem.hide();
  4101. }
  4102. (o.callback && o.callback.apply(this, arguments));
  4103. });
  4104. elem
  4105. .queue('fx', function() { elem.dequeue(); })
  4106. .dequeue();
  4107. });
  4108. };
  4109. })(jQuery);
  4110. (function( $, undefined ) {
  4111. $.effects.puff = function(o) {
  4112. return this.queue(function() {
  4113. var elem = $(this),
  4114. mode = $.effects.setMode(elem, o.options.mode || 'hide'),
  4115. percent = parseInt(o.options.percent, 10) || 150,
  4116. factor = percent / 100,
  4117. original = { height: elem.height(), width: elem.width() };
  4118. $.extend(o.options, {
  4119. fade: true,
  4120. mode: mode,
  4121. percent: mode == 'hide' ? percent : 100,
  4122. from: mode == 'hide'
  4123. ? original
  4124. : {
  4125. height: original.height * factor,
  4126. width: original.width * factor
  4127. }
  4128. });
  4129. elem.effect('scale', o.options, o.duration, o.callback);
  4130. elem.dequeue();
  4131. });
  4132. };
  4133. $.effects.scale = function(o) {
  4134. return this.queue(function() {
  4135. // Create element
  4136. var el = $(this);
  4137. // Set options
  4138. var options = $.extend(true, {}, o.options);
  4139. var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
  4140. var percent = parseInt(o.options.percent,10) || (parseInt(o.options.percent,10) == 0 ? 0 : (mode == 'hide' ? 0 : 100)); // Set default scaling percent
  4141. var direction = o.options.direction || 'both'; // Set default axis
  4142. var origin = o.options.origin; // The origin of the scaling
  4143. if (mode != 'effect') { // Set default origin and restore for show/hide
  4144. options.origin = origin || ['middle','center'];
  4145. options.restore = true;
  4146. }
  4147. var original = {height: el.height(), width: el.width()}; // Save original
  4148. el.from = o.options.from || (mode == 'show' ? {height: 0, width: 0} : original); // Default from state
  4149. // Adjust
  4150. var factor = { // Set scaling factor
  4151. y: direction != 'horizontal' ? (percent / 100) : 1,
  4152. x: direction != 'vertical' ? (percent / 100) : 1
  4153. };
  4154. el.to = {height: original.height * factor.y, width: original.width * factor.x}; // Set to state
  4155. if (o.options.fade) { // Fade option to support puff
  4156. if (mode == 'show') {el.from.opacity = 0; el.to.opacity = 1;};
  4157. if (mode == 'hide') {el.from.opacity = 1; el.to.opacity = 0;};
  4158. };
  4159. // Animation
  4160. options.from = el.from; options.to = el.to; options.mode = mode;
  4161. // Animate
  4162. el.effect('size', options, o.duration, o.callback);
  4163. el.dequeue();
  4164. });
  4165. };
  4166. $.effects.size = function(o) {
  4167. return this.queue(function() {
  4168. // Create element
  4169. var el = $(this), props = ['position','top','bottom','left','right','width','height','overflow','opacity'];
  4170. var props1 = ['position','top','bottom','left','right','overflow','opacity']; // Always restore
  4171. var props2 = ['width','height','overflow']; // Copy for children
  4172. var cProps = ['fontSize'];
  4173. var vProps = ['borderTopWidth', 'borderBottomWidth', 'paddingTop', 'paddingBottom'];
  4174. var hProps = ['borderLeftWidth', 'borderRightWidth', 'paddingLeft', 'paddingRight'];
  4175. // Set options
  4176. var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
  4177. var restore = o.options.restore || false; // Default restore
  4178. var scale = o.options.scale || 'both'; // Default scale mode
  4179. var origin = o.options.origin; // The origin of the sizing
  4180. var original = {height: el.height(), width: el.width()}; // Save original
  4181. el.from = o.options.from || original; // Default from state
  4182. el.to = o.options.to || original; // Default to state
  4183. // Adjust
  4184. if (origin) { // Calculate baseline shifts
  4185. var baseline = $.effects.getBaseline(origin, original);
  4186. el.from.top = (original.height - el.from.height) * baseline.y;
  4187. el.from.left = (original.width - el.from.width) * baseline.x;
  4188. el.to.top = (original.height - el.to.height) * baseline.y;
  4189. el.to.left = (original.width - el.to.width) * baseline.x;
  4190. };
  4191. var factor = { // Set scaling factor
  4192. from: {y: el.from.height / original.height, x: el.from.width / original.width},
  4193. to: {y: el.to.height / original.height, x: el.to.width / original.width}
  4194. };
  4195. if (scale == 'box' || scale == 'both') { // Scale the css box
  4196. if (factor.from.y != factor.to.y) { // Vertical props scaling
  4197. props = props.concat(vProps);
  4198. el.from = $.effects.setTransition(el, vProps, factor.from.y, el.from);
  4199. el.to = $.effects.setTransition(el, vProps, factor.to.y, el.to);
  4200. };
  4201. if (factor.from.x != factor.to.x) { // Horizontal props scaling
  4202. props = props.concat(hProps);
  4203. el.from = $.effects.setTransition(el, hProps, factor.from.x, el.from);
  4204. el.to = $.effects.setTransition(el, hProps, factor.to.x, el.to);
  4205. };
  4206. };
  4207. if (scale == 'content' || scale == 'both') { // Scale the content
  4208. if (factor.from.y != factor.to.y) { // Vertical props scaling
  4209. props = props.concat(cProps);
  4210. el.from = $.effects.setTransition(el, cProps, factor.from.y, el.from);
  4211. el.to = $.effects.setTransition(el, cProps, factor.to.y, el.to);
  4212. };
  4213. };
  4214. $.effects.save(el, restore ? props : props1); el.show(); // Save & Show
  4215. $.effects.createWrapper(el); // Create Wrapper
  4216. el.css('overflow','hidden').css(el.from); // Shift
  4217. // Animate
  4218. if (scale == 'content' || scale == 'both') { // Scale the children
  4219. vProps = vProps.concat(['marginTop','marginBottom']).concat(cProps); // Add margins/font-size
  4220. hProps = hProps.concat(['marginLeft','marginRight']); // Add margins
  4221. props2 = props.concat(vProps).concat(hProps); // Concat
  4222. el.find("*[width]").each(function(){
  4223. var child = $(this);
  4224. if (restore) $.effects.save(child, props2);
  4225. var c_original = {height: child.height(), width: child.width()}; // Save original
  4226. child.from = {height: c_original.height * factor.from.y, width: c_original.width * factor.from.x};
  4227. child.to = {height: c_original.height * factor.to.y, width: c_original.width * factor.to.x};
  4228. if (factor.from.y != factor.to.y) { // Vertical props scaling
  4229. child.from = $.effects.setTransition(child, vProps, factor.from.y, child.from);
  4230. child.to = $.effects.setTransition(child, vProps, factor.to.y, child.to);
  4231. };
  4232. if (factor.from.x != factor.to.x) { // Horizontal props scaling
  4233. child.from = $.effects.setTransition(child, hProps, factor.from.x, child.from);
  4234. child.to = $.effects.setTransition(child, hProps, factor.to.x, child.to);
  4235. };
  4236. child.css(child.from); // Shift children
  4237. child.animate(child.to, o.duration, o.options.easing, function(){
  4238. if (restore) $.effects.restore(child, props2); // Restore children
  4239. }); // Animate children
  4240. });
  4241. };
  4242. // Animate
  4243. el.animate(el.to, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
  4244. if (el.to.opacity === 0) {
  4245. el.css('opacity', el.from.opacity);
  4246. }
  4247. if(mode == 'hide') el.hide(); // Hide
  4248. $.effects.restore(el, restore ? props : props1); $.effects.removeWrapper(el); // Restore
  4249. if(o.callback) o.callback.apply(this, arguments); // Callback
  4250. el.dequeue();
  4251. }});
  4252. });
  4253. };
  4254. })(jQuery);
  4255. (function( $, undefined ) {
  4256. $.effects.shake = function(o) {
  4257. return this.queue(function() {
  4258. // Create element
  4259. var el = $(this), props = ['position','top','bottom','left','right'];
  4260. // Set options
  4261. var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
  4262. var direction = o.options.direction || 'left'; // Default direction
  4263. var distance = o.options.distance || 20; // Default distance
  4264. var times = o.options.times || 3; // Default # of times
  4265. var speed = o.duration || o.options.duration || 140; // Default speed per shake
  4266. // Adjust
  4267. $.effects.save(el, props); el.show(); // Save & Show
  4268. $.effects.createWrapper(el); // Create Wrapper
  4269. var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
  4270. var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
  4271. // Animation
  4272. var animation = {}, animation1 = {}, animation2 = {};
  4273. animation[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
  4274. animation1[ref] = (motion == 'pos' ? '+=' : '-=') + distance * 2;
  4275. animation2[ref] = (motion == 'pos' ? '-=' : '+=') + distance * 2;
  4276. // Animate
  4277. el.animate(animation, speed, o.options.easing);
  4278. for (var i = 1; i < times; i++) { // Shakes
  4279. el.animate(animation1, speed, o.options.easing).animate(animation2, speed, o.options.easing);
  4280. };
  4281. el.animate(animation1, speed, o.options.easing).
  4282. animate(animation, speed / 2, o.options.easing, function(){ // Last shake
  4283. $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
  4284. if(o.callback) o.callback.apply(this, arguments); // Callback
  4285. });
  4286. el.queue('fx', function() { el.dequeue(); });
  4287. el.dequeue();
  4288. });
  4289. };
  4290. })(jQuery);
  4291. (function( $, undefined ) {
  4292. $.effects.slide = function(o) {
  4293. return this.queue(function() {
  4294. // Create element
  4295. var el = $(this), props = ['position','top','bottom','left','right'];
  4296. // Set options
  4297. var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode
  4298. var direction = o.options.direction || 'left'; // Default Direction
  4299. // Adjust
  4300. $.effects.save(el, props); el.show(); // Save & Show
  4301. $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
  4302. var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
  4303. var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
  4304. var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) : el.outerWidth({margin:true}));
  4305. if (mode == 'show') el.css(ref, motion == 'pos' ? (isNaN(distance) ? "-" + distance : -distance) : distance); // Shift
  4306. // Animation
  4307. var animation = {};
  4308. animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance;
  4309. // Animate
  4310. el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
  4311. if(mode == 'hide') el.hide(); // Hide
  4312. $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
  4313. if(o.callback) o.callback.apply(this, arguments); // Callback
  4314. el.dequeue();
  4315. }});
  4316. });
  4317. };
  4318. })(jQuery);
  4319. (function( $, undefined ) {
  4320. $.effects.transfer = function(o) {
  4321. return this.queue(function() {
  4322. var elem = $(this),
  4323. target = $(o.options.to),
  4324. endPosition = target.offset(),
  4325. animation = {
  4326. top: endPosition.top,
  4327. left: endPosition.left,
  4328. height: target.innerHeight(),
  4329. width: target.innerWidth()
  4330. },
  4331. startPosition = elem.offset(),
  4332. transfer = $('<div class="ui-effects-transfer"></div>')
  4333. .appendTo(document.body)
  4334. .addClass(o.options.className)
  4335. .css({
  4336. top: startPosition.top,
  4337. left: startPosition.left,
  4338. height: elem.innerHeight(),
  4339. width: elem.innerWidth(),
  4340. position: 'absolute'
  4341. })
  4342. .animate(animation, o.duration, o.options.easing, function() {
  4343. transfer.remove();
  4344. (o.callback && o.callback.apply(elem[0], arguments));
  4345. elem.dequeue();
  4346. });
  4347. });
  4348. };
  4349. })(jQuery);
  4350. (function( $, undefined ) {
  4351. $.widget( "ui.accordion", {
  4352. options: {
  4353. active: 0,
  4354. animated: "slide",
  4355. autoHeight: true,
  4356. clearStyle: false,
  4357. collapsible: false,
  4358. event: "click",
  4359. fillSpace: false,
  4360. header: "> li > :first-child,> :not(li):even",
  4361. icons: {
  4362. header: "ui-icon-triangle-1-e",
  4363. headerSelected: "ui-icon-triangle-1-s"
  4364. },
  4365. navigation: false,
  4366. navigationFilter: function() {
  4367. return this.href.toLowerCase() === location.href.toLowerCase();
  4368. }
  4369. },
  4370. _create: function() {
  4371. var self = this,
  4372. options = self.options;
  4373. self.running = 0;
  4374. self.element
  4375. .addClass( "ui-accordion ui-widget ui-helper-reset" )
  4376. // in lack of child-selectors in CSS
  4377. // we need to mark top-LIs in a UL-accordion for some IE-fix
  4378. .children( "li" )
  4379. .addClass( "ui-accordion-li-fix" );
  4380. self.headers = self.element.find( options.header )
  4381. .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" )
  4382. .bind( "mouseenter.accordion", function() {
  4383. if ( options.disabled ) {
  4384. return;
  4385. }
  4386. $( this ).addClass( "ui-state-hover" );
  4387. })
  4388. .bind( "mouseleave.accordion", function() {
  4389. if ( options.disabled ) {
  4390. return;
  4391. }
  4392. $( this ).removeClass( "ui-state-hover" );
  4393. })
  4394. .bind( "focus.accordion", function() {
  4395. if ( options.disabled ) {
  4396. return;
  4397. }
  4398. $( this ).addClass( "ui-state-focus" );
  4399. })
  4400. .bind( "blur.accordion", function() {
  4401. if ( options.disabled ) {
  4402. return;
  4403. }
  4404. $( this ).removeClass( "ui-state-focus" );
  4405. });
  4406. self.headers.next()
  4407. .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" );
  4408. if ( options.navigation ) {
  4409. var current = self.element.find( "a" ).filter( options.navigationFilter ).eq( 0 );
  4410. if ( current.length ) {
  4411. var header = current.closest( ".ui-accordion-header" );
  4412. if ( header.length ) {
  4413. // anchor within header
  4414. self.active = header;
  4415. } else {
  4416. // anchor within content
  4417. self.active = current.closest( ".ui-accordion-content" ).prev();
  4418. }
  4419. }
  4420. }
  4421. self.active = self._findActive( self.active || options.active )
  4422. .addClass( "ui-state-default ui-state-active" )
  4423. .toggleClass( "ui-corner-all" )
  4424. .toggleClass( "ui-corner-top" );
  4425. self.active.next().addClass( "ui-accordion-content-active" );
  4426. self._createIcons();
  4427. self.resize();
  4428. // ARIA
  4429. self.element.attr( "role", "tablist" );
  4430. self.headers
  4431. .attr( "role", "tab" )
  4432. .bind( "keydown.accordion", function( event ) {
  4433. return self._keydown( event );
  4434. })
  4435. .next()
  4436. .attr( "role", "tabpanel" );
  4437. self.headers
  4438. .not( self.active || "" )
  4439. .attr({
  4440. "aria-expanded": "false",
  4441. "aria-selected": "false",
  4442. tabIndex: -1
  4443. })
  4444. .next()
  4445. .hide();
  4446. // make sure at least one header is in the tab order
  4447. if ( !self.active.length ) {
  4448. self.headers.eq( 0 ).attr( "tabIndex", 0 );
  4449. } else {
  4450. self.active
  4451. .attr({
  4452. "aria-expanded": "true",
  4453. "aria-selected": "true",
  4454. tabIndex: 0
  4455. });
  4456. }
  4457. // only need links in tab order for Safari
  4458. if ( !$.browser.safari ) {
  4459. self.headers.find( "a" ).attr( "tabIndex", -1 );
  4460. }
  4461. if ( options.event ) {
  4462. self.headers.bind( options.event.split(" ").join(".accordion ") + ".accordion", function(event) {
  4463. self._clickHandler.call( self, event, this );
  4464. event.preventDefault();
  4465. });
  4466. }
  4467. },
  4468. _createIcons: function() {
  4469. var options = this.options;
  4470. if ( options.icons ) {
  4471. $( "<span></span>" )
  4472. .addClass( "ui-icon " + options.icons.header )
  4473. .prependTo( this.headers );
  4474. this.active.children( ".ui-icon" )
  4475. .toggleClass(options.icons.header)
  4476. .toggleClass(options.icons.headerSelected);
  4477. this.element.addClass( "ui-accordion-icons" );
  4478. }
  4479. },
  4480. _destroyIcons: function() {
  4481. this.headers.children( ".ui-icon" ).remove();
  4482. this.element.removeClass( "ui-accordion-icons" );
  4483. },
  4484. destroy: function() {
  4485. var options = this.options;
  4486. this.element
  4487. .removeClass( "ui-accordion ui-widget ui-helper-reset" )
  4488. .removeAttr( "role" );
  4489. this.headers
  4490. .unbind( ".accordion" )
  4491. .removeClass( "ui-accordion-header ui-accordion-disabled ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
  4492. .removeAttr( "role" )
  4493. .removeAttr( "aria-expanded" )
  4494. .removeAttr( "aria-selected" )
  4495. .removeAttr( "tabIndex" );
  4496. this.headers.find( "a" ).removeAttr( "tabIndex" );
  4497. this._destroyIcons();
  4498. var contents = this.headers.next()
  4499. .css( "display", "" )
  4500. .removeAttr( "role" )
  4501. .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-accordion-disabled ui-state-disabled" );
  4502. if ( options.autoHeight || options.fillHeight ) {
  4503. contents.css( "height", "" );
  4504. }
  4505. return $.Widget.prototype.destroy.call( this );
  4506. },
  4507. _setOption: function( key, value ) {
  4508. $.Widget.prototype._setOption.apply( this, arguments );
  4509. if ( key == "active" ) {
  4510. this.activate( value );
  4511. }
  4512. if ( key == "icons" ) {
  4513. this._destroyIcons();
  4514. if ( value ) {
  4515. this._createIcons();
  4516. }
  4517. }
  4518. // #5332 - opacity doesn't cascade to positioned elements in IE
  4519. // so we need to add the disabled class to the headers and panels
  4520. if ( key == "disabled" ) {
  4521. this.headers.add(this.headers.next())
  4522. [ value ? "addClass" : "removeClass" ](
  4523. "ui-accordion-disabled ui-state-disabled" );
  4524. }
  4525. },
  4526. _keydown: function( event ) {
  4527. if ( this.options.disabled || event.altKey || event.ctrlKey ) {
  4528. return;
  4529. }
  4530. var keyCode = $.ui.keyCode,
  4531. length = this.headers.length,
  4532. currentIndex = this.headers.index( event.target ),
  4533. toFocus = false;
  4534. switch ( event.keyCode ) {
  4535. case keyCode.RIGHT:
  4536. case keyCode.DOWN:
  4537. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  4538. break;
  4539. case keyCode.LEFT:
  4540. case keyCode.UP:
  4541. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  4542. break;
  4543. case keyCode.SPACE:
  4544. case keyCode.ENTER:
  4545. this._clickHandler( { target: event.target }, event.target );
  4546. event.preventDefault();
  4547. }
  4548. if ( toFocus ) {
  4549. $( event.target ).attr( "tabIndex", -1 );
  4550. $( toFocus ).attr( "tabIndex", 0 );
  4551. toFocus.focus();
  4552. return false;
  4553. }
  4554. return true;
  4555. },
  4556. resize: function() {
  4557. var options = this.options,
  4558. maxHeight;
  4559. if ( options.fillSpace ) {
  4560. if ( $.browser.msie ) {
  4561. var defOverflow = this.element.parent().css( "overflow" );
  4562. this.element.parent().css( "overflow", "hidden");
  4563. }
  4564. maxHeight = this.element.parent().height();
  4565. if ($.browser.msie) {
  4566. this.element.parent().css( "overflow", defOverflow );
  4567. }
  4568. this.headers.each(function() {
  4569. maxHeight -= $( this ).outerHeight( true );
  4570. });
  4571. this.headers.next()
  4572. .each(function() {
  4573. $( this ).height( Math.max( 0, maxHeight -
  4574. $( this ).innerHeight() + $( this ).height() ) );
  4575. })
  4576. .css( "overflow", "auto" );
  4577. } else if ( options.autoHeight ) {
  4578. maxHeight = 0;
  4579. this.headers.next()
  4580. .each(function() {
  4581. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  4582. })
  4583. .height( maxHeight );
  4584. }
  4585. return this;
  4586. },
  4587. activate: function( index ) {
  4588. // TODO this gets called on init, changing the option without an explicit call for that
  4589. this.options.active = index;
  4590. // call clickHandler with custom event
  4591. var active = this._findActive( index )[ 0 ];
  4592. this._clickHandler( { target: active }, active );
  4593. return this;
  4594. },
  4595. _findActive: function( selector ) {
  4596. return selector
  4597. ? typeof selector === "number"
  4598. ? this.headers.filter( ":eq(" + selector + ")" )
  4599. : this.headers.not( this.headers.not( selector ) )
  4600. : selector === false
  4601. ? $( [] )
  4602. : this.headers.filter( ":eq(0)" );
  4603. },
  4604. // TODO isn't event.target enough? why the separate target argument?
  4605. _clickHandler: function( event, target ) {
  4606. var options = this.options;
  4607. if ( options.disabled ) {
  4608. return;
  4609. }
  4610. // called only when using activate(false) to close all parts programmatically
  4611. if ( !event.target ) {
  4612. if ( !options.collapsible ) {
  4613. return;
  4614. }
  4615. this.active
  4616. .removeClass( "ui-state-active ui-corner-top" )
  4617. .addClass( "ui-state-default ui-corner-all" )
  4618. .children( ".ui-icon" )
  4619. .removeClass( options.icons.headerSelected )
  4620. .addClass( options.icons.header );
  4621. this.active.next().addClass( "ui-accordion-content-active" );
  4622. var toHide = this.active.next(),
  4623. data = {
  4624. options: options,
  4625. newHeader: $( [] ),
  4626. oldHeader: options.active,
  4627. newContent: $( [] ),
  4628. oldContent: toHide
  4629. },
  4630. toShow = ( this.active = $( [] ) );
  4631. this._toggle( toShow, toHide, data );
  4632. return;
  4633. }
  4634. // get the click target
  4635. var clicked = $( event.currentTarget || target ),
  4636. clickedIsActive = clicked[0] === this.active[0];
  4637. // TODO the option is changed, is that correct?
  4638. // TODO if it is correct, shouldn't that happen after determining that the click is valid?
  4639. options.active = options.collapsible && clickedIsActive ?
  4640. false :
  4641. this.headers.index( clicked );
  4642. // if animations are still active, or the active header is the target, ignore click
  4643. if ( this.running || ( !options.collapsible && clickedIsActive ) ) {
  4644. return;
  4645. }
  4646. // find elements to show and hide
  4647. var active = this.active,
  4648. toShow = clicked.next(),
  4649. toHide = this.active.next(),
  4650. data = {
  4651. options: options,
  4652. newHeader: clickedIsActive && options.collapsible ? $([]) : clicked,
  4653. oldHeader: this.active,
  4654. newContent: clickedIsActive && options.collapsible ? $([]) : toShow,
  4655. oldContent: toHide
  4656. },
  4657. down = this.headers.index( this.active[0] ) > this.headers.index( clicked[0] );
  4658. // when the call to ._toggle() comes after the class changes
  4659. // it causes a very odd bug in IE 8 (see #6720)
  4660. this.active = clickedIsActive ? $([]) : clicked;
  4661. this._toggle( toShow, toHide, data, clickedIsActive, down );
  4662. // switch classes
  4663. active
  4664. .removeClass( "ui-state-active ui-corner-top" )
  4665. .addClass( "ui-state-default ui-corner-all" )
  4666. .children( ".ui-icon" )
  4667. .removeClass( options.icons.headerSelected )
  4668. .addClass( options.icons.header );
  4669. if ( !clickedIsActive ) {
  4670. clicked
  4671. .removeClass( "ui-state-default ui-corner-all" )
  4672. .addClass( "ui-state-active ui-corner-top" )
  4673. .children( ".ui-icon" )
  4674. .removeClass( options.icons.header )
  4675. .addClass( options.icons.headerSelected );
  4676. clicked
  4677. .next()
  4678. .addClass( "ui-accordion-content-active" );
  4679. }
  4680. return;
  4681. },
  4682. _toggle: function( toShow, toHide, data, clickedIsActive, down ) {
  4683. var self = this,
  4684. options = self.options;
  4685. self.toShow = toShow;
  4686. self.toHide = toHide;
  4687. self.data = data;
  4688. var complete = function() {
  4689. if ( !self ) {
  4690. return;
  4691. }
  4692. return self._completed.apply( self, arguments );
  4693. };
  4694. // trigger changestart event
  4695. self._trigger( "changestart", null, self.data );
  4696. // count elements to animate
  4697. self.running = toHide.size() === 0 ? toShow.size() : toHide.size();
  4698. if ( options.animated ) {
  4699. var animOptions = {};
  4700. if ( options.collapsible && clickedIsActive ) {
  4701. animOptions = {
  4702. toShow: $( [] ),
  4703. toHide: toHide,
  4704. complete: complete,
  4705. down: down,
  4706. autoHeight: options.autoHeight || options.fillSpace
  4707. };
  4708. } else {
  4709. animOptions = {
  4710. toShow: toShow,
  4711. toHide: toHide,
  4712. complete: complete,
  4713. down: down,
  4714. autoHeight: options.autoHeight || options.fillSpace
  4715. };
  4716. }
  4717. if ( !options.proxied ) {
  4718. options.proxied = options.animated;
  4719. }
  4720. if ( !options.proxiedDuration ) {
  4721. options.proxiedDuration = options.duration;
  4722. }
  4723. options.animated = $.isFunction( options.proxied ) ?
  4724. options.proxied( animOptions ) :
  4725. options.proxied;
  4726. options.duration = $.isFunction( options.proxiedDuration ) ?
  4727. options.proxiedDuration( animOptions ) :
  4728. options.proxiedDuration;
  4729. var animations = $.ui.accordion.animations,
  4730. duration = options.duration,
  4731. easing = options.animated;
  4732. if ( easing && !animations[ easing ] && !$.easing[ easing ] ) {
  4733. easing = "slide";
  4734. }
  4735. if ( !animations[ easing ] ) {
  4736. animations[ easing ] = function( options ) {
  4737. this.slide( options, {
  4738. easing: easing,
  4739. duration: duration || 700
  4740. });
  4741. };
  4742. }
  4743. animations[ easing ]( animOptions );
  4744. } else {
  4745. if ( options.collapsible && clickedIsActive ) {
  4746. toShow.toggle();
  4747. } else {
  4748. toHide.hide();
  4749. toShow.show();
  4750. }
  4751. complete( true );
  4752. }
  4753. // TODO assert that the blur and focus triggers are really necessary, remove otherwise
  4754. toHide.prev()
  4755. .attr({
  4756. "aria-expanded": "false",
  4757. "aria-selected": "false",
  4758. tabIndex: -1
  4759. })
  4760. .blur();
  4761. toShow.prev()
  4762. .attr({
  4763. "aria-expanded": "true",
  4764. "aria-selected": "true",
  4765. tabIndex: 0
  4766. })
  4767. .focus();
  4768. },
  4769. _completed: function( cancel ) {
  4770. this.running = cancel ? 0 : --this.running;
  4771. if ( this.running ) {
  4772. return;
  4773. }
  4774. if ( this.options.clearStyle ) {
  4775. this.toShow.add( this.toHide ).css({
  4776. height: "",
  4777. overflow: ""
  4778. });
  4779. }
  4780. // other classes are removed before the animation; this one needs to stay until completed
  4781. this.toHide.removeClass( "ui-accordion-content-active" );
  4782. // Work around for rendering bug in IE (#5421)
  4783. if ( this.toHide.length ) {
  4784. this.toHide.parent()[0].className = this.toHide.parent()[0].className;
  4785. }
  4786. this._trigger( "change", null, this.data );
  4787. }
  4788. });
  4789. $.extend( $.ui.accordion, {
  4790. version: "1.8.20",
  4791. animations: {
  4792. slide: function( options, additions ) {
  4793. options = $.extend({
  4794. easing: "swing",
  4795. duration: 300
  4796. }, options, additions );
  4797. if ( !options.toHide.size() ) {
  4798. options.toShow.animate({
  4799. height: "show",
  4800. paddingTop: "show",
  4801. paddingBottom: "show"
  4802. }, options );
  4803. return;
  4804. }
  4805. if ( !options.toShow.size() ) {
  4806. options.toHide.animate({
  4807. height: "hide",
  4808. paddingTop: "hide",
  4809. paddingBottom: "hide"
  4810. }, options );
  4811. return;
  4812. }
  4813. var overflow = options.toShow.css( "overflow" ),
  4814. percentDone = 0,
  4815. showProps = {},
  4816. hideProps = {},
  4817. fxAttrs = [ "height", "paddingTop", "paddingBottom" ],
  4818. originalWidth;
  4819. // fix width before calculating height of hidden element
  4820. var s = options.toShow;
  4821. originalWidth = s[0].style.width;
  4822. s.width( s.parent().width()
  4823. - parseFloat( s.css( "paddingLeft" ) )
  4824. - parseFloat( s.css( "paddingRight" ) )
  4825. - ( parseFloat( s.css( "borderLeftWidth" ) ) || 0 )
  4826. - ( parseFloat( s.css( "borderRightWidth" ) ) || 0 ) );
  4827. $.each( fxAttrs, function( i, prop ) {
  4828. hideProps[ prop ] = "hide";
  4829. var parts = ( "" + $.css( options.toShow[0], prop ) ).match( /^([\d+-.]+)(.*)$/ );
  4830. showProps[ prop ] = {
  4831. value: parts[ 1 ],
  4832. unit: parts[ 2 ] || "px"
  4833. };
  4834. });
  4835. options.toShow.css({ height: 0, overflow: "hidden" }).show();
  4836. options.toHide
  4837. .filter( ":hidden" )
  4838. .each( options.complete )
  4839. .end()
  4840. .filter( ":visible" )
  4841. .animate( hideProps, {
  4842. step: function( now, settings ) {
  4843. // only calculate the percent when animating height
  4844. // IE gets very inconsistent results when animating elements
  4845. // with small values, which is common for padding
  4846. if ( settings.prop == "height" ) {
  4847. percentDone = ( settings.end - settings.start === 0 ) ? 0 :
  4848. ( settings.now - settings.start ) / ( settings.end - settings.start );
  4849. }
  4850. options.toShow[ 0 ].style[ settings.prop ] =
  4851. ( percentDone * showProps[ settings.prop ].value )
  4852. + showProps[ settings.prop ].unit;
  4853. },
  4854. duration: options.duration,
  4855. easing: options.easing,
  4856. complete: function() {
  4857. if ( !options.autoHeight ) {
  4858. options.toShow.css( "height", "" );
  4859. }
  4860. options.toShow.css({
  4861. width: originalWidth,
  4862. overflow: overflow
  4863. });
  4864. options.complete();
  4865. }
  4866. });
  4867. },
  4868. bounceslide: function( options ) {
  4869. this.slide( options, {
  4870. easing: options.down ? "easeOutBounce" : "swing",
  4871. duration: options.down ? 1000 : 200
  4872. });
  4873. }
  4874. }
  4875. });
  4876. })( jQuery );
  4877. (function( $, undefined ) {
  4878. // used to prevent race conditions with remote data sources
  4879. var requestIndex = 0;
  4880. $.widget( "ui.autocomplete", {
  4881. options: {
  4882. appendTo: "body",
  4883. autoFocus: false,
  4884. delay: 300,
  4885. minLength: 1,
  4886. position: {
  4887. my: "left top",
  4888. at: "left bottom",
  4889. collision: "none"
  4890. },
  4891. source: null
  4892. },
  4893. pending: 0,
  4894. _create: function() {
  4895. var self = this,
  4896. doc = this.element[ 0 ].ownerDocument,
  4897. suppressKeyPress;
  4898. this.isMultiLine = this.element.is( "textarea" );
  4899. this.element
  4900. .addClass( "ui-autocomplete-input" )
  4901. .attr( "autocomplete", "off" )
  4902. // TODO verify these actually work as intended
  4903. .attr({
  4904. role: "textbox",
  4905. "aria-autocomplete": "list",
  4906. "aria-haspopup": "true"
  4907. })
  4908. .bind( "keydown.autocomplete", function( event ) {
  4909. if ( self.options.disabled || self.element.propAttr( "readOnly" ) ) {
  4910. return;
  4911. }
  4912. suppressKeyPress = false;
  4913. var keyCode = $.ui.keyCode;
  4914. switch( event.keyCode ) {
  4915. case keyCode.PAGE_UP:
  4916. self._move( "previousPage", event );
  4917. break;
  4918. case keyCode.PAGE_DOWN:
  4919. self._move( "nextPage", event );
  4920. break;
  4921. case keyCode.UP:
  4922. self._keyEvent( "previous", event );
  4923. break;
  4924. case keyCode.DOWN:
  4925. self._keyEvent( "next", event );
  4926. break;
  4927. case keyCode.ENTER:
  4928. case keyCode.NUMPAD_ENTER:
  4929. // when menu is open and has focus
  4930. if ( self.menu.active ) {
  4931. // #6055 - Opera still allows the keypress to occur
  4932. // which causes forms to submit
  4933. suppressKeyPress = true;
  4934. event.preventDefault();
  4935. }
  4936. //passthrough - ENTER and TAB both select the current element
  4937. case keyCode.TAB:
  4938. if ( !self.menu.active ) {
  4939. return;
  4940. }
  4941. self.menu.select( event );
  4942. break;
  4943. case keyCode.ESCAPE:
  4944. self.element.val( self.term );
  4945. self.close( event );
  4946. break;
  4947. default:
  4948. // keypress is triggered before the input value is changed
  4949. clearTimeout( self.searching );
  4950. self.searching = setTimeout(function() {
  4951. // only search if the value has changed
  4952. if ( self.term != self.element.val() ) {
  4953. self.selectedItem = null;
  4954. self.search( null, event );
  4955. }
  4956. }, self.options.delay );
  4957. break;
  4958. }
  4959. })
  4960. .bind( "keypress.autocomplete", function( event ) {
  4961. if ( suppressKeyPress ) {
  4962. suppressKeyPress = false;
  4963. event.preventDefault();
  4964. }
  4965. })
  4966. .bind( "focus.autocomplete", function() {
  4967. if ( self.options.disabled ) {
  4968. return;
  4969. }
  4970. self.selectedItem = null;
  4971. self.previous = self.element.val();
  4972. })
  4973. .bind( "blur.autocomplete", function( event ) {
  4974. if ( self.options.disabled ) {
  4975. return;
  4976. }
  4977. clearTimeout( self.searching );
  4978. // clicks on the menu (or a button to trigger a search) will cause a blur event
  4979. self.closing = setTimeout(function() {
  4980. self.close( event );
  4981. self._change( event );
  4982. }, 150 );
  4983. });
  4984. this._initSource();
  4985. this.menu = $( "<ul></ul>" )
  4986. .addClass( "ui-autocomplete" )
  4987. .appendTo( $( this.options.appendTo || "body", doc )[0] )
  4988. // prevent the close-on-blur in case of a "slow" click on the menu (long mousedown)
  4989. .mousedown(function( event ) {
  4990. // clicking on the scrollbar causes focus to shift to the body
  4991. // but we can't detect a mouseup or a click immediately afterward
  4992. // so we have to track the next mousedown and close the menu if
  4993. // the user clicks somewhere outside of the autocomplete
  4994. var menuElement = self.menu.element[ 0 ];
  4995. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  4996. setTimeout(function() {
  4997. $( document ).one( 'mousedown', function( event ) {
  4998. if ( event.target !== self.element[ 0 ] &&
  4999. event.target !== menuElement &&
  5000. !$.ui.contains( menuElement, event.target ) ) {
  5001. self.close();
  5002. }
  5003. });
  5004. }, 1 );
  5005. }
  5006. // use another timeout to make sure the blur-event-handler on the input was already triggered
  5007. setTimeout(function() {
  5008. clearTimeout( self.closing );
  5009. }, 13);
  5010. })
  5011. .menu({
  5012. focus: function( event, ui ) {
  5013. var item = ui.item.data( "item.autocomplete" );
  5014. if ( false !== self._trigger( "focus", event, { item: item } ) ) {
  5015. // use value to match what will end up in the input, if it was a key event
  5016. if ( /^key/.test(event.originalEvent.type) ) {
  5017. self.element.val( item.value );
  5018. }
  5019. }
  5020. },
  5021. selected: function( event, ui ) {
  5022. var item = ui.item.data( "item.autocomplete" ),
  5023. previous = self.previous;
  5024. // only trigger when focus was lost (click on menu)
  5025. if ( self.element[0] !== doc.activeElement ) {
  5026. self.element.focus();
  5027. self.previous = previous;
  5028. // #6109 - IE triggers two focus events and the second
  5029. // is asynchronous, so we need to reset the previous
  5030. // term synchronously and asynchronously :-(
  5031. setTimeout(function() {
  5032. self.previous = previous;
  5033. self.selectedItem = item;
  5034. }, 1);
  5035. }
  5036. if ( false !== self._trigger( "select", event, { item: item } ) ) {
  5037. self.element.val( item.value );
  5038. }
  5039. // reset the term after the select event
  5040. // this allows custom select handling to work properly
  5041. self.term = self.element.val();
  5042. self.close( event );
  5043. self.selectedItem = item;
  5044. },
  5045. blur: function( event, ui ) {
  5046. // don't set the value of the text field if it's already correct
  5047. // this prevents moving the cursor unnecessarily
  5048. if ( self.menu.element.is(":visible") &&
  5049. ( self.element.val() !== self.term ) ) {
  5050. self.element.val( self.term );
  5051. }
  5052. }
  5053. })
  5054. .zIndex( this.element.zIndex() + 1 )
  5055. // workaround for jQuery bug #5781 http://dev.jquery.com/ticket/5781
  5056. .css({ top: 0, left: 0 })
  5057. .hide()
  5058. .data( "menu" );
  5059. if ( $.fn.bgiframe ) {
  5060. this.menu.element.bgiframe();
  5061. }
  5062. // turning off autocomplete prevents the browser from remembering the
  5063. // value when navigating through history, so we re-enable autocomplete
  5064. // if the page is unloaded before the widget is destroyed. #7790
  5065. self.beforeunloadHandler = function() {
  5066. self.element.removeAttr( "autocomplete" );
  5067. };
  5068. $( window ).bind( "beforeunload", self.beforeunloadHandler );
  5069. },
  5070. destroy: function() {
  5071. this.element
  5072. .removeClass( "ui-autocomplete-input" )
  5073. .removeAttr( "autocomplete" )
  5074. .removeAttr( "role" )
  5075. .removeAttr( "aria-autocomplete" )
  5076. .removeAttr( "aria-haspopup" );
  5077. this.menu.element.remove();
  5078. $( window ).unbind( "beforeunload", this.beforeunloadHandler );
  5079. $.Widget.prototype.destroy.call( this );
  5080. },
  5081. _setOption: function( key, value ) {
  5082. $.Widget.prototype._setOption.apply( this, arguments );
  5083. if ( key === "source" ) {
  5084. this._initSource();
  5085. }
  5086. if ( key === "appendTo" ) {
  5087. this.menu.element.appendTo( $( value || "body", this.element[0].ownerDocument )[0] )
  5088. }
  5089. if ( key === "disabled" && value && this.xhr ) {
  5090. this.xhr.abort();
  5091. }
  5092. },
  5093. _initSource: function() {
  5094. var self = this,
  5095. array,
  5096. url;
  5097. if ( $.isArray(this.options.source) ) {
  5098. array = this.options.source;
  5099. this.source = function( request, response ) {
  5100. response( $.ui.autocomplete.filter(array, request.term) );
  5101. };
  5102. } else if ( typeof this.options.source === "string" ) {
  5103. url = this.options.source;
  5104. this.source = function( request, response ) {
  5105. if ( self.xhr ) {
  5106. self.xhr.abort();
  5107. }
  5108. self.xhr = $.ajax({
  5109. url: url,
  5110. data: request,
  5111. dataType: "json",
  5112. success: function( data, status ) {
  5113. response( data );
  5114. },
  5115. error: function() {
  5116. response( [] );
  5117. }
  5118. });
  5119. };
  5120. } else {
  5121. this.source = this.options.source;
  5122. }
  5123. },
  5124. search: function( value, event ) {
  5125. value = value != null ? value : this.element.val();
  5126. // always save the actual value, not the one passed as an argument
  5127. this.term = this.element.val();
  5128. if ( value.length < this.options.minLength ) {
  5129. return this.close( event );
  5130. }
  5131. clearTimeout( this.closing );
  5132. if ( this._trigger( "search", event ) === false ) {
  5133. return;
  5134. }
  5135. return this._search( value );
  5136. },
  5137. _search: function( value ) {
  5138. this.pending++;
  5139. this.element.addClass( "ui-autocomplete-loading" );
  5140. this.source( { term: value }, this._response() );
  5141. },
  5142. _response: function() {
  5143. var that = this,
  5144. index = ++requestIndex;
  5145. return function( content ) {
  5146. if ( index === requestIndex ) {
  5147. that.__response( content );
  5148. }
  5149. that.pending--;
  5150. if ( !that.pending ) {
  5151. that.element.removeClass( "ui-autocomplete-loading" );
  5152. }
  5153. };
  5154. },
  5155. __response: function( content ) {
  5156. if ( !this.options.disabled && content && content.length ) {
  5157. content = this._normalize( content );
  5158. this._suggest( content );
  5159. this._trigger( "open" );
  5160. } else {
  5161. this.close();
  5162. }
  5163. },
  5164. close: function( event ) {
  5165. clearTimeout( this.closing );
  5166. if ( this.menu.element.is(":visible") ) {
  5167. this.menu.element.hide();
  5168. this.menu.deactivate();
  5169. this._trigger( "close", event );
  5170. }
  5171. },
  5172. _change: function( event ) {
  5173. if ( this.previous !== this.element.val() ) {
  5174. this._trigger( "change", event, { item: this.selectedItem } );
  5175. }
  5176. },
  5177. _normalize: function( items ) {
  5178. // assume all items have the right format when the first item is complete
  5179. if ( items.length && items[0].label && items[0].value ) {
  5180. return items;
  5181. }
  5182. return $.map( items, function(item) {
  5183. if ( typeof item === "string" ) {
  5184. return {
  5185. label: item,
  5186. value: item
  5187. };
  5188. }
  5189. return $.extend({
  5190. label: item.label || item.value,
  5191. value: item.value || item.label
  5192. }, item );
  5193. });
  5194. },
  5195. _suggest: function( items ) {
  5196. var ul = this.menu.element
  5197. .empty()
  5198. .zIndex( this.element.zIndex() + 1 );
  5199. this._renderMenu( ul, items );
  5200. // TODO refresh should check if the active item is still in the dom, removing the need for a manual deactivate
  5201. this.menu.deactivate();
  5202. this.menu.refresh();
  5203. // size and position menu
  5204. ul.show();
  5205. this._resizeMenu();
  5206. ul.position( $.extend({
  5207. of: this.element
  5208. }, this.options.position ));
  5209. if ( this.options.autoFocus ) {
  5210. this.menu.next( new $.Event("mouseover") );
  5211. }
  5212. },
  5213. _resizeMenu: function() {
  5214. var ul = this.menu.element;
  5215. ul.outerWidth( Math.max(
  5216. // Firefox wraps long text (possibly a rounding bug)
  5217. // so we add 1px to avoid the wrapping (#7513)
  5218. ul.width( "" ).outerWidth() + 1,
  5219. this.element.outerWidth()
  5220. ) );
  5221. },
  5222. _renderMenu: function( ul, items ) {
  5223. var self = this;
  5224. $.each( items, function( index, item ) {
  5225. self._renderItem( ul, item );
  5226. });
  5227. },
  5228. _renderItem: function( ul, item) {
  5229. return $( "<li></li>" )
  5230. .data( "item.autocomplete", item )
  5231. .append( $( "<a></a>" ).text( item.label ) )
  5232. .appendTo( ul );
  5233. },
  5234. _move: function( direction, event ) {
  5235. if ( !this.menu.element.is(":visible") ) {
  5236. this.search( null, event );
  5237. return;
  5238. }
  5239. if ( this.menu.first() && /^previous/.test(direction) ||
  5240. this.menu.last() && /^next/.test(direction) ) {
  5241. this.element.val( this.term );
  5242. this.menu.deactivate();
  5243. return;
  5244. }
  5245. this.menu[ direction ]( event );
  5246. },
  5247. widget: function() {
  5248. return this.menu.element;
  5249. },
  5250. _keyEvent: function( keyEvent, event ) {
  5251. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  5252. this._move( keyEvent, event );
  5253. // prevents moving cursor to beginning/end of the text field in some browsers
  5254. event.preventDefault();
  5255. }
  5256. }
  5257. });
  5258. $.extend( $.ui.autocomplete, {
  5259. escapeRegex: function( value ) {
  5260. return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
  5261. },
  5262. filter: function(array, term) {
  5263. var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
  5264. return $.grep( array, function(value) {
  5265. return matcher.test( value.label || value.value || value );
  5266. });
  5267. }
  5268. });
  5269. }( jQuery ));
  5270. /*
  5271. * jQuery UI Menu (not officially released)
  5272. *
  5273. * This widget isn't yet finished and the API is subject to change. We plan to finish
  5274. * it for the next release. You're welcome to give it a try anyway and give us feedback,
  5275. * as long as you're okay with migrating your code later on. We can help with that, too.
  5276. *
  5277. * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
  5278. * Dual licensed under the MIT or GPL Version 2 licenses.
  5279. * http://jquery.org/license
  5280. *
  5281. * http://docs.jquery.com/UI/Menu
  5282. *
  5283. * Depends:
  5284. * jquery.ui.core.js
  5285. * jquery.ui.widget.js
  5286. */
  5287. (function($) {
  5288. $.widget("ui.menu", {
  5289. _create: function() {
  5290. var self = this;
  5291. this.element
  5292. .addClass("ui-menu ui-widget ui-widget-content ui-corner-all")
  5293. .attr({
  5294. role: "listbox",
  5295. "aria-activedescendant": "ui-active-menuitem"
  5296. })
  5297. .click(function( event ) {
  5298. if ( !$( event.target ).closest( ".ui-menu-item a" ).length ) {
  5299. return;
  5300. }
  5301. // temporary
  5302. event.preventDefault();
  5303. self.select( event );
  5304. });
  5305. this.refresh();
  5306. },
  5307. refresh: function() {
  5308. var self = this;
  5309. // don't refresh list items that are already adapted
  5310. var items = this.element.children("li:not(.ui-menu-item):has(a)")
  5311. .addClass("ui-menu-item")
  5312. .attr("role", "menuitem");
  5313. items.children("a")
  5314. .addClass("ui-corner-all")
  5315. .attr("tabindex", -1)
  5316. // mouseenter doesn't work with event delegation
  5317. .mouseenter(function( event ) {
  5318. self.activate( event, $(this).parent() );
  5319. })
  5320. .mouseleave(function() {
  5321. self.deactivate();
  5322. });
  5323. },
  5324. activate: function( event, item ) {
  5325. this.deactivate();
  5326. if (this.hasScroll()) {
  5327. var offset = item.offset().top - this.element.offset().top,
  5328. scroll = this.element.scrollTop(),
  5329. elementHeight = this.element.height();
  5330. if (offset < 0) {
  5331. this.element.scrollTop( scroll + offset);
  5332. } else if (offset >= elementHeight) {
  5333. this.element.scrollTop( scroll + offset - elementHeight + item.height());
  5334. }
  5335. }
  5336. this.active = item.eq(0)
  5337. .children("a")
  5338. .addClass("ui-state-hover")
  5339. .attr("id", "ui-active-menuitem")
  5340. .end();
  5341. this._trigger("focus", event, { item: item });
  5342. },
  5343. deactivate: function() {
  5344. if (!this.active) { return; }
  5345. this.active.children("a")
  5346. .removeClass("ui-state-hover")
  5347. .removeAttr("id");
  5348. this._trigger("blur");
  5349. this.active = null;
  5350. },
  5351. next: function(event) {
  5352. this.move("next", ".ui-menu-item:first", event);
  5353. },
  5354. previous: function(event) {
  5355. this.move("prev", ".ui-menu-item:last", event);
  5356. },
  5357. first: function() {
  5358. return this.active && !this.active.prevAll(".ui-menu-item").length;
  5359. },
  5360. last: function() {
  5361. return this.active && !this.active.nextAll(".ui-menu-item").length;
  5362. },
  5363. move: function(direction, edge, event) {
  5364. if (!this.active) {
  5365. this.activate(event, this.element.children(edge));
  5366. return;
  5367. }
  5368. var next = this.active[direction + "All"](".ui-menu-item").eq(0);
  5369. if (next.length) {
  5370. this.activate(event, next);
  5371. } else {
  5372. this.activate(event, this.element.children(edge));
  5373. }
  5374. },
  5375. // TODO merge with previousPage
  5376. nextPage: function(event) {
  5377. if (this.hasScroll()) {
  5378. // TODO merge with no-scroll-else
  5379. if (!this.active || this.last()) {
  5380. this.activate(event, this.element.children(".ui-menu-item:first"));
  5381. return;
  5382. }
  5383. var base = this.active.offset().top,
  5384. height = this.element.height(),
  5385. result = this.element.children(".ui-menu-item").filter(function() {
  5386. var close = $(this).offset().top - base - height + $(this).height();
  5387. // TODO improve approximation
  5388. return close < 10 && close > -10;
  5389. });
  5390. // TODO try to catch this earlier when scrollTop indicates the last page anyway
  5391. if (!result.length) {
  5392. result = this.element.children(".ui-menu-item:last");
  5393. }
  5394. this.activate(event, result);
  5395. } else {
  5396. this.activate(event, this.element.children(".ui-menu-item")
  5397. .filter(!this.active || this.last() ? ":first" : ":last"));
  5398. }
  5399. },
  5400. // TODO merge with nextPage
  5401. previousPage: function(event) {
  5402. if (this.hasScroll()) {
  5403. // TODO merge with no-scroll-else
  5404. if (!this.active || this.first()) {
  5405. this.activate(event, this.element.children(".ui-menu-item:last"));
  5406. return;
  5407. }
  5408. var base = this.active.offset().top,
  5409. height = this.element.height(),
  5410. result = this.element.children(".ui-menu-item").filter(function() {
  5411. var close = $(this).offset().top - base + height - $(this).height();
  5412. // TODO improve approximation
  5413. return close < 10 && close > -10;
  5414. });
  5415. // TODO try to catch this earlier when scrollTop indicates the last page anyway
  5416. if (!result.length) {
  5417. result = this.element.children(".ui-menu-item:first");
  5418. }
  5419. this.activate(event, result);
  5420. } else {
  5421. this.activate(event, this.element.children(".ui-menu-item")
  5422. .filter(!this.active || this.first() ? ":last" : ":first"));
  5423. }
  5424. },
  5425. hasScroll: function() {
  5426. return this.element.height() < this.element[ $.fn.prop ? "prop" : "attr" ]("scrollHeight");
  5427. },
  5428. select: function( event ) {
  5429. this._trigger("selected", event, { item: this.active });
  5430. }
  5431. });
  5432. }(jQuery));
  5433. (function( $, undefined ) {
  5434. var lastActive, startXPos, startYPos, clickDragged,
  5435. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  5436. stateClasses = "ui-state-hover ui-state-active ",
  5437. 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",
  5438. formResetHandler = function() {
  5439. var buttons = $( this ).find( ":ui-button" );
  5440. setTimeout(function() {
  5441. buttons.button( "refresh" );
  5442. }, 1 );
  5443. },
  5444. radioGroup = function( radio ) {
  5445. var name = radio.name,
  5446. form = radio.form,
  5447. radios = $( [] );
  5448. if ( name ) {
  5449. if ( form ) {
  5450. radios = $( form ).find( "[name='" + name + "']" );
  5451. } else {
  5452. radios = $( "[name='" + name + "']", radio.ownerDocument )
  5453. .filter(function() {
  5454. return !this.form;
  5455. });
  5456. }
  5457. }
  5458. return radios;
  5459. };
  5460. $.widget( "ui.button", {
  5461. options: {
  5462. disabled: null,
  5463. text: true,
  5464. label: null,
  5465. icons: {
  5466. primary: null,
  5467. secondary: null
  5468. }
  5469. },
  5470. _create: function() {
  5471. this.element.closest( "form" )
  5472. .unbind( "reset.button" )
  5473. .bind( "reset.button", formResetHandler );
  5474. if ( typeof this.options.disabled !== "boolean" ) {
  5475. this.options.disabled = !!this.element.propAttr( "disabled" );
  5476. } else {
  5477. this.element.propAttr( "disabled", this.options.disabled );
  5478. }
  5479. this._determineButtonType();
  5480. this.hasTitle = !!this.buttonElement.attr( "title" );
  5481. var self = this,
  5482. options = this.options,
  5483. toggleButton = this.type === "checkbox" || this.type === "radio",
  5484. hoverClass = "ui-state-hover" + ( !toggleButton ? " ui-state-active" : "" ),
  5485. focusClass = "ui-state-focus";
  5486. if ( options.label === null ) {
  5487. options.label = this.buttonElement.html();
  5488. }
  5489. this.buttonElement
  5490. .addClass( baseClasses )
  5491. .attr( "role", "button" )
  5492. .bind( "mouseenter.button", function() {
  5493. if ( options.disabled ) {
  5494. return;
  5495. }
  5496. $( this ).addClass( "ui-state-hover" );
  5497. if ( this === lastActive ) {
  5498. $( this ).addClass( "ui-state-active" );
  5499. }
  5500. })
  5501. .bind( "mouseleave.button", function() {
  5502. if ( options.disabled ) {
  5503. return;
  5504. }
  5505. $( this ).removeClass( hoverClass );
  5506. })
  5507. .bind( "click.button", function( event ) {
  5508. if ( options.disabled ) {
  5509. event.preventDefault();
  5510. event.stopImmediatePropagation();
  5511. }
  5512. });
  5513. this.element
  5514. .bind( "focus.button", function() {
  5515. // no need to check disabled, focus won't be triggered anyway
  5516. self.buttonElement.addClass( focusClass );
  5517. })
  5518. .bind( "blur.button", function() {
  5519. self.buttonElement.removeClass( focusClass );
  5520. });
  5521. if ( toggleButton ) {
  5522. this.element.bind( "change.button", function() {
  5523. if ( clickDragged ) {
  5524. return;
  5525. }
  5526. self.refresh();
  5527. });
  5528. // if mouse moves between mousedown and mouseup (drag) set clickDragged flag
  5529. // prevents issue where button state changes but checkbox/radio checked state
  5530. // does not in Firefox (see ticket #6970)
  5531. this.buttonElement
  5532. .bind( "mousedown.button", function( event ) {
  5533. if ( options.disabled ) {
  5534. return;
  5535. }
  5536. clickDragged = false;
  5537. startXPos = event.pageX;
  5538. startYPos = event.pageY;
  5539. })
  5540. .bind( "mouseup.button", function( event ) {
  5541. if ( options.disabled ) {
  5542. return;
  5543. }
  5544. if ( startXPos !== event.pageX || startYPos !== event.pageY ) {
  5545. clickDragged = true;
  5546. }
  5547. });
  5548. }
  5549. if ( this.type === "checkbox" ) {
  5550. this.buttonElement.bind( "click.button", function() {
  5551. if ( options.disabled || clickDragged ) {
  5552. return false;
  5553. }
  5554. $( this ).toggleClass( "ui-state-active" );
  5555. self.buttonElement.attr( "aria-pressed", self.element[0].checked );
  5556. });
  5557. } else if ( this.type === "radio" ) {
  5558. this.buttonElement.bind( "click.button", function() {
  5559. if ( options.disabled || clickDragged ) {
  5560. return false;
  5561. }
  5562. $( this ).addClass( "ui-state-active" );
  5563. self.buttonElement.attr( "aria-pressed", "true" );
  5564. var radio = self.element[ 0 ];
  5565. radioGroup( radio )
  5566. .not( radio )
  5567. .map(function() {
  5568. return $( this ).button( "widget" )[ 0 ];
  5569. })
  5570. .removeClass( "ui-state-active" )
  5571. .attr( "aria-pressed", "false" );
  5572. });
  5573. } else {
  5574. this.buttonElement
  5575. .bind( "mousedown.button", function() {
  5576. if ( options.disabled ) {
  5577. return false;
  5578. }
  5579. $( this ).addClass( "ui-state-active" );
  5580. lastActive = this;
  5581. $( document ).one( "mouseup", function() {
  5582. lastActive = null;
  5583. });
  5584. })
  5585. .bind( "mouseup.button", function() {
  5586. if ( options.disabled ) {
  5587. return false;
  5588. }
  5589. $( this ).removeClass( "ui-state-active" );
  5590. })
  5591. .bind( "keydown.button", function(event) {
  5592. if ( options.disabled ) {
  5593. return false;
  5594. }
  5595. if ( event.keyCode == $.ui.keyCode.SPACE || event.keyCode == $.ui.keyCode.ENTER ) {
  5596. $( this ).addClass( "ui-state-active" );
  5597. }
  5598. })
  5599. .bind( "keyup.button", function() {
  5600. $( this ).removeClass( "ui-state-active" );
  5601. });
  5602. if ( this.buttonElement.is("a") ) {
  5603. this.buttonElement.keyup(function(event) {
  5604. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  5605. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  5606. $( this ).click();
  5607. }
  5608. });
  5609. }
  5610. }
  5611. // TODO: pull out $.Widget's handling for the disabled option into
  5612. // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
  5613. // be overridden by individual plugins
  5614. this._setOption( "disabled", options.disabled );
  5615. this._resetButton();
  5616. },
  5617. _determineButtonType: function() {
  5618. if ( this.element.is(":checkbox") ) {
  5619. this.type = "checkbox";
  5620. } else if ( this.element.is(":radio") ) {
  5621. this.type = "radio";
  5622. } else if ( this.element.is("input") ) {
  5623. this.type = "input";
  5624. } else {
  5625. this.type = "button";
  5626. }
  5627. if ( this.type === "checkbox" || this.type === "radio" ) {
  5628. // we don't search against the document in case the element
  5629. // is disconnected from the DOM
  5630. var ancestor = this.element.parents().filter(":last"),
  5631. labelSelector = "label[for='" + this.element.attr("id") + "']";
  5632. this.buttonElement = ancestor.find( labelSelector );
  5633. if ( !this.buttonElement.length ) {
  5634. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  5635. this.buttonElement = ancestor.filter( labelSelector );
  5636. if ( !this.buttonElement.length ) {
  5637. this.buttonElement = ancestor.find( labelSelector );
  5638. }
  5639. }
  5640. this.element.addClass( "ui-helper-hidden-accessible" );
  5641. var checked = this.element.is( ":checked" );
  5642. if ( checked ) {
  5643. this.buttonElement.addClass( "ui-state-active" );
  5644. }
  5645. this.buttonElement.attr( "aria-pressed", checked );
  5646. } else {
  5647. this.buttonElement = this.element;
  5648. }
  5649. },
  5650. widget: function() {
  5651. return this.buttonElement;
  5652. },
  5653. destroy: function() {
  5654. this.element
  5655. .removeClass( "ui-helper-hidden-accessible" );
  5656. this.buttonElement
  5657. .removeClass( baseClasses + " " + stateClasses + " " + typeClasses )
  5658. .removeAttr( "role" )
  5659. .removeAttr( "aria-pressed" )
  5660. .html( this.buttonElement.find(".ui-button-text").html() );
  5661. if ( !this.hasTitle ) {
  5662. this.buttonElement.removeAttr( "title" );
  5663. }
  5664. $.Widget.prototype.destroy.call( this );
  5665. },
  5666. _setOption: function( key, value ) {
  5667. $.Widget.prototype._setOption.apply( this, arguments );
  5668. if ( key === "disabled" ) {
  5669. if ( value ) {
  5670. this.element.propAttr( "disabled", true );
  5671. } else {
  5672. this.element.propAttr( "disabled", false );
  5673. }
  5674. return;
  5675. }
  5676. this._resetButton();
  5677. },
  5678. refresh: function() {
  5679. var isDisabled = this.element.is( ":disabled" );
  5680. if ( isDisabled !== this.options.disabled ) {
  5681. this._setOption( "disabled", isDisabled );
  5682. }
  5683. if ( this.type === "radio" ) {
  5684. radioGroup( this.element[0] ).each(function() {
  5685. if ( $( this ).is( ":checked" ) ) {
  5686. $( this ).button( "widget" )
  5687. .addClass( "ui-state-active" )
  5688. .attr( "aria-pressed", "true" );
  5689. } else {
  5690. $( this ).button( "widget" )
  5691. .removeClass( "ui-state-active" )
  5692. .attr( "aria-pressed", "false" );
  5693. }
  5694. });
  5695. } else if ( this.type === "checkbox" ) {
  5696. if ( this.element.is( ":checked" ) ) {
  5697. this.buttonElement
  5698. .addClass( "ui-state-active" )
  5699. .attr( "aria-pressed", "true" );
  5700. } else {
  5701. this.buttonElement
  5702. .removeClass( "ui-state-active" )
  5703. .attr( "aria-pressed", "false" );
  5704. }
  5705. }
  5706. },
  5707. _resetButton: function() {
  5708. if ( this.type === "input" ) {
  5709. if ( this.options.label ) {
  5710. this.element.val( this.options.label );
  5711. }
  5712. return;
  5713. }
  5714. var buttonElement = this.buttonElement.removeClass( typeClasses ),
  5715. buttonText = $( "<span></span>", this.element[0].ownerDocument )
  5716. .addClass( "ui-button-text" )
  5717. .html( this.options.label )
  5718. .appendTo( buttonElement.empty() )
  5719. .text(),
  5720. icons = this.options.icons,
  5721. multipleIcons = icons.primary && icons.secondary,
  5722. buttonClasses = [];
  5723. if ( icons.primary || icons.secondary ) {
  5724. if ( this.options.text ) {
  5725. buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
  5726. }
  5727. if ( icons.primary ) {
  5728. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  5729. }
  5730. if ( icons.secondary ) {
  5731. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  5732. }
  5733. if ( !this.options.text ) {
  5734. buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
  5735. if ( !this.hasTitle ) {
  5736. buttonElement.attr( "title", buttonText );
  5737. }
  5738. }
  5739. } else {
  5740. buttonClasses.push( "ui-button-text-only" );
  5741. }
  5742. buttonElement.addClass( buttonClasses.join( " " ) );
  5743. }
  5744. });
  5745. $.widget( "ui.buttonset", {
  5746. options: {
  5747. items: ":button, :submit, :reset, :checkbox, :radio, a, :data(button)"
  5748. },
  5749. _create: function() {
  5750. this.element.addClass( "ui-buttonset" );
  5751. },
  5752. _init: function() {
  5753. this.refresh();
  5754. },
  5755. _setOption: function( key, value ) {
  5756. if ( key === "disabled" ) {
  5757. this.buttons.button( "option", key, value );
  5758. }
  5759. $.Widget.prototype._setOption.apply( this, arguments );
  5760. },
  5761. refresh: function() {
  5762. var rtl = this.element.css( "direction" ) === "rtl";
  5763. this.buttons = this.element.find( this.options.items )
  5764. .filter( ":ui-button" )
  5765. .button( "refresh" )
  5766. .end()
  5767. .not( ":ui-button" )
  5768. .button()
  5769. .end()
  5770. .map(function() {
  5771. return $( this ).button( "widget" )[ 0 ];
  5772. })
  5773. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  5774. .filter( ":first" )
  5775. .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
  5776. .end()
  5777. .filter( ":last" )
  5778. .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
  5779. .end()
  5780. .end();
  5781. },
  5782. destroy: function() {
  5783. this.element.removeClass( "ui-buttonset" );
  5784. this.buttons
  5785. .map(function() {
  5786. return $( this ).button( "widget" )[ 0 ];
  5787. })
  5788. .removeClass( "ui-corner-left ui-corner-right" )
  5789. .end()
  5790. .button( "destroy" );
  5791. $.Widget.prototype.destroy.call( this );
  5792. }
  5793. });
  5794. }( jQuery ) );
  5795. (function( $, undefined ) {
  5796. $.extend($.ui, { datepicker: { version: "1.8.20" } });
  5797. var PROP_NAME = 'datepicker';
  5798. var dpuuid = new Date().getTime();
  5799. var instActive;
  5800. /* Date picker manager.
  5801. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  5802. Settings for (groups of) date pickers are maintained in an instance object,
  5803. allowing multiple different settings on the same page. */
  5804. function Datepicker() {
  5805. this.debug = false; // Change this to true to start debugging
  5806. this._curInst = null; // The current instance in use
  5807. this._keyEvent = false; // If the last event was a key event
  5808. this._disabledInputs = []; // List of date picker inputs that have been disabled
  5809. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  5810. this._inDialog = false; // True if showing within a "dialog", false if not
  5811. this._mainDivId = 'ui-datepicker-div'; // The ID of the main datepicker division
  5812. this._inlineClass = 'ui-datepicker-inline'; // The name of the inline marker class
  5813. this._appendClass = 'ui-datepicker-append'; // The name of the append marker class
  5814. this._triggerClass = 'ui-datepicker-trigger'; // The name of the trigger marker class
  5815. this._dialogClass = 'ui-datepicker-dialog'; // The name of the dialog marker class
  5816. this._disableClass = 'ui-datepicker-disabled'; // The name of the disabled covering marker class
  5817. this._unselectableClass = 'ui-datepicker-unselectable'; // The name of the unselectable cell marker class
  5818. this._currentClass = 'ui-datepicker-current-day'; // The name of the current day marker class
  5819. this._dayOverClass = 'ui-datepicker-days-cell-over'; // The name of the day hover marker class
  5820. this.regional = []; // Available regional settings, indexed by language code
  5821. this.regional[''] = { // Default regional settings
  5822. closeText: 'Done', // Display text for close link
  5823. prevText: 'Prev', // Display text for previous month link
  5824. nextText: 'Next', // Display text for next month link
  5825. currentText: 'Today', // Display text for current month link
  5826. monthNames: ['January','February','March','April','May','June',
  5827. 'July','August','September','October','November','December'], // Names of months for drop-down and formatting
  5828. monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting
  5829. dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting
  5830. dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting
  5831. dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday
  5832. weekHeader: 'Wk', // Column header for week of the year
  5833. dateFormat: 'mm/dd/yy', // See format options on parseDate
  5834. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  5835. isRTL: false, // True if right-to-left language, false if left-to-right
  5836. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  5837. yearSuffix: '' // Additional text to append to the year in the month headers
  5838. };
  5839. this._defaults = { // Global defaults for all the date picker instances
  5840. showOn: 'focus', // 'focus' for popup on focus,
  5841. // 'button' for trigger button, or 'both' for either
  5842. showAnim: 'fadeIn', // Name of jQuery animation for popup
  5843. showOptions: {}, // Options for enhanced animations
  5844. defaultDate: null, // Used when field is blank: actual date,
  5845. // +/-number for offset from today, null for today
  5846. appendText: '', // Display text following the input box, e.g. showing the format
  5847. buttonText: '...', // Text for trigger button
  5848. buttonImage: '', // URL for trigger button image
  5849. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  5850. hideIfNoPrevNext: false, // True to hide next/previous month links
  5851. // if not applicable, false to just disable them
  5852. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  5853. gotoCurrent: false, // True if today link goes back to current selection instead
  5854. changeMonth: false, // True if month can be selected directly, false if only prev/next
  5855. changeYear: false, // True if year can be selected directly, false if only prev/next
  5856. yearRange: 'c-10:c+10', // Range of years to display in drop-down,
  5857. // either relative to today's year (-nn:+nn), relative to currently displayed year
  5858. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  5859. showOtherMonths: false, // True to show dates in other months, false to leave blank
  5860. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  5861. showWeek: false, // True to show week of the year, false to not show it
  5862. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  5863. // takes a Date and returns the number of the week for it
  5864. shortYearCutoff: '+10', // Short year values < this are in the current century,
  5865. // > this are in the previous century,
  5866. // string value starting with '+' for current year + value
  5867. minDate: null, // The earliest selectable date, or null for no limit
  5868. maxDate: null, // The latest selectable date, or null for no limit
  5869. duration: 'fast', // Duration of display/closure
  5870. beforeShowDay: null, // Function that takes a date and returns an array with
  5871. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or '',
  5872. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  5873. beforeShow: null, // Function that takes an input field and
  5874. // returns a set of custom settings for the date picker
  5875. onSelect: null, // Define a callback function when a date is selected
  5876. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  5877. onClose: null, // Define a callback function when the datepicker is closed
  5878. numberOfMonths: 1, // Number of months to show at a time
  5879. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  5880. stepMonths: 1, // Number of months to step back/forward
  5881. stepBigMonths: 12, // Number of months to step back/forward for the big links
  5882. altField: '', // Selector for an alternate field to store selected dates into
  5883. altFormat: '', // The date format to use for the alternate field
  5884. constrainInput: true, // The input is constrained by the current date format
  5885. showButtonPanel: false, // True to show button panel, false to not show it
  5886. autoSize: false, // True to size the input for the date format, false to leave as is
  5887. disabled: false // The initial disabled state
  5888. };
  5889. $.extend(this._defaults, this.regional['']);
  5890. this.dpDiv = bindHover($('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'));
  5891. }
  5892. $.extend(Datepicker.prototype, {
  5893. /* Class name added to elements to indicate already configured with a date picker. */
  5894. markerClassName: 'hasDatepicker',
  5895. //Keep track of the maximum number of rows displayed (see #7043)
  5896. maxRows: 4,
  5897. /* Debug logging (if enabled). */
  5898. log: function () {
  5899. if (this.debug)
  5900. console.log.apply('', arguments);
  5901. },
  5902. // TODO rename to "widget" when switching to widget factory
  5903. _widgetDatepicker: function() {
  5904. return this.dpDiv;
  5905. },
  5906. /* Override the default settings for all instances of the date picker.
  5907. @param settings object - the new settings to use as defaults (anonymous object)
  5908. @return the manager object */
  5909. setDefaults: function(settings) {
  5910. extendRemove(this._defaults, settings || {});
  5911. return this;
  5912. },
  5913. /* Attach the date picker to a jQuery selection.
  5914. @param target element - the target input field or division or span
  5915. @param settings object - the new settings to use for this date picker instance (anonymous) */
  5916. _attachDatepicker: function(target, settings) {
  5917. // check for settings on the control itself - in namespace 'date:'
  5918. var inlineSettings = null;
  5919. for (var attrName in this._defaults) {
  5920. var attrValue = target.getAttribute('date:' + attrName);
  5921. if (attrValue) {
  5922. inlineSettings = inlineSettings || {};
  5923. try {
  5924. inlineSettings[attrName] = eval(attrValue);
  5925. } catch (err) {
  5926. inlineSettings[attrName] = attrValue;
  5927. }
  5928. }
  5929. }
  5930. var nodeName = target.nodeName.toLowerCase();
  5931. var inline = (nodeName == 'div' || nodeName == 'span');
  5932. if (!target.id) {
  5933. this.uuid += 1;
  5934. target.id = 'dp' + this.uuid;
  5935. }
  5936. var inst = this._newInst($(target), inline);
  5937. inst.settings = $.extend({}, settings || {}, inlineSettings || {});
  5938. if (nodeName == 'input') {
  5939. this._connectDatepicker(target, inst);
  5940. } else if (inline) {
  5941. this._inlineDatepicker(target, inst);
  5942. }
  5943. },
  5944. /* Create a new instance object. */
  5945. _newInst: function(target, inline) {
  5946. var id = target[0].id.replace(/([^A-Za-z0-9_-])/g, '\\\\$1'); // escape jQuery meta chars
  5947. return {id: id, input: target, // associated target
  5948. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  5949. drawMonth: 0, drawYear: 0, // month being drawn
  5950. inline: inline, // is datepicker inline or not
  5951. dpDiv: (!inline ? this.dpDiv : // presentation div
  5952. bindHover($('<div class="' + this._inlineClass + ' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>')))};
  5953. },
  5954. /* Attach the date picker to an input field. */
  5955. _connectDatepicker: function(target, inst) {
  5956. var input = $(target);
  5957. inst.append = $([]);
  5958. inst.trigger = $([]);
  5959. if (input.hasClass(this.markerClassName))
  5960. return;
  5961. this._attachments(input, inst);
  5962. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  5963. keypress(this._doKeyPress).keyup(this._doKeyUp).
  5964. bind("setData.datepicker", function(event, key, value) {
  5965. inst.settings[key] = value;
  5966. }).bind("getData.datepicker", function(event, key) {
  5967. return this._get(inst, key);
  5968. });
  5969. this._autoSize(inst);
  5970. $.data(target, PROP_NAME, inst);
  5971. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  5972. if( inst.settings.disabled ) {
  5973. this._disableDatepicker( target );
  5974. }
  5975. },
  5976. /* Make attachments based on settings. */
  5977. _attachments: function(input, inst) {
  5978. var appendText = this._get(inst, 'appendText');
  5979. var isRTL = this._get(inst, 'isRTL');
  5980. if (inst.append)
  5981. inst.append.remove();
  5982. if (appendText) {
  5983. inst.append = $('<span class="' + this._appendClass + '">' + appendText + '</span>');
  5984. input[isRTL ? 'before' : 'after'](inst.append);
  5985. }
  5986. input.unbind('focus', this._showDatepicker);
  5987. if (inst.trigger)
  5988. inst.trigger.remove();
  5989. var showOn = this._get(inst, 'showOn');
  5990. if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field
  5991. input.focus(this._showDatepicker);
  5992. if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked
  5993. var buttonText = this._get(inst, 'buttonText');
  5994. var buttonImage = this._get(inst, 'buttonImage');
  5995. inst.trigger = $(this._get(inst, 'buttonImageOnly') ?
  5996. $('<img/>').addClass(this._triggerClass).
  5997. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  5998. $('<button type="button"></button>').addClass(this._triggerClass).
  5999. html(buttonImage == '' ? buttonText : $('<img/>').attr(
  6000. { src:buttonImage, alt:buttonText, title:buttonText })));
  6001. input[isRTL ? 'before' : 'after'](inst.trigger);
  6002. inst.trigger.click(function() {
  6003. if ($.datepicker._datepickerShowing && $.datepicker._lastInput == input[0])
  6004. $.datepicker._hideDatepicker();
  6005. else if ($.datepicker._datepickerShowing && $.datepicker._lastInput != input[0]) {
  6006. $.datepicker._hideDatepicker();
  6007. $.datepicker._showDatepicker(input[0]);
  6008. } else
  6009. $.datepicker._showDatepicker(input[0]);
  6010. return false;
  6011. });
  6012. }
  6013. },
  6014. /* Apply the maximum length for the date format. */
  6015. _autoSize: function(inst) {
  6016. if (this._get(inst, 'autoSize') && !inst.inline) {
  6017. var date = new Date(2009, 12 - 1, 20); // Ensure double digits
  6018. var dateFormat = this._get(inst, 'dateFormat');
  6019. if (dateFormat.match(/[DM]/)) {
  6020. var findMax = function(names) {
  6021. var max = 0;
  6022. var maxI = 0;
  6023. for (var i = 0; i < names.length; i++) {
  6024. if (names[i].length > max) {
  6025. max = names[i].length;
  6026. maxI = i;
  6027. }
  6028. }
  6029. return maxI;
  6030. };
  6031. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  6032. 'monthNames' : 'monthNamesShort'))));
  6033. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  6034. 'dayNames' : 'dayNamesShort'))) + 20 - date.getDay());
  6035. }
  6036. inst.input.attr('size', this._formatDate(inst, date).length);
  6037. }
  6038. },
  6039. /* Attach an inline date picker to a div. */
  6040. _inlineDatepicker: function(target, inst) {
  6041. var divSpan = $(target);
  6042. if (divSpan.hasClass(this.markerClassName))
  6043. return;
  6044. divSpan.addClass(this.markerClassName).append(inst.dpDiv).
  6045. bind("setData.datepicker", function(event, key, value){
  6046. inst.settings[key] = value;
  6047. }).bind("getData.datepicker", function(event, key){
  6048. return this._get(inst, key);
  6049. });
  6050. $.data(target, PROP_NAME, inst);
  6051. this._setDate(inst, this._getDefaultDate(inst), true);
  6052. this._updateDatepicker(inst);
  6053. this._updateAlternate(inst);
  6054. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  6055. if( inst.settings.disabled ) {
  6056. this._disableDatepicker( target );
  6057. }
  6058. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  6059. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  6060. inst.dpDiv.css( "display", "block" );
  6061. },
  6062. /* Pop-up the date picker in a "dialog" box.
  6063. @param input element - ignored
  6064. @param date string or Date - the initial date to display
  6065. @param onSelect function - the function to call when a date is selected
  6066. @param settings object - update the dialog date picker instance's settings (anonymous object)
  6067. @param pos int[2] - coordinates for the dialog's position within the screen or
  6068. event - with x/y coordinates or
  6069. leave empty for default (screen centre)
  6070. @return the manager object */
  6071. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  6072. var inst = this._dialogInst; // internal instance
  6073. if (!inst) {
  6074. this.uuid += 1;
  6075. var id = 'dp' + this.uuid;
  6076. this._dialogInput = $('<input type="text" id="' + id +
  6077. '" style="position: absolute; top: -100px; width: 0px; z-index: -10;"/>');
  6078. this._dialogInput.keydown(this._doKeyDown);
  6079. $('body').append(this._dialogInput);
  6080. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  6081. inst.settings = {};
  6082. $.data(this._dialogInput[0], PROP_NAME, inst);
  6083. }
  6084. extendRemove(inst.settings, settings || {});
  6085. date = (date && date.constructor == Date ? this._formatDate(inst, date) : date);
  6086. this._dialogInput.val(date);
  6087. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  6088. if (!this._pos) {
  6089. var browserWidth = document.documentElement.clientWidth;
  6090. var browserHeight = document.documentElement.clientHeight;
  6091. var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  6092. var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  6093. this._pos = // should use actual width/height below
  6094. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  6095. }
  6096. // move input on screen for focus, but hidden behind dialog
  6097. this._dialogInput.css('left', (this._pos[0] + 20) + 'px').css('top', this._pos[1] + 'px');
  6098. inst.settings.onSelect = onSelect;
  6099. this._inDialog = true;
  6100. this.dpDiv.addClass(this._dialogClass);
  6101. this._showDatepicker(this._dialogInput[0]);
  6102. if ($.blockUI)
  6103. $.blockUI(this.dpDiv);
  6104. $.data(this._dialogInput[0], PROP_NAME, inst);
  6105. return this;
  6106. },
  6107. /* Detach a datepicker from its control.
  6108. @param target element - the target input field or division or span */
  6109. _destroyDatepicker: function(target) {
  6110. var $target = $(target);
  6111. var inst = $.data(target, PROP_NAME);
  6112. if (!$target.hasClass(this.markerClassName)) {
  6113. return;
  6114. }
  6115. var nodeName = target.nodeName.toLowerCase();
  6116. $.removeData(target, PROP_NAME);
  6117. if (nodeName == 'input') {
  6118. inst.append.remove();
  6119. inst.trigger.remove();
  6120. $target.removeClass(this.markerClassName).
  6121. unbind('focus', this._showDatepicker).
  6122. unbind('keydown', this._doKeyDown).
  6123. unbind('keypress', this._doKeyPress).
  6124. unbind('keyup', this._doKeyUp);
  6125. } else if (nodeName == 'div' || nodeName == 'span')
  6126. $target.removeClass(this.markerClassName).empty();
  6127. },
  6128. /* Enable the date picker to a jQuery selection.
  6129. @param target element - the target input field or division or span */
  6130. _enableDatepicker: function(target) {
  6131. var $target = $(target);
  6132. var inst = $.data(target, PROP_NAME);
  6133. if (!$target.hasClass(this.markerClassName)) {
  6134. return;
  6135. }
  6136. var nodeName = target.nodeName.toLowerCase();
  6137. if (nodeName == 'input') {
  6138. target.disabled = false;
  6139. inst.trigger.filter('button').
  6140. each(function() { this.disabled = false; }).end().
  6141. filter('img').css({opacity: '1.0', cursor: ''});
  6142. }
  6143. else if (nodeName == 'div' || nodeName == 'span') {
  6144. var inline = $target.children('.' + this._inlineClass);
  6145. inline.children().removeClass('ui-state-disabled');
  6146. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  6147. removeAttr("disabled");
  6148. }
  6149. this._disabledInputs = $.map(this._disabledInputs,
  6150. function(value) { return (value == target ? null : value); }); // delete entry
  6151. },
  6152. /* Disable the date picker to a jQuery selection.
  6153. @param target element - the target input field or division or span */
  6154. _disableDatepicker: function(target) {
  6155. var $target = $(target);
  6156. var inst = $.data(target, PROP_NAME);
  6157. if (!$target.hasClass(this.markerClassName)) {
  6158. return;
  6159. }
  6160. var nodeName = target.nodeName.toLowerCase();
  6161. if (nodeName == 'input') {
  6162. target.disabled = true;
  6163. inst.trigger.filter('button').
  6164. each(function() { this.disabled = true; }).end().
  6165. filter('img').css({opacity: '0.5', cursor: 'default'});
  6166. }
  6167. else if (nodeName == 'div' || nodeName == 'span') {
  6168. var inline = $target.children('.' + this._inlineClass);
  6169. inline.children().addClass('ui-state-disabled');
  6170. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  6171. attr("disabled", "disabled");
  6172. }
  6173. this._disabledInputs = $.map(this._disabledInputs,
  6174. function(value) { return (value == target ? null : value); }); // delete entry
  6175. this._disabledInputs[this._disabledInputs.length] = target;
  6176. },
  6177. /* Is the first field in a jQuery collection disabled as a datepicker?
  6178. @param target element - the target input field or division or span
  6179. @return boolean - true if disabled, false if enabled */
  6180. _isDisabledDatepicker: function(target) {
  6181. if (!target) {
  6182. return false;
  6183. }
  6184. for (var i = 0; i < this._disabledInputs.length; i++) {
  6185. if (this._disabledInputs[i] == target)
  6186. return true;
  6187. }
  6188. return false;
  6189. },
  6190. /* Retrieve the instance data for the target control.
  6191. @param target element - the target input field or division or span
  6192. @return object - the associated instance data
  6193. @throws error if a jQuery problem getting data */
  6194. _getInst: function(target) {
  6195. try {
  6196. return $.data(target, PROP_NAME);
  6197. }
  6198. catch (err) {
  6199. throw 'Missing instance data for this datepicker';
  6200. }
  6201. },
  6202. /* Update or retrieve the settings for a date picker attached to an input field or division.
  6203. @param target element - the target input field or division or span
  6204. @param name object - the new settings to update or
  6205. string - the name of the setting to change or retrieve,
  6206. when retrieving also 'all' for all instance settings or
  6207. 'defaults' for all global defaults
  6208. @param value any - the new value for the setting
  6209. (omit if above is an object or to retrieve a value) */
  6210. _optionDatepicker: function(target, name, value) {
  6211. var inst = this._getInst(target);
  6212. if (arguments.length == 2 && typeof name == 'string') {
  6213. return (name == 'defaults' ? $.extend({}, $.datepicker._defaults) :
  6214. (inst ? (name == 'all' ? $.extend({}, inst.settings) :
  6215. this._get(inst, name)) : null));
  6216. }
  6217. var settings = name || {};
  6218. if (typeof name == 'string') {
  6219. settings = {};
  6220. settings[name] = value;
  6221. }
  6222. if (inst) {
  6223. if (this._curInst == inst) {
  6224. this._hideDatepicker();
  6225. }
  6226. var date = this._getDateDatepicker(target, true);
  6227. var minDate = this._getMinMaxDate(inst, 'min');
  6228. var maxDate = this._getMinMaxDate(inst, 'max');
  6229. extendRemove(inst.settings, settings);
  6230. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  6231. if (minDate !== null && settings['dateFormat'] !== undefined && settings['minDate'] === undefined)
  6232. inst.settings.minDate = this._formatDate(inst, minDate);
  6233. if (maxDate !== null && settings['dateFormat'] !== undefined && settings['maxDate'] === undefined)
  6234. inst.settings.maxDate = this._formatDate(inst, maxDate);
  6235. this._attachments($(target), inst);
  6236. this._autoSize(inst);
  6237. this._setDate(inst, date);
  6238. this._updateAlternate(inst);
  6239. this._updateDatepicker(inst);
  6240. }
  6241. },
  6242. // change method deprecated
  6243. _changeDatepicker: function(target, name, value) {
  6244. this._optionDatepicker(target, name, value);
  6245. },
  6246. /* Redraw the date picker attached to an input field or division.
  6247. @param target element - the target input field or division or span */
  6248. _refreshDatepicker: function(target) {
  6249. var inst = this._getInst(target);
  6250. if (inst) {
  6251. this._updateDatepicker(inst);
  6252. }
  6253. },
  6254. /* Set the dates for a jQuery selection.
  6255. @param target element - the target input field or division or span
  6256. @param date Date - the new date */
  6257. _setDateDatepicker: function(target, date) {
  6258. var inst = this._getInst(target);
  6259. if (inst) {
  6260. this._setDate(inst, date);
  6261. this._updateDatepicker(inst);
  6262. this._updateAlternate(inst);
  6263. }
  6264. },
  6265. /* Get the date(s) for the first entry in a jQuery selection.
  6266. @param target element - the target input field or division or span
  6267. @param noDefault boolean - true if no default date is to be used
  6268. @return Date - the current date */
  6269. _getDateDatepicker: function(target, noDefault) {
  6270. var inst = this._getInst(target);
  6271. if (inst && !inst.inline)
  6272. this._setDateFromField(inst, noDefault);
  6273. return (inst ? this._getDate(inst) : null);
  6274. },
  6275. /* Handle keystrokes. */
  6276. _doKeyDown: function(event) {
  6277. var inst = $.datepicker._getInst(event.target);
  6278. var handled = true;
  6279. var isRTL = inst.dpDiv.is('.ui-datepicker-rtl');
  6280. inst._keyEvent = true;
  6281. if ($.datepicker._datepickerShowing)
  6282. switch (event.keyCode) {
  6283. case 9: $.datepicker._hideDatepicker();
  6284. handled = false;
  6285. break; // hide on tab out
  6286. case 13: var sel = $('td.' + $.datepicker._dayOverClass + ':not(.' +
  6287. $.datepicker._currentClass + ')', inst.dpDiv);
  6288. if (sel[0])
  6289. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  6290. var onSelect = $.datepicker._get(inst, 'onSelect');
  6291. if (onSelect) {
  6292. var dateStr = $.datepicker._formatDate(inst);
  6293. // trigger custom callback
  6294. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  6295. }
  6296. else
  6297. $.datepicker._hideDatepicker();
  6298. return false; // don't submit the form
  6299. break; // select the value on enter
  6300. case 27: $.datepicker._hideDatepicker();
  6301. break; // hide on escape
  6302. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6303. -$.datepicker._get(inst, 'stepBigMonths') :
  6304. -$.datepicker._get(inst, 'stepMonths')), 'M');
  6305. break; // previous month/year on page up/+ ctrl
  6306. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6307. +$.datepicker._get(inst, 'stepBigMonths') :
  6308. +$.datepicker._get(inst, 'stepMonths')), 'M');
  6309. break; // next month/year on page down/+ ctrl
  6310. case 35: if (event.ctrlKey || event.metaKey) $.datepicker._clearDate(event.target);
  6311. handled = event.ctrlKey || event.metaKey;
  6312. break; // clear on ctrl or command +end
  6313. case 36: if (event.ctrlKey || event.metaKey) $.datepicker._gotoToday(event.target);
  6314. handled = event.ctrlKey || event.metaKey;
  6315. break; // current on ctrl or command +home
  6316. case 37: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), 'D');
  6317. handled = event.ctrlKey || event.metaKey;
  6318. // -1 day on ctrl or command +left
  6319. if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6320. -$.datepicker._get(inst, 'stepBigMonths') :
  6321. -$.datepicker._get(inst, 'stepMonths')), 'M');
  6322. // next month/year on alt +left on Mac
  6323. break;
  6324. case 38: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, -7, 'D');
  6325. handled = event.ctrlKey || event.metaKey;
  6326. break; // -1 week on ctrl or command +up
  6327. case 39: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), 'D');
  6328. handled = event.ctrlKey || event.metaKey;
  6329. // +1 day on ctrl or command +right
  6330. if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6331. +$.datepicker._get(inst, 'stepBigMonths') :
  6332. +$.datepicker._get(inst, 'stepMonths')), 'M');
  6333. // next month/year on alt +right
  6334. break;
  6335. case 40: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, +7, 'D');
  6336. handled = event.ctrlKey || event.metaKey;
  6337. break; // +1 week on ctrl or command +down
  6338. default: handled = false;
  6339. }
  6340. else if (event.keyCode == 36 && event.ctrlKey) // display the date picker on ctrl+home
  6341. $.datepicker._showDatepicker(this);
  6342. else {
  6343. handled = false;
  6344. }
  6345. if (handled) {
  6346. event.preventDefault();
  6347. event.stopPropagation();
  6348. }
  6349. },
  6350. /* Filter entered characters - based on date format. */
  6351. _doKeyPress: function(event) {
  6352. var inst = $.datepicker._getInst(event.target);
  6353. if ($.datepicker._get(inst, 'constrainInput')) {
  6354. var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat'));
  6355. var chr = String.fromCharCode(event.charCode == undefined ? event.keyCode : event.charCode);
  6356. return event.ctrlKey || event.metaKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1);
  6357. }
  6358. },
  6359. /* Synchronise manual entry and field/alternate field. */
  6360. _doKeyUp: function(event) {
  6361. var inst = $.datepicker._getInst(event.target);
  6362. if (inst.input.val() != inst.lastVal) {
  6363. try {
  6364. var date = $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
  6365. (inst.input ? inst.input.val() : null),
  6366. $.datepicker._getFormatConfig(inst));
  6367. if (date) { // only if valid
  6368. $.datepicker._setDateFromField(inst);
  6369. $.datepicker._updateAlternate(inst);
  6370. $.datepicker._updateDatepicker(inst);
  6371. }
  6372. }
  6373. catch (err) {
  6374. $.datepicker.log(err);
  6375. }
  6376. }
  6377. return true;
  6378. },
  6379. /* Pop-up the date picker for a given input field.
  6380. If false returned from beforeShow event handler do not show.
  6381. @param input element - the input field attached to the date picker or
  6382. event - if triggered by focus */
  6383. _showDatepicker: function(input) {
  6384. input = input.target || input;
  6385. if (input.nodeName.toLowerCase() != 'input') // find from button/image trigger
  6386. input = $('input', input.parentNode)[0];
  6387. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput == input) // already here
  6388. return;
  6389. var inst = $.datepicker._getInst(input);
  6390. if ($.datepicker._curInst && $.datepicker._curInst != inst) {
  6391. $.datepicker._curInst.dpDiv.stop(true, true);
  6392. if ( inst && $.datepicker._datepickerShowing ) {
  6393. $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
  6394. }
  6395. }
  6396. var beforeShow = $.datepicker._get(inst, 'beforeShow');
  6397. var beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  6398. if(beforeShowSettings === false){
  6399. //false
  6400. return;
  6401. }
  6402. extendRemove(inst.settings, beforeShowSettings);
  6403. inst.lastVal = null;
  6404. $.datepicker._lastInput = input;
  6405. $.datepicker._setDateFromField(inst);
  6406. if ($.datepicker._inDialog) // hide cursor
  6407. input.value = '';
  6408. if (!$.datepicker._pos) { // position below input
  6409. $.datepicker._pos = $.datepicker._findPos(input);
  6410. $.datepicker._pos[1] += input.offsetHeight; // add the height
  6411. }
  6412. var isFixed = false;
  6413. $(input).parents().each(function() {
  6414. isFixed |= $(this).css('position') == 'fixed';
  6415. return !isFixed;
  6416. });
  6417. if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled
  6418. $.datepicker._pos[0] -= document.documentElement.scrollLeft;
  6419. $.datepicker._pos[1] -= document.documentElement.scrollTop;
  6420. }
  6421. var offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  6422. $.datepicker._pos = null;
  6423. //to avoid flashes on Firefox
  6424. inst.dpDiv.empty();
  6425. // determine sizing offscreen
  6426. inst.dpDiv.css({position: 'absolute', display: 'block', top: '-1000px'});
  6427. $.datepicker._updateDatepicker(inst);
  6428. // fix width for dynamic number of date pickers
  6429. // and adjust position before showing
  6430. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  6431. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  6432. 'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none',
  6433. left: offset.left + 'px', top: offset.top + 'px'});
  6434. if (!inst.inline) {
  6435. var showAnim = $.datepicker._get(inst, 'showAnim');
  6436. var duration = $.datepicker._get(inst, 'duration');
  6437. var postProcess = function() {
  6438. var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only
  6439. if( !! cover.length ){
  6440. var borders = $.datepicker._getBorders(inst.dpDiv);
  6441. cover.css({left: -borders[0], top: -borders[1],
  6442. width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()});
  6443. }
  6444. };
  6445. inst.dpDiv.zIndex($(input).zIndex()+1);
  6446. $.datepicker._datepickerShowing = true;
  6447. if ($.effects && $.effects[showAnim])
  6448. inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
  6449. else
  6450. inst.dpDiv[showAnim || 'show']((showAnim ? duration : null), postProcess);
  6451. if (!showAnim || !duration)
  6452. postProcess();
  6453. if (inst.input.is(':visible') && !inst.input.is(':disabled'))
  6454. inst.input.focus();
  6455. $.datepicker._curInst = inst;
  6456. }
  6457. },
  6458. /* Generate the date picker content. */
  6459. _updateDatepicker: function(inst) {
  6460. var self = this;
  6461. self.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  6462. var borders = $.datepicker._getBorders(inst.dpDiv);
  6463. instActive = inst; // for delegate hover events
  6464. inst.dpDiv.empty().append(this._generateHTML(inst));
  6465. var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only
  6466. if( !!cover.length ){ //avoid call to outerXXXX() when not in IE6
  6467. cover.css({left: -borders[0], top: -borders[1], width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()})
  6468. }
  6469. inst.dpDiv.find('.' + this._dayOverClass + ' a').mouseover();
  6470. var numMonths = this._getNumberOfMonths(inst);
  6471. var cols = numMonths[1];
  6472. var width = 17;
  6473. inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width('');
  6474. if (cols > 1)
  6475. inst.dpDiv.addClass('ui-datepicker-multi-' + cols).css('width', (width * cols) + 'em');
  6476. inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') +
  6477. 'Class']('ui-datepicker-multi');
  6478. inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') +
  6479. 'Class']('ui-datepicker-rtl');
  6480. if (inst == $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input &&
  6481. // #6694 - don't focus the input if it's already focused
  6482. // this breaks the change event in IE
  6483. inst.input.is(':visible') && !inst.input.is(':disabled') && inst.input[0] != document.activeElement)
  6484. inst.input.focus();
  6485. // deffered render of the years select (to avoid flashes on Firefox)
  6486. if( inst.yearshtml ){
  6487. var origyearshtml = inst.yearshtml;
  6488. setTimeout(function(){
  6489. //assure that inst.yearshtml didn't change.
  6490. if( origyearshtml === inst.yearshtml && inst.yearshtml ){
  6491. inst.dpDiv.find('select.ui-datepicker-year:first').replaceWith(inst.yearshtml);
  6492. }
  6493. origyearshtml = inst.yearshtml = null;
  6494. }, 0);
  6495. }
  6496. },
  6497. /* Retrieve the size of left and top borders for an element.
  6498. @param elem (jQuery object) the element of interest
  6499. @return (number[2]) the left and top borders */
  6500. _getBorders: function(elem) {
  6501. var convert = function(value) {
  6502. return {thin: 1, medium: 2, thick: 3}[value] || value;
  6503. };
  6504. return [parseFloat(convert(elem.css('border-left-width'))),
  6505. parseFloat(convert(elem.css('border-top-width')))];
  6506. },
  6507. /* Check positioning to remain on screen. */
  6508. _checkOffset: function(inst, offset, isFixed) {
  6509. var dpWidth = inst.dpDiv.outerWidth();
  6510. var dpHeight = inst.dpDiv.outerHeight();
  6511. var inputWidth = inst.input ? inst.input.outerWidth() : 0;
  6512. var inputHeight = inst.input ? inst.input.outerHeight() : 0;
  6513. var viewWidth = document.documentElement.clientWidth + $(document).scrollLeft();
  6514. var viewHeight = document.documentElement.clientHeight + $(document).scrollTop();
  6515. offset.left -= (this._get(inst, 'isRTL') ? (dpWidth - inputWidth) : 0);
  6516. offset.left -= (isFixed && offset.left == inst.input.offset().left) ? $(document).scrollLeft() : 0;
  6517. offset.top -= (isFixed && offset.top == (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  6518. // now check if datepicker is showing outside window viewport - move to a better place if so.
  6519. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  6520. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  6521. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  6522. Math.abs(dpHeight + inputHeight) : 0);
  6523. return offset;
  6524. },
  6525. /* Find an object's position on the screen. */
  6526. _findPos: function(obj) {
  6527. var inst = this._getInst(obj);
  6528. var isRTL = this._get(inst, 'isRTL');
  6529. while (obj && (obj.type == 'hidden' || obj.nodeType != 1 || $.expr.filters.hidden(obj))) {
  6530. obj = obj[isRTL ? 'previousSibling' : 'nextSibling'];
  6531. }
  6532. var position = $(obj).offset();
  6533. return [position.left, position.top];
  6534. },
  6535. /* Hide the date picker from view.
  6536. @param input element - the input field attached to the date picker */
  6537. _hideDatepicker: function(input) {
  6538. var inst = this._curInst;
  6539. if (!inst || (input && inst != $.data(input, PROP_NAME)))
  6540. return;
  6541. if (this._datepickerShowing) {
  6542. var showAnim = this._get(inst, 'showAnim');
  6543. var duration = this._get(inst, 'duration');
  6544. var postProcess = function() {
  6545. $.datepicker._tidyDialog(inst);
  6546. };
  6547. if ($.effects && $.effects[showAnim])
  6548. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
  6549. else
  6550. inst.dpDiv[(showAnim == 'slideDown' ? 'slideUp' :
  6551. (showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess);
  6552. if (!showAnim)
  6553. postProcess();
  6554. this._datepickerShowing = false;
  6555. var onClose = this._get(inst, 'onClose');
  6556. if (onClose)
  6557. onClose.apply((inst.input ? inst.input[0] : null),
  6558. [(inst.input ? inst.input.val() : ''), inst]);
  6559. this._lastInput = null;
  6560. if (this._inDialog) {
  6561. this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
  6562. if ($.blockUI) {
  6563. $.unblockUI();
  6564. $('body').append(this.dpDiv);
  6565. }
  6566. }
  6567. this._inDialog = false;
  6568. }
  6569. },
  6570. /* Tidy up after a dialog display. */
  6571. _tidyDialog: function(inst) {
  6572. inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker-calendar');
  6573. },
  6574. /* Close date picker if clicked elsewhere. */
  6575. _checkExternalClick: function(event) {
  6576. if (!$.datepicker._curInst)
  6577. return;
  6578. var $target = $(event.target),
  6579. inst = $.datepicker._getInst($target[0]);
  6580. if ( ( ( $target[0].id != $.datepicker._mainDivId &&
  6581. $target.parents('#' + $.datepicker._mainDivId).length == 0 &&
  6582. !$target.hasClass($.datepicker.markerClassName) &&
  6583. !$target.closest("." + $.datepicker._triggerClass).length &&
  6584. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
  6585. ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst != inst ) )
  6586. $.datepicker._hideDatepicker();
  6587. },
  6588. /* Adjust one of the date sub-fields. */
  6589. _adjustDate: function(id, offset, period) {
  6590. var target = $(id);
  6591. var inst = this._getInst(target[0]);
  6592. if (this._isDisabledDatepicker(target[0])) {
  6593. return;
  6594. }
  6595. this._adjustInstDate(inst, offset +
  6596. (period == 'M' ? this._get(inst, 'showCurrentAtPos') : 0), // undo positioning
  6597. period);
  6598. this._updateDatepicker(inst);
  6599. },
  6600. /* Action for current link. */
  6601. _gotoToday: function(id) {
  6602. var target = $(id);
  6603. var inst = this._getInst(target[0]);
  6604. if (this._get(inst, 'gotoCurrent') && inst.currentDay) {
  6605. inst.selectedDay = inst.currentDay;
  6606. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  6607. inst.drawYear = inst.selectedYear = inst.currentYear;
  6608. }
  6609. else {
  6610. var date = new Date();
  6611. inst.selectedDay = date.getDate();
  6612. inst.drawMonth = inst.selectedMonth = date.getMonth();
  6613. inst.drawYear = inst.selectedYear = date.getFullYear();
  6614. }
  6615. this._notifyChange(inst);
  6616. this._adjustDate(target);
  6617. },
  6618. /* Action for selecting a new month/year. */
  6619. _selectMonthYear: function(id, select, period) {
  6620. var target = $(id);
  6621. var inst = this._getInst(target[0]);
  6622. inst['selected' + (period == 'M' ? 'Month' : 'Year')] =
  6623. inst['draw' + (period == 'M' ? 'Month' : 'Year')] =
  6624. parseInt(select.options[select.selectedIndex].value,10);
  6625. this._notifyChange(inst);
  6626. this._adjustDate(target);
  6627. },
  6628. /* Action for selecting a day. */
  6629. _selectDay: function(id, month, year, td) {
  6630. var target = $(id);
  6631. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  6632. return;
  6633. }
  6634. var inst = this._getInst(target[0]);
  6635. inst.selectedDay = inst.currentDay = $('a', td).html();
  6636. inst.selectedMonth = inst.currentMonth = month;
  6637. inst.selectedYear = inst.currentYear = year;
  6638. this._selectDate(id, this._formatDate(inst,
  6639. inst.currentDay, inst.currentMonth, inst.currentYear));
  6640. },
  6641. /* Erase the input field and hide the date picker. */
  6642. _clearDate: function(id) {
  6643. var target = $(id);
  6644. var inst = this._getInst(target[0]);
  6645. this._selectDate(target, '');
  6646. },
  6647. /* Update the input field with the selected date. */
  6648. _selectDate: function(id, dateStr) {
  6649. var target = $(id);
  6650. var inst = this._getInst(target[0]);
  6651. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  6652. if (inst.input)
  6653. inst.input.val(dateStr);
  6654. this._updateAlternate(inst);
  6655. var onSelect = this._get(inst, 'onSelect');
  6656. if (onSelect)
  6657. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  6658. else if (inst.input)
  6659. inst.input.trigger('change'); // fire the change event
  6660. if (inst.inline)
  6661. this._updateDatepicker(inst);
  6662. else {
  6663. this._hideDatepicker();
  6664. this._lastInput = inst.input[0];
  6665. if (typeof(inst.input[0]) != 'object')
  6666. inst.input.focus(); // restore focus
  6667. this._lastInput = null;
  6668. }
  6669. },
  6670. /* Update any alternate field to synchronise with the main field. */
  6671. _updateAlternate: function(inst) {
  6672. var altField = this._get(inst, 'altField');
  6673. if (altField) { // update alternate field too
  6674. var altFormat = this._get(inst, 'altFormat') || this._get(inst, 'dateFormat');
  6675. var date = this._getDate(inst);
  6676. var dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  6677. $(altField).each(function() { $(this).val(dateStr); });
  6678. }
  6679. },
  6680. /* Set as beforeShowDay function to prevent selection of weekends.
  6681. @param date Date - the date to customise
  6682. @return [boolean, string] - is this date selectable?, what is its CSS class? */
  6683. noWeekends: function(date) {
  6684. var day = date.getDay();
  6685. return [(day > 0 && day < 6), ''];
  6686. },
  6687. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  6688. @param date Date - the date to get the week for
  6689. @return number - the number of the week within the year that contains this date */
  6690. iso8601Week: function(date) {
  6691. var checkDate = new Date(date.getTime());
  6692. // Find Thursday of this week starting on Monday
  6693. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  6694. var time = checkDate.getTime();
  6695. checkDate.setMonth(0); // Compare with Jan 1
  6696. checkDate.setDate(1);
  6697. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  6698. },
  6699. /* Parse a string value into a date object.
  6700. See formatDate below for the possible formats.
  6701. @param format string - the expected format of the date
  6702. @param value string - the date in the above format
  6703. @param settings Object - attributes include:
  6704. shortYearCutoff number - the cutoff year for determining the century (optional)
  6705. dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  6706. dayNames string[7] - names of the days from Sunday (optional)
  6707. monthNamesShort string[12] - abbreviated names of the months (optional)
  6708. monthNames string[12] - names of the months (optional)
  6709. @return Date - the extracted date value or null if value is blank */
  6710. parseDate: function (format, value, settings) {
  6711. if (format == null || value == null)
  6712. throw 'Invalid arguments';
  6713. value = (typeof value == 'object' ? value.toString() : value + '');
  6714. if (value == '')
  6715. return null;
  6716. var shortYearCutoff = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff;
  6717. shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
  6718. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  6719. var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
  6720. var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
  6721. var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
  6722. var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
  6723. var year = -1;
  6724. var month = -1;
  6725. var day = -1;
  6726. var doy = -1;
  6727. var literal = false;
  6728. // Check whether a format character is doubled
  6729. var lookAhead = function(match) {
  6730. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
  6731. if (matches)
  6732. iFormat++;
  6733. return matches;
  6734. };
  6735. // Extract a number from the string value
  6736. var getNumber = function(match) {
  6737. var isDoubled = lookAhead(match);
  6738. var size = (match == '@' ? 14 : (match == '!' ? 20 :
  6739. (match == 'y' && isDoubled ? 4 : (match == 'o' ? 3 : 2))));
  6740. var digits = new RegExp('^\\d{1,' + size + '}');
  6741. var num = value.substring(iValue).match(digits);
  6742. if (!num)
  6743. throw 'Missing number at position ' + iValue;
  6744. iValue += num[0].length;
  6745. return parseInt(num[0], 10);
  6746. };
  6747. // Extract a name from the string value and convert to an index
  6748. var getName = function(match, shortNames, longNames) {
  6749. var names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  6750. return [ [k, v] ];
  6751. }).sort(function (a, b) {
  6752. return -(a[1].length - b[1].length);
  6753. });
  6754. var index = -1;
  6755. $.each(names, function (i, pair) {
  6756. var name = pair[1];
  6757. if (value.substr(iValue, name.length).toLowerCase() == name.toLowerCase()) {
  6758. index = pair[0];
  6759. iValue += name.length;
  6760. return false;
  6761. }
  6762. });
  6763. if (index != -1)
  6764. return index + 1;
  6765. else
  6766. throw 'Unknown name at position ' + iValue;
  6767. };
  6768. // Confirm that a literal character matches the string value
  6769. var checkLiteral = function() {
  6770. if (value.charAt(iValue) != format.charAt(iFormat))
  6771. throw 'Unexpected literal at position ' + iValue;
  6772. iValue++;
  6773. };
  6774. var iValue = 0;
  6775. for (var iFormat = 0; iFormat < format.length; iFormat++) {
  6776. if (literal)
  6777. if (format.charAt(iFormat) == "'" && !lookAhead("'"))
  6778. literal = false;
  6779. else
  6780. checkLiteral();
  6781. else
  6782. switch (format.charAt(iFormat)) {
  6783. case 'd':
  6784. day = getNumber('d');
  6785. break;
  6786. case 'D':
  6787. getName('D', dayNamesShort, dayNames);
  6788. break;
  6789. case 'o':
  6790. doy = getNumber('o');
  6791. break;
  6792. case 'm':
  6793. month = getNumber('m');
  6794. break;
  6795. case 'M':
  6796. month = getName('M', monthNamesShort, monthNames);
  6797. break;
  6798. case 'y':
  6799. year = getNumber('y');
  6800. break;
  6801. case '@':
  6802. var date = new Date(getNumber('@'));
  6803. year = date.getFullYear();
  6804. month = date.getMonth() + 1;
  6805. day = date.getDate();
  6806. break;
  6807. case '!':
  6808. var date = new Date((getNumber('!') - this._ticksTo1970) / 10000);
  6809. year = date.getFullYear();
  6810. month = date.getMonth() + 1;
  6811. day = date.getDate();
  6812. break;
  6813. case "'":
  6814. if (lookAhead("'"))
  6815. checkLiteral();
  6816. else
  6817. literal = true;
  6818. break;
  6819. default:
  6820. checkLiteral();
  6821. }
  6822. }
  6823. if (iValue < value.length){
  6824. throw "Extra/unparsed characters found in date: " + value.substring(iValue);
  6825. }
  6826. if (year == -1)
  6827. year = new Date().getFullYear();
  6828. else if (year < 100)
  6829. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  6830. (year <= shortYearCutoff ? 0 : -100);
  6831. if (doy > -1) {
  6832. month = 1;
  6833. day = doy;
  6834. do {
  6835. var dim = this._getDaysInMonth(year, month - 1);
  6836. if (day <= dim)
  6837. break;
  6838. month++;
  6839. day -= dim;
  6840. } while (true);
  6841. }
  6842. var date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  6843. if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day)
  6844. throw 'Invalid date'; // E.g. 31/02/00
  6845. return date;
  6846. },
  6847. /* Standard date formats. */
  6848. ATOM: 'yy-mm-dd', // RFC 3339 (ISO 8601)
  6849. COOKIE: 'D, dd M yy',
  6850. ISO_8601: 'yy-mm-dd',
  6851. RFC_822: 'D, d M y',
  6852. RFC_850: 'DD, dd-M-y',
  6853. RFC_1036: 'D, d M y',
  6854. RFC_1123: 'D, d M yy',
  6855. RFC_2822: 'D, d M yy',
  6856. RSS: 'D, d M y', // RFC 822
  6857. TICKS: '!',
  6858. TIMESTAMP: '@',
  6859. W3C: 'yy-mm-dd', // ISO 8601
  6860. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  6861. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  6862. /* Format a date object into a string value.
  6863. The format can be combinations of the following:
  6864. d - day of month (no leading zero)
  6865. dd - day of month (two digit)
  6866. o - day of year (no leading zeros)
  6867. oo - day of year (three digit)
  6868. D - day name short
  6869. DD - day name long
  6870. m - month of year (no leading zero)
  6871. mm - month of year (two digit)
  6872. M - month name short
  6873. MM - month name long
  6874. y - year (two digit)
  6875. yy - year (four digit)
  6876. @ - Unix timestamp (ms since 01/01/1970)
  6877. ! - Windows ticks (100ns since 01/01/0001)
  6878. '...' - literal text
  6879. '' - single quote
  6880. @param format string - the desired format of the date
  6881. @param date Date - the date value to format
  6882. @param settings Object - attributes include:
  6883. dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  6884. dayNames string[7] - names of the days from Sunday (optional)
  6885. monthNamesShort string[12] - abbreviated names of the months (optional)
  6886. monthNames string[12] - names of the months (optional)
  6887. @return string - the date in the above format */
  6888. formatDate: function (format, date, settings) {
  6889. if (!date)
  6890. return '';
  6891. var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
  6892. var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
  6893. var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
  6894. var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
  6895. // Check whether a format character is doubled
  6896. var lookAhead = function(match) {
  6897. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
  6898. if (matches)
  6899. iFormat++;
  6900. return matches;
  6901. };
  6902. // Format a number, with leading zero if necessary
  6903. var formatNumber = function(match, value, len) {
  6904. var num = '' + value;
  6905. if (lookAhead(match))
  6906. while (num.length < len)
  6907. num = '0' + num;
  6908. return num;
  6909. };
  6910. // Format a name, short or long as requested
  6911. var formatName = function(match, value, shortNames, longNames) {
  6912. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  6913. };
  6914. var output = '';
  6915. var literal = false;
  6916. if (date)
  6917. for (var iFormat = 0; iFormat < format.length; iFormat++) {
  6918. if (literal)
  6919. if (format.charAt(iFormat) == "'" && !lookAhead("'"))
  6920. literal = false;
  6921. else
  6922. output += format.charAt(iFormat);
  6923. else
  6924. switch (format.charAt(iFormat)) {
  6925. case 'd':
  6926. output += formatNumber('d', date.getDate(), 2);
  6927. break;
  6928. case 'D':
  6929. output += formatName('D', date.getDay(), dayNamesShort, dayNames);
  6930. break;
  6931. case 'o':
  6932. output += formatNumber('o',
  6933. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  6934. break;
  6935. case 'm':
  6936. output += formatNumber('m', date.getMonth() + 1, 2);
  6937. break;
  6938. case 'M':
  6939. output += formatName('M', date.getMonth(), monthNamesShort, monthNames);
  6940. break;
  6941. case 'y':
  6942. output += (lookAhead('y') ? date.getFullYear() :
  6943. (date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100);
  6944. break;
  6945. case '@':
  6946. output += date.getTime();
  6947. break;
  6948. case '!':
  6949. output += date.getTime() * 10000 + this._ticksTo1970;
  6950. break;
  6951. case "'":
  6952. if (lookAhead("'"))
  6953. output += "'";
  6954. else
  6955. literal = true;
  6956. break;
  6957. default:
  6958. output += format.charAt(iFormat);
  6959. }
  6960. }
  6961. return output;
  6962. },
  6963. /* Extract all possible characters from the date format. */
  6964. _possibleChars: function (format) {
  6965. var chars = '';
  6966. var literal = false;
  6967. // Check whether a format character is doubled
  6968. var lookAhead = function(match) {
  6969. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
  6970. if (matches)
  6971. iFormat++;
  6972. return matches;
  6973. };
  6974. for (var iFormat = 0; iFormat < format.length; iFormat++)
  6975. if (literal)
  6976. if (format.charAt(iFormat) == "'" && !lookAhead("'"))
  6977. literal = false;
  6978. else
  6979. chars += format.charAt(iFormat);
  6980. else
  6981. switch (format.charAt(iFormat)) {
  6982. case 'd': case 'm': case 'y': case '@':
  6983. chars += '0123456789';
  6984. break;
  6985. case 'D': case 'M':
  6986. return null; // Accept anything
  6987. case "'":
  6988. if (lookAhead("'"))
  6989. chars += "'";
  6990. else
  6991. literal = true;
  6992. break;
  6993. default:
  6994. chars += format.charAt(iFormat);
  6995. }
  6996. return chars;
  6997. },
  6998. /* Get a setting value, defaulting if necessary. */
  6999. _get: function(inst, name) {
  7000. return inst.settings[name] !== undefined ?
  7001. inst.settings[name] : this._defaults[name];
  7002. },
  7003. /* Parse existing date and initialise date picker. */
  7004. _setDateFromField: function(inst, noDefault) {
  7005. if (inst.input.val() == inst.lastVal) {
  7006. return;
  7007. }
  7008. var dateFormat = this._get(inst, 'dateFormat');
  7009. var dates = inst.lastVal = inst.input ? inst.input.val() : null;
  7010. var date, defaultDate;
  7011. date = defaultDate = this._getDefaultDate(inst);
  7012. var settings = this._getFormatConfig(inst);
  7013. try {
  7014. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  7015. } catch (event) {
  7016. this.log(event);
  7017. dates = (noDefault ? '' : dates);
  7018. }
  7019. inst.selectedDay = date.getDate();
  7020. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7021. inst.drawYear = inst.selectedYear = date.getFullYear();
  7022. inst.currentDay = (dates ? date.getDate() : 0);
  7023. inst.currentMonth = (dates ? date.getMonth() : 0);
  7024. inst.currentYear = (dates ? date.getFullYear() : 0);
  7025. this._adjustInstDate(inst);
  7026. },
  7027. /* Retrieve the default date shown on opening. */
  7028. _getDefaultDate: function(inst) {
  7029. return this._restrictMinMax(inst,
  7030. this._determineDate(inst, this._get(inst, 'defaultDate'), new Date()));
  7031. },
  7032. /* A date may be specified as an exact value or a relative one. */
  7033. _determineDate: function(inst, date, defaultDate) {
  7034. var offsetNumeric = function(offset) {
  7035. var date = new Date();
  7036. date.setDate(date.getDate() + offset);
  7037. return date;
  7038. };
  7039. var offsetString = function(offset) {
  7040. try {
  7041. return $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
  7042. offset, $.datepicker._getFormatConfig(inst));
  7043. }
  7044. catch (e) {
  7045. // Ignore
  7046. }
  7047. var date = (offset.toLowerCase().match(/^c/) ?
  7048. $.datepicker._getDate(inst) : null) || new Date();
  7049. var year = date.getFullYear();
  7050. var month = date.getMonth();
  7051. var day = date.getDate();
  7052. var pattern = /([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g;
  7053. var matches = pattern.exec(offset);
  7054. while (matches) {
  7055. switch (matches[2] || 'd') {
  7056. case 'd' : case 'D' :
  7057. day += parseInt(matches[1],10); break;
  7058. case 'w' : case 'W' :
  7059. day += parseInt(matches[1],10) * 7; break;
  7060. case 'm' : case 'M' :
  7061. month += parseInt(matches[1],10);
  7062. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  7063. break;
  7064. case 'y': case 'Y' :
  7065. year += parseInt(matches[1],10);
  7066. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  7067. break;
  7068. }
  7069. matches = pattern.exec(offset);
  7070. }
  7071. return new Date(year, month, day);
  7072. };
  7073. var newDate = (date == null || date === '' ? defaultDate : (typeof date == 'string' ? offsetString(date) :
  7074. (typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  7075. newDate = (newDate && newDate.toString() == 'Invalid Date' ? defaultDate : newDate);
  7076. if (newDate) {
  7077. newDate.setHours(0);
  7078. newDate.setMinutes(0);
  7079. newDate.setSeconds(0);
  7080. newDate.setMilliseconds(0);
  7081. }
  7082. return this._daylightSavingAdjust(newDate);
  7083. },
  7084. /* Handle switch to/from daylight saving.
  7085. Hours may be non-zero on daylight saving cut-over:
  7086. > 12 when midnight changeover, but then cannot generate
  7087. midnight datetime, so jump to 1AM, otherwise reset.
  7088. @param date (Date) the date to check
  7089. @return (Date) the corrected date */
  7090. _daylightSavingAdjust: function(date) {
  7091. if (!date) return null;
  7092. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  7093. return date;
  7094. },
  7095. /* Set the date(s) directly. */
  7096. _setDate: function(inst, date, noChange) {
  7097. var clear = !date;
  7098. var origMonth = inst.selectedMonth;
  7099. var origYear = inst.selectedYear;
  7100. var newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  7101. inst.selectedDay = inst.currentDay = newDate.getDate();
  7102. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  7103. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  7104. if ((origMonth != inst.selectedMonth || origYear != inst.selectedYear) && !noChange)
  7105. this._notifyChange(inst);
  7106. this._adjustInstDate(inst);
  7107. if (inst.input) {
  7108. inst.input.val(clear ? '' : this._formatDate(inst));
  7109. }
  7110. },
  7111. /* Retrieve the date(s) directly. */
  7112. _getDate: function(inst) {
  7113. var startDate = (!inst.currentYear || (inst.input && inst.input.val() == '') ? null :
  7114. this._daylightSavingAdjust(new Date(
  7115. inst.currentYear, inst.currentMonth, inst.currentDay)));
  7116. return startDate;
  7117. },
  7118. /* Generate the HTML for the current state of the date picker. */
  7119. _generateHTML: function(inst) {
  7120. var today = new Date();
  7121. today = this._daylightSavingAdjust(
  7122. new Date(today.getFullYear(), today.getMonth(), today.getDate())); // clear time
  7123. var isRTL = this._get(inst, 'isRTL');
  7124. var showButtonPanel = this._get(inst, 'showButtonPanel');
  7125. var hideIfNoPrevNext = this._get(inst, 'hideIfNoPrevNext');
  7126. var navigationAsDateFormat = this._get(inst, 'navigationAsDateFormat');
  7127. var numMonths = this._getNumberOfMonths(inst);
  7128. var showCurrentAtPos = this._get(inst, 'showCurrentAtPos');
  7129. var stepMonths = this._get(inst, 'stepMonths');
  7130. var isMultiMonth = (numMonths[0] != 1 || numMonths[1] != 1);
  7131. var currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  7132. new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  7133. var minDate = this._getMinMaxDate(inst, 'min');
  7134. var maxDate = this._getMinMaxDate(inst, 'max');
  7135. var drawMonth = inst.drawMonth - showCurrentAtPos;
  7136. var drawYear = inst.drawYear;
  7137. if (drawMonth < 0) {
  7138. drawMonth += 12;
  7139. drawYear--;
  7140. }
  7141. if (maxDate) {
  7142. var maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  7143. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  7144. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  7145. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  7146. drawMonth--;
  7147. if (drawMonth < 0) {
  7148. drawMonth = 11;
  7149. drawYear--;
  7150. }
  7151. }
  7152. }
  7153. inst.drawMonth = drawMonth;
  7154. inst.drawYear = drawYear;
  7155. var prevText = this._get(inst, 'prevText');
  7156. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  7157. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  7158. this._getFormatConfig(inst)));
  7159. var prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  7160. '<a class="ui-datepicker-prev ui-corner-all" onclick="DP_jQuery_' + dpuuid +
  7161. '.datepicker._adjustDate(\'#' + inst.id + '\', -' + stepMonths + ', \'M\');"' +
  7162. ' title="' + prevText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>' :
  7163. (hideIfNoPrevNext ? '' : '<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="'+ prevText +'"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>'));
  7164. var nextText = this._get(inst, 'nextText');
  7165. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  7166. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  7167. this._getFormatConfig(inst)));
  7168. var next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  7169. '<a class="ui-datepicker-next ui-corner-all" onclick="DP_jQuery_' + dpuuid +
  7170. '.datepicker._adjustDate(\'#' + inst.id + '\', +' + stepMonths + ', \'M\');"' +
  7171. ' title="' + nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>' :
  7172. (hideIfNoPrevNext ? '' : '<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="'+ nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>'));
  7173. var currentText = this._get(inst, 'currentText');
  7174. var gotoDate = (this._get(inst, 'gotoCurrent') && inst.currentDay ? currentDate : today);
  7175. currentText = (!navigationAsDateFormat ? currentText :
  7176. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  7177. var controls = (!inst.inline ? '<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" onclick="DP_jQuery_' + dpuuid +
  7178. '.datepicker._hideDatepicker();">' + this._get(inst, 'closeText') + '</button>' : '');
  7179. var buttonPanel = (showButtonPanel) ? '<div class="ui-datepicker-buttonpane ui-widget-content">' + (isRTL ? controls : '') +
  7180. (this._isInRange(inst, gotoDate) ? '<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" onclick="DP_jQuery_' + dpuuid +
  7181. '.datepicker._gotoToday(\'#' + inst.id + '\');"' +
  7182. '>' + currentText + '</button>' : '') + (isRTL ? '' : controls) + '</div>' : '';
  7183. var firstDay = parseInt(this._get(inst, 'firstDay'),10);
  7184. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  7185. var showWeek = this._get(inst, 'showWeek');
  7186. var dayNames = this._get(inst, 'dayNames');
  7187. var dayNamesShort = this._get(inst, 'dayNamesShort');
  7188. var dayNamesMin = this._get(inst, 'dayNamesMin');
  7189. var monthNames = this._get(inst, 'monthNames');
  7190. var monthNamesShort = this._get(inst, 'monthNamesShort');
  7191. var beforeShowDay = this._get(inst, 'beforeShowDay');
  7192. var showOtherMonths = this._get(inst, 'showOtherMonths');
  7193. var selectOtherMonths = this._get(inst, 'selectOtherMonths');
  7194. var calculateWeek = this._get(inst, 'calculateWeek') || this.iso8601Week;
  7195. var defaultDate = this._getDefaultDate(inst);
  7196. var html = '';
  7197. for (var row = 0; row < numMonths[0]; row++) {
  7198. var group = '';
  7199. this.maxRows = 4;
  7200. for (var col = 0; col < numMonths[1]; col++) {
  7201. var selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  7202. var cornerClass = ' ui-corner-all';
  7203. var calender = '';
  7204. if (isMultiMonth) {
  7205. calender += '<div class="ui-datepicker-group';
  7206. if (numMonths[1] > 1)
  7207. switch (col) {
  7208. case 0: calender += ' ui-datepicker-group-first';
  7209. cornerClass = ' ui-corner-' + (isRTL ? 'right' : 'left'); break;
  7210. case numMonths[1]-1: calender += ' ui-datepicker-group-last';
  7211. cornerClass = ' ui-corner-' + (isRTL ? 'left' : 'right'); break;
  7212. default: calender += ' ui-datepicker-group-middle'; cornerClass = ''; break;
  7213. }
  7214. calender += '">';
  7215. }
  7216. calender += '<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix' + cornerClass + '">' +
  7217. (/all|left/.test(cornerClass) && row == 0 ? (isRTL ? next : prev) : '') +
  7218. (/all|right/.test(cornerClass) && row == 0 ? (isRTL ? prev : next) : '') +
  7219. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  7220. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  7221. '</div><table class="ui-datepicker-calendar"><thead>' +
  7222. '<tr>';
  7223. var thead = (showWeek ? '<th class="ui-datepicker-week-col">' + this._get(inst, 'weekHeader') + '</th>' : '');
  7224. for (var dow = 0; dow < 7; dow++) { // days of the week
  7225. var day = (dow + firstDay) % 7;
  7226. thead += '<th' + ((dow + firstDay + 6) % 7 >= 5 ? ' class="ui-datepicker-week-end"' : '') + '>' +
  7227. '<span title="' + dayNames[day] + '">' + dayNamesMin[day] + '</span></th>';
  7228. }
  7229. calender += thead + '</tr></thead><tbody>';
  7230. var daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  7231. if (drawYear == inst.selectedYear && drawMonth == inst.selectedMonth)
  7232. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  7233. var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  7234. var curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  7235. var numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  7236. this.maxRows = numRows;
  7237. var printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  7238. for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  7239. calender += '<tr>';
  7240. var tbody = (!showWeek ? '' : '<td class="ui-datepicker-week-col">' +
  7241. this._get(inst, 'calculateWeek')(printDate) + '</td>');
  7242. for (var dow = 0; dow < 7; dow++) { // create date picker days
  7243. var daySettings = (beforeShowDay ?
  7244. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, '']);
  7245. var otherMonth = (printDate.getMonth() != drawMonth);
  7246. var unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  7247. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  7248. tbody += '<td class="' +
  7249. ((dow + firstDay + 6) % 7 >= 5 ? ' ui-datepicker-week-end' : '') + // highlight weekends
  7250. (otherMonth ? ' ui-datepicker-other-month' : '') + // highlight days from other months
  7251. ((printDate.getTime() == selectedDate.getTime() && drawMonth == inst.selectedMonth && inst._keyEvent) || // user pressed key
  7252. (defaultDate.getTime() == printDate.getTime() && defaultDate.getTime() == selectedDate.getTime()) ?
  7253. // or defaultDate is current printedDate and defaultDate is selectedDate
  7254. ' ' + this._dayOverClass : '') + // highlight selected day
  7255. (unselectable ? ' ' + this._unselectableClass + ' ui-state-disabled': '') + // highlight unselectable days
  7256. (otherMonth && !showOtherMonths ? '' : ' ' + daySettings[1] + // highlight custom dates
  7257. (printDate.getTime() == currentDate.getTime() ? ' ' + this._currentClass : '') + // highlight selected day
  7258. (printDate.getTime() == today.getTime() ? ' ui-datepicker-today' : '')) + '"' + // highlight today (if different)
  7259. ((!otherMonth || showOtherMonths) && daySettings[2] ? ' title="' + daySettings[2] + '"' : '') + // cell title
  7260. (unselectable ? '' : ' onclick="DP_jQuery_' + dpuuid + '.datepicker._selectDay(\'#' +
  7261. inst.id + '\',' + printDate.getMonth() + ',' + printDate.getFullYear() + ', this);return false;"') + '>' + // actions
  7262. (otherMonth && !showOtherMonths ? '&#xa0;' : // display for other months
  7263. (unselectable ? '<span class="ui-state-default">' + printDate.getDate() + '</span>' : '<a class="ui-state-default' +
  7264. (printDate.getTime() == today.getTime() ? ' ui-state-highlight' : '') +
  7265. (printDate.getTime() == currentDate.getTime() ? ' ui-state-active' : '') + // highlight selected day
  7266. (otherMonth ? ' ui-priority-secondary' : '') + // distinguish dates from other months
  7267. '" href="#">' + printDate.getDate() + '</a>')) + '</td>'; // display selectable date
  7268. printDate.setDate(printDate.getDate() + 1);
  7269. printDate = this._daylightSavingAdjust(printDate);
  7270. }
  7271. calender += tbody + '</tr>';
  7272. }
  7273. drawMonth++;
  7274. if (drawMonth > 11) {
  7275. drawMonth = 0;
  7276. drawYear++;
  7277. }
  7278. calender += '</tbody></table>' + (isMultiMonth ? '</div>' +
  7279. ((numMonths[0] > 0 && col == numMonths[1]-1) ? '<div class="ui-datepicker-row-break"></div>' : '') : '');
  7280. group += calender;
  7281. }
  7282. html += group;
  7283. }
  7284. html += buttonPanel + ($.browser.msie && parseInt($.browser.version,10) < 7 && !inst.inline ?
  7285. '<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>' : '');
  7286. inst._keyEvent = false;
  7287. return html;
  7288. },
  7289. /* Generate the month and year header. */
  7290. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  7291. secondary, monthNames, monthNamesShort) {
  7292. var changeMonth = this._get(inst, 'changeMonth');
  7293. var changeYear = this._get(inst, 'changeYear');
  7294. var showMonthAfterYear = this._get(inst, 'showMonthAfterYear');
  7295. var html = '<div class="ui-datepicker-title">';
  7296. var monthHtml = '';
  7297. // month selection
  7298. if (secondary || !changeMonth)
  7299. monthHtml += '<span class="ui-datepicker-month">' + monthNames[drawMonth] + '</span>';
  7300. else {
  7301. var inMinYear = (minDate && minDate.getFullYear() == drawYear);
  7302. var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear);
  7303. monthHtml += '<select class="ui-datepicker-month" ' +
  7304. 'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'M\');" ' +
  7305. '>';
  7306. for (var month = 0; month < 12; month++) {
  7307. if ((!inMinYear || month >= minDate.getMonth()) &&
  7308. (!inMaxYear || month <= maxDate.getMonth()))
  7309. monthHtml += '<option value="' + month + '"' +
  7310. (month == drawMonth ? ' selected="selected"' : '') +
  7311. '>' + monthNamesShort[month] + '</option>';
  7312. }
  7313. monthHtml += '</select>';
  7314. }
  7315. if (!showMonthAfterYear)
  7316. html += monthHtml + (secondary || !(changeMonth && changeYear) ? '&#xa0;' : '');
  7317. // year selection
  7318. if ( !inst.yearshtml ) {
  7319. inst.yearshtml = '';
  7320. if (secondary || !changeYear)
  7321. html += '<span class="ui-datepicker-year">' + drawYear + '</span>';
  7322. else {
  7323. // determine range of years to display
  7324. var years = this._get(inst, 'yearRange').split(':');
  7325. var thisYear = new Date().getFullYear();
  7326. var determineYear = function(value) {
  7327. var year = (value.match(/c[+-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  7328. (value.match(/[+-].*/) ? thisYear + parseInt(value, 10) :
  7329. parseInt(value, 10)));
  7330. return (isNaN(year) ? thisYear : year);
  7331. };
  7332. var year = determineYear(years[0]);
  7333. var endYear = Math.max(year, determineYear(years[1] || ''));
  7334. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  7335. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  7336. inst.yearshtml += '<select class="ui-datepicker-year" ' +
  7337. 'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'Y\');" ' +
  7338. '>';
  7339. for (; year <= endYear; year++) {
  7340. inst.yearshtml += '<option value="' + year + '"' +
  7341. (year == drawYear ? ' selected="selected"' : '') +
  7342. '>' + year + '</option>';
  7343. }
  7344. inst.yearshtml += '</select>';
  7345. html += inst.yearshtml;
  7346. inst.yearshtml = null;
  7347. }
  7348. }
  7349. html += this._get(inst, 'yearSuffix');
  7350. if (showMonthAfterYear)
  7351. html += (secondary || !(changeMonth && changeYear) ? '&#xa0;' : '') + monthHtml;
  7352. html += '</div>'; // Close datepicker_header
  7353. return html;
  7354. },
  7355. /* Adjust one of the date sub-fields. */
  7356. _adjustInstDate: function(inst, offset, period) {
  7357. var year = inst.drawYear + (period == 'Y' ? offset : 0);
  7358. var month = inst.drawMonth + (period == 'M' ? offset : 0);
  7359. var day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) +
  7360. (period == 'D' ? offset : 0);
  7361. var date = this._restrictMinMax(inst,
  7362. this._daylightSavingAdjust(new Date(year, month, day)));
  7363. inst.selectedDay = date.getDate();
  7364. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7365. inst.drawYear = inst.selectedYear = date.getFullYear();
  7366. if (period == 'M' || period == 'Y')
  7367. this._notifyChange(inst);
  7368. },
  7369. /* Ensure a date is within any min/max bounds. */
  7370. _restrictMinMax: function(inst, date) {
  7371. var minDate = this._getMinMaxDate(inst, 'min');
  7372. var maxDate = this._getMinMaxDate(inst, 'max');
  7373. var newDate = (minDate && date < minDate ? minDate : date);
  7374. newDate = (maxDate && newDate > maxDate ? maxDate : newDate);
  7375. return newDate;
  7376. },
  7377. /* Notify change of month/year. */
  7378. _notifyChange: function(inst) {
  7379. var onChange = this._get(inst, 'onChangeMonthYear');
  7380. if (onChange)
  7381. onChange.apply((inst.input ? inst.input[0] : null),
  7382. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  7383. },
  7384. /* Determine the number of months to show. */
  7385. _getNumberOfMonths: function(inst) {
  7386. var numMonths = this._get(inst, 'numberOfMonths');
  7387. return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths));
  7388. },
  7389. /* Determine the current maximum date - ensure no time components are set. */
  7390. _getMinMaxDate: function(inst, minMax) {
  7391. return this._determineDate(inst, this._get(inst, minMax + 'Date'), null);
  7392. },
  7393. /* Find the number of days in a given month. */
  7394. _getDaysInMonth: function(year, month) {
  7395. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  7396. },
  7397. /* Find the day of the week of the first of a month. */
  7398. _getFirstDayOfMonth: function(year, month) {
  7399. return new Date(year, month, 1).getDay();
  7400. },
  7401. /* Determines if we should allow a "next/prev" month display change. */
  7402. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  7403. var numMonths = this._getNumberOfMonths(inst);
  7404. var date = this._daylightSavingAdjust(new Date(curYear,
  7405. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  7406. if (offset < 0)
  7407. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  7408. return this._isInRange(inst, date);
  7409. },
  7410. /* Is the given date in the accepted range? */
  7411. _isInRange: function(inst, date) {
  7412. var minDate = this._getMinMaxDate(inst, 'min');
  7413. var maxDate = this._getMinMaxDate(inst, 'max');
  7414. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  7415. (!maxDate || date.getTime() <= maxDate.getTime()));
  7416. },
  7417. /* Provide the configuration settings for formatting/parsing. */
  7418. _getFormatConfig: function(inst) {
  7419. var shortYearCutoff = this._get(inst, 'shortYearCutoff');
  7420. shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
  7421. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  7422. return {shortYearCutoff: shortYearCutoff,
  7423. dayNamesShort: this._get(inst, 'dayNamesShort'), dayNames: this._get(inst, 'dayNames'),
  7424. monthNamesShort: this._get(inst, 'monthNamesShort'), monthNames: this._get(inst, 'monthNames')};
  7425. },
  7426. /* Format the given date for display. */
  7427. _formatDate: function(inst, day, month, year) {
  7428. if (!day) {
  7429. inst.currentDay = inst.selectedDay;
  7430. inst.currentMonth = inst.selectedMonth;
  7431. inst.currentYear = inst.selectedYear;
  7432. }
  7433. var date = (day ? (typeof day == 'object' ? day :
  7434. this._daylightSavingAdjust(new Date(year, month, day))) :
  7435. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  7436. return this.formatDate(this._get(inst, 'dateFormat'), date, this._getFormatConfig(inst));
  7437. }
  7438. });
  7439. /*
  7440. * Bind hover events for datepicker elements.
  7441. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  7442. * Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  7443. */
  7444. function bindHover(dpDiv) {
  7445. var selector = 'button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a';
  7446. return dpDiv.bind('mouseout', function(event) {
  7447. var elem = $( event.target ).closest( selector );
  7448. if ( !elem.length ) {
  7449. return;
  7450. }
  7451. elem.removeClass( "ui-state-hover ui-datepicker-prev-hover ui-datepicker-next-hover" );
  7452. })
  7453. .bind('mouseover', function(event) {
  7454. var elem = $( event.target ).closest( selector );
  7455. if ($.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0]) ||
  7456. !elem.length ) {
  7457. return;
  7458. }
  7459. elem.parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover');
  7460. elem.addClass('ui-state-hover');
  7461. if (elem.hasClass('ui-datepicker-prev')) elem.addClass('ui-datepicker-prev-hover');
  7462. if (elem.hasClass('ui-datepicker-next')) elem.addClass('ui-datepicker-next-hover');
  7463. });
  7464. }
  7465. /* jQuery extend now ignores nulls! */
  7466. function extendRemove(target, props) {
  7467. $.extend(target, props);
  7468. for (var name in props)
  7469. if (props[name] == null || props[name] == undefined)
  7470. target[name] = props[name];
  7471. return target;
  7472. };
  7473. /* Determine whether an object is an array. */
  7474. function isArray(a) {
  7475. return (a && (($.browser.safari && typeof a == 'object' && a.length) ||
  7476. (a.constructor && a.constructor.toString().match(/\Array\(\)/))));
  7477. };
  7478. /* Invoke the datepicker functionality.
  7479. @param options string - a command, optionally followed by additional parameters or
  7480. Object - settings for attaching new datepicker functionality
  7481. @return jQuery object */
  7482. $.fn.datepicker = function(options){
  7483. /* Verify an empty collection wasn't passed - Fixes #6976 */
  7484. if ( !this.length ) {
  7485. return this;
  7486. }
  7487. /* Initialise the date picker. */
  7488. if (!$.datepicker.initialized) {
  7489. $(document).mousedown($.datepicker._checkExternalClick).
  7490. find('body').append($.datepicker.dpDiv);
  7491. $.datepicker.initialized = true;
  7492. }
  7493. var otherArgs = Array.prototype.slice.call(arguments, 1);
  7494. if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate' || options == 'widget'))
  7495. return $.datepicker['_' + options + 'Datepicker'].
  7496. apply($.datepicker, [this[0]].concat(otherArgs));
  7497. if (options == 'option' && arguments.length == 2 && typeof arguments[1] == 'string')
  7498. return $.datepicker['_' + options + 'Datepicker'].
  7499. apply($.datepicker, [this[0]].concat(otherArgs));
  7500. return this.each(function() {
  7501. typeof options == 'string' ?
  7502. $.datepicker['_' + options + 'Datepicker'].
  7503. apply($.datepicker, [this].concat(otherArgs)) :
  7504. $.datepicker._attachDatepicker(this, options);
  7505. });
  7506. };
  7507. $.datepicker = new Datepicker(); // singleton instance
  7508. $.datepicker.initialized = false;
  7509. $.datepicker.uuid = new Date().getTime();
  7510. $.datepicker.version = "1.8.20";
  7511. // Workaround for #4055
  7512. // Add another global to avoid noConflict issues with inline event handlers
  7513. window['DP_jQuery_' + dpuuid] = $;
  7514. })(jQuery);
  7515. (function( $, undefined ) {
  7516. var uiDialogClasses =
  7517. 'ui-dialog ' +
  7518. 'ui-widget ' +
  7519. 'ui-widget-content ' +
  7520. 'ui-corner-all ',
  7521. sizeRelatedOptions = {
  7522. buttons: true,
  7523. height: true,
  7524. maxHeight: true,
  7525. maxWidth: true,
  7526. minHeight: true,
  7527. minWidth: true,
  7528. width: true
  7529. },
  7530. resizableRelatedOptions = {
  7531. maxHeight: true,
  7532. maxWidth: true,
  7533. minHeight: true,
  7534. minWidth: true
  7535. },
  7536. // support for jQuery 1.3.2 - handle common attrFn methods for dialog
  7537. attrFn = $.attrFn || {
  7538. val: true,
  7539. css: true,
  7540. html: true,
  7541. text: true,
  7542. data: true,
  7543. width: true,
  7544. height: true,
  7545. offset: true,
  7546. click: true
  7547. };
  7548. $.widget("ui.dialog", {
  7549. options: {
  7550. autoOpen: true,
  7551. buttons: {},
  7552. closeOnEscape: true,
  7553. closeText: 'close',
  7554. dialogClass: '',
  7555. draggable: true,
  7556. hide: null,
  7557. height: 'auto',
  7558. maxHeight: false,
  7559. maxWidth: false,
  7560. minHeight: 150,
  7561. minWidth: 150,
  7562. modal: false,
  7563. position: {
  7564. my: 'center',
  7565. at: 'center',
  7566. collision: 'fit',
  7567. // ensure that the titlebar is never outside the document
  7568. using: function(pos) {
  7569. var topOffset = $(this).css(pos).offset().top;
  7570. if (topOffset < 0) {
  7571. $(this).css('top', pos.top - topOffset);
  7572. }
  7573. }
  7574. },
  7575. resizable: true,
  7576. show: null,
  7577. stack: true,
  7578. title: '',
  7579. width: 300,
  7580. zIndex: 1000
  7581. },
  7582. _create: function() {
  7583. this.originalTitle = this.element.attr('title');
  7584. // #5742 - .attr() might return a DOMElement
  7585. if ( typeof this.originalTitle !== "string" ) {
  7586. this.originalTitle = "";
  7587. }
  7588. this.options.title = this.options.title || this.originalTitle;
  7589. var self = this,
  7590. options = self.options,
  7591. title = options.title || '&#160;',
  7592. titleId = $.ui.dialog.getTitleId(self.element),
  7593. uiDialog = (self.uiDialog = $('<div></div>'))
  7594. .appendTo(document.body)
  7595. .hide()
  7596. .addClass(uiDialogClasses + options.dialogClass)
  7597. .css({
  7598. zIndex: options.zIndex
  7599. })
  7600. // setting tabIndex makes the div focusable
  7601. // setting outline to 0 prevents a border on focus in Mozilla
  7602. .attr('tabIndex', -1).css('outline', 0).keydown(function(event) {
  7603. if (options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  7604. event.keyCode === $.ui.keyCode.ESCAPE) {
  7605. self.close(event);
  7606. event.preventDefault();
  7607. }
  7608. })
  7609. .attr({
  7610. role: 'dialog',
  7611. 'aria-labelledby': titleId
  7612. })
  7613. .mousedown(function(event) {
  7614. self.moveToTop(false, event);
  7615. }),
  7616. uiDialogContent = self.element
  7617. .show()
  7618. .removeAttr('title')
  7619. .addClass(
  7620. 'ui-dialog-content ' +
  7621. 'ui-widget-content')
  7622. .appendTo(uiDialog),
  7623. uiDialogTitlebar = (self.uiDialogTitlebar = $('<div></div>'))
  7624. .addClass(
  7625. 'ui-dialog-titlebar ' +
  7626. 'ui-widget-header ' +
  7627. 'ui-corner-all ' +
  7628. 'ui-helper-clearfix'
  7629. )
  7630. .prependTo(uiDialog),
  7631. uiDialogTitlebarClose = $('<a href="#"></a>')
  7632. .addClass(
  7633. 'ui-dialog-titlebar-close ' +
  7634. 'ui-corner-all'
  7635. )
  7636. .attr('role', 'button')
  7637. .hover(
  7638. function() {
  7639. uiDialogTitlebarClose.addClass('ui-state-hover');
  7640. },
  7641. function() {
  7642. uiDialogTitlebarClose.removeClass('ui-state-hover');
  7643. }
  7644. )
  7645. .focus(function() {
  7646. uiDialogTitlebarClose.addClass('ui-state-focus');
  7647. })
  7648. .blur(function() {
  7649. uiDialogTitlebarClose.removeClass('ui-state-focus');
  7650. })
  7651. .click(function(event) {
  7652. self.close(event);
  7653. return false;
  7654. })
  7655. .appendTo(uiDialogTitlebar),
  7656. uiDialogTitlebarCloseText = (self.uiDialogTitlebarCloseText = $('<span></span>'))
  7657. .addClass(
  7658. 'ui-icon ' +
  7659. 'ui-icon-closethick'
  7660. )
  7661. .text(options.closeText)
  7662. .appendTo(uiDialogTitlebarClose),
  7663. uiDialogTitle = $('<span></span>')
  7664. .addClass('ui-dialog-title')
  7665. .attr('id', titleId)
  7666. .html(title)
  7667. .prependTo(uiDialogTitlebar);
  7668. //handling of deprecated beforeclose (vs beforeClose) option
  7669. //Ticket #4669 http://dev.jqueryui.com/ticket/4669
  7670. //TODO: remove in 1.9pre
  7671. if ($.isFunction(options.beforeclose) && !$.isFunction(options.beforeClose)) {
  7672. options.beforeClose = options.beforeclose;
  7673. }
  7674. uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection();
  7675. if (options.draggable && $.fn.draggable) {
  7676. self._makeDraggable();
  7677. }
  7678. if (options.resizable && $.fn.resizable) {
  7679. self._makeResizable();
  7680. }
  7681. self._createButtons(options.buttons);
  7682. self._isOpen = false;
  7683. if ($.fn.bgiframe) {
  7684. uiDialog.bgiframe();
  7685. }
  7686. },
  7687. _init: function() {
  7688. if ( this.options.autoOpen ) {
  7689. this.open();
  7690. }
  7691. },
  7692. destroy: function() {
  7693. var self = this;
  7694. if (self.overlay) {
  7695. self.overlay.destroy();
  7696. }
  7697. self.uiDialog.hide();
  7698. self.element
  7699. .unbind('.dialog')
  7700. .removeData('dialog')
  7701. .removeClass('ui-dialog-content ui-widget-content')
  7702. .hide().appendTo('body');
  7703. self.uiDialog.remove();
  7704. if (self.originalTitle) {
  7705. self.element.attr('title', self.originalTitle);
  7706. }
  7707. return self;
  7708. },
  7709. widget: function() {
  7710. return this.uiDialog;
  7711. },
  7712. close: function(event) {
  7713. var self = this,
  7714. maxZ, thisZ;
  7715. if (false === self._trigger('beforeClose', event)) {
  7716. return;
  7717. }
  7718. if (self.overlay) {
  7719. self.overlay.destroy();
  7720. }
  7721. self.uiDialog.unbind('keypress.ui-dialog');
  7722. self._isOpen = false;
  7723. if (self.options.hide) {
  7724. self.uiDialog.hide(self.options.hide, function() {
  7725. self._trigger('close', event);
  7726. });
  7727. } else {
  7728. self.uiDialog.hide();
  7729. self._trigger('close', event);
  7730. }
  7731. $.ui.dialog.overlay.resize();
  7732. // adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
  7733. if (self.options.modal) {
  7734. maxZ = 0;
  7735. $('.ui-dialog').each(function() {
  7736. if (this !== self.uiDialog[0]) {
  7737. thisZ = $(this).css('z-index');
  7738. if(!isNaN(thisZ)) {
  7739. maxZ = Math.max(maxZ, thisZ);
  7740. }
  7741. }
  7742. });
  7743. $.ui.dialog.maxZ = maxZ;
  7744. }
  7745. return self;
  7746. },
  7747. isOpen: function() {
  7748. return this._isOpen;
  7749. },
  7750. // the force parameter allows us to move modal dialogs to their correct
  7751. // position on open
  7752. moveToTop: function(force, event) {
  7753. var self = this,
  7754. options = self.options,
  7755. saveScroll;
  7756. if ((options.modal && !force) ||
  7757. (!options.stack && !options.modal)) {
  7758. return self._trigger('focus', event);
  7759. }
  7760. if (options.zIndex > $.ui.dialog.maxZ) {
  7761. $.ui.dialog.maxZ = options.zIndex;
  7762. }
  7763. if (self.overlay) {
  7764. $.ui.dialog.maxZ += 1;
  7765. self.overlay.$el.css('z-index', $.ui.dialog.overlay.maxZ = $.ui.dialog.maxZ);
  7766. }
  7767. //Save and then restore scroll since Opera 9.5+ resets when parent z-Index is changed.
  7768. // http://ui.jquery.com/bugs/ticket/3193
  7769. saveScroll = { scrollTop: self.element.scrollTop(), scrollLeft: self.element.scrollLeft() };
  7770. $.ui.dialog.maxZ += 1;
  7771. self.uiDialog.css('z-index', $.ui.dialog.maxZ);
  7772. self.element.attr(saveScroll);
  7773. self._trigger('focus', event);
  7774. return self;
  7775. },
  7776. open: function() {
  7777. if (this._isOpen) { return; }
  7778. var self = this,
  7779. options = self.options,
  7780. uiDialog = self.uiDialog;
  7781. self.overlay = options.modal ? new $.ui.dialog.overlay(self) : null;
  7782. self._size();
  7783. self._position(options.position);
  7784. uiDialog.show(options.show);
  7785. self.moveToTop(true);
  7786. // prevent tabbing out of modal dialogs
  7787. if ( options.modal ) {
  7788. uiDialog.bind( "keydown.ui-dialog", function( event ) {
  7789. if ( event.keyCode !== $.ui.keyCode.TAB ) {
  7790. return;
  7791. }
  7792. var tabbables = $(':tabbable', this),
  7793. first = tabbables.filter(':first'),
  7794. last = tabbables.filter(':last');
  7795. if (event.target === last[0] && !event.shiftKey) {
  7796. first.focus(1);
  7797. return false;
  7798. } else if (event.target === first[0] && event.shiftKey) {
  7799. last.focus(1);
  7800. return false;
  7801. }
  7802. });
  7803. }
  7804. // set focus to the first tabbable element in the content area or the first button
  7805. // if there are no tabbable elements, set focus on the dialog itself
  7806. $(self.element.find(':tabbable').get().concat(
  7807. uiDialog.find('.ui-dialog-buttonpane :tabbable').get().concat(
  7808. uiDialog.get()))).eq(0).focus();
  7809. self._isOpen = true;
  7810. self._trigger('open');
  7811. return self;
  7812. },
  7813. _createButtons: function(buttons) {
  7814. var self = this,
  7815. hasButtons = false,
  7816. uiDialogButtonPane = $('<div></div>')
  7817. .addClass(
  7818. 'ui-dialog-buttonpane ' +
  7819. 'ui-widget-content ' +
  7820. 'ui-helper-clearfix'
  7821. ),
  7822. uiButtonSet = $( "<div></div>" )
  7823. .addClass( "ui-dialog-buttonset" )
  7824. .appendTo( uiDialogButtonPane );
  7825. // if we already have a button pane, remove it
  7826. self.uiDialog.find('.ui-dialog-buttonpane').remove();
  7827. if (typeof buttons === 'object' && buttons !== null) {
  7828. $.each(buttons, function() {
  7829. return !(hasButtons = true);
  7830. });
  7831. }
  7832. if (hasButtons) {
  7833. $.each(buttons, function(name, props) {
  7834. props = $.isFunction( props ) ?
  7835. { click: props, text: name } :
  7836. props;
  7837. var button = $('<button type="button"></button>')
  7838. .click(function() {
  7839. props.click.apply(self.element[0], arguments);
  7840. })
  7841. .appendTo(uiButtonSet);
  7842. // can't use .attr( props, true ) with jQuery 1.3.2.
  7843. $.each( props, function( key, value ) {
  7844. if ( key === "click" ) {
  7845. return;
  7846. }
  7847. if ( key in attrFn ) {
  7848. button[ key ]( value );
  7849. } else {
  7850. button.attr( key, value );
  7851. }
  7852. });
  7853. if ($.fn.button) {
  7854. button.button();
  7855. }
  7856. });
  7857. uiDialogButtonPane.appendTo(self.uiDialog);
  7858. }
  7859. },
  7860. _makeDraggable: function() {
  7861. var self = this,
  7862. options = self.options,
  7863. doc = $(document),
  7864. heightBeforeDrag;
  7865. function filteredUi(ui) {
  7866. return {
  7867. position: ui.position,
  7868. offset: ui.offset
  7869. };
  7870. }
  7871. self.uiDialog.draggable({
  7872. cancel: '.ui-dialog-content, .ui-dialog-titlebar-close',
  7873. handle: '.ui-dialog-titlebar',
  7874. containment: 'document',
  7875. start: function(event, ui) {
  7876. heightBeforeDrag = options.height === "auto" ? "auto" : $(this).height();
  7877. $(this).height($(this).height()).addClass("ui-dialog-dragging");
  7878. self._trigger('dragStart', event, filteredUi(ui));
  7879. },
  7880. drag: function(event, ui) {
  7881. self._trigger('drag', event, filteredUi(ui));
  7882. },
  7883. stop: function(event, ui) {
  7884. options.position = [ui.position.left - doc.scrollLeft(),
  7885. ui.position.top - doc.scrollTop()];
  7886. $(this).removeClass("ui-dialog-dragging").height(heightBeforeDrag);
  7887. self._trigger('dragStop', event, filteredUi(ui));
  7888. $.ui.dialog.overlay.resize();
  7889. }
  7890. });
  7891. },
  7892. _makeResizable: function(handles) {
  7893. handles = (handles === undefined ? this.options.resizable : handles);
  7894. var self = this,
  7895. options = self.options,
  7896. // .ui-resizable has position: relative defined in the stylesheet
  7897. // but dialogs have to use absolute or fixed positioning
  7898. position = self.uiDialog.css('position'),
  7899. resizeHandles = (typeof handles === 'string' ?
  7900. handles :
  7901. 'n,e,s,w,se,sw,ne,nw'
  7902. );
  7903. function filteredUi(ui) {
  7904. return {
  7905. originalPosition: ui.originalPosition,
  7906. originalSize: ui.originalSize,
  7907. position: ui.position,
  7908. size: ui.size
  7909. };
  7910. }
  7911. self.uiDialog.resizable({
  7912. cancel: '.ui-dialog-content',
  7913. containment: 'document',
  7914. alsoResize: self.element,
  7915. maxWidth: options.maxWidth,
  7916. maxHeight: options.maxHeight,
  7917. minWidth: options.minWidth,
  7918. minHeight: self._minHeight(),
  7919. handles: resizeHandles,
  7920. start: function(event, ui) {
  7921. $(this).addClass("ui-dialog-resizing");
  7922. self._trigger('resizeStart', event, filteredUi(ui));
  7923. },
  7924. resize: function(event, ui) {
  7925. self._trigger('resize', event, filteredUi(ui));
  7926. },
  7927. stop: function(event, ui) {
  7928. $(this).removeClass("ui-dialog-resizing");
  7929. options.height = $(this).height();
  7930. options.width = $(this).width();
  7931. self._trigger('resizeStop', event, filteredUi(ui));
  7932. $.ui.dialog.overlay.resize();
  7933. }
  7934. })
  7935. .css('position', position)
  7936. .find('.ui-resizable-se').addClass('ui-icon ui-icon-grip-diagonal-se');
  7937. },
  7938. _minHeight: function() {
  7939. var options = this.options;
  7940. if (options.height === 'auto') {
  7941. return options.minHeight;
  7942. } else {
  7943. return Math.min(options.minHeight, options.height);
  7944. }
  7945. },
  7946. _position: function(position) {
  7947. var myAt = [],
  7948. offset = [0, 0],
  7949. isVisible;
  7950. if (position) {
  7951. // deep extending converts arrays to objects in jQuery <= 1.3.2 :-(
  7952. // if (typeof position == 'string' || $.isArray(position)) {
  7953. // myAt = $.isArray(position) ? position : position.split(' ');
  7954. if (typeof position === 'string' || (typeof position === 'object' && '0' in position)) {
  7955. myAt = position.split ? position.split(' ') : [position[0], position[1]];
  7956. if (myAt.length === 1) {
  7957. myAt[1] = myAt[0];
  7958. }
  7959. $.each(['left', 'top'], function(i, offsetPosition) {
  7960. if (+myAt[i] === myAt[i]) {
  7961. offset[i] = myAt[i];
  7962. myAt[i] = offsetPosition;
  7963. }
  7964. });
  7965. position = {
  7966. my: myAt.join(" "),
  7967. at: myAt.join(" "),
  7968. offset: offset.join(" ")
  7969. };
  7970. }
  7971. position = $.extend({}, $.ui.dialog.prototype.options.position, position);
  7972. } else {
  7973. position = $.ui.dialog.prototype.options.position;
  7974. }
  7975. // need to show the dialog to get the actual offset in the position plugin
  7976. isVisible = this.uiDialog.is(':visible');
  7977. if (!isVisible) {
  7978. this.uiDialog.show();
  7979. }
  7980. this.uiDialog
  7981. // workaround for jQuery bug #5781 http://dev.jquery.com/ticket/5781
  7982. .css({ top: 0, left: 0 })
  7983. .position($.extend({ of: window }, position));
  7984. if (!isVisible) {
  7985. this.uiDialog.hide();
  7986. }
  7987. },
  7988. _setOptions: function( options ) {
  7989. var self = this,
  7990. resizableOptions = {},
  7991. resize = false;
  7992. $.each( options, function( key, value ) {
  7993. self._setOption( key, value );
  7994. if ( key in sizeRelatedOptions ) {
  7995. resize = true;
  7996. }
  7997. if ( key in resizableRelatedOptions ) {
  7998. resizableOptions[ key ] = value;
  7999. }
  8000. });
  8001. if ( resize ) {
  8002. this._size();
  8003. }
  8004. if ( this.uiDialog.is( ":data(resizable)" ) ) {
  8005. this.uiDialog.resizable( "option", resizableOptions );
  8006. }
  8007. },
  8008. _setOption: function(key, value){
  8009. var self = this,
  8010. uiDialog = self.uiDialog;
  8011. switch (key) {
  8012. //handling of deprecated beforeclose (vs beforeClose) option
  8013. //Ticket #4669 http://dev.jqueryui.com/ticket/4669
  8014. //TODO: remove in 1.9pre
  8015. case "beforeclose":
  8016. key = "beforeClose";
  8017. break;
  8018. case "buttons":
  8019. self._createButtons(value);
  8020. break;
  8021. case "closeText":
  8022. // ensure that we always pass a string
  8023. self.uiDialogTitlebarCloseText.text("" + value);
  8024. break;
  8025. case "dialogClass":
  8026. uiDialog
  8027. .removeClass(self.options.dialogClass)
  8028. .addClass(uiDialogClasses + value);
  8029. break;
  8030. case "disabled":
  8031. if (value) {
  8032. uiDialog.addClass('ui-dialog-disabled');
  8033. } else {
  8034. uiDialog.removeClass('ui-dialog-disabled');
  8035. }
  8036. break;
  8037. case "draggable":
  8038. var isDraggable = uiDialog.is( ":data(draggable)" );
  8039. if ( isDraggable && !value ) {
  8040. uiDialog.draggable( "destroy" );
  8041. }
  8042. if ( !isDraggable && value ) {
  8043. self._makeDraggable();
  8044. }
  8045. break;
  8046. case "position":
  8047. self._position(value);
  8048. break;
  8049. case "resizable":
  8050. // currently resizable, becoming non-resizable
  8051. var isResizable = uiDialog.is( ":data(resizable)" );
  8052. if (isResizable && !value) {
  8053. uiDialog.resizable('destroy');
  8054. }
  8055. // currently resizable, changing handles
  8056. if (isResizable && typeof value === 'string') {
  8057. uiDialog.resizable('option', 'handles', value);
  8058. }
  8059. // currently non-resizable, becoming resizable
  8060. if (!isResizable && value !== false) {
  8061. self._makeResizable(value);
  8062. }
  8063. break;
  8064. case "title":
  8065. // convert whatever was passed in o a string, for html() to not throw up
  8066. $(".ui-dialog-title", self.uiDialogTitlebar).html("" + (value || '&#160;'));
  8067. break;
  8068. }
  8069. $.Widget.prototype._setOption.apply(self, arguments);
  8070. },
  8071. _size: function() {
  8072. /* If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  8073. * divs will both have width and height set, so we need to reset them
  8074. */
  8075. var options = this.options,
  8076. nonContentHeight,
  8077. minContentHeight,
  8078. isVisible = this.uiDialog.is( ":visible" );
  8079. // reset content sizing
  8080. this.element.show().css({
  8081. width: 'auto',
  8082. minHeight: 0,
  8083. height: 0
  8084. });
  8085. if (options.minWidth > options.width) {
  8086. options.width = options.minWidth;
  8087. }
  8088. // reset wrapper sizing
  8089. // determine the height of all the non-content elements
  8090. nonContentHeight = this.uiDialog.css({
  8091. height: 'auto',
  8092. width: options.width
  8093. })
  8094. .height();
  8095. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  8096. if ( options.height === "auto" ) {
  8097. // only needed for IE6 support
  8098. if ( $.support.minHeight ) {
  8099. this.element.css({
  8100. minHeight: minContentHeight,
  8101. height: "auto"
  8102. });
  8103. } else {
  8104. this.uiDialog.show();
  8105. var autoHeight = this.element.css( "height", "auto" ).height();
  8106. if ( !isVisible ) {
  8107. this.uiDialog.hide();
  8108. }
  8109. this.element.height( Math.max( autoHeight, minContentHeight ) );
  8110. }
  8111. } else {
  8112. this.element.height( Math.max( options.height - nonContentHeight, 0 ) );
  8113. }
  8114. if (this.uiDialog.is(':data(resizable)')) {
  8115. this.uiDialog.resizable('option', 'minHeight', this._minHeight());
  8116. }
  8117. }
  8118. });
  8119. $.extend($.ui.dialog, {
  8120. version: "1.8.20",
  8121. uuid: 0,
  8122. maxZ: 0,
  8123. getTitleId: function($el) {
  8124. var id = $el.attr('id');
  8125. if (!id) {
  8126. this.uuid += 1;
  8127. id = this.uuid;
  8128. }
  8129. return 'ui-dialog-title-' + id;
  8130. },
  8131. overlay: function(dialog) {
  8132. this.$el = $.ui.dialog.overlay.create(dialog);
  8133. }
  8134. });
  8135. $.extend($.ui.dialog.overlay, {
  8136. instances: [],
  8137. // reuse old instances due to IE memory leak with alpha transparency (see #5185)
  8138. oldInstances: [],
  8139. maxZ: 0,
  8140. events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','),
  8141. function(event) { return event + '.dialog-overlay'; }).join(' '),
  8142. create: function(dialog) {
  8143. if (this.instances.length === 0) {
  8144. // prevent use of anchors and inputs
  8145. // we use a setTimeout in case the overlay is created from an
  8146. // event that we're going to be cancelling (see #2804)
  8147. setTimeout(function() {
  8148. // handle $(el).dialog().dialog('close') (see #4065)
  8149. if ($.ui.dialog.overlay.instances.length) {
  8150. $(document).bind($.ui.dialog.overlay.events, function(event) {
  8151. // stop events if the z-index of the target is < the z-index of the overlay
  8152. // we cannot return true when we don't want to cancel the event (#3523)
  8153. if ($(event.target).zIndex() < $.ui.dialog.overlay.maxZ) {
  8154. return false;
  8155. }
  8156. });
  8157. }
  8158. }, 1);
  8159. // allow closing by pressing the escape key
  8160. $(document).bind('keydown.dialog-overlay', function(event) {
  8161. if (dialog.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  8162. event.keyCode === $.ui.keyCode.ESCAPE) {
  8163. dialog.close(event);
  8164. event.preventDefault();
  8165. }
  8166. });
  8167. // handle window resize
  8168. $(window).bind('resize.dialog-overlay', $.ui.dialog.overlay.resize);
  8169. }
  8170. var $el = (this.oldInstances.pop() || $('<div></div>').addClass('ui-widget-overlay'))
  8171. .appendTo(document.body)
  8172. .css({
  8173. width: this.width(),
  8174. height: this.height()
  8175. });
  8176. if ($.fn.bgiframe) {
  8177. $el.bgiframe();
  8178. }
  8179. this.instances.push($el);
  8180. return $el;
  8181. },
  8182. destroy: function($el) {
  8183. var indexOf = $.inArray($el, this.instances);
  8184. if (indexOf != -1){
  8185. this.oldInstances.push(this.instances.splice(indexOf, 1)[0]);
  8186. }
  8187. if (this.instances.length === 0) {
  8188. $([document, window]).unbind('.dialog-overlay');
  8189. }
  8190. $el.remove();
  8191. // adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
  8192. var maxZ = 0;
  8193. $.each(this.instances, function() {
  8194. maxZ = Math.max(maxZ, this.css('z-index'));
  8195. });
  8196. this.maxZ = maxZ;
  8197. },
  8198. height: function() {
  8199. var scrollHeight,
  8200. offsetHeight;
  8201. // handle IE 6
  8202. if ($.browser.msie && $.browser.version < 7) {
  8203. scrollHeight = Math.max(
  8204. document.documentElement.scrollHeight,
  8205. document.body.scrollHeight
  8206. );
  8207. offsetHeight = Math.max(
  8208. document.documentElement.offsetHeight,
  8209. document.body.offsetHeight
  8210. );
  8211. if (scrollHeight < offsetHeight) {
  8212. return $(window).height() + 'px';
  8213. } else {
  8214. return scrollHeight + 'px';
  8215. }
  8216. // handle "good" browsers
  8217. } else {
  8218. return $(document).height() + 'px';
  8219. }
  8220. },
  8221. width: function() {
  8222. var scrollWidth,
  8223. offsetWidth;
  8224. // handle IE
  8225. if ( $.browser.msie ) {
  8226. scrollWidth = Math.max(
  8227. document.documentElement.scrollWidth,
  8228. document.body.scrollWidth
  8229. );
  8230. offsetWidth = Math.max(
  8231. document.documentElement.offsetWidth,
  8232. document.body.offsetWidth
  8233. );
  8234. if (scrollWidth < offsetWidth) {
  8235. return $(window).width() + 'px';
  8236. } else {
  8237. return scrollWidth + 'px';
  8238. }
  8239. // handle "good" browsers
  8240. } else {
  8241. return $(document).width() + 'px';
  8242. }
  8243. },
  8244. resize: function() {
  8245. /* If the dialog is draggable and the user drags it past the
  8246. * right edge of the window, the document becomes wider so we
  8247. * need to stretch the overlay. If the user then drags the
  8248. * dialog back to the left, the document will become narrower,
  8249. * so we need to shrink the overlay to the appropriate size.
  8250. * This is handled by shrinking the overlay before setting it
  8251. * to the full document size.
  8252. */
  8253. var $overlays = $([]);
  8254. $.each($.ui.dialog.overlay.instances, function() {
  8255. $overlays = $overlays.add(this);
  8256. });
  8257. $overlays.css({
  8258. width: 0,
  8259. height: 0
  8260. }).css({
  8261. width: $.ui.dialog.overlay.width(),
  8262. height: $.ui.dialog.overlay.height()
  8263. });
  8264. }
  8265. });
  8266. $.extend($.ui.dialog.overlay.prototype, {
  8267. destroy: function() {
  8268. $.ui.dialog.overlay.destroy(this.$el);
  8269. }
  8270. });
  8271. }(jQuery));
  8272. (function( $, undefined ) {
  8273. $.ui = $.ui || {};
  8274. var horizontalPositions = /left|center|right/,
  8275. verticalPositions = /top|center|bottom/,
  8276. center = "center",
  8277. support = {},
  8278. _position = $.fn.position,
  8279. _offset = $.fn.offset;
  8280. $.fn.position = function( options ) {
  8281. if ( !options || !options.of ) {
  8282. return _position.apply( this, arguments );
  8283. }
  8284. // make a copy, we don't want to modify arguments
  8285. options = $.extend( {}, options );
  8286. var target = $( options.of ),
  8287. targetElem = target[0],
  8288. collision = ( options.collision || "flip" ).split( " " ),
  8289. offset = options.offset ? options.offset.split( " " ) : [ 0, 0 ],
  8290. targetWidth,
  8291. targetHeight,
  8292. basePosition;
  8293. if ( targetElem.nodeType === 9 ) {
  8294. targetWidth = target.width();
  8295. targetHeight = target.height();
  8296. basePosition = { top: 0, left: 0 };
  8297. // TODO: use $.isWindow() in 1.9
  8298. } else if ( targetElem.setTimeout ) {
  8299. targetWidth = target.width();
  8300. targetHeight = target.height();
  8301. basePosition = { top: target.scrollTop(), left: target.scrollLeft() };
  8302. } else if ( targetElem.preventDefault ) {
  8303. // force left top to allow flipping
  8304. options.at = "left top";
  8305. targetWidth = targetHeight = 0;
  8306. basePosition = { top: options.of.pageY, left: options.of.pageX };
  8307. } else {
  8308. targetWidth = target.outerWidth();
  8309. targetHeight = target.outerHeight();
  8310. basePosition = target.offset();
  8311. }
  8312. // force my and at to have valid horizontal and veritcal positions
  8313. // if a value is missing or invalid, it will be converted to center
  8314. $.each( [ "my", "at" ], function() {
  8315. var pos = ( options[this] || "" ).split( " " );
  8316. if ( pos.length === 1) {
  8317. pos = horizontalPositions.test( pos[0] ) ?
  8318. pos.concat( [center] ) :
  8319. verticalPositions.test( pos[0] ) ?
  8320. [ center ].concat( pos ) :
  8321. [ center, center ];
  8322. }
  8323. pos[ 0 ] = horizontalPositions.test( pos[0] ) ? pos[ 0 ] : center;
  8324. pos[ 1 ] = verticalPositions.test( pos[1] ) ? pos[ 1 ] : center;
  8325. options[ this ] = pos;
  8326. });
  8327. // normalize collision option
  8328. if ( collision.length === 1 ) {
  8329. collision[ 1 ] = collision[ 0 ];
  8330. }
  8331. // normalize offset option
  8332. offset[ 0 ] = parseInt( offset[0], 10 ) || 0;
  8333. if ( offset.length === 1 ) {
  8334. offset[ 1 ] = offset[ 0 ];
  8335. }
  8336. offset[ 1 ] = parseInt( offset[1], 10 ) || 0;
  8337. if ( options.at[0] === "right" ) {
  8338. basePosition.left += targetWidth;
  8339. } else if ( options.at[0] === center ) {
  8340. basePosition.left += targetWidth / 2;
  8341. }
  8342. if ( options.at[1] === "bottom" ) {
  8343. basePosition.top += targetHeight;
  8344. } else if ( options.at[1] === center ) {
  8345. basePosition.top += targetHeight / 2;
  8346. }
  8347. basePosition.left += offset[ 0 ];
  8348. basePosition.top += offset[ 1 ];
  8349. return this.each(function() {
  8350. var elem = $( this ),
  8351. elemWidth = elem.outerWidth(),
  8352. elemHeight = elem.outerHeight(),
  8353. marginLeft = parseInt( $.curCSS( this, "marginLeft", true ) ) || 0,
  8354. marginTop = parseInt( $.curCSS( this, "marginTop", true ) ) || 0,
  8355. collisionWidth = elemWidth + marginLeft +
  8356. ( parseInt( $.curCSS( this, "marginRight", true ) ) || 0 ),
  8357. collisionHeight = elemHeight + marginTop +
  8358. ( parseInt( $.curCSS( this, "marginBottom", true ) ) || 0 ),
  8359. position = $.extend( {}, basePosition ),
  8360. collisionPosition;
  8361. if ( options.my[0] === "right" ) {
  8362. position.left -= elemWidth;
  8363. } else if ( options.my[0] === center ) {
  8364. position.left -= elemWidth / 2;
  8365. }
  8366. if ( options.my[1] === "bottom" ) {
  8367. position.top -= elemHeight;
  8368. } else if ( options.my[1] === center ) {
  8369. position.top -= elemHeight / 2;
  8370. }
  8371. // prevent fractions if jQuery version doesn't support them (see #5280)
  8372. if ( !support.fractions ) {
  8373. position.left = Math.round( position.left );
  8374. position.top = Math.round( position.top );
  8375. }
  8376. collisionPosition = {
  8377. left: position.left - marginLeft,
  8378. top: position.top - marginTop
  8379. };
  8380. $.each( [ "left", "top" ], function( i, dir ) {
  8381. if ( $.ui.position[ collision[i] ] ) {
  8382. $.ui.position[ collision[i] ][ dir ]( position, {
  8383. targetWidth: targetWidth,
  8384. targetHeight: targetHeight,
  8385. elemWidth: elemWidth,
  8386. elemHeight: elemHeight,
  8387. collisionPosition: collisionPosition,
  8388. collisionWidth: collisionWidth,
  8389. collisionHeight: collisionHeight,
  8390. offset: offset,
  8391. my: options.my,
  8392. at: options.at
  8393. });
  8394. }
  8395. });
  8396. if ( $.fn.bgiframe ) {
  8397. elem.bgiframe();
  8398. }
  8399. elem.offset( $.extend( position, { using: options.using } ) );
  8400. });
  8401. };
  8402. $.ui.position = {
  8403. fit: {
  8404. left: function( position, data ) {
  8405. var win = $( window ),
  8406. over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft();
  8407. position.left = over > 0 ? position.left - over : Math.max( position.left - data.collisionPosition.left, position.left );
  8408. },
  8409. top: function( position, data ) {
  8410. var win = $( window ),
  8411. over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop();
  8412. position.top = over > 0 ? position.top - over : Math.max( position.top - data.collisionPosition.top, position.top );
  8413. }
  8414. },
  8415. flip: {
  8416. left: function( position, data ) {
  8417. if ( data.at[0] === center ) {
  8418. return;
  8419. }
  8420. var win = $( window ),
  8421. over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft(),
  8422. myOffset = data.my[ 0 ] === "left" ?
  8423. -data.elemWidth :
  8424. data.my[ 0 ] === "right" ?
  8425. data.elemWidth :
  8426. 0,
  8427. atOffset = data.at[ 0 ] === "left" ?
  8428. data.targetWidth :
  8429. -data.targetWidth,
  8430. offset = -2 * data.offset[ 0 ];
  8431. position.left += data.collisionPosition.left < 0 ?
  8432. myOffset + atOffset + offset :
  8433. over > 0 ?
  8434. myOffset + atOffset + offset :
  8435. 0;
  8436. },
  8437. top: function( position, data ) {
  8438. if ( data.at[1] === center ) {
  8439. return;
  8440. }
  8441. var win = $( window ),
  8442. over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop(),
  8443. myOffset = data.my[ 1 ] === "top" ?
  8444. -data.elemHeight :
  8445. data.my[ 1 ] === "bottom" ?
  8446. data.elemHeight :
  8447. 0,
  8448. atOffset = data.at[ 1 ] === "top" ?
  8449. data.targetHeight :
  8450. -data.targetHeight,
  8451. offset = -2 * data.offset[ 1 ];
  8452. position.top += data.collisionPosition.top < 0 ?
  8453. myOffset + atOffset + offset :
  8454. over > 0 ?
  8455. myOffset + atOffset + offset :
  8456. 0;
  8457. }
  8458. }
  8459. };
  8460. // offset setter from jQuery 1.4
  8461. if ( !$.offset.setOffset ) {
  8462. $.offset.setOffset = function( elem, options ) {
  8463. // set position first, in-case top/left are set even on static elem
  8464. if ( /static/.test( $.curCSS( elem, "position" ) ) ) {
  8465. elem.style.position = "relative";
  8466. }
  8467. var curElem = $( elem ),
  8468. curOffset = curElem.offset(),
  8469. curTop = parseInt( $.curCSS( elem, "top", true ), 10 ) || 0,
  8470. curLeft = parseInt( $.curCSS( elem, "left", true ), 10) || 0,
  8471. props = {
  8472. top: (options.top - curOffset.top) + curTop,
  8473. left: (options.left - curOffset.left) + curLeft
  8474. };
  8475. if ( 'using' in options ) {
  8476. options.using.call( elem, props );
  8477. } else {
  8478. curElem.css( props );
  8479. }
  8480. };
  8481. $.fn.offset = function( options ) {
  8482. var elem = this[ 0 ];
  8483. if ( !elem || !elem.ownerDocument ) { return null; }
  8484. if ( options ) {
  8485. return this.each(function() {
  8486. $.offset.setOffset( this, options );
  8487. });
  8488. }
  8489. return _offset.call( this );
  8490. };
  8491. }
  8492. // fraction support test (older versions of jQuery don't support fractions)
  8493. (function () {
  8494. var body = document.getElementsByTagName( "body" )[ 0 ],
  8495. div = document.createElement( "div" ),
  8496. testElement, testElementParent, testElementStyle, offset, offsetTotal;
  8497. //Create a "fake body" for testing based on method used in jQuery.support
  8498. testElement = document.createElement( body ? "div" : "body" );
  8499. testElementStyle = {
  8500. visibility: "hidden",
  8501. width: 0,
  8502. height: 0,
  8503. border: 0,
  8504. margin: 0,
  8505. background: "none"
  8506. };
  8507. if ( body ) {
  8508. $.extend( testElementStyle, {
  8509. position: "absolute",
  8510. left: "-1000px",
  8511. top: "-1000px"
  8512. });
  8513. }
  8514. for ( var i in testElementStyle ) {
  8515. testElement.style[ i ] = testElementStyle[ i ];
  8516. }
  8517. testElement.appendChild( div );
  8518. testElementParent = body || document.documentElement;
  8519. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  8520. div.style.cssText = "position: absolute; left: 10.7432222px; top: 10.432325px; height: 30px; width: 201px;";
  8521. offset = $( div ).offset( function( _, offset ) {
  8522. return offset;
  8523. }).offset();
  8524. testElement.innerHTML = "";
  8525. testElementParent.removeChild( testElement );
  8526. offsetTotal = offset.top + offset.left + ( body ? 2000 : 0 );
  8527. support.fractions = offsetTotal > 21 && offsetTotal < 22;
  8528. })();
  8529. }( jQuery ));
  8530. (function( $, undefined ) {
  8531. $.widget( "ui.progressbar", {
  8532. options: {
  8533. value: 0,
  8534. max: 100
  8535. },
  8536. min: 0,
  8537. _create: function() {
  8538. this.element
  8539. .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  8540. .attr({
  8541. role: "progressbar",
  8542. "aria-valuemin": this.min,
  8543. "aria-valuemax": this.options.max,
  8544. "aria-valuenow": this._value()
  8545. });
  8546. this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
  8547. .appendTo( this.element );
  8548. this.oldValue = this._value();
  8549. this._refreshValue();
  8550. },
  8551. destroy: function() {
  8552. this.element
  8553. .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  8554. .removeAttr( "role" )
  8555. .removeAttr( "aria-valuemin" )
  8556. .removeAttr( "aria-valuemax" )
  8557. .removeAttr( "aria-valuenow" );
  8558. this.valueDiv.remove();
  8559. $.Widget.prototype.destroy.apply( this, arguments );
  8560. },
  8561. value: function( newValue ) {
  8562. if ( newValue === undefined ) {
  8563. return this._value();
  8564. }
  8565. this._setOption( "value", newValue );
  8566. return this;
  8567. },
  8568. _setOption: function( key, value ) {
  8569. if ( key === "value" ) {
  8570. this.options.value = value;
  8571. this._refreshValue();
  8572. if ( this._value() === this.options.max ) {
  8573. this._trigger( "complete" );
  8574. }
  8575. }
  8576. $.Widget.prototype._setOption.apply( this, arguments );
  8577. },
  8578. _value: function() {
  8579. var val = this.options.value;
  8580. // normalize invalid value
  8581. if ( typeof val !== "number" ) {
  8582. val = 0;
  8583. }
  8584. return Math.min( this.options.max, Math.max( this.min, val ) );
  8585. },
  8586. _percentage: function() {
  8587. return 100 * this._value() / this.options.max;
  8588. },
  8589. _refreshValue: function() {
  8590. var value = this.value();
  8591. var percentage = this._percentage();
  8592. if ( this.oldValue !== value ) {
  8593. this.oldValue = value;
  8594. this._trigger( "change" );
  8595. }
  8596. this.valueDiv
  8597. .toggle( value > this.min )
  8598. .toggleClass( "ui-corner-right", value === this.options.max )
  8599. .width( percentage.toFixed(0) + "%" );
  8600. this.element.attr( "aria-valuenow", value );
  8601. }
  8602. });
  8603. $.extend( $.ui.progressbar, {
  8604. version: "1.8.20"
  8605. });
  8606. })( jQuery );
  8607. (function( $, undefined ) {
  8608. // number of pages in a slider
  8609. // (how many times can you page up/down to go through the whole range)
  8610. var numPages = 5;
  8611. $.widget( "ui.slider", $.ui.mouse, {
  8612. widgetEventPrefix: "slide",
  8613. options: {
  8614. animate: false,
  8615. distance: 0,
  8616. max: 100,
  8617. min: 0,
  8618. orientation: "horizontal",
  8619. range: false,
  8620. step: 1,
  8621. value: 0,
  8622. values: null
  8623. },
  8624. _create: function() {
  8625. var self = this,
  8626. o = this.options,
  8627. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  8628. handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
  8629. handleCount = ( o.values && o.values.length ) || 1,
  8630. handles = [];
  8631. this._keySliding = false;
  8632. this._mouseSliding = false;
  8633. this._animateOff = true;
  8634. this._handleIndex = null;
  8635. this._detectOrientation();
  8636. this._mouseInit();
  8637. this.element
  8638. .addClass( "ui-slider" +
  8639. " ui-slider-" + this.orientation +
  8640. " ui-widget" +
  8641. " ui-widget-content" +
  8642. " ui-corner-all" +
  8643. ( o.disabled ? " ui-slider-disabled ui-disabled" : "" ) );
  8644. this.range = $([]);
  8645. if ( o.range ) {
  8646. if ( o.range === true ) {
  8647. if ( !o.values ) {
  8648. o.values = [ this._valueMin(), this._valueMin() ];
  8649. }
  8650. if ( o.values.length && o.values.length !== 2 ) {
  8651. o.values = [ o.values[0], o.values[0] ];
  8652. }
  8653. }
  8654. this.range = $( "<div></div>" )
  8655. .appendTo( this.element )
  8656. .addClass( "ui-slider-range" +
  8657. // note: this isn't the most fittingly semantic framework class for this element,
  8658. // but worked best visually with a variety of themes
  8659. " ui-widget-header" +
  8660. ( ( o.range === "min" || o.range === "max" ) ? " ui-slider-range-" + o.range : "" ) );
  8661. }
  8662. for ( var i = existingHandles.length; i < handleCount; i += 1 ) {
  8663. handles.push( handle );
  8664. }
  8665. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( self.element ) );
  8666. this.handle = this.handles.eq( 0 );
  8667. this.handles.add( this.range ).filter( "a" )
  8668. .click(function( event ) {
  8669. event.preventDefault();
  8670. })
  8671. .hover(function() {
  8672. if ( !o.disabled ) {
  8673. $( this ).addClass( "ui-state-hover" );
  8674. }
  8675. }, function() {
  8676. $( this ).removeClass( "ui-state-hover" );
  8677. })
  8678. .focus(function() {
  8679. if ( !o.disabled ) {
  8680. $( ".ui-slider .ui-state-focus" ).removeClass( "ui-state-focus" );
  8681. $( this ).addClass( "ui-state-focus" );
  8682. } else {
  8683. $( this ).blur();
  8684. }
  8685. })
  8686. .blur(function() {
  8687. $( this ).removeClass( "ui-state-focus" );
  8688. });
  8689. this.handles.each(function( i ) {
  8690. $( this ).data( "index.ui-slider-handle", i );
  8691. });
  8692. this.handles
  8693. .keydown(function( event ) {
  8694. var index = $( this ).data( "index.ui-slider-handle" ),
  8695. allowed,
  8696. curVal,
  8697. newVal,
  8698. step;
  8699. if ( self.options.disabled ) {
  8700. return;
  8701. }
  8702. switch ( event.keyCode ) {
  8703. case $.ui.keyCode.HOME:
  8704. case $.ui.keyCode.END:
  8705. case $.ui.keyCode.PAGE_UP:
  8706. case $.ui.keyCode.PAGE_DOWN:
  8707. case $.ui.keyCode.UP:
  8708. case $.ui.keyCode.RIGHT:
  8709. case $.ui.keyCode.DOWN:
  8710. case $.ui.keyCode.LEFT:
  8711. event.preventDefault();
  8712. if ( !self._keySliding ) {
  8713. self._keySliding = true;
  8714. $( this ).addClass( "ui-state-active" );
  8715. allowed = self._start( event, index );
  8716. if ( allowed === false ) {
  8717. return;
  8718. }
  8719. }
  8720. break;
  8721. }
  8722. step = self.options.step;
  8723. if ( self.options.values && self.options.values.length ) {
  8724. curVal = newVal = self.values( index );
  8725. } else {
  8726. curVal = newVal = self.value();
  8727. }
  8728. switch ( event.keyCode ) {
  8729. case $.ui.keyCode.HOME:
  8730. newVal = self._valueMin();
  8731. break;
  8732. case $.ui.keyCode.END:
  8733. newVal = self._valueMax();
  8734. break;
  8735. case $.ui.keyCode.PAGE_UP:
  8736. newVal = self._trimAlignValue( curVal + ( (self._valueMax() - self._valueMin()) / numPages ) );
  8737. break;
  8738. case $.ui.keyCode.PAGE_DOWN:
  8739. newVal = self._trimAlignValue( curVal - ( (self._valueMax() - self._valueMin()) / numPages ) );
  8740. break;
  8741. case $.ui.keyCode.UP:
  8742. case $.ui.keyCode.RIGHT:
  8743. if ( curVal === self._valueMax() ) {
  8744. return;
  8745. }
  8746. newVal = self._trimAlignValue( curVal + step );
  8747. break;
  8748. case $.ui.keyCode.DOWN:
  8749. case $.ui.keyCode.LEFT:
  8750. if ( curVal === self._valueMin() ) {
  8751. return;
  8752. }
  8753. newVal = self._trimAlignValue( curVal - step );
  8754. break;
  8755. }
  8756. self._slide( event, index, newVal );
  8757. })
  8758. .keyup(function( event ) {
  8759. var index = $( this ).data( "index.ui-slider-handle" );
  8760. if ( self._keySliding ) {
  8761. self._keySliding = false;
  8762. self._stop( event, index );
  8763. self._change( event, index );
  8764. $( this ).removeClass( "ui-state-active" );
  8765. }
  8766. });
  8767. this._refreshValue();
  8768. this._animateOff = false;
  8769. },
  8770. destroy: function() {
  8771. this.handles.remove();
  8772. this.range.remove();
  8773. this.element
  8774. .removeClass( "ui-slider" +
  8775. " ui-slider-horizontal" +
  8776. " ui-slider-vertical" +
  8777. " ui-slider-disabled" +
  8778. " ui-widget" +
  8779. " ui-widget-content" +
  8780. " ui-corner-all" )
  8781. .removeData( "slider" )
  8782. .unbind( ".slider" );
  8783. this._mouseDestroy();
  8784. return this;
  8785. },
  8786. _mouseCapture: function( event ) {
  8787. var o = this.options,
  8788. position,
  8789. normValue,
  8790. distance,
  8791. closestHandle,
  8792. self,
  8793. index,
  8794. allowed,
  8795. offset,
  8796. mouseOverHandle;
  8797. if ( o.disabled ) {
  8798. return false;
  8799. }
  8800. this.elementSize = {
  8801. width: this.element.outerWidth(),
  8802. height: this.element.outerHeight()
  8803. };
  8804. this.elementOffset = this.element.offset();
  8805. position = { x: event.pageX, y: event.pageY };
  8806. normValue = this._normValueFromMouse( position );
  8807. distance = this._valueMax() - this._valueMin() + 1;
  8808. self = this;
  8809. this.handles.each(function( i ) {
  8810. var thisDistance = Math.abs( normValue - self.values(i) );
  8811. if ( distance > thisDistance ) {
  8812. distance = thisDistance;
  8813. closestHandle = $( this );
  8814. index = i;
  8815. }
  8816. });
  8817. // workaround for bug #3736 (if both handles of a range are at 0,
  8818. // the first is always used as the one with least distance,
  8819. // and moving it is obviously prevented by preventing negative ranges)
  8820. if( o.range === true && this.values(1) === o.min ) {
  8821. index += 1;
  8822. closestHandle = $( this.handles[index] );
  8823. }
  8824. allowed = this._start( event, index );
  8825. if ( allowed === false ) {
  8826. return false;
  8827. }
  8828. this._mouseSliding = true;
  8829. self._handleIndex = index;
  8830. closestHandle
  8831. .addClass( "ui-state-active" )
  8832. .focus();
  8833. offset = closestHandle.offset();
  8834. mouseOverHandle = !$( event.target ).parents().andSelf().is( ".ui-slider-handle" );
  8835. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  8836. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  8837. top: event.pageY - offset.top -
  8838. ( closestHandle.height() / 2 ) -
  8839. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  8840. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  8841. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  8842. };
  8843. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  8844. this._slide( event, index, normValue );
  8845. }
  8846. this._animateOff = true;
  8847. return true;
  8848. },
  8849. _mouseStart: function( event ) {
  8850. return true;
  8851. },
  8852. _mouseDrag: function( event ) {
  8853. var position = { x: event.pageX, y: event.pageY },
  8854. normValue = this._normValueFromMouse( position );
  8855. this._slide( event, this._handleIndex, normValue );
  8856. return false;
  8857. },
  8858. _mouseStop: function( event ) {
  8859. this.handles.removeClass( "ui-state-active" );
  8860. this._mouseSliding = false;
  8861. this._stop( event, this._handleIndex );
  8862. this._change( event, this._handleIndex );
  8863. this._handleIndex = null;
  8864. this._clickOffset = null;
  8865. this._animateOff = false;
  8866. return false;
  8867. },
  8868. _detectOrientation: function() {
  8869. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  8870. },
  8871. _normValueFromMouse: function( position ) {
  8872. var pixelTotal,
  8873. pixelMouse,
  8874. percentMouse,
  8875. valueTotal,
  8876. valueMouse;
  8877. if ( this.orientation === "horizontal" ) {
  8878. pixelTotal = this.elementSize.width;
  8879. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  8880. } else {
  8881. pixelTotal = this.elementSize.height;
  8882. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  8883. }
  8884. percentMouse = ( pixelMouse / pixelTotal );
  8885. if ( percentMouse > 1 ) {
  8886. percentMouse = 1;
  8887. }
  8888. if ( percentMouse < 0 ) {
  8889. percentMouse = 0;
  8890. }
  8891. if ( this.orientation === "vertical" ) {
  8892. percentMouse = 1 - percentMouse;
  8893. }
  8894. valueTotal = this._valueMax() - this._valueMin();
  8895. valueMouse = this._valueMin() + percentMouse * valueTotal;
  8896. return this._trimAlignValue( valueMouse );
  8897. },
  8898. _start: function( event, index ) {
  8899. var uiHash = {
  8900. handle: this.handles[ index ],
  8901. value: this.value()
  8902. };
  8903. if ( this.options.values && this.options.values.length ) {
  8904. uiHash.value = this.values( index );
  8905. uiHash.values = this.values();
  8906. }
  8907. return this._trigger( "start", event, uiHash );
  8908. },
  8909. _slide: function( event, index, newVal ) {
  8910. var otherVal,
  8911. newValues,
  8912. allowed;
  8913. if ( this.options.values && this.options.values.length ) {
  8914. otherVal = this.values( index ? 0 : 1 );
  8915. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  8916. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  8917. ) {
  8918. newVal = otherVal;
  8919. }
  8920. if ( newVal !== this.values( index ) ) {
  8921. newValues = this.values();
  8922. newValues[ index ] = newVal;
  8923. // A slide can be canceled by returning false from the slide callback
  8924. allowed = this._trigger( "slide", event, {
  8925. handle: this.handles[ index ],
  8926. value: newVal,
  8927. values: newValues
  8928. } );
  8929. otherVal = this.values( index ? 0 : 1 );
  8930. if ( allowed !== false ) {
  8931. this.values( index, newVal, true );
  8932. }
  8933. }
  8934. } else {
  8935. if ( newVal !== this.value() ) {
  8936. // A slide can be canceled by returning false from the slide callback
  8937. allowed = this._trigger( "slide", event, {
  8938. handle: this.handles[ index ],
  8939. value: newVal
  8940. } );
  8941. if ( allowed !== false ) {
  8942. this.value( newVal );
  8943. }
  8944. }
  8945. }
  8946. },
  8947. _stop: function( event, index ) {
  8948. var uiHash = {
  8949. handle: this.handles[ index ],
  8950. value: this.value()
  8951. };
  8952. if ( this.options.values && this.options.values.length ) {
  8953. uiHash.value = this.values( index );
  8954. uiHash.values = this.values();
  8955. }
  8956. this._trigger( "stop", event, uiHash );
  8957. },
  8958. _change: function( event, index ) {
  8959. if ( !this._keySliding && !this._mouseSliding ) {
  8960. var uiHash = {
  8961. handle: this.handles[ index ],
  8962. value: this.value()
  8963. };
  8964. if ( this.options.values && this.options.values.length ) {
  8965. uiHash.value = this.values( index );
  8966. uiHash.values = this.values();
  8967. }
  8968. this._trigger( "change", event, uiHash );
  8969. }
  8970. },
  8971. value: function( newValue ) {
  8972. if ( arguments.length ) {
  8973. this.options.value = this._trimAlignValue( newValue );
  8974. this._refreshValue();
  8975. this._change( null, 0 );
  8976. return;
  8977. }
  8978. return this._value();
  8979. },
  8980. values: function( index, newValue ) {
  8981. var vals,
  8982. newValues,
  8983. i;
  8984. if ( arguments.length > 1 ) {
  8985. this.options.values[ index ] = this._trimAlignValue( newValue );
  8986. this._refreshValue();
  8987. this._change( null, index );
  8988. return;
  8989. }
  8990. if ( arguments.length ) {
  8991. if ( $.isArray( arguments[ 0 ] ) ) {
  8992. vals = this.options.values;
  8993. newValues = arguments[ 0 ];
  8994. for ( i = 0; i < vals.length; i += 1 ) {
  8995. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  8996. this._change( null, i );
  8997. }
  8998. this._refreshValue();
  8999. } else {
  9000. if ( this.options.values && this.options.values.length ) {
  9001. return this._values( index );
  9002. } else {
  9003. return this.value();
  9004. }
  9005. }
  9006. } else {
  9007. return this._values();
  9008. }
  9009. },
  9010. _setOption: function( key, value ) {
  9011. var i,
  9012. valsLength = 0;
  9013. if ( $.isArray( this.options.values ) ) {
  9014. valsLength = this.options.values.length;
  9015. }
  9016. $.Widget.prototype._setOption.apply( this, arguments );
  9017. switch ( key ) {
  9018. case "disabled":
  9019. if ( value ) {
  9020. this.handles.filter( ".ui-state-focus" ).blur();
  9021. this.handles.removeClass( "ui-state-hover" );
  9022. this.handles.propAttr( "disabled", true );
  9023. this.element.addClass( "ui-disabled" );
  9024. } else {
  9025. this.handles.propAttr( "disabled", false );
  9026. this.element.removeClass( "ui-disabled" );
  9027. }
  9028. break;
  9029. case "orientation":
  9030. this._detectOrientation();
  9031. this.element
  9032. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  9033. .addClass( "ui-slider-" + this.orientation );
  9034. this._refreshValue();
  9035. break;
  9036. case "value":
  9037. this._animateOff = true;
  9038. this._refreshValue();
  9039. this._change( null, 0 );
  9040. this._animateOff = false;
  9041. break;
  9042. case "values":
  9043. this._animateOff = true;
  9044. this._refreshValue();
  9045. for ( i = 0; i < valsLength; i += 1 ) {
  9046. this._change( null, i );
  9047. }
  9048. this._animateOff = false;
  9049. break;
  9050. }
  9051. },
  9052. //internal value getter
  9053. // _value() returns value trimmed by min and max, aligned by step
  9054. _value: function() {
  9055. var val = this.options.value;
  9056. val = this._trimAlignValue( val );
  9057. return val;
  9058. },
  9059. //internal values getter
  9060. // _values() returns array of values trimmed by min and max, aligned by step
  9061. // _values( index ) returns single value trimmed by min and max, aligned by step
  9062. _values: function( index ) {
  9063. var val,
  9064. vals,
  9065. i;
  9066. if ( arguments.length ) {
  9067. val = this.options.values[ index ];
  9068. val = this._trimAlignValue( val );
  9069. return val;
  9070. } else {
  9071. // .slice() creates a copy of the array
  9072. // this copy gets trimmed by min and max and then returned
  9073. vals = this.options.values.slice();
  9074. for ( i = 0; i < vals.length; i+= 1) {
  9075. vals[ i ] = this._trimAlignValue( vals[ i ] );
  9076. }
  9077. return vals;
  9078. }
  9079. },
  9080. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  9081. _trimAlignValue: function( val ) {
  9082. if ( val <= this._valueMin() ) {
  9083. return this._valueMin();
  9084. }
  9085. if ( val >= this._valueMax() ) {
  9086. return this._valueMax();
  9087. }
  9088. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  9089. valModStep = (val - this._valueMin()) % step,
  9090. alignValue = val - valModStep;
  9091. if ( Math.abs(valModStep) * 2 >= step ) {
  9092. alignValue += ( valModStep > 0 ) ? step : ( -step );
  9093. }
  9094. // Since JavaScript has problems with large floats, round
  9095. // the final value to 5 digits after the decimal point (see #4124)
  9096. return parseFloat( alignValue.toFixed(5) );
  9097. },
  9098. _valueMin: function() {
  9099. return this.options.min;
  9100. },
  9101. _valueMax: function() {
  9102. return this.options.max;
  9103. },
  9104. _refreshValue: function() {
  9105. var oRange = this.options.range,
  9106. o = this.options,
  9107. self = this,
  9108. animate = ( !this._animateOff ) ? o.animate : false,
  9109. valPercent,
  9110. _set = {},
  9111. lastValPercent,
  9112. value,
  9113. valueMin,
  9114. valueMax;
  9115. if ( this.options.values && this.options.values.length ) {
  9116. this.handles.each(function( i, j ) {
  9117. valPercent = ( self.values(i) - self._valueMin() ) / ( self._valueMax() - self._valueMin() ) * 100;
  9118. _set[ self.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  9119. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  9120. if ( self.options.range === true ) {
  9121. if ( self.orientation === "horizontal" ) {
  9122. if ( i === 0 ) {
  9123. self.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  9124. }
  9125. if ( i === 1 ) {
  9126. self.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  9127. }
  9128. } else {
  9129. if ( i === 0 ) {
  9130. self.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  9131. }
  9132. if ( i === 1 ) {
  9133. self.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  9134. }
  9135. }
  9136. }
  9137. lastValPercent = valPercent;
  9138. });
  9139. } else {
  9140. value = this.value();
  9141. valueMin = this._valueMin();
  9142. valueMax = this._valueMax();
  9143. valPercent = ( valueMax !== valueMin ) ?
  9144. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  9145. 0;
  9146. _set[ self.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  9147. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  9148. if ( oRange === "min" && this.orientation === "horizontal" ) {
  9149. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  9150. }
  9151. if ( oRange === "max" && this.orientation === "horizontal" ) {
  9152. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  9153. }
  9154. if ( oRange === "min" && this.orientation === "vertical" ) {
  9155. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  9156. }
  9157. if ( oRange === "max" && this.orientation === "vertical" ) {
  9158. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  9159. }
  9160. }
  9161. }
  9162. });
  9163. $.extend( $.ui.slider, {
  9164. version: "1.8.20"
  9165. });
  9166. }(jQuery));
  9167. (function( $, undefined ) {
  9168. var tabId = 0,
  9169. listId = 0;
  9170. function getNextTabId() {
  9171. return ++tabId;
  9172. }
  9173. function getNextListId() {
  9174. return ++listId;
  9175. }
  9176. $.widget( "ui.tabs", {
  9177. options: {
  9178. add: null,
  9179. ajaxOptions: null,
  9180. cache: false,
  9181. cookie: null, // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }
  9182. collapsible: false,
  9183. disable: null,
  9184. disabled: [],
  9185. enable: null,
  9186. event: "click",
  9187. fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 }
  9188. idPrefix: "ui-tabs-",
  9189. load: null,
  9190. panelTemplate: "<div></div>",
  9191. remove: null,
  9192. select: null,
  9193. show: null,
  9194. spinner: "<em>Loading&#8230;</em>",
  9195. tabTemplate: "<li><a href='#{href}'><span>#{label}</span></a></li>"
  9196. },
  9197. _create: function() {
  9198. this._tabify( true );
  9199. },
  9200. _setOption: function( key, value ) {
  9201. if ( key == "selected" ) {
  9202. if (this.options.collapsible && value == this.options.selected ) {
  9203. return;
  9204. }
  9205. this.select( value );
  9206. } else {
  9207. this.options[ key ] = value;
  9208. this._tabify();
  9209. }
  9210. },
  9211. _tabId: function( a ) {
  9212. return a.title && a.title.replace( /\s/g, "_" ).replace( /[^\w\u00c0-\uFFFF-]/g, "" ) ||
  9213. this.options.idPrefix + getNextTabId();
  9214. },
  9215. _sanitizeSelector: function( hash ) {
  9216. // we need this because an id may contain a ":"
  9217. return hash.replace( /:/g, "\\:" );
  9218. },
  9219. _cookie: function() {
  9220. var cookie = this.cookie ||
  9221. ( this.cookie = this.options.cookie.name || "ui-tabs-" + getNextListId() );
  9222. return $.cookie.apply( null, [ cookie ].concat( $.makeArray( arguments ) ) );
  9223. },
  9224. _ui: function( tab, panel ) {
  9225. return {
  9226. tab: tab,
  9227. panel: panel,
  9228. index: this.anchors.index( tab )
  9229. };
  9230. },
  9231. _cleanup: function() {
  9232. // restore all former loading tabs labels
  9233. this.lis.filter( ".ui-state-processing" )
  9234. .removeClass( "ui-state-processing" )
  9235. .find( "span:data(label.tabs)" )
  9236. .each(function() {
  9237. var el = $( this );
  9238. el.html( el.data( "label.tabs" ) ).removeData( "label.tabs" );
  9239. });
  9240. },
  9241. _tabify: function( init ) {
  9242. var self = this,
  9243. o = this.options,
  9244. fragmentId = /^#.+/; // Safari 2 reports '#' for an empty hash
  9245. this.list = this.element.find( "ol,ul" ).eq( 0 );
  9246. this.lis = $( " > li:has(a[href])", this.list );
  9247. this.anchors = this.lis.map(function() {
  9248. return $( "a", this )[ 0 ];
  9249. });
  9250. this.panels = $( [] );
  9251. this.anchors.each(function( i, a ) {
  9252. var href = $( a ).attr( "href" );
  9253. // For dynamically created HTML that contains a hash as href IE < 8 expands
  9254. // such href to the full page url with hash and then misinterprets tab as ajax.
  9255. // Same consideration applies for an added tab with a fragment identifier
  9256. // since a[href=#fragment-identifier] does unexpectedly not match.
  9257. // Thus normalize href attribute...
  9258. var hrefBase = href.split( "#" )[ 0 ],
  9259. baseEl;
  9260. if ( hrefBase && ( hrefBase === location.toString().split( "#" )[ 0 ] ||
  9261. ( baseEl = $( "base" )[ 0 ]) && hrefBase === baseEl.href ) ) {
  9262. href = a.hash;
  9263. a.href = href;
  9264. }
  9265. // inline tab
  9266. if ( fragmentId.test( href ) ) {
  9267. self.panels = self.panels.add( self.element.find( self._sanitizeSelector( href ) ) );
  9268. // remote tab
  9269. // prevent loading the page itself if href is just "#"
  9270. } else if ( href && href !== "#" ) {
  9271. // required for restore on destroy
  9272. $.data( a, "href.tabs", href );
  9273. // TODO until #3808 is fixed strip fragment identifier from url
  9274. // (IE fails to load from such url)
  9275. $.data( a, "load.tabs", href.replace( /#.*$/, "" ) );
  9276. var id = self._tabId( a );
  9277. a.href = "#" + id;
  9278. var $panel = self.element.find( "#" + id );
  9279. if ( !$panel.length ) {
  9280. $panel = $( o.panelTemplate )
  9281. .attr( "id", id )
  9282. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  9283. .insertAfter( self.panels[ i - 1 ] || self.list );
  9284. $panel.data( "destroy.tabs", true );
  9285. }
  9286. self.panels = self.panels.add( $panel );
  9287. // invalid tab href
  9288. } else {
  9289. o.disabled.push( i );
  9290. }
  9291. });
  9292. // initialization from scratch
  9293. if ( init ) {
  9294. // attach necessary classes for styling
  9295. this.element.addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" );
  9296. this.list.addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" );
  9297. this.lis.addClass( "ui-state-default ui-corner-top" );
  9298. this.panels.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" );
  9299. // Selected tab
  9300. // use "selected" option or try to retrieve:
  9301. // 1. from fragment identifier in url
  9302. // 2. from cookie
  9303. // 3. from selected class attribute on <li>
  9304. if ( o.selected === undefined ) {
  9305. if ( location.hash ) {
  9306. this.anchors.each(function( i, a ) {
  9307. if ( a.hash == location.hash ) {
  9308. o.selected = i;
  9309. return false;
  9310. }
  9311. });
  9312. }
  9313. if ( typeof o.selected !== "number" && o.cookie ) {
  9314. o.selected = parseInt( self._cookie(), 10 );
  9315. }
  9316. if ( typeof o.selected !== "number" && this.lis.filter( ".ui-tabs-selected" ).length ) {
  9317. o.selected = this.lis.index( this.lis.filter( ".ui-tabs-selected" ) );
  9318. }
  9319. o.selected = o.selected || ( this.lis.length ? 0 : -1 );
  9320. } else if ( o.selected === null ) { // usage of null is deprecated, TODO remove in next release
  9321. o.selected = -1;
  9322. }
  9323. // sanity check - default to first tab...
  9324. o.selected = ( ( o.selected >= 0 && this.anchors[ o.selected ] ) || o.selected < 0 )
  9325. ? o.selected
  9326. : 0;
  9327. // Take disabling tabs via class attribute from HTML
  9328. // into account and update option properly.
  9329. // A selected tab cannot become disabled.
  9330. o.disabled = $.unique( o.disabled.concat(
  9331. $.map( this.lis.filter( ".ui-state-disabled" ), function( n, i ) {
  9332. return self.lis.index( n );
  9333. })
  9334. ) ).sort();
  9335. if ( $.inArray( o.selected, o.disabled ) != -1 ) {
  9336. o.disabled.splice( $.inArray( o.selected, o.disabled ), 1 );
  9337. }
  9338. // highlight selected tab
  9339. this.panels.addClass( "ui-tabs-hide" );
  9340. this.lis.removeClass( "ui-tabs-selected ui-state-active" );
  9341. // check for length avoids error when initializing empty list
  9342. if ( o.selected >= 0 && this.anchors.length ) {
  9343. self.element.find( self._sanitizeSelector( self.anchors[ o.selected ].hash ) ).removeClass( "ui-tabs-hide" );
  9344. this.lis.eq( o.selected ).addClass( "ui-tabs-selected ui-state-active" );
  9345. // seems to be expected behavior that the show callback is fired
  9346. self.element.queue( "tabs", function() {
  9347. self._trigger( "show", null,
  9348. self._ui( self.anchors[ o.selected ], self.element.find( self._sanitizeSelector( self.anchors[ o.selected ].hash ) )[ 0 ] ) );
  9349. });
  9350. this.load( o.selected );
  9351. }
  9352. // clean up to avoid memory leaks in certain versions of IE 6
  9353. // TODO: namespace this event
  9354. $( window ).bind( "unload", function() {
  9355. self.lis.add( self.anchors ).unbind( ".tabs" );
  9356. self.lis = self.anchors = self.panels = null;
  9357. });
  9358. // update selected after add/remove
  9359. } else {
  9360. o.selected = this.lis.index( this.lis.filter( ".ui-tabs-selected" ) );
  9361. }
  9362. // update collapsible
  9363. // TODO: use .toggleClass()
  9364. this.element[ o.collapsible ? "addClass" : "removeClass" ]( "ui-tabs-collapsible" );
  9365. // set or update cookie after init and add/remove respectively
  9366. if ( o.cookie ) {
  9367. this._cookie( o.selected, o.cookie );
  9368. }
  9369. // disable tabs
  9370. for ( var i = 0, li; ( li = this.lis[ i ] ); i++ ) {
  9371. $( li )[ $.inArray( i, o.disabled ) != -1 &&
  9372. // TODO: use .toggleClass()
  9373. !$( li ).hasClass( "ui-tabs-selected" ) ? "addClass" : "removeClass" ]( "ui-state-disabled" );
  9374. }
  9375. // reset cache if switching from cached to not cached
  9376. if ( o.cache === false ) {
  9377. this.anchors.removeData( "cache.tabs" );
  9378. }
  9379. // remove all handlers before, tabify may run on existing tabs after add or option change
  9380. this.lis.add( this.anchors ).unbind( ".tabs" );
  9381. if ( o.event !== "mouseover" ) {
  9382. var addState = function( state, el ) {
  9383. if ( el.is( ":not(.ui-state-disabled)" ) ) {
  9384. el.addClass( "ui-state-" + state );
  9385. }
  9386. };
  9387. var removeState = function( state, el ) {
  9388. el.removeClass( "ui-state-" + state );
  9389. };
  9390. this.lis.bind( "mouseover.tabs" , function() {
  9391. addState( "hover", $( this ) );
  9392. });
  9393. this.lis.bind( "mouseout.tabs", function() {
  9394. removeState( "hover", $( this ) );
  9395. });
  9396. this.anchors.bind( "focus.tabs", function() {
  9397. addState( "focus", $( this ).closest( "li" ) );
  9398. });
  9399. this.anchors.bind( "blur.tabs", function() {
  9400. removeState( "focus", $( this ).closest( "li" ) );
  9401. });
  9402. }
  9403. // set up animations
  9404. var hideFx, showFx;
  9405. if ( o.fx ) {
  9406. if ( $.isArray( o.fx ) ) {
  9407. hideFx = o.fx[ 0 ];
  9408. showFx = o.fx[ 1 ];
  9409. } else {
  9410. hideFx = showFx = o.fx;
  9411. }
  9412. }
  9413. // Reset certain styles left over from animation
  9414. // and prevent IE's ClearType bug...
  9415. function resetStyle( $el, fx ) {
  9416. $el.css( "display", "" );
  9417. if ( !$.support.opacity && fx.opacity ) {
  9418. $el[ 0 ].style.removeAttribute( "filter" );
  9419. }
  9420. }
  9421. // Show a tab...
  9422. var showTab = showFx
  9423. ? function( clicked, $show ) {
  9424. $( clicked ).closest( "li" ).addClass( "ui-tabs-selected ui-state-active" );
  9425. $show.hide().removeClass( "ui-tabs-hide" ) // avoid flicker that way
  9426. .animate( showFx, showFx.duration || "normal", function() {
  9427. resetStyle( $show, showFx );
  9428. self._trigger( "show", null, self._ui( clicked, $show[ 0 ] ) );
  9429. });
  9430. }
  9431. : function( clicked, $show ) {
  9432. $( clicked ).closest( "li" ).addClass( "ui-tabs-selected ui-state-active" );
  9433. $show.removeClass( "ui-tabs-hide" );
  9434. self._trigger( "show", null, self._ui( clicked, $show[ 0 ] ) );
  9435. };
  9436. // Hide a tab, $show is optional...
  9437. var hideTab = hideFx
  9438. ? function( clicked, $hide ) {
  9439. $hide.animate( hideFx, hideFx.duration || "normal", function() {
  9440. self.lis.removeClass( "ui-tabs-selected ui-state-active" );
  9441. $hide.addClass( "ui-tabs-hide" );
  9442. resetStyle( $hide, hideFx );
  9443. self.element.dequeue( "tabs" );
  9444. });
  9445. }
  9446. : function( clicked, $hide, $show ) {
  9447. self.lis.removeClass( "ui-tabs-selected ui-state-active" );
  9448. $hide.addClass( "ui-tabs-hide" );
  9449. self.element.dequeue( "tabs" );
  9450. };
  9451. // attach tab event handler, unbind to avoid duplicates from former tabifying...
  9452. this.anchors.bind( o.event + ".tabs", function() {
  9453. var el = this,
  9454. $li = $(el).closest( "li" ),
  9455. $hide = self.panels.filter( ":not(.ui-tabs-hide)" ),
  9456. $show = self.element.find( self._sanitizeSelector( el.hash ) );
  9457. // If tab is already selected and not collapsible or tab disabled or
  9458. // or is already loading or click callback returns false stop here.
  9459. // Check if click handler returns false last so that it is not executed
  9460. // for a disabled or loading tab!
  9461. if ( ( $li.hasClass( "ui-tabs-selected" ) && !o.collapsible) ||
  9462. $li.hasClass( "ui-state-disabled" ) ||
  9463. $li.hasClass( "ui-state-processing" ) ||
  9464. self.panels.filter( ":animated" ).length ||
  9465. self._trigger( "select", null, self._ui( this, $show[ 0 ] ) ) === false ) {
  9466. this.blur();
  9467. return false;
  9468. }
  9469. o.selected = self.anchors.index( this );
  9470. self.abort();
  9471. // if tab may be closed
  9472. if ( o.collapsible ) {
  9473. if ( $li.hasClass( "ui-tabs-selected" ) ) {
  9474. o.selected = -1;
  9475. if ( o.cookie ) {
  9476. self._cookie( o.selected, o.cookie );
  9477. }
  9478. self.element.queue( "tabs", function() {
  9479. hideTab( el, $hide );
  9480. }).dequeue( "tabs" );
  9481. this.blur();
  9482. return false;
  9483. } else if ( !$hide.length ) {
  9484. if ( o.cookie ) {
  9485. self._cookie( o.selected, o.cookie );
  9486. }
  9487. self.element.queue( "tabs", function() {
  9488. showTab( el, $show );
  9489. });
  9490. // TODO make passing in node possible, see also http://dev.jqueryui.com/ticket/3171
  9491. self.load( self.anchors.index( this ) );
  9492. this.blur();
  9493. return false;
  9494. }
  9495. }
  9496. if ( o.cookie ) {
  9497. self._cookie( o.selected, o.cookie );
  9498. }
  9499. // show new tab
  9500. if ( $show.length ) {
  9501. if ( $hide.length ) {
  9502. self.element.queue( "tabs", function() {
  9503. hideTab( el, $hide );
  9504. });
  9505. }
  9506. self.element.queue( "tabs", function() {
  9507. showTab( el, $show );
  9508. });
  9509. self.load( self.anchors.index( this ) );
  9510. } else {
  9511. throw "jQuery UI Tabs: Mismatching fragment identifier.";
  9512. }
  9513. // Prevent IE from keeping other link focussed when using the back button
  9514. // and remove dotted border from clicked link. This is controlled via CSS
  9515. // in modern browsers; blur() removes focus from address bar in Firefox
  9516. // which can become a usability and annoying problem with tabs('rotate').
  9517. if ( $.browser.msie ) {
  9518. this.blur();
  9519. }
  9520. });
  9521. // disable click in any case
  9522. this.anchors.bind( "click.tabs", function(){
  9523. return false;
  9524. });
  9525. },
  9526. _getIndex: function( index ) {
  9527. // meta-function to give users option to provide a href string instead of a numerical index.
  9528. // also sanitizes numerical indexes to valid values.
  9529. if ( typeof index == "string" ) {
  9530. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  9531. }
  9532. return index;
  9533. },
  9534. destroy: function() {
  9535. var o = this.options;
  9536. this.abort();
  9537. this.element
  9538. .unbind( ".tabs" )
  9539. .removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" )
  9540. .removeData( "tabs" );
  9541. this.list.removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" );
  9542. this.anchors.each(function() {
  9543. var href = $.data( this, "href.tabs" );
  9544. if ( href ) {
  9545. this.href = href;
  9546. }
  9547. var $this = $( this ).unbind( ".tabs" );
  9548. $.each( [ "href", "load", "cache" ], function( i, prefix ) {
  9549. $this.removeData( prefix + ".tabs" );
  9550. });
  9551. });
  9552. this.lis.unbind( ".tabs" ).add( this.panels ).each(function() {
  9553. if ( $.data( this, "destroy.tabs" ) ) {
  9554. $( this ).remove();
  9555. } else {
  9556. $( this ).removeClass([
  9557. "ui-state-default",
  9558. "ui-corner-top",
  9559. "ui-tabs-selected",
  9560. "ui-state-active",
  9561. "ui-state-hover",
  9562. "ui-state-focus",
  9563. "ui-state-disabled",
  9564. "ui-tabs-panel",
  9565. "ui-widget-content",
  9566. "ui-corner-bottom",
  9567. "ui-tabs-hide"
  9568. ].join( " " ) );
  9569. }
  9570. });
  9571. if ( o.cookie ) {
  9572. this._cookie( null, o.cookie );
  9573. }
  9574. return this;
  9575. },
  9576. add: function( url, label, index ) {
  9577. if ( index === undefined ) {
  9578. index = this.anchors.length;
  9579. }
  9580. var self = this,
  9581. o = this.options,
  9582. $li = $( o.tabTemplate.replace( /#\{href\}/g, url ).replace( /#\{label\}/g, label ) ),
  9583. id = !url.indexOf( "#" ) ? url.replace( "#", "" ) : this._tabId( $( "a", $li )[ 0 ] );
  9584. $li.addClass( "ui-state-default ui-corner-top" ).data( "destroy.tabs", true );
  9585. // try to find an existing element before creating a new one
  9586. var $panel = self.element.find( "#" + id );
  9587. if ( !$panel.length ) {
  9588. $panel = $( o.panelTemplate )
  9589. .attr( "id", id )
  9590. .data( "destroy.tabs", true );
  9591. }
  9592. $panel.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" );
  9593. if ( index >= this.lis.length ) {
  9594. $li.appendTo( this.list );
  9595. $panel.appendTo( this.list[ 0 ].parentNode );
  9596. } else {
  9597. $li.insertBefore( this.lis[ index ] );
  9598. $panel.insertBefore( this.panels[ index ] );
  9599. }
  9600. o.disabled = $.map( o.disabled, function( n, i ) {
  9601. return n >= index ? ++n : n;
  9602. });
  9603. this._tabify();
  9604. if ( this.anchors.length == 1 ) {
  9605. o.selected = 0;
  9606. $li.addClass( "ui-tabs-selected ui-state-active" );
  9607. $panel.removeClass( "ui-tabs-hide" );
  9608. this.element.queue( "tabs", function() {
  9609. self._trigger( "show", null, self._ui( self.anchors[ 0 ], self.panels[ 0 ] ) );
  9610. });
  9611. this.load( 0 );
  9612. }
  9613. this._trigger( "add", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
  9614. return this;
  9615. },
  9616. remove: function( index ) {
  9617. index = this._getIndex( index );
  9618. var o = this.options,
  9619. $li = this.lis.eq( index ).remove(),
  9620. $panel = this.panels.eq( index ).remove();
  9621. // If selected tab was removed focus tab to the right or
  9622. // in case the last tab was removed the tab to the left.
  9623. if ( $li.hasClass( "ui-tabs-selected" ) && this.anchors.length > 1) {
  9624. this.select( index + ( index + 1 < this.anchors.length ? 1 : -1 ) );
  9625. }
  9626. o.disabled = $.map(
  9627. $.grep( o.disabled, function(n, i) {
  9628. return n != index;
  9629. }),
  9630. function( n, i ) {
  9631. return n >= index ? --n : n;
  9632. });
  9633. this._tabify();
  9634. this._trigger( "remove", null, this._ui( $li.find( "a" )[ 0 ], $panel[ 0 ] ) );
  9635. return this;
  9636. },
  9637. enable: function( index ) {
  9638. index = this._getIndex( index );
  9639. var o = this.options;
  9640. if ( $.inArray( index, o.disabled ) == -1 ) {
  9641. return;
  9642. }
  9643. this.lis.eq( index ).removeClass( "ui-state-disabled" );
  9644. o.disabled = $.grep( o.disabled, function( n, i ) {
  9645. return n != index;
  9646. });
  9647. this._trigger( "enable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
  9648. return this;
  9649. },
  9650. disable: function( index ) {
  9651. index = this._getIndex( index );
  9652. var self = this, o = this.options;
  9653. // cannot disable already selected tab
  9654. if ( index != o.selected ) {
  9655. this.lis.eq( index ).addClass( "ui-state-disabled" );
  9656. o.disabled.push( index );
  9657. o.disabled.sort();
  9658. this._trigger( "disable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
  9659. }
  9660. return this;
  9661. },
  9662. select: function( index ) {
  9663. index = this._getIndex( index );
  9664. if ( index == -1 ) {
  9665. if ( this.options.collapsible && this.options.selected != -1 ) {
  9666. index = this.options.selected;
  9667. } else {
  9668. return this;
  9669. }
  9670. }
  9671. this.anchors.eq( index ).trigger( this.options.event + ".tabs" );
  9672. return this;
  9673. },
  9674. load: function( index ) {
  9675. index = this._getIndex( index );
  9676. var self = this,
  9677. o = this.options,
  9678. a = this.anchors.eq( index )[ 0 ],
  9679. url = $.data( a, "load.tabs" );
  9680. this.abort();
  9681. // not remote or from cache
  9682. if ( !url || this.element.queue( "tabs" ).length !== 0 && $.data( a, "cache.tabs" ) ) {
  9683. this.element.dequeue( "tabs" );
  9684. return;
  9685. }
  9686. // load remote from here on
  9687. this.lis.eq( index ).addClass( "ui-state-processing" );
  9688. if ( o.spinner ) {
  9689. var span = $( "span", a );
  9690. span.data( "label.tabs", span.html() ).html( o.spinner );
  9691. }
  9692. this.xhr = $.ajax( $.extend( {}, o.ajaxOptions, {
  9693. url: url,
  9694. success: function( r, s ) {
  9695. self.element.find( self._sanitizeSelector( a.hash ) ).html( r );
  9696. // take care of tab labels
  9697. self._cleanup();
  9698. if ( o.cache ) {
  9699. $.data( a, "cache.tabs", true );
  9700. }
  9701. self._trigger( "load", null, self._ui( self.anchors[ index ], self.panels[ index ] ) );
  9702. try {
  9703. o.ajaxOptions.success( r, s );
  9704. }
  9705. catch ( e ) {}
  9706. },
  9707. error: function( xhr, s, e ) {
  9708. // take care of tab labels
  9709. self._cleanup();
  9710. self._trigger( "load", null, self._ui( self.anchors[ index ], self.panels[ index ] ) );
  9711. try {
  9712. // Passing index avoid a race condition when this method is
  9713. // called after the user has selected another tab.
  9714. // Pass the anchor that initiated this request allows
  9715. // loadError to manipulate the tab content panel via $(a.hash)
  9716. o.ajaxOptions.error( xhr, s, index, a );
  9717. }
  9718. catch ( e ) {}
  9719. }
  9720. } ) );
  9721. // last, so that load event is fired before show...
  9722. self.element.dequeue( "tabs" );
  9723. return this;
  9724. },
  9725. abort: function() {
  9726. // stop possibly running animations
  9727. this.element.queue( [] );
  9728. this.panels.stop( false, true );
  9729. // "tabs" queue must not contain more than two elements,
  9730. // which are the callbacks for the latest clicked tab...
  9731. this.element.queue( "tabs", this.element.queue( "tabs" ).splice( -2, 2 ) );
  9732. // terminate pending requests from other tabs
  9733. if ( this.xhr ) {
  9734. this.xhr.abort();
  9735. delete this.xhr;
  9736. }
  9737. // take care of tab labels
  9738. this._cleanup();
  9739. return this;
  9740. },
  9741. url: function( index, url ) {
  9742. this.anchors.eq( index ).removeData( "cache.tabs" ).data( "load.tabs", url );
  9743. return this;
  9744. },
  9745. length: function() {
  9746. return this.anchors.length;
  9747. }
  9748. });
  9749. $.extend( $.ui.tabs, {
  9750. version: "1.8.20"
  9751. });
  9752. /*
  9753. * Tabs Extensions
  9754. */
  9755. /*
  9756. * Rotate
  9757. */
  9758. $.extend( $.ui.tabs.prototype, {
  9759. rotation: null,
  9760. rotate: function( ms, continuing ) {
  9761. var self = this,
  9762. o = this.options;
  9763. var rotate = self._rotate || ( self._rotate = function( e ) {
  9764. clearTimeout( self.rotation );
  9765. self.rotation = setTimeout(function() {
  9766. var t = o.selected;
  9767. self.select( ++t < self.anchors.length ? t : 0 );
  9768. }, ms );
  9769. if ( e ) {
  9770. e.stopPropagation();
  9771. }
  9772. });
  9773. var stop = self._unrotate || ( self._unrotate = !continuing
  9774. ? function(e) {
  9775. if (e.clientX) { // in case of a true click
  9776. self.rotate(null);
  9777. }
  9778. }
  9779. : function( e ) {
  9780. rotate();
  9781. });
  9782. // start rotation
  9783. if ( ms ) {
  9784. this.element.bind( "tabsshow", rotate );
  9785. this.anchors.bind( o.event + ".tabs", stop );
  9786. rotate();
  9787. // stop rotation
  9788. } else {
  9789. clearTimeout( self.rotation );
  9790. this.element.unbind( "tabsshow", rotate );
  9791. this.anchors.unbind( o.event + ".tabs", stop );
  9792. delete this._rotate;
  9793. delete this._unrotate;
  9794. }
  9795. return this;
  9796. }
  9797. });
  9798. })( jQuery );